import { db } from "../../db/postgre.js";
import { UserGroupInvitation } from "../entities/user-group-invitation.js";
import { UserGroups } from "../index.js";
export const UserGroupInvitationRepository = db.getRepository(UserGroupInvitation).extend({
    async pack (src) {
        const invitation = typeof src === "object" ? src : await this.findOneByOrFail({
            id: src
        });
        return {
            id: invitation.id,
            group: await UserGroups.pack(invitation.userGroup || invitation.userGroupId)
        };
    },
    packMany (invitations) {
        return Promise.all(invitations.map((x)=>this.pack(x)));
    }
});
