"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FieldsSchema = exports.dataPoints = exports.fields = void 0;
const extensions_core_1 = require("@awell-health/extensions-core");
const lodash_1 = require("lodash");
const zod_1 = require("zod");
exports.fields = {
    campaignId: {
        id: 'campaignId',
        label: 'Campaign ID',
        type: extensions_core_1.FieldType.STRING,
        required: true,
        description: 'The ID of the campaign to send the email with attributes to.',
    },
    sendId: {
        id: 'sendId',
        label: 'Send ID',
        type: extensions_core_1.FieldType.STRING,
        required: false,
        description: 'Send identifier (optional)',
    },
    externalUserId: {
        id: 'externalUserId',
        label: 'External User ID',
        type: extensions_core_1.FieldType.STRING,
        required: false,
        description: 'The ID of the user in your system that this message is being sent to. Either external_user_id or email must be provided.',
    },
    email: {
        id: 'email',
        label: 'Email',
        type: extensions_core_1.FieldType.STRING,
        required: false,
        description: 'The email address of the user to send the email to. Either External User ID or Email must be provided.',
    },
    triggerProperties: {
        id: 'triggerProperties',
        label: 'Trigger Properties',
        type: extensions_core_1.FieldType.JSON,
        required: false,
        description: 'Key-value pairs that can be referenced in your message template to personalize it and insert dynamic content.',
    },
    attributes: {
        id: 'attributes',
        label: 'Attributes',
        type: extensions_core_1.FieldType.JSON,
        required: false,
        description: 'Create or update user-specific profile attribute. Attributes can trigger campaigns, can be used for segmentation, and personalization of messages.',
    },
};
exports.dataPoints = {
    EmailDispatchId: {
        key: 'EmailDispatchId',
        valueType: 'string',
    },
};
exports.FieldsSchema = zod_1.z.object({
    campaignId: zod_1.z.string().min(1),
    sendId: zod_1.z.string().optional(),
    externalUserId: zod_1.z.string().optional(),
    email: zod_1.z.string().optional(),
    triggerProperties: zod_1.z
        .string()
        .optional()
        .transform((str, ctx) => {
        if ((0, lodash_1.isNil)(str) || (0, lodash_1.isEmpty)(str))
            return undefined;
        try {
            const parsedJson = JSON.parse(str);
            return parsedJson;
        }
        catch (e) {
            ctx.addIssue({
                code: 'custom',
                message: 'triggerProperties is not a valid JSON object',
            });
            return zod_1.z.NEVER;
        }
    }),
    attributes: zod_1.z
        .string()
        .optional()
        .transform((str, ctx) => {
        if ((0, lodash_1.isNil)(str) || (0, lodash_1.isEmpty)(str))
            return undefined;
        try {
            const parsedJson = JSON.parse(str);
            return parsedJson;
        }
        catch (e) {
            ctx.addIssue({
                code: 'custom',
                message: 'attributes is not a valid JSON object',
            });
            return zod_1.z.NEVER;
        }
    }),
});
//# sourceMappingURL=config.js.map