"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 lodash_1 = require("lodash");
exports.fields = {
    to: {
        label: 'To',
        id: 'to',
        type: extensions_core_1.FieldType.STRING,
        required: true,
        description: 'The email address to which you intend to send the email',
    },
    subject: {
        label: 'Subject',
        id: 'subject',
        type: extensions_core_1.FieldType.STRING,
        required: false,
        description: 'When provided, it overwrites the subject specified in the Broadcast template',
    },
    templateId: {
        label: 'Template ID',
        id: 'templateId',
        type: extensions_core_1.FieldType.NUMERIC,
        required: true,
        description: 'The ID of the template used for generating email content',
    },
    placeholders: {
        label: 'Placeholders',
        id: 'placeholders',
        type: extensions_core_1.FieldType.JSON,
        required: true,
        description: 'The values for the placeholders defined in your template. Must be a valid key-value pair JSON object.',
    },
};
exports.FieldsValidationSchema = zod_1.z.object({
    to: zod_1.z.string().email(),
    subject: (0, extensions_core_1.makeStringOptional)(zod_1.z.string()),
    templateId: zod_1.z.number(),
    placeholders: zod_1.z
        .optional(zod_1.z.string())
        .transform((str, ctx) => {
        if ((0, lodash_1.isNil)(str) || (0, lodash_1.isEmpty)(str))
            return {};
        try {
            return JSON.parse(str);
        }
        catch (e) {
            ctx.addIssue({ code: 'custom', message: 'Invalid JSON' });
            return zod_1.z.NEVER;
        }
    }),
});
//# sourceMappingURL=fields.js.map