From 6bc6a7d7faf1dde92fb4abeb3132a5ee417f3af8 Mon Sep 17 00:00:00 2001 From: Michael Housh Date: Mon, 29 Dec 2025 09:23:08 -0500 Subject: [PATCH] feat: Begins integrating url routing. --- Package.resolved | 38 +++++++++++++++++++++- Package.swift | 11 +++++-- Sources/ManualDClient/Live.swift | 1 + Sources/ManualDCore/EquipmentInfo.swift | 2 +- Sources/ManualDCore/Routes/ApiRoute.swift | 17 ++++++++++ Sources/ManualDCore/Routes/SiteRoute.swift | 6 ++++ Sources/ManualDCore/Routes/ViewRoute.swift | 0 7 files changed, 71 insertions(+), 4 deletions(-) create mode 100644 Sources/ManualDCore/Routes/ApiRoute.swift create mode 100644 Sources/ManualDCore/Routes/SiteRoute.swift create mode 100644 Sources/ManualDCore/Routes/ViewRoute.swift diff --git a/Package.resolved b/Package.resolved index 9f6fd04..1be6d83 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "426df0aee89a834f20c1c804ecbfbed0bc19ef629c2a1fd2e6260702b97b6f31", + "originHash" : "6db0ff1757d16de886ae50dadf070f0d2ada4d31b5765536ba4266e399ed7a67", "pins" : [ { "identity" : "combine-schedulers", @@ -19,6 +19,15 @@ "version" : "0.14.0" } }, + { + "identity" : "swift-case-paths", + "kind" : "remoteSourceControl", + "location" : "https://github.com/pointfreeco/swift-case-paths.git", + "state" : { + "revision" : "6989976265be3f8d2b5802c722f9ba168e227c71", + "version" : "1.7.2" + } + }, { "identity" : "swift-clocks", "kind" : "remoteSourceControl", @@ -28,6 +37,15 @@ "version" : "1.0.6" } }, + { + "identity" : "swift-collections", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-collections", + "state" : { + "revision" : "7b847a3b7008b2dc2f47ca3110d8c782fb2e5c7e", + "version" : "1.3.0" + } + }, { "identity" : "swift-concurrency-extras", "kind" : "remoteSourceControl", @@ -46,6 +64,15 @@ "version" : "1.10.0" } }, + { + "identity" : "swift-parsing", + "kind" : "remoteSourceControl", + "location" : "https://github.com/pointfreeco/swift-parsing", + "state" : { + "revision" : "3432cb81164dd3d69a75d0d63205be5fbae2c34b", + "version" : "0.14.1" + } + }, { "identity" : "swift-syntax", "kind" : "remoteSourceControl", @@ -55,6 +82,15 @@ "version" : "602.0.0" } }, + { + "identity" : "swift-url-routing", + "kind" : "remoteSourceControl", + "location" : "https://github.com/pointfreeco/swift-url-routing.git", + "state" : { + "revision" : "1cfd564259ecb1d324bb718a8f03e513dab738d2", + "version" : "0.6.2" + } + }, { "identity" : "xctest-dynamic-overlay", "kind" : "remoteSourceControl", diff --git a/Package.swift b/Package.swift index 9c49dbf..73e12f5 100644 --- a/Package.swift +++ b/Package.swift @@ -10,14 +10,21 @@ let package = Package( .library(name: "ManualDClient", targets: ["ManualDClient"]), ], dependencies: [ - .package(url: "https://github.com/pointfreeco/swift-dependencies", from: "1.0.0") + .package(url: "https://github.com/pointfreeco/swift-dependencies", from: "1.0.0"), + .package(url: "https://github.com/pointfreeco/swift-url-routing.git", from: "0.6.2"), + .package(url: "https://github.com/pointfreeco/swift-case-paths.git", from: "1.6.0"), ], targets: [ .target( name: "swift-manual-d" ), .target( - name: "ManualDCore" + name: "ManualDCore", + dependencies: [ + .product(name: "Dependencies", package: "swift-dependencies"), + .product(name: "URLRouting", package: "swift-url-routing"), + .product(name: "CasePaths", package: "swift-case-paths"), + ] ), .target( name: "ManualDClient", diff --git a/Sources/ManualDClient/Live.swift b/Sources/ManualDClient/Live.swift index c46a066..b323131 100644 --- a/Sources/ManualDClient/Live.swift +++ b/Sources/ManualDClient/Live.swift @@ -38,6 +38,7 @@ extension ManualDClient: DependencyKey { }, equivalentRectangularDuct: { request in let width = (Double.pi * (pow(Double(request.roundSize) / 2.0, 2.0))) / Double(request.height) + // Round the width up or fail (really should never fail since we know the input is a number). guard let widthStr = numberFormatter.string(for: width), let widthInt = Int(widthStr) else { diff --git a/Sources/ManualDCore/EquipmentInfo.swift b/Sources/ManualDCore/EquipmentInfo.swift index 4019c07..9da06bf 100644 --- a/Sources/ManualDCore/EquipmentInfo.swift +++ b/Sources/ManualDCore/EquipmentInfo.swift @@ -1,6 +1,6 @@ import Foundation -public struct EquipmentInfo: Codable, Equatable { +public struct EquipmentInfo: Codable, Equatable, Sendable { public let staticPressure: Double public let heatingCFM: Int public let coolingCFM: Int diff --git a/Sources/ManualDCore/Routes/ApiRoute.swift b/Sources/ManualDCore/Routes/ApiRoute.swift new file mode 100644 index 0000000..5f4700c --- /dev/null +++ b/Sources/ManualDCore/Routes/ApiRoute.swift @@ -0,0 +1,17 @@ +import CasePathsCore +import Foundation +@preconcurrency import URLRouting + +extension SiteRoute { + /// Represents api routes. + /// + /// The routes return json as opposed to view routes that return html. + public enum Api { + public static let rootPath = Path { + "api" + "v1" + } + + } + +} diff --git a/Sources/ManualDCore/Routes/SiteRoute.swift b/Sources/ManualDCore/Routes/SiteRoute.swift new file mode 100644 index 0000000..da49b8a --- /dev/null +++ b/Sources/ManualDCore/Routes/SiteRoute.swift @@ -0,0 +1,6 @@ +import CasePathsCore +import Foundation +@preconcurrency import URLRouting + +public enum SiteRoute { +} diff --git a/Sources/ManualDCore/Routes/ViewRoute.swift b/Sources/ManualDCore/Routes/ViewRoute.swift new file mode 100644 index 0000000..e69de29