"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FieldsValidationSchema = exports.fields = void 0;
const zod_1 = require("zod");
const extensions_core_1 = require("@awell-health/extensions-core");
const extensions_core_2 = require("@awell-health/extensions-core");
const lodash_1 = require("lodash");
exports.fields = {
    from: {
        label: '"From" number',
        id: 'from',
        type: extensions_core_2.FieldType.STRING,
        stringType: extensions_core_2.StringType.PHONE,
        required: false,
        description: 'Search for text messages sent from a specific phone number'
    },
    recipient: {
        id: 'recipient',
        label: '"To" number',
        type: extensions_core_2.FieldType.STRING,
        stringType: extensions_core_2.StringType.PHONE,
        description: 'Search for text messages sent to a specific phone number',
        required: false,
    },
    page_size: {
        id: 'page_size',
        label: 'Page Size',
        description: 'The number of results per page. Minimum is 1 and maximum is 1000.',
        type: extensions_core_2.FieldType.NUMERIC,
        required: false,
    },
    date_sent_after: {
        id: 'date_sent_after',
        label: 'Sent date after than',
        description: 'Search for messages sent after a given date',
        type: extensions_core_2.FieldType.DATE,
        required: false,
    },
    date_sent_before: {
        id: 'date_sent_before',
        label: 'Sent date before than',
        description: 'Search for messages sent before a given date',
        type: extensions_core_2.FieldType.DATE,
        required: false,
    },
    date_sent: {
        id: 'date_sent',
        label: 'Sent date',
        description: 'Search for messages sent on a given date',
        type: extensions_core_2.FieldType.DATE,
        required: false,
    },
};
const toDate = (arg) => !(0, lodash_1.isNil)(arg) ? new Date(arg) : undefined;
exports.FieldsValidationSchema = zod_1.z.object({
    recipient: extensions_core_1.E164PhoneValidationOptionalSchema,
    from: extensions_core_1.E164PhoneValidationOptionalSchema,
    page_size: zod_1.z
        .number()
        .min(1, { message: 'Page size must be at least one' })
        .max(1000, { message: 'Cannot fetch more than 1000 messages' })
        .default(50),
    date_sent: extensions_core_1.DateOnlyOptionalSchema.transform(toDate),
    date_sent_after: extensions_core_1.DateOnlyOptionalSchema.transform(toDate),
    date_sent_before: extensions_core_1.DateOnlyOptionalSchema.transform(toDate),
});
//# sourceMappingURL=fields.js.map