import Foundation
import GRDB

public struct TaskRecord: Codable, FetchableRecord, PersistableRecord, Sendable {
	public static let databaseTableName = "task"

	public var id: String
	public var accountId: String
	public var summary: String
	public var description: String?
	public var status: String
	public var priority: Int
	public var dueDate: String?
	public var deferUntil: String?
	public var createdAt: String
	public var updatedAt: String
	public var filePath: String?
	public var linkedMessageId: String?
	public var isSomeday: Bool

	public init(
		id: String,
		accountId: String,
		summary: String,
		description: String? = nil,
		status: String = "NEEDS-ACTION",
		priority: Int = 0,
		dueDate: String? = nil,
		deferUntil: String? = nil,
		createdAt: String,
		updatedAt: String,
		filePath: String? = nil,
		linkedMessageId: String? = nil,
		isSomeday: Bool = false
	) {
		self.id = id
		self.accountId = accountId
		self.summary = summary
		self.description = description
		self.status = status
		self.priority = priority
		self.dueDate = dueDate
		self.deferUntil = deferUntil
		self.createdAt = createdAt
		self.updatedAt = updatedAt
		self.filePath = filePath
		self.linkedMessageId = linkedMessageId
		self.isSomeday = isSomeday
	}
}
