"use strict";
//----------------------------------------------------------------------------------------
Object.defineProperty(exports, "__esModule", { value: true });
exports.minioDeleteFileSchema = exports.minioPdfSchema = exports.minioMediaSchema = exports.minioDocumentSchema = exports.minioImageSchema = exports.pdfSchema = exports.mediaSchema = exports.documentSchema = exports.imageSchema = void 0;
const zod_1 = require("zod");
const consts_1 = require("../../utils/consts");
//----------------------------------------------------------------------------------------
exports.imageSchema = zod_1.z
    .any()
    .refine((file) => !!file, {
    message: "L'image est obligatoire",
})
    .refine((file) => {
    return (file === null || file === void 0 ? void 0 : file.file.bytesRead) <= consts_1.MAX_FILE_SIZE;
}, {
    message: "La taille de l'image est supérieure à 50 Mo.",
})
    .refine((file) => consts_1.ACCEPTED_IMAGE_TYPES.includes(file.mimetype), {
    message: "Seuls les formats .jpg, .jpeg, .png et .webp sont acceptés",
});
exports.documentSchema = zod_1.z
    .any()
    .refine((file) => !!file, {
    message: "Le document est obligatoire",
})
    .refine((file) => {
    return (file === null || file === void 0 ? void 0 : file.file.bytesRead) <= consts_1.MAX_FILE_SIZE;
}, {
    message: "La taille du document est supérieure à 50 Mo.",
})
    .refine((file) => consts_1.ACCEPTED_DOCS_TYPES.includes(file.mimetype), {
    message: "Le format est inacceptable",
});
exports.mediaSchema = zod_1.z
    .any()
    .refine((file) => !!file, {
    message: "Le document est obligatoire",
})
    .refine((file) => {
    return (file === null || file === void 0 ? void 0 : file.file.bytesRead) <= consts_1.MAX_FILE_SIZE;
}, {
    message: "La taille du document est supérieure à 50 Mo.",
})
    .refine((file) => consts_1.ACCEPTED_MEDIA_TYPES.includes(file.mimetype), {
    message: "Le format est inacceptable",
});
exports.pdfSchema = zod_1.z
    .any()
    .refine((file) => !!file, {
    message: "Le document est obligatoire",
})
    .refine((file) => {
    return (file === null || file === void 0 ? void 0 : file.file.bytesRead) <= consts_1.MAX_FILE_SIZE;
}, {
    message: "La taille du document est supérieure à 50 Mo.",
})
    .refine((file) => file.mimetype === "application/pdf", {
    message: "Le format est inacceptable",
});
//--------------------------------------------------------------------------------------
exports.minioImageSchema = zod_1.z.object({
    image: exports.imageSchema,
});
//--------------------------------------------------------------------------------------
exports.minioDocumentSchema = zod_1.z.object({
    document: exports.documentSchema,
});
//--------------------------------------------------------------------------------------
exports.minioMediaSchema = zod_1.z.object({
    document: exports.mediaSchema,
});
//--------------------------------------------------------------------------------------
exports.minioPdfSchema = zod_1.z.object({
    document: exports.pdfSchema,
});
//--------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------
exports.minioDeleteFileSchema = zod_1.z.object({
    path: zod_1.z.string({ required_error: "Le fichier est obligatoirs" }),
});
//--------------------------------------------------------------------------------------
