import { fieldTypes } from '../../../jdl/jhipster/index.js';
import { fieldIsEnum } from '../../base-application/support/index.js';
const { BOOLEAN: TYPE_BOOLEAN, ZONED_DATE_TIME: TYPE_ZONED_DATE_TIME, INSTANT: TYPE_INSTANT, LOCAL_DATE: TYPE_LOCAL_DATE, INTEGER: TYPE_INTEGER, LONG: TYPE_LONG, BIG_DECIMAL: TYPE_BIG_DECIMAL, FLOAT: TYPE_FLOAT, DOUBLE: TYPE_DOUBLE, } = fieldTypes.CommonDBTypes;
export const getEntryIfTypeOrTypeAttribute = key => {
    if (typeof key === 'object') {
        return key.type;
    }
    return key;
};
const getTypescriptKeyType = primaryKey => {
    if ([TYPE_INTEGER, TYPE_LONG, TYPE_FLOAT, TYPE_DOUBLE, TYPE_BIG_DECIMAL].includes(getEntryIfTypeOrTypeAttribute(primaryKey))) {
        return 'number';
    }
    return 'string';
};
export const getTypescriptType = fieldType => {
    if ([TYPE_INTEGER, TYPE_LONG, TYPE_FLOAT, TYPE_DOUBLE, TYPE_BIG_DECIMAL].includes(fieldType)) {
        return 'number';
    }
    if ([TYPE_LOCAL_DATE, TYPE_ZONED_DATE_TIME, TYPE_INSTANT].includes(fieldType)) {
        return 'dayjs.Dayjs';
    }
    if ([TYPE_BOOLEAN].includes(fieldType)) {
        return 'boolean';
    }
    if (fieldIsEnum(fieldType)) {
        return fieldType;
    }
    return 'string';
};
export default getTypescriptKeyType;
