// CONTRACT record-page v1: `parts` beside the existing `page` section array. import Foundation /// One part of a record's page, from the fixed vocabulary the app draws /// (architect, 13 Oct 2026; cotton-core `parts::PagePart`): a definition's /// `page_parts` names its parts in order, and a layout is its list — never a /// style keyed in Swift. A new layout is a new part kind, built once. public typealias PagePart = DefinitionPagePart extension DefinitionPagePart { /// The parts of a page whose definition names none (cotton-core /// `PLAIN_PAGE`): drawn only for a definition the core did not hand over. public static let plain: [PagePart] = [.title, .facts, .grid, .content, .sections] } /// One table's page as the core resolved it (`definitions.catalogue`'s /// `pages`, cotton-ffi `catalogue::Page`): the parts the app draws, their /// defaults dealt by the core's `resolved_parts`, in the order its /// `resolved_page_parts` gives. The app draws this and derives no page of its /// own — a second derivation would be a second truth, as a second decoder is. public typealias DrawnPage = DefinitionPage /// A record page's parts as the core resolved them (cotton-core /// `parts::PageParts`): the head's facts, the links, the body, the lists, the /// acts, the hand (`cards`) and the strip. public typealias PageParts = DefinitionPageParts extension DefinitionPageParts { /// The record's stamps: said on the facts line under the title, never a /// card (architect, r6; cotton-core `parts::STAMPS`). public static let stamps: Set = ["created_at", "updated_at", "trashed_at"] public typealias Shape = DefinitionPageShape public typealias Head = DefinitionPartsHead /// A list over another table by its link back (`table` + `relation`), by /// value (`table` + `match`), or over an allowlisted screen read (`read`); /// its `face` draws what is tagged to the record as slips (absent), notes /// as paper, or photos as polaroids. public typealias List = DefinitionPartsList public typealias ListFace = DefinitionListFace /// `table`'s records whose `column` equals this record's `parent` value. public typealias Match = DefinitionPartsMatch /// `read.` with `bindings` from the record; `rows` is the answer's /// array, `id`/`title`/`trailing` a row's fields. public typealias Read = DefinitionPartsRead /// A card of the hand or the strip: a field (`column`) or, on the strip, /// an act (`act`); `width` is how much of the sheet's row it takes, `object` /// names a field card's object where its type would draw another, and /// `stock` its paper where the definition names one (otherwise its kind's, /// cream, or the linked tool's). public typealias Card = DefinitionPartsCard public typealias Acts = DefinitionPartsActs public init( shape: Shape, head: Head, links: [String], body: String? = nil, lists: [List], acts: Acts, cards: [Card]? = nil, strip: [Card]? = nil ) { self.init(_generated: (), shape: shape, head: head, links: links, lists: lists, acts: acts) self.body = body self.cards = cards self.strip = strip } } extension DefinitionPartsHead { public init(facts: [String], state: String? = nil) { self.init(_generated: (), facts: facts) self.state = state } } extension DefinitionPartsActs { public init(main: String? = nil, more: [String], away: String? = nil) { self.init(_generated: (), more: more) self.main = main self.away = away } } extension TableDefinition { /// The page's parts: the core's resolved parts; for a definition the core /// did not hand over, the parts it names, else none — a title alone. The /// app deals no hand of its own. public var resolvedParts: PageParts { drawnPage?.parts ?? parts ?? PageParts( shape: .sheet, head: .init(facts: [], state: nil), links: [], body: nil, lists: [], acts: .init(main: nil, more: [], away: nil)) } } extension DefinitionPartsList { public init( table: String? = nil, relation: String? = nil, heading: String? = nil, mainAct: String? = nil, read: PageParts.Read? = nil, matching: PageParts.Match? = nil, face: PageParts.ListFace? = nil ) { self.init(_generated: ()) self.table = table self.relation = relation self.heading = heading self.mainAct = mainAct self.read = read self.matching = matching self.face = face } } extension DefinitionPartsCard { public init(column: String? = nil, act: String? = nil, width: DefinitionSlipWidth? = nil, object: String? = nil) { self.init(_generated: ()) self.column = column self.act = act self.width = width self.object = object } }