Repository Public
1// SP Wallet Core2// File: Sources/SPWalletCore/Domains/Ops/DashboardAPI.swift3// Description: The read-only aggregates of the Dashboard and Activity screens (services/api/src/dashboard): the risk indicator4// of the shell, the summary of Home, the unified timeline and its CSV. Owner session only (an API key is refused).5//6// Author: Simon-Pierre Boucher7// Contact: contact@spboucher.ai8import Foundation910public struct DashboardAPI: Sendable {11 let client: APIClient12 public init(_ client: APIClient) { self.client = client }1314 /** The two global switches of the risk engine and whether the live limits are complete. Each section fails on its own. */15 public func status() async throws -> DashboardStatus { try await client.get("/dashboard/status") }1617 /** The three books, risk, agents, today's agent PnL per mode, health and the audit chain. Each section fails on its own. */18 public func summary() async throws -> DashboardSummary { try await client.get("/dashboard/summary") }1920 /** One page of the unified history, newest first. Walk the pages with `cursor: page.nextCursor`. */21 public func activity(_ q: TimelineQuery = TimelineQuery(), limit: Int? = nil, cursor: String? = nil) async throws -> TimelinePage {22 var query = q.items23 query["limit"] = limit.map { String(min(max($0, 1), 200)) }24 query["cursor"] = cursor25 return try await client.get("/dashboard/activity", query: query)26 }2728 /** The server's own CSV of the filtered timeline (at most 2 500 rows; formula-injection-safe quoting is the server's). */29 public func activityCSV(_ q: TimelineQuery = TimelineQuery()) async throws -> Data {30 try await client.raw(.get, "/dashboard/activity.csv", query: q.items, headers: ["Accept": "text/csv"]).031 }32}33