using EAIAdminDAL.DTO;
using GB5Shared.DTO.Framework.Login;
using System.Threading;
using System.Threading.Tasks;
namespace EAIAdminBLL.Sync
{
///
/// Pushes/pulls EAIAdmin config to/from gbEAI (AI-Enterprise-v1.0) over REST, built on top of
/// the shared GB5Shared.ExternalAI.IAIEngineSyncClient transport. One method pair per entity.
///
/// Failure semantics (every Push*/Delete* method): called AFTER the caller's own local
/// IQueryExecutor commit has already succeeded — never inside a DB transaction. A failed push
/// does NOT roll back the local save; GB5 stays system-of-record even when gbEAI is
/// unreachable. Callers surface EAISyncResult.Success == false as a warning suffix on their
/// own return message, never as a thrown exception.
///
/// Every Push* call is an upsert on the gbEAI side, keyed by each entity's business code (not
/// gbEAI's own numeric id) — GB5 never needs to know gbEAI's id ahead of time; it comes back
/// in the result and is persisted onto each table's EAIRemoteId column as a correlation
/// accelerator only. Every Delete* call no-ops (Success=true) if EAIRemoteId is null — nothing
/// was ever synced remotely, so there is nothing to delete there.
///
public interface IEAISyncClient
{
Task PushInitiativeAsync(
EAIInitiativeAdminDTO dto, LoginDTO login, CancellationToken ct = default);
Task DeleteInitiativeAsync(
EAIInitiativeAdminDTO dto, LoginDTO login, CancellationToken ct = default);
Task PushCapabilityAsync(
EAICapabilityAdminDTO dto, LoginDTO login, CancellationToken ct = default);
Task DeleteCapabilityAsync(
EAICapabilityAdminDTO dto, LoginDTO login, CancellationToken ct = default);
Task PushBotAsync(
EAIBotAdminDTO dto, LoginDTO login, CancellationToken ct = default);
Task DeleteBotAsync(
EAIBotAdminDTO dto, LoginDTO login, CancellationToken ct = default);
/// Response carries the new server-computed PromptVersion in addition to
/// EAIRemoteId — callers must persist both back onto the local row.
Task PushPromptTemplateAsync(
EAIPromptTemplateAdminDTO dto, LoginDTO login, CancellationToken ct = default);
Task DeletePromptTemplateAsync(
EAIPromptTemplateAdminDTO dto, LoginDTO login, CancellationToken ct = default);
/// Never sends dto.ApiKeyVaultKey's underlying secret — only the Vault path
/// itself is not even sent to gbEAI at all (gbEAI has no Vault client; GB5 never forwards
/// the raw key). This call carries only modelCode/modelName/provider/endpoint.
Task PushModelConfigAsync(
EAIModelConfigAdminDTO dto, LoginDTO login, CancellationToken ct = default);
Task DeleteModelConfigAsync(
EAIModelConfigAdminDTO dto, LoginDTO login, CancellationToken ct = default);
Task PushAgentRouteAsync(
EAIAgentRouteAdminDTO dto, LoginDTO login, CancellationToken ct = default);
Task DeleteAgentRouteAsync(
EAIAgentRouteAdminDTO dto, LoginDTO login, CancellationToken ct = default);
}
}