feat: Begin using Tagged types
All checks were successful
CI / Linux Tests (push) Successful in 5m23s

This commit is contained in:
2026-01-29 17:10:35 -05:00
parent 18a5ef06d3
commit 9379774fae
22 changed files with 167 additions and 150 deletions

View File

@@ -4,22 +4,33 @@ import FluentKit
import ManualDCore
extension DependencyValues {
/// The database dependency.
public var database: DatabaseClient {
get { self[DatabaseClient.self] }
set { self[DatabaseClient.self] = newValue }
}
}
/// Represents the database interactions used by the application.
@DependencyClient
public struct DatabaseClient: Sendable {
/// Database migrations.
public var migrations: Migrations
/// Interactions with the projects table.
public var projects: Projects
/// Interactions with the rooms table.
public var rooms: Rooms
/// Interactions with the equipment table.
public var equipment: Equipment
/// Interactions with the component losses table.
public var componentLosses: ComponentLosses
/// Interactions with the equivalent lengths table.
public var equivalentLengths: EquivalentLengths
/// Interactions with the users table.
public var users: Users
/// Interactions with the user profiles table.
public var userProfiles: UserProfiles
/// Interactions with the trunk sizes table.
public var trunkSizes: TrunkSizes
@DependencyClient
@@ -147,23 +158,3 @@ extension DatabaseClient: TestDependencyKey {
)
}
}
extension DatabaseClient.Migrations: DependencyKey {
public static let testValue = Self()
public static let liveValue = Self(
all: {
[
Project.Migrate(),
User.Migrate(),
User.Token.Migrate(),
User.Profile.Migrate(),
ComponentPressureLoss.Migrate(),
EquipmentInfo.Migrate(),
Room.Migrate(),
EquivalentLength.Migrate(),
TrunkSize.Migrate(),
]
}
)
}

View File

@@ -0,0 +1,22 @@
import Dependencies
import ManualDCore
extension DatabaseClient.Migrations: DependencyKey {
public static let testValue = Self()
public static let liveValue = Self(
all: {
[
Project.Migrate(),
User.Migrate(),
User.Token.Migrate(),
User.Profile.Migrate(),
ComponentPressureLoss.Migrate(),
EquipmentInfo.Migrate(),
Room.Migrate(),
EquivalentLength.Migrate(),
TrunkSize.Migrate(),
]
}
)
}