import { SupportedDbtAdapter } from '../types/dbt';
import { CustomDimensionType, DimensionType, FieldType, } from '../types/field';
import { FilterOperator, } from '../types/filter';
import { OrderFieldsByStrategy } from '../types/table';
export const chartAndFilterGroup = {
    id: 'fillter-group-1',
    and: [
        {
            id: '1',
            target: { fieldId: 'field-1' },
            values: ['1'],
            disabled: false,
            operator: FilterOperator.EQUALS,
        },
        {
            id: '2',
            target: { fieldId: 'field-2' },
            values: ['2'],
            disabled: false,
            operator: FilterOperator.EQUALS,
        },
    ],
};
export const chartOrFilterGroup = {
    id: 'fillter-group-1',
    or: [
        {
            id: '3',
            target: { fieldId: 'field-1' },
            values: ['1'],
            disabled: false,
            operator: FilterOperator.EQUALS,
        },
        {
            id: '4',
            target: { fieldId: 'field-2' },
            values: ['2'],
            disabled: false,
            operator: FilterOperator.EQUALS,
        },
    ],
};
export const dashboardFilterWithSameTargetAndOperator = [
    {
        id: '5',
        target: { fieldId: 'field-1' },
        values: ['1', '2', '3'],
        disabled: false,
        operator: FilterOperator.EQUALS,
    },
];
export const dashboardFilterWithSameTargetButDifferentOperator = [
    {
        id: '5',
        target: { fieldId: 'field-1' },
        values: ['1', '2', '3'],
        disabled: false,
        operator: FilterOperator.NOT_EQUALS,
    },
];
export const metricQueryWithAndFilters = {
    exploreName: 'test',
    limit: 501,
    dimensions: ['a_dim1'],
    metrics: [],
    sorts: [],
    tableCalculations: [],
    filters: {
        dimensions: {
            id: 'root',
            and: [
                {
                    id: '1',
                    target: {
                        fieldId: 'a_dim1',
                    },
                    operator: FilterOperator.EQUALS,
                    values: [0],
                },
            ],
        },
    },
};
export const metricQueryWithOrFilters = {
    exploreName: 'test',
    limit: 501,
    dimensions: ['a_dim1'],
    metrics: [],
    sorts: [],
    tableCalculations: [],
    filters: {
        dimensions: {
            id: 'root',
            or: [
                {
                    id: '1',
                    target: {
                        fieldId: 'a_dim1',
                    },
                    operator: FilterOperator.EQUALS,
                    values: [0],
                },
            ],
        },
    },
};
export const dashboardFilters = {
    dimensions: [
        {
            id: '4',
            label: undefined,
            target: {
                fieldId: 'a_dim1',
                tableName: 'test',
            },
            operator: FilterOperator.EQUALS,
            values: ['1', '2', '3'],
        },
    ],
    metrics: [],
    tableCalculations: [],
};
export const dashboardFiltersWithMetrics = {
    dimensions: [
        {
            id: '4',
            label: undefined,
            target: {
                fieldId: 'a_dim1',
                tableName: 'test',
            },
            operator: FilterOperator.EQUALS,
            values: ['1', '2', '3'],
        },
    ],
    metrics: [
        {
            id: 'm1',
            label: undefined,
            target: {
                fieldId: 'a_metric1',
                tableName: 'test',
            },
            operator: FilterOperator.GREATER_THAN,
            values: [100],
        },
    ],
    tableCalculations: [],
};
export const metricQueryWithExistingMetricFilters = {
    exploreName: 'test',
    limit: 501,
    dimensions: ['a_dim1'],
    metrics: ['a_metric1'],
    sorts: [],
    tableCalculations: [],
    filters: {
        dimensions: {
            id: 'root',
            and: [
                {
                    id: '1',
                    target: {
                        fieldId: 'a_dim1',
                    },
                    operator: FilterOperator.EQUALS,
                    values: [0],
                },
            ],
        },
        metrics: {
            id: 'metric-root',
            and: [
                {
                    id: 'existing-metric-filter',
                    target: {
                        fieldId: 'a_metric1',
                    },
                    operator: FilterOperator.LESS_THAN,
                    values: [1000],
                },
            ],
        },
    },
};
export const emptyDashboardFilters = {
    dimensions: [],
    metrics: [],
    tableCalculations: [],
};
export const expectedChartWithOverrideDashboardFilters = {
    exploreName: 'test',
    dimensions: ['a_dim1'],
    limit: 501,
    metrics: [],
    sorts: [],
    tableCalculations: [],
    filters: {
        dimensions: {
            and: [
                {
                    id: '4',
                    target: {
                        fieldId: 'a_dim1',
                    },
                    operator: FilterOperator.EQUALS,
                    values: ['1', '2', '3'],
                },
            ],
            id: 'uuid',
        },
        metrics: {
            and: [],
            id: 'uuid',
        },
        tableCalculations: {
            and: [],
            id: 'uuid',
        },
    },
};
export const expectedChartWithOverrideDashboardORFilters = {
    exploreName: 'test',
    dimensions: ['a_dim1'],
    limit: 501,
    metrics: [],
    sorts: [],
    tableCalculations: [],
    filters: {
        dimensions: {
            and: [
                {
                    id: 'root',
                    or: [
                        {
                            id: '4',
                            target: {
                                fieldId: 'a_dim1',
                            },
                            operator: FilterOperator.EQUALS,
                            values: ['1', '2', '3'],
                        },
                    ],
                },
            ],
            id: 'uuid',
        },
        metrics: {
            and: [],
            id: 'uuid',
        },
        tableCalculations: {
            and: [],
            id: 'uuid',
        },
    },
};
export const customSqlDimension = {
    id: 'custom-sql-dimension',
    name: 'Custom SQL Dimension',
    table: 'custom_sql',
    type: CustomDimensionType.SQL,
    sql: '${table.field}',
    dimensionType: DimensionType.STRING,
};
export const expectedFiltersWithCustomSqlDimension = {
    dimensions: {
        and: [
            {
                id: 'uuid',
                operator: FilterOperator.EQUALS,
                target: {
                    fieldId: 'custom-sql-dimension',
                },
                values: [],
            },
        ],
        id: 'uuid',
    },
};
export const expectedRequiredResult = (fieldIdRef, tableName) => ({
    id: 'uuid',
    target: {
        fieldId: `${tableName}_${fieldIdRef}`,
    },
    operator: FilterOperator.IN_THE_NEXT,
    values: [14],
    settings: {
        unitOfTime: 'years',
    },
    required: true,
});
export const dimension = (dimensionName, tableName) => ({
    fieldType: FieldType.DIMENSION,
    type: DimensionType.STRING,
    name: dimensionName,
    isIntervalBase: false,
    timeInterval: undefined,
    label: 'mockLabel',
    table: tableName,
    tableLabel: 'mockTableLabel',
    sql: 'mockSql',
    hidden: false,
});
export const filterRule = {
    id: 'mockId',
    target: {
        fieldId: 'mockFieldId',
    },
    operator: FilterOperator.IN_THE_NEXT,
    values: ['mockValue1', 'mockValue2'],
};
export const modelRequiredFilterRule = (inputFieldRef) => ({
    id: 'uuid',
    operator: FilterOperator.IN_THE_NEXT,
    settings: {
        unitOfTime: 'years',
    },
    target: {
        fieldRef: inputFieldRef,
    },
    values: [14],
});
export const joinedModelRequiredFilterRule = (inputFieldRef, tableName) => {
    const requiredFilterRule = modelRequiredFilterRule(inputFieldRef);
    return {
        ...requiredFilterRule,
        target: {
            ...requiredFilterRule.target,
            tableName,
        },
    };
};
export const baseTable = {
    name: 'table',
    label: 'My table',
    database: 'database',
    schema: 'schema',
    sqlTable: '',
    description: '',
    sqlWhere: undefined,
    requiredAttributes: undefined,
    dimensions: {},
    metrics: {},
    orderFieldsBy: OrderFieldsByStrategy.LABEL,
    requiredFilters: [],
    groupLabel: undefined,
    groupDetails: {},
};
export const expectedRequiredResetResult = {
    id: 'uuidGroup',
    and: [
        {
            id: 'uuid',
            target: {
                fieldId: 'table_mockFieldRef1',
            },
            operator: FilterOperator.IN_THE_NEXT,
            values: [14],
            required: true,
            settings: {
                unitOfTime: 'years',
            },
        },
        {
            id: 'uuid',
            target: {
                fieldId: 'table_mockFieldRef2',
            },
            operator: FilterOperator.IN_THE_NEXT,
            values: [14],
            required: false,
            settings: {
                unitOfTime: 'years',
            },
        },
    ],
};
export const mockExplore = {
    name: 'test',
    label: 'Test',
    tags: [],
    baseTable: 'orders',
    targetDatabase: SupportedDbtAdapter.POSTGRES,
    joinedTables: [],
    tables: {
        orders: {
            name: 'orders',
            label: 'Orders',
            database: 'test',
            schema: 'public',
            sqlTable: 'orders',
            metrics: {},
            lineageGraph: {},
            dimensions: {
                // Interval base dimensions have isIntervalBase set and no
                // timeIntervalBaseDimensionName (see convertDimension in translator.ts)
                order_date: {
                    name: 'order_date',
                    label: 'Order Date',
                    table: 'orders',
                    tableLabel: 'Orders',
                    compiledSql: 'order_date',
                    tablesReferences: [],
                    sql: 'order_date',
                    hidden: false,
                    fieldType: FieldType.DIMENSION,
                    type: DimensionType.DATE,
                    isIntervalBase: true,
                },
                order_date_year: {
                    name: 'order_date_year',
                    label: 'Order Date Year',
                    table: 'orders',
                    tableLabel: 'Orders',
                    compiledSql: 'order_date_year',
                    tablesReferences: [],
                    sql: 'order_date_year',
                    hidden: false,
                    fieldType: FieldType.DIMENSION,
                    type: DimensionType.DATE,
                    timeIntervalBaseDimensionName: 'order_date',
                },
                order_date_month: {
                    name: 'order_date_month',
                    label: 'Order Date Month',
                    table: 'orders',
                    tableLabel: 'Orders',
                    compiledSql: 'order_date_month',
                    tablesReferences: [],
                    sql: 'order_date_month',
                    hidden: false,
                    fieldType: FieldType.DIMENSION,
                    type: DimensionType.DATE,
                    timeIntervalBaseDimensionName: 'order_date',
                },
                order_date_week: {
                    name: 'order_date_week',
                    label: 'Order Date Week',
                    table: 'orders',
                    tableLabel: 'Orders',
                    compiledSql: 'order_date_week',
                    sql: 'order_date_week',
                    hidden: false,
                    tablesReferences: [],
                    fieldType: FieldType.DIMENSION,
                    type: DimensionType.DATE,
                    timeIntervalBaseDimensionName: 'order_date',
                },
                status: {
                    name: 'status',
                    label: 'Status',
                    table: 'orders',
                    tableLabel: 'Orders',
                    compiledSql: 'status',
                    sql: 'status',
                    hidden: false,
                    tablesReferences: [],
                    fieldType: FieldType.DIMENSION,
                    type: DimensionType.BOOLEAN,
                },
            },
        },
    },
};
export const mockExploreWithJoinedTable = {
    ...mockExplore,
    tables: {
        orders: {
            ...mockExplore.tables.orders,
            dimensions: {
                ...mockExplore.tables.orders.dimensions,
                customer_id: {
                    name: 'customer_id',
                    label: 'Customer ID',
                    table: 'orders',
                    tableLabel: 'Orders',
                    compiledSql: 'customer_id',
                    sql: 'customer_id',
                    hidden: false,
                    fieldType: FieldType.DIMENSION,
                    type: DimensionType.NUMBER,
                    tablesReferences: [],
                },
            },
        },
        customers: {
            name: 'customers',
            label: 'Customers',
            database: 'test',
            schema: 'public',
            sqlTable: 'customers',
            metrics: {},
            lineageGraph: {},
            dimensions: {
                id: {
                    name: 'id',
                    label: 'ID',
                    table: 'customers',
                    tableLabel: 'Customers',
                    compiledSql: 'id',
                    tablesReferences: [],
                    fieldType: FieldType.DIMENSION,
                    type: DimensionType.STRING,
                    sql: 'id',
                    hidden: false,
                },
                created_at_week: {
                    name: 'created_at_week',
                    label: 'Created At Week',
                    table: 'customers',
                    tableLabel: 'Customers',
                    compiledSql: 'created_at_week',
                    sql: 'created_at_week',
                    hidden: false,
                    tablesReferences: [],
                    fieldType: FieldType.DIMENSION,
                    type: DimensionType.DATE,
                    timeIntervalBaseDimensionName: 'created_at',
                },
            },
        },
    },
    joinedTables: [
        {
            table: 'customers',
            sqlOn: '${orders.customer_id} = ${customers.id}',
            compiledSqlOn: '(orders.customer_id) = (customers.id)',
            type: undefined,
        },
    ],
};
//# sourceMappingURL=filters.mock.js.map