"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 = {
    patientId: {
        id: 'patientId',
        label: 'Patient ID',
        description: 'The ID of the patient you want to create an appointment for.',
        type: extensions_core_1.FieldType.STRING,
        required: true,
    },
    otherPartyId: {
        id: 'otherPartyId',
        label: 'Provider ID',
        description: 'The ID of the provider the appointment is with. If none provided, the user the API key is associated with will be used.',
        type: extensions_core_1.FieldType.STRING,
    },
    contactTypeId: {
        id: 'contactTypeId',
        label: 'Contact type ID',
        description: 'How the appointment will be conducted.',
        type: extensions_core_1.FieldType.STRING,
        required: true,
    },
    appointmentTypeId: {
        id: 'appointmentTypeId',
        label: 'Appointment type ID',
        description: 'The ID of the appointment type.',
        type: extensions_core_1.FieldType.STRING,
        required: true,
    },
    datetime: {
        id: 'datetime',
        label: 'Appointment date and time',
        description: 'The date and time of the appointment in ISO8601 format.',
        type: extensions_core_1.FieldType.DATE,
        required: true,
    },
    notes: {
        id: 'notes',
        label: 'Notes',
        description: 'Any notes you want to add to the appointment.',
        type: extensions_core_1.FieldType.TEXT,
        required: false,
    },
    externalVideochatUrl: {
        id: 'externalVideochatUrl',
        label: 'External video chat URL',
        description: 'When passed in, this video chat URL will be used instead of built-in Video Chat or Zoom.',
        type: extensions_core_1.FieldType.STRING,
        required: false,
    },
    metadata: {
        id: 'metadata',
        label: 'Metadata',
        description: '',
        type: extensions_core_1.FieldType.JSON,
        required: false,
    },
};
exports.FieldsValidationSchema = zod_1.z.object({
    patientId: zod_1.z.string().min(1),
    otherPartyId: zod_1.z.string().optional(),
    contactTypeId: zod_1.z.string().min(1),
    appointmentTypeId: zod_1.z.string().min(1),
    datetime: extensions_core_1.DateTimeSchema,
    notes: zod_1.z.string().optional(),
    externalVideochatUrl: zod_1.z
        .string()
        .optional()
        .transform((val) => {
        if ((0, lodash_1.isEmpty)(val))
            return undefined;
        return val;
    }),
    metadata: zod_1.z
        .string()
        .optional()
        .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