feat: More cleanup / renaming for project client.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct DuctCalcClientError: Error {
|
public struct ProjectClientError: Error {
|
||||||
public let reason: String
|
public let reason: String
|
||||||
|
|
||||||
public init(_ reason: String) {
|
public init(_ reason: String) {
|
||||||
|
|||||||
@@ -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
|
@DependencyClient
|
||||||
public struct ProjectClient: Sendable {
|
public struct ProjectClient: Sendable {
|
||||||
public var calculateDuctSizes: @Sendable (Project.ID) async throws -> DuctSizeResponse
|
public var calculateDuctSizes: @Sendable (Project.ID) async throws -> DuctSizeResponse
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ extension DatabaseClient {
|
|||||||
func sharedDuctRequest(_ projectID: Project.ID) async throws -> DuctSizeSharedRequest {
|
func sharedDuctRequest(_ projectID: Project.ID) async throws -> DuctSizeSharedRequest {
|
||||||
|
|
||||||
guard let dfrResponse = try await designFrictionRate(projectID: projectID) else {
|
guard let dfrResponse = try await designFrictionRate(projectID: projectID) else {
|
||||||
throw DuctCalcClientError("Project not complete.")
|
throw ProjectClientError("Project not complete.")
|
||||||
}
|
}
|
||||||
|
|
||||||
let ensuredTEL = try dfrResponse.ensureMaxContainer()
|
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.
|
// Fetches the project sensible heat ratio or throws an error if it's nil.
|
||||||
func ensuredSHR(_ projectID: Project.ID) async throws -> Double {
|
func ensuredSHR(_ projectID: Project.ID) async throws -> Double {
|
||||||
guard let projectSHR = try await projects.getSensibleHeatRatio(projectID) else {
|
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
|
return projectSHR
|
||||||
}
|
}
|
||||||
@@ -78,10 +78,10 @@ extension DatabaseClient {
|
|||||||
func ensureMaxContainer() throws -> EnsuredTEL {
|
func ensureMaxContainer() throws -> EnsuredTEL {
|
||||||
|
|
||||||
guard let maxSupplyLength = telMaxContainer.supply else {
|
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 {
|
guard let maxReturnLength = telMaxContainer.return else {
|
||||||
throw DuctCalcClientError("Max supply TEL not found")
|
throw ProjectClientError("Max supply TEL not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
return (maxSupplyLength, maxReturnLength)
|
return (maxSupplyLength, maxReturnLength)
|
||||||
|
|||||||
Reference in New Issue
Block a user