import JSONEntity from '../../jhipster/json-entity.js';
import formatComment from '../../utils/format-utils.js';
import { getTableNameFromEntityNameFallback } from '../../jhipster/entity-table-name-creator.js';
export default {
    convert,
};
export function convert(jdlEntities) {
    if (!jdlEntities) {
        throw new Error('JDL entities must be passed to get the basic entity information.');
    }
    return createJSONEntities(jdlEntities);
}
function createJSONEntities(jdlEntities) {
    const convertedEntities = new Map();
    jdlEntities.forEach((jdlEntity) => {
        const entityName = jdlEntity.name;
        convertedEntities.set(entityName, new JSONEntity({
            entityName,
            entityTableName: jdlEntity.tableName ?? getTableNameFromEntityNameFallback(entityName),
            documentation: formatComment(jdlEntity.comment),
            annotations: jdlEntity.annotations,
        }));
    });
    return convertedEntities;
}
