import Foundation struct SheetSummary: Decodable, Identifiable, Hashable, Sendable { let ID: UInt64 let Title: String let TabID: UInt64 let TabName: String var Preview: SheetPreview? = nil var id: UInt64 { self.ID } } struct SheetList: Decodable { let Sheets: [SheetSummary]? } struct PaletteItem: Decodable, Identifiable { let Name: String let Label: String var id: String { Name } } struct NumberStyle: Decodable, Identifiable { let Code: String let Label: String var id: String { Code } } struct SheetPage: Decodable { let Sheet: SheetSummary let Rows: Int let Cols: Int let Truncated: Bool let MayWrite: Bool let MayComment: Bool let MayShare: Bool let FillSwatches: [PaletteItem] let InkSwatches: [PaletteItem] let NumberFormats: [NumberStyle] let Warned: [String]? } struct Cell: Codable, Sendable { let r: Int let c: Int var raw: String var display: String var n: Bool? var f: String? var coordinate: Coordinate { Coordinate(r: r, c: c) } } struct CellStyle: Decodable, Sendable { var b: Bool? var i: Bool? var a: String? var n: String? var fx: String? var k: String? var fh: Double? var fc: Double? var kh: Double? var kc: Double? var lc: Bool? } struct Sizes: Decodable, Sendable { var cols: [String: Double]? var rows: [String: Double]? } struct GridResponse: Decodable, Sendable { let version: UInt64 var rows: Int? var cols: Int? var cells: [Cell]? var formats: [String: CellStyle]? var sizes: Sizes? var resync: Bool? /// Versions the write behind this response consumed: 1 for a cell, N /// for an N-cell batch, absent for format, size and snapshot responses /// (server grid.go gridResponse.Stamps). See SheetModel.accept. var stamps: Int? } struct CellWrite: Encodable, Sendable { let r: Int let c: Int let raw: String var fromR: Int? var fromC: Int? } struct Notice: Decodable { let notice: String let message: String } struct HistoryEntry: Decodable, Identifiable { let ID: UInt64 let Ref: String let Who: String let Old: String let New: String let When: String var id: UInt64 { self.ID } } struct HistoryPage: Decodable { let Entries: [HistoryEntry]? } struct ViewSpec: Codable { var sortCol = -1 var sortDesc = false var filterCol = -1 var filterOp = "contains" var filterVal = "" } struct TableCell: Decodable { let R: Int let C: Int let Raw: String let Display: String } struct TableRow: Decodable { let Number: Int let Cells: [TableCell] } struct TablePage: Decodable { let View: ViewSpec let Rows: [TableRow]? let HasNext: Bool let HasPrev: Bool }