import define from "../../../define.js";
import { Plans, UserPlans, Users } from "../../../../../models/index.js";
export const meta = {
    tags: [
        "admin"
    ],
    requireCredential: true,
    requireAdmin: true
};
export const paramDef = {
    type: "object",
    properties: {
        userId: {
            type: "string",
            format: "misskey:id"
        }
    },
    required: [
        "userId"
    ]
};
export default define(meta, paramDef, async (ps)=>{
    await Users.findOneByOrFail({
        id: ps.userId
    });
    const joins = await UserPlans.find({
        where: {
            userId: ps.userId
        },
        relations: [
            "plan"
        ],
        order: {
            createdAt: "ASC"
        }
    });
    return await Plans.packMany(joins.map((join)=>join.plan).filter((plan)=>plan != null));
});
