<?php
/**
 * database-ajax.php — async JSON endpoint for Database Management (paired with
 * whp-async-forms.js). Uses the shared whp_ajax_endpoint wrapper (output
 * buffering, auth 401, CSRF 403, {success,message,type} envelope) and the
 * shared libs/database_actions.php handler, so there's no boilerplate or logic
 * duplication. Multi-tenant: the handler enforces per-user DB ownership
 * (canManageDatabase / the AUTH_USER_ name sandbox), so no root gate here.
 */
require_once __DIR__ . '/../includes/whp-ajax-endpoint.php';   // also loads auto-prepend (AUTH_USER, CSRF)
require_once __DIR__ . '/../libs/mysqlmgmt.php';
require_once __DIR__ . '/../libs/database_actions.php';

whp_ajax_endpoint(function () {
    $MySQLMgmt = new mysqlmgmt();
    return whp_database_handle_action($MySQLMgmt);
});
