"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AwellToAthenaDateOnlyOptionalSchema = exports.AwellToAthenaDateOnlySchema = void 0;
const extensions_core_1 = require("@awell-health/extensions-core");
const date_fns_1 = require("date-fns");
const zod_1 = require("zod");
/**
 * Athena expects dates MM/dd/yyyy
 */
exports.AwellToAthenaDateOnlySchema = zod_1.z.string().transform((arg, ctx) => {
    const date = new Date(arg);
    if (!(0, date_fns_1.isValid)(date)) {
        ctx.addIssue({
            code: zod_1.z.ZodIssueCode.invalid_date,
            message: 'No valid date',
        });
        return zod_1.z.NEVER;
    }
    return (0, date_fns_1.format)(date, 'MM/dd/yyyy');
});
exports.AwellToAthenaDateOnlyOptionalSchema = (0, extensions_core_1.makeStringOptional)(exports.AwellToAthenaDateOnlySchema);
//# sourceMappingURL=date.js.map