<?php
/**
 * postgresql-ajax.php — async JSON endpoint for PostgreSQL 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/postgresql_actions.php handler, so there's no boilerplate or
 * logic duplication. Multi-tenant: the handler enforces per-user ownership
 * (the AUTH_USER_ name sandbox + role checks), so no root gate here.
 */
require_once __DIR__ . '/../includes/whp-ajax-endpoint.php';   // also loads auto-prepend (AUTH_USER, CSRF)
require_once __DIR__ . '/../libs/pgsqlmgmt.php';
require_once __DIR__ . '/../libs/postgresql_actions.php';

whp_ajax_endpoint(function () {
    $PgSQLMgmt = new pgsqlmgmt();
    return whp_postgresql_handle_action($PgSQLMgmt);
});
