"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const zod_1 = require("zod");
const field_1 = require("../../../../types/field");
const filter_1 = require("../../../../types/filter");
const fieldId_1 = require("../fieldId");
const filterDescriptionUtils_1 = require("./filterDescriptionUtils");
const commonNumberFilterRuleSchema = zod_1.z.object({
    fieldId: (0, fieldId_1.getFieldIdSchema)({ additionalDescription: null }),
    fieldType: zod_1.z.union([
        zod_1.z.literal(field_1.DimensionType.NUMBER),
        zod_1.z.literal(field_1.MetricType.NUMBER),
        zod_1.z.literal(field_1.MetricType.PERCENTILE),
        zod_1.z.literal(field_1.MetricType.MEDIAN),
        zod_1.z.literal(field_1.MetricType.AVERAGE),
        zod_1.z.literal(field_1.MetricType.COUNT),
        zod_1.z.literal(field_1.MetricType.COUNT_DISTINCT),
        zod_1.z.literal(field_1.MetricType.SUM),
        zod_1.z.literal(field_1.MetricType.SUM_DISTINCT),
        zod_1.z.literal(field_1.MetricType.AVERAGE_DISTINCT),
        zod_1.z.literal(field_1.MetricType.MIN),
        zod_1.z.literal(field_1.MetricType.MAX),
    ]),
    fieldFilterType: zod_1.z.literal(filter_1.FilterType.NUMBER),
});
const numberFilterSchema = zod_1.z.union([
    commonNumberFilterRuleSchema
        .extend({
        operator: zod_1.z
            .union([
            zod_1.z.literal(filter_1.FilterOperator.NULL),
            zod_1.z.literal(filter_1.FilterOperator.NOT_NULL),
        ])
            .describe(filterDescriptionUtils_1.valuePresenceOperatorDescription),
    })
        .describe(`Use for numeric fields when checking if a value is missing or present. Do not include values. ${(0, filterDescriptionUtils_1.filterJsonExamples)({
        fieldId: 'orders_total_revenue',
        fieldType: field_1.MetricType.SUM,
        fieldFilterType: filter_1.FilterType.NUMBER,
        operator: filter_1.FilterOperator.NULL,
    }, {
        fieldId: 'orders_total_revenue',
        fieldType: field_1.MetricType.SUM,
        fieldFilterType: filter_1.FilterType.NUMBER,
        operator: filter_1.FilterOperator.NOT_NULL,
    })}`),
    commonNumberFilterRuleSchema
        .extend({
        operator: zod_1.z
            .union([
            zod_1.z.literal(filter_1.FilterOperator.EQUALS),
            zod_1.z.literal(filter_1.FilterOperator.NOT_EQUALS),
        ])
            .describe(`Use ${(0, filterDescriptionUtils_1.filterOperatorList)(filter_1.FilterOperator.EQUALS, filter_1.FilterOperator.NOT_EQUALS)} for exact numeric matches.`),
        values: zod_1.z
            .array(zod_1.z.number())
            .describe('One or more exact numeric values to match.'),
    })
        .describe(`Use for numeric fields that equal or exclude specific values. ${(0, filterDescriptionUtils_1.filterJsonExamples)({
        fieldId: 'orders_item_count',
        fieldType: field_1.MetricType.COUNT,
        fieldFilterType: filter_1.FilterType.NUMBER,
        operator: filter_1.FilterOperator.EQUALS,
        values: [1, 2],
    }, {
        fieldId: 'orders_discount_percent',
        fieldType: field_1.DimensionType.NUMBER,
        fieldFilterType: filter_1.FilterType.NUMBER,
        operator: filter_1.FilterOperator.NOT_EQUALS,
        values: [0],
    })}`),
    commonNumberFilterRuleSchema
        .extend({
        operator: zod_1.z
            .union([
            zod_1.z.literal(filter_1.FilterOperator.LESS_THAN),
            zod_1.z.literal(filter_1.FilterOperator.LESS_THAN_OR_EQUAL),
            zod_1.z.literal(filter_1.FilterOperator.GREATER_THAN),
            zod_1.z.literal(filter_1.FilterOperator.GREATER_THAN_OR_EQUAL),
        ])
            .describe('Use for threshold comparisons such as greater than 100.'),
        values: zod_1.z
            .array(zod_1.z.number())
            .length(1)
            .describe('Exactly one numeric threshold value.'),
    })
        .describe(`Use for numeric fields with a single comparison threshold. ${(0, filterDescriptionUtils_1.filterJsonExamples)({
        fieldId: 'orders_total_revenue',
        fieldType: field_1.MetricType.SUM,
        fieldFilterType: filter_1.FilterType.NUMBER,
        operator: filter_1.FilterOperator.GREATER_THAN,
        values: [1000],
    }, {
        fieldId: 'orders_discount_percent',
        fieldType: field_1.DimensionType.NUMBER,
        fieldFilterType: filter_1.FilterType.NUMBER,
        operator: filter_1.FilterOperator.LESS_THAN_OR_EQUAL,
        values: [0.15],
    })}`),
    commonNumberFilterRuleSchema
        .extend({
        operator: zod_1.z
            .union([
            zod_1.z.literal(filter_1.FilterOperator.IN_BETWEEN),
            zod_1.z.literal(filter_1.FilterOperator.NOT_IN_BETWEEN),
        ])
            .describe('Use for ranges between two numeric bounds.'),
        values: zod_1.z
            .array(zod_1.z.number())
            .length(2)
            .describe('Exactly two numeric bounds: [lower, upper].'),
    })
        .describe(`Use for numeric fields inside or outside a two-value range. ${(0, filterDescriptionUtils_1.filterJsonExamples)({
        fieldId: 'orders_total_revenue',
        fieldType: field_1.MetricType.SUM,
        fieldFilterType: filter_1.FilterType.NUMBER,
        operator: filter_1.FilterOperator.IN_BETWEEN,
        values: [100, 500],
    }, {
        fieldId: 'orders_margin_percent',
        fieldType: field_1.DimensionType.NUMBER,
        fieldFilterType: filter_1.FilterType.NUMBER,
        operator: filter_1.FilterOperator.NOT_IN_BETWEEN,
        values: [0.2, 0.4],
    })}`),
]);
exports.default = numberFilterSchema;
//# sourceMappingURL=numberFilters.js.map