File size: 1,444 Bytes
4977db2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import Foundation

public struct PromptQuery: Hashable, Sendable {
    public enum Sort: String, CaseIterable, Sendable {
        case updatedDescending
        case titleAscending
        case mostUsed
    }

    public var text: String
    public var tag: String?
    public var sourceFamily: String?
    public var promptedDay: String?
    public var untaggedOnly: Bool
    public var starredOnly: Bool
    public var usedOnly: Bool
    public var sort: Sort
    public var limit: Int
    public var offset: Int

    public init(
        text: String = "",
        tag: String? = nil,
        sourceFamily: String? = nil,
        promptedDay: String? = nil,
        untaggedOnly: Bool = false,
        starredOnly: Bool = false,
        usedOnly: Bool = false,
        sort: Sort = .updatedDescending,
        limit: Int = 100,
        offset: Int = 0
    ) {
        self.text = text
        self.tag = tag
        self.sourceFamily = sourceFamily
        self.promptedDay = promptedDay
        self.untaggedOnly = untaggedOnly
        self.starredOnly = starredOnly
        self.usedOnly = usedOnly
        self.sort = sort
        self.limit = max(1, min(limit, 500))
        self.offset = max(0, offset)
    }
}

public struct PromptPage: Sendable {
    public let prompts: [PromptRecord]
    public let total: Int

    public init(prompts: [PromptRecord], total: Int) {
        self.prompts = prompts
        self.total = total
    }
}