"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FieldsValidationSchema = exports.fields = void 0;
const extensions_core_1 = require("@awell-health/extensions-core");
const zod_1 = __importDefault(require("zod"));
exports.fields = {
    sObjectId: {
        id: 'sObjectId',
        label: 'Lead ID',
        description: 'The object ID of the Lead in Salesforce to update',
        type: extensions_core_1.FieldType.STRING,
        required: true,
    },
    data: {
        id: 'data',
        label: 'Data',
        description: 'Information used to update the Lead',
        type: extensions_core_1.FieldType.JSON,
        required: true,
    },
};
exports.FieldsValidationSchema = zod_1.default.object({
    sObjectId: zod_1.default.string().min(1),
    data: zod_1.default
        .string()
        .transform((str) => {
        try {
            return JSON.parse(str);
        }
        catch (e) {
            throw new Error('Invalid JSON string');
        }
    })
        .refine((obj) => typeof obj === 'object' && obj !== null && !Array.isArray(obj), {
        message: 'Parsed value is not an object',
    })
        .refine((obj) => {
        return Object.keys(obj).every((key) => typeof key === 'string');
    }, {
        message: 'All keys must be strings',
    })
        .refine((obj) => {
        return Object.values(obj).every((value) => typeof value !== 'undefined');
    }, {
        message: 'All values must be defined',
    })
        .pipe(zod_1.default.record(zod_1.default.unknown())),
});
//# sourceMappingURL=fields.js.map