Multi-agent AI laboratory with ASP.NET Core 8.0 backend and Flutter frontend. Implements CQRS architecture, OpenAPI contract-first API design. BACKEND: Agent management, conversations, executions with PostgreSQL + Ollama FRONTEND: Cross-platform UI with strict typing and Result-based error handling Co-Authored-By: Jean-Philippe Brule <jp@svrnty.io>
136 lines
3.3 KiB
Dart
136 lines
3.3 KiB
Dart
/// Svrnty Console API Client Library
|
|
///
|
|
/// Type-safe CQRS API client for communicating with the backend.
|
|
///
|
|
/// This library provides:
|
|
/// - CQRS pattern support (queries, commands, paginated queries)
|
|
/// - Functional error handling with Result<T>
|
|
/// - Type-safe serialization via Serializable interface
|
|
/// - OpenAPI contract-driven development
|
|
///
|
|
/// ## Quick Start
|
|
///
|
|
/// ```dart
|
|
/// import 'package:console/api/api.dart';
|
|
///
|
|
/// // Create client
|
|
/// final client = CqrsApiClient(
|
|
/// config: ApiClientConfig.development,
|
|
/// );
|
|
///
|
|
/// // Execute query
|
|
/// final result = await client.checkHealth();
|
|
///
|
|
/// result.when(
|
|
/// success: (isHealthy) => print('API healthy: $isHealthy'),
|
|
/// error: (error) => print('Error: ${error.message}'),
|
|
/// );
|
|
///
|
|
/// // Clean up
|
|
/// client.dispose();
|
|
/// ```
|
|
///
|
|
/// ## CQRS Patterns
|
|
///
|
|
/// ### Queries (Read)
|
|
/// ```dart
|
|
/// final result = await client.executeQuery<UserDto>(
|
|
/// endpoint: 'users/123',
|
|
/// query: GetUserQuery(userId: '123'),
|
|
/// fromJson: UserDto.fromJson,
|
|
/// );
|
|
/// ```
|
|
///
|
|
/// ### Commands (Write)
|
|
/// ```dart
|
|
/// final result = await client.executeCommand(
|
|
/// endpoint: 'createUser',
|
|
/// command: CreateUserCommand(name: 'John', email: 'john@example.com'),
|
|
/// );
|
|
/// ```
|
|
///
|
|
/// ### Paginated Queries (Lists)
|
|
/// ```dart
|
|
/// final result = await client.executePaginatedQuery<UserDto>(
|
|
/// endpoint: 'users',
|
|
/// query: ListUsersQuery(),
|
|
/// itemFromJson: UserDto.fromJson,
|
|
/// page: 1,
|
|
/// pageSize: 20,
|
|
/// );
|
|
/// ```
|
|
///
|
|
/// See [README_API.md] for complete documentation.
|
|
library;
|
|
|
|
// Core exports
|
|
export 'client.dart' show CqrsApiClient, ApiClientConfig;
|
|
export 'types.dart'
|
|
show
|
|
// Result type
|
|
Result,
|
|
ApiSuccess,
|
|
ApiError,
|
|
// Error types
|
|
ApiErrorInfo,
|
|
ApiErrorType,
|
|
// Pagination
|
|
PaginatedResponse,
|
|
PageInfo,
|
|
FilterCriteria,
|
|
FilterOperator,
|
|
SortCriteria,
|
|
SortDirection,
|
|
// Serialization
|
|
Serializable,
|
|
// Queries (from schema)
|
|
HealthQuery;
|
|
|
|
// Endpoint extensions
|
|
export 'endpoints/health_endpoint.dart' show HealthEndpoint, performHealthCheck;
|
|
export 'endpoints/agent_endpoint.dart'
|
|
show
|
|
AgentEndpoint,
|
|
// Enums
|
|
AgentType,
|
|
AgentStatus,
|
|
ModelProviderType,
|
|
// Commands
|
|
CreateAgentCommand,
|
|
UpdateAgentCommand,
|
|
DeleteAgentCommand,
|
|
// Queries
|
|
GetAgentQuery,
|
|
// DTOs
|
|
AgentDto;
|
|
export 'endpoints/conversation_endpoint.dart'
|
|
show
|
|
ConversationEndpoint,
|
|
// Commands
|
|
CreateConversationCommand,
|
|
SendMessageCommand,
|
|
// Queries
|
|
GetConversationQuery,
|
|
// DTOs
|
|
CreateConversationResult,
|
|
ConversationDto,
|
|
ConversationListItemDto,
|
|
ConversationMessageDto,
|
|
SendMessageResult,
|
|
UserMessageDto,
|
|
AgentResponseDto;
|
|
export 'endpoints/execution_endpoint.dart'
|
|
show
|
|
ExecutionEndpoint,
|
|
// Enums
|
|
ExecutionStatus,
|
|
// Commands
|
|
StartAgentExecutionCommand,
|
|
CompleteAgentExecutionCommand,
|
|
// Queries
|
|
GetAgentExecutionQuery,
|
|
// DTOs
|
|
StartExecutionResult,
|
|
AgentExecutionDto,
|
|
ExecutionListItemDto;
|