using Codex.CQRS.Commands;
using Codex.CQRS.Queries;
using Codex.Dal.QueryProviders;
using Microsoft.AspNetCore.Mvc;
using Microsoft.OpenApi.Models;
using OpenHarbor.CQRS.Abstractions;
using OpenHarbor.CQRS.DynamicQuery.Abstractions;
using PoweredSoft.Data.Core;
using PoweredSoft.DynamicQuery;
using PoweredSoft.DynamicQuery.Core;
namespace Codex.Api.Endpoints;
///
/// Manual endpoint registration for endpoints requiring custom OpenAPI documentation.
/// OpenHarbor.CQRS v8.1.0-rc1 auto-registers and auto-documents all ICommandHandler implementations.
/// Manual registration should only be used for advanced customization needs.
///
public static class ManualEndpointRegistration
{
public static WebApplication MapCodexEndpoints(this WebApplication app)
{
// ============================================================
// COMMANDS - AUTO-REGISTERED BY OPENHARBOR.CQRS
// ============================================================
// All commands are automatically registered and documented by the framework:
// - CreateAgent (no return value)
// - UpdateAgent (no return value)
// - DeleteAgent (no return value)
// - CreateConversation (returns Guid)
// - StartAgentExecution (returns Guid)
// - CompleteAgentExecution (no return value)
//
// Routes: POST /api/command/{commandName}
// Documentation: Automatically generated from XML comments in command classes
// ============================================================
// QUERIES - AUTO-REGISTERED BY OPENHARBOR.CQRS
// ============================================================
// All queries are automatically registered and documented by the framework:
// - Health (simple check)
// - GetAgent (returns AgentDetails)
// - GetAgentExecution (returns AgentExecutionDetails)
// - GetConversation (returns ConversationDetails)
//
// Routes: POST /api/query/{queryName}
// Documentation: Automatically generated from XML comments in query classes
// ============================================================
// DYNAMIC QUERIES (Paginated Lists)
// ============================================================
// NOTE: Dynamic queries are auto-registered by OpenHarbor but not auto-documented.
// They work via /api/dynamicquery/{ItemType} but aren't in Swagger without manual registration.
// The endpoints exist and function - frontend can use them directly from openapi.json examples below.
// Manual registration disabled for now - OpenHarbor handles these automatically
// TODO: Add proper schema documentation for dynamic query request/response
/*
// ListAgents
app.MapPost("/api/dynamicquery/ListAgentsQueryItem",
async (HttpContext context,
IQueryableProvider provider,
IAsyncQueryableService queryService) =>
{
var query = await context.Request.ReadFromJsonAsync