"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateActionFields = exports.FieldsValidationSchema = exports.fields = void 0;
const zod_1 = require("zod");
const extensions_core_1 = require("@awell-health/extensions-core");
const validation_1 = require("../../../../../sendbird/v1/validation");
exports.fields = {
    label: {
        id: 'label',
        label: 'Select - Label',
        description: 'Enter the label text that will be displayed before the selector.',
        type: extensions_core_1.FieldType.STRING,
        required: true,
    },
    mandatory: {
        id: 'mandatory',
        label: 'Select - Response required?',
        description: 'The user must select an option before continuing.',
        type: extensions_core_1.FieldType.BOOLEAN,
        required: true,
    },
    url: {
        id: 'url',
        label: 'Options - Endpoint URL',
        description: 'Enter the URL (starting with `https://`) where the options to display can be fetched. The endpoint must return an array of objects with the following properties: `id`, `label` and `value`.',
        type: extensions_core_1.FieldType.STRING,
        required: true,
    },
    headers: {
        id: 'headers',
        label: 'Options - Headers',
        description: 'Enter the headers to send to the options source URL. The headers must be in JSON format.',
        type: extensions_core_1.FieldType.JSON,
        required: false,
    },
    queryParam: {
        id: 'queryParam',
        label: 'Options - Search query param',
        description: 'Enter the key of the free text search query param if the endpoint supports this e.g. `search` for `https://example.com/options?search=foo`.',
        type: extensions_core_1.FieldType.STRING,
        required: false,
    },
};
exports.FieldsValidationSchema = zod_1.z.object({
    label: zod_1.z.string().min(1),
    url: zod_1.z.string().url(),
    headers: (0, extensions_core_1.makeStringOptional)(validation_1.JsonStringValidationSchema),
    queryParam: (0, extensions_core_1.makeStringOptional)(zod_1.z.string()),
    mandatory: zod_1.z.boolean(),
});
const validateActionFields = (fields) => {
    const parsedData = exports.FieldsValidationSchema.parse(fields);
    return parsedData;
};
exports.validateActionFields = validateActionFields;
//# sourceMappingURL=fields.js.map