// // SyncedStorable.swift // LeStorage // // Created by Laurent Morvillier on 11/10/2024. // import Foundation public protocol SyncedStorable: Storable { var lastUpdate: Date { get set } /// Returns HTTP methods that do not need to pass the token to the request static func tokenExemptedMethods() -> [HTTPMethod] /// A method called to retrieve data added by the server on a POST request /// The method will be called after a POST has succeeded, /// and will provide a copy of what's on the server /// Should return true to trigger a write on the collection, or false if nothing changed func copyFromServerInstance(_ instance: any Storable) -> Bool } public protocol SideStorable { var storeId: String? { get set } } extension SyncedStorable { func getStoreId() -> String? { if let alt = self as? SideStorable { return alt.storeId } return nil } }