oficina / sheets Public

Clone
git clone https://amadan.net/oficina/sheets

Plain git — no account needed to clone.

Download

Download this file

1import Foundation
2
3struct SheetSummary: Decodable, Identifiable, Hashable, Sendable {
4 let ID: UInt64
5 let Title: String
6 let TabID: UInt64
7 let TabName: String
8 var Preview: SheetPreview? = nil
9 var id: UInt64 { self.ID }
10}
11struct SheetList: Decodable { let Sheets: [SheetSummary]? }
12struct PaletteItem: Decodable, Identifiable {
13 let Name: String
14 let Label: String
15 var id: String { Name }
16}
17struct NumberStyle: Decodable, Identifiable {
18 let Code: String
19 let Label: String
20 var id: String { Code }
21}
22struct SheetPage: Decodable {
23 let Sheet: SheetSummary
24 let Rows: Int
25 let Cols: Int
26 let Truncated: Bool
27 let MayWrite: Bool
28 let MayComment: Bool
29 let MayShare: Bool
30 let FillSwatches: [PaletteItem]
31 let InkSwatches: [PaletteItem]
32 let NumberFormats: [NumberStyle]
33 let Warned: [String]?
34}
35struct Cell: Codable, Sendable {
36 let r: Int
37 let c: Int
38 var raw: String
39 var display: String
40 var n: Bool?
41 var f: String?
42 var coordinate: Coordinate { Coordinate(r: r, c: c) }
43}
44struct CellStyle: Decodable, Sendable {
45 var b: Bool?
46 var i: Bool?
47 var a: String?
48 var n: String?
49 var fx: String?
50 var k: String?
51 var fh: Double?
52 var fc: Double?
53 var kh: Double?
54 var kc: Double?
55 var lc: Bool?
56}
57struct Sizes: Decodable, Sendable {
58 var cols: [String: Double]?
59 var rows: [String: Double]?
60}
61struct GridResponse: Decodable, Sendable {
62 let version: UInt64
63 var rows: Int?
64 var cols: Int?
65 var cells: [Cell]?
66 var formats: [String: CellStyle]?
67 var sizes: Sizes?
68 var resync: Bool?
69 /// Versions the write behind this response consumed: 1 for a cell, N
70 /// for an N-cell batch, absent for format, size and snapshot responses
71 /// (server grid.go gridResponse.Stamps). See SheetModel.accept.
72 var stamps: Int?
73}
74struct CellWrite: Encodable, Sendable {
75 let r: Int
76 let c: Int
77 let raw: String
78 var fromR: Int?
79 var fromC: Int?
80}
81struct Notice: Decodable {
82 let notice: String
83 let message: String
84}
85struct HistoryEntry: Decodable, Identifiable {
86 let ID: UInt64
87 let Ref: String
88 let Who: String
89 let Old: String
90 let New: String
91 let When: String
92 var id: UInt64 { self.ID }
93}
94struct HistoryPage: Decodable { let Entries: [HistoryEntry]? }
95struct ViewSpec: Codable {
96 var sortCol = -1
97 var sortDesc = false
98 var filterCol = -1
99 var filterOp = "contains"
100 var filterVal = ""
101}
102struct TableCell: Decodable {
103 let R: Int
104 let C: Int
105 let Raw: String
106 let Display: String
107}
108struct TableRow: Decodable {
109 let Number: Int
110 let Cells: [TableCell]
111}
112struct TablePage: Decodable {
113 let View: ViewSpec
114 let Rows: [TableRow]?
115 let HasNext: Bool
116 let HasPrev: Bool
117}
118