import { db } from "../../db/postgre.js";
import { Emoji } from "../entities/emoji.js";
export const EmojiRepository = db.getRepository(Emoji).extend({
    async pack (src) {
        const emoji = typeof src === "object" ? src : await this.findOneByOrFail({
            id: src
        });
        return {
            id: emoji.id,
            aliases: emoji.aliases,
            name: emoji.name,
            category: emoji.category,
            host: emoji.host,
            // || emoji.originalUrl してるのは後方互換性のため
            url: emoji.publicUrl || emoji.originalUrl,
            license: emoji.license,
            width: emoji.width,
            height: emoji.height
        };
    },
    packMany (emojis) {
        return Promise.all(emojis.map((x)=>this.pack(x)));
    }
});
