import { CustomCommandStatus, system } from "@minecraft/server";
import { fetchDatabase } from "../../functions/database/fetch-database";
import { debugLog } from "../../data/util/debug";
export function debugDatabaseConsoleCmd(_origin, targetDatabase) {
    let db;
    const entity = _origin.sourceEntity;
    const sender = entity;
    try {
        db = fetchDatabase(targetDatabase);
    }
    catch (err) {
        sender.sendMessage(`§4[ReplayCraft]§cDatabase "${targetDatabase}" not found or invalid.`);
        return {
            status: CustomCommandStatus.Failure,
            message: `Database "${targetDatabase}" not found or invalid.`,
        };
    }
    system.run(() => {
        for (const [key, value] of db.entries()) {
            debugLog(`[${key}]`, JSON.stringify(value, null, 2));
        }
    });
    return {
        status: CustomCommandStatus.Success,
        message: `Check the server console.`,
    };
}
