"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FieldsValidationSchema = 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 = {
    botId: {
        id: 'botId',
        label: 'Bot ID',
        description: 'You can find the id of your Bot by clicking on the Details tab of the Bot resource in the Medplum app',
        type: extensions_core_1.FieldType.STRING,
        required: true,
    },
    body: {
        id: 'body',
        label: 'Body',
        description: 'Data in JSON format you would like to pass to the Bot',
        type: extensions_core_1.FieldType.JSON,
        required: false,
    },
};
exports.FieldsValidationSchema = zod_1.z.object({
    botId: zod_1.z.string().nonempty({
        message: 'Missing "Bot ID"',
    }),
    body: zod_1.z
        .optional(zod_1.z.string())
        .transform((str, ctx) => {
        if ((0, lodash_1.isNil)(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