import Dependencies import DependenciesMacros import Foundation import SharedModels public extension DatabaseClient { @DependencyClient struct Users: Sendable { public var create: @Sendable (User.Create) async throws -> User public var delete: @Sendable (User.ID) async throws -> Void public var fetchAll: @Sendable () async throws -> [User] public var get: @Sendable (User.ID) async throws -> User? public var login: @Sendable (User.Login) async throws -> User.Token public var logout: @Sendable (User.Token.ID) async throws -> Void } } extension DatabaseClient.Users: TestDependencyKey { public static let testValue: DatabaseClient.Users = Self() } public extension User { struct Create: Codable, Sendable { public let username: String public let email: String public let password: String public let confirmPassword: String public init( username: String, email: String, password: String, confirmPassword: String ) { self.username = username self.email = email self.password = password self.confirmPassword = confirmPassword } } struct Login: Codable, Sendable { public let username: String? public let email: String? public let password: String public init( username: String?, email: String? = nil, password: String ) { self.username = username self.email = email self.password = password } } struct Token: Codable, Equatable, Identifiable, Sendable { public let id: UUID public let userID: User.ID public let value: String public init( id: UUID, userID: User.ID, value: String ) { self.id = id self.userID = userID self.value = value } } }