// // shortcut // // Created by Bailey Townsend on 6/29/25. // import ATProtoKit import AppIntents import Foundation struct RecordAppEntity: TransientAppEntity, Codable { /// The URI for the record. @Property(title: "Record's URI") public var uri: String /// The CID hash for the record. @Property(title: "Record's CID") public var cid: String /// Can change output from the variable to dictionary in shortcuts @Property(title: "Value") var value: IntentFile? var id: String { uri } static var typeDisplayName: LocalizedStringResource = "Record" static var typeDescription: LocalizedStringResource? = "Response from a PDS when you get a record" var displayRepresentation: AppIntents.DisplayRepresentation { var anonymousObject: [String: CodableValue] = [ "uri": CodableValue(stringLiteral: self.uri), "cid": CodableValue(stringLiteral: self.cid), ] do { if let valueData = self.value?.data { let decoder = JSONDecoder() anonymousObject["value"] = try decoder.decode( CodableValue.self, from: valueData) } guard let fullJsonData = try anonymousObject.toJsonData() else { throw GenericIntentError.general } let jsonString = String(data: fullJsonData, encoding: .utf8) ?? "" return DisplayRepresentation(title: "\(jsonString)") } catch { return DisplayRepresentation( title: "uri: \(uri)\n recordCID:\(cid)") } } static var typeDisplayRepresentation: TypeDisplayRepresentation { TypeDisplayRepresentation( name: LocalizedStringResource("ATProtocol Record", table: "AppIntents") ) } }