From 65fc8565b680e9063b4a10295425031474fabd93 Mon Sep 17 00:00:00 2001 From: Michael Housh Date: Fri, 16 Jan 2026 09:40:15 -0500 Subject: [PATCH] feat: More cleanup / renaming for project client. --- Sources/ProjectClient/DuctCalcClientError.swift | 2 +- Sources/ProjectClient/Interface.swift | 4 ++++ .../Internal/DatabaseClient+calculateDuctSizes.swift | 8 ++++---- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Sources/ProjectClient/DuctCalcClientError.swift b/Sources/ProjectClient/DuctCalcClientError.swift index 9a533b0..1e676cb 100644 --- a/Sources/ProjectClient/DuctCalcClientError.swift +++ b/Sources/ProjectClient/DuctCalcClientError.swift @@ -1,6 +1,6 @@ import Foundation -public struct DuctCalcClientError: Error { +public struct ProjectClientError: Error { public let reason: String public init(_ reason: String) { diff --git a/Sources/ProjectClient/Interface.swift b/Sources/ProjectClient/Interface.swift index a4e0ea2..9d85847 100644 --- a/Sources/ProjectClient/Interface.swift +++ b/Sources/ProjectClient/Interface.swift @@ -10,6 +10,10 @@ extension DependencyValues { } } +/// Useful helper utilities for project's. +/// +/// This is primarily used for implementing logic required to get the needed data +/// for the view controller client to render views. @DependencyClient public struct ProjectClient: Sendable { public var calculateDuctSizes: @Sendable (Project.ID) async throws -> DuctSizeResponse diff --git a/Sources/ProjectClient/Internal/DatabaseClient+calculateDuctSizes.swift b/Sources/ProjectClient/Internal/DatabaseClient+calculateDuctSizes.swift index 6e9d123..50c965a 100644 --- a/Sources/ProjectClient/Internal/DatabaseClient+calculateDuctSizes.swift +++ b/Sources/ProjectClient/Internal/DatabaseClient+calculateDuctSizes.swift @@ -43,7 +43,7 @@ extension DatabaseClient { func sharedDuctRequest(_ projectID: Project.ID) async throws -> DuctSizeSharedRequest { guard let dfrResponse = try await designFrictionRate(projectID: projectID) else { - throw DuctCalcClientError("Project not complete.") + throw ProjectClientError("Project not complete.") } let ensuredTEL = try dfrResponse.ensureMaxContainer() @@ -61,7 +61,7 @@ extension DatabaseClient { // Fetches the project sensible heat ratio or throws an error if it's nil. func ensuredSHR(_ projectID: Project.ID) async throws -> Double { guard let projectSHR = try await projects.getSensibleHeatRatio(projectID) else { - throw DuctCalcClientError("Project sensible heat ratio not set.") + throw ProjectClientError("Project sensible heat ratio not set.") } return projectSHR } @@ -78,10 +78,10 @@ extension DatabaseClient { func ensureMaxContainer() throws -> EnsuredTEL { guard let maxSupplyLength = telMaxContainer.supply else { - throw DuctCalcClientError("Max supply TEL not found") + throw ProjectClientError("Max supply TEL not found") } guard let maxReturnLength = telMaxContainer.return else { - throw DuctCalcClientError("Max supply TEL not found") + throw ProjectClientError("Max supply TEL not found") } return (maxSupplyLength, maxReturnLength)