"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 commonStringFilterRuleSchema = zod_1.z.object({
    fieldId: (0, fieldId_1.getFieldIdSchema)({ additionalDescription: null }),
    fieldType: zod_1.z.union([
        zod_1.z.literal(field_1.DimensionType.STRING),
        zod_1.z.literal(field_1.MetricType.STRING),
    ]),
    fieldFilterType: zod_1.z.literal(filter_1.FilterType.STRING),
});
const stringFilterSchema = zod_1.z.union([
    commonStringFilterRuleSchema
        .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 string fields when checking if a value is missing or present. Do not include values. ${(0, filterDescriptionUtils_1.filterJsonExamples)({
        fieldId: 'orders_status',
        fieldType: field_1.DimensionType.STRING,
        fieldFilterType: filter_1.FilterType.STRING,
        operator: filter_1.FilterOperator.NULL,
    }, {
        fieldId: 'orders_status',
        fieldType: field_1.DimensionType.STRING,
        fieldFilterType: filter_1.FilterType.STRING,
        operator: filter_1.FilterOperator.NOT_NULL,
    })}`),
    commonStringFilterRuleSchema
        .extend({
        operator: zod_1.z
            .union([
            zod_1.z.literal(filter_1.FilterOperator.EQUALS),
            zod_1.z.literal(filter_1.FilterOperator.NOT_EQUALS),
            zod_1.z.literal(filter_1.FilterOperator.STARTS_WITH),
            zod_1.z.literal(filter_1.FilterOperator.ENDS_WITH),
            zod_1.z.literal(filter_1.FilterOperator.INCLUDE),
            zod_1.z.literal(filter_1.FilterOperator.NOT_INCLUDE),
        ])
            .describe(`${(0, filterDescriptionUtils_1.filterOperatorList)(filter_1.FilterOperator.EQUALS, filter_1.FilterOperator.NOT_EQUALS)} for exact matches; ${(0, filterDescriptionUtils_1.filterOperatorList)(filter_1.FilterOperator.INCLUDE, filter_1.FilterOperator.NOT_INCLUDE)} for contains; ${(0, filterDescriptionUtils_1.filterOperatorList)(filter_1.FilterOperator.STARTS_WITH, filter_1.FilterOperator.ENDS_WITH)} for prefixes/suffixes.`),
        values: zod_1.z
            .array(zod_1.z.string())
            .describe('String values to match. Do not put natural-language date ranges here.'),
    })
        .describe(`Use for text matching on string fields. For dates like "last 2 weeks", use a date filter instead. ${(0, filterDescriptionUtils_1.filterJsonExamples)({
        fieldId: 'orders_status',
        fieldType: field_1.DimensionType.STRING,
        fieldFilterType: filter_1.FilterType.STRING,
        operator: filter_1.FilterOperator.EQUALS,
        values: ['complete', 'paid'],
    }, {
        fieldId: 'customers_email',
        fieldType: field_1.DimensionType.STRING,
        fieldFilterType: filter_1.FilterType.STRING,
        operator: filter_1.FilterOperator.INCLUDE,
        values: ['@lightdash.com'],
    }, {
        fieldId: 'products_sku',
        fieldType: field_1.DimensionType.STRING,
        fieldFilterType: filter_1.FilterType.STRING,
        operator: filter_1.FilterOperator.STARTS_WITH,
        values: ['SKU-'],
    }, {
        fieldId: 'orders_status',
        fieldType: field_1.DimensionType.STRING,
        fieldFilterType: filter_1.FilterType.STRING,
        operator: filter_1.FilterOperator.NOT_EQUALS,
        values: ['cancelled'],
    })}`),
]);
exports.default = stringFilterSchema;
//# sourceMappingURL=stringFilters.js.map