Added the catalogue models and seed to support phase 4 of the POC prototype in the Persistence package.

This commit is contained in:
javier committed 2026-09-21 12:50:53 +02:00
1 parent 0dc3fe6bea
commit 95e0a455e8
14 files changed
+743 -9

No files matched your search

@@ -53,6 +53,10 @@ public struct Listing: Sendable, Equatable {
public let listedAt: Date
/// When a sale of the copy was agreed, or `nil` while it is for sale.
public let soldAt: Date?
/// The defects the seller declared, from the grading guide's checklist.
public let defects: [String]
/// The URL paths of the photos of this copy, the front first; empty while the listing shows its placeholder cover.
public let photos: [String]
// MARK: Initializers
@@ -80,7 +84,9 @@ public struct Listing: Sendable, Equatable {
acceptsOffers: Bool,
cover: Cover,
listedAt: Date,
soldAt: Date? = nil
soldAt: Date? = nil,
defects: [String] = [],
photos: [String] = []
) {
self.slug = slug
self.shop = shop
@@ -106,6 +112,8 @@ public struct Listing: Sendable, Equatable {
self.cover = cover
self.listedAt = listedAt
self.soldAt = soldAt
self.defects = defects
self.photos = photos
}
}
@@ -116,6 +124,15 @@ public extension Listing {
// MARK: Computed
/// What the seller declared of the copy's condition, in a sentence: the defects, then the notes. Frozen into a sale at agreement.
var declaration: String {
let defects = defects.isEmpty
? "No defects declared."
: "Declared defects: \(defects.joined(separator: "; "))."
return sellerNotes.isEmpty ? defects : "\(defects) \(sellerNotes)"
}
/// The grade or condition in a few words: `CGC 9.8` for a slab, `Raw · NM` for a raw issue, the condition alone for a collected edition.
var gradeLabel: String {
if let grader, let grade {