"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AthenaDateOnlyOptionalSchema = exports.AthenaDateOnlySchema = void 0;
const extensions_core_1 = require("@awell-health/extensions-core");
const date_fns_1 = require("date-fns");
const zod_1 = require("zod");
/**
 * Athena dates are in MM/DD/YYYY
 * We transform it to ISO date format
 */
exports.AthenaDateOnlySchema = 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: 'Not able to parse athena date',
        });
        return zod_1.z.NEVER;
    }
    return (0, date_fns_1.formatISO)(date, { representation: 'date' });
});
exports.AthenaDateOnlyOptionalSchema = (0, extensions_core_1.makeStringOptional)(exports.AthenaDateOnlySchema);
//# sourceMappingURL=date.js.map