import { SelectQueryBuilder } from 'typeorm'

import { Font } from '@things-factory/font-base'
import { getRepository } from '@things-factory/shell'

export const fonts = async () => {
  const qb: SelectQueryBuilder<Font> = await getRepository(Font).createQueryBuilder('FONT')
  return (await qb.select('name').distinct(true).where({ active: true }).getRawMany()).map(
    (f: { name: string }) => f.name
  )
}
