"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FieldsValidationSchema = exports.DictionarySchema = exports.fields = void 0;
const zod_1 = require("zod");
const extensions_core_1 = require("@awell-health/extensions-core");
const lodash_1 = require("lodash");
exports.fields = {
    number: {
        id: 'number',
        label: 'Number',
        description: 'The number you want to parse to a text (string)',
        type: extensions_core_1.FieldType.NUMERIC,
        required: true,
    },
    dictionary: {
        id: 'dictionary',
        label: 'Dictionary',
        description: 'A JSON dictionary where each string key represents a number and maps to a corresponding string/text value',
        type: extensions_core_1.FieldType.JSON,
        required: true,
    },
};
exports.DictionarySchema = zod_1.z
    .string()
    .transform((dict, ctx) => {
    if ((0, lodash_1.isNil)(dict) || (0, lodash_1.isEmpty)(dict))
        return {};
    try {
        return JSON.parse(dict);
    }
    catch (e) {
        ctx.addIssue({
            code: 'custom',
            message: 'Invalid dictionary. Must be a valid key-value pair JSON object.',
        });
        return zod_1.z.NEVER;
    }
});
exports.FieldsValidationSchema = zod_1.z.object({
    number: zod_1.z.union([zod_1.z.number(), zod_1.z.nan()]),
    dictionary: exports.DictionarySchema,
});
//# sourceMappingURL=fields.js.map