/** Boolean predicates for individual properties. */
import { QUOTATION_TYPES, UNACCENT_MAP } from './config.js';
export const isRelationship = (p) => p.type === 'relationship';
export const isOneToMany = (p) => p.relationship?.type === 'one-to-many';
export const isManyToOne = (p) => p.relationship?.type === 'many-to-one';
export const isManyToMany = (p) => p.relationship?.type === 'many-to-many';
export const isOneToOne = (p) => p.relationship?.type === 'one-to-one';
export const isPrimaryKey = (p) => Boolean(p.primaryKey);
export const isNullable = (p) => Boolean(p.nullable);
export const isAutoIncrement = (p) => Boolean(p.autoIncrement);
export const isReadonly = (p) => Boolean(p.readonly);
export const isI18n = (p) => Boolean(p.isI18n);
export const isPivot = (p) => Boolean(p.aggregateName && p.modulePath);
export const isBinary = (p) => p.type === 'blob' || p.type === 'blob.medium' || p.type === 'blob.long';
export const isTimezone = (p) => {
    if (p.applyTimezone === false)
        return false;
    return p.type === 'timestamp';
};
export const isUnaccent = (p) => UNACCENT_MAP[p.type] ?? false;
export const hasQuotation = (p) => QUOTATION_TYPES[p.type] ?? false;
/** Property maps to a @Column in Sequelize. */
export const hasColumnDecorator = (p) => p.relationship?.type !== 'one-to-many' &&
    p.relationship?.type !== 'many-to-many' &&
    !(p.relationship?.type === 'one-to-one' && !p.relationship.field);
/** Property maps to a @HasOne decorator. */
export const hasHasOneDecorator = (p) => p.relationship?.type === 'one-to-one' && !p.relationship.field;
/** Property maps to a @BelongsTo decorator. */
export const hasBelongsToDecorator = (p) => (p.relationship?.type === 'many-to-one' && Boolean(p.relationship.field)) ||
    (p.relationship?.type === 'one-to-one' && Boolean(p.relationship?.field));
/** Property maps to a @HasMany decorator. */
export const hasHasManyDecorator = (p) => p.relationship?.type === 'one-to-many';
/** Property maps to a @BelongsToMany decorator. */
export const hasBelongsToManyDecorator = (p) => p.relationship?.type === 'many-to-many';
export const hasBelongsToDecoratorProperty = hasBelongsToDecorator;
export const hasBelongsToManyDecoratorProperty = hasBelongsToManyDecorator;
export const hasColumnDecoratorProperty = hasColumnDecorator;
export const hasHasManyDecoratorProperty = hasHasManyDecorator;
export const hasHasOneDecoratorProperty = hasHasOneDecorator;
export const hasQuotationProperty = hasQuotation;
export const isBinaryProperty = isBinary;
export const isI18nAvailableLangsProperty = (prop, _aggregateProperties) => prop.name === 'availableLangs' && prop.isI18n === true;
export const isI18nRelationProperty = (_moduleNameOrProp, propOrUndef) => {
    const prop = typeof _moduleNameOrProp === 'string' ? propOrUndef : _moduleNameOrProp;
    return prop.isI18n === true;
};
export const isManyToManyRelationshipProperty = isManyToMany;
export const isManyToOneRelationshipProperty = isManyToOne;
export const isPivotProperty = isPivot;
export const isPrimaryKeyProperty = isPrimaryKey;
export const isTimezoneProperty = isTimezone;
export const isUnaccentProperty = isUnaccent;
export { hasBelongsToDecoratorProperties, hasBelongsToManyDecoratorProperties, hasCompositePrimaryKeys, hasEnumProperties, hasForeignKeyDecoratorProperties, hasHasManyDecoratorProperties, hasHasOneDecoratorProperties, hasI18nProperties, hasIndexProperties, hasPivotProperties, } from './property-filters.js';
export { isAllowProperty } from './property-mappers.js';
