"use strict";
/**
 * Field Mapping Types
 *
 * Defines the mapping rules between JSON schema field types
 * and their TypeScript, Zod, and form component equivalents.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.DEFAULT_MODULE_ICON = exports.ENTITY_ZOD_SCHEMA = exports.AUTHOR_ZOD_SCHEMA = exports.AUTHOR_VARIANT = exports.STANDARD_FIELDS = exports.CONTENT_INDICATOR_FIELDS = exports.TYPE_TO_FORM_COMPONENT = exports.SPECIAL_FIELD_COMPONENTS = exports.JSON_TO_ZOD_BASE = exports.JSON_TO_TS_TYPE = void 0;
exports.getTsType = getTsType;
exports.getZodBase = getZodBase;
exports.getFormComponent = getFormComponent;
exports.isContentField = isContentField;
exports.buildZodSchema = buildZodSchema;
/**
 * Mapping from JSON type to TypeScript type
 */
exports.JSON_TO_TS_TYPE = {
    string: "string",
    number: "number",
    boolean: "boolean",
    date: "Date",
    any: "any",
};
/**
 * Mapping from JSON type to Zod schema (base, without modifiers)
 */
exports.JSON_TO_ZOD_BASE = {
    string: "z.string()",
    number: "z.number()",
    boolean: "z.boolean()",
    date: "z.date()",
    any: "z.any()",
};
/**
 * Special field names that get specific form components
 */
exports.SPECIAL_FIELD_COMPONENTS = {
    content: "BlockNoteEditor",
    description: "FormTextarea",
    abstract: "FormTextarea",
    body: "FormTextarea",
};
/**
 * Default form component by type
 */
exports.TYPE_TO_FORM_COMPONENT = {
    string: "FormInput",
    number: "FormInputNumber",
    boolean: "Checkbox",
    date: "DatePicker",
    any: "FormInput",
};
/**
 * Fields that indicate the module extends Content
 */
exports.CONTENT_INDICATOR_FIELDS = ["name", "tldr", "abstract"];
/**
 * Standard fields added to all modules
 */
exports.STANDARD_FIELDS = ["createdAt", "updatedAt"];
/**
 * Author variant special handling
 */
exports.AUTHOR_VARIANT = "Author";
/**
 * Zod schema for author relationships
 */
exports.AUTHOR_ZOD_SCHEMA = "userObjectSchema";
/**
 * Zod schema for entity relationships (non-author)
 */
exports.ENTITY_ZOD_SCHEMA = "entityObjectSchema";
/**
 * Default icon for new modules
 */
exports.DEFAULT_MODULE_ICON = "FileTextIcon";
/**
 * Get TypeScript type for a field
 */
function getTsType(jsonType) {
    return exports.JSON_TO_TS_TYPE[jsonType] || "any";
}
/**
 * Get base Zod schema for a field type
 */
function getZodBase(jsonType) {
    return exports.JSON_TO_ZOD_BASE[jsonType] || "z.any()";
}
/**
 * Get form component for a field
 */
function getFormComponent(fieldName, fieldType) {
    // Check for special field names first
    if (exports.SPECIAL_FIELD_COMPONENTS[fieldName]) {
        return exports.SPECIAL_FIELD_COMPONENTS[fieldName];
    }
    // Fall back to type-based component
    return exports.TYPE_TO_FORM_COMPONENT[fieldType] || "FormInput";
}
/**
 * Check if a field name indicates BlockNoteEditor should be used
 */
function isContentField(fieldName) {
    return fieldName === "content";
}
/**
 * Build complete Zod schema for a field
 */
function buildZodSchema(fieldType, nullable, fieldName) {
    const base = getZodBase(fieldType);
    // Content fields use z.any()
    if (isContentField(fieldName)) {
        return "z.any()";
    }
    // String fields with min(1) for required
    if (fieldType === "string") {
        if (nullable) {
            return `${base}.optional()`;
        }
        return `${base}.min(1, { message: t(\`features.\${moduleName}.fields.${fieldName}.error\`) })`;
    }
    // Other fields with optional modifier
    if (nullable) {
        return `${base}.optional()`;
    }
    return base;
}
//# sourceMappingURL=field-mapping.types.js.map