From 5e922f5bd8821c2af1ea47541bace4a94d1a2399 Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Thu, 16 May 2024 02:50:24 -0400 Subject: [PATCH 01/51] Add main lexicon files This is the beginning of the lexicon model re-structure. --- .../ATProtoKit/Models/Lexicons/Lexicons.swift | 20 +++++++++++ .../Lexicons/app.bsky/AppBskyLexicon.swift | 33 +++++++++++++++++++ .../Lexicons/chat.bsky/ChatBskyLexicon.swift | 20 +++++++++++ .../com.atproto/ComAtprotoLexicon.swift | 32 ++++++++++++++++++ .../tools.ozone/ToolsOzoneLexicon.swift | 17 ++++++++++ 5 files changed, 122 insertions(+) create mode 100644 Sources/ATProtoKit/Models/Lexicons/Lexicons.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/AppBskyLexicon.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/chat.bsky/ChatBskyLexicon.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/ComAtprotoLexicon.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/tools.ozone/ToolsOzoneLexicon.swift diff --git a/Sources/ATProtoKit/Models/Lexicons/Lexicons.swift b/Sources/ATProtoKit/Models/Lexicons/Lexicons.swift new file mode 100644 index 0000000000..edb3467f9c --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/Lexicons.swift @@ -0,0 +1,20 @@ +// +// Lexicons.swift +// +// +// Created by Christopher Jr Riley on 2024-05-16. +// + +import Foundation + +/// A group of lexicons within the `app.bsky` namespace. +public struct AppBskyLexicon {} + +/// A group of lexicons within the `com.atproto` namespace. +public struct ComAtprotoLexicon {} + +/// A group of lexicons within the `chat.bsky` namespace. +public struct ChatBskyLexicon {} + +/// A group of lexicons within the `tools.ozone` namespace. +public struct ToolsOzoneLexicon {} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/AppBskyLexicon.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/AppBskyLexicon.swift new file mode 100644 index 0000000000..3825365bed --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/AppBskyLexicon.swift @@ -0,0 +1,33 @@ +// +// AppBskyLexicon.swift +// +// +// Created by Christopher Jr Riley on 2024-05-16. +// + +import Foundation + + +extension AppBskyLexicon { + + /// + public struct Actor {} + + /// + public struct Embed {} + + /// + public struct Feed {} + + /// + public struct Graph {} + + /// + public struct Labeler {} + + /// + public struct Notification {} + + /// + public struct Unspecced {} +} diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/ChatBskyLexicon.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/ChatBskyLexicon.swift new file mode 100644 index 0000000000..943ddfbaff --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/ChatBskyLexicon.swift @@ -0,0 +1,20 @@ +// +// ChatBskyLexicon.swift +// +// +// Created by Christopher Jr Riley on 2024-05-16. +// + +import Foundation + +extension ChatBskyLexicon { + + /// + public struct Actor {} + + /// + public struct Convo {} + + /// + public struct Moderation {} +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/ComAtprotoLexicon.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/ComAtprotoLexicon.swift new file mode 100644 index 0000000000..8b23866f96 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/ComAtprotoLexicon.swift @@ -0,0 +1,32 @@ +// +// ComAtprotoLexicon.swift +// +// +// Created by Christopher Jr Riley on 2024-05-16. +// + +import Foundation + +extension ComAtprotoLexicon { + + /// + public struct Admin {} + + /// + public struct Identity {} + + /// + public struct Label {} + + /// + public struct Moderation {} + + /// + public struct Repo {} + + /// + public struct Server {} + + /// + public struct Temp {} +} diff --git a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/ToolsOzoneLexicon.swift b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/ToolsOzoneLexicon.swift new file mode 100644 index 0000000000..10f25fcb31 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/ToolsOzoneLexicon.swift @@ -0,0 +1,17 @@ +// +// ToolsOzoneLexicon.swift +// +// +// Created by Christopher Jr Riley on 2024-05-16. +// + +import Foundation + +extension ToolsOzoneLexicon { + + /// + public struct Communication {} + + /// + public struct Moderation {} +} From 0e1c9a2205a3c5d992e0fd1ae3ae3e61d6518b40 Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Thu, 16 May 2024 03:04:16 -0400 Subject: [PATCH 02/51] Add documentation and lengthen names --- .../Lexicons/app.bsky/AppBskyLexicon.swift | 14 +++++++------- .../Lexicons/chat.bsky/ChatBskyLexicon.swift | 8 ++++---- .../Lexicons/com.atproto/ComAtprotoLexicon.swift | 16 ++++++++-------- .../Lexicons/tools.ozone/ToolsOzoneLexicon.swift | 4 ++-- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/AppBskyLexicon.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/AppBskyLexicon.swift index 3825365bed..b3b95dfbc8 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/AppBskyLexicon.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/AppBskyLexicon.swift @@ -10,24 +10,24 @@ import Foundation extension AppBskyLexicon { - /// + /// A group of lexicons within the `app.bsky.actor` namespace. public struct Actor {} - /// + /// A group of lexicons within the `app.bsky.embed` namespace. public struct Embed {} - /// + /// A group of lexicons within the `app.bsky.feed` namespace. public struct Feed {} - /// + /// A group of lexicons within the `app.bsky.graph` namespace. public struct Graph {} - /// + /// A group of lexicons within the `app.bsky.labeler` namespace. public struct Labeler {} - /// + /// A group of lexicons within the `app.bsky.notification` namespace. public struct Notification {} - /// + /// A group of lexicons within the `app.bsky.unspecced` namespace. public struct Unspecced {} } diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/ChatBskyLexicon.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/ChatBskyLexicon.swift index 943ddfbaff..54d829c12a 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/ChatBskyLexicon.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/ChatBskyLexicon.swift @@ -9,12 +9,12 @@ import Foundation extension ChatBskyLexicon { - /// + /// A group of lexicons within the `chat.bsky.actor` namespace. public struct Actor {} - /// - public struct Convo {} + /// A group of lexicons within the `chat.bsky.convo` namespace. + public struct Conversation {} - /// + /// A group of lexicons within the `chat.bsky.moderation` namespace. public struct Moderation {} } diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/ComAtprotoLexicon.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/ComAtprotoLexicon.swift index 8b23866f96..9277f8d1e4 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/ComAtprotoLexicon.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/ComAtprotoLexicon.swift @@ -9,24 +9,24 @@ import Foundation extension ComAtprotoLexicon { - /// + /// A group of lexicons within the `com.atproto.admin` namespace. public struct Admin {} - /// + /// A group of lexicons within the `com.atproto.identity` namespace. public struct Identity {} - /// + /// A group of lexicons within the `com.atproto.label` namespace. public struct Label {} - /// + /// A group of lexicons within the `com.atproto.moderation` namespace. public struct Moderation {} - /// - public struct Repo {} + /// A group of lexicons within the `com.atproto.repository` namespace. + public struct Repository {} - /// + /// A group of lexicons within the `com.atproto.server` namespace. public struct Server {} - /// + /// A group of lexicons within the `com.atproto.temp` namespace. public struct Temp {} } diff --git a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/ToolsOzoneLexicon.swift b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/ToolsOzoneLexicon.swift index 10f25fcb31..f303d1af33 100644 --- a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/ToolsOzoneLexicon.swift +++ b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/ToolsOzoneLexicon.swift @@ -9,9 +9,9 @@ import Foundation extension ToolsOzoneLexicon { - /// + /// A group of lexicons within the `tools.ozone.communication` namespace. public struct Communication {} - /// + /// A group of lexicons within the `tools.ozone.moderation` namespace. public struct Moderation {} } From 0e5b219ac9dcf37a89604d9ea5426d5b2ec6cdfb Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Thu, 16 May 2024 03:20:08 -0400 Subject: [PATCH 03/51] Fix documentation Corrected the namespace. --- .../Models/Lexicons/com.atproto/ComAtprotoLexicon.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/ComAtprotoLexicon.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/ComAtprotoLexicon.swift index 9277f8d1e4..13a0466518 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/ComAtprotoLexicon.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/ComAtprotoLexicon.swift @@ -21,7 +21,7 @@ extension ComAtprotoLexicon { /// A group of lexicons within the `com.atproto.moderation` namespace. public struct Moderation {} - /// A group of lexicons within the `com.atproto.repository` namespace. + /// A group of lexicons within the `com.atproto.repo` namespace. public struct Repository {} /// A group of lexicons within the `com.atproto.server` namespace. From 6df4dbb62dec82bb12843df11341ef352608f20f Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Fri, 17 May 2024 14:19:57 -0400 Subject: [PATCH 04/51] Convert lexicons to new layout The following have been converted: - app.bsky.actor.* - app.bsky.embed.* --- .../app.bsky/Actor/AppBskyActorDefs.swift | 929 ++++++++++++++++++ .../Actor/AppBskyActorGetPreferences.swift | 24 + .../Actor/AppBskyActorGetProfile.swift | 25 + .../Actor/AppBskyActorGetProfiles.swift | 25 + .../Actor/AppBskyActorGetSuggestions.swift | 27 + .../app.bsky/Actor/AppBskyActorProfile.swift | 58 ++ .../Actor/AppBskyActorPutPreferences.swift | 27 + .../Actor/AppBskyActorSearchActors.swift | 26 + .../AppBskyActorSearchActorsTypeahead.swift | 22 + .../app.bsky/Embed/AppBskyEmbedExternal.swift | 109 ++ .../app.bsky/Embed/AppBskyEmbedImages.swift | 159 +++ .../app.bsky/Embed/AppBskyEmbedRecord.swift | 203 ++++ .../Embed/AppBskyEmbedRecordWithMedia.swift | 66 ++ 13 files changed, 1700 insertions(+) create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorDefs.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorGetPreferences.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorGetProfile.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorGetProfiles.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorGetSuggestions.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorProfile.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorPutPreferences.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorSearchActors.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorSearchActorsTypeahead.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedExternal.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedImages.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedRecord.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedRecordWithMedia.swift diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorDefs.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorDefs.swift new file mode 100644 index 0000000000..4bcf9c4b39 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorDefs.swift @@ -0,0 +1,929 @@ +// +// AppBskyActorDefs.swift +// +// +// Created by Christopher Jr Riley on 2024-05-16. +// + +import Foundation + +extension AppBskyLexicon.Actor { + + /// A data model for a basic profile view definition. + /// + /// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/defs.json + public struct ProfileViewBasicDefinition: Codable { + + /// The decentralized identifier (DID) of the user. + public let actorDID: String + + /// The unique handle of the user. + public let actorHandle: String + + /// The display name of the user. Optional. + /// + /// - Important: Current maximum length is 64 characters. + public let displayName: String? + + /// The avatar image URL of the user's profile. Optional. + public let avatarImageURL: URL? + + /// The associated profile view. Optional. + public let associated: ProfileAssociatedDefinition? + + /// The list of metadata relating to the requesting account's relationship with the subject + /// account. Optional. + public let viewer: ViewerStateDefinition? + + /// An array of labels created by the user. Optional. + public let labels: [Label]? + + public init(actorDID: String, actorHandle: String, displayName: String?, avatarImageURL: URL?, associated: ProfileAssociatedDefinition?, + viewer: ViewerStateDefinition?, labels: [Label]?) { + self.actorDID = actorDID + self.actorHandle = actorHandle + self.displayName = displayName + self.avatarImageURL = avatarImageURL + self.associated = associated + self.viewer = viewer + self.labels = labels + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.actorDID = try container.decode(String.self, forKey: .actorDID) + self.actorHandle = try container.decode(String.self, forKey: .actorHandle) + self.displayName = try container.decodeIfPresent(String.self, forKey: .displayName) + self.avatarImageURL = try container.decodeIfPresent(URL.self, forKey: .avatarImageURL) + self.associated = try container.decodeIfPresent(ProfileAssociatedDefinition.self, forKey: .associated) + self.viewer = try container.decodeIfPresent(ViewerStateDefinition.self, forKey: .viewer) + self.labels = try container.decodeIfPresent([Label].self, forKey: .labels) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.actorDID, forKey: .actorDID) + try container.encode(self.actorHandle, forKey: .actorHandle) + + // Truncate `displayName` to 640 characters before encoding + // `maxGraphemes`'s limit is 64, but `String.count` should respect that limit implictly + try truncatedEncodeIfPresent(self.displayName, withContainer: &container, forKey: .displayName, upToLength: 640) + try container.encodeIfPresent(self.avatarImageURL, forKey: .avatarImageURL) + try container.encodeIfPresent(self.associated, forKey: .associated) + try container.encodeIfPresent(self.viewer, forKey: .viewer) + try container.encodeIfPresent(self.labels, forKey: .labels) + } + + enum CodingKeys: String, CodingKey { + case actorDID = "did" + case actorHandle = "handle" + case displayName + case avatarImageURL = "avatar" + case associated + case viewer + case labels + } + } + + /// A data model for a profile view definition. + /// + /// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/defs.json + public struct ProfileViewDefinition: Codable { + + /// The decentralized identifier (DID) of the user. + public let actorDID: String + + /// The unique handle of the user. + public let actorHandle: String + + /// The display name of the user's profile. Optional. + /// + /// - Important: Current maximum length is 64 characters. + public var displayName: String? + + /// The description of the user's profile. Optional. + /// + /// - Important: Current maximum length is 256 characters. + public var description: String? + + /// The avatar image URL of a user's profile. Optional. + public let avatarImageURL: URL? + + /// The associated profile view. Optional. + public var associated: ProfileAssociatedDefinition? + + /// The date the profile was last indexed. Optional. + @DateFormattingOptional public var indexedAt: Date? + + /// The list of metadata relating to the requesting account's relationship with the subject + /// account. Optional. + public var viewer: ViewerStateDefinition? + + /// An array of labels created by the user. Optional. + public var labels: [Label]? = nil + + public init(actorDID: String, actorHandle: String, displayName: String?, description: String?, avatarImageURL: URL?, associated: ProfileAssociatedDefinition?, + indexedAt: Date?, viewer: ViewerStateDefinition?, labels: [Label]?) { + self.actorDID = actorDID + self.actorHandle = actorHandle + self.displayName = displayName + self.description = description + self.avatarImageURL = avatarImageURL + self.associated = associated + self._indexedAt = DateFormattingOptional(wrappedValue: indexedAt) + self.viewer = viewer + self.labels = labels + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.actorDID = try container.decode(String.self, forKey: .actorDID) + self.actorHandle = try container.decode(String.self, forKey: .actorHandle) + self.displayName = try container.decodeIfPresent(String.self, forKey: .displayName) + self.description = try container.decodeIfPresent(String.self, forKey: .description) + self.avatarImageURL = try container.decodeIfPresent(URL.self, forKey: .avatarImageURL) + self.associated = try container.decodeIfPresent(ProfileAssociatedDefinition.self, forKey: .associated) + self.indexedAt = try container.decodeIfPresent(DateFormattingOptional.self, forKey: .indexedAt)?.wrappedValue + self.viewer = try container.decodeIfPresent(ViewerStateDefinition.self, forKey: .viewer) + self.labels = try container.decodeIfPresent([Label].self, forKey: .labels) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.actorDID, forKey: .actorDID) + try container.encode(self.actorHandle, forKey: .actorHandle) + + // Truncate `displayName` to 640 characters before encoding + // `maxGraphemes`'s limit is 64, but `String.count` should respect that limit implictly + try truncatedEncodeIfPresent(self.displayName, withContainer: &container, forKey: .displayName, upToLength: 640) + + // Truncate `description` to 2560 characters before encoding + // `maxGraphemes`'s limit is 256, but `String.count` should respect that limit + try truncatedEncodeIfPresent(self.description, withContainer: &container, forKey: .description, upToLength: 2560) + try container.encodeIfPresent(self.avatarImageURL, forKey: .avatarImageURL) + try container.encodeIfPresent(self.associated, forKey: .associated) + try container.encodeIfPresent(self._indexedAt, forKey: .indexedAt) + try container.encodeIfPresent(self.viewer, forKey: .viewer) + try container.encodeIfPresent(self.labels, forKey: .labels) + } + + enum CodingKeys: String, CodingKey { + case actorDID = "did" + case actorHandle = "handle" + case displayName + case description + case avatarImageURL = "avatar" + case associated + case indexedAt + case viewer + case labels + } + } + + /// A data model for a detailed profile view definition. + /// + /// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/defs.json + public struct ProfileViewDetailedDefinition: Codable { + + /// The decentralized identifier (DID) of the user. + public let actorDID: String + + /// The unique handle of the user. + public let actorHandle: String + + /// The display name of the user's profile. Optional. + /// + /// - Important: Current maximum length is 64 characters. + public var displayName: String? + + /// The description of the user's profile. Optional. + /// + /// - Important: Current maximum length is 256 characters. + public var description: String? + + /// The avatar image URL of a user's profile. Optional. + public var avatarImageURL: URL? + + /// The banner image URL of a user's profile. Optional. + public var bannerImageURL: URL? + + /// The number of followers a user has. Optional. + public var followerCount: Int? + + /// The number of accounts the user follows. Optional. + public var followCount: Int? + + /// The number of posts the user has. Optional. + public var postCount: Int? + + /// The associated profile view. Optional. + public let associated: ProfileAssociatedDefinition? + + /// The date the profile was last indexed. Optional. + @DateFormattingOptional public var indexedAt: Date? + + /// The list of metadata relating to the requesting account's relationship with the subject + /// account. Optional. + public var viewer: ViewerStateDefinition? + + /// An array of labels created by the user. Optional. + public var labels: [Label]? + + public init(actorDID: String, actorHandle: String, displayName: String?, description: String?, avatarImageURL: URL?, bannerImageURL: URL?, + followerCount: Int?, followCount: Int?, postCount: Int?, associated: ProfileAssociatedDefinition?, indexedAt: Date?, viewer: ViewerStateDefinition?, labels: [Label]?) { + self.actorDID = actorDID + self.actorHandle = actorHandle + self.displayName = displayName + self.description = description + self.avatarImageURL = avatarImageURL + self.bannerImageURL = bannerImageURL + self.followerCount = followerCount + self.followCount = followCount + self.postCount = postCount + self.associated = associated + self._indexedAt = DateFormattingOptional(wrappedValue: indexedAt) + self.viewer = viewer + self.labels = labels + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.actorDID = try container.decode(String.self, forKey: .actorDID) + self.actorHandle = try container.decode(String.self, forKey: .actorHandle) + self.displayName = try container.decodeIfPresent(String.self, forKey: .displayName) + self.description = try container.decodeIfPresent(String.self, forKey: .description) + self.avatarImageURL = try container.decodeIfPresent(URL.self, forKey: .avatarImageURL) + self.bannerImageURL = try container.decodeIfPresent(URL.self, forKey: .bannerImageURL) + self.followerCount = try container.decodeIfPresent(Int.self, forKey: .followerCount) + self.followCount = try container.decodeIfPresent(Int.self, forKey: .followCount) + self.postCount = try container.decodeIfPresent(Int.self, forKey: .postCount) + self.associated = try container.decodeIfPresent(ProfileAssociatedDefinition.self, forKey: .associated) + self.indexedAt = try container.decodeIfPresent(DateFormattingOptional.self, forKey: .indexedAt)?.wrappedValue + self.viewer = try container.decodeIfPresent(ViewerStateDefinition.self, forKey: .viewer) + self.labels = try container.decodeIfPresent([Label].self, forKey: .labels) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.actorDID, forKey: .actorDID) + try container.encode(self.actorHandle, forKey: .actorHandle) + + // Truncate `displayName` to 640 characters before encoding + // `maxGraphemes`'s limit is 64, but `String.count` should respect that limit implictly + try truncatedEncodeIfPresent(self.displayName, withContainer: &container, forKey: .displayName, upToLength: 640) + + // Truncate `description` to 2560 characters before decoding + // `maxGraphemes`'s limit is 256, but `String.count` should respect that limit + try truncatedEncodeIfPresent(self.description, withContainer: &container, forKey: .description, upToLength: 2560) + try container.encodeIfPresent(self.avatarImageURL, forKey: .avatarImageURL) + try container.encodeIfPresent(self.bannerImageURL, forKey: .bannerImageURL) + try container.encodeIfPresent(self.followerCount, forKey: .followerCount) + try container.encodeIfPresent(self.followCount, forKey: .followCount) + try container.encodeIfPresent(self.postCount, forKey: .postCount) + try container.encodeIfPresent(self.associated, forKey: .associated) + try container.encodeIfPresent(self._indexedAt, forKey: .indexedAt) + try container.encodeIfPresent(self.viewer, forKey: .viewer) + try container.encodeIfPresent(self.labels, forKey: .labels) + } + + enum CodingKeys: String, CodingKey { + case actorDID = "did" + case actorHandle = "handle" + case displayName + case description + case avatarImageURL = "avatar" + case bannerImageURL = "banner" + case followerCount = "followersCount" + case followCount = "followsCount" + case postCount = "postsCount" + case associated + case indexedAt + case viewer + case labels + } + } + + /// A data model definition for an actor's associated profile. + /// + /// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/defs.json + public struct ProfileAssociatedDefinition: Codable { + /// The number of lists associated with the user. Optional. + public let lists: Int? + /// The number of feed generators associated with the user. Optional. + public let feedGenerators: Int? + /// Indicates whether the user account is a labeler. Optional. + public let isActorLabeler: Bool? + + enum CodingKeys: String, CodingKey { + case lists + case feedGenerators = "feedgens" + case isActorLabeler = "labeler" + } + } + + /// A data model for an actor viewer state definition. + /// + /// - Note: From the AT Protocol specification: "Metadata about the requesting account's + /// relationship with the subject account. Only has meaningful content for authed requests." + /// + /// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/defs.json + public struct ViewerStateDefinition: Codable { + + /// Indicates whether the requesting account has been muted by the subject + /// account. Optional. + public let isMuted: Bool? + + /// An array of lists that the subject account is muted by. + public let mutedByArray: GraphListViewBasic? + + /// Indicates whether the requesting account has been blocked by the subject + /// account. Optional. + public let isBlocked: Bool? + + /// A URI which indicates the user has blocked the requesting account. + public let blockingURI: String? + + /// An array of the subject account's lists. + public let blockingByArray: GraphListViewBasic? + + /// A URI which indicates the user is following the requesting account. + public let followingURI: String? + + /// A URI which indicates the user is being followed by the requesting account. + public let followedByURI: String? + + enum CodingKeys: String, CodingKey { + case isMuted = "muted" + case mutedByArray = "mutedByList" + case isBlocked = "blockedBy" + case blockingURI = "blocking" + case blockingByArray = "blockingByList" + case followingURI = "following" + case followedByURI = "followedBy" + } + } + + /// A data model for a preferences definition. + /// + /// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/defs.json + public struct PreferencesDefinition: Codable { + + /// An array of different preferences the user can set. + public let preferences: [ActorPreferenceUnion] + + public init(preferences: [ActorPreferenceUnion]) { + self.preferences = preferences + } + } + + /// A data model for an "Adult Content" preference definition. + /// + /// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/defs.json + public struct AdultContentPreferencesDefinition: Codable { + + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. + public let type: String = "app.bsky.actor.defs#adultContentPref" + /// Indicates whether the user will be able to see adult content in their feed. Set to + /// `false` by default. + public var isAdultContentEnabled: Bool = false + + public init(isAdultContentEnabled: Bool) { + self.isAdultContentEnabled = isAdultContentEnabled + } + + enum CodingKeys: String, CodingKey { + case type = "$type" + case isAdultContentEnabled = "enabled" + } + } + + /// A data model for a "Content Label" preference definition. + /// + /// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/defs.json + public struct ContentLabelPreferencesDefinition: Codable { + + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. + public let type: String = "app.bsky.actor.defs#contentLabelPref" + + /// The decentralized identifier of the labeler that this preference applies to. + /// + /// - Note: If this field is empty, then the preferences apply to all labels. + /// + /// - Note: According to the AT Protocol specifications: "Which labeler does this + /// preference apply to? If undefined, applies globally." + public let labelerDID: String? + + /// The name of the content label. + public let label: String + + /// Indicates the visibility of the label's content. + public let visibility: Visibility + + public init(labelerDID: String?, label: String, visibility: Visibility) { + self.labelerDID = labelerDID + self.label = label + self.visibility = visibility + } + /// Determines how visible a label's content is. + public enum Visibility: String, Codable { + + /// Indicates the content can be ignored. + case ignore = "ignore" + + /// Indicates the content can be seen without restriction. + case show = "show" + + /// Indicates the content can be seen, but will ask if the user wants to view it. + case warn = "warn" + + /// Indicates the content is fully invisible by the user. + case hide = "hide" + } + + enum CodingKeys: String, CodingKey { + case type = "$type" + case labelerDID = "labelerDid" + case label + case visibility + } + } + + /// The data model for a saved feed. + /// + /// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/defs.json + public struct SavedFeed: Codable { + + /// + public let feedID: String + + /// The type of feed generator is. + /// + /// This is usually referring to the location of the feed in context to the + /// user account's choice of placement within Bluesky. + public let type: FeedType + + /// The value of the saved feed generator. + public let value: String + + /// Indicated whether the saved feed generator is pinned. + public let isPinned: Bool + + + /// The type of feed generator. + /// + /// This is usually referring to the location of the feed in context to the + /// user account's choice of placement within Bluesky. + public enum FeedType: String, Codable { + + /// Indicates the feed generator resides only in the "Feeds" section of Bluesky. + case feed + + /// Indicates the feed generator additionally resides in a list. + case list + + /// Indicates the feed generator additionally resides within the + /// user account's timeline. + case timeline + } + + enum CodingKeys: String, CodingKey { + case feedID = "id" + case type + case value + case isPinned = "pinned" + } + } + + /// A data model for version 2 of a "Saved Feeds" preference definition. + /// + /// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/defs.json + public struct SavedFeedPreferencesVersion2Definition: Codable { + + /// An array of saved feed generators. + public let items: SavedFeed + } + + /// A data model for a "Saved Feeds" preference definition. + /// + /// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/defs.json + public struct SavedFeedsPreferencesDefinition: Codable { + + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. + public let type: String = "app.bsky.actor.defs#savedFeedsPref" + + /// An array of feed URIs that have been saved and pinned. + public let pinned: [String] + + /// An array of feed URIs that have been saved. + public let saved: [String] + + // TODO: Find out more about what this does. + /// The index number of the timeline for the list of feeds. Optional. + public var timelineIndex: Int? + + public init(pinned: [String], saved: [String], timelineIndex: Int?) { + self.pinned = pinned + self.saved = saved + self.timelineIndex = timelineIndex + } + + enum CodingKeys: String, CodingKey { + case type = "$type" + case pinned + case saved + case timelineIndex + } + } + + /// A data model for a "Personal Details" preference definition. + /// + /// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/defs.json + public struct PersonalDetailsPreferencesDefinition: Codable { + + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. + public let type: String = "app.bsky.actor.defs#personalDetailsPref" + + /// The birth date of the user. Optional. + /// + /// - Note: From the AT Protocol specification: "The birth date of account owner." + @DateFormattingOptional public var birthDate: Date? + + public init(birthDate: Date) { + self._birthDate = DateFormattingOptional(wrappedValue: birthDate) + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.birthDate = try container.decodeIfPresent(DateFormattingOptional.self, forKey: .birthDate)?.wrappedValue + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encodeIfPresent(self._birthDate, forKey: .birthDate) + } + + enum CodingKeys: String, CodingKey { + case type = "$type" + case birthDate + } + } + + /// A data model for a "Feed View" preference definition. + /// + /// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/defs.json + public struct FeedViewPreferencesDefinition: Codable { + + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. + public let type: String = "app.bsky.actor.defs#feedViewPref" + + /// The feed's identifier (typically the URI). + /// + /// - Note:From the AT Protocol specification: "The URI of the feed, or an identifier + /// which describes the feed." + public let feedURI: String + + /// Indicates whether the replies are hidden from the user. Optional. + /// + /// - Note: From the AT Protocol specification: "Hide replies in the feed." + public let areRepliesHidden: Bool? + + /// Indicates whether replies from users you don't follow are hidden from the user. Optional. + /// + /// - Note: From the AT Protocol specification: "Hide replies in the feed if they are not + /// by followed users." + public let areUnfollowedRepliesHidden: Bool? + + /// Indicates how many likes a post needs in order for the user to see the + /// reply. Optional. + /// + /// - Note: From the AT Protocol specification: "Hide replies in the feed if they do not + /// have this number of likes." + public let hideRepliesByLikeCount: Int? + + /// Indicates whether reposts are hidden from the user. Optional. + /// + /// - Note: From the AT Protocol specification: "Hide reposts in the feed." + public let areRepostsHidden: Bool? + + /// Indicates whether quote posts are hidden from the user. Optional. + /// + /// - Note: From the AT Protocol specification: "Hide quote posts in the feed." + public let areQuotePostsHidden: Bool? + + enum CodingKeys: String, CodingKey { + case type = "$type" + case feedURI = "feed" + case areRepliesHidden = "hideReplies" + case areUnfollowedRepliesHidden = "hideRepliesByUnfollowed" + case hideRepliesByLikeCount + case areRepostsHidden = "hideReposts" + case areQuotePostsHidden = "hideQuotePosts" + } + } + + /// A data model for a "Thread View" preference definition. + /// + /// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/defs.json + public struct ThreadViewPreferencesDefinition: Codable { + + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. + public let type: String = "app.bsky.actor.defs#threadViewPref" + + /// The sorting mode of a thread. Optional. + /// + /// - Note: From the AT Protocol specification: "Sorting mode for threads." + public let sortingMode: SortingMode? + + /// Indicates whether users you follow are prioritized over other users. Optional. + /// + /// - Note: From the AT Protocol specification: "Show followed users at the top of + /// all replies." + public let areFollowedUsersPrioritized: Bool? + + /// The sorting mode for a thread. + public enum SortingMode: String, Codable { + + /// Indicates the thread will be sorted from the oldest post. + case oldest = "oldest" + + /// Indicates the thread will be sorted from the newest post. + case newest = "newest" + + /// Indicates the thread will be sorted from the posts with the most number + /// of likes. + case mostLikes = "most-likes" + + /// Indicates the thread will be completely random. + case random = "random" + } + + enum CodingKeys: String, CodingKey { + case type = "$type" + case sortingMode = "sort" + case areFollowedUsersPrioritized = "prioritizeFollowedUsers" + } + } + + /// A data model for an "Interest View" preference definition. + /// + /// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/defs.json + public struct InterestViewPreferencesDefinition: Codable { + + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. + public let type: String = "app.bsky.actor.defs#interestsPref" + + /// An array of interest tags. + /// + /// - Note: According to AT Protocol's specifications: "A list of tags which describe the + /// account owner's interests gathered during onboarding." + /// + /// - Important: Current maximum limit is 100 tags. Current maximum length for each tag + /// name is 64 characters. + public let tags: [String] + + public init(tags: [String]) { + self.tags = tags + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.tags = try container.decode([String].self, forKey: .tags) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + // Truncate `tags` to 640 characters before encoding. + // `maxGraphemes`'s limit is 64, but `String.count` should respect that limit implictly. + // Then, truncate `tags` to 100 items before encoding. + try truncatedEncode( + self.tags.map { $0.truncated(toLength: 640) }, + withContainer: &container, forKey: .tags, upToLength: 100) + } + + enum CodingKeys: String, CodingKey { + case type = "$type" + case tags + } + } + + /// A data model for a definition of the muted word's target. + /// + /// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/defs.json + public enum MutedWordTarget: Codable { + + /// Indicates the muted word is within the content itself. + case content + + /// Indicates the muted word is a tag. + case tag + + /// Indicates the muted word is located at an unknown area. + /// + /// This case shouldn't be used. If it does appear, then Bluesky may have updated + /// something that ATProtoKit doesn't yet recognize. + case other(String) + + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + + let value = try container.decode(String.self) + + switch value { + case "content": + self = .content + case "tag": + self = .tag + default: + self = .other(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + switch self { + case .content: + try container.encode("content") + case .tag: + try container.encode("tag") + case .other(let other): + // Truncate `other` to 640 characters before decoding + // `maxGraphemes`'s limit is 64, but `String.count` should respect that limit + let truncatedOther = other.truncated(toLength: 640) + try container.encode(truncatedOther) + } + } + } + + /// A data model for a muted word definition. + /// + /// - Note: According to the AT Protocol specifications: "A word that the account owner + /// has muted." + /// + /// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/defs.json + public struct MutedWord: Codable { + + /// The word to mute. + public let value: String + + /// An array of intended targets for the muted word. + public let targets: [MutedWordTarget] + + public init(value: String, targets: [MutedWordTarget]) { + self.value = value + self.targets = targets + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.value = try container.decode(String.self, forKey: .value) + self.targets = try container.decode([MutedWordTarget].self, forKey: .targets) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + // Truncate `value` to 1000 characters before decoding + // `maxGraphemes`'s limit is 100, but `String.count` should respect that limit + try truncatedEncode(self.value, withContainer: &container, forKey: .value, upToLength: 1000) + try container.encode(self.targets, forKey: .targets) + } + + enum CodingKeys: CodingKey { + case value + case targets + } + } + + /// A data model for a "Muted Words" preference definition. + /// + /// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/defs.json + public struct MutedWordsPreferencesDefinition: Codable { + + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. + public let type: String = "app.bsky.actor.defs#mutedWordsPref" + + /// An array of items the user has muted. + /// + /// - Note: According to the AT Protocol specifications: "A list of words the account + /// owner has muted." + public let mutedItems: [MutedWord] + + enum CodingKeys: String, CodingKey { + case type = "$type" + case mutedItems = "items" + } + } + + /// A data model for a "Hidden Posts" preference definition. + /// + /// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/defs.json + public struct HiddenPostsPreferencesDefinition: Codable { + + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. + public let type: String = "app.bsky.actor.defs#hiddenPostsPref" + + /// An array of URIs related to posts that the user wants to hide. + /// + /// - Note: According to the AT Protocol specifications: "A list of URIs of posts the + /// account owner has hidden." + public let items: [String] + + enum CodingKeys: String, CodingKey { + case type = "$type" + case items + } + } + + /// A data model for a "Labelers" preference definition. + /// + /// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/defs.json + public struct LabelersPreferencesDefinition: Codable { + + /// An array of labeler items. + public let labelers: [String] + } + + /// A data model definition for a labeler item. + /// + /// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/defs.json + public struct LabelersPreferenceItem: Codable { + + /// The decentralized identifier (DID) of the labeler. + public let labelerDID: String + + enum CodingKeys: String, CodingKey { + case labelerDID = "did" + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorGetPreferences.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorGetPreferences.swift new file mode 100644 index 0000000000..d6b957a045 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorGetPreferences.swift @@ -0,0 +1,24 @@ +// +// AppBskyActorGetPreferences.swift +// +// +// Created by Christopher Jr Riley on 2024-05-17. +// + +import Foundation + +extension AppBskyLexicon.Actor { + /// An output data model definition for the output of getting preferences. + /// + /// - Note: According to the AT Protocol specifications: "Get private preferences attached to + /// the current account. Expected use is synchronization between multiple devices, and + /// import/export during account migration. Requires auth." + /// + /// - SeeAlso: This is based on the [`app.bsky.actor.getPreferences`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/getPreferences.json + public struct GetPreferencesOutput: Codable { + /// The list of preferences in the user's account. + public let preference: PreferencesDefinition + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorGetProfile.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorGetProfile.swift new file mode 100644 index 0000000000..1f0425681f --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorGetProfile.swift @@ -0,0 +1,25 @@ +// +// AppBskyActorGetProfile.swift +// +// +// Created by Christopher Jr Riley on 2024-05-17. +// + +import Foundation + +extension AppBskyLexicon.Actor { + + /// A data model definition for the output for a detailed profile view for the user. + /// + /// - Note: According to the AT Protocol specifications: "Get detailed profile view of + /// an actor. Does not require auth, but contains relevant metadata with auth." + /// + /// - SeeAlso: This is based on the [`app.bsky.actor.getProfile`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/getProfile.json + public struct ActorGetProfileOutput: Codable { + + /// A detailed profile view of the user. + public let actorProfileView: ProfileViewDetailedDefinition + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorGetProfiles.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorGetProfiles.swift new file mode 100644 index 0000000000..ffcbd522fa --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorGetProfiles.swift @@ -0,0 +1,25 @@ +// +// AppBskyActorGetProfiles.swift +// +// +// Created by Christopher Jr Riley on 2024-05-17. +// + +import Foundation + +extension AppBskyLexicon.Actor { + + /// A data model definition for the output of detailed profile views for multiple users. + /// + /// - Note: According to the AT Protocol specifications: "Get detailed profile views of + /// multiple actors." + /// + /// - SeeAlso: This is based on the [`app.bsky.actor.getProfiles`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/getProfiles.json + public struct GetProfilesOutput: Codable { + + /// An array of detailed profile views for several users. + public let profiles: [ProfileViewDetailedDefinition] + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorGetSuggestions.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorGetSuggestions.swift new file mode 100644 index 0000000000..21833f386a --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorGetSuggestions.swift @@ -0,0 +1,27 @@ +// +// AppBskyActorGetSuggestions.swift +// +// +// Created by Christopher Jr Riley on 2024-05-17. +// + +import Foundation + +extension AppBskyLexicon.Actor { + /// A data model for the output of the list of suggested users to follow. + /// + /// - Note: According to the AT Protocol specifications: "Get a list of suggested actors. + /// Expected use is discovery of accounts to follow during new account onboarding." + /// + /// - SeeAlso: This is based on the [`app.bsky.actor.getSuggestions`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/getSuggestions.json + public struct ActorGetSuggestionsOutput: Codable { + + /// The mark used to indicate the starting point for the next set of results. Optional. + public let cursor: String? + + /// An array of actors. + public let actors: [ProfileViewDefinition] + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorProfile.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorProfile.swift new file mode 100644 index 0000000000..3677897f52 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorProfile.swift @@ -0,0 +1,58 @@ +// +// AppBskyActorProfile.swift +// +// +// Created by Christopher Jr Riley on 2024-05-17. +// + +import Foundation + +extension AppBskyLexicon.Actor { + + /// The main data model definition for an actor. + /// + /// - Note: According to the AT Protocol specifications: "A declaration of a Bluesky + /// account profile." + /// + /// - SeeAlso: This is based on the [`app.bsky.actor.profile`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/profile.json + public struct ProfileRecord: ATRecordProtocol { + + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. + public static private(set) var type: String = "app.bsky.actor.profile" + + /// The display name of the profile. Optional. + public let displayName: String? + + /// The description of the profile. Optional. + /// + /// - Note: According to the AT Protocol specifications: "Free-form profile + /// description text." + public let description: String? + + /// The avatar image URL of the profile. Optional. + /// + /// - Note: According to the AT Protocol specifications: "Small image to be displayed next + /// to posts from account. AKA, 'profile picture'" + /// + /// - Note: Only JPEGs and PNGs are accepted. + public let avatarBlob: BlobContainer? + + /// The banner image URL of the profile. Optional. + /// + /// - Note: According to the AT Protocol specifications: "Larger horizontal image to + /// display behind profile view." + /// + /// - Note: Only JPEGs and PNGs are accepted. + public let bannerBlob: BlobContainer? + + /// An array of user-defined labels. Optional. + /// + /// - Note: According to the AT Protocol specifications: "Self-label values, specific to + /// the Bluesky application, on the overall account." + public let labels: [SelfLabels] + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorPutPreferences.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorPutPreferences.swift new file mode 100644 index 0000000000..8b3a762cfd --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorPutPreferences.swift @@ -0,0 +1,27 @@ +// +// AppBskyActorPutPreferences.swift +// +// +// Created by Christopher Jr Riley on 2024-05-17. +// + +import Foundation + +extension AppBskyLexicon.Actor { + + public struct PutPreferencesRequestBody: Codable { + + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. + public let type: String = "app.bsky.actor.putPreferences" + + /// A list of preferences by the user. + public let preferences: [ActorPreferenceUnion] + + enum CodingKeys: String, CodingKey { + case type = "$type" + case preferences + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorSearchActors.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorSearchActors.swift new file mode 100644 index 0000000000..20f9cd70e8 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorSearchActors.swift @@ -0,0 +1,26 @@ +// +// AppBskyActorSearchActors.swift +// +// +// Created by Christopher Jr Riley on 2024-05-17. +// + +import Foundation + +extension AppBskyLexicon.Actor { + + /// A data model definition for the output of searching for actors matching the + /// search criteria. + /// + /// - SeeAlso: This is based on the [`app.bsky.actor.searchActors`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/searchActors.json + public struct ActorSearchActorsOutput: Codable { + + /// The mark used to indicate the starting point for the next set of results. Optional. + public let cursor: String + + /// An array of actors. + public let actors: [ProfileViewDefinition] + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorSearchActorsTypeahead.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorSearchActorsTypeahead.swift new file mode 100644 index 0000000000..dbb5fb1daa --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorSearchActorsTypeahead.swift @@ -0,0 +1,22 @@ +// +// AppBskyActorSearchActorsTypeahead.swift +// +// +// Created by Christopher Jr Riley on 2024-05-17. +// + +import Foundation + +extension AppBskyLexicon.Actor { + + /// A data model definition for the output of searching for actors matching the prefixed + /// search criteria. + /// + /// - SeeAlso: This is based on the [`app.bsky.actor.searchActorsTypeahead`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/searchActorsTypeahead.json + public struct ActorSearchActorsTypeaheadOutput: Codable { + /// An array of actors. + public let actors: [ActorProfileViewBasic] + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedExternal.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedExternal.swift new file mode 100644 index 0000000000..969b812ed3 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedExternal.swift @@ -0,0 +1,109 @@ +// +// AppBskyEmbedExternal.swift +// +// +// Created by Christopher Jr Riley on 2024-05-17. +// + +import Foundation + +extension AppBskyLexicon.Embed { + + /// The main data model definition for external embeds. + /// + /// - Note: According to the AT Protocol specifications: "A representation of some externally + /// linked content (eg, a URL and 'card'), embedded in a Bluesky record (eg, a post)." + /// + /// - SeeAlso: This is based on the [`app.bsky.embed.external`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/external.json + public struct ExternalDefinition: Codable { + + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. + public let type: String = "app.bsky.embed.external" + + /// The external content needed to be embeeded. + public let external: External + + enum CodingKeys: String, CodingKey { + case type = "$type" + case external + } + } + // MARK: - + /// A data model for an external definition. + /// + /// - SeeAlso: This is based on the [`app.bsky.embed.external`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/external.json + public struct External: Codable { + + /// The URI of the external content. + public let embedURI: String + + /// The title of the external content. + public let title: String + + /// The description of the external content. + public let description: String + + /// The thumbnail image of the external content. + /// + /// - Warning: The image size can't be higher than 1 MB. Failure to do so will result in + /// the image failing to upload. + public let thumbnailImage: UploadBlobOutput? + + enum CodingKeys: String, CodingKey { + case embedURI = "uri" + case title + case description + case thumbnailImage = "thumb" + } + } + + /// A data model for an external view definition. + /// + /// - SeeAlso: This is based on the [`app.bsky.embed.external`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/external.json + public struct ExternalView: Codable { + + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. + public let type: String = "app.bsky.embed.external#view" + + /// The external content embedded in a post. + public let external: ViewExternal + + enum CodingKeys: String, CodingKey { + case type = "$type" + case external + } + } + + /// A data model for a definition for the external content. + public struct ViewExternal: Codable { + + /// The URI of the external content. + public let embedURI: String + + /// The title of the external content. + public let title: String + + /// The description of the external content. + public let description: String + + /// The thumbnail image URL of the external content. + public let thumbnailImageURL: URL? + + enum CodingKeys: String, CodingKey { + case embedURI = "uri" + case title + case description + case thumbnailImageURL = "thumb" + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedImages.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedImages.swift new file mode 100644 index 0000000000..d1ce4a0615 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedImages.swift @@ -0,0 +1,159 @@ +// +// AppBskyEmbedImages.swift +// +// +// Created by Christopher Jr Riley on 2024-05-17. +// + +import Foundation + +extension AppBskyLexicon.Embed { + + /// The main data model definition for image embeds. + /// + /// - Note: According to the AT Protocol specifications: "A set of images embedded in a Bluesky + /// record (eg, a post)." + /// + /// - SeeAlso: This is based on the [`app.bsky.embed.images`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/images.json + public struct ImagesDefinition: Codable { + + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. + public let type: String = "app.bsky.embed.images" + + /// An array of images to embed. + /// + ///- Note: Current maximum upload count is 4 images. + public let images: [Image] + + public init(images: [Image]) { + self.images = images + } + + enum CodingKeys: String, CodingKey { + case type = "$type" + case images + } + } + + // MARK: - + /// A data model for an external definition. + /// + /// - SeeAlso: This is based on the [`app.bsky.embed.images`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/images.json + public struct Image: Codable { + + /// The image that needs to be uploaded. + /// + /// - Warning: The image size can't be higher than 1 MB. Failure to do so will result in + /// the image failing to upload. + public let image: UploadBlobOutput + + /// The alternative text for the image. + /// + /// - Note: From the AT Protocol specification: "Alt text description of the image, + /// for accessibility." + public let altText: String + + /// The aspect ratio of the image. Optional. + public let aspectRatio: AspectRatio? + + public init(image: UploadBlobOutput, altText: String, aspectRatio: AspectRatio?) { + self.image = image + self.altText = altText + self.aspectRatio = aspectRatio + } + + enum CodingKeys: String, CodingKey { + case image + case altText = "alt" + case aspectRatio + } + } + + /// A data model for the aspect ratio definition. + /// + /// - Note: From the AT Protocol specification: "width:height represents an aspect ratio. + /// It may be approximate, and may not correspond to absolute dimensions in any given unit." + /// + /// - SeeAlso: This is based on the [`app.bsky.embed.images`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/images.json + public struct AspectRatio: Codable { + + /// The width of the image. + public let width: Int + + /// The height of the image. + public let height: Int + + public init(width: Int, height: Int) { + self.width = width + self.height = height + } + } + + /// A data model for the embed images definition. + /// + /// - SeeAlso: This is based on the [`app.bsky.embed.images`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/images.json + public struct ImagesView: Codable { + + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. + // public let type: String = "app.bsky.embed.images#view" + /// An array of images to be viewed. + public let images: [ViewImage] + } + + /// A data model for a definition related to viewing an image. + /// + /// - SeeAlso: This is based on the [`app.bsky.embed.images`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/images.json + public struct ViewImage: Codable { + + /// The URI of the image's thumbnail. + /// + /// - Note: From the AT Protocol specification: "Fully-qualified URL where a thumbnail of + /// the image can be fetched. For example, CDN location provided by the App View." + public let thumbnailImageURL: URL + + /// The URI of the fully-sized image. + /// + /// - Note: From the AT Protocol specification: "Fully-qualified URL where a large version + /// of the image can be fetched. May or may not be the exact original blob. For example, + /// CDN location provided by the App View." + public let fullSizeImageURL: URL + + /// /// The alternative text for the image. + /// + /// - Note: From the AT Protocol specification: "Alt text description of the image, + /// for accessibility." + public let altText: String + + /// The aspect ratio of the image. Optional. + public let aspectRatio: AspectRatio? + + public init(thumbnailImageURL: URL, fullSizeImageURL: URL, altText: String, aspectRatio: AspectRatio?) { + self.thumbnailImageURL = thumbnailImageURL + self.fullSizeImageURL = fullSizeImageURL + self.altText = altText + self.aspectRatio = aspectRatio + } + + enum CodingKeys: String, CodingKey { + case thumbnailImageURL = "thumb" + case fullSizeImageURL = "fullsize" + case altText = "alt" + case aspectRatio + } + } + +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedRecord.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedRecord.swift new file mode 100644 index 0000000000..66e493fc82 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedRecord.swift @@ -0,0 +1,203 @@ +// +// AppBskyEmbedRecord.swift +// +// +// Created by Christopher Jr Riley on 2024-05-17. +// + +import Foundation + +extension AppBskyLexicon.Embed { + + /// The main data model definition for record embeds. + /// + /// - Note: According to the AT Protocol specifications: "A representation of a record embedded + /// in a Bluesky record (eg, a post). For example, a quote-post, or sharing a + /// feed generator record." + /// + /// - SeeAlso: This is based on the [`app.bsky.embed.record`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/record.json + public struct RecordDefinition: Codable { + + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. + public let type: String = "app.bsky.embed.record" + + /// The strong reference of the record. + public let record: StrongReference + + enum CodingKeys: String, CodingKey { + case type = "$type" + case record + } + } + + // MARK: - + /// A data model for a view definition. + /// + /// - SeeAlso: This is based on the [`app.bsky.embed.record`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/record.json + public struct RecordView: Codable { + + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. + public let type: String = "app.bsky.embed.record#view" + + /// The record of a specific type. + public let record: RecordViewUnion + + enum CodingKeys: String, CodingKey { + case type = "$type" + case record + } + } + + /// A data model for a record definition in an embed. + /// + /// - SeeAlso: This is based on the [`app.bsky.embed.record`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/record.json + public struct ViewRecord: Codable { + + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. + public let type: String = "app.bsky.embed.record#viewRecord" + + /// The URI of the record. + public let recordURI: String + + /// The CID of the record. + public let cidHash: String + + /// The creator of the record. + public let author: AppBskyLexicon.Actor.ProfileViewBasicDefinition + + /// The value of the record. + /// + /// - Note: According to the AT Protocol specifications: "The record data itself." + public let value: UnknownType + + /// An array of labels attached to the record. + public let labels: [Label]? + + /// The number of replies for the record. Optional. + public let replyCount: Int? + + /// The number of reposts for the record. Optional. + public let repostCount: Int? + + /// The number of likes for the record. Optional. + public let likeCount: Int? + + /// An array of embed views of various types. + public let embeds: [EmbedViewUnion]? + + /// The date the record was last indexed. + @DateFormatting public var indexedAt: Date + + public init(recordURI: String, cidHash: String, author: AppBskyLexicon.Actor.ProfileViewBasicDefinition, value: UnknownType, labels: [Label]?, replyCount: Int?, + repostCount: Int?, likeCount: Int?, embeds: [EmbedViewUnion]?, indexedAt: Date) { + self.recordURI = recordURI + self.cidHash = cidHash + self.author = author + self.value = value + self.labels = labels + self.replyCount = replyCount + self.repostCount = repostCount + self.likeCount = likeCount + self.embeds = embeds + self._indexedAt = DateFormatting(wrappedValue: indexedAt) + } + + public init(from decoder: any Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.recordURI = try container.decode(String.self, forKey: .recordURI) + self.cidHash = try container.decode(String.self, forKey: .cidHash) + self.author = try container.decode(AppBskyLexicon.Actor.ProfileViewBasicDefinition.self, forKey: .author) + self.value = try container.decode(UnknownType.self, forKey: .value) + self.labels = try container.decodeIfPresent([Label].self, forKey: .labels) + self.replyCount = try container.decodeIfPresent(Int.self, forKey: .replyCount) + self.repostCount = try container.decodeIfPresent(Int.self, forKey: .repostCount) + self.likeCount = try container.decodeIfPresent(Int.self, forKey: .likeCount) + self.embeds = try container.decodeIfPresent([EmbedViewUnion].self, forKey: .embeds) + self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue + } + + public func encode(to encoder: any Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.recordURI, forKey: .recordURI) + try container.encode(self.cidHash, forKey: .cidHash) + try container.encode(self.author, forKey: .author) + try container.encode(self.value, forKey: .value) + try container.encodeIfPresent(self.labels, forKey: .labels) + try container.encodeIfPresent(self.replyCount, forKey: .replyCount) + try container.encodeIfPresent(self.repostCount, forKey: .repostCount) + try container.encodeIfPresent(self.likeCount, forKey: .likeCount) + try container.encodeIfPresent(self.embeds, forKey: .embeds) + try container.encode(self._indexedAt, forKey: .indexedAt) + } + + enum CodingKeys: String, CodingKey { + case type = "$type" + case recordURI = "uri" + case cidHash = "cid" + case author + case value + case labels + case replyCount + case repostCount + case likeCount + case embeds = "embeds" + case indexedAt + } + } + + /// A data model for a definition of a record that was unable to be found. + /// + /// - SeeAlso: This is based on the [`app.bsky.embed.record`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/record.json + public struct ViewNotFound: Codable { + + /// The URI of the record. + public let recordURI: String + + /// Indicates whether the record was found. + public let isRecordNotFound: Bool + + enum CodingKeys: String, CodingKey { + case recordURI = "uri" + case isRecordNotFound = "notFound" + } + } + + /// A data model for a definition of a record that has been blocked. + /// + /// - SeeAlso: This is based on the [`app.bsky.embed.record`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/record.json + public struct ViewBlocked: Codable { + + /// The URI of the record. + public let recordURI: String + + /// Indicates whether the record has been blocked. + public let isRecordBlocked: Bool + + /// The author of the record. + public let recordAuthor: FeedBlockedAuthor + + enum CodingKeys: String, CodingKey { + case recordURI = "uri" + case isRecordBlocked = "blocked" + case recordAuthor = "author" + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedRecordWithMedia.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedRecordWithMedia.swift new file mode 100644 index 0000000000..477302e387 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedRecordWithMedia.swift @@ -0,0 +1,66 @@ +// +// AppBskyEmbedRecordWithMedia.swift +// +// +// Created by Christopher Jr Riley on 2024-05-17. +// + +import Foundation + +extension AppBskyLexicon.Embed { + + /// The main data model definition for a record embedded with some form of compatible media. + /// + /// - Note: According to the AT Protocol specifications: "A representation of a record + /// embedded in a Bluesky record (eg, a post), alongside other compatible embeds. For example, + /// a quote post and image, or a quote post and external URL card." + /// + /// - SeeAlso: This is based on the [`app.bsky.embed.recordWithMedia][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/recordWithMedia.json + public struct RecordWithMediaDefinition: Codable { + + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. + public let type: String = "app.bsky.embed.recordWithMedia" + + /// The record that will be embedded. + public let record: RecordDefinition + + /// The media of a specific type. + public let media: MediaUnion + + enum CodingKeys: String, CodingKey { + case type = "$type" + case record + case media + } + } + + // MARK: - + /// A data model for a definition which contains an embedded record and embedded media. + /// + /// - SeeAlso: This is based on the [`app.bsky.embed.recordWithMedia`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/recordWithMedia.json + public struct RecordWithMediaView: Codable { + + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. + public let type: String = "app.bsky.embed.recordWithMedia#view" + + /// The embeded record. + public let record: EmbedRecordView + + /// The embedded media. + public let media: MediaViewUnion + + enum CodingKeys: String, CodingKey { + case type = "$type" + case record + case media + } + } +} From 2495d7ed574e9fc1a836d43236329e7cfe97b792 Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Sun, 19 May 2024 01:30:16 -0400 Subject: [PATCH 05/51] Convert lexicons to new layout The following have been converted: - app.bsky.feed.* - app.bsky.graph.* Various fixes towards the previously converted lexicons have also been added. --- .../app.bsky/Actor/AppBskyActorDefs.swift | 5 +- .../app.bsky/Feed/AppBskyFeedDefs.swift | 701 ++++++++++++++++++ .../AppBskyFeedDescribeFeedGenerator.swift | 59 ++ .../app.bsky/Feed/AppBskyFeedGenerator.swift | 115 +++ .../Feed/AppBskyFeedGetActorFeeds.swift | 28 + .../Feed/AppBskyFeedGetActorLikes.swift | 28 + .../Feed/AppBskyFeedGetAuthorFeed.swift | 48 ++ .../app.bsky/Feed/AppBskyFeedGetFeed.swift | 28 + .../Feed/AppBskyFeedGetFeedGenerator.swift | 39 + .../Feed/AppBskyFeedGetFeedGenerators.swift | 26 + .../Feed/AppBskyFeedGetFeedSkeleton.swift | 29 + .../app.bsky/Feed/AppBskyFeedGetLikes.swift | 80 ++ .../Feed/AppBskyFeedGetListFeed.swift | 29 + .../Feed/AppBskyFeedGetPostThread.swift | 25 + .../app.bsky/Feed/AppBskyFeedGetPosts.swift | 26 + .../Feed/AppBskyFeedGetRepostedBy.swift | 42 ++ .../Feed/AppBskyFeedGetSuggestedFeeds.swift | 29 + .../Feed/AppBskyFeedGetTimeline.swift | 28 + .../app.bsky/Feed/AppBskyFeedLike.swift | 63 ++ .../app.bsky/Feed/AppBskyFeedPost.swift | 175 +++++ .../app.bsky/Feed/AppBskyFeedRepost.swift | 60 ++ .../Feed/AppBskyFeedSearchPosts.swift | 54 ++ .../Feed/AppBskyFeedSendInteractions.swift | 32 + .../app.bsky/Feed/AppBskyFeedThreadgate.swift | 90 +++ .../app.bsky/Graph/AppBskyGraphBlock.swift | 61 ++ .../app.bsky/Graph/AppBskyGraphDefs.swift | 307 ++++++++ .../app.bsky/Graph/AppBskyGraphFollow.swift | 56 ++ .../Graph/AppBskyGraphGetBlocks.swift | 29 + .../Graph/AppBskyGraphGetFollowers.swift | 31 + .../Graph/AppBskyGraphGetFollows.swift | 32 + .../app.bsky/Graph/AppBskyGraphGetList.swift | 31 + .../Graph/AppBskyGraphGetListBlocks.swift | 29 + .../Graph/AppBskyGraphGetListMutes.swift | 29 + .../app.bsky/Graph/AppBskyGraphGetLists.swift | 29 + .../app.bsky/Graph/AppBskyGraphGetMutes.swift | 29 + .../Graph/AppBskyGraphGetRelationships.swift | 29 + ...pBskyGraphGetSuggestedFollowsByActor.swift | 27 + .../app.bsky/Graph/AppBskyGraphList.swift | 101 +++ .../Graph/AppBskyGraphListblock.swift | 61 ++ .../app.bsky/Graph/AppBskyGraphListitem.swift | 71 ++ .../Graph/AppBskyGraphMuteActor.swift | 29 + .../Graph/AppBskyGraphMuteActorList.swift | 29 + .../Graph/AppBskyGraphUnmuteActor.swift | 29 + .../Graph/AppBskyGraphUnmuteActorList.swift | 29 + 44 files changed, 2906 insertions(+), 1 deletion(-) create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedDefs.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedDescribeFeedGenerator.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGenerator.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetActorFeeds.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetActorLikes.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetAuthorFeed.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeed.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeedGenerator.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeedGenerators.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeedSkeleton.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetLikes.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetListFeed.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetPostThread.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetPosts.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetRepostedBy.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetSuggestedFeeds.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetTimeline.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedLike.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedPost.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedRepost.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedSearchPosts.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedSendInteractions.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedThreadgate.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphBlock.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphDefs.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphFollow.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetBlocks.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetFollowers.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetFollows.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetList.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetListBlocks.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetListMutes.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetLists.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetMutes.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetRelationships.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetSuggestedFollowsByActor.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphList.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphListblock.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphListitem.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphMuteActor.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphMuteActorList.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphUnmuteActor.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphUnmuteActorList.swift diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorDefs.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorDefs.swift index 4bcf9c4b39..dd7b8ca654 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorDefs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorDefs.swift @@ -126,7 +126,7 @@ extension AppBskyLexicon.Actor { public var viewer: ViewerStateDefinition? /// An array of labels created by the user. Optional. - public var labels: [Label]? = nil + public var labels: [Label]? public init(actorDID: String, actorHandle: String, displayName: String?, description: String?, avatarImageURL: URL?, associated: ProfileAssociatedDefinition?, indexedAt: Date?, viewer: ViewerStateDefinition?, labels: [Label]?) { @@ -321,10 +321,13 @@ extension AppBskyLexicon.Actor { /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/defs.json public struct ProfileAssociatedDefinition: Codable { + /// The number of lists associated with the user. Optional. public let lists: Int? + /// The number of feed generators associated with the user. Optional. public let feedGenerators: Int? + /// Indicates whether the user account is a labeler. Optional. public let isActorLabeler: Bool? diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedDefs.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedDefs.swift new file mode 100644 index 0000000000..71d9614f5f --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedDefs.swift @@ -0,0 +1,701 @@ +// +// AppBskyFeedDefs.swift +// +// +// Created by Christopher Jr Riley on 2024-05-18. +// + +import Foundation + +extension AppBskyLexicon.Feed { + + /// A data model for a post view definition. + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/defs.json + public struct PostViewDefinition: Codable { + + /// The URI of the post. + public let postURI: String + + /// The CID of the post. + public let cidHash: String + + /// The author of the post. This will give the basic details of the post author. + public let author: AppBskyLexicon.Actor.ProfileViewBasicDefinition + + /// The record data itself. + public let record: UnknownType + + /// An embed view of a specific type. Optional. + public var embed: EmbedViewUnion? + + /// The number of replies in the post. Optional. + public var replyCount: Int? + + /// The number of reposts in the post. Optional. + public var repostCount: Int? + + /// The number of likes in the post. Optional. + public var likeCount: Int? + + /// The last time the post has been indexed. + @DateFormatting public var indexedAt: Date + + /// The viewer's interaction with the post. Optional. + public var viewer: ViewerStateDefinition? + + /// An array of labels attached to the post. Optional. + public var labels: [Label]? + + /// The ruleset of who can reply to the post. Optional. + public var threadgate: ThreadgateViewDefinition? + + public init(postURI: String, cidHash: String, author: AppBskyLexicon.Actor.ProfileViewBasicDefinition, record: UnknownType, embed: EmbedViewUnion?, replyCount: Int?, + repostCount: Int?, likeCount: Int?, indexedAt: Date, viewer: ViewerStateDefinition?, labels: [Label]?, threadgate: ThreadgateViewDefinition?) { + self.postURI = postURI + self.cidHash = cidHash + self.author = author + self.record = record + self.embed = embed + self.replyCount = replyCount + self.repostCount = repostCount + self.likeCount = likeCount + self._indexedAt = DateFormatting(wrappedValue: indexedAt) + self.viewer = viewer + self.labels = labels + self.threadgate = threadgate + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.postURI = try container.decode(String.self, forKey: .postURI) + self.cidHash = try container.decode(String.self, forKey: .cidHash) + self.author = try container.decode(AppBskyLexicon.Actor.ProfileViewBasicDefinition.self, forKey: .author) + self.record = try container.decode(UnknownType.self, forKey: .record) + self.embed = try container.decodeIfPresent(EmbedViewUnion.self, forKey: .embed) + self.replyCount = try container.decodeIfPresent(Int.self, forKey: .replyCount) + self.repostCount = try container.decodeIfPresent(Int.self, forKey: .repostCount) + self.likeCount = try container.decodeIfPresent(Int.self, forKey: .likeCount) + self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue + self.viewer = try container.decodeIfPresent(ViewerStateDefinition.self, forKey: .viewer) + self.labels = try container.decodeIfPresent([Label].self, forKey: .labels) + self.threadgate = try container.decodeIfPresent(ThreadgateViewDefinition.self, forKey: .threadgate) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.postURI, forKey: .postURI) + try container.encode(self.cidHash, forKey: .cidHash) + try container.encode(self.author, forKey: .author) + try container.encode(self.record, forKey: .record) + try container.encodeIfPresent(self.embed, forKey: .embed) + try container.encodeIfPresent(self.replyCount, forKey: .replyCount) + try container.encodeIfPresent(self.repostCount, forKey: .repostCount) + try container.encodeIfPresent(self.likeCount, forKey: .likeCount) + try container.encode(self._indexedAt, forKey: .indexedAt) + try container.encodeIfPresent(self.viewer, forKey: .viewer) + try container.encodeIfPresent(self.labels, forKey: .labels) + try container.encodeIfPresent(self.threadgate, forKey: .threadgate) + } + + enum CodingKeys: String, CodingKey { + case postURI = "uri" + case cidHash = "cid" + case author + case record + case embed + case replyCount + case repostCount + case likeCount + case indexedAt + case viewer + case labels + case threadgate + } + } + + /// A data model for a viewer state definition. + /// + /// - Note: According to the AT Protocol specifications: "Metadata about the requesting + /// account's relationship with the subject content. Only has meaningful content for + /// authed requests." + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/defs.json + public struct ViewerStateDefinition: Codable { + + /// The URI of the requesting account's repost of the subject account's post. Optional. + public let repostURI: String? + + /// The URI of the requesting account's like of the subject account's post. Optional. + public let likeURI: String? + + /// Indicates whether the requesting account can reply to the account's post. Optional. + public let areRepliesDisabled: Bool? + + enum CodingKeys: String, CodingKey { + case repostURI = "repost" + case likeURI = "like" + case areRepliesDisabled = "replyDisabled" + } + } + + /// A data model for a definition of a feed's view. + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/defs.json + public struct FeedViewPostDefinition: Codable { + + /// The post contained in a feed. + public let post: PostViewDefinition + + /// The reply reference for the post, if it's a reply. Optional. + public var reply: ReplyReferenceDefinition? + + // TODO: Check to see if this is correct. + /// The user who reposted the post. Optional. + public var reason: ReasonRepostDefinition? + + /// The feed generator's context. Optional + /// + /// - Note: According to the AT Protocol specifications: "Context provided by + /// feed generator that may be passed back alongside interactions." + public let feedContext: String? + + public init(post: PostViewDefinition, reply: ReplyReferenceDefinition?, reason: ReasonRepostDefinition?, feedContext: String?) { + self.post = post + self.reply = reply + self.reason = reason + self.feedContext = feedContext + } + + public init(from decoder: any Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.post = try container.decode(PostViewDefinition.self, forKey: .post) + self.reply = try container.decodeIfPresent(ReplyReferenceDefinition.self, forKey: .reply) + self.reason = try container.decodeIfPresent(ReasonRepostDefinition.self, forKey: .reason) + self.feedContext = try container.decodeIfPresent(String.self, forKey: .feedContext) + } + + public func encode(to encoder: any Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.post, forKey: .post) + try container.encodeIfPresent(self.reply, forKey: .reply) + try container.encodeIfPresent(self.reason, forKey: .reason) + // Truncate `description` to 2000 characters before encoding + // `maxGraphemes`'s limit is 300, but `String.count` should respect that limit + try truncatedEncodeIfPresent(self.feedContext, withContainer: &container, forKey: .feedContext, upToLength: 2000) + } + + public enum CodingKeys: CodingKey { + case post + case reply + case reason + case feedContext + } + } + + /// A data model for a reply reference definition. + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/defs.json + public struct ReplyReferenceDefinition: Codable { + + /// The original post of the thread. + public let root: PostUnion + + // TODO: Fix up the note's message. + /// The direct post that the user's post is replying to. + /// + /// - Note: If `parent` and `root` are identical, the post is a direct reply to the + /// original post of the thread. + public let parent: PostUnion + + /// The author of the parent's post. + /// + /// - Note: According to the AT Protocol specifications: "When parent is a reply to another + /// post, this is the author of that post." + public let grandparentAuthor: AppBskyLexicon.Actor.ProfileViewBasicDefinition + } + + /// A data model for a definition for a very stripped down version of a repost. + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/defs.json + public struct ReasonRepostDefinition: Codable { + + /// The basic details of the user who reposted the post. + public let by: AppBskyLexicon.Actor.ProfileViewBasicDefinition + + /// The last time the repost was indexed. + @DateFormatting public var indexedAt: Date + + public init(by: AppBskyLexicon.Actor.ProfileViewBasicDefinition, indexedAt: Date) { + self.by = by + self._indexedAt = DateFormatting(wrappedValue: indexedAt) + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.by = try container.decode(AppBskyLexicon.Actor.ProfileViewBasicDefinition.self, forKey: .by) + self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue + } + + enum CodingKeys: CodingKey { + case by + case indexedAt + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.by, forKey: .by) + try container.encode(self._indexedAt, forKey: .indexedAt) + } + } + + /// A data model for a definition of a hydrated version of a repost. + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/defs.json + public struct ThreadViewPostDefinition: Codable { + + /// The post contained in a thread. + public let post: PostViewDefinition + + /// The direct post that the user's post is replying to. Optional. + public var parent: ThreadPostUnion? + + /// An array of posts of various types. Optional. + public var replies: [ThreadPostUnion]? + } + + /// A data model for a definition of a post that may not have been found. + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/defs.json + public struct NotFoundPostDefinition: Codable { + + /// The URI of the post. + public let feedURI: String + + /// Indicates whether the post wasn't found. Defaults to `true`. + public private(set) var isNotFound: Bool = true + + public init(feedURI: String, isNotFound: Bool = true) { + self.feedURI = feedURI + self.isNotFound = isNotFound + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + feedURI = try container.decode(String.self, forKey: .feedURI) + isNotFound = (try? container.decodeIfPresent(Bool.self, forKey: .isNotFound)) ?? true + } + + enum CodingKeys: String, CodingKey { + case feedURI = "uri" + case isNotFound = "notFound" + } + } + + /// A data model for a definition of a post that may have been blocked. + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/defs.json + public struct BlockedPostDefinition: Codable { + + /// The URI of the post. + public let feedURI: String + + /// Indicates whether this post has been blocked from the user. Defaults to `true`. + public private(set) var isBlocked: Bool = true + + /// The author of the post. + public let author: BlockedAuthorDefinition + + public init(feedURI: String, isBlocked: Bool = true, author: BlockedAuthorDefinition) { + self.feedURI = feedURI + self.isBlocked = isBlocked + self.author = author + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.feedURI = try container.decode(String.self, forKey: .feedURI) + self.isBlocked = (try? container.decode(Bool.self, forKey: .isBlocked)) ?? true + self.author = try container.decode(BlockedAuthorDefinition.self, forKey: .author) + } + + enum CodingKeys: String, CodingKey { + case feedURI = "uri" + case isBlocked = "blocked" + case author + } + } + + /// The data model of a blocked author definition. + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/defs.json + public struct BlockedAuthorDefinition: Codable { + + /// The URI of the author. + public let authorDID: String + + /// The viewer state of the user. Optional. + public var viewer: AppBskyLexicon.Actor.ViewerStateDefinition? + + enum CodingKeys: String, CodingKey { + case authorDID = "did" + case viewer + } + } + + /// The data model of a feed generator definition. + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/defs.json + public struct GeneratorViewDefinition: Codable { + + /// The URI of the feed generator. + public let feedURI: String + + /// The CID of the feed generator. + public let cidHash: String + + /// The decentralized identifier (DID) of the feed generator. + public let feedDID: String + + /// The author of the feed generator. + public let creator: AppBskyLexicon.Actor.ProfileViewDefinition + + /// The display name of the feed generator. + public let displayName: String + + /// The description of the feed generator. Optional. + public var description: String? + + /// An array of the facets within the feed generator's description. + public let descriptionFacets: [Facet]? + + /// The avatar image URL of the feed generator. + public var avatarImageURL: URL? + + /// The number of likes for the feed generator. + public var likeCount: Int? + + /// Indicates whether the feed generator can accept interactions. + /// + /// - Note: According to the AT Protocol specifications: "Context that will be passed + /// through to client and may be passed to feed generator back alongside interactions." + public let canAcceptInteractions: Bool? + + /// An array of labels. Optional. + public let labels: [Label]? + + /// The viewer's state for the feed generator. + public var viewer: GeneratorViewerStateDefinition? + + /// The last time the feed generator was indexed. + @DateFormatting public var indexedAt: Date + + public init(feedURI: String, cidHash: String, feedDID: String, creator: AppBskyLexicon.Actor.ProfileViewDefinition, displayName: String, description: String?, + descriptionFacets: [Facet]?, avatarImageURL: URL?, likeCount: Int?, canAcceptInteractions: Bool?, labels: [Label]?, + viewer: GeneratorViewerStateDefinition?, indexedAt: Date) { + self.feedURI = feedURI + self.cidHash = cidHash + self.feedDID = feedDID + self.creator = creator + self.displayName = displayName + self.description = description + self.descriptionFacets = descriptionFacets + self.avatarImageURL = avatarImageURL + self.likeCount = likeCount + self.canAcceptInteractions = canAcceptInteractions + self.labels = labels + self.viewer = viewer + self._indexedAt = DateFormatting(wrappedValue: indexedAt) + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.feedURI = try container.decode(String.self, forKey: .feedURI) + self.cidHash = try container.decode(String.self, forKey: .cidHash) + self.feedDID = try container.decode(String.self, forKey: .feedDID) + self.creator = try container.decode(AppBskyLexicon.Actor.ProfileViewDefinition.self, forKey: .creator) + self.displayName = try container.decode(String.self, forKey: .displayName) + self.description = try container.decodeIfPresent(String.self, forKey: .description) + self.descriptionFacets = try container.decodeIfPresent([Facet].self, forKey: .descriptionFacets) + self.avatarImageURL = try container.decodeIfPresent(URL.self, forKey: .avatarImageURL) + self.likeCount = try container.decodeIfPresent(Int.self, forKey: .likeCount) + self.canAcceptInteractions = try container.decodeIfPresent(Bool.self, forKey: .canAcceptInteractions) + self.labels = try container.decodeIfPresent([Label].self, forKey: .labels) + self.viewer = try container.decodeIfPresent(GeneratorViewerStateDefinition.self, forKey: .viewer) + self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.feedURI, forKey: .feedURI) + try container.encode(self.cidHash, forKey: .cidHash) + try container.encode(self.feedDID, forKey: .feedDID) + try container.encode(self.creator, forKey: .creator) + try container.encode(self.displayName, forKey: .displayName) + + // Truncate `description` to 3000 characters before encoding + // `maxGraphemes`'s limit is 300, but `String.count` should respect that limit + try truncatedEncodeIfPresent(self.description, withContainer: &container, forKey: .description, upToLength: 3000) + + try container.encodeIfPresent(self.descriptionFacets, forKey: .descriptionFacets) + try container.encodeIfPresent(self.avatarImageURL, forKey: .avatarImageURL) + + // Assuming `likeCount` is not nil, only encode it if it's 0 or higher + if let likeCount = self.likeCount, likeCount >= 0 { + try container.encode(likeCount, forKey: .likeCount) + } + try container.encodeIfPresent(self.canAcceptInteractions, forKey: .canAcceptInteractions) + try container.encodeIfPresent(self.labels, forKey: .labels) + try container.encodeIfPresent(self.viewer, forKey: .viewer) + try container.encode(self._indexedAt, forKey: .indexedAt) + } + + enum CodingKeys: String, CodingKey { + case feedURI = "uri" + case cidHash = "cid" + case feedDID = "did" + case creator + case displayName + case description + case descriptionFacets = "descriptionFacets" + case avatarImageURL = "avatar" + case likeCount + case canAcceptInteractions = "acceptsInteractions" + case labels + case viewer + case indexedAt + } + } + + /// The data model of a definition for the viewer's state of the feed generator. + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/defs.json + public struct GeneratorViewerStateDefinition: Codable { + + /// The URI of the viewer's like, if they liked the feed generator. Optional. + public var likeURI: String? + + enum CodingKeys: String, CodingKey { + case likeURI = "like" + } + } + + /// The data model of a feed's skeleton + public struct SkeletonFeedPostDefinition: Codable { + + /// The URI of the post in the feed generator. + /// + /// - Note: This refers to the original post's URI. If the post is a repost, then `reason` + /// will contain a value. + public let postURI: String + + /// The indication that the post was a repost. Optional. + public var reason: SkeletonReasonRepostDefinition? + + enum CodingKeys: String, CodingKey { + case postURI = "post" + case reason + } + } + + /// The data model of a definition for a respost in a feed generator. + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/defs.json + public struct SkeletonReasonRepostDefinition: Codable { + + /// The URI of the repost. + /// + /// This property uniquely identifies the repost itself, separate from the original post's URI. + public let repostURI: String + + enum CodingKeys: String, CodingKey { + case repostURI = "repost" + } + } + + /// The data model of a feed threadgate view definition. + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/defs.json + public struct ThreadgateViewDefinition: Codable { + + /// The URI of the feed's threadgate. + public let threadgateURI: String + + /// The CID of the feed's threadgate. + public let cidHash: String + + /// The record of the feed's threadgate + public let record: UnknownType + + // TODO: Make sure this is correct. + /// An array of user lists. + public let lists: [GraphListViewBasic] + + enum CodingKeys: String, CodingKey { + case threadgateURI = "uri" + case cidHash = "cid" + case record = "record" + case lists = "lists" + } + } + + /// The main data model definition for an interaction for an item in a feed generator. + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/defs.json + public struct InteractionDefinition: Codable { + + /// The item itself. Optional. + public let item: String? + + /// The interaction event of the feed generator. Optional. + public let event: InteractionEventDefinition? + + /// The feed generator's context. Optional. + /// + /// - Note: According to the AT Protocol specifications: "Context on a feed item that was + /// orginally supplied by the feed generator on getFeedSkeleton." + public let feedContext: String? + + public init(item: String, event: InteractionEventDefinition, feedContext: String) { + self.item = item + self.event = event + self.feedContext = feedContext + } + + public init(from decoder: any Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.item = try container.decode(String.self, forKey: .item) + self.event = try container.decode(InteractionEventDefinition.self, forKey: .event) + self.feedContext = try container.decode(String.self, forKey: .feedContext) + } + + public func encode(to encoder: any Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.item, forKey: .item) + try container.encode(self.event, forKey: .event) + // Truncate `description` to 2000 characters before encoding + // `maxGraphemes`'s limit is 300, but `String.count` should respect that limit + try truncatedEncodeIfPresent(self.feedContext, withContainer: &container, forKey: .feedContext, upToLength: 2000) + } + + enum CodingKeys: CodingKey { + case item + case event + case feedContext + } + } + + /// A data model definition for an interaction event. + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/defs.json + public enum InteractionEventDefinition: Codable { + + /// Indicates the feed generator should request less content similar to the feed's item. + /// + /// - Note: According to the AT Protocol specifications: "Request that less content like the + /// given feed item be shown in the feed." + case requestLess + + /// Indicates the feed generator should request more content similar to the feed's item. + /// + /// - Note: According to the AT Protocol specifications: "Request that more content like the + /// given feed item be shown in the feed." + case requestMore + + /// Indicates the feed generator clicked on the feed's item. + /// + /// - Note: According to the AT Protocol specifications: "User clicked through to the + /// feed item." + case clickthroughItem + + /// Indicates the user clicked on the author of the feed's item. + /// + /// - Note: According to the AT Protocol specifications: "User clicked through to the author + /// of the feed item." + case clickthroughAuthor + + /// Indicates the user clicked on the reposter of the feed's item. + /// + /// - Note: According to the AT Protocol specifications: "User clicked through to the reposter + /// of the feed item." + case clickthroughReposter + + /// Indicates the user clicked on the embedded content of the feed's item. + /// + /// - Note: According to the AT Protocol specifications: "User clicked through to the embedded + /// content of the feed item." + case clickthroughEmbed + + /// Indicates the user has viewed the item in the feed. + /// + /// - Note: According to the AT Protocol specifications: "Feed item was seen by user." + case interactionSeen + + /// Indicates the user has liked the item of the feed. + /// + /// - Note: According to the AT Protocol specifications: "User liked the feed item." + case interactionLike + + /// Indicates the user has reposted the item of the feed. + /// + /// - Note: According to the AT Protocol specifications: "User reposted the feed item." + case interactionRepost + + /// Indicates the user has replied to the item of the feed. + /// + /// - Note: According to the AT Protocol specifications: "User replied to the feed item." + case interactionReply + + /// Indicates the user has quote posted the feed's item. + /// + /// - Note: According to the AT Protocol specifications: "User quoted the feed item." + case interactionQuote + + /// Indicates the user has shared the feed's item. + /// + /// - Note: According to the AT Protocol specifications: "User shared the feed item." + case interactionShare + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedDescribeFeedGenerator.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedDescribeFeedGenerator.swift new file mode 100644 index 0000000000..18fc0587b2 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedDescribeFeedGenerator.swift @@ -0,0 +1,59 @@ +// +// AppBskyFeedDescribeFeedGenerator.swift +// +// +// Created by Christopher Jr Riley on 2024-05-18. +// + +import Foundation + +extension AppBskyLexicon.Feed { + + /// A data model definition for the output ofretrieving information about a feed generator. + /// + /// - Note: According to the AT Protocol specifications: "Get information about a + /// feed generator, including policies and offered feed URIs. Does not require auth; + /// implemented by Feed Generator services (not App View)." + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.describeFeedGenerator`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/describeFeedGenerator.json + public struct DescribeFeedGeneratorOutput: Codable { + + /// The decentralized identifier (DID) of the feed generator. + public let atDID: String + + /// An array of feed generators. + public let feeds: [Feed] + + /// The URL of the Privacy Policy and Terms of Service. Optional. + public let links: Links? + + enum CodingKeys: String, CodingKey { + case atDID = "did" + case feeds + case links + } + + /// A data model definiion for the feed generator. + public struct Feed: Codable { + + /// The URI of the feed. + public let feedURI: String + + enum CodingKeys: String, CodingKey { + case feedURI = "uri" + } + } + + /// A data model definition for the Privacy Policy and Terms of Service URLs. + public struct Links: Codable { + + /// The URL to the Privacy Policy. + public let privacyPolicy: URL + + /// The URL to the Terms of Service. + public let termsOfService: URL + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGenerator.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGenerator.swift new file mode 100644 index 0000000000..4604af8c30 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGenerator.swift @@ -0,0 +1,115 @@ +// +// AppBskyFeedGenerator.swift +// +// +// Created by Christopher Jr Riley on 2024-05-18. +// + +import Foundation + +extension AppBskyLexicon.Feed { + + /// The main data model definition for a feed generator record. + /// + /// - Note: According to the AT Protocol specifications: "Record declaring of the existence of + /// a feed generator, and containing metadata about it. The record can exist in + /// any repository." + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.generator`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/generator.json + public struct FeedGeneratorRecord: ATRecordProtocol { + + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. + public static private(set) var type: String = "app.bsky.feed.generator" + + /// The decentralized identifier (DID) of the feed. + public let feedDID: String + + /// The display name of the feed. + /// + /// - Important: Current maximum lenth is 24 characters. This library will automatically + /// truncate the `String` to the maximum length if it does go over the limit. + public let displayName: String + + /// The description of the feed. Optional. + /// + /// - Important: Current maximum lenth is 300 characters. This library will automatically + /// truncate the `String` to the maximum length if it does go over the limit. + public let description: String? + + /// An array of the facets within the feed generator's description. Optional. + public let descriptionFacets: [Facet]? + + /// The URL of the avatar image. Optional. + public let avatarImageURL: URL? + + /// Indicates whether the feed generator can accept interactions. + /// + /// - Note: According to the AT Protocol specifications: "Declaration that a feed accepts + /// feedback interactions from a client through `app.bsky.feed.sendInteractions`" + public let canAcceptInteractions: Bool? + + /// An array of labels created by the user. Optional. + public let labels: [SelfLabels]? + + /// The date and time the feed was created. + @DateFormatting public var createdAt: Date + + public init(feedDID: String, displayName: String, description: String?, descriptionFacets: [Facet]?, avatarImageURL: URL?, + canAcceptInteractions: Bool?, labels: [SelfLabels]?, createdAt: Date) { + self.feedDID = feedDID + self.displayName = displayName + self.description = description + self.descriptionFacets = descriptionFacets + self.avatarImageURL = avatarImageURL + self.canAcceptInteractions = canAcceptInteractions + self.labels = labels + self._createdAt = DateFormatting(wrappedValue: createdAt) + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.feedDID = try container.decode(String.self, forKey: .feedDID) + self.displayName = try container.decode(String.self, forKey: .displayName) + self.description = try container.decodeIfPresent(String.self, forKey: .description) + self.descriptionFacets = try container.decodeIfPresent([Facet].self, forKey: .descriptionFacets) + self.avatarImageURL = try container.decodeIfPresent(URL.self, forKey: .avatarImageURL) + self.canAcceptInteractions = try container.decodeIfPresent(Bool.self, forKey: .canAcceptInteractions) + self.labels = try container.decodeIfPresent([SelfLabels].self, forKey: .labels) + self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.feedDID, forKey: .feedDID) + // Truncate `displayName` to 240 characters before encoding + // `maxGraphemes`'s limit is 24, but `String.count` should respect that limit implictly + try truncatedEncode(self.displayName, withContainer: &container, forKey: .description, upToLength: 240) + // Truncate `displayName` to 3,000 characters before encoding + // `maxGraphemes`'s limit is 300, but `String.count` should respect that limit implictly + try truncatedEncodeIfPresent(self.description, withContainer: &container, forKey: .description, upToLength: 3_000) + try container.encodeIfPresent(self.descriptionFacets, forKey: .descriptionFacets) + try container.encodeIfPresent(self.avatarImageURL, forKey: .avatarImageURL) + try container.encodeIfPresent(self.canAcceptInteractions, forKey: .canAcceptInteractions) + try container.encodeIfPresent(self.labels, forKey: .labels) + try container.encode(self._createdAt, forKey: .createdAt) + } + + enum CodingKeys: String, CodingKey { + case type = "$type" + case feedDID = "did" + case displayName + case description + case descriptionFacets + case avatarImageURL = "avatar" + case canAcceptInteractions = "acceptsInteractions" + case labels + case createdAt + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetActorFeeds.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetActorFeeds.swift new file mode 100644 index 0000000000..f540db1ff3 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetActorFeeds.swift @@ -0,0 +1,28 @@ +// +// AppBskyFeedGetActorFeeds.swift +// +// +// Created by Christopher Jr Riley on 2024-05-18. +// + +import Foundation + +extension AppBskyLexicon.Feed { + + /// The main data model definition for the output of retrieving a feed list by a user. + /// + /// - Note: According to the AT Protocol specifications: "Get a list of feeds (feed generator + /// records) created by the actor (in the actor's repo)." + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.getActorFeeds`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getActorFeeds.json + public struct GetActorFeedsOutput: Codable { + + /// The mark used to indicate the starting point for the next set of results. Optional. + public let cursor: String? + + /// An array of feeds. + public let feeds: [GeneratorViewDefinition] + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetActorLikes.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetActorLikes.swift new file mode 100644 index 0000000000..acb1edf2dd --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetActorLikes.swift @@ -0,0 +1,28 @@ +// +// AppBskyFeedGetActorLikes.swift +// +// +// Created by Christopher Jr Riley on 2024-05-18. +// + +import Foundation + +extension AppBskyLexicon.Feed { + + /// The main data model definition for the output of seeing all of a user account's likes. + /// + /// - Note: According to the AT Protocol specifications: "Get a list of posts liked by an actor. + /// Does not require auth." + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.getActorLikes`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getActorLikes.json + public struct GetActorLikesOutput: Codable { + + /// The mark used to indicate the starting point for the next set of result. Optional. + public let cursor: String? + + /// An array of like records. + public let feed: [FeedViewPost] + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetAuthorFeed.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetAuthorFeed.swift new file mode 100644 index 0000000000..e212e87689 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetAuthorFeed.swift @@ -0,0 +1,48 @@ +// +// AppBskyFeedGetAuthorFeed.swift +// +// +// Created by Christopher Jr Riley on 2024-05-18. +// + +import Foundation + +extension AppBskyLexicon.Feed { + + /// The main data model definition for the output of seeing the user account's posts + /// and reposts. + /// + /// - Note: According to the AT Protocol specifications: "Get a view of an actor's + /// 'author feed' (post and reposts by the author). Does not require auth." + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.getAuthorFeed`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getAuthorFeed.json + public struct GetAuthorFeedOutput: Codable { + + /// The mark used to indicate the starting point for the next set of result. Optional. + public let cursor: String? + + /// An array of like records. + public let feed: [FeedViewPostDefinition] + } + + /// Indicates the kind of combinations of posts and reposts for the feed's array. + /// + /// - Note: According to the AT Protocol specifications: "Combinations of post/repost types to + /// include in response." + public enum GetAuthorFeedFilter: String { + + /// Indicates the array of feeds will contain posts with replies. + case postsWithReplies = "posts_with_replies" + + /// Indicates the array of feeds will contain posts with no replies. + case postsWithNoReplies = "posts_no_replies" + + /// Indicates the array of feeds will contain posts with media. + case postsWithMedia = "posts_with_media" + + /// Indicates the array of feeds will contain posts that are threads. + case postAndAuthorThreads = "posts_and_author_threads" + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeed.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeed.swift new file mode 100644 index 0000000000..100a563f87 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeed.swift @@ -0,0 +1,28 @@ +// +// AppBskyFeedGetFeed.swift +// +// +// Created by Christopher Jr Riley on 2024-05-18. +// + +import Foundation + +extension AppBskyLexicon.Feed { + + /// The main data model definition for the output of viewing the selected feed generator. + /// + /// - Note: According to the AT Protocol specifications: "Get a hydrated feed from an actor's + /// selected feed generator. Implemented by App View." + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.getFeed`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getFeed.json + public struct GetFeedOutput: Codable { + + /// The mark used to indicate the starting point for the next set of result. Optional. + public let cursor: String? + + /// An array of posts in the feed. + public let feed: [FeedViewPostDefinition] + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeedGenerator.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeedGenerator.swift new file mode 100644 index 0000000000..2e68e4101f --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeedGenerator.swift @@ -0,0 +1,39 @@ +// +// AppBskyFeedGetFeedGenerator.swift +// +// +// Created by Christopher Jr Riley on 2024-05-18. +// + +import Foundation + +extension AppBskyLexicon.Feed { + + /// The main data model definition for the output of getting information about a given + /// feed generator. + /// + /// - Note: According to the AT Protocol specifications: "Get information about a feed + /// generator. Implemented by AppView." + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.getFeedGenerator`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getFeedGenerator.json + public struct FeedGetFeedGeneratorOutput: Codable { + + /// The general information about the feed generator. + public let view: GeneratorViewDefinition + + /// Indicates whether the feed generator is currently online. + /// + /// - Note: According to the AT Protocol specifications: "Indicates whether the + /// feed generator service has been online recently, or else seems to be inactive." + public let isOnline: Bool + + /// Indicates whether the feed generator is compatible with the record declaration. + /// + /// - Note: According to the AT Protocol specifications: "Indicates whether the + /// feed generator service is compatible with the record declaration." + public let isValid: Bool + + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeedGenerators.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeedGenerators.swift new file mode 100644 index 0000000000..1ad47f965b --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeedGenerators.swift @@ -0,0 +1,26 @@ +// +// AppBskyFeedGetFeedGenerators.swift +// +// +// Created by Christopher Jr Riley on 2024-05-18. +// + +import Foundation + +extension AppBskyLexicon.Feed { + + /// The main data model definition for the output of getting information about several + /// feed generators. + /// + /// - Note: According to the AT Protocol specifications: "Get information about a list of + /// feed generators." + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.getFeedGenerators`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getFeedGenerator.json + public struct FeedGetFeedGeneratorsOutput: Codable { + + /// An array of feed generators. + public let feeds: [GeneratorViewDefinition] + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeedSkeleton.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeedSkeleton.swift new file mode 100644 index 0000000000..0d7ecb8364 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeedSkeleton.swift @@ -0,0 +1,29 @@ +// +// AppBskyFeedGetFeedSkeleton.swift +// +// +// Created by Christopher Jr Riley on 2024-05-18. +// + +import Foundation + +extension AppBskyLexicon.Feed { + + /// The main data model definition for the output of getting a skeleton for a feed generator. + /// + /// - Note: According to the AT Protocol specifications: "Get a skeleton of a feed provided + /// by a feed generator. Auth is optional, depending on provider requirements, and provides the + /// DID of the requester. Implemented by Feed Generator Service." + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.getFeedSkeleton`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getFeedSkeleton.json + public struct GetFeedSkeletonOutput: Codable { + + /// The mark used to indicate the starting point for the next set of result. Optional. + public let cursor: String? + + /// An array of skeleton feeds. + public let feed: [SkeletonFeedPostDefinition] + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetLikes.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetLikes.swift new file mode 100644 index 0000000000..0bce38cd8b --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetLikes.swift @@ -0,0 +1,80 @@ +// +// AppBskyFeedGetLikes.swift +// +// +// Created by Christopher Jr Riley on 2024-05-18. +// + +import Foundation + +extension AppBskyLexicon.Feed { + + /// The main data model definition for the output of retrieving like records of a specific subject. + /// + /// - Note: According to the AT Protocol specifications: "Get like records which reference a + /// subject (by AT-URI and CID)." + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.getLikes`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getLikes.json + public struct GetLikesOutput: Codable { + + /// The URI of the record. + public let recordURI: String + + /// The CID hash of the record. + public let recordCID: String? + + /// The mark used to indicate the starting point for the next set of results. + public let cursor: String? + + /// An array of like records. + public let likes: [GetLikesLike] + + enum CodingKeys: String, CodingKey { + case recordURI = "uri" + case recordCID = "cid" + case cursor + case likes + } + } + + /// A data model definition of the like record itself. + public struct GetLikesLike: Codable { + + /// The date and time the like record was indexed. + @DateFormatting public var indexedAt: Date + + /// The date and time the like record was created. + @DateFormatting public var createdAt: Date + + /// The user that created the like record. + public let actor: ActorProfileView + + public init(indexedAt: Date, createdAt: Date, actor: ActorProfileView) { + self._indexedAt = DateFormatting(wrappedValue: indexedAt) + self._createdAt = DateFormatting(wrappedValue: createdAt) + self.actor = actor + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue + self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue + self.actor = try container.decode(ActorProfileView.self, forKey: .actor) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(self._indexedAt, forKey: .indexedAt) + try container.encode(self._createdAt, forKey: .createdAt) + try container.encode(self.actor, forKey: .actor) + } + + public enum CodingKeys: CodingKey { + case indexedAt + case createdAt + case actor + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetListFeed.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetListFeed.swift new file mode 100644 index 0000000000..820e3319b0 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetListFeed.swift @@ -0,0 +1,29 @@ +// +// AppBskyFeedGetListFeed.swift +// +// +// Created by Christopher Jr Riley on 2024-05-18. +// + +import Foundation + +extension AppBskyLexicon.Feed { + + /// The main data model definition for the output of retireving recent posts and reposts from + /// a given feed. + /// + /// - Note: According to the AT Protocol specifications: "Get a feed of recent posts from a + /// list (posts and reposts from any actors on the list). Does not require auth." + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.getListFeed`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getListFeed.json + public struct GetListFeedOutput: Codable { + + /// The mark used to indicate the starting point for the next set of results. Optional. + public let cursor: String? + + /// An array of posts in a feed. + public let feed: [FeedViewPostDefinition] + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetPostThread.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetPostThread.swift new file mode 100644 index 0000000000..117b076336 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetPostThread.swift @@ -0,0 +1,25 @@ +// +// AppBskyFeedGetPostThread.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.Feed { + + /// The main data model definition for the output of retrieving a post thread. + /// + /// - Note: According to the AT Protocol specifications: "Get posts in a thread. Does not require + /// auth, but additional metadata and filtering will be applied for authed requests." + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.getPostThread`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getPostThread.json + public struct GetPostThreadOutput: Codable { + + /// The post thread itself. + public let thread: FeedGetPostThreadUnion + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetPosts.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetPosts.swift new file mode 100644 index 0000000000..10be09d734 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetPosts.swift @@ -0,0 +1,26 @@ +// +// AppBskyFeedGetPosts.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.Feed { + + /// The main data model definition for the output of getting a hydrated array of posts. + /// + /// - Note: According to the AT Protocol specifications: "Gets post views for a specified list + /// of posts (by AT-URI). This is sometimes referred to as 'hydrating' + /// a 'feed skeleton'." + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.getPosts`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getPosts.json + public struct GetPostsOutput: Codable { + + /// An array of hydrated posts. + public let posts: [PostViewDefinition] + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetRepostedBy.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetRepostedBy.swift new file mode 100644 index 0000000000..dfd0001619 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetRepostedBy.swift @@ -0,0 +1,42 @@ +// +// AppBskyFeedGetRepostedBy.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.Feed { + + /// The main data model definition for the output of retrieving an array of users who have + /// reposted the given post. + /// + /// - Note: According to the AT Protocol specifications: "Get a list of reposts for a + /// given post." + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.getRepostedBy`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getRepostedBy.json + public struct GetRepostedByOutput: Codable { + + /// The URI of the post record. + public let postURI: String + + /// The CID hash of the post record. + public let postCID: String? + + /// The mark used to indicate the starting point for the next set of results. Optional. + public let cursor: String? + + /// An array of user accounts who reported the post record. + public let repostedBy: [AppBskyLexicon.Actor.ProfileViewDefinition] + + enum CodingKeys:String, CodingKey { + case postURI = "uri" + case postCID = "cid" + case cursor + case repostedBy + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetSuggestedFeeds.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetSuggestedFeeds.swift new file mode 100644 index 0000000000..92789d461f --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetSuggestedFeeds.swift @@ -0,0 +1,29 @@ +// +// AppBskyFeedGetSuggestedFeeds.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.Feed { + + /// The main data model definition for the output of getting a list of feed generators + /// suggested for the user account. + /// + /// - Note: According to the AT Protocol specifications: "Get a list of suggested feeds + /// (feed generators) for the requesting account." + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.getSuggestedFeeds`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getSuggestedFeeds.json + public struct FeedGetSuggestedFeedsOutput: Codable { + + /// The mark used to indicate the starting point for the next set of result. Optional. + public let cursor: String? + + /// An array of feed generators. + public let feeds: [GeneratorViewDefinition] + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetTimeline.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetTimeline.swift new file mode 100644 index 0000000000..ec62698edb --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetTimeline.swift @@ -0,0 +1,28 @@ +// +// AppBskyFeedGetTimeline.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.Feed { + + /// The main data model definition for the output of getting the user account's timeline. + /// + /// - Note: According to the AT Protocol specifications: "Get a view of the requesting account's + /// home timeline. This is expected to be some form of reverse-chronological feed." + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.getTimeline`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getTimeline.json + public struct FeedGetTimelineOutput: Codable { + + /// The mark used to indicate the starting point for the next set of results. Optional. + public let cursor: String? + + /// An array of post records. + public let feed: [FeedViewPostDefinition] + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedLike.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedLike.swift new file mode 100644 index 0000000000..984b3e929a --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedLike.swift @@ -0,0 +1,63 @@ +// +// AppBskyFeedLike.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.Feed { + + /// The record model definition for a like record. + /// + /// - Note: According to the AT Protocol specifications: "Record declaring a 'like' of a piece + /// of subject content." + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.like`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/like.json + public struct LikeRecord: ATRecordProtocol { + + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. + public static private(set) var type: String = "app.bsky.feed.like" + + /// The strong reference of the like. + /// + /// - Note: According to the AT Protocol specifications: "Record declaring a 'like' of a + /// piece of subject content." + public let subject: StrongReference + + /// The date the like record was created. + /// + /// This is the date where the user "liked" a post. + @DateFormatting public var createdAt: Date + + public init(subject: StrongReference, createdAt: Date) { + self.subject = subject + self._createdAt = DateFormatting(wrappedValue: createdAt) + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.subject = try container.decode(StrongReference.self, forKey: .subject) + self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.subject, forKey: .subject) + try container.encode(self._createdAt, forKey: .createdAt) + } + + enum CodingKeys: String, CodingKey { + case type = "$type" + case subject + case createdAt + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedPost.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedPost.swift new file mode 100644 index 0000000000..d7b6bf1a41 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedPost.swift @@ -0,0 +1,175 @@ +// +// AppBskyFeedPost.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.Feed { + + /// The record model definition for a post record. + /// + /// - Note: According to the AT Protocol specifications: "Record containing a Bluesky post." + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.post`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/post.json + public struct PostRecord: ATRecordProtocol { + + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. + public static private(set) var type: String = "app.bsky.feed.post" + + /// The text contained in the post. + /// + /// - Note: According to the AT Protocol specifications: "The primary post content. May be + /// an empty string, if there are embeds." + /// + /// - Important: Current maximum length is 300 characters. This library will automatically + /// truncate the `String` to the maximum length if it does go over the limit. + public let text: String + + /// An array of facets contained in the post's text. Optional. + /// + /// - Note: According to the AT Protocol specifications: "Annotations of text (mentions, URLs, + /// hashtags, etc)" + public var facets: [Facet]? + /// The references to posts when replying. Optional. + public var reply: PostReplyReference? + /// The embed of the post. Optional. + public var embed: EmbedUnion? + /// An array of languages the post text contains. Optional. + /// + /// - Note: According to the AT Protocol specifications: "Indicates human language of post + /// primary text content." + /// + /// - Important: Current maximum length is 3 languages. This library will automatically + /// truncate the `Array` to the maximum number of items if it does go over the limit. + public var languages: [String]? + /// An array of user-defined labels. Optional. + /// + /// - Note: According to the AT Protocol specifications: "Self-label values for this post. + /// Effectively content warnings." + public var labels: FeedLabelUnion? + /// An array of user-defined tags. Optional. + /// + /// - Note: According to the AT Protocol specifications: "Additional hashtags, in addition to + /// any included in post text and facets." + /// + /// - Important: Current maximum length is 8 tags. Current maximum length of the tag name is + /// 64 characters. This library will automatically truncate the `Array`and `String` + /// respectively to the maximum length if it does go over the limit. + public var tags: [String]? = nil + /// The date the post was created. + /// + /// - Note: According to the AT Protocol specifications: "Client-declared timestamp when this + /// post was originally created." + @DateFormatting public var createdAt: Date + + public init(text: String, facets: [Facet]? = nil, reply: PostReplyReference? = nil, embed: EmbedUnion? = nil, languages: [String]? = nil, + labels: FeedLabelUnion? = nil, tags: [String]? = nil, createdAt: Date) { + self.text = text + self.facets = facets + self.reply = reply + self.embed = embed + self.languages = languages + self.labels = labels + self.tags = tags + self._createdAt = DateFormatting(wrappedValue: createdAt) + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.text = try container.decode(String.self, forKey: .text) + self.facets = try container.decodeIfPresent([Facet].self, forKey: .facets) + self.reply = try container.decodeIfPresent(PostReplyReference.self, forKey: .reply) + self.embed = try container.decodeIfPresent(EmbedUnion.self, forKey: .embed) + self.languages = try container.decodeIfPresent([String].self, forKey: .languages) + self.labels = try container.decodeIfPresent(FeedLabelUnion.self, forKey: .labels) + self.tags = try container.decodeIfPresent([String].self, forKey: .tags) + self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + // try container.encode(self.type, forKey: .type) + try container.encode(self.text, forKey: .text) + // Truncate `tags` to 3000 characters before encoding + // `maxGraphemes`'s limit is 300, but `String.count` should respect that limit implictly + try truncatedEncode(self.text, withContainer: &container, forKey: .text, upToLength: 300) + try container.encodeIfPresent(self.facets, forKey: .facets) + try container.encodeIfPresent(self.reply, forKey: .reply) + try container.encodeIfPresent(self.embed, forKey: .embed) + // Truncate `langs` to 3 items before encoding. + try truncatedEncodeIfPresent(self.languages, withContainer: &container, forKey: .languages, upToLength: 3) + try container.encodeIfPresent(self.labels, forKey: .labels) + + // Truncate `tags` to 640 characters before encoding + // `maxGraphemes`'s limit is 64, but `String.count` should respect that limit implictly + // Then, truncate `tags` to 8 items before encoding + try truncatedEncodeIfPresent( + self.tags.map { $0.truncated(toLength: 640) }, + withContainer: &container, forKey: .tags, upToLength: 8) + + try container.encode(self._createdAt, forKey: .createdAt) + } + + enum CodingKeys: String, CodingKey { + case type = "$type" + case text + case entities + case facets + case reply + case embed + case languages = "langs" + case labels + case tags + case createdAt + } + } + + // MARK: - + /// A data model for a reply reference definition. + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.post`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/post.json + public struct PostReplyReference: Codable { + /// The original post of the thread. + public let root: StrongReference + /// The direct post that the user's post is replying to. + /// + /// - Note: If `parent` and `root` are identical, the post is a direct reply to the original + /// post of the thread. + public let parent: StrongReference + + public init(root: StrongReference, parent: StrongReference) { + self.root = root + self.parent = parent + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.root = try container.decode(StrongReference.self, forKey: .root) + self.parent = try container.decode(StrongReference.self, forKey: .parent) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.root, forKey: .root) + try container.encode(self.parent, forKey: .parent) + } + + enum CodingKeys: CodingKey { + case root + case parent + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedRepost.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedRepost.swift new file mode 100644 index 0000000000..e797e4130f --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedRepost.swift @@ -0,0 +1,60 @@ +// +// AppBskyFeedRepost.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.Feed { + + /// The record model definition for a repost record on Bluesky. + /// + /// - Note: According to the AT Protocol specifications: "Record representing a 'repost' of an + /// existing Bluesky post." + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.repost`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/repost.json + public struct RepostRecord: ATRecordProtocol { + + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. + public static private(set) var type: String = "app.bsky.feed.repost" + + /// The strong reference of the repost record. + public let subject: StrongReference + + /// The date the like record was created. + /// + /// This is the date where the user "liked" a post. + @DateFormatting public var createdAt: Date + + public init(subject: StrongReference, createdAt: Date) { + self.subject = subject + self._createdAt = DateFormatting(wrappedValue: createdAt) + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + self.subject = try container.decode(StrongReference.self, forKey: .subject) + self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.subject, forKey: .subject) + try container.encode(self._createdAt, forKey: .createdAt) + } + + enum CodingKeys: String, CodingKey { + case type = "$type" + case subject + case createdAt + } + } + +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedSearchPosts.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedSearchPosts.swift new file mode 100644 index 0000000000..35a45905dc --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedSearchPosts.swift @@ -0,0 +1,54 @@ +// +// AppBskyFeedSearchPosts.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.Feed { + + /// The main data model definition for the output of the results of the post search query. + /// + /// - Note: According to the AT Protocol specifications: "Find posts matching search criteria, + /// returning views of those posts." + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.searchPosts`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/searchPosts.json + public struct SearchPostsOutput: Codable { + + /// The mark used to indicate the starting point for the next set of results. Optional. + /// + /// - Note: According to the AT Protocol specifications: "Optional pagination mechanism; + /// may not necessarily allow scrolling through entire result set." + public let cursor: String? + + /// The number of times the query appears. Optional. + /// + /// - Note: According to the AT Protocol specifications: "Count of search hits. Optional, + /// may be rounded/truncated, and may not be possible to paginate through all hits." + public let hitsTotal: Int? + + /// An array of post records in the results. + public let posts: [PostViewDefinition] + } + + /// Determines the ranking order for the search results. + /// + /// - Note: According to the AT Protocol specifications: "Specifies the ranking order + /// of results." + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.searchPosts`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/searchPosts.json + public enum SortRanking: String { + + /// Indicates the results will be sorted by the top posts. + case top + + /// Indicates the results will be sorted by the latest posts. + case latest + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedSendInteractions.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedSendInteractions.swift new file mode 100644 index 0000000000..dfdb337359 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedSendInteractions.swift @@ -0,0 +1,32 @@ +// +// AppBskyFeedSendInteractions.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.Feed { + + /// The request body model definition for sending interactions to a feed generator. + /// + /// - Note: According to the AT Protocol specifications: "end information about interactions with + /// feed items back to the feed generator that served them." + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.sendInteractions`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/sendInteractions.json + public struct SendInteractionsRequestBody: Codable { + + /// An array of interactions. + public let interactions: [InteractionDefinition] + } + + /// The output model definition for sending interactions to a feed generator. + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.sendInteractions`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/sendInteractions.json + public struct SendInteractionsOutput: Codable {} +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedThreadgate.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedThreadgate.swift new file mode 100644 index 0000000000..b4e48e75d0 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedThreadgate.swift @@ -0,0 +1,90 @@ +// +// AppBskyFeedThreadgate.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.Feed { + + /// The main data model definition for a threadgate record. + /// + /// - Note: According to the AT Protocol specifications: "Record defining interaction gating rules + /// for a thread (aka, reply controls). The record key (rkey) of the threadgate record must match + /// the record key of the thread's root post, and that record must be in the same repository." + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.threadgate`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/threadgate.json + public struct ThreadgateRecord: ATRecordProtocol { + + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. + public static private(set) var type: String = "app.bsky.feed.threadgate" + + /// The URI of a post record. + /// + /// - Note: According to the AT Protocol specifications: "Reference (AT-URI) to the + /// post record." + public let post: String + + /// An array of rules used as an allowlist. + public let allow: [ThreadgateUnion] + + /// The date and time of the creation of the threadgate. + @DateFormatting public var createdAt: Date + + public init(post: String, allow: [ThreadgateUnion], createdAt: Date) { + self.post = post + self.allow = allow + self._createdAt = DateFormatting(wrappedValue: createdAt) + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.post = try container.decode(String.self, forKey: .post) + self.allow = try container.decode([ThreadgateUnion].self, forKey: .allow) + self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.post, forKey: .post) + try container.encode(self.allow, forKey: .allow) + try container.encode(self._createdAt, forKey: .createdAt) + } + + enum CodingKeys: String, CodingKey { + case type = "$type" + case post + case allow + case createdAt + } + } + + /// A rule that indicates whether users that the post author mentions can reply to the post. + /// + /// - Note: According to the AT Protocol specifications: "Allow replies from actors mentioned + /// in your post." + public struct FeedThreadgateMentionRule: Codable {} + + /// A rule that indicates whether users that the post author is following can reply to the post. + /// + /// - Note: According to the AT Protocol specifications: "Allow replies from actors you follow." + public struct FeedThreadgateFollowingRule: Codable {} + + /// A rule that indicates whether users that are on a specific list made by the post author can + /// reply to the post. + /// + /// - Note: According to the AT Protocol specifications: "Allow replies from actors on a list." + public struct FeedThreadgateListRule: Codable { + + /// The list itself. + public let list: String + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphBlock.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphBlock.swift new file mode 100644 index 0000000000..be67394afc --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphBlock.swift @@ -0,0 +1,61 @@ +// +// AppBskyGraphBlock.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.Graph { + + /// The main data model definition for a block record. + /// + /// - Note: According to the AT Protocol specifications: "Record declaring a 'block' + /// relationship against another account. NOTE: blocks are public in Bluesky; see + /// blog posts for details." + /// + /// - SeeAlso: This is based on the [`app.bsky.graph.block`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/block.json + public struct BlockRecord: ATRecordProtocol { + + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. + public static private(set) var type: String = "app.bsky.graph.block" + + /// The decentralized identifier(DID) of the subject that has been blocked. + /// + /// - Note: According to the AT Protocol specifications: "DID of the account to be blocked." + public let subjectDID: String + + /// The date and time the block record was created. + @DateFormatting public var createdAt: Date + + public init(subjectDID: String, createdAt: Date) { + self.subjectDID = subjectDID + self._createdAt = DateFormatting(wrappedValue: createdAt) + } + + public init(from decoder: any Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.subjectDID = try container.decode(String.self, forKey: .subjectDID) + self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue + } + + public func encode(to encoder: any Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.subjectDID, forKey: .subjectDID) + try container.encode(self._createdAt, forKey: .createdAt) + } + + enum CodingKeys: String, CodingKey { + case type = "$type" + case subjectDID = "subject" + case createdAt + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphDefs.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphDefs.swift new file mode 100644 index 0000000000..cf230bf931 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphDefs.swift @@ -0,0 +1,307 @@ +// +// AppBskyGraphDefs.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.Graph { + + /// A data model for a basic list view definition. + /// + /// - SeeAlso: This is based on the [`app.bsky.graph.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/defs.json + public struct ListViewBasicDefinition: Codable { + + /// The URI of a user list. + public let actorURI: String + + /// The CID of a user list. + public let cidHash: String + + /// The name of the list. + public let name: String + + /// The purpose of the user list. + /// + /// - Important: Current maximum length is 64 characters. This library will truncate the + /// `String` to the maximum number of characters if it does go over. + public let purpose: ListPurpose + + /// The avatar image URL of the user list. Optional. + public let avatarImageURL: URL? + + /// The viewer's state of the user list. Optional. + public var viewer: ListViewerStateDefinition? + + /// The late time the user list was indexed. + @DateFormattingOptional public var indexedAt: Date? + + public init(actorURI: String, cidHash: String, name: String, purpose: ListPurpose, avatarImageURL: URL?, viewer: ListViewerStateDefinition?, + indexedAt: Date?) { + self.actorURI = actorURI + self.cidHash = cidHash + self.name = name + self.purpose = purpose + self.avatarImageURL = avatarImageURL + self.viewer = viewer + self._indexedAt = DateFormattingOptional(wrappedValue: indexedAt) + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.actorURI = try container.decode(String.self, forKey: .actorURI) + self.cidHash = try container.decode(String.self, forKey: .cidHash) + self.name = try container.decode(String.self, forKey: .name) + self.purpose = try container.decode(ListPurpose.self, forKey: .purpose) + self.avatarImageURL = try container.decodeIfPresent(URL.self, forKey: .avatarImageURL) + self.viewer = try container.decodeIfPresent(ListViewerStateDefinition.self, forKey: .viewer) + self.indexedAt = try container.decodeIfPresent(DateFormattingOptional.self, forKey: .indexedAt)?.wrappedValue + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.actorURI, forKey: .actorURI) + try container.encode(self.cidHash, forKey: .cidHash) + try container.encode(self.name, forKey: .name) + // + try truncatedEncode(self.name, withContainer: &container, forKey: .name, upToLength: 64) + try container.encode(self.purpose, forKey: .purpose) + try container.encodeIfPresent(self.avatarImageURL, forKey: .avatarImageURL) + try container.encodeIfPresent(self.viewer, forKey: .viewer) + try container.encode(self._indexedAt, forKey: .indexedAt) + } + + enum CodingKeys: String, CodingKey { + case actorURI = "uri" + case cidHash = "cid" + case name = "name" + case purpose = "purpose" + case avatarImageURL = "avatar" + case viewer = "viewer" + case indexedAt + } + } + + /// A data model for a definition of the view of a user list. + /// + /// - SeeAlso: This is based on the [`app.bsky.graph.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/defs.json + public struct ListViewDefinition: Codable { + + /// The URI of the user list. + public let listURI: String + + /// The CID of the user list. + public let cidHash: String + + /// The creator of the user list. + public let creator: AppBskyLexicon.Actor.ProfileViewDefinition + + /// The name of the user list. + /// + /// - Important: Current maximum length is 64 characters. This library will truncate the + /// `String` to the maximum number of characters if it does go over. + public let name: String + + /// The purpose of the user list. + public let purpose: ListPurpose + + /// The description of the user list. Optional. + /// + /// - Important: Current maximum length is 300 characters. This library will truncate the + /// `String` to the maximum number of characters if it does go over. + public var description: String? + + /// An array of facets contained in the post's text. Optional. + public var descriptionFacets: [Facet]? + + /// The avatar image URL of the user list. Optional. + public var avatarImageURL: URL? + + /// The viewer's state of the user list. Optional. + public var viewer: ListViewerStateDefinition? + + /// The late time the user list was indexed. + @DateFormatting public var indexedAt: Date + + public init(listURI: String, cidHash: String, creator: AppBskyLexicon.Actor.ProfileViewDefinition, name: String, purpose: ListPurpose, description: String?, + descriptionFacets: [Facet]?, avatarImageURL: URL?, viewer: ListViewerStateDefinition?, indexedAt: Date) { + self.listURI = listURI + self.cidHash = cidHash + self.creator = creator + self.name = name + self.purpose = purpose + self.description = description + self.descriptionFacets = descriptionFacets + self.avatarImageURL = avatarImageURL + self.viewer = viewer + self._indexedAt = DateFormatting(wrappedValue: indexedAt) + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.listURI = try container.decode(String.self, forKey: .listURI) + self.cidHash = try container.decode(String.self, forKey: .cidHash) + self.creator = try container.decode(AppBskyLexicon.Actor.ProfileViewDefinition.self, forKey: .creator) + self.name = try container.decode(String.self, forKey: .name) + self.purpose = try container.decode(ListPurpose.self, forKey: .purpose) + self.description = try container.decodeIfPresent(String.self, forKey: .description) + self.descriptionFacets = try container.decodeIfPresent([Facet].self, forKey: .descriptionFacets) + self.avatarImageURL = try container.decodeIfPresent(URL.self, forKey: .avatarImageURL) + self.viewer = try container.decodeIfPresent(ListViewerStateDefinition.self, forKey: .viewer) + self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.listURI, forKey: .listURI) + try container.encode(self.cidHash, forKey: .cidHash) + try container.encode(self.creator, forKey: .creator) + // Truncate `name` to 64 characters before encoding. + try truncatedEncode(self.name, withContainer: &container, forKey: .name, upToLength: 64) + try container.encode(self.purpose, forKey: .purpose) + + // Truncate `description` to 3000 characters before encoding + // `maxGraphemes`'s limit is 300, but `String.count` should respect that limit + try truncatedEncodeIfPresent(self.description, withContainer: &container, forKey: .description, upToLength: 3000) + try container.encodeIfPresent(self.descriptionFacets, forKey: .descriptionFacets) + try container.encodeIfPresent(self.avatarImageURL, forKey: .avatarImageURL) + try container.encodeIfPresent(self.viewer, forKey: .viewer) + try container.encode(self._indexedAt, forKey: .indexedAt) + } + + enum CodingKeys: String, CodingKey { + case listURI = "uri" + case cidHash = "cid" + case creator = "creator" + case name = "name" + case purpose = "purpose" + case description = "description" + case descriptionFacets = "descriptionFacets" + case avatarImageURL = "avatar" + case viewer = "viewer" + case indexedAt = "indexedAt" + } + } + + /// A data model for the definition of an item with in a user list. + /// + /// - SeeAlso: This is based on the [`app.bsky.graph.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/defs.json + public struct ListItemViewDefinition: Codable { + + /// The URI of the user list item. + public let listItemURI: String + + /// A user in the user list item. + public let subject: AppBskyLexicon.Actor.ProfileViewDefinition + + enum CodingKeys: String, CodingKey { + case listItemURI = "uri" + case subject + } + } + + /// A data model of the definition of the user list's purpose. + /// + /// - SeeAlso: This is based on the [`app.bsky.graph.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/defs.json + public enum ListPurpose: String, Codable { + + /// An array of actors to apply an aggregate moderation action (mute/block) on. + /// + /// - Note: The documentation is taken directly from the lexicon itself. + case modlist = "app.bsky.graph.defs#modlist" + + /// An array of actors used for curation purposes such as list feeds or interaction gating. + /// + /// - Note: The documentation is taken directly from the lexicon itself. + case curatelist = "app.bsky.graph.defs#curatelist" + } + + + /// A data model of a definition for a viewer's state of a user list. + /// + /// - SeeAlso: This is based on the [`app.bsky.graph.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/defs.json + public struct ListViewerStateDefinition: Codable { + + /// Indicates whether the user is muted. Optional. + public var isMuted: Bool? + + /// The URI of the block record if the user has blocked the user list. Optional + public var blockedURI: String? + + enum CodingKeys: String, CodingKey { + case isMuted = "muted" + case blockedURI = "blocked" + } + } + + /// A data model for a definition of a user that may not have been found in the user list. + /// + /// - SeeAlso: This is based on the [`app.bsky.graph.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/defs.json + public struct NotFoundActorDefinition: Codable { + + /// The URI of the user. + /// + /// - Note: According to the AT Protocol specifications: "indicates that a handle or DID could + /// not be resolved", + public let actorURI: String + + /// Indicates whether the user is not found. + public let isNotFound: Bool + + enum CodingKeys: String, CodingKey { + case actorURI = "actor" + case isNotFound = "notFound" + } + } + + /// A data model for the graph relationship definition. + /// + /// - Note: According to the AT Protocol specifications: "lists the bi-directional graph + /// relationships between one actor (not indicated in the object), and the target actors (the DID + /// included in the object)" + /// + /// - SeeAlso: This is based on the [`app.bsky.graph.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/defs.json + public struct RelationshipDefinition: Codable { + + /// The decentralized identifier (DID) of the target user. + public let actorDID: String + + /// The URI of the follow record, if the first user is following the target user. Optional. + /// + /// - Note: According to the AT Protocol specifications: "if the actor follows this DID, this + /// is the AT-URI of the follow record" + public let followingURI: String? + + /// The URI of the follow record, if the target user is following the first user. Optional. + /// + /// - Note: According to the AT Protocol specifications: "if the actor is followed by this + /// DID, contains the AT-URI of the follow record" + public let followedByURI: String? + + enum CodingKeys: String, CodingKey { + case actorDID = "did" + case followingURI = "following" + case followedByURI = "followedBy" + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphFollow.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphFollow.swift new file mode 100644 index 0000000000..bb48c78efc --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphFollow.swift @@ -0,0 +1,56 @@ +// +// AppBskyGraphFollow.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.Graph { + /// The main data model definition for a follow record. + /// + /// - Note: According to the AT Protocol specifications: "Record declaring a social 'follow' + /// relationship of another account. Duplicate follows will be ignored by the AppView." + /// + /// - SeeAlso: This is based on the [`app.bsky.graph.follow`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/follow.json + public struct FollowRecord: ATRecordProtocol { + + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. + public static private(set) var type: String = "app.bsky.graph.follow" + + /// The subject that the user account wants to "follow." + public let subjectDID: String + + /// The date and time the record was created. + @DateFormatting public var createdAt: Date + + public init(subjectDID: String, createdAt: Date) { + self.subjectDID = subjectDID + self._createdAt = DateFormatting(wrappedValue: createdAt) + } + + public init(from decoder: any Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.subjectDID = try container.decode(String.self, forKey: .subjectDID) + self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue + } + + public func encode(to encoder: any Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.subjectDID, forKey: .subjectDID) + try container.encode(self._createdAt, forKey: .createdAt) + } + + enum CodingKeys: String, CodingKey { + case subjectDID = "subject" + case createdAt + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetBlocks.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetBlocks.swift new file mode 100644 index 0000000000..2ea01aad34 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetBlocks.swift @@ -0,0 +1,29 @@ +// +// AppBskyGraphGetBlocks.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.Graph { + + /// The main data model definition for the output of getting all of the users that have been + /// blocked by the user account. + /// + /// - Note: According to the AT Protocol specifications: "Enumerates which accounts the + /// requesting account is currently blocking. Requires auth." + /// + /// - SeeAlso: This is based on the [`app.bsky.graph.getBlocks`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/getBlocks.json + public struct GetBlocksOutput: Codable { + + /// The mark used to indicate the starting point for the next set of results. Optional. + public let cursor: String? + + /// An array of profiles that have been blocked by the user account. + public let blocks: [AppBskyLexicon.Actor.ProfileViewDefinition] + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetFollowers.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetFollowers.swift new file mode 100644 index 0000000000..daffabf13d --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetFollowers.swift @@ -0,0 +1,31 @@ +// +// AppBskyGraphGetFollowers.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.Graph { + + /// The main data model definition for the output of getting all of the user account's followers. + /// + /// - Note: According to the AT Protocol specifications: "Enumerates accounts which follow a + /// specified account (actor)." + /// + /// - SeeAlso: This is based on the [`app.bsky.graph.getFollowers`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/getFollowers.json + public struct GetFollowersOutput: Codable { + + /// The user account itself. + public let subject: AppBskyLexicon.Actor.ProfileViewDefinition + + /// The mark used to indicate the starting point for the next set of results. Optional. + public let cursor: String? + + /// An array of user accounts that follow the user account. + public let followers: [AppBskyLexicon.Actor.ProfileViewDefinition] + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetFollows.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetFollows.swift new file mode 100644 index 0000000000..4da75bc6a2 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetFollows.swift @@ -0,0 +1,32 @@ +// +// AppBskyGraphGetFollows.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.Graph { + + /// The main data model definition for the output for grabbing all of the accounts the user + /// account follows. + /// + /// - Note: According to the AT Protocol specifications: "Enumerates accounts which a specified + /// account (actor) follows." + /// + /// - SeeAlso: This is based on the [`app.bsky.graph.getFollows`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/getFollows.json + public struct GetFollowsOutput: Codable { + + /// The user account itself. + public let subject: AppBskyLexicon.Actor.ProfileViewDefinition + + /// The mark used to indicate the starting point for the next set of results. Optional. + public let cursor: String? + + /// An array of user accounts that the user account follows. + public let follows: [AppBskyLexicon.Actor.ProfileViewDefinition] + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetList.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetList.swift new file mode 100644 index 0000000000..f3f9753be9 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetList.swift @@ -0,0 +1,31 @@ +// +// AppBskyGraphGetList.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.Graph { + + /// The main data model definition for the output of grabbing the list view. + /// + /// - Note: According to the AT Protocol specifications: "Gets a 'view' (with additional context) + /// of a specified list." + /// + /// - SeeAlso: This is based on the [`app.bsky.graph.getList`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/getList.json + public struct GetListOutput: Codable { + + /// The mark used to indicate the starting point for the next set of results. Optional. + public let cursor: String? + + /// The metadata of the list. + public let list: ListViewDefinition + + /// An array of list items. + public let items: [ListItemViewDefinition] + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetListBlocks.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetListBlocks.swift new file mode 100644 index 0000000000..fddeeead23 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetListBlocks.swift @@ -0,0 +1,29 @@ +// +// AppBskyGraphGetListBlocks.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.Graph { + + /// The main data model definition for the output of getting the moderator lists that the user + /// account is blocking. + /// + /// - Note: According to the AT Protocol specifications: "Get mod lists that the requesting + /// account (actor) is blocking. Requires auth." + /// + /// - SeeAlso: This is based on the [`app.bsky.graph.getListBlocks`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/getListBlocks.json + public struct GetListBlocksOutput: Codable { + + /// The mark used to indicate the starting point for the next set of results. Optional. + public let cursor: String? + + /// An array of lists that the user account is blocking. + public let lists: [ListViewDefinition] + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetListMutes.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetListMutes.swift new file mode 100644 index 0000000000..fcfbacb924 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetListMutes.swift @@ -0,0 +1,29 @@ +// +// AppBskyGraphGetListMutes.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.Graph { + + /// The main data model definition for the output of grabbing the moderator list that the user + /// account is currently muting. + /// + /// - Note: According to the AT Protocol specifications: "Enumerates mod lists that the requesting + /// account (actor) currently has muted. Requires auth." + /// + /// - SeeAlso: This is based on the [`app.bsky.graph.getListMutes`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/getListMutes.json + public struct GetListMutesOutput: Codable { + + /// The mark used to indicate the starting point for the next set of results. Optional. + public let cursor: String? + + /// An array of lists the user account is muting. + public let lists: [GraphListView] + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetLists.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetLists.swift new file mode 100644 index 0000000000..6e399886ed --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetLists.swift @@ -0,0 +1,29 @@ +// +// AppBskyGraphGetLists.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.Graph { + + /// The main data model definition for the output of retrieving the lists created by the + /// user account. + /// + /// - Note: According to the AT Protocol specifications: "Enumerates the lists created by a + /// specified account (actor)." + /// + /// - SeeAlso: This is based on the [`app.bsky.graph.getLists`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/getLists.json + public struct GetListsOutput: Codable { + + /// The mark used to indicate the starting point for the next set of results. Optional. + public let cursor: String? + + /// An array of lists created by the user account. + public let lists: [ListViewDefinition] + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetMutes.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetMutes.swift new file mode 100644 index 0000000000..7ffa4ac129 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetMutes.swift @@ -0,0 +1,29 @@ +// +// AppBskyGraphGetMutes.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.Graph { + + /// The main data model definition for the output of retrieving all accounts the user account + /// is currently muting. + /// + /// - Note: According to the AT Protocol specifications: "Enumerates accounts that the + /// requesting account (actor) currently has muted. Requires auth." + /// + /// - SeeAlso: This is based on the [`app.bsky.graph.getMutes`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/getMutes.json + public struct GraphGetMutesOutput: Codable { + + /// The mark used to indicate the starting point for the next set of results. Optional. + public let cursor: String? + + /// An array of accounts the user account is muting. + public let mutes: [AppBskyLexicon.Actor.ProfileViewDefinition] + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetRelationships.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetRelationships.swift new file mode 100644 index 0000000000..323e01b491 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetRelationships.swift @@ -0,0 +1,29 @@ +// +// AppBskyGraphGetRelationships.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.Graph { + + /// The main data model definition for the output of the public relationship between two + /// user accounts. + /// + /// - Note: According to the AT Protocol specifications: "Enumerates public relationships between + /// one account, and a list of other accounts. Does not require auth." + /// + /// - SeeAlso: This is based on the [`app.bsky.graph.getRelationships`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/getRelationships.json + public struct GetRelationshipsOutput: Codable { + + /// The decentralized identifier (DID) of the user account. + public let actor: String? + + /// The metadata containing the relationship between mutliple user accounts. + public let relationships: [GraphRelationshipUnion] + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetSuggestedFollowsByActor.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetSuggestedFollowsByActor.swift new file mode 100644 index 0000000000..58a6195939 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetSuggestedFollowsByActor.swift @@ -0,0 +1,27 @@ +// +// AppBskyGraphGetSuggestedFollowsByActor.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.Graph { + + /// The main data model definition for the output of getting the list of user accounts that + /// requesting user account is suggested to follow. + /// + /// - Note: According to the AT Protocol specifications: "Enumerates follows similar to a given + /// account (actor). Expected use is to recommend additional accounts immediately after + /// following one account." + /// + /// - SeeAlso: This is based on the [`app.bsky.graph.getSuggestedFollowsByActor`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/getSuggestedFollowsByActor.json + public struct GraphGetSuggestedFollowsByActorOutput: Codable { + + /// An array of user accounts the requesting user account is suggested to follow. + public let suggestions: [AppBskyLexicon.Actor.ProfileViewDefinition] + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphList.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphList.swift new file mode 100644 index 0000000000..f2609b5442 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphList.swift @@ -0,0 +1,101 @@ +// +// AppBskyGraphList.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.Graph { + + /// The main data model definition for a list record. + /// + /// - Note: According to the AT Protocol specifications: "Record representing a list of + /// accounts (actors). Scope includes both moderation-oriented lists and + /// curration-oriented lists." + /// + /// - SeeAlso: This is based on the [`app.bsky.graph.list`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/list.json + public struct ListRecord: ATRecordProtocol { + + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. + public static private(set) var type: String = "app.bsky.graph.list" + + /// The name of the list. + /// + /// - Note: According to the AT Protocol specifications: "Display name for list; can not + /// be empty." + public let name: String + + /// The purpose of the list. + /// + /// - Note: According to the AT Protocol specifications: "Defines the purpose of the list + /// (aka, moderation-oriented or curration-oriented)." + public let purpose: ListPurpose + + /// The description of the list. Optional. + public let description: String? + + /// An array of facets contained within the description. Optional. + public let descriptionFacets: [Facet]? + + /// The avatar image of the list. Optional. + public let avatarImage: UploadBlobOutput? + + /// The user-defined labels for the list. Optional. + public let labels: SelfLabels + + /// The date and time the list was created. + @DateFormatting public var createdAt: Date + + public init(name: String, purpose: ListPurpose, description: String?, descriptionFacets: [Facet]?, avatarImage: UploadBlobOutput?, + labels: SelfLabels, createdAt: Date) { + self.name = name + self.purpose = purpose + self.description = description + self.descriptionFacets = descriptionFacets + self.avatarImage = avatarImage + self.labels = labels + self._createdAt = DateFormatting(wrappedValue: createdAt) + } + + public init(from decoder: any Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.name = try container.decode(String.self, forKey: .name) + self.purpose = try container.decode(ListPurpose.self, forKey: .purpose) + self.description = try container.decodeIfPresent(String.self, forKey: .description) + self.descriptionFacets = try container.decodeIfPresent([Facet].self, forKey: .descriptionFacets) + self.avatarImage = try container.decodeIfPresent(UploadBlobOutput.self, forKey: .avatarImage) + self.labels = try container.decode(SelfLabels.self, forKey: .labels) + self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue + } + + public func encode(to encoder: any Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.name, forKey: .name) + try container.encode(self.purpose, forKey: .purpose) + try container.encodeIfPresent(self.description, forKey: .description) + try container.encodeIfPresent(self.descriptionFacets, forKey: .descriptionFacets) + try container.encodeIfPresent(self.avatarImage, forKey: .avatarImage) + try container.encode(self.labels, forKey: .labels) + try container.encode(self._createdAt, forKey: .createdAt) + } + + enum CodingKeys: String, CodingKey { + case type = "$type" + case name + case purpose + case description + case descriptionFacets + case avatarImage = "avatar" + case labels + case createdAt + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphListblock.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphListblock.swift new file mode 100644 index 0000000000..b620efc2cf --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphListblock.swift @@ -0,0 +1,61 @@ +// +// AppBskyGraphListblock.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.Graph { + + /// The main data model definition for a blocking list record. + /// + /// - Note: According to the AT Protocol specifications: "Record representing a block + /// relationship against an entire [...] list of accounts (actors)." + /// + /// - SeeAlso: This is based on the [`app.bsky.graph.listblock`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/listblock.json + public struct ListBlockRecord: ATRecordProtocol { + + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. + public static private(set) var type: String = "app.bsky.graph.listblock" + + /// The decentralized identifier (DID) of the moderator list record. + /// + /// - Note: According to the AT Protocol specifications: "Reference (AT-URI) to the mod + /// list record." + public let subjectDID: String + + /// The date and time the record was created. + @DateFormatting public var createdAt: Date + + public init(subjectDID: String, createdAt: Date) { + self.subjectDID = subjectDID + self._createdAt = DateFormatting(wrappedValue: createdAt) + } + + public init(from decoder: any Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.subjectDID = try container.decode(String.self, forKey: .subjectDID) + self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue + } + + public func encode(to encoder: any Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.subjectDID, forKey: .subjectDID) + try container.encode(self._createdAt, forKey: .createdAt) + } + + enum CodingKeys: String, CodingKey { + case type = "$type" + case subjectDID = "subject" + case createdAt + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphListitem.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphListitem.swift new file mode 100644 index 0000000000..497cbf86e4 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphListitem.swift @@ -0,0 +1,71 @@ +// +// AppBskyGraphListitem.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.Graph { + + /// The main data model definition for a list item record. + /// + /// - Note: According to the AT Protocol specifications: "Record representing an account's + /// inclusion on a specific list. The AppView will ignore duplicate listitem records." + /// + /// - SeeAlso: This is based on the [`app.bsky.graph.listitem`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/listitem.json + public struct ListItemRecord: ATRecordProtocol { + + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. + public static private(set) var type: String = "app.bsky.graph.listitem" + + /// The decentralized identifier (DID) of the account that's in a list. + /// + /// - Note: According to the AT Protocol specifications: "The account which is included on + /// the list." + public let subjectDID: String + + /// The decentralized identifier (DID) of the list record. + /// + /// - Note: According to the AT Protocol specifications: "The account which is included on + /// the list." + public let list: String + + /// The date and time the record was created. + @DateFormatting public var createdAt: Date + + public init(subjectDID: String, list: String, createdAt: Date) { + self.subjectDID = subjectDID + self.list = list + self._createdAt = DateFormatting(wrappedValue: createdAt) + } + + public init(from decoder: any Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.subjectDID = try container.decode(String.self, forKey: .subjectDID) + self.list = try container.decode(String.self, forKey: .list) + self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue + } + + public func encode(to encoder: any Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.subjectDID, forKey: .subjectDID) + try container.encode(self.list, forKey: .list) + try container.encode(self._createdAt, forKey: .createdAt) + } + + enum CodingKeys: String, CodingKey { + case type = "$type" + case subjectDID = "subject" + case list + case createdAt + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphMuteActor.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphMuteActor.swift new file mode 100644 index 0000000000..2579c70d59 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphMuteActor.swift @@ -0,0 +1,29 @@ +// +// AppBskyGraphMuteActor.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.Graph { + + /// The request body data model definition for muting a user account. + /// + /// - Note: According to the AT Protocol specifications: "Creates a mute relationship for the + /// specified account. Mutes are private in Bluesky. Requires auth." + /// + /// - SeeAlso: This is based on the [`app.bsky.graph.muteActor`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/muteActor.json + public struct MuteActorRequestBody: Codable { + + /// The decentralized identifier (DID) or handle of a user account. + public let actorDID: String + + enum CodingKeys: String, CodingKey { + case actorDID = "actor" + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphMuteActorList.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphMuteActorList.swift new file mode 100644 index 0000000000..34649185c7 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphMuteActorList.swift @@ -0,0 +1,29 @@ +// +// AppBskyGraphMuteActorList.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.Graph { + + /// The main data model definition for muting a list. + /// + /// - Note: According to the AT Protocol specifications: "Creates a mute relationship for the + /// specified list of accounts. Mutes are private in Bluesky. Requires auth." + /// + /// - SeeAlso: This is based on the [`app.bsky.graph.muteActorList`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/muteActor.json + public struct MuteActorListRequestBody: Codable { + + /// The URI of a list. + public let listURI: String + + enum CodingKeys: String, CodingKey { + case listURI = "list" + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphUnmuteActor.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphUnmuteActor.swift new file mode 100644 index 0000000000..149f259c6b --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphUnmuteActor.swift @@ -0,0 +1,29 @@ +// +// AppBskyGraphUnmuteActor.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.Graph { + + /// The main data model definition for unmuting a user account. + /// + /// - Note: According to the AT Protocol specifications: "Unmutes the specified account. + /// Requires auth." + /// + /// - SeeAlso: This is based on the [`app.bsky.graph.unmuteActor`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/unmuteActor.json + public struct GraphUnmuteActorRequestBody: Codable { + + /// The decentralized identifier (DID) or handle of a user account. + public let actorDID: String + + enum CodingKeys: String, CodingKey { + case actorDID = "actor" + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphUnmuteActorList.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphUnmuteActorList.swift new file mode 100644 index 0000000000..fcfa22fe99 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphUnmuteActorList.swift @@ -0,0 +1,29 @@ +// +// AppBskyGraphUnmuteActorList.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.Graph { + + /// The main data model definition for unmuting a list of user accounts. + /// + /// - Note: According to the AT Protocol specifications: "Unmutes the specified list of + /// accounts. Requires auth." + /// + /// - SeeAlso: This is based on the [`app.bsky.graph.unmuteActorList`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/unmuteActorList.json + public struct UnmuteActorListRequestBody: Codable { + + /// The URI of a list. + public let listURI: String + + enum CodingKeys: String, CodingKey { + case listURI = "list" + } + } +} From f04a9e4fd2f7a3996311f2b4d86d9efe59c7d69a Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Sun, 19 May 2024 03:36:39 -0400 Subject: [PATCH 06/51] Convert lexicons to new layout The following have been converted: - app.bsky.labeler.* - app.bsky.notification.* Various fixes from the converted lexicons have also been fixed. --- .../app.bsky/Actor/AppBskyActorDefs.swift | 4 +- .../app.bsky/Labeler/AppBskyLabelerDefs.swift | 207 ++++++++++++++++++ .../Labeler/AppBskyLabelerGetServices.swift | 25 +++ .../Labeler/AppBskyLabelerService.swift | 65 ++++++ .../AppBskyNotificationGetUnreadCount.swift | 25 +++ ...AppBskyNotificationListNotifications.swift | 144 ++++++++++++ .../AppBskyNotificationRegisterPush.swift | 55 +++++ .../AppBskyNotificationUpdateSeen.swift | 45 ++++ 8 files changed, 568 insertions(+), 2 deletions(-) create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerDefs.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerGetServices.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerService.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/AppBskyNotificationGetUnreadCount.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/AppBskyNotificationListNotifications.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/AppBskyNotificationRegisterPush.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/AppBskyNotificationUpdateSeen.swift diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorDefs.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorDefs.swift index dd7b8ca654..e211d63399 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorDefs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorDefs.swift @@ -353,7 +353,7 @@ extension AppBskyLexicon.Actor { public let isMuted: Bool? /// An array of lists that the subject account is muted by. - public let mutedByArray: GraphListViewBasic? + public let mutedByArray: AppBskyLexicon.Graph.ListViewBasicDefinition? /// Indicates whether the requesting account has been blocked by the subject /// account. Optional. @@ -363,7 +363,7 @@ extension AppBskyLexicon.Actor { public let blockingURI: String? /// An array of the subject account's lists. - public let blockingByArray: GraphListViewBasic? + public let blockingByArray: AppBskyLexicon.Graph.ListViewBasicDefinition? /// A URI which indicates the user is following the requesting account. public let followingURI: String? diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerDefs.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerDefs.swift new file mode 100644 index 0000000000..dc8c1882e7 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerDefs.swift @@ -0,0 +1,207 @@ +// +// AppBskyLabelerDefs.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.Labeler { + + /// A data model definition for a labeler view. + /// + /// - SeeAlso: This is based on the [`app.bsky.labeler.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/labeler/defs.json + public struct LabelerViewDefinition: Codable { + + /// The URI of the labeler. + public let labelerURI: String + + /// The CID hash of the labeler. + public let labelerCIDHash: String + + /// The creator of the labeler. + public let creator: AppBskyLexicon.Actor.ProfileViewDefinition + + /// The number of likes for the labeler. Optional. + public let likeCount: Int? + + /// The viewer state of the labeler. Optional. + public let viewer: LabelerViewerStateDefinition? + + /// The date and time the labeler was last indexed. + @DateFormatting public var indexedAt: Date + + /// An array of labels. Optional. + public let labels: [Label]? + + public init(labelerURI: String, labelerCIDHash: String, creator: AppBskyLexicon.Actor.ProfileViewDefinition, likeCount: Int?, viewer: LabelerViewerStateDefinition?, indexedAt: Date, labels: [Label]?) { + self.labelerURI = labelerURI + self.labelerCIDHash = labelerCIDHash + self.creator = creator + self.likeCount = likeCount + self.viewer = viewer + self._indexedAt = DateFormatting(wrappedValue: indexedAt) + self.labels = labels + } + + public init(from decoder: any Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.labelerURI = try container.decode(String.self, forKey: .labelerURI) + self.labelerCIDHash = try container.decode(String.self, forKey: .labelerCIDHash) + self.creator = try container.decode(AppBskyLexicon.Actor.ProfileViewDefinition.self, forKey: .creator) + self.likeCount = try container.decodeIfPresent(Int.self, forKey: .likeCount) + self.viewer = try container.decodeIfPresent(LabelerViewerStateDefinition.self, forKey: .viewer) + self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue + self.labels = try container.decodeIfPresent([Label].self, forKey: .labels) + } + + public func encode(to encoder: any Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.labelerURI, forKey: .labelerURI) + try container.encode(self.labelerCIDHash, forKey: .labelerCIDHash) + try container.encode(self.creator, forKey: .creator) + + // Assuming `likeCount` is not nil, only encode it if it's 0 or higher + if let likeCount = self.likeCount, likeCount >= 0 { + try container.encode(likeCount, forKey: .likeCount) + } + try container.encodeIfPresent(self.viewer, forKey: .viewer) + try container.encode(self._indexedAt, forKey: .indexedAt) + try container.encodeIfPresent(self.labels, forKey: .labels) + } + + enum CodingKeys: String, CodingKey { + case labelerURI = "uri" + case labelerCIDHash = "cid" + case creator + case likeCount + case viewer + case indexedAt + case labels + } + } + + /// A data model definition for a detailed labeler view. + /// + /// - SeeAlso: This is based on the [`app.bsky.labeler.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/labeler/defs.json + public struct LabelerViewDetailedDefinition: Codable { + + /// The URI of the labeler. + public let labelerURI: String + + /// The CID hash of the labeler. + public let labelerCIDHash: String + + /// The creator of the labeler. + public let creator: AppBskyLexicon.Actor.ProfileViewDefinition + + /// A list of policies by the labeler. + public let policies: LabelerPolicies + + /// The number of likes for the labeler. Optional. + public let likeCount: Int? + + /// The viewer state of the labeler. Optional. + public let viewer: LabelerViewerState? + + /// The date and time the labeler was last indexed. + @DateFormatting public var indexedAt: Date + + /// An array of labels. Optional. + public let labels: [Label]? + + public init(labelerURI: String, labelerCIDHash: String, creator: AppBskyLexicon.Actor.ProfileViewDefinition, policies: LabelerPolicies, likeCount: Int?, viewer: LabelerViewerState?, indexedAt: Date, labels: [Label]?) { + self.labelerURI = labelerURI + self.labelerCIDHash = labelerCIDHash + self.creator = creator + self.policies = policies + self.likeCount = likeCount + self.viewer = viewer + self._indexedAt = DateFormatting(wrappedValue: indexedAt) + self.labels = labels + } + + public init(from decoder: any Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.labelerURI = try container.decode(String.self, forKey: .labelerURI) + self.labelerCIDHash = try container.decode(String.self, forKey: .labelerCIDHash) + self.creator = try container.decode(AppBskyLexicon.Actor.ProfileViewDefinition.self, forKey: .creator) + self.policies = try container.decode(LabelerPolicies.self, forKey: .policies) + self.likeCount = try container.decodeIfPresent(Int.self, forKey: .likeCount) + self.viewer = try container.decodeIfPresent(LabelerViewerState.self, forKey: .viewer) + self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue + self.labels = try container.decodeIfPresent([Label].self, forKey: .labels) + } + + public func encode(to encoder: any Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.labelerURI, forKey: .labelerURI) + try container.encode(self.labelerCIDHash, forKey: .labelerCIDHash) + try container.encode(self.creator, forKey: .creator) + try container.encode(self.policies, forKey: .policies) + + // Assuming `likeCount` is not nil, only encode it if it's 0 or higher + if let likeCount = self.likeCount, likeCount >= 0 { + try container.encode(likeCount, forKey: .likeCount) + } + try container.encodeIfPresent(self.viewer, forKey: .viewer) + try container.encode(self._indexedAt, forKey: .indexedAt) + try container.encodeIfPresent(self.labels, forKey: .labels) + } + + enum CodingKeys: String, CodingKey { + case labelerURI = "uri" + case labelerCIDHash = "cid" + case creator + case policies + case likeCount + case viewer + case indexedAt + case labels + } + } + + /// A data model definition for a user account's view state for the labeler. + /// + /// - SeeAlso: This is based on the [`app.bsky.labeler.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/labeler/defs.json + public struct LabelerViewerStateDefinition: Codable { + + /// The URI of the like record, if the user liked the labeler. + public let like: String + } + + /// A data model definition for a labeler's policies. + /// + /// - SeeAlso: This is based on the [`app.bsky.labeler.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/labeler/defs.json + public struct LabelerPolicies: Codable { + + /// An array of the labeler-published values. + /// + /// - Note: According to the AT Protocol specifications: "The label values which this labeler + /// publishes. May include global + /// or custom labels." + public let labelValues: [LabelValueDefinition] + + /// An array of labeler-created labels. + /// + /// Labels made in here will override global definitions. + /// + /// - Note: According to the AT Protocol specifications: "Label values created by this labeler + /// and scoped exclusively to it. Labels defined here will override global label definitions + /// for this labeler." + public let labelValueDefinitions: [LabelValueDefinition] + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerGetServices.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerGetServices.swift new file mode 100644 index 0000000000..0057970c4e --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerGetServices.swift @@ -0,0 +1,25 @@ +// +// AppBskyLabelerGetServices.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.Labeler { + + /// The main data model definition for the output of the labeler service information. + /// + /// - Note: According to the AT Protocol specifications: "Get information about a list of + /// labeler services." + /// + /// - SeeAlso: This is based on the [`app.bsky.labeler.getServices`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/labeler/getServices.json + public struct LabelerGetServicesOutput: Codable { + + /// A labeler view. + public let views: LabelerViewUnion + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerService.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerService.swift new file mode 100644 index 0000000000..01320b917b --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerService.swift @@ -0,0 +1,65 @@ +// +// AppBskyLabelerService.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.Labeler { + + /// The main data model definition for a labeler service record. + /// + /// - Note: According to the AT Protocol specifications: "A declaration of the existence of + /// labeler service." + /// + /// - SeeAlso: This is based on the [`app.bsky.labeler.service`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/labeler/service.json + public struct LabelerServiceRecord: ATRecordProtocol { + + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. + public static private(set) var type: String = "app.bsky.labeler.service" + + /// The policies the labeler service adheres to. + public let policies: LabelerPolicies + + /// An array of labels the labeler uses. Optional. + public let labels: [SelfLabels]? + + /// The date and time the labeler service was created. + @DateFormatting public var createdAt: Date + + public init(policies: LabelerPolicies, labels: [SelfLabels], createdAt: Date) { + self.policies = policies + self.labels = labels + self._createdAt = DateFormatting(wrappedValue: createdAt) + } + + public init(from decoder: any Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.policies = try container.decode(LabelerPolicies.self, forKey: .policies) + self.labels = try container.decode([SelfLabels].self, forKey: .labels) + self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue + } + + public func encode(to encoder: any Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.policies, forKey: .policies) + try container.encode(self.labels, forKey: .labels) + try container.encode(self._createdAt, forKey: .createdAt) + } + + enum CodingKeys: String, CodingKey { + case type = "$type" + case policies + case labels + case createdAt + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/AppBskyNotificationGetUnreadCount.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/AppBskyNotificationGetUnreadCount.swift new file mode 100644 index 0000000000..f4a0e7da3a --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/AppBskyNotificationGetUnreadCount.swift @@ -0,0 +1,25 @@ +// +// AppBskyNotificationGetUnreadCount.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.Notification { + + /// The main data model definition for the output of counting the unread notifications. + /// + /// - Note: According to the AT Protocol specifications: "Count the number of unread + /// notifications for the requesting account. Requires auth." + /// + /// - SeeAlso: This is based on the [`app.bsky.notification.getUnreadCount`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/notification/getUnreadCount.json + public struct GetUnreadCountOutput: Codable { + + /// The number of unread notifications. + public let count: Int + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/AppBskyNotificationListNotifications.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/AppBskyNotificationListNotifications.swift new file mode 100644 index 0000000000..55fc199566 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/AppBskyNotificationListNotifications.swift @@ -0,0 +1,144 @@ +// +// AppBskyNotificationListNotifications.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.Notification { + + /// The main data model definition for the output of listing notifications. + /// + /// - Note: According to the AT Protocol specifications: "Enumerate notifications for the + /// requesting account. Requires auth." + /// + /// - SeeAlso: This is based on the [`app.bsky.notification.listNotifications`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/notification/listNotifications.json + public struct ListNotificationsOutput: Codable { + + /// The mark used to indicate the starting point for the next set of results. Optional. + public let cursor: String? + + /// An array of notifications. + public let notifications: [Notification] + } + + /// A data model definition for a notification. + /// + /// - SeeAlso: This is based on the [`app.bsky.notification.listNotifications`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/notification/listNotifications.json + public struct Notification: Codable { + + /// The URI of the notification. + public let notificationURI: String + + /// The CID hash of the notification. + public let notificationCID: String + + /// The author of the record contained in the notification. + public let notificationAuthor: String + + /// The kind of notification received. + /// + /// - Note: According to the AT Protocol specifications: "Expected values are 'like', + /// 'repost', 'follow', 'mention', 'reply', and 'quote'." + public let notificationReason: Reason + + /// The URI of the subject in the notification. Optional. + public let reasonSubjectURI: String? + + /// The record itself that's attached to the notification. + public let record: UnknownType + + /// Indicates whether or not this notification was read. + public let isRead: Bool + + /// The date and time the notification was last indexed. + @DateFormatting public var indexedAt: Date + + /// An array of labels. Optional. + public let labels: [Label]? + + public init(notificationURI: String, notificationCID: String, notificationAuthor: String, notificationReason: Reason, reasonSubjectURI: String, + record: UnknownType, isRead: Bool, indexedAt: Date, labels: [Label]) { + self.notificationURI = notificationURI + self.notificationCID = notificationCID + self.notificationAuthor = notificationAuthor + self.notificationReason = notificationReason + self.reasonSubjectURI = reasonSubjectURI + self.record = record + self.isRead = isRead + self._indexedAt = DateFormatting(wrappedValue: indexedAt) + self.labels = labels + } + + public init(from decoder: any Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.notificationURI = try container.decode(String.self, forKey: .notificationURI) + self.notificationCID = try container.decode(String.self, forKey: .notificationCID) + self.notificationAuthor = try container.decode(String.self, forKey: .notificationAuthor) + self.notificationReason = try container.decode(Notification.Reason.self, forKey: .notificationReason) + self.reasonSubjectURI = try container.decodeIfPresent(String.self, forKey: .reasonSubjectURI) + self.record = try container.decode(UnknownType.self, forKey: .record) + self.isRead = try container.decode(Bool.self, forKey: .isRead) + self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue + self.labels = try container.decodeIfPresent([Label].self, forKey: .labels) + } + + public func encode(to encoder: any Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.notificationURI, forKey: .notificationURI) + try container.encode(self.notificationCID, forKey: .notificationCID) + try container.encode(self.notificationAuthor, forKey: .notificationAuthor) + try container.encode(self.notificationReason, forKey: .notificationReason) + try container.encodeIfPresent(self.reasonSubjectURI, forKey: .reasonSubjectURI) + try container.encode(self.record, forKey: .record) + try container.encode(self.isRead, forKey: .isRead) + try container.encode(self._indexedAt, forKey: .indexedAt) + try container.encodeIfPresent(self.labels, forKey: .labels) + } + + enum CodingKeys: String, CodingKey { + case notificationURI = "uri" + case notificationCID = "cid" + case notificationAuthor = "author" + case notificationReason = "reason" + case reasonSubjectURI = "reasonSubject" + case record + case isRead + case indexedAt + case labels + } + + // Enums + /// The kind of notification received. + public enum Reason: String, Codable { + + /// Indicates the notification is about someone liking a post from the user account. + case like + + /// Indicates the notification is about someone reposting a post from the + /// user account. + case repost + + /// Indicates the notification is about someone following the user account. + case follow + + /// Indicates the notification is about someone @mentioning the user account. + case mention + + /// Indicates the notification is about someone replying to one of the + /// user account's posts. + case reply + + /// Indicates the notification is about someone quoting a post from the user account. + case quote + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/AppBskyNotificationRegisterPush.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/AppBskyNotificationRegisterPush.swift new file mode 100644 index 0000000000..639c089e73 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/AppBskyNotificationRegisterPush.swift @@ -0,0 +1,55 @@ +// +// AppBskyNotificationRegisterPush.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.Notification { + + /// The main data model definition for registering push notifications. + /// + /// - Note: According to the AT Protocol specifications: "Register to receive + /// push notifications, via a specified service, for the requesting account. + /// Requires auth." + /// + /// - SeeAlso: This is based on the [`app.bsky.notification.registerPush`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/notification/registerPush.json + public struct RegisterPushRequest: Codable { + + /// The decentralized identifier (DID) for the push notification request. + public let serviceDID: String + + /// The push notification token. + public let token: String + + /// The platform for the push notifications. + public let platform: Platform + + /// The app ID for the push notification. + public let appID: String + + /// Represents the platform for the push notifications. + public enum Platform: String, Codable { + + /// Indicates iOS as the platform. + case ios + + /// Indicates Android as the platform. + case android + + /// Indicates the web as the platform. + case web + } + + enum CodingKeys: String, CodingKey { + case serviceDID = "serviceDid" + case token + case platform + case appID = "appId" + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/AppBskyNotificationUpdateSeen.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/AppBskyNotificationUpdateSeen.swift new file mode 100644 index 0000000000..64a7da6cd2 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/AppBskyNotificationUpdateSeen.swift @@ -0,0 +1,45 @@ +// +// AppBskyNotificationUpdateSeen.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.Notification { + + /// The main data model definition for updating the server of the user seeing the notification. + /// + /// - Note: According to the AT Protocol specifications: "Notify server that the requesting + /// account has seen notifications. Requires auth." + /// + /// - SeeAlso: This is based on the [`app.bsky.notification.updateSeen`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/notification/updateSeen.json + public struct NotificationUpdateSeen: Codable { + + /// The date and time the notification was seen by the user account. + @DateFormatting public var seenAt: Date + + public init(seenAt: Date) { + self._seenAt = DateFormatting(wrappedValue: seenAt) + } + + public init(from decoder: any Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.seenAt = try container.decode(DateFormatting.self, forKey: .seenAt).wrappedValue + } + + public func encode(to encoder: any Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self._seenAt, forKey: .seenAt) + } + + enum CodingKeys: CodingKey { + case seenAt + } + } +} From a02278d4fc145869bb927c4236f2184d99086490 Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Sun, 19 May 2024 04:17:24 -0400 Subject: [PATCH 07/51] Convert lexicons to new layout The following have been converted: - app.bsky.richtext.* - app.bsky.unspecced.* --- .../Lexicons/app.bsky/AppBskyLexicon.swift | 3 + .../RichText/AppBskyRichTextFacet.swift | 239 ++++++++++++++++++ .../Unspecced/AppBskyUnspeccedDefs.swift | 47 ++++ ...skyUnspeccedGetPopularFeedGenerators.swift | 31 +++ ...pBskyUnspeccedGetSuggestionsSkeleton.swift | 31 +++ ...AppBskyUnspeccedGetTaggedSuggestions.swift | 87 +++++++ ...AppBskyUnspeccedSearchActorsSkeleton.swift | 40 +++ .../AppBskyUnspeccedSearchPostsSkeleton.swift | 58 +++++ 8 files changed, 536 insertions(+) create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/RichText/AppBskyRichTextFacet.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedDefs.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedGetPopularFeedGenerators.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedGetSuggestionsSkeleton.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedGetTaggedSuggestions.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedSearchActorsSkeleton.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedSearchPostsSkeleton.swift diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/AppBskyLexicon.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/AppBskyLexicon.swift index b3b95dfbc8..0379aaf7b2 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/AppBskyLexicon.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/AppBskyLexicon.swift @@ -28,6 +28,9 @@ extension AppBskyLexicon { /// A group of lexicons within the `app.bsky.notification` namespace. public struct Notification {} + /// A group of lexicons within the `app.bsky.richtext` namespace. + public struct RichText {} + /// A group of lexicons within the `app.bsky.unspecced` namespace. public struct Unspecced {} } diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/RichText/AppBskyRichTextFacet.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/RichText/AppBskyRichTextFacet.swift new file mode 100644 index 0000000000..6ae27c005c --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/RichText/AppBskyRichTextFacet.swift @@ -0,0 +1,239 @@ +// +// AppBskyRichTextFacet.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.RichText { + + /// The main data model definition for a facet. + /// + /// - Note: According to the AT Protocol specifications: "Annotation of a sub-string within + /// rich text." + /// + /// - SeeAlso: This is based on the [`app.bsky.richtext.facet`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/richtext/facet.json + public struct Facet: Codable { + + /// The range of characters related to the facet. + public let index: ByteSlice + + /// The facet's feature type. + public let features: [FeatureUnion] + + public init(index: ByteSlice, features: [FeatureUnion]) { + self.index = index + self.features = features + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.index = try container.decode(ByteSlice.self, forKey: .index) + self.features = try container.decode([FeatureUnion].self, forKey: .features) + } + + public func encode(to encoder: Encoder) throws { + + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.index, forKey: .index) + try container.encode(self.features, forKey: .features) + } + + enum CodingKeys: String, CodingKey { + case index + case features + } + } + + // Represents the ByteSlice + /// The data model definition for the byte slice. + /// + /// - Note: According to the AT Protocol specifications: "Specifies the sub-string range a + /// facet feature applies to. Start index is inclusive, end index is exclusive. Indices are + /// zero-indexed, counting bytes of the UTF-8 encoded text. NOTE: some languages, like + /// Javascript, use UTF-16 or Unicode codepoints for string slice indexing; in these + /// languages, convert to byte arrays before working with facets." + /// + /// - SeeAlso: This is based on the [`app.bsky.richtext.facet`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/richtext/facet.json + public struct ByteSlice: Codable { + + /// The start index of the byte slice. + public let byteStart: Int + + /// The end index of the byte slice. + public let byteEnd: Int + + public init(byteStart: Int, byteEnd: Int) { + self.byteStart = byteStart + self.byteEnd = byteEnd + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + self.byteStart = try container.decode(Int.self, forKey: .byteStart) + self.byteEnd = try container.decode(Int.self, forKey: .byteEnd) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(self.byteStart, forKey: .byteStart) + try container.encode(self.byteEnd, forKey: .byteEnd) + } + + enum CodingKeys: String, CodingKey { + case byteStart + case byteEnd + } + } + + /// A data model protocol for Features. + /// + /// - SeeAlso: This is based on the [`app.bsky.richtext.facet`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/richtext/facet.json + internal protocol FeatureCodable: Codable { + + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. + static var type: String { get } + } + + + /// A data model for the Mention feature definition. + /// + /// - Note: According to the AT Protocol specifications: "Facet feature for mention of + /// another account. The text is usually a handle, including a '@' prefix, but the facet + /// reference is a DID." + /// + /// - SeeAlso: This is based on the [`app.bsky.richtext.facet`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/richtext/facet.json + public struct Mention: FeatureCodable { + + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. + public static var type: String = "app.bsky.richtext.facet#mention" + + /// The decentralized identifier (DID) of the feature. + public let did: String + + public init(did: String) { + self.did = did + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.did = try container.decode(String.self, forKey: .did) + Mention.type = try container.decode(String.self, forKey: .type) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.did, forKey: .did) + try container.encode(Mention.type, forKey: .type) + } + + enum CodingKeys: String, CodingKey { + case type = "$type" + case did + } + } + + + /// A data model for the Link feature definition. + /// + /// - Note: According to the AT Protocol specifications: "Facet feature for a URL. The text URL + /// may have been simplified or truncated, but the facet reference should be a complete URL." + /// + /// - SeeAlso: This is based on the [`app.bsky.richtext.facet`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/richtext/facet.json + public struct Link: FeatureCodable { + + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. + public static var type: String = "app.bsky.richtext.facet#link" + + /// The URI of the feature. + public let uri: String + + public init(uri: String) { + self.uri = uri + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.uri = try container.decode(String.self, forKey: .uri) + Link.type = try container.decode(String.self, forKey: .type) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.uri, forKey: .uri) + try container.encode(Link.type, forKey: .type) + } + + enum CodingKeys: String, CodingKey { + case type = "$type" + case uri + } + } + + /// A data model for the Tag feature definition. + /// + /// - Note: According to the AT Protocol specifications: "Facet feature for a hashtag. The text + /// usually includes a '#' prefix, but the facet reference should not (except in the case of + /// 'double hash tags')." + /// + /// - SeeAlso: This is based on the [`app.bsky.richtext.facet`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/richtext/facet.json + public struct Tag: FeatureCodable { + + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. + public static var type: String = "app.bsky.richtext.facet#tag" + + /// The + public let tag: String + + public init(tag: String) { + self.tag = tag + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.tag = try container.decode(String.self, forKey: .tag) + Tag.type = try container.decode(String.self, forKey: .type) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.tag, forKey: .tag) + try container.encode(Tag.type, forKey: .type) + } + + enum CodingKeys: String, CodingKey { + case type = "$type" + case tag + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedDefs.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedDefs.swift new file mode 100644 index 0000000000..68b9de9993 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedDefs.swift @@ -0,0 +1,47 @@ +// +// AppBskyUnspeccedDefs.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.Unspecced { + + /// A data model definition for a skeleton search post. + /// + /// - Important: This is an unspecced model, and as such, this is highly volatile and may + /// change or be removed at any time. Use at your own risk. + /// + /// - SeeAlso: This is based on the [`app.bsky.unspecced.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/unspecced/defs.json + public struct SkeletonSearchPostDefinition: Codable { + + /// The URI of the skeleton search post. + public let postURI: String + + enum CodingKeys: String, CodingKey { + case postURI = "uri" + } + } + + /// A data model definition for a skeleton search post. + /// + /// - Important: This is an unspecced model, and as such, this is highly volatile and may + /// change or be removed at any time. Use at your own risk. + /// + /// - SeeAlso: This is based on the [`app.bsky.unspecced.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/unspecced/defs.json + public struct SkeletonSearchActorDefinition: Codable { + + /// The URI of the skeleton search actor. + public let actorDID: String + + enum CodingKeys: String, CodingKey { + case actorDID = "did" + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedGetPopularFeedGenerators.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedGetPopularFeedGenerators.swift new file mode 100644 index 0000000000..aa1fe94b5d --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedGetPopularFeedGenerators.swift @@ -0,0 +1,31 @@ +// +// AppBskyUnspeccedGetPopularFeedGenerators.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.Unspecced { + + /// The main data model definition for the output of globally popular feed generators. + /// + /// - Note: According to the AT Protocol specifications: "An unspecced view of globally + /// popular feed generators." + /// + /// - Important: This is an unspecced model, and as such, this is highly volatile and may + /// change or be removed at any time. Use at your own risk. + /// + /// - SeeAlso: This is based on the [`app.bsky.unspecced.getPopularFeedGenerators`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/unspecced/getPopularFeedGenerators.json + public struct GetPopularFeedGeneratorsOutput: Codable { + + /// The mark used to indicate the starting point for the next set of result. Optional. + public let cursor: String? + + /// An array of feed generators. + public let feeds: [AppBskyLexicon.Feed.GeneratorViewDefinition] + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedGetSuggestionsSkeleton.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedGetSuggestionsSkeleton.swift new file mode 100644 index 0000000000..21200454bb --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedGetSuggestionsSkeleton.swift @@ -0,0 +1,31 @@ +// +// AppBskyUnspeccedGetSuggestionsSkeleton.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.Unspecced { + + /// The main data model definition for getting a skeleton of suggestion of actors. + /// + /// - Note: According to the AT Protocol specifications: "Get a skeleton of suggested actors. + /// Intended to be called and then hydrated through app.bsky.actor.getSuggestions." + /// + /// - Important: This is an unspecced model, and as such, this is highly volatile and may change + /// or be removed at any time. Use at your own risk. + /// + /// - SeeAlso: This is based on the [`app.bsky.unspecced.getSuggestionsSkeleton`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/unspecced/getSuggestionsSkeleton.json + public struct GetSuggestionsSkeletonOutput: Codable { + + /// The mark used to indicate the starting point for the next set of results. Optional. + public let cursor: String? + + /// An array of actors. + public let actors: [SkeletonSearchActorDefinition] + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedGetTaggedSuggestions.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedGetTaggedSuggestions.swift new file mode 100644 index 0000000000..26e538d273 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedGetTaggedSuggestions.swift @@ -0,0 +1,87 @@ +// +// AppBskyUnspeccedGetTaggedSuggestions.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.Unspecced { + + /// The main data model definition for the output of getting tagged suggestions. + /// + /// - Note: According to the AT Protocol specifications: "Get a list of suggestions (feeds + /// and users) tagged with categories." + /// + /// - Important: This is an unspecced model, and as such, this is highly volatile and may + /// change or be removed at any time. Use at your own risk. + /// + /// - SeeAlso: This is based on the [`app.bsky.unspecced.getTaggedSuggestions`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/unspecced/getTaggedSuggestions.json + public struct GetTaggedSuggestionsOutput: Codable { + + /// An array of suggestions. + public let suggestions: [TaggedSuggestion] + } + + /// A data model for a tagged suggestion. + /// + /// - Important: This is an unspecced model, and as such, this is highly volatile and may + /// change or be removed at any time. Use at your own risk. + /// + /// - SeeAlso: This is based on the [`app.bsky.unspecced.getTaggedSuggestions`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/unspecced/getTaggedSuggestions.json + public struct TaggedSuggestion: Codable { + + /// The tag attached to the suggestion. + public let tag: String + + /// Indicates whether the suggestion is a feed generator or actor (user). + public let subjectType: SubjectType + + /// The URI of the suggestion. + public let subjectURI: String + + public init(tag: String, subjectType: SubjectType, subjectURI: String) { + self.tag = tag + self.subjectType = subjectType + self.subjectURI = subjectURI + } + + public init(from decoder: any Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.tag = try container.decode(String.self, forKey: .tag) + self.subjectType = try container.decode(TaggedSuggestion.SubjectType.self, forKey: .subjectType) + self.subjectURI = try container.decode(String.self, forKey: .subjectURI) + } + + public func encode(to encoder: any Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.tag, forKey: .tag) + try container.encode(self.subjectType, forKey: .subjectType) + try container.encode(self.subjectURI, forKey: .subjectURI) + } + + enum CodingKeys: String, CodingKey { + case tag + case subjectType + case subjectURI = "subject" + } + + // Enums + /// Indicates whether the subject of the suggestion is a feed generator or an actor (user). + public enum SubjectType: String, Codable { + + /// Indicates the subject of the suggestion is an actor (user). + case actor + + /// Indicates the subject of the suggestion is a feed generator. + case feed + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedSearchActorsSkeleton.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedSearchActorsSkeleton.swift new file mode 100644 index 0000000000..b0be16dd0e --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedSearchActorsSkeleton.swift @@ -0,0 +1,40 @@ +// +// AppBskyUnspeccedSearchActorsSkeleton.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.Unspecced { + + /// The main data model definition for the output of retrieving the skeleton results of actors (users). + /// + /// - Important: This is an unspecced model, and as such, this is highly volatile and may + /// change or be removed at any time. Use at your own risk. + /// + /// - Note: According to the AT Protocol specifications: "Backend Actors (profile) search, + /// returns only skeleton." + /// + /// - SeeAlso: This is based on the [`app.bsky.unspecced.searchActorsSkeleton`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/unspecced/searchActorsSkeleton.json + public struct SearchActorsSkeletonOutput: Codable { + + /// The mark used to indicate the starting point for the next set of result. Optional. + public let cursor: String? + + /// The number of search results. + /// + /// This number may not be completely reliable, as it can be rounded or truncated. This number + /// doesn't reflect all of the possible actors that can be seen. + /// + /// - Note: According to the AT Protocol specifications: "Count of search hits. Optional, may + /// be rounded/truncated, and may not be possible to paginate through all hits." + public let hitsTotal: Int? + + /// An array of actors. + public let actors: [SkeletonSearchActorDefinition] + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedSearchPostsSkeleton.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedSearchPostsSkeleton.swift new file mode 100644 index 0000000000..89ef30fe5d --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedSearchPostsSkeleton.swift @@ -0,0 +1,58 @@ +// +// AppBskyUnspeccedSearchPostsSkeleton.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension AppBskyLexicon.Unspecced { + + /// The main data model definition for the output of retrieving the skeleton results of posts. + /// + /// - Important: This is an unspecced model, and as such, this is highly volatile and may + /// change or be removed at any time. Use at your own risk. + /// + /// - Note: According to the AT Protocol specifications: "Backend Posts search, returns + /// only skeleton." + /// + /// - SeeAlso: This is based on the [`app.bsky.unspecced.searchPostsSkeleton`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/unspecced/searchPostsSkeleton.json + public struct SearchPostsSkeletonOutput: Codable { + + /// The mark used to indicate the starting point for the next set of result. Optional. + public let cursor: String? + + /// The number of search results. + /// + /// This number may not be completely reliable, as it can be rounded or truncated. + /// This number doesn't reflect all of the possible posts that can be seen. + /// + /// - Note: According to the AT Protocol specifications: "Count of search hits. + /// Optional, may be rounded/truncated, and may not be possible to paginate through + /// all hits." + public let hitsTotal: Int? + + /// An array of posts. + public let posts: [SkeletonSearchPostDefinition] + } + + /// Determines the ranking order for the search results. + /// + /// - Note: According to the AT Protocol specifications: "Specifies the ranking order + /// of results." + /// + /// - SeeAlso: This is based on the [`app.bsky.unspecced.searchPostsSkeleton`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/unspecced/searchPostsSkeleton.json + public enum SearchPostsSortRanking: String { + + /// Indicates the results will be sorted by the top posts. + case top + + /// Indicates the results will be sorted by the latest posts. + case latest + } +} From 88394f8ac7d365115e63505bd8edf3b47831563c Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Sun, 19 May 2024 09:15:34 -0400 Subject: [PATCH 08/51] Convert lexicons to new layout The following have been converted: - chat.bsky.* Also created ATUnion, which will house all of the union types. --- .../ATProtoKit/Models/Lexicons/ATUnion.swift | 33 ++ .../app.bsky/Feed/AppBskyFeedPost.swift | 14 +- .../Actor/ChatBskyActorDeclaration.swift | 48 +++ .../chat.bsky/Actor/ChatBskyActorDefs.swift | 99 +++++ .../Actor/ChatBskyActorDeleteAccount.swift | 18 + .../chat.bsky/Convo/ChatBskyConvoDefs.swift | 339 ++++++++++++++++++ .../ChatBskyConvoDeleteMessageForSelf.swift | 30 ++ .../Convo/ChatBskyConvoGetConvo.swift | 26 ++ .../ChatBskyConvoGetConvoForMembers.swift | 26 ++ .../chat.bsky/Convo/ChatBskyConvoGetLog.swift | 25 ++ .../Convo/ChatBskyConvoGetMessages.swift | 25 ++ .../Convo/ChatBskyConvoLeaveConvo.swift | 45 +++ .../Convo/ChatBskyConvoListConvo.swift | 30 ++ .../Convo/ChatBskyConvoMuteConvo.swift | 41 +++ .../Convo/ChatBskyConvoSendMessage.swift | 30 ++ .../Convo/ChatBskyConvoSendMessageBatch.swift | 52 +++ .../Convo/ChatBskyConvoUnmuteConvo.swift | 41 +++ .../Convo/ChatBskyConvoUpdateRead.swift | 41 +++ .../ChatBskyModerationGetActorMetadata.swift | 57 +++ .../ChatBskyModerationGetMessageContext.swift | 22 ++ .../ChatBskyModerationUpdateActorAccess.swift | 35 ++ 21 files changed, 1070 insertions(+), 7 deletions(-) create mode 100644 Sources/ATProtoKit/Models/Lexicons/ATUnion.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/chat.bsky/Actor/ChatBskyActorDeclaration.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/chat.bsky/Actor/ChatBskyActorDefs.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/chat.bsky/Actor/ChatBskyActorDeleteAccount.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoDefs.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoDeleteMessageForSelf.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetConvo.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetConvoForMembers.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetLog.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetMessages.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoLeaveConvo.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoListConvo.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoMuteConvo.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoSendMessage.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoSendMessageBatch.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoUnmuteConvo.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoUpdateRead.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/chat.bsky/Moderation/ChatBskyModerationGetActorMetadata.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/chat.bsky/Moderation/ChatBskyModerationGetMessageContext.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/chat.bsky/Moderation/ChatBskyModerationUpdateActorAccess.swift diff --git a/Sources/ATProtoKit/Models/Lexicons/ATUnion.swift b/Sources/ATProtoKit/Models/Lexicons/ATUnion.swift new file mode 100644 index 0000000000..37a754f235 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/ATUnion.swift @@ -0,0 +1,33 @@ +// +// ATUnion.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +/// An object that lists all of the union types for each of the lexicons. +public struct ATUnion { + + /// A reference containing the list of message embeds. + public enum MessageEmbedUnion: Codable { + case record(AppBskyLexicon.Embed.RecordDefinition) + } + + /// A reference containing the list of messages. + public enum MessageViewUnion: Codable { + case messageView(ChatBskyLexicon.Conversation.MessageView) + case deletedMessageView(ChatBskyLexicon.Conversation.DeleteMessageView) + } + + /// A reference containing the list of message logs. + public enum MessageLogsUnion: Codable { + case logBeginConversation(ChatBskyLexicon.Conversation.LogBeginConversation) + case logLeaveConversation(ChatBskyLexicon.Conversation.LogLeaveConversation) + case logCreateMessage(ChatBskyLexicon.Conversation.LogCreateMessage) + case logDeleteMessage(ChatBskyLexicon.Conversation.LogDeleteMessage) + } + + +} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedPost.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedPost.swift index d7b6bf1a41..4d5d3de28d 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedPost.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedPost.swift @@ -36,7 +36,7 @@ extension AppBskyLexicon.Feed { /// /// - Note: According to the AT Protocol specifications: "Annotations of text (mentions, URLs, /// hashtags, etc)" - public var facets: [Facet]? + public var facets: [AppBskyLexicon.RichText.Facet]? /// The references to posts when replying. Optional. public var reply: PostReplyReference? /// The embed of the post. Optional. @@ -59,18 +59,18 @@ extension AppBskyLexicon.Feed { /// - Note: According to the AT Protocol specifications: "Additional hashtags, in addition to /// any included in post text and facets." /// - /// - Important: Current maximum length is 8 tags. Current maximum length of the tag name is - /// 64 characters. This library will automatically truncate the `Array`and `String` + /// - Important: Current maximum length is 8 tags. Current maximum length of the tag name + /// is 64 characters. This library will automatically truncate the `Array`and `String` /// respectively to the maximum length if it does go over the limit. - public var tags: [String]? = nil + public var tags: [String]? /// The date the post was created. /// /// - Note: According to the AT Protocol specifications: "Client-declared timestamp when this /// post was originally created." @DateFormatting public var createdAt: Date - public init(text: String, facets: [Facet]? = nil, reply: PostReplyReference? = nil, embed: EmbedUnion? = nil, languages: [String]? = nil, - labels: FeedLabelUnion? = nil, tags: [String]? = nil, createdAt: Date) { + public init(text: String, facets: [AppBskyLexicon.RichText.Facet]?, reply: PostReplyReference?, embed: EmbedUnion?, languages: [String]?, + labels: FeedLabelUnion?, tags: [String]?, createdAt: Date) { self.text = text self.facets = facets self.reply = reply @@ -85,7 +85,7 @@ extension AppBskyLexicon.Feed { let container = try decoder.container(keyedBy: CodingKeys.self) self.text = try container.decode(String.self, forKey: .text) - self.facets = try container.decodeIfPresent([Facet].self, forKey: .facets) + self.facets = try container.decodeIfPresent([AppBskyLexicon.RichText.Facet].self, forKey: .facets) self.reply = try container.decodeIfPresent(PostReplyReference.self, forKey: .reply) self.embed = try container.decodeIfPresent(EmbedUnion.self, forKey: .embed) self.languages = try container.decodeIfPresent([String].self, forKey: .languages) diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Actor/ChatBskyActorDeclaration.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Actor/ChatBskyActorDeclaration.swift new file mode 100644 index 0000000000..55b6fd4dbd --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Actor/ChatBskyActorDeclaration.swift @@ -0,0 +1,48 @@ +// +// ChatBskyActorDeclaration.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension ChatBskyLexicon.Actor { + + /// The main data model definition for a Bluesky chat account. + /// + /// - Note: According to the AT Protocol specifications: "A declaration of a Bluesky + /// chat account." + /// + /// - SeeAlso: This is based on the [`chat.bsky.actor.declaration`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/actor/declaration.json + public struct DeclarationRecord: ATRecordProtocol { + + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. + public private(set) static var type: String = "chat.bsky.actor.declaration" + + /// Establishes rule for who can message the user account. + public let allowIncoming: AllIncoming + + enum CodingKeys: String, CodingKey { + case allowIncoming + } + + /// A rule that states who can message the user account. + public enum AllIncoming: Codable { + + /// Indicates that anyone can message the user account. + case all + + /// Indicates that no one can message the user account. + case none + + /// Indicates that only people who the user account follows can message + /// the user account. + case following + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Actor/ChatBskyActorDefs.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Actor/ChatBskyActorDefs.swift new file mode 100644 index 0000000000..d3bb7870e6 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Actor/ChatBskyActorDefs.swift @@ -0,0 +1,99 @@ +// +// ChatBskyActorDefs.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension ChatBskyLexicon.Actor { + + /// The main data model for a basic profile view definition. + /// + /// - SeeAlso: This is based on the [`chat.bsky.actor.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/actor/defs.json + public struct ProfileViewBasicDefinition: Codable { + + /// The decentralized identifier (DID) of the user. + public let actorDID: String + + /// The unique handle of the user. + public let actorHandle: String + + /// The display name of the user account. Optional. + /// + /// - Important: Current maximum length is 64 characters. + public let displayName: String? + + /// The avatar image URL of the user's profile. Optional. + public let avatarImageURL: URL? + + /// The associated profile view. Optional. + public let associated: AppBskyLexicon.Actor.ProfileAssociatedDefinition? + + /// The list of metadata relating to the requesting account's relationship with the + /// subject account. Optional. + public let viewer: [AppBskyLexicon.Actor.ViewerStateDefinition]? + + /// An array of labels created by the user. Optional. + public let labels: [Label]? + + /// Indicates whether the user account can no longer be a part of the conversations. Optional. + /// + /// - Note: According to the AT Protocol specifications: "Set to true when the actor + /// cannot actively participate in converations" + public let isChatDisabled: Bool? + + public init(actorDID: String, actorHandle: String, displayName: String?, avatarImageURL: URL?, associated: AppBskyLexicon.Actor.ProfileAssociatedDefinition?, viewer: [AppBskyLexicon.Actor.ViewerStateDefinition]?, labels: [Label]?, isChatDisabled: Bool?) { + self.actorDID = actorDID + self.actorHandle = actorHandle + self.displayName = displayName + self.avatarImageURL = avatarImageURL + self.associated = associated + self.viewer = viewer + self.labels = labels + self.isChatDisabled = isChatDisabled + } + + public init(from decoder: any Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.actorDID = try container.decode(String.self, forKey: .actorDID) + self.actorHandle = try container.decode(String.self, forKey: .actorHandle) + self.displayName = try container.decodeIfPresent(String.self, forKey: .displayName) + self.avatarImageURL = try container.decodeIfPresent(URL.self, forKey: .avatarImageURL) + self.associated = try container.decodeIfPresent(AppBskyLexicon.Actor.ProfileAssociatedDefinition.self, forKey: .associated) + self.viewer = try container.decodeIfPresent([AppBskyLexicon.Actor.ViewerStateDefinition].self, forKey: .viewer) + self.labels = try container.decodeIfPresent([Label].self, forKey: .labels) + self.isChatDisabled = try container.decodeIfPresent(Bool.self, forKey: .isChatDisabled) + } + + public func encode(to encoder: any Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.actorDID, forKey: .actorDID) + try container.encode(self.actorHandle, forKey: .actorHandle) + // Truncate `displayName` to 640 characters before encoding + // `maxGraphemes`'s limit is 64, but `String.count` should respect that limit implictly + try truncatedEncodeIfPresent(self.displayName, withContainer: &container, forKey: .displayName, upToLength: 640) + try container.encodeIfPresent(self.avatarImageURL, forKey: .avatarImageURL) + try container.encodeIfPresent(self.associated, forKey: .associated) + try container.encodeIfPresent(self.viewer, forKey: .viewer) + try container.encodeIfPresent(self.labels, forKey: .labels) + try container.encodeIfPresent(self.isChatDisabled, forKey: .isChatDisabled) + } + + enum CodingKeys: String, CodingKey { + case actorDID = "did" + case actorHandle = "handle" + case displayName + case avatarImageURL = "avatar" + case associated + case viewer + case labels + case isChatDisabled = "chatDisabled" + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Actor/ChatBskyActorDeleteAccount.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Actor/ChatBskyActorDeleteAccount.swift new file mode 100644 index 0000000000..2bb5760f25 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Actor/ChatBskyActorDeleteAccount.swift @@ -0,0 +1,18 @@ +// +// ChatBskyActorDeleteAccount.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension ChatBskyLexicon.Actor { + + /// The request body data model definition for deleting an account. + /// + /// - SeeAlso: This is based on the [`chat.bsky.actor.deleteAccount`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/actor/deleteAccount.json + public struct DeleteAccount: Codable {} +} diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoDefs.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoDefs.swift new file mode 100644 index 0000000000..e2722cbd40 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoDefs.swift @@ -0,0 +1,339 @@ +// +// ChatBskyConvoDefs.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension ChatBskyLexicon.Conversation { + + /// The main data model definition for a messafe reference. + /// + /// - SeeAlso: This is based on the [`chat.bsky.convo.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/defs.json + public struct MessageReference: Codable { + + /// The decentralized identifier (DID) of the message. + public let messageDID: String + + /// The ID of the message. + public let messageID: String + + enum CodingKeys: String, CodingKey { + case messageDID = "did" + case messageID = "messageId" + } + } + + /// The main data model definition for a message. + /// + /// - SeeAlso: This is based on the [`chat.bsky.convo.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/defs.json + public struct Message: Codable { + + /// The ID of the message. Optional. + public let messageID: String? + + /// The message text itself. + /// + /// - Important: Current maximum length is 1,000 characters. + public let text: String + + /// An array of facets contained in the message's text. Optional. + /// + /// - Note: According to the AT Protocol specifications: "Annotations of text (mentions, + /// URLs, hashtags, etc)" + public let facets: [AppBskyLexicon.RichText.Facet]? + + /// An array of embeds for the message. Optional. + public let embeds: [ATUnion.MessageEmbedUnion]? + + public func encode(to encoder: any Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encodeIfPresent(self.messageID, forKey: .messageID) + // Truncate `tags` to 10000 characters before encoding + // `maxGraphemes`'s limit is 1000, but `String.count` should respect that limit implictly + try truncatedEncode(self.text, withContainer: &container, forKey: .text, upToLength: 1_000) + try container.encodeIfPresent(self.facets, forKey: .facets) + try container.encodeIfPresent(self.embeds, forKey: .embeds) + } + + enum CodingKeys: String, CodingKey { + case messageID = "id" + case text + case facets + case embeds = "embed" + } + } + + /// The main data model definition for a message view. + /// + /// - SeeAlso: This is based on the [`chat.bsky.convo.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/defs.json + public struct MessageView: Codable { + + /// The ID of the message. Optional. + public let messageID: String? + + /// The revision of the message. + public let revision: String + + /// The message text itself. + /// + /// - Important: Current maximum length is 1,000 characters. + public let text: String + + /// An array of facets contained in the message's text. Optional. + /// + /// - Note: According to the AT Protocol specifications: "Annotations of text (mentions, + /// URLs, hashtags, etc)" + public let facets: [AppBskyLexicon.RichText.Facet]? + + /// An array of embeds for the message. Optional. + public let embeds: [ATUnion.MessageEmbedUnion]? + + /// The sender of the message. + public let sender: String + + /// The date and time the message was seen. + @DateFormatting public var seenAt: Date + + public init(messageID: String?, revision: String, text: String, facets: [AppBskyLexicon.RichText.Facet]?, embeds: [ATUnion.MessageEmbedUnion]?, sender: String, seenAt: Date) { + self.messageID = messageID + self.revision = revision + self.text = text + self.facets = facets + self.embeds = embeds + self.sender = sender + self._seenAt = DateFormatting(wrappedValue: seenAt) + } + + public init(from decoder: any Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.messageID = try container.decodeIfPresent(String.self, forKey: .messageID) + self.revision = try container.decode(String.self, forKey: .revision) + self.text = try container.decode(String.self, forKey: .text) + self.facets = try container.decodeIfPresent([AppBskyLexicon.RichText.Facet].self, forKey: .facets) + self.embeds = try container.decodeIfPresent([ATUnion.MessageEmbedUnion].self, forKey: .embeds) + self.sender = try container.decode(String.self, forKey: .sender) + self.seenAt = try container.decode(DateFormatting.self, forKey: .seenAt).wrappedValue + } + + public func encode(to encoder: any Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encodeIfPresent(self.messageID, forKey: .messageID) + try container.encode(self.revision, forKey: .revision) + // Truncate `tags` to 10000 characters before encoding + // `maxGraphemes`'s limit is 1000, but `String.count` should respect that limit implictly + try truncatedEncode(self.text, withContainer: &container, forKey: .text, upToLength: 1_000) + try container.encodeIfPresent(self.facets, forKey: .facets) + try container.encodeIfPresent(self.embeds, forKey: .embeds) + try container.encode(self.sender, forKey: .sender) + try container.encode(self._seenAt, forKey: .seenAt) + } + + public enum CodingKeys: String, CodingKey { + case messageID = "id" + case revision = "rev" + case text + case facets + case embeds = "embed" + case sender + case seenAt + } + } + + /// The main data model definition for a deleted message view. + /// + /// - SeeAlso: This is based on the [`chat.bsky.convo.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/defs.json + public struct DeleteMessageView: Codable { + + /// The ID of the message. Optional. + public let messageID: String? + + /// The revision of the message. + public let revision: String + + /// The sender of the message. + public let sender: String + + /// The date and time the message was seen. + @DateFormatting public var seenAt: Date + + public init(messageID: String?, revision: String, sender: String, seenAt: Date) { + self.messageID = messageID + self.revision = revision + self.sender = sender + self._seenAt = DateFormatting(wrappedValue: seenAt) + } + + public init(from decoder: any Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.messageID = try container.decodeIfPresent(String.self, forKey: .messageID) + self.revision = try container.decode(String.self, forKey: .revision) + self.sender = try container.decode(String.self, forKey: .sender) + self.seenAt = try container.decode(DateFormatting.self, forKey: .seenAt).wrappedValue + } + + public func encode(to encoder: any Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encodeIfPresent(self.messageID, forKey: .messageID) + try container.encode(self.revision, forKey: .revision) + try container.encode(self.sender, forKey: .sender) + try container.encode(self._seenAt, forKey: .seenAt) + } + + enum CodingKeys: String, CodingKey { + case messageID = "id" + case revision = "rev" + case sender + case seenAt + } + } + + /// The main data model definition for the message view's sender. + /// + /// - SeeAlso: This is based on the [`chat.bsky.convo.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/defs.json + public struct MessageViewSender: Codable { + + /// The decentralized identifier (DID) of the message. + public let messageDID: String + + enum CodingKeys: String, CodingKey { + case messageDID = "did" + } + } + + /// The main data model definition for a conversation view. + /// + /// - SeeAlso: This is based on the [`chat.bsky.convo.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/defs.json + public struct ConversationView: Codable { + + /// The ID of the conversation. + public let conversationID: String + + /// The revision of the conversation. + public let revision: String + + /// An array of basic profile views within the conversation. + public let members: [ChatBskyLexicon.Actor.ProfileViewBasicDefinition] + + /// The last message in the conversation. Optional. + public let lastMessage: ATUnion.MessageViewUnion? + + /// Indicates whether the conversation is muted. + public let isMuted: Bool + + /// The number of messages that haven't been read. + public let unreadCount: Int + + enum CodingKeys: String, CodingKey { + case conversationID = "id" + case revision = "rev" + case members + case lastMessage + case isMuted = "muted" + case unreadCount + } + } + + /// The main data model definition for a log for beginning the coversation. + /// + /// - SeeAlso: This is based on the [`chat.bsky.convo.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/defs.json + public struct LogBeginConversation: Codable { + + /// The revision of the log. + public let revision: String + + /// The ID of the conversation. + public let conversationID: String + + enum CodingKeys: String, CodingKey { + case revision = "rev" + case conversationID = "convoID" + } + } + + /// The main data model definition for a log for leaving the conversation. + /// + /// - SeeAlso: This is based on the [`chat.bsky.convo.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/defs.json + public struct LogLeaveConversation: Codable { + + /// The revision of the log. + public let revision: String + + /// The ID of the conversation. + public let conversationID: String + + enum CodingKeys: String, CodingKey { + case revision = "rev" + case conversationID = "convoID" + } + } + + /// The main data model definition for a log for creating a message. + /// + /// - SeeAlso: This is based on the [`chat.bsky.convo.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/defs.json + public struct LogCreateMessage: Codable { + + /// The revision of the log. + public let revision: String + + /// The ID of the conversation. + public let conversationID: String + + /// The message itself. + public let message: ATUnion.MessageViewUnion + + enum CodingKeys: String, CodingKey { + case revision = "rev" + case conversationID = "convoID" + case message + } + } + + /// The main data model definition for a log for deleting a message. + /// + /// - SeeAlso: This is based on the [`chat.bsky.convo.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/defs.json + public struct LogDeleteMessage: Codable { + + /// The revision of the log. + public let revision: String + + /// The ID of the conversation. + public let conversationID: String + + /// The message itself. + public let message: ATUnion.MessageViewUnion + + enum CodingKeys: String, CodingKey { + case revision = "rev" + case conversationID = "convoID" + case message + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoDeleteMessageForSelf.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoDeleteMessageForSelf.swift new file mode 100644 index 0000000000..42246859e1 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoDeleteMessageForSelf.swift @@ -0,0 +1,30 @@ +// +// ChatBskyConvoDeleteMessageForSelf.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension ChatBskyLexicon.Conversation { + + /// The request body data model definition for a message reference. + /// + /// - SeeAlso: This is based on the [`chat.bsky.convo.deleteMessageForSelf`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/deleteMessageForSelf.json + public struct DeleteMessageForSelfRequestBody: Codable { + + /// The ID of the conversation. + public let conversationID: String + + /// The ID of the message. + public let messageID: DeleteMessageView + + enum CodingKeys: String, CodingKey { + case conversationID = "convoID" + case messageID = "messageId" + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetConvo.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetConvo.swift new file mode 100644 index 0000000000..05142224ce --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetConvo.swift @@ -0,0 +1,26 @@ +// +// ChatBskyConvoGetConvo.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension ChatBskyLexicon.Conversation { + + /// The data model definition for the output of a message reference. + /// + /// - SeeAlso: This is based on the [`chat.bsky.convo.getConvo`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/getConvo.json + public struct GetConversationOutput: Codable { + + /// The conversation itself. + public let conversation: ConversationView + + enum CodingKeys: String, CodingKey { + case conversation = "convo" + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetConvoForMembers.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetConvoForMembers.swift new file mode 100644 index 0000000000..c004faf112 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetConvoForMembers.swift @@ -0,0 +1,26 @@ +// +// ChatBskyConvoGetConvoForMembers.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension ChatBskyLexicon.Conversation { + + /// The data model definition for the output of getting a conversation for members. + /// + /// - SeeAlso: This is based on the [`chat.bsky.convo.getConvoForMembers`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/getConvoForMembers.json + public struct GetConversationForMembersOutput: Codable { + + /// The conversation view. + public let conversation: ConversationView + + enum CodingKeys: String, CodingKey { + case conversation = "convo" + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetLog.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetLog.swift new file mode 100644 index 0000000000..b92ad49312 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetLog.swift @@ -0,0 +1,25 @@ +// +// ChatBskyConvoGetLog.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension ChatBskyLexicon.Conversation { + + /// The data model definition for the output of getting logs. + /// + /// - SeeAlso: This is based on the [`chat.bsky.convo.getLog`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/getLog.json + public struct GetLogOutput: Codable { + + /// The mark used to indicate the starting point for the next set of results. Optional. + public let cursor: String? + + /// An array of logs. + public let logs: [ATUnion.MessageLogsUnion] + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetMessages.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetMessages.swift new file mode 100644 index 0000000000..58e5a0adfe --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetMessages.swift @@ -0,0 +1,25 @@ +// +// ChatBskyConvoGetMessages.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension ChatBskyLexicon.Conversation { + + /// The data model definition for the output of getting messages. + /// + /// - SeeAlso: This is based on the [`chat.bsky.convo.getMessages`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/getMessages.json + public struct GetMessagesOutput: Codable { + + /// The mark used to indicate the starting point for the next set of results. Optional. + public let cursor: String? + + /// An array of messages. + public let messages: [ATUnion.MessageViewUnion] + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoLeaveConvo.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoLeaveConvo.swift new file mode 100644 index 0000000000..f0cb69c3d2 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoLeaveConvo.swift @@ -0,0 +1,45 @@ +// +// ChatBskyConvoLeaveConvo.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension ChatBskyLexicon.Conversation { + + /// The request body data model definition for leaving a conversation. + /// + /// - SeeAlso: This is based on the [`chat.bsky.convo.leaveConvo`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/leaveConvo.json + public struct LeaveConversationRequestBody: Codable { + + /// The ID of the conversation. + public let conversationID: String + + enum CodingKeys: String, CodingKey { + case conversationID = "convoId" + } + } + + /// The data model definition for the output of leaving a conversation. + /// + /// - SeeAlso: This is based on the [`chat.bsky.convo.leaveConvo`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/leaveConvo.json + public struct LeaveConversationOutput: Codable { + + /// The ID of the conversation. + public let conversationID: String + + /// The revision of the conversation. + public let revision: String + + enum CodingKeys: String, CodingKey { + case conversationID = "convoId" + case revision = "rev" + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoListConvo.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoListConvo.swift new file mode 100644 index 0000000000..0533c4361e --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoListConvo.swift @@ -0,0 +1,30 @@ +// +// ChatBskyConvoListConvo.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension ChatBskyLexicon.Conversation { + + /// The data model definition for the output of listing a conversation. + /// + /// - SeeAlso: This is based on the [`chat.bsky.convo.listConvos`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/listConvos.json + public struct ListConversationOutput: Codable { + + /// The mark used to indicate the starting point for the next set of results. Optional. + public let cursor: String + + /// An array of conversations. + public let conversations: [ConversationView] + + enum CodingKeys: String, CodingKey { + case cursor + case conversations = "convos" + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoMuteConvo.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoMuteConvo.swift new file mode 100644 index 0000000000..06c84e5251 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoMuteConvo.swift @@ -0,0 +1,41 @@ +// +// ChatBskyConvoMuteConvo.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension ChatBskyLexicon.Conversation { + + /// The request body data model definition for muting a conversation. + /// + /// - SeeAlso: This is based on the [`chat.bsky.convo.muteConvo`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/muteConvo.json + public struct MuteConversationRequestBody: Codable { + + /// The ID of the conversation. + public let conversationID: String + + enum CodingKeys: String, CodingKey { + case conversationID = "convoId" + } + } + + /// The data model definition for the output of muting a conversation. + /// + /// - SeeAlso: This is based on the [`chat.bsky.convo.muteConvo`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/muteConvo.json + public struct MuteConversationOutput: Codable { + + /// The conversation itself. + public let conversation: [ConversationView] + + enum CodingKeys: String, CodingKey { + case conversation = "convo" + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoSendMessage.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoSendMessage.swift new file mode 100644 index 0000000000..336b668523 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoSendMessage.swift @@ -0,0 +1,30 @@ +// +// ChatBskyConvoSendMessage.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension ChatBskyLexicon.Conversation { + + /// The request body data model definition for sending a message. + /// + /// - SeeAlso: This is based on the [`chat.bsky.convo.sendMessage`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/sendMessage.json + public struct SendMessageRequestBody: Codable { + + /// The ID of the conversation. + public let conversationID: String + + /// The message text itself. + public let message: Message + + enum CodingKeys: String, CodingKey { + case conversationID = "convoId" + case message + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoSendMessageBatch.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoSendMessageBatch.swift new file mode 100644 index 0000000000..7de2ba2ecd --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoSendMessageBatch.swift @@ -0,0 +1,52 @@ +// +// ChatBskyConvoSendMessageBatch.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension ChatBskyLexicon.Conversation { + + /// The request body data model definition for sending a message batch. + /// + /// - SeeAlso: This is based on the [`chat.bsky.convo.sendMessageBatch`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/sendMessageBatch.json + public struct SendMessageBatchRequestBody: Codable { + + /// An array of messages. + public let items: [MessageBatchItem] + } + + /// The data model definition for the output of sending a message batch. + /// + /// - SeeAlso: This is based on the [`chat.bsky.convo.sendMessageBatch`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/sendMessageBatch.json + public struct SendMessageBatchOutput: Codable { + + /// An array of message views. + public let items: [MessageView] + } + + /// A message batch object. + /// + /// - SeeAlso: This is based on the [`chat.bsky.convo.sendMessageBatch`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/sendMessageBatch.json + public struct MessageBatchItem: Codable { + + /// The ID of the conversation. + public let conversationID: String + + /// The message text itself. + public let message: Message + + enum CodingKeys: String, CodingKey { + case conversationID = "convoId" + case message + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoUnmuteConvo.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoUnmuteConvo.swift new file mode 100644 index 0000000000..c093a16bf8 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoUnmuteConvo.swift @@ -0,0 +1,41 @@ +// +// ChatBskyConvoUnmuteConvo.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension ChatBskyLexicon.Conversation { + + /// The request body data model definition for unmuting a conversation. + /// + /// - SeeAlso: This is based on the [`chat.bsky.convo.unmuteConvo`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/unmuteConvo.json + public struct UnMuteConversationRequestBody: Codable { + + /// The ID of the conversation. + public let conversationID: String + + enum CodingKeys: String, CodingKey { + case conversationID = "convoId" + } + } + + /// The data model definition for the output of unmuting a conversation. + /// + /// - SeeAlso: This is based on the [`chat.bsky.convo.unmuteConvo`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/unmuteConvo.json + public struct UnmuteConversationOutput: Codable { + + /// The conversation itself. + public let conversationView: ConversationView + + enum CodingKeys: String, CodingKey { + case conversationView = "convo" + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoUpdateRead.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoUpdateRead.swift new file mode 100644 index 0000000000..cda0383d05 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoUpdateRead.swift @@ -0,0 +1,41 @@ +// +// ChatBskyConvoUpdateRead.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension ChatBskyLexicon.Conversation { + + /// The request body data model definition for updating the conversation to mark it as read. + /// + /// - SeeAlso: This is based on the [`chat.bsky.convo.updateRead`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/updateRead.json + public struct UpdateReadRequestBody: Codable { + + /// The ID of the conversation to be marked as read. + public let conversationID: String + + /// The ID of the message. + public let messageID: String + + enum CodingKeys: String, CodingKey { + case conversationID = "convoId" + case messageID = "messageId" + } + } + + /// The main data model definition for the output of updating the conversation to mark it as read. + /// + /// - SeeAlso: This is based on the [`chat.bsky.convo.updateRead`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/updateRead.json + public struct UpdateReadOutput: Codable { + + /// The conversation itself. + public let conversationView: ConversationView + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Moderation/ChatBskyModerationGetActorMetadata.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Moderation/ChatBskyModerationGetActorMetadata.swift new file mode 100644 index 0000000000..95ed6d82ed --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Moderation/ChatBskyModerationGetActorMetadata.swift @@ -0,0 +1,57 @@ +// +// ChatBskyModerationGetActorMetadata.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension ChatBskyLexicon.Moderation { + + /// The data model definition for the output of getting the user account's metadata. + /// + /// - SeeAlso: This is based on the [`chat.bsky.moderation.getActorMetadata`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/moderation/getActorMetadata.json + public struct GetActorMetadataOutput: Codable { + + /// The metadata that reflects the past day. + public let dayMetadata: String + + /// The metadata that reflects the past month. + public let monthMetadata: String + + /// The metadata that reflects the entire lifetime of the user account. + public let allMetadata: String + + enum CodingKeys: String, CodingKey { + case dayMetadata = "day" + case monthMetadata = "month" + case allMetadata = "all" + } + } + + /// The metadata given to the moderator. + public struct Metadata: Codable { + + /// The number of messages sent from the user account. + public let messagesSent: Int + + /// The number of messages the user account received. + public let messagesReceived: Int + + /// The number of conversations the user account participates in. + public let conversations: Int + + /// The number of conversations the user account had started. + public let conversationsStarted: Int + + enum CodingKeys: String, CodingKey { + case messagesSent + case messagesReceived + case conversations = "convos" + case conversationsStarted = "convosStarted" + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Moderation/ChatBskyModerationGetMessageContext.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Moderation/ChatBskyModerationGetMessageContext.swift new file mode 100644 index 0000000000..cef5dffa2e --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Moderation/ChatBskyModerationGetMessageContext.swift @@ -0,0 +1,22 @@ +// +// ChatBskyModerationGetMessageContext.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension ChatBskyLexicon.Moderation { + + /// The data model definition for the output of getting the message context. + /// + /// - SeeAlso: This is based on the [`chat.bsky.moderation.getMessageContext`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/moderation/getMessageContext.json + public struct GetMessageContextOutput: Codable { + + /// An array of messages. + public let messages: [ATUnion.MessageViewUnion] + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Moderation/ChatBskyModerationUpdateActorAccess.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Moderation/ChatBskyModerationUpdateActorAccess.swift new file mode 100644 index 0000000000..ac8b0aafa2 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Moderation/ChatBskyModerationUpdateActorAccess.swift @@ -0,0 +1,35 @@ +// +// ChatBskyModerationUpdateActorAccess.swift +// +// +// Created by Christopher Jr Riley on 2024-05-19. +// + +import Foundation + +extension ChatBskyLexicon.Moderation { + + /// The request body data model definition for updating the user account's access to + /// direct messages. + /// + /// - SeeAlso: This is based on the [`hat.bsky.moderation.updateActorAccess`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/moderation/updateActorAccess.json + public struct UpdateActorAccessRequestBody: Codable { + + /// The user account to change access to direct messages. + public let actorDID: String + + /// Indicates whether the user account has access to direct messages. + public let doesAllowAccess: Bool + + /// A reference object for the action taken. + public let reference: String + + enum CodingKeys: String, CodingKey { + case actorDID = "did" + case doesAllowAccess = "allowAccess" + case reference = "ref" + } + } +} From 0d03a048bc9acabc55d7962ecf7ff36118a56232 Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Sun, 19 May 2024 09:35:11 -0400 Subject: [PATCH 09/51] Implement ATUnion All union types for chat.bsky.* have been implemented. --- .../ATProtoKit/Models/Lexicons/ATUnion.swift | 83 ++++++++++++++++++- 1 file changed, 80 insertions(+), 3 deletions(-) diff --git a/Sources/ATProtoKit/Models/Lexicons/ATUnion.swift b/Sources/ATProtoKit/Models/Lexicons/ATUnion.swift index 37a754f235..6db5ce14f4 100644 --- a/Sources/ATProtoKit/Models/Lexicons/ATUnion.swift +++ b/Sources/ATProtoKit/Models/Lexicons/ATUnion.swift @@ -9,16 +9,62 @@ import Foundation /// An object that lists all of the union types for each of the lexicons. public struct ATUnion { - + /// A reference containing the list of message embeds. public enum MessageEmbedUnion: Codable { case record(AppBskyLexicon.Embed.RecordDefinition) + + public init(from decoder: any Decoder) throws { + let container = try decoder.singleValueContainer() + + if let value = try? container.decode(AppBskyLexicon.Embed.RecordDefinition.self) { + self = .record(value) + } else { + throw DecodingError.typeMismatch( + MessageEmbedUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown MessageEmbedUnion type")) + } + } + + public func encode(to encoder: any Encoder) throws { + var container = encoder.singleValueContainer() + + switch self { + case .record(let record): + try container.encode(record) + } + } } /// A reference containing the list of messages. public enum MessageViewUnion: Codable { case messageView(ChatBskyLexicon.Conversation.MessageView) case deletedMessageView(ChatBskyLexicon.Conversation.DeleteMessageView) + + public init(from decoder: any Decoder) throws { + let container = try decoder.singleValueContainer() + + if let value = try? container.decode(ChatBskyLexicon.Conversation.MessageView.self) { + self = .messageView(value) + } else if let value = try? container.decode(ChatBskyLexicon.Conversation.DeleteMessageView.self) { + self = .deletedMessageView(value) + } else { + throw DecodingError.typeMismatch( + MessageViewUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown MessageViewUnion type")) + } + } + + public func encode(to encoder: any Encoder) throws { + var container = encoder.singleValueContainer() + + switch self { + case .messageView(let messageView): + try container.encode(messageView) + case .deletedMessageView(let deletedMessageView): + try container.encode(deletedMessageView) + } + } } /// A reference containing the list of message logs. @@ -27,7 +73,38 @@ public struct ATUnion { case logLeaveConversation(ChatBskyLexicon.Conversation.LogLeaveConversation) case logCreateMessage(ChatBskyLexicon.Conversation.LogCreateMessage) case logDeleteMessage(ChatBskyLexicon.Conversation.LogDeleteMessage) + + public init(from decoder: any Decoder) throws { + let container = try decoder.singleValueContainer() + + if let value = try? container.decode(ChatBskyLexicon.Conversation.LogBeginConversation.self) { + self = .logBeginConversation(value) + } else if let value = try? container.decode(ChatBskyLexicon.Conversation.LogLeaveConversation.self) { + self = .logLeaveConversation(value) + } else if let value = try? container.decode(ChatBskyLexicon.Conversation.LogCreateMessage.self) { + self = .logCreateMessage(value) + } else if let value = try? container.decode(ChatBskyLexicon.Conversation.LogDeleteMessage.self) { + self = .logDeleteMessage(value) + } else { + throw DecodingError.typeMismatch( + MessageLogsUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown MessageLogsUnion type")) + } + } + + public func encode(to encoder: any Encoder) throws { + var container = encoder.singleValueContainer() + + switch self { + case .logBeginConversation(let logBeginConversation): + try container.encode(logBeginConversation) + case .logLeaveConversation(let logLeaveConversation): + try container.encode(logLeaveConversation) + case .logCreateMessage(let logCreateMessage): + try container.encode(logCreateMessage) + case .logDeleteMessage(let logDeleteMessage): + try container.encode(logDeleteMessage) + } + } } - - } From da89b45bda9f2cec36effef011a36dde48512fd7 Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Sun, 19 May 2024 11:27:52 -0400 Subject: [PATCH 10/51] Begin to move union types to ATUnion --- .../ATProtoKit/Models/Lexicons/ATUnion.swift | 508 +++++++++++++++++- .../app.bsky/Actor/AppBskyActorDefs.swift | 6 +- .../app.bsky/Embed/AppBskyEmbedRecord.swift | 2 +- 3 files changed, 508 insertions(+), 8 deletions(-) diff --git a/Sources/ATProtoKit/Models/Lexicons/ATUnion.swift b/Sources/ATProtoKit/Models/Lexicons/ATUnion.swift index 6db5ce14f4..d54ba620aa 100644 --- a/Sources/ATProtoKit/Models/Lexicons/ATUnion.swift +++ b/Sources/ATProtoKit/Models/Lexicons/ATUnion.swift @@ -10,6 +10,506 @@ import Foundation /// An object that lists all of the union types for each of the lexicons. public struct ATUnion { + /// A reference containing the list of preferences. + public enum ActorPreferenceUnion: Codable { + /// The "Adult Content" preference. + case adultContent(AppBskyLexicon.Actor.AdultContentPreferencesDefinition) + /// The "Content Label" preference. + case contentLabel(AppBskyLexicon.Actor.ContentLabelPreferencesDefinition) + /// Version 2 of the "Saved Feeds" preference. + case savedFeedsVersion2(AppBskyLexicon.Actor.SavedFeedPreferencesVersion2Definition) + /// The "Saved Feeds" preference. + case savedFeeds(AppBskyLexicon.Actor.SavedFeedsPreferencesDefinition) + /// The "Personal Details" preference. + case personalDetails(AppBskyLexicon.Actor.PersonalDetailsPreferencesDefinition) + /// The "Feed View" preference. + case feedView(AppBskyLexicon.Actor.FeedViewPreferencesDefinition) + /// The "Thread View" preference. + case threadView(AppBskyLexicon.Actor.ThreadViewPreferencesDefinition) + /// The "Interest View" preference. + case interestViewPreferences(AppBskyLexicon.Actor.InterestViewPreferencesDefinition) + /// The "Muted Words" preference. + case mutedWordsPreferences(AppBskyLexicon.Actor.MutedWordsPreferencesDefinition) + /// The Hidden Posts" preference. + case hiddenPostsPreferences(AppBskyLexicon.Actor.HiddenPostsPreferencesDefinition) + + // Implement custom decoding + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + + if let value = try? container.decode(AppBskyLexicon.Actor.AdultContentPreferencesDefinition.self) { + self = .adultContent(value) + } else if let value = try? container.decode(AppBskyLexicon.Actor.ContentLabelPreferencesDefinition.self) { + self = .contentLabel(value) + } else if let value = try? container.decode(AppBskyLexicon.Actor.SavedFeedPreferencesVersion2Definition.self) { + self = .savedFeedsVersion2(value) + } else if let value = try? container.decode(AppBskyLexicon.Actor.SavedFeedsPreferencesDefinition.self) { + self = .savedFeeds(value) + } else if let value = try? container.decode(AppBskyLexicon.Actor.PersonalDetailsPreferencesDefinition.self) { + self = .personalDetails(value) + } else if let value = try? container.decode(AppBskyLexicon.Actor.FeedViewPreferencesDefinition.self) { + self = .feedView(value) + } else if let value = try? container.decode(AppBskyLexicon.Actor.ThreadViewPreferencesDefinition.self) { + self = .threadView(value) + } else if let value = try? container.decode(AppBskyLexicon.Actor.InterestViewPreferencesDefinition.self) { + self = .interestViewPreferences(value) + } else if let value = try? container.decode(AppBskyLexicon.Actor.MutedWordsPreferencesDefinition.self) { + self = .mutedWordsPreferences(value) + } else if let value = try? container.decode(AppBskyLexicon.Actor.HiddenPostsPreferencesDefinition.self) { + self = .hiddenPostsPreferences(value) + } else { + throw DecodingError.typeMismatch( + ActorPreferenceUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown ActorPreference type")) + } + } + + // Implement custom encoding + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + + switch self { + case .adultContent(let adultContent): + try container.encode(adultContent) + case .contentLabel(let contentLabel): + try container.encode(contentLabel) + case .savedFeedsVersion2(let savedFeedsVersion2): + try container.encode(savedFeedsVersion2) + case .savedFeeds(let savedFeeds): + try container.encode(savedFeeds) + case .personalDetails(let personalDetails): + try container.encode(personalDetails) + case .feedView(let feedView): + try container.encode(feedView) + case .threadView(let threadView): + try container.encode(threadView) + case .interestViewPreferences(let interestViewPreferences): + try container.encode(interestViewPreferences) + case .mutedWordsPreferences(let mutedWordsPreferences): + try container.encode(mutedWordsPreferences) + case .hiddenPostsPreferences(let hiddenPostsPreferences): + try container.encode(hiddenPostsPreferences) + } + } + } + + /// A reference containing the list of the status of a record. + public enum RecordViewUnion: Codable { + /// A normal record type. + case viewRecord(AppBskyLexicon.Embed.ViewRecord) + /// A record that may not have been found. + case viewNotFound(AppBskyLexicon.Embed.ViewNotFound) + /// A record that may have been blocked. + case viewBlocked(AppBskyLexicon.Embed.ViewBlocked) + /// A generator view. + case generatorView(AppBskyLexicon.Feed.GeneratorViewDefinition) + /// A list view. + case listView(AppBskyLexicon.Graph.ListViewDefinition) + /// A labeler view. + case labelerView(AppBskyLexicon.Labeler.LabelerViewDefinition) + + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + + if let value = try? container.decode(AppBskyLexicon.Embed.ViewRecord.self) { + self = .viewRecord(value) + } else if let value = try? container.decode(AppBskyLexicon.Embed.ViewNotFound.self) { + self = .viewNotFound(value) + } else if let value = try? container.decode(AppBskyLexicon.Embed.ViewBlocked.self) { + self = .viewBlocked(value) + } else if let value = try? container.decode(AppBskyLexicon.Feed.GeneratorViewDefinition.self) { + self = .generatorView(value) + } else if let value = try? container.decode(AppBskyLexicon.Graph.ListViewDefinition.self) { + self = .listView(value) + } else if let value = try? container.decode(AppBskyLexicon.Labeler.LabelerViewDefinition.self) { + self = .labelerView(value) + } else { + throw DecodingError.typeMismatch( + RecordViewUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown RecordViewUnion type")) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + + switch self { + case .viewRecord(let viewRecord): + try container.encode(viewRecord) + case .viewNotFound(let viewNotFound): + try container.encode(viewNotFound) + case .viewBlocked(let viewBlocked): + try container.encode(viewBlocked) + case .generatorView(let generatorView): + try container.encode(generatorView) + case .listView(let listView): + try container.encode(listView) + case .labelerView(let labelerView): + try container.encode(labelerView) + } + } + } + + /// A reference containing the list of the types of compatible media. + public enum MediaUnion: Codable { + /// An image that will be embedded. + case embedImages(AppBskyLexicon.Embed.ImagesDefinition) + /// An external link that will be embedded. + case embedExternal(AppBskyLexicon.Embed.ExternalDefinition) + + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + + if let value = try? container.decode(AppBskyLexicon.Embed.ImagesDefinition.self) { + self = .embedImages(value) + } else if let value = try? container.decode(AppBskyLexicon.Embed.ExternalDefinition.self) { + self = .embedExternal(value) + } else { + throw DecodingError.typeMismatch( + PostUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown MediaUnion type")) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + + switch self { + case .embedImages(let media): + try container.encode(media) + case .embedExternal(let media): + try container.encode(media) + } + } + } + + /// A reference containing the list of the types of compatible media that can be viewed. + public enum MediaViewUnion: Codable { + /// An image that's been embedded. + case embedImagesView(AppBskyLexicon.Embed.ImagesView) + /// An external link that's been embedded. + case embedExternalView(AppBskyLexicon.Embed.ExternalView) + + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + + if let value = try? container.decode(AppBskyLexicon.Embed.ImagesView.self) { + self = .embedImagesView(value) + } else if let value = try? container.decode(AppBskyLexicon.Embed.ExternalView.self) { + self = .embedExternalView(value) + } else { + throw DecodingError.typeMismatch( + PostUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown MediaViewUnion type")) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + + switch self { + case .embedImagesView(let mediaView): + try container.encode(mediaView) + case .embedExternalView(let mediaView): + try container.encode(mediaView) + } + } + } + + /// A reference containing the list of the types of embeds. + public enum EmbedViewUnion: Codable { + /// The view of an external embed. + case embedExternalView(AppBskyLexicon.Embed.ExternalView) + /// The view of an image embed. + case embedImagesView(AppBskyLexicon.Embed.ImagesView) + /// The view of a record embed. + case embedRecordView(AppBskyLexicon.Embed.RecordView) + /// The view of a record embed alongside an embed of some compatible media. + case embedRecordWithMediaView(AppBskyLexicon.Embed.RecordWithMediaView) + + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + + if let value = try? container.decode(AppBskyLexicon.Embed.ExternalView.self) { + self = .embedExternalView(value) + } else if let value = try? container.decode(AppBskyLexicon.Embed.ImagesView.self) { + self = .embedImagesView(value) + } else if let value = try? container.decode(AppBskyLexicon.Embed.RecordView.self) { + print("EmbedView.embedRecordView is about to be read.") + self = .embedRecordView(value) + } else if let value = try? container.decode(AppBskyLexicon.Embed.RecordWithMediaView.self) { + self = .embedRecordWithMediaView(value) + } else { + throw DecodingError.typeMismatch( + EmbedViewUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown EmbedView type")) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + + switch self { + case .embedExternalView(let embedExternalView): + try container.encode(embedExternalView) + case .embedImagesView(let embedImagesView): + try container.encode(embedImagesView) + case .embedRecordView(let embedRecordView): + try container.encode(embedRecordView) + case .embedRecordWithMediaView(let embedRecordWithMediaView): + try container.encode(embedRecordWithMediaView) + } + } + } + + /// A reference containing the list of the states of a post. + public enum PostUnion: Codable { + /// The view of a post. + case postView(AppBskyLexicon.Feed.PostViewDefinition) + /// The view of a post that may not have been found. + case notFoundPost(AppBskyLexicon.Feed.NotFoundPostDefinition) + /// The view of a post that's been blocked by the post author. + case blockedPost(AppBskyLexicon.Feed.BlockedPostDefinition) + + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + + if let value = try? container.decode(AppBskyLexicon.Feed.PostViewDefinition.self) { + self = .postView(value) + } else if let value = try? container.decode(AppBskyLexicon.Feed.NotFoundPostDefinition.self) { + self = .notFoundPost(value) + } else if let value = try? container.decode(AppBskyLexicon.Feed.BlockedPostDefinition.self) { + self = .blockedPost(value) + } else { + throw DecodingError.typeMismatch( + PostUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown PostUnion type")) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + + switch self { + case .postView(let postView): + try container.encode(postView) + case .notFoundPost(let notFoundPost): + try container.encode(notFoundPost) + case .blockedPost(let blockedPost): + try container.encode(blockedPost) + } + } + } + + /// A reference containing the list of the states of a post. + public indirect enum ThreadPostUnion: Codable { + /// The view of a post thread. + case threadViewPost(AppBskyLexicon.Feed.ThreadViewPostDefinition) + /// The view of a post that may not have been found. + case notFoundPost(AppBskyLexicon.Feed.NotFoundPostDefinition) + /// The view of a post that's been blocked by the post author. + case blockedPost(AppBskyLexicon.Feed.BlockedPostDefinition) + + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + + if let value = try? container.decode(AppBskyLexicon.Feed.ThreadViewPostDefinition.self) { + self = .threadViewPost(value) + } else if let value = try? container.decode(AppBskyLexicon.Feed.NotFoundPostDefinition.self) { + self = .notFoundPost(value) + } else if let value = try? container.decode(AppBskyLexicon.Feed.BlockedPostDefinition.self) { + self = .blockedPost(value) + } else { + throw DecodingError.typeMismatch( + ThreadPostUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown ThreadPostUnion type")) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + + switch self { + case .threadViewPost(let threadViewPost): + try container.encode(threadViewPost) + case .notFoundPost(let notFoundPost): + try container.encode(notFoundPost) + case .blockedPost(let blockedPost): + try container.encode(blockedPost) + } + } + } + + /// A reference containing the list of the state of a post thread. + public enum FeedGetPostThreadUnion: Codable { + /// A post thread. + case threadViewPost(AppBskyLexicon.Feed.ThreadViewPostDefinition) + /// The post thread wasn't found. + case notFoundPost(AppBskyLexicon.Feed.NotFoundPostDefinition) + /// The post thread was made by someone who blocked the user account. + case blockedPost(AppBskyLexicon.Feed.BlockedPostDefinition) + + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + + if let value = try? container.decode(AppBskyLexicon.Feed.ThreadViewPostDefinition.self) { + self = .threadViewPost(value) + } else if let value = try? container.decode(AppBskyLexicon.Feed.NotFoundPostDefinition.self) { + self = .notFoundPost(value) + } else if let value = try? container.decode(AppBskyLexicon.Feed.BlockedPostDefinition.self) { + self = .blockedPost(value) + } else { + throw DecodingError.typeMismatch( + FeedGetPostThreadUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown FeedGetPostThread type")) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + + switch self { + case .threadViewPost(let threadViewPost): + try container.encode(threadViewPost) + case .notFoundPost(let notFoundPost): + try container.encode(notFoundPost) + case .blockedPost(let blockedPost): + try container.encode(blockedPost) + } + } + } + + /// A reference containing the list of user-defined labels. + public enum FeedLabelUnion: Codable { + /// An array of user-defined labels. + case selfLabels(SelfLabels) + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + let selfLabelsValue = try container.decode(SelfLabels.self, forKey: .selfLabels) + self = .selfLabels(selfLabelsValue) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + + switch self { + case .selfLabels(let selfLabelsValue): + try container.encode(selfLabelsValue) + } + } + + enum CodingKeys: String, CodingKey { + case selfLabels + } + } + + /// A reference containing the list of relationships of multiple user accounts. + public enum GraphRelationshipUnion: Codable { + case relationship(AppBskyLexicon.Graph.RelationshipDefinition) + case notFoundActor(AppBskyLexicon.Graph.NotFoundActorDefinition) + + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + + if let value = try? container.decode(AppBskyLexicon.Graph.RelationshipDefinition.self) { + self = .relationship(value) + } else if let value = try? container.decode(AppBskyLexicon.Graph.NotFoundActorDefinition.self) { + self = .notFoundActor(value) + } else { + throw DecodingError.typeMismatch( + ActorPreferenceUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown GraphRelationshipUnion type")) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + + switch self { + case .relationship(let relationship): + try container.encode(relationship) + case .notFoundActor(let notFoundActor): + try container.encode(notFoundActor) + } + } + } + + /// A reference containing the list of labeler views. + public enum LabelerViewUnion: Codable { + /// A labeler view. + case labelerView(AppBskyLexicon.Labeler.LabelerViewDefinition) + /// A detailed view of a labeler. + case labelerViewDetailed(AppBskyLexicon.Labeler.LabelerViewDetailedDefinition) + + public init(from decoder: any Decoder) throws { + let container = try decoder.singleValueContainer() + + if let value = try? container.decode(AppBskyLexicon.Labeler.LabelerViewDefinition.self) { + self = .labelerView(value) + } else if let value = try? container.decode(AppBskyLexicon.Labeler.LabelerViewDetailedDefinition.self) { + self = .labelerViewDetailed(value) + } else { + throw DecodingError.typeMismatch( + ActorPreferenceUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown LabelerViewUnion type")) + } + } + + public func encode(to encoder: any Encoder) throws { + var container = encoder.singleValueContainer() + + switch self { + case .labelerView(let labelerView): + try container.encode(labelerView) + case .labelerViewDetailed(let labelerViewDetailed): + try container.encode(labelerViewDetailed) + } + } + } + + /// A reference containing the list of feature types. + public enum FeatureUnion: Codable { + /// The Mention feature. + case mention(AppBskyLexicon.RichText.Mention) + /// The Link feature. + case link(AppBskyLexicon.RichText.Link) + /// The Tag feature. + case tag(AppBskyLexicon.RichText.Tag) + + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + + if let value = try? container.decode(AppBskyLexicon.RichText.Mention.self) { + self = .mention(value) + } else if let value = try? container.decode(AppBskyLexicon.RichText.Link.self) { + self = .link(value) + } else if let value = try? container.decode(AppBskyLexicon.RichText.Tag.self) { + self = .tag(value) + } else { + throw DecodingError.typeMismatch( + FeatureUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown FeatureUnion type")) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + + switch self { + case .mention(let mention): + try container.encode(mention) + case .link(let link): + try container.encode(link) + case .tag(let tag): + try container.encode(tag) + } + } + } + + + /// A reference containing the list of message embeds. public enum MessageEmbedUnion: Codable { case record(AppBskyLexicon.Embed.RecordDefinition) @@ -73,10 +573,10 @@ public struct ATUnion { case logLeaveConversation(ChatBskyLexicon.Conversation.LogLeaveConversation) case logCreateMessage(ChatBskyLexicon.Conversation.LogCreateMessage) case logDeleteMessage(ChatBskyLexicon.Conversation.LogDeleteMessage) - + public init(from decoder: any Decoder) throws { let container = try decoder.singleValueContainer() - + if let value = try? container.decode(ChatBskyLexicon.Conversation.LogBeginConversation.self) { self = .logBeginConversation(value) } else if let value = try? container.decode(ChatBskyLexicon.Conversation.LogLeaveConversation.self) { @@ -91,10 +591,10 @@ public struct ATUnion { codingPath: decoder.codingPath, debugDescription: "Unknown MessageLogsUnion type")) } } - + public func encode(to encoder: any Encoder) throws { var container = encoder.singleValueContainer() - + switch self { case .logBeginConversation(let logBeginConversation): try container.encode(logBeginConversation) diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorDefs.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorDefs.swift index e211d63399..efdfb6e088 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorDefs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorDefs.swift @@ -390,9 +390,9 @@ extension AppBskyLexicon.Actor { public struct PreferencesDefinition: Codable { /// An array of different preferences the user can set. - public let preferences: [ActorPreferenceUnion] - - public init(preferences: [ActorPreferenceUnion]) { + public let preferences: [ATUnion.ActorPreferenceUnion] + + public init(preferences: [ATUnion.ActorPreferenceUnion]) { self.preferences = preferences } } diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedRecord.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedRecord.swift index 66e493fc82..383d803b3e 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedRecord.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedRecord.swift @@ -48,7 +48,7 @@ extension AppBskyLexicon.Embed { public let type: String = "app.bsky.embed.record#view" /// The record of a specific type. - public let record: RecordViewUnion + public let record: ATUnion.RecordViewUnion enum CodingKeys: String, CodingKey { case type = "$type" From ce24b02356e2ecf8f6343ca7867e310e205ac67f Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Mon, 20 May 2024 04:24:20 -0400 Subject: [PATCH 11/51] Move union types to ATUnion and rename types --- .../ATProtoKit/Models/Lexicons/ATUnion.swift | 519 +++++++++++++++++- .../Actor/AppBskyActorPutPreferences.swift | 2 +- .../AppBskyActorSearchActorsTypeahead.swift | 1 + .../app.bsky/Embed/AppBskyEmbedRecord.swift | 8 +- .../Embed/AppBskyEmbedRecordWithMedia.swift | 4 +- .../app.bsky/Feed/AppBskyFeedDefs.swift | 14 +- .../Feed/AppBskyFeedGetPostThread.swift | 2 +- .../app.bsky/Feed/AppBskyFeedPost.swift | 12 +- .../app.bsky/Feed/AppBskyFeedThreadgate.swift | 6 +- 9 files changed, 543 insertions(+), 25 deletions(-) diff --git a/Sources/ATProtoKit/Models/Lexicons/ATUnion.swift b/Sources/ATProtoKit/Models/Lexicons/ATUnion.swift index d54ba620aa..e9faa5b371 100644 --- a/Sources/ATProtoKit/Models/Lexicons/ATUnion.swift +++ b/Sources/ATProtoKit/Models/Lexicons/ATUnion.swift @@ -12,24 +12,34 @@ public struct ATUnion { /// A reference containing the list of preferences. public enum ActorPreferenceUnion: Codable { + /// The "Adult Content" preference. case adultContent(AppBskyLexicon.Actor.AdultContentPreferencesDefinition) + /// The "Content Label" preference. case contentLabel(AppBskyLexicon.Actor.ContentLabelPreferencesDefinition) + /// Version 2 of the "Saved Feeds" preference. case savedFeedsVersion2(AppBskyLexicon.Actor.SavedFeedPreferencesVersion2Definition) + /// The "Saved Feeds" preference. case savedFeeds(AppBskyLexicon.Actor.SavedFeedsPreferencesDefinition) + /// The "Personal Details" preference. case personalDetails(AppBskyLexicon.Actor.PersonalDetailsPreferencesDefinition) + /// The "Feed View" preference. case feedView(AppBskyLexicon.Actor.FeedViewPreferencesDefinition) + /// The "Thread View" preference. case threadView(AppBskyLexicon.Actor.ThreadViewPreferencesDefinition) + /// The "Interest View" preference. case interestViewPreferences(AppBskyLexicon.Actor.InterestViewPreferencesDefinition) + /// The "Muted Words" preference. case mutedWordsPreferences(AppBskyLexicon.Actor.MutedWordsPreferencesDefinition) + /// The Hidden Posts" preference. case hiddenPostsPreferences(AppBskyLexicon.Actor.HiddenPostsPreferencesDefinition) @@ -95,16 +105,22 @@ public struct ATUnion { /// A reference containing the list of the status of a record. public enum RecordViewUnion: Codable { + /// A normal record type. case viewRecord(AppBskyLexicon.Embed.ViewRecord) + /// A record that may not have been found. case viewNotFound(AppBskyLexicon.Embed.ViewNotFound) + /// A record that may have been blocked. case viewBlocked(AppBskyLexicon.Embed.ViewBlocked) + /// A generator view. case generatorView(AppBskyLexicon.Feed.GeneratorViewDefinition) + /// A list view. case listView(AppBskyLexicon.Graph.ListViewDefinition) + /// A labeler view. case labelerView(AppBskyLexicon.Labeler.LabelerViewDefinition) @@ -152,8 +168,10 @@ public struct ATUnion { /// A reference containing the list of the types of compatible media. public enum MediaUnion: Codable { + /// An image that will be embedded. case embedImages(AppBskyLexicon.Embed.ImagesDefinition) + /// An external link that will be embedded. case embedExternal(AppBskyLexicon.Embed.ExternalDefinition) @@ -185,8 +203,10 @@ public struct ATUnion { /// A reference containing the list of the types of compatible media that can be viewed. public enum MediaViewUnion: Codable { + /// An image that's been embedded. case embedImagesView(AppBskyLexicon.Embed.ImagesView) + /// An external link that's been embedded. case embedExternalView(AppBskyLexicon.Embed.ExternalView) @@ -218,12 +238,16 @@ public struct ATUnion { /// A reference containing the list of the types of embeds. public enum EmbedViewUnion: Codable { + /// The view of an external embed. case embedExternalView(AppBskyLexicon.Embed.ExternalView) + /// The view of an image embed. case embedImagesView(AppBskyLexicon.Embed.ImagesView) + /// The view of a record embed. case embedRecordView(AppBskyLexicon.Embed.RecordView) + /// The view of a record embed alongside an embed of some compatible media. case embedRecordWithMediaView(AppBskyLexicon.Embed.RecordWithMediaView) @@ -235,7 +259,7 @@ public struct ATUnion { } else if let value = try? container.decode(AppBskyLexicon.Embed.ImagesView.self) { self = .embedImagesView(value) } else if let value = try? container.decode(AppBskyLexicon.Embed.RecordView.self) { - print("EmbedView.embedRecordView is about to be read.") +// print("EmbedView.embedRecordView is about to be read.") self = .embedRecordView(value) } else if let value = try? container.decode(AppBskyLexicon.Embed.RecordWithMediaView.self) { self = .embedRecordWithMediaView(value) @@ -264,10 +288,13 @@ public struct ATUnion { /// A reference containing the list of the states of a post. public enum PostUnion: Codable { + /// The view of a post. case postView(AppBskyLexicon.Feed.PostViewDefinition) + /// The view of a post that may not have been found. case notFoundPost(AppBskyLexicon.Feed.NotFoundPostDefinition) + /// The view of a post that's been blocked by the post author. case blockedPost(AppBskyLexicon.Feed.BlockedPostDefinition) @@ -303,10 +330,13 @@ public struct ATUnion { /// A reference containing the list of the states of a post. public indirect enum ThreadPostUnion: Codable { + /// The view of a post thread. case threadViewPost(AppBskyLexicon.Feed.ThreadViewPostDefinition) + /// The view of a post that may not have been found. case notFoundPost(AppBskyLexicon.Feed.NotFoundPostDefinition) + /// The view of a post that's been blocked by the post author. case blockedPost(AppBskyLexicon.Feed.BlockedPostDefinition) @@ -342,10 +372,13 @@ public struct ATUnion { /// A reference containing the list of the state of a post thread. public enum FeedGetPostThreadUnion: Codable { + /// A post thread. case threadViewPost(AppBskyLexicon.Feed.ThreadViewPostDefinition) + /// The post thread wasn't found. case notFoundPost(AppBskyLexicon.Feed.NotFoundPostDefinition) + /// The post thread was made by someone who blocked the user account. case blockedPost(AppBskyLexicon.Feed.BlockedPostDefinition) @@ -379,8 +412,58 @@ public struct ATUnion { } } + /// A reference containing the list of types of embeds. + public enum EmbedUnion: Codable { + + /// An image embed. + case images(AppBskyLexicon.Embed.ImagesDefinition) + + /// An external embed. + case external(AppBskyLexicon.Embed.ExternalDefinition) + + /// A record embed. + case record(AppBskyLexicon.Embed.RecordDefinition) + + /// A embed with both a record and some compatible media. + case recordWithMedia(AppBskyLexicon.Embed.RecordWithMediaDefinition) + + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + + if let imagesValue = try? container.decode(AppBskyLexicon.Embed.ImagesDefinition.self) { + self = .images(imagesValue) + } else if let externalValue = try? container.decode(AppBskyLexicon.Embed.ExternalDefinition.self) { + self = .external(externalValue) + } else if let recordValue = try? container.decode(AppBskyLexicon.Embed.RecordDefinition.self) { + self = .record(recordValue) + } else if let recordWithMediaValue = try? container.decode(AppBskyLexicon.Embed.RecordWithMediaDefinition.self) { + self = .recordWithMedia(recordWithMediaValue) + } else { + throw DecodingError.typeMismatch( + EmbedUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown EmbedUnion type")) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + + switch self { + case .images(let imagesValue): + try container.encode(imagesValue) + case .external(let externalValue): + try container.encode(externalValue) + case .record(let recordValue): + try container.encode(recordValue) + case .recordWithMedia(let recordWithMediaValue): + try container.encode(recordWithMediaValue) + } + } + } + /// A reference containing the list of user-defined labels. public enum FeedLabelUnion: Codable { + /// An array of user-defined labels. case selfLabels(SelfLabels) @@ -405,9 +488,55 @@ public struct ATUnion { } } + /// A reference containing the list of thread rules for a post. + public enum ThreadgateUnion: Codable { + + /// The rule which states that anyone who the user account has mentioned can interact. + case mentionRule(AppBskyLexicon.Feed.FeedThreadgateListRule) + + /// The rule which states that anyone the user account is following can interact. + case followingRule(AppBskyLexicon.Feed.FeedThreadgateFollowingRule) + + /// The rule which states that anyone within a list can interact. + case listRule(AppBskyLexicon.Feed.FeedThreadgateListRule) + + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + + if let value = try? container.decode(AppBskyLexicon.Feed.FeedThreadgateListRule.self) { + self = .mentionRule(value) + } else if let value = try? container.decode(AppBskyLexicon.Feed.FeedThreadgateFollowingRule.self) { + self = .followingRule(value) + } else if let value = try? container.decode(AppBskyLexicon.Feed.FeedThreadgateListRule.self) { + self = .listRule(value) + } else { + throw DecodingError.typeMismatch( + EmbedViewUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown ThreadgateUnion type")) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + + switch self { + case .mentionRule(let embedView): + try container.encode(embedView) + case .followingRule(let embedView): + try container.encode(embedView) + case .listRule(let embedView): + try container.encode(embedView) + } + } + } + /// A reference containing the list of relationships of multiple user accounts. public enum GraphRelationshipUnion: Codable { + + /// The relationship between two user accounts. case relationship(AppBskyLexicon.Graph.RelationshipDefinition) + + /// Indicates the user account is not found. case notFoundActor(AppBskyLexicon.Graph.NotFoundActorDefinition) public init(from decoder: Decoder) throws { @@ -438,8 +567,10 @@ public struct ATUnion { /// A reference containing the list of labeler views. public enum LabelerViewUnion: Codable { + /// A labeler view. case labelerView(AppBskyLexicon.Labeler.LabelerViewDefinition) + /// A detailed view of a labeler. case labelerViewDetailed(AppBskyLexicon.Labeler.LabelerViewDetailedDefinition) @@ -471,10 +602,13 @@ public struct ATUnion { /// A reference containing the list of feature types. public enum FeatureUnion: Codable { + /// The Mention feature. case mention(AppBskyLexicon.RichText.Mention) + /// The Link feature. case link(AppBskyLexicon.RichText.Link) + /// The Tag feature. case tag(AppBskyLexicon.RichText.Tag) @@ -512,6 +646,8 @@ public struct ATUnion { /// A reference containing the list of message embeds. public enum MessageEmbedUnion: Codable { + + /// A record within the embed. case record(AppBskyLexicon.Embed.RecordDefinition) public init(from decoder: any Decoder) throws { @@ -538,7 +674,11 @@ public struct ATUnion { /// A reference containing the list of messages. public enum MessageViewUnion: Codable { + + /// A message view. case messageView(ChatBskyLexicon.Conversation.MessageView) + + /// A deleted message view. case deletedMessageView(ChatBskyLexicon.Conversation.DeleteMessageView) public init(from decoder: any Decoder) throws { @@ -569,9 +709,17 @@ public struct ATUnion { /// A reference containing the list of message logs. public enum MessageLogsUnion: Codable { + + /// A log entry for beginning the coversation. case logBeginConversation(ChatBskyLexicon.Conversation.LogBeginConversation) + + /// A log entry for leaving the conversation. case logLeaveConversation(ChatBskyLexicon.Conversation.LogLeaveConversation) + + /// A log entry for creating a message. case logCreateMessage(ChatBskyLexicon.Conversation.LogCreateMessage) + + /// A log entry for deleting a message. case logDeleteMessage(ChatBskyLexicon.Conversation.LogDeleteMessage) public init(from decoder: any Decoder) throws { @@ -607,4 +755,373 @@ public struct ATUnion { } } } + + /// A reference containing the list of event views. + public enum AdminEventViewUnion: Codable { + + /// A takedown event. + case moderationEventTakedown(OzoneModerationEventTakedown) + + /// A reverse takedown event. + case moderationEventReverseTakedown(OzoneModerationEventReverseTakedown) + + /// A comment event. + case moderationEventComment(OzoneModerationEventComment) + + /// A report event. + case moderationEventReport(OzoneModerationEventReport) + + /// A label event. + case moderationEventLabel(OzoneModerationEventLabel) + + /// An acknowledgement event. + case moderationEventAcknowledge(OzoneModerationEventAcknowledge) + + /// An escalation event. + case moderationEventEscalate(OzoneModerationEventEscalate) + + /// A mute event. + case moderationEventMute(OzoneModerationEventMute) + + /// An unmute event. + case moderationEventUnmute(OzoneModerationEventUnmute) + + /// A mute reporter event. + case moderationEventMuteReporter(OzoneModerationEventMuteReporter) + + /// An unmute reporter event. + case moderationEventUnmuteReporter(OzoneModerationEventUnmuteReporter) + + /// An email event. + case moderationEventEmail(OzoneModerationEventEmail) + + /// A resolve appeal event. + case moderationEventResolveAppeal(OzoneModerationEventResolveAppeal) + + /// A diversion event. + case moderationEventDivert(OzoneModerationEventDivert) + + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + + if let value = try? container.decode(OzoneModerationEventTakedown.self) { + self = .moderationEventTakedown(value) + } else if let value = try? container.decode(OzoneModerationEventReverseTakedown.self) { + self = .moderationEventReverseTakedown(value) + } else if let value = try? container.decode(OzoneModerationEventComment.self) { + self = .moderationEventComment(value) + } else if let value = try? container.decode(OzoneModerationEventReport.self) { + self = .moderationEventReport(value) + } else if let value = try? container.decode(OzoneModerationEventLabel.self) { + self = .moderationEventLabel(value) + } else if let value = try? container.decode(OzoneModerationEventAcknowledge.self) { + self = .moderationEventAcknowledge(value) + } else if let value = try? container.decode(OzoneModerationEventEscalate.self) { + self = .moderationEventEscalate(value) + } else if let value = try? container.decode(OzoneModerationEventMute.self) { + self = .moderationEventMute(value) + } else if let value = try? container.decode(OzoneModerationEventUnmute.self) { + self = .moderationEventUnmute(value) + } else if let value = try? container.decode(OzoneModerationEventMuteReporter.self) { + self = .moderationEventMuteReporter(value) + } else if let value = try? container.decode(OzoneModerationEventUnmuteReporter.self) { + self = .moderationEventUnmuteReporter(value) + } else if let value = try? container.decode(OzoneModerationEventEmail.self) { + self = .moderationEventEmail(value) + } else if let value = try? container.decode(OzoneModerationEventResolveAppeal.self) { + self = .moderationEventResolveAppeal(value) + } else if let value = try? container.decode(OzoneModerationEventDivert.self) { + self = .moderationEventDivert(value) + } else { + throw DecodingError.typeMismatch( + AdminEventViewUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown EventViewUnion type")) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + + switch self { + case .moderationEventTakedown(let moderationEventTakedown): + try container.encode(moderationEventTakedown) + case .moderationEventReverseTakedown(let moderationEventReverseTakedown): + try container.encode(moderationEventReverseTakedown) + case .moderationEventComment(let moderationEventComment): + try container.encode(moderationEventComment) + case .moderationEventReport(let moderationEventReport): + try container.encode(moderationEventReport) + case .moderationEventLabel(let moderationEventLabel): + try container.encode(moderationEventLabel) + case .moderationEventAcknowledge(let moderationEventAcknowledge): + try container.encode(moderationEventAcknowledge) + case .moderationEventEscalate(let moderationEventEscalate): + try container.encode(moderationEventEscalate) + case .moderationEventMute(let moderationEventMute): + try container.encode(moderationEventMute) + case .moderationEventUnmute(let moderationEventUnmute): + try container.encode(moderationEventUnmute) + case .moderationEventMuteReporter(let moderationEventMuteReporter): + try container.encode(moderationEventMuteReporter) + case .moderationEventUnmuteReporter(let moderationEventUnmuteReporter): + try container.encode(moderationEventUnmuteReporter) + case .moderationEventEmail(let moderationEventEmail): + try container.encode(moderationEventEmail) + case .moderationEventResolveAppeal(let moderationEventResolveAppeal): + try container.encode(moderationEventResolveAppeal) + case .moderationEventDivert(let moderationEventDivert): + try container.encode(moderationEventDivert) + } + } + } + + // Create the custom init and encode methods. + /// A reference containing the list of repository references. + public enum RepositoryReferencesUnion: Codable { + + /// A repository reference. + case repositoryReference(AdminRepositoryReference) + + /// A strong reference. + case strongReference(StrongReference) + + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + + if let value = try? container.decode(AdminRepositoryReference.self) { + self = .repositoryReference(value) + } else if let value = try? container.decode(StrongReference.self) { + self = .strongReference(value) + } else { + throw DecodingError.typeMismatch( + ActorPreferenceUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown RepositoryReferencesUnion type")) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + + switch self { + case .repositoryReference(let repositoryReference): + try container.encode(repositoryReference) + case .strongReference(let strongReference): + try container.encode(strongReference) + } + } + } + + // Create the custom init and encode methods. + /// A reference containing the list of moderator events. + public enum EventViewDetailUnion: Codable { + + /// A takedown event. + case moderationEventTakedown(OzoneModerationEventTakedown) + + /// A reverse takedown event. + case moderationEventReverseTakedown(OzoneModerationEventReverseTakedown) + + /// A comment event. + case moderationEventComment(OzoneModerationEventComment) + + /// A report event. + case moderationEventReport(OzoneModerationEventReport) + + /// A label event. + case moderationEventLabel(OzoneModerationEventLabel) + + /// An acknowledgment event. + case moderationEventAcknowledge(OzoneModerationEventAcknowledge) + + /// An escalation event. + case moderationEventEscalate(OzoneModerationEventEscalate) + + /// A mute event. + case moderationEventMute(OzoneModerationEventMute) + + /// A resolve appeal event. + case moderationEventResolveAppeal(OzoneModerationEventResolveAppeal) + + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + + if let value = try? container.decode(OzoneModerationEventTakedown.self) { + self = .moderationEventTakedown(value) + } else if let value = try? container.decode(OzoneModerationEventReverseTakedown.self) { + self = .moderationEventReverseTakedown(value) + } else if let value = try? container.decode(OzoneModerationEventComment.self) { + self = .moderationEventComment(value) + } else if let value = try? container.decode(OzoneModerationEventReport.self) { + self = .moderationEventReport(value) + } else if let value = try? container.decode(OzoneModerationEventLabel.self) { + self = .moderationEventLabel(value) + } else if let value = try? container.decode(OzoneModerationEventAcknowledge.self) { + self = .moderationEventAcknowledge(value) + } else if let value = try? container.decode(OzoneModerationEventEscalate.self) { + self = .moderationEventEscalate(value) + } else if let value = try? container.decode(OzoneModerationEventMute.self) { + self = .moderationEventMute(value) + } else if let value = try? container.decode(OzoneModerationEventResolveAppeal.self) { + self = .moderationEventResolveAppeal(value) + } else { + throw DecodingError.typeMismatch( + ActorPreferenceUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown EventViewDetailUnion type")) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + + switch self { + case .moderationEventTakedown(let moderationEventTakedown): + try container.encode(moderationEventTakedown) + case .moderationEventReverseTakedown(let moderationEventDetail): + try container.encode(moderationEventDetail) + case .moderationEventComment(let moderationEventComment): + try container.encode(moderationEventComment) + case .moderationEventReport(let moderationEventReport): + try container.encode(moderationEventReport) + case .moderationEventLabel(let moderationEventLabel): + try container.encode(moderationEventLabel) + case .moderationEventAcknowledge(let moderationEventAcknowledge): + try container.encode(moderationEventAcknowledge) + case .moderationEventEscalate(let moderationEventEscalate): + try container.encode(moderationEventEscalate) + case .moderationEventMute(let moderationEventMute): + try container.encode(moderationEventMute) + case .moderationEventResolveAppeal(let moderationEventResolveAppeal): + try container.encode(moderationEventResolveAppeal) + } + } + } + + // Create the custom init and encode methods. + /// A reference containing the list of the types of repository or record views. + public enum RepositoryViewUnion: Codable { + + /// A normal repository view. + case repositoryView(AdminReportView) + + /// A repository view that may not have been found. + case repositoryViewNotFound(OzoneModerationRepositoryViewNotFound) + + /// A normal record. + case recordView(OzoneModerationRecordView) + + /// A record view that may not have been found. + case recordViewNotFound(OzoneModerationRecordViewNotFound) + + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + + if let value = try? container.decode(AdminReportView.self) { + self = .repositoryView(value) + } else if let value = try? container.decode(OzoneModerationRepositoryViewNotFound.self) { + self = .repositoryViewNotFound(value) + } else if let value = try? container.decode(OzoneModerationRecordView.self) { + self = .recordView(value) + } else if let value = try? container.decode(OzoneModerationRecordViewNotFound.self) { + self = .recordViewNotFound(value) + } else { + throw DecodingError.typeMismatch( + ActorPreferenceUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown RepositoryViewUnion type")) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + + switch self { + case .repositoryView(let repositoryView): + try container.encode(repositoryView) + case .repositoryViewNotFound(let repositoryViewNotFound): + try container.encode(repositoryViewNotFound) + case .recordView(let recordView): + try container.encode(recordView) + case .recordViewNotFound(let recordViewNotFound): + try container.encode(recordViewNotFound) + } + } + } + + /// A reference containing the list of the types of media details. + public enum MediaDetailUnion: Codable { + + /// The details for an image. + case mediaImageDetails(OzoneModerationMediaImageDetails) + + /// The details for a video. + case mediaVideoDetails(OzoneModerationMediaVideoDetails) + + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + + if let value = try? container.decode(OzoneModerationMediaImageDetails.self) { + self = .mediaImageDetails(value) + } else if let value = try? container.decode(OzoneModerationMediaVideoDetails.self) { + self = .mediaVideoDetails(value) + } else { + throw DecodingError.typeMismatch( + ActorPreferenceUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown MediaDetailUnion type")) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + + switch self { + case .mediaImageDetails(let mediaImageDetails): + try container.encode(mediaImageDetails) + case .mediaVideoDetails(let mediaVideoDetails): + try container.encode(mediaVideoDetails) + } + } + } + + /// A reference containing the list of write operations. + public enum ApplyWritesUnion: Codable { + + /// A "Create" write operation. + case create(RepoApplyWritesCreate) + + /// An "Update" write operation. + case update(RepoApplyWritesUpdate) + + /// A "Delete" write operation. + case delete(RepoApplyWritesDelete) + + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + + if let value = try? container.decode(RepoApplyWritesCreate.self) { + self = .create(value) + } else if let value = try? container.decode(RepoApplyWritesUpdate.self) { + self = .update(value) + } else if let value = try? container.decode(RepoApplyWritesDelete.self) { + self = .delete(value) + } else { + throw DecodingError.typeMismatch( + EmbedViewUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown ApplyWritesUnion type")) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + + switch self { + case .create(let embedView): + try container.encode(embedView) + case .update(let embedView): + try container.encode(embedView) + case .delete(let embedView): + try container.encode(embedView) + } + } + } + + } diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorPutPreferences.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorPutPreferences.swift index 8b3a762cfd..d1619ac4b1 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorPutPreferences.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorPutPreferences.swift @@ -17,7 +17,7 @@ extension AppBskyLexicon.Actor { public let type: String = "app.bsky.actor.putPreferences" /// A list of preferences by the user. - public let preferences: [ActorPreferenceUnion] + public let preferences: [ATUnion.ActorPreferenceUnion] enum CodingKeys: String, CodingKey { case type = "$type" diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorSearchActorsTypeahead.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorSearchActorsTypeahead.swift index dbb5fb1daa..b6e8e96d7b 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorSearchActorsTypeahead.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorSearchActorsTypeahead.swift @@ -16,6 +16,7 @@ extension AppBskyLexicon.Actor { /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/searchActorsTypeahead.json public struct ActorSearchActorsTypeaheadOutput: Codable { + /// An array of actors. public let actors: [ActorProfileViewBasic] } diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedRecord.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedRecord.swift index 383d803b3e..7381a37931 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedRecord.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedRecord.swift @@ -49,7 +49,7 @@ extension AppBskyLexicon.Embed { /// The record of a specific type. public let record: ATUnion.RecordViewUnion - + enum CodingKeys: String, CodingKey { case type = "$type" case record @@ -95,13 +95,13 @@ extension AppBskyLexicon.Embed { public let likeCount: Int? /// An array of embed views of various types. - public let embeds: [EmbedViewUnion]? + public let embeds: [ATUnion.EmbedViewUnion]? /// The date the record was last indexed. @DateFormatting public var indexedAt: Date public init(recordURI: String, cidHash: String, author: AppBskyLexicon.Actor.ProfileViewBasicDefinition, value: UnknownType, labels: [Label]?, replyCount: Int?, - repostCount: Int?, likeCount: Int?, embeds: [EmbedViewUnion]?, indexedAt: Date) { + repostCount: Int?, likeCount: Int?, embeds: [ATUnion.EmbedViewUnion]?, indexedAt: Date) { self.recordURI = recordURI self.cidHash = cidHash self.author = author @@ -125,7 +125,7 @@ extension AppBskyLexicon.Embed { self.replyCount = try container.decodeIfPresent(Int.self, forKey: .replyCount) self.repostCount = try container.decodeIfPresent(Int.self, forKey: .repostCount) self.likeCount = try container.decodeIfPresent(Int.self, forKey: .likeCount) - self.embeds = try container.decodeIfPresent([EmbedViewUnion].self, forKey: .embeds) + self.embeds = try container.decodeIfPresent([ATUnion.EmbedViewUnion].self, forKey: .embeds) self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue } diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedRecordWithMedia.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedRecordWithMedia.swift index 477302e387..d3a7f5c83d 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedRecordWithMedia.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedRecordWithMedia.swift @@ -29,7 +29,7 @@ extension AppBskyLexicon.Embed { public let record: RecordDefinition /// The media of a specific type. - public let media: MediaUnion + public let media: ATUnion.MediaUnion enum CodingKeys: String, CodingKey { case type = "$type" @@ -55,7 +55,7 @@ extension AppBskyLexicon.Embed { public let record: EmbedRecordView /// The embedded media. - public let media: MediaViewUnion + public let media: ATUnion.MediaViewUnion enum CodingKeys: String, CodingKey { case type = "$type" diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedDefs.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedDefs.swift index 71d9614f5f..1ea91c83d4 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedDefs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedDefs.swift @@ -29,7 +29,7 @@ extension AppBskyLexicon.Feed { public let record: UnknownType /// An embed view of a specific type. Optional. - public var embed: EmbedViewUnion? + public var embed: ATUnion.EmbedViewUnion? /// The number of replies in the post. Optional. public var replyCount: Int? @@ -52,7 +52,7 @@ extension AppBskyLexicon.Feed { /// The ruleset of who can reply to the post. Optional. public var threadgate: ThreadgateViewDefinition? - public init(postURI: String, cidHash: String, author: AppBskyLexicon.Actor.ProfileViewBasicDefinition, record: UnknownType, embed: EmbedViewUnion?, replyCount: Int?, + public init(postURI: String, cidHash: String, author: AppBskyLexicon.Actor.ProfileViewBasicDefinition, record: UnknownType, embed: ATUnion.EmbedViewUnion?, replyCount: Int?, repostCount: Int?, likeCount: Int?, indexedAt: Date, viewer: ViewerStateDefinition?, labels: [Label]?, threadgate: ThreadgateViewDefinition?) { self.postURI = postURI self.cidHash = cidHash @@ -75,7 +75,7 @@ extension AppBskyLexicon.Feed { self.cidHash = try container.decode(String.self, forKey: .cidHash) self.author = try container.decode(AppBskyLexicon.Actor.ProfileViewBasicDefinition.self, forKey: .author) self.record = try container.decode(UnknownType.self, forKey: .record) - self.embed = try container.decodeIfPresent(EmbedViewUnion.self, forKey: .embed) + self.embed = try container.decodeIfPresent(ATUnion.EmbedViewUnion.self, forKey: .embed) self.replyCount = try container.decodeIfPresent(Int.self, forKey: .replyCount) self.repostCount = try container.decodeIfPresent(Int.self, forKey: .repostCount) self.likeCount = try container.decodeIfPresent(Int.self, forKey: .likeCount) @@ -211,14 +211,14 @@ extension AppBskyLexicon.Feed { public struct ReplyReferenceDefinition: Codable { /// The original post of the thread. - public let root: PostUnion + public let root: ATUnion.PostUnion // TODO: Fix up the note's message. /// The direct post that the user's post is replying to. /// /// - Note: If `parent` and `root` are identical, the post is a direct reply to the /// original post of the thread. - public let parent: PostUnion + public let parent: ATUnion.PostUnion /// The author of the parent's post. /// @@ -276,10 +276,10 @@ extension AppBskyLexicon.Feed { public let post: PostViewDefinition /// The direct post that the user's post is replying to. Optional. - public var parent: ThreadPostUnion? + public var parent: ATUnion.ThreadPostUnion? /// An array of posts of various types. Optional. - public var replies: [ThreadPostUnion]? + public var replies: [ATUnion.ThreadPostUnion]? } /// A data model for a definition of a post that may not have been found. diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetPostThread.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetPostThread.swift index 117b076336..4358f41630 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetPostThread.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetPostThread.swift @@ -20,6 +20,6 @@ extension AppBskyLexicon.Feed { public struct GetPostThreadOutput: Codable { /// The post thread itself. - public let thread: FeedGetPostThreadUnion + public let thread: ATUnion.FeedGetPostThreadUnion } } diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedPost.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedPost.swift index 4d5d3de28d..ae702c3e20 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedPost.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedPost.swift @@ -40,7 +40,7 @@ extension AppBskyLexicon.Feed { /// The references to posts when replying. Optional. public var reply: PostReplyReference? /// The embed of the post. Optional. - public var embed: EmbedUnion? + public var embed: ATUnion.EmbedUnion? /// An array of languages the post text contains. Optional. /// /// - Note: According to the AT Protocol specifications: "Indicates human language of post @@ -53,7 +53,7 @@ extension AppBskyLexicon.Feed { /// /// - Note: According to the AT Protocol specifications: "Self-label values for this post. /// Effectively content warnings." - public var labels: FeedLabelUnion? + public var labels: ATUnion.FeedLabelUnion? /// An array of user-defined tags. Optional. /// /// - Note: According to the AT Protocol specifications: "Additional hashtags, in addition to @@ -69,8 +69,8 @@ extension AppBskyLexicon.Feed { /// post was originally created." @DateFormatting public var createdAt: Date - public init(text: String, facets: [AppBskyLexicon.RichText.Facet]?, reply: PostReplyReference?, embed: EmbedUnion?, languages: [String]?, - labels: FeedLabelUnion?, tags: [String]?, createdAt: Date) { + public init(text: String, facets: [AppBskyLexicon.RichText.Facet]?, reply: PostReplyReference?, embed: ATUnion.EmbedUnion?, languages: [String]?, + labels: ATUnion.FeedLabelUnion?, tags: [String]?, createdAt: Date) { self.text = text self.facets = facets self.reply = reply @@ -87,9 +87,9 @@ extension AppBskyLexicon.Feed { self.text = try container.decode(String.self, forKey: .text) self.facets = try container.decodeIfPresent([AppBskyLexicon.RichText.Facet].self, forKey: .facets) self.reply = try container.decodeIfPresent(PostReplyReference.self, forKey: .reply) - self.embed = try container.decodeIfPresent(EmbedUnion.self, forKey: .embed) + self.embed = try container.decodeIfPresent(ATUnion.EmbedUnion.self, forKey: .embed) self.languages = try container.decodeIfPresent([String].self, forKey: .languages) - self.labels = try container.decodeIfPresent(FeedLabelUnion.self, forKey: .labels) + self.labels = try container.decodeIfPresent(ATUnion.FeedLabelUnion.self, forKey: .labels) self.tags = try container.decodeIfPresent([String].self, forKey: .tags) self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue } diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedThreadgate.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedThreadgate.swift index b4e48e75d0..c082fd61bf 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedThreadgate.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedThreadgate.swift @@ -32,12 +32,12 @@ extension AppBskyLexicon.Feed { public let post: String /// An array of rules used as an allowlist. - public let allow: [ThreadgateUnion] + public let allow: [ATUnion.ThreadgateUnion] /// The date and time of the creation of the threadgate. @DateFormatting public var createdAt: Date - public init(post: String, allow: [ThreadgateUnion], createdAt: Date) { + public init(post: String, allow: [ATUnion.ThreadgateUnion], createdAt: Date) { self.post = post self.allow = allow self._createdAt = DateFormatting(wrappedValue: createdAt) @@ -47,7 +47,7 @@ extension AppBskyLexicon.Feed { let container = try decoder.container(keyedBy: CodingKeys.self) self.post = try container.decode(String.self, forKey: .post) - self.allow = try container.decode([ThreadgateUnion].self, forKey: .allow) + self.allow = try container.decode([ATUnion.ThreadgateUnion].self, forKey: .allow) self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue } From 21bba6eddaabfc4edbd9dece35b01652b3b77f30 Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Mon, 20 May 2024 11:33:01 -0400 Subject: [PATCH 12/51] Change lexicon layout and fix issues - The following lexicons have been changed: - com.atproto.admin.* - com.atproto.identity.* - com.atproto.label.* - com.atproto.moderation.* - com.atproto.repo.* - Fixed an issue where some of the models in the ".def" files lacked the "Definition" suffix. - Updated chat.bsky.* lexicons to the latest changes. - Added more union types to ATUnion. - Fixed ATUnion to reflect the above changes. --- .../ATProtoKit/Models/Lexicons/ATUnion.swift | 65 ++- .../chat.bsky/Convo/ChatBskyConvoDefs.swift | 33 +- .../ChatBskyConvoDeleteMessageForSelf.swift | 2 +- .../Convo/ChatBskyConvoGetConvo.swift | 2 +- .../ChatBskyConvoGetConvoForMembers.swift | 2 +- .../Convo/ChatBskyConvoListConvo.swift | 2 +- .../Convo/ChatBskyConvoMuteConvo.swift | 2 +- .../Convo/ChatBskyConvoSendMessage.swift | 2 +- .../Convo/ChatBskyConvoSendMessageBatch.swift | 10 +- .../Convo/ChatBskyConvoUnmuteConvo.swift | 2 +- .../Convo/ChatBskyConvoUpdateRead.swift | 2 +- .../Admin/ComAtprotoAdminDefs.swift | 343 ++++++++++++++ .../Admin/ComAtprotoAdminDeleteAccount.swift | 25 ++ ...ComAtprotoAdminDisableAccountInvites.swift | 37 ++ .../ComAtprotoAdminDisableInviteCodes.swift | 34 ++ .../ComAtprotoAdminEnableAccountInvites.swift | 35 ++ .../ComAtprotoAdminGetAccountInfos.swift | 24 + .../Admin/ComAtprotoAdminGetInviteCodes.swift | 37 ++ .../ComAtprotoAdminGetSubjectStatus.swift | 28 ++ ...mAtprotoAdminQueryModerationStatuses.swift | 49 ++ .../Admin/ComAtprotoAdminSearchRepos.swift | 28 ++ .../Admin/ComAtprotoAdminSendEmail.swift | 63 +++ .../ComAtprotoAdminUpdateAccountEmail.swift | 32 ++ .../ComAtprotoAdminUpdateAccountHandle.swift | 34 ++ ...ComAtprotoAdminUpdateAccountPassword.swift | 34 ++ .../ComAtprotoAdminUpdateSubjectStatus.swift | 47 ++ ...IdentityGetRecommendedDidCredentials.swift | 34 ++ ...IdentityRequestPlcOperationSignature.swift | 21 + .../ComAtprotoIdentityResolveHandle.swift | 22 + .../ComAtprotoIdentitySignPLCOperation.swift | 55 +++ ...ComAtprotoIdentitySubmitPLCOperation.swift | 26 ++ .../ComAtprotoIdentityUpdateHandle.swift | 28 ++ .../Label/ComAtprotoLabelDefs.swift | 423 ++++++++++++++++++ .../Label/ComAtprotoLabelQueryLabels.swift | 27 ++ .../ComAtprotoModerationCreateReport.swift | 119 +++++ .../Moderation/ComAtprotoModerationDefs.swift | 67 +++ .../Repo/ComAtProtoRepoStrongRef.swift | 44 ++ .../Repo/ComAtprotoRepoApplyWrites.swift | 128 ++++++ .../Repo/ComAtprotoRepoCreateRecord.swift | 76 ++++ .../Repo/ComAtprotoRepoDeleteRecord.swift | 61 +++ .../Repo/ComAtprotoRepoDescribeRepo.swift | 54 +++ .../Repo/ComAtprotoRepoGetRecord.swift | 46 ++ .../Repo/ComAtprotoRepoImportRepo.swift | 25 ++ .../Repo/ComAtprotoRepoListMissingBlobs.swift | 36 ++ .../Repo/ComAtprotoRepoListRecords.swift | 28 ++ .../Repo/ComAtprotoRepoPutRecord.swift | 75 ++++ .../Repo/ComAtprotoRepoUploadBlob.swift | 88 ++++ 47 files changed, 2418 insertions(+), 39 deletions(-) create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminDefs.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminDeleteAccount.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminDisableAccountInvites.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminDisableInviteCodes.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminEnableAccountInvites.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminGetAccountInfos.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminGetInviteCodes.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminGetSubjectStatus.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminQueryModerationStatuses.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminSearchRepos.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminSendEmail.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminUpdateAccountEmail.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminUpdateAccountHandle.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminUpdateAccountPassword.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminUpdateSubjectStatus.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentityGetRecommendedDidCredentials.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentityRequestPlcOperationSignature.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentityResolveHandle.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentitySignPLCOperation.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentitySubmitPLCOperation.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentityUpdateHandle.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Label/ComAtprotoLabelDefs.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Label/ComAtprotoLabelQueryLabels.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Moderation/ComAtprotoModerationCreateReport.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Moderation/ComAtprotoModerationDefs.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtProtoRepoStrongRef.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoApplyWrites.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoCreateRecord.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoDeleteRecord.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoDescribeRepo.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoGetRecord.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoImportRepo.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoListMissingBlobs.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoListRecords.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoPutRecord.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoUploadBlob.swift diff --git a/Sources/ATProtoKit/Models/Lexicons/ATUnion.swift b/Sources/ATProtoKit/Models/Lexicons/ATUnion.swift index e9faa5b371..2ae25aef9b 100644 --- a/Sources/ATProtoKit/Models/Lexicons/ATUnion.swift +++ b/Sources/ATProtoKit/Models/Lexicons/ATUnion.swift @@ -676,17 +676,17 @@ public struct ATUnion { public enum MessageViewUnion: Codable { /// A message view. - case messageView(ChatBskyLexicon.Conversation.MessageView) + case messageView(ChatBskyLexicon.Conversation.MessageViewDefinition) /// A deleted message view. - case deletedMessageView(ChatBskyLexicon.Conversation.DeleteMessageView) + case deletedMessageView(ChatBskyLexicon.Conversation.DeleteMessageViewDefinition) public init(from decoder: any Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(ChatBskyLexicon.Conversation.MessageView.self) { + if let value = try? container.decode(ChatBskyLexicon.Conversation.MessageViewDefinition.self) { self = .messageView(value) - } else if let value = try? container.decode(ChatBskyLexicon.Conversation.DeleteMessageView.self) { + } else if let value = try? container.decode(ChatBskyLexicon.Conversation.DeleteMessageViewDefinition.self) { self = .deletedMessageView(value) } else { throw DecodingError.typeMismatch( @@ -711,27 +711,27 @@ public struct ATUnion { public enum MessageLogsUnion: Codable { /// A log entry for beginning the coversation. - case logBeginConversation(ChatBskyLexicon.Conversation.LogBeginConversation) + case logBeginConversation(ChatBskyLexicon.Conversation.LogBeginConversationDefinition) /// A log entry for leaving the conversation. - case logLeaveConversation(ChatBskyLexicon.Conversation.LogLeaveConversation) + case logLeaveConversation(ChatBskyLexicon.Conversation.LogLeaveConversationDefinition) /// A log entry for creating a message. - case logCreateMessage(ChatBskyLexicon.Conversation.LogCreateMessage) + case logCreateMessage(ChatBskyLexicon.Conversation.LogCreateMessageDefinition) /// A log entry for deleting a message. - case logDeleteMessage(ChatBskyLexicon.Conversation.LogDeleteMessage) + case logDeleteMessage(ChatBskyLexicon.Conversation.LogDeleteMessageDefinition) public init(from decoder: any Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(ChatBskyLexicon.Conversation.LogBeginConversation.self) { + if let value = try? container.decode(ChatBskyLexicon.Conversation.LogBeginConversationDefinition.self) { self = .logBeginConversation(value) - } else if let value = try? container.decode(ChatBskyLexicon.Conversation.LogLeaveConversation.self) { + } else if let value = try? container.decode(ChatBskyLexicon.Conversation.LogLeaveConversationDefinition.self) { self = .logLeaveConversation(value) - } else if let value = try? container.decode(ChatBskyLexicon.Conversation.LogCreateMessage.self) { + } else if let value = try? container.decode(ChatBskyLexicon.Conversation.LogCreateMessageDefinition.self) { self = .logCreateMessage(value) - } else if let value = try? container.decode(ChatBskyLexicon.Conversation.LogDeleteMessage.self) { + } else if let value = try? container.decode(ChatBskyLexicon.Conversation.LogDeleteMessageDefinition.self) { self = .logDeleteMessage(value) } else { throw DecodingError.typeMismatch( @@ -875,6 +875,47 @@ public struct ATUnion { } } + /// A reference containing the list of repository references. + public enum AdminGetSubjectStatusUnion: Codable { + + /// A repository reference. + case repositoryReference(AdminRepositoryReference) + + /// A strong reference. + case strongReference(StrongReference) + /// A repository blob reference. + case repoBlobReference(AdminRepoBlobReference) + + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + + if let value = try? container.decode(AdminRepositoryReference.self) { + self = .repositoryReference(value) + } else if let value = try? container.decode(StrongReference.self) { + self = .strongReference(value) + } else if let value = try? container.decode(AdminRepoBlobReference.self) { + self = .repoBlobReference(value) + } else { + throw DecodingError.typeMismatch( + AdminEventViewUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "UnknownAdminGetSubjectStatusUnion type")) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + + switch self { + case .repositoryReference(let repositoryReference): + try container.encode(repositoryReference) + case .strongReference(let strongReference): + try container.encode(strongReference) + case .repoBlobReference(let repoBlobReference): + try container.encode(repoBlobReference) + } + } + } + // Create the custom init and encode methods. /// A reference containing the list of repository references. public enum RepositoryReferencesUnion: Codable { diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoDefs.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoDefs.swift index e2722cbd40..57a2a116f6 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoDefs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoDefs.swift @@ -14,7 +14,7 @@ extension ChatBskyLexicon.Conversation { /// - SeeAlso: This is based on the [`chat.bsky.convo.defs`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/defs.json - public struct MessageReference: Codable { + public struct MessageReferenceDefinition: Codable { /// The decentralized identifier (DID) of the message. public let messageDID: String @@ -22,9 +22,13 @@ extension ChatBskyLexicon.Conversation { /// The ID of the message. public let messageID: String + /// The ID of the conversation. + public let conversationID: String + enum CodingKeys: String, CodingKey { case messageDID = "did" case messageID = "messageId" + case conversationID = "convoId" } } @@ -33,10 +37,7 @@ extension ChatBskyLexicon.Conversation { /// - SeeAlso: This is based on the [`chat.bsky.convo.defs`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/defs.json - public struct Message: Codable { - - /// The ID of the message. Optional. - public let messageID: String? + public struct MessageInputDefinition: Codable { /// The message text itself. /// @@ -55,7 +56,6 @@ extension ChatBskyLexicon.Conversation { public func encode(to encoder: any Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) - try container.encodeIfPresent(self.messageID, forKey: .messageID) // Truncate `tags` to 10000 characters before encoding // `maxGraphemes`'s limit is 1000, but `String.count` should respect that limit implictly try truncatedEncode(self.text, withContainer: &container, forKey: .text, upToLength: 1_000) @@ -64,7 +64,6 @@ extension ChatBskyLexicon.Conversation { } enum CodingKeys: String, CodingKey { - case messageID = "id" case text case facets case embeds = "embed" @@ -76,7 +75,7 @@ extension ChatBskyLexicon.Conversation { /// - SeeAlso: This is based on the [`chat.bsky.convo.defs`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/defs.json - public struct MessageView: Codable { + public struct MessageViewDefinition: Codable { /// The ID of the message. Optional. public let messageID: String? @@ -156,8 +155,8 @@ extension ChatBskyLexicon.Conversation { /// - SeeAlso: This is based on the [`chat.bsky.convo.defs`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/defs.json - public struct DeleteMessageView: Codable { - + public struct DeleteMessageViewDefinition: Codable { + /// The ID of the message. Optional. public let messageID: String? @@ -208,8 +207,8 @@ extension ChatBskyLexicon.Conversation { /// - SeeAlso: This is based on the [`chat.bsky.convo.defs`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/defs.json - public struct MessageViewSender: Codable { - + public struct MessageViewSenderDefinition: Codable { + /// The decentralized identifier (DID) of the message. public let messageDID: String @@ -223,7 +222,7 @@ extension ChatBskyLexicon.Conversation { /// - SeeAlso: This is based on the [`chat.bsky.convo.defs`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/defs.json - public struct ConversationView: Codable { + public struct ConversationViewDefinition: Codable { /// The ID of the conversation. public let conversationID: String @@ -258,7 +257,7 @@ extension ChatBskyLexicon.Conversation { /// - SeeAlso: This is based on the [`chat.bsky.convo.defs`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/defs.json - public struct LogBeginConversation: Codable { + public struct LogBeginConversationDefinition: Codable { /// The revision of the log. public let revision: String @@ -277,7 +276,7 @@ extension ChatBskyLexicon.Conversation { /// - SeeAlso: This is based on the [`chat.bsky.convo.defs`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/defs.json - public struct LogLeaveConversation: Codable { + public struct LogLeaveConversationDefinition: Codable { /// The revision of the log. public let revision: String @@ -296,7 +295,7 @@ extension ChatBskyLexicon.Conversation { /// - SeeAlso: This is based on the [`chat.bsky.convo.defs`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/defs.json - public struct LogCreateMessage: Codable { + public struct LogCreateMessageDefinition: Codable { /// The revision of the log. public let revision: String @@ -319,7 +318,7 @@ extension ChatBskyLexicon.Conversation { /// - SeeAlso: This is based on the [`chat.bsky.convo.defs`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/defs.json - public struct LogDeleteMessage: Codable { + public struct LogDeleteMessageDefinition: Codable { /// The revision of the log. public let revision: String diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoDeleteMessageForSelf.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoDeleteMessageForSelf.swift index 42246859e1..3056f567fa 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoDeleteMessageForSelf.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoDeleteMessageForSelf.swift @@ -20,7 +20,7 @@ extension ChatBskyLexicon.Conversation { public let conversationID: String /// The ID of the message. - public let messageID: DeleteMessageView + public let messageID: DeleteMessageViewDefinition enum CodingKeys: String, CodingKey { case conversationID = "convoID" diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetConvo.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetConvo.swift index 05142224ce..3a5205fb35 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetConvo.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetConvo.swift @@ -17,7 +17,7 @@ extension ChatBskyLexicon.Conversation { public struct GetConversationOutput: Codable { /// The conversation itself. - public let conversation: ConversationView + public let conversation: ConversationViewDefinition enum CodingKeys: String, CodingKey { case conversation = "convo" diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetConvoForMembers.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetConvoForMembers.swift index c004faf112..f0ce185169 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetConvoForMembers.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetConvoForMembers.swift @@ -17,7 +17,7 @@ extension ChatBskyLexicon.Conversation { public struct GetConversationForMembersOutput: Codable { /// The conversation view. - public let conversation: ConversationView + public let conversation: ConversationViewDefinition enum CodingKeys: String, CodingKey { case conversation = "convo" diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoListConvo.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoListConvo.swift index 0533c4361e..0bc9f32f18 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoListConvo.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoListConvo.swift @@ -20,7 +20,7 @@ extension ChatBskyLexicon.Conversation { public let cursor: String /// An array of conversations. - public let conversations: [ConversationView] + public let conversations: [ConversationViewDefinition] enum CodingKeys: String, CodingKey { case cursor diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoMuteConvo.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoMuteConvo.swift index 06c84e5251..faaf7853a3 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoMuteConvo.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoMuteConvo.swift @@ -32,7 +32,7 @@ extension ChatBskyLexicon.Conversation { public struct MuteConversationOutput: Codable { /// The conversation itself. - public let conversation: [ConversationView] + public let conversation: [ConversationViewDefinition] enum CodingKeys: String, CodingKey { case conversation = "convo" diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoSendMessage.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoSendMessage.swift index 336b668523..e23f330f27 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoSendMessage.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoSendMessage.swift @@ -20,7 +20,7 @@ extension ChatBskyLexicon.Conversation { public let conversationID: String /// The message text itself. - public let message: Message + public let message: MessageInputDefinition enum CodingKeys: String, CodingKey { case conversationID = "convoId" diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoSendMessageBatch.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoSendMessageBatch.swift index 7de2ba2ecd..02b6275bf9 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoSendMessageBatch.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoSendMessageBatch.swift @@ -18,6 +18,12 @@ extension ChatBskyLexicon.Conversation { /// An array of messages. public let items: [MessageBatchItem] + + public func encode(to encoder: any Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try truncatedEncode(self.items, withContainer: &container, forKey: .items, upToLength: 100) + } } /// The data model definition for the output of sending a message batch. @@ -28,7 +34,7 @@ extension ChatBskyLexicon.Conversation { public struct SendMessageBatchOutput: Codable { /// An array of message views. - public let items: [MessageView] + public let items: [MessageViewDefinition] } /// A message batch object. @@ -42,7 +48,7 @@ extension ChatBskyLexicon.Conversation { public let conversationID: String /// The message text itself. - public let message: Message + public let message: MessageInputDefinition enum CodingKeys: String, CodingKey { case conversationID = "convoId" diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoUnmuteConvo.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoUnmuteConvo.swift index c093a16bf8..a135b0d7b3 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoUnmuteConvo.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoUnmuteConvo.swift @@ -32,7 +32,7 @@ extension ChatBskyLexicon.Conversation { public struct UnmuteConversationOutput: Codable { /// The conversation itself. - public let conversationView: ConversationView + public let conversationView: ConversationViewDefinition enum CodingKeys: String, CodingKey { case conversationView = "convo" diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoUpdateRead.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoUpdateRead.swift index cda0383d05..fcda4ee1a1 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoUpdateRead.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoUpdateRead.swift @@ -36,6 +36,6 @@ extension ChatBskyLexicon.Conversation { public struct UpdateReadOutput: Codable { /// The conversation itself. - public let conversationView: ConversationView + public let conversationView: ConversationViewDefinition } } diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminDefs.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminDefs.swift new file mode 100644 index 0000000000..eea53dab52 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminDefs.swift @@ -0,0 +1,343 @@ +// +// ComAtprotoAdminDefs.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Admin { + + /// The main data model definition for admin status attributes. + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/defs.json + public struct StatusAttributesDefinition: Codable { + + /// Indicates whether the status attributes are being applied. + public let isApplied: Bool + + /// The reference of the attributes. + public let reference: String? + + enum CodingKeys: String, CodingKey { + case isApplied = "applied" + case reference = "ref" + } + } + + /// A data model for a report view definition. + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/defs.json + public struct ReportViewDefinition: Codable { + + /// The ID of the report. + public let id: Int + + /// The reason for the report. + public let reasonType: ModerationReasonType + + /// The additional comment provided for a report. Optional. + public let comment: String? + + /// The handle of the subject who's related to the report. Optional. + public let subjectRepoHandle: String? + + /// The subject reference of the report. + public let subject: ATUnion.RepositoryReferencesUnion + + /// The user who created the report. + public let reportedBy: String + + /// The date and time the report was created. + @DateFormatting public var createdAt: Date + + /// An array of action IDs that relate to resolutions. + public let resolvedByActionIDs: [Int] + + public init(id: Int, reasonType: ModerationReasonType, comment: String?, subjectRepoHandle: String?, subject: ATUnion.RepositoryReferencesUnion, reportedBy: String, createdAt: Date, + resolvedByActionIDs: [Int]) { + self.id = id + self.reasonType = reasonType + self.comment = comment + self.subjectRepoHandle = subjectRepoHandle + self.subject = subject + self.reportedBy = reportedBy + self._createdAt = DateFormatting(wrappedValue: createdAt) + self.resolvedByActionIDs = resolvedByActionIDs + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.id = try container.decode(Int.self, forKey: .id) + self.reasonType = try container.decode(ModerationReasonType.self, forKey: .reasonType) + self.comment = try container.decodeIfPresent(String.self, forKey: .comment) + self.subjectRepoHandle = try container.decodeIfPresent(String.self, forKey: .subjectRepoHandle) + self.subject = try container.decode(ATUnion.RepositoryReferencesUnion.self, forKey: .subject) + self.reportedBy = try container.decode(String.self, forKey: .reportedBy) + self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue + self.resolvedByActionIDs = try container.decode([Int].self, forKey: .resolvedByActionIDs) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.id, forKey: .id) + try container.encode(self.reasonType, forKey: .reasonType) + try container.encodeIfPresent(self.comment, forKey: .comment) + try container.encodeIfPresent(self.subjectRepoHandle, forKey: .subjectRepoHandle) + try container.encode(self.subject, forKey: .subject) + try container.encode(self.reportedBy, forKey: .reportedBy) + try container.encode(self._createdAt, forKey: .createdAt) + try container.encode(self.resolvedByActionIDs, forKey: .resolvedByActionIDs) + } + + enum CodingKeys: String, CodingKey { + case id + case reasonType + case comment + case subjectRepoHandle + case subject + case reportedBy + case createdAt + case resolvedByActionIDs = "resolvedByActionIds" + } + } + + /// A data model for a detailed report view definition. + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/defs.json + public struct ReportViewDetailDefinition: Codable { + + /// The ID of a report. + public let id: Int + + /// The reason for the report. + public let reasonType: ModerationReasonType + + /// Any additional comments about the report. Optional. + public var comment: String? + + /// The subject of the report. + /// + /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ + /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ + /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ + /// \ + /// Clarifications from Bluesky are needed in order to fully understand this item. + public let subject: ATUnion.RepositoryViewUnion + + /// The status for the subject of the report. Optional. + /// + /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ + /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ + /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ + /// \ + /// Clarifications from Bluesky are needed in order to fully understand this item. + public var subjectStatus: OzoneSubjectStatusView? + + /// The user who created the report. + public let reportedBy: String + + /// The date and time the report was created. + @DateFormatting public var createdAt: Date + + /// An array of resolved actions made in relation to the report. + public let resolvedByActions: [OzoneModerationEventView] + + public init(id: Int, reasonType: ModerationReasonType, comment: String? = nil, subject: ATUnion.RepositoryViewUnion, subjectStatus: OzoneSubjectStatusView? = nil, + reportedBy: String, createdAt: Date, resolvedByActions: [OzoneModerationEventView]) { + self.id = id + self.reasonType = reasonType + self.comment = comment + self.subject = subject + self.subjectStatus = subjectStatus + self.reportedBy = reportedBy + self._createdAt = DateFormatting(wrappedValue: createdAt) + self.resolvedByActions = resolvedByActions + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.id = try container.decode(Int.self, forKey: .id) + self.reasonType = try container.decode(ModerationReasonType.self, forKey: .reasonType) + self.comment = try container.decodeIfPresent(String.self, forKey: .comment) + self.subject = try container.decode(ATUnion.RepositoryViewUnion.self, forKey: .subject) + self.subjectStatus = try container.decodeIfPresent(OzoneSubjectStatusView.self, forKey: .subjectStatus) + self.reportedBy = try container.decode(String.self, forKey: .reportedBy) + self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue + self.resolvedByActions = try container.decode([OzoneModerationEventView].self, forKey: .resolvedByActions) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.id, forKey: .id) + try container.encode(self.reasonType, forKey: .reasonType) + try container.encodeIfPresent(self.comment, forKey: .comment) + try container.encode(self.subject, forKey: .subject) + try container.encodeIfPresent(self.subjectStatus, forKey: .subjectStatus) + try container.encode(self.reportedBy, forKey: .reportedBy) + try container.encode(self._createdAt, forKey: .createdAt) + try container.encode(self.resolvedByActions, forKey: .resolvedByActions) + } + + enum CodingKeys: CodingKey { + case id + case reasonType + case comment + case subject + case subjectStatus + case reportedBy + case createdAt + case resolvedByActions + } + } + + /// A data model for a definition of an account view. + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/defs.json + public struct AccountViewDefinition: Codable { + + /// The decentralized identifier (DID) of the user. + public let actorDID: String + + /// The handle of the user. + public let handle: String + + /// The email of the user. Optional. + public var email: String? + + /// The user's related records. Optional. + /// + /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ + /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ + /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ + /// \ + /// Clarifications from Bluesky are needed in order to fully understand this item. + public var relatedRecords: [UnknownType]? + + /// The date and time the user was last indexed. + @DateFormatting public var indexedAt: Date + + /// The invite code used by the user to sign up. Optional. + public var invitedBy: ServerInviteCode? + + /// An array of invite codes held by the user. Optional. + public var invites: [ServerInviteCode]? + + /// Indicates whether the invite codes held by the user are diabled. Optional. + public var areInvitesDisabled: Bool? + + /// The date and time the email of the user was confirmed. Optional. + @DateFormattingOptional public var emailConfirmedAt: Date? + + /// Any notes related to inviting the user. Optional. + public var inviteNote: String? + + public init(actorDID: String, handle: String, email: String?, relatedRecords: [UnknownType]?, indexedAt: Date, invitedBy: ServerInviteCode?, + invites: [ServerInviteCode]?, areInvitesDisabled: Bool?, emailConfirmedAt: Date? = nil, inviteNote: String?) { + self.actorDID = actorDID + self.handle = handle + self.email = email + self.relatedRecords = relatedRecords + self._indexedAt = DateFormatting(wrappedValue: indexedAt) + self.invitedBy = invitedBy + self.invites = invites + self.areInvitesDisabled = areInvitesDisabled + self._emailConfirmedAt = DateFormattingOptional(wrappedValue: emailConfirmedAt) + self.inviteNote = inviteNote + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.actorDID = try container.decode(String.self, forKey: .actorDID) + self.handle = try container.decode(String.self, forKey: .handle) + self.email = try container.decodeIfPresent(String.self, forKey: .email) + self.relatedRecords = try container.decodeIfPresent([UnknownType].self, forKey: .relatedRecords) + self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue + self.invitedBy = try container.decodeIfPresent(ServerInviteCode.self, forKey: .invitedBy) + self.invites = try container.decodeIfPresent([ServerInviteCode].self, forKey: .invites) + self.areInvitesDisabled = try container.decodeIfPresent(Bool.self, forKey: .areInvitesDisabled) + self.emailConfirmedAt = try container.decodeIfPresent(DateFormattingOptional.self, forKey: .emailConfirmedAt)?.wrappedValue + self.inviteNote = try container.decodeIfPresent(String.self, forKey: .inviteNote) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.actorDID, forKey: .actorDID) + try container.encode(self.handle, forKey: .handle) + try container.encodeIfPresent(self.email, forKey: .email) + try container.encodeIfPresent(self.relatedRecords, forKey: .relatedRecords) + try container.encode(self._indexedAt, forKey: .indexedAt) + try container.encodeIfPresent(self.invitedBy, forKey: .invitedBy) + try container.encodeIfPresent(self.invites, forKey: .invites) + try container.encodeIfPresent(self.areInvitesDisabled, forKey: .areInvitesDisabled) + try container.encode(self._emailConfirmedAt, forKey: .emailConfirmedAt) + try container.encodeIfPresent(self.inviteNote, forKey: .inviteNote) + } + + enum CodingKeys: String, CodingKey { + case actorDID = "did" + case handle + case email + case relatedRecords + case indexedAt + case invitedBy + case invites + case areInvitesDisabled = "invitesDisabled" + case emailConfirmedAt + case inviteNote + } + } + + /// A data model for a definition of a repository reference. + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/defs.json + public struct RepositoryReferenceDefinition: Codable { + + /// The decentralized identifier (DID) of the repository. + public let repositoryDID: String + + enum CodingKeys: String, CodingKey { + case repositoryDID = "did" + } + } + + /// A data model for a blob reference definition. + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/defs.json + public struct RepositoryBlobReferenceDefinition: Codable { + + /// The decentralized identifier (DID) of the blob reference. + public let blobDID: String + + /// The CID hash of the blob reference. + public let cidHash: String + + /// The URI of the record that contains the blob reference. + public let recordURI: String? + + enum CodingKeys: String, CodingKey { + case blobDID = "did" + case cidHash = "cid" + case recordURI = "recordUri" + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminDeleteAccount.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminDeleteAccount.swift new file mode 100644 index 0000000000..770752730b --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminDeleteAccount.swift @@ -0,0 +1,25 @@ +// +// ComAtprotoAdminDeleteAccount.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Admin { + + /// The main data model definition for deleting a user's account as an administrator. + /// + /// - Note: According to the AT Protocol specifications: "Delete a user account as + /// an administrator." + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.deleteAccount`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/deleteAccount.json + public struct DeleteAccount: Codable { + + /// The decentralized identifier (DID) of the account to be deleted. + public let accountDID: String + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminDisableAccountInvites.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminDisableAccountInvites.swift new file mode 100644 index 0000000000..290fe5295a --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminDisableAccountInvites.swift @@ -0,0 +1,37 @@ +// +// ComAtprotoAdminDisableAccountInvites.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Admin { + + /// The main data model definition for disabling a user account's ability to receive new + /// invite codes. + /// + /// - Note: According to the AT Protocol specifications: "Disable an account from receiving new + /// invite codes, but does not invalidate existing codes." + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.disableAccountInvites`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/disableAccountInvites.json + public struct DisableAccountInvites: Codable { + + /// The decentralized identifier (DID) of the user account. + public let accountDID: String + + /// A comment explaining why the user won't receive new account invites. Optional. + /// + /// - Note: According to the AT Protocol specifications: "Optional reason for + /// disabled invites." + public let note: String? + + enum CodingKeys: String, CodingKey { + case accountDID = "account" + case note + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminDisableInviteCodes.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminDisableInviteCodes.swift new file mode 100644 index 0000000000..6eeade616f --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminDisableInviteCodes.swift @@ -0,0 +1,34 @@ +// +// ComAtprotoAdminDisableInviteCodes.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Admin { + + /// The main data model definition for disabling some or all of the invite codes for one or + /// more user accounts. + /// + /// - Note: According to the AT Protocol specifications: "Disable some set of codes and/or all + /// codes associated with a set of users." + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.disableInviteCodes`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/disableInviteCodes.json + public struct DisableInviteCodes: Codable { + + /// The invite codes to disable. + public let codes: [String] + + /// The decentralized identifiers (DIDs) of the user accounts. + public let accountDIDs: [String] + + enum CodingKeys: String, CodingKey { + case codes + case accountDIDs = "accounts" + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminEnableAccountInvites.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminEnableAccountInvites.swift new file mode 100644 index 0000000000..d3f770cc9b --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminEnableAccountInvites.swift @@ -0,0 +1,35 @@ +// +// ComAtprotoAdminEnableAccountInvites.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Admin { + + /// The main data model definition for giving the user account access to receive invite + /// codes again. + /// + /// - Note: According to the AT Protocol specifications: "Re-enable an account's ability to + /// receive invite codes." + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.enableAccountInvites`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/enableAccountInvites.json + public struct EnableAccountInvitesRequestBody: Codable { + + /// The decentralized identifier (DID) of the account that will regain access to receiving + /// invite codes. + public let accountDID: String + + /// A note as to why this action is being done. Optional. + public let note: String? + + enum CodingKeys: String, CodingKey { + case accountDID = "account" + case note + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminGetAccountInfos.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminGetAccountInfos.swift new file mode 100644 index 0000000000..f779574fbf --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminGetAccountInfos.swift @@ -0,0 +1,24 @@ +// +// ComAtprotoAdminGetAccountInfos.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Admin { + + /// A data model definition for the output of retrieving an array of user accounts. + /// + /// - Note: According to the AT Protocol specifications: "Get details about some accounts." + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.getAccountInfos`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/getAccountInfos.json + public struct GetAccountInfosOutput: Codable { + + /// An array of user account information. + public let infos: [AdminAccountView] + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminGetInviteCodes.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminGetInviteCodes.swift new file mode 100644 index 0000000000..a640ce0bbd --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminGetInviteCodes.swift @@ -0,0 +1,37 @@ +// +// ComAtprotoAdminGetInviteCodes.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Admin { + + /// A data model definition for the output of getting the invite codes from a user account. + /// + /// - Note: According to the AT Protocol specifications: "Get an admin view of invite codes." + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.getInviteCodes`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/getInviteCodes.json + public struct GetInviteCodesOutput: Codable { + + /// The mark used to indicate the starting point for the next set of results. Optional. + public let cursor: String? + + /// An array of invite codes. + public let codes: [ServerInviteCode] + } + + /// Sorts the invite codes by a particular order. + public enum GetInviteCodesSort { + + /// Sorts the invite codes by the most recently made. + case recent + + /// Sorts the invite codes by the number of times it's been used. + case usage + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminGetSubjectStatus.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminGetSubjectStatus.swift new file mode 100644 index 0000000000..dbe7c0856b --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminGetSubjectStatus.swift @@ -0,0 +1,28 @@ +// +// ComAtprotoAdminGetSubjectStatus.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Admin { + + /// A data model definition for the output of getting the status of a subject as an administrator. + /// + /// - Note: According to the AT Protocol specifications: "Get the service-specific admin status of + /// a subject (account, record, or blob)." + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.getSubjectStatus`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/getSubjectStatus.json + public struct GetSubjectStatusOutput: Codable { + + /// The subject itself. + public let subject: ATUnion.AdminGetSubjectStatusUnion + + /// The attributes of the takedown event. + public let takedown: AdminStatusAttributes + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminQueryModerationStatuses.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminQueryModerationStatuses.swift new file mode 100644 index 0000000000..7fe5569b47 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminQueryModerationStatuses.swift @@ -0,0 +1,49 @@ +// +// ComAtprotoAdminQueryModerationStatuses.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Admin { + + /// A data model definition for the output of listing all of moderation statuses of records + /// and repositories. + /// + /// - Note: According to the AT Protocol specifications: "View moderation statuses of + /// subjects (record or repo)." + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.queryModerationStatuses`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/queryModerationStatuses.json + public struct QueryModerationStatusesOutput: Codable { + + /// The mark used to indicate the starting point for the next set of results. Optional. + public let cursor: String + + /// An array of subject statuses. + public let subjectStatuses: [OzoneSubjectStatusView] + } + + /// Indicates the sorting field for the moderation status array. + public enum AdminQueryModerationStatusesSortField { + + /// Indicates the moderation status array will be sorted by the last reported user. + case lastReportedAt + + /// Indicates the moderation status array will be sorted by the last reviwed user. + case lastReviewedAt + } + + /// Indicates the sorting direction for the array of moderation statuses. + public enum QueryModerationStatusesSortDirection: String { + + /// Indicates the moderation events will be sorted in ascending order. + case ascending = "asc" + + /// Indicates the moderation events will be sorted in descending order. + case descending = "desc" + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminSearchRepos.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminSearchRepos.swift new file mode 100644 index 0000000000..db344c74e6 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminSearchRepos.swift @@ -0,0 +1,28 @@ +// +// ComAtprotoAdminSearchRepos.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Admin { + + /// The main data model definition for the output of searching repositories. + /// + /// - Note: According to the AT Protocol specifications: "Find repositories based on a + /// search term." + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.searchRepos`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/searchRepos.json + public struct AdminSearchReposOutput: Codable { + + /// The mark used to indicate the starting point for the next set of results. Optional. + public let cursor: String? + + /// An array of repositories. + public let repos: OzoneModerationRepositoryView + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminSendEmail.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminSendEmail.swift new file mode 100644 index 0000000000..652b10e60e --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminSendEmail.swift @@ -0,0 +1,63 @@ +// +// ComAtprotoAdminSendEmail.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Admin { + + /// The main data model definition for sending an email to a user. + /// + /// - Note: According to the AT Protocol specifications: "Send email to a user's account + /// email address." + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.sendEmail`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/sendEmail.json + public struct SendEmailRequestBody: Codable { + + /// The decentralized identifier (DID) of the recipient. + public let recipientDID: String + + /// The content of the email. + public let content: String + + /// The subject line of the email. Optional. + public let subject: String? + + /// The decentralized identifier (DID) of the sender. + public let senderDID: String + + /// Any additional comments viewable to other moderators and administrators. + public let comment: String? + + enum CodingKeys: String, CodingKey { + case recipientDID = "recipientDid" + case content + case subject + case senderDID = "senderDid" + case comment + } + } + + /// A data model definition for the output of sending an email to a user. + /// + /// - Note: According to the AT Protocol specifications: "Send email to a user's account + /// email address." + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.sendEmail`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/sendEmail.json + public struct SendEmailOutput: Codable { + + /// Indicates whether the email has been sent. + public let isSent: Bool + + enum CodingKeys: String, CodingKey { + case isSent = "sent" + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminUpdateAccountEmail.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminUpdateAccountEmail.swift new file mode 100644 index 0000000000..8f942d5dc1 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminUpdateAccountEmail.swift @@ -0,0 +1,32 @@ +// +// ComAtprotoAdminUpdateAccountEmail.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Admin { + + /// The main data model definition for updating the email address of a user account as + /// an administrator. + /// + /// - Note: According to the AT Protocol specifications: "Administrative action to update an + /// account's email." + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.updateAccountEmail`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/updateAccountEmail.json + public struct AdminUpdateAccountEmailRequestBody: Codable { + /// The decentralized identifier (DID) of the account. + public let accountDID: String + /// The new email account the user wants to change to. + public let accountEmail: String + + enum CodingKeys: String, CodingKey { + case accountDID = "account" + case accountEmail = "email" + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminUpdateAccountHandle.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminUpdateAccountHandle.swift new file mode 100644 index 0000000000..a168b45197 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminUpdateAccountHandle.swift @@ -0,0 +1,34 @@ +// +// ComAtprotoAdminUpdateAccountHandle.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Admin { + + /// The main data model definition for updating the handle of a user account as + /// an administrator. + /// + /// - Note: According to the AT Protocol specifications: "Administrative action to update + /// an account's handle." + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.updateAccountHandle`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/updateAccountHandle.json + public struct UpdateAccountHandleRequestBody: Codable { + + /// The decentralized identifier (DID) of the account. + public let accountDID: String + + /// The new account handle the user wants to change to. + public let accountHandle: String + + enum CodingKeys: String, CodingKey { + case accountDID = "did" + case accountHandle = "handle" + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminUpdateAccountPassword.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminUpdateAccountPassword.swift new file mode 100644 index 0000000000..bcc5b33fab --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminUpdateAccountPassword.swift @@ -0,0 +1,34 @@ +// +// ComAtprotoAdminUpdateAccountPassword.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Admin { + + /// The main data model definition for updating the handle of a user account as + /// an administrator. + /// + /// - Note: According to the AT Protocol specifications: "Update the password for a + /// user account as an administrator." + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.updateAccountPassword`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/updateAccountPassword.json + public struct UpdateAccountPasswordRequestBody: Codable { + + /// The decentralized identifier (DID) of the account. + public let accountDID: String + + /// The new password for the user account. + public let newPassword: String + + enum CodingKeys: String, CodingKey { + case accountDID = "did" + case newPassword = "password" + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminUpdateSubjectStatus.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminUpdateSubjectStatus.swift new file mode 100644 index 0000000000..0da1fd1d7b --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminUpdateSubjectStatus.swift @@ -0,0 +1,47 @@ +// +// ComAtprotoAdminUpdateSubjectStatus.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Admin { + + /// The main data model definition for updating a subject status of an account, record, + /// or blob. + /// + /// - Note: According to the AT Protocol specifications: "Update the service-specific + /// admin status of a subject (account, record, or blob)." + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.updateSubjectStatus`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/updateSubjectStatus.json + public struct AdminUpdateSubjectStatus: Codable { + + /// The subject associated with the subject status. + public let subject: AdminGetSubjectStatusUnion + + /// The status attributes of the subject. Optional. + public let takedown: AdminStatusAttributes? + } + + /// A data model definition for the output of updating a subject status of an account, record, + /// or blob. + /// + /// - Note: According to the AT Protocol specifications: "Update the service-specific admin + /// status of a subject (account, record, or blob)." + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.updateSubjectStatus`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/updateSubjectStatus.json + public struct AdminUpdateSubjectStatusOutput: Codable { + + /// The subject associated with the subject status. + public let subject: AdminGetSubjectStatusUnion + + /// The status attributes of the subject. Optional. + public let takedown: AdminStatusAttributes? + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentityGetRecommendedDidCredentials.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentityGetRecommendedDidCredentials.swift new file mode 100644 index 0000000000..4d97773c67 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentityGetRecommendedDidCredentials.swift @@ -0,0 +1,34 @@ +// +// ComAtprotoIdentityGetRecommendedDidCredentials.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Identity { + + /// The main data model definition for the output of getting the required information of a + /// Personal Data Server's (PDS) DID document for migration. + /// + /// - Note: According to the AT Protocol specifications: "Describe the credentials that should + /// be included in the DID doc of an account that is migrating to this service." + /// + /// - SeeAlso: This is based on the [`com.atproto.identity.getRecommendedDidCredentials`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/identity/getRecommendedDidCredentials.json + public struct GetRecommendedDidCredentialsOutput: Codable { + /// The rotation keys recommended to be added in the DID document. Optional. + /// + /// - Note: According to the AT Protocol specifications: "Recommended rotation keys for PLC + /// dids. Should be undefined (or ignored) for did:webs." + public let rotationKeys: [String]? + /// An array of aliases of the user account. Optional. + public let alsoKnownAs: [String]? + /// A verification method recommeneded to be added in the DID document. Optional. + public let verificationMethods: VerificationMethod? + /// The service endpoint recommended in the DID document. Optional. + public let service: ATService? + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentityRequestPlcOperationSignature.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentityRequestPlcOperationSignature.swift new file mode 100644 index 0000000000..1155f4a776 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentityRequestPlcOperationSignature.swift @@ -0,0 +1,21 @@ +// +// ComAtprotoIdentityRequestPlcOperationSignature.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Identity { + + /// The request body data model definition for requesting a signed PLC operation. + /// + /// - Note: According to the AT Protocol specifications: "Request an email with a code to in + /// order to request a signed PLC operation. Requires Auth." + /// + /// - SeeAlso: This is based on the [`com.atproto.identity.requestPlcOperationSignature`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/identity/requestPlcOperationSignature.json + public struct RequestPlcOperationSignatureRequestBody: Codable {} +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentityResolveHandle.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentityResolveHandle.swift new file mode 100644 index 0000000000..0f6445de3f --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentityResolveHandle.swift @@ -0,0 +1,22 @@ +// +// ComAtprotoIdentityResolveHandle.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Identity { + + /// A data model that represents the output of resolving handles. + /// + /// - SeeAlso: This is based on the [`com.atproto.identity.resolveHandle`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/identity/resolveHandle.json + public struct ResolveHandleOutput: Decodable { + + /// The resolved handle's decentralized identifier (DID). + public let handleDID: String + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentitySignPLCOperation.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentitySignPLCOperation.swift new file mode 100644 index 0000000000..b82fac302e --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentitySignPLCOperation.swift @@ -0,0 +1,55 @@ +// +// ComAtprotoIdentitySignPLCOperation.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Identity { + + /// The main data model definition for signing a PLC operation to a DID document. + /// + /// - Note: According to the AT Protocol specifications: "Signs a PLC operation to update some + /// value(s) in the requesting DID's document." + /// + /// - SeeAlso: This is based on the [`com.atproto.identity.signPlcOperation`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/identity/signPlcOperation.json + public struct SignPLCOperationRequestBody: Codable { + + /// A token received from + /// ``ATProtoKit/ATProtoKit/requestPLCOperationSignature()``. Optional. + /// + /// - Note: According to the AT Protocol specifications: "A token received + /// through com.atproto.identity.requestPlcOperationSignature" + public let token: String? + + /// The rotation keys recommended to be added in the DID document. Optional. + public let rotationKeys: [String]? + + /// An array of aliases of the user account. Optional. + public let alsoKnownAs: [String]? + + /// A verification method recommeneded to be added in the DID document. Optional. + public let verificationMethods: VerificationMethod? + + /// The service endpoint recommended in the DID document. Optional. + public let service: ATService? + } + + /// The main data model definition for the output of signing a PLC operation to a DID document. + /// + /// - Note: According to the AT Protocol specifications: "Signs a PLC operation to update some + /// value(s) in the requesting DID's document." + /// + /// - SeeAlso: This is based on the [`com.atproto.identity.signPlcOperation`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/identity/signPlcOperation.json + public struct SignPLCOperationOutput: Codable { + + /// The operation itself. + public let operation: UnknownType + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentitySubmitPLCOperation.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentitySubmitPLCOperation.swift new file mode 100644 index 0000000000..7fdc8f2c89 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentitySubmitPLCOperation.swift @@ -0,0 +1,26 @@ +// +// ComAtprotoIdentitySubmitPLCOperation.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Identity { + + /// The main data model definition for the output of validating a PLC operation. + /// + /// - Note: According to the AT Protocol specifications: "Validates a PLC operation to ensure + /// that it doesn't violate a service's constraints or get the identity into a bad state, then + /// submits it to the PLC registry." + /// + /// - SeeAlso: This is based on the [`com.atproto.identity.submitPlcOperation`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/identity/submitPlcOperation.json + public struct SubmitPLCOperationOutput: Codable { + + /// The operation itself. + public let operation: UnknownType + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentityUpdateHandle.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentityUpdateHandle.swift new file mode 100644 index 0000000000..15f83edc46 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentityUpdateHandle.swift @@ -0,0 +1,28 @@ +// +// ComAtprotoIdentityUpdateHandle.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Identity { + + /// The main data model definition for updating a handle. + /// + /// - Note: According to the AT Protocol specifications: "Updates the current account's handle. + /// Verifies handle validity, and updates did:plc document if necessary. Implemented by PDS, + /// and requires auth." + /// + /// - SeeAlso: This is based on the [`com.atproto.identity.updateHandle`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/identity/updateHandle.json + public struct UpdateHandleQuery: Encodable { + + /// The handle the user would like to change to. + /// + /// - Note: According to the AT Protocol specifications: "The new handle." + public let handle: String + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Label/ComAtprotoLabelDefs.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Label/ComAtprotoLabelDefs.swift new file mode 100644 index 0000000000..aac65fa4dc --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Label/ComAtprotoLabelDefs.swift @@ -0,0 +1,423 @@ +// +// ComAtprotoLabelDefs.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Label { + + /// The main data model definition for a label. + /// + /// - Note: According to the AT Protocol specifications: "Metadata tag on an atproto resource + /// (eg, repo or record)." + /// + /// - SeeAlso: This is based on the [`com.atproto.label.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/label/defs.json + public struct LabelDefinition: Codable { + + /// The version number of the label. Optional. + /// + /// - Note: According to the AT Protocol specifications: "The AT Protocol version of the + /// label object." + public let version: Int? + + /// The decentralized identifier (DID) of the label creator. + /// + /// - Note: According to the AT Protocol specifications: "DID of the actor who created + /// this label." + public let actorDID: String + + /// The URI of the resource the label applies to. + /// + /// - Note: According to the AT Protocol specifications: "AT URI of the record, repository + /// (account), or other resource that this label applies to." + public let atURI: String + + /// The CID hash of the resource the label applies to. Optional. + /// + /// - Note: According to the AT Protocol specifications: "Optionally, CID specifying the + /// specific version of 'uri' resource this label applies to." + public let cidHash: String? + + /// The name of the label. + /// + /// - Note: According to the AT Protocol specifications: "The short string name of the + /// value or type of this label." + /// + /// - Important: Current maximum length is 128 characters. This library will automatically + /// truncate the `String` to the maximum length if it does go over the limit. + public var name: String + + /// Indicates whether this label is negating a previously-used label. Optional. + /// + /// - Note: According to the AT Protocol specifications: "If true, this is a negation label, + /// overwriting a previous label." + public let isNegated: Bool? + + /// The date and time the label was created. + /// + /// - Note: According to the AT Protocol specifications: "Timestamp when this label + /// was created." + @DateFormatting public var timestamp: Date + + /// The date and time the label expires on. + /// + /// - Note: According to the AT Protocol specifications: "Timestamp at which this label + /// expires (no longer applies)." + @DateFormattingOptional public var expiresOn: Date? + + /// The DAG-CBOR-encoded signature. Optional. + /// + /// - Note: According to the AT Protocol specifications: "Signature of dag-cbor + /// encoded label." + public let signature: Data? + + public init(version: Int?, actorDID: String, atURI: String, cidHash: String?, name: String, isNegated: Bool?, timestamp: Date, + expiresOn: Date?, signature: Data) { + self.version = version + self.actorDID = actorDID + self.atURI = atURI + self.cidHash = cidHash + self.name = name + self.isNegated = isNegated + self._timestamp = DateFormatting(wrappedValue: timestamp) + self._expiresOn = DateFormattingOptional(wrappedValue: expiresOn) + self.signature = signature + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.version = try container.decodeIfPresent(Int.self, forKey: .version) + self.actorDID = try container.decode(String.self, forKey: .actorDID) + self.atURI = try container.decode(String.self, forKey: .atURI) + self.cidHash = try container.decodeIfPresent(String.self, forKey: .cidHash) + self.name = try container.decode(String.self, forKey: .name) + self.isNegated = try container.decodeIfPresent(Bool.self, forKey: .isNegated) + self.timestamp = try container.decode(DateFormatting.self, forKey: .timestamp).wrappedValue + self.expiresOn = try container.decodeIfPresent(DateFormattingOptional.self, forKey: .expiresOn)?.wrappedValue + self.signature = try container.decodeIfPresent(Data.self, forKey: .signature) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encodeIfPresent(self.version, forKey: .version) + try container.encode(self.actorDID, forKey: .actorDID) + try container.encode(self.atURI, forKey: .atURI) + try container.encodeIfPresent(self.cidHash, forKey: .cidHash) + + // Truncate `name` to 128 characters before encoding + try truncatedEncode(self.name, withContainer: &container, forKey: .name, upToLength: 128) + + try container.encodeIfPresent(self.isNegated, forKey: .isNegated) + try container.encode(self._timestamp, forKey: .timestamp) + try container.encodeIfPresent(self._expiresOn, forKey: .expiresOn) + try container.encodeIfPresent(self.signature, forKey: .signature) + } + + enum CodingKeys: String, CodingKey { + case version = "ver" + case actorDID = "src" + case atURI = "uri" + case cidHash = "cid" + case name = "val" + case isNegated = "neg" + case timestamp = "cts" + case expiresOn = "exp" + case signature = "sig" + } + } + + /// A data model for a definition for an array of self-defined labels. + /// + /// - SeeAlso: This is based on the [`com.atproto.label.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/label/defs.json + public struct SelfLabelsDefinition: Codable { + + /// An array of self-defined tags on a record. + /// + /// - Note: According to the AT Protocol specifications: "Metadata tags on an atproto + /// record, published by the author within the record." + /// + /// - Important: Current maximum length is 10 tags. This library will automatically + /// truncate the `Array` to the maximum length if it does go over the limit. + /// + /// - SeeAlso: This is based on the [`com.atproto.label.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/label/defs.json + public let values: [SelfLabel] + + public init(values: [SelfLabel]) { + self.values = values + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.values = try container.decode([SelfLabel].self, forKey: .values) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + // Truncate `values` to 10 items before encoding + try truncatedEncode(self.values, withContainer: &container, forKey: .values, upToLength: 10) + } + + enum CodingKeys: CodingKey { + case values + } + } + + /// A data model for a definition for a user-defined label. + /// + /// - Note: According to the AT Protocol specifications: "Metadata tag on an atproto record, + /// published by the author within the record. Note that schemas should use #selfLabels, + /// not #selfLabel.", + /// + /// - SeeAlso: This is based on the [`com.atproto.label.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/label/defs.json + public struct SelfLabelDefinition: Codable { + + /// A user-defined label. + /// + /// - Note: According to the AT Protocol specifications: "The short string name of the + /// value or type of this label." + /// + /// - Important: Current maximum length is 128 characters. This library will automatically + /// truncate the `String` to the maximum length if it does go over the limit. + public let value: String + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + // Truncate `value` to 128 characters before encoding + try truncatedEncode(self.value, withContainer: &container, forKey: .value, upToLength: 128) + } + + enum CodingKeys: String, CodingKey { + case value = "val" + } + } + + /// A data model definition for labeler-created labels. + /// + /// - Note: According to the AT Protocol specifications: "Declares a label value and its expected + /// interpertations and behaviors." + /// + /// - SeeAlso: This is based on the [`com.atproto.label.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/label/defs.json + public struct LabelValueDefinition: Codable { + + /// The value of the label. + /// + /// - Important: This field can only contain lowercased letter and the hypen (-) character. + /// This library will automatically convert uppercased letters to lowercased, as well as any + /// hashes other than the hypen into a hypen. All additional characters will be removed. + /// + /// - Note: According to the AT Protocol specifications: "The value of the label + /// being defined. Must only include lowercase ascii and the '-' character ([a-z-]+)." + public let identifier: String + + /// The visual indicator of the label that indicates the severity. + /// + /// - Note: According to the AT Protocol specifications: "How should a client visually + /// convey this label? 'inform' means neutral and informational; 'alert' means negative + /// and warning; 'none' means show nothing." + public let severity: Severity + + /// Indicates how much of the content should be hidden for the user. + /// + /// - Note: According to the AT Protocol specifications: "What should this label hide in + /// the UI, if applied? 'content' hides all of the target; 'media' hides the + /// images/video/audio; 'none' hides nothing." + public let blurs: Blurs + + /// The default setting for the label. + /// + /// - Note: According to the AT Protocol specifications: "The default setting for + /// this label." + public let defaultSetting: DefaultSetting = .warn + + /// Indicates whether the "Adult Content" preference needs to be enabled in order to use + /// this label. Optional. + /// + /// - Note: According to the AT Protocol specifications: "Does the user need to have adult + /// content enabled in order to configure this label?" + public let isAdultOnly: Bool? + + /// An array of localized strings for the label. Optional. + public let locales: [LabelValueDefinitionStrings] + + public func encode(to encoder: any Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + // Ensure `value` is lowercased and only has the standard hyphen (-). + // Then, truncate `value` to 100 characters before encoding. + try truncatedEncode(self.identifier.transformToLowerASCIIAndHyphen(), withContainer: &container, forKey: .identifier, upToLength: 100) + try container.encode(self.severity, forKey: .severity) + try container.encode(self.blurs, forKey: .blurs) + try container.encode(self.defaultSetting, forKey: .defaultSetting) + try container.encodeIfPresent(self.isAdultOnly, forKey: .isAdultOnly) + try container.encode(self.locales, forKey: .locales) + } + + enum CodingKeys: CodingKey { + case identifier + case severity + case blurs + case defaultSetting + case isAdultOnly + case locales + } + + // Enums + /// The visual indicator of the label that indicates the severity. + public enum Severity: String, Codable { + + /// Indicates the labeler should only inform the user of the content. + case inform + + /// Indicates the labeler should alert the user of the content. + case alert + + /// Indicates the labeler should do nothing. + case none + } + + /// Indicates how much of the content should be hidden for the user. + public enum Blurs: String, Codable { + + /// Indicates the labeler should hide the entire content from the user. + case content + + /// Indicates the labeler should hide only the media of the content, but keeps the + /// text intact. + case media + + /// Indicates the labeler should hide nothing. + case none + } + + /// The default setting for the label. + public enum DefaultSetting: String, Codable { + + /// Indicates the user will ignore the label. + case ignore + + /// Indicates the user will be warned. + case warn + + /// Indicates the user will hide the label. + case hide + } + } + + /// A data model definition for a localized description of a label. + /// + /// - Note: According to the AT Protocol specifications: "Strings which describe the label in + /// the UI, localized into a specific language." + /// + /// - SeeAlso: This is based on the [`com.atproto.label.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/label/defs.json + public struct LabelValueDefinitionStringsDefinition: Codable { + + /// The language code of the label's definition. + /// + /// - Note: According to the AT Protocol specifications: "The code of the language these + /// strings are written in." + public let language: Locale + + /// The localized name of the label. + /// + /// - Note: According to the AT Protocol specifications: "A short human-readable name for + /// the label." + public let name: String + + /// The localized description of the label. + /// + /// - Note: According to the AT Protocol specifications: "A longer description of what the + /// label means and why it might be applied." + public let description: String + + public init(from decoder: any Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.language = try container.decode(Locale.self, forKey: .language) + self.name = try container.decode(String.self, forKey: .name) + self.description = try container.decode(String.self, forKey: .description) + } + + public func encode(to encoder: any Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.language, forKey: .language) + // Truncate `name` to 640 characters before encoding. + try truncatedEncode(self.name, withContainer: &container, forKey: .name, upToLength: 640) + + try truncatedEncode(self.description, withContainer: &container, forKey: .description, upToLength: 100_000) + } + + enum CodingKeys: String, CodingKey { + case language = "lang" + case name + case description + } + } + + /// An enumuation that defines the value of a label. + /// + /// - Note: According to the AT Protocol specifications: "Strings which describe the label + /// in the UI, localized into a specific language." + /// + /// - SeeAlso: This is based on the [`com.atproto.label.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/label/defs.json + public enum LabelValue: String, Codable { + + /// Marked as hidden. + case hide = "!hide" + + /// Marked as no promotion. + case noPromote = "!no-promote" + + /// Marked as a warning. + case warn = "!warn" + + /// Marked as no authentication. + /// + /// This would be used for user accounts that requests clients to not show their + /// content for logged-out users. + case noUnauthenticated = "!no-unauthenticated" + + /// Marked as a DMCA violation. + case dmcaViolation = "dmca-violation" + + /// Marked as doxxing. + case doxxing + + /// Marked as porn. + case porn + + /// Marked as sexual content. + case sexual + + /// Marked as nudity. + case nudity + + /// Marked as Not Safe For Life (NSFL). + case nsfl + + /// Marked as gory. + case gore + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Label/ComAtprotoLabelQueryLabels.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Label/ComAtprotoLabelQueryLabels.swift new file mode 100644 index 0000000000..f2588353c2 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Label/ComAtprotoLabelQueryLabels.swift @@ -0,0 +1,27 @@ +// +// ComAtprotoLabelQueryLabels.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Label { + + /// The main data model definition for the output of finding relevant labels based on a + /// given URI. + /// + /// - Note: According to the AT Protocol specifications: "Find labels relevant to the provided + /// AT-URI patterns. Public endpoint for moderation services, though may return different or + /// additional results with auth." + /// + /// - SeeAlso: This is based on the [`com.atproto.label.queryLabels`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/label/queryLabels.json + public struct QueryLabelsOutput: Codable { + + /// An array of labels. + public let labels: [Label] + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Moderation/ComAtprotoModerationCreateReport.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Moderation/ComAtprotoModerationCreateReport.swift new file mode 100644 index 0000000000..74aae6b3bd --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Moderation/ComAtprotoModerationCreateReport.swift @@ -0,0 +1,119 @@ +// +// ComAtprotoModerationCreateReport.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Moderation { + + /// The main data model definition for creating a report. + /// + /// - Note: According to the AT Protocol specifications: "Submit a moderation report regarding + /// an atproto account or record. Implemented by moderation services (with PDS proxying), and + /// requires auth." + /// + /// - SeeAlso: This is based on the [`com.atproto.moderation.createReport`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/moderation/createReport.json + public struct CreateReportRequestBody: Codable { + + /// The reason for the report. + /// + /// - Note: According to the AT Protocol specifications: "Indicates the broad category of + /// violation the report is for." + public let reasonType: ModerationReasonType + + /// Any clarifying comments accompanying the report. Optional. + /// + /// - Note: According to the AT Protocol specifications: "Additional context about the + /// content and violation." + public let reason: String? + + /// The subject reference. + /// + /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ + /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ + /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ + /// \ + /// Clarifications from Bluesky are needed in order to fully understand this item. + public let subject: RepositoryReferencesUnion + } + + /// A data model definition for the output of creating a report. + /// + /// - SeeAlso: This is based on the [`com.atproto.moderation.createReport`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/moderation/createReport.json + public struct CreateReportOutput: Codable { + + /// The ID of the report. + public let id: Int + + /// The reason for the report. + public let reasonType: ModerationReasonType + + /// The reason for the report. Optional. + public let reason: String? + + /// The subject reference. + /// + /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ + /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ + /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ + /// \ + /// Clarifications from Bluesky are needed in order to fully understand this item. + public let subject: RepositoryReferencesUnion + + /// The decentralized identifier (DID) of the user who created the report. + public let reportedBy: String + + /// The date and time the report was created. + @DateFormatting public var createdAt: Date + + public init(id: Int, reasonType: ModerationReasonType, reason: String?, subject: RepositoryReferencesUnion, reportedBy: String, createdAt: Date) { + self.id = id + self.reasonType = reasonType + self.reason = reason + self.subject = subject + self.reportedBy = reportedBy + self._createdAt = DateFormatting(wrappedValue: createdAt) + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.id = try container.decode(Int.self, forKey: .id) + self.reasonType = try container.decode(ModerationReasonType.self, forKey: .reasonType) + self.reason = try container.decodeIfPresent(String.self, forKey: .reason) + self.subject = try container.decode(RepositoryReferencesUnion.self, forKey: .subject) + self.reportedBy = try container.decode(String.self, forKey: .reportedBy) + self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.id, forKey: .id) + try container.encode(self.reasonType, forKey: .reasonType) + + // Truncate `reason` to 20,000 characters before encoding + // `maxGraphemes`'s limit is 2,000, but `String.count` should respect that limit implictly + try truncatedEncodeIfPresent(self.reason, withContainer: &container, forKey: .reason, upToLength: 20_000) + try container.encode(self.subject, forKey: .subject) + try container.encode(self.reportedBy, forKey: .reportedBy) + try container.encode(self._createdAt, forKey: .createdAt) + } + + public enum CodingKeys: CodingKey { + case id + case reasonType + case reason + case subject + case reportedBy + case createdAt + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Moderation/ComAtprotoModerationDefs.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Moderation/ComAtprotoModerationDefs.swift new file mode 100644 index 0000000000..4f1f112d2d --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Moderation/ComAtprotoModerationDefs.swift @@ -0,0 +1,67 @@ +// +// ComAtprotoModerationDefs.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Moderation { + + /// A data model for the definition of the moderator's reason for reporting. + /// + /// - SeeAlso: This is based on the [`com.atproto.moderation.defs`][github] lexicon. + /// + /// - Important: The item associated with this enum is undocumented in the AT Protocol specifications. The documentation here is based on:\ + /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ + /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ + /// \ + /// Clarifications from Bluesky are needed in order to fully understand this item. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/moderation/defs.json + public enum ReasonTypeDefinition: String, Codable { + + /// Indicates spam as the reason. + /// + /// - Note: According to the AT Protocol specifications: "Spam: frequent unwanted + /// promotion, replies, mentions." + case reasonSpam + + /// Indicates a rule violation as the reason. + /// + /// - Note: According to the AT Protocol specifications: "Direct violation of server rules, + /// laws, terms of service." + case reasonViolation + + /// Indicates misleading content as the reason. + /// + /// - Note: According to the AT Protocol specifications: "Misleading identity, + /// affiliation, or content." + case reasonMisleading + + /// Indicates mislabeled/unwanted sexual content as the reason. + /// + /// - Note: According to the AT Protocol specifications: "Unwanted or mislabeled + /// sexual content." + case reasonSexual + + /// Indicates rude behavior as the reason. + /// + /// - Note: According to the AT Protocol specifications: "Rude, harassing, explicit, or + /// otherwise unwelcoming behavior." + case reasonRude + + /// Indicates a reason not otherwise specified. + /// + /// - Note: According to the AT Protocol specifications: "Other: reports not falling under + /// another report category." + case reasonOther + + /// Indicates an appeal to a previous moderation ruling as the reason. + /// + /// - Note: According to the AT Protocol specifications: "Appeal: appeal a previously taken + /// moderation action." + case reasonAppeal + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtProtoRepoStrongRef.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtProtoRepoStrongRef.swift new file mode 100644 index 0000000000..524bf2f062 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtProtoRepoStrongRef.swift @@ -0,0 +1,44 @@ +// +// ComAtProtoRepoStrongRef.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Repository { + + /// The main data model definition for a strong reference. + /// + /// - Note: According to the AT Protocol specifications: "A URI with a + /// content-hash fingerprint." + /// + /// - SeeAlso: This is based on the [`com.atproto.repo.strongRef`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/repo/strongRef.json + public struct StrongReference: Codable { + + /// The URI for the record. + public let recordURI: String + + /// The CID hash for the record. + public let cidHash: String + + public init(recordURI: String, cidHash: String) { + self.recordURI = recordURI + self.cidHash = cidHash + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + self.recordURI = try container.decode(String.self, forKey: .recordURI) + self.cidHash = try container.decode(String.self, forKey: .cidHash) + } + + enum CodingKeys: String, CodingKey { + case recordURI = "uri" + case cidHash = "cid" + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoApplyWrites.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoApplyWrites.swift new file mode 100644 index 0000000000..3a2be39f3d --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoApplyWrites.swift @@ -0,0 +1,128 @@ +// +// ComAtprotoRepoApplyWrites.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Repository { + + /// The main data model definition for applying batch CRUD transactions. + /// + /// - Note: According to the AT Protocol specifications: "Apply a batch transaction of + /// repository creates, updates, and deletes. Requires auth, implemented by PDS." + /// + /// - SeeAlso: This is based on the [`com.atproto.repo.applyWrites`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/repo/applyWrites.json + public struct ApplyWritesRequestBody: Codable { + + /// The decentralized identifier (DID) or handle of the repository. + /// + /// - Note: According to the AT Protocol specifications: "The handle or DID of the repo + /// (aka, current account)." + public let repositoryDID: String + + /// Indicates whether the operation should be validated. Optional. Defaults to `true`. + /// + /// - Note: According to the AT Protocol specifications: "Can be set to 'false' to skip + /// Lexicon schema validation of record data, for all operations." + public let shouldValidate: Bool? + + /// The write operation itself. + public let writes: [ApplyWritesUnion]? + + /// Swaps out an operation based on the CID. Optional. + /// + /// - Important: If a value is entered in here, the entire operation will fail if there is + /// no matching value in the repository. + /// + /// - Note: According to the AT Protocol specifications: "If provided, the entire operation + /// will fail if the current repo commit CID does not match this value. Used to prevent + /// conflicting repo mutations." + public let swapCommit: String? + + enum CodingKeys: String, CodingKey { + case repositoryDID = "repo" + case shouldValidate = "validate" + case writes + case swapCommit + } + } + + /// A data model definition for a "Create" write operation. + /// + /// - Note: According to the AT Protocol specifications: "Operation which creates a + /// new record." + /// + /// - SeeAlso: This is based on the [`com.atproto.repo.applyWrites`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/repo/applyWrites.json + public struct ApplyWritesCreate: Codable { + + /// The NSID of the collection. + public let collection: String + + /// The record key of the write operation. Optional. + public let recordKey: String? + + /// The value of the write operation. + public let value: UnknownType + + enum CodingKeys: String, CodingKey { + case collection + case recordKey = "rkey" + case value + } + } + + /// A data model definition for an "Update" write operation. + /// + /// - Note: According to the AT Protocol specifications: "Operation which updates an + /// existing record." + /// + /// - SeeAlso: This is based on the [`com.atproto.repo.applyWrites`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/repo/applyWrites.json + public struct ApplyWritesUpdate: Codable { + + /// The NSID of the collection. + public let collection: String + + /// The record key of the write operation. + public let recordKey: String + + /// The value of the write operation. + public let value: UnknownType + + enum CodingKeys: String, CodingKey { + case collection + case recordKey = "rkey" + case value + } + } + + /// A data model definition for a "Delete" write operation. + /// + /// - Note: According to the AT Protocol specifications: "Operation which deletes an + /// existing record." + /// + /// - SeeAlso: This is based on the [`com.atproto.repo.applyWrites`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/repo/applyWrites.json + public struct ApplyWritesDelete: Codable { + + /// The NSID of the collection. + public let collection: String + + /// The record key of the write operation. + public let recordKey: String + + enum CodingKeys: String, CodingKey { + case collection + case recordKey = "rkey" + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoCreateRecord.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoCreateRecord.swift new file mode 100644 index 0000000000..ed0efc82ed --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoCreateRecord.swift @@ -0,0 +1,76 @@ +// +// ComAtprotoRepoCreateRecord.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Repository { + + /// The main data model definition for creating a record. + /// + /// - Note: According to the AT Protocol specifications: "Create a single new repository record + /// Requires auth, implemented by PDS." + /// + /// - SeeAlso: This is based on the [`com.atproto.repo.createRecord`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/repo/createRecord.json + public struct CreateRecordRequestBody: Codable { + + /// The decentralized identifier (DID) or handle of the user account. + /// + /// - Note: According to the AT Protocol specifications: "The handle or DID of the repo + /// (aka, current account)." + public let repositoryDID: String + + /// The NSID of the record. + /// + /// - Note: According to the AT Protocol specifications: "The NSID of the record collection." + public let collection: String + + /// The record key of the collection. Optional. + /// + /// - Important: Current maximum length is 15 characters. This library will automatically + /// truncate the `String` to the maximum length if it does go over the limit. + /// + /// - Note: According to the AT Protocol specifications: "The Record Key." + public let recordKey: String? + + /// Indicates whether the record should be validated. Optional. Defaults to `true`. + public let shouldValidate: Bool? + + /// The record itself. + public let record: UnknownType + + /// Swaps out an operation based on the CID. Optional. + /// + /// - Important: If a value is entered in here, the entire operation will fail if there is no + /// matching value in the repository. + /// + /// - Note: According to the AT Protocol specifications: "Compare and swap with the previous + /// commit by CID." + public let swapCommit: String? + + public func encode(to encoder: any Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.repositoryDID, forKey: .repositoryDID) + try container.encode(self.collection, forKey: .collection) + try truncatedEncodeIfPresent(self.recordKey, withContainer: &container, forKey: .recordKey, upToLength: 15) + try container.encodeIfPresent(self.shouldValidate, forKey: .shouldValidate) + try container.encode(self.record, forKey: .record) + try container.encodeIfPresent(self.swapCommit, forKey: .swapCommit) + } + + enum CodingKeys: String, CodingKey { + case repositoryDID = "repo" + case collection + case recordKey = "rkey" + case shouldValidate = "validate" + case record + case swapCommit + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoDeleteRecord.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoDeleteRecord.swift new file mode 100644 index 0000000000..7376fdd436 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoDeleteRecord.swift @@ -0,0 +1,61 @@ +// +// ComAtprotoRepoDeleteRecord.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Repository { + + /// The main data model definition for deleting a record. + /// + /// - Note: According to the AT Protocol specifications: "Delete a repository record, or ensure + /// it doesn't exist. Requires auth, implemented by PDS." + /// + /// - SeeAlso: This is based on the [`com.atproto.repo.deleteRecord`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/repo/deleteRecord.json + public struct DeleteRecordRequestBody: Codable { + + /// The decentralized identifier (DID) or handle of the user account. + /// + /// - Note: According to the AT Protocol specifications: "The handle or DID of the repo + /// (aka, current account)." + public let repositoryDID: String + + /// The NSID of the record. + /// + /// - Note: According to the AT Protocol specifications: "The NSID of the + /// record collection." + public let collection: String + + /// The record key of the record. + /// + /// - Note: According to the AT Protocol specifications: "The Record Key." + public let recordKey: String + + /// Swap the record on the server with this current record based on the CID of the record + /// on the server. + /// + /// - Note: According to the AT Protocol specifications: "Compare and swap with the + /// previous record by CID." + public let swapRecord: String? + + /// Swap the commit on the server with this current commit based on the CID of the commit + /// on the server. + /// + /// - Note: According to the AT Protocol specifications: "Compare and swap with the + /// previous commit by CID." + public let swapCommit: String? + + enum CodingKeys: String, CodingKey { + case repositoryDID = "repo" + case collection + case recordKey = "rkey" + case swapRecord + case swapCommit + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoDescribeRepo.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoDescribeRepo.swift new file mode 100644 index 0000000000..8d6f4f3acd --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoDescribeRepo.swift @@ -0,0 +1,54 @@ +// +// ComAtprotoRepoDescribeRepo.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Repository { + + /// The main data model definition for the output of describing the repository. + /// + /// - Note: According to the AT Protocol specifications: "Get information about an account + /// and repository, including the list of collections. Does not require auth." + /// + /// - SeeAlso: This is based on the [`com.atproto.repo.describeRepo`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/repo/describeRepo.json + public struct DescribeRepositoryOutput: Codable { + + /// The handle of the repository. + public let repositoryHandle: String + + /// The decentralized identitifer (DID) of the repository. + public let repositoryDID: String + + /// The DID Document of the repository. + /// + /// - Note: According to the AT Protocol specifications: "The complete DID document for + /// this account." + public let didDocument: DIDDocument + + /// An array of collections related to the repository. + /// + /// - Note: According to the AT Protocol specifications: "List of all the collections + /// (NSIDs) for which this repo contains at least one record." + public let collections: [String] + + /// Indicates whether the repository's handle is valid. + /// + /// - Note: According to the AT Protocol specifications: "Indicates if handle is currently + /// valid (resolves bi-directionally)." + public let isHandleCorrect: Bool + + enum CodingKeys: String, CodingKey { + case repositoryHandle = "handle" + case repositoryDID = "did" + case didDocument = "didDoc" + case collections + case isHandleCorrect = "handleIsCorrect" + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoGetRecord.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoGetRecord.swift new file mode 100644 index 0000000000..ddc1cbdd52 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoGetRecord.swift @@ -0,0 +1,46 @@ +// +// ComAtprotoRepoGetRecord.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Repository { + + /// The main data model definition for the outpot of a record. + /// + /// - SeeAlso: This is based on the [`com.atproto.repo.getRecord`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/repo/getRecord.json + public struct RecordOutput: Codable { + + /// The URI of the record. + public let recordURI: String + + /// The CID hash for the record. + public let recordCID: String + + /// The value for the record. + public let value: RecordValueReply? + + enum CodingKeys: String, CodingKey { + case recordURI = "uri" + case recordCID = "cid" + case value = "value" + } + } + + // MARK: - + /// The main data model definition for the outpot . + /// + /// - SeeAlso: This is based on the [`com.atproto.repo.getRecord`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/repo/getRecord.json + public struct RecordValueReply: Codable { + + /// The reply reference of the record. + public let reply: ReplyReference? + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoImportRepo.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoImportRepo.swift new file mode 100644 index 0000000000..527e4eee5f --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoImportRepo.swift @@ -0,0 +1,25 @@ +// +// ComAtprotoRepoImportRepo.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Repository { + + /// The main data model definition for importing a CAR file. + /// + /// - Note: According to the AT Protocol specifications: "Import a repo in the form of a + /// CAR file. Requires Content-Length HTTP header to be set." + /// + /// - SeeAlso: This is based on the [`com.atproto.repo.importRepo`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/repo/importRepo.json + public struct ImportRepositoryRequestBody: Codable { + + /// The repository data in the form of a CAR file. + public let repository: Data + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoListMissingBlobs.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoListMissingBlobs.swift new file mode 100644 index 0000000000..3fd6cd62f8 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoListMissingBlobs.swift @@ -0,0 +1,36 @@ +// +// ComAtprotoRepoListMissingBlobs.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Repository { + + /// The main data model definition for the output of listing any missing blobs attached to the + /// user account. + /// + /// - Note: According to the AT Protocol specifications: "Returns a list of missing blobs for + /// the requesting account. Intended to be used in the account migration flow." + /// + /// - SeeAlso: This is based on the [`com.atproto.repo.listMissingBlobs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/repo/listMissingBlobs.json + public struct ListMissingBlobsOutput: Codable { + + /// An array of blobs. + public let blobs: [RecordBlob] + } + + /// A data model definition for a record blob. + public struct RecordBlob: Codable { + + /// The CID hash of the record. + public let recordCID: String + + /// The URI of the record. + public let recordURI: String + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoListRecords.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoListRecords.swift new file mode 100644 index 0000000000..28c36bc3cd --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoListRecords.swift @@ -0,0 +1,28 @@ +// +// ComAtprotoRepoListRecords.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Repository { + + /// The main data model definition for the output of listing records. + /// + /// - Note: According to the AT Protocol specifications: "List a range of records in a + /// repository, matching a specific collection. Does not require auth." + /// + /// - SeeAlso: This is based on the [`com.atproto.repo.listRecords`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/repo/listRecords.json + public struct ListRecordsOutput: Codable { + + /// The mark used to indicate the starting point for the next set of result. Optional. + public let cursor: String? + + /// An array of records. + public let records: [RecordOutput] + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoPutRecord.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoPutRecord.swift new file mode 100644 index 0000000000..d0efac8ead --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoPutRecord.swift @@ -0,0 +1,75 @@ +// +// ComAtprotoRepoPutRecord.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Repository { + + /// The main data model definition for creating a record that replaces a previous record. + /// + /// - Note: According to the AT Protocol specifications: "Write a repository record, creating + /// or updating it as needed. Requires auth, implemented by PDS." + /// + /// - SeeAlso: This is based on the [`com.atproto.repo.putRecord`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/repo/putRecord.json + public struct PutRecordRequestBody: Codable { + + /// The decentralized identifier (DID) or handle of the repository. + /// + /// - Note: According to the AT Protocol specifications: "The handle or DID of the repo + /// (aka, current account)." + public let repositoryDID: String + + /// The NSID of the record. + /// + /// - Note: According to the AT Protocol specifications: "The NSID of the + /// record collection." + public let collection: String + + /// The record key of the collection. + /// + /// - Note: According to the AT Protocol specifications: "The Record Key." + public let recordKey: String + + /// Indicates whether the record should be validated. Optional. + /// + /// - Note: According to the AT Protocol specifications: "Can be set to 'false' to skip + /// Lexicon schema validation of record data." + public let shouldValidate: Bool? + + /// The record itself. + /// + /// - Note: According to the AT Protocol specifications: "The record to write." + public let record: UnknownType + + /// Swaps the record in the server with the record contained in here. Optional. + /// + /// - Important: This field can be left blank. + /// + /// - Note: According to the AT Protocol specifications: "Compare and swap with the + /// previous record by CID. WARNING: nullable and optional field; may cause problems + /// with golang implementation" + public let swapRecord: String? + + /// Swaps the commit in the server with the commit contained in here. Optional. + /// + /// - Note: According to the AT Protocol specifications: "Compare and swap with the + /// previous commit by CID." + public let swapCommit: String? + + enum CodingKeys: String, CodingKey { + case repositoryDID = "repo" + case collection + case recordKey = "rkey" + case shouldValidate = "validate" + case record + case swapRecord + case swapCommit + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoUploadBlob.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoUploadBlob.swift new file mode 100644 index 0000000000..4357694b76 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoUploadBlob.swift @@ -0,0 +1,88 @@ +// +// ComAtprotoRepoUploadBlob.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Repository { + + /// The main data model definition for the image's query. + public struct ImageQuery: Encodable { + /// The data of the image. + public let imageData: Data + /// The file name of the image. + public let fileName: String + /// The alt text of the image, + public let altText: String? + + public init(imageData: Data, fileName: String, altText: String?) { + self.imageData = imageData + self.fileName = fileName + self.altText = altText + } + } + + /// The request body data model definition for uploading a blob. + /// + /// - Note: According to the AT Protocol specifications: "Upload a new blob, to be referenced + /// from a repository record. The blob will be deleted if it is not referenced within a time + /// window (eg, minutes). Blob restrictions (mimetype, size, etc) are enforced when the + /// reference is created. Requires auth, implemented by PDS." + /// + /// - SeeAlso: This is based on the [`com.atproto.repo.uploadBlob`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/repo/uploadBlob.json + public struct UploadBlobRequestBody: Codable {} + + // MARK: - + // TODO: Find a way to remove BlobContainer without breaking the JSON encoding. + // This will be here until a way to remove this without the issues of + // the JSON encoding are solved. + /// The container used for storing blobs within a record. + /// + /// - Note: This is a temporary measure and will be deleted once a better solution is made. + public struct BlobContainer: Codable { + + /// The blob itself. + public let blob: UploadBlobOutput + } + + /// A data model for a definition of an output of uploading a blob. + public struct UploadBlobOutput: Codable { + + /// The type of blob. + public let type: String? + + /// The strong reference of the blob. + public let reference: BlobReference + + /// The the MIME type. + /// + /// This can be a `.jpg`, `.png`, and `.gif` + public let mimeType: String + + /// The size of the blob. + public let size: Int + + enum CodingKeys: String, CodingKey { + case type = "$type" + case reference = "ref" + case mimeType + case size + } + } + + /// A data model for a blob reference definition. + public struct BlobReference: Codable { + + /// The link of the blob reference. + public let link: String + + enum CodingKeys: String, CodingKey { + case link = "$link" + } + } +} From 3fdc79e4d19c481d258efcc872b14c5a81ac30bd Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Mon, 20 May 2024 17:02:14 -0400 Subject: [PATCH 13/51] Change lexicon layout and fix issues - The following lexicons have been changed: - com.atproto.server.* - com.atproto.sync.* - com.atproto.temp.* --- .../com.atproto/ComAtprotoLexicon.swift | 3 + .../ComAtprotoServerActivateAccount.swift | 22 ++++ .../ComAtprotoServerCheckAccountStatus.swift | 78 +++++++++++++ .../Server/ComAtprotoServerConfirmEmail.swift | 27 +++++ .../ComAtprotoServerCreateAccount.swift | 94 +++++++++++++++ .../ComAtprotoServerCreateAppPassword.swift | 77 ++++++++++++ .../ComAtprotoServerCreateInviteCode.swift | 44 +++++++ .../ComAtprotoServerCreateInviteCodes.swift | 68 +++++++++++ .../ComAtprotoServerCreateSession.swift | 33 ++++++ .../ComAtprotoServerDeactivateAccount.swift | 49 ++++++++ .../Server/ComAtprotoServerDefs.swift | 110 ++++++++++++++++++ .../ComAtprotoServerDeleteAccount.swift | 37 ++++++ .../ComAtprotoServerDescribeServer.swift | 96 +++++++++++++++ ...omAtprotoServerGetAccountInviteCodes.swift | 22 ++++ .../ComAtprotoServerGetServiceAuth.swift | 25 ++++ .../ComAtprotoServerListAppPasswords.swift | 62 ++++++++++ .../ComAtprotoServerRequestEmailUpdate.swift | 29 +++++ ...ComAtprotoServerRequestPasswordReset.swift | 25 ++++ .../ComAtprotoServerReserveSigningKey.swift | 45 +++++++ .../ComAtprotoServerResetPassword.swift | 32 +++++ .../ComAtprotoServerRevokeAppPassword.swift | 28 +++++ .../Server/ComAtprotoServerUpdateEmail.swift | 39 +++++++ .../Sync/ComAtprotoSyncGetBlob.swift | 22 ++++ .../Sync/ComAtprotoSyncGetBlocks.swift | 22 ++++ .../Sync/ComAtprotoSyncGetLatestCommit.swift | 33 ++++++ .../Sync/ComAtprotoSyncListBlobs.swift | 33 ++++++ .../Sync/ComAtprotoSyncListRepos.swift | 56 +++++++++ .../Sync/ComAtprotoSyncSubscribeRepos.swift | 26 +++++ .../Temp/ComAtprotoTempCheckSignupQueue.swift | 43 +++++++ ...mAtprotoTempRequestPhoneVerification.swift | 28 +++++ 30 files changed, 1308 insertions(+) create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerActivateAccount.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCheckAccountStatus.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerConfirmEmail.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCreateAccount.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCreateAppPassword.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCreateInviteCode.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCreateInviteCodes.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCreateSession.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerDeactivateAccount.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerDefs.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerDeleteAccount.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerDescribeServer.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerGetAccountInviteCodes.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerGetServiceAuth.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerListAppPasswords.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerRequestEmailUpdate.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerRequestPasswordReset.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerReserveSigningKey.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerResetPassword.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerRevokeAppPassword.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerUpdateEmail.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncGetBlob.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncGetBlocks.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncGetLatestCommit.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncListBlobs.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncListRepos.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncSubscribeRepos.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Temp/ComAtprotoTempCheckSignupQueue.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Temp/ComAtprotoTempRequestPhoneVerification.swift diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/ComAtprotoLexicon.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/ComAtprotoLexicon.swift index 13a0466518..0562b70379 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/ComAtprotoLexicon.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/ComAtprotoLexicon.swift @@ -27,6 +27,9 @@ extension ComAtprotoLexicon { /// A group of lexicons within the `com.atproto.server` namespace. public struct Server {} + /// A group of lexicons within the `com.atproto.sync` namespace. + public struct Sync {} + /// A group of lexicons within the `com.atproto.temp` namespace. public struct Temp {} } diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerActivateAccount.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerActivateAccount.swift new file mode 100644 index 0000000000..bf10a9d874 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerActivateAccount.swift @@ -0,0 +1,22 @@ +// +// ComAtprotoServerActivateAccount.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Server { + + /// The request body data model definition for activating an account. + /// + /// - Note: According to the AT Protocol specifications: "Activates a currently deactivated + /// account. Used to finalize account migration after the account's repo is imported and + /// identity is setup." + /// + /// - SeeAlso: This is based on the [`com.atproto.server.activateAccount`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/activateAccount.json + public struct ActivateAccountRequestBody: Codable {} +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCheckAccountStatus.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCheckAccountStatus.swift new file mode 100644 index 0000000000..c62d18d950 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCheckAccountStatus.swift @@ -0,0 +1,78 @@ +// +// ComAtprotoServerCheckAccountStatus.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Server { + + /// A data model definition for the output of checking the user's account status. + /// + /// - Note: According to the AT Protocol specifications: "Returns the status of an account, + /// especially as pertaining to import or recovery. Can be called many times over the course + /// of an account migration. Requires auth and can only be called pertaining to oneself." + /// + /// - SeeAlso: This is based on the [`com.atproto.server.checkAccountStatus`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/checkAccountStatus.json + public struct CheckAccountStatusOutput: Codable { + + /// Indicates whether the user's account has been activated. + public let isActivated: Bool + + /// Indicates whether the user's account has a valid decentralized identifier (DID). + public let isValidDID: Bool + + /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ + /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ + /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ + /// \ + /// Clarifications from Bluesky are needed in order to fully understand this item. + public let repositoryCommit: String + + /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ + /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ + /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ + /// \ + /// Clarifications from Bluesky are needed in order to fully understand this item. + public let repositoryRev: String + + /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ + /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ + /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ + /// \ + /// Clarifications from Bluesky are needed in order to fully understand this item. + public let repositoryBlocks: Int + + /// The number of indexed records in the user's account. + public let indexedRecords: Int + + /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ + /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ + /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ + /// \ + /// Clarifications from Bluesky are needed in order to fully understand this item. + public let privateStateValues: Int + + /// The expected number of blobs in the user's account. + public let expectedBlobs: Int + + /// The number of blobs imported into the user's account. + public let importedBlobs: Int + + enum CodingKeys: String, CodingKey { + case isActivated = "activated" + case isValidDID = "validDid" + case repositoryCommit = "repoCommit" + case repositoryRev = "repoRev" + case repositoryBlocks = "repoBlocks" + case indexedRecords + case privateStateValues + case expectedBlobs + case importedBlobs + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerConfirmEmail.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerConfirmEmail.swift new file mode 100644 index 0000000000..7b495369b4 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerConfirmEmail.swift @@ -0,0 +1,27 @@ +// +// ComAtprotoServerConfirmEmail.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Server { + + /// The main data model of a definition for confirming emails. + /// + /// - Note: According to the AT Protocol specifications: "Confirm an email using a token from com.atproto.server.requestEmailConfirmation." + /// + /// - SeeAlso: This is based on the [`com.atproto.server.confirmEmail`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/confirmEmail.json + public struct ConfirmEmailRequestBody: Codable { + + /// The email of the user. + public let email: String + + /// The token given to the user via email. + public let token: String + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCreateAccount.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCreateAccount.swift new file mode 100644 index 0000000000..ad72e52c53 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCreateAccount.swift @@ -0,0 +1,94 @@ +// +// ComAtprotoServerCreateAccount.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Server { + + /// The main data model definition for creating an account. + /// + /// - Note: According to the AT Protocol specifications: "Create an account. Implemented + /// by PDS." + /// + /// - SeeAlso: This is based on the [`com.atproto.server.createAccount`][github] lexicon. + /// + /// [github]: https://docs.bsky.app/docs/api/com-atproto-server-create-account + public struct CreateAccountRequestBody: Codable { + + /// The email of the user. Optional. + public var email: String? + + /// The handle the user wishes to use. + /// + /// - Note: According to the AT Protocol specifications: "Requested handle for + /// the account." + public let handle: String + + /// A decentralized identifier (DID) that has existed before and will be used to be + /// imported to the new account. Optional. + /// + /// - Note: According to the AT Protocol specifications: "Pre-existing atproto DID, being + /// imported to a new account." + public var existingDID: String? + + /// The invite code for the user. Optional. + /// + /// - Note: Invite codes are no longer used in Bluesky. This is left here for legacy + /// purposes, as well as for any federated networks that may use this feature. + public var inviteCode: String? + + /// A verification code. + public var verificationCode: String? + + /// A code that has come from a text message in the user's phone. Optional. + public var verificationPhone: String? + + /// The password the user will use for the account. Optional. + /// + /// - Note: According to the AT Protocol specifications: "Initial account password. + /// May need to meet instance-specific password strength requirements." + public var password: String? + + /// DID PLC rotation key (aka, recovery key) to be included in PLC + /// creation operation. Optional. + /// + /// - Note: The above documentation is taken directly from the AT Protocol apecifications. + public var recoveryKey: String? + + /// A signed DID PLC operation to be submitted as part of importing an existing account + /// to this instance. NOTE: this optional field may be updated when full account migration + /// is implemented. Optional. + /// + /// - Note: The above documentation is taken directly from the AT Protocol apecifications. + public var plcOp: UnknownType? + + public init(email: String?, handle: String, existingDID: String?, inviteCode: String?, verificationCode: String?, verificationPhone: String?, + password: String?, recoveryKey: String?, plcOp: UnknownType?) { + self.email = email + self.handle = handle + self.existingDID = existingDID + self.inviteCode = inviteCode + self.verificationCode = verificationCode + self.verificationPhone = verificationCode + self.password = password + self.recoveryKey = recoveryKey + self.plcOp = plcOp + } + + enum CodingKeys: String, CodingKey { + case email + case handle + case existingDID = "did" + case inviteCode + case verificationCode + case verificationPhone + case password + case recoveryKey + case plcOp + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCreateAppPassword.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCreateAppPassword.swift new file mode 100644 index 0000000000..fd985ea1b2 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCreateAppPassword.swift @@ -0,0 +1,77 @@ +// +// ComAtprotoServerCreateAppPassword.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Server { + + /// The request body data model definition for creating an App Password. + /// + /// - Note: According to the AT Protocol specifications: "Create an App Password." + /// + /// - SeeAlso: This is based on the [`com.atproto.server.createAppPassword`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/createAppPassword.json + public struct CreateAppPasswordRequestBody: Codable { + + /// The name given to the App Password to help distingush it from others. + /// + /// - Note: According to the AT Protocol specifications: "A short name for the + /// App Password, to help distinguish them." + public let name: String + } + + /// A data model definition for creating an App Password. + /// + /// - Note: According to the AT Protocol specifications: "Create an App Password." + /// + /// - SeeAlso: This is based on the [`com.atproto.server.createAppPassword`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/createAppPassword.json + public struct CreateAppPasswordOutput: Codable { + + /// The name given to the App Password to help distingush it from others. + /// + /// - Note: According to the AT Protocol specifications: "A short name for the + /// App Password, to help distinguish them." + public let name: String + + /// The password itself. + public let password: String + + /// The date and time the App Password was created. + @DateFormatting public var createdAt: Date + + public init(name: String, password: String, createdAt: Date) { + self.name = name + self.password = password + self._createdAt = DateFormatting(wrappedValue: createdAt) + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.name = try container.decode(String.self, forKey: .name) + self.password = try container.decode(String.self, forKey: .password) + self.createdAt = try container.decode(DateFormatting.self.self, forKey: .createdAt).wrappedValue + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.name, forKey: .name) + try container.encode(self.password, forKey: .password) + try container.encode(self._createdAt, forKey: .createdAt) + } + + enum CodingKeys: CodingKey { + case name + case password + case createdAt + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCreateInviteCode.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCreateInviteCode.swift new file mode 100644 index 0000000000..af1a470a15 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCreateInviteCode.swift @@ -0,0 +1,44 @@ +// +// ComAtprotoServerCreateInviteCode.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Server { + + /// The main data model definition for creating an invite code. + /// + /// - Note: According to the AT Protocol specifications: "Create invite code." + /// + /// - SeeAlso: This is based on the [`com.atproto.server.createInviteCode`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/createInviteCode.json + public struct CreateInviteCodeRequestBody: Codable { + + /// The number of times the invite code(s) can be used. + public let useCount: Int + + /// The decentralized identifier (DIDs) of the user that can use the invite code. Optional. + /// + /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ + /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ + /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ + /// \ + /// Clarifications from Bluesky are needed in order to fully understand this item. + public let forAccount: [String]? + } + + /// A data model definition of the output for creating an invite code. + /// + /// - SeeAlso: This is based on the [`com.atproto.server.createInviteCode`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/createInviteCode.json + public struct CreateInviteCodeOutput: Codable { + + /// An array of invite codes. + public let code: [String] + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCreateInviteCodes.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCreateInviteCodes.swift new file mode 100644 index 0000000000..aadb855d4a --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCreateInviteCodes.swift @@ -0,0 +1,68 @@ +// +// ComAtprotoServerCreateInviteCodes.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Server { + + /// The main data model definition for creating invite codes. + /// + /// - Note: According to the AT Protocol specifications: "Create invite codes." + /// + /// - SeeAlso: This is based on the [`com.atproto.server.createInviteCodes`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/createInviteCodes.json + public struct CreateInviteCodes: Codable { + + /// The number of invite codes to create. Defaults to 1. + public var codeCount: Int = 1 + + /// The number of times the invite code(s) can be used. + public let useCount: Int + + /// An array of decentralized identifiers (DIDs) that can use the invite codes. Optional. + /// + /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ + /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ + /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ + /// \ + /// Clarifications from Bluesky are needed in order to fully understand this item. + public let forAccounts: [String]? + } + + /// A data model definition of the output for creating invite codes. + /// + /// - SeeAlso: This is based on the [`com.atproto.server.createInviteCodes`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/createInviteCodes.json + public struct CreateInviteCodesOutput: Codable { + + /// An array of invite codes. + public let codes: [ServerAccountCodes] + } + + /// A data model definition of the server invite codes generated from + /// ``ServerCreateInviteCodes``. + /// + /// - SeeAlso: This is based on the [`com.atproto.server.createInviteCodes`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/createInviteCodes.json + public struct ServerAccountCodes: Codable { + + /// The account that holds the invite codes. + /// + /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ + /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ + /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ + /// \ + /// Clarifications from Bluesky are needed in order to fully understand this item. + public let account: String + + /// An array of invite codes. + public let codes: [String] + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCreateSession.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCreateSession.swift new file mode 100644 index 0000000000..3ed327b33d --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCreateSession.swift @@ -0,0 +1,33 @@ +// +// ComAtprotoServerCreateSession.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Server { + + /// The main data model definition for creating a session. + /// + /// - Note: According to the AT Protocol specifications: "Create an authentication session." + /// + /// - SeeAlso: This is based on the [`com.atproto.server.createSession`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/createSession.json + public struct CredentialsRequestBody: Encodable { + + /// The indentifier of the user's account (typically a handle). + /// + /// - Note: According to the AT Protocol specifications: "Handle or other identifier + /// supported by the server for the authenticating user." + let identifier: String + + /// The App Password of the user's account. + let password: String + + /// A token used for Two-Factor Authentication. Optional. + let authenticationFactorToken: String? + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerDeactivateAccount.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerDeactivateAccount.swift new file mode 100644 index 0000000000..82ea47f6ec --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerDeactivateAccount.swift @@ -0,0 +1,49 @@ +// +// ComAtprotoServerDeactivateAccount.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Server { + + /// The main data model definition for deactivating an account. + /// + /// - Note: According to the AT Protocol specifications: "Deactivates a currently + /// active account. Stops serving of repo, and future writes to repo until reactivated. + /// Used to finalize account migration with the old host after the account has been + /// activated on the new host." + /// + /// - SeeAlso: This is based on the [`com.atproto.server.deactivateAccount`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/deactivateAccount.json + public struct DeactivateAccount: Codable { + /// The date and time of when the server should delete the account. + /// + /// - Note: According to the AT Protocol specifications: "A recommendation to server as + /// to how long they should hold onto the deactivated account before deleting." + @DateFormatting public var deleteAfter: Date + + public init(deleteAfter: Date) { + self._deleteAfter = DateFormatting(wrappedValue: deleteAfter) + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.deleteAfter = try container.decode(DateFormatting.self, forKey: .deleteAfter).wrappedValue + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.deleteAfter, forKey: .deleteAfter) + } + + enum CodingKeys: CodingKey { + case deleteAfter + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerDefs.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerDefs.swift new file mode 100644 index 0000000000..67c2a21171 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerDefs.swift @@ -0,0 +1,110 @@ +// +// ComAtprotoServerDefs.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Server { + + /// The main data model definition for a server invite code. + /// + /// - SeeAlso: This is based on the [`com.atproto.server.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/defs.json + public struct InviteCodeDefinition: Codable { + + /// The actual invite code. + public let code: String + + /// The number of codes available. + public let available: Int + + /// Indicates whether the invite code is disabled. + public let isDisabled: Bool + + /// The user who holds the invite codes. + public let forAccount: String + + /// The name of the user who currently holds the account. + public let createdBy: String + + /// The date and time the invite codes were created. + @DateFormatting public var createdAt: Date + + /// An array of the invite code uses. + public let uses: [ServerInviteCodeUse] + + public init(code: String, available: Int, isDisabled: Bool, forAccount: String, createdBy: String, createdAt: Date, uses: [ServerInviteCodeUse]) { + self.code = code + self.available = available + self.isDisabled = isDisabled + self.forAccount = forAccount + self.createdBy = createdBy + self._createdAt = DateFormatting(wrappedValue: createdAt) + self.uses = uses + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.code = try container.decode(String.self, forKey: .code) + self.available = try container.decode(Int.self, forKey: .available) + self.isDisabled = try container.decode(Bool.self, forKey: .isDisabled) + self.forAccount = try container.decode(String.self, forKey: .forAccount) + self.createdBy = try container.decode(String.self, forKey: .createdBy) + self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue + self.uses = try container.decode([ServerInviteCodeUse].self, forKey: .uses) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.code, forKey: .code) + try container.encode(self.available, forKey: .available) + try container.encode(self.isDisabled, forKey: .isDisabled) + try container.encode(self.forAccount, forKey: .forAccount) + try container.encode(self.createdBy, forKey: .createdBy) + try container.encode(self._createdAt, forKey: .createdAt) + try container.encode(self.uses, forKey: .uses) + } + + enum CodingKeys: String, CodingKey { + case code + case available + case isDisabled = "disabled" + case forAccount + case createdBy + case createdAt + case uses + } + } + + /// A data model for a definition for the invite code's use. + /// + /// - SeeAlso: This is based on the [`com.atproto.server.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/defs.json + public struct InviteCodeUseDefinition: Codable { + + /// Who used the invite code. + public let usedBy: String + + /// The date and time the service code was used. + @DateFormatting public var usedAt: Date + + public init(usedBy: String, usedAt: Date) { + self.usedBy = usedBy + self._usedAt = DateFormatting(wrappedValue: usedAt) + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.usedBy = try container.decode(String.self, forKey: .usedBy) + self.usedAt = try container.decode(DateFormatting.self, forKey: .usedAt).wrappedValue + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerDeleteAccount.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerDeleteAccount.swift new file mode 100644 index 0000000000..b6e3419cff --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerDeleteAccount.swift @@ -0,0 +1,37 @@ +// +// ComAtprotoServerDeleteAccount.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Server { + + /// The main data model definition for deleting an account. + /// + /// - Note: According to the AT Protocol specifications: "Delete an actor's account with a + /// token and password. Can only be called after requesting a deletion token. Requires auth." + /// + /// - SeeAlso: This is based on the [`com.atproto.server.deleteAccount`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/deleteAccount.json + public struct DeleteAccountRequestBody: Codable { + + /// The decentralized identifier (DID) of the account. + public let accountDID: String + + /// The main password of the account. + /// + /// - Note: This is not the App Password. + public let accountPassword: String + + /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ + /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ + /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ + /// \ + /// Clarifications from Bluesky are needed in order to fully understand this item. + public let token: String + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerDescribeServer.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerDescribeServer.swift new file mode 100644 index 0000000000..ee9bfd6436 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerDescribeServer.swift @@ -0,0 +1,96 @@ +// +// ComAtprotoServerDescribeServer.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Server { + + /// A data model definition for the output of retrieving a description of the server. + /// + /// - Note: According to the AT Protocol specifications: "Describes the server's account + /// creation requirements and capabilities. Implemented by PDS." + /// + /// - SeeAlso: This is based on the [`com.atproto.server.describeServer`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/describeServer.json + public struct DescribeServerOutput: Codable { + + /// Indicates whether an invite code is required to join the server. Optional. + /// + /// - Note: According to the AT Protocol specifications: "If true, an invite code must + /// be supplied to create an account on this instance." + public let isInviteCodeRequired: Bool? + + /// Indicates whether the user is required to verify using a phone number. Optional. + /// + /// - Note: According to the AT Protocol specifications: "If true, a phone verification + /// token must be supplied to create an account on this instance." + public let isPhoneVerificationRequired: Bool? + + /// An array of available user domains. + /// + /// - Note: According to the AT Protocol specifications: "List of domain suffixes that + /// can be used in account handles." + public let availableUserDomains: [String] + + /// A group of URLs for the server's service policies. Optional. + /// + /// - Note: According to the AT Protocol specifications: "URLs of service + /// policy documents." + public let servicePolicyURLs: ServicePolicyURLs + + /// The contact information for the server. + /// + /// - Note: According to the AT Protocol specifications: "Contact information." + public let contactInformation: ContactInformation + + /// The decentralized identifier (DID) of the server. + public let serverDID: String + + enum CodingKeys: String, CodingKey { + case isInviteCodeRequired = "inviteCodeRequired" + case isPhoneVerificationRequired = "phoneVerificationRequired" + case availableUserDomains + case servicePolicyURLs = "links" + case contactInformation = "contact" + case serverDID = "did" + } + } + + /// A data model definition of service policy URLs. + /// + /// - Note: According to the AT Protocol specifications: "Describes the server's account + /// creation requirements and capabilities. Implemented by PDS." + /// + /// - SeeAlso: This is based on the [`com.atproto.server.describeServer`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/describeServer.json + public struct ServicePolicyURLs: Codable { + + /// The URL for the server's Privacy Policy. Optional. + public let privacyPolicyURL: URL? + + /// The URL for the server's Terms of Service. Optional. + public let termsOfServiceURL: URL? + + enum CodingKeys: String, CodingKey { + case privacyPolicyURL = "privacyPolicy" + case termsOfServiceURL = "termsOfService" + } + } + + /// A data model definition of the server's contact information. + /// + /// - SeeAlso: This is based on the [`com.atproto.server.describeServer`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/describeServer.json + public struct ContactInformation: Codable { + + /// The email address users can use to contact the server owner. + public let email: String + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerGetAccountInviteCodes.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerGetAccountInviteCodes.swift new file mode 100644 index 0000000000..1ff71f5a5d --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerGetAccountInviteCodes.swift @@ -0,0 +1,22 @@ +// +// ComAtprotoServerGetAccountInviteCodes.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Server { + + /// A data model definition for the output of getting the invite codes of the user's account. + /// + /// - SeeAlso: This is based on the [`com.atproto.server.getAccountInviteCodes`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/getAccountInviteCodes.json + public struct GetAccountInviteCodesOutput: Codable { + + /// An array of the user's invite codes. + public let code: [ServerInviteCode] + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerGetServiceAuth.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerGetServiceAuth.swift new file mode 100644 index 0000000000..53edd68303 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerGetServiceAuth.swift @@ -0,0 +1,25 @@ +// +// ComAtprotoServerGetServiceAuth.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Server { + + /// A data model definition for the output of getting the signed token for the service. + /// + /// - Note: According to the AT Protocol specifications: "Get a signed token on behalf of the + /// requesting DID for the requested service." + /// + /// - SeeAlso: This is based on the [`com.atproto.server.getServiceAuth`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/getServiceAuth.json + public struct GetServiceAuthOutput: Codable { + + /// The token for the requested service. + public let token: String + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerListAppPasswords.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerListAppPasswords.swift new file mode 100644 index 0000000000..189c8e3a99 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerListAppPasswords.swift @@ -0,0 +1,62 @@ +// +// ComAtprotoServerListAppPasswords.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Server { + + /// A data model definition of the of listing App Passwords. + /// + /// - Note: According to the AT Protocol specifications: "List all App Passwords." + /// + /// - SeeAlso: This is based on the [`com.atproto.server.listAppPasswords`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/listAppPasswords.json + public struct ListAppPasswordsOutput: Codable { + + /// An array of App Passwords. + public let passwords: [AppPassword] + } + + /// A data model definition of App Password information. + /// + /// - SeeAlso: This is based on the [`com.atproto.server.listAppPasswords`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/listAppPasswords.json + public struct AppPassword: Codable { + + /// The name associated with the App Password. + public let name: String + + /// The date and date the App Password was created. + @DateFormatting public var createdAt: Date + + public init(name: String, createdAt: Date) { + self.name = name + self._createdAt = DateFormatting(wrappedValue: createdAt) + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.name = try container.decode(String.self, forKey: .name) + self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.name, forKey: .name) + try container.encode(self._createdAt, forKey: .createdAt) + } + + enum CodingKeys: CodingKey { + case name + case createdAt + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerRequestEmailUpdate.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerRequestEmailUpdate.swift new file mode 100644 index 0000000000..effc338600 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerRequestEmailUpdate.swift @@ -0,0 +1,29 @@ +// +// ComAtprotoServerRequestEmailUpdate.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Server { + + /// A data model definition for the output of requesting to update the user's email address. + /// + /// - Note: According to the AT Protocol specifications: "Request a token in order to + /// update email." + /// + /// - SeeAlso: This is based on the [`com.atproto.server.requestEmailUpdate`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/requestEmailUpdate.json + public struct RequestEmailUpdateOutput: Codable { + + /// Indicates whether a token is required. + public let isTokenRequired: Bool + + enum CodingKeys: String, CodingKey { + case isTokenRequired = "tokenRequired" + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerRequestPasswordReset.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerRequestPasswordReset.swift new file mode 100644 index 0000000000..d5954a0188 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerRequestPasswordReset.swift @@ -0,0 +1,25 @@ +// +// ComAtprotoServerRequestPasswordReset.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Server { + + /// The main data model definition for resetting the user's password. + /// + /// - Note: According to the AT Protocol specifications: "Initiate a user account password + /// reset via email." + /// + /// - SeeAlso: This is based on the [`com.atproto.server.requestPasswordReset`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/requestPasswordReset.json + public struct RequestPasswordResetRequestBody: Codable { + + /// The email address associated with the user's account. + public let email: String + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerReserveSigningKey.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerReserveSigningKey.swift new file mode 100644 index 0000000000..d4d69ca05b --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerReserveSigningKey.swift @@ -0,0 +1,45 @@ +// +// ComAtprotoServerReserveSigningKey.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Server { + + /// The main data model definition for reversing signing keys. + /// + /// - Note: According to the AT Protocol specifications: "Reserve a repo signing key, for + /// use with account creation. Necessary so that a DID PLC update operation can be constructed + /// during an account migraiton. Public and does not require auth; implemented by PDS. + /// NOTE: this endpoint may change when full account migration is implemented." + /// + /// - SeeAlso: This is based on the [`com.atproto.server.reserveSigningKey`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/reserveSigningKey.json + public struct ReserveSigningKeyRequestBody: Codable { + /// The decentralized identifier (DID) of the repository that will use the signing key. + /// + /// - Note: According to the AT Protocol specifications: "The DID to reserve a key for." + public let repositoryDID: String + + enum CodingKeys: String, CodingKey { + case repositoryDID = "did" + } + } + + /// A data model definition for the output of reversing a signing keys. + /// + /// - SeeAlso: This is based on the [`com.atproto.server.reserveSigningKey`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/reserveSigningKey.json + public struct ReserveSigningKeyOutput: Codable { + /// The signing key itself. + /// + /// - Note: According to the AT Protocol specifications: "The public key for the reserved + /// signing key, in did:key serialization." + public let signingKey: String + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerResetPassword.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerResetPassword.swift new file mode 100644 index 0000000000..a992a04761 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerResetPassword.swift @@ -0,0 +1,32 @@ +// +// ComAtprotoServerResetPassword.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Server { + + /// The main data model definition for resetting a password. + /// + /// - Note: According to the AT Protocol specifications: "Reset a user account password using a token." + /// + /// - SeeAlso: This is based on the [`com.atproto.server.resetPassword`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/resetPassword.json + public struct ResetPasswordRequestBody: Codable { + + /// The token used to reset the password. + public let token: String + + /// The new password for the user's account. + public let newPassword: String + + enum CodingKeys: String, CodingKey { + case token + case newPassword = "password" + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerRevokeAppPassword.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerRevokeAppPassword.swift new file mode 100644 index 0000000000..65b8d3de17 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerRevokeAppPassword.swift @@ -0,0 +1,28 @@ +// +// ComAtprotoServerRevokeAppPassword.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Server { + + /// The main data model definition for revoking a password. + /// + /// - Note: According to the AT Protocol specifications: "Revoke an App Password by name." + /// + /// - SeeAlso: This is based on the [`com.atproto.server.revokeAppPassword`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/revokeAppPassword.json + public struct RevokeAppPassword: Codable { + + /// The name associated with the App Password. + public let appPasswordName: String + + enum CodingKeys: String, CodingKey { + case appPasswordName = "name" + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerUpdateEmail.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerUpdateEmail.swift new file mode 100644 index 0000000000..9ba86570d7 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerUpdateEmail.swift @@ -0,0 +1,39 @@ +// +// ComAtprotoServerUpdateEmail.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Server { + + /// The request body data model definition for updating the user's email address. + /// + /// - Note: According to the AT Protocol specifications: "Update an account's email." + /// + /// - SeeAlso: This is based on the [`com.atproto.server.updateEmail`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/updateEmail.json + public struct UpdateEmailRequestBody: Codable { + + /// The email associated with the user's account. + public let email: String + + /// Indicates whether Two-Factor Authentication (via email) is enabled. Optional. + public let isEmailAuthenticationFactorEnabled: Bool? + + /// The token that's used if the email has been confirmed. Optional. + /// + /// - Note: According to the AT Protocol specifications: "Requires a token from com.atproto.sever.requestEmailUpdate if the account's email has + /// been confirmed." + public let token: String? + + enum CodingKeys: String, CodingKey { + case email + case isEmailAuthenticationFactorEnabled = "emailAuthFactor" + case token + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncGetBlob.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncGetBlob.swift new file mode 100644 index 0000000000..4e2b3b411b --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncGetBlob.swift @@ -0,0 +1,22 @@ +// +// ComAtprotoSyncGetBlob.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Sync { + + /// The main data model definition for the output of getting a blob. + /// + /// - Note: According to the AT Protocol specifications: "Get a blob associated with a + /// given account. Returns the full blob as originally uploaded. Does not require auth; + /// implemented by PDS." + /// + /// - SeeAlso: This is based on the [`com.atproto.sync.getBlob`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/sync/getBlob.json + public struct GetBlobOutput: Decodable {} +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncGetBlocks.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncGetBlocks.swift new file mode 100644 index 0000000000..af9bae8948 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncGetBlocks.swift @@ -0,0 +1,22 @@ +// +// ComAtprotoSyncGetBlocks.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Sync { + + /// The main data model definition for the output of getting a repository's blocks. + /// + /// - Note: According to the AT Protocol specifications: "Get data blocks from a given repo, by + /// CID. For example, intermediate MST nodes, or records. Does not require auth; implemented + /// by PDS." + /// + /// - SeeAlso: This is based on the [`com.atproto.sync.getBlocks`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/sync/getBlocks.json + public struct GetBlocksOutput: Codable {} +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncGetLatestCommit.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncGetLatestCommit.swift new file mode 100644 index 0000000000..3a96bb408f --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncGetLatestCommit.swift @@ -0,0 +1,33 @@ +// +// ComAtprotoSyncGetLatestCommit.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Sync { + + /// The main data model definition for the output of getting a repository's latest commit CID. + /// + /// - Note: According to the AT Protocol specifications: "Get the current commit CID & revision + /// of the specified repo. Does not require auth." + /// + /// - SeeAlso: This is based on the [`com.atproto.sync.getLatestCommit`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/sync/getLatestCommit.json + public struct GetLatestCommitOutput: Codable { + + /// The commit CID of the repository. + public let commitCID: String + + /// The repository's revision. + public let revision: String + + enum CodingKeys: String, CodingKey { + case commitCID = "cid" + case revision = "rev" + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncListBlobs.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncListBlobs.swift new file mode 100644 index 0000000000..ce56cea250 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncListBlobs.swift @@ -0,0 +1,33 @@ +// +// ComAtprotoSyncListBlobs.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Sync { + + /// The main data model definition for the output of a user account's blob CID hashes. + /// + /// - Note: According to the AT Protocol specifications: "List blob CIDs for an account, since + /// some repo revision. Does not require auth; implemented by PDS." + /// + /// - SeeAlso: This is based on the [`com.atproto.sync.listBlobs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/sync/listBlobs.json + public struct ListBlobsOutput: Codable { + + /// The mark used to indicate the starting point for the next set of results. Optional. + public let cursor: String? + + /// An array of CID hashes from a user account. + public let accountCIDHashes: [String] + + enum CodingKeys: String, CodingKey { + case cursor + case accountCIDHashes = "cids" + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncListRepos.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncListRepos.swift new file mode 100644 index 0000000000..4dc2aef680 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncListRepos.swift @@ -0,0 +1,56 @@ +// +// ComAtprotoSyncListRepos.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Sync { + + /// The main data model definition for the output of listing all decentralized identifiers + /// (DIDs), revisions, and commit CID hashes of given repositiories. + /// + /// - Note: According to the AT Protocol specifications: "Enumerates all the DID, rev, and + /// commit CID for all repos hosted by this service. Does not require auth; + /// implemented by PDS and Relay." + /// + /// - SeeAlso: This is based on the [`com.atproto.sync.listRepos`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/sync/listRepos.json + public struct ListRepositoriesOutput: Codable { + + /// The mark used to indicate the starting point for the next set of results. Optional. + public let cursor: String? + + /// An array of repositories. + public let repositories: [Repository] + + enum CodingKeys: String, CodingKey { + case cursor + case repositories = "repos" + } + } + + /// A data model definition for a repository. + public struct Repository: Codable { + + /// The decentralized identifier (DID) of the repository. + public let repositoryDID: String + + /// The commit CID hash of the repository. + /// + /// - Note: According to the AT Protocol specifications: "Current repo commit CID." + public let commitCID: String + + /// The repository's revision. + public let revision: String + + enum CodingKeys: String, CodingKey { + case repositoryDID = "did" + case commitCID = "head" + case revision = "rev" + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncSubscribeRepos.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncSubscribeRepos.swift new file mode 100644 index 0000000000..b6ba83e24c --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncSubscribeRepos.swift @@ -0,0 +1,26 @@ +// +// ComAtprotoSyncSubscribeRepos.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Sync { + + /// The main data model definition for the firehose service. + /// + /// - Note: According to the AT Protocol specifications: "Repository event stream, aka Firehose + /// endpoint. Outputs repo commits with diff data, and identity update events, for all + /// repositories on the current server. See the atproto specifications for details around + /// stream sequencing, repo versioning, CAR diff format, and more. Public and does not require + /// auth; implemented by PDS and Relay." + /// + /// - SeeAlso: This is based on the [`com.atproto.sync.subscribeRepos`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/sync/subscribeRepos.json + public struct SubscribeRepos: Codable { + + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Temp/ComAtprotoTempCheckSignupQueue.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Temp/ComAtprotoTempCheckSignupQueue.swift new file mode 100644 index 0000000000..1f26900688 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Temp/ComAtprotoTempCheckSignupQueue.swift @@ -0,0 +1,43 @@ +// +// ComAtprotoTempCheckSignupQueue.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + + +extension ComAtprotoLexicon.Temp { + + /// The main data model definition for the output of retrieving information about the + /// sign up queue. + /// + /// - Important: The lexicon associated with this model may be removed at any time. This may + /// not work. + /// + /// - Note: According to the AT Protocol specifications: "Check accounts location in + /// signup queue." + /// + /// - SeeAlso: This is based on the [`com.atproto.temp.checkSignupQueue`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/temp/checkSignupQueue.json + public struct CheckSignupQueueOutput: Codable { + + /// Indicates whether the user with the queried username has been activated. + public let isActivated: Bool + + /// The user's place in queue. Optional. + public let placeInQueue: Int? + + /// The estimated amount of time before the user can use the service + /// (in minutes). Optional. + public let estimatedTimeinMinutes: Int + + enum CodingKeys: String, CodingKey { + case isActivated = "activated" + case placeInQueue = "placeInQueue" + case estimatedTimeinMinutes = "estimatedTimeMs" + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Temp/ComAtprotoTempRequestPhoneVerification.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Temp/ComAtprotoTempRequestPhoneVerification.swift new file mode 100644 index 0000000000..35f49c1a90 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Temp/ComAtprotoTempRequestPhoneVerification.swift @@ -0,0 +1,28 @@ +// +// ComAtprotoTempRequestPhoneVerification.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ComAtprotoLexicon.Temp { + + /// The main data model definition for requesting a text code from a phone number. + /// + /// - Important: The lexicon associated with this model may be removed at any time. This may + /// not work. + /// + /// - Note: According to the AT Protocol specifications: "Request a verification code to be + /// sent to the supplied phone number." + /// + /// - SeeAlso: This is based on the [`com.atproto.temp.requestPhoneVerification`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/temp/requestPhoneVerification.json + public struct RequestPhoneVerification: Codable { + + /// The user's mobile phone number. + public let phoneNumber: String + } +} From 601b1f41d055148f411bcda0ac0a39ac8d2d1e0a Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Tue, 21 May 2024 09:36:26 -0400 Subject: [PATCH 14/51] Change lexicon layout and fix issues - The following lexicons have been changed: - tools.ozone.* --- ...oolsOzoneCommunicationCreateTemplate.swift | 46 + .../ToolsOzoneCommunicationDefs.swift | 106 ++ ...oolsOzoneCommunicationDeleteTemplate.swift | 24 + ...ToolsOzoneCommunicationListTemplates.swift | 25 + ...oolsOzoneCommunicationUpdateTemplate.swift | 53 + .../Moderation/ToolsOzoneModerationDefs.swift | 1224 +++++++++++++++++ .../ToolsOzoneModerationEmitEvent.swift | 40 + .../ToolsOzoneModerationQueryEvents.swift | 38 + .../ToolsOzoneModerationQueryStatuses.swift | 28 + .../ToolsOzoneModerationSearchRepos.swift | 33 + 10 files changed, 1617 insertions(+) create mode 100644 Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/ToolsOzoneCommunicationCreateTemplate.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/ToolsOzoneCommunicationDefs.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/ToolsOzoneCommunicationDeleteTemplate.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/ToolsOzoneCommunicationListTemplates.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/ToolsOzoneCommunicationUpdateTemplate.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationDefs.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationEmitEvent.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationQueryEvents.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationQueryStatuses.swift create mode 100644 Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationSearchRepos.swift diff --git a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/ToolsOzoneCommunicationCreateTemplate.swift b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/ToolsOzoneCommunicationCreateTemplate.swift new file mode 100644 index 0000000000..b97117bad8 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/ToolsOzoneCommunicationCreateTemplate.swift @@ -0,0 +1,46 @@ +// +// ToolsOzoneCommunicationCreateTemplate.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ToolsOzoneLexicon.Communication { + + /// The request body data model definition for creating a communication template. + /// + /// - Note: According to the AT Protocol specifications: "Administrative action to create a + /// new, re-usable communication (email for now) template." + /// + /// - SeeAlso: This is based on the [`tools.ozone.communication.createTemplate`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/communication/createTemplate.json + public struct CreateTemplateRequestBody: Codable { + + /// The name of the template. + /// + /// - Note: According to the AT Protocol specifications: "Name of the template." + public let name: String + + /// A Markdown-formatted content of the communitcation template. + /// + /// - Note: According to the AT Protocol specifications: "Content of the template, markdown + /// supported, can contain variable placeholders." + public let contentMarkdown: String + + /// The subject line of the communication template. + /// + /// - Note: According to the AT Protocol specifications: "Subject of the message, used + /// in emails." + public let subject: String + + /// The decentralized identifier (DID) of the creator of the + /// communication template. Optional. + /// + /// - Note: According to the AT Protocol specifications: "DID of the user who is creating + /// the template." + public let createdBy: String? + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/ToolsOzoneCommunicationDefs.swift b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/ToolsOzoneCommunicationDefs.swift new file mode 100644 index 0000000000..b79a846068 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/ToolsOzoneCommunicationDefs.swift @@ -0,0 +1,106 @@ +// +// ToolsOzoneCommunicationDefs.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ToolsOzoneLexicon.Communication { + + /// A data model definition for a communication template. + /// + /// - SeeAlso: This is based on the [`tools.ozone.communication.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/communication/defs.json + public struct TemplateViewDefinition: Codable { + + /// The ID of the communication template. + public let id: Int + + /// The name of the communication template. + /// + /// - Note: According to the AT Protocol specifications: "Name of the template." + public let name: String + + /// The subject of the message. Optional. + /// + /// - Note: According to the AT Protocol specifications: "Subject of the message, used + /// in emails." + public var subject: String? + + /// The content of the communication template. Optional. + /// + /// This may contain Markdown placeholders and variable placeholders. + /// + /// - Note: According to the AT Protocol specifications: "Content of the template, can + /// contain markdown and variable placeholders." + public let contentMarkdown: String + + /// Indicates whether the communication template has been disabled. + public let isDisabled: Bool + + /// The decentralized identifier (DID) of the user who last updated the + /// communication template. + /// + /// - Note: According to the AT Protocol specifications: "DID of the user who last updated + /// the template." + public let lastUpdatedBy: String + + /// The date and time the communication template was created. + @DateFormatting public var createdAt: Date + + /// The date and time the communication template was updated. + @DateFormatting public var updatedAt: Date + + public init(id: Int, name: String, subject: String? = nil, contentMarkdown: String, isDisabled: Bool, lastUpdatedBy: String, + createdAt: Date, updatedAt: Date) { + self.id = id + self.name = name + self.subject = subject + self.contentMarkdown = contentMarkdown + self.isDisabled = isDisabled + self.lastUpdatedBy = lastUpdatedBy + self._createdAt = DateFormatting(wrappedValue: createdAt) + self._updatedAt = DateFormatting(wrappedValue: updatedAt) + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.id = try container.decode(Int.self, forKey: .id) + self.name = try container.decode(String.self, forKey: .name) + self.subject = try container.decodeIfPresent(String.self, forKey: .subject) + self.contentMarkdown = try container.decode(String.self, forKey: .contentMarkdown) + self.isDisabled = try container.decode(Bool.self, forKey: .isDisabled) + self.lastUpdatedBy = try container.decode(String.self, forKey: .lastUpdatedBy) + self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue + self.updatedAt = try container.decode(DateFormatting.self, forKey: .updatedAt).wrappedValue + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.id, forKey: .id) + try container.encode(self.name, forKey: .name) + try container.encodeIfPresent(self.subject, forKey: .subject) + try container.encode(self.contentMarkdown, forKey: .contentMarkdown) + try container.encode(self.isDisabled, forKey: .isDisabled) + try container.encode(self.lastUpdatedBy, forKey: .lastUpdatedBy) + try container.encode(self._createdAt, forKey: .createdAt) + try container.encode(self._updatedAt, forKey: .updatedAt) + } + + enum CodingKeys: String, CodingKey { + case id + case name + case subject + case contentMarkdown + case isDisabled = "disabled" + case lastUpdatedBy + case createdAt + case updatedAt + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/ToolsOzoneCommunicationDeleteTemplate.swift b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/ToolsOzoneCommunicationDeleteTemplate.swift new file mode 100644 index 0000000000..91cfb032c4 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/ToolsOzoneCommunicationDeleteTemplate.swift @@ -0,0 +1,24 @@ +// +// ToolsOzoneCommunicationDeleteTemplate.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ToolsOzoneLexicon.Communication { + + /// The main data model definition for deleting a communication template as an administrator. + /// + /// - Note: According to the AT Protocol specifications: "Delete a communication template." + /// + /// - SeeAlso: This is based on the [`tools.ozone.communication.deleteTemplate`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/communication/deleteTemplate.json + public struct DeleteTemplateRequestBody: Codable { + + /// The ID of the communication template. + public let id: String + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/ToolsOzoneCommunicationListTemplates.swift b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/ToolsOzoneCommunicationListTemplates.swift new file mode 100644 index 0000000000..19ca73dd0a --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/ToolsOzoneCommunicationListTemplates.swift @@ -0,0 +1,25 @@ +// +// ToolsOzoneCommunicationListTemplates.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ToolsOzoneLexicon.Communication { + + /// The output definition for retrieves a list of communication templates. + /// + /// - Note: According to the AT Protocol specifications: "Get list of all + /// communication templates." + /// + /// - SeeAlso: This is based on the [`tools.ozone.communication.listTemplates`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/communication/listTemplates.json + public struct ListTemplatesOutput: Codable { + + /// An array of communication templates. + public let communicationTemplates: [TemplateViewDefinition] + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/ToolsOzoneCommunicationUpdateTemplate.swift b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/ToolsOzoneCommunicationUpdateTemplate.swift new file mode 100644 index 0000000000..454fa2b516 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/ToolsOzoneCommunicationUpdateTemplate.swift @@ -0,0 +1,53 @@ +// +// ToolsOzoneCommunicationUpdateTemplate.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ToolsOzoneLexicon.Communication { + + /// The request body data model definition for updating a communication template. + /// + /// - Note: According to the AT Protocol specifications: "Administrative action to update an + /// existing communication template. Allows passing partial fields to patch specific + /// fields only." + /// + /// - SeeAlso: This is based on the [`tools.ozone.communication.updateTemplate`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/communication/updateTemplate.json + public struct UpdateTemplateRequestBody: Codable { + + /// The ID of the communication template. + public let id: String + + /// The name of the communication template. Optional. + public let name: String? + + /// The content of the communication template. Optional. + /// + /// This may contain Markdown placeholders and variable placeholders. + public let contentMarkdown: String? + + /// The subject line of the message itself. Optional. + public let subject: String? + + /// The decentralized identifier (DID) of the user who updated the + /// communication template. Optional. + public let updatedBy: String? + + /// Indicates whether the communication template is disabled. Optional. + public let isDisabled: Bool? + + enum CodingKeys: String, CodingKey { + case id + case name + case contentMarkdown + case subject + case updatedBy + case isDisabled = "disabled" + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationDefs.swift b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationDefs.swift new file mode 100644 index 0000000000..2e62e78b7e --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationDefs.swift @@ -0,0 +1,1224 @@ +// +// ToolsOzoneModerationDefs.swift +// +// +// Created by Christopher Jr Riley on 2024-05-20. +// + +import Foundation + +extension ToolsOzoneLexicon.Moderation { + + /// A data model for a moderation event view definition. + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/defs.json + public struct EventViewDefinition: Codable { + + /// The ID of the moderator's event view. + public let id: Int + + /// The type of the moderator's event view. + public let event: AdminEventViewUnion + + /// The subject reference of the moderator's event view. + public let subject: RepositoryReferencesUnion + + /// An array of CID hashes related to blobs for the moderator's event view. + public let subjectBlobCIDHashes: [String] + + /// The creator of the event view. + public let createdBy: String + + /// The date and time the event view was created. + @DateFormatting public var createdAt: Date + + /// The handle of the moderator. Optional. + public var creatorHandle: String? + + /// The subject handle of the event view. Optional. + public var subjectHandle: String? + + public init(id: Int, event: AdminEventViewUnion, subject: RepositoryReferencesUnion, subjectBlobCIDHashes: [String], createdBy: String, + createdAt: Date, creatorHandle: String?, subjectHandle: String?) { + self.id = id + self.event = event + self.subject = subject + self.subjectBlobCIDHashes = subjectBlobCIDHashes + self.createdBy = createdBy + self._createdAt = DateFormatting(wrappedValue: createdAt) + self.creatorHandle = creatorHandle + self.subjectHandle = subjectHandle + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.id = try container.decode(Int.self, forKey: .id) + self.event = try container.decode(AdminEventViewUnion.self, forKey: .event) + self.subject = try container.decode(RepositoryReferencesUnion.self, forKey: .subject) + self.subjectBlobCIDHashes = try container.decode([String].self, forKey: .subjectBlobCIDHashes) + self.createdBy = try container.decode(String.self, forKey: .createdBy) + self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue + self.creatorHandle = try container.decodeIfPresent(String.self, forKey: .creatorHandle) + self.subjectHandle = try container.decodeIfPresent(String.self, forKey: .subjectHandle) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.id, forKey: .id) + try container.encode(self.event, forKey: .event) + try container.encode(self.subject, forKey: .subject) + try container.encode(self.subjectBlobCIDHashes, forKey: .subjectBlobCIDHashes) + try container.encode(self.createdBy, forKey: .createdBy) + try container.encode(self._createdAt, forKey: .createdAt) + try container.encodeIfPresent(self.creatorHandle, forKey: .creatorHandle) + try container.encodeIfPresent(self.subjectHandle, forKey: .subjectHandle) + } + + enum CodingKeys: String, CodingKey { + case id + case event + case subject + case subjectBlobCIDHashes = "subjectBlobCids" + case createdBy + case createdAt + case creatorHandle + case subjectHandle + } + } + + /// A data model for a detailed moderation event view definition. + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/defs.json + public struct EventViewDetailDefinition: Codable { + + /// The ID of the moderator's event view. + public let id: Int + + /// The type of the moderator's event view. + public let event: EventViewDetailUnion + + /// The subject reference of the moderator's event view. + public let subject: RepositoryViewUnion + + /// An array of blobs for a moderator to look at. + public let subjectBlobs: [OzoneModerationBlobView] + + /// The creator of the event view. + public let createdBy: String + + /// The date and time the event view was created. + @DateFormatting public var createdAt: Date + + public init(id: Int, event: EventViewDetailUnion, subject: RepositoryViewUnion, subjectBlobs: [OzoneModerationBlobView], + createdBy: String, createdAt: Date) { + self.id = id + self.event = event + self.subject = subject + self.subjectBlobs = subjectBlobs + self.createdBy = createdBy + self._createdAt = DateFormatting(wrappedValue: createdAt) + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.id = try container.decode(Int.self, forKey: .id) + self.event = try container.decode(EventViewDetailUnion.self, forKey: .event) + self.subject = try container.decode(RepositoryViewUnion.self, forKey: .subject) + self.subjectBlobs = try container.decode([OzoneModerationBlobView].self, forKey: .subjectBlobs) + self.createdBy = try container.decode(String.self, forKey: .createdBy) + self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.id, forKey: .id) + try container.encode(self.event, forKey: .event) + try container.encode(self.subject, forKey: .subject) + try container.encode(self.subjectBlobs, forKey: .subjectBlobs) + try container.encode(self.createdBy, forKey: .createdBy) + try container.encode(self._createdAt, forKey: .createdAt) + } + + enum CodingKeys: CodingKey { + case id + case event + case subject + case subjectBlobs + case createdBy + case createdAt + } + } + + /// A data model for a subject's status view definition. + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/defs.json + public struct SubjectStatusViewDefinition: Codable { + + /// The ID of the status view. + public let id: Int + + /// The subject reference of the status view. + public let subject: RepositoryReferencesUnion + + /// An array of CID hashes related to blobs. Optional. + public var subjectBlobCIDHashes: [String]? + + /// The handle of the subject related to the status. Optional. + public var subjectRepoHandle: String? + + /// The date and time of the last update for the status view. + /// + /// - Note: According to the AT Protocol specifications: "Timestamp referencing when + /// the last update was made to the moderation status of the subject." + @DateFormatting public var updatedAt: Date + + /// The date and time of the day the first event occured. + /// + /// - Note: According to the AT Protocol specifications: "Timestamp referencing the first + /// moderation status impacting event was emitted on the subject." + @DateFormatting public var createdAt: Date + + /// The review status of the subject. + public let reviewState: OzoneSubjectReviewState + + /// Any additional comments written about the subject. Optional. + public var comment: String? + + /// The date and time the subject's time to be muted has been lifted. Optional. + /// + /// - Note: According to the AT Protocol specifications: "Sticky comment on the subject." + @DateFormattingOptional public var muteUntil: Date? + + /// The date and time until which reporting on the subject is muted. Optional. + /// + /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ + /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ + /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ + /// \ + /// Clarifications from Bluesky are needed in order to fully understand this item. + @DateFormattingOptional public var muteReportingUntil: Date? + + /// The name of the reviewer that reviewed the subject. Optional. + public var lastReviewedBy: String? + + /// The date and time the last reviewer looked at the subject. Optional. + @DateFormattingOptional public var lastReviewedAt: Date? + + /// The date and time of the last report about the subject. Optional. + @DateFormattingOptional public var lastReportedAt: Date? + + /// The date and time of the last appeal. Optional. + @DateFormattingOptional public var lastAppealedAt: Date? + + /// Indicates whether the subject was taken down. Optional. + public var isTakenDown: Bool? + + /// Indicates whether an appeal has been made. Optional. + public var wasAppealed: Bool? + + /// The date and time the subject's suspension will be lifted. Optional. + @DateFormattingOptional public var suspendUntil: Date? + + /// An array of tags. Optional. + public var tags: [String]? + + public init(id: Int, subject: RepositoryReferencesUnion, subjectBlobCIDHashes: [String]?, subjectRepoHandle: String?, updatedAt: Date, createdAt: Date, + reviewState: OzoneSubjectReviewState, comment: String?, muteUntil: Date?, muteReportingUntil: Date?, lastReviewedBy: String?, + lastReviewedAt: Date?, lastReportedAt: Date?, lastAppealedAt: Date?, isTakenDown: Bool?, wasAppealed: Bool?, suspendUntil: Date?, + tags: [String]?) { + self.id = id + self.subject = subject + self.subjectBlobCIDHashes = subjectBlobCIDHashes + self.subjectRepoHandle = subjectRepoHandle + self._updatedAt = DateFormatting(wrappedValue: updatedAt) + self._createdAt = DateFormatting(wrappedValue: createdAt) + self.reviewState = reviewState + self.comment = comment + self.muteUntil = muteUntil + self._muteReportingUntil = DateFormattingOptional(wrappedValue: muteReportingUntil) + self.lastReviewedBy = lastReviewedBy + self._lastReviewedAt = DateFormattingOptional(wrappedValue: lastReviewedAt) + self._lastReportedAt = DateFormattingOptional(wrappedValue: lastReportedAt) + self._lastAppealedAt = DateFormattingOptional(wrappedValue: lastAppealedAt) + self.isTakenDown = isTakenDown + self.wasAppealed = wasAppealed + self._suspendUntil = DateFormattingOptional(wrappedValue: suspendUntil) + self.tags = tags + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.id = try container.decode(Int.self, forKey: .id) + self.subject = try container.decode(RepositoryReferencesUnion.self, forKey: .subject) + self.subjectBlobCIDHashes = try container.decodeIfPresent([String].self, forKey: .subjectBlobCIDHashes) + self.subjectRepoHandle = try container.decodeIfPresent(String.self, forKey: .subjectRepoHandle) + self.updatedAt = try container.decode(DateFormatting.self, forKey: .updatedAt).wrappedValue + self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue + self.reviewState = try container.decode(OzoneSubjectReviewState.self, forKey: .reviewState) + self.comment = try container.decodeIfPresent(String.self, forKey: .comment) + self.muteUntil = try container.decodeIfPresent(DateFormattingOptional.self, forKey: .muteUntil)?.wrappedValue + self.muteReportingUntil = try container.decodeIfPresent(DateFormattingOptional.self, forKey: .muteReportingUntil)?.wrappedValue + self.lastReviewedBy = try container.decodeIfPresent(String.self, forKey: .lastReviewedBy) + self.lastReviewedAt = try container.decodeIfPresent(DateFormattingOptional.self, forKey: .lastReviewedAt)?.wrappedValue + self.lastReportedAt = try container.decodeIfPresent(DateFormattingOptional.self, forKey: .lastReportedAt)?.wrappedValue + self.lastAppealedAt = try container.decodeIfPresent(DateFormattingOptional.self, forKey: .lastAppealedAt)?.wrappedValue + self.isTakenDown = try container.decodeIfPresent(Bool.self, forKey: .isTakenDown) + self.wasAppealed = try container.decodeIfPresent(Bool.self, forKey: .wasAppealed) + self.suspendUntil = try container.decodeIfPresent(DateFormattingOptional.self, forKey: .suspendUntil)?.wrappedValue + self.tags = try container.decode([String].self, forKey: .tags) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.id, forKey: .id) + try container.encode(self.subject, forKey: .subject) + try container.encodeIfPresent(self.subjectBlobCIDHashes, forKey: .subjectBlobCIDHashes) + try container.encodeIfPresent(self.subjectRepoHandle, forKey: .subjectRepoHandle) + try container.encode(self._updatedAt, forKey: .updatedAt) + try container.encode(self._createdAt, forKey: .createdAt) + try container.encode(self.reviewState, forKey: .reviewState) + try container.encodeIfPresent(self.comment, forKey: .comment) + try container.encode(self._muteUntil, forKey: .muteUntil) + try container.encodeIfPresent(self._muteReportingUntil, forKey: .muteReportingUntil) + try container.encodeIfPresent(self.lastReviewedBy, forKey: .lastReviewedBy) + try container.encode(self._lastReviewedAt, forKey: .lastReviewedAt) + try container.encode(self._lastReportedAt, forKey: .lastReportedAt) + try container.encode(self._lastAppealedAt, forKey: .lastAppealedAt) + try container.encodeIfPresent(self.isTakenDown, forKey: .isTakenDown) + try container.encodeIfPresent(self.wasAppealed, forKey: .wasAppealed) + try container.encode(self._suspendUntil, forKey: .suspendUntil) + try container.encode(self.tags, forKey: .tags) + } + + enum CodingKeys: String, CodingKey { + case id + case subject + case subjectBlobCIDHashes = "subjectBlobCids" + case subjectRepoHandle + case updatedAt + case createdAt + case reviewState + case comment + case muteUntil + case muteReportingUntil + case lastReviewedBy + case lastReviewedAt + case lastReportedAt + case lastAppealedAt + case isTakenDown = "takendown" + case wasAppealed = "appealed" + case suspendUntil + case tags + } + } + + /// A data model for the subject review state definition. + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/defs.json + public enum SubjectReviewStateDefinition: String, Codable { + + /// Moderator review status of a subject: Open. Indicates that the subject needs to be + /// reviewed by a moderator. + /// + /// - Note: The above documentation was taken directly from the AT Protocol specifications. + case reviewOpen + + /// Moderator review status of a subject: Escalated. Indicates that the subject was + /// escalated for review by a moderator. + /// + /// - Note: The above documentation was taken directly from the AT Protocol specifications. + case reviewEscalated + + /// Moderator review status of a subject: Closed. Indicates that the subject was already + /// reviewed and resolved by a moderator. + /// + /// - Note: The above documentation was taken directly from the AT Protocol specifications. + case reviewClosed + + /// Moderator review status of a subject: Unnecessary. Indicates that the subject does + /// not need a review at the moment but there + /// is probably some moderation related metadata available for it + /// + /// - Note: The above documentation was taken directly from the AT Protocol specifications. + case reviewNone + } + + /// A data model for an event takedown definition. + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/defs.json + public struct EventTakedownDefinition: Codable { + + /// Any additional comments for the takedown event. Optional. + /// + /// - Note: According to the AT Protocol specifications: "Take down a subject permanently + /// or temporarily." + public let comment: String? + + /// The amount of time (in hours) for the user to be considered takendown. Optional. + /// + /// - Note: According to the AT Protocol specifications: "Indicates how long the takedown + /// should be in effect before automatically expiring." + public let durationInHours: Int? + } + + /// A data model for a reverse takedown event definition. + /// + /// - Note: According to the AT Protocol specifications: "Revert take down action on + /// a subject." + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/defs.json + public struct EventReverseTakedownDefinition: Codable { + + /// Any comments for the reverse takedown event. Optional. + /// + /// - Note: According to the AT Protocol specifications: "Describe reasoning behind + /// the reversal." + public let comment: String? + } + + /// A data model for a definition of an resolved appeal event. + /// + /// - Note: According to the AT Protocol specifications: "Resolve appeal on a subject." + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/defs.json + public struct EventResolveAppealDefinition: Codable { + + /// Any comments for the moderator's appeal resolution event. Optional. + /// + /// - Note: According to the AT Protocol specifications: "Describe resolution." + public let comment: String? + } + + /// A data model for a definition of a comment event. + /// + /// - Note: According to the AT Protocol specifications: "Add a comment to a subject." + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/defs.json + public struct EventCommentDefinition: Codable { + + /// Any comment for the moderator's comment event. + public let comment: String + + /// Indicates whether the moderator event is sticky. Optional. + /// + /// - Note: According to the AT Protocol specifications: "Make the comment persistent on the subject." + public let isSticky: Bool? + + enum CodingKeys: String, CodingKey { + case comment + case isSticky = "sticky" + } + } + + /// A data model for a report event definition. + /// + /// - Note: According to the AT Protocol specifications: "Report a subject." + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/defs.json + public struct EventReportDefinition: Codable { + + /// Any comments for the moderator's report event. Optional. + public var comment: String? + + /// Indicates whether the reporter has been muted. Optional. + /// + /// - Note: According to the AT Protocol specifications: "Set to true if the reporter + /// was muted from reporting at the time of the event. These reports won't impact + /// the reviewState of the subject." + public let isReporterMuted: Bool? + + /// The type of report. + public let reportType: ModerationReasonType + } + + /// A data model for a label event definition. + /// + /// - Note: According to the AT Protocol specifications: "Apply/Negate labels on a subject" + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/defs.json + public struct EventLabelDefinition: Codable { + + /// Any comments for the moderator's label event. Optional. + public let comment: String? + + /// An array of labels that apply to a user. + public let createLabelValues: [String] + + /// An array of labels that's applied to a user for the purpose of negating. + public let negateLabelValues: [String] + + enum CodingKeys: String, CodingKey { + case comment + case createLabelValues = "createLabelVals" + case negateLabelValues = "negateLabelVals" + } + } + + /// A data model for a definition of an acknowledgement event. + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/defs.json + public struct EventAcknowledgeDefinition: Codable { + + /// Any comments for the moderator's acknowledge event. Optional. + public var comment: String? + } + + /// A data model for a definition of an escalation event. + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/defs.json + public struct EventEscalateDefinition: Codable { + + /// Any additional comments for escalating a report. Optional. + public var comment: String? + } + + /// A data model for a definition of a mute event. + /// + /// - Note: According to the AT Protocol specifications: "Mute incoming reports on a subject." + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/defs.json + public struct EventMuteDefinition: Codable { + + /// Any additional comments for the mute event. Optional. + public var comment: String? + + /// The amount of time (in hours) that the moderator has put in for muting a user. + /// + /// - Note: According to the AT Protocol specifications: "Indicates how long the + /// subject should remain muted." + public let durationInHours: Int + } + + /// A data model for an unmute event definition. + /// + /// - Note: According to the AT Protocol specifications: "Unmute action on a subject." + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/defs.json + public struct EventUnmuteDefinition: Codable { + + /// Any comments for the moderator's unmute event. Optional. + /// + /// - Note: According to the AT Protocol specifications: "Describe reasoning behind + /// the reversal." + public var comment: String? + } + + /// A data model definition for a mute reporter event. + /// + /// - Note: According to the AT Protocol specifications: "Mute incoming reports from + /// an account." + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/defs.json + public struct EventMuteReporterDefinition: Codable { + + /// Indicates how long the account should remain muted (in hours). + /// + /// - Note: According to the AT Protocol specifications: "Indicates how long the + /// account should remain muted." + public let durationInHours: Int + + /// Any additional comments about the event. Optional. + public let comment: String? + } + + /// A data model definition for an unmute reporter event. + /// + /// - Note: According to the AT Protocol specifications: "Unmute incoming reports + /// from an account." + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/defs.json + public struct EventUnmuteReporterDefinition: Codable { + + /// Any additional comments about the event. + /// + /// - Note: According to the AT Protocol specifications: "Describe reasoning + /// behind the reversal." + public let comment: String? + } + + /// A data model for a definition of an email event. + /// + /// - Note: According to the AT Protocol specifications: "Keep a log of outgoing email to a user." + /// + /// - SeeAlso: This is based on the [`tools.ozone.moderation.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/defs.json + public struct EventEmailDefinition: Codable { + + /// The subject line of the email. + /// + /// - Note: According to the AT Protocol specifications: "The subject line of the email + /// sent to the user." + public let subjectLine: String + + /// The body of the email. + /// + /// - Note: According to the AT Protocol specifications: "The content of the email + /// sent to the user." + public let content: String + + /// Any additional comments about the email. Optional. + /// + /// - Note: According to the AT Protocol specifications: "Additional comment about + /// the outgoing comm." + public var comment: String? + } + + /// A data model for a definition of a diversion event. + /// + /// - Note: According to the AT Protocol specifications: "Divert a record's blobs to a + /// 3rd party service for further scanning/tagging" + /// + /// - SeeAlso: This is based on the [`tools.ozone.moderation.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/defs.json + public struct EventDivertDefinition: Codable { + + /// Any additional comments about the diversion. + public let comment: String? + } + + /// A data model for a tag event definition. + /// + /// - Note: According to the AT Protocol specifications: "Add/Remove a tag on a subject." + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/defs.json + public struct EventTagDefinition: Codable { + + /// An array of tags to be added to the user. + /// + /// If a tag in the array already exists on the user, then the tag will be ignored. + /// + /// - Note: According to the AT Protocol specifications: "Tags to be added to + /// the subject. If already exists, won't be duplicated." + public let add: [String] + + /// An array of tags to be removed from the user. + /// + /// If a tag in the array doesn't exist on the user, then the tag will be ignored. + /// + /// - Note: According to the AT Protocol specifications: "Tags to be removed to + /// the subject. Ignores a tag If it doesn't exist, won't be duplicated." + public let remove: [String] + + /// Any additional comments about the moderator's tag event. + /// + /// - Note: According to the AT Protocol specifications: "Additional comment about + /// added/removed tags." + public let comment: String? + } + + /// A data model for a definition of a repository view. + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/defs.json + public struct RepositoryViewDefinition: Codable { + + /// The decentralized identifier (DID) of the user. + public let actorDID: String + + /// The handle of the user. + public let handle: String + + /// The email of the user. Optional. + public var email: String? + + /// The related records of the user. + /// + /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ + /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ + /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ + /// \ + /// Clarifications from Bluesky are needed in order to fully understand this item. + public let relatedRecords: UnknownType + + /// The date and time the user was indexed. + @DateFormatting public var indexedAt: Date + + /// The moderation status of the user. + public let moderation: OzoneModeration + + /// The invite code used by the user to sign up. Optional. + public var invitedBy: ServerInviteCode? + + /// Indicates whether the invite codes held by the user are diabled. Optional. + public var areInvitesDisabled: Bool? + + /// The note of the invite. Optional. + public var inviteNote: String? + + public init(actorDID: String, handle: String, email: String? = nil, relatedRecords: UnknownType, indexedAt: Date, moderation: OzoneModeration, + invitedBy: ServerInviteCode? = nil, areInvitesDisabled: Bool? = nil, inviteNote: String? = nil) { + self.actorDID = actorDID + self.handle = handle + self.email = email + self.relatedRecords = relatedRecords + self._indexedAt = DateFormatting(wrappedValue: indexedAt) + self.moderation = moderation + self.invitedBy = invitedBy + self.areInvitesDisabled = areInvitesDisabled + self.inviteNote = inviteNote + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.actorDID = try container.decode(String.self, forKey: .actorDID) + self.handle = try container.decode(String.self, forKey: .handle) + self.email = try container.decodeIfPresent(String.self, forKey: .email) + self.relatedRecords = try container.decode(UnknownType.self, forKey: .relatedRecords) + self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue + self.moderation = try container.decode(OzoneModeration.self, forKey: .moderation) + self.invitedBy = try container.decodeIfPresent(ServerInviteCode.self, forKey: .invitedBy) + self.areInvitesDisabled = try container.decodeIfPresent(Bool.self, forKey: .areInvitesDisabled) + self.inviteNote = try container.decodeIfPresent(String.self, forKey: .inviteNote) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.actorDID, forKey: .actorDID) + try container.encode(self.handle, forKey: .handle) + try container.encodeIfPresent(self.email, forKey: .email) + try container.encode(self.relatedRecords, forKey: .relatedRecords) + try container.encode(self._indexedAt, forKey: .indexedAt) + try container.encode(self.moderation, forKey: .moderation) + try container.encodeIfPresent(self.invitedBy, forKey: .invitedBy) + try container.encodeIfPresent(self.areInvitesDisabled, forKey: .areInvitesDisabled) + try container.encodeIfPresent(self.inviteNote, forKey: .inviteNote) + } + + enum CodingKeys: String, CodingKey { + case actorDID = "did" + case handle + case email + case relatedRecords + case indexedAt + case moderation + case invitedBy + case areInvitesDisabled = "invitesDisabled" + case inviteNote + } + } + + /// A data model for a definition of a detailed repository view. + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/defs.json + public struct RepositoryViewDetailDefinition: Codable { + + /// The decentralized identifier (DID) of the user. + public let actorDID: String + + /// The handle of the user. + public let handle: String + + /// The email of the user. Optional. + public var email: String? + + /// The user's related records. + /// + /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ + /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ + /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ + /// \ + /// Clarifications from Bluesky are needed in order to fully understand this item. + public let relatedRecords: UnknownType + + /// The date and time the user was last indexed. + @DateFormatting public var indexedAt: Date + + /// The detailed moderation status of the user. + public let moderation: OzoneModerationDetail + + /// An array of labels associated with the user. Optional. + public var labels: [Label]? + + /// The invite code used by the user to sign up. Optional. + public var invitedBy: ServerInviteCode? + + /// An array of invite codes held by the user. Optional. + public var invites: [ServerInviteCode]? + + /// Indicates whether the invite codes held by the user are diabled. Optional. + public var areInvitesDisabled: Bool? + + /// The note of the invite. Optional. + public var inviteNote: String? + + /// The date and time the email of the user was confirmed. Optional. + @DateFormattingOptional public var emailConfirmedAt: Date? + + public init(actorDID: String, handle: String, email: String?, relatedRecords: UnknownType, indexedAt: Date, moderation: OzoneModerationDetail, + labels: [Label]?, invitedBy: ServerInviteCode?, invites: [ServerInviteCode]?, areInvitesDisabled: Bool?, inviteNote: String?, + emailConfirmedAt: Date? = nil) { + self.actorDID = actorDID + self.handle = handle + self.email = email + self.relatedRecords = relatedRecords + self._indexedAt = DateFormatting(wrappedValue: indexedAt) + self.moderation = moderation + self.labels = labels + self.invitedBy = invitedBy + self.invites = invites + self.areInvitesDisabled = areInvitesDisabled + self.inviteNote = inviteNote + self._emailConfirmedAt = DateFormattingOptional(wrappedValue: emailConfirmedAt) + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.actorDID = try container.decode(String.self, forKey: .actorDID) + self.handle = try container.decode(String.self, forKey: .handle) + self.email = try container.decodeIfPresent(String.self, forKey: .email) + self.relatedRecords = try container.decode(UnknownType.self, forKey: .relatedRecords) + self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue + self.moderation = try container.decode(OzoneModerationDetail.self, forKey: .moderation) + self.labels = try container.decodeIfPresent([Label].self, forKey: .labels) + self.invitedBy = try container.decodeIfPresent(ServerInviteCode.self, forKey: .invitedBy) + self.invites = try container.decodeIfPresent([ServerInviteCode].self, forKey: .invites) + self.areInvitesDisabled = try container.decodeIfPresent(Bool.self, forKey: .areInvitesDisabled) + self.inviteNote = try container.decodeIfPresent(String.self, forKey: .inviteNote) + self.emailConfirmedAt = try container.decodeIfPresent(DateFormattingOptional.self, forKey: .emailConfirmedAt)?.wrappedValue + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.actorDID, forKey: .actorDID) + try container.encode(self.handle, forKey: .handle) + try container.encodeIfPresent(self.email, forKey: .email) + try container.encode(self.relatedRecords, forKey: .relatedRecords) + try container.encode(self._indexedAt, forKey: .indexedAt) + try container.encode(self.moderation, forKey: .moderation) + try container.encodeIfPresent(self.labels, forKey: .labels) + try container.encodeIfPresent(self.invitedBy, forKey: .invitedBy) + try container.encodeIfPresent(self.invites, forKey: .invites) + try container.encodeIfPresent(self.areInvitesDisabled, forKey: .areInvitesDisabled) + try container.encodeIfPresent(self.inviteNote, forKey: .inviteNote) + try container.encode(self._emailConfirmedAt, forKey: .emailConfirmedAt) + } + + enum CodingKeys: String, CodingKey { + case actorDID = "did" + case handle + case email + case relatedRecords + case indexedAt + case moderation + case labels + case invitedBy + case invites + case areInvitesDisabled = "invitesDisabled" + case inviteNote + case emailConfirmedAt + } + } + + /// A data model for a definition of a respository view that may not have been found. + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/defs.json + public struct RepositoryViewNotFoundDefinition: Codable { + + /// The decentralized identifier (DID) of the repository. + public let repositoryDID: String + + enum CodingKeys: String, CodingKey { + case repositoryDID = "did" + } + } + + /// A data model for the definition of a record view. + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/defs.json + public struct RecordViewDefinition: Codable { + + /// The URI of the record. + public let recordURI: String + + /// The CID hash of the record. + public let cidHash: String + + /// The value of the record. + /// + /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ + /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ + /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ + /// \ + /// Clarifications from Bluesky are needed in order to fully understand this item. + public let value: UnknownType + + /// An array of CID hashes for blobs. + public let blobCIDHashes: [String] + + /// The date and time the record is indexed. + @DateFormatting public var indexedAt: Date + + /// The status of the subject. + /// + /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ + /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ + /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ + /// \ + /// Clarifications from Bluesky are needed in order to fully understand this item. + public let moderation: OzoneModeration + + /// The repository view of the record. + /// + /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ + /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ + /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ + /// \ + /// Clarifications from Bluesky are needed in order to fully understand this item. + public let repository: OzoneModerationRepositoryView + + public init(recordURI: String, cidHash: String, value: UnknownType, blobCIDHashes: [String], indexedAt: Date, + moderation: OzoneModeration, repository: OzoneModerationRepositoryView) { + self.recordURI = recordURI + self.cidHash = cidHash + self.value = value + self.blobCIDHashes = blobCIDHashes + self._indexedAt = DateFormatting(wrappedValue: indexedAt) + self.moderation = moderation + self.repository = repository + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.recordURI = try container.decode(String.self, forKey: .recordURI) + self.cidHash = try container.decode(String.self, forKey: .cidHash) + self.value = try container.decode(UnknownType.self, forKey: .value) + self.blobCIDHashes = try container.decode([String].self, forKey: .blobCIDHashes) + self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue + self.moderation = try container.decode(OzoneModeration.self, forKey: .moderation) + self.repository = try container.decode(OzoneModerationRepositoryView.self, forKey: .repository) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.recordURI, forKey: .recordURI) + try container.encode(self.cidHash, forKey: .cidHash) + try container.encode(self.value, forKey: .value) + try container.encode(self.blobCIDHashes, forKey: .blobCIDHashes) + try container.encode(self._indexedAt, forKey: .indexedAt) + try container.encode(self.moderation, forKey: .moderation) + try container.encode(self.repository, forKey: .repository) + } + + enum CodingKeys: String, CodingKey { + case recordURI = "uri" + case cidHash = "cid" + case value + case blobCIDHashes = "blobCids" + case indexedAt + case moderation + case repository = "repo" + } + } + + /// A data model for a definition a detailed view of a record. + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/defs.json + public struct RecordViewDetailDefinition: Codable { + + /// The URI of a record. + public let recordURI: String + + /// The CID hash of the record. + public let cidHash: String + + /// The value of the record. + /// + /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ + /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ + /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ + /// \ + /// Clarifications from Bluesky are needed in order to fully understand this item. + public let value: String + + /// An array of CID hashes for blobs. + public let blobs: [OzoneModerationBlobView] + + /// An array of labels attached to the record. Optional. + public var labels: [Label]? + + /// The date and time the record is indexed. + @DateFormatting public var indexedAt: Date + + /// The repository view of the record. + /// + /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ + /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ + /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ + /// \ + /// Clarifications from Bluesky are needed in order to fully understand this item. + public let moderation: OzoneModerationDetail + + /// The repository view of the record. + /// + /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ + /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ + /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ + /// \ + /// Clarifications from Bluesky are needed in order to fully understand this item. + public let repository: OzoneModerationRepositoryView + + public init(recordURI: String, cidHash: String, value: String, blobs: [OzoneModerationBlobView], labels: [Label]? = nil, indexedAt: Date, + moderation: OzoneModerationDetail, repository: OzoneModerationRepositoryView) { + self.recordURI = recordURI + self.cidHash = cidHash + self.value = value + self.blobs = blobs + self.labels = labels + self._indexedAt = DateFormatting(wrappedValue: indexedAt) + self.moderation = moderation + self.repository = repository + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.recordURI = try container.decode(String.self, forKey: .recordURI) + self.cidHash = try container.decode(String.self, forKey: .cidHash) + self.value = try container.decode(String.self, forKey: .value) + self.blobs = try container.decode([OzoneModerationBlobView].self, forKey: .blobs) + self.labels = try container.decodeIfPresent([Label].self, forKey: .labels) + self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue + self.moderation = try container.decode(OzoneModerationDetail.self, forKey: .moderation) + self.repository = try container.decode(OzoneModerationRepositoryView.self, forKey: .repository) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.recordURI, forKey: .recordURI) + try container.encode(self.cidHash, forKey: .cidHash) + try container.encode(self.value, forKey: .value) + try container.encode(self.blobs, forKey: .blobs) + try container.encodeIfPresent(self.labels, forKey: .labels) + try container.encode(self._indexedAt, forKey: .indexedAt) + try container.encode(self.moderation, forKey: .moderation) + try container.encode(self.repository, forKey: .repository) + } + + enum CodingKeys: String, CodingKey { + case recordURI = "uri" + case cidHash = "cid" + case value + case blobs + case labels + case indexedAt + case moderation + case repository = "repo" + } + } + + /// A data model for a definition of a record that may not have been found. + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/defs.json + public struct RecordViewNotFoundDefinition: Codable { + + /// The URI of the record. + public let recordURI: String + + enum CodingKeys: String, CodingKey { + case recordURI = "uri" + } + } + + /// A data model of a definition for moderation. + /// + /// - Important: The item associated with this struct is undocumented in the AT Protocol specifications. The documentation here is based on:\ + /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ + /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ + /// \ + /// Clarifications from Bluesky are needed in order to fully understand this item. + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/defs.json + public struct ModerationDefinition: Codable { + + /// The status of the subject. Optional. + /// + /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ + /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ + /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ + /// \ + /// Clarifications from Bluesky are needed in order to fully understand this item. + public var subjectStatus: OzoneSubjectStatusView? + } + + /// A data model of a definition for a detailed moderation. + /// + /// - Important: The item associated with this struct is undocumented in the AT Protocol specifications. The documentation here is based on:\ + /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ + /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ + /// \ + /// Clarifications from Bluesky are needed in order to fully understand this item. + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/defs.json + public struct ModerationDetailDefinition: Codable { + + /// The status of the subject. Optional. + /// + /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ + /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ + /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ + /// \ + /// Clarifications from Bluesky are needed in order to fully understand this item. + public var subjectStatus: OzoneSubjectStatusView? + } + + /// The data model for a definition of a blob view. + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/defs.json + public struct BlobViewDefinition: Codable { + + /// The CID hash of the blob. + public let cidHash: String + + /// The MIME type of the blob. + public let mimeType: String + + /// The size of the blob. Written in bytes. + public let size: Int + + /// The date and time the blob was created. + @DateFormatting public var createdAt: Date + + /// The type of media in the blob. + public let details: MediaDetailUnion + + /// The status of the subject. + public let moderation: OzoneModeration + + public init(cidHash: String, mimeType: String, size: Int, createdAt: Date, details: MediaDetailUnion, moderation: OzoneModeration) { + self.cidHash = cidHash + self.mimeType = mimeType + self.size = size + self._createdAt = DateFormatting(wrappedValue: createdAt) + self.details = details + self.moderation = moderation + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.cidHash = try container.decode(String.self, forKey: .cidHash) + self.mimeType = try container.decode(String.self, forKey: .mimeType) + self.size = try container.decode(Int.self, forKey: .size) + self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue + self.details = try container.decode(MediaDetailUnion.self, forKey: .details) + self.moderation = try container.decode(OzoneModeration.self, forKey: .moderation) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.cidHash, forKey: .cidHash) + try container.encode(self.mimeType, forKey: .mimeType) + try container.encode(self.size, forKey: .size) + try container.encode(self._createdAt, forKey: .createdAt) + try container.encode(self.details, forKey: .details) + try container.encode(self.moderation, forKey: .moderation) + } + + enum CodingKeys: String, CodingKey { + case cidHash = "cid" + case mimeType + case size + case createdAt + case details + case moderation + } + } + + /// A data model for a definition of details for an image. + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/defs.json + public struct ImageDetailsDefinition: Codable { + + /// The width of the image. + public let width: Int + + /// The height of the image. + public let height: Int + } + + /// A data model for a definition of details for a video. + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/defs.json + public struct VideoDetailsDefinition: Codable { + + /// The width of the video. + public let width: Int + + /// The height of the video. + public let height: Int + + /// The duration of the video. + public let length: Int + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationEmitEvent.swift b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationEmitEvent.swift new file mode 100644 index 0000000000..f8679a87c6 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationEmitEvent.swift @@ -0,0 +1,40 @@ +// +// ToolsOzoneModerationEmitEvent.swift +// +// +// Created by Christopher Jr Riley on 2024-05-21. +// + +import Foundation + +extension ToolsOzoneLexicon.Moderation { + + /// The main data model definition for enacting on an action against a user's account. + /// + /// - Note: According to the AT Protocol specifications: "Take a moderation action on an actor." + /// + /// - SeeAlso: This is based on the [`tools.ozone.moderation.emitEvent`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/emitEvent.json + public struct EmitEvent: Codable { + + /// The type of event the moderator is taking, + public let event: ATUnion.AdminEventViewUnion + + /// The type of repository reference. + public let subject: RepositoryReferencesUnion + + /// An array of CID hashes related to blobs for the moderator's event view. Optional. + public let subjectBlobCIDHashes: [String]? + + /// The decentralized identifier (DID) of the moderator taking this action. + public let createdBy: String + + enum CodingKeys: String, CodingKey { + case event + case subject + case subjectBlobCIDHashes = "subjectBlobCids" + case createdBy + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationQueryEvents.swift b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationQueryEvents.swift new file mode 100644 index 0000000000..7812ab5c16 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationQueryEvents.swift @@ -0,0 +1,38 @@ +// +// ToolsOzoneModerationQueryEvents.swift +// +// +// Created by Christopher Jr Riley on 2024-05-21. +// + +import Foundation + +extension ToolsOzoneLexicon.Moderation { + + /// The main data model definition for listing all moderation events pertaining a subject. + /// + /// - Note: According to the AT Protocol specifications: "List moderation events related + /// to a subject." + /// + /// - SeeAlso: This is based on the [`tools.ozone.moderation.queryEvents`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/queryEvents.json + public struct EventsOutput: Codable { + + /// The mark used to indicate the starting point for the next set of results. Optional. + public let cursor: String? + + /// An array of moderator events. + public let events: [OzoneModerationEventView] + } + + /// Indicates the sorting direction for the array of moderation events. + public enum AdminQueryModerationEventSortDirection: String { + + /// Indicates the moderation events will be sorted in ascending order. + case ascending = "asc" + + /// Indicates the moderation events will be sorted in descending order. + case descending = "desc" + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationQueryStatuses.swift b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationQueryStatuses.swift new file mode 100644 index 0000000000..22e8b8d2e8 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationQueryStatuses.swift @@ -0,0 +1,28 @@ +// +// ToolsOzoneModerationQueryStatuses.swift +// +// +// Created by Christopher Jr Riley on 2024-05-21. +// + +import Foundation + +extension ToolsOzoneLexicon.Moderation { + + /// The main data model definition for listing all moderation events pertaining a subject. + /// + /// - Note: According to the AT Protocol specifications: "View moderation statuses of subjects + /// (record or repo)." + /// + /// - SeeAlso: This is based on the [`ools.ozone.moderation.queryStatuses`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/queryEvents.json + public struct QueryStatusesOutput: Codable { + + /// The mark used to indicate the starting point for the next set of results. Optional. + public let cursor: String? + + /// An array of subject status views. + public let subjectStatuses: [OzoneSubjectStatusView] + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationSearchRepos.swift b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationSearchRepos.swift new file mode 100644 index 0000000000..5b76948182 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationSearchRepos.swift @@ -0,0 +1,33 @@ +// +// ToolsOzoneModerationSearchRepos.swift +// +// +// Created by Christopher Jr Riley on 2024-05-21. +// + +import Foundation + +extension ToolsOzoneLexicon.Moderation { + + /// The output model definition for searching for repositories as an administrator or moderator. + /// + /// - Note: According to the AT Protocol specifications: "Find repositories based on a + /// search term." + /// + /// - SeeAlso: This is based on the [`tools.ozone.moderation.searchRepos`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/searchRepos.json + public struct SearchRepositoryOutput: Codable { + + /// The mark used to indicate the starting point for the next set of results. Optional. + public let cursor: String? + + /// An array of repository views. + public let repositories: [OzoneModerationRepositoryView] + + enum CodingKeys: String, CodingKey { + case cursor + case repositories = "repos" + } + } +} From 5d5cd404f73d4087edcce5b9ae81ed8c8f652903 Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Tue, 21 May 2024 11:12:24 -0400 Subject: [PATCH 15/51] Change name of structs - "FeedGeneratorRecord" is changed to "GeneratorRecord." - "LabelerServiceRecord" is changed to "ServiceRecord." --- .../Models/Lexicons/app.bsky/Feed/AppBskyFeedGenerator.swift | 2 +- .../Lexicons/app.bsky/Labeler/AppBskyLabelerService.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGenerator.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGenerator.swift index 4604af8c30..14a322423c 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGenerator.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGenerator.swift @@ -18,7 +18,7 @@ extension AppBskyLexicon.Feed { /// - SeeAlso: This is based on the [`app.bsky.feed.generator`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/generator.json - public struct FeedGeneratorRecord: ATRecordProtocol { + public struct GeneratorRecord: ATRecordProtocol { /// The identifier of the lexicon. /// diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerService.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerService.swift index 01320b917b..ccb60fbdc4 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerService.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerService.swift @@ -17,7 +17,7 @@ extension AppBskyLexicon.Labeler { /// - SeeAlso: This is based on the [`app.bsky.labeler.service`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/labeler/service.json - public struct LabelerServiceRecord: ATRecordProtocol { + public struct ServiceRecord: ATRecordProtocol { /// The identifier of the lexicon. /// From 913b6ff22abffdc0ad830fb3d2e3aca7bf0f5bbe Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Tue, 21 May 2024 21:08:01 -0400 Subject: [PATCH 16/51] Prevent records from being re-added --- Sources/ATProtoKit/ATProtoKit.swift | 4 +++- .../SessionManager/ATProtocolConfiguration.swift | 1 + Sources/ATProtoKit/Utilities/ATRecordProtocol.swift | 7 +++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Sources/ATProtoKit/ATProtoKit.swift b/Sources/ATProtoKit/ATProtoKit.swift index 023ebf74a7..d3dc8bd739 100644 --- a/Sources/ATProtoKit/ATProtoKit.swift +++ b/Sources/ATProtoKit/ATProtoKit.swift @@ -135,6 +135,7 @@ public class ATProtoKit: ATProtoKitConfiguration { /// This will also handle some of the logging-related setup. The identifier will either be your /// project's `CFBundleIdentifier` or an identifier named /// `com.cjrriley.ATProtoKit`. However, you can manually override this. + /// /// - Parameters: /// - session: The authenticated user session within the AT Protocol. Optional. /// - canUseBlueskyRecords: Indicates whether Bluesky's lexicons should be used. @@ -149,8 +150,9 @@ public class ATProtoKit: ATProtoKitConfiguration { self.session = session self.logger = session?.logger ?? logger - if canUseBlueskyRecords { + if canUseBlueskyRecords && !ATRecordTypeRegistry.areBlueskyRecordsRegistered { _ = ATRecordTypeRegistry(types: self.recordLexicons) + ATRecordTypeRegistry.areBlueskyRecordsRegistered = false } } diff --git a/Sources/ATProtoKit/Networking/SessionManager/ATProtocolConfiguration.swift b/Sources/ATProtoKit/Networking/SessionManager/ATProtocolConfiguration.swift index 04806f168b..2abccbb6d2 100644 --- a/Sources/ATProtoKit/Networking/SessionManager/ATProtocolConfiguration.swift +++ b/Sources/ATProtoKit/Networking/SessionManager/ATProtocolConfiguration.swift @@ -82,6 +82,7 @@ public class ATProtocolConfiguration: ProtocolConfiguration { /// - SeeAlso: This is based on the [`com.atproto.server.createSession`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/createSession.json + /// /// - Parameter authenticationFactorToken: A token used for /// Two-Factor Authentication. Optional. /// - Returns: A `Result` containing ``UserSession`` on success or an `Error` on failure. diff --git a/Sources/ATProtoKit/Utilities/ATRecordProtocol.swift b/Sources/ATProtoKit/Utilities/ATRecordProtocol.swift index d069d3efb5..2e7077ad62 100644 --- a/Sources/ATProtoKit/Utilities/ATRecordProtocol.swift +++ b/Sources/ATProtoKit/Utilities/ATRecordProtocol.swift @@ -91,7 +91,14 @@ public struct ATRecordTypeRegistry { /// `struct` that was found if there's a match. public static var recordRegistry = [String: ATRecordProtocol.Type]() + /// Indicates whether any Bluesky-related `ATRecordProtocol`-conforming `struct`s have been + /// added to ``recordRegistry``. Defaults to `false`. + /// + /// - Warning: Don't touch this property; this should only be used for ``ATProtoKit``. + public static var areBlueskyRecordsRegistered = false + /// Initializes the registry with an array of record types. + /// /// - Parameter types: An array of ``ATRecordProtocol``-conforming `struct`s. public init(types: [ATRecordProtocol.Type]) { for type in types { From b262a78f50069c5c4c1dcffeb87049e240686058 Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Tue, 21 May 2024 22:32:13 -0400 Subject: [PATCH 17/51] Update API_GUIDELINES --- API_GUIDELINES.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/API_GUIDELINES.md b/API_GUIDELINES.md index 587facfcc2..79f3bca3de 100644 --- a/API_GUIDELINES.md +++ b/API_GUIDELINES.md @@ -417,4 +417,7 @@ _TBD..._ ``` - If there’s a `return` statement in the `do-catch` block, or if the query method is in there, the request and response methods should be beside each other. - If any additional method calls are being made, put them beside `createRequest()` and `sendRequest()` if they're strongly related to them. - +- In documentation, when referring to the following, you _must_ write them out exactly as shown: + - decentralized identifier (DID) + - content identifer (CID) + - Namespaced Identifier (NSID) From 0abb10b33aa90e51c3971c2357ce27a0f8f4d58f Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Thu, 23 May 2024 18:04:28 -0400 Subject: [PATCH 18/51] Fix struct names and documentation --- .../app.bsky/Actor/AppBskyActorDefs.swift | 159 +++++++++--------- .../Actor/AppBskyActorGetPreferences.swift | 2 + .../Actor/AppBskyActorGetProfile.swift | 2 +- .../Actor/AppBskyActorGetSuggestions.swift | 3 +- .../app.bsky/Actor/AppBskyActorProfile.swift | 2 +- .../Actor/AppBskyActorPutPreferences.swift | 2 +- .../Actor/AppBskyActorSearchActors.swift | 2 +- .../AppBskyActorSearchActorsTypeahead.swift | 4 +- .../app.bsky/Embed/AppBskyEmbedExternal.swift | 17 +- .../app.bsky/Embed/AppBskyEmbedImages.swift | 25 ++- .../app.bsky/Embed/AppBskyEmbedRecord.swift | 32 ++-- .../Embed/AppBskyEmbedRecordWithMedia.swift | 4 +- .../app.bsky/Feed/AppBskyFeedDefs.swift | 47 +++--- .../AppBskyFeedDescribeFeedGenerator.swift | 10 +- .../app.bsky/Feed/AppBskyFeedGenerator.swift | 2 +- .../Feed/AppBskyFeedGetActorFeeds.swift | 2 +- .../Feed/AppBskyFeedGetActorLikes.swift | 2 +- .../Feed/AppBskyFeedGetAuthorFeed.swift | 5 +- .../app.bsky/Feed/AppBskyFeedGetFeed.swift | 2 +- .../Feed/AppBskyFeedGetFeedGenerator.swift | 3 +- .../Feed/AppBskyFeedGetFeedGenerators.swift | 3 +- .../Feed/AppBskyFeedGetFeedSkeleton.swift | 2 +- .../app.bsky/Feed/AppBskyFeedGetLikes.swift | 20 ++- .../Feed/AppBskyFeedGetListFeed.swift | 3 +- .../Feed/AppBskyFeedGetPostThread.swift | 2 +- .../app.bsky/Feed/AppBskyFeedGetPosts.swift | 2 +- .../Feed/AppBskyFeedGetRepostedBy.swift | 5 +- .../Feed/AppBskyFeedGetSuggestedFeeds.swift | 3 +- .../Feed/AppBskyFeedGetTimeline.swift | 2 +- .../app.bsky/Feed/AppBskyFeedLike.swift | 2 +- .../app.bsky/Feed/AppBskyFeedPost.swift | 39 +++-- .../app.bsky/Feed/AppBskyFeedRepost.swift | 2 +- .../Feed/AppBskyFeedSearchPosts.swift | 2 +- .../Feed/AppBskyFeedSendInteractions.swift | 2 +- .../app.bsky/Feed/AppBskyFeedThreadgate.swift | 2 +- .../app.bsky/Graph/AppBskyGraphBlock.swift | 2 +- .../app.bsky/Graph/AppBskyGraphDefs.swift | 20 +-- .../app.bsky/Graph/AppBskyGraphFollow.swift | 3 +- .../Graph/AppBskyGraphGetBlocks.swift | 3 +- .../Graph/AppBskyGraphGetFollowers.swift | 2 +- .../Graph/AppBskyGraphGetFollows.swift | 3 +- .../app.bsky/Graph/AppBskyGraphGetList.swift | 2 +- .../Graph/AppBskyGraphGetListBlocks.swift | 3 +- .../Graph/AppBskyGraphGetListMutes.swift | 3 +- .../app.bsky/Graph/AppBskyGraphGetLists.swift | 3 +- .../app.bsky/Graph/AppBskyGraphGetMutes.swift | 5 +- .../Graph/AppBskyGraphGetRelationships.swift | 3 +- ...pBskyGraphGetSuggestedFollowsByActor.swift | 6 +- .../app.bsky/Graph/AppBskyGraphList.swift | 2 +- .../Graph/AppBskyGraphListblock.swift | 2 +- .../app.bsky/Graph/AppBskyGraphListitem.swift | 2 +- .../Graph/AppBskyGraphMuteActor.swift | 2 +- .../Graph/AppBskyGraphMuteActorList.swift | 2 +- .../Graph/AppBskyGraphUnmuteActor.swift | 2 +- .../Graph/AppBskyGraphUnmuteActorList.swift | 2 +- .../app.bsky/Labeler/AppBskyLabelerDefs.swift | 11 +- .../Labeler/AppBskyLabelerGetServices.swift | 2 +- .../Labeler/AppBskyLabelerService.swift | 2 +- .../AppBskyNotificationGetUnreadCount.swift | 2 +- ...AppBskyNotificationListNotifications.swift | 2 +- .../AppBskyNotificationRegisterPush.swift | 2 +- .../AppBskyNotificationUpdateSeen.swift | 4 +- .../RichText/AppBskyRichTextFacet.swift | 7 +- .../Unspecced/AppBskyUnspeccedDefs.swift | 4 +- ...skyUnspeccedGetPopularFeedGenerators.swift | 2 +- ...pBskyUnspeccedGetSuggestionsSkeleton.swift | 2 +- ...AppBskyUnspeccedGetTaggedSuggestions.swift | 2 +- ...AppBskyUnspeccedSearchActorsSkeleton.swift | 2 +- .../AppBskyUnspeccedSearchPostsSkeleton.swift | 2 +- .../Actor/ChatBskyActorDeclaration.swift | 2 +- .../chat.bsky/Actor/ChatBskyActorDefs.swift | 4 +- .../Actor/ChatBskyActorDeleteAccount.swift | 2 +- .../chat.bsky/Convo/ChatBskyConvoDefs.swift | 23 +-- .../ChatBskyConvoDeleteMessageForSelf.swift | 2 +- .../Convo/ChatBskyConvoGetConvo.swift | 2 +- .../ChatBskyConvoGetConvoForMembers.swift | 2 +- .../chat.bsky/Convo/ChatBskyConvoGetLog.swift | 2 +- .../Convo/ChatBskyConvoGetMessages.swift | 2 +- .../Convo/ChatBskyConvoLeaveConvo.swift | 4 +- .../Convo/ChatBskyConvoListConvo.swift | 2 +- .../Convo/ChatBskyConvoMuteConvo.swift | 6 +- .../Convo/ChatBskyConvoSendMessage.swift | 2 +- .../Convo/ChatBskyConvoSendMessageBatch.swift | 4 +- .../Convo/ChatBskyConvoUnmuteConvo.swift | 4 +- .../Convo/ChatBskyConvoUpdateRead.swift | 4 +- .../ChatBskyModerationGetActorMetadata.swift | 4 +- .../ChatBskyModerationGetMessageContext.swift | 2 +- .../ChatBskyModerationUpdateActorAccess.swift | 3 +- .../Admin/ComAtprotoAdminDefs.swift | 21 +-- .../Admin/ComAtprotoAdminDeleteAccount.swift | 4 +- ...ComAtprotoAdminDisableAccountInvites.swift | 5 +- .../ComAtprotoAdminDisableInviteCodes.swift | 6 +- .../ComAtprotoAdminEnableAccountInvites.swift | 3 +- .../ComAtprotoAdminGetAccountInfos.swift | 2 +- .../Admin/ComAtprotoAdminGetInviteCodes.swift | 2 +- .../ComAtprotoAdminGetSubjectStatus.swift | 2 +- ...mAtprotoAdminQueryModerationStatuses.swift | 3 +- .../Admin/ComAtprotoAdminSearchRepos.swift | 2 +- .../Admin/ComAtprotoAdminSendEmail.swift | 2 +- .../ComAtprotoAdminUpdateAccountEmail.swift | 5 +- .../ComAtprotoAdminUpdateAccountHandle.swift | 3 +- ...ComAtprotoAdminUpdateAccountPassword.swift | 3 +- .../ComAtprotoAdminUpdateSubjectStatus.swift | 8 +- ...IdentityGetRecommendedDidCredentials.swift | 6 +- ...IdentityRequestPlcOperationSignature.swift | 2 +- .../ComAtprotoIdentityResolveHandle.swift | 2 +- .../ComAtprotoIdentitySignPLCOperation.swift | 4 +- ...ComAtprotoIdentitySubmitPLCOperation.swift | 2 +- .../ComAtprotoIdentityUpdateHandle.swift | 4 +- .../Label/ComAtprotoLabelDefs.swift | 10 +- .../Label/ComAtprotoLabelQueryLabels.swift | 3 +- .../ComAtprotoModerationCreateReport.swift | 4 +- .../Moderation/ComAtprotoModerationDefs.swift | 2 +- .../Repo/ComAtProtoRepoStrongRef.swift | 2 +- .../Repo/ComAtprotoRepoApplyWrites.swift | 2 +- .../Repo/ComAtprotoRepoCreateRecord.swift | 2 +- .../Repo/ComAtprotoRepoDeleteRecord.swift | 2 +- .../Repo/ComAtprotoRepoDescribeRepo.swift | 2 +- .../Repo/ComAtprotoRepoGetRecord.swift | 26 +-- .../Repo/ComAtprotoRepoImportRepo.swift | 2 +- .../Repo/ComAtprotoRepoListMissingBlobs.swift | 3 +- .../Repo/ComAtprotoRepoListRecords.swift | 2 +- .../Repo/ComAtprotoRepoPutRecord.swift | 2 +- .../Repo/ComAtprotoRepoUploadBlob.swift | 5 +- .../ComAtprotoServerActivateAccount.swift | 2 +- .../ComAtprotoServerCheckAccountStatus.swift | 2 +- .../Server/ComAtprotoServerConfirmEmail.swift | 2 +- .../ComAtprotoServerCreateAccount.swift | 2 +- .../ComAtprotoServerCreateAppPassword.swift | 6 +- .../ComAtprotoServerCreateInviteCode.swift | 4 +- .../ComAtprotoServerCreateInviteCodes.swift | 9 +- .../ComAtprotoServerCreateSession.swift | 4 +- .../ComAtprotoServerDeactivateAccount.swift | 5 +- .../Server/ComAtprotoServerDefs.swift | 6 +- .../ComAtprotoServerDeleteAccount.swift | 2 +- .../ComAtprotoServerDescribeServer.swift | 4 +- ...omAtprotoServerGetAccountInviteCodes.swift | 2 +- .../ComAtprotoServerGetServiceAuth.swift | 2 +- .../ComAtprotoServerListAppPasswords.swift | 4 +- .../ComAtprotoServerRequestEmailUpdate.swift | 2 +- ...ComAtprotoServerRequestPasswordReset.swift | 2 +- .../ComAtprotoServerReserveSigningKey.swift | 4 +- .../ComAtprotoServerResetPassword.swift | 2 +- .../ComAtprotoServerRevokeAppPassword.swift | 4 +- .../Server/ComAtprotoServerUpdateEmail.swift | 2 +- .../Sync/ComAtprotoSyncCrawler.swift | 40 +++++ .../Sync/ComAtprotoSyncGetBlob.swift | 2 +- .../Sync/ComAtprotoSyncGetLatestCommit.swift | 2 +- .../Sync/ComAtprotoSyncListBlobs.swift | 2 +- .../Sync/ComAtprotoSyncListRepos.swift | 4 +- .../Temp/ComAtprotoTempCheckSignupQueue.swift | 3 +- ...mAtprotoTempRequestPhoneVerification.swift | 4 +- ...oolsOzoneCommunicationCreateTemplate.swift | 2 +- .../ToolsOzoneCommunicationDefs.swift | 2 +- ...oolsOzoneCommunicationDeleteTemplate.swift | 2 +- ...ToolsOzoneCommunicationListTemplates.swift | 2 +- ...oolsOzoneCommunicationUpdateTemplate.swift | 2 +- .../Moderation/ToolsOzoneModerationDefs.swift | 60 +++---- .../ToolsOzoneModerationEmitEvent.swift | 4 +- .../ToolsOzoneModerationQueryEvents.swift | 4 +- .../ToolsOzoneModerationQueryStatuses.swift | 4 +- .../ToolsOzoneModerationSearchRepos.swift | 2 +- 162 files changed, 509 insertions(+), 476 deletions(-) create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncCrawler.swift diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorDefs.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorDefs.swift index efdfb6e088..54470fbc7d 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorDefs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorDefs.swift @@ -9,7 +9,7 @@ import Foundation extension AppBskyLexicon.Actor { - /// A data model for a basic profile view definition. + /// A definition model for a basic profile view. /// /// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. /// @@ -89,7 +89,7 @@ extension AppBskyLexicon.Actor { } } - /// A data model for a profile view definition. + /// A definition model for a profile view. /// /// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. /// @@ -188,7 +188,7 @@ extension AppBskyLexicon.Actor { } } - /// A data model for a detailed profile view definition. + /// A definition model for a detailed profile view. /// /// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. /// @@ -314,8 +314,8 @@ extension AppBskyLexicon.Actor { case labels } } - - /// A data model definition for an actor's associated profile. + + /// A definition model for an actor's associated profile. /// /// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. /// @@ -337,7 +337,7 @@ extension AppBskyLexicon.Actor { case isActorLabeler = "labeler" } } - + /// A data model for an actor viewer state definition. /// /// - Note: From the AT Protocol specification: "Metadata about the requesting account's @@ -370,7 +370,7 @@ extension AppBskyLexicon.Actor { /// A URI which indicates the user is being followed by the requesting account. public let followedByURI: String? - + enum CodingKeys: String, CodingKey { case isMuted = "muted" case mutedByArray = "mutedByList" @@ -381,8 +381,8 @@ extension AppBskyLexicon.Actor { case followedByURI = "followedBy" } } - - /// A data model for a preferences definition. + + /// A definition model for preferences. /// /// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. /// @@ -396,8 +396,8 @@ extension AppBskyLexicon.Actor { self.preferences = preferences } } - - /// A data model for an "Adult Content" preference definition. + + /// A definition model for an "Adult Content" preference. /// /// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. /// @@ -408,21 +408,22 @@ extension AppBskyLexicon.Actor { /// /// - Warning: The value must not change. public let type: String = "app.bsky.actor.defs#adultContentPref" + /// Indicates whether the user will be able to see adult content in their feed. Set to /// `false` by default. public var isAdultContentEnabled: Bool = false - + public init(isAdultContentEnabled: Bool) { self.isAdultContentEnabled = isAdultContentEnabled } - + enum CodingKeys: String, CodingKey { case type = "$type" case isAdultContentEnabled = "enabled" } } - - /// A data model for a "Content Label" preference definition. + + /// A definition model for a "Content Label" preference. /// /// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. /// @@ -447,12 +448,13 @@ extension AppBskyLexicon.Actor { /// Indicates the visibility of the label's content. public let visibility: Visibility - + public init(labelerDID: String?, label: String, visibility: Visibility) { self.labelerDID = labelerDID self.label = label self.visibility = visibility } + /// Determines how visible a label's content is. public enum Visibility: String, Codable { @@ -468,7 +470,7 @@ extension AppBskyLexicon.Actor { /// Indicates the content is fully invisible by the user. case hide = "hide" } - + enum CodingKeys: String, CodingKey { case type = "$type" case labelerDID = "labelerDid" @@ -476,17 +478,17 @@ extension AppBskyLexicon.Actor { case visibility } } - - /// The data model for a saved feed. + + /// A definition model for a saved feed. /// /// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/defs.json public struct SavedFeed: Codable { - /// + /// The ID for the saved feed. public let feedID: String - + /// The type of feed generator is. /// /// This is usually referring to the location of the feed in context to the @@ -499,7 +501,6 @@ extension AppBskyLexicon.Actor { /// Indicated whether the saved feed generator is pinned. public let isPinned: Bool - /// The type of feed generator. /// /// This is usually referring to the location of the feed in context to the @@ -516,7 +517,7 @@ extension AppBskyLexicon.Actor { /// user account's timeline. case timeline } - + enum CodingKeys: String, CodingKey { case feedID = "id" case type @@ -525,18 +526,18 @@ extension AppBskyLexicon.Actor { } } - /// A data model for version 2 of a "Saved Feeds" preference definition. + /// A definition model for version 2 of a "Saved Feeds" preference. /// /// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/defs.json public struct SavedFeedPreferencesVersion2Definition: Codable { - + /// An array of saved feed generators. public let items: SavedFeed } - /// A data model for a "Saved Feeds" preference definition. + /// A definition model for a "Saved Feeds" preference. /// /// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. /// @@ -557,13 +558,13 @@ extension AppBskyLexicon.Actor { // TODO: Find out more about what this does. /// The index number of the timeline for the list of feeds. Optional. public var timelineIndex: Int? - + public init(pinned: [String], saved: [String], timelineIndex: Int?) { self.pinned = pinned self.saved = saved self.timelineIndex = timelineIndex } - + enum CodingKeys: String, CodingKey { case type = "$type" case pinned @@ -571,8 +572,8 @@ extension AppBskyLexicon.Actor { case timelineIndex } } - - /// A data model for a "Personal Details" preference definition. + + /// A definition model for a "Personal Details" preference. /// /// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. /// @@ -588,30 +589,30 @@ extension AppBskyLexicon.Actor { /// /// - Note: From the AT Protocol specification: "The birth date of account owner." @DateFormattingOptional public var birthDate: Date? - + public init(birthDate: Date) { self._birthDate = DateFormattingOptional(wrappedValue: birthDate) } - + public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) - + self.birthDate = try container.decodeIfPresent(DateFormattingOptional.self, forKey: .birthDate)?.wrappedValue } - + public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) - + try container.encodeIfPresent(self._birthDate, forKey: .birthDate) } - + enum CodingKeys: String, CodingKey { case type = "$type" case birthDate } } - - /// A data model for a "Feed View" preference definition. + + /// A definition model for a "Feed View" preference. /// /// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. /// @@ -656,7 +657,7 @@ extension AppBskyLexicon.Actor { /// /// - Note: From the AT Protocol specification: "Hide quote posts in the feed." public let areQuotePostsHidden: Bool? - + enum CodingKeys: String, CodingKey { case type = "$type" case feedURI = "feed" @@ -667,8 +668,8 @@ extension AppBskyLexicon.Actor { case areQuotePostsHidden = "hideQuotePosts" } } - - /// A data model for a "Thread View" preference definition. + + /// A definition model for a "Thread View" preference. /// /// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. /// @@ -690,7 +691,7 @@ extension AppBskyLexicon.Actor { /// - Note: From the AT Protocol specification: "Show followed users at the top of /// all replies." public let areFollowedUsersPrioritized: Bool? - + /// The sorting mode for a thread. public enum SortingMode: String, Codable { @@ -707,15 +708,15 @@ extension AppBskyLexicon.Actor { /// Indicates the thread will be completely random. case random = "random" } - + enum CodingKeys: String, CodingKey { case type = "$type" case sortingMode = "sort" case areFollowedUsersPrioritized = "prioritizeFollowedUsers" } } - - /// A data model for an "Interest View" preference definition. + + /// A definition model for an "Interest View" preference. /// /// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. /// @@ -735,20 +736,20 @@ extension AppBskyLexicon.Actor { /// - Important: Current maximum limit is 100 tags. Current maximum length for each tag /// name is 64 characters. public let tags: [String] - + public init(tags: [String]) { self.tags = tags } - + public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) - + self.tags = try container.decode([String].self, forKey: .tags) } - + public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) - + // Truncate `tags` to 640 characters before encoding. // `maxGraphemes`'s limit is 64, but `String.count` should respect that limit implictly. // Then, truncate `tags` to 100 items before encoding. @@ -756,37 +757,37 @@ extension AppBskyLexicon.Actor { self.tags.map { $0.truncated(toLength: 640) }, withContainer: &container, forKey: .tags, upToLength: 100) } - + enum CodingKeys: String, CodingKey { case type = "$type" case tags } } - - /// A data model for a definition of the muted word's target. + + /// A definition model for the muted word's target. /// /// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/defs.json public enum MutedWordTarget: Codable { - + /// Indicates the muted word is within the content itself. case content - + /// Indicates the muted word is a tag. case tag - + /// Indicates the muted word is located at an unknown area. /// /// This case shouldn't be used. If it does appear, then Bluesky may have updated /// something that ATProtoKit doesn't yet recognize. case other(String) - + public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() let value = try container.decode(String.self) - + switch value { case "content": self = .content @@ -796,7 +797,7 @@ extension AppBskyLexicon.Actor { self = .other(value) } } - + public func encode(to encoder: Encoder) throws { var container = encoder.singleValueContainer() switch self { @@ -812,8 +813,8 @@ extension AppBskyLexicon.Actor { } } } - - /// A data model for a muted word definition. + + /// A definition model for a muted word. /// /// - Note: According to the AT Protocol specifications: "A word that the account owner /// has muted." @@ -822,41 +823,41 @@ extension AppBskyLexicon.Actor { /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/defs.json public struct MutedWord: Codable { - + /// The word to mute. public let value: String /// An array of intended targets for the muted word. public let targets: [MutedWordTarget] - + public init(value: String, targets: [MutedWordTarget]) { self.value = value self.targets = targets } - + public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) - + self.value = try container.decode(String.self, forKey: .value) self.targets = try container.decode([MutedWordTarget].self, forKey: .targets) } - + public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) - + // Truncate `value` to 1000 characters before decoding // `maxGraphemes`'s limit is 100, but `String.count` should respect that limit try truncatedEncode(self.value, withContainer: &container, forKey: .value, upToLength: 1000) try container.encode(self.targets, forKey: .targets) } - + enum CodingKeys: CodingKey { case value case targets } } - - /// A data model for a "Muted Words" preference definition. + + /// A definition model for a "Muted Words" preference. /// /// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. /// @@ -873,14 +874,14 @@ extension AppBskyLexicon.Actor { /// - Note: According to the AT Protocol specifications: "A list of words the account /// owner has muted." public let mutedItems: [MutedWord] - + enum CodingKeys: String, CodingKey { case type = "$type" case mutedItems = "items" } } - - /// A data model for a "Hidden Posts" preference definition. + + /// A definition model for a "Hidden Posts" preference. /// /// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. /// @@ -897,14 +898,14 @@ extension AppBskyLexicon.Actor { /// - Note: According to the AT Protocol specifications: "A list of URIs of posts the /// account owner has hidden." public let items: [String] - + enum CodingKeys: String, CodingKey { case type = "$type" case items } } - - /// A data model for a "Labelers" preference definition. + + /// A definition model for a "Labelers" preference. /// /// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. /// @@ -914,8 +915,8 @@ extension AppBskyLexicon.Actor { /// An array of labeler items. public let labelers: [String] } - - /// A data model definition for a labeler item. + + /// A definition model for a labeler item. /// /// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. /// @@ -924,7 +925,7 @@ extension AppBskyLexicon.Actor { /// The decentralized identifier (DID) of the labeler. public let labelerDID: String - + enum CodingKeys: String, CodingKey { case labelerDID = "did" } diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorGetPreferences.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorGetPreferences.swift index d6b957a045..53765efd14 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorGetPreferences.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorGetPreferences.swift @@ -8,6 +8,7 @@ import Foundation extension AppBskyLexicon.Actor { + /// An output data model definition for the output of getting preferences. /// /// - Note: According to the AT Protocol specifications: "Get private preferences attached to @@ -18,6 +19,7 @@ extension AppBskyLexicon.Actor { /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/getPreferences.json public struct GetPreferencesOutput: Codable { + /// The list of preferences in the user's account. public let preference: PreferencesDefinition } diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorGetProfile.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorGetProfile.swift index 1f0425681f..0897d1fe5e 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorGetProfile.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorGetProfile.swift @@ -17,7 +17,7 @@ extension AppBskyLexicon.Actor { /// - SeeAlso: This is based on the [`app.bsky.actor.getProfile`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/getProfile.json - public struct ActorGetProfileOutput: Codable { + public struct GetProfileOutput: Codable { /// A detailed profile view of the user. public let actorProfileView: ProfileViewDetailedDefinition diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorGetSuggestions.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorGetSuggestions.swift index 21833f386a..30ba735bca 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorGetSuggestions.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorGetSuggestions.swift @@ -8,6 +8,7 @@ import Foundation extension AppBskyLexicon.Actor { + /// A data model for the output of the list of suggested users to follow. /// /// - Note: According to the AT Protocol specifications: "Get a list of suggested actors. @@ -16,7 +17,7 @@ extension AppBskyLexicon.Actor { /// - SeeAlso: This is based on the [`app.bsky.actor.getSuggestions`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/getSuggestions.json - public struct ActorGetSuggestionsOutput: Codable { + public struct GetSuggestionsOutput: Codable { /// The mark used to indicate the starting point for the next set of results. Optional. public let cursor: String? diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorProfile.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorProfile.swift index 3677897f52..ad33d819d9 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorProfile.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorProfile.swift @@ -8,7 +8,7 @@ import Foundation extension AppBskyLexicon.Actor { - + /// The main data model definition for an actor. /// /// - Note: According to the AT Protocol specifications: "A declaration of a Bluesky diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorPutPreferences.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorPutPreferences.swift index d1619ac4b1..63af157e8d 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorPutPreferences.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorPutPreferences.swift @@ -18,7 +18,7 @@ extension AppBskyLexicon.Actor { /// A list of preferences by the user. public let preferences: [ATUnion.ActorPreferenceUnion] - + enum CodingKeys: String, CodingKey { case type = "$type" case preferences diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorSearchActors.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorSearchActors.swift index 20f9cd70e8..5e9aeacccc 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorSearchActors.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorSearchActors.swift @@ -15,7 +15,7 @@ extension AppBskyLexicon.Actor { /// - SeeAlso: This is based on the [`app.bsky.actor.searchActors`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/searchActors.json - public struct ActorSearchActorsOutput: Codable { + public struct SearchActorsOutput: Codable { /// The mark used to indicate the starting point for the next set of results. Optional. public let cursor: String diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorSearchActorsTypeahead.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorSearchActorsTypeahead.swift index b6e8e96d7b..a720c62153 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorSearchActorsTypeahead.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorSearchActorsTypeahead.swift @@ -8,14 +8,14 @@ import Foundation extension AppBskyLexicon.Actor { - + /// A data model definition for the output of searching for actors matching the prefixed /// search criteria. /// /// - SeeAlso: This is based on the [`app.bsky.actor.searchActorsTypeahead`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/searchActorsTypeahead.json - public struct ActorSearchActorsTypeaheadOutput: Codable { + public struct SearchActorsTypeaheadOutput: Codable { /// An array of actors. public let actors: [ActorProfileViewBasic] diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedExternal.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedExternal.swift index 969b812ed3..700b94276e 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedExternal.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedExternal.swift @@ -9,7 +9,7 @@ import Foundation extension AppBskyLexicon.Embed { - /// The main data model definition for external embeds. + /// A definition model for external embeds. /// /// - Note: According to the AT Protocol specifications: "A representation of some externally /// linked content (eg, a URL and 'card'), embedded in a Bluesky record (eg, a post)." @@ -26,12 +26,13 @@ extension AppBskyLexicon.Embed { /// The external content needed to be embeeded. public let external: External - + enum CodingKeys: String, CodingKey { case type = "$type" case external } } + // MARK: - /// A data model for an external definition. /// @@ -54,7 +55,7 @@ extension AppBskyLexicon.Embed { /// - Warning: The image size can't be higher than 1 MB. Failure to do so will result in /// the image failing to upload. public let thumbnailImage: UploadBlobOutput? - + enum CodingKeys: String, CodingKey { case embedURI = "uri" case title @@ -62,7 +63,7 @@ extension AppBskyLexicon.Embed { case thumbnailImage = "thumb" } } - + /// A data model for an external view definition. /// /// - SeeAlso: This is based on the [`app.bsky.embed.external`][github] lexicon. @@ -74,16 +75,16 @@ extension AppBskyLexicon.Embed { /// /// - Warning: The value must not change. public let type: String = "app.bsky.embed.external#view" - + /// The external content embedded in a post. public let external: ViewExternal - + enum CodingKeys: String, CodingKey { case type = "$type" case external } } - + /// A data model for a definition for the external content. public struct ViewExternal: Codable { @@ -98,7 +99,7 @@ extension AppBskyLexicon.Embed { /// The thumbnail image URL of the external content. public let thumbnailImageURL: URL? - + enum CodingKeys: String, CodingKey { case embedURI = "uri" case title diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedImages.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedImages.swift index d1ce4a0615..30631ad7cb 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedImages.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedImages.swift @@ -9,7 +9,7 @@ import Foundation extension AppBskyLexicon.Embed { - /// The main data model definition for image embeds. + /// A definition model for image embeds. /// /// - Note: According to the AT Protocol specifications: "A set of images embedded in a Bluesky /// record (eg, a post)." @@ -28,17 +28,17 @@ extension AppBskyLexicon.Embed { /// ///- Note: Current maximum upload count is 4 images. public let images: [Image] - + public init(images: [Image]) { self.images = images } - + enum CodingKeys: String, CodingKey { case type = "$type" case images } } - + // MARK: - /// A data model for an external definition. /// @@ -61,20 +61,20 @@ extension AppBskyLexicon.Embed { /// The aspect ratio of the image. Optional. public let aspectRatio: AspectRatio? - + public init(image: UploadBlobOutput, altText: String, aspectRatio: AspectRatio?) { self.image = image self.altText = altText self.aspectRatio = aspectRatio } - + enum CodingKeys: String, CodingKey { case image case altText = "alt" case aspectRatio } } - + /// A data model for the aspect ratio definition. /// /// - Note: From the AT Protocol specification: "width:height represents an aspect ratio. @@ -90,13 +90,13 @@ extension AppBskyLexicon.Embed { /// The height of the image. public let height: Int - + public init(width: Int, height: Int) { self.width = width self.height = height } } - + /// A data model for the embed images definition. /// /// - SeeAlso: This is based on the [`app.bsky.embed.images`][github] lexicon. @@ -111,7 +111,7 @@ extension AppBskyLexicon.Embed { /// An array of images to be viewed. public let images: [ViewImage] } - + /// A data model for a definition related to viewing an image. /// /// - SeeAlso: This is based on the [`app.bsky.embed.images`][github] lexicon. @@ -140,14 +140,14 @@ extension AppBskyLexicon.Embed { /// The aspect ratio of the image. Optional. public let aspectRatio: AspectRatio? - + public init(thumbnailImageURL: URL, fullSizeImageURL: URL, altText: String, aspectRatio: AspectRatio?) { self.thumbnailImageURL = thumbnailImageURL self.fullSizeImageURL = fullSizeImageURL self.altText = altText self.aspectRatio = aspectRatio } - + enum CodingKeys: String, CodingKey { case thumbnailImageURL = "thumb" case fullSizeImageURL = "fullsize" @@ -155,5 +155,4 @@ extension AppBskyLexicon.Embed { case aspectRatio } } - } diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedRecord.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedRecord.swift index 7381a37931..868486b367 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedRecord.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedRecord.swift @@ -9,7 +9,7 @@ import Foundation extension AppBskyLexicon.Embed { - /// The main data model definition for record embeds. + /// A definition model for record embeds. /// /// - Note: According to the AT Protocol specifications: "A representation of a record embedded /// in a Bluesky record (eg, a post). For example, a quote-post, or sharing a @@ -27,13 +27,13 @@ extension AppBskyLexicon.Embed { /// The strong reference of the record. public let record: StrongReference - + enum CodingKeys: String, CodingKey { case type = "$type" case record } } - + // MARK: - /// A data model for a view definition. /// @@ -55,7 +55,7 @@ extension AppBskyLexicon.Embed { case record } } - + /// A data model for a record definition in an embed. /// /// - SeeAlso: This is based on the [`app.bsky.embed.record`][github] lexicon. @@ -99,9 +99,9 @@ extension AppBskyLexicon.Embed { /// The date the record was last indexed. @DateFormatting public var indexedAt: Date - - public init(recordURI: String, cidHash: String, author: AppBskyLexicon.Actor.ProfileViewBasicDefinition, value: UnknownType, labels: [Label]?, replyCount: Int?, - repostCount: Int?, likeCount: Int?, embeds: [ATUnion.EmbedViewUnion]?, indexedAt: Date) { + + public init(recordURI: String, cidHash: String, author: AppBskyLexicon.Actor.ProfileViewBasicDefinition, value: UnknownType, labels: [Label]?, + replyCount: Int?, repostCount: Int?, likeCount: Int?, embeds: [ATUnion.EmbedViewUnion]?, indexedAt: Date) { self.recordURI = recordURI self.cidHash = cidHash self.author = author @@ -113,10 +113,10 @@ extension AppBskyLexicon.Embed { self.embeds = embeds self._indexedAt = DateFormatting(wrappedValue: indexedAt) } - + public init(from decoder: any Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) - + self.recordURI = try container.decode(String.self, forKey: .recordURI) self.cidHash = try container.decode(String.self, forKey: .cidHash) self.author = try container.decode(AppBskyLexicon.Actor.ProfileViewBasicDefinition.self, forKey: .author) @@ -128,10 +128,10 @@ extension AppBskyLexicon.Embed { self.embeds = try container.decodeIfPresent([ATUnion.EmbedViewUnion].self, forKey: .embeds) self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue } - + public func encode(to encoder: any Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) - + try container.encode(self.recordURI, forKey: .recordURI) try container.encode(self.cidHash, forKey: .cidHash) try container.encode(self.author, forKey: .author) @@ -143,7 +143,7 @@ extension AppBskyLexicon.Embed { try container.encodeIfPresent(self.embeds, forKey: .embeds) try container.encode(self._indexedAt, forKey: .indexedAt) } - + enum CodingKeys: String, CodingKey { case type = "$type" case recordURI = "uri" @@ -158,7 +158,7 @@ extension AppBskyLexicon.Embed { case indexedAt } } - + /// A data model for a definition of a record that was unable to be found. /// /// - SeeAlso: This is based on the [`app.bsky.embed.record`][github] lexicon. @@ -171,13 +171,13 @@ extension AppBskyLexicon.Embed { /// Indicates whether the record was found. public let isRecordNotFound: Bool - + enum CodingKeys: String, CodingKey { case recordURI = "uri" case isRecordNotFound = "notFound" } } - + /// A data model for a definition of a record that has been blocked. /// /// - SeeAlso: This is based on the [`app.bsky.embed.record`][github] lexicon. @@ -193,7 +193,7 @@ extension AppBskyLexicon.Embed { /// The author of the record. public let recordAuthor: FeedBlockedAuthor - + enum CodingKeys: String, CodingKey { case recordURI = "uri" case isRecordBlocked = "blocked" diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedRecordWithMedia.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedRecordWithMedia.swift index d3a7f5c83d..df50aa3746 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedRecordWithMedia.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedRecordWithMedia.swift @@ -9,7 +9,7 @@ import Foundation extension AppBskyLexicon.Embed { - /// The main data model definition for a record embedded with some form of compatible media. + /// A definition model for a record embedded with some form of compatible media. /// /// - Note: According to the AT Protocol specifications: "A representation of a record /// embedded in a Bluesky record (eg, a post), alongside other compatible embeds. For example, @@ -37,7 +37,7 @@ extension AppBskyLexicon.Embed { case media } } - + // MARK: - /// A data model for a definition which contains an embedded record and embedded media. /// diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedDefs.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedDefs.swift index 1ea91c83d4..ff61f13b14 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedDefs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedDefs.swift @@ -9,7 +9,7 @@ import Foundation extension AppBskyLexicon.Feed { - /// A data model for a post view definition. + /// A definition model for a post view. /// /// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. /// @@ -52,8 +52,9 @@ extension AppBskyLexicon.Feed { /// The ruleset of who can reply to the post. Optional. public var threadgate: ThreadgateViewDefinition? - public init(postURI: String, cidHash: String, author: AppBskyLexicon.Actor.ProfileViewBasicDefinition, record: UnknownType, embed: ATUnion.EmbedViewUnion?, replyCount: Int?, - repostCount: Int?, likeCount: Int?, indexedAt: Date, viewer: ViewerStateDefinition?, labels: [Label]?, threadgate: ThreadgateViewDefinition?) { + public init(postURI: String, cidHash: String, author: AppBskyLexicon.Actor.ProfileViewBasicDefinition, record: UnknownType, + embed: ATUnion.EmbedViewUnion?, replyCount: Int?, repostCount: Int?, likeCount: Int?, indexedAt: Date, viewer: ViewerStateDefinition?, + labels: [Label]?, threadgate: ThreadgateViewDefinition?) { self.postURI = postURI self.cidHash = cidHash self.author = author @@ -70,7 +71,7 @@ extension AppBskyLexicon.Feed { public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) - + self.postURI = try container.decode(String.self, forKey: .postURI) self.cidHash = try container.decode(String.self, forKey: .cidHash) self.author = try container.decode(AppBskyLexicon.Actor.ProfileViewBasicDefinition.self, forKey: .author) @@ -87,7 +88,7 @@ extension AppBskyLexicon.Feed { public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) - + try container.encode(self.postURI, forKey: .postURI) try container.encode(self.cidHash, forKey: .cidHash) try container.encode(self.author, forKey: .author) @@ -118,7 +119,7 @@ extension AppBskyLexicon.Feed { } } - /// A data model for a viewer state definition. + /// A definition model for a viewer state. /// /// - Note: According to the AT Protocol specifications: "Metadata about the requesting /// account's relationship with the subject content. Only has meaningful content for @@ -145,7 +146,7 @@ extension AppBskyLexicon.Feed { } } - /// A data model for a definition of a feed's view. + /// A definition model for a feed's view. /// /// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. /// @@ -203,7 +204,7 @@ extension AppBskyLexicon.Feed { } } - /// A data model for a reply reference definition. + /// A definition model for a reply reference. /// /// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. /// @@ -227,7 +228,7 @@ extension AppBskyLexicon.Feed { public let grandparentAuthor: AppBskyLexicon.Actor.ProfileViewBasicDefinition } - /// A data model for a definition for a very stripped down version of a repost. + /// A definition model for a very stripped down version of a repost. /// /// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. /// @@ -265,7 +266,7 @@ extension AppBskyLexicon.Feed { } } - /// A data model for a definition of a hydrated version of a repost. + /// A definition model for a hydrated version of a repost. /// /// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. /// @@ -282,7 +283,7 @@ extension AppBskyLexicon.Feed { public var replies: [ATUnion.ThreadPostUnion]? } - /// A data model for a definition of a post that may not have been found. + /// A definition model for a post that may not have been found. /// /// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. /// @@ -293,7 +294,7 @@ extension AppBskyLexicon.Feed { public let feedURI: String /// Indicates whether the post wasn't found. Defaults to `true`. - public private(set) var isNotFound: Bool = true + public private(set) var isNotFound: Bool public init(feedURI: String, isNotFound: Bool = true) { self.feedURI = feedURI @@ -313,7 +314,7 @@ extension AppBskyLexicon.Feed { } } - /// A data model for a definition of a post that may have been blocked. + /// A definition model for a post that may have been blocked. /// /// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. /// @@ -350,7 +351,7 @@ extension AppBskyLexicon.Feed { } } - /// The data model of a blocked author definition. + /// A definition model for a blocked author. /// /// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. /// @@ -369,7 +370,7 @@ extension AppBskyLexicon.Feed { } } - /// The data model of a feed generator definition. + /// A definition model for a feed geneator. /// /// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. /// @@ -497,7 +498,7 @@ extension AppBskyLexicon.Feed { } } - /// The data model of a definition for the viewer's state of the feed generator. + /// A definition model for the viewer's state of the feed generator. /// /// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. /// @@ -512,7 +513,11 @@ extension AppBskyLexicon.Feed { } } - /// The data model of a feed's skeleton + /// A definition model for a feed's skeleton. + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/defs.json public struct SkeletonFeedPostDefinition: Codable { /// The URI of the post in the feed generator. @@ -530,7 +535,7 @@ extension AppBskyLexicon.Feed { } } - /// The data model of a definition for a respost in a feed generator. + /// A definition model for a repost in a feed generator. /// /// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. /// @@ -547,7 +552,7 @@ extension AppBskyLexicon.Feed { } } - /// The data model of a feed threadgate view definition. + /// A definition model for a feed threadgate view. /// /// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. /// @@ -575,7 +580,7 @@ extension AppBskyLexicon.Feed { } } - /// The main data model definition for an interaction for an item in a feed generator. + /// A definition model for an interaction for an item in a feed generator. /// /// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. /// @@ -625,7 +630,7 @@ extension AppBskyLexicon.Feed { } } - /// A data model definition for an interaction event. + /// A definition model for an interaction event. /// /// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. /// diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedDescribeFeedGenerator.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedDescribeFeedGenerator.swift index 18fc0587b2..a779fe8fa5 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedDescribeFeedGenerator.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedDescribeFeedGenerator.swift @@ -9,7 +9,7 @@ import Foundation extension AppBskyLexicon.Feed { - /// A data model definition for the output ofretrieving information about a feed generator. + /// A definition model for the output ofretrieving information about a feed generator. /// /// - Note: According to the AT Protocol specifications: "Get information about a /// feed generator, including policies and offered feed URIs. Does not require auth; @@ -28,24 +28,24 @@ extension AppBskyLexicon.Feed { /// The URL of the Privacy Policy and Terms of Service. Optional. public let links: Links? - + enum CodingKeys: String, CodingKey { case atDID = "did" case feeds case links } - + /// A data model definiion for the feed generator. public struct Feed: Codable { /// The URI of the feed. public let feedURI: String - + enum CodingKeys: String, CodingKey { case feedURI = "uri" } } - + /// A data model definition for the Privacy Policy and Terms of Service URLs. public struct Links: Codable { diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGenerator.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGenerator.swift index 14a322423c..ac957e50a1 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGenerator.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGenerator.swift @@ -9,7 +9,7 @@ import Foundation extension AppBskyLexicon.Feed { - /// The main data model definition for a feed generator record. + /// A record model for a feed generator record. /// /// - Note: According to the AT Protocol specifications: "Record declaring of the existence of /// a feed generator, and containing metadata about it. The record can exist in diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetActorFeeds.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetActorFeeds.swift index f540db1ff3..1b6a4bae40 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetActorFeeds.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetActorFeeds.swift @@ -9,7 +9,7 @@ import Foundation extension AppBskyLexicon.Feed { - /// The main data model definition for the output of retrieving a feed list by a user. + /// An output model for the output of retrieving a feed list by a user. /// /// - Note: According to the AT Protocol specifications: "Get a list of feeds (feed generator /// records) created by the actor (in the actor's repo)." diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetActorLikes.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetActorLikes.swift index acb1edf2dd..c9408bd5fb 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetActorLikes.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetActorLikes.swift @@ -9,7 +9,7 @@ import Foundation extension AppBskyLexicon.Feed { - /// The main data model definition for the output of seeing all of a user account's likes. + /// An output model for seeing all of a user account's likes. /// /// - Note: According to the AT Protocol specifications: "Get a list of posts liked by an actor. /// Does not require auth." diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetAuthorFeed.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetAuthorFeed.swift index e212e87689..4b55b0d061 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetAuthorFeed.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetAuthorFeed.swift @@ -9,8 +9,7 @@ import Foundation extension AppBskyLexicon.Feed { - /// The main data model definition for the output of seeing the user account's posts - /// and reposts. + /// An output model for seeing the user account's posts and reposts. /// /// - Note: According to the AT Protocol specifications: "Get a view of an actor's /// 'author feed' (post and reposts by the author). Does not require auth." @@ -26,7 +25,7 @@ extension AppBskyLexicon.Feed { /// An array of like records. public let feed: [FeedViewPostDefinition] } - + /// Indicates the kind of combinations of posts and reposts for the feed's array. /// /// - Note: According to the AT Protocol specifications: "Combinations of post/repost types to diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeed.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeed.swift index 100a563f87..23ffe1fa17 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeed.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeed.swift @@ -9,7 +9,7 @@ import Foundation extension AppBskyLexicon.Feed { - /// The main data model definition for the output of viewing the selected feed generator. + /// An output model for viewing the selected feed generator. /// /// - Note: According to the AT Protocol specifications: "Get a hydrated feed from an actor's /// selected feed generator. Implemented by App View." diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeedGenerator.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeedGenerator.swift index 2e68e4101f..f7b4645c7f 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeedGenerator.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeedGenerator.swift @@ -9,8 +9,7 @@ import Foundation extension AppBskyLexicon.Feed { - /// The main data model definition for the output of getting information about a given - /// feed generator. + /// An output model for getting information about a given feed generator. /// /// - Note: According to the AT Protocol specifications: "Get information about a feed /// generator. Implemented by AppView." diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeedGenerators.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeedGenerators.swift index 1ad47f965b..e685b7b4e6 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeedGenerators.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeedGenerators.swift @@ -9,8 +9,7 @@ import Foundation extension AppBskyLexicon.Feed { - /// The main data model definition for the output of getting information about several - /// feed generators. + /// An output model for getting information about several feed generators. /// /// - Note: According to the AT Protocol specifications: "Get information about a list of /// feed generators." diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeedSkeleton.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeedSkeleton.swift index 0d7ecb8364..a914ca1988 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeedSkeleton.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeedSkeleton.swift @@ -9,7 +9,7 @@ import Foundation extension AppBskyLexicon.Feed { - /// The main data model definition for the output of getting a skeleton for a feed generator. + /// An output model for getting a skeleton for a feed generator. /// /// - Note: According to the AT Protocol specifications: "Get a skeleton of a feed provided /// by a feed generator. Auth is optional, depending on provider requirements, and provides the diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetLikes.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetLikes.swift index 0bce38cd8b..4c39fc1f23 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetLikes.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetLikes.swift @@ -9,7 +9,7 @@ import Foundation extension AppBskyLexicon.Feed { - /// The main data model definition for the output of retrieving like records of a specific subject. + /// An output model for etrieving like records of a specific subject. /// /// - Note: According to the AT Protocol specifications: "Get like records which reference a /// subject (by AT-URI and CID)." @@ -30,7 +30,7 @@ extension AppBskyLexicon.Feed { /// An array of like records. public let likes: [GetLikesLike] - + enum CodingKeys: String, CodingKey { case recordURI = "uri" case recordCID = "cid" @@ -38,8 +38,12 @@ extension AppBskyLexicon.Feed { case likes } } - - /// A data model definition of the like record itself. + + /// A data model definition of the like record itself. + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.getLikes`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getLikes.json public struct GetLikesLike: Codable { /// The date and time the like record was indexed. @@ -50,27 +54,27 @@ extension AppBskyLexicon.Feed { /// The user that created the like record. public let actor: ActorProfileView - + public init(indexedAt: Date, createdAt: Date, actor: ActorProfileView) { self._indexedAt = DateFormatting(wrappedValue: indexedAt) self._createdAt = DateFormatting(wrappedValue: createdAt) self.actor = actor } - + public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue self.actor = try container.decode(ActorProfileView.self, forKey: .actor) } - + public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(self._indexedAt, forKey: .indexedAt) try container.encode(self._createdAt, forKey: .createdAt) try container.encode(self.actor, forKey: .actor) } - + public enum CodingKeys: CodingKey { case indexedAt case createdAt diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetListFeed.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetListFeed.swift index 820e3319b0..20c09d86c8 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetListFeed.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetListFeed.swift @@ -9,8 +9,7 @@ import Foundation extension AppBskyLexicon.Feed { - /// The main data model definition for the output of retireving recent posts and reposts from - /// a given feed. + /// An output model for retireving recent posts and reposts from a given feed. /// /// - Note: According to the AT Protocol specifications: "Get a feed of recent posts from a /// list (posts and reposts from any actors on the list). Does not require auth." diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetPostThread.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetPostThread.swift index 4358f41630..eda5f79aca 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetPostThread.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetPostThread.swift @@ -9,7 +9,7 @@ import Foundation extension AppBskyLexicon.Feed { - /// The main data model definition for the output of retrieving a post thread. + /// An output model for retrieving a post thread. /// /// - Note: According to the AT Protocol specifications: "Get posts in a thread. Does not require /// auth, but additional metadata and filtering will be applied for authed requests." diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetPosts.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetPosts.swift index 10be09d734..2df466ef6e 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetPosts.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetPosts.swift @@ -9,7 +9,7 @@ import Foundation extension AppBskyLexicon.Feed { - /// The main data model definition for the output of getting a hydrated array of posts. + /// An output model for getting a hydrated array of posts. /// /// - Note: According to the AT Protocol specifications: "Gets post views for a specified list /// of posts (by AT-URI). This is sometimes referred to as 'hydrating' diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetRepostedBy.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetRepostedBy.swift index dfd0001619..dfec95b13b 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetRepostedBy.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetRepostedBy.swift @@ -9,8 +9,7 @@ import Foundation extension AppBskyLexicon.Feed { - /// The main data model definition for the output of retrieving an array of users who have - /// reposted the given post. + /// An output model for retrieving an array of users who have reposted the given post. /// /// - Note: According to the AT Protocol specifications: "Get a list of reposts for a /// given post." @@ -31,7 +30,7 @@ extension AppBskyLexicon.Feed { /// An array of user accounts who reported the post record. public let repostedBy: [AppBskyLexicon.Actor.ProfileViewDefinition] - + enum CodingKeys:String, CodingKey { case postURI = "uri" case postCID = "cid" diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetSuggestedFeeds.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetSuggestedFeeds.swift index 92789d461f..5c86a5cdc3 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetSuggestedFeeds.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetSuggestedFeeds.swift @@ -9,8 +9,7 @@ import Foundation extension AppBskyLexicon.Feed { - /// The main data model definition for the output of getting a list of feed generators - /// suggested for the user account. + /// An output model for getting a list of feed generators suggested for the user account. /// /// - Note: According to the AT Protocol specifications: "Get a list of suggested feeds /// (feed generators) for the requesting account." diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetTimeline.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetTimeline.swift index ec62698edb..c33b8e4e96 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetTimeline.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetTimeline.swift @@ -9,7 +9,7 @@ import Foundation extension AppBskyLexicon.Feed { - /// The main data model definition for the output of getting the user account's timeline. + /// An output model for getting the user account's timeline. /// /// - Note: According to the AT Protocol specifications: "Get a view of the requesting account's /// home timeline. This is expected to be some form of reverse-chronological feed." diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedLike.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedLike.swift index 984b3e929a..afa14e87ea 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedLike.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedLike.swift @@ -34,7 +34,7 @@ extension AppBskyLexicon.Feed { /// /// This is the date where the user "liked" a post. @DateFormatting public var createdAt: Date - + public init(subject: StrongReference, createdAt: Date) { self.subject = subject self._createdAt = DateFormatting(wrappedValue: createdAt) diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedPost.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedPost.swift index ae702c3e20..2c6e5f6ed6 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedPost.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedPost.swift @@ -37,10 +37,13 @@ extension AppBskyLexicon.Feed { /// - Note: According to the AT Protocol specifications: "Annotations of text (mentions, URLs, /// hashtags, etc)" public var facets: [AppBskyLexicon.RichText.Facet]? + /// The references to posts when replying. Optional. public var reply: PostReplyReference? + /// The embed of the post. Optional. public var embed: ATUnion.EmbedUnion? + /// An array of languages the post text contains. Optional. /// /// - Note: According to the AT Protocol specifications: "Indicates human language of post @@ -49,11 +52,13 @@ extension AppBskyLexicon.Feed { /// - Important: Current maximum length is 3 languages. This library will automatically /// truncate the `Array` to the maximum number of items if it does go over the limit. public var languages: [String]? + /// An array of user-defined labels. Optional. /// /// - Note: According to the AT Protocol specifications: "Self-label values for this post. /// Effectively content warnings." public var labels: ATUnion.FeedLabelUnion? + /// An array of user-defined tags. Optional. /// /// - Note: According to the AT Protocol specifications: "Additional hashtags, in addition to @@ -63,12 +68,13 @@ extension AppBskyLexicon.Feed { /// is 64 characters. This library will automatically truncate the `Array`and `String` /// respectively to the maximum length if it does go over the limit. public var tags: [String]? + /// The date the post was created. /// /// - Note: According to the AT Protocol specifications: "Client-declared timestamp when this /// post was originally created." @DateFormatting public var createdAt: Date - + public init(text: String, facets: [AppBskyLexicon.RichText.Facet]?, reply: PostReplyReference?, embed: ATUnion.EmbedUnion?, languages: [String]?, labels: ATUnion.FeedLabelUnion?, tags: [String]?, createdAt: Date) { self.text = text @@ -80,10 +86,10 @@ extension AppBskyLexicon.Feed { self.tags = tags self._createdAt = DateFormatting(wrappedValue: createdAt) } - + public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) - + self.text = try container.decode(String.self, forKey: .text) self.facets = try container.decodeIfPresent([AppBskyLexicon.RichText.Facet].self, forKey: .facets) self.reply = try container.decodeIfPresent(PostReplyReference.self, forKey: .reply) @@ -93,11 +99,10 @@ extension AppBskyLexicon.Feed { self.tags = try container.decodeIfPresent([String].self, forKey: .tags) self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue } - + public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) - - // try container.encode(self.type, forKey: .type) + try container.encode(self.text, forKey: .text) // Truncate `tags` to 3000 characters before encoding // `maxGraphemes`'s limit is 300, but `String.count` should respect that limit implictly @@ -108,17 +113,17 @@ extension AppBskyLexicon.Feed { // Truncate `langs` to 3 items before encoding. try truncatedEncodeIfPresent(self.languages, withContainer: &container, forKey: .languages, upToLength: 3) try container.encodeIfPresent(self.labels, forKey: .labels) - + // Truncate `tags` to 640 characters before encoding // `maxGraphemes`'s limit is 64, but `String.count` should respect that limit implictly // Then, truncate `tags` to 8 items before encoding try truncatedEncodeIfPresent( self.tags.map { $0.truncated(toLength: 640) }, withContainer: &container, forKey: .tags, upToLength: 8) - + try container.encode(self._createdAt, forKey: .createdAt) } - + enum CodingKeys: String, CodingKey { case type = "$type" case text @@ -132,7 +137,7 @@ extension AppBskyLexicon.Feed { case createdAt } } - + // MARK: - /// A data model for a reply reference definition. /// @@ -140,33 +145,35 @@ extension AppBskyLexicon.Feed { /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/post.json public struct PostReplyReference: Codable { + /// The original post of the thread. public let root: StrongReference + /// The direct post that the user's post is replying to. /// /// - Note: If `parent` and `root` are identical, the post is a direct reply to the original /// post of the thread. public let parent: StrongReference - + public init(root: StrongReference, parent: StrongReference) { self.root = root self.parent = parent } - + public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) - + self.root = try container.decode(StrongReference.self, forKey: .root) self.parent = try container.decode(StrongReference.self, forKey: .parent) } - + public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) - + try container.encode(self.root, forKey: .root) try container.encode(self.parent, forKey: .parent) } - + enum CodingKeys: CodingKey { case root case parent diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedRepost.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedRepost.swift index e797e4130f..a9602aed63 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedRepost.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedRepost.swift @@ -39,6 +39,7 @@ extension AppBskyLexicon.Feed { public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) + self.subject = try container.decode(StrongReference.self, forKey: .subject) self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue } @@ -56,5 +57,4 @@ extension AppBskyLexicon.Feed { case createdAt } } - } diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedSearchPosts.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedSearchPosts.swift index 35a45905dc..9e6810b6bf 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedSearchPosts.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedSearchPosts.swift @@ -9,7 +9,7 @@ import Foundation extension AppBskyLexicon.Feed { - /// The main data model definition for the output of the results of the post search query. + /// An output model for the results of the post search query. /// /// - Note: According to the AT Protocol specifications: "Find posts matching search criteria, /// returning views of those posts." diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedSendInteractions.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedSendInteractions.swift index dfdb337359..d8b98d4b54 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedSendInteractions.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedSendInteractions.swift @@ -23,7 +23,7 @@ extension AppBskyLexicon.Feed { public let interactions: [InteractionDefinition] } - /// The output model definition for sending interactions to a feed generator. + /// An output model for sending interactions to a feed generator. /// /// - SeeAlso: This is based on the [`app.bsky.feed.sendInteractions`][github] lexicon. /// diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedThreadgate.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedThreadgate.swift index c082fd61bf..30cee40ada 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedThreadgate.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedThreadgate.swift @@ -9,7 +9,7 @@ import Foundation extension AppBskyLexicon.Feed { - /// The main data model definition for a threadgate record. + /// A record model for a threadgate. /// /// - Note: According to the AT Protocol specifications: "Record defining interaction gating rules /// for a thread (aka, reply controls). The record key (rkey) of the threadgate record must match diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphBlock.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphBlock.swift index be67394afc..7d1e3d57ba 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphBlock.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphBlock.swift @@ -9,7 +9,7 @@ import Foundation extension AppBskyLexicon.Graph { - /// The main data model definition for a block record. + /// A record model for a block. /// /// - Note: According to the AT Protocol specifications: "Record declaring a 'block' /// relationship against another account. NOTE: blocks are public in Bluesky; see diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphDefs.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphDefs.swift index cf230bf931..87b0a05baa 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphDefs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphDefs.swift @@ -9,7 +9,7 @@ import Foundation extension AppBskyLexicon.Graph { - /// A data model for a basic list view definition. + /// A definition model for a basic list view. /// /// - SeeAlso: This is based on the [`app.bsky.graph.defs`][github] lexicon. /// @@ -69,7 +69,6 @@ extension AppBskyLexicon.Graph { try container.encode(self.actorURI, forKey: .actorURI) try container.encode(self.cidHash, forKey: .cidHash) try container.encode(self.name, forKey: .name) - // try truncatedEncode(self.name, withContainer: &container, forKey: .name, upToLength: 64) try container.encode(self.purpose, forKey: .purpose) try container.encodeIfPresent(self.avatarImageURL, forKey: .avatarImageURL) @@ -88,7 +87,7 @@ extension AppBskyLexicon.Graph { } } - /// A data model for a definition of the view of a user list. + /// A definition model for the view of a user list. /// /// - SeeAlso: This is based on the [`app.bsky.graph.defs`][github] lexicon. /// @@ -193,7 +192,7 @@ extension AppBskyLexicon.Graph { } } - /// A data model for the definition of an item with in a user list. + /// A definition model for an item with in a user list. /// /// - SeeAlso: This is based on the [`app.bsky.graph.defs`][github] lexicon. /// @@ -212,7 +211,7 @@ extension AppBskyLexicon.Graph { } } - /// A data model of the definition of the user list's purpose. + /// A definition model for the user list's purpose. /// /// - SeeAlso: This is based on the [`app.bsky.graph.defs`][github] lexicon. /// @@ -230,8 +229,7 @@ extension AppBskyLexicon.Graph { case curatelist = "app.bsky.graph.defs#curatelist" } - - /// A data model of a definition for a viewer's state of a user list. + /// A definition model for a viewer's state of a user list. /// /// - SeeAlso: This is based on the [`app.bsky.graph.defs`][github] lexicon. /// @@ -250,7 +248,7 @@ extension AppBskyLexicon.Graph { } } - /// A data model for a definition of a user that may not have been found in the user list. + /// A definition model for a user that may not have been found in the user list. /// /// - SeeAlso: This is based on the [`app.bsky.graph.defs`][github] lexicon. /// @@ -259,8 +257,8 @@ extension AppBskyLexicon.Graph { /// The URI of the user. /// - /// - Note: According to the AT Protocol specifications: "indicates that a handle or DID could - /// not be resolved", + /// - Note: According to the AT Protocol specifications: "indicates that a handle or DID + /// could not be resolved". public let actorURI: String /// Indicates whether the user is not found. @@ -272,7 +270,7 @@ extension AppBskyLexicon.Graph { } } - /// A data model for the graph relationship definition. + /// A definition model for a graph relationship between two user accounts. /// /// - Note: According to the AT Protocol specifications: "lists the bi-directional graph /// relationships between one actor (not indicated in the object), and the target actors (the DID diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphFollow.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphFollow.swift index bb48c78efc..e09788c67a 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphFollow.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphFollow.swift @@ -8,7 +8,8 @@ import Foundation extension AppBskyLexicon.Graph { - /// The main data model definition for a follow record. + + /// A record model for a follow. /// /// - Note: According to the AT Protocol specifications: "Record declaring a social 'follow' /// relationship of another account. Duplicate follows will be ignored by the AppView." diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetBlocks.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetBlocks.swift index 2ea01aad34..e6ce463f26 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetBlocks.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetBlocks.swift @@ -9,8 +9,7 @@ import Foundation extension AppBskyLexicon.Graph { - /// The main data model definition for the output of getting all of the users that have been - /// blocked by the user account. + /// An output model for getting all of the users that have been blocked by the user account. /// /// - Note: According to the AT Protocol specifications: "Enumerates which accounts the /// requesting account is currently blocking. Requires auth." diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetFollowers.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetFollowers.swift index daffabf13d..0f3700f682 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetFollowers.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetFollowers.swift @@ -9,7 +9,7 @@ import Foundation extension AppBskyLexicon.Graph { - /// The main data model definition for the output of getting all of the user account's followers. + /// An output model for getting all of the user account's followers. /// /// - Note: According to the AT Protocol specifications: "Enumerates accounts which follow a /// specified account (actor)." diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetFollows.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetFollows.swift index 4da75bc6a2..82f76c7f75 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetFollows.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetFollows.swift @@ -9,8 +9,7 @@ import Foundation extension AppBskyLexicon.Graph { - /// The main data model definition for the output for grabbing all of the accounts the user - /// account follows. + /// An output model for for grabbing all of the accounts the user account follows. /// /// - Note: According to the AT Protocol specifications: "Enumerates accounts which a specified /// account (actor) follows." diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetList.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetList.swift index f3f9753be9..76403e0f0d 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetList.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetList.swift @@ -9,7 +9,7 @@ import Foundation extension AppBskyLexicon.Graph { - /// The main data model definition for the output of grabbing the list view. + /// An output model for grabbing the list view. /// /// - Note: According to the AT Protocol specifications: "Gets a 'view' (with additional context) /// of a specified list." diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetListBlocks.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetListBlocks.swift index fddeeead23..71a47f7678 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetListBlocks.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetListBlocks.swift @@ -9,8 +9,7 @@ import Foundation extension AppBskyLexicon.Graph { - /// The main data model definition for the output of getting the moderator lists that the user - /// account is blocking. + /// An output model for getting the moderator lists that the user account is blocking. /// /// - Note: According to the AT Protocol specifications: "Get mod lists that the requesting /// account (actor) is blocking. Requires auth." diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetListMutes.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetListMutes.swift index fcfbacb924..9f1d331bcd 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetListMutes.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetListMutes.swift @@ -9,8 +9,7 @@ import Foundation extension AppBskyLexicon.Graph { - /// The main data model definition for the output of grabbing the moderator list that the user - /// account is currently muting. + /// An output model for grabbing the moderator list that the user account is currently muting. /// /// - Note: According to the AT Protocol specifications: "Enumerates mod lists that the requesting /// account (actor) currently has muted. Requires auth." diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetLists.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetLists.swift index 6e399886ed..de9489d360 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetLists.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetLists.swift @@ -9,8 +9,7 @@ import Foundation extension AppBskyLexicon.Graph { - /// The main data model definition for the output of retrieving the lists created by the - /// user account. + /// An output model for retrieving the lists created by the user account. /// /// - Note: According to the AT Protocol specifications: "Enumerates the lists created by a /// specified account (actor)." diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetMutes.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetMutes.swift index 7ffa4ac129..6214553568 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetMutes.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetMutes.swift @@ -9,8 +9,7 @@ import Foundation extension AppBskyLexicon.Graph { - /// The main data model definition for the output of retrieving all accounts the user account - /// is currently muting. + /// An output model for retrieving all accounts the user account is currently muting. /// /// - Note: According to the AT Protocol specifications: "Enumerates accounts that the /// requesting account (actor) currently has muted. Requires auth." @@ -18,7 +17,7 @@ extension AppBskyLexicon.Graph { /// - SeeAlso: This is based on the [`app.bsky.graph.getMutes`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/getMutes.json - public struct GraphGetMutesOutput: Codable { + public struct GetMutesOutput: Codable { /// The mark used to indicate the starting point for the next set of results. Optional. public let cursor: String? diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetRelationships.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetRelationships.swift index 323e01b491..3a80717187 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetRelationships.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetRelationships.swift @@ -9,8 +9,7 @@ import Foundation extension AppBskyLexicon.Graph { - /// The main data model definition for the output of the public relationship between two - /// user accounts. + /// An output model for the public relationship between two user accounts. /// /// - Note: According to the AT Protocol specifications: "Enumerates public relationships between /// one account, and a list of other accounts. Does not require auth." diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetSuggestedFollowsByActor.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetSuggestedFollowsByActor.swift index 58a6195939..1d6cd96be3 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetSuggestedFollowsByActor.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetSuggestedFollowsByActor.swift @@ -9,8 +9,8 @@ import Foundation extension AppBskyLexicon.Graph { - /// The main data model definition for the output of getting the list of user accounts that - /// requesting user account is suggested to follow. + /// A output model for getting the list of user accounts that requesting user account is + /// suggested to follow. /// /// - Note: According to the AT Protocol specifications: "Enumerates follows similar to a given /// account (actor). Expected use is to recommend additional accounts immediately after @@ -19,7 +19,7 @@ extension AppBskyLexicon.Graph { /// - SeeAlso: This is based on the [`app.bsky.graph.getSuggestedFollowsByActor`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/getSuggestedFollowsByActor.json - public struct GraphGetSuggestedFollowsByActorOutput: Codable { + public struct GetSuggestedFollowsByActorOutput: Codable { /// An array of user accounts the requesting user account is suggested to follow. public let suggestions: [AppBskyLexicon.Actor.ProfileViewDefinition] diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphList.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphList.swift index f2609b5442..2b2c2010a1 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphList.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphList.swift @@ -9,7 +9,7 @@ import Foundation extension AppBskyLexicon.Graph { - /// The main data model definition for a list record. + /// A record model for a list. /// /// - Note: According to the AT Protocol specifications: "Record representing a list of /// accounts (actors). Scope includes both moderation-oriented lists and diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphListblock.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphListblock.swift index b620efc2cf..a91e0d3079 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphListblock.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphListblock.swift @@ -9,7 +9,7 @@ import Foundation extension AppBskyLexicon.Graph { - /// The main data model definition for a blocking list record. + /// A record model for a blocking list. /// /// - Note: According to the AT Protocol specifications: "Record representing a block /// relationship against an entire [...] list of accounts (actors)." diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphListitem.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphListitem.swift index 497cbf86e4..9a6e4109cc 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphListitem.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphListitem.swift @@ -9,7 +9,7 @@ import Foundation extension AppBskyLexicon.Graph { - /// The main data model definition for a list item record. + /// A record model for a list item. /// /// - Note: According to the AT Protocol specifications: "Record representing an account's /// inclusion on a specific list. The AppView will ignore duplicate listitem records." diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphMuteActor.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphMuteActor.swift index 2579c70d59..a13614bb74 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphMuteActor.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphMuteActor.swift @@ -9,7 +9,7 @@ import Foundation extension AppBskyLexicon.Graph { - /// The request body data model definition for muting a user account. + /// A request body model formuting a user account. /// /// - Note: According to the AT Protocol specifications: "Creates a mute relationship for the /// specified account. Mutes are private in Bluesky. Requires auth." diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphMuteActorList.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphMuteActorList.swift index 34649185c7..83577c24b6 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphMuteActorList.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphMuteActorList.swift @@ -9,7 +9,7 @@ import Foundation extension AppBskyLexicon.Graph { - /// The main data model definition for muting a list. + /// A request body model formuting a list. /// /// - Note: According to the AT Protocol specifications: "Creates a mute relationship for the /// specified list of accounts. Mutes are private in Bluesky. Requires auth." diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphUnmuteActor.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphUnmuteActor.swift index 149f259c6b..6ecab7847e 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphUnmuteActor.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphUnmuteActor.swift @@ -9,7 +9,7 @@ import Foundation extension AppBskyLexicon.Graph { - /// The main data model definition for unmuting a user account. + /// A request body model for unmuting a user account. /// /// - Note: According to the AT Protocol specifications: "Unmutes the specified account. /// Requires auth." diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphUnmuteActorList.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphUnmuteActorList.swift index fcfa22fe99..589f93d12e 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphUnmuteActorList.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphUnmuteActorList.swift @@ -9,7 +9,7 @@ import Foundation extension AppBskyLexicon.Graph { - /// The main data model definition for unmuting a list of user accounts. + /// A request body model for unmuting a list of user accounts. /// /// - Note: According to the AT Protocol specifications: "Unmutes the specified list of /// accounts. Requires auth." diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerDefs.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerDefs.swift index dc8c1882e7..f8f2ac1ad7 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerDefs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerDefs.swift @@ -9,7 +9,7 @@ import Foundation extension AppBskyLexicon.Labeler { - /// A data model definition for a labeler view. + /// A definition model for a labeler view. /// /// - SeeAlso: This is based on the [`app.bsky.labeler.defs`][github] lexicon. /// @@ -86,7 +86,7 @@ extension AppBskyLexicon.Labeler { } } - /// A data model definition for a detailed labeler view. + /// A definition model for a detailed labeler view. /// /// - SeeAlso: This is based on the [`app.bsky.labeler.defs`][github] lexicon. /// @@ -117,7 +117,8 @@ extension AppBskyLexicon.Labeler { /// An array of labels. Optional. public let labels: [Label]? - public init(labelerURI: String, labelerCIDHash: String, creator: AppBskyLexicon.Actor.ProfileViewDefinition, policies: LabelerPolicies, likeCount: Int?, viewer: LabelerViewerState?, indexedAt: Date, labels: [Label]?) { + public init(labelerURI: String, labelerCIDHash: String, creator: AppBskyLexicon.Actor.ProfileViewDefinition, policies: LabelerPolicies, + likeCount: Int?, viewer: LabelerViewerState?, indexedAt: Date, labels: [Label]?) { self.labelerURI = labelerURI self.labelerCIDHash = labelerCIDHash self.creator = creator @@ -170,7 +171,7 @@ extension AppBskyLexicon.Labeler { } } - /// A data model definition for a user account's view state for the labeler. + /// A definition model for a user account's view state for the labeler. /// /// - SeeAlso: This is based on the [`app.bsky.labeler.defs`][github] lexicon. /// @@ -181,7 +182,7 @@ extension AppBskyLexicon.Labeler { public let like: String } - /// A data model definition for a labeler's policies. + /// A definition model for a labeler's policies. /// /// - SeeAlso: This is based on the [`app.bsky.labeler.defs`][github] lexicon. /// diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerGetServices.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerGetServices.swift index 0057970c4e..8fc3a49cef 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerGetServices.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerGetServices.swift @@ -9,7 +9,7 @@ import Foundation extension AppBskyLexicon.Labeler { - /// The main data model definition for the output of the labeler service information. + /// An output model for the labeler service information. /// /// - Note: According to the AT Protocol specifications: "Get information about a list of /// labeler services." diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerService.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerService.swift index ccb60fbdc4..007b0878c2 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerService.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerService.swift @@ -9,7 +9,7 @@ import Foundation extension AppBskyLexicon.Labeler { - /// The main data model definition for a labeler service record. + /// A record model for a labeler service. /// /// - Note: According to the AT Protocol specifications: "A declaration of the existence of /// labeler service." diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/AppBskyNotificationGetUnreadCount.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/AppBskyNotificationGetUnreadCount.swift index f4a0e7da3a..302a99c5ea 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/AppBskyNotificationGetUnreadCount.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/AppBskyNotificationGetUnreadCount.swift @@ -9,7 +9,7 @@ import Foundation extension AppBskyLexicon.Notification { - /// The main data model definition for the output of counting the unread notifications. + /// An output model for counting the unread notifications. /// /// - Note: According to the AT Protocol specifications: "Count the number of unread /// notifications for the requesting account. Requires auth." diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/AppBskyNotificationListNotifications.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/AppBskyNotificationListNotifications.swift index 55fc199566..d9070cad78 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/AppBskyNotificationListNotifications.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/AppBskyNotificationListNotifications.swift @@ -9,7 +9,7 @@ import Foundation extension AppBskyLexicon.Notification { - /// The main data model definition for the output of listing notifications. + /// An output model for listing notifications. /// /// - Note: According to the AT Protocol specifications: "Enumerate notifications for the /// requesting account. Requires auth." diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/AppBskyNotificationRegisterPush.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/AppBskyNotificationRegisterPush.swift index 639c089e73..3bd651400c 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/AppBskyNotificationRegisterPush.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/AppBskyNotificationRegisterPush.swift @@ -9,7 +9,7 @@ import Foundation extension AppBskyLexicon.Notification { - /// The main data model definition for registering push notifications. + /// An output model for registering push notifications. /// /// - Note: According to the AT Protocol specifications: "Register to receive /// push notifications, via a specified service, for the requesting account. diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/AppBskyNotificationUpdateSeen.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/AppBskyNotificationUpdateSeen.swift index 64a7da6cd2..09556350d5 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/AppBskyNotificationUpdateSeen.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/AppBskyNotificationUpdateSeen.swift @@ -9,7 +9,7 @@ import Foundation extension AppBskyLexicon.Notification { - /// The main data model definition for updating the server of the user seeing the notification. + /// A request body model for updating the server of the user seeing the notification. /// /// - Note: According to the AT Protocol specifications: "Notify server that the requesting /// account has seen notifications. Requires auth." @@ -17,7 +17,7 @@ extension AppBskyLexicon.Notification { /// - SeeAlso: This is based on the [`app.bsky.notification.updateSeen`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/notification/updateSeen.json - public struct NotificationUpdateSeen: Codable { + public struct NotificationUpdateSeenRequestBody: Codable { /// The date and time the notification was seen by the user account. @DateFormatting public var seenAt: Date diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/RichText/AppBskyRichTextFacet.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/RichText/AppBskyRichTextFacet.swift index 6ae27c005c..2a39d13293 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/RichText/AppBskyRichTextFacet.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/RichText/AppBskyRichTextFacet.swift @@ -38,7 +38,6 @@ extension AppBskyLexicon.RichText { } public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(self.index, forKey: .index) @@ -78,12 +77,14 @@ extension AppBskyLexicon.RichText { public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) + self.byteStart = try container.decode(Int.self, forKey: .byteStart) self.byteEnd = try container.decode(Int.self, forKey: .byteEnd) } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(self.byteStart, forKey: .byteStart) try container.encode(self.byteEnd, forKey: .byteEnd) } @@ -107,7 +108,6 @@ extension AppBskyLexicon.RichText { static var type: String { get } } - /// A data model for the Mention feature definition. /// /// - Note: According to the AT Protocol specifications: "Facet feature for mention of @@ -151,7 +151,6 @@ extension AppBskyLexicon.RichText { } } - /// A data model for the Link feature definition. /// /// - Note: According to the AT Protocol specifications: "Facet feature for a URL. The text URL @@ -210,7 +209,7 @@ extension AppBskyLexicon.RichText { /// - Warning: The value must not change. public static var type: String = "app.bsky.richtext.facet#tag" - /// The + /// The name of the tag. public let tag: String public init(tag: String) { diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedDefs.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedDefs.swift index 68b9de9993..2681e808a5 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedDefs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedDefs.swift @@ -9,7 +9,7 @@ import Foundation extension AppBskyLexicon.Unspecced { - /// A data model definition for a skeleton search post. + /// A definition model for a skeleton search post. /// /// - Important: This is an unspecced model, and as such, this is highly volatile and may /// change or be removed at any time. Use at your own risk. @@ -27,7 +27,7 @@ extension AppBskyLexicon.Unspecced { } } - /// A data model definition for a skeleton search post. + /// A definition model for a skeleton search post. /// /// - Important: This is an unspecced model, and as such, this is highly volatile and may /// change or be removed at any time. Use at your own risk. diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedGetPopularFeedGenerators.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedGetPopularFeedGenerators.swift index aa1fe94b5d..1b76415034 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedGetPopularFeedGenerators.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedGetPopularFeedGenerators.swift @@ -9,7 +9,7 @@ import Foundation extension AppBskyLexicon.Unspecced { - /// The main data model definition for the output of globally popular feed generators. + /// An output model for globally popular feed generators. /// /// - Note: According to the AT Protocol specifications: "An unspecced view of globally /// popular feed generators." diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedGetSuggestionsSkeleton.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedGetSuggestionsSkeleton.swift index 21200454bb..80bf3bc04c 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedGetSuggestionsSkeleton.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedGetSuggestionsSkeleton.swift @@ -9,7 +9,7 @@ import Foundation extension AppBskyLexicon.Unspecced { - /// The main data model definition for getting a skeleton of suggestion of actors. + /// An output model for getting a skeleton of suggestion of actors. /// /// - Note: According to the AT Protocol specifications: "Get a skeleton of suggested actors. /// Intended to be called and then hydrated through app.bsky.actor.getSuggestions." diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedGetTaggedSuggestions.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedGetTaggedSuggestions.swift index 26e538d273..8c9f316719 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedGetTaggedSuggestions.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedGetTaggedSuggestions.swift @@ -9,7 +9,7 @@ import Foundation extension AppBskyLexicon.Unspecced { - /// The main data model definition for the output of getting tagged suggestions. + /// An output model for getting tagged suggestions. /// /// - Note: According to the AT Protocol specifications: "Get a list of suggestions (feeds /// and users) tagged with categories." diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedSearchActorsSkeleton.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedSearchActorsSkeleton.swift index b0be16dd0e..197339f925 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedSearchActorsSkeleton.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedSearchActorsSkeleton.swift @@ -9,7 +9,7 @@ import Foundation extension AppBskyLexicon.Unspecced { - /// The main data model definition for the output of retrieving the skeleton results of actors (users). + /// An output model for retrieving the skeleton results of actors (users). /// /// - Important: This is an unspecced model, and as such, this is highly volatile and may /// change or be removed at any time. Use at your own risk. diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedSearchPostsSkeleton.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedSearchPostsSkeleton.swift index 89ef30fe5d..48fc8c9cb9 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedSearchPostsSkeleton.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedSearchPostsSkeleton.swift @@ -9,7 +9,7 @@ import Foundation extension AppBskyLexicon.Unspecced { - /// The main data model definition for the output of retrieving the skeleton results of posts. + /// An output model for retrieving the skeleton results of posts. /// /// - Important: This is an unspecced model, and as such, this is highly volatile and may /// change or be removed at any time. Use at your own risk. diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Actor/ChatBskyActorDeclaration.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Actor/ChatBskyActorDeclaration.swift index 55b6fd4dbd..5e1e670e6a 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Actor/ChatBskyActorDeclaration.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Actor/ChatBskyActorDeclaration.swift @@ -9,7 +9,7 @@ import Foundation extension ChatBskyLexicon.Actor { - /// The main data model definition for a Bluesky chat account. + /// A record model for a Bluesky chat account. /// /// - Note: According to the AT Protocol specifications: "A declaration of a Bluesky /// chat account." diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Actor/ChatBskyActorDefs.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Actor/ChatBskyActorDefs.swift index d3bb7870e6..d2b1ad1c0a 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Actor/ChatBskyActorDefs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Actor/ChatBskyActorDefs.swift @@ -9,13 +9,13 @@ import Foundation extension ChatBskyLexicon.Actor { - /// The main data model for a basic profile view definition. + /// A definition model for a basic profile view. /// /// - SeeAlso: This is based on the [`chat.bsky.actor.defs`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/actor/defs.json public struct ProfileViewBasicDefinition: Codable { - + /// The decentralized identifier (DID) of the user. public let actorDID: String diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Actor/ChatBskyActorDeleteAccount.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Actor/ChatBskyActorDeleteAccount.swift index 2bb5760f25..722936223f 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Actor/ChatBskyActorDeleteAccount.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Actor/ChatBskyActorDeleteAccount.swift @@ -9,7 +9,7 @@ import Foundation extension ChatBskyLexicon.Actor { - /// The request body data model definition for deleting an account. + /// A request body model for deleting an account. /// /// - SeeAlso: This is based on the [`chat.bsky.actor.deleteAccount`][github] lexicon. /// diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoDefs.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoDefs.swift index 57a2a116f6..20a9ef40eb 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoDefs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoDefs.swift @@ -9,7 +9,7 @@ import Foundation extension ChatBskyLexicon.Conversation { - /// The main data model definition for a messafe reference. + /// A definition model for a message reference. /// /// - SeeAlso: This is based on the [`chat.bsky.convo.defs`][github] lexicon. /// @@ -32,7 +32,7 @@ extension ChatBskyLexicon.Conversation { } } - /// The main data model definition for a message. + /// A definition model for a message. /// /// - SeeAlso: This is based on the [`chat.bsky.convo.defs`][github] lexicon. /// @@ -70,7 +70,7 @@ extension ChatBskyLexicon.Conversation { } } - /// The main data model definition for a message view. + /// A definition model for a message view. /// /// - SeeAlso: This is based on the [`chat.bsky.convo.defs`][github] lexicon. /// @@ -103,7 +103,8 @@ extension ChatBskyLexicon.Conversation { /// The date and time the message was seen. @DateFormatting public var seenAt: Date - public init(messageID: String?, revision: String, text: String, facets: [AppBskyLexicon.RichText.Facet]?, embeds: [ATUnion.MessageEmbedUnion]?, sender: String, seenAt: Date) { + public init(messageID: String?, revision: String, text: String, facets: [AppBskyLexicon.RichText.Facet]?, + embeds: [ATUnion.MessageEmbedUnion]?, sender: String, seenAt: Date) { self.messageID = messageID self.revision = revision self.text = text @@ -150,7 +151,7 @@ extension ChatBskyLexicon.Conversation { } } - /// The main data model definition for a deleted message view. + /// A definition model for a deleted message view. /// /// - SeeAlso: This is based on the [`chat.bsky.convo.defs`][github] lexicon. /// @@ -202,7 +203,7 @@ extension ChatBskyLexicon.Conversation { } } - /// The main data model definition for the message view's sender. + /// A definition model for the message view's sender. /// /// - SeeAlso: This is based on the [`chat.bsky.convo.defs`][github] lexicon. /// @@ -217,7 +218,7 @@ extension ChatBskyLexicon.Conversation { } } - /// The main data model definition for a conversation view. + /// A definition model for a conversation view. /// /// - SeeAlso: This is based on the [`chat.bsky.convo.defs`][github] lexicon. /// @@ -252,7 +253,7 @@ extension ChatBskyLexicon.Conversation { } } - /// The main data model definition for a log for beginning the coversation. + /// A definition model for a log for beginning the coversation. /// /// - SeeAlso: This is based on the [`chat.bsky.convo.defs`][github] lexicon. /// @@ -271,7 +272,7 @@ extension ChatBskyLexicon.Conversation { } } - /// The main data model definition for a log for leaving the conversation. + /// A definition model for a log for leaving the conversation. /// /// - SeeAlso: This is based on the [`chat.bsky.convo.defs`][github] lexicon. /// @@ -290,7 +291,7 @@ extension ChatBskyLexicon.Conversation { } } - /// The main data model definition for a log for creating a message. + /// A definition model for a log for creating a message. /// /// - SeeAlso: This is based on the [`chat.bsky.convo.defs`][github] lexicon. /// @@ -313,7 +314,7 @@ extension ChatBskyLexicon.Conversation { } } - /// The main data model definition for a log for deleting a message. + /// A definition model for a log for deleting a message. /// /// - SeeAlso: This is based on the [`chat.bsky.convo.defs`][github] lexicon. /// diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoDeleteMessageForSelf.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoDeleteMessageForSelf.swift index 3056f567fa..d7f58ed5ec 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoDeleteMessageForSelf.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoDeleteMessageForSelf.swift @@ -9,7 +9,7 @@ import Foundation extension ChatBskyLexicon.Conversation { - /// The request body data model definition for a message reference. + /// A request body model for a message reference. /// /// - SeeAlso: This is based on the [`chat.bsky.convo.deleteMessageForSelf`][github] lexicon. /// diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetConvo.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetConvo.swift index 3a5205fb35..5e4356bb73 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetConvo.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetConvo.swift @@ -9,7 +9,7 @@ import Foundation extension ChatBskyLexicon.Conversation { - /// The data model definition for the output of a message reference. + /// An output model for a message reference. /// /// - SeeAlso: This is based on the [`chat.bsky.convo.getConvo`][github] lexicon. /// diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetConvoForMembers.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetConvoForMembers.swift index f0ce185169..ac4526453d 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetConvoForMembers.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetConvoForMembers.swift @@ -9,7 +9,7 @@ import Foundation extension ChatBskyLexicon.Conversation { - /// The data model definition for the output of getting a conversation for members. + /// An output model for getting a conversation for members. /// /// - SeeAlso: This is based on the [`chat.bsky.convo.getConvoForMembers`][github] lexicon. /// diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetLog.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetLog.swift index b92ad49312..1a3c8355ba 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetLog.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetLog.swift @@ -9,7 +9,7 @@ import Foundation extension ChatBskyLexicon.Conversation { - /// The data model definition for the output of getting logs. + /// An output model for getting logs. /// /// - SeeAlso: This is based on the [`chat.bsky.convo.getLog`][github] lexicon. /// diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetMessages.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetMessages.swift index 58e5a0adfe..43e515d6b6 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetMessages.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetMessages.swift @@ -9,7 +9,7 @@ import Foundation extension ChatBskyLexicon.Conversation { - /// The data model definition for the output of getting messages. + /// An output model for getting messages. /// /// - SeeAlso: This is based on the [`chat.bsky.convo.getMessages`][github] lexicon. /// diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoLeaveConvo.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoLeaveConvo.swift index f0cb69c3d2..284bf228f3 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoLeaveConvo.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoLeaveConvo.swift @@ -9,7 +9,7 @@ import Foundation extension ChatBskyLexicon.Conversation { - /// The request body data model definition for leaving a conversation. + /// A request body model for leaving a conversation. /// /// - SeeAlso: This is based on the [`chat.bsky.convo.leaveConvo`][github] lexicon. /// @@ -24,7 +24,7 @@ extension ChatBskyLexicon.Conversation { } } - /// The data model definition for the output of leaving a conversation. + /// An output model for leaving a conversation. /// /// - SeeAlso: This is based on the [`chat.bsky.convo.leaveConvo`][github] lexicon. /// diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoListConvo.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoListConvo.swift index 0bc9f32f18..7e049dcc91 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoListConvo.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoListConvo.swift @@ -9,7 +9,7 @@ import Foundation extension ChatBskyLexicon.Conversation { - /// The data model definition for the output of listing a conversation. + /// An output model for listing a conversation. /// /// - SeeAlso: This is based on the [`chat.bsky.convo.listConvos`][github] lexicon. /// diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoMuteConvo.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoMuteConvo.swift index faaf7853a3..453ae9ee7c 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoMuteConvo.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoMuteConvo.swift @@ -9,7 +9,7 @@ import Foundation extension ChatBskyLexicon.Conversation { - /// The request body data model definition for muting a conversation. + /// A request body model for muting a conversation. /// /// - SeeAlso: This is based on the [`chat.bsky.convo.muteConvo`][github] lexicon. /// @@ -24,13 +24,13 @@ extension ChatBskyLexicon.Conversation { } } - /// The data model definition for the output of muting a conversation. + /// An output model for muting a conversation. /// /// - SeeAlso: This is based on the [`chat.bsky.convo.muteConvo`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/muteConvo.json public struct MuteConversationOutput: Codable { - + /// The conversation itself. public let conversation: [ConversationViewDefinition] diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoSendMessage.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoSendMessage.swift index e23f330f27..1abeef91e2 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoSendMessage.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoSendMessage.swift @@ -9,7 +9,7 @@ import Foundation extension ChatBskyLexicon.Conversation { - /// The request body data model definition for sending a message. + /// A request body model for sending a message. /// /// - SeeAlso: This is based on the [`chat.bsky.convo.sendMessage`][github] lexicon. /// diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoSendMessageBatch.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoSendMessageBatch.swift index 02b6275bf9..06cb4ffa10 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoSendMessageBatch.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoSendMessageBatch.swift @@ -9,7 +9,7 @@ import Foundation extension ChatBskyLexicon.Conversation { - /// The request body data model definition for sending a message batch. + /// A request body model for sending a message batch. /// /// - SeeAlso: This is based on the [`chat.bsky.convo.sendMessageBatch`][github] lexicon. /// @@ -26,7 +26,7 @@ extension ChatBskyLexicon.Conversation { } } - /// The data model definition for the output of sending a message batch. + /// An output model for sending a message batch. /// /// - SeeAlso: This is based on the [`chat.bsky.convo.sendMessageBatch`][github] lexicon. /// diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoUnmuteConvo.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoUnmuteConvo.swift index a135b0d7b3..7d300aea10 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoUnmuteConvo.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoUnmuteConvo.swift @@ -9,7 +9,7 @@ import Foundation extension ChatBskyLexicon.Conversation { - /// The request body data model definition for unmuting a conversation. + /// A request body model for unmuting a conversation. /// /// - SeeAlso: This is based on the [`chat.bsky.convo.unmuteConvo`][github] lexicon. /// @@ -24,7 +24,7 @@ extension ChatBskyLexicon.Conversation { } } - /// The data model definition for the output of unmuting a conversation. + /// An output model for unmuting a conversation. /// /// - SeeAlso: This is based on the [`chat.bsky.convo.unmuteConvo`][github] lexicon. /// diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoUpdateRead.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoUpdateRead.swift index fcda4ee1a1..582cdb7249 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoUpdateRead.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoUpdateRead.swift @@ -9,7 +9,7 @@ import Foundation extension ChatBskyLexicon.Conversation { - /// The request body data model definition for updating the conversation to mark it as read. + /// A request body model for updating the conversation to mark it as read. /// /// - SeeAlso: This is based on the [`chat.bsky.convo.updateRead`][github] lexicon. /// @@ -28,7 +28,7 @@ extension ChatBskyLexicon.Conversation { } } - /// The main data model definition for the output of updating the conversation to mark it as read. + /// An output model for updating the conversation to mark it as read. /// /// - SeeAlso: This is based on the [`chat.bsky.convo.updateRead`][github] lexicon. /// diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Moderation/ChatBskyModerationGetActorMetadata.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Moderation/ChatBskyModerationGetActorMetadata.swift index 95ed6d82ed..baeb4d7efc 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Moderation/ChatBskyModerationGetActorMetadata.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Moderation/ChatBskyModerationGetActorMetadata.swift @@ -8,8 +8,8 @@ import Foundation extension ChatBskyLexicon.Moderation { - - /// The data model definition for the output of getting the user account's metadata. + + /// An output model for getting the user account's metadata. /// /// - SeeAlso: This is based on the [`chat.bsky.moderation.getActorMetadata`][github] lexicon. /// diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Moderation/ChatBskyModerationGetMessageContext.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Moderation/ChatBskyModerationGetMessageContext.swift index cef5dffa2e..98be79fa73 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Moderation/ChatBskyModerationGetMessageContext.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Moderation/ChatBskyModerationGetMessageContext.swift @@ -9,7 +9,7 @@ import Foundation extension ChatBskyLexicon.Moderation { - /// The data model definition for the output of getting the message context. + /// An output model for getting the message context. /// /// - SeeAlso: This is based on the [`chat.bsky.moderation.getMessageContext`][github] lexicon. /// diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Moderation/ChatBskyModerationUpdateActorAccess.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Moderation/ChatBskyModerationUpdateActorAccess.swift index ac8b0aafa2..b62f0b12be 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Moderation/ChatBskyModerationUpdateActorAccess.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Moderation/ChatBskyModerationUpdateActorAccess.swift @@ -9,8 +9,7 @@ import Foundation extension ChatBskyLexicon.Moderation { - /// The request body data model definition for updating the user account's access to - /// direct messages. + /// A request body model for updating the user account's access to direct messages. /// /// - SeeAlso: This is based on the [`hat.bsky.moderation.updateActorAccess`][github] lexicon. /// diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminDefs.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminDefs.swift index eea53dab52..292ad2ee08 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminDefs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminDefs.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Admin { - /// The main data model definition for admin status attributes. + /// A definition model for admin status attributes. /// /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. /// @@ -28,7 +28,7 @@ extension ComAtprotoLexicon.Admin { } } - /// A data model for a report view definition. + /// A definition model for a report view. /// /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. /// @@ -59,8 +59,8 @@ extension ComAtprotoLexicon.Admin { /// An array of action IDs that relate to resolutions. public let resolvedByActionIDs: [Int] - public init(id: Int, reasonType: ModerationReasonType, comment: String?, subjectRepoHandle: String?, subject: ATUnion.RepositoryReferencesUnion, reportedBy: String, createdAt: Date, - resolvedByActionIDs: [Int]) { + public init(id: Int, reasonType: ModerationReasonType, comment: String?, subjectRepoHandle: String?, subject: ATUnion.RepositoryReferencesUnion, + reportedBy: String, createdAt: Date, resolvedByActionIDs: [Int]) { self.id = id self.reasonType = reasonType self.comment = comment @@ -109,7 +109,7 @@ extension ComAtprotoLexicon.Admin { } } - /// A data model for a detailed report view definition. + /// A definition model for a detailed report view. /// /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. /// @@ -152,8 +152,9 @@ extension ComAtprotoLexicon.Admin { /// An array of resolved actions made in relation to the report. public let resolvedByActions: [OzoneModerationEventView] - public init(id: Int, reasonType: ModerationReasonType, comment: String? = nil, subject: ATUnion.RepositoryViewUnion, subjectStatus: OzoneSubjectStatusView? = nil, - reportedBy: String, createdAt: Date, resolvedByActions: [OzoneModerationEventView]) { + public init(id: Int, reasonType: ModerationReasonType, comment: String? = nil, subject: ATUnion.RepositoryViewUnion, + subjectStatus: OzoneSubjectStatusView? = nil, reportedBy: String, createdAt: Date, + resolvedByActions: [OzoneModerationEventView]) { self.id = id self.reasonType = reasonType self.comment = comment @@ -202,7 +203,7 @@ extension ComAtprotoLexicon.Admin { } } - /// A data model for a definition of an account view. + /// A definition model for an account view. /// /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. /// @@ -303,7 +304,7 @@ extension ComAtprotoLexicon.Admin { } } - /// A data model for a definition of a repository reference. + /// A definition model for a repository reference. /// /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. /// @@ -318,7 +319,7 @@ extension ComAtprotoLexicon.Admin { } } - /// A data model for a blob reference definition. + /// A definition model for a blob reference. /// /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. /// diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminDeleteAccount.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminDeleteAccount.swift index 770752730b..d7555fbd42 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminDeleteAccount.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminDeleteAccount.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Admin { - /// The main data model definition for deleting a user's account as an administrator. + /// A request body model for deleting a user's account as an administrator. /// /// - Note: According to the AT Protocol specifications: "Delete a user account as /// an administrator." @@ -17,7 +17,7 @@ extension ComAtprotoLexicon.Admin { /// - SeeAlso: This is based on the [`com.atproto.admin.deleteAccount`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/deleteAccount.json - public struct DeleteAccount: Codable { + public struct DeleteAccountRequestBody: Codable { /// The decentralized identifier (DID) of the account to be deleted. public let accountDID: String diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminDisableAccountInvites.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminDisableAccountInvites.swift index 290fe5295a..ccb6b08f91 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminDisableAccountInvites.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminDisableAccountInvites.swift @@ -9,8 +9,7 @@ import Foundation extension ComAtprotoLexicon.Admin { - /// The main data model definition for disabling a user account's ability to receive new - /// invite codes. + /// A request body model for disabling a user account's ability to receive new invite codes. /// /// - Note: According to the AT Protocol specifications: "Disable an account from receiving new /// invite codes, but does not invalidate existing codes." @@ -18,7 +17,7 @@ extension ComAtprotoLexicon.Admin { /// - SeeAlso: This is based on the [`com.atproto.admin.disableAccountInvites`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/disableAccountInvites.json - public struct DisableAccountInvites: Codable { + public struct DisableAccountInvitesRequestBody: Codable { /// The decentralized identifier (DID) of the user account. public let accountDID: String diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminDisableInviteCodes.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminDisableInviteCodes.swift index 6eeade616f..b71e99417d 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminDisableInviteCodes.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminDisableInviteCodes.swift @@ -9,8 +9,8 @@ import Foundation extension ComAtprotoLexicon.Admin { - /// The main data model definition for disabling some or all of the invite codes for one or - /// more user accounts. + /// A request body model for disabling some or all of the invite codes for one or more + /// user accounts. /// /// - Note: According to the AT Protocol specifications: "Disable some set of codes and/or all /// codes associated with a set of users." @@ -18,7 +18,7 @@ extension ComAtprotoLexicon.Admin { /// - SeeAlso: This is based on the [`com.atproto.admin.disableInviteCodes`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/disableInviteCodes.json - public struct DisableInviteCodes: Codable { + public struct DisableInviteCodesRequestBody: Codable { /// The invite codes to disable. public let codes: [String] diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminEnableAccountInvites.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminEnableAccountInvites.swift index d3f770cc9b..760af0fae4 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminEnableAccountInvites.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminEnableAccountInvites.swift @@ -9,8 +9,7 @@ import Foundation extension ComAtprotoLexicon.Admin { - /// The main data model definition for giving the user account access to receive invite - /// codes again. + /// A request body model for giving the user account access to receive invite codes again. /// /// - Note: According to the AT Protocol specifications: "Re-enable an account's ability to /// receive invite codes." diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminGetAccountInfos.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminGetAccountInfos.swift index f779574fbf..b0ba38848e 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminGetAccountInfos.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminGetAccountInfos.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Admin { - /// A data model definition for the output of retrieving an array of user accounts. + /// An output model for retrieving an array of user accounts. /// /// - Note: According to the AT Protocol specifications: "Get details about some accounts." /// diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminGetInviteCodes.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminGetInviteCodes.swift index a640ce0bbd..6b07812e5e 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminGetInviteCodes.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminGetInviteCodes.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Admin { - /// A data model definition for the output of getting the invite codes from a user account. + /// An output model for getting the invite codes from a user account. /// /// - Note: According to the AT Protocol specifications: "Get an admin view of invite codes." /// diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminGetSubjectStatus.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminGetSubjectStatus.swift index dbe7c0856b..c10b2302ad 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminGetSubjectStatus.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminGetSubjectStatus.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Admin { - /// A data model definition for the output of getting the status of a subject as an administrator. + /// An output model for getting the status of a subject as an administrator. /// /// - Note: According to the AT Protocol specifications: "Get the service-specific admin status of /// a subject (account, record, or blob)." diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminQueryModerationStatuses.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminQueryModerationStatuses.swift index 7fe5569b47..7e8244c39d 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminQueryModerationStatuses.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminQueryModerationStatuses.swift @@ -9,8 +9,7 @@ import Foundation extension ComAtprotoLexicon.Admin { - /// A data model definition for the output of listing all of moderation statuses of records - /// and repositories. + /// An output model for listing all of moderation statuses of records and repositories. /// /// - Note: According to the AT Protocol specifications: "View moderation statuses of /// subjects (record or repo)." diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminSearchRepos.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminSearchRepos.swift index db344c74e6..e34ba1897b 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminSearchRepos.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminSearchRepos.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Admin { - /// The main data model definition for the output of searching repositories. + /// An output model for searching repositories. /// /// - Note: According to the AT Protocol specifications: "Find repositories based on a /// search term." diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminSendEmail.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminSendEmail.swift index 652b10e60e..5a30c56e47 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminSendEmail.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminSendEmail.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Admin { - /// The main data model definition for sending an email to a user. + /// A request body model for sending an email to a user. /// /// - Note: According to the AT Protocol specifications: "Send email to a user's account /// email address." diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminUpdateAccountEmail.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminUpdateAccountEmail.swift index 8f942d5dc1..f57c268092 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminUpdateAccountEmail.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminUpdateAccountEmail.swift @@ -9,8 +9,7 @@ import Foundation extension ComAtprotoLexicon.Admin { - /// The main data model definition for updating the email address of a user account as - /// an administrator. + /// A request body model for updating the email address of a user account as an administrator. /// /// - Note: According to the AT Protocol specifications: "Administrative action to update an /// account's email." @@ -19,8 +18,10 @@ extension ComAtprotoLexicon.Admin { /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/updateAccountEmail.json public struct AdminUpdateAccountEmailRequestBody: Codable { + /// The decentralized identifier (DID) of the account. public let accountDID: String + /// The new email account the user wants to change to. public let accountEmail: String diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminUpdateAccountHandle.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminUpdateAccountHandle.swift index a168b45197..992c8db934 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminUpdateAccountHandle.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminUpdateAccountHandle.swift @@ -9,8 +9,7 @@ import Foundation extension ComAtprotoLexicon.Admin { - /// The main data model definition for updating the handle of a user account as - /// an administrator. + /// A request body model for updating the handle of a user account as an administrator. /// /// - Note: According to the AT Protocol specifications: "Administrative action to update /// an account's handle." diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminUpdateAccountPassword.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminUpdateAccountPassword.swift index bcc5b33fab..61d0cf684d 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminUpdateAccountPassword.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminUpdateAccountPassword.swift @@ -9,8 +9,7 @@ import Foundation extension ComAtprotoLexicon.Admin { - /// The main data model definition for updating the handle of a user account as - /// an administrator. + /// A request body model for updating the handle of a user account as an administrator. /// /// - Note: According to the AT Protocol specifications: "Update the password for a /// user account as an administrator." diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminUpdateSubjectStatus.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminUpdateSubjectStatus.swift index 0da1fd1d7b..445a041032 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminUpdateSubjectStatus.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminUpdateSubjectStatus.swift @@ -9,8 +9,7 @@ import Foundation extension ComAtprotoLexicon.Admin { - /// The main data model definition for updating a subject status of an account, record, - /// or blob. + /// A request body model for updating a subject status of an account, record, or blob. /// /// - Note: According to the AT Protocol specifications: "Update the service-specific /// admin status of a subject (account, record, or blob)." @@ -18,7 +17,7 @@ extension ComAtprotoLexicon.Admin { /// - SeeAlso: This is based on the [`com.atproto.admin.updateSubjectStatus`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/updateSubjectStatus.json - public struct AdminUpdateSubjectStatus: Codable { + public struct AdminUpdateSubjectStatusRequestBody: Codable { /// The subject associated with the subject status. public let subject: AdminGetSubjectStatusUnion @@ -27,8 +26,7 @@ extension ComAtprotoLexicon.Admin { public let takedown: AdminStatusAttributes? } - /// A data model definition for the output of updating a subject status of an account, record, - /// or blob. + /// An output model for updating a subject status of an account, record, or blob. /// /// - Note: According to the AT Protocol specifications: "Update the service-specific admin /// status of a subject (account, record, or blob)." diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentityGetRecommendedDidCredentials.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentityGetRecommendedDidCredentials.swift index 4d97773c67..7b4b872f88 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentityGetRecommendedDidCredentials.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentityGetRecommendedDidCredentials.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Identity { - /// The main data model definition for the output of getting the required information of a + /// An output model for getting the required information of a /// Personal Data Server's (PDS) DID document for migration. /// /// - Note: According to the AT Protocol specifications: "Describe the credentials that should @@ -19,15 +19,19 @@ extension ComAtprotoLexicon.Identity { /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/identity/getRecommendedDidCredentials.json public struct GetRecommendedDidCredentialsOutput: Codable { + /// The rotation keys recommended to be added in the DID document. Optional. /// /// - Note: According to the AT Protocol specifications: "Recommended rotation keys for PLC /// dids. Should be undefined (or ignored) for did:webs." public let rotationKeys: [String]? + /// An array of aliases of the user account. Optional. public let alsoKnownAs: [String]? + /// A verification method recommeneded to be added in the DID document. Optional. public let verificationMethods: VerificationMethod? + /// The service endpoint recommended in the DID document. Optional. public let service: ATService? } diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentityRequestPlcOperationSignature.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentityRequestPlcOperationSignature.swift index 1155f4a776..bfea706936 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentityRequestPlcOperationSignature.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentityRequestPlcOperationSignature.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Identity { - /// The request body data model definition for requesting a signed PLC operation. + /// A request body model for requesting a signed PLC operation. /// /// - Note: According to the AT Protocol specifications: "Request an email with a code to in /// order to request a signed PLC operation. Requires Auth." diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentityResolveHandle.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentityResolveHandle.swift index 0f6445de3f..3f3fb1259e 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentityResolveHandle.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentityResolveHandle.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Identity { - /// A data model that represents the output of resolving handles. + /// An output model for esolving handles. /// /// - SeeAlso: This is based on the [`com.atproto.identity.resolveHandle`][github] lexicon. /// diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentitySignPLCOperation.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentitySignPLCOperation.swift index b82fac302e..c459c534ae 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentitySignPLCOperation.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentitySignPLCOperation.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Identity { - /// The main data model definition for signing a PLC operation to a DID document. + /// A request body model for signing a PLC operation to a DID document. /// /// - Note: According to the AT Protocol specifications: "Signs a PLC operation to update some /// value(s) in the requesting DID's document." @@ -39,7 +39,7 @@ extension ComAtprotoLexicon.Identity { public let service: ATService? } - /// The main data model definition for the output of signing a PLC operation to a DID document. + /// An output model for signing a PLC operation to a DID document. /// /// - Note: According to the AT Protocol specifications: "Signs a PLC operation to update some /// value(s) in the requesting DID's document." diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentitySubmitPLCOperation.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentitySubmitPLCOperation.swift index 7fdc8f2c89..64af146d22 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentitySubmitPLCOperation.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentitySubmitPLCOperation.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Identity { - /// The main data model definition for the output of validating a PLC operation. + /// An output model for validating a PLC operation. /// /// - Note: According to the AT Protocol specifications: "Validates a PLC operation to ensure /// that it doesn't violate a service's constraints or get the identity into a bad state, then diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentityUpdateHandle.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentityUpdateHandle.swift index 15f83edc46..c7c6c97138 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentityUpdateHandle.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentityUpdateHandle.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Identity { - /// The main data model definition for updating a handle. + /// A request body model for updating a handle. /// /// - Note: According to the AT Protocol specifications: "Updates the current account's handle. /// Verifies handle validity, and updates did:plc document if necessary. Implemented by PDS, @@ -18,7 +18,7 @@ extension ComAtprotoLexicon.Identity { /// - SeeAlso: This is based on the [`com.atproto.identity.updateHandle`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/identity/updateHandle.json - public struct UpdateHandleQuery: Encodable { + public struct UpdateHandleRequestBody: Encodable { /// The handle the user would like to change to. /// diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Label/ComAtprotoLabelDefs.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Label/ComAtprotoLabelDefs.swift index aac65fa4dc..16eb7bc4b0 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Label/ComAtprotoLabelDefs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Label/ComAtprotoLabelDefs.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Label { - /// The main data model definition for a label. + /// A definition model for a label. /// /// - Note: According to the AT Protocol specifications: "Metadata tag on an atproto resource /// (eg, repo or record)." @@ -133,7 +133,7 @@ extension ComAtprotoLexicon.Label { } } - /// A data model for a definition for an array of self-defined labels. + /// A definition model for an array of self-defined labels. /// /// - SeeAlso: This is based on the [`com.atproto.label.defs`][github] lexicon. /// @@ -175,7 +175,7 @@ extension ComAtprotoLexicon.Label { } } - /// A data model for a definition for a user-defined label. + /// A definition model for a user-defined label. /// /// - Note: According to the AT Protocol specifications: "Metadata tag on an atproto record, /// published by the author within the record. Note that schemas should use #selfLabels, @@ -207,7 +207,7 @@ extension ComAtprotoLexicon.Label { } } - /// A data model definition for labeler-created labels. + /// A definition model for labeler-created labels. /// /// - Note: According to the AT Protocol specifications: "Declares a label value and its expected /// interpertations and behaviors." @@ -321,7 +321,7 @@ extension ComAtprotoLexicon.Label { } } - /// A data model definition for a localized description of a label. + /// A definition model for a localized description of a label. /// /// - Note: According to the AT Protocol specifications: "Strings which describe the label in /// the UI, localized into a specific language." diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Label/ComAtprotoLabelQueryLabels.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Label/ComAtprotoLabelQueryLabels.swift index f2588353c2..fea483acf8 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Label/ComAtprotoLabelQueryLabels.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Label/ComAtprotoLabelQueryLabels.swift @@ -9,8 +9,7 @@ import Foundation extension ComAtprotoLexicon.Label { - /// The main data model definition for the output of finding relevant labels based on a - /// given URI. + /// An output model for inding relevant labels based on a given URI. /// /// - Note: According to the AT Protocol specifications: "Find labels relevant to the provided /// AT-URI patterns. Public endpoint for moderation services, though may return different or diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Moderation/ComAtprotoModerationCreateReport.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Moderation/ComAtprotoModerationCreateReport.swift index 74aae6b3bd..885d5917b9 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Moderation/ComAtprotoModerationCreateReport.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Moderation/ComAtprotoModerationCreateReport.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Moderation { - /// The main data model definition for creating a report. + /// A request body model for creating a report. /// /// - Note: According to the AT Protocol specifications: "Submit a moderation report regarding /// an atproto account or record. Implemented by moderation services (with PDS proxying), and @@ -42,7 +42,7 @@ extension ComAtprotoLexicon.Moderation { public let subject: RepositoryReferencesUnion } - /// A data model definition for the output of creating a report. + /// An output model for creating a report. /// /// - SeeAlso: This is based on the [`com.atproto.moderation.createReport`][github] lexicon. /// diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Moderation/ComAtprotoModerationDefs.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Moderation/ComAtprotoModerationDefs.swift index 4f1f112d2d..eacda0f949 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Moderation/ComAtprotoModerationDefs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Moderation/ComAtprotoModerationDefs.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Moderation { - /// A data model for the definition of the moderator's reason for reporting. + /// A definition model for the moderator's reason for reporting. /// /// - SeeAlso: This is based on the [`com.atproto.moderation.defs`][github] lexicon. /// diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtProtoRepoStrongRef.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtProtoRepoStrongRef.swift index 524bf2f062..00372a7a59 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtProtoRepoStrongRef.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtProtoRepoStrongRef.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Repository { - /// The main data model definition for a strong reference. + /// A main data model definition for a strong reference. /// /// - Note: According to the AT Protocol specifications: "A URI with a /// content-hash fingerprint." diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoApplyWrites.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoApplyWrites.swift index 3a2be39f3d..93f6cbee5f 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoApplyWrites.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoApplyWrites.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Repository { - /// The main data model definition for applying batch CRUD transactions. + /// A request body model for applying batch CRUD transactions. /// /// - Note: According to the AT Protocol specifications: "Apply a batch transaction of /// repository creates, updates, and deletes. Requires auth, implemented by PDS." diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoCreateRecord.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoCreateRecord.swift index ed0efc82ed..03723ce3b0 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoCreateRecord.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoCreateRecord.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Repository { - /// The main data model definition for creating a record. + /// A request body model for creating a record. /// /// - Note: According to the AT Protocol specifications: "Create a single new repository record /// Requires auth, implemented by PDS." diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoDeleteRecord.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoDeleteRecord.swift index 7376fdd436..d5920e28b1 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoDeleteRecord.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoDeleteRecord.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Repository { - /// The main data model definition for deleting a record. + /// A request body model for deleting a record. /// /// - Note: According to the AT Protocol specifications: "Delete a repository record, or ensure /// it doesn't exist. Requires auth, implemented by PDS." diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoDescribeRepo.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoDescribeRepo.swift index 8d6f4f3acd..e284494ddd 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoDescribeRepo.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoDescribeRepo.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Repository { - /// The main data model definition for the output of describing the repository. + /// An output model for describing the repository. /// /// - Note: According to the AT Protocol specifications: "Get information about an account /// and repository, including the list of collections. Does not require auth." diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoGetRecord.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoGetRecord.swift index ddc1cbdd52..40e3f5dc89 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoGetRecord.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoGetRecord.swift @@ -8,39 +8,27 @@ import Foundation extension ComAtprotoLexicon.Repository { - - /// The main data model definition for the outpot of a record. + + /// An output model for a record. /// /// - SeeAlso: This is based on the [`com.atproto.repo.getRecord`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/repo/getRecord.json public struct RecordOutput: Codable { - + /// The URI of the record. public let recordURI: String - + /// The CID hash for the record. public let recordCID: String - + /// The value for the record. - public let value: RecordValueReply? - + public let value: UnknownType? + enum CodingKeys: String, CodingKey { case recordURI = "uri" case recordCID = "cid" case value = "value" } } - - // MARK: - - /// The main data model definition for the outpot . - /// - /// - SeeAlso: This is based on the [`com.atproto.repo.getRecord`][github] lexicon. - /// - /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/repo/getRecord.json - public struct RecordValueReply: Codable { - - /// The reply reference of the record. - public let reply: ReplyReference? - } } diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoImportRepo.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoImportRepo.swift index 527e4eee5f..47d3d73eed 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoImportRepo.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoImportRepo.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Repository { - /// The main data model definition for importing a CAR file. + /// A request body model for importing a CAR file. /// /// - Note: According to the AT Protocol specifications: "Import a repo in the form of a /// CAR file. Requires Content-Length HTTP header to be set." diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoListMissingBlobs.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoListMissingBlobs.swift index 3fd6cd62f8..0dbaf24ef5 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoListMissingBlobs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoListMissingBlobs.swift @@ -9,8 +9,7 @@ import Foundation extension ComAtprotoLexicon.Repository { - /// The main data model definition for the output of listing any missing blobs attached to the - /// user account. + /// An output model for listing any missing blobs attached to the user account. /// /// - Note: According to the AT Protocol specifications: "Returns a list of missing blobs for /// the requesting account. Intended to be used in the account migration flow." diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoListRecords.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoListRecords.swift index 28c36bc3cd..424720ecd4 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoListRecords.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoListRecords.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Repository { - /// The main data model definition for the output of listing records. + /// An output model for listing records. /// /// - Note: According to the AT Protocol specifications: "List a range of records in a /// repository, matching a specific collection. Does not require auth." diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoPutRecord.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoPutRecord.swift index d0efac8ead..21c4d93d40 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoPutRecord.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoPutRecord.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Repository { - /// The main data model definition for creating a record that replaces a previous record. + /// A request body model for creating a record that replaces a previous record. /// /// - Note: According to the AT Protocol specifications: "Write a repository record, creating /// or updating it as needed. Requires auth, implemented by PDS." diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoUploadBlob.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoUploadBlob.swift index 4357694b76..41427fc821 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoUploadBlob.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoUploadBlob.swift @@ -11,10 +11,13 @@ extension ComAtprotoLexicon.Repository { /// The main data model definition for the image's query. public struct ImageQuery: Encodable { + /// The data of the image. public let imageData: Data + /// The file name of the image. public let fileName: String + /// The alt text of the image, public let altText: String? @@ -25,7 +28,7 @@ extension ComAtprotoLexicon.Repository { } } - /// The request body data model definition for uploading a blob. + /// A request body model for uploading a blob. /// /// - Note: According to the AT Protocol specifications: "Upload a new blob, to be referenced /// from a repository record. The blob will be deleted if it is not referenced within a time diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerActivateAccount.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerActivateAccount.swift index bf10a9d874..ae65bab4de 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerActivateAccount.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerActivateAccount.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Server { - /// The request body data model definition for activating an account. + /// A request body model for activating an account. /// /// - Note: According to the AT Protocol specifications: "Activates a currently deactivated /// account. Used to finalize account migration after the account's repo is imported and diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCheckAccountStatus.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCheckAccountStatus.swift index c62d18d950..7a8a72d31d 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCheckAccountStatus.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCheckAccountStatus.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Server { - /// A data model definition for the output of checking the user's account status. + /// An output model for checking the user's account status. /// /// - Note: According to the AT Protocol specifications: "Returns the status of an account, /// especially as pertaining to import or recovery. Can be called many times over the course diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerConfirmEmail.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerConfirmEmail.swift index 7b495369b4..421c10a804 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerConfirmEmail.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerConfirmEmail.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Server { - /// The main data model of a definition for confirming emails. + /// A request body model for confirming emails. /// /// - Note: According to the AT Protocol specifications: "Confirm an email using a token from com.atproto.server.requestEmailConfirmation." /// diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCreateAccount.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCreateAccount.swift index ad72e52c53..8230705f7b 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCreateAccount.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCreateAccount.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Server { - /// The main data model definition for creating an account. + /// A request body model for creating an account. /// /// - Note: According to the AT Protocol specifications: "Create an account. Implemented /// by PDS." diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCreateAppPassword.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCreateAppPassword.swift index fd985ea1b2..a0549196f9 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCreateAppPassword.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCreateAppPassword.swift @@ -8,8 +8,8 @@ import Foundation extension ComAtprotoLexicon.Server { - - /// The request body data model definition for creating an App Password. + + /// A request body model for creating an App Password. /// /// - Note: According to the AT Protocol specifications: "Create an App Password." /// @@ -25,7 +25,7 @@ extension ComAtprotoLexicon.Server { public let name: String } - /// A data model definition for creating an App Password. + /// An output model for creating an App Password. /// /// - Note: According to the AT Protocol specifications: "Create an App Password." /// diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCreateInviteCode.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCreateInviteCode.swift index af1a470a15..86ba4fc871 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCreateInviteCode.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCreateInviteCode.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Server { - /// The main data model definition for creating an invite code. + /// A request body model for creating an invite code. /// /// - Note: According to the AT Protocol specifications: "Create invite code." /// @@ -31,7 +31,7 @@ extension ComAtprotoLexicon.Server { public let forAccount: [String]? } - /// A data model definition of the output for creating an invite code. + /// An output model for creating an invite code. /// /// - SeeAlso: This is based on the [`com.atproto.server.createInviteCode`][github] lexicon. /// diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCreateInviteCodes.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCreateInviteCodes.swift index aadb855d4a..676ec433ad 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCreateInviteCodes.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCreateInviteCodes.swift @@ -9,14 +9,14 @@ import Foundation extension ComAtprotoLexicon.Server { - /// The main data model definition for creating invite codes. + /// A request body model for creating invite codes. /// /// - Note: According to the AT Protocol specifications: "Create invite codes." /// /// - SeeAlso: This is based on the [`com.atproto.server.createInviteCodes`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/createInviteCodes.json - public struct CreateInviteCodes: Codable { + public struct CreateInviteCodesRequestBody: Codable { /// The number of invite codes to create. Defaults to 1. public var codeCount: Int = 1 @@ -34,7 +34,7 @@ extension ComAtprotoLexicon.Server { public let forAccounts: [String]? } - /// A data model definition of the output for creating invite codes. + /// An output model for creating invite codes. /// /// - SeeAlso: This is based on the [`com.atproto.server.createInviteCodes`][github] lexicon. /// @@ -45,8 +45,7 @@ extension ComAtprotoLexicon.Server { public let codes: [ServerAccountCodes] } - /// A data model definition of the server invite codes generated from - /// ``ServerCreateInviteCodes``. + /// The server invite codes generated from ``ServerCreateInviteCodes``. /// /// - SeeAlso: This is based on the [`com.atproto.server.createInviteCodes`][github] lexicon. /// diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCreateSession.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCreateSession.swift index 3ed327b33d..343829eb39 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCreateSession.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerCreateSession.swift @@ -9,14 +9,14 @@ import Foundation extension ComAtprotoLexicon.Server { - /// The main data model definition for creating a session. + /// A request body model for creating a session. /// /// - Note: According to the AT Protocol specifications: "Create an authentication session." /// /// - SeeAlso: This is based on the [`com.atproto.server.createSession`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/createSession.json - public struct CredentialsRequestBody: Encodable { + public struct CreateSessionRequestBody: Encodable { /// The indentifier of the user's account (typically a handle). /// diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerDeactivateAccount.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerDeactivateAccount.swift index 82ea47f6ec..3725e959b2 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerDeactivateAccount.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerDeactivateAccount.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Server { - /// The main data model definition for deactivating an account. + /// A request body model for deactivating an account. /// /// - Note: According to the AT Protocol specifications: "Deactivates a currently /// active account. Stops serving of repo, and future writes to repo until reactivated. @@ -19,7 +19,8 @@ extension ComAtprotoLexicon.Server { /// - SeeAlso: This is based on the [`com.atproto.server.deactivateAccount`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/deactivateAccount.json - public struct DeactivateAccount: Codable { + public struct DeactivateAccountRequestBody: Codable { + /// The date and time of when the server should delete the account. /// /// - Note: According to the AT Protocol specifications: "A recommendation to server as diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerDefs.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerDefs.swift index 67c2a21171..f86bcccbe5 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerDefs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerDefs.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Server { - /// The main data model definition for a server invite code. + /// A definition model for a server invite code. /// /// - SeeAlso: This is based on the [`com.atproto.server.defs`][github] lexicon. /// @@ -82,7 +82,7 @@ extension ComAtprotoLexicon.Server { } } - /// A data model for a definition for the invite code's use. + /// A definition model for the invite code's use. /// /// - SeeAlso: This is based on the [`com.atproto.server.defs`][github] lexicon. /// @@ -91,7 +91,7 @@ extension ComAtprotoLexicon.Server { /// Who used the invite code. public let usedBy: String - + /// The date and time the service code was used. @DateFormatting public var usedAt: Date diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerDeleteAccount.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerDeleteAccount.swift index b6e3419cff..6ba02ff1e2 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerDeleteAccount.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerDeleteAccount.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Server { - /// The main data model definition for deleting an account. + /// A request body model for deleting an account. /// /// - Note: According to the AT Protocol specifications: "Delete an actor's account with a /// token and password. Can only be called after requesting a deletion token. Requires auth." diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerDescribeServer.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerDescribeServer.swift index ee9bfd6436..2f4aceff3e 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerDescribeServer.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerDescribeServer.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Server { - /// A data model definition for the output of retrieving a description of the server. + /// An output model for retrieving a description of the server. /// /// - Note: According to the AT Protocol specifications: "Describes the server's account /// creation requirements and capabilities. Implemented by PDS." @@ -61,7 +61,7 @@ extension ComAtprotoLexicon.Server { } } - /// A data model definition of service policy URLs. + /// A data model of service policy URLs. /// /// - Note: According to the AT Protocol specifications: "Describes the server's account /// creation requirements and capabilities. Implemented by PDS." diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerGetAccountInviteCodes.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerGetAccountInviteCodes.swift index 1ff71f5a5d..9c241200a9 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerGetAccountInviteCodes.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerGetAccountInviteCodes.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Server { - /// A data model definition for the output of getting the invite codes of the user's account. + /// An output model for getting the invite codes of the user's account. /// /// - SeeAlso: This is based on the [`com.atproto.server.getAccountInviteCodes`][github] lexicon. /// diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerGetServiceAuth.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerGetServiceAuth.swift index 53edd68303..eb7a51041c 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerGetServiceAuth.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerGetServiceAuth.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Server { - /// A data model definition for the output of getting the signed token for the service. + /// An output model for getting the signed token for the service. /// /// - Note: According to the AT Protocol specifications: "Get a signed token on behalf of the /// requesting DID for the requested service." diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerListAppPasswords.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerListAppPasswords.swift index 189c8e3a99..82a7a76ef1 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerListAppPasswords.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerListAppPasswords.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Server { - /// A data model definition of the of listing App Passwords. + /// An output model for listing App Passwords. /// /// - Note: According to the AT Protocol specifications: "List all App Passwords." /// @@ -22,7 +22,7 @@ extension ComAtprotoLexicon.Server { public let passwords: [AppPassword] } - /// A data model definition of App Password information. + /// An App Password. /// /// - SeeAlso: This is based on the [`com.atproto.server.listAppPasswords`][github] lexicon. /// diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerRequestEmailUpdate.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerRequestEmailUpdate.swift index effc338600..5d404fa0aa 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerRequestEmailUpdate.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerRequestEmailUpdate.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Server { - /// A data model definition for the output of requesting to update the user's email address. + /// An output model for requesting to update the user's email address. /// /// - Note: According to the AT Protocol specifications: "Request a token in order to /// update email." diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerRequestPasswordReset.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerRequestPasswordReset.swift index d5954a0188..61d99fb8aa 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerRequestPasswordReset.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerRequestPasswordReset.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Server { - /// The main data model definition for resetting the user's password. + /// A request body model for resetting the user's password. /// /// - Note: According to the AT Protocol specifications: "Initiate a user account password /// reset via email." diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerReserveSigningKey.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerReserveSigningKey.swift index d4d69ca05b..1cd60fc740 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerReserveSigningKey.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerReserveSigningKey.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Server { - /// The main data model definition for reversing signing keys. + /// A request body model for reversing signing keys. /// /// - Note: According to the AT Protocol specifications: "Reserve a repo signing key, for /// use with account creation. Necessary so that a DID PLC update operation can be constructed @@ -30,7 +30,7 @@ extension ComAtprotoLexicon.Server { } } - /// A data model definition for the output of reversing a signing keys. + /// An output model for reversing signing keys. /// /// - SeeAlso: This is based on the [`com.atproto.server.reserveSigningKey`][github] lexicon. /// diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerResetPassword.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerResetPassword.swift index a992a04761..c09959f582 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerResetPassword.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerResetPassword.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Server { - /// The main data model definition for resetting a password. + /// A request body model for resetting a password. /// /// - Note: According to the AT Protocol specifications: "Reset a user account password using a token." /// diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerRevokeAppPassword.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerRevokeAppPassword.swift index 65b8d3de17..7edc5156a3 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerRevokeAppPassword.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerRevokeAppPassword.swift @@ -9,14 +9,14 @@ import Foundation extension ComAtprotoLexicon.Server { - /// The main data model definition for revoking a password. +/// A request body model for revoking a password. /// /// - Note: According to the AT Protocol specifications: "Revoke an App Password by name." /// /// - SeeAlso: This is based on the [`com.atproto.server.revokeAppPassword`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/revokeAppPassword.json - public struct RevokeAppPassword: Codable { + public struct RevokeAppPasswordRequestBody: Codable { /// The name associated with the App Password. public let appPasswordName: String diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerUpdateEmail.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerUpdateEmail.swift index 9ba86570d7..cf52421465 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerUpdateEmail.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerUpdateEmail.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Server { - /// The request body data model definition for updating the user's email address. + /// A request body model for updating the user's email address. /// /// - Note: According to the AT Protocol specifications: "Update an account's email." /// diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncCrawler.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncCrawler.swift new file mode 100644 index 0000000000..6923745a84 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncCrawler.swift @@ -0,0 +1,40 @@ +// +// ComAtprotoSyncCrawler.swift +// +// +// Created by Christopher Jr Riley on 2024-05-23. +// + +import Foundation + +extension ComAtprotoLexicon.Sync { + + /// A request body model for the crawling service. + /// + /// - Note: According to the AT Protocol specifications:\ + /// `com.atproto.sync.notifyOfUpdate`: "Notify a crawling service of a recent update, and that + /// crawling should resume. Intended use is after a gap between repo stream events caused the + /// crawling service to disconnect. Does not require auth; implemented by Relay." \ + /// \ + /// `com.atproto.sync.requestCrawl`: "Request a service to persistently crawl hosted repos. + /// Expected use is new PDS instances declaring their existence to Relays. Does not require auth." + /// + /// - SeeAlso: This is based on the following lexicons:\ + /// \- [`com.atproto.sync.notifyOfUpdate`][notifyOfUpdate]\ + /// \- [`com.atproto.sync.requestCrawl`][requestCrawl] + /// + /// [notifyOfUpdate]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/sync/notifyOfUpdate.json + /// [requestCrawl]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/sync/requestCrawl.json + public struct SyncCrawler: Codable { + + /// The hostname that the crawling service resides in. + /// + /// - Note: According to the AT Protocol specifications: "Hostname of the current service + /// (usually a PDS) that is notifying of update." + public let crawlingHostname: URL + + enum CodingKeys: String, CodingKey { + case crawlingHostname = "hostname" + } + } +} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncGetBlob.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncGetBlob.swift index 4e2b3b411b..70e4027649 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncGetBlob.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncGetBlob.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Sync { - /// The main data model definition for the output of getting a blob. + /// A request body model for getting a blob. /// /// - Note: According to the AT Protocol specifications: "Get a blob associated with a /// given account. Returns the full blob as originally uploaded. Does not require auth; diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncGetLatestCommit.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncGetLatestCommit.swift index 3a96bb408f..4eb4b4b5e7 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncGetLatestCommit.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncGetLatestCommit.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Sync { - /// The main data model definition for the output of getting a repository's latest commit CID. + /// An output model for getting a repository's latest commit CID. /// /// - Note: According to the AT Protocol specifications: "Get the current commit CID & revision /// of the specified repo. Does not require auth." diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncListBlobs.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncListBlobs.swift index ce56cea250..8be794757d 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncListBlobs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncListBlobs.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Sync { - /// The main data model definition for the output of a user account's blob CID hashes. + /// An output model for a user account's blob CID hashes. /// /// - Note: According to the AT Protocol specifications: "List blob CIDs for an account, since /// some repo revision. Does not require auth; implemented by PDS." diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncListRepos.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncListRepos.swift index 4dc2aef680..97c7a11eaa 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncListRepos.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncListRepos.swift @@ -9,8 +9,8 @@ import Foundation extension ComAtprotoLexicon.Sync { - /// The main data model definition for the output of listing all decentralized identifiers - /// (DIDs), revisions, and commit CID hashes of given repositiories. + /// An output model for isting all decentralized identifiers (DIDs), revisions, and + /// commit CID hashes of given repositiories. /// /// - Note: According to the AT Protocol specifications: "Enumerates all the DID, rev, and /// commit CID for all repos hosted by this service. Does not require auth; diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Temp/ComAtprotoTempCheckSignupQueue.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Temp/ComAtprotoTempCheckSignupQueue.swift index 1f26900688..7654dac3ad 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Temp/ComAtprotoTempCheckSignupQueue.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Temp/ComAtprotoTempCheckSignupQueue.swift @@ -10,8 +10,7 @@ import Foundation extension ComAtprotoLexicon.Temp { - /// The main data model definition for the output of retrieving information about the - /// sign up queue. + /// An output model for etrieving information about the sign up queue. /// /// - Important: The lexicon associated with this model may be removed at any time. This may /// not work. diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Temp/ComAtprotoTempRequestPhoneVerification.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Temp/ComAtprotoTempRequestPhoneVerification.swift index 35f49c1a90..abf13d16bd 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Temp/ComAtprotoTempRequestPhoneVerification.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Temp/ComAtprotoTempRequestPhoneVerification.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Temp { - /// The main data model definition for requesting a text code from a phone number. + /// A request body model for requesting a text code from a phone number. /// /// - Important: The lexicon associated with this model may be removed at any time. This may /// not work. @@ -20,7 +20,7 @@ extension ComAtprotoLexicon.Temp { /// - SeeAlso: This is based on the [`com.atproto.temp.requestPhoneVerification`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/temp/requestPhoneVerification.json - public struct RequestPhoneVerification: Codable { + public struct RequestPhoneVerificationRequestBody: Codable { /// The user's mobile phone number. public let phoneNumber: String diff --git a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/ToolsOzoneCommunicationCreateTemplate.swift b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/ToolsOzoneCommunicationCreateTemplate.swift index b97117bad8..4147019165 100644 --- a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/ToolsOzoneCommunicationCreateTemplate.swift +++ b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/ToolsOzoneCommunicationCreateTemplate.swift @@ -9,7 +9,7 @@ import Foundation extension ToolsOzoneLexicon.Communication { - /// The request body data model definition for creating a communication template. + /// A request body model for creating a communication template. /// /// - Note: According to the AT Protocol specifications: "Administrative action to create a /// new, re-usable communication (email for now) template." diff --git a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/ToolsOzoneCommunicationDefs.swift b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/ToolsOzoneCommunicationDefs.swift index b79a846068..630e40b298 100644 --- a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/ToolsOzoneCommunicationDefs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/ToolsOzoneCommunicationDefs.swift @@ -9,7 +9,7 @@ import Foundation extension ToolsOzoneLexicon.Communication { - /// A data model definition for a communication template. + /// A definition model for a communication template. /// /// - SeeAlso: This is based on the [`tools.ozone.communication.defs`][github] lexicon. /// diff --git a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/ToolsOzoneCommunicationDeleteTemplate.swift b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/ToolsOzoneCommunicationDeleteTemplate.swift index 91cfb032c4..2525142872 100644 --- a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/ToolsOzoneCommunicationDeleteTemplate.swift +++ b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/ToolsOzoneCommunicationDeleteTemplate.swift @@ -9,7 +9,7 @@ import Foundation extension ToolsOzoneLexicon.Communication { - /// The main data model definition for deleting a communication template as an administrator. + /// A request body model for deleting a communication template as an administrator. /// /// - Note: According to the AT Protocol specifications: "Delete a communication template." /// diff --git a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/ToolsOzoneCommunicationListTemplates.swift b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/ToolsOzoneCommunicationListTemplates.swift index 19ca73dd0a..4571840ed9 100644 --- a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/ToolsOzoneCommunicationListTemplates.swift +++ b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/ToolsOzoneCommunicationListTemplates.swift @@ -9,7 +9,7 @@ import Foundation extension ToolsOzoneLexicon.Communication { - /// The output definition for retrieves a list of communication templates. + /// An output model for retrieves a list of communication templates. /// /// - Note: According to the AT Protocol specifications: "Get list of all /// communication templates." diff --git a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/ToolsOzoneCommunicationUpdateTemplate.swift b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/ToolsOzoneCommunicationUpdateTemplate.swift index 454fa2b516..fda11068d4 100644 --- a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/ToolsOzoneCommunicationUpdateTemplate.swift +++ b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/ToolsOzoneCommunicationUpdateTemplate.swift @@ -9,7 +9,7 @@ import Foundation extension ToolsOzoneLexicon.Communication { - /// The request body data model definition for updating a communication template. + /// A request body model for updating a communication template. /// /// - Note: According to the AT Protocol specifications: "Administrative action to update an /// existing communication template. Allows passing partial fields to patch specific diff --git a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationDefs.swift b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationDefs.swift index 2e62e78b7e..668905ece4 100644 --- a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationDefs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationDefs.swift @@ -9,7 +9,7 @@ import Foundation extension ToolsOzoneLexicon.Moderation { - /// A data model for a moderation event view definition. + /// A definition model for a moderation event view. /// /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. /// @@ -90,7 +90,7 @@ extension ToolsOzoneLexicon.Moderation { } } - /// A data model for a detailed moderation event view definition. + /// A definition model for a detailed moderation event view /// /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. /// @@ -157,7 +157,7 @@ extension ToolsOzoneLexicon.Moderation { } } - /// A data model for a subject's status view definition. + /// A definition model for a subject's status view. /// /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. /// @@ -324,7 +324,7 @@ extension ToolsOzoneLexicon.Moderation { } } - /// A data model for the subject review state definition. + /// A definition model for the subject review state. /// /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. /// @@ -357,7 +357,7 @@ extension ToolsOzoneLexicon.Moderation { case reviewNone } - /// A data model for an event takedown definition. + /// A definition model for an event takedown. /// /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. /// @@ -377,7 +377,7 @@ extension ToolsOzoneLexicon.Moderation { public let durationInHours: Int? } - /// A data model for a reverse takedown event definition. + /// A definition model for a reverse takedown event. /// /// - Note: According to the AT Protocol specifications: "Revert take down action on /// a subject." @@ -394,7 +394,7 @@ extension ToolsOzoneLexicon.Moderation { public let comment: String? } - /// A data model for a definition of an resolved appeal event. + /// A definition model for an resolved appeal event. /// /// - Note: According to the AT Protocol specifications: "Resolve appeal on a subject." /// @@ -409,7 +409,7 @@ extension ToolsOzoneLexicon.Moderation { public let comment: String? } - /// A data model for a definition of a comment event. + /// A definition model for a comment event. /// /// - Note: According to the AT Protocol specifications: "Add a comment to a subject." /// @@ -432,7 +432,7 @@ extension ToolsOzoneLexicon.Moderation { } } - /// A data model for a report event definition. + /// A definition model for a report event. /// /// - Note: According to the AT Protocol specifications: "Report a subject." /// @@ -455,7 +455,7 @@ extension ToolsOzoneLexicon.Moderation { public let reportType: ModerationReasonType } - /// A data model for a label event definition. + /// A definition model for a label event. /// /// - Note: According to the AT Protocol specifications: "Apply/Negate labels on a subject" /// @@ -480,7 +480,7 @@ extension ToolsOzoneLexicon.Moderation { } } - /// A data model for a definition of an acknowledgement event. + /// A definition model for an acknowledgement event. /// /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. /// @@ -491,7 +491,7 @@ extension ToolsOzoneLexicon.Moderation { public var comment: String? } - /// A data model for a definition of an escalation event. + /// A definition model for an acknowledgement event. /// /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. /// @@ -502,7 +502,7 @@ extension ToolsOzoneLexicon.Moderation { public var comment: String? } - /// A data model for a definition of a mute event. + /// A definition model for a definition of a mute event. /// /// - Note: According to the AT Protocol specifications: "Mute incoming reports on a subject." /// @@ -521,7 +521,7 @@ extension ToolsOzoneLexicon.Moderation { public let durationInHours: Int } - /// A data model for an unmute event definition. + /// A definition model for an unmute event definition. /// /// - Note: According to the AT Protocol specifications: "Unmute action on a subject." /// @@ -537,7 +537,7 @@ extension ToolsOzoneLexicon.Moderation { public var comment: String? } - /// A data model definition for a mute reporter event. + /// A definition model for a mute reporter event. /// /// - Note: According to the AT Protocol specifications: "Mute incoming reports from /// an account." @@ -557,7 +557,7 @@ extension ToolsOzoneLexicon.Moderation { public let comment: String? } - /// A data model definition for an unmute reporter event. + /// A definition model for an unmute reporter event. /// /// - Note: According to the AT Protocol specifications: "Unmute incoming reports /// from an account." @@ -574,7 +574,7 @@ extension ToolsOzoneLexicon.Moderation { public let comment: String? } - /// A data model for a definition of an email event. + /// A definition model for an email event. /// /// - Note: According to the AT Protocol specifications: "Keep a log of outgoing email to a user." /// @@ -602,7 +602,7 @@ extension ToolsOzoneLexicon.Moderation { public var comment: String? } - /// A data model for a definition of a diversion event. + /// A definition model for a diversion event. /// /// - Note: According to the AT Protocol specifications: "Divert a record's blobs to a /// 3rd party service for further scanning/tagging" @@ -616,7 +616,7 @@ extension ToolsOzoneLexicon.Moderation { public let comment: String? } - /// A data model for a tag event definition. + /// A definition model for a tag event definition. /// /// - Note: According to the AT Protocol specifications: "Add/Remove a tag on a subject." /// @@ -648,7 +648,7 @@ extension ToolsOzoneLexicon.Moderation { public let comment: String? } - /// A data model for a definition of a repository view. + /// A definition model for a repository view. /// /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. /// @@ -742,7 +742,7 @@ extension ToolsOzoneLexicon.Moderation { } } - /// A data model for a definition of a detailed repository view. + /// A definition model for a detailed repository view. /// /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. /// @@ -858,7 +858,7 @@ extension ToolsOzoneLexicon.Moderation { } } - /// A data model for a definition of a respository view that may not have been found. + /// A definition model for a respository view that may not have been found. /// /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. /// @@ -873,7 +873,7 @@ extension ToolsOzoneLexicon.Moderation { } } - /// A data model for the definition of a record view. + /// A definition model for a record view. /// /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. /// @@ -965,7 +965,7 @@ extension ToolsOzoneLexicon.Moderation { } } - /// A data model for a definition a detailed view of a record. + /// A definition model for a detailed view of a record. /// /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. /// @@ -1064,7 +1064,7 @@ extension ToolsOzoneLexicon.Moderation { } } - /// A data model for a definition of a record that may not have been found. + /// A definition model for a record that may not have been found. /// /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. /// @@ -1079,7 +1079,7 @@ extension ToolsOzoneLexicon.Moderation { } } - /// A data model of a definition for moderation. + /// A definition model for moderation. /// /// - Important: The item associated with this struct is undocumented in the AT Protocol specifications. The documentation here is based on:\ /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ @@ -1102,7 +1102,7 @@ extension ToolsOzoneLexicon.Moderation { public var subjectStatus: OzoneSubjectStatusView? } - /// A data model of a definition for a detailed moderation. + /// A definition model for a detailed moderation. /// /// - Important: The item associated with this struct is undocumented in the AT Protocol specifications. The documentation here is based on:\ /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ @@ -1125,7 +1125,7 @@ extension ToolsOzoneLexicon.Moderation { public var subjectStatus: OzoneSubjectStatusView? } - /// The data model for a definition of a blob view. + /// A definition model for a blob view. /// /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. /// @@ -1191,7 +1191,7 @@ extension ToolsOzoneLexicon.Moderation { } } - /// A data model for a definition of details for an image. + /// A definition model for details for an image. /// /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. /// @@ -1205,7 +1205,7 @@ extension ToolsOzoneLexicon.Moderation { public let height: Int } - /// A data model for a definition of details for a video. + /// A definition model for details for a video. /// /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. /// diff --git a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationEmitEvent.swift b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationEmitEvent.swift index f8679a87c6..8d0e9402fd 100644 --- a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationEmitEvent.swift +++ b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationEmitEvent.swift @@ -9,14 +9,14 @@ import Foundation extension ToolsOzoneLexicon.Moderation { - /// The main data model definition for enacting on an action against a user's account. + /// A request body model for enacting on an action against a user's account. /// /// - Note: According to the AT Protocol specifications: "Take a moderation action on an actor." /// /// - SeeAlso: This is based on the [`tools.ozone.moderation.emitEvent`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/emitEvent.json - public struct EmitEvent: Codable { + public struct EmitEventRequestBody: Codable { /// The type of event the moderator is taking, public let event: ATUnion.AdminEventViewUnion diff --git a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationQueryEvents.swift b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationQueryEvents.swift index 7812ab5c16..eb2c9f50f7 100644 --- a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationQueryEvents.swift +++ b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationQueryEvents.swift @@ -9,7 +9,7 @@ import Foundation extension ToolsOzoneLexicon.Moderation { - /// The main data model definition for listing all moderation events pertaining a subject. + /// An output model for listing all moderation events pertaining a subject. /// /// - Note: According to the AT Protocol specifications: "List moderation events related /// to a subject." @@ -17,7 +17,7 @@ extension ToolsOzoneLexicon.Moderation { /// - SeeAlso: This is based on the [`tools.ozone.moderation.queryEvents`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/queryEvents.json - public struct EventsOutput: Codable { + public struct QueryEventsOutput: Codable { /// The mark used to indicate the starting point for the next set of results. Optional. public let cursor: String? diff --git a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationQueryStatuses.swift b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationQueryStatuses.swift index 22e8b8d2e8..31eb9dffa5 100644 --- a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationQueryStatuses.swift +++ b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationQueryStatuses.swift @@ -9,7 +9,7 @@ import Foundation extension ToolsOzoneLexicon.Moderation { - /// The main data model definition for listing all moderation events pertaining a subject. + /// An output model for listing all moderation events pertaining a subject. /// /// - Note: According to the AT Protocol specifications: "View moderation statuses of subjects /// (record or repo)." @@ -21,7 +21,7 @@ extension ToolsOzoneLexicon.Moderation { /// The mark used to indicate the starting point for the next set of results. Optional. public let cursor: String? - + /// An array of subject status views. public let subjectStatuses: [OzoneSubjectStatusView] } diff --git a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationSearchRepos.swift b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationSearchRepos.swift index 5b76948182..9a11735eaf 100644 --- a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationSearchRepos.swift +++ b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationSearchRepos.swift @@ -9,7 +9,7 @@ import Foundation extension ToolsOzoneLexicon.Moderation { - /// The output model definition for searching for repositories as an administrator or moderator. + /// An output model for searching for repositories as an administrator or moderator. /// /// - Note: According to the AT Protocol specifications: "Find repositories based on a /// search term." From 737d1007170341be714c902059d3edd3d47002d3 Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Thu, 23 May 2024 18:08:45 -0400 Subject: [PATCH 19/51] Make extensions public This is mainly for the purposes of explosing them to the DocC. --- Sources/ATProtoKit/Utilities/ExtensionHelpers.swift | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Sources/ATProtoKit/Utilities/ExtensionHelpers.swift b/Sources/ATProtoKit/Utilities/ExtensionHelpers.swift index fe7c2161b6..161a1387a9 100644 --- a/Sources/ATProtoKit/Utilities/ExtensionHelpers.swift +++ b/Sources/ATProtoKit/Utilities/ExtensionHelpers.swift @@ -19,7 +19,7 @@ extension String: Truncatable { /// - Parameter length: The maximum number of characters that the `String` can have /// before it truncates. /// - Returns: A new `String` that contains the maximum number of characters or less. - func truncated(toLength length: Int) -> String { + public func truncated(toLength length: Int) -> String { return String(self.prefix(length)) } @@ -29,7 +29,7 @@ extension String: Truncatable { /// Any uppercased characters will be lowercased. Any characters that could be interpreted as /// hypens will be converted into standard hyphens. Any additional characters will /// be discarded. - func transformToLowerASCIIAndHyphen() -> String { + public func transformToLowerASCIIAndHyphen() -> String { // Trim trailing spaces. let trimmedString = self.trimmingCharacters(in: .whitespacesAndNewlines) @@ -86,7 +86,7 @@ extension Array: Truncatable { /// - Parameter length: The maximum number of items that an `Array` can /// have before it truncates. /// - Returns: A new `Array` that contains the maximum number of items or less. - func truncated(toLength length: Int) -> Array { + public func truncated(toLength length: Int) -> Array { return Array(self.prefix(length)) } } @@ -97,7 +97,7 @@ extension Encodable { /// Converts an object into a JSON object. /// /// - Returns: A JSON object. - func toJsonData() throws -> Data? { + public func toJsonData() throws -> Data? { return try JSONEncoder().encode(self) } } @@ -112,7 +112,7 @@ extension UInt64 { /// the characters `234567abcdefghijklmnopqrstuvwxyz` and is 13 characters in length. /// /// - Returns: A `String` that's encoded in a Base32-sortable format. - func toBase32Sortable() -> String { + public func toBase32Sortable() -> String { let base32Characters = "234567abcdefghijklmnopqrstuvwxyz" var number = self var encoded = "" @@ -132,7 +132,7 @@ extension UInt64 { extension Data { /// Returns an array of `UInt8` objects. - var bytes: [UInt8] { + public var bytes: [UInt8] { return [UInt8](self) } } From 73aa64f3c5641a9a927ae431d70188c597d0d96b Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Thu, 23 May 2024 18:24:47 -0400 Subject: [PATCH 20/51] Update API_GUIDELINES --- API_GUIDELINES.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/API_GUIDELINES.md b/API_GUIDELINES.md index 79f3bca3de..22bc3ec939 100644 --- a/API_GUIDELINES.md +++ b/API_GUIDELINES.md @@ -154,9 +154,9 @@ There are multiple kinds of models: main models, definition models, record model ### Definition Models - Documentation for the models are as follows: - - The first line must be structured as "A data model definition for “, followed by a short, one sentence description of what the lexicon is for: + - The first line must be structured as "A definition model for [...].“ (where "[...]") is a short, one sentence description of what the lexicon is for): ```swift - /// A data model definition for the output of checking the user's account status. + /// A definition model for an actor viewer state. ``` The requirements remain the same for the AT Protocol lexicon descriptions, the lexicon's NSID, and the GitHub link. - For the models themselves, they have the following requirements: @@ -180,9 +180,9 @@ There are multiple kinds of models: main models, definition models, record model ### Record Models - Documentation for the models are as follows: - - The first line must be structured as "A record definition for ", followed by a short, one sentence description of what the lexicon is for: + - The first line must be structured as "A record model for [...]." (where "[...]" is a short, one sentence description of what the lexicon is for): ```swift - /// A record definition of a post. + /// A record model of a post. ``` - After an empty `///` in the next line, the following line has the description that's procided by the lexicon. If there's no description, then this can be skipped. If there is one, it must say "- Note: According to the AT Protocol specifications: "`<#Description#>`"", where "`<#Description#>`" is the description provided by the lexicon. - After another empty `///` in the next line, the following line states where the API user can see the name of the lexicon, followed by the link. The structure must look like this: @@ -200,7 +200,7 @@ There are multiple kinds of models: main models, definition models, record model ### Output Models - Documentation for the model are as follows: - - The first line must be structured as "An output model for ", followed by a short, one sentence desctiption of what the lexicon is for: + - The first line must be structured as "An output model for [...]." (where "[...]" is a short, one sentence desctiption of what the lexicon is for): ```swift /// An output model for checking the user's account status. ``` @@ -223,7 +223,7 @@ There are multiple kinds of models: main models, definition models, record model ### `requestBody` Models - Documentation for the model are as follows: - - The first line must be structured as "A request body model for ", followed by a short, one sentence desctiption of what the lexicon is for: + - The first line must be structured as "A request body model for [...]." (where "[...]" is a short, one sentence desctiption of what the lexicon is for]): ```swift /// A request body model for checking the user's account status. ``` From 225e92680336e5928647ad1d5c5092458e0038a5 Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Thu, 23 May 2024 18:46:59 -0400 Subject: [PATCH 21/51] Fix formatting and remove code - Did a pass to check and make sure the code doesn't surpass the 160 character limit per line. - Removed unneeded code from AppBskyLexicon.Feed.PostReplyReference. Also changed a missed documentation. --- .../app.bsky/Actor/AppBskyActorDefs.swift | 9 +++---- .../app.bsky/Feed/AppBskyFeedDefs.swift | 4 ++-- .../app.bsky/Feed/AppBskyFeedPost.swift | 24 ------------------- .../app.bsky/Graph/AppBskyGraphDefs.swift | 4 ++-- .../app.bsky/Labeler/AppBskyLabelerDefs.swift | 3 ++- .../chat.bsky/Actor/ChatBskyActorDefs.swift | 4 +++- 6 files changed, 14 insertions(+), 34 deletions(-) diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorDefs.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorDefs.swift index 54470fbc7d..c2d1eb662f 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorDefs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorDefs.swift @@ -128,8 +128,8 @@ extension AppBskyLexicon.Actor { /// An array of labels created by the user. Optional. public var labels: [Label]? - public init(actorDID: String, actorHandle: String, displayName: String?, description: String?, avatarImageURL: URL?, associated: ProfileAssociatedDefinition?, - indexedAt: Date?, viewer: ViewerStateDefinition?, labels: [Label]?) { + public init(actorDID: String, actorHandle: String, displayName: String?, description: String?, avatarImageURL: URL?, + associated: ProfileAssociatedDefinition?, indexedAt: Date?, viewer: ViewerStateDefinition?, labels: [Label]?) { self.actorDID = actorDID self.actorHandle = actorHandle self.displayName = displayName @@ -240,7 +240,8 @@ extension AppBskyLexicon.Actor { public var labels: [Label]? public init(actorDID: String, actorHandle: String, displayName: String?, description: String?, avatarImageURL: URL?, bannerImageURL: URL?, - followerCount: Int?, followCount: Int?, postCount: Int?, associated: ProfileAssociatedDefinition?, indexedAt: Date?, viewer: ViewerStateDefinition?, labels: [Label]?) { + followerCount: Int?, followCount: Int?, postCount: Int?, associated: ProfileAssociatedDefinition?, indexedAt: Date?, + viewer: ViewerStateDefinition?, labels: [Label]?) { self.actorDID = actorDID self.actorHandle = actorHandle self.displayName = displayName @@ -338,7 +339,7 @@ extension AppBskyLexicon.Actor { } } - /// A data model for an actor viewer state definition. + /// A definition model for an actor viewer state. /// /// - Note: From the AT Protocol specification: "Metadata about the requesting account's /// relationship with the subject account. Only has meaningful content for authed requests." diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedDefs.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedDefs.swift index ff61f13b14..f98b827a28 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedDefs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedDefs.swift @@ -419,8 +419,8 @@ extension AppBskyLexicon.Feed { /// The last time the feed generator was indexed. @DateFormatting public var indexedAt: Date - public init(feedURI: String, cidHash: String, feedDID: String, creator: AppBskyLexicon.Actor.ProfileViewDefinition, displayName: String, description: String?, - descriptionFacets: [Facet]?, avatarImageURL: URL?, likeCount: Int?, canAcceptInteractions: Bool?, labels: [Label]?, + public init(feedURI: String, cidHash: String, feedDID: String, creator: AppBskyLexicon.Actor.ProfileViewDefinition, displayName: String, + description: String?, descriptionFacets: [Facet]?, avatarImageURL: URL?, likeCount: Int?, canAcceptInteractions: Bool?, labels: [Label]?, viewer: GeneratorViewerStateDefinition?, indexedAt: Date) { self.feedURI = feedURI self.cidHash = cidHash diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedPost.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedPost.swift index 2c6e5f6ed6..9c6eff51fe 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedPost.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedPost.swift @@ -154,29 +154,5 @@ extension AppBskyLexicon.Feed { /// - Note: If `parent` and `root` are identical, the post is a direct reply to the original /// post of the thread. public let parent: StrongReference - - public init(root: StrongReference, parent: StrongReference) { - self.root = root - self.parent = parent - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.root = try container.decode(StrongReference.self, forKey: .root) - self.parent = try container.decode(StrongReference.self, forKey: .parent) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self.root, forKey: .root) - try container.encode(self.parent, forKey: .parent) - } - - enum CodingKeys: CodingKey { - case root - case parent - } } } diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphDefs.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphDefs.swift index 87b0a05baa..b6299c6f30 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphDefs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphDefs.swift @@ -130,8 +130,8 @@ extension AppBskyLexicon.Graph { /// The late time the user list was indexed. @DateFormatting public var indexedAt: Date - public init(listURI: String, cidHash: String, creator: AppBskyLexicon.Actor.ProfileViewDefinition, name: String, purpose: ListPurpose, description: String?, - descriptionFacets: [Facet]?, avatarImageURL: URL?, viewer: ListViewerStateDefinition?, indexedAt: Date) { + public init(listURI: String, cidHash: String, creator: AppBskyLexicon.Actor.ProfileViewDefinition, name: String, purpose: ListPurpose, + description: String?, descriptionFacets: [Facet]?, avatarImageURL: URL?, viewer: ListViewerStateDefinition?, indexedAt: Date) { self.listURI = listURI self.cidHash = cidHash self.creator = creator diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerDefs.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerDefs.swift index f8f2ac1ad7..237cfeab67 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerDefs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerDefs.swift @@ -37,7 +37,8 @@ extension AppBskyLexicon.Labeler { /// An array of labels. Optional. public let labels: [Label]? - public init(labelerURI: String, labelerCIDHash: String, creator: AppBskyLexicon.Actor.ProfileViewDefinition, likeCount: Int?, viewer: LabelerViewerStateDefinition?, indexedAt: Date, labels: [Label]?) { + public init(labelerURI: String, labelerCIDHash: String, creator: AppBskyLexicon.Actor.ProfileViewDefinition, likeCount: Int?, + viewer: LabelerViewerStateDefinition?, indexedAt: Date, labels: [Label]?) { self.labelerURI = labelerURI self.labelerCIDHash = labelerCIDHash self.creator = creator diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Actor/ChatBskyActorDefs.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Actor/ChatBskyActorDefs.swift index d2b1ad1c0a..97bf6f6945 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Actor/ChatBskyActorDefs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Actor/ChatBskyActorDefs.swift @@ -46,7 +46,9 @@ extension ChatBskyLexicon.Actor { /// cannot actively participate in converations" public let isChatDisabled: Bool? - public init(actorDID: String, actorHandle: String, displayName: String?, avatarImageURL: URL?, associated: AppBskyLexicon.Actor.ProfileAssociatedDefinition?, viewer: [AppBskyLexicon.Actor.ViewerStateDefinition]?, labels: [Label]?, isChatDisabled: Bool?) { + public init(actorDID: String, actorHandle: String, displayName: String?, avatarImageURL: URL?, + associated: AppBskyLexicon.Actor.ProfileAssociatedDefinition?, viewer: [AppBskyLexicon.Actor.ViewerStateDefinition]?, + labels: [Label]?, isChatDisabled: Bool?) { self.actorDID = actorDID self.actorHandle = actorHandle self.displayName = displayName From 205514b59a1df22e75dbe53ea83d62e33c38c925 Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Fri, 24 May 2024 01:31:52 -0400 Subject: [PATCH 22/51] Replace old types --- .../app.bsky/Actor/AppBskyActorDefs.swift | 25 +- .../app.bsky/Actor/AppBskyActorProfile.swift | 6 +- .../app.bsky/Embed/AppBskyEmbedExternal.swift | 120 +++---- .../app.bsky/Embed/AppBskyEmbedImages.swift | 201 ++++++------ .../app.bsky/Embed/AppBskyEmbedRecord.swift | 295 +++++++++--------- .../Embed/AppBskyEmbedRecordWithMedia.swift | 40 +-- .../app.bsky/Feed/AppBskyFeedDefs.swift | 6 +- .../AppBskyFeedDescribeFeedGenerator.swift | 1 + .../Feed/AppBskyFeedGetAuthorFeed.swift | 42 +-- .../app.bsky/Feed/AppBskyFeedGetFeed.swift | 2 +- .../Feed/AppBskyFeedGetFeedGenerator.swift | 1 - .../Feed/AppBskyFeedGetFeedGenerators.swift | 2 +- .../app.bsky/Feed/AppBskyFeedGetLikes.swift | 87 +++--- .../app.bsky/Feed/AppBskyFeedPost.swift | 36 +-- .../app.bsky/Feed/AppBskyFeedThreadgate.swift | 35 ++- .../Graph/AppBskyGraphGetListMutes.swift | 2 +- .../app.bsky/Graph/AppBskyGraphList.swift | 12 +- .../app.bsky/Labeler/AppBskyLabelerDefs.swift | 16 +- .../Labeler/AppBskyLabelerService.swift | 6 +- ...AppBskyNotificationListNotifications.swift | 6 +- .../RichText/AppBskyRichTextFacet.swift | 287 ++++++++--------- ...AppBskyUnspeccedGetTaggedSuggestions.swift | 118 +++---- .../AppBskyUnspeccedSearchPostsSkeleton.swift | 42 ++- .../Actor/ChatBskyActorDeclaration.swift | 1 + .../chat.bsky/Actor/ChatBskyActorDefs.swift | 6 +- .../Convo/ChatBskyConvoSendMessageBatch.swift | 47 +-- .../ChatBskyModerationGetActorMetadata.swift | 50 +-- .../Admin/ComAtprotoAdminDefs.swift | 177 +---------- .../Admin/ComAtprotoAdminGetInviteCodes.swift | 30 +- ...mAtprotoAdminQueryModerationStatuses.swift | 48 --- .../Label/ComAtprotoLabelDefs.swift | 6 +- .../Label/ComAtprotoLabelQueryLabels.swift | 2 +- .../Repo/ComAtprotoRepoApplyWrites.swift | 115 +++---- .../Repo/ComAtprotoRepoListMissingBlobs.swift | 24 +- .../ComAtprotoServerDescribeServer.swift | 74 ++--- .../ComAtprotoServerListAppPasswords.swift | 56 ++-- .../Sync/ComAtprotoSyncListRepos.swift | 33 +- .../Moderation/ToolsOzoneModerationDefs.swift | 93 +++--- .../ToolsOzoneModerationQueryEvents.swift | 25 +- .../ToolsOzoneModerationQueryStatuses.swift | 2 +- .../ToolsOzoneModerationSearchRepos.swift | 2 +- 41 files changed, 1005 insertions(+), 1174 deletions(-) delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminQueryModerationStatuses.swift diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorDefs.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorDefs.swift index c2d1eb662f..09fc0f24ff 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorDefs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorDefs.swift @@ -38,10 +38,10 @@ extension AppBskyLexicon.Actor { public let viewer: ViewerStateDefinition? /// An array of labels created by the user. Optional. - public let labels: [Label]? - + public let labels: [ComAtprotoLexicon.Label.LabelDefinition]? + public init(actorDID: String, actorHandle: String, displayName: String?, avatarImageURL: URL?, associated: ProfileAssociatedDefinition?, - viewer: ViewerStateDefinition?, labels: [Label]?) { + viewer: ViewerStateDefinition?, labels: [ComAtprotoLexicon.Label.LabelDefinition]?) { self.actorDID = actorDID self.actorHandle = actorHandle self.displayName = displayName @@ -60,7 +60,7 @@ extension AppBskyLexicon.Actor { self.avatarImageURL = try container.decodeIfPresent(URL.self, forKey: .avatarImageURL) self.associated = try container.decodeIfPresent(ProfileAssociatedDefinition.self, forKey: .associated) self.viewer = try container.decodeIfPresent(ViewerStateDefinition.self, forKey: .viewer) - self.labels = try container.decodeIfPresent([Label].self, forKey: .labels) + self.labels = try container.decodeIfPresent([ComAtprotoLexicon.Label.LabelDefinition].self, forKey: .labels) } public func encode(to encoder: Encoder) throws { @@ -126,10 +126,11 @@ extension AppBskyLexicon.Actor { public var viewer: ViewerStateDefinition? /// An array of labels created by the user. Optional. - public var labels: [Label]? - + public var labels: [ComAtprotoLexicon.Label.LabelDefinition]? + public init(actorDID: String, actorHandle: String, displayName: String?, description: String?, avatarImageURL: URL?, - associated: ProfileAssociatedDefinition?, indexedAt: Date?, viewer: ViewerStateDefinition?, labels: [Label]?) { + associated: ProfileAssociatedDefinition?, indexedAt: Date?, viewer: ViewerStateDefinition?, + labels: [ComAtprotoLexicon.Label.LabelDefinition]?) { self.actorDID = actorDID self.actorHandle = actorHandle self.displayName = displayName @@ -152,7 +153,7 @@ extension AppBskyLexicon.Actor { self.associated = try container.decodeIfPresent(ProfileAssociatedDefinition.self, forKey: .associated) self.indexedAt = try container.decodeIfPresent(DateFormattingOptional.self, forKey: .indexedAt)?.wrappedValue self.viewer = try container.decodeIfPresent(ViewerStateDefinition.self, forKey: .viewer) - self.labels = try container.decodeIfPresent([Label].self, forKey: .labels) + self.labels = try container.decodeIfPresent([ComAtprotoLexicon.Label.LabelDefinition].self, forKey: .labels) } public func encode(to encoder: Encoder) throws { @@ -237,11 +238,11 @@ extension AppBskyLexicon.Actor { public var viewer: ViewerStateDefinition? /// An array of labels created by the user. Optional. - public var labels: [Label]? - + public var labels: [ComAtprotoLexicon.Label.LabelDefinition]? + public init(actorDID: String, actorHandle: String, displayName: String?, description: String?, avatarImageURL: URL?, bannerImageURL: URL?, followerCount: Int?, followCount: Int?, postCount: Int?, associated: ProfileAssociatedDefinition?, indexedAt: Date?, - viewer: ViewerStateDefinition?, labels: [Label]?) { + viewer: ViewerStateDefinition?, labels: [ComAtprotoLexicon.Label.LabelDefinition]?) { self.actorDID = actorDID self.actorHandle = actorHandle self.displayName = displayName @@ -272,7 +273,7 @@ extension AppBskyLexicon.Actor { self.associated = try container.decodeIfPresent(ProfileAssociatedDefinition.self, forKey: .associated) self.indexedAt = try container.decodeIfPresent(DateFormattingOptional.self, forKey: .indexedAt)?.wrappedValue self.viewer = try container.decodeIfPresent(ViewerStateDefinition.self, forKey: .viewer) - self.labels = try container.decodeIfPresent([Label].self, forKey: .labels) + self.labels = try container.decodeIfPresent([ComAtprotoLexicon.Label.LabelDefinition].self, forKey: .labels) } public func encode(to encoder: Encoder) throws { diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorProfile.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorProfile.swift index ad33d819d9..75f671e982 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorProfile.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorProfile.swift @@ -39,7 +39,7 @@ extension AppBskyLexicon.Actor { /// to posts from account. AKA, 'profile picture'" /// /// - Note: Only JPEGs and PNGs are accepted. - public let avatarBlob: BlobContainer? + public let avatarBlob: ComAtprotoLexicon.Repository.BlobContainer? /// The banner image URL of the profile. Optional. /// @@ -47,12 +47,12 @@ extension AppBskyLexicon.Actor { /// display behind profile view." /// /// - Note: Only JPEGs and PNGs are accepted. - public let bannerBlob: BlobContainer? + public let bannerBlob: ComAtprotoLexicon.Repository.BlobContainer? /// An array of user-defined labels. Optional. /// /// - Note: According to the AT Protocol specifications: "Self-label values, specific to /// the Bluesky application, on the overall account." - public let labels: [SelfLabels] + public let labels: [ComAtprotoLexicon.Label.SelfLabelsDefinition] } } diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedExternal.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedExternal.swift index 700b94276e..115b9cfe32 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedExternal.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedExternal.swift @@ -31,80 +31,80 @@ extension AppBskyLexicon.Embed { case type = "$type" case external } - } - - // MARK: - - /// A data model for an external definition. - /// - /// - SeeAlso: This is based on the [`app.bsky.embed.external`][github] lexicon. - /// - /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/external.json - public struct External: Codable { - - /// The URI of the external content. - public let embedURI: String - /// The title of the external content. - public let title: String - - /// The description of the external content. - public let description: String - - /// The thumbnail image of the external content. + // Enums + /// An external embed object. /// - /// - Warning: The image size can't be higher than 1 MB. Failure to do so will result in - /// the image failing to upload. - public let thumbnailImage: UploadBlobOutput? - - enum CodingKeys: String, CodingKey { - case embedURI = "uri" - case title - case description - case thumbnailImage = "thumb" + /// - SeeAlso: This is based on the [`app.bsky.embed.external`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/external.json + public struct External: Codable { + + /// The URI of the external content. + public let embedURI: String + + /// The title of the external content. + public let title: String + + /// The description of the external content. + public let description: String + + /// The thumbnail image of the external content. + /// + /// - Warning: The image size can't be higher than 1 MB. Failure to do so will result + /// in the image failing to upload. + public let thumbnailImage: ComAtprotoLexicon.Repository.UploadBlobOutput? + + enum CodingKeys: String, CodingKey { + case embedURI = "uri" + case title + case description + case thumbnailImage = "thumb" + } } - } - /// A data model for an external view definition. - /// - /// - SeeAlso: This is based on the [`app.bsky.embed.external`][github] lexicon. - /// - /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/external.json - public struct ExternalView: Codable { - - /// The identifier of the lexicon. + /// A data model for an external view definition. /// - /// - Warning: The value must not change. - public let type: String = "app.bsky.embed.external#view" + /// - SeeAlso: This is based on the [`app.bsky.embed.external`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/external.json + public struct View: Codable { - /// The external content embedded in a post. - public let external: ViewExternal + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. + public let type: String = "app.bsky.embed.external#view" - enum CodingKeys: String, CodingKey { - case type = "$type" - case external + /// The external content embedded in a post. + public let external: ViewExternal + + enum CodingKeys: String, CodingKey { + case type = "$type" + case external + } } - } - /// A data model for a definition for the external content. - public struct ViewExternal: Codable { + /// A data model for a definition for the external content. + public struct ViewExternal: Codable { - /// The URI of the external content. - public let embedURI: String + /// The URI of the external content. + public let embedURI: String - /// The title of the external content. - public let title: String + /// The title of the external content. + public let title: String - /// The description of the external content. - public let description: String + /// The description of the external content. + public let description: String - /// The thumbnail image URL of the external content. - public let thumbnailImageURL: URL? + /// The thumbnail image URL of the external content. + public let thumbnailImageURL: URL? - enum CodingKeys: String, CodingKey { - case embedURI = "uri" - case title - case description - case thumbnailImageURL = "thumb" + enum CodingKeys: String, CodingKey { + case embedURI = "uri" + case title + case description + case thumbnailImageURL = "thumb" + } } } } diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedImages.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedImages.swift index 30631ad7cb..48833014b5 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedImages.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedImages.swift @@ -37,122 +37,121 @@ extension AppBskyLexicon.Embed { case type = "$type" case images } - } - - // MARK: - - /// A data model for an external definition. - /// - /// - SeeAlso: This is based on the [`app.bsky.embed.images`][github] lexicon. - /// - /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/images.json - public struct Image: Codable { - /// The image that needs to be uploaded. + // Enums + /// A data model for an external definition. /// - /// - Warning: The image size can't be higher than 1 MB. Failure to do so will result in - /// the image failing to upload. - public let image: UploadBlobOutput - - /// The alternative text for the image. + /// - SeeAlso: This is based on the [`app.bsky.embed.images`][github] lexicon. /// - /// - Note: From the AT Protocol specification: "Alt text description of the image, - /// for accessibility." - public let altText: String - - /// The aspect ratio of the image. Optional. - public let aspectRatio: AspectRatio? - - public init(image: UploadBlobOutput, altText: String, aspectRatio: AspectRatio?) { - self.image = image - self.altText = altText - self.aspectRatio = aspectRatio + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/images.json + public struct Image: Codable { + + /// The image that needs to be uploaded. + /// + /// - Warning: The image size can't be higher than 1 MB. Failure to do so will result + /// in the image failing to upload. + public let image: ComAtprotoLexicon.Repository.UploadBlobOutput + + /// The alternative text for the image. + /// + /// - Note: From the AT Protocol specification: "Alt text description of the image, + /// for accessibility." + public let altText: String + + /// The aspect ratio of the image. Optional. + public let aspectRatio: AspectRatio? + + public init(image: ComAtprotoLexicon.Repository.UploadBlobOutput, altText: String, aspectRatio: AspectRatio?) { + self.image = image + self.altText = altText + self.aspectRatio = aspectRatio + } + + enum CodingKeys: String, CodingKey { + case image + case altText = "alt" + case aspectRatio + } } - enum CodingKeys: String, CodingKey { - case image - case altText = "alt" - case aspectRatio - } - } - - /// A data model for the aspect ratio definition. - /// - /// - Note: From the AT Protocol specification: "width:height represents an aspect ratio. - /// It may be approximate, and may not correspond to absolute dimensions in any given unit." - /// - /// - SeeAlso: This is based on the [`app.bsky.embed.images`][github] lexicon. - /// - /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/images.json - public struct AspectRatio: Codable { + /// A data model for the aspect ratio definition. + /// + /// - Note: From the AT Protocol specification: "width:height represents an aspect ratio. + /// It may be approximate, and may not correspond to absolute dimensions in any + /// given unit." + /// + /// - SeeAlso: This is based on the [`app.bsky.embed.images`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/images.json + public struct AspectRatio: Codable { - /// The width of the image. - public let width: Int + /// The width of the image. + public let width: Int - /// The height of the image. - public let height: Int + /// The height of the image. + public let height: Int - public init(width: Int, height: Int) { - self.width = width - self.height = height + public init(width: Int, height: Int) { + self.width = width + self.height = height + } } - } - - /// A data model for the embed images definition. - /// - /// - SeeAlso: This is based on the [`app.bsky.embed.images`][github] lexicon. - /// - /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/images.json - public struct ImagesView: Codable { - /// The identifier of the lexicon. + /// A data model for the embed images definition. /// - /// - Warning: The value must not change. - // public let type: String = "app.bsky.embed.images#view" - /// An array of images to be viewed. - public let images: [ViewImage] - } - - /// A data model for a definition related to viewing an image. - /// - /// - SeeAlso: This is based on the [`app.bsky.embed.images`][github] lexicon. - /// - /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/images.json - public struct ViewImage: Codable { - - /// The URI of the image's thumbnail. - /// - /// - Note: From the AT Protocol specification: "Fully-qualified URL where a thumbnail of - /// the image can be fetched. For example, CDN location provided by the App View." - public let thumbnailImageURL: URL - - /// The URI of the fully-sized image. + /// - SeeAlso: This is based on the [`app.bsky.embed.images`][github] lexicon. /// - /// - Note: From the AT Protocol specification: "Fully-qualified URL where a large version - /// of the image can be fetched. May or may not be the exact original blob. For example, - /// CDN location provided by the App View." - public let fullSizeImageURL: URL + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/images.json + public struct View: Codable { - /// /// The alternative text for the image. - /// - /// - Note: From the AT Protocol specification: "Alt text description of the image, - /// for accessibility." - public let altText: String - - /// The aspect ratio of the image. Optional. - public let aspectRatio: AspectRatio? - - public init(thumbnailImageURL: URL, fullSizeImageURL: URL, altText: String, aspectRatio: AspectRatio?) { - self.thumbnailImageURL = thumbnailImageURL - self.fullSizeImageURL = fullSizeImageURL - self.altText = altText - self.aspectRatio = aspectRatio + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. An array of images to be viewed. + public let images: [ViewImage] } - enum CodingKeys: String, CodingKey { - case thumbnailImageURL = "thumb" - case fullSizeImageURL = "fullsize" - case altText = "alt" - case aspectRatio + /// A data model for a definition related to viewing an image. + /// + /// - SeeAlso: This is based on the [`app.bsky.embed.images`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/images.json + public struct ViewImage: Codable { + + /// The URI of the image's thumbnail. + /// + /// - Note: From the AT Protocol specification: "Fully-qualified URL where a thumbnail + /// of the image can be fetched. For example, CDN location provided by the App View." + public let thumbnailImageURL: URL + + /// The URI of the fully-sized image. + /// + /// - Note: From the AT Protocol specification: "Fully-qualified URL where a large + /// version of the image can be fetched. May or may not be the exact original blob. + /// For example, CDN location provided by the App View." + public let fullSizeImageURL: URL + + /// /// The alternative text for the image. + /// + /// - Note: From the AT Protocol specification: "Alt text description of the image, + /// for accessibility." + public let altText: String + + /// The aspect ratio of the image. Optional. + public let aspectRatio: AspectRatio? + + public init(thumbnailImageURL: URL, fullSizeImageURL: URL, altText: String, aspectRatio: AspectRatio?) { + self.thumbnailImageURL = thumbnailImageURL + self.fullSizeImageURL = fullSizeImageURL + self.altText = altText + self.aspectRatio = aspectRatio + } + + enum CodingKeys: String, CodingKey { + case thumbnailImageURL = "thumb" + case fullSizeImageURL = "fullsize" + case altText = "alt" + case aspectRatio + } } } } diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedRecord.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedRecord.swift index 868486b367..452d6ec8e1 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedRecord.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedRecord.swift @@ -32,172 +32,173 @@ extension AppBskyLexicon.Embed { case type = "$type" case record } - } - // MARK: - - /// A data model for a view definition. - /// - /// - SeeAlso: This is based on the [`app.bsky.embed.record`][github] lexicon. - /// - /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/record.json - public struct RecordView: Codable { - - /// The identifier of the lexicon. + // Enums + /// A data model for a view definition. /// - /// - Warning: The value must not change. - public let type: String = "app.bsky.embed.record#view" - - /// The record of a specific type. - public let record: ATUnion.RecordViewUnion - - enum CodingKeys: String, CodingKey { - case type = "$type" - case record - } - } - - /// A data model for a record definition in an embed. - /// - /// - SeeAlso: This is based on the [`app.bsky.embed.record`][github] lexicon. - /// - /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/record.json - public struct ViewRecord: Codable { - - /// The identifier of the lexicon. + /// - SeeAlso: This is based on the [`app.bsky.embed.record`][github] lexicon. /// - /// - Warning: The value must not change. - public let type: String = "app.bsky.embed.record#viewRecord" - - /// The URI of the record. - public let recordURI: String + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/record.json + public struct View: Codable { - /// The CID of the record. - public let cidHash: String + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. + public let type: String = "app.bsky.embed.record#view" - /// The creator of the record. - public let author: AppBskyLexicon.Actor.ProfileViewBasicDefinition + /// The record of a specific type. + public let record: ATUnion.RecordViewUnion - /// The value of the record. - /// - /// - Note: According to the AT Protocol specifications: "The record data itself." - public let value: UnknownType - - /// An array of labels attached to the record. - public let labels: [Label]? - - /// The number of replies for the record. Optional. - public let replyCount: Int? - - /// The number of reposts for the record. Optional. - public let repostCount: Int? - - /// The number of likes for the record. Optional. - public let likeCount: Int? - - /// An array of embed views of various types. - public let embeds: [ATUnion.EmbedViewUnion]? - - /// The date the record was last indexed. - @DateFormatting public var indexedAt: Date - - public init(recordURI: String, cidHash: String, author: AppBskyLexicon.Actor.ProfileViewBasicDefinition, value: UnknownType, labels: [Label]?, - replyCount: Int?, repostCount: Int?, likeCount: Int?, embeds: [ATUnion.EmbedViewUnion]?, indexedAt: Date) { - self.recordURI = recordURI - self.cidHash = cidHash - self.author = author - self.value = value - self.labels = labels - self.replyCount = replyCount - self.repostCount = repostCount - self.likeCount = likeCount - self.embeds = embeds - self._indexedAt = DateFormatting(wrappedValue: indexedAt) + enum CodingKeys: String, CodingKey { + case type = "$type" + case record + } } - public init(from decoder: any Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.recordURI = try container.decode(String.self, forKey: .recordURI) - self.cidHash = try container.decode(String.self, forKey: .cidHash) - self.author = try container.decode(AppBskyLexicon.Actor.ProfileViewBasicDefinition.self, forKey: .author) - self.value = try container.decode(UnknownType.self, forKey: .value) - self.labels = try container.decodeIfPresent([Label].self, forKey: .labels) - self.replyCount = try container.decodeIfPresent(Int.self, forKey: .replyCount) - self.repostCount = try container.decodeIfPresent(Int.self, forKey: .repostCount) - self.likeCount = try container.decodeIfPresent(Int.self, forKey: .likeCount) - self.embeds = try container.decodeIfPresent([ATUnion.EmbedViewUnion].self, forKey: .embeds) - self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue - } - - public func encode(to encoder: any Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self.recordURI, forKey: .recordURI) - try container.encode(self.cidHash, forKey: .cidHash) - try container.encode(self.author, forKey: .author) - try container.encode(self.value, forKey: .value) - try container.encodeIfPresent(self.labels, forKey: .labels) - try container.encodeIfPresent(self.replyCount, forKey: .replyCount) - try container.encodeIfPresent(self.repostCount, forKey: .repostCount) - try container.encodeIfPresent(self.likeCount, forKey: .likeCount) - try container.encodeIfPresent(self.embeds, forKey: .embeds) - try container.encode(self._indexedAt, forKey: .indexedAt) - } - - enum CodingKeys: String, CodingKey { - case type = "$type" - case recordURI = "uri" - case cidHash = "cid" - case author - case value - case labels - case replyCount - case repostCount - case likeCount - case embeds = "embeds" - case indexedAt + /// A data model for a record definition in an embed. + /// + /// - SeeAlso: This is based on the [`app.bsky.embed.record`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/record.json + public struct ViewRecord: Codable { + + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. + public let type: String = "app.bsky.embed.record#viewRecord" + + /// The URI of the record. + public let recordURI: String + + /// The CID of the record. + public let cidHash: String + + /// The creator of the record. + public let author: AppBskyLexicon.Actor.ProfileViewBasicDefinition + + /// The value of the record. + /// + /// - Note: According to the AT Protocol specifications: "The record data itself." + public let value: UnknownType + + /// An array of labels attached to the record. + public let labels: [ComAtprotoLexicon.Label.LabelDefinition]? + + /// The number of replies for the record. Optional. + public let replyCount: Int? + + /// The number of reposts for the record. Optional. + public let repostCount: Int? + + /// The number of likes for the record. Optional. + public let likeCount: Int? + + /// An array of embed views of various types. + public let embeds: [ATUnion.EmbedViewUnion]? + + /// The date the record was last indexed. + @DateFormatting public var indexedAt: Date + + public init(recordURI: String, cidHash: String, author: AppBskyLexicon.Actor.ProfileViewBasicDefinition, value: UnknownType, + labels: [ComAtprotoLexicon.Label.LabelDefinition]?, replyCount: Int?, repostCount: Int?, likeCount: Int?, + embeds: [ATUnion.EmbedViewUnion]?, indexedAt: Date) { + self.recordURI = recordURI + self.cidHash = cidHash + self.author = author + self.value = value + self.labels = labels + self.replyCount = replyCount + self.repostCount = repostCount + self.likeCount = likeCount + self.embeds = embeds + self._indexedAt = DateFormatting(wrappedValue: indexedAt) + } + + public init(from decoder: any Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.recordURI = try container.decode(String.self, forKey: .recordURI) + self.cidHash = try container.decode(String.self, forKey: .cidHash) + self.author = try container.decode(AppBskyLexicon.Actor.ProfileViewBasicDefinition.self, forKey: .author) + self.value = try container.decode(UnknownType.self, forKey: .value) + self.labels = try container.decodeIfPresent([ComAtprotoLexicon.Label.LabelDefinition].self, forKey: .labels) + self.replyCount = try container.decodeIfPresent(Int.self, forKey: .replyCount) + self.repostCount = try container.decodeIfPresent(Int.self, forKey: .repostCount) + self.likeCount = try container.decodeIfPresent(Int.self, forKey: .likeCount) + self.embeds = try container.decodeIfPresent([ATUnion.EmbedViewUnion].self, forKey: .embeds) + self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue + } + + public func encode(to encoder: any Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.recordURI, forKey: .recordURI) + try container.encode(self.cidHash, forKey: .cidHash) + try container.encode(self.author, forKey: .author) + try container.encode(self.value, forKey: .value) + try container.encodeIfPresent(self.labels, forKey: .labels) + try container.encodeIfPresent(self.replyCount, forKey: .replyCount) + try container.encodeIfPresent(self.repostCount, forKey: .repostCount) + try container.encodeIfPresent(self.likeCount, forKey: .likeCount) + try container.encodeIfPresent(self.embeds, forKey: .embeds) + try container.encode(self._indexedAt, forKey: .indexedAt) + } + + enum CodingKeys: String, CodingKey { + case type = "$type" + case recordURI = "uri" + case cidHash = "cid" + case author + case value + case labels + case replyCount + case repostCount + case likeCount + case embeds = "embeds" + case indexedAt + } } - } - /// A data model for a definition of a record that was unable to be found. - /// - /// - SeeAlso: This is based on the [`app.bsky.embed.record`][github] lexicon. - /// - /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/record.json - public struct ViewNotFound: Codable { + /// A data model for a definition of a record that was unable to be found. + /// + /// - SeeAlso: This is based on the [`app.bsky.embed.record`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/record.json + public struct ViewNotFound: Codable { - /// The URI of the record. - public let recordURI: String + /// The URI of the record. + public let recordURI: String - /// Indicates whether the record was found. - public let isRecordNotFound: Bool + /// Indicates whether the record was found. + public let isRecordNotFound: Bool - enum CodingKeys: String, CodingKey { - case recordURI = "uri" - case isRecordNotFound = "notFound" + enum CodingKeys: String, CodingKey { + case recordURI = "uri" + case isRecordNotFound = "notFound" + } } - } - /// A data model for a definition of a record that has been blocked. - /// - /// - SeeAlso: This is based on the [`app.bsky.embed.record`][github] lexicon. - /// - /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/record.json - public struct ViewBlocked: Codable { + /// A data model for a definition of a record that has been blocked. + /// + /// - SeeAlso: This is based on the [`app.bsky.embed.record`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/record.json + public struct ViewBlocked: Codable { - /// The URI of the record. - public let recordURI: String + /// The URI of the record. + public let recordURI: String - /// Indicates whether the record has been blocked. - public let isRecordBlocked: Bool + /// Indicates whether the record has been blocked. + public let isRecordBlocked: Bool - /// The author of the record. - public let recordAuthor: FeedBlockedAuthor + /// The author of the record. + public let recordAuthor: AppBskyLexicon.Feed.BlockedAuthorDefinition - enum CodingKeys: String, CodingKey { - case recordURI = "uri" - case isRecordBlocked = "blocked" - case recordAuthor = "author" + enum CodingKeys: String, CodingKey { + case recordURI = "uri" + case isRecordBlocked = "blocked" + case recordAuthor = "author" + } } } } diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedRecordWithMedia.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedRecordWithMedia.swift index df50aa3746..4c7d50d9e6 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedRecordWithMedia.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedRecordWithMedia.swift @@ -36,31 +36,31 @@ extension AppBskyLexicon.Embed { case record case media } - } - // MARK: - - /// A data model for a definition which contains an embedded record and embedded media. - /// - /// - SeeAlso: This is based on the [`app.bsky.embed.recordWithMedia`][github] lexicon. - /// - /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/recordWithMedia.json - public struct RecordWithMediaView: Codable { - - /// The identifier of the lexicon. + // Enums + /// A data model for a definition which contains an embedded record and embedded media. /// - /// - Warning: The value must not change. - public let type: String = "app.bsky.embed.recordWithMedia#view" + /// - SeeAlso: This is based on the [`app.bsky.embed.recordWithMedia`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/recordWithMedia.json + public struct RecordWithMediaView: Codable { - /// The embeded record. - public let record: EmbedRecordView + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. + public let type: String = "app.bsky.embed.recordWithMedia#view" - /// The embedded media. - public let media: ATUnion.MediaViewUnion + /// The embeded record. + public let record: AppBskyLexicon.Embed.RecordDefinition.View - enum CodingKeys: String, CodingKey { - case type = "$type" - case record - case media + /// The embedded media. + public let media: ATUnion.MediaViewUnion + + enum CodingKeys: String, CodingKey { + case type = "$type" + case record + case media + } } } } diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedDefs.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedDefs.swift index f98b827a28..616bea1e1a 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedDefs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedDefs.swift @@ -47,14 +47,14 @@ extension AppBskyLexicon.Feed { public var viewer: ViewerStateDefinition? /// An array of labels attached to the post. Optional. - public var labels: [Label]? + public var labels: [ComAtprotoLexicon.Label.LabelDefinition]? /// The ruleset of who can reply to the post. Optional. public var threadgate: ThreadgateViewDefinition? public init(postURI: String, cidHash: String, author: AppBskyLexicon.Actor.ProfileViewBasicDefinition, record: UnknownType, embed: ATUnion.EmbedViewUnion?, replyCount: Int?, repostCount: Int?, likeCount: Int?, indexedAt: Date, viewer: ViewerStateDefinition?, - labels: [Label]?, threadgate: ThreadgateViewDefinition?) { + labels: [ComAtprotoLexicon.Label.LabelDefinition]?, threadgate: ThreadgateViewDefinition?) { self.postURI = postURI self.cidHash = cidHash self.author = author @@ -82,7 +82,7 @@ extension AppBskyLexicon.Feed { self.likeCount = try container.decodeIfPresent(Int.self, forKey: .likeCount) self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue self.viewer = try container.decodeIfPresent(ViewerStateDefinition.self, forKey: .viewer) - self.labels = try container.decodeIfPresent([Label].self, forKey: .labels) + self.labels = try container.decodeIfPresent([ComAtprotoLexicon.Label.LabelDefinition].self, forKey: .labels) self.threadgate = try container.decodeIfPresent(ThreadgateViewDefinition.self, forKey: .threadgate) } diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedDescribeFeedGenerator.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedDescribeFeedGenerator.swift index a779fe8fa5..36df009bf2 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedDescribeFeedGenerator.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedDescribeFeedGenerator.swift @@ -35,6 +35,7 @@ extension AppBskyLexicon.Feed { case links } + // Enums /// A data model definiion for the feed generator. public struct Feed: Codable { diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetAuthorFeed.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetAuthorFeed.swift index 4b55b0d061..8b1de79746 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetAuthorFeed.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetAuthorFeed.swift @@ -9,6 +9,29 @@ import Foundation extension AppBskyLexicon.Feed { + /// The main data model seeing the user account's posts and reposts. + public struct GetAuthorFeed: Codable { + + /// Indicates the kind of combinations of posts and reposts for the feed's array. + /// + /// - Note: According to the AT Protocol specifications: "Combinations of post/repost types to + /// include in response." + public enum GetAuthorFeedFilter: String { + + /// Indicates the array of feeds will contain posts with replies. + case postsWithReplies = "posts_with_replies" + + /// Indicates the array of feeds will contain posts with no replies. + case postsWithNoReplies = "posts_no_replies" + + /// Indicates the array of feeds will contain posts with media. + case postsWithMedia = "posts_with_media" + + /// Indicates the array of feeds will contain posts that are threads. + case postAndAuthorThreads = "posts_and_author_threads" + } + } + /// An output model for seeing the user account's posts and reposts. /// /// - Note: According to the AT Protocol specifications: "Get a view of an actor's @@ -25,23 +48,4 @@ extension AppBskyLexicon.Feed { /// An array of like records. public let feed: [FeedViewPostDefinition] } - - /// Indicates the kind of combinations of posts and reposts for the feed's array. - /// - /// - Note: According to the AT Protocol specifications: "Combinations of post/repost types to - /// include in response." - public enum GetAuthorFeedFilter: String { - - /// Indicates the array of feeds will contain posts with replies. - case postsWithReplies = "posts_with_replies" - - /// Indicates the array of feeds will contain posts with no replies. - case postsWithNoReplies = "posts_no_replies" - - /// Indicates the array of feeds will contain posts with media. - case postsWithMedia = "posts_with_media" - - /// Indicates the array of feeds will contain posts that are threads. - case postAndAuthorThreads = "posts_and_author_threads" - } } diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeed.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeed.swift index 23ffe1fa17..6d83f1c326 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeed.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeed.swift @@ -23,6 +23,6 @@ extension AppBskyLexicon.Feed { public let cursor: String? /// An array of posts in the feed. - public let feed: [FeedViewPostDefinition] + public let feed: [ViewerStateDefinition] } } diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeedGenerator.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeedGenerator.swift index f7b4645c7f..e3497076ba 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeedGenerator.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeedGenerator.swift @@ -33,6 +33,5 @@ extension AppBskyLexicon.Feed { /// - Note: According to the AT Protocol specifications: "Indicates whether the /// feed generator service is compatible with the record declaration." public let isValid: Bool - } } diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeedGenerators.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeedGenerators.swift index e685b7b4e6..0c97c502a3 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeedGenerators.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeedGenerators.swift @@ -17,7 +17,7 @@ extension AppBskyLexicon.Feed { /// - SeeAlso: This is based on the [`app.bsky.feed.getFeedGenerators`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getFeedGenerator.json - public struct FeedGetFeedGeneratorsOutput: Codable { + public struct GetFeedGeneratorsOutput: Codable { /// An array of feed generators. public let feeds: [GeneratorViewDefinition] diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetLikes.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetLikes.swift index 4c39fc1f23..6800a239c5 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetLikes.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetLikes.swift @@ -29,7 +29,7 @@ extension AppBskyLexicon.Feed { public let cursor: String? /// An array of like records. - public let likes: [GetLikesLike] + public let likes: [Like] enum CodingKeys: String, CodingKey { case recordURI = "uri" @@ -37,48 +37,49 @@ extension AppBskyLexicon.Feed { case cursor case likes } - } - - /// A data model definition of the like record itself. - /// - /// - SeeAlso: This is based on the [`app.bsky.feed.getLikes`][github] lexicon. - /// - /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getLikes.json - public struct GetLikesLike: Codable { - - /// The date and time the like record was indexed. - @DateFormatting public var indexedAt: Date - - /// The date and time the like record was created. - @DateFormatting public var createdAt: Date - - /// The user that created the like record. - public let actor: ActorProfileView - - public init(indexedAt: Date, createdAt: Date, actor: ActorProfileView) { - self._indexedAt = DateFormatting(wrappedValue: indexedAt) - self._createdAt = DateFormatting(wrappedValue: createdAt) - self.actor = actor - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue - self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue - self.actor = try container.decode(ActorProfileView.self, forKey: .actor) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(self._indexedAt, forKey: .indexedAt) - try container.encode(self._createdAt, forKey: .createdAt) - try container.encode(self.actor, forKey: .actor) - } - - public enum CodingKeys: CodingKey { - case indexedAt - case createdAt - case actor + + // Enums + /// A data model definition of the like record itself. + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.getLikes`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getLikes.json + public struct Like: Codable { + + /// The date and time the like record was indexed. + @DateFormatting public var indexedAt: Date + + /// The date and time the like record was created. + @DateFormatting public var createdAt: Date + + /// The user that created the like record. + public let actor: AppBskyLexicon.Actor.ProfileViewDefinition + + public init(indexedAt: Date, createdAt: Date, actor: AppBskyLexicon.Actor.ProfileViewDefinition) { + self._indexedAt = DateFormatting(wrappedValue: indexedAt) + self._createdAt = DateFormatting(wrappedValue: createdAt) + self.actor = actor + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue + self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue + self.actor = try container.decode(AppBskyLexicon.Actor.ProfileViewDefinition.self, forKey: .actor) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(self._indexedAt, forKey: .indexedAt) + try container.encode(self._createdAt, forKey: .createdAt) + try container.encode(self.actor, forKey: .actor) + } + + public enum CodingKeys: CodingKey { + case indexedAt + case createdAt + case actor + } } } } diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedPost.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedPost.swift index 9c6eff51fe..8c3a9d651a 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedPost.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedPost.swift @@ -39,7 +39,7 @@ extension AppBskyLexicon.Feed { public var facets: [AppBskyLexicon.RichText.Facet]? /// The references to posts when replying. Optional. - public var reply: PostReplyReference? + public var reply: ReplyReference? /// The embed of the post. Optional. public var embed: ATUnion.EmbedUnion? @@ -75,7 +75,7 @@ extension AppBskyLexicon.Feed { /// post was originally created." @DateFormatting public var createdAt: Date - public init(text: String, facets: [AppBskyLexicon.RichText.Facet]?, reply: PostReplyReference?, embed: ATUnion.EmbedUnion?, languages: [String]?, + public init(text: String, facets: [AppBskyLexicon.RichText.Facet]?, reply: ReplyReference?, embed: ATUnion.EmbedUnion?, languages: [String]?, labels: ATUnion.FeedLabelUnion?, tags: [String]?, createdAt: Date) { self.text = text self.facets = facets @@ -92,7 +92,7 @@ extension AppBskyLexicon.Feed { self.text = try container.decode(String.self, forKey: .text) self.facets = try container.decodeIfPresent([AppBskyLexicon.RichText.Facet].self, forKey: .facets) - self.reply = try container.decodeIfPresent(PostReplyReference.self, forKey: .reply) + self.reply = try container.decodeIfPresent(ReplyReference.self, forKey: .reply) self.embed = try container.decodeIfPresent(ATUnion.EmbedUnion.self, forKey: .embed) self.languages = try container.decodeIfPresent([String].self, forKey: .languages) self.labels = try container.decodeIfPresent(ATUnion.FeedLabelUnion.self, forKey: .labels) @@ -136,23 +136,23 @@ extension AppBskyLexicon.Feed { case tags case createdAt } - } - // MARK: - - /// A data model for a reply reference definition. - /// - /// - SeeAlso: This is based on the [`app.bsky.feed.post`][github] lexicon. - /// - /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/post.json - public struct PostReplyReference: Codable { + // Enums + /// A data model for a reply reference definition. + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.post`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/post.json + public struct ReplyReference: Codable { - /// The original post of the thread. - public let root: StrongReference + /// The original post of the thread. + public let root: StrongReference - /// The direct post that the user's post is replying to. - /// - /// - Note: If `parent` and `root` are identical, the post is a direct reply to the original - /// post of the thread. - public let parent: StrongReference + /// The direct post that the user's post is replying to. + /// + /// - Note: If `parent` and `root` are identical, the post is a direct reply to the original + /// post of the thread. + public let parent: StrongReference + } } } diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedThreadgate.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedThreadgate.swift index 30cee40ada..8573e592f7 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedThreadgate.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedThreadgate.swift @@ -65,26 +65,27 @@ extension AppBskyLexicon.Feed { case allow case createdAt } - } - /// A rule that indicates whether users that the post author mentions can reply to the post. - /// - /// - Note: According to the AT Protocol specifications: "Allow replies from actors mentioned - /// in your post." - public struct FeedThreadgateMentionRule: Codable {} + // Enums + /// A rule that indicates whether users that the post author mentions can reply to the post. + /// + /// - Note: According to the AT Protocol specifications: "Allow replies from actors mentioned + /// in your post." + public struct MentionRule: Codable {} - /// A rule that indicates whether users that the post author is following can reply to the post. - /// - /// - Note: According to the AT Protocol specifications: "Allow replies from actors you follow." - public struct FeedThreadgateFollowingRule: Codable {} + /// A rule that indicates whether users that the post author is following can reply to the post. + /// + /// - Note: According to the AT Protocol specifications: "Allow replies from actors you follow." + public struct FollowingRule: Codable {} - /// A rule that indicates whether users that are on a specific list made by the post author can - /// reply to the post. - /// - /// - Note: According to the AT Protocol specifications: "Allow replies from actors on a list." - public struct FeedThreadgateListRule: Codable { + /// A rule that indicates whether users that are on a specific list made by the post author can + /// reply to the post. + /// + /// - Note: According to the AT Protocol specifications: "Allow replies from actors on a list." + public struct ListRule: Codable { - /// The list itself. - public let list: String + /// The list itself. + public let list: String + } } } diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetListMutes.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetListMutes.swift index 9f1d331bcd..a8fe24cf9e 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetListMutes.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetListMutes.swift @@ -23,6 +23,6 @@ extension AppBskyLexicon.Graph { public let cursor: String? /// An array of lists the user account is muting. - public let lists: [GraphListView] + public let lists: [AppBskyLexicon.Graph.ListViewDefinition] } } diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphList.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphList.swift index 2b2c2010a1..d80c60d923 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphList.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphList.swift @@ -44,16 +44,16 @@ extension AppBskyLexicon.Graph { public let descriptionFacets: [Facet]? /// The avatar image of the list. Optional. - public let avatarImage: UploadBlobOutput? + public let avatarImage: ComAtprotoLexicon.Repository.UploadBlobOutput? /// The user-defined labels for the list. Optional. - public let labels: SelfLabels + public let labels: ComAtprotoLexicon.Label.SelfLabelsDefinition /// The date and time the list was created. @DateFormatting public var createdAt: Date - public init(name: String, purpose: ListPurpose, description: String?, descriptionFacets: [Facet]?, avatarImage: UploadBlobOutput?, - labels: SelfLabels, createdAt: Date) { + public init(name: String, purpose: ListPurpose, description: String?, descriptionFacets: [Facet]?, + avatarImage: ComAtprotoLexicon.Repository.UploadBlobOutput?, labels: ComAtprotoLexicon.Label.SelfLabelsDefinition, createdAt: Date) { self.name = name self.purpose = purpose self.description = description @@ -70,8 +70,8 @@ extension AppBskyLexicon.Graph { self.purpose = try container.decode(ListPurpose.self, forKey: .purpose) self.description = try container.decodeIfPresent(String.self, forKey: .description) self.descriptionFacets = try container.decodeIfPresent([Facet].self, forKey: .descriptionFacets) - self.avatarImage = try container.decodeIfPresent(UploadBlobOutput.self, forKey: .avatarImage) - self.labels = try container.decode(SelfLabels.self, forKey: .labels) + self.avatarImage = try container.decodeIfPresent(ComAtprotoLexicon.Repository.UploadBlobOutput.self, forKey: .avatarImage) + self.labels = try container.decode(ComAtprotoLexicon.Label.SelfLabelsDefinition.self, forKey: .labels) self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue } diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerDefs.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerDefs.swift index 237cfeab67..34436b7914 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerDefs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerDefs.swift @@ -35,10 +35,10 @@ extension AppBskyLexicon.Labeler { @DateFormatting public var indexedAt: Date /// An array of labels. Optional. - public let labels: [Label]? + public let labels: [ComAtprotoLexicon.Label.LabelDefinition]? public init(labelerURI: String, labelerCIDHash: String, creator: AppBskyLexicon.Actor.ProfileViewDefinition, likeCount: Int?, - viewer: LabelerViewerStateDefinition?, indexedAt: Date, labels: [Label]?) { + viewer: LabelerViewerStateDefinition?, indexedAt: Date, labels: [ComAtprotoLexicon.Label.LabelDefinition]?) { self.labelerURI = labelerURI self.labelerCIDHash = labelerCIDHash self.creator = creator @@ -57,7 +57,7 @@ extension AppBskyLexicon.Labeler { self.likeCount = try container.decodeIfPresent(Int.self, forKey: .likeCount) self.viewer = try container.decodeIfPresent(LabelerViewerStateDefinition.self, forKey: .viewer) self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue - self.labels = try container.decodeIfPresent([Label].self, forKey: .labels) + self.labels = try container.decodeIfPresent([ComAtprotoLexicon.Label.LabelDefinition].self, forKey: .labels) } public func encode(to encoder: any Encoder) throws { @@ -116,10 +116,10 @@ extension AppBskyLexicon.Labeler { @DateFormatting public var indexedAt: Date /// An array of labels. Optional. - public let labels: [Label]? + public let labels: [ComAtprotoLexicon.Label.LabelDefinition]? public init(labelerURI: String, labelerCIDHash: String, creator: AppBskyLexicon.Actor.ProfileViewDefinition, policies: LabelerPolicies, - likeCount: Int?, viewer: LabelerViewerState?, indexedAt: Date, labels: [Label]?) { + likeCount: Int?, viewer: LabelerViewerState?, indexedAt: Date, labels: [ComAtprotoLexicon.Label.LabelDefinition]?) { self.labelerURI = labelerURI self.labelerCIDHash = labelerCIDHash self.creator = creator @@ -140,7 +140,7 @@ extension AppBskyLexicon.Labeler { self.likeCount = try container.decodeIfPresent(Int.self, forKey: .likeCount) self.viewer = try container.decodeIfPresent(LabelerViewerState.self, forKey: .viewer) self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue - self.labels = try container.decodeIfPresent([Label].self, forKey: .labels) + self.labels = try container.decodeIfPresent([ComAtprotoLexicon.Label.LabelDefinition].self, forKey: .labels) } public func encode(to encoder: any Encoder) throws { @@ -195,7 +195,7 @@ extension AppBskyLexicon.Labeler { /// - Note: According to the AT Protocol specifications: "The label values which this labeler /// publishes. May include global /// or custom labels." - public let labelValues: [LabelValueDefinition] + public let labelValues: [ComAtprotoLexicon.Label.LabelValueDefinition] /// An array of labeler-created labels. /// @@ -204,6 +204,6 @@ extension AppBskyLexicon.Labeler { /// - Note: According to the AT Protocol specifications: "Label values created by this labeler /// and scoped exclusively to it. Labels defined here will override global label definitions /// for this labeler." - public let labelValueDefinitions: [LabelValueDefinition] + public let labelValueDefinitions: [ComAtprotoLexicon.Label.LabelValueDefinition] } } diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerService.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerService.swift index 007b0878c2..3214b1f28a 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerService.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerService.swift @@ -28,12 +28,12 @@ extension AppBskyLexicon.Labeler { public let policies: LabelerPolicies /// An array of labels the labeler uses. Optional. - public let labels: [SelfLabels]? + public let labels: [ComAtprotoLexicon.Label.SelfLabelDefinition]? /// The date and time the labeler service was created. @DateFormatting public var createdAt: Date - public init(policies: LabelerPolicies, labels: [SelfLabels], createdAt: Date) { + public init(policies: LabelerPolicies, labels: [ComAtprotoLexicon.Label.SelfLabelDefinition], createdAt: Date) { self.policies = policies self.labels = labels self._createdAt = DateFormatting(wrappedValue: createdAt) @@ -43,7 +43,7 @@ extension AppBskyLexicon.Labeler { let container = try decoder.container(keyedBy: CodingKeys.self) self.policies = try container.decode(LabelerPolicies.self, forKey: .policies) - self.labels = try container.decode([SelfLabels].self, forKey: .labels) + self.labels = try container.decode([ComAtprotoLexicon.Label.SelfLabelDefinition].self, forKey: .labels) self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue } diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/AppBskyNotificationListNotifications.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/AppBskyNotificationListNotifications.swift index d9070cad78..38b663bd40 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/AppBskyNotificationListNotifications.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/AppBskyNotificationListNotifications.swift @@ -61,10 +61,10 @@ extension AppBskyLexicon.Notification { @DateFormatting public var indexedAt: Date /// An array of labels. Optional. - public let labels: [Label]? + public let labels: [ComAtprotoLexicon.Label.LabelDefinition]? public init(notificationURI: String, notificationCID: String, notificationAuthor: String, notificationReason: Reason, reasonSubjectURI: String, - record: UnknownType, isRead: Bool, indexedAt: Date, labels: [Label]) { + record: UnknownType, isRead: Bool, indexedAt: Date, labels: [ComAtprotoLexicon.Label.LabelDefinition]) { self.notificationURI = notificationURI self.notificationCID = notificationCID self.notificationAuthor = notificationAuthor @@ -87,7 +87,7 @@ extension AppBskyLexicon.Notification { self.record = try container.decode(UnknownType.self, forKey: .record) self.isRead = try container.decode(Bool.self, forKey: .isRead) self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue - self.labels = try container.decodeIfPresent([Label].self, forKey: .labels) + self.labels = try container.decodeIfPresent([ComAtprotoLexicon.Label.LabelDefinition].self, forKey: .labels) } public func encode(to encoder: any Encoder) throws { diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/RichText/AppBskyRichTextFacet.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/RichText/AppBskyRichTextFacet.swift index 2a39d13293..fb13518323 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/RichText/AppBskyRichTextFacet.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/RichText/AppBskyRichTextFacet.swift @@ -48,191 +48,192 @@ extension AppBskyLexicon.RichText { case index case features } - } - // Represents the ByteSlice - /// The data model definition for the byte slice. - /// - /// - Note: According to the AT Protocol specifications: "Specifies the sub-string range a - /// facet feature applies to. Start index is inclusive, end index is exclusive. Indices are - /// zero-indexed, counting bytes of the UTF-8 encoded text. NOTE: some languages, like - /// Javascript, use UTF-16 or Unicode codepoints for string slice indexing; in these - /// languages, convert to byte arrays before working with facets." - /// - /// - SeeAlso: This is based on the [`app.bsky.richtext.facet`][github] lexicon. - /// - /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/richtext/facet.json - public struct ByteSlice: Codable { + // Enums + // Represents the ByteSlice + /// The data model definition for the byte slice. + /// + /// - Note: According to the AT Protocol specifications: "Specifies the sub-string range a + /// facet feature applies to. Start index is inclusive, end index is exclusive. Indices are + /// zero-indexed, counting bytes of the UTF-8 encoded text. NOTE: some languages, like + /// Javascript, use UTF-16 or Unicode codepoints for string slice indexing; in these + /// languages, convert to byte arrays before working with facets." + /// + /// - SeeAlso: This is based on the [`app.bsky.richtext.facet`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/richtext/facet.json + public struct ByteSlice: Codable { - /// The start index of the byte slice. - public let byteStart: Int + /// The start index of the byte slice. + public let byteStart: Int - /// The end index of the byte slice. - public let byteEnd: Int + /// The end index of the byte slice. + public let byteEnd: Int - public init(byteStart: Int, byteEnd: Int) { - self.byteStart = byteStart - self.byteEnd = byteEnd - } + public init(byteStart: Int, byteEnd: Int) { + self.byteStart = byteStart + self.byteEnd = byteEnd + } - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) - self.byteStart = try container.decode(Int.self, forKey: .byteStart) - self.byteEnd = try container.decode(Int.self, forKey: .byteEnd) - } + self.byteStart = try container.decode(Int.self, forKey: .byteStart) + self.byteEnd = try container.decode(Int.self, forKey: .byteEnd) + } - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(self.byteStart, forKey: .byteStart) - try container.encode(self.byteEnd, forKey: .byteEnd) - } + try container.encode(self.byteStart, forKey: .byteStart) + try container.encode(self.byteEnd, forKey: .byteEnd) + } - enum CodingKeys: String, CodingKey { - case byteStart - case byteEnd + enum CodingKeys: String, CodingKey { + case byteStart + case byteEnd + } } - } - /// A data model protocol for Features. - /// - /// - SeeAlso: This is based on the [`app.bsky.richtext.facet`][github] lexicon. - /// - /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/richtext/facet.json - internal protocol FeatureCodable: Codable { - - /// The identifier of the lexicon. + /// A data model protocol for Features. /// - /// - Warning: The value must not change. - static var type: String { get } - } + /// - SeeAlso: This is based on the [`app.bsky.richtext.facet`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/richtext/facet.json + internal protocol FeatureCodable: Codable { - /// A data model for the Mention feature definition. - /// - /// - Note: According to the AT Protocol specifications: "Facet feature for mention of - /// another account. The text is usually a handle, including a '@' prefix, but the facet - /// reference is a DID." - /// - /// - SeeAlso: This is based on the [`app.bsky.richtext.facet`][github] lexicon. - /// - /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/richtext/facet.json - public struct Mention: FeatureCodable { + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. + static var type: String { get } + } - /// The identifier of the lexicon. + /// A data model for the Mention feature definition. + /// + /// - Note: According to the AT Protocol specifications: "Facet feature for mention of + /// another account. The text is usually a handle, including a '@' prefix, but the facet + /// reference is a DID." + /// + /// - SeeAlso: This is based on the [`app.bsky.richtext.facet`][github] lexicon. /// - /// - Warning: The value must not change. - public static var type: String = "app.bsky.richtext.facet#mention" + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/richtext/facet.json + public struct Mention: FeatureCodable { - /// The decentralized identifier (DID) of the feature. - public let did: String + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. + public static var type: String = "app.bsky.richtext.facet#mention" - public init(did: String) { - self.did = did - } + /// The decentralized identifier (DID) of the feature. + public let did: String - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) + public init(did: String) { + self.did = did + } - self.did = try container.decode(String.self, forKey: .did) - Mention.type = try container.decode(String.self, forKey: .type) - } + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) + self.did = try container.decode(String.self, forKey: .did) + Mention.type = try container.decode(String.self, forKey: .type) + } - try container.encode(self.did, forKey: .did) - try container.encode(Mention.type, forKey: .type) - } + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) - enum CodingKeys: String, CodingKey { - case type = "$type" - case did - } - } + try container.encode(self.did, forKey: .did) + try container.encode(Mention.type, forKey: .type) + } - /// A data model for the Link feature definition. - /// - /// - Note: According to the AT Protocol specifications: "Facet feature for a URL. The text URL - /// may have been simplified or truncated, but the facet reference should be a complete URL." - /// - /// - SeeAlso: This is based on the [`app.bsky.richtext.facet`][github] lexicon. - /// - /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/richtext/facet.json - public struct Link: FeatureCodable { + enum CodingKeys: String, CodingKey { + case type = "$type" + case did + } + } - /// The identifier of the lexicon. + /// A data model for the Link feature definition. /// - /// - Warning: The value must not change. - public static var type: String = "app.bsky.richtext.facet#link" + /// - Note: According to the AT Protocol specifications: "Facet feature for a URL. The text URL + /// may have been simplified or truncated, but the facet reference should be a complete URL." + /// + /// - SeeAlso: This is based on the [`app.bsky.richtext.facet`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/richtext/facet.json + public struct Link: FeatureCodable { - /// The URI of the feature. - public let uri: String + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. + public static var type: String = "app.bsky.richtext.facet#link" - public init(uri: String) { - self.uri = uri - } + /// The URI of the feature. + public let uri: String - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) + public init(uri: String) { + self.uri = uri + } - self.uri = try container.decode(String.self, forKey: .uri) - Link.type = try container.decode(String.self, forKey: .type) - } + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) + self.uri = try container.decode(String.self, forKey: .uri) + Link.type = try container.decode(String.self, forKey: .type) + } - try container.encode(self.uri, forKey: .uri) - try container.encode(Link.type, forKey: .type) - } + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) - enum CodingKeys: String, CodingKey { - case type = "$type" - case uri - } - } + try container.encode(self.uri, forKey: .uri) + try container.encode(Link.type, forKey: .type) + } - /// A data model for the Tag feature definition. - /// - /// - Note: According to the AT Protocol specifications: "Facet feature for a hashtag. The text - /// usually includes a '#' prefix, but the facet reference should not (except in the case of - /// 'double hash tags')." - /// - /// - SeeAlso: This is based on the [`app.bsky.richtext.facet`][github] lexicon. - /// - /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/richtext/facet.json - public struct Tag: FeatureCodable { + enum CodingKeys: String, CodingKey { + case type = "$type" + case uri + } + } - /// The identifier of the lexicon. + /// A data model for the Tag feature definition. + /// + /// - Note: According to the AT Protocol specifications: "Facet feature for a hashtag. The text + /// usually includes a '#' prefix, but the facet reference should not (except in the case of + /// 'double hash tags')." + /// + /// - SeeAlso: This is based on the [`app.bsky.richtext.facet`][github] lexicon. /// - /// - Warning: The value must not change. - public static var type: String = "app.bsky.richtext.facet#tag" + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/richtext/facet.json + public struct Tag: FeatureCodable { - /// The name of the tag. - public let tag: String + /// The identifier of the lexicon. + /// + /// - Warning: The value must not change. + public static var type: String = "app.bsky.richtext.facet#tag" - public init(tag: String) { - self.tag = tag - } + /// The name of the tag. + public let tag: String - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) + public init(tag: String) { + self.tag = tag + } - self.tag = try container.decode(String.self, forKey: .tag) - Tag.type = try container.decode(String.self, forKey: .type) - } + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) + self.tag = try container.decode(String.self, forKey: .tag) + Tag.type = try container.decode(String.self, forKey: .type) + } - try container.encode(self.tag, forKey: .tag) - try container.encode(Tag.type, forKey: .type) - } + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) - enum CodingKeys: String, CodingKey { - case type = "$type" - case tag + try container.encode(self.tag, forKey: .tag) + try container.encode(Tag.type, forKey: .type) + } + + enum CodingKeys: String, CodingKey { + case type = "$type" + case tag + } } } } diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedGetTaggedSuggestions.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedGetTaggedSuggestions.swift index 8c9f316719..601d3d563a 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedGetTaggedSuggestions.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedGetTaggedSuggestions.swift @@ -23,65 +23,65 @@ extension AppBskyLexicon.Unspecced { public struct GetTaggedSuggestionsOutput: Codable { /// An array of suggestions. - public let suggestions: [TaggedSuggestion] - } - - /// A data model for a tagged suggestion. - /// - /// - Important: This is an unspecced model, and as such, this is highly volatile and may - /// change or be removed at any time. Use at your own risk. - /// - /// - SeeAlso: This is based on the [`app.bsky.unspecced.getTaggedSuggestions`][github] lexicon. - /// - /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/unspecced/getTaggedSuggestions.json - public struct TaggedSuggestion: Codable { - - /// The tag attached to the suggestion. - public let tag: String - - /// Indicates whether the suggestion is a feed generator or actor (user). - public let subjectType: SubjectType - - /// The URI of the suggestion. - public let subjectURI: String - - public init(tag: String, subjectType: SubjectType, subjectURI: String) { - self.tag = tag - self.subjectType = subjectType - self.subjectURI = subjectURI - } - - public init(from decoder: any Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.tag = try container.decode(String.self, forKey: .tag) - self.subjectType = try container.decode(TaggedSuggestion.SubjectType.self, forKey: .subjectType) - self.subjectURI = try container.decode(String.self, forKey: .subjectURI) - } - - public func encode(to encoder: any Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self.tag, forKey: .tag) - try container.encode(self.subjectType, forKey: .subjectType) - try container.encode(self.subjectURI, forKey: .subjectURI) - } - - enum CodingKeys: String, CodingKey { - case tag - case subjectType - case subjectURI = "subject" - } - - // Enums - /// Indicates whether the subject of the suggestion is a feed generator or an actor (user). - public enum SubjectType: String, Codable { - - /// Indicates the subject of the suggestion is an actor (user). - case actor - - /// Indicates the subject of the suggestion is a feed generator. - case feed + public let suggestions: [Suggestion] + + /// A data model for a tagged suggestion. + /// + /// - Important: This is an unspecced model, and as such, this is highly volatile and may + /// change or be removed at any time. Use at your own risk. + /// + /// - SeeAlso: This is based on the [`app.bsky.unspecced.getTaggedSuggestions`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/unspecced/getTaggedSuggestions.json + public struct Suggestion: Codable { + + /// The tag attached to the suggestion. + public let tag: String + + /// Indicates whether the suggestion is a feed generator or actor (user). + public let subjectType: Subject + + /// The URI of the suggestion. + public let subjectURI: String + + public init(tag: String, subjectType: Subject, subjectURI: String) { + self.tag = tag + self.subjectType = subjectType + self.subjectURI = subjectURI + } + + public init(from decoder: any Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.tag = try container.decode(String.self, forKey: .tag) + self.subjectType = try container.decode(Suggestion.Subject.self, forKey: .subjectType) + self.subjectURI = try container.decode(String.self, forKey: .subjectURI) + } + + public func encode(to encoder: any Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(self.tag, forKey: .tag) + try container.encode(self.subjectType, forKey: .subjectType) + try container.encode(self.subjectURI, forKey: .subjectURI) + } + + enum CodingKeys: String, CodingKey { + case tag + case subjectType + case subjectURI = "subject" + } + + // Enums + /// Indicates whether the subject of the suggestion is a feed generator or an actor (user). + public enum Subject: String, Codable { + + /// Indicates the subject of the suggestion is an actor (user). + case actor + + /// Indicates the subject of the suggestion is a feed generator. + case feed + } } } } diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedSearchPostsSkeleton.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedSearchPostsSkeleton.swift index 48fc8c9cb9..856fb21284 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedSearchPostsSkeleton.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/AppBskyUnspeccedSearchPostsSkeleton.swift @@ -9,6 +9,31 @@ import Foundation extension AppBskyLexicon.Unspecced { + /// The main data model for retrieving the skeleton results of posts. + /// + /// - SeeAlso: This is based on the [`app.bsky.unspecced.searchPostsSkeleton`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/unspecced/searchPostsSkeleton.json + public struct SearchPostsSkeleton: Codable { + + /// Determines the ranking order for the search results. + /// + /// - Note: According to the AT Protocol specifications: "Specifies the ranking order + /// of results." + /// + /// - SeeAlso: This is based on the [`app.bsky.unspecced.searchPostsSkeleton`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/unspecced/searchPostsSkeleton.json + public enum Sort: String { + + /// Indicates the results will be sorted by the top posts. + case top + + /// Indicates the results will be sorted by the latest posts. + case latest + } + } + /// An output model for retrieving the skeleton results of posts. /// /// - Important: This is an unspecced model, and as such, this is highly volatile and may @@ -38,21 +63,4 @@ extension AppBskyLexicon.Unspecced { /// An array of posts. public let posts: [SkeletonSearchPostDefinition] } - - /// Determines the ranking order for the search results. - /// - /// - Note: According to the AT Protocol specifications: "Specifies the ranking order - /// of results." - /// - /// - SeeAlso: This is based on the [`app.bsky.unspecced.searchPostsSkeleton`][github] lexicon. - /// - /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/unspecced/searchPostsSkeleton.json - public enum SearchPostsSortRanking: String { - - /// Indicates the results will be sorted by the top posts. - case top - - /// Indicates the results will be sorted by the latest posts. - case latest - } } diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Actor/ChatBskyActorDeclaration.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Actor/ChatBskyActorDeclaration.swift index 5e1e670e6a..a22c1f4493 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Actor/ChatBskyActorDeclaration.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Actor/ChatBskyActorDeclaration.swift @@ -31,6 +31,7 @@ extension ChatBskyLexicon.Actor { case allowIncoming } + // Enums /// A rule that states who can message the user account. public enum AllIncoming: Codable { diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Actor/ChatBskyActorDefs.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Actor/ChatBskyActorDefs.swift index 97bf6f6945..cc7d7ccaf5 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Actor/ChatBskyActorDefs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Actor/ChatBskyActorDefs.swift @@ -38,7 +38,7 @@ extension ChatBskyLexicon.Actor { public let viewer: [AppBskyLexicon.Actor.ViewerStateDefinition]? /// An array of labels created by the user. Optional. - public let labels: [Label]? + public let labels: [ComAtprotoLexicon.Label.LabelDefinition]? /// Indicates whether the user account can no longer be a part of the conversations. Optional. /// @@ -48,7 +48,7 @@ extension ChatBskyLexicon.Actor { public init(actorDID: String, actorHandle: String, displayName: String?, avatarImageURL: URL?, associated: AppBskyLexicon.Actor.ProfileAssociatedDefinition?, viewer: [AppBskyLexicon.Actor.ViewerStateDefinition]?, - labels: [Label]?, isChatDisabled: Bool?) { + labels: [ComAtprotoLexicon.Label.LabelDefinition]?, isChatDisabled: Bool?) { self.actorDID = actorDID self.actorHandle = actorHandle self.displayName = displayName @@ -68,7 +68,7 @@ extension ChatBskyLexicon.Actor { self.avatarImageURL = try container.decodeIfPresent(URL.self, forKey: .avatarImageURL) self.associated = try container.decodeIfPresent(AppBskyLexicon.Actor.ProfileAssociatedDefinition.self, forKey: .associated) self.viewer = try container.decodeIfPresent([AppBskyLexicon.Actor.ViewerStateDefinition].self, forKey: .viewer) - self.labels = try container.decodeIfPresent([Label].self, forKey: .labels) + self.labels = try container.decodeIfPresent([ComAtprotoLexicon.Label.LabelDefinition].self, forKey: .labels) self.isChatDisabled = try container.decodeIfPresent(Bool.self, forKey: .isChatDisabled) } diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoSendMessageBatch.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoSendMessageBatch.swift index 06cb4ffa10..a9e0bfd01e 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoSendMessageBatch.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoSendMessageBatch.swift @@ -9,6 +9,32 @@ import Foundation extension ChatBskyLexicon.Conversation { + /// The main data model for sending a message batch. + /// + /// - SeeAlso: This is based on the [`chat.bsky.convo.sendMessageBatch`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/sendMessageBatch.json + public struct SendMessageBatch: Codable { + /// A message batch object. + /// + /// - SeeAlso: This is based on the [`chat.bsky.convo.sendMessageBatch`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/sendMessageBatch.json + public struct MessageBatchItem: Codable { + + /// The ID of the conversation. + public let conversationID: String + + /// The message text itself. + public let message: MessageInputDefinition + + enum CodingKeys: String, CodingKey { + case conversationID = "convoId" + case message + } + } + } + /// A request body model for sending a message batch. /// /// - SeeAlso: This is based on the [`chat.bsky.convo.sendMessageBatch`][github] lexicon. @@ -17,7 +43,7 @@ extension ChatBskyLexicon.Conversation { public struct SendMessageBatchRequestBody: Codable { /// An array of messages. - public let items: [MessageBatchItem] + public let items: [SendMessageBatch.MessageBatchItem] public func encode(to encoder: any Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) @@ -36,23 +62,4 @@ extension ChatBskyLexicon.Conversation { /// An array of message views. public let items: [MessageViewDefinition] } - - /// A message batch object. - /// - /// - SeeAlso: This is based on the [`chat.bsky.convo.sendMessageBatch`][github] lexicon. - /// - /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/sendMessageBatch.json - public struct MessageBatchItem: Codable { - - /// The ID of the conversation. - public let conversationID: String - - /// The message text itself. - public let message: MessageInputDefinition - - enum CodingKeys: String, CodingKey { - case conversationID = "convoId" - case message - } - } } diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Moderation/ChatBskyModerationGetActorMetadata.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Moderation/ChatBskyModerationGetActorMetadata.swift index baeb4d7efc..c8fe80d432 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Moderation/ChatBskyModerationGetActorMetadata.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Moderation/ChatBskyModerationGetActorMetadata.swift @@ -9,6 +9,33 @@ import Foundation extension ChatBskyLexicon.Moderation { + /// The main data model for getting the user account's metadata. + public struct GetActorMetadata: Codable { + + /// The metadata given to the moderator. + public struct Metadata: Codable { + + /// The number of messages sent from the user account. + public let messagesSent: Int + + /// The number of messages the user account received. + public let messagesReceived: Int + + /// The number of conversations the user account participates in. + public let conversations: Int + + /// The number of conversations the user account had started. + public let conversationsStarted: Int + + enum CodingKeys: String, CodingKey { + case messagesSent + case messagesReceived + case conversations = "convos" + case conversationsStarted = "convosStarted" + } + } + } + /// An output model for getting the user account's metadata. /// /// - SeeAlso: This is based on the [`chat.bsky.moderation.getActorMetadata`][github] lexicon. @@ -31,27 +58,4 @@ extension ChatBskyLexicon.Moderation { case allMetadata = "all" } } - - /// The metadata given to the moderator. - public struct Metadata: Codable { - - /// The number of messages sent from the user account. - public let messagesSent: Int - - /// The number of messages the user account received. - public let messagesReceived: Int - - /// The number of conversations the user account participates in. - public let conversations: Int - - /// The number of conversations the user account had started. - public let conversationsStarted: Int - - enum CodingKeys: String, CodingKey { - case messagesSent - case messagesReceived - case conversations = "convos" - case conversationsStarted = "convosStarted" - } - } } diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminDefs.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminDefs.swift index 292ad2ee08..ae4314e34d 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminDefs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminDefs.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Admin { - /// A definition model for admin status attributes. + /// A definition model for admin status attributes. /// /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. /// @@ -28,181 +28,6 @@ extension ComAtprotoLexicon.Admin { } } - /// A definition model for a report view. - /// - /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. - /// - /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/defs.json - public struct ReportViewDefinition: Codable { - - /// The ID of the report. - public let id: Int - - /// The reason for the report. - public let reasonType: ModerationReasonType - - /// The additional comment provided for a report. Optional. - public let comment: String? - - /// The handle of the subject who's related to the report. Optional. - public let subjectRepoHandle: String? - - /// The subject reference of the report. - public let subject: ATUnion.RepositoryReferencesUnion - - /// The user who created the report. - public let reportedBy: String - - /// The date and time the report was created. - @DateFormatting public var createdAt: Date - - /// An array of action IDs that relate to resolutions. - public let resolvedByActionIDs: [Int] - - public init(id: Int, reasonType: ModerationReasonType, comment: String?, subjectRepoHandle: String?, subject: ATUnion.RepositoryReferencesUnion, - reportedBy: String, createdAt: Date, resolvedByActionIDs: [Int]) { - self.id = id - self.reasonType = reasonType - self.comment = comment - self.subjectRepoHandle = subjectRepoHandle - self.subject = subject - self.reportedBy = reportedBy - self._createdAt = DateFormatting(wrappedValue: createdAt) - self.resolvedByActionIDs = resolvedByActionIDs - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.id = try container.decode(Int.self, forKey: .id) - self.reasonType = try container.decode(ModerationReasonType.self, forKey: .reasonType) - self.comment = try container.decodeIfPresent(String.self, forKey: .comment) - self.subjectRepoHandle = try container.decodeIfPresent(String.self, forKey: .subjectRepoHandle) - self.subject = try container.decode(ATUnion.RepositoryReferencesUnion.self, forKey: .subject) - self.reportedBy = try container.decode(String.self, forKey: .reportedBy) - self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue - self.resolvedByActionIDs = try container.decode([Int].self, forKey: .resolvedByActionIDs) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self.id, forKey: .id) - try container.encode(self.reasonType, forKey: .reasonType) - try container.encodeIfPresent(self.comment, forKey: .comment) - try container.encodeIfPresent(self.subjectRepoHandle, forKey: .subjectRepoHandle) - try container.encode(self.subject, forKey: .subject) - try container.encode(self.reportedBy, forKey: .reportedBy) - try container.encode(self._createdAt, forKey: .createdAt) - try container.encode(self.resolvedByActionIDs, forKey: .resolvedByActionIDs) - } - - enum CodingKeys: String, CodingKey { - case id - case reasonType - case comment - case subjectRepoHandle - case subject - case reportedBy - case createdAt - case resolvedByActionIDs = "resolvedByActionIds" - } - } - - /// A definition model for a detailed report view. - /// - /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. - /// - /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/defs.json - public struct ReportViewDetailDefinition: Codable { - - /// The ID of a report. - public let id: Int - - /// The reason for the report. - public let reasonType: ModerationReasonType - - /// Any additional comments about the report. Optional. - public var comment: String? - - /// The subject of the report. - /// - /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ - /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ - /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ - /// \ - /// Clarifications from Bluesky are needed in order to fully understand this item. - public let subject: ATUnion.RepositoryViewUnion - - /// The status for the subject of the report. Optional. - /// - /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ - /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ - /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ - /// \ - /// Clarifications from Bluesky are needed in order to fully understand this item. - public var subjectStatus: OzoneSubjectStatusView? - - /// The user who created the report. - public let reportedBy: String - - /// The date and time the report was created. - @DateFormatting public var createdAt: Date - - /// An array of resolved actions made in relation to the report. - public let resolvedByActions: [OzoneModerationEventView] - - public init(id: Int, reasonType: ModerationReasonType, comment: String? = nil, subject: ATUnion.RepositoryViewUnion, - subjectStatus: OzoneSubjectStatusView? = nil, reportedBy: String, createdAt: Date, - resolvedByActions: [OzoneModerationEventView]) { - self.id = id - self.reasonType = reasonType - self.comment = comment - self.subject = subject - self.subjectStatus = subjectStatus - self.reportedBy = reportedBy - self._createdAt = DateFormatting(wrappedValue: createdAt) - self.resolvedByActions = resolvedByActions - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.id = try container.decode(Int.self, forKey: .id) - self.reasonType = try container.decode(ModerationReasonType.self, forKey: .reasonType) - self.comment = try container.decodeIfPresent(String.self, forKey: .comment) - self.subject = try container.decode(ATUnion.RepositoryViewUnion.self, forKey: .subject) - self.subjectStatus = try container.decodeIfPresent(OzoneSubjectStatusView.self, forKey: .subjectStatus) - self.reportedBy = try container.decode(String.self, forKey: .reportedBy) - self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue - self.resolvedByActions = try container.decode([OzoneModerationEventView].self, forKey: .resolvedByActions) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self.id, forKey: .id) - try container.encode(self.reasonType, forKey: .reasonType) - try container.encodeIfPresent(self.comment, forKey: .comment) - try container.encode(self.subject, forKey: .subject) - try container.encodeIfPresent(self.subjectStatus, forKey: .subjectStatus) - try container.encode(self.reportedBy, forKey: .reportedBy) - try container.encode(self._createdAt, forKey: .createdAt) - try container.encode(self.resolvedByActions, forKey: .resolvedByActions) - } - - enum CodingKeys: CodingKey { - case id - case reasonType - case comment - case subject - case subjectStatus - case reportedBy - case createdAt - case resolvedByActions - } - } - /// A definition model for an account view. /// /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminGetInviteCodes.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminGetInviteCodes.swift index 6b07812e5e..a49b31afcd 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminGetInviteCodes.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminGetInviteCodes.swift @@ -9,6 +9,24 @@ import Foundation extension ComAtprotoLexicon.Admin { + /// The main data model for getting the invite codes from a user account. + /// + /// - SeeAlso: This is based on the [`com.atproto.admin.getInviteCodes`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/getInviteCodes.json + public struct GetInviteCodes: Codable { + + /// Sorts the invite codes by a particular order. + public enum Sort { + + /// Sorts the invite codes by the most recently made. + case recent + + /// Sorts the invite codes by the number of times it's been used. + case usage + } + } + /// An output model for getting the invite codes from a user account. /// /// - Note: According to the AT Protocol specifications: "Get an admin view of invite codes." @@ -22,16 +40,6 @@ extension ComAtprotoLexicon.Admin { public let cursor: String? /// An array of invite codes. - public let codes: [ServerInviteCode] - } - - /// Sorts the invite codes by a particular order. - public enum GetInviteCodesSort { - - /// Sorts the invite codes by the most recently made. - case recent - - /// Sorts the invite codes by the number of times it's been used. - case usage + public let codes: [ComAtprotoLexicon.Server.InviteCodeDefinition] } } diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminQueryModerationStatuses.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminQueryModerationStatuses.swift deleted file mode 100644 index 7e8244c39d..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminQueryModerationStatuses.swift +++ /dev/null @@ -1,48 +0,0 @@ -// -// ComAtprotoAdminQueryModerationStatuses.swift -// -// -// Created by Christopher Jr Riley on 2024-05-20. -// - -import Foundation - -extension ComAtprotoLexicon.Admin { - - /// An output model for listing all of moderation statuses of records and repositories. - /// - /// - Note: According to the AT Protocol specifications: "View moderation statuses of - /// subjects (record or repo)." - /// - /// - SeeAlso: This is based on the [`com.atproto.admin.queryModerationStatuses`][github] lexicon. - /// - /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/queryModerationStatuses.json - public struct QueryModerationStatusesOutput: Codable { - - /// The mark used to indicate the starting point for the next set of results. Optional. - public let cursor: String - - /// An array of subject statuses. - public let subjectStatuses: [OzoneSubjectStatusView] - } - - /// Indicates the sorting field for the moderation status array. - public enum AdminQueryModerationStatusesSortField { - - /// Indicates the moderation status array will be sorted by the last reported user. - case lastReportedAt - - /// Indicates the moderation status array will be sorted by the last reviwed user. - case lastReviewedAt - } - - /// Indicates the sorting direction for the array of moderation statuses. - public enum QueryModerationStatusesSortDirection: String { - - /// Indicates the moderation events will be sorted in ascending order. - case ascending = "asc" - - /// Indicates the moderation events will be sorted in descending order. - case descending = "desc" - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Label/ComAtprotoLabelDefs.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Label/ComAtprotoLabelDefs.swift index 16eb7bc4b0..eaa5a11bbe 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Label/ComAtprotoLabelDefs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Label/ComAtprotoLabelDefs.swift @@ -151,16 +151,16 @@ extension ComAtprotoLexicon.Label { /// - SeeAlso: This is based on the [`com.atproto.label.defs`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/label/defs.json - public let values: [SelfLabel] + public let values: [SelfLabelDefinition] - public init(values: [SelfLabel]) { + public init(values: [SelfLabelDefinition]) { self.values = values } public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) - self.values = try container.decode([SelfLabel].self, forKey: .values) + self.values = try container.decode([SelfLabelDefinition].self, forKey: .values) } public func encode(to encoder: Encoder) throws { diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Label/ComAtprotoLabelQueryLabels.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Label/ComAtprotoLabelQueryLabels.swift index fea483acf8..84e3f6bbab 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Label/ComAtprotoLabelQueryLabels.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Label/ComAtprotoLabelQueryLabels.swift @@ -21,6 +21,6 @@ extension ComAtprotoLexicon.Label { public struct QueryLabelsOutput: Codable { /// An array of labels. - public let labels: [Label] + public let labels: [ComAtprotoLexicon.Label.LabelDefinition] } } diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoApplyWrites.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoApplyWrites.swift index 93f6cbee5f..6fc1a4a47b 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoApplyWrites.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoApplyWrites.swift @@ -50,79 +50,80 @@ extension ComAtprotoLexicon.Repository { case writes case swapCommit } - } - /// A data model definition for a "Create" write operation. - /// - /// - Note: According to the AT Protocol specifications: "Operation which creates a - /// new record." - /// - /// - SeeAlso: This is based on the [`com.atproto.repo.applyWrites`][github] lexicon. - /// - /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/repo/applyWrites.json - public struct ApplyWritesCreate: Codable { + // Enums + /// A data model definition for a "Create" write operation. + /// + /// - Note: According to the AT Protocol specifications: "Operation which creates a + /// new record." + /// + /// - SeeAlso: This is based on the [`com.atproto.repo.applyWrites`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/repo/applyWrites.json + public struct Create: Codable { - /// The NSID of the collection. - public let collection: String + /// The NSID of the collection. + public let collection: String - /// The record key of the write operation. Optional. - public let recordKey: String? + /// The record key of the write operation. Optional. + public let recordKey: String? - /// The value of the write operation. - public let value: UnknownType + /// The value of the write operation. + public let value: UnknownType - enum CodingKeys: String, CodingKey { - case collection - case recordKey = "rkey" - case value + enum CodingKeys: String, CodingKey { + case collection + case recordKey = "rkey" + case value + } } - } - /// A data model definition for an "Update" write operation. - /// - /// - Note: According to the AT Protocol specifications: "Operation which updates an - /// existing record." - /// - /// - SeeAlso: This is based on the [`com.atproto.repo.applyWrites`][github] lexicon. - /// - /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/repo/applyWrites.json - public struct ApplyWritesUpdate: Codable { + /// A data model definition for an "Update" write operation. + /// + /// - Note: According to the AT Protocol specifications: "Operation which updates an + /// existing record." + /// + /// - SeeAlso: This is based on the [`com.atproto.repo.applyWrites`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/repo/applyWrites.json + public struct Update: Codable { - /// The NSID of the collection. - public let collection: String + /// The NSID of the collection. + public let collection: String - /// The record key of the write operation. - public let recordKey: String + /// The record key of the write operation. + public let recordKey: String - /// The value of the write operation. - public let value: UnknownType + /// The value of the write operation. + public let value: UnknownType - enum CodingKeys: String, CodingKey { - case collection - case recordKey = "rkey" - case value + enum CodingKeys: String, CodingKey { + case collection + case recordKey = "rkey" + case value + } } - } - /// A data model definition for a "Delete" write operation. - /// - /// - Note: According to the AT Protocol specifications: "Operation which deletes an - /// existing record." - /// - /// - SeeAlso: This is based on the [`com.atproto.repo.applyWrites`][github] lexicon. - /// - /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/repo/applyWrites.json - public struct ApplyWritesDelete: Codable { + /// A data model definition for a "Delete" write operation. + /// + /// - Note: According to the AT Protocol specifications: "Operation which deletes an + /// existing record." + /// + /// - SeeAlso: This is based on the [`com.atproto.repo.applyWrites`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/repo/applyWrites.json + public struct Delete: Codable { - /// The NSID of the collection. - public let collection: String + /// The NSID of the collection. + public let collection: String - /// The record key of the write operation. - public let recordKey: String + /// The record key of the write operation. + public let recordKey: String - enum CodingKeys: String, CodingKey { - case collection - case recordKey = "rkey" + enum CodingKeys: String, CodingKey { + case collection + case recordKey = "rkey" + } } } } diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoListMissingBlobs.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoListMissingBlobs.swift index 0dbaf24ef5..b0399b6502 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoListMissingBlobs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoListMissingBlobs.swift @@ -9,6 +9,20 @@ import Foundation extension ComAtprotoLexicon.Repository { + /// The main data model for a record blob. + public struct ListMissingBlobs: Codable { + + /// A data model definition for a record blob. + public struct RecordBlob: Codable { + + /// The CID hash of the record. + public let recordCID: String + + /// The URI of the record. + public let recordURI: String + } + } + /// An output model for listing any missing blobs attached to the user account. /// /// - Note: According to the AT Protocol specifications: "Returns a list of missing blobs for @@ -22,14 +36,4 @@ extension ComAtprotoLexicon.Repository { /// An array of blobs. public let blobs: [RecordBlob] } - - /// A data model definition for a record blob. - public struct RecordBlob: Codable { - - /// The CID hash of the record. - public let recordCID: String - - /// The URI of the record. - public let recordURI: String - } } diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerDescribeServer.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerDescribeServer.swift index 2f4aceff3e..260e3c8505 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerDescribeServer.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerDescribeServer.swift @@ -9,6 +9,43 @@ import Foundation extension ComAtprotoLexicon.Server { + /// A data model for etrieving a description of the server. + public struct DescribeServer: Codable { + + /// A data model of service policy URLs. + /// + /// - Note: According to the AT Protocol specifications: "Describes the server's account + /// creation requirements and capabilities. Implemented by PDS." + /// + /// - SeeAlso: This is based on the [`com.atproto.server.describeServer`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/describeServer.json + public struct ServicePolicyURLs: Codable { + + /// The URL for the server's Privacy Policy. Optional. + public let privacyPolicyURL: URL? + + /// The URL for the server's Terms of Service. Optional. + public let termsOfServiceURL: URL? + + enum CodingKeys: String, CodingKey { + case privacyPolicyURL = "privacyPolicy" + case termsOfServiceURL = "termsOfService" + } + } + + /// A data model definition of the server's contact information. + /// + /// - SeeAlso: This is based on the [`com.atproto.server.describeServer`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/describeServer.json + public struct ContactInformation: Codable { + + /// The email address users can use to contact the server owner. + public let email: String + } + } + /// An output model for retrieving a description of the server. /// /// - Note: According to the AT Protocol specifications: "Describes the server's account @@ -41,12 +78,12 @@ extension ComAtprotoLexicon.Server { /// /// - Note: According to the AT Protocol specifications: "URLs of service /// policy documents." - public let servicePolicyURLs: ServicePolicyURLs + public let servicePolicyURLs: DescribeServer.ServicePolicyURLs /// The contact information for the server. /// /// - Note: According to the AT Protocol specifications: "Contact information." - public let contactInformation: ContactInformation + public let contactInformation: DescribeServer.ContactInformation /// The decentralized identifier (DID) of the server. public let serverDID: String @@ -60,37 +97,4 @@ extension ComAtprotoLexicon.Server { case serverDID = "did" } } - - /// A data model of service policy URLs. - /// - /// - Note: According to the AT Protocol specifications: "Describes the server's account - /// creation requirements and capabilities. Implemented by PDS." - /// - /// - SeeAlso: This is based on the [`com.atproto.server.describeServer`][github] lexicon. - /// - /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/describeServer.json - public struct ServicePolicyURLs: Codable { - - /// The URL for the server's Privacy Policy. Optional. - public let privacyPolicyURL: URL? - - /// The URL for the server's Terms of Service. Optional. - public let termsOfServiceURL: URL? - - enum CodingKeys: String, CodingKey { - case privacyPolicyURL = "privacyPolicy" - case termsOfServiceURL = "termsOfService" - } - } - - /// A data model definition of the server's contact information. - /// - /// - SeeAlso: This is based on the [`com.atproto.server.describeServer`][github] lexicon. - /// - /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/describeServer.json - public struct ContactInformation: Codable { - - /// The email address users can use to contact the server owner. - public let email: String - } } diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerListAppPasswords.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerListAppPasswords.swift index 82a7a76ef1..676261a25c 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerListAppPasswords.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerListAppPasswords.swift @@ -20,43 +20,43 @@ extension ComAtprotoLexicon.Server { /// An array of App Passwords. public let passwords: [AppPassword] - } - /// An App Password. - /// - /// - SeeAlso: This is based on the [`com.atproto.server.listAppPasswords`][github] lexicon. - /// - /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/listAppPasswords.json - public struct AppPassword: Codable { + /// An App Password. + /// + /// - SeeAlso: This is based on the [`com.atproto.server.listAppPasswords`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/listAppPasswords.json + public struct AppPassword: Codable { - /// The name associated with the App Password. - public let name: String + /// The name associated with the App Password. + public let name: String - /// The date and date the App Password was created. - @DateFormatting public var createdAt: Date + /// The date and date the App Password was created. + @DateFormatting public var createdAt: Date - public init(name: String, createdAt: Date) { - self.name = name - self._createdAt = DateFormatting(wrappedValue: createdAt) - } + public init(name: String, createdAt: Date) { + self.name = name + self._createdAt = DateFormatting(wrappedValue: createdAt) + } - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) - self.name = try container.decode(String.self, forKey: .name) - self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue - } + self.name = try container.decode(String.self, forKey: .name) + self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue + } - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(self.name, forKey: .name) - try container.encode(self._createdAt, forKey: .createdAt) - } + try container.encode(self.name, forKey: .name) + try container.encode(self._createdAt, forKey: .createdAt) + } - enum CodingKeys: CodingKey { - case name - case createdAt + enum CodingKeys: CodingKey { + case name + case createdAt + } } } } diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncListRepos.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncListRepos.swift index 97c7a11eaa..f6f38bb485 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncListRepos.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncListRepos.swift @@ -29,28 +29,29 @@ extension ComAtprotoLexicon.Sync { enum CodingKeys: String, CodingKey { case cursor - case repositories = "repos" + case repositories = "repo" } - } - /// A data model definition for a repository. - public struct Repository: Codable { + // Enums + /// A data model definition for a repository. + public struct Repository: Codable { - /// The decentralized identifier (DID) of the repository. - public let repositoryDID: String + /// The decentralized identifier (DID) of the repository. + public let repositoryDID: String - /// The commit CID hash of the repository. - /// - /// - Note: According to the AT Protocol specifications: "Current repo commit CID." - public let commitCID: String + /// The commit CID hash of the repository. + /// + /// - Note: According to the AT Protocol specifications: "Current repo commit CID." + public let commitCID: String - /// The repository's revision. - public let revision: String + /// The repository's revision. + public let revision: String - enum CodingKeys: String, CodingKey { - case repositoryDID = "did" - case commitCID = "head" - case revision = "rev" + enum CodingKeys: String, CodingKey { + case repositoryDID = "did" + case commitCID = "head" + case revision = "rev" + } } } } diff --git a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationDefs.swift b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationDefs.swift index 668905ece4..2f1373cc94 100644 --- a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationDefs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationDefs.swift @@ -107,7 +107,7 @@ extension ToolsOzoneLexicon.Moderation { public let subject: RepositoryViewUnion /// An array of blobs for a moderator to look at. - public let subjectBlobs: [OzoneModerationBlobView] + public let subjectBlobs: [ToolsOzoneLexicon.Moderation.BlobViewDefinition] /// The creator of the event view. public let createdBy: String @@ -115,7 +115,7 @@ extension ToolsOzoneLexicon.Moderation { /// The date and time the event view was created. @DateFormatting public var createdAt: Date - public init(id: Int, event: EventViewDetailUnion, subject: RepositoryViewUnion, subjectBlobs: [OzoneModerationBlobView], + public init(id: Int, event: EventViewDetailUnion, subject: RepositoryViewUnion, subjectBlobs: [ToolsOzoneLexicon.Moderation.BlobViewDefinition], createdBy: String, createdAt: Date) { self.id = id self.event = event @@ -131,7 +131,7 @@ extension ToolsOzoneLexicon.Moderation { self.id = try container.decode(Int.self, forKey: .id) self.event = try container.decode(EventViewDetailUnion.self, forKey: .event) self.subject = try container.decode(RepositoryViewUnion.self, forKey: .subject) - self.subjectBlobs = try container.decode([OzoneModerationBlobView].self, forKey: .subjectBlobs) + self.subjectBlobs = try container.decode([ToolsOzoneLexicon.Moderation.BlobViewDefinition].self, forKey: .subjectBlobs) self.createdBy = try container.decode(String.self, forKey: .createdBy) self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue } @@ -189,7 +189,7 @@ extension ToolsOzoneLexicon.Moderation { @DateFormatting public var createdAt: Date /// The review status of the subject. - public let reviewState: OzoneSubjectReviewState + public let reviewState: ToolsOzoneLexicon.Moderation.SubjectReviewStateDefinition /// Any additional comments written about the subject. Optional. public var comment: String? @@ -233,9 +233,9 @@ extension ToolsOzoneLexicon.Moderation { public var tags: [String]? public init(id: Int, subject: RepositoryReferencesUnion, subjectBlobCIDHashes: [String]?, subjectRepoHandle: String?, updatedAt: Date, createdAt: Date, - reviewState: OzoneSubjectReviewState, comment: String?, muteUntil: Date?, muteReportingUntil: Date?, lastReviewedBy: String?, - lastReviewedAt: Date?, lastReportedAt: Date?, lastAppealedAt: Date?, isTakenDown: Bool?, wasAppealed: Bool?, suspendUntil: Date?, - tags: [String]?) { + reviewState: ToolsOzoneLexicon.Moderation.SubjectReviewStateDefinition, comment: String?, muteUntil: Date?, muteReportingUntil: Date?, + lastReviewedBy: String?, lastReviewedAt: Date?, lastReportedAt: Date?, lastAppealedAt: Date?, isTakenDown: Bool?, wasAppealed: Bool?, + suspendUntil: Date?, tags: [String]?) { self.id = id self.subject = subject self.subjectBlobCIDHashes = subjectBlobCIDHashes @@ -265,7 +265,7 @@ extension ToolsOzoneLexicon.Moderation { self.subjectRepoHandle = try container.decodeIfPresent(String.self, forKey: .subjectRepoHandle) self.updatedAt = try container.decode(DateFormatting.self, forKey: .updatedAt).wrappedValue self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue - self.reviewState = try container.decode(OzoneSubjectReviewState.self, forKey: .reviewState) + self.reviewState = try container.decode(ToolsOzoneLexicon.Moderation.SubjectReviewStateDefinition.self, forKey: .reviewState) self.comment = try container.decodeIfPresent(String.self, forKey: .comment) self.muteUntil = try container.decodeIfPresent(DateFormattingOptional.self, forKey: .muteUntil)?.wrappedValue self.muteReportingUntil = try container.decodeIfPresent(DateFormattingOptional.self, forKey: .muteReportingUntil)?.wrappedValue @@ -452,7 +452,7 @@ extension ToolsOzoneLexicon.Moderation { public let isReporterMuted: Bool? /// The type of report. - public let reportType: ModerationReasonType + public let reportType: ComAtprotoLexicon.Moderation.ReasonTypeDefinition } /// A definition model for a label event. @@ -677,7 +677,7 @@ extension ToolsOzoneLexicon.Moderation { @DateFormatting public var indexedAt: Date /// The moderation status of the user. - public let moderation: OzoneModeration + public let moderation: ToolsOzoneLexicon.Moderation.ModerationDefinition /// The invite code used by the user to sign up. Optional. public var invitedBy: ServerInviteCode? @@ -688,8 +688,9 @@ extension ToolsOzoneLexicon.Moderation { /// The note of the invite. Optional. public var inviteNote: String? - public init(actorDID: String, handle: String, email: String? = nil, relatedRecords: UnknownType, indexedAt: Date, moderation: OzoneModeration, - invitedBy: ServerInviteCode? = nil, areInvitesDisabled: Bool? = nil, inviteNote: String? = nil) { + public init(actorDID: String, handle: String, email: String? = nil, relatedRecords: UnknownType, indexedAt: Date, + moderation: ToolsOzoneLexicon.Moderation.ModerationDefinition, invitedBy: ServerInviteCode? = nil, areInvitesDisabled: Bool? = nil, + inviteNote: String? = nil) { self.actorDID = actorDID self.handle = handle self.email = email @@ -709,7 +710,7 @@ extension ToolsOzoneLexicon.Moderation { self.email = try container.decodeIfPresent(String.self, forKey: .email) self.relatedRecords = try container.decode(UnknownType.self, forKey: .relatedRecords) self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue - self.moderation = try container.decode(OzoneModeration.self, forKey: .moderation) + self.moderation = try container.decode(ToolsOzoneLexicon.Moderation.ModerationDefinition.self, forKey: .moderation) self.invitedBy = try container.decodeIfPresent(ServerInviteCode.self, forKey: .invitedBy) self.areInvitesDisabled = try container.decodeIfPresent(Bool.self, forKey: .areInvitesDisabled) self.inviteNote = try container.decodeIfPresent(String.self, forKey: .inviteNote) @@ -771,16 +772,16 @@ extension ToolsOzoneLexicon.Moderation { @DateFormatting public var indexedAt: Date /// The detailed moderation status of the user. - public let moderation: OzoneModerationDetail + public let moderation: ToolsOzoneLexicon.Moderation.ModerationDetailDefinition /// An array of labels associated with the user. Optional. - public var labels: [Label]? + public var labels: [ComAtprotoLexicon.Label.LabelDefinition]? /// The invite code used by the user to sign up. Optional. - public var invitedBy: ServerInviteCode? + public let invitedBy: ComAtprotoLexicon.Server.InviteCodeDefinition? /// An array of invite codes held by the user. Optional. - public var invites: [ServerInviteCode]? + public var invites: [ComAtprotoLexicon.Server.InviteCodeDefinition]? /// Indicates whether the invite codes held by the user are diabled. Optional. public var areInvitesDisabled: Bool? @@ -791,9 +792,10 @@ extension ToolsOzoneLexicon.Moderation { /// The date and time the email of the user was confirmed. Optional. @DateFormattingOptional public var emailConfirmedAt: Date? - public init(actorDID: String, handle: String, email: String?, relatedRecords: UnknownType, indexedAt: Date, moderation: OzoneModerationDetail, - labels: [Label]?, invitedBy: ServerInviteCode?, invites: [ServerInviteCode]?, areInvitesDisabled: Bool?, inviteNote: String?, - emailConfirmedAt: Date? = nil) { + public init(actorDID: String, handle: String, email: String?, relatedRecords: UnknownType, indexedAt: Date, + moderation: ToolsOzoneLexicon.Moderation.ModerationDetailDefinition, labels: [ComAtprotoLexicon.Label.LabelDefinition]?, + invitedBy: ComAtprotoLexicon.Server.InviteCodeDefinition?, invites: [ComAtprotoLexicon.Server.InviteCodeDefinition]?, + areInvitesDisabled: Bool?, inviteNote: String?, emailConfirmedAt: Date? = nil) { self.actorDID = actorDID self.handle = handle self.email = email @@ -816,10 +818,10 @@ extension ToolsOzoneLexicon.Moderation { self.email = try container.decodeIfPresent(String.self, forKey: .email) self.relatedRecords = try container.decode(UnknownType.self, forKey: .relatedRecords) self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue - self.moderation = try container.decode(OzoneModerationDetail.self, forKey: .moderation) - self.labels = try container.decodeIfPresent([Label].self, forKey: .labels) - self.invitedBy = try container.decodeIfPresent(ServerInviteCode.self, forKey: .invitedBy) - self.invites = try container.decodeIfPresent([ServerInviteCode].self, forKey: .invites) + self.moderation = try container.decode(ToolsOzoneLexicon.Moderation.ModerationDetailDefinition.self, forKey: .moderation) + self.labels = try container.decodeIfPresent([ComAtprotoLexicon.Label.LabelDefinition].self, forKey: .labels) + self.invitedBy = try container.decodeIfPresent(ComAtprotoLexicon.Server.InviteCodeDefinition.self, forKey: .invitedBy) + self.invites = try container.decodeIfPresent([ComAtprotoLexicon.Server.InviteCodeDefinition].self, forKey: .invites) self.areInvitesDisabled = try container.decodeIfPresent(Bool.self, forKey: .areInvitesDisabled) self.inviteNote = try container.decodeIfPresent(String.self, forKey: .inviteNote) self.emailConfirmedAt = try container.decodeIfPresent(DateFormattingOptional.self, forKey: .emailConfirmedAt)?.wrappedValue @@ -908,7 +910,7 @@ extension ToolsOzoneLexicon.Moderation { /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ /// \ /// Clarifications from Bluesky are needed in order to fully understand this item. - public let moderation: OzoneModeration + public let moderation: ToolsOzoneLexicon.Moderation.ModerationDefinition /// The repository view of the record. /// @@ -917,10 +919,10 @@ extension ToolsOzoneLexicon.Moderation { /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ /// \ /// Clarifications from Bluesky are needed in order to fully understand this item. - public let repository: OzoneModerationRepositoryView + public let repository: ToolsOzoneLexicon.Moderation.RepositoryViewDefinition public init(recordURI: String, cidHash: String, value: UnknownType, blobCIDHashes: [String], indexedAt: Date, - moderation: OzoneModeration, repository: OzoneModerationRepositoryView) { + moderation: ToolsOzoneLexicon.Moderation.ModerationDefinition, repository: ToolsOzoneLexicon.Moderation.RepositoryViewDefinition) { self.recordURI = recordURI self.cidHash = cidHash self.value = value @@ -938,8 +940,8 @@ extension ToolsOzoneLexicon.Moderation { self.value = try container.decode(UnknownType.self, forKey: .value) self.blobCIDHashes = try container.decode([String].self, forKey: .blobCIDHashes) self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue - self.moderation = try container.decode(OzoneModeration.self, forKey: .moderation) - self.repository = try container.decode(OzoneModerationRepositoryView.self, forKey: .repository) + self.moderation = try container.decode(ToolsOzoneLexicon.Moderation.ModerationDefinition.self, forKey: .moderation) + self.repository = try container.decode(ToolsOzoneLexicon.Moderation.RepositoryViewDefinition.self, forKey: .repository) } public func encode(to encoder: Encoder) throws { @@ -988,10 +990,10 @@ extension ToolsOzoneLexicon.Moderation { public let value: String /// An array of CID hashes for blobs. - public let blobs: [OzoneModerationBlobView] + public let blobs: [ToolsOzoneLexicon.Moderation.BlobViewDefinition] /// An array of labels attached to the record. Optional. - public var labels: [Label]? + public var labels: [ComAtprotoLexicon.Label.LabelDefinition]? /// The date and time the record is indexed. @DateFormatting public var indexedAt: Date @@ -1003,7 +1005,7 @@ extension ToolsOzoneLexicon.Moderation { /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ /// \ /// Clarifications from Bluesky are needed in order to fully understand this item. - public let moderation: OzoneModerationDetail + public let moderation: ToolsOzoneLexicon.Moderation.ModerationDetailDefinition /// The repository view of the record. /// @@ -1012,10 +1014,12 @@ extension ToolsOzoneLexicon.Moderation { /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ /// \ /// Clarifications from Bluesky are needed in order to fully understand this item. - public let repository: OzoneModerationRepositoryView + public let repository: ToolsOzoneLexicon.Moderation.RepositoryViewDefinition - public init(recordURI: String, cidHash: String, value: String, blobs: [OzoneModerationBlobView], labels: [Label]? = nil, indexedAt: Date, - moderation: OzoneModerationDetail, repository: OzoneModerationRepositoryView) { + public init(recordURI: String, cidHash: String, value: String, blobs: [ToolsOzoneLexicon.Moderation.BlobViewDefinition], + labels: [ComAtprotoLexicon.Label.LabelDefinition]? = nil, indexedAt: Date, + moderation: ToolsOzoneLexicon.Moderation.ModerationDetailDefinition, + repository: ToolsOzoneLexicon.Moderation.RepositoryViewDefinition) { self.recordURI = recordURI self.cidHash = cidHash self.value = value @@ -1032,11 +1036,11 @@ extension ToolsOzoneLexicon.Moderation { self.recordURI = try container.decode(String.self, forKey: .recordURI) self.cidHash = try container.decode(String.self, forKey: .cidHash) self.value = try container.decode(String.self, forKey: .value) - self.blobs = try container.decode([OzoneModerationBlobView].self, forKey: .blobs) - self.labels = try container.decodeIfPresent([Label].self, forKey: .labels) + self.blobs = try container.decode([ToolsOzoneLexicon.Moderation.BlobViewDefinition].self, forKey: .blobs) + self.labels = try container.decodeIfPresent([ComAtprotoLexicon.Label.LabelDefinition].self, forKey: .labels) self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue - self.moderation = try container.decode(OzoneModerationDetail.self, forKey: .moderation) - self.repository = try container.decode(OzoneModerationRepositoryView.self, forKey: .repository) + self.moderation = try container.decode(ToolsOzoneLexicon.Moderation.ModerationDetailDefinition.self, forKey: .moderation) + self.repository = try container.decode(ToolsOzoneLexicon.Moderation.RepositoryViewDefinition.self, forKey: .repository) } public func encode(to encoder: Encoder) throws { @@ -1099,7 +1103,7 @@ extension ToolsOzoneLexicon.Moderation { /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ /// \ /// Clarifications from Bluesky are needed in order to fully understand this item. - public var subjectStatus: OzoneSubjectStatusView? + public let subjectStatus: ToolsOzoneLexicon.Moderation.SubjectStatusViewDefinition } /// A definition model for a detailed moderation. @@ -1122,7 +1126,7 @@ extension ToolsOzoneLexicon.Moderation { /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ /// \ /// Clarifications from Bluesky are needed in order to fully understand this item. - public var subjectStatus: OzoneSubjectStatusView? + public var subjectStatus: ToolsOzoneLexicon.Moderation.SubjectStatusViewDefinition? } /// A definition model for a blob view. @@ -1148,9 +1152,10 @@ extension ToolsOzoneLexicon.Moderation { public let details: MediaDetailUnion /// The status of the subject. - public let moderation: OzoneModeration + public let moderation: ToolsOzoneLexicon.Moderation.ModerationDefinition - public init(cidHash: String, mimeType: String, size: Int, createdAt: Date, details: MediaDetailUnion, moderation: OzoneModeration) { + public init(cidHash: String, mimeType: String, size: Int, createdAt: Date, details: MediaDetailUnion, + moderation: ToolsOzoneLexicon.Moderation.ModerationDefinition) { self.cidHash = cidHash self.mimeType = mimeType self.size = size @@ -1167,7 +1172,7 @@ extension ToolsOzoneLexicon.Moderation { self.size = try container.decode(Int.self, forKey: .size) self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue self.details = try container.decode(MediaDetailUnion.self, forKey: .details) - self.moderation = try container.decode(OzoneModeration.self, forKey: .moderation) + self.moderation = try container.decode(ToolsOzoneLexicon.Moderation.ModerationDefinition.self, forKey: .moderation) } public func encode(to encoder: Encoder) throws { diff --git a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationQueryEvents.swift b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationQueryEvents.swift index eb2c9f50f7..bdc28c0137 100644 --- a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationQueryEvents.swift +++ b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationQueryEvents.swift @@ -9,6 +9,19 @@ import Foundation extension ToolsOzoneLexicon.Moderation { + public struct QueryEvents: Codable { + + /// Indicates the sorting direction for the array of moderation events. + public enum SortDirection: String { + + /// Indicates the moderation events will be sorted in ascending order. + case ascending = "asc" + + /// Indicates the moderation events will be sorted in descending order. + case descending = "desc" + } + } + /// An output model for listing all moderation events pertaining a subject. /// /// - Note: According to the AT Protocol specifications: "List moderation events related @@ -23,16 +36,6 @@ extension ToolsOzoneLexicon.Moderation { public let cursor: String? /// An array of moderator events. - public let events: [OzoneModerationEventView] - } - - /// Indicates the sorting direction for the array of moderation events. - public enum AdminQueryModerationEventSortDirection: String { - - /// Indicates the moderation events will be sorted in ascending order. - case ascending = "asc" - - /// Indicates the moderation events will be sorted in descending order. - case descending = "desc" + public let events: [ToolsOzoneLexicon.Moderation.EventViewDefinition] } } diff --git a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationQueryStatuses.swift b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationQueryStatuses.swift index 31eb9dffa5..34861619ac 100644 --- a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationQueryStatuses.swift +++ b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationQueryStatuses.swift @@ -23,6 +23,6 @@ extension ToolsOzoneLexicon.Moderation { public let cursor: String? /// An array of subject status views. - public let subjectStatuses: [OzoneSubjectStatusView] + public let subjectStatuses: [ToolsOzoneLexicon.Moderation.SubjectStatusViewDefinition] } } diff --git a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationSearchRepos.swift b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationSearchRepos.swift index 9a11735eaf..efdfdaa58f 100644 --- a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationSearchRepos.swift +++ b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationSearchRepos.swift @@ -23,7 +23,7 @@ extension ToolsOzoneLexicon.Moderation { public let cursor: String? /// An array of repository views. - public let repositories: [OzoneModerationRepositoryView] + public let repositories: [ToolsOzoneLexicon.Moderation.RepositoryViewDefinition] enum CodingKeys: String, CodingKey { case cursor From dbfdeb7a46ad64d7be730934ba56da1a9d9d1df3 Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Wed, 29 May 2024 00:24:18 -0400 Subject: [PATCH 23/51] Re-structure ATUnion; update enum names --- .../ATProtoKit/Models/Lexicons/ATUnion.swift | 1184 +++++++++++++---- .../Embed/AppBskyEmbedRecordWithMedia.swift | 4 +- .../app.bsky/Feed/AppBskyFeedDefs.swift | 165 +-- .../app.bsky/Feed/AppBskyFeedGenerator.swift | 6 +- .../Feed/AppBskyFeedGetPostThread.swift | 2 +- .../app.bsky/Feed/AppBskyFeedPost.swift | 12 +- .../app.bsky/Feed/AppBskyFeedThreadgate.swift | 1 - .../Graph/AppBskyGraphGetRelationships.swift | 2 +- .../app.bsky/Graph/AppBskyGraphList.swift | 6 +- .../chat.bsky/Convo/ChatBskyConvoDefs.swift | 14 +- .../Convo/ChatBskyConvoGetMessages.swift | 2 +- .../ChatBskyModerationGetMessageContext.swift | 2 +- .../ComAtprotoAdminUpdateSubjectStatus.swift | 4 +- .../ComAtprotoModerationCreateReport.swift | 8 +- .../Repo/ComAtprotoRepoApplyWrites.swift | 2 +- .../Moderation/ToolsOzoneModerationDefs.swift | 34 +- .../ToolsOzoneModerationEmitEvent.swift | 4 +- .../ToolsOzoneModerationQueryEvents.swift | 2 +- 18 files changed, 1035 insertions(+), 419 deletions(-) diff --git a/Sources/ATProtoKit/Models/Lexicons/ATUnion.swift b/Sources/ATProtoKit/Models/Lexicons/ATUnion.swift index 2ae25aef9b..92b6a4441c 100644 --- a/Sources/ATProtoKit/Models/Lexicons/ATUnion.swift +++ b/Sources/ATProtoKit/Models/Lexicons/ATUnion.swift @@ -107,13 +107,13 @@ public struct ATUnion { public enum RecordViewUnion: Codable { /// A normal record type. - case viewRecord(AppBskyLexicon.Embed.ViewRecord) + case viewRecord(AppBskyLexicon.Embed.RecordDefinition) /// A record that may not have been found. - case viewNotFound(AppBskyLexicon.Embed.ViewNotFound) + case viewNotFound(AppBskyLexicon.Embed.RecordDefinition.ViewNotFound) /// A record that may have been blocked. - case viewBlocked(AppBskyLexicon.Embed.ViewBlocked) + case viewBlocked(AppBskyLexicon.Embed.RecordDefinition.ViewBlocked) /// A generator view. case generatorView(AppBskyLexicon.Feed.GeneratorViewDefinition) @@ -127,11 +127,11 @@ public struct ATUnion { public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(AppBskyLexicon.Embed.ViewRecord.self) { + if let value = try? container.decode(AppBskyLexicon.Embed.RecordDefinition.self) { self = .viewRecord(value) - } else if let value = try? container.decode(AppBskyLexicon.Embed.ViewNotFound.self) { + } else if let value = try? container.decode(AppBskyLexicon.Embed.RecordDefinition.ViewNotFound.self) { self = .viewNotFound(value) - } else if let value = try? container.decode(AppBskyLexicon.Embed.ViewBlocked.self) { + } else if let value = try? container.decode(AppBskyLexicon.Embed.RecordDefinition.ViewBlocked.self) { self = .viewBlocked(value) } else if let value = try? container.decode(AppBskyLexicon.Feed.GeneratorViewDefinition.self) { self = .generatorView(value) @@ -166,8 +166,57 @@ public struct ATUnion { } } + /// A reference containing the list of the types of embeds. + public enum EmbedViewUnion: Codable { + + /// The view of an external embed. + case embedExternalView(AppBskyLexicon.Embed.ExternalDefinition.View) + + /// The view of an image embed. + case embedImagesView(AppBskyLexicon.Embed.ImagesDefinition.View) + + /// The view of a record embed. + case embedRecordView(AppBskyLexicon.Embed.RecordDefinition.View) + + /// The view of a record embed alongside an embed of some compatible media. + case embedRecordWithMediaView(AppBskyLexicon.Embed.RecordWithMediaDefinition.View) + + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + + if let value = try? container.decode(AppBskyLexicon.Embed.ExternalDefinition.View.self) { + self = .embedExternalView(value) + } else if let value = try? container.decode(AppBskyLexicon.Embed.ImagesDefinition.View.self) { + self = .embedImagesView(value) + } else if let value = try? container.decode(AppBskyLexicon.Embed.RecordDefinition.View.self) { + self = .embedRecordView(value) + } else if let value = try? container.decode(AppBskyLexicon.Embed.RecordWithMediaDefinition.View.self) { + self = .embedRecordWithMediaView(value) + } else { + throw DecodingError.typeMismatch( + EmbedViewUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown EmbedViewUnion type")) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + + switch self { + case .embedExternalView(let embedExternalView): + try container.encode(embedExternalView) + case .embedImagesView(let embedImagesView): + try container.encode(embedImagesView) + case .embedRecordView(let embedRecordView): + try container.encode(embedRecordView) + case .embedRecordWithMediaView(let embedRecordWithMediaView): + try container.encode(embedRecordWithMediaView) + } + } + } + /// A reference containing the list of the types of compatible media. - public enum MediaUnion: Codable { + public enum RecordWithMediaUnion: Codable { /// An image that will be embedded. case embedImages(AppBskyLexicon.Embed.ImagesDefinition) @@ -184,8 +233,8 @@ public struct ATUnion { self = .embedExternal(value) } else { throw DecodingError.typeMismatch( - PostUnion.self, DecodingError.Context( - codingPath: decoder.codingPath, debugDescription: "Unknown MediaUnion type")) + RecordWithMediaUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown RecordWithMediaUnion type")) } } @@ -205,21 +254,21 @@ public struct ATUnion { public enum MediaViewUnion: Codable { /// An image that's been embedded. - case embedImagesView(AppBskyLexicon.Embed.ImagesView) + case embedImagesView(AppBskyLexicon.Embed.ImagesDefinition.View) /// An external link that's been embedded. - case embedExternalView(AppBskyLexicon.Embed.ExternalView) + case embedExternalView(AppBskyLexicon.Embed.ExternalDefinition.View) public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(AppBskyLexicon.Embed.ImagesView.self) { + if let value = try? container.decode(AppBskyLexicon.Embed.ImagesDefinition.View.self) { self = .embedImagesView(value) - } else if let value = try? container.decode(AppBskyLexicon.Embed.ExternalView.self) { + } else if let value = try? container.decode(AppBskyLexicon.Embed.ExternalDefinition.View.self) { self = .embedExternalView(value) } else { throw DecodingError.typeMismatch( - PostUnion.self, DecodingError.Context( + MediaViewUnion.self, DecodingError.Context( codingPath: decoder.codingPath, debugDescription: "Unknown MediaViewUnion type")) } } @@ -236,37 +285,59 @@ public struct ATUnion { } } - /// A reference containing the list of the types of embeds. - public enum EmbedViewUnion: Codable { + /// A reference containing the list of reposts. + public enum ReasonRepostUnion: Codable { - /// The view of an external embed. - case embedExternalView(AppBskyLexicon.Embed.ExternalView) + /// A very stripped down version of a repost. + case reasonRepost(AppBskyLexicon.Feed.ReasonRepostDefinition) - /// The view of an image embed. - case embedImagesView(AppBskyLexicon.Embed.ImagesView) + public init(from decoder: any Decoder) throws { + let container = try decoder.singleValueContainer() - /// The view of a record embed. - case embedRecordView(AppBskyLexicon.Embed.RecordView) + if let value = try? container.decode(AppBskyLexicon.Feed.ReasonRepostDefinition.self) { + self = .reasonRepost(value) + } else { + throw DecodingError.typeMismatch( + ReasonRepostUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown ReasonRepostUnion type")) + } + } - /// The view of a record embed alongside an embed of some compatible media. - case embedRecordWithMediaView(AppBskyLexicon.Embed.RecordWithMediaView) + public func encode(to encoder: any Encoder) throws { + var container = encoder.singleValueContainer() + + switch self { + case .reasonRepost(let reasonRepost): + try container.encode(reasonRepost) + } + } + } + + /// A reference containing the list of the states of a post. + public enum ReplyReferenceRootUnion: Codable { + + /// The view of a post. + case postView(AppBskyLexicon.Feed.PostViewDefinition) + + /// The view of a post that may not have been found. + case notFoundPost(AppBskyLexicon.Feed.NotFoundPostDefinition) + + /// The view of a post that's been blocked by the post author. + case blockedPost(AppBskyLexicon.Feed.BlockedPostDefinition) public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(AppBskyLexicon.Embed.ExternalView.self) { - self = .embedExternalView(value) - } else if let value = try? container.decode(AppBskyLexicon.Embed.ImagesView.self) { - self = .embedImagesView(value) - } else if let value = try? container.decode(AppBskyLexicon.Embed.RecordView.self) { -// print("EmbedView.embedRecordView is about to be read.") - self = .embedRecordView(value) - } else if let value = try? container.decode(AppBskyLexicon.Embed.RecordWithMediaView.self) { - self = .embedRecordWithMediaView(value) + if let value = try? container.decode(AppBskyLexicon.Feed.PostViewDefinition.self) { + self = .postView(value) + } else if let value = try? container.decode(AppBskyLexicon.Feed.NotFoundPostDefinition.self) { + self = .notFoundPost(value) + } else if let value = try? container.decode(AppBskyLexicon.Feed.BlockedPostDefinition.self) { + self = .blockedPost(value) } else { throw DecodingError.typeMismatch( - EmbedViewUnion.self, DecodingError.Context( - codingPath: decoder.codingPath, debugDescription: "Unknown EmbedView type")) + ReplyReferenceRootUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown ReplyReferenceRootUnion type")) } } @@ -274,20 +345,18 @@ public struct ATUnion { var container = encoder.singleValueContainer() switch self { - case .embedExternalView(let embedExternalView): - try container.encode(embedExternalView) - case .embedImagesView(let embedImagesView): - try container.encode(embedImagesView) - case .embedRecordView(let embedRecordView): - try container.encode(embedRecordView) - case .embedRecordWithMediaView(let embedRecordWithMediaView): - try container.encode(embedRecordWithMediaView) + case .postView(let postView): + try container.encode(postView) + case .notFoundPost(let notFoundPost): + try container.encode(notFoundPost) + case .blockedPost(let blockedPost): + try container.encode(blockedPost) } } } /// A reference containing the list of the states of a post. - public enum PostUnion: Codable { + public enum ReplyReferenceParentUnion: Codable { /// The view of a post. case postView(AppBskyLexicon.Feed.PostViewDefinition) @@ -309,8 +378,8 @@ public struct ATUnion { self = .blockedPost(value) } else { throw DecodingError.typeMismatch( - PostUnion.self, DecodingError.Context( - codingPath: decoder.codingPath, debugDescription: "Unknown PostUnion type")) + ReplyReferenceParentUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown ReplyReferenceParentUnion type")) } } @@ -328,8 +397,8 @@ public struct ATUnion { } } - /// A reference containing the list of the states of a post. - public indirect enum ThreadPostUnion: Codable { + /// A reference containing the list of the states of a thread post parent. + public indirect enum ThreadViewPostParentUnion: Codable { /// The view of a post thread. case threadViewPost(AppBskyLexicon.Feed.ThreadViewPostDefinition) @@ -351,8 +420,8 @@ public struct ATUnion { self = .blockedPost(value) } else { throw DecodingError.typeMismatch( - ThreadPostUnion.self, DecodingError.Context( - codingPath: decoder.codingPath, debugDescription: "Unknown ThreadPostUnion type")) + ThreadViewPostParentUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown ThreadViewPostParentUnion type")) } } @@ -370,16 +439,16 @@ public struct ATUnion { } } - /// A reference containing the list of the state of a post thread. - public enum FeedGetPostThreadUnion: Codable { + /// A reference containing the list of the states of a thread post reply. + public indirect enum ThreadViewPostRepliesUnion: Codable { - /// A post thread. + /// The view of a post thread. case threadViewPost(AppBskyLexicon.Feed.ThreadViewPostDefinition) - /// The post thread wasn't found. + /// The view of a post that may not have been found. case notFoundPost(AppBskyLexicon.Feed.NotFoundPostDefinition) - /// The post thread was made by someone who blocked the user account. + /// The view of a post that's been blocked by the post author. case blockedPost(AppBskyLexicon.Feed.BlockedPostDefinition) public init(from decoder: Decoder) throws { @@ -393,8 +462,8 @@ public struct ATUnion { self = .blockedPost(value) } else { throw DecodingError.typeMismatch( - FeedGetPostThreadUnion.self, DecodingError.Context( - codingPath: decoder.codingPath, debugDescription: "Unknown FeedGetPostThread type")) + ThreadViewPostRepliesUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown ThreadViewPostRepliesUnion type")) } } @@ -412,8 +481,97 @@ public struct ATUnion { } } + /// A reference containing the list of reposts. + public enum SkeletonReasonRepostUnion: Codable { + + /// A very stripped down version of a repost. + case skeletonReasonRepost(AppBskyLexicon.Feed.SkeletonReasonRepostDefinition) + + public init(from decoder: any Decoder) throws { + let container = try decoder.singleValueContainer() + + if let value = try? container.decode(AppBskyLexicon.Feed.SkeletonReasonRepostDefinition.self) { + self = .skeletonReasonRepost(value) + } else { + throw DecodingError.typeMismatch( + SkeletonReasonRepostUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown SkeletonReasonRepostUnion type")) + } + } + + public func encode(to encoder: any Encoder) throws { + var container = encoder.singleValueContainer() + + switch self { + case .skeletonReasonRepost(let skeletonReasonRepost): + try container.encode(skeletonReasonRepost) + } + } + } + + /// A reference containing the list of user-defined labels for feed generators. + public enum GeneratorLabelsUnion: Codable { + + /// An array of user-defined labels. + case selfLabels(ComAtprotoLexicon.Label.SelfLabelsDefinition) + + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + + if let value = try? container.decode(ComAtprotoLexicon.Label.SelfLabelsDefinition.self) { + self = .selfLabels(value) + } else { + throw DecodingError.typeMismatch( + GeneratorLabelsUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown GeneratorLabelsUnion type")) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + + switch self { + case .selfLabels(let selfLabelsValue): + try container.encode(selfLabelsValue) + } + } + + enum CodingKeys: String, CodingKey { + case selfLabels + } + } + + /// A reference containing the list of the states of a thread post reply. + public enum GetPostThreadOutputThreadUnion: Codable { + + /// The view of a post thread. + case threadViewPost(AppBskyLexicon.Feed.ThreadViewPostDefinition) + + /// The view of a post that may not have been found. + case notFoundPost(AppBskyLexicon.Feed.NotFoundPostDefinition) + + /// The view of a post that's been blocked by the post author. + case blockedPost(AppBskyLexicon.Feed.BlockedPostDefinition) + + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + + if let value = try? container.decode(AppBskyLexicon.Feed.ThreadViewPostDefinition.self) { + self = .threadViewPost(value) + } else if let value = try? container.decode(AppBskyLexicon.Feed.NotFoundPostDefinition.self) { + self = .notFoundPost(value) + } else if let value = try? container.decode(AppBskyLexicon.Feed.BlockedPostDefinition.self) { + self = .blockedPost(value) + } else { + throw DecodingError.typeMismatch( + GetPostThreadOutputThreadUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown GetPostThreadOutputThreadUnion type")) + } + } + } + /// A reference containing the list of types of embeds. - public enum EmbedUnion: Codable { + public enum PostEmbedUnion: Codable { /// An image embed. case images(AppBskyLexicon.Embed.ImagesDefinition) @@ -440,8 +598,8 @@ public struct ATUnion { self = .recordWithMedia(recordWithMediaValue) } else { throw DecodingError.typeMismatch( - EmbedUnion.self, DecodingError.Context( - codingPath: decoder.codingPath, debugDescription: "Unknown EmbedUnion type")) + PostEmbedUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown PostEmbedUnion type")) } } @@ -462,16 +620,21 @@ public struct ATUnion { } /// A reference containing the list of user-defined labels. - public enum FeedLabelUnion: Codable { + public enum PostSelfLabelsUnion: Codable { /// An array of user-defined labels. - case selfLabels(SelfLabels) + case selfLabels(ComAtprotoLexicon.Label.SelfLabelsDefinition) public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) + let container = try decoder.singleValueContainer() - let selfLabelsValue = try container.decode(SelfLabels.self, forKey: .selfLabels) - self = .selfLabels(selfLabelsValue) + if let value = try? container.decode(ComAtprotoLexicon.Label.SelfLabelsDefinition.self) { + self = .selfLabels(value) + } else { + throw DecodingError.typeMismatch( + PostSelfLabelsUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown PostSelfLabelsUnion type")) + } } public func encode(to encoder: Encoder) throws { @@ -482,36 +645,33 @@ public struct ATUnion { try container.encode(selfLabelsValue) } } - - enum CodingKeys: String, CodingKey { - case selfLabels - } } /// A reference containing the list of thread rules for a post. public enum ThreadgateUnion: Codable { - /// The rule which states that anyone who the user account has mentioned can interact. - case mentionRule(AppBskyLexicon.Feed.FeedThreadgateListRule) + /// A rule that indicates whether users that the post author mentions can reply to the post. + case mentionRule(AppBskyLexicon.Feed.ThreadgateRecord.MentionRule) - /// The rule which states that anyone the user account is following can interact. - case followingRule(AppBskyLexicon.Feed.FeedThreadgateFollowingRule) + /// A rule that indicates whether users that the post author is following can reply to the post. + case followingRule(AppBskyLexicon.Feed.ThreadgateRecord.FollowingRule) - /// The rule which states that anyone within a list can interact. - case listRule(AppBskyLexicon.Feed.FeedThreadgateListRule) + /// A rule that indicates whether users that are on a specific list made by the post author can + /// reply to the post. + case listRule(AppBskyLexicon.Feed.ThreadgateRecord.ListRule) public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(AppBskyLexicon.Feed.FeedThreadgateListRule.self) { + if let value = try? container.decode(AppBskyLexicon.Feed.ThreadgateRecord.MentionRule.self) { self = .mentionRule(value) - } else if let value = try? container.decode(AppBskyLexicon.Feed.FeedThreadgateFollowingRule.self) { + } else if let value = try? container.decode(AppBskyLexicon.Feed.ThreadgateRecord.FollowingRule.self) { self = .followingRule(value) - } else if let value = try? container.decode(AppBskyLexicon.Feed.FeedThreadgateListRule.self) { + } else if let value = try? container.decode(AppBskyLexicon.Feed.ThreadgateRecord.ListRule.self) { self = .listRule(value) } else { throw DecodingError.typeMismatch( - EmbedViewUnion.self, DecodingError.Context( + ThreadgateUnion.self, DecodingError.Context( codingPath: decoder.codingPath, debugDescription: "Unknown ThreadgateUnion type")) } } @@ -531,7 +691,7 @@ public struct ATUnion { } /// A reference containing the list of relationships of multiple user accounts. - public enum GraphRelationshipUnion: Codable { + public enum GetRelationshipsOutputRelationshipUnion: Codable { /// The relationship between two user accounts. case relationship(AppBskyLexicon.Graph.RelationshipDefinition) @@ -548,8 +708,8 @@ public struct ATUnion { self = .notFoundActor(value) } else { throw DecodingError.typeMismatch( - ActorPreferenceUnion.self, DecodingError.Context( - codingPath: decoder.codingPath, debugDescription: "Unknown GraphRelationshipUnion type")) + GetRelationshipsOutputRelationshipUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown GetRelationshipsOutputRelationshipUnion type")) } } @@ -566,7 +726,7 @@ public struct ATUnion { } /// A reference containing the list of labeler views. - public enum LabelerViewUnion: Codable { + public enum GetServicesOutputViewsUnion: Codable { /// A labeler view. case labelerView(AppBskyLexicon.Labeler.LabelerViewDefinition) @@ -583,8 +743,8 @@ public struct ATUnion { self = .labelerViewDetailed(value) } else { throw DecodingError.typeMismatch( - ActorPreferenceUnion.self, DecodingError.Context( - codingPath: decoder.codingPath, debugDescription: "Unknown LabelerViewUnion type")) + GetServicesOutputViewsUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown GetServicesOutputViewsUnion type")) } } @@ -601,30 +761,30 @@ public struct ATUnion { } /// A reference containing the list of feature types. - public enum FeatureUnion: Codable { + public enum FacetFeatureUnion: Codable { /// The Mention feature. - case mention(AppBskyLexicon.RichText.Mention) + case mention(AppBskyLexicon.RichText.Facet.Mention) /// The Link feature. - case link(AppBskyLexicon.RichText.Link) + case link(AppBskyLexicon.RichText.Facet.Link) /// The Tag feature. - case tag(AppBskyLexicon.RichText.Tag) + case tag(AppBskyLexicon.RichText.Facet.Tag) public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(AppBskyLexicon.RichText.Mention.self) { + if let value = try? container.decode(AppBskyLexicon.RichText.Facet.Mention.self) { self = .mention(value) - } else if let value = try? container.decode(AppBskyLexicon.RichText.Link.self) { + } else if let value = try? container.decode(AppBskyLexicon.RichText.Facet.Link.self) { self = .link(value) - } else if let value = try? container.decode(AppBskyLexicon.RichText.Tag.self) { + } else if let value = try? container.decode(AppBskyLexicon.RichText.Facet.Tag.self) { self = .tag(value) } else { throw DecodingError.typeMismatch( - FeatureUnion.self, DecodingError.Context( - codingPath: decoder.codingPath, debugDescription: "Unknown FeatureUnion type")) + FacetFeatureUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown FacetFeatureUnion type")) } } @@ -642,10 +802,64 @@ public struct ATUnion { } } - + /// A reference containing the list of user-defined labels for feed generators. + public enum ListLabelsUnion: Codable { + + /// An array of user-defined labels. + case selfLabels(ComAtprotoLexicon.Label.SelfLabelsDefinition) + + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + + if let value = try? container.decode(ComAtprotoLexicon.Label.SelfLabelsDefinition.self) { + self = .selfLabels(value) + } else { + throw DecodingError.typeMismatch( + ListLabelsUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown ListLabelsUnion type")) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + + switch self { + case .selfLabels(let selfLabelsValue): + try container.encode(selfLabelsValue) + } + } + } + + /// A reference containing the list of message embeds. + public enum MessageInputEmbedUnion: Codable { + + /// A record within the embed. + case record(AppBskyLexicon.Embed.RecordDefinition) + + public init(from decoder: any Decoder) throws { + let container = try decoder.singleValueContainer() + + if let value = try? container.decode(AppBskyLexicon.Embed.RecordDefinition.self) { + self = .record(value) + } else { + throw DecodingError.typeMismatch( + MessageInputEmbedUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown MessageInputEmbedUnion type")) + } + } + + public func encode(to encoder: any Encoder) throws { + var container = encoder.singleValueContainer() + + switch self { + case .record(let record): + try container.encode(record) + } + } + } /// A reference containing the list of message embeds. - public enum MessageEmbedUnion: Codable { + public enum MessageViewEmbedUnion: Codable { /// A record within the embed. case record(AppBskyLexicon.Embed.RecordDefinition) @@ -657,8 +871,8 @@ public struct ATUnion { self = .record(value) } else { throw DecodingError.typeMismatch( - MessageEmbedUnion.self, DecodingError.Context( - codingPath: decoder.codingPath, debugDescription: "Unknown MessageEmbedUnion type")) + MessageViewEmbedUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown MessageViewEmbedUnion type")) } } @@ -673,7 +887,7 @@ public struct ATUnion { } /// A reference containing the list of messages. - public enum MessageViewUnion: Codable { + public enum ConversationViewLastMessageUnion: Codable { /// A message view. case messageView(ChatBskyLexicon.Conversation.MessageViewDefinition) @@ -690,8 +904,8 @@ public struct ATUnion { self = .deletedMessageView(value) } else { throw DecodingError.typeMismatch( - MessageViewUnion.self, DecodingError.Context( - codingPath: decoder.codingPath, debugDescription: "Unknown MessageViewUnion type")) + ConversationViewLastMessageUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown ConversationViewLastMessageUnion type")) } } @@ -707,36 +921,26 @@ public struct ATUnion { } } - /// A reference containing the list of message logs. - public enum MessageLogsUnion: Codable { - - /// A log entry for beginning the coversation. - case logBeginConversation(ChatBskyLexicon.Conversation.LogBeginConversationDefinition) - - /// A log entry for leaving the conversation. - case logLeaveConversation(ChatBskyLexicon.Conversation.LogLeaveConversationDefinition) + /// A reference containing the list of messages. + public enum LogCreateMessageUnion: Codable { - /// A log entry for creating a message. - case logCreateMessage(ChatBskyLexicon.Conversation.LogCreateMessageDefinition) + /// A message view. + case messageView(ChatBskyLexicon.Conversation.MessageViewDefinition) - /// A log entry for deleting a message. - case logDeleteMessage(ChatBskyLexicon.Conversation.LogDeleteMessageDefinition) + /// A deleted message view. + case deletedMessageView(ChatBskyLexicon.Conversation.DeleteMessageViewDefinition) public init(from decoder: any Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(ChatBskyLexicon.Conversation.LogBeginConversationDefinition.self) { - self = .logBeginConversation(value) - } else if let value = try? container.decode(ChatBskyLexicon.Conversation.LogLeaveConversationDefinition.self) { - self = .logLeaveConversation(value) - } else if let value = try? container.decode(ChatBskyLexicon.Conversation.LogCreateMessageDefinition.self) { - self = .logCreateMessage(value) - } else if let value = try? container.decode(ChatBskyLexicon.Conversation.LogDeleteMessageDefinition.self) { - self = .logDeleteMessage(value) + if let value = try? container.decode(ChatBskyLexicon.Conversation.MessageViewDefinition.self) { + self = .messageView(value) + } else if let value = try? container.decode(ChatBskyLexicon.Conversation.DeleteMessageViewDefinition.self) { + self = .deletedMessageView(value) } else { throw DecodingError.typeMismatch( - MessageLogsUnion.self, DecodingError.Context( - codingPath: decoder.codingPath, debugDescription: "Unknown MessageLogsUnion type")) + LogCreateMessageUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown LogCreateMessageUnion type")) } } @@ -744,7 +948,87 @@ public struct ATUnion { var container = encoder.singleValueContainer() switch self { - case .logBeginConversation(let logBeginConversation): + case .messageView(let messageView): + try container.encode(messageView) + case .deletedMessageView(let deletedMessageView): + try container.encode(deletedMessageView) + } + } + } + + /// A reference containing the list of messages. + public enum LogDeleteMessageUnion: Codable { + + /// A message view. + case messageView(ChatBskyLexicon.Conversation.MessageViewDefinition) + + /// A deleted message view. + case deletedMessageView(ChatBskyLexicon.Conversation.DeleteMessageViewDefinition) + + public init(from decoder: any Decoder) throws { + let container = try decoder.singleValueContainer() + + if let value = try? container.decode(ChatBskyLexicon.Conversation.MessageViewDefinition.self) { + self = .messageView(value) + } else if let value = try? container.decode(ChatBskyLexicon.Conversation.DeleteMessageViewDefinition.self) { + self = .deletedMessageView(value) + } else { + throw DecodingError.typeMismatch( + LogDeleteMessageUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown LogDeleteMessageUnion type")) + } + } + + public func encode(to encoder: any Encoder) throws { + var container = encoder.singleValueContainer() + + switch self { + case .messageView(let messageView): + try container.encode(messageView) + case .deletedMessageView(let deletedMessageView): + try container.encode(deletedMessageView) + } + } + } + + /// A reference containing the list of message logs. + public enum MessageLogsUnion: Codable { + + /// A log entry for beginning the coversation. + case logBeginConversation(ChatBskyLexicon.Conversation.LogBeginConversationDefinition) + + /// A log entry for leaving the conversation. + case logLeaveConversation(ChatBskyLexicon.Conversation.LogLeaveConversationDefinition) + + /// A log entry for creating a message. + case logCreateMessage(ChatBskyLexicon.Conversation.LogCreateMessageDefinition) + + /// A log entry for deleting a message. + case logDeleteMessage(ChatBskyLexicon.Conversation.LogDeleteMessageDefinition) + + public init(from decoder: any Decoder) throws { + let container = try decoder.singleValueContainer() + + if let value = try? container.decode(ChatBskyLexicon.Conversation.LogBeginConversationDefinition.self) { + self = .logBeginConversation(value) + } else if let value = try? container.decode(ChatBskyLexicon.Conversation.LogLeaveConversationDefinition.self) { + self = .logLeaveConversation(value) + } else if let value = try? container.decode(ChatBskyLexicon.Conversation.LogCreateMessageDefinition.self) { + self = .logCreateMessage(value) + } else if let value = try? container.decode(ChatBskyLexicon.Conversation.LogDeleteMessageDefinition.self) { + self = .logDeleteMessage(value) + } else { + throw DecodingError.typeMismatch( + MessageLogsUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown MessageLogsUnion type")) + } + } + + public func encode(to encoder: any Encoder) throws { + var container = encoder.singleValueContainer() + + switch self { + case .logBeginConversation(let logBeginConversation): try container.encode(logBeginConversation) case .logLeaveConversation(let logLeaveConversation): try container.encode(logLeaveConversation) @@ -756,86 +1040,317 @@ public struct ATUnion { } } + /// A reference containing the list of messages. + public enum GetMessagesOutputMessagesUnion: Codable { + + /// A message view. + case messageView(ChatBskyLexicon.Conversation.MessageViewDefinition) + + /// A deleted message view. + case deletedMessageView(ChatBskyLexicon.Conversation.DeleteMessageViewDefinition) + + public init(from decoder: any Decoder) throws { + let container = try decoder.singleValueContainer() + + if let value = try? container.decode(ChatBskyLexicon.Conversation.MessageViewDefinition.self) { + self = .messageView(value) + } else if let value = try? container.decode(ChatBskyLexicon.Conversation.DeleteMessageViewDefinition.self) { + self = .deletedMessageView(value) + } else { + throw DecodingError.typeMismatch( + GetMessagesOutputMessagesUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown GetMessagesOutputMessagesUnion type")) + } + } + + public func encode(to encoder: any Encoder) throws { + var container = encoder.singleValueContainer() + + switch self { + case .messageView(let messageView): + try container.encode(messageView) + case .deletedMessageView(let deletedMessageView): + try container.encode(deletedMessageView) + } + } + } + + /// A reference containing the list of messages. + public enum GetMessageContextOutputMessagesUnion: Codable { + + /// A message view. + case messageView(ChatBskyLexicon.Conversation.MessageViewDefinition) + + /// A deleted message view. + case deletedMessageView(ChatBskyLexicon.Conversation.DeleteMessageViewDefinition) + + public init(from decoder: any Decoder) throws { + let container = try decoder.singleValueContainer() + + if let value = try? container.decode(ChatBskyLexicon.Conversation.MessageViewDefinition.self) { + self = .messageView(value) + } else if let value = try? container.decode(ChatBskyLexicon.Conversation.DeleteMessageViewDefinition.self) { + self = .deletedMessageView(value) + } else { + throw DecodingError.typeMismatch( + ConversationViewLastMessageUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown ConversationViewLastMessageUnion type")) + } + } + + public func encode(to encoder: any Encoder) throws { + var container = encoder.singleValueContainer() + + switch self { + case .messageView(let messageView): + try container.encode(messageView) + case .deletedMessageView(let deletedMessageView): + try container.encode(deletedMessageView) + } + } + } + + /// A reference containing the list of repository references. + public enum AdminGetSubjectStatusUnion: Codable { + + /// A repository reference. + case repositoryReference(ComAtprotoLexicon.Admin.RepositoryReferenceDefinition) + + /// A strong reference. + case strongReference(StrongReference) + + /// A repository blob reference. + case repositoryBlobReference(ComAtprotoLexicon.Admin.RepositoryBlobReferenceDefinition) + + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + + if let value = try? container.decode(ComAtprotoLexicon.Admin.RepositoryReferenceDefinition.self) { + self = .repositoryReference(value) + } else if let value = try? container.decode(StrongReference.self) { + self = .strongReference(value) + } else if let value = try? container.decode(ComAtprotoLexicon.Admin.RepositoryBlobReferenceDefinition.self) { + self = .repositoryBlobReference(value) + } else { + throw DecodingError.typeMismatch( + AdminGetSubjectStatusUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown AdminGetSubjectStatusUnion type")) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + + switch self { + case .repositoryReference(let repositoryReference): + try container.encode(repositoryReference) + case .strongReference(let strongReference): + try container.encode(strongReference) + case .repositoryBlobReference(let repoBlobReference): + try container.encode(repoBlobReference) + } + } + } + + /// A reference containing the list of repository references. + public enum AdminUpdateSubjectStatusUnion: Codable { + + /// A repository reference. + case repositoryReference(ComAtprotoLexicon.Admin.RepositoryReferenceDefinition) + + /// A strong reference. + case strongReference(StrongReference) + + /// A repository blob reference. + case repositoryBlobReference(ComAtprotoLexicon.Admin.RepositoryBlobReferenceDefinition) + + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + + if let value = try? container.decode(ComAtprotoLexicon.Admin.RepositoryReferenceDefinition.self) { + self = .repositoryReference(value) + } else if let value = try? container.decode(StrongReference.self) { + self = .strongReference(value) + } else if let value = try? container.decode(ComAtprotoLexicon.Admin.RepositoryBlobReferenceDefinition.self) { + self = .repositoryBlobReference(value) + } else { + throw DecodingError.typeMismatch( + AdminUpdateSubjectStatusUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Uknown AdminUpdateSubjectStatusUnion type")) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + + switch self { + case .repositoryReference(let repositoryReference): + try container.encode(repositoryReference) + case .strongReference(let strongReference): + try container.encode(strongReference) + case .repositoryBlobReference(let repoBlobReference): + try container.encode(repoBlobReference) + } + } + } + + /// A reference containing the list of repository references. + public enum CreateReportSubjectUnion: Codable { + + /// A repository reference. + case repositoryReference(ComAtprotoLexicon.Admin.RepositoryReferenceDefinition) + + /// A strong reference. + case strongReference(ComAtprotoLexicon.Repository.StrongReference) + + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + + if let value = try? container.decode(ComAtprotoLexicon.Admin.RepositoryReferenceDefinition.self) { + self = .repositoryReference(value) + } else if let value = try? container.decode(ComAtprotoLexicon.Repository.StrongReference.self) { + self = .strongReference(value) + } else { + throw DecodingError.typeMismatch( + CreateReportSubjectUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown CreateReportSubjectUnion type")) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + + switch self { + case .repositoryReference(let repositoryReference): + try container.encode(repositoryReference) + case .strongReference(let strongReference): + try container.encode(strongReference) + } + } + } + + /// A reference containing the list of write operations. + public enum ApplyWritesUnion: Codable { + + /// A "Create" write operation. + case create(RepoApplyWritesCreate) + + /// An "Update" write operation. + case update(RepoApplyWritesUpdate) + + /// A "Delete" write operation. + case delete(RepoApplyWritesDelete) + + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + + if let value = try? container.decode(RepoApplyWritesCreate.self) { + self = .create(value) + } else if let value = try? container.decode(RepoApplyWritesUpdate.self) { + self = .update(value) + } else if let value = try? container.decode(RepoApplyWritesDelete.self) { + self = .delete(value) + } else { + throw DecodingError.typeMismatch( + ApplyWritesUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown ApplyWritesUnion type")) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + + switch self { + case .create(let embedView): + try container.encode(embedView) + case .update(let embedView): + try container.encode(embedView) + case .delete(let embedView): + try container.encode(embedView) + } + } + } + /// A reference containing the list of event views. - public enum AdminEventViewUnion: Codable { + public enum ModerationEventViewUnion: Codable { /// A takedown event. - case moderationEventTakedown(OzoneModerationEventTakedown) + case moderationEventTakedown(ToolsOzoneLexicon.Moderation.EventTakedownDefinition) /// A reverse takedown event. - case moderationEventReverseTakedown(OzoneModerationEventReverseTakedown) + case moderationEventReverseTakedown(ToolsOzoneLexicon.Moderation.EventReverseTakedownDefinition) /// A comment event. - case moderationEventComment(OzoneModerationEventComment) + case moderationEventComment(ToolsOzoneLexicon.Moderation.EventCommentDefinition) /// A report event. - case moderationEventReport(OzoneModerationEventReport) + case moderationEventReport(ToolsOzoneLexicon.Moderation.EventReportDefinition) /// A label event. - case moderationEventLabel(OzoneModerationEventLabel) + case moderationEventLabel(ToolsOzoneLexicon.Moderation.EventLabelDefinition) /// An acknowledgement event. - case moderationEventAcknowledge(OzoneModerationEventAcknowledge) + case moderationEventAcknowledge(ToolsOzoneLexicon.Moderation.EventAcknowledgeDefinition) /// An escalation event. - case moderationEventEscalate(OzoneModerationEventEscalate) + case moderationEventEscalate(ToolsOzoneLexicon.Moderation.EventEscalateDefinition) /// A mute event. - case moderationEventMute(OzoneModerationEventMute) + case moderationEventMute(ToolsOzoneLexicon.Moderation.EventMuteDefinition) /// An unmute event. - case moderationEventUnmute(OzoneModerationEventUnmute) + case moderationEventUnmute(ToolsOzoneLexicon.Moderation.EventUnmuteDefinition) /// A mute reporter event. - case moderationEventMuteReporter(OzoneModerationEventMuteReporter) + case moderationEventMuteReporter(ToolsOzoneLexicon.Moderation.EventMuteReporterDefinition) /// An unmute reporter event. - case moderationEventUnmuteReporter(OzoneModerationEventUnmuteReporter) + case moderationEventUnmuteReporter(ToolsOzoneLexicon.Moderation.EventUnmuteReporterDefinition) /// An email event. - case moderationEventEmail(OzoneModerationEventEmail) + case moderationEventEmail(ToolsOzoneLexicon.Moderation.EventEmailDefinition) /// A resolve appeal event. - case moderationEventResolveAppeal(OzoneModerationEventResolveAppeal) + case moderationEventResolveAppeal(ToolsOzoneLexicon.Moderation.EventResolveAppealDefinition) /// A diversion event. - case moderationEventDivert(OzoneModerationEventDivert) + case moderationEventDivert(ToolsOzoneLexicon.Moderation.EventDivertDefinition) public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(OzoneModerationEventTakedown.self) { + if let value = try? container.decode(ToolsOzoneLexicon.Moderation.EventTakedownDefinition.self) { self = .moderationEventTakedown(value) - } else if let value = try? container.decode(OzoneModerationEventReverseTakedown.self) { + } else if let value = try? container.decode(ToolsOzoneLexicon.Moderation.EventReverseTakedownDefinition.self) { self = .moderationEventReverseTakedown(value) - } else if let value = try? container.decode(OzoneModerationEventComment.self) { + } else if let value = try? container.decode(ToolsOzoneLexicon.Moderation.EventCommentDefinition.self) { self = .moderationEventComment(value) - } else if let value = try? container.decode(OzoneModerationEventReport.self) { + } else if let value = try? container.decode(ToolsOzoneLexicon.Moderation.EventReportDefinition.self) { self = .moderationEventReport(value) - } else if let value = try? container.decode(OzoneModerationEventLabel.self) { + } else if let value = try? container.decode(ToolsOzoneLexicon.Moderation.EventLabelDefinition.self) { self = .moderationEventLabel(value) - } else if let value = try? container.decode(OzoneModerationEventAcknowledge.self) { + } else if let value = try? container.decode(ToolsOzoneLexicon.Moderation.EventAcknowledgeDefinition.self) { self = .moderationEventAcknowledge(value) - } else if let value = try? container.decode(OzoneModerationEventEscalate.self) { + } else if let value = try? container.decode(ToolsOzoneLexicon.Moderation.EventEscalateDefinition.self) { self = .moderationEventEscalate(value) - } else if let value = try? container.decode(OzoneModerationEventMute.self) { + } else if let value = try? container.decode(ToolsOzoneLexicon.Moderation.EventMuteDefinition.self) { self = .moderationEventMute(value) - } else if let value = try? container.decode(OzoneModerationEventUnmute.self) { + } else if let value = try? container.decode(ToolsOzoneLexicon.Moderation.EventUnmuteDefinition.self) { self = .moderationEventUnmute(value) - } else if let value = try? container.decode(OzoneModerationEventMuteReporter.self) { + } else if let value = try? container.decode(ToolsOzoneLexicon.Moderation.EventMuteReporterDefinition.self) { self = .moderationEventMuteReporter(value) - } else if let value = try? container.decode(OzoneModerationEventUnmuteReporter.self) { + } else if let value = try? container.decode(ToolsOzoneLexicon.Moderation.EventUnmuteReporterDefinition.self) { self = .moderationEventUnmuteReporter(value) - } else if let value = try? container.decode(OzoneModerationEventEmail.self) { + } else if let value = try? container.decode(ToolsOzoneLexicon.Moderation.EventEmailDefinition.self) { self = .moderationEventEmail(value) - } else if let value = try? container.decode(OzoneModerationEventResolveAppeal.self) { + } else if let value = try? container.decode(ToolsOzoneLexicon.Moderation.EventResolveAppealDefinition.self) { self = .moderationEventResolveAppeal(value) - } else if let value = try? container.decode(OzoneModerationEventDivert.self) { + } else if let value = try? container.decode(ToolsOzoneLexicon.Moderation.EventDivertDefinition.self) { self = .moderationEventDivert(value) } else { throw DecodingError.typeMismatch( - AdminEventViewUnion.self, DecodingError.Context( - codingPath: decoder.codingPath, debugDescription: "Unknown EventViewUnion type")) + ModerationEventViewUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown ModerationEventViewUnion type")) } } @@ -876,67 +1391,30 @@ public struct ATUnion { } /// A reference containing the list of repository references. - public enum AdminGetSubjectStatusUnion: Codable { + public enum ModerationEventViewSubjectUnion: Codable { /// A repository reference. - case repositoryReference(AdminRepositoryReference) + case repositoryReference(ComAtprotoLexicon.Admin.RepositoryReferenceDefinition) /// A strong reference. - case strongReference(StrongReference) - /// A repository blob reference. - case repoBlobReference(AdminRepoBlobReference) - - public init(from decoder: Decoder) throws { - let container = try decoder.singleValueContainer() - - if let value = try? container.decode(AdminRepositoryReference.self) { - self = .repositoryReference(value) - } else if let value = try? container.decode(StrongReference.self) { - self = .strongReference(value) - } else if let value = try? container.decode(AdminRepoBlobReference.self) { - self = .repoBlobReference(value) - } else { - throw DecodingError.typeMismatch( - AdminEventViewUnion.self, DecodingError.Context( - codingPath: decoder.codingPath, debugDescription: "UnknownAdminGetSubjectStatusUnion type")) - } - } + case strongReference(ComAtprotoLexicon.Repository.StrongReference) - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - - switch self { - case .repositoryReference(let repositoryReference): - try container.encode(repositoryReference) - case .strongReference(let strongReference): - try container.encode(strongReference) - case .repoBlobReference(let repoBlobReference): - try container.encode(repoBlobReference) - } - } - } - - // Create the custom init and encode methods. - /// A reference containing the list of repository references. - public enum RepositoryReferencesUnion: Codable { - - /// A repository reference. - case repositoryReference(AdminRepositoryReference) - - /// A strong reference. - case strongReference(StrongReference) + /// A message reference for a conversation. + case messageReference(ChatBskyLexicon.Conversation.MessageReferenceDefinition) public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(AdminRepositoryReference.self) { + if let value = try? container.decode(ComAtprotoLexicon.Admin.RepositoryReferenceDefinition.self) { self = .repositoryReference(value) - } else if let value = try? container.decode(StrongReference.self) { + } else if let value = try? container.decode(ComAtprotoLexicon.Repository.StrongReference.self) { self = .strongReference(value) + } else if let value = try? container.decode(ChatBskyLexicon.Conversation.MessageReferenceDefinition.self) { + self = .messageReference(value) } else { throw DecodingError.typeMismatch( - ActorPreferenceUnion.self, DecodingError.Context( - codingPath: decoder.codingPath, debugDescription: "Unknown RepositoryReferencesUnion type")) + ModerationEventViewSubjectUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown ModerationEventViewSubjectUnion type")) } } @@ -948,66 +1426,67 @@ public struct ATUnion { try container.encode(repositoryReference) case .strongReference(let strongReference): try container.encode(strongReference) + case .messageReference(let messageReference): + try container.encode(messageReference) } } } - // Create the custom init and encode methods. /// A reference containing the list of moderator events. - public enum EventViewDetailUnion: Codable { + public enum ModerationEventViewDetailUnion: Codable { /// A takedown event. - case moderationEventTakedown(OzoneModerationEventTakedown) + case moderationEventTakedown(ToolsOzoneLexicon.Moderation.EventTakedownDefinition) /// A reverse takedown event. - case moderationEventReverseTakedown(OzoneModerationEventReverseTakedown) + case moderationEventReverseTakedown(ToolsOzoneLexicon.Moderation.EventReverseTakedownDefinition) /// A comment event. - case moderationEventComment(OzoneModerationEventComment) + case moderationEventComment(ToolsOzoneLexicon.Moderation.EventCommentDefinition) /// A report event. - case moderationEventReport(OzoneModerationEventReport) + case moderationEventReport(ToolsOzoneLexicon.Moderation.EventReportDefinition) /// A label event. - case moderationEventLabel(OzoneModerationEventLabel) + case moderationEventLabel(ToolsOzoneLexicon.Moderation.EventLabelDefinition) /// An acknowledgment event. - case moderationEventAcknowledge(OzoneModerationEventAcknowledge) + case moderationEventAcknowledge(ToolsOzoneLexicon.Moderation.EventAcknowledgeDefinition) /// An escalation event. - case moderationEventEscalate(OzoneModerationEventEscalate) + case moderationEventEscalate(ToolsOzoneLexicon.Moderation.EventEscalateDefinition) /// A mute event. - case moderationEventMute(OzoneModerationEventMute) + case moderationEventMute(ToolsOzoneLexicon.Moderation.EventMuteDefinition) /// A resolve appeal event. - case moderationEventResolveAppeal(OzoneModerationEventResolveAppeal) + case moderationEventResolveAppeal(ToolsOzoneLexicon.Moderation.EventResolveAppealDefinition) public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(OzoneModerationEventTakedown.self) { + if let value = try? container.decode(ToolsOzoneLexicon.Moderation.EventTakedownDefinition.self) { self = .moderationEventTakedown(value) - } else if let value = try? container.decode(OzoneModerationEventReverseTakedown.self) { + } else if let value = try? container.decode(ToolsOzoneLexicon.Moderation.EventReverseTakedownDefinition.self) { self = .moderationEventReverseTakedown(value) - } else if let value = try? container.decode(OzoneModerationEventComment.self) { + } else if let value = try? container.decode(ToolsOzoneLexicon.Moderation.EventCommentDefinition.self) { self = .moderationEventComment(value) - } else if let value = try? container.decode(OzoneModerationEventReport.self) { + } else if let value = try? container.decode(ToolsOzoneLexicon.Moderation.EventReportDefinition.self) { self = .moderationEventReport(value) - } else if let value = try? container.decode(OzoneModerationEventLabel.self) { + } else if let value = try? container.decode(ToolsOzoneLexicon.Moderation.EventLabelDefinition.self) { self = .moderationEventLabel(value) - } else if let value = try? container.decode(OzoneModerationEventAcknowledge.self) { + } else if let value = try? container.decode(ToolsOzoneLexicon.Moderation.EventAcknowledgeDefinition.self) { self = .moderationEventAcknowledge(value) - } else if let value = try? container.decode(OzoneModerationEventEscalate.self) { + } else if let value = try? container.decode(ToolsOzoneLexicon.Moderation.EventEscalateDefinition.self) { self = .moderationEventEscalate(value) - } else if let value = try? container.decode(OzoneModerationEventMute.self) { + } else if let value = try? container.decode(ToolsOzoneLexicon.Moderation.EventMuteDefinition.self) { self = .moderationEventMute(value) - } else if let value = try? container.decode(OzoneModerationEventResolveAppeal.self) { + } else if let value = try? container.decode(ToolsOzoneLexicon.Moderation.EventResolveAppealDefinition.self) { self = .moderationEventResolveAppeal(value) } else { throw DecodingError.typeMismatch( - ActorPreferenceUnion.self, DecodingError.Context( - codingPath: decoder.codingPath, debugDescription: "Unknown EventViewDetailUnion type")) + ModerationEventViewDetailUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown ModerationEventViewDetailUnion type")) } } @@ -1037,37 +1516,68 @@ public struct ATUnion { } } - // Create the custom init and encode methods. - /// A reference containing the list of the types of repository or record views. - public enum RepositoryViewUnion: Codable { + /// A reference containing the list of repository references. + public enum ModerationEventViewDetailSubjectUnion: Codable { + + /// A repository reference. + case repositoryReference(ComAtprotoLexicon.Admin.RepositoryReferenceDefinition) + + /// A strong reference. + case strongReference(ComAtprotoLexicon.Repository.StrongReference) + + /// A message reference for a conversation. + case messageReference(ChatBskyLexicon.Conversation.MessageReferenceDefinition) + + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + + if let value = try? container.decode(ComAtprotoLexicon.Admin.RepositoryReferenceDefinition.self) { + self = .repositoryReference(value) + } else if let value = try? container.decode(ComAtprotoLexicon.Repository.StrongReference.self) { + self = .strongReference(value) + } else if let value = try? container.decode(ChatBskyLexicon.Conversation.MessageReferenceDefinition.self) { + self = .messageReference(value) + } else { + throw DecodingError.typeMismatch( + ModerationEventViewDetailSubjectUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown ModerationEventViewDetailSubjectUnion type")) + } + } - /// A normal repository view. - case repositoryView(AdminReportView) + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() - /// A repository view that may not have been found. - case repositoryViewNotFound(OzoneModerationRepositoryViewNotFound) + switch self { + case .repositoryReference(let repositoryReference): + try container.encode(repositoryReference) + case .strongReference(let strongReference): + try container.encode(strongReference) + case .messageReference(let messageReference): + try container.encode(messageReference) + } + } + } - /// A normal record. - case recordView(OzoneModerationRecordView) + /// A reference containing the list of repository references. + public enum SubjectStatusViewSubjectUnion: Codable { - /// A record view that may not have been found. - case recordViewNotFound(OzoneModerationRecordViewNotFound) + /// A repository reference. + case repositoryReference(ComAtprotoLexicon.Admin.RepositoryReferenceDefinition) + + /// A strong reference. + case strongReference(ComAtprotoLexicon.Repository.StrongReference) public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(AdminReportView.self) { - self = .repositoryView(value) - } else if let value = try? container.decode(OzoneModerationRepositoryViewNotFound.self) { - self = .repositoryViewNotFound(value) - } else if let value = try? container.decode(OzoneModerationRecordView.self) { - self = .recordView(value) - } else if let value = try? container.decode(OzoneModerationRecordViewNotFound.self) { - self = .recordViewNotFound(value) + if let value = try? container.decode(ComAtprotoLexicon.Admin.RepositoryReferenceDefinition.self) { + self = .repositoryReference(value) + } else if let value = try? container.decode(ComAtprotoLexicon.Repository.StrongReference.self) { + self = .strongReference(value) } else { throw DecodingError.typeMismatch( - ActorPreferenceUnion.self, DecodingError.Context( - codingPath: decoder.codingPath, debugDescription: "Unknown RepositoryViewUnion type")) + SubjectStatusViewSubjectUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown SubjectStatusViewSubjectUnion type")) } } @@ -1075,38 +1585,34 @@ public struct ATUnion { var container = encoder.singleValueContainer() switch self { - case .repositoryView(let repositoryView): - try container.encode(repositoryView) - case .repositoryViewNotFound(let repositoryViewNotFound): - try container.encode(repositoryViewNotFound) - case .recordView(let recordView): - try container.encode(recordView) - case .recordViewNotFound(let recordViewNotFound): - try container.encode(recordViewNotFound) + case .repositoryReference(let repositoryReference): + try container.encode(repositoryReference) + case .strongReference(let strongReference): + try container.encode(strongReference) } } } /// A reference containing the list of the types of media details. - public enum MediaDetailUnion: Codable { + public enum BlobViewDetailUnion: Codable { /// The details for an image. - case mediaImageDetails(OzoneModerationMediaImageDetails) + case mediaImageDetails(ToolsOzoneLexicon.Moderation.ImageDetailsDefinition) /// The details for a video. - case mediaVideoDetails(OzoneModerationMediaVideoDetails) + case mediaVideoDetails(ToolsOzoneLexicon.Moderation.VideoDetailsDefinition) public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(OzoneModerationMediaImageDetails.self) { + if let value = try? container.decode(ToolsOzoneLexicon.Moderation.ImageDetailsDefinition.self) { self = .mediaImageDetails(value) - } else if let value = try? container.decode(OzoneModerationMediaVideoDetails.self) { + } else if let value = try? container.decode(ToolsOzoneLexicon.Moderation.VideoDetailsDefinition.self) { self = .mediaVideoDetails(value) } else { throw DecodingError.typeMismatch( - ActorPreferenceUnion.self, DecodingError.Context( - codingPath: decoder.codingPath, debugDescription: "Unknown MediaDetailUnion type")) + BlobViewDetailUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown BlobViewDetailUnion type")) } } @@ -1122,31 +1628,86 @@ public struct ATUnion { } } - /// A reference containing the list of write operations. - public enum ApplyWritesUnion: Codable { + /// A reference containing the list of event views. + public enum EmitEventUnion: Codable { - /// A "Create" write operation. - case create(RepoApplyWritesCreate) + /// A takedown event. + case moderationEventTakedown(ToolsOzoneLexicon.Moderation.EventTakedownDefinition) - /// An "Update" write operation. - case update(RepoApplyWritesUpdate) + /// A reverse takedown event. + case moderationEventReverseTakedown(ToolsOzoneLexicon.Moderation.EventReverseTakedownDefinition) - /// A "Delete" write operation. - case delete(RepoApplyWritesDelete) + /// A comment event. + case moderationEventComment(ToolsOzoneLexicon.Moderation.EventCommentDefinition) + + /// A report event. + case moderationEventReport(ToolsOzoneLexicon.Moderation.EventReportDefinition) + + /// A label event. + case moderationEventLabel(ToolsOzoneLexicon.Moderation.EventLabelDefinition) + + /// An acknowledgement event. + case moderationEventAcknowledge(ToolsOzoneLexicon.Moderation.EventAcknowledgeDefinition) + + /// An escalation event. + case moderationEventEscalate(ToolsOzoneLexicon.Moderation.EventEscalateDefinition) + + /// A mute event. + case moderationEventMute(ToolsOzoneLexicon.Moderation.EventMuteDefinition) + + /// An unmute event. + case moderationEventUnmute(ToolsOzoneLexicon.Moderation.EventUnmuteDefinition) + + /// A mute reporter event. + case moderationEventMuteReporter(ToolsOzoneLexicon.Moderation.EventMuteReporterDefinition) + + /// An unmute reporter event. + case moderationEventUnmuteReporter(ToolsOzoneLexicon.Moderation.EventUnmuteReporterDefinition) + + /// An email event. + case moderationEventEmail(ToolsOzoneLexicon.Moderation.EventEmailDefinition) + + /// A resolve appeal event. + case moderationEventResolveAppeal(ToolsOzoneLexicon.Moderation.EventResolveAppealDefinition) + + /// A diversion event. + case moderationEventDivert(ToolsOzoneLexicon.Moderation.EventDivertDefinition) public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(RepoApplyWritesCreate.self) { - self = .create(value) - } else if let value = try? container.decode(RepoApplyWritesUpdate.self) { - self = .update(value) - } else if let value = try? container.decode(RepoApplyWritesDelete.self) { - self = .delete(value) + if let value = try? container.decode(ToolsOzoneLexicon.Moderation.EventTakedownDefinition.self) { + self = .moderationEventTakedown(value) + } else if let value = try? container.decode(ToolsOzoneLexicon.Moderation.EventReverseTakedownDefinition.self) { + self = .moderationEventReverseTakedown(value) + } else if let value = try? container.decode(ToolsOzoneLexicon.Moderation.EventCommentDefinition.self) { + self = .moderationEventComment(value) + } else if let value = try? container.decode(ToolsOzoneLexicon.Moderation.EventReportDefinition.self) { + self = .moderationEventReport(value) + } else if let value = try? container.decode(ToolsOzoneLexicon.Moderation.EventLabelDefinition.self) { + self = .moderationEventLabel(value) + } else if let value = try? container.decode(ToolsOzoneLexicon.Moderation.EventAcknowledgeDefinition.self) { + self = .moderationEventAcknowledge(value) + } else if let value = try? container.decode(ToolsOzoneLexicon.Moderation.EventEscalateDefinition.self) { + self = .moderationEventEscalate(value) + } else if let value = try? container.decode(ToolsOzoneLexicon.Moderation.EventMuteDefinition.self) { + self = .moderationEventMute(value) + } else if let value = try? container.decode(ToolsOzoneLexicon.Moderation.EventUnmuteDefinition.self) { + self = .moderationEventUnmute(value) + } else if let value = try? container.decode(ToolsOzoneLexicon.Moderation.EventMuteReporterDefinition.self) { + self = .moderationEventMuteReporter(value) + } else if let value = try? container.decode(ToolsOzoneLexicon.Moderation.EventUnmuteReporterDefinition.self) { + self = .moderationEventUnmuteReporter(value) + } else if let value = try? container.decode(ToolsOzoneLexicon.Moderation.EventEmailDefinition.self) { + self = .moderationEventEmail(value) + } else if let value = try? container.decode(ToolsOzoneLexicon.Moderation.EventResolveAppealDefinition.self) { + self = .moderationEventResolveAppeal(value) + } else if let value = try? container.decode(ToolsOzoneLexicon.Moderation.EventDivertDefinition.self) { + self = .moderationEventDivert(value) } else { throw DecodingError.typeMismatch( - EmbedViewUnion.self, DecodingError.Context( - codingPath: decoder.codingPath, debugDescription: "Unknown ApplyWritesUnion type")) + EmitEventUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown EmitEventUnion type")) } } @@ -1154,15 +1715,70 @@ public struct ATUnion { var container = encoder.singleValueContainer() switch self { - case .create(let embedView): - try container.encode(embedView) - case .update(let embedView): - try container.encode(embedView) - case .delete(let embedView): - try container.encode(embedView) + case .moderationEventTakedown(let moderationEventTakedown): + try container.encode(moderationEventTakedown) + case .moderationEventReverseTakedown(let moderationEventReverseTakedown): + try container.encode(moderationEventReverseTakedown) + case .moderationEventComment(let moderationEventComment): + try container.encode(moderationEventComment) + case .moderationEventReport(let moderationEventReport): + try container.encode(moderationEventReport) + case .moderationEventLabel(let moderationEventLabel): + try container.encode(moderationEventLabel) + case .moderationEventAcknowledge(let moderationEventAcknowledge): + try container.encode(moderationEventAcknowledge) + case .moderationEventEscalate(let moderationEventEscalate): + try container.encode(moderationEventEscalate) + case .moderationEventMute(let moderationEventMute): + try container.encode(moderationEventMute) + case .moderationEventUnmute(let moderationEventUnmute): + try container.encode(moderationEventUnmute) + case .moderationEventMuteReporter(let moderationEventMuteReporter): + try container.encode(moderationEventMuteReporter) + case .moderationEventUnmuteReporter(let moderationEventUnmuteReporter): + try container.encode(moderationEventUnmuteReporter) + case .moderationEventEmail(let moderationEventEmail): + try container.encode(moderationEventEmail) + case .moderationEventResolveAppeal(let moderationEventResolveAppeal): + try container.encode(moderationEventResolveAppeal) + case .moderationEventDivert(let moderationEventDivert): + try container.encode(moderationEventDivert) } } } - + /// A reference containing the list of repository references. + public enum EmitEventSubjectUnion: Codable { + + /// A repository reference. + case repositoryReference(ComAtprotoLexicon.Admin.RepositoryReferenceDefinition) + + /// A strong reference. + case strongReference(ComAtprotoLexicon.Repository.StrongReference) + + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + + if let value = try? container.decode(ComAtprotoLexicon.Admin.RepositoryReferenceDefinition.self) { + self = .repositoryReference(value) + } else if let value = try? container.decode(ComAtprotoLexicon.Repository.StrongReference.self) { + self = .strongReference(value) + } else { + throw DecodingError.typeMismatch( + EmitEventSubjectUnion.self, DecodingError.Context( + codingPath: decoder.codingPath, debugDescription: "Unknown EmitEventSubjectUnion type")) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + + switch self { + case .repositoryReference(let repositoryReference): + try container.encode(repositoryReference) + case .strongReference(let strongReference): + try container.encode(strongReference) + } + } + } } diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedRecordWithMedia.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedRecordWithMedia.swift index 4c7d50d9e6..f2283345f8 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedRecordWithMedia.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedRecordWithMedia.swift @@ -29,7 +29,7 @@ extension AppBskyLexicon.Embed { public let record: RecordDefinition /// The media of a specific type. - public let media: ATUnion.MediaUnion + public let media: ATUnion.RecordWithMediaUnion enum CodingKeys: String, CodingKey { case type = "$type" @@ -43,7 +43,7 @@ extension AppBskyLexicon.Embed { /// - SeeAlso: This is based on the [`app.bsky.embed.recordWithMedia`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/recordWithMedia.json - public struct RecordWithMediaView: Codable { + public struct View: Codable { /// The identifier of the lexicon. /// diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedDefs.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedDefs.swift index 616bea1e1a..acde044801 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedDefs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedDefs.swift @@ -161,7 +161,7 @@ extension AppBskyLexicon.Feed { // TODO: Check to see if this is correct. /// The user who reposted the post. Optional. - public var reason: ReasonRepostDefinition? + public var reason: ATUnion.ReasonRepostUnion? /// The feed generator's context. Optional /// @@ -169,7 +169,7 @@ extension AppBskyLexicon.Feed { /// feed generator that may be passed back alongside interactions." public let feedContext: String? - public init(post: PostViewDefinition, reply: ReplyReferenceDefinition?, reason: ReasonRepostDefinition?, feedContext: String?) { + public init(post: PostViewDefinition, reply: ReplyReferenceDefinition?, reason: ATUnion.ReasonRepostUnion?, feedContext: String?) { self.post = post self.reply = reply self.reason = reason @@ -181,7 +181,7 @@ extension AppBskyLexicon.Feed { self.post = try container.decode(PostViewDefinition.self, forKey: .post) self.reply = try container.decodeIfPresent(ReplyReferenceDefinition.self, forKey: .reply) - self.reason = try container.decodeIfPresent(ReasonRepostDefinition.self, forKey: .reason) + self.reason = try container.decodeIfPresent(ATUnion.ReasonRepostUnion.self, forKey: .reason) self.feedContext = try container.decodeIfPresent(String.self, forKey: .feedContext) } @@ -212,14 +212,14 @@ extension AppBskyLexicon.Feed { public struct ReplyReferenceDefinition: Codable { /// The original post of the thread. - public let root: ATUnion.PostUnion + public let root: ATUnion.ReplyReferenceRootUnion // TODO: Fix up the note's message. /// The direct post that the user's post is replying to. /// /// - Note: If `parent` and `root` are identical, the post is a direct reply to the /// original post of the thread. - public let parent: ATUnion.PostUnion + public let parent: ATUnion.ReplyReferenceParentUnion /// The author of the parent's post. /// @@ -277,10 +277,10 @@ extension AppBskyLexicon.Feed { public let post: PostViewDefinition /// The direct post that the user's post is replying to. Optional. - public var parent: ATUnion.ThreadPostUnion? + public let parent: ATUnion.ThreadViewPostParentUnion? /// An array of posts of various types. Optional. - public var replies: [ATUnion.ThreadPostUnion]? + public var replies: [ATUnion.ThreadViewPostRepliesUnion]? } /// A definition model for a post that may not have been found. @@ -527,7 +527,7 @@ extension AppBskyLexicon.Feed { public let postURI: String /// The indication that the post was a repost. Optional. - public var reason: SkeletonReasonRepostDefinition? + public var reason: ATUnion.SkeletonReasonRepostUnion? enum CodingKeys: String, CodingKey { case postURI = "post" @@ -591,7 +591,7 @@ extension AppBskyLexicon.Feed { public let item: String? /// The interaction event of the feed generator. Optional. - public let event: InteractionEventDefinition? + public let event: Event? /// The feed generator's context. Optional. /// @@ -599,7 +599,7 @@ extension AppBskyLexicon.Feed { /// orginally supplied by the feed generator on getFeedSkeleton." public let feedContext: String? - public init(item: String, event: InteractionEventDefinition, feedContext: String) { + public init(item: String, event: Event, feedContext: String) { self.item = item self.event = event self.feedContext = feedContext @@ -609,7 +609,7 @@ extension AppBskyLexicon.Feed { let container = try decoder.container(keyedBy: CodingKeys.self) self.item = try container.decode(String.self, forKey: .item) - self.event = try container.decode(InteractionEventDefinition.self, forKey: .event) + self.event = try container.decode(Event.self, forKey: .event) self.feedContext = try container.decode(String.self, forKey: .feedContext) } @@ -628,79 +628,80 @@ extension AppBskyLexicon.Feed { case event case feedContext } - } - - /// A definition model for an interaction event. - /// - /// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. - /// - /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/defs.json - public enum InteractionEventDefinition: Codable { - - /// Indicates the feed generator should request less content similar to the feed's item. - /// - /// - Note: According to the AT Protocol specifications: "Request that less content like the - /// given feed item be shown in the feed." - case requestLess - - /// Indicates the feed generator should request more content similar to the feed's item. - /// - /// - Note: According to the AT Protocol specifications: "Request that more content like the - /// given feed item be shown in the feed." - case requestMore - - /// Indicates the feed generator clicked on the feed's item. - /// - /// - Note: According to the AT Protocol specifications: "User clicked through to the - /// feed item." - case clickthroughItem - - /// Indicates the user clicked on the author of the feed's item. - /// - /// - Note: According to the AT Protocol specifications: "User clicked through to the author - /// of the feed item." - case clickthroughAuthor - /// Indicates the user clicked on the reposter of the feed's item. + // Enums + /// A definition model for an interaction event. /// - /// - Note: According to the AT Protocol specifications: "User clicked through to the reposter - /// of the feed item." - case clickthroughReposter - - /// Indicates the user clicked on the embedded content of the feed's item. - /// - /// - Note: According to the AT Protocol specifications: "User clicked through to the embedded - /// content of the feed item." - case clickthroughEmbed - - /// Indicates the user has viewed the item in the feed. - /// - /// - Note: According to the AT Protocol specifications: "Feed item was seen by user." - case interactionSeen - - /// Indicates the user has liked the item of the feed. - /// - /// - Note: According to the AT Protocol specifications: "User liked the feed item." - case interactionLike - - /// Indicates the user has reposted the item of the feed. + /// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. /// - /// - Note: According to the AT Protocol specifications: "User reposted the feed item." - case interactionRepost - - /// Indicates the user has replied to the item of the feed. - /// - /// - Note: According to the AT Protocol specifications: "User replied to the feed item." - case interactionReply - - /// Indicates the user has quote posted the feed's item. - /// - /// - Note: According to the AT Protocol specifications: "User quoted the feed item." - case interactionQuote - - /// Indicates the user has shared the feed's item. - /// - /// - Note: According to the AT Protocol specifications: "User shared the feed item." - case interactionShare + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/defs.json + public enum Event: Codable { + + /// Indicates the feed generator should request less content similar to the feed's item. + /// + /// - Note: According to the AT Protocol specifications: "Request that less content like the + /// given feed item be shown in the feed." + case requestLess + + /// Indicates the feed generator should request more content similar to the feed's item. + /// + /// - Note: According to the AT Protocol specifications: "Request that more content like the + /// given feed item be shown in the feed." + case requestMore + + /// Indicates the feed generator clicked on the feed's item. + /// + /// - Note: According to the AT Protocol specifications: "User clicked through to the + /// feed item." + case clickthroughItem + + /// Indicates the user clicked on the author of the feed's item. + /// + /// - Note: According to the AT Protocol specifications: "User clicked through to the author + /// of the feed item." + case clickthroughAuthor + + /// Indicates the user clicked on the reposter of the feed's item. + /// + /// - Note: According to the AT Protocol specifications: "User clicked through to the reposter + /// of the feed item." + case clickthroughReposter + + /// Indicates the user clicked on the embedded content of the feed's item. + /// + /// - Note: According to the AT Protocol specifications: "User clicked through to the embedded + /// content of the feed item." + case clickthroughEmbed + + /// Indicates the user has viewed the item in the feed. + /// + /// - Note: According to the AT Protocol specifications: "Feed item was seen by user." + case interactionSeen + + /// Indicates the user has liked the item of the feed. + /// + /// - Note: According to the AT Protocol specifications: "User liked the feed item." + case interactionLike + + /// Indicates the user has reposted the item of the feed. + /// + /// - Note: According to the AT Protocol specifications: "User reposted the feed item." + case interactionRepost + + /// Indicates the user has replied to the item of the feed. + /// + /// - Note: According to the AT Protocol specifications: "User replied to the feed item." + case interactionReply + + /// Indicates the user has quote posted the feed's item. + /// + /// - Note: According to the AT Protocol specifications: "User quoted the feed item." + case interactionQuote + + /// Indicates the user has shared the feed's item. + /// + /// - Note: According to the AT Protocol specifications: "User shared the feed item." + case interactionShare + } } } diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGenerator.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGenerator.swift index ac957e50a1..9501143a28 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGenerator.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGenerator.swift @@ -53,13 +53,13 @@ extension AppBskyLexicon.Feed { public let canAcceptInteractions: Bool? /// An array of labels created by the user. Optional. - public let labels: [SelfLabels]? + public let labels: ATUnion.GeneratorLabelsUnion? /// The date and time the feed was created. @DateFormatting public var createdAt: Date public init(feedDID: String, displayName: String, description: String?, descriptionFacets: [Facet]?, avatarImageURL: URL?, - canAcceptInteractions: Bool?, labels: [SelfLabels]?, createdAt: Date) { + canAcceptInteractions: Bool?, labels: ATUnion.GeneratorLabelsUnion?, createdAt: Date) { self.feedDID = feedDID self.displayName = displayName self.description = description @@ -79,7 +79,7 @@ extension AppBskyLexicon.Feed { self.descriptionFacets = try container.decodeIfPresent([Facet].self, forKey: .descriptionFacets) self.avatarImageURL = try container.decodeIfPresent(URL.self, forKey: .avatarImageURL) self.canAcceptInteractions = try container.decodeIfPresent(Bool.self, forKey: .canAcceptInteractions) - self.labels = try container.decodeIfPresent([SelfLabels].self, forKey: .labels) + self.labels = try container.decodeIfPresent(ATUnion.GeneratorLabelsUnion.self, forKey: .labels) self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue } diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetPostThread.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetPostThread.swift index eda5f79aca..ab659aa927 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetPostThread.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetPostThread.swift @@ -20,6 +20,6 @@ extension AppBskyLexicon.Feed { public struct GetPostThreadOutput: Codable { /// The post thread itself. - public let thread: ATUnion.FeedGetPostThreadUnion + public let thread: ATUnion.GetPostThreadOutputThreadUnion } } diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedPost.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedPost.swift index 8c3a9d651a..06d628af65 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedPost.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedPost.swift @@ -42,7 +42,7 @@ extension AppBskyLexicon.Feed { public var reply: ReplyReference? /// The embed of the post. Optional. - public var embed: ATUnion.EmbedUnion? + public var embed: ATUnion.PostEmbedUnion? /// An array of languages the post text contains. Optional. /// @@ -57,7 +57,7 @@ extension AppBskyLexicon.Feed { /// /// - Note: According to the AT Protocol specifications: "Self-label values for this post. /// Effectively content warnings." - public var labels: ATUnion.FeedLabelUnion? + public var labels: ATUnion.PostSelfLabelsUnion? /// An array of user-defined tags. Optional. /// @@ -75,8 +75,8 @@ extension AppBskyLexicon.Feed { /// post was originally created." @DateFormatting public var createdAt: Date - public init(text: String, facets: [AppBskyLexicon.RichText.Facet]?, reply: ReplyReference?, embed: ATUnion.EmbedUnion?, languages: [String]?, - labels: ATUnion.FeedLabelUnion?, tags: [String]?, createdAt: Date) { + public init(text: String, facets: [AppBskyLexicon.RichText.Facet]?, reply: ReplyReference?, embed: ATUnion.PostEmbedUnion?, languages: [String]?, + labels: ATUnion.PostSelfLabelsUnion?, tags: [String]?, createdAt: Date) { self.text = text self.facets = facets self.reply = reply @@ -93,9 +93,9 @@ extension AppBskyLexicon.Feed { self.text = try container.decode(String.self, forKey: .text) self.facets = try container.decodeIfPresent([AppBskyLexicon.RichText.Facet].self, forKey: .facets) self.reply = try container.decodeIfPresent(ReplyReference.self, forKey: .reply) - self.embed = try container.decodeIfPresent(ATUnion.EmbedUnion.self, forKey: .embed) + self.embed = try container.decodeIfPresent(ATUnion.PostEmbedUnion.self, forKey: .embed) self.languages = try container.decodeIfPresent([String].self, forKey: .languages) - self.labels = try container.decodeIfPresent(ATUnion.FeedLabelUnion.self, forKey: .labels) + self.labels = try container.decodeIfPresent(ATUnion.PostSelfLabelsUnion.self, forKey: .labels) self.tags = try container.decodeIfPresent([String].self, forKey: .tags) self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue } diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedThreadgate.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedThreadgate.swift index 8573e592f7..a2042fd95a 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedThreadgate.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedThreadgate.swift @@ -66,7 +66,6 @@ extension AppBskyLexicon.Feed { case createdAt } - // Enums /// A rule that indicates whether users that the post author mentions can reply to the post. /// /// - Note: According to the AT Protocol specifications: "Allow replies from actors mentioned diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetRelationships.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetRelationships.swift index 3a80717187..ce9bac96e0 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetRelationships.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphGetRelationships.swift @@ -23,6 +23,6 @@ extension AppBskyLexicon.Graph { public let actor: String? /// The metadata containing the relationship between mutliple user accounts. - public let relationships: [GraphRelationshipUnion] + public let relationships: [ATUnion.GetRelationshipsOutputRelationshipUnion] } } diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphList.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphList.swift index d80c60d923..1781dcaa26 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphList.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphList.swift @@ -47,13 +47,13 @@ extension AppBskyLexicon.Graph { public let avatarImage: ComAtprotoLexicon.Repository.UploadBlobOutput? /// The user-defined labels for the list. Optional. - public let labels: ComAtprotoLexicon.Label.SelfLabelsDefinition + public let labels: ATUnion.ListLabelsUnion /// The date and time the list was created. @DateFormatting public var createdAt: Date public init(name: String, purpose: ListPurpose, description: String?, descriptionFacets: [Facet]?, - avatarImage: ComAtprotoLexicon.Repository.UploadBlobOutput?, labels: ComAtprotoLexicon.Label.SelfLabelsDefinition, createdAt: Date) { + avatarImage: ComAtprotoLexicon.Repository.UploadBlobOutput?, labels: ATUnion.ListLabelsUnion, createdAt: Date) { self.name = name self.purpose = purpose self.description = description @@ -71,7 +71,7 @@ extension AppBskyLexicon.Graph { self.description = try container.decodeIfPresent(String.self, forKey: .description) self.descriptionFacets = try container.decodeIfPresent([Facet].self, forKey: .descriptionFacets) self.avatarImage = try container.decodeIfPresent(ComAtprotoLexicon.Repository.UploadBlobOutput.self, forKey: .avatarImage) - self.labels = try container.decode(ComAtprotoLexicon.Label.SelfLabelsDefinition.self, forKey: .labels) + self.labels = try container.decode(ATUnion.ListLabelsUnion.self, forKey: .labels) self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue } diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoDefs.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoDefs.swift index 20a9ef40eb..69e7bb7dfe 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoDefs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoDefs.swift @@ -51,7 +51,7 @@ extension ChatBskyLexicon.Conversation { public let facets: [AppBskyLexicon.RichText.Facet]? /// An array of embeds for the message. Optional. - public let embeds: [ATUnion.MessageEmbedUnion]? + public let embeds: [ATUnion.MessageInputEmbedUnion]? public func encode(to encoder: any Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) @@ -95,7 +95,7 @@ extension ChatBskyLexicon.Conversation { public let facets: [AppBskyLexicon.RichText.Facet]? /// An array of embeds for the message. Optional. - public let embeds: [ATUnion.MessageEmbedUnion]? + public let embeds: [ATUnion.MessageViewEmbedUnion]? /// The sender of the message. public let sender: String @@ -104,7 +104,7 @@ extension ChatBskyLexicon.Conversation { @DateFormatting public var seenAt: Date public init(messageID: String?, revision: String, text: String, facets: [AppBskyLexicon.RichText.Facet]?, - embeds: [ATUnion.MessageEmbedUnion]?, sender: String, seenAt: Date) { + embeds: [ATUnion.MessageViewEmbedUnion]?, sender: String, seenAt: Date) { self.messageID = messageID self.revision = revision self.text = text @@ -121,7 +121,7 @@ extension ChatBskyLexicon.Conversation { self.revision = try container.decode(String.self, forKey: .revision) self.text = try container.decode(String.self, forKey: .text) self.facets = try container.decodeIfPresent([AppBskyLexicon.RichText.Facet].self, forKey: .facets) - self.embeds = try container.decodeIfPresent([ATUnion.MessageEmbedUnion].self, forKey: .embeds) + self.embeds = try container.decodeIfPresent([ATUnion.MessageViewEmbedUnion].self, forKey: .embeds) self.sender = try container.decode(String.self, forKey: .sender) self.seenAt = try container.decode(DateFormatting.self, forKey: .seenAt).wrappedValue } @@ -235,7 +235,7 @@ extension ChatBskyLexicon.Conversation { public let members: [ChatBskyLexicon.Actor.ProfileViewBasicDefinition] /// The last message in the conversation. Optional. - public let lastMessage: ATUnion.MessageViewUnion? + public let lastMessage: ATUnion.ConversationViewLastMessageUnion? /// Indicates whether the conversation is muted. public let isMuted: Bool @@ -305,7 +305,7 @@ extension ChatBskyLexicon.Conversation { public let conversationID: String /// The message itself. - public let message: ATUnion.MessageViewUnion + public let message: ATUnion.LogCreateMessageUnion enum CodingKeys: String, CodingKey { case revision = "rev" @@ -328,7 +328,7 @@ extension ChatBskyLexicon.Conversation { public let conversationID: String /// The message itself. - public let message: ATUnion.MessageViewUnion + public let message: ATUnion.LogDeleteMessageUnion enum CodingKeys: String, CodingKey { case revision = "rev" diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetMessages.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetMessages.swift index 43e515d6b6..a10951ac18 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetMessages.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetMessages.swift @@ -20,6 +20,6 @@ extension ChatBskyLexicon.Conversation { public let cursor: String? /// An array of messages. - public let messages: [ATUnion.MessageViewUnion] + public let messages: [ATUnion.GetMessagesOutputMessagesUnion] } } diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Moderation/ChatBskyModerationGetMessageContext.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Moderation/ChatBskyModerationGetMessageContext.swift index 98be79fa73..6f1ddafe7f 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Moderation/ChatBskyModerationGetMessageContext.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Moderation/ChatBskyModerationGetMessageContext.swift @@ -17,6 +17,6 @@ extension ChatBskyLexicon.Moderation { public struct GetMessageContextOutput: Codable { /// An array of messages. - public let messages: [ATUnion.MessageViewUnion] + public let messages: [ATUnion.GetMessageContextOutputMessagesUnion] } } diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminUpdateSubjectStatus.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminUpdateSubjectStatus.swift index 445a041032..fd952cc6c0 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminUpdateSubjectStatus.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminUpdateSubjectStatus.swift @@ -20,7 +20,7 @@ extension ComAtprotoLexicon.Admin { public struct AdminUpdateSubjectStatusRequestBody: Codable { /// The subject associated with the subject status. - public let subject: AdminGetSubjectStatusUnion + public let subject: ATUnion.AdminUpdateSubjectStatusUnion /// The status attributes of the subject. Optional. public let takedown: AdminStatusAttributes? @@ -37,7 +37,7 @@ extension ComAtprotoLexicon.Admin { public struct AdminUpdateSubjectStatusOutput: Codable { /// The subject associated with the subject status. - public let subject: AdminGetSubjectStatusUnion + public let subject: ATUnion.AdminUpdateSubjectStatusUnion /// The status attributes of the subject. Optional. public let takedown: AdminStatusAttributes? diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Moderation/ComAtprotoModerationCreateReport.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Moderation/ComAtprotoModerationCreateReport.swift index 885d5917b9..11f741439c 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Moderation/ComAtprotoModerationCreateReport.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Moderation/ComAtprotoModerationCreateReport.swift @@ -39,7 +39,7 @@ extension ComAtprotoLexicon.Moderation { /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ /// \ /// Clarifications from Bluesky are needed in order to fully understand this item. - public let subject: RepositoryReferencesUnion + public let subject: ATUnion.CreateReportSubjectUnion } /// An output model for creating a report. @@ -65,7 +65,7 @@ extension ComAtprotoLexicon.Moderation { /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ /// \ /// Clarifications from Bluesky are needed in order to fully understand this item. - public let subject: RepositoryReferencesUnion + public let subject: ATUnion.CreateReportSubjectUnion /// The decentralized identifier (DID) of the user who created the report. public let reportedBy: String @@ -73,7 +73,7 @@ extension ComAtprotoLexicon.Moderation { /// The date and time the report was created. @DateFormatting public var createdAt: Date - public init(id: Int, reasonType: ModerationReasonType, reason: String?, subject: RepositoryReferencesUnion, reportedBy: String, createdAt: Date) { + public init(id: Int, reasonType: ModerationReasonType, reason: String?, subject: ATUnion.CreateReportSubjectUnion, reportedBy: String, createdAt: Date) { self.id = id self.reasonType = reasonType self.reason = reason @@ -88,7 +88,7 @@ extension ComAtprotoLexicon.Moderation { self.id = try container.decode(Int.self, forKey: .id) self.reasonType = try container.decode(ModerationReasonType.self, forKey: .reasonType) self.reason = try container.decodeIfPresent(String.self, forKey: .reason) - self.subject = try container.decode(RepositoryReferencesUnion.self, forKey: .subject) + self.subject = try container.decode(ATUnion.CreateReportSubjectUnion.self, forKey: .subject) self.reportedBy = try container.decode(String.self, forKey: .reportedBy) self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue } diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoApplyWrites.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoApplyWrites.swift index 6fc1a4a47b..9cb4a30fc0 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoApplyWrites.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoApplyWrites.swift @@ -32,7 +32,7 @@ extension ComAtprotoLexicon.Repository { public let shouldValidate: Bool? /// The write operation itself. - public let writes: [ApplyWritesUnion]? + public let writes: [ATUnion.ApplyWritesUnion]? /// Swaps out an operation based on the CID. Optional. /// diff --git a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationDefs.swift b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationDefs.swift index 2f1373cc94..153ecf7b98 100644 --- a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationDefs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationDefs.swift @@ -14,16 +14,16 @@ extension ToolsOzoneLexicon.Moderation { /// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/defs.json - public struct EventViewDefinition: Codable { + public struct ModerationEventViewDefinition: Codable { /// The ID of the moderator's event view. public let id: Int /// The type of the moderator's event view. - public let event: AdminEventViewUnion + public let event: ATUnion.ModerationEventViewUnion /// The subject reference of the moderator's event view. - public let subject: RepositoryReferencesUnion + public let subject: ATUnion.ModerationEventViewSubjectUnion /// An array of CID hashes related to blobs for the moderator's event view. public let subjectBlobCIDHashes: [String] @@ -40,7 +40,7 @@ extension ToolsOzoneLexicon.Moderation { /// The subject handle of the event view. Optional. public var subjectHandle: String? - public init(id: Int, event: AdminEventViewUnion, subject: RepositoryReferencesUnion, subjectBlobCIDHashes: [String], createdBy: String, + public init(id: Int, event: ATUnion.ModerationEventViewUnion, subject: ATUnion.ModerationEventViewSubjectUnion, subjectBlobCIDHashes: [String], createdBy: String, createdAt: Date, creatorHandle: String?, subjectHandle: String?) { self.id = id self.event = event @@ -56,8 +56,8 @@ extension ToolsOzoneLexicon.Moderation { let container = try decoder.container(keyedBy: CodingKeys.self) self.id = try container.decode(Int.self, forKey: .id) - self.event = try container.decode(AdminEventViewUnion.self, forKey: .event) - self.subject = try container.decode(RepositoryReferencesUnion.self, forKey: .subject) + self.event = try container.decode(ATUnion.ModerationEventViewUnion.self, forKey: .event) + self.subject = try container.decode(ATUnion.ModerationEventViewSubjectUnion.self, forKey: .subject) self.subjectBlobCIDHashes = try container.decode([String].self, forKey: .subjectBlobCIDHashes) self.createdBy = try container.decode(String.self, forKey: .createdBy) self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue @@ -101,10 +101,10 @@ extension ToolsOzoneLexicon.Moderation { public let id: Int /// The type of the moderator's event view. - public let event: EventViewDetailUnion + public let event: ATUnion.ModerationEventViewDetailUnion /// The subject reference of the moderator's event view. - public let subject: RepositoryViewUnion + public let subject: ATUnion.ModerationEventViewDetailSubjectUnion /// An array of blobs for a moderator to look at. public let subjectBlobs: [ToolsOzoneLexicon.Moderation.BlobViewDefinition] @@ -115,7 +115,7 @@ extension ToolsOzoneLexicon.Moderation { /// The date and time the event view was created. @DateFormatting public var createdAt: Date - public init(id: Int, event: EventViewDetailUnion, subject: RepositoryViewUnion, subjectBlobs: [ToolsOzoneLexicon.Moderation.BlobViewDefinition], + public init(id: Int, event: ATUnion.ModerationEventViewDetailUnion, subject: ATUnion.ModerationEventViewDetailSubjectUnion, subjectBlobs: [ToolsOzoneLexicon.Moderation.BlobViewDefinition], createdBy: String, createdAt: Date) { self.id = id self.event = event @@ -129,8 +129,8 @@ extension ToolsOzoneLexicon.Moderation { let container = try decoder.container(keyedBy: CodingKeys.self) self.id = try container.decode(Int.self, forKey: .id) - self.event = try container.decode(EventViewDetailUnion.self, forKey: .event) - self.subject = try container.decode(RepositoryViewUnion.self, forKey: .subject) + self.event = try container.decode(ATUnion.ModerationEventViewDetailUnion.self, forKey: .event) + self.subject = try container.decode(ATUnion.ModerationEventViewDetailSubjectUnion.self, forKey: .subject) self.subjectBlobs = try container.decode([ToolsOzoneLexicon.Moderation.BlobViewDefinition].self, forKey: .subjectBlobs) self.createdBy = try container.decode(String.self, forKey: .createdBy) self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue @@ -168,7 +168,7 @@ extension ToolsOzoneLexicon.Moderation { public let id: Int /// The subject reference of the status view. - public let subject: RepositoryReferencesUnion + public let subject: ATUnion.SubjectStatusViewSubjectUnion /// An array of CID hashes related to blobs. Optional. public var subjectBlobCIDHashes: [String]? @@ -232,7 +232,7 @@ extension ToolsOzoneLexicon.Moderation { /// An array of tags. Optional. public var tags: [String]? - public init(id: Int, subject: RepositoryReferencesUnion, subjectBlobCIDHashes: [String]?, subjectRepoHandle: String?, updatedAt: Date, createdAt: Date, + public init(id: Int, subject: ATUnion.SubjectStatusViewSubjectUnion, subjectBlobCIDHashes: [String]?, subjectRepoHandle: String?, updatedAt: Date, createdAt: Date, reviewState: ToolsOzoneLexicon.Moderation.SubjectReviewStateDefinition, comment: String?, muteUntil: Date?, muteReportingUntil: Date?, lastReviewedBy: String?, lastReviewedAt: Date?, lastReportedAt: Date?, lastAppealedAt: Date?, isTakenDown: Bool?, wasAppealed: Bool?, suspendUntil: Date?, tags: [String]?) { @@ -260,7 +260,7 @@ extension ToolsOzoneLexicon.Moderation { let container = try decoder.container(keyedBy: CodingKeys.self) self.id = try container.decode(Int.self, forKey: .id) - self.subject = try container.decode(RepositoryReferencesUnion.self, forKey: .subject) + self.subject = try container.decode(ATUnion.SubjectStatusViewSubjectUnion.self, forKey: .subject) self.subjectBlobCIDHashes = try container.decodeIfPresent([String].self, forKey: .subjectBlobCIDHashes) self.subjectRepoHandle = try container.decodeIfPresent(String.self, forKey: .subjectRepoHandle) self.updatedAt = try container.decode(DateFormatting.self, forKey: .updatedAt).wrappedValue @@ -1149,12 +1149,12 @@ extension ToolsOzoneLexicon.Moderation { @DateFormatting public var createdAt: Date /// The type of media in the blob. - public let details: MediaDetailUnion + public let details: ATUnion.BlobViewDetailUnion /// The status of the subject. public let moderation: ToolsOzoneLexicon.Moderation.ModerationDefinition - public init(cidHash: String, mimeType: String, size: Int, createdAt: Date, details: MediaDetailUnion, + public init(cidHash: String, mimeType: String, size: Int, createdAt: Date, details: ATUnion.BlobViewDetailUnion, moderation: ToolsOzoneLexicon.Moderation.ModerationDefinition) { self.cidHash = cidHash self.mimeType = mimeType @@ -1171,7 +1171,7 @@ extension ToolsOzoneLexicon.Moderation { self.mimeType = try container.decode(String.self, forKey: .mimeType) self.size = try container.decode(Int.self, forKey: .size) self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue - self.details = try container.decode(MediaDetailUnion.self, forKey: .details) + self.details = try container.decode(ATUnion.BlobViewDetailUnion.self, forKey: .details) self.moderation = try container.decode(ToolsOzoneLexicon.Moderation.ModerationDefinition.self, forKey: .moderation) } diff --git a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationEmitEvent.swift b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationEmitEvent.swift index 8d0e9402fd..34b1d844e6 100644 --- a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationEmitEvent.swift +++ b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationEmitEvent.swift @@ -19,10 +19,10 @@ extension ToolsOzoneLexicon.Moderation { public struct EmitEventRequestBody: Codable { /// The type of event the moderator is taking, - public let event: ATUnion.AdminEventViewUnion + public let event: ATUnion.EmitEventUnion /// The type of repository reference. - public let subject: RepositoryReferencesUnion + public let subject: ATUnion.EmitEventSubjectUnion /// An array of CID hashes related to blobs for the moderator's event view. Optional. public let subjectBlobCIDHashes: [String]? diff --git a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationQueryEvents.swift b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationQueryEvents.swift index bdc28c0137..5577f25f30 100644 --- a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationQueryEvents.swift +++ b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationQueryEvents.swift @@ -36,6 +36,6 @@ extension ToolsOzoneLexicon.Moderation { public let cursor: String? /// An array of moderator events. - public let events: [ToolsOzoneLexicon.Moderation.EventViewDefinition] + public let events: [ToolsOzoneLexicon.Moderation.ModerationEventViewDefinition] } } From eecde79fc8b88c7028b2bd3c0114ad3467bc5994 Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Wed, 29 May 2024 02:19:32 -0400 Subject: [PATCH 24/51] Format method signatures If the signature more than one parameter, then each parameter will have a separate line, and the beginning and ending portions of the signature will have their own lines. Otherwise, teh entire signature will be in one line. --- .../CreateCommunicationTemplateAsAdmin.swift | 12 ++++-- .../DisableAccountInvitesAsAdmin.swift | 5 ++- .../DisableInviteCodesAsAdmin.swift | 5 ++- .../ATProtoAdmin/EmitEventAsAdmin.swift | 8 +++- .../EnableAccountInvitesAsAdmin.swift | 5 ++- .../ATProtoAdmin/GetInviteCodesAsAdmin.swift | 6 ++- .../ATProtoAdmin/GetRecordAsAdmin.swift | 5 ++- .../GetSubjectStatusAsAdmin.swift | 7 +++- .../QueryModerationEventsAsAdmin.swift | 24 ++++++++--- .../QueryModerationStatusesAsAdmin.swift | 27 +++++++++--- .../SearchRepositoriesAsAdmin.swift | 7 +++- .../ATProtoAdmin/SendEmailAsAdmin.swift | 9 +++- .../UpdateAccountEmailAsAdmin.swift | 5 ++- .../UpdateAccountHandleAsAdmin.swift | 5 ++- .../UpdateAccountPasswordAsAdmin.swift | 5 ++- .../UpdateCommunicationTemplateAsAdmin.swift | 10 ++++- .../UpdateSubjectStatusAsAdmin.swift | 6 ++- .../Networking/CoreAPI/ApplyWrites.swift | 7 +++- .../Networking/CoreAPI/ConfirmEmail.swift | 5 ++- .../Networking/CoreAPI/CreateInviteCode.swift | 5 ++- .../CoreAPI/CreateInviteCodes.swift | 5 ++- .../Networking/CoreAPI/CreateRecord.swift | 10 ++++- .../Networking/CoreAPI/CreateReport.swift | 7 +++- .../Networking/CoreAPI/DeleteAccount.swift | 6 ++- .../Networking/CoreAPI/DeleteRecord.swift | 8 +++- .../CoreAPI/DescribeRepository.swift | 6 ++- .../CoreAPI/GetAccountInviteCodes.swift | 6 ++- .../Networking/CoreAPI/GetBlob.swift | 5 ++- .../Networking/CoreAPI/GetLatestCommit.swift | 5 ++- .../Networking/CoreAPI/GetRepoRecord.swift | 5 ++- .../Networking/CoreAPI/GetRepository.swift | 7 +++- .../Networking/CoreAPI/GetSyncBlocks.swift | 7 +++- .../Networking/CoreAPI/GetSyncRecord.swift | 6 ++- .../Networking/CoreAPI/ImportRepository.swift | 5 ++- .../Networking/CoreAPI/ListBlobs.swift | 9 +++- .../Networking/CoreAPI/ListMissingBlobs.swift | 5 ++- .../Networking/CoreAPI/ListRecords.swift | 10 ++++- .../Networking/CoreAPI/ListRepositories.swift | 7 +++- .../Networking/CoreAPI/NotifyOfUpdate.swift | 6 ++- .../Networking/CoreAPI/PutRecord.swift | 11 ++++- .../Networking/CoreAPI/QueryLabels.swift | 11 +++-- .../Networking/CoreAPI/RequestCrawl.swift | 6 ++- .../CoreAPI/RequestPasswordReset.swift | 6 ++- .../CoreAPI/ReserveSigningKey.swift | 5 ++- .../Networking/CoreAPI/ResetPassword.swift | 7 +++- .../Networking/CoreAPI/ResolveHandle.swift | 5 ++- .../Networking/CoreAPI/SignPLCOperation.swift | 9 +++- .../Networking/CoreAPI/UpdateEmail.swift | 6 ++- .../Networking/PlatformAPI/CreateLike.swift | 7 +++- .../Networking/PlatformAPI/CreatePost.swift | 15 +++++-- .../PlatformAPI/GetActorFeeds.swift | 6 ++- .../PlatformAPI/GetActorLikes.swift | 6 ++- .../PlatformAPI/GetAuthorFeed.swift | 8 +++- .../Networking/PlatformAPI/GetFeed.swift | 6 ++- .../PlatformAPI/GetFeedSkeleton.swift | 8 +++- .../Networking/PlatformAPI/GetFollowers.swift | 6 ++- .../Networking/PlatformAPI/GetFollows.swift | 6 ++- .../PlatformAPI/GetGraphBlocks.swift | 5 ++- .../PlatformAPI/GetLabelerServices.swift | 7 +++- .../Networking/PlatformAPI/GetLikes.swift | 8 +++- .../Networking/PlatformAPI/GetList.swift | 6 ++- .../PlatformAPI/GetListBlocks.swift | 5 ++- .../Networking/PlatformAPI/GetListFeed.swift | 10 +++-- .../Networking/PlatformAPI/GetListMutes.swift | 5 ++- .../Networking/PlatformAPI/GetLists.swift | 6 ++- .../Networking/PlatformAPI/GetMutes.swift | 5 ++- .../GetPopularFeedGenerators.swift | 7 +++- .../PlatformAPI/GetPostThread.swift | 10 +++-- .../Networking/PlatformAPI/GetProfile.swift | 8 ++-- .../Networking/PlatformAPI/GetProfiles.swift | 8 ++-- .../PlatformAPI/GetRelationships.swift | 8 +++- .../PlatformAPI/GetRepostedBy.swift | 8 +++- .../PlatformAPI/GetSuggestedFeeds.swift | 5 ++- .../PlatformAPI/GetSuggestions.swift | 5 ++- .../PlatformAPI/GetSuggestionsSkeleton.swift | 5 ++- .../Networking/PlatformAPI/GetTimeline.swift | 6 ++- .../PlatformAPI/GetUnreadCount.swift | 4 +- .../PlatformAPI/ListNotifications.swift | 7 +++- .../Networking/PlatformAPI/RegisterPush.swift | 7 +++- .../PlatformAPI/SearchActorsSkeleton.swift | 10 ++++- .../Networking/PlatformAPI/SearchPosts.swift | 17 ++++++-- .../PlatformAPI/SearchPostsSkeleton.swift | 19 +++++++-- .../Networking/PlatformAPI/SearchUsers.swift | 10 +++-- .../PlatformAPI/SearchUsersTypeahead.swift | 9 ++-- .../ATProtocolConfiguration.swift | 41 ++++++++++++++----- 85 files changed, 516 insertions(+), 162 deletions(-) diff --git a/Sources/ATProtoKit/Networking/ATProtoAdmin/CreateCommunicationTemplateAsAdmin.swift b/Sources/ATProtoKit/Networking/ATProtoAdmin/CreateCommunicationTemplateAsAdmin.swift index 085deafedf..bd131b7df0 100644 --- a/Sources/ATProtoKit/Networking/ATProtoAdmin/CreateCommunicationTemplateAsAdmin.swift +++ b/Sources/ATProtoKit/Networking/ATProtoAdmin/CreateCommunicationTemplateAsAdmin.swift @@ -27,10 +27,14 @@ extension ATProtoAdmin { /// - subject: The subject line of the communication template. /// - createdBy: The decentralized identifier (DID) of the creator of the /// communication template. Optional. - /// - Returns: A `Result`, containing either ``OzoneCommunicationTemplateView`` + /// - Returns: A `Result`, containing either ``ToolsOzoneLexicon/Communication/TemplateViewDefinition`` /// if successful, or an `Error` if not. - public func createCommunicationTemplate(named name: String, contentMarkdown: String, subject: String, - createdBy: String?) async throws -> Result { + public func createCommunicationTemplate( + named name: String, + contentMarkdown: String, + subject: String, + createdBy: String? + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -56,7 +60,7 @@ extension ATProtoAdmin { authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, withEncodingBody: requestBody, - decodeTo: OzoneCommunicationTemplateView.self) + decodeTo: ToolsOzoneLexicon.Communication.TemplateViewDefinition.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/ATProtoAdmin/DisableAccountInvitesAsAdmin.swift b/Sources/ATProtoKit/Networking/ATProtoAdmin/DisableAccountInvitesAsAdmin.swift index bab3fffa59..c8589f424b 100644 --- a/Sources/ATProtoKit/Networking/ATProtoAdmin/DisableAccountInvitesAsAdmin.swift +++ b/Sources/ATProtoKit/Networking/ATProtoAdmin/DisableAccountInvitesAsAdmin.swift @@ -24,7 +24,10 @@ extension ATProtoAdmin { /// - Parameters: /// - accountDID: The decentralized identifier (DID) of the user account. /// - note: A note on why the account will lose the ability to get new invite codes. - public func disableAccountInvites(for accountDID: String, note: String?) async throws { + public func disableAccountInvites( + for accountDID: String, + note: String? + ) async throws { guard session != nil, let accessToken = session?.accessToken else { throw ATRequestPrepareError.missingActiveSession diff --git a/Sources/ATProtoKit/Networking/ATProtoAdmin/DisableInviteCodesAsAdmin.swift b/Sources/ATProtoKit/Networking/ATProtoAdmin/DisableInviteCodesAsAdmin.swift index c7152142ca..56d2c3448e 100644 --- a/Sources/ATProtoKit/Networking/ATProtoAdmin/DisableInviteCodesAsAdmin.swift +++ b/Sources/ATProtoKit/Networking/ATProtoAdmin/DisableInviteCodesAsAdmin.swift @@ -24,7 +24,10 @@ extension ATProtoAdmin { /// - Parameters: /// - codes: The invite codes to disable. /// - accountDIDs: The decentralized identifiers (DIDs) of the user accounts. - public func disableInviteCodes(codes: [String], accountDIDs: [String]) async throws { + public func disableInviteCodes( + codes: [String], + accountDIDs: [String] + ) async throws { guard session != nil, let accessToken = session?.accessToken else { throw ATRequestPrepareError.missingActiveSession diff --git a/Sources/ATProtoKit/Networking/ATProtoAdmin/EmitEventAsAdmin.swift b/Sources/ATProtoKit/Networking/ATProtoAdmin/EmitEventAsAdmin.swift index ee0b9207c4..6a6589d8d2 100644 --- a/Sources/ATProtoKit/Networking/ATProtoAdmin/EmitEventAsAdmin.swift +++ b/Sources/ATProtoKit/Networking/ATProtoAdmin/EmitEventAsAdmin.swift @@ -29,8 +29,12 @@ extension ATProtoAdmin { /// - createdBy: The decentralized identifier (DID) of the moderator taking this action. /// - Returns: A `Result`, containing either an ``OzoneModerationEventView`` if successful, /// or an `Error` if not. - public func emitEvent(_ event: AdminEventViewUnion, subject: RepositoryReferencesUnion, subjectBlobCIDHashes: [String]?, - createdBy: String) async throws -> Result { + public func emitEvent( + _ event: AdminEventViewUnion, + subject: RepositoryReferencesUnion, + subjectBlobCIDHashes: [String]?, + createdBy: String + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) diff --git a/Sources/ATProtoKit/Networking/ATProtoAdmin/EnableAccountInvitesAsAdmin.swift b/Sources/ATProtoKit/Networking/ATProtoAdmin/EnableAccountInvitesAsAdmin.swift index e97755e806..157e9246ac 100644 --- a/Sources/ATProtoKit/Networking/ATProtoAdmin/EnableAccountInvitesAsAdmin.swift +++ b/Sources/ATProtoKit/Networking/ATProtoAdmin/EnableAccountInvitesAsAdmin.swift @@ -27,7 +27,10 @@ extension ATProtoAdmin { /// - accountDID: The decentralized identifier (DID) of the user's account. /// - note: A note as to why the user account is getting the ability to receive invite /// codes reinstated. Optional. - public func enableAccountInvites(for accountDID: String, note: String?) async throws { + public func enableAccountInvites( + for accountDID: String, + note: String? + ) async throws { guard session != nil, let accessToken = session?.accessToken else { throw ATRequestPrepareError.missingActiveSession diff --git a/Sources/ATProtoKit/Networking/ATProtoAdmin/GetInviteCodesAsAdmin.swift b/Sources/ATProtoKit/Networking/ATProtoAdmin/GetInviteCodesAsAdmin.swift index 13140df6f4..6bff7c8de5 100644 --- a/Sources/ATProtoKit/Networking/ATProtoAdmin/GetInviteCodesAsAdmin.swift +++ b/Sources/ATProtoKit/Networking/ATProtoAdmin/GetInviteCodesAsAdmin.swift @@ -26,8 +26,10 @@ extension ATProtoAdmin { /// - cursor: The mark used to indicate the starting point for the next set of results. Optional. /// - Returns: A `Result`, containing either an ``AdminGetInviteCodesOutput`` /// if successful, or an `Error` if not. - public func getInviteCodes(sortedBy sort: AdminGetInviteCodesSort = .recent, withLimitOf limit: Int = 100, - cursor: String?) async throws -> Result { + public func getInviteCodes( + sortedBy sort: AdminGetInviteCodesSort = .recent, + withLimitOf limit: Int = 100, + cursor: String?) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) diff --git a/Sources/ATProtoKit/Networking/ATProtoAdmin/GetRecordAsAdmin.swift b/Sources/ATProtoKit/Networking/ATProtoAdmin/GetRecordAsAdmin.swift index 5e0639cdfd..3115ee1bb3 100644 --- a/Sources/ATProtoKit/Networking/ATProtoAdmin/GetRecordAsAdmin.swift +++ b/Sources/ATProtoKit/Networking/ATProtoAdmin/GetRecordAsAdmin.swift @@ -25,7 +25,10 @@ extension ATProtoAdmin { /// - recordCID: The CID hash of the record. Optional. /// - Returns: A `Result`, containing either an ``OzoneModerationRecordViewDetail`` /// if successful, or an `Error` if not. - public func getRecord(_ recordURI: String, recordCID: String?) async throws -> Result { + public func getRecord( + _ recordURI: String, + recordCID: String? + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) diff --git a/Sources/ATProtoKit/Networking/ATProtoAdmin/GetSubjectStatusAsAdmin.swift b/Sources/ATProtoKit/Networking/ATProtoAdmin/GetSubjectStatusAsAdmin.swift index e9f98f5a93..8bfd543ee3 100644 --- a/Sources/ATProtoKit/Networking/ATProtoAdmin/GetSubjectStatusAsAdmin.swift +++ b/Sources/ATProtoKit/Networking/ATProtoAdmin/GetSubjectStatusAsAdmin.swift @@ -27,8 +27,11 @@ extension ATProtoAdmin { /// - subjectBlobCIDHash: The CID hash of the blob for the subject. /// - Returns: A `Result`, containing either an ``AdminGetSubjectStatusOutput`` /// if successful, or an `Error` if not. - public func getSubjectStatus(_ subjectDID: String, subjectURI: String, - subjectBlobCIDHash: String) async throws -> Result { + public func getSubjectStatus( + _ subjectDID: String, + subjectURI: String, + subjectBlobCIDHash: String + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) diff --git a/Sources/ATProtoKit/Networking/ATProtoAdmin/QueryModerationEventsAsAdmin.swift b/Sources/ATProtoKit/Networking/ATProtoAdmin/QueryModerationEventsAsAdmin.swift index 1df0393c43..a0a1afb229 100644 --- a/Sources/ATProtoKit/Networking/ATProtoAdmin/QueryModerationEventsAsAdmin.swift +++ b/Sources/ATProtoKit/Networking/ATProtoAdmin/QueryModerationEventsAsAdmin.swift @@ -54,12 +54,24 @@ extension ATProtoAdmin { /// of results. Optional. /// - Returns: A `Result`, containing either an ``ModerationQueryEventsOutput`` /// if successful, or an `Error` if not. - public func queryEvents(_ eventTypes: [String]? = nil, createdBy: String? = nil, - sortDirection: AdminQueryModerationEventSortDirection? = .descending, createdAfter: Date? = nil, createdBefore: Date? = nil, - subject: String? = nil, canIncludeAllUserRecords: Bool? = false, limit: Int? = 50, doesHaveComment: Bool? = nil, - comment: String? = nil, addedLabels: [String]? = nil, - removedLabels: [String]? = nil, addedTags: [String]? = nil, removedTags: [String]? = nil, reportTypes: [String]? = nil, - cursor: String? = nil) async throws -> Result { + public func queryEvents( + _ eventTypes: [String]? = nil, + createdBy: String? = nil, + sortDirection: AdminQueryModerationEventSortDirection? = .descending, + createdAfter: Date? = nil, + createdBefore: Date? = nil, + subject: String? = nil, + canIncludeAllUserRecords: Bool? = false, + limit: Int? = 50, + doesHaveComment: Bool? = nil, + comment: String? = nil, + addedLabels: [String]? = nil, + removedLabels: [String]? = nil, + addedTags: [String]? = nil, + removedTags: [String]? = nil, + reportTypes: [String]? = nil, + cursor: String? = nil + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) diff --git a/Sources/ATProtoKit/Networking/ATProtoAdmin/QueryModerationStatusesAsAdmin.swift b/Sources/ATProtoKit/Networking/ATProtoAdmin/QueryModerationStatusesAsAdmin.swift index a296b46255..428c55025a 100644 --- a/Sources/ATProtoKit/Networking/ATProtoAdmin/QueryModerationStatusesAsAdmin.swift +++ b/Sources/ATProtoKit/Networking/ATProtoAdmin/QueryModerationStatusesAsAdmin.swift @@ -58,12 +58,27 @@ extension ATProtoAdmin { /// results. Optional. /// - Returns: A `Result`, containing either an ``AdminQueryModerationStatusesOutput`` /// if successful, or an `Error` if not. - public func queryStatuses(_ subject: String?, comment: String?, reportedAfter: Date?, reportedBefore: Date?, reviewedAfter: Date?, - reviewedBefore: Date?, shouldIncludeMuted: Bool? = false, isOnlyMuted: Bool?, reviewState: String?, - ignoreSubjects: [String]?, lastReviewedBy: String?, sortField: AdminQueryModerationStatusesSortField? = .lastReportedAt, - sortDirection: AdminQueryModerationStatusesSortDirection? = .descending, isTakenDown: Bool?, - isAppealed: Bool?, limit: Int? = 50, tags: [String]?, excludeTags: [String]?, - cursor: String?) async throws -> Result { + public func queryStatuses( + _ subject: String?, + comment: String?, + reportedAfter: Date?, + reportedBefore: Date?, + reviewedAfter: Date?, + reviewedBefore: Date?, + shouldIncludeMuted: Bool? = false, + isOnlyMuted: Bool?, + reviewState: String?, + ignoreSubjects: [String]?, + lastReviewedBy: String?, + sortField: AdminQueryModerationStatusesSortField? = .lastReportedAt, + sortDirection: AdminQueryModerationStatusesSortDirection? = .descending, + isTakenDown: Bool?, + isAppealed: Bool?, + limit: Int? = 50, + tags: [String]?, + excludeTags: [String]?, + cursor: String? + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) diff --git a/Sources/ATProtoKit/Networking/ATProtoAdmin/SearchRepositoriesAsAdmin.swift b/Sources/ATProtoKit/Networking/ATProtoAdmin/SearchRepositoriesAsAdmin.swift index 15d4f44578..3bbc4524a3 100644 --- a/Sources/ATProtoKit/Networking/ATProtoAdmin/SearchRepositoriesAsAdmin.swift +++ b/Sources/ATProtoKit/Networking/ATProtoAdmin/SearchRepositoriesAsAdmin.swift @@ -28,8 +28,11 @@ extension ATProtoAdmin { /// results. Optional. /// - Returns: A `Result`, containing either an ``AdminSearchReposOutput`` /// if successful, or an `Error` if not. - public func searchRepositories(_ query: String?, withLimitOf limit: Int? = 50, - cursor: String?) async throws -> Result { + public func searchRepositories( + _ query: String?, + withLimitOf limit: Int? = 50, + cursor: String? + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) diff --git a/Sources/ATProtoKit/Networking/ATProtoAdmin/SendEmailAsAdmin.swift b/Sources/ATProtoKit/Networking/ATProtoAdmin/SendEmailAsAdmin.swift index 9721b02f8d..6625bce11d 100644 --- a/Sources/ATProtoKit/Networking/ATProtoAdmin/SendEmailAsAdmin.swift +++ b/Sources/ATProtoKit/Networking/ATProtoAdmin/SendEmailAsAdmin.swift @@ -29,8 +29,13 @@ extension ATProtoAdmin { /// - comment: Any additional comments viewable to other moderators and administrators. /// - Returns: A `Result`, containing either an ``AdminSendEmailOutput`` /// if successful, or an `Error` if not. - public func sendEmail(to recipientDID: String, withSubjectLine subjectLine: String?, content: String, - senderDID: String, comment: String?) async throws -> Result { + public func sendEmail( + to recipientDID: String, + withSubjectLine subjectLine: String?, + content: String, + senderDID: String, + comment: String? + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) diff --git a/Sources/ATProtoKit/Networking/ATProtoAdmin/UpdateAccountEmailAsAdmin.swift b/Sources/ATProtoKit/Networking/ATProtoAdmin/UpdateAccountEmailAsAdmin.swift index 8f66ef29cd..6ed83b3a34 100644 --- a/Sources/ATProtoKit/Networking/ATProtoAdmin/UpdateAccountEmailAsAdmin.swift +++ b/Sources/ATProtoKit/Networking/ATProtoAdmin/UpdateAccountEmailAsAdmin.swift @@ -24,7 +24,10 @@ extension ATProtoAdmin { /// - Parameters: /// - accountDID: The decentralized identifier (DID) of the user account. /// - newEmail: The new email address the user wants to change to. - public func updateAccountEmail(for accountDID: String, newEmail: String) async throws { + public func updateAccountEmail( + for accountDID: String, + newEmail: String + ) async throws { guard session != nil, let accessToken = session?.accessToken else { throw ATRequestPrepareError.missingActiveSession diff --git a/Sources/ATProtoKit/Networking/ATProtoAdmin/UpdateAccountHandleAsAdmin.swift b/Sources/ATProtoKit/Networking/ATProtoAdmin/UpdateAccountHandleAsAdmin.swift index dec8f356e0..a411c832ca 100644 --- a/Sources/ATProtoKit/Networking/ATProtoAdmin/UpdateAccountHandleAsAdmin.swift +++ b/Sources/ATProtoKit/Networking/ATProtoAdmin/UpdateAccountHandleAsAdmin.swift @@ -24,7 +24,10 @@ extension ATProtoAdmin { /// - Parameters: /// - accountDID: The decentralized identifier (DID) of the user account. /// - newAccountHandle: The new handle for the user account. - public func updateAccountHandle(for accountDID: String, newAccountHandle: String) async throws { + public func updateAccountHandle( + for accountDID: String, + newAccountHandle: String + ) async throws { guard session != nil, let accessToken = session?.accessToken else { throw ATRequestPrepareError.missingActiveSession diff --git a/Sources/ATProtoKit/Networking/ATProtoAdmin/UpdateAccountPasswordAsAdmin.swift b/Sources/ATProtoKit/Networking/ATProtoAdmin/UpdateAccountPasswordAsAdmin.swift index 4126eacb2e..f3df429244 100644 --- a/Sources/ATProtoKit/Networking/ATProtoAdmin/UpdateAccountPasswordAsAdmin.swift +++ b/Sources/ATProtoKit/Networking/ATProtoAdmin/UpdateAccountPasswordAsAdmin.swift @@ -21,7 +21,10 @@ extension ATProtoAdmin { /// - Parameters: /// - accountDID: The decentralized identifier (DID) of the user account. /// - newPassword: The new password for the user account. - public func updateAccountPassword(for accountDID: String, newPassword: String) async throws { + public func updateAccountPassword( + for accountDID: String, + newPassword: String + ) async throws { guard session != nil, let accessToken = session?.accessToken else { throw ATRequestPrepareError.missingActiveSession diff --git a/Sources/ATProtoKit/Networking/ATProtoAdmin/UpdateCommunicationTemplateAsAdmin.swift b/Sources/ATProtoKit/Networking/ATProtoAdmin/UpdateCommunicationTemplateAsAdmin.swift index 8d4df8bef1..c493a32cff 100644 --- a/Sources/ATProtoKit/Networking/ATProtoAdmin/UpdateCommunicationTemplateAsAdmin.swift +++ b/Sources/ATProtoKit/Networking/ATProtoAdmin/UpdateCommunicationTemplateAsAdmin.swift @@ -31,8 +31,14 @@ extension ATProtoKit { /// - isDisabled: Indicates whether the communication template is disabled. Optional. /// - Returns: A `Result`, containing either an ``OzoneCommunicationTemplateView`` /// if successful, or an `Error` if not. - public func updateCommunicationTemplate(_ id: String, name: String?, contentMarkdown: String?, subject: String?, updatedBy: String?, - isDisabled: Bool?) async throws -> Result { + public func updateCommunicationTemplate( + _ id: String, + name: String?, + contentMarkdown: String?, + subject: String?, + updatedBy: String?, + isDisabled: Bool? + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) diff --git a/Sources/ATProtoKit/Networking/ATProtoAdmin/UpdateSubjectStatusAsAdmin.swift b/Sources/ATProtoKit/Networking/ATProtoAdmin/UpdateSubjectStatusAsAdmin.swift index 0c8a66da4a..681c610f68 100644 --- a/Sources/ATProtoKit/Networking/ATProtoAdmin/UpdateSubjectStatusAsAdmin.swift +++ b/Sources/ATProtoKit/Networking/ATProtoAdmin/UpdateSubjectStatusAsAdmin.swift @@ -24,8 +24,10 @@ extension ATProtoAdmin { /// - Parameters: /// - subject: The subject associated with the subject status. /// - takedown: The status attributes of the subject. Optional. - public func updateSubjectStatusAsAdmin(_ subject: AdminGetSubjectStatusUnion, - takedown: AdminStatusAttributes?) async throws -> Result { + public func updateSubjectStatusAsAdmin( + _ subject: AdminGetSubjectStatusUnion, + takedown: AdminStatusAttributes? + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) diff --git a/Sources/ATProtoKit/Networking/CoreAPI/ApplyWrites.swift b/Sources/ATProtoKit/Networking/CoreAPI/ApplyWrites.swift index 4cac9b7c92..a2af66c8b7 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/ApplyWrites.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/ApplyWrites.swift @@ -23,7 +23,12 @@ extension ATProtoKit { /// - shouldValidate: Indicates whether the operation should be validated. Optional. Defaults to `true`. /// - writes: The write operation itself. /// - swapCommit: Swaps out an operation based on the CID. Optional. - public func applyWrites(_ repositoryDID: String, shouldValidate: Bool? = true, writes: [ApplyWritesUnion], swapCommit: String?) async throws { + public func applyWrites( + _ repositoryDID: String, + shouldValidate: Bool? = true, + writes: [ApplyWritesUnion], + swapCommit: String? + ) async throws { guard session != nil, let accessToken = session?.accessToken else { throw ATRequestPrepareError.missingActiveSession diff --git a/Sources/ATProtoKit/Networking/CoreAPI/ConfirmEmail.swift b/Sources/ATProtoKit/Networking/CoreAPI/ConfirmEmail.swift index b6d6d5f423..d714df56e1 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/ConfirmEmail.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/ConfirmEmail.swift @@ -28,7 +28,10 @@ extension ATProtoKit { /// - Parameters: /// - email: The email address to confirm. /// - token: The token used to confirm the email address. - public func confirmEmail(_ email: String, token: String) async throws { + public func confirmEmail( + _ email: String, + token: String + ) async throws { guard session != nil, let accessToken = session?.accessToken else { throw ATRequestPrepareError.missingActiveSession diff --git a/Sources/ATProtoKit/Networking/CoreAPI/CreateInviteCode.swift b/Sources/ATProtoKit/Networking/CoreAPI/CreateInviteCode.swift index d86fa1de05..fd2f7e3249 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/CreateInviteCode.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/CreateInviteCode.swift @@ -26,7 +26,10 @@ extension ATProtoKit { /// invite code. Optional. /// - Returns: A `Result`, containing either a ``ServerCreateInviteCodeOutput`` /// if successful, or an `Error` if not. - public func createInviteCode(_ codeCount: Int = 1, for account: [String]) async throws -> Result { + public func createInviteCode( + _ codeCount: Int = 1, + for account: [String] + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) diff --git a/Sources/ATProtoKit/Networking/CoreAPI/CreateInviteCodes.swift b/Sources/ATProtoKit/Networking/CoreAPI/CreateInviteCodes.swift index 95610c7785..6efedb38d4 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/CreateInviteCodes.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/CreateInviteCodes.swift @@ -23,7 +23,10 @@ extension ATProtoKit { /// invite codes. /// - Returns: A `Result`, containing either a ``ServerCreateInviteCodesOutput`` /// if successful, or an `Error` if not. - public func createInviteCodes(_ codeCount: Int = 1, for accounts: [String]) async throws -> Result { + public func createInviteCodes( + _ codeCount: Int = 1, + for accounts: [String] + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) diff --git a/Sources/ATProtoKit/Networking/CoreAPI/CreateRecord.swift b/Sources/ATProtoKit/Networking/CoreAPI/CreateRecord.swift index 2dbd291788..e42d4f7243 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/CreateRecord.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/CreateRecord.swift @@ -31,8 +31,14 @@ extension ATProtoKit { /// - swapCommit: Swaps out an operation based on the CID. Optional. /// - Returns: A `Result`, containing either a ``StrongReference`` /// if successful, and an `Error` if not. - public func createRecord(repositoryDID: String, collection: String, recordKey: String? = nil, shouldValidate: Bool? = true, record: UnknownType, - swapCommit: String? = nil) async -> Result { + public func createRecord( + repositoryDID: String, + collection: String, + recordKey: String? = nil, + shouldValidate: Bool? = true, + record: UnknownType, + swapCommit: String? = nil + ) async -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) diff --git a/Sources/ATProtoKit/Networking/CoreAPI/CreateReport.swift b/Sources/ATProtoKit/Networking/CoreAPI/CreateReport.swift index efccfbee2e..c4d5ff18a8 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/CreateReport.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/CreateReport.swift @@ -25,8 +25,11 @@ extension ATProtoAdmin { /// - subject: The responsible party being reported. /// - Returns: A `Result`, containing either ``ModerationCreateReportOutput`` /// if successful, or an `Error` if not. - public func createReport(with reasonType: ModerationReasonType, withContextof reason: String?, - subject: RepositoryReferencesUnion) async throws -> Result { + public func createReport( + with reasonType: ModerationReasonType, + withContextof reason: String?, + subject: RepositoryReferencesUnion + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) diff --git a/Sources/ATProtoKit/Networking/CoreAPI/DeleteAccount.swift b/Sources/ATProtoKit/Networking/CoreAPI/DeleteAccount.swift index 861a41fc44..00c19d40ec 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/DeleteAccount.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/DeleteAccount.swift @@ -24,7 +24,11 @@ extension ATProtoKit { /// - accountDID: The decentralized identifier (DID) of the user account to be deleted. /// - password: The password of the user account. /// - token: A token to confirm the deletion of the account. - public func deleteAccount(_ accountDID: String, password: String, token: String) async throws { + public func deleteAccount( + _ accountDID: String, + password: String, + token: String + ) async throws { guard session != nil, let accessToken = session?.accessToken else { throw ATRequestPrepareError.missingActiveSession diff --git a/Sources/ATProtoKit/Networking/CoreAPI/DeleteRecord.swift b/Sources/ATProtoKit/Networking/CoreAPI/DeleteRecord.swift index 418c84bcb0..43930a8760 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/DeleteRecord.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/DeleteRecord.swift @@ -26,7 +26,13 @@ extension ATProtoKit { /// of the record on the server. /// - swapCommit: Swap the commit on the server with this current commit based on the CID /// of the commit on the server. - public func deleteRecord(repositoryDID: String, collection: String, recordKey: String, swapRecord: String? = nil, swapCommit: String? = nil) async throws { + public func deleteRecord( + repositoryDID: String, + collection: String, + recordKey: String, + swapRecord: String? = nil, + swapCommit: String? = nil + ) async throws { guard session != nil, let accessToken = session?.accessToken else { throw ATRequestPrepareError.missingActiveSession diff --git a/Sources/ATProtoKit/Networking/CoreAPI/DescribeRepository.swift b/Sources/ATProtoKit/Networking/CoreAPI/DescribeRepository.swift index 663073ac85..3aa2c79946 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/DescribeRepository.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/DescribeRepository.swift @@ -21,8 +21,10 @@ extension ATProtoKit { /// - Parameter repositoryDID: The decentralized identifier (DID) or handle of the repository. /// - Returns: A `Result`, containing either a ``RepoDescribeRepoOutput`` /// if successful, ot an `Error` if not. - public func describeRepository(_ repositoryDID: String, - pdsURL: String? = nil) async throws -> Result { + public func describeRepository( + _ repositoryDID: String, + pdsURL: String? = nil + ) async throws -> Result { guard let sessionURL = pdsURL != nil ? pdsURL : session?.pdsURL, let requestURL = URL(string: "\(sessionURL)/xrpc/com.atproto.repo.describeRepo") else { return .failure(ATRequestPrepareError.invalidRequestURL) diff --git a/Sources/ATProtoKit/Networking/CoreAPI/GetAccountInviteCodes.swift b/Sources/ATProtoKit/Networking/CoreAPI/GetAccountInviteCodes.swift index e025d214d4..bd7cbff7fc 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/GetAccountInviteCodes.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/GetAccountInviteCodes.swift @@ -25,8 +25,10 @@ extension ATProtoKit { /// be included in the list. Optional. Defaults to `true`. /// - Returns: A `Result`, containing either ``ServerGetAccountInviteCodesOutput`` /// if successful, and an `Error` if not. - public func getAccountInviteCodes(_ areUsedCodesIncluded: Bool = true, - areEarnedCodesIncluded: Bool = true) async throws -> Result { + public func getAccountInviteCodes( + _ areUsedCodesIncluded: Bool = true, + areEarnedCodesIncluded: Bool = true + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) diff --git a/Sources/ATProtoKit/Networking/CoreAPI/GetBlob.swift b/Sources/ATProtoKit/Networking/CoreAPI/GetBlob.swift index d51fcbd392..f8dd89802f 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/GetBlob.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/GetBlob.swift @@ -21,7 +21,10 @@ extension ATProtoKit { /// /// - Parameter blobQuery: An object containing the `accountDID` and `cidHash` of the blob. /// - Returns: A `Result` containing `Data` on success or `Error` on failure. - public static func getBlob(from blobQuery: BlobQuery, pdsURL: String? = "https://bsky.social") async -> Result { + public static func getBlob( + from blobQuery: BlobQuery, + pdsURL: String? = "https://bsky.social" + ) async -> Result { guard let sessionURL = pdsURL, let requestURL = URL(string: "\(sessionURL)/xrpc/com.atproto.sync.getBlob") else { return .failure(ATRequestPrepareError.invalidRequestURL) diff --git a/Sources/ATProtoKit/Networking/CoreAPI/GetLatestCommit.swift b/Sources/ATProtoKit/Networking/CoreAPI/GetLatestCommit.swift index 37d3be73f1..991a759d8e 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/GetLatestCommit.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/GetLatestCommit.swift @@ -23,7 +23,10 @@ extension ATProtoKit { /// - pdsURL: The URL of the Personal Data Server (PDS). Defaults to `nil`. /// - Returns: A `Result`, containing either a ``SyncGetBlocksOutput`` /// if successful, or an `Error` if not. - public func getLatestCommit(from repositoryDID: String, pdsURL: String? = nil) async throws -> Result { + public func getLatestCommit( + from repositoryDID: String, + pdsURL: String? = nil + ) async throws -> Result { guard let sessionURL = pdsURL != nil ? pdsURL : session?.pdsURL, let requestURL = URL(string: "\(sessionURL)/xrpc/com.atproto.sync.getLatestCommit") else { return .failure(ATRequestPrepareError.invalidRequestURL) diff --git a/Sources/ATProtoKit/Networking/CoreAPI/GetRepoRecord.swift b/Sources/ATProtoKit/Networking/CoreAPI/GetRepoRecord.swift index 91fe0f33f3..1216e5c84b 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/GetRepoRecord.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/GetRepoRecord.swift @@ -23,7 +23,10 @@ extension ATProtoKit { /// - pdsURL: The URL of the Personal Data Server (PDS). /// - Returns: A `Result`, which either contains a ``RecordOutput`` /// if successful, and an `Error` if not. - public func getRepositoryRecord(from recordQuery: RecordQuery, pdsURL: String? = nil) async throws -> Result { + public func getRepositoryRecord( + from recordQuery: RecordQuery, + pdsURL: String? = nil + ) async throws -> Result { guard let sessionURL = pdsURL != nil ? pdsURL : session?.pdsURL, let requestURL = URL(string: "\(sessionURL)/xrpc/com.atproto.repo.getRecord") else { return .failure(ATRequestPrepareError.invalidRequestURL) diff --git a/Sources/ATProtoKit/Networking/CoreAPI/GetRepository.swift b/Sources/ATProtoKit/Networking/CoreAPI/GetRepository.swift index 61382ae333..658313790d 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/GetRepository.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/GetRepository.swift @@ -25,8 +25,11 @@ extension ATProtoKit { /// - pdsURL: The URL of the Personal Data Server (PDS). Defaults to `nil`. /// - Returns: A `Result`, containing either a `Data` object /// if successful, or an `Error` if not. - public func getRepository(_ repositoryDID: String, sinceRevision: String? = nil, - pdsURL: String? = nil) async throws -> Result { + public func getRepository( + _ repositoryDID: String, + sinceRevision: String? = nil, + pdsURL: String? = nil + ) async throws -> Result { guard let sessionURL = pdsURL != nil ? pdsURL : session?.pdsURL, let requestURL = URL(string: "\(sessionURL)/xrpc/com.atproto.sync.getRepo") else { return .failure(ATRequestPrepareError.invalidRequestURL) diff --git a/Sources/ATProtoKit/Networking/CoreAPI/GetSyncBlocks.swift b/Sources/ATProtoKit/Networking/CoreAPI/GetSyncBlocks.swift index 2ceffce250..39f533da7a 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/GetSyncBlocks.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/GetSyncBlocks.swift @@ -29,8 +29,11 @@ extension ATProtoKit { /// - pdsURL: The URL of the Personal Data Server (PDS). Defaults to `nil`. /// - Returns: A `Result`, containing either `Data` /// if successful, or `Error` if not. - public func getSyncBlocks(from repositoryDID: String, by repositoryCIDHashes: [String], - pdsURL: String? = nil) async throws -> Result { + public func getSyncBlocks( + from repositoryDID: String, + by repositoryCIDHashes: [String], + pdsURL: String? = nil + ) async throws -> Result { guard let sessionURL = pdsURL != nil ? pdsURL : session?.pdsURL, let requestURL = URL(string: "\(sessionURL)/xrpc/com.atproto.sync.getBlocks") else { return .failure(ATRequestPrepareError.invalidRequestURL) diff --git a/Sources/ATProtoKit/Networking/CoreAPI/GetSyncRecord.swift b/Sources/ATProtoKit/Networking/CoreAPI/GetSyncRecord.swift index 84cdf0eae6..e5ce4af937 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/GetSyncRecord.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/GetSyncRecord.swift @@ -23,8 +23,10 @@ extension ATProtoKit { /// - pdsURL: The URL of the Personal Data Server (PDS). Defaults to `nil`. /// - Returns: A `Result`, containing either a `Data` object /// if successful, or an `Error` if not. - public func getSyncRecord(_ recordQuery: RecordQuery, - pdsURL: String? = nil) async throws -> Result { + public func getSyncRecord( + _ recordQuery: RecordQuery, + pdsURL: String? = nil + ) async throws -> Result { guard let sessionURL = pdsURL != nil ? pdsURL : session?.pdsURL, let requestURL = URL(string: "\(sessionURL)/xrpc/com.atproto.sync.getRecord") else { return .failure(ATRequestPrepareError.invalidRequestURL) diff --git a/Sources/ATProtoKit/Networking/CoreAPI/ImportRepository.swift b/Sources/ATProtoKit/Networking/CoreAPI/ImportRepository.swift index f2018d8de7..a231024e40 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/ImportRepository.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/ImportRepository.swift @@ -26,7 +26,10 @@ extension ATProtoKit { /// - Parameters: /// - repositoryData: The repository data in the form of a CAR file. /// - pdsURL: The URL of the Personal Data Server (PDS). Defaults to `nil`. - public func importRepository(_ repositoryData: Data, pdsURL: String? = nil) async throws { + public func importRepository( + _ repositoryData: Data, + pdsURL: String? = nil + ) async throws { guard let sessionURL = pdsURL != nil ? pdsURL : session?.pdsURL, let requestURL = URL(string: "\(sessionURL)/xrpc/com.atproto.repo.importRepo") else { throw ATRequestPrepareError.invalidRequestURL diff --git a/Sources/ATProtoKit/Networking/CoreAPI/ListBlobs.swift b/Sources/ATProtoKit/Networking/CoreAPI/ListBlobs.swift index 4135ce9e64..29abb979e6 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/ListBlobs.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/ListBlobs.swift @@ -27,8 +27,13 @@ extension ATProtoKit { /// - pdsURL: The URL of the Personal Data Server (PDS). Defaults to `nil`. /// - Returns: A `Result`, containing either a ``SyncListBlobsOutput`` /// if successful, or an `Error` if not. - public func listBlobs(from repositoryDID: String, sinceRevision: String?, limit: Int? = 500, cursor: String? = nil, - pdsURL: String? = nil) async throws -> Result { + public func listBlobs( + from repositoryDID: String, + sinceRevision: String?, + limit: Int? = 500, + cursor: String? = nil, + pdsURL: String? = nil + ) async throws -> Result { guard let sessionURL = pdsURL != nil ? pdsURL : session?.pdsURL, let requestURL = URL(string: "\(sessionURL)/xrpc/com.atproto.sync.listBlobs") else { return .failure(ATRequestPrepareError.invalidRequestURL) diff --git a/Sources/ATProtoKit/Networking/CoreAPI/ListMissingBlobs.swift b/Sources/ATProtoKit/Networking/CoreAPI/ListMissingBlobs.swift index 71e3db6a9b..e107bba8bb 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/ListMissingBlobs.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/ListMissingBlobs.swift @@ -24,7 +24,10 @@ extension ATProtoKit { /// result. Optional. /// - Returns: A `Result`, containing either a ``RepoListMissingBlobsOutput`` /// if successful, or an `Error` if not. - public func listMissingBlobs(limit: Int? = 500, cursor: String? = nil) async throws -> Result { + public func listMissingBlobs( + limit: Int? = 500, + cursor: String? = nil + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) diff --git a/Sources/ATProtoKit/Networking/CoreAPI/ListRecords.swift b/Sources/ATProtoKit/Networking/CoreAPI/ListRecords.swift index c97dc28ef1..f00b2e199b 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/ListRecords.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/ListRecords.swift @@ -28,8 +28,14 @@ extension ATProtoKit { /// - pdsURL: The URL of the Personal Data Server (PDS). Defaults to `nil`. /// - Returns: A `Result`, containing ``RepoListRecordsOutput`` /// if successful, or an `Error` if not. - public func listRecords(from repositoryDID: String, collection: String, limit: Int? = 50, cursor: String? = nil, isArrayReverse: Bool? = nil, - pdsURL: String? = nil) async throws -> Result { + public func listRecords( + from repositoryDID: String, + collection: String, + limit: Int? = 50, + cursor: String? = nil, + isArrayReverse: Bool? = nil, + pdsURL: String? = nil + ) async throws -> Result { guard let sessionURL = pdsURL != nil ? pdsURL : session?.pdsURL, let requestURL = URL(string: "\(sessionURL)/xrpc/com.atproto.repo.listRecords") else { return .failure(ATRequestPrepareError.invalidRequestURL) diff --git a/Sources/ATProtoKit/Networking/CoreAPI/ListRepositories.swift b/Sources/ATProtoKit/Networking/CoreAPI/ListRepositories.swift index 1db6f61ed0..54dffdd5b8 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/ListRepositories.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/ListRepositories.swift @@ -27,8 +27,11 @@ extension ATProtoKit { /// - pdsURL: The URL of the Personal Data Server (PDS). Defaults to `nil`. /// - Returns: A `Result`, containing either a ``SyncListReposOutput`` /// if successful, or an `Error` if not. - public func listRepositories(limit: Int? = 500, cursor: String? = nil, - pdsURL: String? = nil) async throws -> Result { + public func listRepositories( + limit: Int? = 500, + cursor: String? = nil, + pdsURL: String? = nil + ) async throws -> Result { guard let sessionURL = pdsURL != nil ? pdsURL : session?.pdsURL, let requestURL = URL(string: "\(sessionURL)/xrpc/com.atproto.sync.getRepos") else { return .failure(ATRequestPrepareError.invalidRequestURL) diff --git a/Sources/ATProtoKit/Networking/CoreAPI/NotifyOfUpdate.swift b/Sources/ATProtoKit/Networking/CoreAPI/NotifyOfUpdate.swift index c461f1fca9..f608c3d780 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/NotifyOfUpdate.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/NotifyOfUpdate.swift @@ -26,8 +26,10 @@ extension ATProtoKit { /// - Parameters: /// - crawlingHostname: The hostname that the crawling service resides in. Optional. /// - pdsURL: The URL of the Personal Data Server (PDS). Defaults to `nil`. - public func notifyOfUpdate(in crawlingHostname: String? = nil, - pdsURL: String? = nil) async throws { + public func notifyOfUpdate( + in crawlingHostname: String? = nil, + pdsURL: String? = nil + ) async throws { guard let sessionURL = pdsURL != nil ? pdsURL : session?.pdsURL, let requestURL = URL(string: "\(sessionURL)/xrpc/app.bsky.graph.notifyOfUpdate") else { throw ATRequestPrepareError.invalidRequestURL diff --git a/Sources/ATProtoKit/Networking/CoreAPI/PutRecord.swift b/Sources/ATProtoKit/Networking/CoreAPI/PutRecord.swift index 41616fc5c2..b311a384eb 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/PutRecord.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/PutRecord.swift @@ -29,8 +29,15 @@ extension ATProtoKit { /// - swapCommit: Swaps the commit in the server with the commit contained in here. Optional. /// - Returns: A `Result`, containing either a ``StrongReference`` /// if successful, or an `Error` if not. - public func putRecord(_ repositoryDID: String, collection: String, recordKey: String, shouldValidate: Bool? = true, record: UnknownType, - swapRecord: String? = nil, swapCommit: String? = nil) async throws -> Result { + public func putRecord( + _ repositoryDID: String, + collection: String, + recordKey: String, + shouldValidate: Bool? = true, + record: UnknownType, + swapRecord: String? = nil, + swapCommit: String? = nil + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) diff --git a/Sources/ATProtoKit/Networking/CoreAPI/QueryLabels.swift b/Sources/ATProtoKit/Networking/CoreAPI/QueryLabels.swift index a46bc61e3d..d5efd6ec2e 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/QueryLabels.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/QueryLabels.swift @@ -34,9 +34,14 @@ extension ATProtoKit { /// sending the request. Defaults to `false`. /// - Returns: A `Result`, containing either a ``LabelQueryLabelsOutput`` /// if successful, or an `Error` if not. - public func queryLabels(uriPatterns: [String], sources: [String]?, limit: Int? = 50, cursor: String? = nil, - pdsURL: String? = nil, - shouldAuthenticate: Bool = false) async throws -> Result { + public func queryLabels( + uriPatterns: [String], + sources: [String]?, + limit: Int? = 50, + cursor: String? = nil, + pdsURL: String? = nil, + shouldAuthenticate: Bool = false + ) async throws -> Result { let authorizationValue = prepareAuthorizationValue( methodPDSURL: pdsURL, shouldAuthenticate: shouldAuthenticate, diff --git a/Sources/ATProtoKit/Networking/CoreAPI/RequestCrawl.swift b/Sources/ATProtoKit/Networking/CoreAPI/RequestCrawl.swift index b4be90bc7a..732fd08e02 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/RequestCrawl.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/RequestCrawl.swift @@ -23,8 +23,10 @@ extension ATProtoKit { /// - Parameters: /// - crawlingHostname: The hostname that the crawling service resides in. Optional. /// - pdsURL: The URL of the Personal Data Server (PDS). Defaults to `nil`. - public func requestCrawl(in crawlingHostname: String? = nil, - pdsURL: String? = nil) async throws { + public func requestCrawl( + in crawlingHostname: String? = nil, + pdsURL: String? = nil + ) async throws { guard let sessionURL = pdsURL != nil ? pdsURL : session?.pdsURL, let requestURL = URL(string: "\(sessionURL)/xrpc/com.atproto.sync.notifyOfUpdate") else { throw ATRequestPrepareError.invalidRequestURL diff --git a/Sources/ATProtoKit/Networking/CoreAPI/RequestPasswordReset.swift b/Sources/ATProtoKit/Networking/CoreAPI/RequestPasswordReset.swift index 5c9d00740a..287c6f8b7d 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/RequestPasswordReset.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/RequestPasswordReset.swift @@ -23,8 +23,10 @@ extension ATProtoKit { /// - Parameters: /// - email: The email associated with the user's account. /// - pdsURL: The URL of the Personal Data Server (PDS). Defaults to `nil`. - public func requestPasswordReset(_ email: String, - pdsURL: String? = nil) async throws { + public func requestPasswordReset( + _ email: String, + pdsURL: String? = nil + ) async throws { guard let sessionURL = pdsURL != nil ? pdsURL : session?.pdsURL, let requestURL = URL(string: "\(sessionURL)/xrpc/com.atproto.server.requestPasswordReset") else { throw ATRequestPrepareError.invalidRequestURL diff --git a/Sources/ATProtoKit/Networking/CoreAPI/ReserveSigningKey.swift b/Sources/ATProtoKit/Networking/CoreAPI/ReserveSigningKey.swift index b58d56f9b2..4113771938 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/ReserveSigningKey.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/ReserveSigningKey.swift @@ -25,7 +25,10 @@ extension ATProtoKit { /// - pdsURL: The URL of the Personal Data Server (PDS). Defaults to `nil`. /// - Returns: A `Result`, containing either a ``ServerReserveSigningKeyOutput`` /// if successful, or an `Error` if not. - public func reserveSigningKey(_ repositoryDID: String, pdsURL: String? = nil) async throws -> Result { + public func reserveSigningKey( + _ repositoryDID: String, + pdsURL: String? = nil + ) async throws -> Result { guard let sessionURL = pdsURL != nil ? pdsURL : determinePDSURL(customPDSURL: pdsURL), let requestURL = URL(string: "\(sessionURL)/xrpc/com.atproto.server.reserveSigningKey") else { return .failure(ATRequestPrepareError.invalidRequestURL) diff --git a/Sources/ATProtoKit/Networking/CoreAPI/ResetPassword.swift b/Sources/ATProtoKit/Networking/CoreAPI/ResetPassword.swift index ebe13710e8..1535c152db 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/ResetPassword.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/ResetPassword.swift @@ -24,8 +24,11 @@ extension ATProtoKit { /// - token: The token used to reset the password. /// - newPassword: The new password for the user's account. /// - pdsURL: The URL of the Personal Data Server (PDS). Defaults to `nil`. - public func resetPassword(using token: String, newPassword: String, - pdsURL: String? = nil) async throws { + public func resetPassword( + using token: String, + newPassword: String, + pdsURL: String? = nil + ) async throws { guard let sessionURL = pdsURL != nil ? pdsURL : session?.pdsURL, let requestURL = URL(string: "\(sessionURL)/xrpc/com.atproto.server.resetPassword") else { throw ATRequestPrepareError.invalidRequestURL diff --git a/Sources/ATProtoKit/Networking/CoreAPI/ResolveHandle.swift b/Sources/ATProtoKit/Networking/CoreAPI/ResolveHandle.swift index da505a6a5d..d3c0c1b683 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/ResolveHandle.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/ResolveHandle.swift @@ -24,7 +24,10 @@ extension ATProtoKit { /// - pdsURL: The URL of the Personal Data Server (PDS). Defaults to `nil`. /// - Returns: A `Result`, containing either a ``ResolveHandleOutput`` /// if successful, or an `Error` if not. - public func resolveHandle(from handle: String, pdsURL: String? = nil) async throws -> Result { + public func resolveHandle( + from handle: String, + pdsURL: String? = nil + ) async throws -> Result { guard let sessionURL = pdsURL != nil ? pdsURL : session?.pdsURL, let requestURL = URL(string: "\(sessionURL)/xrpc/com.atproto.identity.resolveHandle") else { return .failure(ATRequestPrepareError.invalidRequestURL) diff --git a/Sources/ATProtoKit/Networking/CoreAPI/SignPLCOperation.swift b/Sources/ATProtoKit/Networking/CoreAPI/SignPLCOperation.swift index 62db477cf4..a6a4d7eb9c 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/SignPLCOperation.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/SignPLCOperation.swift @@ -29,8 +29,13 @@ extension ATProtoKit { /// - service: The service endpoint recommended in the DID document. Optional. /// - Returns: A `Result`, containing either an ``IdentitySignPLCOperationOutput`` /// if successful, ot an `Error` if not. - public func signPLCOperation(token: String, rotationKeys: [String]?, alsoKnownAs: [String]?, verificationMethods: VerificationMethod?, - service: ATService?) async throws -> Result { + public func signPLCOperation( + token: String, + rotationKeys: [String]?, + alsoKnownAs: [String]?, + verificationMethods: VerificationMethod?, + service: ATService? + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) diff --git a/Sources/ATProtoKit/Networking/CoreAPI/UpdateEmail.swift b/Sources/ATProtoKit/Networking/CoreAPI/UpdateEmail.swift index a55189d138..96b58e7f54 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/UpdateEmail.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/UpdateEmail.swift @@ -26,7 +26,11 @@ extension ATProtoKit { /// - isEmailAuthenticationFactorEnabled: Indicates whether /// Two-Factor Authentication (via email) is enabled. Optional. /// - token: The token used to confirm the change. Optional. - public func updateEmail(_ email: String, isEmailAuthenticationFactorEnabled: Bool? = nil, token: String? = nil) async throws { + public func updateEmail( + _ email: String, + isEmailAuthenticationFactorEnabled: Bool? = nil, + token: String? = nil + ) async throws { guard session != nil, let accessToken = session?.accessToken else { throw ATRequestPrepareError.missingActiveSession diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/CreateLike.swift b/Sources/ATProtoKit/Networking/PlatformAPI/CreateLike.swift index 192ac6a5a6..fa0dabcf61 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/CreateLike.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/CreateLike.swift @@ -18,8 +18,11 @@ extension ATProtoKit { /// Defaults to `true`. /// - Returns: A `Result`, containing either a ``StrongReference`` /// if it's successful, or an `Error` if it's not. - public func createLikeRecord(_ strongReference: StrongReference, createdAt: Date = Date.now, - shouldValidate: Bool? = true) async throws -> Result { + public func createLikeRecord( + _ strongReference: StrongReference, + createdAt: Date = Date.now, + shouldValidate: Bool? = true + ) async throws -> Result { // guard let sessionURL = session.pdsURL, // let requestURL = URL(string: "\(sessionURL)/xrpc/com.atproto.repo.createRecord") else { // throw NSError(domain: "", code: -1, userInfo: [NSLocalizedDescriptionKey: "Invalid URL"]) diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/CreatePost.swift b/Sources/ATProtoKit/Networking/PlatformAPI/CreatePost.swift index 76e854d2e9..f9a9deb61e 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/CreatePost.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/CreatePost.swift @@ -26,9 +26,18 @@ extension ATProtoKit { /// Defaults to `true`. /// - swapCommit: Swaps out an operation based on the CID. Optional. /// - Returns: A strong reference, which contains the newly-created record's URI and CID hash. - public func createPostRecord(text: String, locales: [Locale] = [], replyTo: String? = nil, embed: EmbedIdentifier? = nil, - labels: FeedLabelUnion? = nil, tags: [String]? = nil, creationDate: Date = Date.now, recordKey: String? = nil, - shouldValidate: Bool? = true, swapCommit: String? = nil) async -> Result { + public func createPostRecord( + text: String, + locales: [Locale] = [], + replyTo: String? = nil, + embed: EmbedIdentifier? = nil, + labels: FeedLabelUnion? = nil, + tags: [String]? = nil, + creationDate: Date = Date.now, + recordKey: String? = nil, + shouldValidate: Bool? = true, + swapCommit: String? = nil + ) async -> Result { guard let session else { return .failure(ATRequestPrepareError.missingActiveSession) diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetActorFeeds.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetActorFeeds.swift index e03d54eea9..d4886c80a8 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetActorFeeds.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetActorFeeds.swift @@ -25,7 +25,11 @@ extension ATProtoKit { /// result. Optional. /// - Returns: A `Result`, containing either a ``FeedGetActorFeedsOutput`` /// if successful, or an `Error` if not. - public func getActorFeeds(by actorDID: String, limit: Int? = 50, cursor: String? = nil) async throws -> Result { + public func getActorFeeds( + by actorDID: String, + limit: Int? = 50, + cursor: String? = nil + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetActorLikes.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetActorLikes.swift index 880562314e..58a7547c61 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetActorLikes.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetActorLikes.swift @@ -36,7 +36,11 @@ extension ATProtoKit { /// result. Optional. /// - Returns: A `Result`, containing either a ``FeedGetActorLikesOutput`` /// if successful, or an `Error` if not. - public func getActorLikes(by actorDID: String, limit: Int? = 50, cursor: String? = nil) async throws -> Result { + public func getActorLikes( + by actorDID: String, + limit: Int? = 50, + cursor: String? = nil + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetAuthorFeed.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetAuthorFeed.swift index 8916d392bd..f10c043e5b 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetAuthorFeed.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetAuthorFeed.swift @@ -31,8 +31,12 @@ extension ATProtoKit { /// result. Optional. /// - Returns: A `Result`, containing either a ``FeedGetAuthorFeedOutput`` /// if successful, or an `Error` if not. - public func getAuthorFeed(by actorDID: String, limit: Int? = 50, cursor: String? = nil, postFilter: - FeedGetAuthorFeedFilter? = .postsWithReplies) async throws -> Result { + public func getAuthorFeed( + by actorDID: String, + limit: Int? = 50, + cursor: String? = nil, + postFilter: FeedGetAuthorFeedFilter? = .postsWithReplies + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetFeed.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetFeed.swift index de47a5d181..1605ec6206 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetFeed.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetFeed.swift @@ -25,7 +25,11 @@ extension ATProtoKit { /// result. Optional. /// - Returns: A `Result`, containing either a ``FeedGetFeedOutput`` /// if successful, or an `Error` if not. - public func getFeed(_ feedURI: String, limit: Int? = 50, cursor: String? = nil) async throws -> Result { + public func getFeed( + _ feedURI: String, + limit: Int? = 50, + cursor: String? = nil + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetFeedSkeleton.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetFeedSkeleton.swift index e397fba5ae..b1ee734be4 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetFeedSkeleton.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetFeedSkeleton.swift @@ -31,8 +31,12 @@ extension ATProtoKit { /// - pdsURL: The URL of the Personal Data Server (PDS). /// - Returns: A `Result`, containing either a ``FeedGetFeedSkeletonOutput`` /// if successful, or an `Error` if not. - public static func getFeedSkeleton(_ feedURI: String, limit: Int? = 50, cursor: String? = nil, - pdsURL: String) async throws -> Result { + public static func getFeedSkeleton( + _ feedURI: String, + limit: Int? = 50, + cursor: String? = nil, + pdsURL: String + ) async throws -> Result { guard let requestURL = URL(string: "\(pdsURL)/xrpc/app.bsky.feed.getFeedSkeleton") else { return .failure(ATRequestPrepareError.invalidRequestURL) } diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetFollowers.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetFollowers.swift index 7eb3e8430e..beb0c7a2fb 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetFollowers.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetFollowers.swift @@ -25,7 +25,11 @@ extension ATProtoKit { /// - cursor: The mark used to indicate the starting point for the next set of result. Optional. /// - Returns: A `Result`, containing either a ``GraphGetFollowersOutput`` /// if successful, or an `Error` if not. - public func getFollowers(by actorDID: String, limit: Int? = 50, cursor: String? = nil) async throws -> Result { + public func getFollowers( + by actorDID: String, + limit: Int? = 50, + cursor: String? = nil + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetFollows.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetFollows.swift index 1483a55f42..e3b7ad0cf2 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetFollows.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetFollows.swift @@ -26,7 +26,11 @@ extension ATProtoKit { /// result. Optional. /// - Returns: A `Result`, containing either a ``GraphFollowsOutput`` /// if successful, or an `Error` if not. - public func getFollows(from actorDID: String, limit: Int? = 50, cursor: String? = nil) async throws -> Result { + public func getFollows( + from actorDID: String, + limit: Int? = 50, + cursor: String? = nil + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetGraphBlocks.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetGraphBlocks.swift index b43c013712..8cb8f8527e 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetGraphBlocks.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetGraphBlocks.swift @@ -24,7 +24,10 @@ extension ATProtoKit { /// result. Optional. /// - Returns: A `Result`, containing either a ``GraphGetBlocksOutput`` /// if successful, or an `Error` if not. - public func getGraphBlocks(limit: Int? = 50, cursor: String? = nil) async throws -> Result { + public func getGraphBlocks( + limit: Int? = 50, + cursor: String? = nil + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetLabelerServices.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetLabelerServices.swift index 55d19e7cb8..6f0da88f52 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetLabelerServices.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetLabelerServices.swift @@ -24,8 +24,11 @@ extension ATProtoKit { /// - pdsURL: The URL of the Personal Data Server (PDS). Defaults to `nil`. /// - Returns: A `Result`, containing either a ``LabelerGetServicesOutput`` /// if successful, or an `Error` if not. - public func getLabelerServices(labelerDIDs: [String], isDetailed: Bool? = nil, - pdsURL: String? = nil) async throws -> Result { + public func getLabelerServices( + labelerDIDs: [String], + isDetailed: Bool? = nil, + pdsURL: String? = nil + ) async throws -> Result { guard let sessionURL = pdsURL != nil ? pdsURL : session?.pdsURL, let requestURL = URL(string: "\(sessionURL)/xrpc/app.bsky.labeler.getServices") else { return .failure(ATRequestPrepareError.invalidFormat) diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetLikes.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetLikes.swift index 9886bf98b9..7a8e9c4a81 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetLikes.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetLikes.swift @@ -26,8 +26,12 @@ extension ATProtoKit { /// result. Optional. /// - Returns: A `Result`, containing either a ``FeedGetLikesOutput`` /// if successful, or an `Error` if not. - public func getLikes(from recordURI: String, recordCID: String? = nil, limit: Int? = 50, - cursor: String? = nil) async throws -> Result { + public func getLikes( + from recordURI: String, + recordCID: String? = nil, + limit: Int? = 50, + cursor: String? = nil + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetList.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetList.swift index f05dc7e420..67a0b9275f 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetList.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetList.swift @@ -25,7 +25,11 @@ extension ATProtoKit { /// result. Optional. /// - Returns: A `Result`, containing either a ``GraphGetListOutput`` /// if successful, or an `Error` if not. - public func getList(from listURI: String, limit: Int? = 50, cursor: String? = nil) async throws -> Result { + public func getList( + from listURI: String, + limit: Int? = 50, + cursor: String? = nil + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetListBlocks.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetListBlocks.swift index 236040e4de..824b255b27 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetListBlocks.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetListBlocks.swift @@ -24,7 +24,10 @@ extension ATProtoKit { /// result. Optional. /// - Returns: A `Result`, containing either a ``GraphGetBlocksOutput`` /// if successful, or an `Error` if not. - public func getListBlocks(limit: Int? = 50, cursor: String? = nil) async throws -> Result { + public func getListBlocks( + limit: Int? = 50, + cursor: String? = nil + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetListFeed.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetListFeed.swift index 796a793e66..5648fbf872 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetListFeed.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetListFeed.swift @@ -27,9 +27,13 @@ extension ATProtoKit { /// - pdsURL: The URL of the Personal Data Server (PDS). Defaults to `nil`. /// - Returns: A `Result`, containing either an ``FeedGetListFeedOutput`` /// if succesful, or an `Error` if it's not. - public func getListFeed(from listURI: String, limit: Int? = 50, cursor: String? = nil, - accessToken: String? = nil, - pdsURL: String? = nil) async throws -> Result { + public func getListFeed( + from listURI: String, + limit: Int? = 50, + cursor: String? = nil, + accessToken: String? = nil, + pdsURL: String? = nil + ) async throws -> Result { guard let sessionURL = pdsURL != nil ? pdsURL : session?.pdsURL, let requestURL = URL(string: "\(sessionURL)/xrpc/app.bsky.feed.getListFeed") else { return .failure(ATRequestPrepareError.invalidRequestURL) diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetListMutes.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetListMutes.swift index cd848affdb..a7ac2c5492 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetListMutes.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetListMutes.swift @@ -24,7 +24,10 @@ extension ATProtoKit { /// result. Optional. /// - Returns: A `Result`, containing either a ``GraphGetListMutesOutput`` /// if successful, or an `Error` if not. - public func getListMutes(limit: Int? = 50, cursor: String? = nil) async throws -> Result { + public func getListMutes( + limit: Int? = 50, + cursor: String? = nil + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetLists.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetLists.swift index 5181a27282..1e6c158761 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetLists.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetLists.swift @@ -25,7 +25,11 @@ extension ATProtoKit { /// result. Optional. /// - Returns: A `Result`, containing either a ``GraphGetListsOutput`` /// if successful, or an `Error` if not. - public func getLists(from actorDID: String, limit: Int? = 50, cursor: String? = nil) async throws -> Result { + public func getLists( + from actorDID: String, + limit: Int? = 50, + cursor: String? = nil + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetMutes.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetMutes.swift index 52bcaec1f7..152fca8a89 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetMutes.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetMutes.swift @@ -24,7 +24,10 @@ extension ATProtoKit { /// result. Optional. /// - Returns: A `Result`, containing either a ``GraphGetMutesOutput`` /// if successful, or an `Error` if not. - public func getMutes(limit: Int? = 50, cursor: String? = nil) async throws -> Result { + public func getMutes( + limit: Int? = 50, + cursor: String? = nil + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetPopularFeedGenerators.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetPopularFeedGenerators.swift index e8d9977d6c..c43ae70af6 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetPopularFeedGenerators.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetPopularFeedGenerators.swift @@ -28,8 +28,11 @@ extension ATProtoKit { /// result. Optional. /// - Returns: A `Result`, containing either an ``UnspeccedGetPopularFeedGeneratorsOutput`` /// if successful, or an `Error` if not. - public func getPopularFeedGenerators(_ query: String?, limit: Int? = 50, - cursor: String? = nil) async throws -> Result { + public func getPopularFeedGenerators( + _ query: String?, + limit: Int? = 50, + cursor: String? = nil + ) async throws -> Result { guard let sessionURL = session?.pdsURL, let requestURL = URL(string: "\(sessionURL)/xrpc/app.bsky.unspecced.getPopularFeedGenerators") else { return .failure(ATRequestPrepareError.invalidRequestURL) diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetPostThread.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetPostThread.swift index 7581537099..9788c5d176 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetPostThread.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetPostThread.swift @@ -28,9 +28,13 @@ extension ATProtoKit { /// - pdsURL: The URL of the Personal Data Server (PDS). Defaults to `nil`. /// - Returns: A `Result`, containing either a ``FeedGetPostThreadOutput`` /// if successful, or an `Error` if not. - public func getPostThread(from postURI: String, depth: Int? = 6, parentHeight: Int? = 80, - pdsURL: String? = nil, - shouldAuthenticate: Bool = false) async throws -> Result { + public func getPostThread( + from postURI: String, + depth: Int? = 6, + parentHeight: Int? = 80, + pdsURL: String? = nil, + shouldAuthenticate: Bool = false + ) async throws -> Result { let authorizationValue = prepareAuthorizationValue( methodPDSURL: pdsURL, shouldAuthenticate: shouldAuthenticate, diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetProfile.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetProfile.swift index 3525704f27..a931a3b628 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetProfile.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetProfile.swift @@ -35,9 +35,11 @@ extension ATProtoKit { /// sending the request. Defaults to `false`. /// - Returns: A `Result`, containing ``ActorGetProfileOutput`` /// if successful, or an `Error` if not. - public func getProfile(_ actor: String, - pdsURL: String? = nil, - shouldAuthenticate: Bool = false) async throws -> Result { + public func getProfile( + _ actor: String, + pdsURL: String? = nil, + shouldAuthenticate: Bool = false + ) async throws -> Result { let authorizationValue = prepareAuthorizationValue( methodPDSURL: pdsURL, shouldAuthenticate: shouldAuthenticate, diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetProfiles.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetProfiles.swift index 4287c517ea..b5dc77f248 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetProfiles.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetProfiles.swift @@ -37,9 +37,11 @@ extension ATProtoKit { /// sending the request. Defaults to `false`. /// - Returns: A `Result`, containing ``ActorGetProfileOutput`` /// if successful, or an `Error` if not. - public func getProfiles(_ actors: [String], - pdsURL: String? = nil, - shouldAuthenticate: Bool = false) async throws -> Result { + public func getProfiles( + _ actors: [String], + pdsURL: String? = nil, + shouldAuthenticate: Bool = false + ) async throws -> Result { let authorizationValue = prepareAuthorizationValue( methodPDSURL: pdsURL, shouldAuthenticate: shouldAuthenticate, diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetRelationships.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetRelationships.swift index b8d17445ef..1d6572015b 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetRelationships.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetRelationships.swift @@ -25,8 +25,12 @@ extension ATProtoKit { /// is `30`. /// - Returns: A `Result`, containing either a ``GraphGetRelationships`` /// if successful, or an `Error` if not. - public func getRelationships(between actorDID: String, and otherDIDs: [String]? = nil, maxLength: Int? = 50, - pdsURL: String? = nil) async throws -> Result { + public func getRelationships( + between actorDID: String, + and otherDIDs: [String]? = nil, + maxLength: Int? = 50, + pdsURL: String? = nil + ) async throws -> Result { guard let sessionURL = pdsURL != nil ? pdsURL : session?.pdsURL, let requestURL = URL(string: "\(sessionURL)/xrpc/app.bsky.graph.getRelationships") else { return .failure(ATRequestPrepareError.invalidRequestURL) diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetRepostedBy.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetRepostedBy.swift index debbd51ec9..999b18386c 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetRepostedBy.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetRepostedBy.swift @@ -26,8 +26,12 @@ extension ATProtoKit { /// result. Optional. /// - Returns: A `Result`, containing either a ``FeedGetRepostedBy`` /// if successful, or an `Error` if not. - public func getRepostedBy(_ postURI: String, postCID: String? = nil, limit: Int? = 50, - cursor: String? = nil) async throws -> Result { + public func getRepostedBy( + _ postURI: String, + postCID: String? = nil, + limit: Int? = 50, + cursor: String? = nil + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetSuggestedFeeds.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetSuggestedFeeds.swift index 2ca8e93494..2a5b970c5a 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetSuggestedFeeds.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetSuggestedFeeds.swift @@ -24,7 +24,10 @@ extension ATProtoKit { /// result. Optional. /// - Returns: A `Result`, containing either a ``FeedGetSuggestedFeedsOutput`` /// if successful, or an `Error` if not. - public func getSuggestedFeeds(limit: Int? = 50, cursor: String? = nil) async throws -> Result { + public func getSuggestedFeeds( + limit: Int? = 50, + cursor: String? = nil + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetSuggestions.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetSuggestions.swift index ffddcbd86a..5a2cec54f9 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetSuggestions.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetSuggestions.swift @@ -25,7 +25,10 @@ extension ATProtoKit { /// results. Optional. /// - Returns: A `Result`, containing either an ``ActorGetSuggestionsOutput`` /// if succesful, or an `Error` if it's not. - public func getSuggestions(limit: Int? = 50, cursor: String? = nil) async throws -> Result { + public func getSuggestions( + limit: Int? = 50, + cursor: String? = nil + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetSuggestionsSkeleton.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetSuggestionsSkeleton.swift index aa96ab2e00..7f952c5c48 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetSuggestionsSkeleton.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetSuggestionsSkeleton.swift @@ -28,7 +28,10 @@ extension ATProtoKit { /// only be between `1` and `100`. /// - Returns: A `Result`, containing either an ``UnspeccedGetSuggestionsSkeletonOutput`` /// if successful, or an `Error` if not. - public func getSuggestionsSkeleton(viewerDID: String?, limit: Int? = 50) async throws -> Result { + public func getSuggestionsSkeleton( + viewerDID: String?, + limit: Int? = 50 + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetTimeline.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetTimeline.swift index eadccfccc2..3213fa49d1 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetTimeline.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetTimeline.swift @@ -31,7 +31,11 @@ extension ATProtoKit { /// - cursor: The mark used to indicate the starting point for the next set of result. Optional. /// - Returns: A `Result`, containing either a ``FeedGetTimelineOutput`` /// if successful, or an `Error` if not. - public func getTimeline(using algorithm: String? = nil, limit: Int? = 50, cursor: String? = nil) async throws -> Result { + public func getTimeline( + using algorithm: String? = nil, + limit: Int? = 50, + cursor: String? = nil + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetUnreadCount.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetUnreadCount.swift index ea1a2c8bb1..73fa9e6496 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetUnreadCount.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetUnreadCount.swift @@ -22,7 +22,9 @@ extension ATProtoKit { /// time the request was sent. /// - Returns: A `Result`, containing either a ``NotificationGetUnreadCountOutput`` /// if successful, or an `Error` if not. - public func getUnreadCount(seenAt: Date = Date.now) async throws -> Result { + public func getUnreadCount( + seenAt: Date = Date.now + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/ListNotifications.swift b/Sources/ATProtoKit/Networking/PlatformAPI/ListNotifications.swift index bbea46f410..b0780796ed 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/ListNotifications.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/ListNotifications.swift @@ -26,8 +26,11 @@ extension ATProtoKit { /// request was sent. /// - Returns: A `Result`, containing either a ``NotificationListNotificationsOutput`` /// if successful, or an `Error` if not. - public func listNotifications(withLimitOf limit: Int? = 50, cursor: String? = nil, - seenAt: Date = Date.now) async throws -> Result { + public func listNotifications( + withLimitOf limit: Int? = 50, + cursor: String? = nil, + seenAt: Date = Date.now + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/RegisterPush.swift b/Sources/ATProtoKit/Networking/PlatformAPI/RegisterPush.swift index e4f9425ac0..ab653896ad 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/RegisterPush.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/RegisterPush.swift @@ -23,7 +23,12 @@ extension ATProtoKit { /// - token: The token of the service. /// - platform: The platform of the client. /// - appID: The identifier of the client. - public func registerPush(serviceDID: String, token: String, platform: RegisterPushRequest.Platform, appID: String) async throws { + public func registerPush( + serviceDID: String, + token: String, + platform: RegisterPushRequest.Platform, + appID: String + ) async throws { guard session != nil, let accessToken = session?.accessToken else { throw ATRequestPrepareError.missingActiveSession diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/SearchActorsSkeleton.swift b/Sources/ATProtoKit/Networking/PlatformAPI/SearchActorsSkeleton.swift index af77212494..33e217ad77 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/SearchActorsSkeleton.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/SearchActorsSkeleton.swift @@ -30,8 +30,14 @@ extension ATProtoKit { /// result. Optional. /// - Returns: A `Result`, containing either an ``UnspeccedSearchActorsSkeletonOutput`` /// if successful, or an `Error` if not. - public func searchActorsSkeleton(_ query: String, viewerDID: String? = nil, canTypeAhead: Bool?, limit: Int? = 25, cursor: String? = nil, - pdsURL: String? = nil) async throws -> Result { + public func searchActorsSkeleton( + _ query: String, + viewerDID: String? = nil, + canTypeAhead: Bool?, + limit: Int? = 25, + cursor: String? = nil, + pdsURL: String? = nil + ) async throws -> Result { guard let sessionURL = pdsURL != nil ? pdsURL : session?.pdsURL, let requestURL = URL(string: "\(sessionURL)/xrpc/app.bsky.unspecced.searchActorsSkeleton") else { return .failure(ATRequestPrepareError.invalidRequestURL) diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/SearchPosts.swift b/Sources/ATProtoKit/Networking/PlatformAPI/SearchPosts.swift index 857ba40292..444a5aca50 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/SearchPosts.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/SearchPosts.swift @@ -41,9 +41,20 @@ extension ATProtoKit { /// results. Optional. /// - Returns: A `Result`, containing either an ``FeedSearchPostsOutput`` /// if succesful, or an `Error` if it's not. - public func searchPosts(with searchQuery: String, sortRanking: FeedSearchPostsSortRanking? = .latest, sinceDate: Date?, untilDate: Date?, - mentionIdentifier: String? = nil, author: String? = nil, language: Locale?, domain: String?, url: String?, tags: [String]?, - limit: Int? = 25, cursor: String? = nil) async throws -> Result { + public func searchPosts( + with searchQuery: String, + sortRanking: FeedSearchPostsSortRanking? = .latest, + sinceDate: Date?, + untilDate: Date?, + mentionIdentifier: String? = nil, + author: String? = nil, + language: Locale?, + domain: String?, + url: String?, + tags: [String]?, + limit: Int? = 25, + cursor: String? = nil + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/SearchPostsSkeleton.swift b/Sources/ATProtoKit/Networking/PlatformAPI/SearchPostsSkeleton.swift index 131b3f1118..024b490acf 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/SearchPostsSkeleton.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/SearchPostsSkeleton.swift @@ -44,10 +44,21 @@ extension ATProtoKit { /// result. Optional. /// - Returns: A `Result`, containing either an ``UnspeccedSearchPostsSkeletonOutput`` /// if successful, or an `Error` if not. - public func searchPostsSkeleton(with searchQuery: String, sortRanking: UnspeccedSearchPostsSortRanking? = .latest, sinceDate: Date?, untilDate: Date?, - mentionIdentifier: String? = nil, author: String? = nil, language: Locale?, domain: String?, url: String?, - tags: [String]?, limit: Int? = 25, cursor: String? = nil, - pdsURL: String? = nil) async throws -> Result { + public func searchPostsSkeleton( + with searchQuery: String, + sortRanking: UnspeccedSearchPostsSortRanking? = .latest, + sinceDate: Date?, + untilDate: Date?, + mentionIdentifier: String? = nil, + author: String? = nil, + language: Locale?, + domain: String?, + url: String?, + tags: [String]?, + limit: Int? = 25, + cursor: String? = nil, + pdsURL: String? = nil + ) async throws -> Result { guard let sessionURL = pdsURL != nil ? pdsURL : session?.pdsURL, let requestURL = URL(string: "\(sessionURL)/xrpc/app.bsky.unspecced.searchPostsSkeleton") else { return .failure(ATRequestPrepareError.invalidRequestURL) diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/SearchUsers.swift b/Sources/ATProtoKit/Networking/PlatformAPI/SearchUsers.swift index cb62c68798..606b298fc4 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/SearchUsers.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/SearchUsers.swift @@ -40,9 +40,13 @@ extension ATProtoKit { /// when sending the request. Defaults to `false`. /// - Returns: A `Result`, containing either ``ActorSearchActorsOutput`` /// if successful, and an `Error` if not. - public func searchUsers(by query: String, limit: Int? = 25, cursor: String? = nil, - pdsURL: String? = nil, - shouldAuthenticate: Bool = false) async throws -> Result { + public func searchUsers( + by query: String, + limit: Int? = 25, + cursor: String? = nil, + pdsURL: String? = nil, + shouldAuthenticate: Bool = false + ) async throws -> Result { let authorizationValue = prepareAuthorizationValue( methodPDSURL: pdsURL, shouldAuthenticate: shouldAuthenticate, diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/SearchUsersTypeahead.swift b/Sources/ATProtoKit/Networking/PlatformAPI/SearchUsersTypeahead.swift index 3f4981fd99..caa4f8e370 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/SearchUsersTypeahead.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/SearchUsersTypeahead.swift @@ -39,9 +39,12 @@ extension ATProtoKit { /// sending the request. Defaults to `false`. /// - Returns: A `Result`, containing either ``ActorSearchActorsOutput`` /// if successful, and an `Error` if not. - public func searchUsersTypeahead(by query: String, limit: Int? = 10, - pdsURL: String? = nil, - shouldAuthenticate: Bool = false) async throws -> Result { + public func searchUsersTypeahead( + by query: String, + limit: Int? = 10, + pdsURL: String? = nil, + shouldAuthenticate: Bool = false + ) async throws -> Result { let authorizationValue = prepareAuthorizationValue( methodPDSURL: pdsURL, shouldAuthenticate: shouldAuthenticate, diff --git a/Sources/ATProtoKit/Networking/SessionManager/ATProtocolConfiguration.swift b/Sources/ATProtoKit/Networking/SessionManager/ATProtocolConfiguration.swift index 2abccbb6d2..1411137ceb 100644 --- a/Sources/ATProtoKit/Networking/SessionManager/ATProtocolConfiguration.swift +++ b/Sources/ATProtoKit/Networking/SessionManager/ATProtocolConfiguration.swift @@ -49,8 +49,13 @@ public class ATProtocolConfiguration: ProtocolConfiguration { /// be in. Optional. Defaults to `ATProtoKit`. /// - logLevel: Specifies the highest level of logs that will be outputted. Optional. /// Defaults to `.info`. - public init(handle: String, appPassword: String, pdsURL: String = "https://bsky.social", logIdentifier: String? = nil, logCategory: String? = nil, - logLevel: Logger.Level? = .info) { + public init( + handle: String, + appPassword: String, + pdsURL: String = "https://bsky.social", + logIdentifier: String? = nil, + logCategory: String? = nil, + logLevel: Logger.Level? = .info) { self.handle = handle self.appPassword = appPassword self.pdsURL = !pdsURL.isEmpty ? pdsURL : "https://bsky.social" @@ -149,9 +154,17 @@ public class ATProtocolConfiguration: ProtocolConfiguration { /// account to this instance. Optional. /// - Returns: A `Result`, containing either a ``UserSession`` /// if successful, or an `Error` if not. - public func createAccount(email: String? = nil, handle: String, existingDID: String? = nil, inviteCode: String? = nil, - verificationCode: String? = nil, verificationPhone: String? = nil, password: String? = nil, recoveryKey: String? = nil, - plcOp: UnknownType? = nil) async throws -> Result { + public func createAccount( + email: String? = nil, + handle: String, + existingDID: String? = nil, + inviteCode: String? = nil, + verificationCode: String? = nil, + verificationPhone: String? = nil, + password: String? = nil, + recoveryKey: String? = nil, + plcOp: UnknownType? = nil + ) async throws -> Result { guard let requestURL = URL(string: "\(self.pdsURL)/xrpc/com.atproto.server.createAccount") else { return .failure(ATRequestPrepareError.invalidRequestURL) } @@ -203,8 +216,10 @@ public class ATProtocolConfiguration: ProtocolConfiguration { /// - pdsURL: The URL of the Personal Data Server (PDS). Defaults to `nil`. /// - Returns: Returns: A `Result` containing either ``SessionResponse`` /// if successful, or an `Error` if not. - public func getSession(by accessToken: String, - pdsURL: String? = nil) async throws -> Result { + public func getSession( + by accessToken: String, + pdsURL: String? = nil + ) async throws -> Result { guard let sessionURL = pdsURL != nil ? pdsURL : self.pdsURL, let requestURL = URL(string: "\(sessionURL)/xrpc/com.atproto.server.getSession") else { return .failure(ATRequestPrepareError.invalidRequestURL) @@ -237,8 +252,10 @@ public class ATProtocolConfiguration: ProtocolConfiguration { /// - pdsURL: The URL of the Personal Data Server (PDS). Defaults to `nil`. /// - Returns: A `Result`, containing either a ``UserSession`` /// if successful, or an `Error` if not. - public func refreshSession(using refreshToken: String, - pdsURL: String? = nil) async throws -> Result { + public func refreshSession( + using refreshToken: String, + pdsURL: String? = nil + ) async throws -> Result { guard let sessionURL = pdsURL != nil ? pdsURL : self.pdsURL, let requestURL = URL(string: "\(sessionURL)/xrpc/com.atproto.server.refreshSession") else { return .failure(ATRequestPrepareError.invalidRequestURL) @@ -274,8 +291,10 @@ public class ATProtocolConfiguration: ProtocolConfiguration { /// - Parameters: /// - accessToken: The access token for the session. /// - pdsURL: The URL of the Personal Data Server (PDS). Defaults to `nil`. - public func deleteSession(using accessToken: String, - pdsURL: String? = nil) async throws { + public func deleteSession( + using accessToken: String, + pdsURL: String? = nil + ) async throws { guard let sessionURL = pdsURL != nil ? pdsURL : self.pdsURL, let requestURL = URL(string: "\(sessionURL)/xrpc/com.atproto.server.deleteSession") else { throw ATRequestPrepareError.invalidRequestURL From 5fc26b2561ff52413216b93c62675a39ff3e7a24 Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Thu, 30 May 2024 20:54:48 -0400 Subject: [PATCH 25/51] Change lexicon methods - Replaced old structs with newer, re-organized structs. - Fixed structs that may have been missed. - Moved RecordQuery to ATProtoTools. --- .../app.bsky/Embed/AppBskyEmbedRecord.swift | 2 +- .../Feed/AppBskyFeedGetAuthorFeed.swift | 2 +- .../Feed/AppBskyFeedGetFeedGenerator.swift | 2 +- .../Feed/AppBskyFeedGetSuggestedFeeds.swift | 2 +- .../Feed/AppBskyFeedGetTimeline.swift | 2 +- .../app.bsky/Feed/AppBskyFeedLike.swift | 6 +- .../app.bsky/Feed/AppBskyFeedPost.swift | 4 +- .../Feed/AppBskyFeedSearchPosts.swift | 38 ++++--- .../Graph/AppBskyGraphUnmuteActor.swift | 2 +- .../Labeler/AppBskyLabelerGetServices.swift | 5 +- .../AppBskyNotificationRegisterPush.swift | 37 +++--- .../AppBskyNotificationUpdateSeen.swift | 2 +- .../Admin/ComAtprotoAdminSearchRepos.swift | 2 +- .../ComAtprotoAdminUpdateAccountEmail.swift | 2 +- .../ComAtprotoAdminUpdateSubjectStatus.swift | 8 +- ...ComAtprotoIdentitySubmitPLCOperation.swift | 2 +- .../ComAtprotoModerationCreateReport.swift | 2 +- .../Repo/ComAtprotoRepoGetRecord.swift | 2 +- .../Repo/ComAtprotoRepoUploadBlob.swift | 2 +- .../Sync/ComAtprotoSyncCrawler.swift | 2 +- .../ToolsOzoneModerationQueryStatuses.swift | 22 ++++ .../CreateCommunicationTemplateAsAdmin.swift | 2 +- .../ATProtoAdmin/DeleteAccountAsAdmin.swift | 2 +- .../DeleteCommunicationTemplateAsAdmin.swift | 2 +- .../DisableAccountInvitesAsAdmin.swift | 2 +- .../DisableInviteCodesAsAdmin.swift | 2 +- .../ATProtoAdmin/EmitEventAsAdmin.swift | 12 +- .../EnableAccountInvitesAsAdmin.swift | 2 +- .../ATProtoAdmin/GetAccountInfoAsAdmin.swift | 6 +- .../ATProtoAdmin/GetAccountInfosAsAdmin.swift | 6 +- .../ATProtoAdmin/GetInviteCodesAsAdmin.swift | 8 +- .../GetModerationEventAsAdmin.swift | 6 +- .../ATProtoAdmin/GetRecordAsAdmin.swift | 6 +- .../ATProtoAdmin/GetRepositoryAsAdmin.swift | 6 +- .../GetSubjectStatusAsAdmin.swift | 6 +- .../ListCommunicationTemplatesAsAdmin.swift | 6 +- .../QueryModerationEventsAsAdmin.swift | 8 +- .../QueryModerationStatusesAsAdmin.swift | 10 +- .../SearchRepositoriesAsAdmin.swift | 6 +- .../ATProtoAdmin/SendEmailAsAdmin.swift | 8 +- .../UpdateAccountEmailAsAdmin.swift | 2 +- .../UpdateAccountHandleAsAdmin.swift | 2 +- .../UpdateAccountPasswordAsAdmin.swift | 2 +- .../UpdateCommunicationTemplateAsAdmin.swift | 8 +- .../UpdateSubjectStatusAsAdmin.swift | 22 ++-- .../Networking/CoreAPI/ApplyWrites.swift | 4 +- .../CoreAPI/CheckAccountStatus.swift | 6 +- .../Networking/CoreAPI/CheckSignupQueue.swift | 6 +- .../Networking/CoreAPI/ConfirmEmail.swift | 2 +- .../CoreAPI/CreateAppPassword.swift | 8 +- .../Networking/CoreAPI/CreateInviteCode.swift | 6 +- .../CoreAPI/CreateInviteCodes.swift | 6 +- .../Networking/CoreAPI/CreateRecord.swift | 8 +- .../Networking/CoreAPI/CreateReport.swift | 12 +- .../CoreAPI/DeactivateAccount.swift | 2 +- .../Networking/CoreAPI/DeleteAccount.swift | 4 +- .../Networking/CoreAPI/DeleteRecord.swift | 2 +- .../CoreAPI/DescribeRepository.swift | 6 +- .../Networking/CoreAPI/DescribeServer.swift | 6 +- .../CoreAPI/GetAccountInviteCodes.swift | 6 +- .../Networking/CoreAPI/GetBlob.swift | 17 +-- .../Networking/CoreAPI/GetLatestCommit.swift | 6 +- .../GetRecommendedDidCredentials.swift | 6 +- .../Networking/CoreAPI/GetRepoRecord.swift | 34 +++--- .../CoreAPI/GetServiceAuthentication.swift | 6 +- .../Networking/CoreAPI/GetSyncBlocks.swift | 4 - .../Networking/CoreAPI/GetSyncRecord.swift | 22 +++- .../Networking/CoreAPI/ImportRepository.swift | 2 +- .../Networking/CoreAPI/ListAppPasswords.swift | 6 +- .../Networking/CoreAPI/ListBlobs.swift | 6 +- .../Networking/CoreAPI/ListMissingBlobs.swift | 6 +- .../Networking/CoreAPI/ListRecords.swift | 6 +- .../Networking/CoreAPI/ListRepositories.swift | 6 +- .../Networking/CoreAPI/NotifyOfUpdate.swift | 2 +- .../Networking/CoreAPI/PutRecord.swift | 8 +- .../Networking/CoreAPI/QueryLabels.swift | 6 +- .../Networking/CoreAPI/RequestCrawl.swift | 2 +- .../CoreAPI/RequestEmailUpdate.swift | 6 +- .../CoreAPI/RequestPasswordReset.swift | 2 +- .../CoreAPI/RequestPhoneVerification.swift | 2 +- .../CoreAPI/ReserveSigningKey.swift | 8 +- .../Networking/CoreAPI/ResetPassword.swift | 2 +- .../Networking/CoreAPI/ResolveHandle.swift | 6 +- .../CoreAPI/RevokeAppPassword.swift | 2 +- .../Networking/CoreAPI/SignPLCOperation.swift | 8 +- .../CoreAPI/SubmitPLCOperation.swift | 17 +-- .../Networking/CoreAPI/UpdateEmail.swift | 2 +- .../Networking/CoreAPI/UpdateHandle.swift | 8 +- .../Networking/PlatformAPI/CreateLike.swift | 13 +-- .../Networking/PlatformAPI/CreatePost.swift | 30 ++--- .../Networking/PlatformAPI/DeleteLike.swift | 16 +-- .../PlatformAPI/DescribeFeedGenerator.swift | 6 +- .../PlatformAPI/GetActorFeeds.swift | 6 +- .../PlatformAPI/GetActorLikes.swift | 6 +- .../PlatformAPI/GetAuthorFeed.swift | 8 +- .../Networking/PlatformAPI/GetFeed.swift | 6 +- .../PlatformAPI/GetFeedGenerator.swift | 6 +- .../PlatformAPI/GetFeedGenerators.swift | 6 +- .../PlatformAPI/GetFeedSkeleton.swift | 7 +- .../Networking/PlatformAPI/GetFollowers.swift | 6 +- .../Networking/PlatformAPI/GetFollows.swift | 6 +- .../PlatformAPI/GetGraphBlocks.swift | 6 +- .../PlatformAPI/GetLabelerServices.swift | 6 +- .../Networking/PlatformAPI/GetLikes.swift | 6 +- .../Networking/PlatformAPI/GetList.swift | 6 +- .../PlatformAPI/GetListBlocks.swift | 6 +- .../Networking/PlatformAPI/GetListFeed.swift | 6 +- .../Networking/PlatformAPI/GetListMutes.swift | 6 +- .../Networking/PlatformAPI/GetLists.swift | 6 +- .../Networking/PlatformAPI/GetMutes.swift | 6 +- .../GetPopularFeedGenerators.swift | 6 +- .../PlatformAPI/GetPostThread.swift | 6 +- .../Networking/PlatformAPI/GetPosts.swift | 6 +- .../PlatformAPI/GetPreferences.swift | 6 +- .../Networking/PlatformAPI/GetProfile.swift | 9 +- .../Networking/PlatformAPI/GetProfiles.swift | 10 +- .../PlatformAPI/GetRelationships.swift | 6 +- .../PlatformAPI/GetRepostedBy.swift | 6 +- .../PlatformAPI/GetSuggestedFeeds.swift | 6 +- .../GetSuggestedFollowsByActor.swift | 6 +- .../PlatformAPI/GetSuggestions.swift | 6 +- .../PlatformAPI/GetSuggestionsSkeleton.swift | 6 +- .../PlatformAPI/GetTaggedSuggestions.swift | 6 +- .../Networking/PlatformAPI/GetTimeline.swift | 6 +- .../PlatformAPI/GetUnreadCount.swift | 6 +- .../PlatformAPI/ListNotifications.swift | 6 +- .../Networking/PlatformAPI/MuteActor.swift | 2 +- .../PlatformAPI/MuteActorList.swift | 2 +- .../PlatformAPI/PutPreferences.swift | 4 +- .../Networking/PlatformAPI/RegisterPush.swift | 4 +- .../PlatformAPI/SearchActorsSkeleton.swift | 6 +- .../Networking/PlatformAPI/SearchPosts.swift | 8 +- .../PlatformAPI/SearchPostsSkeleton.swift | 8 +- .../Networking/PlatformAPI/SearchUsers.swift | 6 +- .../PlatformAPI/SearchUsersTypeahead.swift | 6 +- .../PlatformAPI/SendInteractions.swift | 10 +- .../Networking/PlatformAPI/UnmuteActor.swift | 2 +- .../PlatformAPI/UnmuteActorList.swift | 2 +- .../Networking/PlatformAPI/UpdateSeen.swift | 2 +- .../Utilities/APIClientService.swift | 4 +- .../ATProtoKit/Utilities/ATFacetParser.swift | 32 +++--- .../ATProtoKit/Utilities/ATProtoTools.swift | 105 +++++++++++++++--- 142 files changed, 592 insertions(+), 472 deletions(-) diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedRecord.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedRecord.swift index 452d6ec8e1..0a83050a07 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedRecord.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/AppBskyEmbedRecord.swift @@ -26,7 +26,7 @@ extension AppBskyLexicon.Embed { public let type: String = "app.bsky.embed.record" /// The strong reference of the record. - public let record: StrongReference + public let record: ComAtprotoLexicon.Repository.StrongReference enum CodingKeys: String, CodingKey { case type = "$type" diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetAuthorFeed.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetAuthorFeed.swift index 8b1de79746..d766325229 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetAuthorFeed.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetAuthorFeed.swift @@ -16,7 +16,7 @@ extension AppBskyLexicon.Feed { /// /// - Note: According to the AT Protocol specifications: "Combinations of post/repost types to /// include in response." - public enum GetAuthorFeedFilter: String { + public enum Filter: String { /// Indicates the array of feeds will contain posts with replies. case postsWithReplies = "posts_with_replies" diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeedGenerator.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeedGenerator.swift index e3497076ba..751fe2bbb9 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeedGenerator.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetFeedGenerator.swift @@ -17,7 +17,7 @@ extension AppBskyLexicon.Feed { /// - SeeAlso: This is based on the [`app.bsky.feed.getFeedGenerator`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getFeedGenerator.json - public struct FeedGetFeedGeneratorOutput: Codable { + public struct GetFeedGeneratorOutput: Codable { /// The general information about the feed generator. public let view: GeneratorViewDefinition diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetSuggestedFeeds.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetSuggestedFeeds.swift index 5c86a5cdc3..2869496481 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetSuggestedFeeds.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetSuggestedFeeds.swift @@ -17,7 +17,7 @@ extension AppBskyLexicon.Feed { /// - SeeAlso: This is based on the [`app.bsky.feed.getSuggestedFeeds`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getSuggestedFeeds.json - public struct FeedGetSuggestedFeedsOutput: Codable { + public struct GetSuggestedFeedsOutput: Codable { /// The mark used to indicate the starting point for the next set of result. Optional. public let cursor: String? diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetTimeline.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetTimeline.swift index c33b8e4e96..a0b7cdfdae 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetTimeline.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetTimeline.swift @@ -17,7 +17,7 @@ extension AppBskyLexicon.Feed { /// - SeeAlso: This is based on the [`app.bsky.feed.getTimeline`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getTimeline.json - public struct FeedGetTimelineOutput: Codable { + public struct GetTimelineOutput: Codable { /// The mark used to indicate the starting point for the next set of results. Optional. public let cursor: String? diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedLike.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedLike.swift index afa14e87ea..3f0a13f7bc 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedLike.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedLike.swift @@ -28,14 +28,14 @@ extension AppBskyLexicon.Feed { /// /// - Note: According to the AT Protocol specifications: "Record declaring a 'like' of a /// piece of subject content." - public let subject: StrongReference + public let subject: ComAtprotoLexicon.Repository.StrongReference /// The date the like record was created. /// /// This is the date where the user "liked" a post. @DateFormatting public var createdAt: Date - public init(subject: StrongReference, createdAt: Date) { + public init(subject: ComAtprotoLexicon.Repository.StrongReference, createdAt: Date) { self.subject = subject self._createdAt = DateFormatting(wrappedValue: createdAt) } @@ -43,7 +43,7 @@ extension AppBskyLexicon.Feed { public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) - self.subject = try container.decode(StrongReference.self, forKey: .subject) + self.subject = try container.decode(ComAtprotoLexicon.Repository.StrongReference.self, forKey: .subject) self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue } diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedPost.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedPost.swift index 06d628af65..fbeb5cdff0 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedPost.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedPost.swift @@ -146,13 +146,13 @@ extension AppBskyLexicon.Feed { public struct ReplyReference: Codable { /// The original post of the thread. - public let root: StrongReference + public let root: ComAtprotoLexicon.Repository.StrongReference /// The direct post that the user's post is replying to. /// /// - Note: If `parent` and `root` are identical, the post is a direct reply to the original /// post of the thread. - public let parent: StrongReference + public let parent: ComAtprotoLexicon.Repository.StrongReference } } } diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedSearchPosts.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedSearchPosts.swift index 9e6810b6bf..58e8dfe9b4 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedSearchPosts.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedSearchPosts.swift @@ -9,6 +9,27 @@ import Foundation extension AppBskyLexicon.Feed { + /// The main data model definition for the results of the post search query. + public struct SearchPosts: Codable { + + /// Determines the ranking order for the search results. + /// + /// - Note: According to the AT Protocol specifications: "Specifies the ranking order + /// of results." + /// + /// - SeeAlso: This is based on the [`app.bsky.feed.searchPosts`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/searchPosts.json + public enum SortRanking: String { + + /// Indicates the results will be sorted by the top posts. + case top + + /// Indicates the results will be sorted by the latest posts. + case latest + } + } + /// An output model for the results of the post search query. /// /// - Note: According to the AT Protocol specifications: "Find posts matching search criteria, @@ -34,21 +55,4 @@ extension AppBskyLexicon.Feed { /// An array of post records in the results. public let posts: [PostViewDefinition] } - - /// Determines the ranking order for the search results. - /// - /// - Note: According to the AT Protocol specifications: "Specifies the ranking order - /// of results." - /// - /// - SeeAlso: This is based on the [`app.bsky.feed.searchPosts`][github] lexicon. - /// - /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/searchPosts.json - public enum SortRanking: String { - - /// Indicates the results will be sorted by the top posts. - case top - - /// Indicates the results will be sorted by the latest posts. - case latest - } } diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphUnmuteActor.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphUnmuteActor.swift index 6ecab7847e..ab2a70d151 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphUnmuteActor.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphUnmuteActor.swift @@ -17,7 +17,7 @@ extension AppBskyLexicon.Graph { /// - SeeAlso: This is based on the [`app.bsky.graph.unmuteActor`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/unmuteActor.json - public struct GraphUnmuteActorRequestBody: Codable { + public struct UnmuteActorRequestBody: Codable { /// The decentralized identifier (DID) or handle of a user account. public let actorDID: String diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerGetServices.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerGetServices.swift index 8fc3a49cef..46658e6973 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerGetServices.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerGetServices.swift @@ -17,9 +17,10 @@ extension AppBskyLexicon.Labeler { /// - SeeAlso: This is based on the [`app.bsky.labeler.getServices`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/labeler/getServices.json - public struct LabelerGetServicesOutput: Codable { + public struct GetServicesOutput: Codable { /// A labeler view. - public let views: LabelerViewUnion + public let views: ATUnion.GetServicesOutputViewsUnion + } } diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/AppBskyNotificationRegisterPush.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/AppBskyNotificationRegisterPush.swift index 3bd651400c..61cc08baf1 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/AppBskyNotificationRegisterPush.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/AppBskyNotificationRegisterPush.swift @@ -9,7 +9,25 @@ import Foundation extension AppBskyLexicon.Notification { - /// An output model for registering push notifications. + + /// The main data model definition for registering push notifications. + public struct RegisterPush: Codable { + + /// Represents the platform for the push notifications. + public enum Platform: String, Codable { + + /// Indicates iOS as the platform. + case ios + + /// Indicates Android as the platform. + case android + + /// Indicates the web as the platform. + case web + } + } + + /// A request body model for registering push notifications. /// /// - Note: According to the AT Protocol specifications: "Register to receive /// push notifications, via a specified service, for the requesting account. @@ -18,7 +36,7 @@ extension AppBskyLexicon.Notification { /// - SeeAlso: This is based on the [`app.bsky.notification.registerPush`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/notification/registerPush.json - public struct RegisterPushRequest: Codable { + public struct RegisterPushRequestBody: Codable { /// The decentralized identifier (DID) for the push notification request. public let serviceDID: String @@ -27,24 +45,11 @@ extension AppBskyLexicon.Notification { public let token: String /// The platform for the push notifications. - public let platform: Platform + public let platform: RegisterPush.Platform /// The app ID for the push notification. public let appID: String - /// Represents the platform for the push notifications. - public enum Platform: String, Codable { - - /// Indicates iOS as the platform. - case ios - - /// Indicates Android as the platform. - case android - - /// Indicates the web as the platform. - case web - } - enum CodingKeys: String, CodingKey { case serviceDID = "serviceDid" case token diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/AppBskyNotificationUpdateSeen.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/AppBskyNotificationUpdateSeen.swift index 09556350d5..7b309f2277 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/AppBskyNotificationUpdateSeen.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/AppBskyNotificationUpdateSeen.swift @@ -17,7 +17,7 @@ extension AppBskyLexicon.Notification { /// - SeeAlso: This is based on the [`app.bsky.notification.updateSeen`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/notification/updateSeen.json - public struct NotificationUpdateSeenRequestBody: Codable { + public struct UpdateSeenRequestBody: Codable { /// The date and time the notification was seen by the user account. @DateFormatting public var seenAt: Date diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminSearchRepos.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminSearchRepos.swift index e34ba1897b..c9bb5e5498 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminSearchRepos.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminSearchRepos.swift @@ -17,7 +17,7 @@ extension ComAtprotoLexicon.Admin { /// - SeeAlso: This is based on the [`com.atproto.admin.searchRepos`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/searchRepos.json - public struct AdminSearchReposOutput: Codable { + public struct SearchRepositoriesOutput: Codable { /// The mark used to indicate the starting point for the next set of results. Optional. public let cursor: String? diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminUpdateAccountEmail.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminUpdateAccountEmail.swift index f57c268092..7062b3035d 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminUpdateAccountEmail.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminUpdateAccountEmail.swift @@ -17,7 +17,7 @@ extension ComAtprotoLexicon.Admin { /// - SeeAlso: This is based on the [`com.atproto.admin.updateAccountEmail`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/updateAccountEmail.json - public struct AdminUpdateAccountEmailRequestBody: Codable { + public struct UpdateAccountEmailRequestBody: Codable { /// The decentralized identifier (DID) of the account. public let accountDID: String diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminUpdateSubjectStatus.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminUpdateSubjectStatus.swift index fd952cc6c0..0b0b8e1b41 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminUpdateSubjectStatus.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminUpdateSubjectStatus.swift @@ -17,13 +17,13 @@ extension ComAtprotoLexicon.Admin { /// - SeeAlso: This is based on the [`com.atproto.admin.updateSubjectStatus`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/updateSubjectStatus.json - public struct AdminUpdateSubjectStatusRequestBody: Codable { + public struct UpdateSubjectStatusRequestBody: Codable { /// The subject associated with the subject status. public let subject: ATUnion.AdminUpdateSubjectStatusUnion /// The status attributes of the subject. Optional. - public let takedown: AdminStatusAttributes? + public let takedown: ComAtprotoLexicon.Admin.StatusAttributesDefinition? } /// An output model for updating a subject status of an account, record, or blob. @@ -34,12 +34,12 @@ extension ComAtprotoLexicon.Admin { /// - SeeAlso: This is based on the [`com.atproto.admin.updateSubjectStatus`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/updateSubjectStatus.json - public struct AdminUpdateSubjectStatusOutput: Codable { + public struct UpdateSubjectStatusOutput: Codable { /// The subject associated with the subject status. public let subject: ATUnion.AdminUpdateSubjectStatusUnion /// The status attributes of the subject. Optional. - public let takedown: AdminStatusAttributes? + public let takedown: ComAtprotoLexicon.Admin.StatusAttributesDefinition? } } diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentitySubmitPLCOperation.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentitySubmitPLCOperation.swift index 64af146d22..85ca7e9fc6 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentitySubmitPLCOperation.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentitySubmitPLCOperation.swift @@ -18,7 +18,7 @@ extension ComAtprotoLexicon.Identity { /// - SeeAlso: This is based on the [`com.atproto.identity.submitPlcOperation`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/identity/submitPlcOperation.json - public struct SubmitPLCOperationOutput: Codable { + public struct SubmitPLCOperationRequestBody: Codable { /// The operation itself. public let operation: UnknownType diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Moderation/ComAtprotoModerationCreateReport.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Moderation/ComAtprotoModerationCreateReport.swift index 11f741439c..7ba223fdc5 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Moderation/ComAtprotoModerationCreateReport.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Moderation/ComAtprotoModerationCreateReport.swift @@ -24,7 +24,7 @@ extension ComAtprotoLexicon.Moderation { /// /// - Note: According to the AT Protocol specifications: "Indicates the broad category of /// violation the report is for." - public let reasonType: ModerationReasonType + public let reasonType: ComAtprotoLexicon.Moderation.ReasonTypeDefinition /// Any clarifying comments accompanying the report. Optional. /// diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoGetRecord.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoGetRecord.swift index 40e3f5dc89..d4ea7e8219 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoGetRecord.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoGetRecord.swift @@ -14,7 +14,7 @@ extension ComAtprotoLexicon.Repository { /// - SeeAlso: This is based on the [`com.atproto.repo.getRecord`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/repo/getRecord.json - public struct RecordOutput: Codable { + public struct GetRecordOutput: Codable { /// The URI of the record. public let recordURI: String diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoUploadBlob.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoUploadBlob.swift index 41427fc821..3341c59904 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoUploadBlob.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoUploadBlob.swift @@ -60,7 +60,7 @@ extension ComAtprotoLexicon.Repository { public let type: String? /// The strong reference of the blob. - public let reference: BlobReference + public let reference: ComAtprotoLexicon.Repository.BlobReference /// The the MIME type. /// diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncCrawler.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncCrawler.swift index 6923745a84..9455d5fd0e 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncCrawler.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncCrawler.swift @@ -25,7 +25,7 @@ extension ComAtprotoLexicon.Sync { /// /// [notifyOfUpdate]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/sync/notifyOfUpdate.json /// [requestCrawl]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/sync/requestCrawl.json - public struct SyncCrawler: Codable { + public struct Crawler: Codable { /// The hostname that the crawling service resides in. /// diff --git a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationQueryStatuses.swift b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationQueryStatuses.swift index 34861619ac..0902af4c75 100644 --- a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationQueryStatuses.swift +++ b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationQueryStatuses.swift @@ -9,6 +9,28 @@ import Foundation extension ToolsOzoneLexicon.Moderation { + public struct QueryStatuses: Codable { + + /// Indicates the sorting field for the moderation status array. + public enum SortField: Codable { + + /// Indicates the moderation status array will be sorted by the last reported user. + case lastReportedAt + + /// Indicates the moderation status array will be sorted by the last reviwed user. + case lastReviewedAt + } + + public enum SortDirection: String, Codable { + + /// Indicates the moderation events will be sorted in ascending order. + case ascending = "asc" + + /// Indicates the moderation events will be sorted in descending order. + case descending = "desc" + } + } + /// An output model for listing all moderation events pertaining a subject. /// /// - Note: According to the AT Protocol specifications: "View moderation statuses of subjects diff --git a/Sources/ATProtoKit/Networking/ATProtoAdmin/CreateCommunicationTemplateAsAdmin.swift b/Sources/ATProtoKit/Networking/ATProtoAdmin/CreateCommunicationTemplateAsAdmin.swift index bd131b7df0..6bbe9a6b18 100644 --- a/Sources/ATProtoKit/Networking/ATProtoAdmin/CreateCommunicationTemplateAsAdmin.swift +++ b/Sources/ATProtoKit/Networking/ATProtoAdmin/CreateCommunicationTemplateAsAdmin.swift @@ -45,7 +45,7 @@ extension ATProtoAdmin { return .failure(ATRequestPrepareError.invalidRequestURL) } - let requestBody = CommunicationCreateTemplate( + let requestBody = ToolsOzoneLexicon.Communication.CreateTemplateRequestBody( name: name, contentMarkdown: contentMarkdown, subject: subject, diff --git a/Sources/ATProtoKit/Networking/ATProtoAdmin/DeleteAccountAsAdmin.swift b/Sources/ATProtoKit/Networking/ATProtoAdmin/DeleteAccountAsAdmin.swift index b83b0e48fe..f2a316efd8 100644 --- a/Sources/ATProtoKit/Networking/ATProtoAdmin/DeleteAccountAsAdmin.swift +++ b/Sources/ATProtoKit/Networking/ATProtoAdmin/DeleteAccountAsAdmin.swift @@ -33,7 +33,7 @@ extension ATProtoAdmin { throw ATRequestPrepareError.invalidRequestURL } - let requestBody = AdminDeleteAccount( + let requestBody = ComAtprotoLexicon.Admin.DeleteAccountRequestBody( accountDID: accountDID ) diff --git a/Sources/ATProtoKit/Networking/ATProtoAdmin/DeleteCommunicationTemplateAsAdmin.swift b/Sources/ATProtoKit/Networking/ATProtoAdmin/DeleteCommunicationTemplateAsAdmin.swift index 9b101b8581..eb8a1cfbee 100644 --- a/Sources/ATProtoKit/Networking/ATProtoAdmin/DeleteCommunicationTemplateAsAdmin.swift +++ b/Sources/ATProtoKit/Networking/ATProtoAdmin/DeleteCommunicationTemplateAsAdmin.swift @@ -32,7 +32,7 @@ extension ATProtoAdmin { throw ATRequestPrepareError.invalidRequestURL } - let requestBody = CommunicationDeleteTemplate( + let requestBody = ToolsOzoneLexicon.Communication.DeleteTemplateRequestBody( id: id ) diff --git a/Sources/ATProtoKit/Networking/ATProtoAdmin/DisableAccountInvitesAsAdmin.swift b/Sources/ATProtoKit/Networking/ATProtoAdmin/DisableAccountInvitesAsAdmin.swift index c8589f424b..b8c152af0f 100644 --- a/Sources/ATProtoKit/Networking/ATProtoAdmin/DisableAccountInvitesAsAdmin.swift +++ b/Sources/ATProtoKit/Networking/ATProtoAdmin/DisableAccountInvitesAsAdmin.swift @@ -38,7 +38,7 @@ extension ATProtoAdmin { throw ATRequestPrepareError.invalidRequestURL } - let requestBody = AdminDisableAccountInvites( + let requestBody = ComAtprotoLexicon.Admin.DisableAccountInvitesRequestBody( accountDID: accountDID, note: note ) diff --git a/Sources/ATProtoKit/Networking/ATProtoAdmin/DisableInviteCodesAsAdmin.swift b/Sources/ATProtoKit/Networking/ATProtoAdmin/DisableInviteCodesAsAdmin.swift index 56d2c3448e..49d34ffb45 100644 --- a/Sources/ATProtoKit/Networking/ATProtoAdmin/DisableInviteCodesAsAdmin.swift +++ b/Sources/ATProtoKit/Networking/ATProtoAdmin/DisableInviteCodesAsAdmin.swift @@ -38,7 +38,7 @@ extension ATProtoAdmin { throw ATRequestPrepareError.invalidRequestURL } - let requestBody = AdminDisableInviteCodes( + let requestBody = ComAtprotoLexicon.Admin.DisableInviteCodesRequestBody( codes: codes, accountDIDs: accountDIDs ) diff --git a/Sources/ATProtoKit/Networking/ATProtoAdmin/EmitEventAsAdmin.swift b/Sources/ATProtoKit/Networking/ATProtoAdmin/EmitEventAsAdmin.swift index 6a6589d8d2..f408d71adc 100644 --- a/Sources/ATProtoKit/Networking/ATProtoAdmin/EmitEventAsAdmin.swift +++ b/Sources/ATProtoKit/Networking/ATProtoAdmin/EmitEventAsAdmin.swift @@ -27,14 +27,14 @@ extension ATProtoAdmin { /// - subjectBlobCIDHashes: An array of CID hashes related to blobs for the moderator's /// event view. Optional. /// - createdBy: The decentralized identifier (DID) of the moderator taking this action. - /// - Returns: A `Result`, containing either an ``OzoneModerationEventView`` if successful, + /// - Returns: A `Result`, containing either an ``ToolsOzoneLexicon/Moderation/ModerationEventViewDefinition`` if successful, /// or an `Error` if not. public func emitEvent( - _ event: AdminEventViewUnion, - subject: RepositoryReferencesUnion, + _ event: ATUnion.EmitEventUnion, + subject: ATUnion.EmitEventSubjectUnion, subjectBlobCIDHashes: [String]?, createdBy: String - ) async throws -> Result { + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -45,7 +45,7 @@ extension ATProtoAdmin { return .failure(ATRequestPrepareError.invalidRequestURL) } - let requestBody = ModerationEmitEvent( + let requestBody = ToolsOzoneLexicon.Moderation.EmitEventRequestBody( event: event, subject: subject, subjectBlobCIDHashes: subjectBlobCIDHashes, @@ -60,7 +60,7 @@ extension ATProtoAdmin { authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, withEncodingBody: requestBody, - decodeTo: OzoneModerationEventView.self) + decodeTo: ToolsOzoneLexicon.Moderation.ModerationEventViewDefinition.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/ATProtoAdmin/EnableAccountInvitesAsAdmin.swift b/Sources/ATProtoKit/Networking/ATProtoAdmin/EnableAccountInvitesAsAdmin.swift index 157e9246ac..63478abf07 100644 --- a/Sources/ATProtoKit/Networking/ATProtoAdmin/EnableAccountInvitesAsAdmin.swift +++ b/Sources/ATProtoKit/Networking/ATProtoAdmin/EnableAccountInvitesAsAdmin.swift @@ -41,7 +41,7 @@ extension ATProtoAdmin { throw ATRequestPrepareError.invalidRequestURL } - let requestBody = AdminEnableAccountInvites( + let requestBody = ComAtprotoLexicon.Admin.EnableAccountInvitesRequestBody( accountDID: accountDID, note: note ) diff --git a/Sources/ATProtoKit/Networking/ATProtoAdmin/GetAccountInfoAsAdmin.swift b/Sources/ATProtoKit/Networking/ATProtoAdmin/GetAccountInfoAsAdmin.swift index 2208037cac..c11783ce21 100644 --- a/Sources/ATProtoKit/Networking/ATProtoAdmin/GetAccountInfoAsAdmin.swift +++ b/Sources/ATProtoKit/Networking/ATProtoAdmin/GetAccountInfoAsAdmin.swift @@ -24,9 +24,9 @@ extension ATProtoAdmin { /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/getAccountInfo.json /// /// - Parameter accountDID: The decentralized identifier (DID) of the user account. - /// - Returns: A `Result`, containing either an ``AdminAccountView`` + /// - Returns: A `Result`, containing either an ``ComAtprotoLexicon/Admin/AccountViewDefinition`` /// if successful, or an `Error` if not. - public func getAccountInfo(_ accountDID: String) async throws -> Result { + public func getAccountInfo(_ accountDID: String) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { throw ATRequestPrepareError.missingActiveSession @@ -55,7 +55,7 @@ extension ATProtoAdmin { contentTypeValue: nil, authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, - decodeTo: AdminAccountView.self) + decodeTo: ComAtprotoLexicon.Admin.AccountViewDefinition.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/ATProtoAdmin/GetAccountInfosAsAdmin.swift b/Sources/ATProtoKit/Networking/ATProtoAdmin/GetAccountInfosAsAdmin.swift index 87febf5e75..66ceeec99f 100644 --- a/Sources/ATProtoKit/Networking/ATProtoAdmin/GetAccountInfosAsAdmin.swift +++ b/Sources/ATProtoKit/Networking/ATProtoAdmin/GetAccountInfosAsAdmin.swift @@ -24,9 +24,9 @@ extension ATProtoAdmin { /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/getAccountInfos.json /// /// - Parameter accountDIDs: An array of decentralized identifiers (DIDs) of user accounts. - /// - Returns: A `Result`, containing either an ``AdminGetInviteCodesOutput`` + /// - Returns: A `Result`, containing either an ``ComAtprotoLexicon/Admin/GetAccountInfosOutput`` /// if successful, or an `Error` if not. - public func getAccountInfos(_ accountDIDs: [String]) async throws -> Result { + public func getAccountInfos(_ accountDIDs: [String]) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -53,7 +53,7 @@ extension ATProtoAdmin { contentTypeValue: nil, authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, - decodeTo: AdminGetAccountInfosOutput.self) + decodeTo: ComAtprotoLexicon.Admin.GetAccountInfosOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/ATProtoAdmin/GetInviteCodesAsAdmin.swift b/Sources/ATProtoKit/Networking/ATProtoAdmin/GetInviteCodesAsAdmin.swift index 6bff7c8de5..f0670e4aae 100644 --- a/Sources/ATProtoKit/Networking/ATProtoAdmin/GetInviteCodesAsAdmin.swift +++ b/Sources/ATProtoKit/Networking/ATProtoAdmin/GetInviteCodesAsAdmin.swift @@ -24,12 +24,12 @@ extension ATProtoAdmin { /// - sort: The order the invite codes will be sorted by. Defaults to `.recent`. /// - limit: The number of invite codes in the list. Defaults to `100`. /// - cursor: The mark used to indicate the starting point for the next set of results. Optional. - /// - Returns: A `Result`, containing either an ``AdminGetInviteCodesOutput`` + /// - Returns: A `Result`, containing either an ``ComAtprotoLexicon/Admin/GetInviteCodesOutput`` /// if successful, or an `Error` if not. public func getInviteCodes( - sortedBy sort: AdminGetInviteCodesSort = .recent, + sortedBy sort: ComAtprotoLexicon.Admin.GetInviteCodes.Sort = .recent, withLimitOf limit: Int = 100, - cursor: String?) async throws -> Result { + cursor: String?) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -65,7 +65,7 @@ extension ATProtoAdmin { contentTypeValue: nil, authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, - decodeTo: AdminGetInviteCodesOutput.self) + decodeTo: ComAtprotoLexicon.Admin.GetInviteCodesOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/ATProtoAdmin/GetModerationEventAsAdmin.swift b/Sources/ATProtoKit/Networking/ATProtoAdmin/GetModerationEventAsAdmin.swift index 62248ac450..9527ef7d12 100644 --- a/Sources/ATProtoKit/Networking/ATProtoAdmin/GetModerationEventAsAdmin.swift +++ b/Sources/ATProtoKit/Networking/ATProtoAdmin/GetModerationEventAsAdmin.swift @@ -22,9 +22,9 @@ extension ATProtoAdmin { /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/getEvent.json /// /// - Parameter id: The ID of the moderator event. - /// - Returns: A `Result`, containing either an ``OzoneModerationEventViewDetail`` + /// - Returns: A `Result`, containing either an ``ToolsOzoneLexicon/Moderation/EventViewDetailDefinition`` /// if successful, or an `Error` if not. - public func getEvent(_ id: String) async throws -> Result { + public func getEvent(_ id: String) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -53,7 +53,7 @@ extension ATProtoAdmin { contentTypeValue: nil, authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, - decodeTo: OzoneModerationEventViewDetail.self) + decodeTo: ToolsOzoneLexicon.Moderation.EventViewDetailDefinition.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/ATProtoAdmin/GetRecordAsAdmin.swift b/Sources/ATProtoKit/Networking/ATProtoAdmin/GetRecordAsAdmin.swift index 3115ee1bb3..dcab99fe5d 100644 --- a/Sources/ATProtoKit/Networking/ATProtoAdmin/GetRecordAsAdmin.swift +++ b/Sources/ATProtoKit/Networking/ATProtoAdmin/GetRecordAsAdmin.swift @@ -23,12 +23,12 @@ extension ATProtoAdmin { /// - Parameters: /// - recordURI: The URI of the record. /// - recordCID: The CID hash of the record. Optional. - /// - Returns: A `Result`, containing either an ``OzoneModerationRecordViewDetail`` + /// - Returns: A `Result`, containing either an ``ToolsOzoneLexicon/Moderation/RecordViewDetailDefinition`` /// if successful, or an `Error` if not. public func getRecord( _ recordURI: String, recordCID: String? - ) async throws -> Result { + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -59,7 +59,7 @@ extension ATProtoAdmin { contentTypeValue: nil, authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, - decodeTo: OzoneModerationRecordViewDetail.self) + decodeTo: ToolsOzoneLexicon.Moderation.RecordViewDetailDefinition.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/ATProtoAdmin/GetRepositoryAsAdmin.swift b/Sources/ATProtoKit/Networking/ATProtoAdmin/GetRepositoryAsAdmin.swift index bb38b1b520..44bba1d5d9 100644 --- a/Sources/ATProtoKit/Networking/ATProtoAdmin/GetRepositoryAsAdmin.swift +++ b/Sources/ATProtoKit/Networking/ATProtoAdmin/GetRepositoryAsAdmin.swift @@ -21,9 +21,9 @@ extension ATProtoAdmin { /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/getRepo.json /// /// - Parameter repositoryDID: The decentralized identifier (DID) of the repository. - /// - Returns: A `Result`, containing either an ``OzoneModerationRepositoryView`` + /// - Returns: A `Result`, containing either an ``ToolsOzoneLexicon/Moderation/RepositoryViewDefinition`` /// if successful, or an `Error` if not. - public func getRepository(_ repositoryDID: String) async throws -> Result { + public func getRepository(_ repositoryDID: String) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -50,7 +50,7 @@ extension ATProtoAdmin { contentTypeValue: nil, authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, - decodeTo: OzoneModerationRepositoryView.self) + decodeTo: ToolsOzoneLexicon.Moderation.RepositoryViewDetailDefinition.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/ATProtoAdmin/GetSubjectStatusAsAdmin.swift b/Sources/ATProtoKit/Networking/ATProtoAdmin/GetSubjectStatusAsAdmin.swift index 8bfd543ee3..4699e6b39e 100644 --- a/Sources/ATProtoKit/Networking/ATProtoAdmin/GetSubjectStatusAsAdmin.swift +++ b/Sources/ATProtoKit/Networking/ATProtoAdmin/GetSubjectStatusAsAdmin.swift @@ -25,13 +25,13 @@ extension ATProtoAdmin { /// - subjectDID: The decentralized identifier (DID) of the subject. /// - subjectURI: The URI of the subject. /// - subjectBlobCIDHash: The CID hash of the blob for the subject. - /// - Returns: A `Result`, containing either an ``AdminGetSubjectStatusOutput`` + /// - Returns: A `Result`, containing either an ``ComAtprotoLexicon/Admin/GetSubjectStatusOutput`` /// if successful, or an `Error` if not. public func getSubjectStatus( _ subjectDID: String, subjectURI: String, subjectBlobCIDHash: String - ) async throws -> Result { + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -62,7 +62,7 @@ extension ATProtoAdmin { contentTypeValue: nil, authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, - decodeTo: AdminGetSubjectStatusOutput.self) + decodeTo: ComAtprotoLexicon.Admin.GetSubjectStatusOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/ATProtoAdmin/ListCommunicationTemplatesAsAdmin.swift b/Sources/ATProtoKit/Networking/ATProtoAdmin/ListCommunicationTemplatesAsAdmin.swift index e14f0eee67..2376276537 100644 --- a/Sources/ATProtoKit/Networking/ATProtoAdmin/ListCommunicationTemplatesAsAdmin.swift +++ b/Sources/ATProtoKit/Networking/ATProtoAdmin/ListCommunicationTemplatesAsAdmin.swift @@ -21,9 +21,9 @@ extension ATProtoAdmin { /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/communication/listTemplates.json /// - /// - Returns: A `Result`, containing either an ``CommunicationListTemplatesOutput`` + /// - Returns: A `Result`, containing either an ``ToolsOzoneLexicon/Communication/ListTemplatesOutput`` /// if successful, or an `Error` if not. - public func listCommunicationTemplates() async throws -> Result { + public func listCommunicationTemplates() async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -41,7 +41,7 @@ extension ATProtoAdmin { contentTypeValue: nil, authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, - decodeTo: CommunicationListTemplatesOutput.self) + decodeTo: ToolsOzoneLexicon.Communication.ListTemplatesOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/ATProtoAdmin/QueryModerationEventsAsAdmin.swift b/Sources/ATProtoKit/Networking/ATProtoAdmin/QueryModerationEventsAsAdmin.swift index a0a1afb229..385ff2bca8 100644 --- a/Sources/ATProtoKit/Networking/ATProtoAdmin/QueryModerationEventsAsAdmin.swift +++ b/Sources/ATProtoKit/Networking/ATProtoAdmin/QueryModerationEventsAsAdmin.swift @@ -52,12 +52,12 @@ extension ATProtoAdmin { /// - reportTypes: An array of report types. /// - cursor: The mark used to indicate the starting point for the next set /// of results. Optional. - /// - Returns: A `Result`, containing either an ``ModerationQueryEventsOutput`` + /// - Returns: A `Result`, containing either an ``ToolsOzoneLexicon/Moderation/QueryEventsOutput`` /// if successful, or an `Error` if not. public func queryEvents( _ eventTypes: [String]? = nil, createdBy: String? = nil, - sortDirection: AdminQueryModerationEventSortDirection? = .descending, + sortDirection: ToolsOzoneLexicon.Moderation.QueryEvents.SortDirection? = .descending, createdAfter: Date? = nil, createdBefore: Date? = nil, subject: String? = nil, @@ -71,7 +71,7 @@ extension ATProtoAdmin { removedTags: [String]? = nil, reportTypes: [String]? = nil, cursor: String? = nil - ) async throws -> Result { + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -179,7 +179,7 @@ extension ATProtoAdmin { contentTypeValue: nil, authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, - decodeTo: ModerationQueryEventsOutput.self) + decodeTo: ToolsOzoneLexicon.Moderation.QueryEventsOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/ATProtoAdmin/QueryModerationStatusesAsAdmin.swift b/Sources/ATProtoKit/Networking/ATProtoAdmin/QueryModerationStatusesAsAdmin.swift index 428c55025a..e8c0c1f638 100644 --- a/Sources/ATProtoKit/Networking/ATProtoAdmin/QueryModerationStatusesAsAdmin.swift +++ b/Sources/ATProtoKit/Networking/ATProtoAdmin/QueryModerationStatusesAsAdmin.swift @@ -56,7 +56,7 @@ extension ATProtoAdmin { /// the added tags. Optional. /// - cursor: The mark used to indicate the starting point for the next set of /// results. Optional. - /// - Returns: A `Result`, containing either an ``AdminQueryModerationStatusesOutput`` + /// - Returns: A `Result`, containing either an ``ToolsOzoneLexicon/Moderation/QueryStatusesOutput`` /// if successful, or an `Error` if not. public func queryStatuses( _ subject: String?, @@ -70,15 +70,15 @@ extension ATProtoAdmin { reviewState: String?, ignoreSubjects: [String]?, lastReviewedBy: String?, - sortField: AdminQueryModerationStatusesSortField? = .lastReportedAt, - sortDirection: AdminQueryModerationStatusesSortDirection? = .descending, + sortField: ToolsOzoneLexicon.Moderation.QueryStatuses.SortField? = .lastReportedAt, + sortDirection: ToolsOzoneLexicon.Moderation.QueryStatuses.SortDirection? = .descending, isTakenDown: Bool?, isAppealed: Bool?, limit: Int? = 50, tags: [String]?, excludeTags: [String]?, cursor: String? - ) async throws -> Result { + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -192,7 +192,7 @@ extension ATProtoAdmin { contentTypeValue: nil, authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, - decodeTo: AdminQueryModerationStatusesOutput.self) + decodeTo: ToolsOzoneLexicon.Moderation.QueryStatusesOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/ATProtoAdmin/SearchRepositoriesAsAdmin.swift b/Sources/ATProtoKit/Networking/ATProtoAdmin/SearchRepositoriesAsAdmin.swift index 3bbc4524a3..10c28e6c6b 100644 --- a/Sources/ATProtoKit/Networking/ATProtoAdmin/SearchRepositoriesAsAdmin.swift +++ b/Sources/ATProtoKit/Networking/ATProtoAdmin/SearchRepositoriesAsAdmin.swift @@ -26,13 +26,13 @@ extension ATProtoAdmin { /// choose between `1` and `100`. /// - cursor: The mark used to indicate the starting point for the next set of /// results. Optional. - /// - Returns: A `Result`, containing either an ``AdminSearchReposOutput`` + /// - Returns: A `Result`, containing either an ``ComAtprotoLexicon/Admin/SearchRepositoriesOutput`` /// if successful, or an `Error` if not. public func searchRepositories( _ query: String?, withLimitOf limit: Int? = 50, cursor: String? - ) async throws -> Result { + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -72,7 +72,7 @@ extension ATProtoAdmin { contentTypeValue: nil, authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, - decodeTo: AdminSearchReposOutput.self) + decodeTo: ComAtprotoLexicon.Admin.SearchRepositoriesOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/ATProtoAdmin/SendEmailAsAdmin.swift b/Sources/ATProtoKit/Networking/ATProtoAdmin/SendEmailAsAdmin.swift index 6625bce11d..eade72f31b 100644 --- a/Sources/ATProtoKit/Networking/ATProtoAdmin/SendEmailAsAdmin.swift +++ b/Sources/ATProtoKit/Networking/ATProtoAdmin/SendEmailAsAdmin.swift @@ -27,7 +27,7 @@ extension ATProtoAdmin { /// - content: The content of the email. /// - senderDID: The decentralized identifier (DID) of the sender. /// - comment: Any additional comments viewable to other moderators and administrators. - /// - Returns: A `Result`, containing either an ``AdminSendEmailOutput`` + /// - Returns: A `Result`, containing either an ``ComAtprotoLexicon/Admin/SendEmailOutput`` /// if successful, or an `Error` if not. public func sendEmail( to recipientDID: String, @@ -35,7 +35,7 @@ extension ATProtoAdmin { content: String, senderDID: String, comment: String? - ) async throws -> Result { + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -46,7 +46,7 @@ extension ATProtoAdmin { return .failure(ATRequestPrepareError.invalidRequestURL) } - let requestBody = AdminSendEmail( + let requestBody = ComAtprotoLexicon.Admin.SendEmailRequestBody( recipientDID: recipientDID, content: content, subject: subjectLine, @@ -62,7 +62,7 @@ extension ATProtoAdmin { authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, withEncodingBody: requestBody, - decodeTo: AdminSendEmailOutput.self) + decodeTo: ComAtprotoLexicon.Admin.SendEmailOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/ATProtoAdmin/UpdateAccountEmailAsAdmin.swift b/Sources/ATProtoKit/Networking/ATProtoAdmin/UpdateAccountEmailAsAdmin.swift index 6ed83b3a34..14b60574ff 100644 --- a/Sources/ATProtoKit/Networking/ATProtoAdmin/UpdateAccountEmailAsAdmin.swift +++ b/Sources/ATProtoKit/Networking/ATProtoAdmin/UpdateAccountEmailAsAdmin.swift @@ -38,7 +38,7 @@ extension ATProtoAdmin { throw ATRequestPrepareError.invalidRequestURL } - let requestBody = AdminUpdateAccountEmail( + let requestBody = ComAtprotoLexicon.Admin.UpdateAccountEmailRequestBody( accountDID: accountDID, accountEmail: newEmail ) diff --git a/Sources/ATProtoKit/Networking/ATProtoAdmin/UpdateAccountHandleAsAdmin.swift b/Sources/ATProtoKit/Networking/ATProtoAdmin/UpdateAccountHandleAsAdmin.swift index a411c832ca..d2ddac7fa9 100644 --- a/Sources/ATProtoKit/Networking/ATProtoAdmin/UpdateAccountHandleAsAdmin.swift +++ b/Sources/ATProtoKit/Networking/ATProtoAdmin/UpdateAccountHandleAsAdmin.swift @@ -38,7 +38,7 @@ extension ATProtoAdmin { throw ATRequestPrepareError.invalidRequestURL } - let requestBody = AdminUpdateAccountHandle( + let requestBody = ComAtprotoLexicon.Admin.UpdateAccountHandleRequestBody( accountDID: accountDID, accountHandle: newAccountHandle ) diff --git a/Sources/ATProtoKit/Networking/ATProtoAdmin/UpdateAccountPasswordAsAdmin.swift b/Sources/ATProtoKit/Networking/ATProtoAdmin/UpdateAccountPasswordAsAdmin.swift index f3df429244..9628213c3d 100644 --- a/Sources/ATProtoKit/Networking/ATProtoAdmin/UpdateAccountPasswordAsAdmin.swift +++ b/Sources/ATProtoKit/Networking/ATProtoAdmin/UpdateAccountPasswordAsAdmin.swift @@ -35,7 +35,7 @@ extension ATProtoAdmin { throw ATRequestPrepareError.invalidRequestURL } - let requestBody = AdminUpdateAccountPassword( + let requestBody = ComAtprotoLexicon.Admin.UpdateAccountPasswordRequestBody( accountDID: accountDID, newPassword: newPassword ) diff --git a/Sources/ATProtoKit/Networking/ATProtoAdmin/UpdateCommunicationTemplateAsAdmin.swift b/Sources/ATProtoKit/Networking/ATProtoAdmin/UpdateCommunicationTemplateAsAdmin.swift index c493a32cff..0b1fca1939 100644 --- a/Sources/ATProtoKit/Networking/ATProtoAdmin/UpdateCommunicationTemplateAsAdmin.swift +++ b/Sources/ATProtoKit/Networking/ATProtoAdmin/UpdateCommunicationTemplateAsAdmin.swift @@ -29,7 +29,7 @@ extension ATProtoKit { /// - updatedBy: The decentralized identifier (DID) of the user who updated the /// communication template. Optional. /// - isDisabled: Indicates whether the communication template is disabled. Optional. - /// - Returns: A `Result`, containing either an ``OzoneCommunicationTemplateView`` + /// - Returns: A `Result`, containing either an ``ToolsOzoneLexicon/Communication/TemplateViewDefinition`` /// if successful, or an `Error` if not. public func updateCommunicationTemplate( _ id: String, @@ -38,7 +38,7 @@ extension ATProtoKit { subject: String?, updatedBy: String?, isDisabled: Bool? - ) async throws -> Result { + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -49,7 +49,7 @@ extension ATProtoKit { return .failure(ATRequestPrepareError.invalidRequestURL) } - let requestBody = CommunicationUpdateTemplate( + let requestBody = ToolsOzoneLexicon.Communication.UpdateTemplateRequestBody( id: id, name: name, contentMarkdown: contentMarkdown, @@ -66,7 +66,7 @@ extension ATProtoKit { authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, withEncodingBody: requestBody, - decodeTo: OzoneCommunicationTemplateView.self) + decodeTo: ToolsOzoneLexicon.Communication.TemplateViewDefinition.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/ATProtoAdmin/UpdateSubjectStatusAsAdmin.swift b/Sources/ATProtoKit/Networking/ATProtoAdmin/UpdateSubjectStatusAsAdmin.swift index 681c610f68..8025c3ad32 100644 --- a/Sources/ATProtoKit/Networking/ATProtoAdmin/UpdateSubjectStatusAsAdmin.swift +++ b/Sources/ATProtoKit/Networking/ATProtoAdmin/UpdateSubjectStatusAsAdmin.swift @@ -10,24 +10,26 @@ import Foundation extension ATProtoAdmin { /// Updates a subject status of an account, record, or blob. - /// + /// /// - Important: This is an administrator task and as such, regular users won't be able to /// access this; if they attempt to do so, an error will occur. - /// + /// /// - Note: According to the AT Protocol specifications: "Update the service-specific admin /// status of a subject (account, record, or blob)." - /// + /// /// - SeeAlso: This is based on the [`com.atproto.admin.updateSubjectStatus`][github] lexicon. - /// + /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/updateSubjectStatus.json - /// + /// /// - Parameters: /// - subject: The subject associated with the subject status. /// - takedown: The status attributes of the subject. Optional. + /// - Returns: A `Result`, containing either an ``ComAtprotoLexicon`` + /// if successful, or an `Error` if not. public func updateSubjectStatusAsAdmin( - _ subject: AdminGetSubjectStatusUnion, - takedown: AdminStatusAttributes? - ) async throws -> Result { + _ subject: ATUnion.AdminUpdateSubjectStatusUnion, + takedown: ComAtprotoLexicon.Admin.StatusAttributesDefinition? + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -38,7 +40,7 @@ extension ATProtoAdmin { return .failure(ATRequestPrepareError.invalidRequestURL) } - let requestBody = AdminUpdateSubjectStatus( + let requestBody = ComAtprotoLexicon.Admin.UpdateSubjectStatusRequestBody( subject: subject, takedown: takedown ) @@ -51,7 +53,7 @@ extension ATProtoAdmin { authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, withEncodingBody: requestBody, - decodeTo: AdminUpdateSubjectStatusOutput.self) + decodeTo: ComAtprotoLexicon.Admin.UpdateSubjectStatusOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/CoreAPI/ApplyWrites.swift b/Sources/ATProtoKit/Networking/CoreAPI/ApplyWrites.swift index a2af66c8b7..daeeb388c1 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/ApplyWrites.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/ApplyWrites.swift @@ -26,7 +26,7 @@ extension ATProtoKit { public func applyWrites( _ repositoryDID: String, shouldValidate: Bool? = true, - writes: [ApplyWritesUnion], + writes: [ATUnion.ApplyWritesUnion], swapCommit: String? ) async throws { guard session != nil, @@ -39,7 +39,7 @@ extension ATProtoKit { throw ATRequestPrepareError.invalidRequestURL } - let requestBody = RepoApplyWrites( + let requestBody = ComAtprotoLexicon.Repository.ApplyWritesRequestBody( repositoryDID: repositoryDID, shouldValidate: shouldValidate, writes: writes, diff --git a/Sources/ATProtoKit/Networking/CoreAPI/CheckAccountStatus.swift b/Sources/ATProtoKit/Networking/CoreAPI/CheckAccountStatus.swift index f0e6a05de8..f9d86b2315 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/CheckAccountStatus.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/CheckAccountStatus.swift @@ -19,9 +19,9 @@ extension ATProtoKit { /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/checkAccountStatus.json /// - /// - Returns: A `Result`, containing either ``ServerCheckAccountStatusOutput`` + /// - Returns: A `Result`, containing either ``ComAtprotoLexicon/Server/CheckAccountStatusOutput`` /// if successful, or an `Error` if not. - public func checkAccountStatus() async throws -> Result { + public func checkAccountStatus() async throws -> Result { guard let sessionURL = session?.pdsURL, let requestURL = URL(string: "\(sessionURL)/xrpc/com.atproto.server.checkAccountStatus") else { return .failure(ATRequestPrepareError.invalidRequestURL) @@ -33,7 +33,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: nil) let response = try await APIClientService.sendRequest(request, - decodeTo: ServerCheckAccountStatusOutput.self) + decodeTo: ComAtprotoLexicon.Server.CheckAccountStatusOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/CoreAPI/CheckSignupQueue.swift b/Sources/ATProtoKit/Networking/CoreAPI/CheckSignupQueue.swift index 8f6e3f920a..87c77b1318 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/CheckSignupQueue.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/CheckSignupQueue.swift @@ -21,9 +21,9 @@ extension ATProtoKit { /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/temp/checkSignupQueue.json /// /// - Parameter query: The string used to search for the username. - /// - Returns: A `Result`, containing either a ``TempCheckSignupQueueOutput`` + /// - Returns: A `Result`, containing either a ``ComAtprotoLexicon/Temp/CheckSignupQueueOutput`` /// if successful, ot an `Error` if not. - public func checkSignupQueue(for query: String) async throws -> Result { + public func checkSignupQueue(for query: String) async throws -> Result { guard let sessionURL = session?.pdsURL, let requestURL = URL(string: "\(sessionURL)/xrpc/com.atproto.temp.checkSignupQueue") else { return .failure(ATRequestPrepareError.invalidRequestURL) @@ -47,7 +47,7 @@ extension ATProtoKit { contentTypeValue: "application/json", authorizationValue: nil) let response = try await APIClientService.sendRequest(request, - decodeTo: TempCheckSignupQueueOutput.self) + decodeTo: ComAtprotoLexicon.Temp.CheckSignupQueueOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/CoreAPI/ConfirmEmail.swift b/Sources/ATProtoKit/Networking/CoreAPI/ConfirmEmail.swift index d714df56e1..5dae2e0dd5 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/ConfirmEmail.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/ConfirmEmail.swift @@ -42,7 +42,7 @@ extension ATProtoKit { throw ATRequestPrepareError.invalidRequestURL } - let requestBody = ServerConfirmEmail( + let requestBody = ComAtprotoLexicon.Server.ConfirmEmailRequestBody( email: email, token: token ) diff --git a/Sources/ATProtoKit/Networking/CoreAPI/CreateAppPassword.swift b/Sources/ATProtoKit/Networking/CoreAPI/CreateAppPassword.swift index b17e5ae8ce..c062a4b0f3 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/CreateAppPassword.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/CreateAppPassword.swift @@ -23,9 +23,9 @@ extension ATProtoKit { /// /// - Parameter passwordName: The name given to the App Password to help distingush it /// from others. - /// - Returns: A `Result`, either containing a ``ServerCreateAppPasswordOutput`` + /// - Returns: A `Result`, either containing a ``ComAtprotoLexicon/Server/CreateAppPasswordOutput`` /// if successful, or an `Error` if not. - public func createAppPassword(named passwordName: String) async throws -> Result { + public func createAppPassword(named passwordName: String) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -36,7 +36,7 @@ extension ATProtoKit { return .failure(ATRequestPrepareError.invalidRequestURL) } - let requestBody = ServerCreateAppPassword( + let requestBody = ComAtprotoLexicon.Server.CreateAppPasswordRequestBody( name: passwordName ) @@ -48,7 +48,7 @@ extension ATProtoKit { authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, withEncodingBody: requestBody, - decodeTo: ServerCreateAppPasswordOutput.self) + decodeTo: ComAtprotoLexicon.Server.CreateAppPasswordOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/CoreAPI/CreateInviteCode.swift b/Sources/ATProtoKit/Networking/CoreAPI/CreateInviteCode.swift index fd2f7e3249..b3c780b295 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/CreateInviteCode.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/CreateInviteCode.swift @@ -24,12 +24,12 @@ extension ATProtoKit { /// - codeCount: The number of invite codes to be created. Defaults to 1. /// - forAccount: The decentralized identifier (DIDs) of the user that can use the /// invite code. Optional. - /// - Returns: A `Result`, containing either a ``ServerCreateInviteCodeOutput`` + /// - Returns: A `Result`, containing either a ``ComAtprotoLexicon/Server/CreateInviteCodeOutput`` /// if successful, or an `Error` if not. public func createInviteCode( _ codeCount: Int = 1, for account: [String] - ) async throws -> Result { + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -54,7 +54,7 @@ extension ATProtoKit { authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, withEncodingBody: requestBody, - decodeTo: ServerCreateInviteCodeOutput.self) + decodeTo: ComAtprotoLexicon.Server.CreateInviteCodeOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/CoreAPI/CreateInviteCodes.swift b/Sources/ATProtoKit/Networking/CoreAPI/CreateInviteCodes.swift index 6efedb38d4..c5812d5308 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/CreateInviteCodes.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/CreateInviteCodes.swift @@ -21,12 +21,12 @@ extension ATProtoKit { /// - codeCount: The number of invite codes to be created. Defaults to `1`. /// - forAccounts: An array of decentralized identifiers (DIDs) that can use the /// invite codes. - /// - Returns: A `Result`, containing either a ``ServerCreateInviteCodesOutput`` + /// - Returns: A `Result`, containing either a ``ComAtprotoLexicon/Server/CreateInviteCodesOutput`` /// if successful, or an `Error` if not. public func createInviteCodes( _ codeCount: Int = 1, for accounts: [String] - ) async throws -> Result { + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -51,7 +51,7 @@ extension ATProtoKit { authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, withEncodingBody: requestBody, - decodeTo: ServerCreateInviteCodesOutput.self) + decodeTo: ComAtprotoLexicon.Server.CreateInviteCodesOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/CoreAPI/CreateRecord.swift b/Sources/ATProtoKit/Networking/CoreAPI/CreateRecord.swift index e42d4f7243..d6f93687f3 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/CreateRecord.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/CreateRecord.swift @@ -29,7 +29,7 @@ extension ATProtoKit { /// - shouldValidate: ndicates whether the record should be validated. Optional. Defaults to `true`. /// - record: The record itself. /// - swapCommit: Swaps out an operation based on the CID. Optional. - /// - Returns: A `Result`, containing either a ``StrongReference`` + /// - Returns: A `Result`, containing either a ``ComAtprotoLexicon/Repository/StrongReference`` /// if successful, and an `Error` if not. public func createRecord( repositoryDID: String, @@ -38,7 +38,7 @@ extension ATProtoKit { shouldValidate: Bool? = true, record: UnknownType, swapCommit: String? = nil - ) async -> Result { + ) async -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -49,7 +49,7 @@ extension ATProtoKit { return .failure(ATRequestPrepareError.invalidRequestURL) } - let requestBody = RepoCreateRecord( + let requestBody = ComAtprotoLexicon.Repository.CreateRecordRequestBody( repositoryDID: repositoryDID, collection: collection, recordKey: recordKey, @@ -66,7 +66,7 @@ extension ATProtoKit { authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, withEncodingBody: requestBody, - decodeTo: StrongReference.self) + decodeTo: ComAtprotoLexicon.Repository.StrongReference.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/CoreAPI/CreateReport.swift b/Sources/ATProtoKit/Networking/CoreAPI/CreateReport.swift index c4d5ff18a8..f1c3332a32 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/CreateReport.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/CreateReport.swift @@ -23,13 +23,13 @@ extension ATProtoAdmin { /// - reasonType: The reason for the report. /// - reason: Any additional context accompanying the report. Optional. /// - subject: The responsible party being reported. - /// - Returns: A `Result`, containing either ``ModerationCreateReportOutput`` + /// - Returns: A `Result`, containing either ``ComAtprotoLexicon/Moderation/CreateReportOutput`` /// if successful, or an `Error` if not. public func createReport( - with reasonType: ModerationReasonType, + with reasonType: ComAtprotoLexicon.Moderation.ReasonTypeDefinition, withContextof reason: String?, - subject: RepositoryReferencesUnion - ) async throws -> Result { + subject: ATUnion.CreateReportSubjectUnion + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -40,7 +40,7 @@ extension ATProtoAdmin { return .failure(ATRequestPrepareError.invalidRequestURL) } - let requestBody = ModerationCreateReport( + let requestBody = ComAtprotoLexicon.Moderation.CreateReportRequestBody( reasonType: reasonType, reason: reason, subject: subject @@ -54,7 +54,7 @@ extension ATProtoAdmin { authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, withEncodingBody: requestBody, - decodeTo: ModerationCreateReportOutput.self) + decodeTo: ComAtprotoLexicon.Moderation.CreateReportOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/CoreAPI/DeactivateAccount.swift b/Sources/ATProtoKit/Networking/CoreAPI/DeactivateAccount.swift index 5327490751..9e7d87165e 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/DeactivateAccount.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/DeactivateAccount.swift @@ -35,7 +35,7 @@ extension ATProtoKit { throw ATRequestPrepareError.invalidRequestURL } - let requestBody = ServerDeactivateAccount( + let requestBody = ComAtprotoLexicon.Server.DeactivateAccountRequestBody( deleteAfter: date ) diff --git a/Sources/ATProtoKit/Networking/CoreAPI/DeleteAccount.swift b/Sources/ATProtoKit/Networking/CoreAPI/DeleteAccount.swift index 00c19d40ec..0e5f2458ea 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/DeleteAccount.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/DeleteAccount.swift @@ -18,7 +18,7 @@ extension ATProtoKit { /// /// - SeeAlso: This is based on the [`com.atproto.server.deleteAccount`][github] lexicon. /// - /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/deleteAccount.json + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/deleteAccount.json /// /// - Parameters: /// - accountDID: The decentralized identifier (DID) of the user account to be deleted. @@ -39,7 +39,7 @@ extension ATProtoKit { throw ATRequestPrepareError.invalidRequestURL } - let requestBody = ServerDeleteAccount( + let requestBody = ComAtprotoLexicon.Server.DeleteAccountRequestBody( accountDID: accountDID, accountPassword: password, token: token diff --git a/Sources/ATProtoKit/Networking/CoreAPI/DeleteRecord.swift b/Sources/ATProtoKit/Networking/CoreAPI/DeleteRecord.swift index 43930a8760..df9a339f8e 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/DeleteRecord.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/DeleteRecord.swift @@ -43,7 +43,7 @@ extension ATProtoKit { throw ATRequestPrepareError.invalidRequestURL } - let requestBody = RepoDeleteRecord( + let requestBody = ComAtprotoLexicon.Repository.DeleteRecordRequestBody( repositoryDID: repositoryDID, collection: collection, recordKey: recordKey, diff --git a/Sources/ATProtoKit/Networking/CoreAPI/DescribeRepository.swift b/Sources/ATProtoKit/Networking/CoreAPI/DescribeRepository.swift index 3aa2c79946..567901ea1e 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/DescribeRepository.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/DescribeRepository.swift @@ -19,12 +19,12 @@ extension ATProtoKit { /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/repo/describeRepo.json /// /// - Parameter repositoryDID: The decentralized identifier (DID) or handle of the repository. - /// - Returns: A `Result`, containing either a ``RepoDescribeRepoOutput`` + /// - Returns: A `Result`, containing either a ``ComAtprotoLexicon/Repository/DescribeRepositoryOutput`` /// if successful, ot an `Error` if not. public func describeRepository( _ repositoryDID: String, pdsURL: String? = nil - ) async throws -> Result { + ) async throws -> Result { guard let sessionURL = pdsURL != nil ? pdsURL : session?.pdsURL, let requestURL = URL(string: "\(sessionURL)/xrpc/com.atproto.repo.describeRepo") else { return .failure(ATRequestPrepareError.invalidRequestURL) @@ -48,7 +48,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: nil) let response = try await APIClientService.sendRequest(request, - decodeTo: RepoDescribeRepoOutput.self) + decodeTo: ComAtprotoLexicon.Repository.DescribeRepositoryOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/CoreAPI/DescribeServer.swift b/Sources/ATProtoKit/Networking/CoreAPI/DescribeServer.swift index ea8efe189e..1da30c513b 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/DescribeServer.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/DescribeServer.swift @@ -19,9 +19,9 @@ extension ATProtoKit { /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/describeServer.json /// /// - Parameter pdsURL: The URL of the Personal Data Server (PDS). Defaults to `nil`. - /// - Returns: A `Result`, containing either a ``ServerDescribeServerOutput`` + /// - Returns: A `Result`, containing either a ``ComAtprotoLexicon/Server/DescribeServerOutput`` /// if successful, or an `Error` if not. - public func describeServer(_ pdsURL: String? = nil) async throws -> Result { + public func describeServer(_ pdsURL: String? = nil) async throws -> Result { guard let sessionURL = pdsURL != nil ? pdsURL : session?.pdsURL, let requestURL = URL(string: "\(sessionURL)/xrpc/com.atproto.server.describeServer") else { return .failure(ATRequestPrepareError.invalidRequestURL) @@ -34,7 +34,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: nil) let response = try await APIClientService.sendRequest(request, - decodeTo: ServerDescribeServerOutput.self) + decodeTo: ComAtprotoLexicon.Server.DescribeServerOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/CoreAPI/GetAccountInviteCodes.swift b/Sources/ATProtoKit/Networking/CoreAPI/GetAccountInviteCodes.swift index bd7cbff7fc..5b3273e7f7 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/GetAccountInviteCodes.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/GetAccountInviteCodes.swift @@ -23,12 +23,12 @@ extension ATProtoKit { /// be included in the list. Optional. Defaults to `true`. /// - areEarnedCodesIncluded: Indicates whether the invite codes that the user earned should /// be included in the list. Optional. Defaults to `true`. - /// - Returns: A `Result`, containing either ``ServerGetAccountInviteCodesOutput`` + /// - Returns: A `Result`, containing either ``ComAtprotoLexicon/Server/GetAccountInviteCodesOutput`` /// if successful, and an `Error` if not. public func getAccountInviteCodes( _ areUsedCodesIncluded: Bool = true, areEarnedCodesIncluded: Bool = true - ) async throws -> Result { + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -58,7 +58,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, - decodeTo: ServerGetAccountInviteCodesOutput.self) + decodeTo: ComAtprotoLexicon.Server.GetAccountInviteCodesOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/CoreAPI/GetBlob.swift b/Sources/ATProtoKit/Networking/CoreAPI/GetBlob.swift index f8dd89802f..b075aa73d9 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/GetBlob.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/GetBlob.swift @@ -10,19 +10,22 @@ import Foundation extension ATProtoKit { /// Retrieves a blob from a given record. - /// + /// /// - Note: According to the AT Protocol specifications: "Get a blob associated with a given /// account. Returns the full blob as originally uploaded. Does not require auth; implemented /// by PDS." - /// + /// /// - SeeAlso: This is based on the [`com.atproto.sync.getBlob`][github] lexicon. - /// + /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/sync/getBlob.json /// - /// - Parameter blobQuery: An object containing the `accountDID` and `cidHash` of the blob. + /// - Parameter accountDID: The decentralized identifier (DID) of the account. + /// - Parameter cidHash: The CID hash of the blob. + /// - Parameter pdsURL: The URL of the Personal Data Server (PDS). Defaults to `https://bsky.social`. /// - Returns: A `Result` containing `Data` on success or `Error` on failure. public static func getBlob( - from blobQuery: BlobQuery, + from accountDID: String, + cidHash: String, pdsURL: String? = "https://bsky.social" ) async -> Result { guard let sessionURL = pdsURL, @@ -31,8 +34,8 @@ extension ATProtoKit { } let queryItems = [ - ("did", blobQuery.accountDID), - ("cid", blobQuery.cidHash) + ("did", accountDID), + ("cid", cidHash) ] let queryURL: URL diff --git a/Sources/ATProtoKit/Networking/CoreAPI/GetLatestCommit.swift b/Sources/ATProtoKit/Networking/CoreAPI/GetLatestCommit.swift index 991a759d8e..19196e97f0 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/GetLatestCommit.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/GetLatestCommit.swift @@ -21,12 +21,12 @@ extension ATProtoKit { /// - Parameters: /// - repositoryDID: The decentralized identifier (DID) of the repository. /// - pdsURL: The URL of the Personal Data Server (PDS). Defaults to `nil`. - /// - Returns: A `Result`, containing either a ``SyncGetBlocksOutput`` + /// - Returns: A `Result`, containing either a ``ComAtprotoLexicon/Sync/GetLatestCommitOutput`` /// if successful, or an `Error` if not. public func getLatestCommit( from repositoryDID: String, pdsURL: String? = nil - ) async throws -> Result { + ) async throws -> Result { guard let sessionURL = pdsURL != nil ? pdsURL : session?.pdsURL, let requestURL = URL(string: "\(sessionURL)/xrpc/com.atproto.sync.getLatestCommit") else { return .failure(ATRequestPrepareError.invalidRequestURL) @@ -50,7 +50,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: nil) let response = try await APIClientService.sendRequest(request, - decodeTo: SyncGetLatestCommitOutput.self) + decodeTo: ComAtprotoLexicon.Sync.GetLatestCommitOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/CoreAPI/GetRecommendedDidCredentials.swift b/Sources/ATProtoKit/Networking/CoreAPI/GetRecommendedDidCredentials.swift index a8ffca3fa5..2752943225 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/GetRecommendedDidCredentials.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/GetRecommendedDidCredentials.swift @@ -19,9 +19,9 @@ extension ATProtoKit { /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/identity/getRecommendedDidCredentials.json /// - /// - Returns: A `Result`, containing either an ``IdentityGetRecommendedDidCredentialsOutput`` + /// - Returns: A `Result`, containing either an ``ComAtprotoLexicon/Identity/GetRecommendedDidCredentialsOutput`` /// if successful, or an `Error` if not. - public func getRecommendedDIDCredentials() async throws -> Result { + public func getRecommendedDIDCredentials() async throws -> Result { guard let sessionURL = session?.pdsURL, let requestURL = URL(string: "\(sessionURL)/xrpc/com.atproto.identity.getRecommendedDidCredentials") else { return .failure(ATRequestPrepareError.invalidRequestURL) @@ -34,7 +34,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: nil) let response = try await APIClientService.sendRequest(request, decodeTo: - IdentityGetRecommendedDidCredentialsOutput.self) + ComAtprotoLexicon.Identity.GetRecommendedDidCredentialsOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/CoreAPI/GetRepoRecord.swift b/Sources/ATProtoKit/Networking/CoreAPI/GetRepoRecord.swift index 1216e5c84b..8f619b2880 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/GetRepoRecord.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/GetRepoRecord.swift @@ -10,36 +10,42 @@ import Foundation extension ATProtoKit { /// Searches for and validates a record from the repository. - /// + /// /// - Note: According to the AT Protocol specifications: "Get a single record from a /// repository. Does not require auth." - /// + /// /// - SeeAlso: This is based on the [`com.atproto.repo.getRecord`][github] lexicon. - /// + /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/repo/getRecord.json - /// + /// /// - Parameters: - /// - recordQuery: The record object. + /// - repository: The repository that owns the record. + /// - collection: The Namespaced Identifier (NSID) of the record. + /// - recordKey: The record key of the record. + /// - recordCID: The CID hash of the record. Optional. /// - pdsURL: The URL of the Personal Data Server (PDS). - /// - Returns: A `Result`, which either contains a ``RecordOutput`` + /// - Returns: A `Result`, which either contains a ``ComAtprotoLexicon/Repository/GetRecordOutput`` /// if successful, and an `Error` if not. public func getRepositoryRecord( - from recordQuery: RecordQuery, + from repository: String, + collection: String, + recordKey: String, + recordCID: String? = nil, pdsURL: String? = nil - ) async throws -> Result { + ) async throws -> Result { guard let sessionURL = pdsURL != nil ? pdsURL : session?.pdsURL, let requestURL = URL(string: "\(sessionURL)/xrpc/com.atproto.repo.getRecord") else { return .failure(ATRequestPrepareError.invalidRequestURL) } var queryItems = [ - ("repo", recordQuery.repo), - ("collection", recordQuery.collection), - ("rkey", recordQuery.recordKey) + ("repo", repository), + ("collection", collection), + ("rkey", recordKey) ] - if let cid = recordQuery.recordCID { - queryItems.append(("cid", cid)) + if let recordCID { + queryItems.append(("cid", recordCID)) } let queryURL: URL @@ -54,7 +60,7 @@ extension ATProtoKit { andMethod: .get, authorizationValue: nil) let response = try await APIClientService.sendRequest(request, - decodeTo: RecordOutput.self) + decodeTo: ComAtprotoLexicon.Repository.GetRecordOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/CoreAPI/GetServiceAuthentication.swift b/Sources/ATProtoKit/Networking/CoreAPI/GetServiceAuthentication.swift index d83f4e6e70..9acb1e2343 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/GetServiceAuthentication.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/GetServiceAuthentication.swift @@ -19,9 +19,9 @@ extension ATProtoKit { /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/getServiceAuth.json /// /// - Parameter serviceDID: The decentralized identifier (DID) of the service. - /// - Returns: A `Result`, containing either a ``ServerGetServiceAuthOutput`` + /// - Returns: A `Result`, containing either a ``ComAtprotoLexicon/Server/GetServiceAuthOutput`` /// if successful, or an `Error`if not. - public func getServiceAuthentication(from serviceDID: String) async throws -> Result { + public func getServiceAuthentication(from serviceDID: String) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -50,7 +50,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, - decodeTo: ServerGetServiceAuthOutput.self) + decodeTo: ComAtprotoLexicon.Server.GetServiceAuthOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/CoreAPI/GetSyncBlocks.swift b/Sources/ATProtoKit/Networking/CoreAPI/GetSyncBlocks.swift index 39f533da7a..3fd5128d64 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/GetSyncBlocks.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/GetSyncBlocks.swift @@ -40,10 +40,6 @@ extension ATProtoKit { } var queryItems = [(String, String)]() -// let queryItems = [ -// ("did", blobQuery.accountDID), -// ("cid", blobQuery.cidHash) -// ] queryItems.append(("did", repositoryDID)) queryItems += repositoryCIDHashes.map { ("cids", $0) } diff --git a/Sources/ATProtoKit/Networking/CoreAPI/GetSyncRecord.swift b/Sources/ATProtoKit/Networking/CoreAPI/GetSyncRecord.swift index e5ce4af937..7cc309a065 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/GetSyncRecord.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/GetSyncRecord.swift @@ -19,12 +19,18 @@ extension ATProtoKit { /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/sync/getRecord.json /// /// - Parameters: - /// - recordQuery: The information required to get a record. + /// - repository: The repository that owns the record. + /// - collection: The Namespaced Identifier (NSID) of the record. + /// - recordKey: The record key of the record. + /// - recordCID: The CID hash of the record. Optional. /// - pdsURL: The URL of the Personal Data Server (PDS). Defaults to `nil`. /// - Returns: A `Result`, containing either a `Data` object /// if successful, or an `Error` if not. public func getSyncRecord( - _ recordQuery: RecordQuery, + from repository: String, + collection: String, + recordKey: String, + recordCID: String? = nil, pdsURL: String? = nil ) async throws -> Result { guard let sessionURL = pdsURL != nil ? pdsURL : session?.pdsURL, @@ -32,12 +38,16 @@ extension ATProtoKit { return .failure(ATRequestPrepareError.invalidRequestURL) } - let queryItems = [ - ("repo", recordQuery.repo), - ("collection", recordQuery.collection), - ("rkey", recordQuery.recordKey) + var queryItems = [ + ("repo", repository), + ("collection", collection), + ("rkey", recordKey) ] + if let recordCID { + queryItems.append(("cid", recordCID)) + } + let queryURL: URL do { diff --git a/Sources/ATProtoKit/Networking/CoreAPI/ImportRepository.swift b/Sources/ATProtoKit/Networking/CoreAPI/ImportRepository.swift index a231024e40..0d722b770b 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/ImportRepository.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/ImportRepository.swift @@ -35,7 +35,7 @@ extension ATProtoKit { throw ATRequestPrepareError.invalidRequestURL } - let requestBody = RepoImportRepo( + let requestBody = ComAtprotoLexicon.Repository.ImportRepositoryRequestBody( repository: repositoryData ) diff --git a/Sources/ATProtoKit/Networking/CoreAPI/ListAppPasswords.swift b/Sources/ATProtoKit/Networking/CoreAPI/ListAppPasswords.swift index 75fcc2b4f8..9c2cd9fdcc 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/ListAppPasswords.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/ListAppPasswords.swift @@ -20,9 +20,9 @@ extension ATProtoKit { /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/listAppPasswords.json /// - /// - Returns: A `Result`, containing either a ``ServerListAppPasswordsOutput`` + /// - Returns: A `Result`, containing either a ``ComAtprotoLexicon/Server/ListAppPasswordsOutput`` /// if successful, or an `Error` if not. - public func listAppPasswords() async throws -> Result { + public func listAppPasswords() async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -40,7 +40,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, - decodeTo: ServerListAppPasswordsOutput.self) + decodeTo: ComAtprotoLexicon.Server.ListAppPasswordsOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/CoreAPI/ListBlobs.swift b/Sources/ATProtoKit/Networking/CoreAPI/ListBlobs.swift index 29abb979e6..8a6e69c067 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/ListBlobs.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/ListBlobs.swift @@ -25,7 +25,7 @@ extension ATProtoKit { /// - cursor: The mark used to indicate the starting point for the next set of /// results. Optional. /// - pdsURL: The URL of the Personal Data Server (PDS). Defaults to `nil`. - /// - Returns: A `Result`, containing either a ``SyncListBlobsOutput`` + /// - Returns: A `Result`, containing either a ``ComAtprotoLexicon/Sync/ListBlobsOutput`` /// if successful, or an `Error` if not. public func listBlobs( from repositoryDID: String, @@ -33,7 +33,7 @@ extension ATProtoKit { limit: Int? = 500, cursor: String? = nil, pdsURL: String? = nil - ) async throws -> Result { + ) async throws -> Result { guard let sessionURL = pdsURL != nil ? pdsURL : session?.pdsURL, let requestURL = URL(string: "\(sessionURL)/xrpc/com.atproto.sync.listBlobs") else { return .failure(ATRequestPrepareError.invalidRequestURL) @@ -70,7 +70,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: nil) let response = try await APIClientService.sendRequest(request, - decodeTo: SyncListBlobsOutput.self) + decodeTo: ComAtprotoLexicon.Sync.ListBlobsOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/CoreAPI/ListMissingBlobs.swift b/Sources/ATProtoKit/Networking/CoreAPI/ListMissingBlobs.swift index e107bba8bb..dfe0518917 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/ListMissingBlobs.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/ListMissingBlobs.swift @@ -22,12 +22,12 @@ extension ATProtoKit { /// - limit: The number of items that can be in the list. Optional. Defaults to `500`. /// - cursor: The mark used to indicate the starting point for the next set of /// result. Optional. - /// - Returns: A `Result`, containing either a ``RepoListMissingBlobsOutput`` + /// - Returns: A `Result`, containing either a ``ComAtprotoLexicon/Repository/ListMissingBlobsOutput`` /// if successful, or an `Error` if not. public func listMissingBlobs( limit: Int? = 500, cursor: String? = nil - ) async throws -> Result { + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -63,7 +63,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, - decodeTo: RepoListMissingBlobsOutput.self) + decodeTo: ComAtprotoLexicon.Repository.ListMissingBlobsOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/CoreAPI/ListRecords.swift b/Sources/ATProtoKit/Networking/CoreAPI/ListRecords.swift index f00b2e199b..4e6f347d22 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/ListRecords.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/ListRecords.swift @@ -26,7 +26,7 @@ extension ATProtoKit { /// result. Optional. /// - isArrayReverse: Indicates whether the list of records is listed in reverse. Optional. /// - pdsURL: The URL of the Personal Data Server (PDS). Defaults to `nil`. - /// - Returns: A `Result`, containing ``RepoListRecordsOutput`` + /// - Returns: A `Result`, containing ``ComAtprotoLexicon/Repository/ListRecordsOutput`` /// if successful, or an `Error` if not. public func listRecords( from repositoryDID: String, @@ -35,7 +35,7 @@ extension ATProtoKit { cursor: String? = nil, isArrayReverse: Bool? = nil, pdsURL: String? = nil - ) async throws -> Result { + ) async throws -> Result { guard let sessionURL = pdsURL != nil ? pdsURL : session?.pdsURL, let requestURL = URL(string: "\(sessionURL)/xrpc/com.atproto.repo.listRecords") else { return .failure(ATRequestPrepareError.invalidRequestURL) @@ -74,7 +74,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: nil) let response = try await APIClientService.sendRequest(request, - decodeTo: RepoListRecordsOutput.self) + decodeTo: ComAtprotoLexicon.Repository.ListRecordsOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/CoreAPI/ListRepositories.swift b/Sources/ATProtoKit/Networking/CoreAPI/ListRepositories.swift index 54dffdd5b8..7577ae3713 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/ListRepositories.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/ListRepositories.swift @@ -25,13 +25,13 @@ extension ATProtoKit { /// - cursor: The mark used to indicate the starting point for the next set of /// results. Optional. /// - pdsURL: The URL of the Personal Data Server (PDS). Defaults to `nil`. - /// - Returns: A `Result`, containing either a ``SyncListReposOutput`` + /// - Returns: A `Result`, containing either a ``ComAtprotoLexicon/Sync/ListRepositoriesOutput`` /// if successful, or an `Error` if not. public func listRepositories( limit: Int? = 500, cursor: String? = nil, pdsURL: String? = nil - ) async throws -> Result { + ) async throws -> Result { guard let sessionURL = pdsURL != nil ? pdsURL : session?.pdsURL, let requestURL = URL(string: "\(sessionURL)/xrpc/com.atproto.sync.getRepos") else { return .failure(ATRequestPrepareError.invalidRequestURL) @@ -62,7 +62,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: nil) let response = try await APIClientService.sendRequest(request, - decodeTo: SyncListReposOutput.self) + decodeTo: ComAtprotoLexicon.Sync.ListRepositoriesOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/CoreAPI/NotifyOfUpdate.swift b/Sources/ATProtoKit/Networking/CoreAPI/NotifyOfUpdate.swift index f608c3d780..96a35f533a 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/NotifyOfUpdate.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/NotifyOfUpdate.swift @@ -41,7 +41,7 @@ extension ATProtoKit { throw ATRequestPrepareError.invalidHostnameURL } - let requestBody = SyncCrawler( + let requestBody = ComAtprotoLexicon.Sync.Crawler( crawlingHostname: finalhostnameURL ) diff --git a/Sources/ATProtoKit/Networking/CoreAPI/PutRecord.swift b/Sources/ATProtoKit/Networking/CoreAPI/PutRecord.swift index b311a384eb..2a0ec1878d 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/PutRecord.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/PutRecord.swift @@ -27,7 +27,7 @@ extension ATProtoKit { /// - record: The record itself. /// - swapRecord: Swaps the record in the server with the record contained in here. Optional. /// - swapCommit: Swaps the commit in the server with the commit contained in here. Optional. - /// - Returns: A `Result`, containing either a ``StrongReference`` + /// - Returns: A `Result`, containing either a ``ComAtprotoLexicon/Repository/StrongReference`` /// if successful, or an `Error` if not. public func putRecord( _ repositoryDID: String, @@ -37,7 +37,7 @@ extension ATProtoKit { record: UnknownType, swapRecord: String? = nil, swapCommit: String? = nil - ) async throws -> Result { + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -48,7 +48,7 @@ extension ATProtoKit { return .failure(ATRequestPrepareError.invalidRequestURL) } - let requestBody = RepoPutRecord( + let requestBody = ComAtprotoLexicon.Repository.PutRecordRequestBody( repositoryDID: repositoryDID, collection: collection, recordKey: recordKey, @@ -66,7 +66,7 @@ extension ATProtoKit { authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, withEncodingBody: requestBody, - decodeTo: StrongReference.self) + decodeTo: ComAtprotoLexicon.Repository.StrongReference.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/CoreAPI/QueryLabels.swift b/Sources/ATProtoKit/Networking/CoreAPI/QueryLabels.swift index d5efd6ec2e..844bba0be7 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/QueryLabels.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/QueryLabels.swift @@ -32,7 +32,7 @@ extension ATProtoKit { /// - pdsURL: The URL of the Personal Data Server (PDS). Defaults to `nil`. /// - shouldAuthenticate: Indicates whether the method will use the access token when /// sending the request. Defaults to `false`. - /// - Returns: A `Result`, containing either a ``LabelQueryLabelsOutput`` + /// - Returns: A `Result`, containing either a ``ComAtprotoLexicon/Label/QueryLabelsOutput`` /// if successful, or an `Error` if not. public func queryLabels( uriPatterns: [String], @@ -41,7 +41,7 @@ extension ATProtoKit { cursor: String? = nil, pdsURL: String? = nil, shouldAuthenticate: Bool = false - ) async throws -> Result { + ) async throws -> Result { let authorizationValue = prepareAuthorizationValue( methodPDSURL: pdsURL, shouldAuthenticate: shouldAuthenticate, @@ -84,7 +84,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: authorizationValue) let response = try await APIClientService.sendRequest(request, - decodeTo: LabelQueryLabelsOutput.self) + decodeTo: ComAtprotoLexicon.Label.QueryLabelsOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/CoreAPI/RequestCrawl.swift b/Sources/ATProtoKit/Networking/CoreAPI/RequestCrawl.swift index 732fd08e02..86abdedf85 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/RequestCrawl.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/RequestCrawl.swift @@ -38,7 +38,7 @@ extension ATProtoKit { throw ATRequestPrepareError.invalidHostnameURL } - let requestBody = SyncCrawler( + let requestBody = ComAtprotoLexicon.Sync.Crawler( crawlingHostname: finalhostnameURL ) diff --git a/Sources/ATProtoKit/Networking/CoreAPI/RequestEmailUpdate.swift b/Sources/ATProtoKit/Networking/CoreAPI/RequestEmailUpdate.swift index 1b36082b4e..60690541d1 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/RequestEmailUpdate.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/RequestEmailUpdate.swift @@ -18,9 +18,9 @@ extension ATProtoKit { /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/requestEmailUpdate.json /// - /// - Returns: A `Result`, containing either a ``RequestEmailUpdateOutput`` + /// - Returns: A `Result`, containing either a ``ComAtprotoLexicon/Server/RequestEmailUpdateOutput`` /// if successful, or an `Error` if not. - public func requestEmailUpdate() async throws -> Result { + public func requestEmailUpdate() async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -38,7 +38,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, - decodeTo: RequestEmailUpdateOutput.self) + decodeTo: ComAtprotoLexicon.Server.RequestEmailUpdateOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/CoreAPI/RequestPasswordReset.swift b/Sources/ATProtoKit/Networking/CoreAPI/RequestPasswordReset.swift index 287c6f8b7d..9a8c6c9461 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/RequestPasswordReset.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/RequestPasswordReset.swift @@ -32,7 +32,7 @@ extension ATProtoKit { throw ATRequestPrepareError.invalidRequestURL } - let requestBody = ServerRequestPasswordReset( + let requestBody = ComAtprotoLexicon.Server.RequestPasswordResetRequestBody( email: email ) diff --git a/Sources/ATProtoKit/Networking/CoreAPI/RequestPhoneVerification.swift b/Sources/ATProtoKit/Networking/CoreAPI/RequestPhoneVerification.swift index b8cd94a439..a94a8fd85c 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/RequestPhoneVerification.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/RequestPhoneVerification.swift @@ -31,7 +31,7 @@ extension ATProtoKit { throw ATRequestPrepareError.invalidRequestURL } - let requestBody = TempRequestPhoneVerification( + let requestBody = ComAtprotoLexicon.Temp.RequestPhoneVerificationRequestBody( phoneNumber: phoneNumber ) diff --git a/Sources/ATProtoKit/Networking/CoreAPI/ReserveSigningKey.swift b/Sources/ATProtoKit/Networking/CoreAPI/ReserveSigningKey.swift index 4113771938..6ad2464b1a 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/ReserveSigningKey.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/ReserveSigningKey.swift @@ -23,18 +23,18 @@ extension ATProtoKit { /// - Parameters: /// - repositoryDID: The decentalized identifier (DID) of the repository. /// - pdsURL: The URL of the Personal Data Server (PDS). Defaults to `nil`. - /// - Returns: A `Result`, containing either a ``ServerReserveSigningKeyOutput`` + /// - Returns: A `Result`, containing either a ``ComAtprotoLexicon/Server/ReserveSigningKeyOutput`` /// if successful, or an `Error` if not. public func reserveSigningKey( _ repositoryDID: String, pdsURL: String? = nil - ) async throws -> Result { + ) async throws -> Result { guard let sessionURL = pdsURL != nil ? pdsURL : determinePDSURL(customPDSURL: pdsURL), let requestURL = URL(string: "\(sessionURL)/xrpc/com.atproto.server.reserveSigningKey") else { return .failure(ATRequestPrepareError.invalidRequestURL) } - let requestBody = ServerReserveSigningKey( + let requestBody = ComAtprotoLexicon.Server.ReserveSigningKeyRequestBody( repositoryDID: repositoryDID ) @@ -46,7 +46,7 @@ extension ATProtoKit { authorizationValue: nil) let response = try await APIClientService.sendRequest(request, withEncodingBody: requestBody, - decodeTo: ServerReserveSigningKeyOutput.self) + decodeTo: ComAtprotoLexicon.Server.ReserveSigningKeyOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/CoreAPI/ResetPassword.swift b/Sources/ATProtoKit/Networking/CoreAPI/ResetPassword.swift index 1535c152db..394d3ee62a 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/ResetPassword.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/ResetPassword.swift @@ -34,7 +34,7 @@ extension ATProtoKit { throw ATRequestPrepareError.invalidRequestURL } - let requestBody = ServerResetPassword( + let requestBody = ComAtprotoLexicon.Server.ResetPasswordRequestBody( token: token, newPassword: newPassword ) diff --git a/Sources/ATProtoKit/Networking/CoreAPI/ResolveHandle.swift b/Sources/ATProtoKit/Networking/CoreAPI/ResolveHandle.swift index d3c0c1b683..c61914c05d 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/ResolveHandle.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/ResolveHandle.swift @@ -22,12 +22,12 @@ extension ATProtoKit { /// - Parameters: /// - handle: The handle to resolve into a decentralized identifier (DID). /// - pdsURL: The URL of the Personal Data Server (PDS). Defaults to `nil`. - /// - Returns: A `Result`, containing either a ``ResolveHandleOutput`` + /// - Returns: A `Result`, containing either a ``ComAtprotoLexicon/Identity/ResolveHandleOutput`` /// if successful, or an `Error` if not. public func resolveHandle( from handle: String, pdsURL: String? = nil - ) async throws -> Result { + ) async throws -> Result { guard let sessionURL = pdsURL != nil ? pdsURL : session?.pdsURL, let requestURL = URL(string: "\(sessionURL)/xrpc/com.atproto.identity.resolveHandle") else { return .failure(ATRequestPrepareError.invalidRequestURL) @@ -51,7 +51,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: nil) let response = try await APIClientService.sendRequest(request, - decodeTo: ResolveHandleOutput.self) + decodeTo: ComAtprotoLexicon.Identity.ResolveHandleOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/CoreAPI/RevokeAppPassword.swift b/Sources/ATProtoKit/Networking/CoreAPI/RevokeAppPassword.swift index d6cf1d5cfa..1dca71255b 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/RevokeAppPassword.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/RevokeAppPassword.swift @@ -30,7 +30,7 @@ extension ATProtoKit { throw ATRequestPrepareError.invalidRequestURL } - let requestBody = ServerRevokeAppPassword( + let requestBody = ComAtprotoLexicon.Server.RevokeAppPasswordRequestBody( appPasswordName: appPasswordName ) diff --git a/Sources/ATProtoKit/Networking/CoreAPI/SignPLCOperation.swift b/Sources/ATProtoKit/Networking/CoreAPI/SignPLCOperation.swift index a6a4d7eb9c..5d3f4ae704 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/SignPLCOperation.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/SignPLCOperation.swift @@ -27,7 +27,7 @@ extension ATProtoKit { /// - verificationMethods: A verification method recommeneded to be added in the /// DID document. Optional. /// - service: The service endpoint recommended in the DID document. Optional. - /// - Returns: A `Result`, containing either an ``IdentitySignPLCOperationOutput`` + /// - Returns: A `Result`, containing either an ``ComAtprotoLexicon/Identity/SignPLCOperationOutput`` /// if successful, ot an `Error` if not. public func signPLCOperation( token: String, @@ -35,7 +35,7 @@ extension ATProtoKit { alsoKnownAs: [String]?, verificationMethods: VerificationMethod?, service: ATService? - ) async throws -> Result { + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -46,7 +46,7 @@ extension ATProtoKit { return .failure(ATRequestPrepareError.invalidRequestURL) } - let requestBody = IdentitySignPLCOperation( + let requestBody = ComAtprotoLexicon.Identity.SignPLCOperationRequestBody( token: token, rotationKeys: rotationKeys, alsoKnownAs: alsoKnownAs, @@ -62,7 +62,7 @@ extension ATProtoKit { authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, withEncodingBody: requestBody, - decodeTo: IdentitySignPLCOperationOutput.self) + decodeTo: ComAtprotoLexicon.Identity.SignPLCOperationOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/CoreAPI/SubmitPLCOperation.swift b/Sources/ATProtoKit/Networking/CoreAPI/SubmitPLCOperation.swift index b6ee4ada70..00a9b0dd5e 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/SubmitPLCOperation.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/SubmitPLCOperation.swift @@ -20,15 +20,13 @@ extension ATProtoKit { /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/identity/submitPlcOperation.json /// /// - Parameter operation: - /// - Returns: A `Result`, containing either an ``IdentitySignPLCOperationOutput`` - /// if successful, or an `Error` if not. - public func submitPLCOperation(_ operation: UnknownType) async throws -> Result { + public func submitPLCOperation(_ operation: UnknownType) async throws { guard let sessionURL = session?.pdsURL, let requestURL = URL(string: "\(sessionURL)/xrpc/com.atproto.identity.identitySubmitPLCOperation") else { - return .failure(ATRequestPrepareError.invalidRequestURL) + throw ATRequestPrepareError.invalidRequestURL } - let requestBody = IdentitySignPLCOperationOutput( + let requestBody = ComAtprotoLexicon.Identity.SubmitPLCOperationRequestBody( operation: operation ) @@ -38,13 +36,10 @@ extension ATProtoKit { acceptValue: "application/json", contentTypeValue: nil, authorizationValue: nil) - let response = try await APIClientService.sendRequest(request, - withEncodingBody: requestBody, - decodeTo: IdentitySignPLCOperation.self) - - return .success(response) + try await APIClientService.sendRequest(request, + withEncodingBody: requestBody) } catch { - return .failure(error) + throw error } } } diff --git a/Sources/ATProtoKit/Networking/CoreAPI/UpdateEmail.swift b/Sources/ATProtoKit/Networking/CoreAPI/UpdateEmail.swift index 96b58e7f54..98b77bd6ad 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/UpdateEmail.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/UpdateEmail.swift @@ -40,7 +40,7 @@ extension ATProtoKit { throw ATRequestPrepareError.invalidRequestURL } - let requestBody = ServerUpdateEmail( + let requestBody = ComAtprotoLexicon.Server.UpdateEmailRequestBody( email: email, isEmailAuthenticationFactorEnabled: isEmailAuthenticationFactorEnabled, token: token diff --git a/Sources/ATProtoKit/Networking/CoreAPI/UpdateHandle.swift b/Sources/ATProtoKit/Networking/CoreAPI/UpdateHandle.swift index f80ad3a689..07c36f3d0a 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/UpdateHandle.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/UpdateHandle.swift @@ -20,7 +20,7 @@ extension ATProtoKit { /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/identity/updateHandle.json /// /// - Parameter handle: The object which conains the user's new handle. - public func updateHandle(_ handle: UpdateHandleQuery) async throws { + public func updateHandle(_ handle: String) async throws { guard session != nil, let accessToken = session?.accessToken else { throw ATRequestPrepareError.missingActiveSession @@ -31,13 +31,17 @@ extension ATProtoKit { throw ATRequestPrepareError.invalidRequestURL } + let requestBody = ComAtprotoLexicon.Identity.UpdateHandleRequestBody( + handle: handle + ) + do { let request = APIClientService.createRequest(forRequest: requestURL, andMethod: .post, authorizationValue: "Bearer \(accessToken)") try await APIClientService.sendRequest(request, - withEncodingBody: handle) + withEncodingBody: requestBody) } catch { throw error } diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/CreateLike.swift b/Sources/ATProtoKit/Networking/PlatformAPI/CreateLike.swift index fa0dabcf61..2d6c012a36 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/CreateLike.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/CreateLike.swift @@ -19,18 +19,13 @@ extension ATProtoKit { /// - Returns: A `Result`, containing either a ``StrongReference`` /// if it's successful, or an `Error` if it's not. public func createLikeRecord( - _ strongReference: StrongReference, + _ strongReference: ComAtprotoLexicon.Repository.StrongReference, createdAt: Date = Date.now, shouldValidate: Bool? = true - ) async throws -> Result { -// guard let sessionURL = session.pdsURL, -// let requestURL = URL(string: "\(sessionURL)/xrpc/com.atproto.repo.createRecord") else { -// throw NSError(domain: "", code: -1, userInfo: [NSLocalizedDescriptionKey: "Invalid URL"]) -// } - + ) async throws -> Result { guard let session else { return .failure(ATRequestPrepareError.missingActiveSession) } - let likeRecord = FeedLike( + let likeRecord = AppBskyLexicon.Feed.LikeRecord( subject: strongReference, createdAt: createdAt ) @@ -52,6 +47,6 @@ extension ATProtoKit { /// - Warning: The value must not change. let collection: String = "app.bsky.feed.like" /// The like record itself. - let record: FeedLike + let record: AppBskyLexicon.Feed.LikeRecord } } diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/CreatePost.swift b/Sources/ATProtoKit/Networking/PlatformAPI/CreatePost.swift index f9a9deb61e..62c53e5316 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/CreatePost.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/CreatePost.swift @@ -31,13 +31,13 @@ extension ATProtoKit { locales: [Locale] = [], replyTo: String? = nil, embed: EmbedIdentifier? = nil, - labels: FeedLabelUnion? = nil, + labels: ATUnion.PostSelfLabelsUnion? = nil, tags: [String]? = nil, creationDate: Date = Date.now, recordKey: String? = nil, shouldValidate: Bool? = true, swapCommit: String? = nil - ) async -> Result { + ) async -> Result { guard let session else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -47,7 +47,7 @@ extension ATProtoKit { return .failure(ATRequestPrepareError.invalidPDS) } // Replies - var resolvedReplyTo: ReplyReference? = nil + var resolvedReplyTo: AppBskyLexicon.Feed.PostRecord.ReplyReference? = nil if let replyURI = replyTo { do { resolvedReplyTo = try await ATProtoTools().resolveReplyReferences(parentURI: replyURI) @@ -60,7 +60,7 @@ extension ATProtoKit { let localeIdentifiers = locales.isEmpty ? nil : locales.map { $0.identifier } // Embed - var resolvedEmbed: EmbedUnion? = nil + var resolvedEmbed: ATUnion.PostEmbedUnion? = nil if let embedUnion = embed { do { switch embedUnion { @@ -80,7 +80,7 @@ extension ATProtoKit { } // Compiling all parts of the post into one. - let postRecord = FeedPost( + let postRecord = AppBskyLexicon.Feed.PostRecord( text: text, facets: await ATFacetParser.parseFacets(from: text, pdsURL: session.accessToken), reply: resolvedReplyTo, @@ -110,8 +110,8 @@ extension ATProtoKit { /// use in a record. /// /// - Important: Each image can only be 1 MB in size. - public func uploadImages(_ images: [ImageQuery], pdsURL: String = "https://bsky.social", accessToken: String) async throws -> EmbedUnion { - var embedImages = [EmbedImage]() + public func uploadImages(_ images: [ImageQuery], pdsURL: String = "https://bsky.social", accessToken: String) async throws -> ATUnion.PostEmbedUnion { + var embedImages = [AppBskyLexicon.Embed.ImagesDefinition.Image]() for image in images { // Check if the image is too large. @@ -123,11 +123,11 @@ extension ATProtoKit { let blobReference = try await APIClientService.uploadBlob(pdsURL: pdsURL, accessToken: accessToken, filename: image.fileName, imageData: image.imageData) - let embedImage = EmbedImage(image: blobReference.blob, altText: image.altText ?? "", aspectRatio: nil) + let embedImage = AppBskyLexicon.Embed.ImagesDefinition.Image(image: blobReference.blob, altText: image.altText ?? "", aspectRatio: nil) embedImages.append(embedImage) } - return .images(EmbedImages(images: embedImages)) + return .images(AppBskyLexicon.Embed.ImagesDefinition(images: embedImages)) } /// Scraps the website for the required information in order to attach to a record's embed at a @@ -135,7 +135,7 @@ extension ATProtoKit { /// - Parameter url: The URL of the website /// - Returns: An ``EmbedUnion`` which contains an ``EmbedExternal`` for use /// in a record. - public func buildExternalEmbed(from url: URL) async throws -> EmbedUnion? { + public func buildExternalEmbed(from url: URL) async throws -> ATUnion.PostEmbedUnion? { // Temporary comment until it's time to work on this part of the library. // let external = EmbedExternal(external: External(embedURI: "", title: "", description: "", thumbnailImage: UploadBlobOutput(type: <#T##String?#>, reference: <#T##BlobReference#>, mimeType: <#T##String#>, size: <#T##Int#>))) @@ -148,10 +148,10 @@ extension ATProtoKit { /// the `cidHash` (CID) . /// - Returns: A strong reference, which contains a record's `recordURI` (URI) and the /// `cidHash` (CID) . - public func addQuotePostToEmbed(_ strongReference: StrongReference) async throws -> EmbedUnion { + public func addQuotePostToEmbed(_ strongReference: ComAtprotoLexicon.Repository.StrongReference) async throws -> ATUnion.PostEmbedUnion { let record = try await ATProtoTools().fetchRecordForURI(strongReference.recordURI) - let reference = StrongReference(recordURI: record.recordURI, cidHash: record.recordCID) - let embedRecord = EmbedRecord(record: reference) + let reference = ComAtprotoLexicon.Repository.StrongReference(recordURI: record.recordURI, cidHash: record.recordCID) + let embedRecord = AppBskyLexicon.Embed.RecordDefinition(record: reference) return .record(embedRecord) } @@ -183,12 +183,12 @@ extension ATProtoKit { /// Represents another post record that is to be embedded within the current post. /// - Parameter strongReference: A `StrongReference` to the post record to be embedded, /// which contains a record's `recordURI` (URI) and the `cidHash` (CID) . - case record(strongReference: StrongReference) + case record(strongReference: ComAtprotoLexicon.Repository.StrongReference) /// Represents a post record accompanied by media, to be embedded within the current post. /// - Parameters: /// - record: An `EmbedRecord`, representing the post to be embedded. /// - media: A `MediaUnion`, representing the media content associated with the post. - case recordWithMedia(record: EmbedRecord, media: MediaUnion) + case recordWithMedia(record: AppBskyLexicon.Embed.RecordDefinition, media: ATUnion.RecordWithMediaUnion) } } diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/DeleteLike.swift b/Sources/ATProtoKit/Networking/PlatformAPI/DeleteLike.swift index 2c55a038c9..0e5f6a026d 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/DeleteLike.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/DeleteLike.swift @@ -24,12 +24,12 @@ extension ATProtoKit { throw ATRequestPrepareError.invalidRequestURL } - var likeRecord: RecordQuery? = nil + var likeRecord: ATProtoTools.RecordQuery? = nil try await resolveRecordIdentifierToQuery(record, sessionURL, &likeRecord) let requestBody = likeRecord - guard let repositoryDID = requestBody?.repo, + guard let repositoryDID = requestBody?.repository, let likeCollection = requestBody?.collection, let likeRecordKey = requestBody?.recordKey else { throw ATRequestPrepareError.invalidRecord @@ -39,15 +39,16 @@ extension ATProtoKit { } fileprivate func resolveRecordIdentifierToQuery(_ record: RecordIdentifier, _ sessionURL: String, - _ likeRecord: inout RecordQuery?) async throws { + _ likeRecord: inout ATProtoTools.RecordQuery?) async throws { switch record { case .recordQuery(let recordQuery): // Perform the fetch and validation based on recordQuery. - let output = try await ATProtoKit().getRepositoryRecord(from: recordQuery, pdsURL: sessionURL) + let output = try await self.getRepositoryRecord(from: recordQuery.repository, collection: recordQuery.collection, + recordKey: recordQuery.recordKey, recordCID: recordQuery.recordCID, pdsURL: sessionURL) switch output { case .success(let result): - let recordURI = "at://\(recordQuery.repo)/\(recordQuery.collection)/\(recordQuery.recordKey)" + let recordURI = "at://\(recordQuery.repository)/\(recordQuery.collection)/\(recordQuery.recordKey)" guard result.recordURI == recordURI else { throw ATRequestPrepareError.invalidRecord } @@ -60,7 +61,8 @@ extension ATProtoKit { case .recordURI(let recordURI): // Perform the fetch and validation based on the parsed URI. let parsedURI = try ATProtoTools().parseURI(recordURI) - let output = try await ATProtoKit().getRepositoryRecord(from: parsedURI, pdsURL: sessionURL) + let output = try await self.getRepositoryRecord(from: parsedURI.repository, collection: parsedURI.collection, + recordKey: parsedURI.recordKey, recordCID: parsedURI.recordCID, pdsURL: sessionURL) switch output { case .success(let result): @@ -83,7 +85,7 @@ extension ATProtoKit { public enum RecordIdentifier { /// The record object itself. /// - Parameter recordQuery: the record object. - case recordQuery(recordQuery: RecordQuery) + case recordQuery(recordQuery: ATProtoTools.RecordQuery) /// The URI of the record. case recordURI(atURI: String) } diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/DescribeFeedGenerator.swift b/Sources/ATProtoKit/Networking/PlatformAPI/DescribeFeedGenerator.swift index 00b09b65e7..a847d58f3a 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/DescribeFeedGenerator.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/DescribeFeedGenerator.swift @@ -19,9 +19,9 @@ extension ATProtoKit { /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/describeFeedGenerator.json /// - /// - Returns: A `Result`, containing either a ``FeedDescribeFeedGeneratorOutput`` + /// - Returns: A `Result`, containing either a ``AppBskyLexicon/Feed/DescribeFeedGeneratorOutput`` /// if successful, or an `Error` if not. - public func describeFeedGenerator(pdsURL: String? = nil) async throws -> Result { + public func describeFeedGenerator(pdsURL: String? = nil) async throws -> Result { guard let sessionURL = pdsURL != nil ? pdsURL : session?.pdsURL, let requestURL = URL(string: "\(sessionURL)/app.bsky.feed.describeFeedGenerator") else { return .failure(ATRequestPrepareError.invalidRequestURL) @@ -34,7 +34,7 @@ extension ATProtoKit { contentTypeValue: "application/json", authorizationValue: nil) let response = try await APIClientService.sendRequest(request, - decodeTo: FeedDescribeFeedGeneratorOutput.self) + decodeTo: AppBskyLexicon.Feed.DescribeFeedGeneratorOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetActorFeeds.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetActorFeeds.swift index d4886c80a8..1c45c7c0f2 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetActorFeeds.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetActorFeeds.swift @@ -23,13 +23,13 @@ extension ATProtoKit { /// - limit: The number of items that can be in the list. Optional. Defaults to `50`. /// - cursor: The mark used to indicate the starting point for the next set of /// result. Optional. - /// - Returns: A `Result`, containing either a ``FeedGetActorFeedsOutput`` + /// - Returns: A `Result`, containing either a ``AppBskyLexicon/Feed/GetActorFeedsOutput`` /// if successful, or an `Error` if not. public func getActorFeeds( by actorDID: String, limit: Int? = 50, cursor: String? = nil - ) async throws -> Result { + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -67,7 +67,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, - decodeTo: FeedGetActorFeedsOutput.self) + decodeTo: AppBskyLexicon.Feed.GetActorFeedsOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetActorLikes.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetActorLikes.swift index 58a7547c61..087c13c776 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetActorLikes.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetActorLikes.swift @@ -34,13 +34,13 @@ extension ATProtoKit { /// - limit: The number of items the list will hold. Optional. Defaults to `50`. /// - cursor: The mark used to indicate the starting point for the next set of /// result. Optional. - /// - Returns: A `Result`, containing either a ``FeedGetActorLikesOutput`` + /// - Returns: A `Result`, containing either a ``AppBskyLexicon/Feed/GetActorLikesOutput`` /// if successful, or an `Error` if not. public func getActorLikes( by actorDID: String, limit: Int? = 50, cursor: String? = nil - ) async throws -> Result { + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -78,7 +78,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, - decodeTo: FeedGetActorLikesOutput.self) + decodeTo: AppBskyLexicon.Feed.GetActorLikesOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetAuthorFeed.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetAuthorFeed.swift index f10c043e5b..d2f212a800 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetAuthorFeed.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetAuthorFeed.swift @@ -29,14 +29,14 @@ extension ATProtoKit { /// - limit: The number of items the list will hold. Optional. Defaults to `50`. /// - cursor: The mark used to indicate the starting point for the next set of /// result. Optional. - /// - Returns: A `Result`, containing either a ``FeedGetAuthorFeedOutput`` + /// - Returns: A `Result`, containing either a ``AppBskyLexicon/Feed/GetAuthorFeedOutput`` /// if successful, or an `Error` if not. public func getAuthorFeed( by actorDID: String, limit: Int? = 50, cursor: String? = nil, - postFilter: FeedGetAuthorFeedFilter? = .postsWithReplies - ) async throws -> Result { + postFilter: AppBskyLexicon.Feed.GetAuthorFeed.Filter? = .postsWithReplies + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -78,7 +78,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, - decodeTo: FeedGetAuthorFeedOutput.self) + decodeTo: AppBskyLexicon.Feed.GetAuthorFeedOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetFeed.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetFeed.swift index 1605ec6206..ca99b18062 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetFeed.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetFeed.swift @@ -23,13 +23,13 @@ extension ATProtoKit { /// - limit: The number of items the list will hold. Optional. Defaults to `50`. /// - cursor: The mark used to indicate the starting point for the next set of /// result. Optional. - /// - Returns: A `Result`, containing either a ``FeedGetFeedOutput`` + /// - Returns: A `Result`, containing either a ``AppBskyLexicon/Feed/GetFeedOutput`` /// if successful, or an `Error` if not. public func getFeed( _ feedURI: String, limit: Int? = 50, cursor: String? = nil - ) async throws -> Result { + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -67,7 +67,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, - decodeTo: FeedGetFeedOutput.self) + decodeTo: AppBskyLexicon.Feed.GetFeedOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetFeedGenerator.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetFeedGenerator.swift index 8db9807be0..25dfc84078 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetFeedGenerator.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetFeedGenerator.swift @@ -22,9 +22,9 @@ extension ATProtoKit { /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getFeedGenerator.json /// /// - Parameter feedURI: The URI of the feed generator. - /// - Returns: A `Result`, containing either a ``FeedGetFeedGeneratorOutput`` + /// - Returns: A `Result`, containing either a ``AppBskyLexicon/Feed/GetFeedGeneratorOutput`` /// if successful, or an `Error` if not. - public func getFeedGenerator(_ feedURI: String) async throws -> Result { + public func getFeedGenerator(_ feedURI: String) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -53,7 +53,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, - decodeTo: FeedGetFeedGeneratorOutput.self) + decodeTo: AppBskyLexicon.Feed.GetFeedGeneratorOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetFeedGenerators.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetFeedGenerators.swift index 6e20ab2486..b89aa92fcc 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetFeedGenerators.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetFeedGenerators.swift @@ -22,9 +22,9 @@ extension ATProtoKit { /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getFeedGenerators.json /// /// - Parameter feedURIs: An array of URIs for feed generators. - /// - Returns: A `Result`, containing either a ``FeedGetFeedGeneratorOutput`` + /// - Returns: A `Result`, containing either a ``AppBskyLexicon/Feed/GetFeedGeneratorsOutput`` /// if successful, or an `Error` if not. - public func getFeedGenerators(_ feedURIs: [String]) async throws -> Result { + public func getFeedGenerators(_ feedURIs: [String]) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -53,7 +53,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, - decodeTo: FeedGetFeedGeneratorsOutput.self) + decodeTo: AppBskyLexicon.Feed.GetFeedGeneratorsOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetFeedSkeleton.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetFeedSkeleton.swift index b1ee734be4..37b4c80d8b 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetFeedSkeleton.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetFeedSkeleton.swift @@ -29,14 +29,14 @@ extension ATProtoKit { /// result. Optional. /// - accessToken: The token used to authenticate the user. Optional. /// - pdsURL: The URL of the Personal Data Server (PDS). - /// - Returns: A `Result`, containing either a ``FeedGetFeedSkeletonOutput`` + /// - Returns: A `Result`, containing either a ``AppBskyLexicon/Feed/GetFeedSkeletonOutput`` /// if successful, or an `Error` if not. public static func getFeedSkeleton( _ feedURI: String, limit: Int? = 50, cursor: String? = nil, pdsURL: String - ) async throws -> Result { + ) async throws -> Result { guard let requestURL = URL(string: "\(pdsURL)/xrpc/app.bsky.feed.getFeedSkeleton") else { return .failure(ATRequestPrepareError.invalidRequestURL) } @@ -44,6 +44,7 @@ extension ATProtoKit { if pdsURL == "https://bsky.social" { return .failure(ATRequestPrepareError.invalidPDS) } + var queryItems = [(String, String)]() queryItems.append(("feed", feedURI)) @@ -62,7 +63,7 @@ extension ATProtoKit { contentTypeValue: "application/json", authorizationValue: nil) let response = try await APIClientService.sendRequest(request, - decodeTo: FeedGetFeedSkeletonOutput.self) + decodeTo: AppBskyLexicon.Feed.GetFeedSkeletonOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetFollowers.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetFollowers.swift index beb0c7a2fb..71e1beec9e 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetFollowers.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetFollowers.swift @@ -23,13 +23,13 @@ extension ATProtoKit { /// their followers. /// - limit: The number of items the list will hold. Optional. Defaults to `50`. /// - cursor: The mark used to indicate the starting point for the next set of result. Optional. - /// - Returns: A `Result`, containing either a ``GraphGetFollowersOutput`` + /// - Returns: A `Result`, containing either a ``AppBskyLexicon/Graph/GetFollowersOutput`` /// if successful, or an `Error` if not. public func getFollowers( by actorDID: String, limit: Int? = 50, cursor: String? = nil - ) async throws -> Result { + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -67,7 +67,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, - decodeTo: GraphGetFollowersOutput.self) + decodeTo: AppBskyLexicon.Graph.GetFollowersOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetFollows.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetFollows.swift index e3b7ad0cf2..22e4454f0c 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetFollows.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetFollows.swift @@ -24,13 +24,13 @@ extension ATProtoKit { /// - limit: The number of items the list will hold. Optional. Defaults to `50`. /// - cursor: The mark used to indicate the starting point for the next set of /// result. Optional. - /// - Returns: A `Result`, containing either a ``GraphFollowsOutput`` + /// - Returns: A `Result`, containing either a ``AppBskyLexicon/Graph/GetFollowsOutput`` /// if successful, or an `Error` if not. public func getFollows( from actorDID: String, limit: Int? = 50, cursor: String? = nil - ) async throws -> Result { + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -68,7 +68,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, - decodeTo: GraphFollowsOutput.self) + decodeTo: AppBskyLexicon.Graph.GetFollowsOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetGraphBlocks.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetGraphBlocks.swift index 8cb8f8527e..8c82f2d473 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetGraphBlocks.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetGraphBlocks.swift @@ -22,12 +22,12 @@ extension ATProtoKit { /// - limit: The number of items the list will hold. Optional. Defaults to `50`. /// - cursor: The mark used to indicate the starting point for the next set of /// result. Optional. - /// - Returns: A `Result`, containing either a ``GraphGetBlocksOutput`` + /// - Returns: A `Result`, containing either a ``AppBskyLexicon/Graph/GetBlocksOutput`` /// if successful, or an `Error` if not. public func getGraphBlocks( limit: Int? = 50, cursor: String? = nil - ) async throws -> Result { + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -63,7 +63,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, - decodeTo: GraphGetBlocksOutput.self) + decodeTo: AppBskyLexicon.Graph.GetBlocksOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetLabelerServices.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetLabelerServices.swift index 6f0da88f52..0a463beb5d 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetLabelerServices.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetLabelerServices.swift @@ -22,13 +22,13 @@ extension ATProtoKit { /// - labelerDIDs: An array of decentralized identifiers (DIDs) of labeler services. /// - isDetailed: Indicates whether the information is detailed. Optional. /// - pdsURL: The URL of the Personal Data Server (PDS). Defaults to `nil`. - /// - Returns: A `Result`, containing either a ``LabelerGetServicesOutput`` + /// - Returns: A `Result`, containing either a ``AppBskyLexicon/Labeler/GetServicesOutput`` /// if successful, or an `Error` if not. public func getLabelerServices( labelerDIDs: [String], isDetailed: Bool? = nil, pdsURL: String? = nil - ) async throws -> Result { + ) async throws -> Result { guard let sessionURL = pdsURL != nil ? pdsURL : session?.pdsURL, let requestURL = URL(string: "\(sessionURL)/xrpc/app.bsky.labeler.getServices") else { return .failure(ATRequestPrepareError.invalidFormat) @@ -52,7 +52,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: nil) let response = try await APIClientService.sendRequest(request, decodeTo: - LabelerGetServicesOutput.self) + AppBskyLexicon.Labeler.GetServicesOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetLikes.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetLikes.swift index 7a8e9c4a81..b17b9afb23 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetLikes.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetLikes.swift @@ -24,14 +24,14 @@ extension ATProtoKit { /// - limit: The number of items that can be in the list. Optional. Defaults to `50`. /// - cursor: The mark used to indicate the starting point for the next set of /// result. Optional. - /// - Returns: A `Result`, containing either a ``FeedGetLikesOutput`` + /// - Returns: A `Result`, containing either a ``AppBskyLexicon/Feed/GetLikesOutput`` /// if successful, or an `Error` if not. public func getLikes( from recordURI: String, recordCID: String? = nil, limit: Int? = 50, cursor: String? = nil - ) async throws -> Result { + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -73,7 +73,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, - decodeTo: FeedGetLikesOutput.self) + decodeTo: AppBskyLexicon.Feed.GetLikesOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetList.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetList.swift index 67a0b9275f..acf76d4b9d 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetList.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetList.swift @@ -23,13 +23,13 @@ extension ATProtoKit { /// - limit: The number of items that can be in the list. Optional. Defaults to `50`. /// - cursor: The mark used to indicate the starting point for the next set of /// result. Optional. - /// - Returns: A `Result`, containing either a ``GraphGetListOutput`` + /// - Returns: A `Result`, containing either a ``AppBskyLexicon/Graph/GetListOutput`` /// if successful, or an `Error` if not. public func getList( from listURI: String, limit: Int? = 50, cursor: String? = nil - ) async throws -> Result { + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -67,7 +67,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, - decodeTo: GraphGetListOutput.self) + decodeTo: AppBskyLexicon.Graph.GetListOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetListBlocks.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetListBlocks.swift index 824b255b27..a2699659c2 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetListBlocks.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetListBlocks.swift @@ -22,12 +22,12 @@ extension ATProtoKit { /// - limit: The number of items that can be in the list. Optional. Defaults to `50`. /// - cursor: The mark used to indicate the starting point for the next set of /// result. Optional. - /// - Returns: A `Result`, containing either a ``GraphGetBlocksOutput`` + /// - Returns: A `Result`, containing either a ``AppBskyLexicon/Graph/GetBlocksOutput`` /// if successful, or an `Error` if not. public func getListBlocks( limit: Int? = 50, cursor: String? = nil - ) async throws -> Result { + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -63,7 +63,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, - decodeTo: GraphGetBlocksOutput.self) + decodeTo: AppBskyLexicon.Graph.GetBlocksOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetListFeed.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetListFeed.swift index 5648fbf872..ee8ea8724b 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetListFeed.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetListFeed.swift @@ -25,7 +25,7 @@ extension ATProtoKit { /// - cursor: The mark used to indicate the starting point for the next set of results. Optional. /// - accessToken: The access token of the user. Optional. /// - pdsURL: The URL of the Personal Data Server (PDS). Defaults to `nil`. - /// - Returns: A `Result`, containing either an ``FeedGetListFeedOutput`` + /// - Returns: A `Result`, containing either an ``AppBskyLexicon/Feed/GetListFeedOutput`` /// if succesful, or an `Error` if it's not. public func getListFeed( from listURI: String, @@ -33,7 +33,7 @@ extension ATProtoKit { cursor: String? = nil, accessToken: String? = nil, pdsURL: String? = nil - ) async throws -> Result { + ) async throws -> Result { guard let sessionURL = pdsURL != nil ? pdsURL : session?.pdsURL, let requestURL = URL(string: "\(sessionURL)/xrpc/app.bsky.feed.getListFeed") else { return .failure(ATRequestPrepareError.invalidRequestURL) @@ -66,7 +66,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: nil) let response = try await APIClientService.sendRequest(request, - decodeTo: FeedGetListFeedOutput.self) + decodeTo: AppBskyLexicon.Feed.GetListFeedOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetListMutes.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetListMutes.swift index a7ac2c5492..bc2981af3d 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetListMutes.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetListMutes.swift @@ -22,12 +22,12 @@ extension ATProtoKit { /// - limit: The number of items that can be in the list. Optional. Defaults to `50`. /// - cursor: The mark used to indicate the starting point for the next set of /// result. Optional. - /// - Returns: A `Result`, containing either a ``GraphGetListMutesOutput`` + /// - Returns: A `Result`, containing either a ``AppBskyLexicon/Graph/GetListMutesOutput`` /// if successful, or an `Error` if not. public func getListMutes( limit: Int? = 50, cursor: String? = nil - ) async throws -> Result { + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -63,7 +63,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, - decodeTo: GraphGetListMutesOutput.self) + decodeTo: AppBskyLexicon.Graph.GetListMutesOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetLists.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetLists.swift index 1e6c158761..5f26342fa5 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetLists.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetLists.swift @@ -23,13 +23,13 @@ extension ATProtoKit { /// - limit: The number of items that can be in the list. Optional. Defaults to `50`. /// - cursor: The mark used to indicate the starting point for the next set of /// result. Optional. - /// - Returns: A `Result`, containing either a ``GraphGetListsOutput`` + /// - Returns: A `Result`, containing either a ``AppBskyLexicon/Graph/GetListsOutput`` /// if successful, or an `Error` if not. public func getLists( from actorDID: String, limit: Int? = 50, cursor: String? = nil - ) async throws -> Result { + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -67,7 +67,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, - decodeTo: GraphGetListsOutput.self) + decodeTo: AppBskyLexicon.Graph.GetListsOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetMutes.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetMutes.swift index 152fca8a89..213af61ed5 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetMutes.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetMutes.swift @@ -22,12 +22,12 @@ extension ATProtoKit { /// - limit: The number of items that can be in the list. Optional. Defaults to `50`. /// - cursor: The mark used to indicate the starting point for the next set of /// result. Optional. - /// - Returns: A `Result`, containing either a ``GraphGetMutesOutput`` + /// - Returns: A `Result`, containing either a ``AppBskyLexicon/Graph/GetMutesOutput`` /// if successful, or an `Error` if not. public func getMutes( limit: Int? = 50, cursor: String? = nil - ) async throws -> Result { + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -63,7 +63,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, - decodeTo: GraphGetMutesOutput.self) + decodeTo: AppBskyLexicon.Graph.GetMutesOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetPopularFeedGenerators.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetPopularFeedGenerators.swift index c43ae70af6..d8c894abaf 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetPopularFeedGenerators.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetPopularFeedGenerators.swift @@ -26,13 +26,13 @@ extension ATProtoKit { /// - limit: The number of items that can be in the list. Optional. Defaults to `50`. /// - cursor: The mark used to indicate the starting point for the next set of /// result. Optional. - /// - Returns: A `Result`, containing either an ``UnspeccedGetPopularFeedGeneratorsOutput`` + /// - Returns: A `Result`, containing either an ``AppBskyLexicon/Unspecced/GetPopularFeedGeneratorsOutput`` /// if successful, or an `Error` if not. public func getPopularFeedGenerators( _ query: String?, limit: Int? = 50, cursor: String? = nil - ) async throws -> Result { + ) async throws -> Result { guard let sessionURL = session?.pdsURL, let requestURL = URL(string: "\(sessionURL)/xrpc/app.bsky.unspecced.getPopularFeedGenerators") else { return .failure(ATRequestPrepareError.invalidRequestURL) @@ -67,7 +67,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: nil) let response = try await APIClientService.sendRequest(request, - decodeTo: UnspeccedGetPopularFeedGeneratorsOutput.self) + decodeTo: AppBskyLexicon.Unspecced.GetPopularFeedGeneratorsOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetPostThread.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetPostThread.swift index 9788c5d176..50da6781a3 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetPostThread.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetPostThread.swift @@ -26,7 +26,7 @@ extension ATProtoKit { /// Optional. Defaults to `80`. Can be between `0` and `1000`. /// - accessToken: The token used to authenticate the user. Optional. /// - pdsURL: The URL of the Personal Data Server (PDS). Defaults to `nil`. - /// - Returns: A `Result`, containing either a ``FeedGetPostThreadOutput`` + /// - Returns: A `Result`, containing either a ``AppBskyLexicon/Feed/GetPostThreadOutput`` /// if successful, or an `Error` if not. public func getPostThread( from postURI: String, @@ -34,7 +34,7 @@ extension ATProtoKit { parentHeight: Int? = 80, pdsURL: String? = nil, shouldAuthenticate: Bool = false - ) async throws -> Result { + ) async throws -> Result { let authorizationValue = prepareAuthorizationValue( methodPDSURL: pdsURL, shouldAuthenticate: shouldAuthenticate, @@ -74,7 +74,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: authorizationValue) let response = try await APIClientService.sendRequest(request, - decodeTo: FeedGetPostThreadOutput.self) + decodeTo: AppBskyLexicon.Feed.GetPostThreadOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetPosts.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetPosts.swift index 8e1ff0b027..e1a29ad77c 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetPosts.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetPosts.swift @@ -25,9 +25,9 @@ extension ATProtoKit { /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getPosts.json /// /// - Parameter postURIs: An array of URIs of post records. - /// - Returns: A `Result`, containing either a ``FeedGetPostsOutput`` + /// - Returns: A `Result`, containing either a ``AppBskyLexicon/Feed/GetPostsOutput`` /// if successful, or an `Error` if not. - public func getPosts(_ postURIs: [String]) async throws -> Result { + public func getPosts(_ postURIs: [String]) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -58,7 +58,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, - decodeTo: FeedGetPostsOutput.self) + decodeTo: AppBskyLexicon.Feed.GetPostsOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetPreferences.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetPreferences.swift index 00d18df861..c1a7e5b515 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetPreferences.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetPreferences.swift @@ -19,8 +19,8 @@ extension ATProtoKit { /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/getPreferences.json /// - /// - Returns: A `Result`, containing either ``ActorPreferences`` if successful, or `Error` if not. - public func getPreferences() async throws -> Result { + /// - Returns: A `Result`, containing either ``AppBskyLexicon/Actor/GetPreferencesOutput`` if successful, or `Error` if not. + public func getPreferences() async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -38,7 +38,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, - decodeTo: ActorPreferences.self) + decodeTo: AppBskyLexicon.Actor.GetPreferencesOutput.self) return .success(response) } catch(let error) { diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetProfile.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetProfile.swift index a931a3b628..b44eb83149 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetProfile.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetProfile.swift @@ -33,13 +33,13 @@ extension ATProtoKit { /// - pdsURL: The URL of the Personal Data Server (PDS). Defaults to `nil`. /// - shouldAuthenticate: Indicates whether the method will use the access token when /// sending the request. Defaults to `false`. - /// - Returns: A `Result`, containing ``ActorGetProfileOutput`` + /// - Returns: A `Result`, containing ``AppBskyLexicon/Actor/GetProfileOutput`` /// if successful, or an `Error` if not. public func getProfile( _ actor: String, pdsURL: String? = nil, shouldAuthenticate: Bool = false - ) async throws -> Result { + ) async throws -> Result { let authorizationValue = prepareAuthorizationValue( methodPDSURL: pdsURL, shouldAuthenticate: shouldAuthenticate, @@ -68,9 +68,8 @@ extension ATProtoKit { andMethod: .get, contentTypeValue: nil, authorizationValue: authorizationValue) - let actorProfileViewDetailedResult = try await APIClientService.sendRequest(request, - decodeTo: ActorProfileViewDetailed.self) - let result = ActorGetProfileOutput(actorProfileView: actorProfileViewDetailedResult) + let result = try await APIClientService.sendRequest(request, + decodeTo: AppBskyLexicon.Actor.GetProfileOutput.self) return .success(result) } catch { diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetProfiles.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetProfiles.swift index b5dc77f248..70d9abfc74 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetProfiles.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetProfiles.swift @@ -35,13 +35,13 @@ extension ATProtoKit { /// - pdsURL: The URL of the Personal Data Server (PDS). Defaults to `nil`. /// - shouldAuthenticate: Indicates whether the method will use the access token when /// sending the request. Defaults to `false`. - /// - Returns: A `Result`, containing ``ActorGetProfileOutput`` + /// - Returns: A `Result`, containing ``AppBskyLexicon/Actor/GetProfilesOutput`` /// if successful, or an `Error` if not. public func getProfiles( _ actors: [String], pdsURL: String? = nil, shouldAuthenticate: Bool = false - ) async throws -> Result { + ) async throws -> Result { let authorizationValue = prepareAuthorizationValue( methodPDSURL: pdsURL, shouldAuthenticate: shouldAuthenticate, @@ -71,10 +71,10 @@ extension ATProtoKit { andMethod: .get, contentTypeValue: nil, authorizationValue: authorizationValue) - let actorProfileViewsDetailedResult = try await APIClientService.sendRequest(request, - decodeTo: ActorGetProfilesOutput.self) + let result = try await APIClientService.sendRequest(request, + decodeTo: AppBskyLexicon.Actor.GetProfilesOutput.self) - return .success(actorProfileViewsDetailedResult) + return .success(result) } catch { return .failure(error) } diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetRelationships.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetRelationships.swift index 1d6572015b..4e1173c3df 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetRelationships.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetRelationships.swift @@ -23,14 +23,14 @@ extension ATProtoKit { /// - otherDIDs: An array of decentralized identifiers (DIDs) for the other user accounts /// that the primary user account may be related to. Optional. Current maximum item length /// is `30`. - /// - Returns: A `Result`, containing either a ``GraphGetRelationships`` + /// - Returns: A `Result`, containing either a ``AppBskyLexicon/Graph/GetRelationshipsOutput`` /// if successful, or an `Error` if not. public func getRelationships( between actorDID: String, and otherDIDs: [String]? = nil, maxLength: Int? = 50, pdsURL: String? = nil - ) async throws -> Result { + ) async throws -> Result { guard let sessionURL = pdsURL != nil ? pdsURL : session?.pdsURL, let requestURL = URL(string: "\(sessionURL)/xrpc/app.bsky.graph.getRelationships") else { return .failure(ATRequestPrepareError.invalidRequestURL) @@ -59,7 +59,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: nil) let response = try await APIClientService.sendRequest(request, - decodeTo: GraphGetRelationships.self) + decodeTo: AppBskyLexicon.Graph.GetRelationshipsOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetRepostedBy.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetRepostedBy.swift index 999b18386c..243123db54 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetRepostedBy.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetRepostedBy.swift @@ -24,14 +24,14 @@ extension ATProtoKit { /// - limit: The number of items that can be in the list. Optional. Defaults to `50`. /// - cursor: The mark used to indicate the starting point for the next set of /// result. Optional. - /// - Returns: A `Result`, containing either a ``FeedGetRepostedBy`` + /// - Returns: A `Result`, containing either a ``AppBskyLexicon/Feed/GetRepostedByOutput`` /// if successful, or an `Error` if not. public func getRepostedBy( _ postURI: String, postCID: String? = nil, limit: Int? = 50, cursor: String? = nil - ) async throws -> Result { + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -73,7 +73,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, - decodeTo: FeedGetRepostedBy.self) + decodeTo: AppBskyLexicon.Feed.GetRepostedByOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetSuggestedFeeds.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetSuggestedFeeds.swift index 2a5b970c5a..0f199351c7 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetSuggestedFeeds.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetSuggestedFeeds.swift @@ -22,12 +22,12 @@ extension ATProtoKit { /// - limit: The number of items the list will hold. Optional. Defaults to `50`. /// - cursor: The mark used to indicate the starting point for the next set of /// result. Optional. - /// - Returns: A `Result`, containing either a ``FeedGetSuggestedFeedsOutput`` + /// - Returns: A `Result`, containing either a ``AppBskyLexicon/Feed/GetSuggestedFeedsOutput`` /// if successful, or an `Error` if not. public func getSuggestedFeeds( limit: Int? = 50, cursor: String? = nil - ) async throws -> Result { + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -63,7 +63,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, - decodeTo: FeedGetSuggestedFeedsOutput.self) + decodeTo: AppBskyLexicon.Feed.GetSuggestedFeedsOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetSuggestedFollowsByActor.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetSuggestedFollowsByActor.swift index f6e20bb32e..4b08e2cc05 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetSuggestedFollowsByActor.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetSuggestedFollowsByActor.swift @@ -21,9 +21,9 @@ extension ATProtoKit { /// /// - Parameter actorDID: The decentralized identifier (DID) or handle of the user account /// that the suggestions are based on. - /// - Returns: A `Result`, containing either a ``GraphGetSuggestedFollowsByActorOutput`` + /// - Returns: A `Result`, containing either a ``AppBskyLexicon/Graph/GetSuggestedFollowsByActorOutput`` /// if successful, or an `Error` if not. - public func getSuggestedFollowsByActor(_ actorDID: String) async throws -> Result { + public func getSuggestedFollowsByActor(_ actorDID: String) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -53,7 +53,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, - decodeTo: GraphGetSuggestedFollowsByActorOutput.self) + decodeTo: AppBskyLexicon.Graph.GetSuggestedFollowsByActorOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetSuggestions.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetSuggestions.swift index 5a2cec54f9..c6acdb13c9 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetSuggestions.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetSuggestions.swift @@ -23,12 +23,12 @@ extension ATProtoKit { /// Can only choose between 1 and 100. /// - cursor: The mark used to indicate the starting point for the next set of /// results. Optional. - /// - Returns: A `Result`, containing either an ``ActorGetSuggestionsOutput`` + /// - Returns: A `Result`, containing either an ``AppBskyLexicon/Actor/GetSuggestionsOutput`` /// if succesful, or an `Error` if it's not. public func getSuggestions( limit: Int? = 50, cursor: String? = nil - ) async throws -> Result { + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -61,7 +61,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, - decodeTo: ActorGetSuggestionsOutput.self) + decodeTo: AppBskyLexicon.Actor.GetSuggestionsOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetSuggestionsSkeleton.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetSuggestionsSkeleton.swift index 7f952c5c48..a5de2ceda7 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetSuggestionsSkeleton.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetSuggestionsSkeleton.swift @@ -26,12 +26,12 @@ extension ATProtoKit { /// - viewerDID: The decentralized identifier (DID) of the requesting account. Optional. /// - limit: - limit: The number of items the list will hold. Optional. Defaults to `50`. Can /// only be between `1` and `100`. - /// - Returns: A `Result`, containing either an ``UnspeccedGetSuggestionsSkeletonOutput`` + /// - Returns: A `Result`, containing either an ``AppBskyLexicon/Unspecced/GetSuggestionsSkeletonOutput`` /// if successful, or an `Error` if not. public func getSuggestionsSkeleton( viewerDID: String?, limit: Int? = 50 - ) async throws -> Result { + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -67,7 +67,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, - decodeTo: UnspeccedGetSuggestionsSkeletonOutput.self) + decodeTo: AppBskyLexicon.Unspecced.GetSuggestionsSkeletonOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetTaggedSuggestions.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetTaggedSuggestions.swift index 414039afac..a16e09deca 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetTaggedSuggestions.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetTaggedSuggestions.swift @@ -21,9 +21,9 @@ extension ATProtoKit { /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/unspecced/getTaggedSuggestions.json /// - /// - Returns: A `Result`, containing either an ``UnspeccedGetTaggedSuggestionsOutput`` + /// - Returns: A `Result`, containing either an ``AppBskyLexicon/Unspecced/GetTaggedSuggestionsOutput`` /// if successful, or an `Error` if not. - public func getTaggedSuggestions(pdsURL: String? = nil) async throws -> Result { + public func getTaggedSuggestions(pdsURL: String? = nil) async throws -> Result { guard let sessionURL = pdsURL != nil ? pdsURL : session?.pdsURL, let requestURL = URL(string: "\(sessionURL)/xrpc/app.bsky.unspecced.getTaggedSuggestions") else { return .failure(ATRequestPrepareError.invalidRequestURL) @@ -36,7 +36,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: nil) let response = try await APIClientService.sendRequest(request, - decodeTo: UnspeccedGetTaggedSuggestionsOutput.self) + decodeTo: AppBskyLexicon.Unspecced.GetTaggedSuggestionsOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetTimeline.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetTimeline.swift index 3213fa49d1..e1e956abe7 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetTimeline.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetTimeline.swift @@ -29,13 +29,13 @@ extension ATProtoKit { /// - limit: The number of items the list will hold. Optional. Defaults to `50`. Can only be /// between `1` and `100`. /// - cursor: The mark used to indicate the starting point for the next set of result. Optional. - /// - Returns: A `Result`, containing either a ``FeedGetTimelineOutput`` + /// - Returns: A `Result`, containing either a ``AppBskyLexicon/Feed/GetTimelineOutput`` /// if successful, or an `Error` if not. public func getTimeline( using algorithm: String? = nil, limit: Int? = 50, cursor: String? = nil - ) async throws -> Result { + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -74,7 +74,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, - decodeTo: FeedGetTimelineOutput.self) + decodeTo: AppBskyLexicon.Feed.GetTimelineOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/GetUnreadCount.swift b/Sources/ATProtoKit/Networking/PlatformAPI/GetUnreadCount.swift index 73fa9e6496..48097b905d 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/GetUnreadCount.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/GetUnreadCount.swift @@ -20,11 +20,11 @@ extension ATProtoKit { /// /// - Parameter seenAt: The date and time the notifications were seen. Defaults to the date and /// time the request was sent. - /// - Returns: A `Result`, containing either a ``NotificationGetUnreadCountOutput`` + /// - Returns: A `Result`, containing either a ``AppBskyLexicon/Notification/GetUnreadCountOutput`` /// if successful, or an `Error` if not. public func getUnreadCount( seenAt: Date = Date.now - ) async throws -> Result { + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -55,7 +55,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, - decodeTo: NotificationGetUnreadCountOutput.self) + decodeTo: AppBskyLexicon.Notification.GetUnreadCountOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/ListNotifications.swift b/Sources/ATProtoKit/Networking/PlatformAPI/ListNotifications.swift index b0780796ed..768e8ae37f 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/ListNotifications.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/ListNotifications.swift @@ -24,13 +24,13 @@ extension ATProtoKit { /// results. Optional. /// - seenAt: The date and time the notification was seen. Defaults to the date and time the /// request was sent. - /// - Returns: A `Result`, containing either a ``NotificationListNotificationsOutput`` + /// - Returns: A `Result`, containing either a ``AppBskyLexicon/Notification/ListNotificationsOutput`` /// if successful, or an `Error` if not. public func listNotifications( withLimitOf limit: Int? = 50, cursor: String? = nil, seenAt: Date = Date.now - ) async throws -> Result { + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -72,7 +72,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, - decodeTo: NotificationListNotificationsOutput.self) + decodeTo: AppBskyLexicon.Notification.ListNotificationsOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/MuteActor.swift b/Sources/ATProtoKit/Networking/PlatformAPI/MuteActor.swift index 9502522565..0fa93064ea 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/MuteActor.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/MuteActor.swift @@ -30,7 +30,7 @@ extension ATProtoKit { throw ATRequestPrepareError.invalidRequestURL } - let requestBody = GraphMuteActor( + let requestBody = AppBskyLexicon.Graph.MuteActorRequestBody( actorDID: actorDID ) diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/MuteActorList.swift b/Sources/ATProtoKit/Networking/PlatformAPI/MuteActorList.swift index 4eb923f027..4bdb543821 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/MuteActorList.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/MuteActorList.swift @@ -30,7 +30,7 @@ extension ATProtoKit { throw ATRequestPrepareError.invalidRequestURL } - let requestBody = GraphMuteActorList( + let requestBody = AppBskyLexicon.Graph.MuteActorListRequestBody( listURI: listURI ) diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/PutPreferences.swift b/Sources/ATProtoKit/Networking/PlatformAPI/PutPreferences.swift index eb616b9b45..18650e37e9 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/PutPreferences.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/PutPreferences.swift @@ -19,7 +19,7 @@ extension ATProtoKit { /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/putPreferences.json /// /// - Parameter preferences: An array of preferences the user wants to change. - public func putPreferences(preferences: ActorPreferences) async throws { + public func putPreferences(preferences: AppBskyLexicon.Actor.PreferencesDefinition) async throws { guard session != nil, let accessToken = session?.accessToken else { throw ATRequestPrepareError.missingActiveSession @@ -30,7 +30,7 @@ extension ATProtoKit { throw ATRequestPrepareError.invalidRequestURL } - let requestBody = ActorPutPreferences( + let requestBody = AppBskyLexicon.Actor.PutPreferencesRequestBody( preferences: preferences.preferences ) diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/RegisterPush.swift b/Sources/ATProtoKit/Networking/PlatformAPI/RegisterPush.swift index ab653896ad..66c51b3ae6 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/RegisterPush.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/RegisterPush.swift @@ -26,7 +26,7 @@ extension ATProtoKit { public func registerPush( serviceDID: String, token: String, - platform: RegisterPushRequest.Platform, + platform: AppBskyLexicon.Notification.RegisterPush.Platform, appID: String ) async throws { guard session != nil, @@ -39,7 +39,7 @@ extension ATProtoKit { throw ATRequestPrepareError.invalidRequestURL } - let requestBody = RegisterPushRequest( + let requestBody = AppBskyLexicon.Notification.RegisterPushRequestBody( serviceDID: serviceDID, token: token, platform: platform, diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/SearchActorsSkeleton.swift b/Sources/ATProtoKit/Networking/PlatformAPI/SearchActorsSkeleton.swift index 33e217ad77..0aafc8f346 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/SearchActorsSkeleton.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/SearchActorsSkeleton.swift @@ -28,7 +28,7 @@ extension ATProtoKit { /// - limit: The number of items that can be in the list. Optional. Defaults to `25`. /// - cursor: The mark used to indicate the starting point for the next set of /// result. Optional. - /// - Returns: A `Result`, containing either an ``UnspeccedSearchActorsSkeletonOutput`` + /// - Returns: A `Result`, containing either an ``AppBskyLexicon/Unspecced/SearchActorsSkeletonOutput`` /// if successful, or an `Error` if not. public func searchActorsSkeleton( _ query: String, @@ -37,7 +37,7 @@ extension ATProtoKit { limit: Int? = 25, cursor: String? = nil, pdsURL: String? = nil - ) async throws -> Result { + ) async throws -> Result { guard let sessionURL = pdsURL != nil ? pdsURL : session?.pdsURL, let requestURL = URL(string: "\(sessionURL)/xrpc/app.bsky.unspecced.searchActorsSkeleton") else { return .failure(ATRequestPrepareError.invalidRequestURL) @@ -78,7 +78,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: nil) let response = try await APIClientService.sendRequest(request, - decodeTo: UnspeccedSearchActorsSkeletonOutput.self) + decodeTo: AppBskyLexicon.Unspecced.SearchActorsSkeletonOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/SearchPosts.swift b/Sources/ATProtoKit/Networking/PlatformAPI/SearchPosts.swift index 444a5aca50..a25d438b2e 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/SearchPosts.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/SearchPosts.swift @@ -39,11 +39,11 @@ extension ATProtoKit { /// Can only choose between `1` and `100`. /// - cursor: The mark used to indicate the starting point for the next set of /// results. Optional. - /// - Returns: A `Result`, containing either an ``FeedSearchPostsOutput`` + /// - Returns: A `Result`, containing either an ``AppBskyLexicon/Feed/SearchPostsOutput`` /// if succesful, or an `Error` if it's not. public func searchPosts( with searchQuery: String, - sortRanking: FeedSearchPostsSortRanking? = .latest, + sortRanking: AppBskyLexicon.Feed.SearchPosts.SortRanking? = .latest, sinceDate: Date?, untilDate: Date?, mentionIdentifier: String? = nil, @@ -54,7 +54,7 @@ extension ATProtoKit { tags: [String]?, limit: Int? = 25, cursor: String? = nil - ) async throws -> Result { + ) async throws -> Result { guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -128,7 +128,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, - decodeTo: FeedSearchPostsOutput.self) + decodeTo: AppBskyLexicon.Feed.SearchPostsOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/SearchPostsSkeleton.swift b/Sources/ATProtoKit/Networking/PlatformAPI/SearchPostsSkeleton.swift index 024b490acf..140dac4dcd 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/SearchPostsSkeleton.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/SearchPostsSkeleton.swift @@ -42,11 +42,11 @@ extension ATProtoKit { /// to `25`. /// - cursor: The mark used to indicate the starting point for the next set of /// result. Optional. - /// - Returns: A `Result`, containing either an ``UnspeccedSearchPostsSkeletonOutput`` + /// - Returns: A `Result`, containing either an ``AppBskyLexicon/Unspecced/SearchPostsSkeletonOutput`` /// if successful, or an `Error` if not. public func searchPostsSkeleton( with searchQuery: String, - sortRanking: UnspeccedSearchPostsSortRanking? = .latest, + sortRanking: AppBskyLexicon.Unspecced.SearchPostsSkeleton.Sort? = .latest, sinceDate: Date?, untilDate: Date?, mentionIdentifier: String? = nil, @@ -58,7 +58,7 @@ extension ATProtoKit { limit: Int? = 25, cursor: String? = nil, pdsURL: String? = nil - ) async throws -> Result { + ) async throws -> Result { guard let sessionURL = pdsURL != nil ? pdsURL : session?.pdsURL, let requestURL = URL(string: "\(sessionURL)/xrpc/app.bsky.unspecced.searchPostsSkeleton") else { return .failure(ATRequestPrepareError.invalidRequestURL) @@ -127,7 +127,7 @@ extension ATProtoKit { contentTypeValue: nil, authorizationValue: nil) let response = try await APIClientService.sendRequest(request, - decodeTo: UnspeccedSearchPostsSkeletonOutput.self) + decodeTo: AppBskyLexicon.Unspecced.SearchPostsSkeletonOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/SearchUsers.swift b/Sources/ATProtoKit/Networking/PlatformAPI/SearchUsers.swift index 606b298fc4..238285245d 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/SearchUsers.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/SearchUsers.swift @@ -38,7 +38,7 @@ extension ATProtoKit { /// - pdsURL: The URL of the Personal Data Server (PDS). Defaults to `nil`. /// - shouldAuthenticate: Indicates whether the method will use the access token /// when sending the request. Defaults to `false`. - /// - Returns: A `Result`, containing either ``ActorSearchActorsOutput`` + /// - Returns: A `Result`, containing either ``AppBskyLexicon/Actor/SearchActorsOutput`` /// if successful, and an `Error` if not. public func searchUsers( by query: String, @@ -46,7 +46,7 @@ extension ATProtoKit { cursor: String? = nil, pdsURL: String? = nil, shouldAuthenticate: Bool = false - ) async throws -> Result { + ) async throws -> Result { let authorizationValue = prepareAuthorizationValue( methodPDSURL: pdsURL, shouldAuthenticate: shouldAuthenticate, @@ -84,7 +84,7 @@ extension ATProtoKit { acceptValue: "application/json", authorizationValue: authorizationValue) let response = try await APIClientService.sendRequest(request, - decodeTo: ActorSearchActorsOutput.self) + decodeTo: AppBskyLexicon.Actor.SearchActorsOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/SearchUsersTypeahead.swift b/Sources/ATProtoKit/Networking/PlatformAPI/SearchUsersTypeahead.swift index caa4f8e370..aba76ca9fc 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/SearchUsersTypeahead.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/SearchUsersTypeahead.swift @@ -37,14 +37,14 @@ extension ATProtoKit { /// - pdsURL: The URL of the Personal Data Server (PDS). Defaults to `nil`. /// - shouldAuthenticate: Indicates whether the method will use the access token when /// sending the request. Defaults to `false`. - /// - Returns: A `Result`, containing either ``ActorSearchActorsOutput`` + /// - Returns: A `Result`, containing either ``AppBskyLexicon/Actor/SearchActorsTypeaheadOutput`` /// if successful, and an `Error` if not. public func searchUsersTypeahead( by query: String, limit: Int? = 10, pdsURL: String? = nil, shouldAuthenticate: Bool = false - ) async throws -> Result { + ) async throws -> Result { let authorizationValue = prepareAuthorizationValue( methodPDSURL: pdsURL, shouldAuthenticate: shouldAuthenticate, @@ -79,7 +79,7 @@ extension ATProtoKit { acceptValue: "application/json", authorizationValue: authorizationValue) let response = try await APIClientService.sendRequest(request, - decodeTo: ActorSearchActorsTypeaheadOutput.self) + decodeTo: AppBskyLexicon.Actor.SearchActorsTypeaheadOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/SendInteractions.swift b/Sources/ATProtoKit/Networking/PlatformAPI/SendInteractions.swift index 135366e69a..bef2274a05 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/SendInteractions.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/SendInteractions.swift @@ -22,9 +22,11 @@ extension ATProtoKit { /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/sendInteractions.json /// /// - Parameter interactions: An array of interactions. - /// - Returns: A `Result`, containing either a ``FeedSendInteractionsOutput`` + /// - Returns: A `Result`, containing either a ``AppBskyLexicon/Feed/SendInteractionsOutput`` /// if sucessful, or an `Error` if not. - public func sendInteractions(_ interactions: [FeedInteraction]) async throws -> Result{ + public func sendInteractions( + _ interactions: [AppBskyLexicon.Feed.InteractionDefinition] + ) async throws -> Result{ guard session != nil, let accessToken = session?.accessToken else { return .failure(ATRequestPrepareError.missingActiveSession) @@ -35,7 +37,7 @@ extension ATProtoKit { return .failure(ATRequestPrepareError.invalidRequestURL) } - let requestBody = FeedSendInteractions( + let requestBody = AppBskyLexicon.Feed.SendInteractionsRequestBody( interactions: interactions ) @@ -47,7 +49,7 @@ extension ATProtoKit { authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, withEncodingBody: requestBody, - decodeTo: FeedSendInteractionsOutput.self) + decodeTo: AppBskyLexicon.Feed.SendInteractionsOutput.self) return .success(response) } catch { diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/UnmuteActor.swift b/Sources/ATProtoKit/Networking/PlatformAPI/UnmuteActor.swift index c7ecc70370..5fd069b3a4 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/UnmuteActor.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/UnmuteActor.swift @@ -31,7 +31,7 @@ extension ATProtoKit { throw ATRequestPrepareError.invalidRequestURL } - let requestBody = GraphUnmuteActor( + let requestBody = AppBskyLexicon.Graph.UnmuteActorRequestBody( actorDID: actorDID ) diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/UnmuteActorList.swift b/Sources/ATProtoKit/Networking/PlatformAPI/UnmuteActorList.swift index 6a9a56d62b..c1349a4de3 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/UnmuteActorList.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/UnmuteActorList.swift @@ -30,7 +30,7 @@ extension ATProtoKit { throw ATRequestPrepareError.invalidRequestURL } - let requestBody = GraphUnmuteActorList( + let requestBody = AppBskyLexicon.Graph.UnmuteActorListRequestBody( listURI: listURI ) diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/UpdateSeen.swift b/Sources/ATProtoKit/Networking/PlatformAPI/UpdateSeen.swift index 58671c70df..284e42f6c3 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/UpdateSeen.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/UpdateSeen.swift @@ -31,7 +31,7 @@ extension ATProtoKit { throw ATRequestPrepareError.invalidRequestURL } - let requestBody = NotificationUpdateSeen( + let requestBody = AppBskyLexicon.Notification.UpdateSeenRequestBody( seenAt: seenAt ) diff --git a/Sources/ATProtoKit/Utilities/APIClientService.swift b/Sources/ATProtoKit/Utilities/APIClientService.swift index 560ffe4957..c84b8641d2 100644 --- a/Sources/ATProtoKit/Utilities/APIClientService.swift +++ b/Sources/ATProtoKit/Utilities/APIClientService.swift @@ -134,7 +134,7 @@ public class APIClientService { /// - imageData: The data of the blob to upload. /// - Returns: A `BlobContainer` instance with the upload result. public static func uploadBlob(pdsURL: String = "https://bsky.social", accessToken: String, filename: String, - imageData: Data) async throws -> BlobContainer { + imageData: Data) async throws -> ComAtprotoLexicon.Repository.BlobContainer { guard let requestURL = URL(string: "\(pdsURL)/xrpc/com.atproto.repo.uploadBlob") else { throw ATRequestPrepareError.invalidRequestURL } @@ -150,7 +150,7 @@ public class APIClientService { request.httpBody = imageData let response = try await sendRequest(request, - decodeTo: BlobContainer.self) + decodeTo: ComAtprotoLexicon.Repository.BlobContainer.self) return response } catch { diff --git a/Sources/ATProtoKit/Utilities/ATFacetParser.swift b/Sources/ATProtoKit/Utilities/ATFacetParser.swift index 1b1cecf1d8..35685d6afa 100644 --- a/Sources/ATProtoKit/Utilities/ATFacetParser.swift +++ b/Sources/ATProtoKit/Utilities/ATFacetParser.swift @@ -10,15 +10,15 @@ import Foundation /// A utility class designed for parsing various elements like mentions, URLs, and hashtags from text. public class ATFacetParser { - /// Manages a collection of ``Facet`` objects, providing thread-safe append operations. + /// Manages a collection of ``AppBskyLexicon/RichText/Facet`` objects, providing thread-safe append operations. actor FacetsActor { - /// The collection of ``Facet`` objects. - var facets = [Facet]() - - /// Appends a new ``Facet`` to the collection in a thread-safe manner. - /// - Parameter facet: Parameter facet: The ``Facet`` to append. - func append(_ facet: Facet) { + /// The collection of ``AppBskyLexicon/RichText/Facet`` objects. + var facets = [AppBskyLexicon.RichText.Facet]() + + /// Appends a new ``AppBskyLexicon/RichText/Facet`` to the collection in a thread-safe manner. + /// - Parameter facet: Parameter facet: The ``AppBskyLexicon/RichText/Facet`` to append. + func append(_ facet: AppBskyLexicon.RichText.Facet) { facets.append(facet) } } @@ -136,13 +136,13 @@ public class ATFacetParser { } /// Processes text to find mentions, URLs, and hashtags, converting these elements into - /// ``Facet`` objects. + /// ``AppBskyLexicon/RichText/Facet`` objects. /// - Parameters: /// - text: The text to be processed. /// - pdsURL: The URL of the Personal Data Server, defaulting to "https://bsky.social". - /// - Returns: An array of ``Facet`` objects representing the structured data elements found + /// - Returns: An array of ``AppBskyLexicon/RichText/Facet`` objects representing the structured data elements found /// in the text. - public static func parseFacets(from text: String, pdsURL: String = "https://bsky.social") async -> [Facet] { + public static func parseFacets(from text: String, pdsURL: String = "https://bsky.social") async -> [AppBskyLexicon.RichText.Facet] { let facets = FacetsActor() await withTaskGroup(of: Void.self) { group in @@ -174,8 +174,8 @@ public class ATFacetParser { case .success(let resolveHandleOutput): guard let start = mention["start"] as? Int, let end = mention["end"] as? Int else { return } - let mentionFacet = Facet( - index: ByteSlice(byteStart: start, byteEnd: end), + let mentionFacet = AppBskyLexicon.RichText.Facet( + index: AppBskyLexicon.RichText.Facet.ByteSlice(byteStart: start, byteEnd: end), features: [.mention(Mention(did: resolveHandleOutput.handleDID))]) await facets.append(mentionFacet) @@ -197,8 +197,8 @@ public class ATFacetParser { if let start = link["start"] as? Int, let end = link["end"] as? Int { - let linkFacet = Facet( - index: ByteSlice(byteStart: start, byteEnd: end), + let linkFacet = AppBskyLexicon.RichText.Facet( + index: AppBskyLexicon.RichText.Facet.ByteSlice(byteStart: start, byteEnd: end), features: [.link(Link(uri: url))] ) @@ -216,8 +216,8 @@ public class ATFacetParser { if let start = hashtag["start"] as? Int, let end = hashtag["end"] as? Int { - let hashTagFacet = Facet( - index: ByteSlice(byteStart: start, byteEnd: end), + let hashTagFacet = AppBskyLexicon.RichText.Facet( + index: AppBskyLexicon.RichText.Facet.ByteSlice(byteStart: start, byteEnd: end), features: [.tag(Tag(tag: tag))] ) diff --git a/Sources/ATProtoKit/Utilities/ATProtoTools.swift b/Sources/ATProtoKit/Utilities/ATProtoTools.swift index 0d01bb0d92..3d8372cfa7 100644 --- a/Sources/ATProtoKit/Utilities/ATProtoTools.swift +++ b/Sources/ATProtoKit/Utilities/ATProtoTools.swift @@ -19,34 +19,67 @@ import Foundation /// - Important: The rule where the method becomes deprecated will be active either /// when version 1.0 is launched or `ATProtoTools` is stabilized, whichever comes first. /// Until then, if a method is better suited elsewhere, it will be immediately moved. -class ATProtoTools { +public class ATProtoTools { /// Resolves the reply references to prepare them for a later post record request. /// /// - Parameter parentURI: The URI of the post record the current one is directly replying to. /// - Returns: A ``ReplyReference``. - public func resolveReplyReferences(parentURI: String) async throws -> ReplyReference { - let parentRecord = try await fetchRecordForURI(parentURI) + public func resolveReplyReferences(parentURI: String) async throws -> AppBskyLexicon.Feed.PostRecord.ReplyReference { + let threadRecords = try await fetchRecordForURI(parentURI) - guard let replyReference = parentRecord.value?.reply else { - // The parent record is a top-level post, so it is also the root - return createReplyReference(from: parentRecord) + guard let parentRecord = threadRecords.value else { + return createReplyReference(from: threadRecords) } + var replyReference: AppBskyLexicon.Feed.PostRecord.ReplyReference? + + switch parentRecord { + case .unknown(let unknown): + replyReference = try decodeReplyReference(from: unknown) + default: + break + } + + if let replyReference = replyReference { + return try await getReplyReferenceWithRoot(replyReference) + } + + return createReplyReference(from: threadRecords) + } + + private func decodeReplyReference(from unknown: [String: Any]) throws -> AppBskyLexicon.Feed.PostRecord.ReplyReference? { + if let replyData = unknown["reply"] as? [String: Any] { + let jsonData = try JSONSerialization.data(withJSONObject: replyData, options: []) + let decoder = JSONDecoder() + return try decoder.decode(AppBskyLexicon.Feed.PostRecord.ReplyReference.self, from: jsonData) + } + return nil + } + + private func getReplyReferenceWithRoot( + _ replyReference: AppBskyLexicon.Feed.PostRecord.ReplyReference) async throws -> AppBskyLexicon.Feed.PostRecord.ReplyReference { let rootRecord = try await fetchRecordForURI(replyReference.root.recordURI) - let rootReference = rootRecord.value?.reply?.root ?? replyReference.root - return ReplyReference(root: rootReference, parent: replyReference.parent) + if let rootReferenceValue = rootRecord.value { + switch rootReferenceValue { + case .unknown: + return AppBskyLexicon.Feed.PostRecord.ReplyReference(root: replyReference.root, parent: replyReference.parent) + default: + return AppBskyLexicon.Feed.PostRecord.ReplyReference(root: replyReference.root, parent: replyReference.parent) + } + } + return AppBskyLexicon.Feed.PostRecord.ReplyReference(root: replyReference.root, parent: replyReference.parent) } /// Gets a record from the user's repository. /// /// - Parameter uri: The URI of the record. /// - Returns: A ``RecordOutput`` - public func fetchRecordForURI(_ uri: String) async throws -> RecordOutput { + public func fetchRecordForURI(_ uri: String) async throws -> ComAtprotoLexicon.Repository.GetRecordOutput { let query = try parseURI(uri) - let record = try await ATProtoKit().getRepositoryRecord(from: query, pdsURL: nil) + let record = try await ATProtoKit().getRepositoryRecord(from: query.repository, collection: query.collection, recordKey: query.recordKey, pdsURL: nil) switch record { case .success(let result): @@ -60,9 +93,10 @@ class ATProtoTools { /// /// - Parameter record: The record to convert. /// - Returns: A ``ReplyReference``. - private func createReplyReference(from record: RecordOutput) -> ReplyReference { - let reference = StrongReference(recordURI: record.recordURI, cidHash: record.recordCID) - return ReplyReference(root: reference, parent: reference) + private func createReplyReference(from record: ComAtprotoLexicon.Repository.GetRecordOutput) -> AppBskyLexicon.Feed.PostRecord.ReplyReference { + let reference = ComAtprotoLexicon.Repository.StrongReference(recordURI: record.recordURI, cidHash: record.recordCID) + + return AppBskyLexicon.Feed.PostRecord.ReplyReference(root: reference, parent: reference) } /// Parses the URI in order to get a ``RecordQuery``. @@ -82,11 +116,12 @@ class ATProtoTools { let components = uri.split(separator: "/").map(String.init) guard components.count >= 4 else { throw ATRequestPrepareError.invalidFormat } - return RecordQuery(repo: components[1], collection: components[2], recordKey: components[3]) + return ATProtoTools.RecordQuery(repository: components[1], collection: components[2], recordKey: components[3]) } else if uri.hasPrefix("\(pdsURL)/") { let components = uri.split(separator: "/").map(String.init) guard components.count >= 6 else { - throw ATRequestPrepareError.invalidFormat } + throw ATRequestPrepareError.invalidFormat + } let record = components[3] let recordKey = components[5] @@ -103,9 +138,47 @@ class ATProtoTools { throw ATRequestPrepareError.invalidFormat } - return RecordQuery(repo: record, collection: collection, recordKey: recordKey) + return RecordQuery(repository: record, collection: collection, recordKey: recordKey) } else { throw ATRequestPrepareError.invalidFormat } } + + /// A structure for a record. + public struct RecordQuery: Codable { + + /// The handle or decentralized identifier (DID) of the repo." + /// + /// - Note: According to the AT Protocol specifications: "The handle or DID of the repo." + public let repository: String + + /// The NSID of the record. + /// + /// - Note: According to the AT Protocol specifications: "The NSID of the record collection." + public let collection: String + + /// The record's key. + /// + //// - Note: According to the AT Protocol specifications: "The Record Key." + public let recordKey: String + + /// The CID of the version of the record. Optional. Defaults to `nil`. + /// + /// - Note: According to the AT Protocol specifications: "The CID of the version of the record. + /// If not specified, then return the most recent version." + public let recordCID: String? = nil + + public init(repository: String, collection: String, recordKey: String) { + self.repository = repository + self.collection = collection + self.recordKey = recordKey + } + + enum CodingKeys: String, CodingKey { + case repository = "repo" + case collection = "collection" + case recordKey = "rkey" + case recordCID = "cid" + } + } } From 69fcaf07f1d684171639018dba57dac0d967ba37 Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Thu, 30 May 2024 21:02:12 -0400 Subject: [PATCH 26/51] Replace record structs in ATProtoKit class --- Sources/ATProtoKit/ATProtoKit.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Sources/ATProtoKit/ATProtoKit.swift b/Sources/ATProtoKit/ATProtoKit.swift index d3dc8bd739..3776ed403c 100644 --- a/Sources/ATProtoKit/ATProtoKit.swift +++ b/Sources/ATProtoKit/ATProtoKit.swift @@ -124,8 +124,10 @@ public class ATProtoKit: ATProtoKitConfiguration { /// /// If `canUseBlueskyRecords` is set to `false`, these will not be used. private let recordLexicons: [ATRecordProtocol.Type] = [ - FeedGenerator.self, FeedLike.self, FeedPost.self, FeedRepost.self, FeedThreadgate.self, GraphBlock.self, GraphFollow.self, GraphList.self, - GraphListBlock.self, GraphListItem.self, LabelerService.self] + AppBskyLexicon.Feed.GeneratorRecord.self, AppBskyLexicon.Feed.LikeRecord.self, AppBskyLexicon.Feed.PostRecord.self, + AppBskyLexicon.Feed.RepostRecord.self, AppBskyLexicon.Feed.ThreadgateRecord.self, AppBskyLexicon.Graph.BlockRecord.self, + AppBskyLexicon.Graph.FollowRecord.self, AppBskyLexicon.Graph.ListRecord.self, AppBskyLexicon.Graph.ListBlockRecord.self, + AppBskyLexicon.Graph.ListItemRecord.self, AppBskyLexicon.Labeler.ServiceRecord.self] /// Specifies the logger that will be used for emitting log messages. public private(set) var logger: Logger? From 92ed1688273f412465de204537e45d9e23951586 Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Thu, 30 May 2024 23:09:58 -0400 Subject: [PATCH 27/51] Add ATProtoBluesky and ATProtoBlueskyChat --- Sources/ATProtoKit/ATProtoKit.swift | 72 +++++++++++++++++++++++++---- 1 file changed, 62 insertions(+), 10 deletions(-) diff --git a/Sources/ATProtoKit/ATProtoKit.swift b/Sources/ATProtoKit/ATProtoKit.swift index 3776ed403c..df42e3b30e 100644 --- a/Sources/ATProtoKit/ATProtoKit.swift +++ b/Sources/ATProtoKit/ATProtoKit.swift @@ -142,12 +142,8 @@ public class ATProtoKit: ATProtoKitConfiguration { /// - session: The authenticated user session within the AT Protocol. Optional. /// - canUseBlueskyRecords: Indicates whether Bluesky's lexicons should be used. /// Defaults to `true`. - /// - logIdentifier: Specifies the identifier for managing log outputs. Optional. Defaults + /// - logger: Specifies the identifier for managing log outputs. Optional. Defaults /// to the project's `CFBundleIdentifier`. - /// - logCategory: Specifies the category name the logs in the logger within ATProtoKit will - /// be in. Optional. Defaults to `ATProtoKit`. - /// - logLevel: Specifies the highest level of logs that will be outputted. Optional. - /// Defaults to `.info`. public init(session: UserSession? = nil, canUseBlueskyRecords: Bool = true, logger: Logger? = nil) { self.session = session self.logger = session?.logger ?? logger @@ -210,14 +206,70 @@ public class ATProtoAdmin: ATProtoKitConfiguration { /// Initializes a new instance of `ATProtoAdmin`. /// - Parameters: /// - session: The authenticated user session within the AT Protocol. - /// - logIdentifier: Specifies the identifier for managing log outputs. Optional. + /// - logger: Specifies the identifier for managing log outputs. Optional. /// Defaults to the project's `CFBundleIdentifier`. - /// - logCategory: Specifies the category name the logs in the logger within ATProtoKit - /// will be in. Optional. Defaults to `ATProtoKit`. - /// - logLevel: Specifies the highest level of logs that will be outputted. Optional. - /// Defaults to `.info`. public init(session: UserSession? = nil, logger: Logger? = nil) { self.session = session self.logger = session?.logger ?? logger } } + +/// The base class that handles all direct Bluesky-related functionality of the ATProtoKit +/// API library. +/// +/// This class requires you to first create an instance of ``ATProtoKit/ATProtoKit``. The class +/// will import the session, Bluesky records, and logging information from the instance. +/// +/// With some exceptions, the main functionality includes adding, putting, and deleting a record. +public class ATProtoBluesky: ATProtoKitConfiguration { + + /// Represents an authenticated user session within the AT Protocol. Optional. + /// + /// - Warning: This is not in use. + public private(set) var session: UserSession? + + /// Specifies the logger that will be used for emitting log messages. + public private(set) var logger: Logger? + + /// Represents the instance of ``ATProtoKit/ATProtoKit``. + private let atProtoKitInstance: ATProtoKit + + /// Initializes a new instance of `ATProtoBluesky`. + /// - Parameters: + /// - atProtoKitInstance: Represents the instance of ``ATProtoKit/ATProtoKit``. + /// - logger: Specifies the identifier for managing log outputs. Optional. + /// Defaults to the project's `CFBundleIdentifier`. + public init(atProtoKitInstance: ATProtoKit, logger: Logger? = nil) { + self.session = nil + self.atProtoKitInstance = atProtoKitInstance + self.logger = self.atProtoKitInstance.session?.logger ?? logger + } +} + +/// The base class that handles the the Bluesky chat functionality of the ATProtoKit API library. +/// +/// This class requires you to first create an instance of ``ATProtoKit/ATProtoKit``. The class +/// will import the session, Bluesky records, and logging information from the instance. +public class ATProtoBlueskyChat: ATProtoKitConfiguration { + + /// Represents an authenticated user session within the AT Protocol. Optional. + /// + /// - Warning: This is not in use. + public private(set) var session: UserSession? + + /// Specifies the logger that will be used for emitting log messages. + public private(set) var logger: Logger? + + /// Represents the instance of ``ATProtoKit/ATProtoKit``. + private let atProtoKitInstance: ATProtoKit + + /// Initializes a new instance of `ATProtoBlueskyChat`. + /// - Parameters: + /// - atProtoKitInstance: Represents the instance of ``ATProtoKit/ATProtoKit``. + /// - logger: Specifies the identifier for managing log outputs. Optional. + /// Defaults to the project's `CFBundleIdentifier`. + public init(atProtoKitInstance: ATProtoKit, logger: Logger? = nil) { + self.atProtoKitInstance = atProtoKitInstance + self.logger = self.atProtoKitInstance.session?.logger ?? logger + } +} From 4ea1a5e6ebd9169a4c9511a360095c59abb51c40 Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Fri, 31 May 2024 02:28:33 -0400 Subject: [PATCH 28/51] Add DeclarationRecord --- Sources/ATProtoKit/ATProtoKit.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/ATProtoKit/ATProtoKit.swift b/Sources/ATProtoKit/ATProtoKit.swift index df42e3b30e..11f20d47cc 100644 --- a/Sources/ATProtoKit/ATProtoKit.swift +++ b/Sources/ATProtoKit/ATProtoKit.swift @@ -127,7 +127,7 @@ public class ATProtoKit: ATProtoKitConfiguration { AppBskyLexicon.Feed.GeneratorRecord.self, AppBskyLexicon.Feed.LikeRecord.self, AppBskyLexicon.Feed.PostRecord.self, AppBskyLexicon.Feed.RepostRecord.self, AppBskyLexicon.Feed.ThreadgateRecord.self, AppBskyLexicon.Graph.BlockRecord.self, AppBskyLexicon.Graph.FollowRecord.self, AppBskyLexicon.Graph.ListRecord.self, AppBskyLexicon.Graph.ListBlockRecord.self, - AppBskyLexicon.Graph.ListItemRecord.self, AppBskyLexicon.Labeler.ServiceRecord.self] + AppBskyLexicon.Graph.ListItemRecord.self, AppBskyLexicon.Labeler.ServiceRecord.self, ChatBskyLexicon.Actor.DeclarationRecord.self] /// Specifies the logger that will be used for emitting log messages. public private(set) var logger: Logger? From ae125cc82d48828ec9cb43dcbcc1accdcbc0b251 Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Fri, 31 May 2024 02:31:52 -0400 Subject: [PATCH 29/51] Use session property --- Sources/ATProtoKit/ATProtoKit.swift | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Sources/ATProtoKit/ATProtoKit.swift b/Sources/ATProtoKit/ATProtoKit.swift index 11f20d47cc..9961539dc9 100644 --- a/Sources/ATProtoKit/ATProtoKit.swift +++ b/Sources/ATProtoKit/ATProtoKit.swift @@ -224,8 +224,6 @@ public class ATProtoAdmin: ATProtoKitConfiguration { public class ATProtoBluesky: ATProtoKitConfiguration { /// Represents an authenticated user session within the AT Protocol. Optional. - /// - /// - Warning: This is not in use. public private(set) var session: UserSession? /// Specifies the logger that will be used for emitting log messages. @@ -240,8 +238,8 @@ public class ATProtoBluesky: ATProtoKitConfiguration { /// - logger: Specifies the identifier for managing log outputs. Optional. /// Defaults to the project's `CFBundleIdentifier`. public init(atProtoKitInstance: ATProtoKit, logger: Logger? = nil) { - self.session = nil self.atProtoKitInstance = atProtoKitInstance + self.session = self.atProtoKitInstance.session ?? nil self.logger = self.atProtoKitInstance.session?.logger ?? logger } } @@ -253,8 +251,6 @@ public class ATProtoBluesky: ATProtoKitConfiguration { public class ATProtoBlueskyChat: ATProtoKitConfiguration { /// Represents an authenticated user session within the AT Protocol. Optional. - /// - /// - Warning: This is not in use. public private(set) var session: UserSession? /// Specifies the logger that will be used for emitting log messages. @@ -270,6 +266,7 @@ public class ATProtoBlueskyChat: ATProtoKitConfiguration { /// Defaults to the project's `CFBundleIdentifier`. public init(atProtoKitInstance: ATProtoKit, logger: Logger? = nil) { self.atProtoKitInstance = atProtoKitInstance + self.session = self.atProtoKitInstance.session ?? nil self.logger = self.atProtoKitInstance.session?.logger ?? logger } } From 4e6bc2c9c949c58e40a0b38ba1e1d4f3e37bedda Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Fri, 31 May 2024 02:41:33 -0400 Subject: [PATCH 30/51] Add note about App Passowords --- Sources/ATProtoKit/ATProtoKit.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sources/ATProtoKit/ATProtoKit.swift b/Sources/ATProtoKit/ATProtoKit.swift index 9961539dc9..e43e7f3830 100644 --- a/Sources/ATProtoKit/ATProtoKit.swift +++ b/Sources/ATProtoKit/ATProtoKit.swift @@ -248,6 +248,9 @@ public class ATProtoBluesky: ATProtoKitConfiguration { /// /// This class requires you to first create an instance of ``ATProtoKit/ATProtoKit``. The class /// will import the session, Bluesky records, and logging information from the instance. +/// +/// - Important: Please use an App Password in ``ATProtocolConfiguration`` that has chatting +/// privileges. Failure to do so will result in an error. public class ATProtoBlueskyChat: ATProtoKitConfiguration { /// Represents an authenticated user session within the AT Protocol. Optional. From 63ff5e6629e1b6b86bc81de0949c21a2897616c0 Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Fri, 31 May 2024 02:43:02 -0400 Subject: [PATCH 31/51] Add ChatDeleteAccount --- .../ChatAPI/ChatDeleteAccount.swift | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Sources/ATProtoKit/Networking/ChatAPI/ChatDeleteAccount.swift diff --git a/Sources/ATProtoKit/Networking/ChatAPI/ChatDeleteAccount.swift b/Sources/ATProtoKit/Networking/ChatAPI/ChatDeleteAccount.swift new file mode 100644 index 0000000000..db5ad25a0e --- /dev/null +++ b/Sources/ATProtoKit/Networking/ChatAPI/ChatDeleteAccount.swift @@ -0,0 +1,46 @@ +// +// ChatDeleteAccount.swift +// +// +// Created by Christopher Jr Riley on 2024-05-31. +// + +import Foundation + +extension ATProtoBlueskyChat { + + /// Deletes a chat account. + /// + /// This only deletes the chat account; the Bluesky account remains in place. + /// + /// - SeeAlso: This is based on the [`chat.bsky.actor.deleteAccount`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/actor/deleteAccount.json + /// + public func deleteAccount() async throws { + guard session != nil, + let accessToken = session?.accessToken else { + throw ATRequestPrepareError.missingActiveSession + } + + guard let sessionURL = session?.pdsURL, + let requestURL = URL(string: "\(sessionURL)/xrpc/chat.bsky.actor.deleteAccount") else { + throw ATRequestPrepareError.invalidRequestURL + } + + let requestBody = ChatBskyLexicon.Actor.DeleteAccount() + + do { + let request = APIClientService.createRequest(forRequest: requestURL, + andMethod: .post, + acceptValue: "application/json", + contentTypeValue: nil, + authorizationValue: "Bearer \(accessToken)") + + try await APIClientService.sendRequest(request, + withEncodingBody: requestBody) + } catch { + throw error + } + } +} From 16c201e776a8b15cee6373e124c816e0e6701f9b Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Fri, 31 May 2024 03:13:12 -0400 Subject: [PATCH 32/51] Add ChatDeleteMessageForSelf and fix typo Also fixed the HTTP methods and changed some of the property types. --- .../ATProtoKit/Models/Lexicons/ATUnion.swift | 20 +++---- .../chat.bsky/Convo/ChatBskyConvoDefs.swift | 2 +- .../ChatBskyConvoDeleteMessageForSelf.swift | 4 +- .../ChatAPI/ChatDeleteAccount.swift | 2 +- .../ChatAPI/ChatDeleteMessageForSelf.swift | 57 +++++++++++++++++++ .../ChatAPI/ChatExportAccountData.swift | 41 +++++++++++++ 6 files changed, 112 insertions(+), 14 deletions(-) create mode 100644 Sources/ATProtoKit/Networking/ChatAPI/ChatDeleteMessageForSelf.swift create mode 100644 Sources/ATProtoKit/Networking/ChatAPI/ChatExportAccountData.swift diff --git a/Sources/ATProtoKit/Models/Lexicons/ATUnion.swift b/Sources/ATProtoKit/Models/Lexicons/ATUnion.swift index 92b6a4441c..d7c3046db4 100644 --- a/Sources/ATProtoKit/Models/Lexicons/ATUnion.swift +++ b/Sources/ATProtoKit/Models/Lexicons/ATUnion.swift @@ -893,14 +893,14 @@ public struct ATUnion { case messageView(ChatBskyLexicon.Conversation.MessageViewDefinition) /// A deleted message view. - case deletedMessageView(ChatBskyLexicon.Conversation.DeleteMessageViewDefinition) + case deletedMessageView(ChatBskyLexicon.Conversation.DeletedMessageViewDefinition) public init(from decoder: any Decoder) throws { let container = try decoder.singleValueContainer() if let value = try? container.decode(ChatBskyLexicon.Conversation.MessageViewDefinition.self) { self = .messageView(value) - } else if let value = try? container.decode(ChatBskyLexicon.Conversation.DeleteMessageViewDefinition.self) { + } else if let value = try? container.decode(ChatBskyLexicon.Conversation.DeletedMessageViewDefinition.self) { self = .deletedMessageView(value) } else { throw DecodingError.typeMismatch( @@ -928,14 +928,14 @@ public struct ATUnion { case messageView(ChatBskyLexicon.Conversation.MessageViewDefinition) /// A deleted message view. - case deletedMessageView(ChatBskyLexicon.Conversation.DeleteMessageViewDefinition) + case deletedMessageView(ChatBskyLexicon.Conversation.DeletedMessageViewDefinition) public init(from decoder: any Decoder) throws { let container = try decoder.singleValueContainer() if let value = try? container.decode(ChatBskyLexicon.Conversation.MessageViewDefinition.self) { self = .messageView(value) - } else if let value = try? container.decode(ChatBskyLexicon.Conversation.DeleteMessageViewDefinition.self) { + } else if let value = try? container.decode(ChatBskyLexicon.Conversation.DeletedMessageViewDefinition.self) { self = .deletedMessageView(value) } else { throw DecodingError.typeMismatch( @@ -963,14 +963,14 @@ public struct ATUnion { case messageView(ChatBskyLexicon.Conversation.MessageViewDefinition) /// A deleted message view. - case deletedMessageView(ChatBskyLexicon.Conversation.DeleteMessageViewDefinition) + case deletedMessageView(ChatBskyLexicon.Conversation.DeletedMessageViewDefinition) public init(from decoder: any Decoder) throws { let container = try decoder.singleValueContainer() if let value = try? container.decode(ChatBskyLexicon.Conversation.MessageViewDefinition.self) { self = .messageView(value) - } else if let value = try? container.decode(ChatBskyLexicon.Conversation.DeleteMessageViewDefinition.self) { + } else if let value = try? container.decode(ChatBskyLexicon.Conversation.DeletedMessageViewDefinition.self) { self = .deletedMessageView(value) } else { throw DecodingError.typeMismatch( @@ -1047,14 +1047,14 @@ public struct ATUnion { case messageView(ChatBskyLexicon.Conversation.MessageViewDefinition) /// A deleted message view. - case deletedMessageView(ChatBskyLexicon.Conversation.DeleteMessageViewDefinition) + case deletedMessageView(ChatBskyLexicon.Conversation.DeletedMessageViewDefinition) public init(from decoder: any Decoder) throws { let container = try decoder.singleValueContainer() if let value = try? container.decode(ChatBskyLexicon.Conversation.MessageViewDefinition.self) { self = .messageView(value) - } else if let value = try? container.decode(ChatBskyLexicon.Conversation.DeleteMessageViewDefinition.self) { + } else if let value = try? container.decode(ChatBskyLexicon.Conversation.DeletedMessageViewDefinition.self) { self = .deletedMessageView(value) } else { throw DecodingError.typeMismatch( @@ -1082,14 +1082,14 @@ public struct ATUnion { case messageView(ChatBskyLexicon.Conversation.MessageViewDefinition) /// A deleted message view. - case deletedMessageView(ChatBskyLexicon.Conversation.DeleteMessageViewDefinition) + case deletedMessageView(ChatBskyLexicon.Conversation.DeletedMessageViewDefinition) public init(from decoder: any Decoder) throws { let container = try decoder.singleValueContainer() if let value = try? container.decode(ChatBskyLexicon.Conversation.MessageViewDefinition.self) { self = .messageView(value) - } else if let value = try? container.decode(ChatBskyLexicon.Conversation.DeleteMessageViewDefinition.self) { + } else if let value = try? container.decode(ChatBskyLexicon.Conversation.DeletedMessageViewDefinition.self) { self = .deletedMessageView(value) } else { throw DecodingError.typeMismatch( diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoDefs.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoDefs.swift index 69e7bb7dfe..41df669795 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoDefs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoDefs.swift @@ -156,7 +156,7 @@ extension ChatBskyLexicon.Conversation { /// - SeeAlso: This is based on the [`chat.bsky.convo.defs`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/defs.json - public struct DeleteMessageViewDefinition: Codable { + public struct DeletedMessageViewDefinition: Codable { /// The ID of the message. Optional. public let messageID: String? diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoDeleteMessageForSelf.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoDeleteMessageForSelf.swift index d7f58ed5ec..b4859bbcb3 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoDeleteMessageForSelf.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoDeleteMessageForSelf.swift @@ -9,7 +9,7 @@ import Foundation extension ChatBskyLexicon.Conversation { - /// A request body model for a message reference. + /// A request body model for deleting a message only from the user account's end. /// /// - SeeAlso: This is based on the [`chat.bsky.convo.deleteMessageForSelf`][github] lexicon. /// @@ -20,7 +20,7 @@ extension ChatBskyLexicon.Conversation { public let conversationID: String /// The ID of the message. - public let messageID: DeleteMessageViewDefinition + public let messageID: String enum CodingKeys: String, CodingKey { case conversationID = "convoID" diff --git a/Sources/ATProtoKit/Networking/ChatAPI/ChatDeleteAccount.swift b/Sources/ATProtoKit/Networking/ChatAPI/ChatDeleteAccount.swift index db5ad25a0e..3dcb909746 100644 --- a/Sources/ATProtoKit/Networking/ChatAPI/ChatDeleteAccount.swift +++ b/Sources/ATProtoKit/Networking/ChatAPI/ChatDeleteAccount.swift @@ -32,7 +32,7 @@ extension ATProtoBlueskyChat { do { let request = APIClientService.createRequest(forRequest: requestURL, - andMethod: .post, + andMethod: .get, acceptValue: "application/json", contentTypeValue: nil, authorizationValue: "Bearer \(accessToken)") diff --git a/Sources/ATProtoKit/Networking/ChatAPI/ChatDeleteMessageForSelf.swift b/Sources/ATProtoKit/Networking/ChatAPI/ChatDeleteMessageForSelf.swift new file mode 100644 index 0000000000..954711463e --- /dev/null +++ b/Sources/ATProtoKit/Networking/ChatAPI/ChatDeleteMessageForSelf.swift @@ -0,0 +1,57 @@ +// +// ChatDeleteMessageForSelf.swift +// +// +// Created by Christopher Jr Riley on 2024-05-31. +// + +import Foundation + +extension ATProtoBlueskyChat { + + /// Deletes a mesage only from the user account's end. + /// + /// - SeeAlso: This is based on the [`chat.bsky.convo.deleteMessageForSelf`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/deleteMessageForSelf.json + /// + /// - Parameters: + /// - conversationID: The ID of the conversation. + /// - messageID: The ID of the message. + /// /// - Returns: A `Result`, containing either a ``ChatBskyLexicon/Conversation/DeletedMessageViewDefinition`` + /// if successful, or an `Error` if not. + public func DeleteMessageForSelf( + conversationID: String, + messageID: String + ) async throws -> Result { + guard session != nil, + let accessToken = session?.accessToken else { + throw ATRequestPrepareError.missingActiveSession + } + + guard let sessionURL = session?.pdsURL, + let requestURL = URL(string: "\(sessionURL)/xrpc/chat.bsky.convo.deleteMessageForSelf") else { + return .failure(ATRequestPrepareError.invalidRequestURL) + } + + let requestBody = ChatBskyLexicon.Conversation.DeleteMessageForSelfRequestBody( + conversationID: conversationID, + messageID: messageID + ) + + do { + let request = APIClientService.createRequest(forRequest: requestURL, + andMethod: .get, + acceptValue: "application/json", + contentTypeValue: "application/json", + authorizationValue: "Bearer \(accessToken)") + let response = try await APIClientService.sendRequest(request, + withEncodingBody: requestBody, + decodeTo: ChatBskyLexicon.Conversation.DeletedMessageViewDefinition.self) + + return .success(response) + } catch { + return .failure(error) + } + } +} diff --git a/Sources/ATProtoKit/Networking/ChatAPI/ChatExportAccountData.swift b/Sources/ATProtoKit/Networking/ChatAPI/ChatExportAccountData.swift new file mode 100644 index 0000000000..ffb26d214e --- /dev/null +++ b/Sources/ATProtoKit/Networking/ChatAPI/ChatExportAccountData.swift @@ -0,0 +1,41 @@ +// +// ChatExportAccountData.swift +// +// +// Created by Christopher Jr Riley on 2024-05-31. +// + +import Foundation + +extension ATProtoBlueskyChat { + + /// Exports the user's account data. + /// + /// - SeeAlso: This is based on the [`app.bsky.graph.unmuteActorList`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/actor/exportAccountData.json + /// + public func exportAccountData() async throws { + guard session != nil, + let accessToken = session?.accessToken else { + throw ATRequestPrepareError.missingActiveSession + } + + guard let sessionURL = session?.pdsURL, + let requestURL = URL(string: "\(sessionURL)/xrpc/chat.bsky.actor.exportAccountData") else { + throw ATRequestPrepareError.invalidRequestURL + } + + do { + let request = APIClientService.createRequest(forRequest: requestURL, + andMethod: .get, + acceptValue: "application/jsonl", + contentTypeValue: nil, + authorizationValue: "Bearer \(accessToken)") + + _ = try await APIClientService.sendRequest(request) + } catch { + throw error + } + } +} From 3181b033f5c9dd629453103053d93e6dfc70a2b8 Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Fri, 31 May 2024 03:33:02 -0400 Subject: [PATCH 33/51] Add ChatGetConvoForMembers and fix NSID --- .../ChatAPI/ChatExportAccountData.swift | 2 +- .../ChatAPI/ChatGetConvoForMembers.swift | 60 +++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 Sources/ATProtoKit/Networking/ChatAPI/ChatGetConvoForMembers.swift diff --git a/Sources/ATProtoKit/Networking/ChatAPI/ChatExportAccountData.swift b/Sources/ATProtoKit/Networking/ChatAPI/ChatExportAccountData.swift index ffb26d214e..b39ec6a174 100644 --- a/Sources/ATProtoKit/Networking/ChatAPI/ChatExportAccountData.swift +++ b/Sources/ATProtoKit/Networking/ChatAPI/ChatExportAccountData.swift @@ -11,7 +11,7 @@ extension ATProtoBlueskyChat { /// Exports the user's account data. /// - /// - SeeAlso: This is based on the [`app.bsky.graph.unmuteActorList`][github] lexicon. + /// - SeeAlso: This is based on the [`chat.bsky.actor.exportAccountData`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/actor/exportAccountData.json /// diff --git a/Sources/ATProtoKit/Networking/ChatAPI/ChatGetConvoForMembers.swift b/Sources/ATProtoKit/Networking/ChatAPI/ChatGetConvoForMembers.swift new file mode 100644 index 0000000000..d157f3f170 --- /dev/null +++ b/Sources/ATProtoKit/Networking/ChatAPI/ChatGetConvoForMembers.swift @@ -0,0 +1,60 @@ +// +// ChatGetConvoForMembers.swift +// +// +// Created by Christopher Jr Riley on 2024-05-31. +// + +import Foundation + +extension ATProtoBlueskyChat { + + /// Retrieves a conversation based on the list of members. + /// + /// - Note: `members` will only take the first 10 items. Any additional items will be discared. + /// + /// - SeeAlso: This is based on the [`chat.bsky.convo.getConvoForMembers`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/getConvoForMembers.json + /// + /// - Parameter members: An array of members within the conversation. Maximum amount is + /// 10 items. + /// - - Returns: A `Result`, containing either a ``ChatBskyLexicon/Conversation/GetConversationForMembersOutput`` + /// if successful, or an `Error` if not. + public func getConversaionForMembers(_ members: [String]) async throws -> Result { + guard session != nil, + let accessToken = session?.accessToken else { + throw ATRequestPrepareError.missingActiveSession + } + + guard let sessionURL = session?.pdsURL, + let requestURL = URL(string: "\(sessionURL)/xrpc/chat.bsky.convo.getConvoForMembers") else { + return .failure(ATRequestPrepareError.invalidRequestURL) + } + + var queryItems = [(String, String)]() + + queryItems += members.map { ("members", $0) } + + let queryURL: URL + + do { + queryURL = try APIClientService.setQueryItems( + for: requestURL, + with: queryItems + ) + + let request = APIClientService.createRequest(forRequest: queryURL, + andMethod: .get, + acceptValue: "application/json", + contentTypeValue: nil, + authorizationValue: "Bearer \(accessToken)") + let response = try await APIClientService.sendRequest(request, + decodeTo: ChatBskyLexicon.Conversation.GetConversationForMembersOutput.self) + + return .success(response) + } catch { + return .failure(error) + } + } +} From 6640b9fe690d90f39406aa264776e0303c7f99f0 Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Fri, 31 May 2024 03:39:41 -0400 Subject: [PATCH 34/51] Add ChatGetConvo --- .../Networking/ChatAPI/ChatGetConvo.swift | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 Sources/ATProtoKit/Networking/ChatAPI/ChatGetConvo.swift diff --git a/Sources/ATProtoKit/Networking/ChatAPI/ChatGetConvo.swift b/Sources/ATProtoKit/Networking/ChatAPI/ChatGetConvo.swift new file mode 100644 index 0000000000..31de3f0c7a --- /dev/null +++ b/Sources/ATProtoKit/Networking/ChatAPI/ChatGetConvo.swift @@ -0,0 +1,59 @@ +// +// ChatGetConvo.swift +// +// +// Created by Christopher Jr Riley on 2024-05-31. +// + +import Foundation + +extension ATProtoBlueskyChat { + + /// Retrieves a conversation. + /// + /// - SeeAlso: This is based on the [`chat.bsky.convo.getConvo`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/getConvo.json + /// + /// - Parameter members: An array of members within the conversation. Maximum amount is + /// 10 items. + /// - Returns: A `Result`, containing either a ``ChatBskyLexicon/Conversation/GetConversationOutput`` + /// if successful, or an `Error` if not. + public func getConversation(byID conversationID: String) async throws -> Result { + guard session != nil, + let accessToken = session?.accessToken else { + return .failure(ATRequestPrepareError.missingActiveSession) + } + + guard let sessionURL = session?.pdsURL, + let requestURL = URL(string: "\(sessionURL)/xrpc/app.bsky.graph.getList") else { + return .failure(ATRequestPrepareError.invalidRequestURL) + } + + var queryItems = [(String, String)]() + + queryItems.append(("convoId", conversationID)) + + let queryURL: URL + + do { + queryURL = try APIClientService.setQueryItems( + for: requestURL, + with: queryItems + ) + + let request = APIClientService.createRequest(forRequest: queryURL, + andMethod: .get, + acceptValue: "application/json", + contentTypeValue: nil, + authorizationValue: "Bearer \(accessToken)") + let response = try await APIClientService.sendRequest(request, + decodeTo: ChatBskyLexicon.Conversation.GetConversationOutput.self) + + return .success(response) + } catch { + return .failure(error) + } + + } +} From e42b286ac1555638805d04e57fdbf7e84097291d Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Fri, 31 May 2024 03:49:14 -0400 Subject: [PATCH 35/51] Add ChatGetLog and tweak documentation --- .../chat.bsky/Convo/ChatBskyConvoGetLog.swift | 2 +- .../Networking/ChatAPI/ChatGetLog.swift | 60 +++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 Sources/ATProtoKit/Networking/ChatAPI/ChatGetLog.swift diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetLog.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetLog.swift index 1a3c8355ba..88c0f180b7 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetLog.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoGetLog.swift @@ -9,7 +9,7 @@ import Foundation extension ChatBskyLexicon.Conversation { - /// An output model for getting logs. + /// An output model for getting logs for messages. /// /// - SeeAlso: This is based on the [`chat.bsky.convo.getLog`][github] lexicon. /// diff --git a/Sources/ATProtoKit/Networking/ChatAPI/ChatGetLog.swift b/Sources/ATProtoKit/Networking/ChatAPI/ChatGetLog.swift new file mode 100644 index 0000000000..d28bdd50db --- /dev/null +++ b/Sources/ATProtoKit/Networking/ChatAPI/ChatGetLog.swift @@ -0,0 +1,60 @@ +// +// ChatGetLog.swift +// +// +// Created by Christopher Jr Riley on 2024-05-31. +// + +import Foundation + +extension ATProtoBlueskyChat { + + /// Retrieves logs for messages. + /// + /// - SeeAlso: This is based on the [`chat.bsky.convo.getLog`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/getLog.json + /// + /// - Parameter cursor: The mark used to indicate the starting point for the next set of + /// result. Optional. + /// - Returns: A `Result`, containing either a ``ChatBskyLexicon/Conversation/GetLogOutput`` + /// if successful, or an `Error` if not. + public func getLog(cursor: String? = nil) async throws -> Result { + guard session != nil, + let accessToken = session?.accessToken else { + return .failure(ATRequestPrepareError.missingActiveSession) + } + + guard let sessionURL = session?.pdsURL, + let requestURL = URL(string: "\(sessionURL)/xrpc/chat.bsky.convo.getLog") else { + return .failure(ATRequestPrepareError.invalidRequestURL) + } + + var queryItems = [(String, String)]() + + if let cursor { + queryItems.append(("cursor", cursor)) + } + + let queryURL: URL + + do { + queryURL = try APIClientService.setQueryItems( + for: requestURL, + with: queryItems + ) + + let request = APIClientService.createRequest(forRequest: queryURL, + andMethod: .get, + acceptValue: "application/json", + contentTypeValue: nil, + authorizationValue: "Bearer \(accessToken)") + let response = try await APIClientService.sendRequest(request, + decodeTo: ChatBskyLexicon.Conversation.GetLogOutput.self) + + return .success(response) + } catch { + return .failure(error) + } + } +} From 17e1b1cfa8b1303aa06fe399cb65322d8b625f36 Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Fri, 31 May 2024 03:57:56 -0400 Subject: [PATCH 36/51] Add ChatGetMessages --- .../Networking/ChatAPI/ChatGetMessages.swift | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 Sources/ATProtoKit/Networking/ChatAPI/ChatGetMessages.swift diff --git a/Sources/ATProtoKit/Networking/ChatAPI/ChatGetMessages.swift b/Sources/ATProtoKit/Networking/ChatAPI/ChatGetMessages.swift new file mode 100644 index 0000000000..ee8c84820d --- /dev/null +++ b/Sources/ATProtoKit/Networking/ChatAPI/ChatGetMessages.swift @@ -0,0 +1,62 @@ +// +// ChatGetMessages.swift +// +// +// Created by Christopher Jr Riley on 2024-05-31. +// + +import Foundation + +extension ATProtoBlueskyChat { + + /// Retrieves messages from a conversation. + /// + /// - SeeAlso: This is based on the [`chat.bsky.convo.getMessages`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/getMessages.json + /// + public func getMessages( + from conversationID: String, + limit: Int? = 50 + ) async throws -> Result { + guard session != nil, + let accessToken = session?.accessToken else { + return .failure(ATRequestPrepareError.missingActiveSession) + } + + guard let sessionURL = session?.pdsURL, + let requestURL = URL(string: "\(sessionURL)/xrpc/chat.bsky.convo.getMessages") else { + return .failure(ATRequestPrepareError.invalidRequestURL) + } + + var queryItems = [(String, String)]() + + queryItems.append(("convoId", conversationID)) + + if let limit { + let finalLimit = max(1, min(limit, 100)) + queryItems.append(("limit", "\(finalLimit)")) + } + + let queryURL: URL + + do { + queryURL = try APIClientService.setQueryItems( + for: requestURL, + with: queryItems + ) + + let request = APIClientService.createRequest(forRequest: queryURL, + andMethod: .get, + acceptValue: "application/json", + contentTypeValue: nil, + authorizationValue: "Bearer \(accessToken)") + let response = try await APIClientService.sendRequest(request, + decodeTo: ChatBskyLexicon.Conversation.GetMessagesOutput.self) + + return .success(response) + } catch { + return .failure(error) + } + } +} From 89327ec53932a576f5c5aff8921ccaf2a206b8b3 Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Fri, 31 May 2024 04:10:47 -0400 Subject: [PATCH 37/51] Add ChatLeaveConvo; fix formatting Also added missing documentation in ChatGetMessages. --- .../ChatAPI/ChatDeleteAccount.swift | 1 - .../Networking/ChatAPI/ChatGetMessages.swift | 11 ++-- .../Networking/ChatAPI/ChatLeaveConvo.swift | 51 +++++++++++++++++++ 3 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 Sources/ATProtoKit/Networking/ChatAPI/ChatLeaveConvo.swift diff --git a/Sources/ATProtoKit/Networking/ChatAPI/ChatDeleteAccount.swift b/Sources/ATProtoKit/Networking/ChatAPI/ChatDeleteAccount.swift index 3dcb909746..0dfa2e21d6 100644 --- a/Sources/ATProtoKit/Networking/ChatAPI/ChatDeleteAccount.swift +++ b/Sources/ATProtoKit/Networking/ChatAPI/ChatDeleteAccount.swift @@ -16,7 +16,6 @@ extension ATProtoBlueskyChat { /// - SeeAlso: This is based on the [`chat.bsky.actor.deleteAccount`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/actor/deleteAccount.json - /// public func deleteAccount() async throws { guard session != nil, let accessToken = session?.accessToken else { diff --git a/Sources/ATProtoKit/Networking/ChatAPI/ChatGetMessages.swift b/Sources/ATProtoKit/Networking/ChatAPI/ChatGetMessages.swift index ee8c84820d..a0a4a9deab 100644 --- a/Sources/ATProtoKit/Networking/ChatAPI/ChatGetMessages.swift +++ b/Sources/ATProtoKit/Networking/ChatAPI/ChatGetMessages.swift @@ -10,11 +10,16 @@ import Foundation extension ATProtoBlueskyChat { /// Retrieves messages from a conversation. - /// + /// /// - SeeAlso: This is based on the [`chat.bsky.convo.getMessages`][github] lexicon. - /// + /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/getMessages.json - /// + /// + /// - Parameters: + /// - conversationID: The ID of the conversation. + /// - limit: The number of items that can be in the list. Optional. Defaults to `50`. + /// - Returns: A `Result`, containing either a ``ChatBskyLexicon/Conversation/GetMessagesOutput`` + /// if successful, or an `Error` if not. public func getMessages( from conversationID: String, limit: Int? = 50 diff --git a/Sources/ATProtoKit/Networking/ChatAPI/ChatLeaveConvo.swift b/Sources/ATProtoKit/Networking/ChatAPI/ChatLeaveConvo.swift new file mode 100644 index 0000000000..23ad01ce90 --- /dev/null +++ b/Sources/ATProtoKit/Networking/ChatAPI/ChatLeaveConvo.swift @@ -0,0 +1,51 @@ +// +// ChatLeaveConvo.swift +// +// +// Created by Christopher Jr Riley on 2024-05-31. +// + +import Foundation + +extension ATProtoBlueskyChat { + + /// Removes the user account from the conversation. + /// + /// - SeeAlso: This is based on the [`chat.bsky.convo.leaveConvo`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/leaveConvo.json + /// + /// - Parameter conversationID: The ID of the conversation. + /// - Returns: A `Result`, containing either a ``ChatBskyLexicon/Conversation/LeaveConversationOutput`` + /// if successful, or an `Error` if not. + public func leaveConversation(from conversationID: String) async throws -> Result { + guard session != nil, + let accessToken = session?.accessToken else { + throw ATRequestPrepareError.missingActiveSession + } + + guard let sessionURL = session?.pdsURL, + let requestURL = URL(string: "\(sessionURL)/xrpc/chat.bsky.convo.leaveConvo") else { + return .failure(ATRequestPrepareError.invalidRequestURL) + } + + let requestBody = ChatBskyLexicon.Conversation.LeaveConversationRequestBody( + conversationID: conversationID + ) + + do { + let request = APIClientService.createRequest(forRequest: requestURL, + andMethod: .post, + acceptValue: "application/json", + contentTypeValue: nil, + authorizationValue: "Bearer \(accessToken)") + let response = try await APIClientService.sendRequest(request, + withEncodingBody: requestBody, + decodeTo: ChatBskyLexicon.Conversation.LeaveConversationOutput.self) + + return .success(response) + } catch { + throw error + } + } +} From f4149921875de426bc096a35b25082b29af2a957 Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Fri, 31 May 2024 04:22:47 -0400 Subject: [PATCH 38/51] Add ChatListConvos; fix docs and spelling --- .../Convo/ChatBskyConvoListConvo.swift | 4 +- .../Networking/ChatAPI/ChatListConvos.swift | 70 +++++++++++++++++++ 2 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 Sources/ATProtoKit/Networking/ChatAPI/ChatListConvos.swift diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoListConvo.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoListConvo.swift index 7e049dcc91..163b4ebd7e 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoListConvo.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoListConvo.swift @@ -9,12 +9,12 @@ import Foundation extension ChatBskyLexicon.Conversation { - /// An output model for listing a conversation. + /// An output model for listing various conversations. /// /// - SeeAlso: This is based on the [`chat.bsky.convo.listConvos`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/listConvos.json - public struct ListConversationOutput: Codable { + public struct ListConversationsOutput: Codable { /// The mark used to indicate the starting point for the next set of results. Optional. public let cursor: String diff --git a/Sources/ATProtoKit/Networking/ChatAPI/ChatListConvos.swift b/Sources/ATProtoKit/Networking/ChatAPI/ChatListConvos.swift new file mode 100644 index 0000000000..b3992cad05 --- /dev/null +++ b/Sources/ATProtoKit/Networking/ChatAPI/ChatListConvos.swift @@ -0,0 +1,70 @@ +// +// ChatListConvos.swift +// +// +// Created by Christopher Jr Riley on 2024-05-31. +// + +import Foundation + +extension ATProtoBlueskyChat { + + /// Lists various conversations the user account is participating in. + /// + /// - SeeAlso: This is based on the [`chat.bsky.convo.listConvos`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/listConvos.json + /// + /// - Parameters: + /// - limit: The number of items that can be in the list. Optional. Defaults to `50`. + /// - cursor: The mark used to indicate the starting point for the next set of + /// result. Optional. + /// - Returns: A `Result`, containing either a ``ChatBskyLexicon/Conversation/ListConversationsOutput`` + /// if successful, or an `Error` if not. + public func listConversations( + limit: Int? = 50, + cursor: String? = nil + ) async throws -> Result { + guard session != nil, + let accessToken = session?.accessToken else { + return .failure(ATRequestPrepareError.missingActiveSession) + } + + guard let sessionURL = session?.pdsURL, + let requestURL = URL(string: "\(sessionURL)/xrpc/chat.bsky.convo.listConvos") else { + return .failure(ATRequestPrepareError.invalidRequestURL) + } + + var queryItems = [(String, String)]() + + if let limit { + let finalLimit = max(1, min(limit, 100)) + queryItems.append(("limit", "\(finalLimit)")) + } + + if let cursor { + queryItems.append(("cursor", cursor)) + } + + let queryURL: URL + + do { + queryURL = try APIClientService.setQueryItems( + for: requestURL, + with: queryItems + ) + + let request = APIClientService.createRequest(forRequest: queryURL, + andMethod: .get, + acceptValue: "application/json", + contentTypeValue: nil, + authorizationValue: "Bearer \(accessToken)") + let response = try await APIClientService.sendRequest(request, + decodeTo: ChatBskyLexicon.Conversation.ListConversationsOutput.self) + + return .success(response) + } catch { + return .failure(error) + } + } +} From fc2397ccda2da50cd6563bc528d7003e4ddd0bdd Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Fri, 31 May 2024 04:32:08 -0400 Subject: [PATCH 39/51] Add ChatMuteConvo --- .../Networking/ChatAPI/ChatMuteConvo.swift | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Sources/ATProtoKit/Networking/ChatAPI/ChatMuteConvo.swift diff --git a/Sources/ATProtoKit/Networking/ChatAPI/ChatMuteConvo.swift b/Sources/ATProtoKit/Networking/ChatAPI/ChatMuteConvo.swift new file mode 100644 index 0000000000..83659e3fb3 --- /dev/null +++ b/Sources/ATProtoKit/Networking/ChatAPI/ChatMuteConvo.swift @@ -0,0 +1,50 @@ +// +// ChatMuteConvo.swift +// +// +// Created by Christopher Jr Riley on 2024-05-31. +// + +import Foundation + +extension ATProtoBlueskyChat { + + /// Mutes a conversation the user account is participating in. + /// + /// - SeeAlso: This is based on the [`chat.bsky.convo.muteConvo`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/muteConvo.json + /// + /// - Parameter conversationID: The ID of the conversation. + /// - Returns: A `Result`, containing either a ``ChatBskyLexicon/Conversation/MuteConversationOutput`` + /// if successful, or an `Error` if not. + public func muteConversation(from conversationID: String) async throws -> Result { + guard session != nil, + let accessToken = session?.accessToken else { + return .failure(ATRequestPrepareError.missingActiveSession) + } + + guard let sessionURL = session?.pdsURL, + let requestURL = URL(string: "\(sessionURL)/xrpc/chat.bsky.convo.muteConvo") else { + return .failure(ATRequestPrepareError.invalidRequestURL) + } + + let requestBody = ChatBskyLexicon.Conversation.MuteConversationRequestBody( + conversationID: conversationID + ) + + do { + let request = APIClientService.createRequest(forRequest: requestURL, + andMethod: .get, + acceptValue: "application/json", + contentTypeValue: nil, + authorizationValue: "Bearer \(accessToken)") + let response = try await APIClientService.sendRequest(request, + decodeTo: ChatBskyLexicon.Conversation.MuteConversationOutput.self) + + return .success(response) + } catch { + return .failure(error) + } + } +} From 2793576a1250c293002c5786ef2da38349fc4e41 Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Fri, 31 May 2024 04:38:37 -0400 Subject: [PATCH 40/51] Add content type parameter The parameter has been filled out in ChatLeaveConvo and ChatMuteConvo. --- Sources/ATProtoKit/Networking/ChatAPI/ChatLeaveConvo.swift | 2 +- Sources/ATProtoKit/Networking/ChatAPI/ChatMuteConvo.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/ATProtoKit/Networking/ChatAPI/ChatLeaveConvo.swift b/Sources/ATProtoKit/Networking/ChatAPI/ChatLeaveConvo.swift index 23ad01ce90..afbdfbbe52 100644 --- a/Sources/ATProtoKit/Networking/ChatAPI/ChatLeaveConvo.swift +++ b/Sources/ATProtoKit/Networking/ChatAPI/ChatLeaveConvo.swift @@ -37,7 +37,7 @@ extension ATProtoBlueskyChat { let request = APIClientService.createRequest(forRequest: requestURL, andMethod: .post, acceptValue: "application/json", - contentTypeValue: nil, + contentTypeValue: "application/json", authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, withEncodingBody: requestBody, diff --git a/Sources/ATProtoKit/Networking/ChatAPI/ChatMuteConvo.swift b/Sources/ATProtoKit/Networking/ChatAPI/ChatMuteConvo.swift index 83659e3fb3..778413f2db 100644 --- a/Sources/ATProtoKit/Networking/ChatAPI/ChatMuteConvo.swift +++ b/Sources/ATProtoKit/Networking/ChatAPI/ChatMuteConvo.swift @@ -37,7 +37,7 @@ extension ATProtoBlueskyChat { let request = APIClientService.createRequest(forRequest: requestURL, andMethod: .get, acceptValue: "application/json", - contentTypeValue: nil, + contentTypeValue: "application/json", authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, decodeTo: ChatBskyLexicon.Conversation.MuteConversationOutput.self) From 53185699a7c77e01f30a602955306d38b8867871 Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Fri, 31 May 2024 04:56:18 -0400 Subject: [PATCH 41/51] Add ChatSendMessage --- .../Networking/ChatAPI/ChatSendMessage.swift | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 Sources/ATProtoKit/Networking/ChatAPI/ChatSendMessage.swift diff --git a/Sources/ATProtoKit/Networking/ChatAPI/ChatSendMessage.swift b/Sources/ATProtoKit/Networking/ChatAPI/ChatSendMessage.swift new file mode 100644 index 0000000000..c251043af4 --- /dev/null +++ b/Sources/ATProtoKit/Networking/ChatAPI/ChatSendMessage.swift @@ -0,0 +1,58 @@ +// +// ChatSendMessage.swift +// +// +// Created by Christopher Jr Riley on 2024-05-31. +// + +import Foundation + +extension ATProtoBlueskyChat { + + /// Sends a message to a conversation. + /// + /// Due to current limitations, there is no way to add images to the messages. + /// + /// - SeeAlso: This is based on the [`chat.bsky.convo.sendMessage`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/sendMessage.json + /// + /// - Parameters: + /// - conversationID: The ID of the conversation. + /// - message: The message to be sent. + /// - Returns: A `Result`, containing either a ``ChatBskyLexicon/Conversation/MessageViewDefinition`` + /// if successful, or an `Error` if not. + public func sendMessage( + conversationID: String, + message: ChatBskyLexicon.Conversation.MessageInputDefinition + ) async throws -> Result { + guard session != nil, + let accessToken = session?.accessToken else { + return .failure(ATRequestPrepareError.missingActiveSession) + } + + guard let sessionURL = session?.pdsURL, + let requestURL = URL(string: "\(sessionURL)/xrpc/chat.bsky.convo.sendMessage") else { + return .failure(ATRequestPrepareError.invalidRequestURL) + } + + let requestBody = ChatBskyLexicon.Conversation.SendMessageRequestBody( + conversationID: conversationID, + message: message + ) + + do { + let request = APIClientService.createRequest(forRequest: requestURL, + andMethod: .get, + acceptValue: "application/json", + contentTypeValue: "application/json", + authorizationValue: "Bearer \(accessToken)") + let response = try await APIClientService.sendRequest(request, + decodeTo: ChatBskyLexicon.Conversation.MessageViewDefinition.self) + + return .success(response) + } catch { + return .failure(error) + } + } +} From cdf585d09e0d334d2131558a3068174379cdf849 Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Fri, 31 May 2024 05:07:48 -0400 Subject: [PATCH 42/51] Add ChatSendMessageBatch --- .../Convo/ChatBskyConvoSendMessageBatch.swift | 1 + .../ChatAPI/ChatSendMessageBatch.swift | 52 +++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 Sources/ATProtoKit/Networking/ChatAPI/ChatSendMessageBatch.swift diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoSendMessageBatch.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoSendMessageBatch.swift index a9e0bfd01e..458f5fe461 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoSendMessageBatch.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoSendMessageBatch.swift @@ -15,6 +15,7 @@ extension ChatBskyLexicon.Conversation { /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/sendMessageBatch.json public struct SendMessageBatch: Codable { + /// A message batch object. /// /// - SeeAlso: This is based on the [`chat.bsky.convo.sendMessageBatch`][github] lexicon. diff --git a/Sources/ATProtoKit/Networking/ChatAPI/ChatSendMessageBatch.swift b/Sources/ATProtoKit/Networking/ChatAPI/ChatSendMessageBatch.swift new file mode 100644 index 0000000000..3680375dc9 --- /dev/null +++ b/Sources/ATProtoKit/Networking/ChatAPI/ChatSendMessageBatch.swift @@ -0,0 +1,52 @@ +// +// ChatSendMessageBatch.swift +// +// +// Created by Christopher Jr Riley on 2024-05-31. +// + +import Foundation + +extension ATProtoBlueskyChat { + + /// Sends a batch of messages to the conversation. + /// + /// Due to Bluesky limitations, you are unable to send images at this time. + /// + /// - SeeAlso: This is based on the [`chat.bsky.convo.sendMessageBatch`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/sendMessageBatch.json + /// + /// - Parameter messages: A array of messages. Maximum number is 100 items. + /// - Returns: A `Result`, containing either a ``ChatBskyLexicon/Conversation/SendMessageBatchOutput`` + /// if successful, or an `Error` if not. + public func sendMessageBatch(messages: [ChatBskyLexicon.Conversation.SendMessageBatch.MessageBatchItem]) async throws -> Result { + guard session != nil, + let accessToken = session?.accessToken else { + return .failure(ATRequestPrepareError.missingActiveSession) + } + + guard let sessionURL = session?.pdsURL, + let requestURL = URL(string: "\(sessionURL)/xrpc/chat.bsky.convo.sendMessageBatch") else { + return .failure(ATRequestPrepareError.invalidRequestURL) + } + + let requestBody = ChatBskyLexicon.Conversation.SendMessageBatchRequestBody( + items: messages + ) + + do { + let request = APIClientService.createRequest(forRequest: requestURL, + andMethod: .get, + acceptValue: "application/json", + contentTypeValue: "application/json", + authorizationValue: "Bearer \(accessToken)") + let response = try await APIClientService.sendRequest(request, + decodeTo: ChatBskyLexicon.Conversation.SendMessageBatchOutput.self) + + return .success(response) + } catch { + return .failure(error) + } + } +} From ae472e754f2d7fc488f196a41bf38c4aa72a2ce2 Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Fri, 31 May 2024 05:16:28 -0400 Subject: [PATCH 43/51] Add ChatUnmuteConvo --- .../Networking/ChatAPI/ChatUnmuteConvo.swift | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Sources/ATProtoKit/Networking/ChatAPI/ChatUnmuteConvo.swift diff --git a/Sources/ATProtoKit/Networking/ChatAPI/ChatUnmuteConvo.swift b/Sources/ATProtoKit/Networking/ChatAPI/ChatUnmuteConvo.swift new file mode 100644 index 0000000000..c14d5c2e0a --- /dev/null +++ b/Sources/ATProtoKit/Networking/ChatAPI/ChatUnmuteConvo.swift @@ -0,0 +1,50 @@ +// +// ChatUnmuteConvo.swift +// +// +// Created by Christopher Jr Riley on 2024-05-31. +// + +import Foundation + +extension ATProtoBlueskyChat { + + /// Unmutes a conversation the user account is participating in. + /// + /// - SeeAlso: This is based on the [`chat.bsky.convo.unmuteConvo`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/unmuteConvo.json + /// + /// - Parameter conversationID: The ID of the conversation. + /// - Returns: A `Result`, containing either a ``ChatBskyLexicon/Conversation/UnmuteConversationOutput`` + /// if successful, or an `Error` if not. + public func unmuteConversation(from conversationID: String) async throws -> Result { + guard session != nil, + let accessToken = session?.accessToken else { + return .failure(ATRequestPrepareError.missingActiveSession) + } + + guard let sessionURL = session?.pdsURL, + let requestURL = URL(string: "\(sessionURL)/xrpc/chat.bsky.convo.unmuteConvo") else { + return .failure(ATRequestPrepareError.invalidRequestURL) + } + + let requestBody = ChatBskyLexicon.Conversation.UnMuteConversationRequestBody( + conversationID: conversationID + ) + + do { + let request = APIClientService.createRequest(forRequest: requestURL, + andMethod: .get, + acceptValue: "application/json", + contentTypeValue: "application/json", + authorizationValue: "Bearer \(accessToken)") + let response = try await APIClientService.sendRequest(request, + decodeTo: ChatBskyLexicon.Conversation.UnmuteConversationOutput.self) + + return .success(response) + } catch { + return .failure(error) + } + } +} From 0ce194d6ebda91ef07c2314273e86b08693d23d4 Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Fri, 31 May 2024 05:28:42 -0400 Subject: [PATCH 44/51] Add ChatUpdateRead Also made messageID optional in UpdateReadRequestBody. --- .../Convo/ChatBskyConvoUpdateRead.swift | 2 +- .../Networking/ChatAPI/ChatUpdateRead.swift | 56 +++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 Sources/ATProtoKit/Networking/ChatAPI/ChatUpdateRead.swift diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoUpdateRead.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoUpdateRead.swift index 582cdb7249..2be33de111 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoUpdateRead.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Convo/ChatBskyConvoUpdateRead.swift @@ -20,7 +20,7 @@ extension ChatBskyLexicon.Conversation { public let conversationID: String /// The ID of the message. - public let messageID: String + public let messageID: String? enum CodingKeys: String, CodingKey { case conversationID = "convoId" diff --git a/Sources/ATProtoKit/Networking/ChatAPI/ChatUpdateRead.swift b/Sources/ATProtoKit/Networking/ChatAPI/ChatUpdateRead.swift new file mode 100644 index 0000000000..c8b7cf55aa --- /dev/null +++ b/Sources/ATProtoKit/Networking/ChatAPI/ChatUpdateRead.swift @@ -0,0 +1,56 @@ +// +// ChatUpdateRead.swift +// +// +// Created by Christopher Jr Riley on 2024-05-31. +// + +import Foundation + +extension ATProtoBlueskyChat { + + /// Updates the conversation to be marked as read. + /// + /// - SeeAlso: This is based on the [`chat.bsky.convo.updateRead`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/convo/updateRead.json + /// + /// - Parameters: + /// - conversationID: The ID of the conversation. + /// - messageID: The ID of the message. Optional. + /// - Returns: A `Result`, containing either a ``ChatBskyLexicon/Conversation/UpdateReadOutput`` + /// if successful, or an `Error` if not. + public func updateRead( + from conversationID: String, + upTo messageID: String? = nil + ) async throws -> Result { + guard session != nil, + let accessToken = session?.accessToken else { + return .failure(ATRequestPrepareError.missingActiveSession) + } + + guard let sessionURL = session?.pdsURL, + let requestURL = URL(string: "\(sessionURL)/xrpc/chat.bsky.convo.updateRead") else { + return .failure(ATRequestPrepareError.invalidRequestURL) + } + + let requestBody = ChatBskyLexicon.Conversation.UpdateReadRequestBody( + conversationID: conversationID, + messageID: messageID + ) + + do { + let request = APIClientService.createRequest(forRequest: requestURL, + andMethod: .get, + acceptValue: "application/json", + contentTypeValue: "application/json", + authorizationValue: "Bearer \(accessToken)") + let response = try await APIClientService.sendRequest(request, + decodeTo: ChatBskyLexicon.Conversation.UpdateReadOutput.self) + + return .success(response) + } catch { + return .failure(error) + } + } +} From 3e07b39fc431074a0dfcffef5f383ab780551803 Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Fri, 31 May 2024 05:43:44 -0400 Subject: [PATCH 45/51] Add ChatGetActorMetadata and fix output GetActorMetadataOutput had each of the properties of type String. This commit fixes it to GetActorMetadata.Metadata. --- .../ChatBskyModerationGetActorMetadata.swift | 6 +- .../ChatAPI/ChatGetActorMetadata.swift | 60 +++++++++++++++++++ 2 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 Sources/ATProtoKit/Networking/ChatAPI/ChatGetActorMetadata.swift diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Moderation/ChatBskyModerationGetActorMetadata.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Moderation/ChatBskyModerationGetActorMetadata.swift index c8fe80d432..f07fb6f1c1 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Moderation/ChatBskyModerationGetActorMetadata.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Moderation/ChatBskyModerationGetActorMetadata.swift @@ -44,13 +44,13 @@ extension ChatBskyLexicon.Moderation { public struct GetActorMetadataOutput: Codable { /// The metadata that reflects the past day. - public let dayMetadata: String + public let dayMetadata: GetActorMetadata.Metadata /// The metadata that reflects the past month. - public let monthMetadata: String + public let monthMetadata: GetActorMetadata.Metadata /// The metadata that reflects the entire lifetime of the user account. - public let allMetadata: String + public let allMetadata: GetActorMetadata.Metadata enum CodingKeys: String, CodingKey { case dayMetadata = "day" diff --git a/Sources/ATProtoKit/Networking/ChatAPI/ChatGetActorMetadata.swift b/Sources/ATProtoKit/Networking/ChatAPI/ChatGetActorMetadata.swift new file mode 100644 index 0000000000..b8d51b81c4 --- /dev/null +++ b/Sources/ATProtoKit/Networking/ChatAPI/ChatGetActorMetadata.swift @@ -0,0 +1,60 @@ +// +// ChatGetActorMetadata.swift +// +// +// Created by Christopher Jr Riley on 2024-05-31. +// + +import Foundation + +extension ATProtoBlueskyChat { + + /// Retrieves the user account's metadata as a moderator. + /// + /// - Important: This is a moderator task and as such, regular users won't be able to access + /// this; if they attempt to do so, an error will occur. + /// + /// - SeeAlso: This is based on the [`chat.bsky.moderation.getActorMetadata`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/moderation/getActorMetadata.json + /// + /// - Parameter actorDID: The decentralized identifier (DID) of the user account. + /// - Returns: A `Result`, containing either a ``ChatBskyLexicon/Moderation/GetActorMetadataOutput`` + /// if successful, or an `Error` if not. + public func getMessageContext(actorDID: String) async throws -> Result { + guard session != nil, + let accessToken = session?.accessToken else { + return .failure(ATRequestPrepareError.missingActiveSession) + } + + guard let sessionURL = session?.pdsURL, + let requestURL = URL(string: "\(sessionURL)/xrpc/chat.bsky.moderation.getActorMetadata") else { + return .failure(ATRequestPrepareError.invalidRequestURL) + } + + var queryItems = [(String, String)]() + + queryItems.append(("actor", actorDID)) + + let queryURL: URL + + do { + queryURL = try APIClientService.setQueryItems( + for: requestURL, + with: queryItems + ) + + let request = APIClientService.createRequest(forRequest: queryURL, + andMethod: .get, + acceptValue: "application/json", + contentTypeValue: "application/json", + authorizationValue: "Bearer \(accessToken)") + let response = try await APIClientService.sendRequest(request, + decodeTo: ChatBskyLexicon.Moderation.GetActorMetadataOutput.self) + + return .success(response) + } catch { + return .failure(error) + } + } +} From e15b6ae4f299d36f68eb47c4d114ddd96a133641 Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Fri, 31 May 2024 06:00:16 -0400 Subject: [PATCH 46/51] Add ChatGetMessageContext and fix content type Set contentTypeValue in ChatGetActorMetadata to nil. --- .../ChatAPI/ChatGetActorMetadata.swift | 2 +- .../ChatAPI/ChatGetMessageContext.swift | 80 +++++++++++++++++++ 2 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 Sources/ATProtoKit/Networking/ChatAPI/ChatGetMessageContext.swift diff --git a/Sources/ATProtoKit/Networking/ChatAPI/ChatGetActorMetadata.swift b/Sources/ATProtoKit/Networking/ChatAPI/ChatGetActorMetadata.swift index b8d51b81c4..d3728dc1ed 100644 --- a/Sources/ATProtoKit/Networking/ChatAPI/ChatGetActorMetadata.swift +++ b/Sources/ATProtoKit/Networking/ChatAPI/ChatGetActorMetadata.swift @@ -47,7 +47,7 @@ extension ATProtoBlueskyChat { let request = APIClientService.createRequest(forRequest: queryURL, andMethod: .get, acceptValue: "application/json", - contentTypeValue: "application/json", + contentTypeValue: nil, authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, decodeTo: ChatBskyLexicon.Moderation.GetActorMetadataOutput.self) diff --git a/Sources/ATProtoKit/Networking/ChatAPI/ChatGetMessageContext.swift b/Sources/ATProtoKit/Networking/ChatAPI/ChatGetMessageContext.swift new file mode 100644 index 0000000000..56d4d027bb --- /dev/null +++ b/Sources/ATProtoKit/Networking/ChatAPI/ChatGetMessageContext.swift @@ -0,0 +1,80 @@ +// +// ChatGetMessageContext.swift +// +// +// Created by Christopher Jr Riley on 2024-05-31. +// + +import Foundation + +extension ATProtoBlueskyChat { + + /// Retrieves the message context as a moderator. + /// + /// - SeeAlso: This is based on the [`chat.bsky.moderation.getMessageContext`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/moderation/getMessageContext.json + /// + /// - Parameters: + /// - conversationID: The ID of the conversation. Optional. + /// - messageID: The ID of the message. + /// - messagesBefore: The number of messages older than the message in `messageID`. Optional. + /// Defaults to `5`. + /// - messagesAfter: The number of messages younger than the message in `messageID`. + /// Optional. Defaults to `5`. + /// - Returns: A `Result`, containing either a ``ChatBskyLexicon/Moderation/GetMessageContextOutput`` + /// if successful, or an `Error` if not. + public func getMessageContext( + from conversationID: String?, + messageID: String, + messagesBefore: Int? = 5, + messagesAfter: Int? = 5 + ) async throws -> Result { + guard session != nil, + let accessToken = session?.accessToken else { + return .failure(ATRequestPrepareError.missingActiveSession) + } + + guard let sessionURL = session?.pdsURL, + let requestURL = URL(string: "\(sessionURL)/xrpc/chat.bsky.moderation.getMessageContext") else { + return .failure(ATRequestPrepareError.invalidRequestURL) + } + + var queryItems = [(String, String)]() + + if let conversationID { + queryItems.append(("convoId", conversationID)) + } + + queryItems.append(("messageId", messageID)) + + if let messagesBefore { + queryItems.append(("before", "\(messagesBefore)")) + } + + if let messagesAfter { + queryItems.append(("after", "\(messagesAfter)")) + } + + let queryURL: URL + + do { + queryURL = try APIClientService.setQueryItems( + for: requestURL, + with: queryItems + ) + + let request = APIClientService.createRequest(forRequest: queryURL, + andMethod: .get, + acceptValue: "application/json", + contentTypeValue: "application/json", + authorizationValue: "Bearer \(accessToken)") + let response = try await APIClientService.sendRequest(request, + decodeTo: ChatBskyLexicon.Moderation.GetMessageContextOutput.self) + + return .success(response) + } catch { + return .failure(error) + } + } +} From a146137007f99bee8a56372e9da73bf8cf2e2f6e Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Fri, 31 May 2024 06:15:35 -0400 Subject: [PATCH 47/51] Add ChatUpdateActorAccess and fix small things - Added moderator note in ChatGetMessageContext. - Made reference to optional in UpdateActorAccessRequestBody. - Fixes a spelling mistake in UpdateActorAccessRequestBody. --- .../ChatBskyModerationUpdateActorAccess.swift | 4 +- .../ChatAPI/ChatGetMessageContext.swift | 3 + .../ChatAPI/ChatUpdateActorAccess.swift | 59 +++++++++++++++++++ 3 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 Sources/ATProtoKit/Networking/ChatAPI/ChatUpdateActorAccess.swift diff --git a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Moderation/ChatBskyModerationUpdateActorAccess.swift b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Moderation/ChatBskyModerationUpdateActorAccess.swift index b62f0b12be..ae4f020960 100644 --- a/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Moderation/ChatBskyModerationUpdateActorAccess.swift +++ b/Sources/ATProtoKit/Models/Lexicons/chat.bsky/Moderation/ChatBskyModerationUpdateActorAccess.swift @@ -11,7 +11,7 @@ extension ChatBskyLexicon.Moderation { /// A request body model for updating the user account's access to direct messages. /// - /// - SeeAlso: This is based on the [`hat.bsky.moderation.updateActorAccess`][github] lexicon. + /// - SeeAlso: This is based on the [`chat.bsky.moderation.updateActorAccess`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/moderation/updateActorAccess.json public struct UpdateActorAccessRequestBody: Codable { @@ -23,7 +23,7 @@ extension ChatBskyLexicon.Moderation { public let doesAllowAccess: Bool /// A reference object for the action taken. - public let reference: String + public let reference: String? enum CodingKeys: String, CodingKey { case actorDID = "did" diff --git a/Sources/ATProtoKit/Networking/ChatAPI/ChatGetMessageContext.swift b/Sources/ATProtoKit/Networking/ChatAPI/ChatGetMessageContext.swift index 56d4d027bb..f423ef17d0 100644 --- a/Sources/ATProtoKit/Networking/ChatAPI/ChatGetMessageContext.swift +++ b/Sources/ATProtoKit/Networking/ChatAPI/ChatGetMessageContext.swift @@ -11,6 +11,9 @@ extension ATProtoBlueskyChat { /// Retrieves the message context as a moderator. /// + /// - Important: This is a moderator task and as such, regular users won't be able to access + /// this; if they attempt to do so, an error will occur. + /// /// - SeeAlso: This is based on the [`chat.bsky.moderation.getMessageContext`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/moderation/getMessageContext.json diff --git a/Sources/ATProtoKit/Networking/ChatAPI/ChatUpdateActorAccess.swift b/Sources/ATProtoKit/Networking/ChatAPI/ChatUpdateActorAccess.swift new file mode 100644 index 0000000000..95bedf0409 --- /dev/null +++ b/Sources/ATProtoKit/Networking/ChatAPI/ChatUpdateActorAccess.swift @@ -0,0 +1,59 @@ +// +// ChatUpdateActorAccess.swift +// +// +// Created by Christopher Jr Riley on 2024-05-31. +// + +import Foundation + +extension ATProtoBlueskyChat { + + /// Updates the user account's access to direct messages as an administrator. + /// + /// - Important: This is an administrator task and as such, regular users won't be able to access + /// this; if they attempt to do so, an error will occur. + /// + /// - SeeAlso: This is based on the [`chat.bsky.moderation.updateActorAccess`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/chat/bsky/moderation/updateActorAccess.json + /// + /// - Parameters: + /// - actorDID: The decentralized identifier (DID) of the user account. + /// - doesAllowAccess: Indicates whether the user account can acess direct messages. + /// - reference: A reference. Optional. + public func updateActorAccess( + actorDID: String, + doesAllowAccess: Bool, + reference: String? + ) async throws { + guard session != nil, + let accessToken = session?.accessToken else { + throw ATRequestPrepareError.missingActiveSession + } + + guard let sessionURL = session?.pdsURL, + let requestURL = URL(string: "\(sessionURL)/xrpc/chat.bsky.moderation.updateActorAccess") else { + throw ATRequestPrepareError.invalidRequestURL + } + + let requestBody = ChatBskyLexicon.Moderation.UpdateActorAccessRequestBody( + actorDID: actorDID, + doesAllowAccess: doesAllowAccess, + reference: reference + ) + + do { + let request = APIClientService.createRequest(forRequest: requestURL, + andMethod: .get, + acceptValue: nil, + contentTypeValue: "application/json", + authorizationValue: "Bearer \(accessToken)") + + try await APIClientService.sendRequest(request, + withEncodingBody: requestBody) + } catch { + throw error + } + } +} From e313a551a28127337750df346f1f35e95f13bb1a Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Fri, 31 May 2024 06:50:31 -0400 Subject: [PATCH 48/51] Add GetRepositoryStatus --- .../Sync/ComAtprotoSyncGetRepoStatus.swift | 69 +++++++++++++++++++ .../CoreAPI/GetRepositoryStatus.swift | 60 ++++++++++++++++ 2 files changed, 129 insertions(+) create mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncGetRepoStatus.swift create mode 100644 Sources/ATProtoKit/Networking/CoreAPI/GetRepositoryStatus.swift diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncGetRepoStatus.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncGetRepoStatus.swift new file mode 100644 index 0000000000..550da207a6 --- /dev/null +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/ComAtprotoSyncGetRepoStatus.swift @@ -0,0 +1,69 @@ +// +// ComAtprotoSyncGetRepoStatus.swift +// +// +// Created by Christopher Jr Riley on 2024-05-31. +// + +import Foundation + +extension ComAtprotoLexicon.Sync { + + /// The main data model definition for getting the status for a repository in the + /// Personal Data Server (PDS). + /// + /// - Note: According to the AT Protocol specifications: "Get the hosting status for a + /// repository, on this server. Expected to be implemented by PDS and Relay." + /// + /// - SeeAlso: This is based on the [`com.atproto.sync.getRepoStatus`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/sync/getRepoStatus.json + public struct GetRepositoryStatus: Codable { + + /// The status of the repository. + public enum Status: String, Codable { + + /// Indicates the repository has been taken down. + case takedown + + /// Indicates the repository has been suspended. + case suspended + + /// Indicates the repository has been deactivated. + case deactivated + } + } + + /// An output model for getting the status for a repository in the Personal Data Server (PDS). + /// + /// - Note: According to the AT Protocol specifications: "Get the hosting status for a + /// repository, on this server. Expected to be implemented by PDS and Relay." + /// + /// - SeeAlso: This is based on the [`com.atproto.sync.getRepoStatus`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/sync/getRepoStatus.json + public struct GetRepositoryStatusOutput: Codable { + + /// The decentralized identifier (DID) of the repository. + public let repositoryDID: String + + /// Indicates whether the repository is active. + public let isActive: Bool + + /// The status of the repository. Optional. + public let status: GetRepositoryStatus.Status + + /// The revision of the repository. + /// + /// - Note: According to the AT Protocol specifications: "Optional field, the current rev + /// of the repo, if active=true" + public let revision: String + + enum CodingKeys: String, CodingKey { + case repositoryDID = "did" + case isActive = "active" + case status + case revision = "rev" + } + } +} diff --git a/Sources/ATProtoKit/Networking/CoreAPI/GetRepositoryStatus.swift b/Sources/ATProtoKit/Networking/CoreAPI/GetRepositoryStatus.swift new file mode 100644 index 0000000000..65e4cd77bd --- /dev/null +++ b/Sources/ATProtoKit/Networking/CoreAPI/GetRepositoryStatus.swift @@ -0,0 +1,60 @@ +// +// GetRepositoryStatus.swift +// +// +// Created by Christopher Jr Riley on 2024-05-31. +// + +import Foundation + +extension ATProtoKit { + + /// Retrieves the status for a repository in the Personal Data Server (PDS). + /// + /// - Note: According to the AT Protocol specifications: "Get the hosting status for a + /// repository, on this server. Expected to be implemented by PDS and Relay." + /// + /// - SeeAlso: This is based on the [`com.atproto.sync.getRepoStatus`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/sync/getRepoStatus.json + /// + /// - Parameter actorDID: The decentralized identifier (DID) of the user account. + /// - Returns: A `Result`, containing either a ``ComAtprotoLexicon/Sync/GetRepositoryStatusOutput`` + /// if successful, or an `Error` if not. + public func getRepositoryStatus(from actorDID: String) async throws -> Result { + guard session != nil, + let accessToken = session?.accessToken else { + return .failure(ATRequestPrepareError.missingActiveSession) + } + + guard let sessionURL = session?.pdsURL, + let requestURL = URL(string: "\(sessionURL)/xrpc/com.atproto.sync.getRepoStatus") else { + return .failure(ATRequestPrepareError.invalidRequestURL) + } + + var queryItems = [(String, String)]() + + queryItems.append(("did", actorDID)) + + let queryURL: URL + + do { + queryURL = try APIClientService.setQueryItems( + for: requestURL, + with: queryItems + ) + + let request = APIClientService.createRequest(forRequest: queryURL, + andMethod: .get, + acceptValue: "application/json", + contentTypeValue: nil, + authorizationValue: "Bearer \(accessToken)") + let response = try await APIClientService.sendRequest(request, + decodeTo: ComAtprotoLexicon.Sync.GetRepositoryStatusOutput.self) + + return .success(response) + } catch { + return .failure(error) + } + } +} From 96b751ba7d713a361238cb374bd923b9c5a28d16 Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Fri, 31 May 2024 06:51:09 -0400 Subject: [PATCH 49/51] Update lexicons to latest changes --- Sources/ATProtoKit/Errors/ATProtoError.swift | 3 +++ Sources/ATProtoKit/Models/Lexicons/ATUnion.swift | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Sources/ATProtoKit/Errors/ATProtoError.swift b/Sources/ATProtoKit/Errors/ATProtoError.swift index 286e1a747a..7fffb39fae 100644 --- a/Sources/ATProtoKit/Errors/ATProtoError.swift +++ b/Sources/ATProtoKit/Errors/ATProtoError.swift @@ -96,6 +96,9 @@ public enum ATAPIError: ATProtoError, Decodable { "UnresolvableDid", "IncompatibleDidDoc", "AccountTakedown", + "RepoTakendown", + "RepoDeactivated", + "RepoSuspended", "DuplicateCreate", "TokenRequired", "FutureCursor", diff --git a/Sources/ATProtoKit/Models/Lexicons/ATUnion.swift b/Sources/ATProtoKit/Models/Lexicons/ATUnion.swift index d7c3046db4..028ba620c7 100644 --- a/Sources/ATProtoKit/Models/Lexicons/ATUnion.swift +++ b/Sources/ATProtoKit/Models/Lexicons/ATUnion.swift @@ -862,12 +862,12 @@ public struct ATUnion { public enum MessageViewEmbedUnion: Codable { /// A record within the embed. - case record(AppBskyLexicon.Embed.RecordDefinition) + case record(AppBskyLexicon.Embed.RecordDefinition.View) public init(from decoder: any Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(AppBskyLexicon.Embed.RecordDefinition.self) { + if let value = try? container.decode(AppBskyLexicon.Embed.RecordDefinition.View.self) { self = .record(value) } else { throw DecodingError.typeMismatch( From 28f6bfeb4930006debe68ea3c1085c08ba6e0e50 Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Fri, 31 May 2024 06:59:04 -0400 Subject: [PATCH 50/51] Add requestBody to methods --- Sources/ATProtoKit/Networking/ChatAPI/ChatMuteConvo.swift | 1 + Sources/ATProtoKit/Networking/ChatAPI/ChatSendMessage.swift | 1 + Sources/ATProtoKit/Networking/ChatAPI/ChatSendMessageBatch.swift | 1 + Sources/ATProtoKit/Networking/ChatAPI/ChatUnmuteConvo.swift | 1 + Sources/ATProtoKit/Networking/ChatAPI/ChatUpdateRead.swift | 1 + 5 files changed, 5 insertions(+) diff --git a/Sources/ATProtoKit/Networking/ChatAPI/ChatMuteConvo.swift b/Sources/ATProtoKit/Networking/ChatAPI/ChatMuteConvo.swift index 778413f2db..14885daa49 100644 --- a/Sources/ATProtoKit/Networking/ChatAPI/ChatMuteConvo.swift +++ b/Sources/ATProtoKit/Networking/ChatAPI/ChatMuteConvo.swift @@ -40,6 +40,7 @@ extension ATProtoBlueskyChat { contentTypeValue: "application/json", authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, + withEncodingBody: requestBody, decodeTo: ChatBskyLexicon.Conversation.MuteConversationOutput.self) return .success(response) diff --git a/Sources/ATProtoKit/Networking/ChatAPI/ChatSendMessage.swift b/Sources/ATProtoKit/Networking/ChatAPI/ChatSendMessage.swift index c251043af4..9e46cffcec 100644 --- a/Sources/ATProtoKit/Networking/ChatAPI/ChatSendMessage.swift +++ b/Sources/ATProtoKit/Networking/ChatAPI/ChatSendMessage.swift @@ -48,6 +48,7 @@ extension ATProtoBlueskyChat { contentTypeValue: "application/json", authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, + withEncodingBody: requestBody, decodeTo: ChatBskyLexicon.Conversation.MessageViewDefinition.self) return .success(response) diff --git a/Sources/ATProtoKit/Networking/ChatAPI/ChatSendMessageBatch.swift b/Sources/ATProtoKit/Networking/ChatAPI/ChatSendMessageBatch.swift index 3680375dc9..e1c254fc48 100644 --- a/Sources/ATProtoKit/Networking/ChatAPI/ChatSendMessageBatch.swift +++ b/Sources/ATProtoKit/Networking/ChatAPI/ChatSendMessageBatch.swift @@ -42,6 +42,7 @@ extension ATProtoBlueskyChat { contentTypeValue: "application/json", authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, + withEncodingBody: requestBody, decodeTo: ChatBskyLexicon.Conversation.SendMessageBatchOutput.self) return .success(response) diff --git a/Sources/ATProtoKit/Networking/ChatAPI/ChatUnmuteConvo.swift b/Sources/ATProtoKit/Networking/ChatAPI/ChatUnmuteConvo.swift index c14d5c2e0a..f2f119b02c 100644 --- a/Sources/ATProtoKit/Networking/ChatAPI/ChatUnmuteConvo.swift +++ b/Sources/ATProtoKit/Networking/ChatAPI/ChatUnmuteConvo.swift @@ -40,6 +40,7 @@ extension ATProtoBlueskyChat { contentTypeValue: "application/json", authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, + withEncodingBody: requestBody, decodeTo: ChatBskyLexicon.Conversation.UnmuteConversationOutput.self) return .success(response) diff --git a/Sources/ATProtoKit/Networking/ChatAPI/ChatUpdateRead.swift b/Sources/ATProtoKit/Networking/ChatAPI/ChatUpdateRead.swift index c8b7cf55aa..fd55f977f0 100644 --- a/Sources/ATProtoKit/Networking/ChatAPI/ChatUpdateRead.swift +++ b/Sources/ATProtoKit/Networking/ChatAPI/ChatUpdateRead.swift @@ -46,6 +46,7 @@ extension ATProtoBlueskyChat { contentTypeValue: "application/json", authorizationValue: "Bearer \(accessToken)") let response = try await APIClientService.sendRequest(request, + withEncodingBody: requestBody, decodeTo: ChatBskyLexicon.Conversation.UpdateReadOutput.self) return .success(response) From b461aa22cfa302ecf0309d8626631ae1f1bb26d5 Mon Sep 17 00:00:00 2001 From: Christopher Jr Riley Date: Fri, 31 May 2024 07:53:15 -0400 Subject: [PATCH 51/51] Remove old files; update outdated files This commit fixes any errors that have occured as a result of deleting the old files. --- .../ATProtoKit/Models/Lexicons/ATUnion.swift | 20 +- .../AppBskyActorSearchActorsTypeahead.swift | 2 +- .../app.bsky/Actor/BskyActorDefs.swift | 855 ------------- .../Actor/BskyActorGetPreferences.swift | 23 - .../app.bsky/Actor/BskyActorGetProfile.swift | 21 - .../app.bsky/Actor/BskyActorGetProfiles.swift | 21 - .../Actor/BskyActorGetSuggestions.swift | 23 - .../app.bsky/Actor/BskyActorProfile.swift | 45 - .../Actor/BskyActorPutPreferences.swift | 34 - .../Actor/BskyActorSearchActors.swift | 20 - .../BskyActorSearchActorsTypeahead.swift | 19 - .../app.bsky/Embed/BskyEmbedExternal.swift | 96 -- .../app.bsky/Embed/BskyEmbedImages.swift | 144 --- .../app.bsky/Embed/BskyEmbedRecord.swift | 243 ---- .../Embed/BskyEmbedRecordWithMedia.swift | 133 -- .../app.bsky/Feed/AppBskyFeedDefs.swift | 13 +- .../app.bsky/Feed/AppBskyFeedGenerator.swift | 6 +- .../Feed/AppBskyFeedGetActorLikes.swift | 2 +- .../app.bsky/Feed/AppBskyFeedRepost.swift | 6 +- .../Lexicons/app.bsky/Feed/BskyFeedDefs.swift | 770 ------------ .../Feed/BskyFeedDescribeFeedGenerator.swift | 51 - .../app.bsky/Feed/BskyFeedGenerator.swift | 103 -- .../app.bsky/Feed/BskyFeedGetActorFeeds.swift | 23 - .../app.bsky/Feed/BskyFeedGetActorLikes.swift | 23 - .../app.bsky/Feed/BskyFeedGetAuthorFeed.swift | 38 - .../app.bsky/Feed/BskyFeedGetFeed.swift | 23 - .../Feed/BskyFeedGetFeedGenerator.swift | 33 - .../Feed/BskyFeedGetFeedGenerators.swift | 22 - .../Feed/BskyFeedGetFeedSkeleton.swift | 24 - .../app.bsky/Feed/BskyFeedGetLikes.swift | 70 -- .../app.bsky/Feed/BskyFeedGetListFeed.swift | 25 - .../app.bsky/Feed/BskyFeedGetPostThread.swift | 60 - .../app.bsky/Feed/BskyFeedGetPosts.swift | 22 - .../app.bsky/Feed/BskyFeedGetRepostedBy.swift | 34 - .../Feed/BskyFeedGetSuggestedFeeds.swift | 24 - .../app.bsky/Feed/BskyFeedGetTimeline.swift | 23 - .../Lexicons/app.bsky/Feed/BskyFeedLike.swift | 59 - .../Lexicons/app.bsky/Feed/BskyFeedPost.swift | 250 ---- .../app.bsky/Feed/BskyFeedRepost.swift | 54 - .../app.bsky/Feed/BskyFeedSearchPosts.swift | 43 - .../Feed/BskyFeedSendInteractions.swift | 28 - .../app.bsky/Feed/BskyFeedThreadgate.swift | 114 -- .../app.bsky/Graph/AppBskyGraphDefs.swift | 7 +- .../app.bsky/Graph/AppBskyGraphList.swift | 6 +- .../app.bsky/Graph/BskyGraphBlock.swift | 55 - .../app.bsky/Graph/BskyGraphDefs.swift | 273 ----- .../app.bsky/Graph/BskyGraphFollow.swift | 52 - .../app.bsky/Graph/BskyGraphGetBlocks.swift | 24 - .../Graph/BskyGraphGetFollowers.swift | 25 - .../app.bsky/Graph/BskyGraphGetFollows.swift | 26 - .../app.bsky/Graph/BskyGraphGetList.swift | 25 - .../Graph/BskyGraphGetListBlocks.swift | 24 - .../Graph/BskyGraphGetListMutes.swift | 24 - .../app.bsky/Graph/BskyGraphGetLists.swift | 24 - .../app.bsky/Graph/BskyGraphGetMutes.swift | 24 - .../Graph/BskyGraphGetRelationships.swift | 56 - .../BskyGraphGetSuggestedFollowsByActor.swift | 23 - .../app.bsky/Graph/BskyGraphList.swift | 90 -- .../app.bsky/Graph/BskyGraphListblock.swift | 56 - .../app.bsky/Graph/BskyGraphListitem.swift | 65 - .../app.bsky/Graph/BskyGraphMuteActor.swift | 25 - .../Graph/BskyGraphMuteActorList.swift | 25 - .../app.bsky/Graph/BskyGraphUnmuteActor.swift | 25 - .../Graph/BskyGraphUnmuteActorList.swift | 26 - .../app.bsky/Labeler/AppBskyLabelerDefs.swift | 7 +- .../app.bsky/Labeler/BskyLabelerDefs.swift | 186 --- .../Labeler/BskyLabelerGetServices.swift | 54 - .../app.bsky/Labeler/BskyLabelerService.swift | 59 - .../BaskyNotificationUpdateSeen.swift | 40 - .../BskyNotificationGetUnreadCount.swift | 20 - .../BskyNotificationListNotifications.swift | 115 -- .../BskyNotificationRegisterPush.swift | 45 - .../RichText/AppBskyRichTextFacet.swift | 6 +- .../app.bsky/RichText/BskyRichTextFacet.swift | 270 ---- .../Unspecced/BskyUnspeccedDefs.swift | 42 - ...skyUnspeccedGetPopularFeedGenerators.swift | 26 - .../BskyUnspeccedGetSuggestionsSkeleton.swift | 26 - .../BskyUnspeccedGetTaggedSuggestions.swift | 78 -- .../BskyUnspeccedSearchActorsSkeleton.swift | 34 - .../BskyUnspeccedSearchPostsSkeleton.swift | 46 - .../com.atproto/Admin/AtprotoAdminDefs.swift | 599 --------- .../Admin/AtprotoAdminDeleteAccount.swift | 21 - .../AtprotoAdminDisableAccountInvites.swift | 32 - .../AtprotoAdminDisableInviteCodes.swift | 29 - .../AtprotoAdminEnableAccountInvites.swift | 30 - .../Admin/AtprotoAdminGetAccountInfos.swift | 20 - .../Admin/AtprotoAdminGetInviteCodes.swift | 30 - .../Admin/AtprotoAdminGetSubjectStatus.swift | 60 - .../AtprotoAdminQueryModerationStatuses.swift | 38 - .../Admin/AtprotoAdminSearchRepos.swift | 23 - .../Admin/AtprotoAdminSendEmail.swift | 52 - .../AtprotoAdminUpdateAccountEmail.swift | 29 - .../AtprotoAdminUpdateAccountHandle.swift | 29 - .../AtprotoAdminUpdateAccountPassword.swift | 28 - .../AtprotoAdminUpdateSubjectStatus.swift | 38 - .../Admin/ComAtprotoAdminDefs.swift | 13 +- .../ComAtprotoAdminGetAccountInfos.swift | 2 +- .../ComAtprotoAdminGetSubjectStatus.swift | 2 +- .../Admin/ComAtprotoAdminSearchRepos.swift | 7 +- ...IdentityGetRecommendedDidCredentials.swift | 31 - .../AtprotoIdentityResolveHandle.swift | 35 - .../AtprotoIdentitySignPLCOperation.swift | 45 - .../AtprotoIdentitySubmitPLCOperation.swift | 22 - .../AtprotoIdentityUpdateHandle.swift | 25 - .../com.atproto/Label/AtprotoLabelDefs.swift | 363 ------ .../Label/AtprotoLabelQueryLabels.swift | 22 - .../Label/ComAtprotoLabelDefs.swift | 2 +- .../AtprotoModerationCreateReport.swift | 107 -- .../Moderation/AtprotoModerationDefs.swift | 57 - .../ComAtprotoModerationCreateReport.swift | 7 +- .../Repo/AtprotoRepoApplyWrites.swift | 131 -- .../Repo/AtprotoRepoCreateRecord.swift | 67 - .../Repo/AtprotoRepoDeleteRecord.swift | 52 - .../Repo/AtprotoRepoDescribeRepo.swift | 46 - .../Repo/AtprotoRepoGetRecord.swift | 83 -- .../Repo/AtprotoRepoImportRepo.swift | 21 - .../Repo/AtprotoRepoListMissingBlobs.swift | 29 - .../Repo/AtprotoRepoListRecords.swift | 23 - .../Repo/AtprotoRepoPutRecord.swift | 64 - .../Repo/AtprotoRepoStrongRef.swift | 39 - .../Repo/AtprotoRepoUploadBlob.swift | 68 -- .../Repo/ComAtprotoRepoApplyWrites.swift | 80 +- .../Repo/ComAtprotoRepoListMissingBlobs.swift | 2 +- .../Repo/ComAtprotoRepoListRecords.swift | 2 +- .../AtprotoServerCheckAccountStatus.swift | 65 - .../Server/AtprotoServerConfirmEmail.swift | 22 - .../Server/AtprotoServerCreateAccount.swift | 73 -- .../AtprotoServerCreateAppPassword.swift | 61 - .../AtprotoServerCreateInviteCode.swift | 38 - .../AtprotoServerCreateInviteCodes.swift | 58 - .../Server/AtprotoServerCreateSession.swift | 27 - .../AtprotoServerDeactivateAccount.swift | 43 - .../Server/AtprotoServerDefs.swift | 99 -- .../Server/AtprotoServerDeleteAccount.swift | 30 - .../Server/AtprotoServerDescribeServer.swift | 78 -- .../AtprotoServerGetAccountInviteCodes.swift | 18 - .../Server/AtprotoServerGetServiceAuth.swift | 20 - .../AtprotoServerListAppPasswords.swift | 56 - .../AtprotoServerRequestEmailUpdate.swift | 24 - .../AtprotoServerRequestPasswordReset.swift | 20 - .../AtprotoServerReserveSigningKey.swift | 39 - .../Server/AtprotoServerResetPassword.swift | 27 - .../AtprotoServerRevokeAppPassword.swift | 24 - .../Server/AtprotoServerUpdateEmail.swift | 33 - .../Server/ComAtprotoServerDefs.swift | 7 +- ...omAtprotoServerGetAccountInviteCodes.swift | 2 +- .../com.atproto/Sync/AtprotoSyncCrawler.swift | 36 - .../com.atproto/Sync/AtprotoSyncGetBlob.swift | 36 - .../Sync/AtprotoSyncGetBlocks.swift | 29 - .../Sync/AtprotoSyncGetLatestCommit.swift | 28 - .../Sync/AtprotoSyncListBlobs.swift | 28 - .../Sync/AtprotoSyncListRepos.swift | 48 - .../Sync/AtprotoSyncSubscribeRepos.swift | 23 - .../Temp/AtprotoTempCheckSignupQueue.swift | 26 - .../AtprotoTempRequestPhoneVerification.swift | 22 - .../OzoneCommunicationCreateTemplate.swift | 38 - .../OzoneCommunicationDefs.swift | 94 -- .../OzoneCommunicationDeleteTemplate.swift | 20 - .../OzoneCommunicationListTemplates.swift | 20 - .../OzoneCommunicationUpdateTemplate.swift | 43 - .../Moderation/OzoneModerationDefs.swift | 1085 ----------------- .../Moderation/OzoneModerationEmitEvent.swift | 33 - .../OzoneModerationQueryEvents.swift | 31 - .../OzoneModerationQueryStatuses.swift | 23 - .../OzoneModerationSearchRepos.swift | 28 - .../Moderation/ToolsOzoneModerationDefs.swift | 6 +- .../Networking/CoreAPI/CreateInviteCode.swift | 2 +- .../CoreAPI/CreateInviteCodes.swift | 2 +- .../Networking/PlatformAPI/CreatePost.swift | 5 +- .../ATProtocolConfiguration.swift | 4 +- .../ATProtoKit/Utilities/ATFacetParser.swift | 6 +- .../Utilities/ATImageProcessing.swift | 6 +- 172 files changed, 127 insertions(+), 10640 deletions(-) delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/BskyActorDefs.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/BskyActorGetPreferences.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/BskyActorGetProfile.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/BskyActorGetProfiles.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/BskyActorGetSuggestions.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/BskyActorProfile.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/BskyActorPutPreferences.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/BskyActorSearchActors.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/BskyActorSearchActorsTypeahead.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/BskyEmbedExternal.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/BskyEmbedImages.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/BskyEmbedRecord.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/BskyEmbedRecordWithMedia.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedDefs.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedDescribeFeedGenerator.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGenerator.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetActorFeeds.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetActorLikes.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetAuthorFeed.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetFeed.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetFeedGenerator.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetFeedGenerators.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetFeedSkeleton.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetLikes.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetListFeed.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetPostThread.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetPosts.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetRepostedBy.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetSuggestedFeeds.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetTimeline.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedLike.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedPost.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedRepost.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedSearchPosts.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedSendInteractions.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedThreadgate.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphBlock.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphDefs.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphFollow.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphGetBlocks.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphGetFollowers.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphGetFollows.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphGetList.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphGetListBlocks.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphGetListMutes.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphGetLists.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphGetMutes.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphGetRelationships.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphGetSuggestedFollowsByActor.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphList.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphListblock.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphListitem.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphMuteActor.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphMuteActorList.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphUnmuteActor.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphUnmuteActorList.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/BskyLabelerDefs.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/BskyLabelerGetServices.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/BskyLabelerService.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/BaskyNotificationUpdateSeen.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/BskyNotificationGetUnreadCount.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/BskyNotificationListNotifications.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/BskyNotificationRegisterPush.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/RichText/BskyRichTextFacet.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/BskyUnspeccedDefs.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/BskyUnspeccedGetPopularFeedGenerators.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/BskyUnspeccedGetSuggestionsSkeleton.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/BskyUnspeccedGetTaggedSuggestions.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/BskyUnspeccedSearchActorsSkeleton.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/BskyUnspeccedSearchPostsSkeleton.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminDefs.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminDeleteAccount.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminDisableAccountInvites.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminDisableInviteCodes.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminEnableAccountInvites.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminGetAccountInfos.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminGetInviteCodes.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminGetSubjectStatus.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminQueryModerationStatuses.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminSearchRepos.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminSendEmail.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminUpdateAccountEmail.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminUpdateAccountHandle.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminUpdateAccountPassword.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminUpdateSubjectStatus.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/AtprotoIdentityGetRecommendedDidCredentials.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/AtprotoIdentityResolveHandle.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/AtprotoIdentitySignPLCOperation.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/AtprotoIdentitySubmitPLCOperation.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/AtprotoIdentityUpdateHandle.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Label/AtprotoLabelDefs.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Label/AtprotoLabelQueryLabels.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Moderation/AtprotoModerationCreateReport.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Moderation/AtprotoModerationDefs.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/AtprotoRepoApplyWrites.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/AtprotoRepoCreateRecord.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/AtprotoRepoDeleteRecord.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/AtprotoRepoDescribeRepo.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/AtprotoRepoGetRecord.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/AtprotoRepoImportRepo.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/AtprotoRepoListMissingBlobs.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/AtprotoRepoListRecords.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/AtprotoRepoPutRecord.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/AtprotoRepoStrongRef.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/AtprotoRepoUploadBlob.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerCheckAccountStatus.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerConfirmEmail.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerCreateAccount.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerCreateAppPassword.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerCreateInviteCode.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerCreateInviteCodes.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerCreateSession.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerDeactivateAccount.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerDefs.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerDeleteAccount.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerDescribeServer.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerGetAccountInviteCodes.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerGetServiceAuth.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerListAppPasswords.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerRequestEmailUpdate.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerRequestPasswordReset.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerReserveSigningKey.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerResetPassword.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerRevokeAppPassword.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerUpdateEmail.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/AtprotoSyncCrawler.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/AtprotoSyncGetBlob.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/AtprotoSyncGetBlocks.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/AtprotoSyncGetLatestCommit.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/AtprotoSyncListBlobs.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/AtprotoSyncListRepos.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/AtprotoSyncSubscribeRepos.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Temp/AtprotoTempCheckSignupQueue.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/com.atproto/Temp/AtprotoTempRequestPhoneVerification.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/OzoneCommunicationCreateTemplate.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/OzoneCommunicationDefs.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/OzoneCommunicationDeleteTemplate.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/OzoneCommunicationListTemplates.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/OzoneCommunicationUpdateTemplate.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/OzoneModerationDefs.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/OzoneModerationEmitEvent.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/OzoneModerationQueryEvents.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/OzoneModerationQueryStatuses.swift delete mode 100644 Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/OzoneModerationSearchRepos.swift diff --git a/Sources/ATProtoKit/Models/Lexicons/ATUnion.swift b/Sources/ATProtoKit/Models/Lexicons/ATUnion.swift index 028ba620c7..5c31a5679f 100644 --- a/Sources/ATProtoKit/Models/Lexicons/ATUnion.swift +++ b/Sources/ATProtoKit/Models/Lexicons/ATUnion.swift @@ -1117,7 +1117,7 @@ public struct ATUnion { case repositoryReference(ComAtprotoLexicon.Admin.RepositoryReferenceDefinition) /// A strong reference. - case strongReference(StrongReference) + case strongReference(ComAtprotoLexicon.Repository.StrongReference) /// A repository blob reference. case repositoryBlobReference(ComAtprotoLexicon.Admin.RepositoryBlobReferenceDefinition) @@ -1127,7 +1127,7 @@ public struct ATUnion { if let value = try? container.decode(ComAtprotoLexicon.Admin.RepositoryReferenceDefinition.self) { self = .repositoryReference(value) - } else if let value = try? container.decode(StrongReference.self) { + } else if let value = try? container.decode(ComAtprotoLexicon.Repository.StrongReference.self) { self = .strongReference(value) } else if let value = try? container.decode(ComAtprotoLexicon.Admin.RepositoryBlobReferenceDefinition.self) { self = .repositoryBlobReference(value) @@ -1159,7 +1159,7 @@ public struct ATUnion { case repositoryReference(ComAtprotoLexicon.Admin.RepositoryReferenceDefinition) /// A strong reference. - case strongReference(StrongReference) + case strongReference(ComAtprotoLexicon.Repository.StrongReference) /// A repository blob reference. case repositoryBlobReference(ComAtprotoLexicon.Admin.RepositoryBlobReferenceDefinition) @@ -1169,7 +1169,7 @@ public struct ATUnion { if let value = try? container.decode(ComAtprotoLexicon.Admin.RepositoryReferenceDefinition.self) { self = .repositoryReference(value) - } else if let value = try? container.decode(StrongReference.self) { + } else if let value = try? container.decode(ComAtprotoLexicon.Repository.StrongReference.self) { self = .strongReference(value) } else if let value = try? container.decode(ComAtprotoLexicon.Admin.RepositoryBlobReferenceDefinition.self) { self = .repositoryBlobReference(value) @@ -1233,22 +1233,22 @@ public struct ATUnion { public enum ApplyWritesUnion: Codable { /// A "Create" write operation. - case create(RepoApplyWritesCreate) + case create(ComAtprotoLexicon.Repository.ApplyWrites.Create) /// An "Update" write operation. - case update(RepoApplyWritesUpdate) + case update(ComAtprotoLexicon.Repository.ApplyWrites.Update) /// A "Delete" write operation. - case delete(RepoApplyWritesDelete) + case delete(ComAtprotoLexicon.Repository.ApplyWrites.Delete) public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(RepoApplyWritesCreate.self) { + if let value = try? container.decode(ComAtprotoLexicon.Repository.ApplyWrites.Create.self) { self = .create(value) - } else if let value = try? container.decode(RepoApplyWritesUpdate.self) { + } else if let value = try? container.decode(ComAtprotoLexicon.Repository.ApplyWrites.Update.self) { self = .update(value) - } else if let value = try? container.decode(RepoApplyWritesDelete.self) { + } else if let value = try? container.decode(ComAtprotoLexicon.Repository.ApplyWrites.Delete.self) { self = .delete(value) } else { throw DecodingError.typeMismatch( diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorSearchActorsTypeahead.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorSearchActorsTypeahead.swift index a720c62153..d733fd7f2b 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorSearchActorsTypeahead.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorSearchActorsTypeahead.swift @@ -18,6 +18,6 @@ extension AppBskyLexicon.Actor { public struct SearchActorsTypeaheadOutput: Codable { /// An array of actors. - public let actors: [ActorProfileViewBasic] + public let actors: [ProfileViewBasicDefinition] } } diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/BskyActorDefs.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/BskyActorDefs.swift deleted file mode 100644 index 5760cf9843..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/BskyActorDefs.swift +++ /dev/null @@ -1,855 +0,0 @@ -// -// BskyActorDefs.swift -// -// -// Created by Christopher Jr Riley on 2024-01-25. -// -import Foundation - -/// A data model for a basic profile view definition. -/// -/// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/9579bec720d30e40c995d09772040212c261d6fb/lexicons/app/bsky/actor/defs.json -public struct ActorProfileViewBasic: Codable { - /// The decentralized identifier (DID) of the user. - public let actorDID: String - /// The unique handle of the user. - public let actorHandle: String - /// The display name of the user. Optional. - /// - /// - Important: Current maximum length is 64 characters. - public var displayName: String? = nil - /// The avatar image URL of the user's profile. Optional. - public var avatarImageURL: URL? = nil - /// The associated profile view. Optional. - public var associated: ActorProfileAssociated? - /// The list of metadata relating to the requesting account's relationship with the subject - /// account. Optional. - public var viewer: ActorViewerState? = nil - /// An array of labels created by the user. Optional. - public var labels: [Label]? = nil - - public init(actorDID: String, actorHandle: String, displayName: String?, avatarImageURL: URL?, associated: ActorProfileAssociated?, - viewer: ActorViewerState?, labels: [Label]?) { - self.actorDID = actorDID - self.actorHandle = actorHandle - self.displayName = displayName - self.avatarImageURL = avatarImageURL - self.associated = associated - self.viewer = viewer - self.labels = labels - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.actorDID = try container.decode(String.self, forKey: .actorDID) - self.actorHandle = try container.decode(String.self, forKey: .actorHandle) - self.displayName = try container.decodeIfPresent(String.self, forKey: .displayName) - self.avatarImageURL = try container.decodeIfPresent(URL.self, forKey: .avatarImageURL) - self.associated = try container.decodeIfPresent(ActorProfileAssociated.self, forKey: .associated) - self.viewer = try container.decodeIfPresent(ActorViewerState.self, forKey: .viewer) - self.labels = try container.decodeIfPresent([Label].self, forKey: .labels) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self.actorDID, forKey: .actorDID) - try container.encode(self.actorHandle, forKey: .actorHandle) - - // Truncate `displayName` to 640 characters before encoding - // `maxGraphemes`'s limit is 64, but `String.count` should respect that limit implictly - try truncatedEncodeIfPresent(self.displayName, withContainer: &container, forKey: .displayName, upToLength: 640) - try container.encodeIfPresent(self.avatarImageURL, forKey: .avatarImageURL) - try container.encodeIfPresent(self.associated, forKey: .associated) - try container.encodeIfPresent(self.viewer, forKey: .viewer) - try container.encodeIfPresent(self.labels, forKey: .labels) - } - - enum CodingKeys: String, CodingKey { - case actorDID = "did" - case actorHandle = "handle" - case displayName - case avatarImageURL = "avatar" - case associated - case viewer - case labels - } -} - -/// A data model for a profile view definition. -/// -/// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/9579bec720d30e40c995d09772040212c261d6fb/lexicons/app/bsky/actor/defs.json -public struct ActorProfileView: Codable { - /// The decentralized identifier (DID) of the user. - public let actorDID: String - /// The unique handle of the user. - public let actorHandle: String - /// The display name of the user's profile. Optional. - /// - /// - Important: Current maximum length is 64 characters. - public var displayName: String? = nil - /// The description of the user's profile. Optional. - /// - /// - Important: Current maximum length is 256 characters. - public var description: String? = nil - /// The avatar image URL of a user's profile. Optional. - public let avatarImageURL: URL? - /// The associated profile view. Optional. - public var associated: ActorProfileAssociated? - /// The date the profile was last indexed. Optional. - @DateFormattingOptional public var indexedAt: Date? = nil - /// The list of metadata relating to the requesting account's relationship with the subject - /// account. Optional. - public var viewer: ActorViewerState? = nil - /// An array of labels created by the user. Optional. - public var labels: [Label]? = nil - - public init(actorDID: String, actorHandle: String, displayName: String?, description: String?, avatarImageURL: URL?, associated: ActorProfileAssociated?, - indexedAt: Date?, viewer: ActorViewerState?, labels: [Label]?) { - self.actorDID = actorDID - self.actorHandle = actorHandle - self.displayName = displayName - self.description = description - self.avatarImageURL = avatarImageURL - self.associated = associated - self._indexedAt = DateFormattingOptional(wrappedValue: indexedAt) - self.viewer = viewer - self.labels = labels - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.actorDID = try container.decode(String.self, forKey: .actorDID) - self.actorHandle = try container.decode(String.self, forKey: .actorHandle) - self.displayName = try container.decodeIfPresent(String.self, forKey: .displayName) - self.description = try container.decodeIfPresent(String.self, forKey: .description) - self.avatarImageURL = try container.decodeIfPresent(URL.self, forKey: .avatarImageURL) - self.associated = try container.decodeIfPresent(ActorProfileAssociated.self, forKey: .associated) - self.indexedAt = try container.decodeIfPresent(DateFormattingOptional.self, forKey: .indexedAt)?.wrappedValue - self.viewer = try container.decodeIfPresent(ActorViewerState.self, forKey: .viewer) - self.labels = try container.decodeIfPresent([Label].self, forKey: .labels) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self.actorDID, forKey: .actorDID) - try container.encode(self.actorHandle, forKey: .actorHandle) - - // Truncate `displayName` to 640 characters before encoding - // `maxGraphemes`'s limit is 64, but `String.count` should respect that limit implictly - try truncatedEncodeIfPresent(self.displayName, withContainer: &container, forKey: .displayName, upToLength: 640) - - // Truncate `description` to 2560 characters before encoding - // `maxGraphemes`'s limit is 256, but `String.count` should respect that limit - try truncatedEncodeIfPresent(self.description, withContainer: &container, forKey: .description, upToLength: 2560) - try container.encodeIfPresent(self.avatarImageURL, forKey: .avatarImageURL) - try container.encodeIfPresent(self.associated, forKey: .associated) - try container.encodeIfPresent(self._indexedAt, forKey: .indexedAt) - try container.encodeIfPresent(self.viewer, forKey: .viewer) - try container.encodeIfPresent(self.labels, forKey: .labels) - } - - enum CodingKeys: String, CodingKey { - case actorDID = "did" - case actorHandle = "handle" - case displayName - case description - case avatarImageURL = "avatar" - case associated - case indexedAt - case viewer - case labels - } -} - -/// A data model for a detailed profile view definition. -/// -/// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/9579bec720d30e40c995d09772040212c261d6fb/lexicons/app/bsky/actor/defs.json -public struct ActorProfileViewDetailed: Codable { - /// The decentralized identifier (DID) of the user. - public let actorDID: String - /// The unique handle of the user. - public let actorHandle: String - /// The display name of the user's profile. Optional. - /// - /// - Important: Current maximum length is 64 characters. - public var displayName: String? = nil - /// The description of the user's profile. Optional. - /// - /// - Important: Current maximum length is 256 characters. - public var description: String? = nil - /// The avatar image URL of a user's profile. Optional. - public var avatarImageURL: URL? = nil - /// The banner image URL of a user's profile. Optional. - public var bannerImageURL: URL? = nil - /// The number of followers a user has. Optional. - public var followerCount: Int? = nil - /// The number of accounts the user follows. Optional. - public var followCount: Int? = nil - /// The number of posts the user has. Optional. - public var postCount: Int? = nil - /// The associated profile view. Optional. - public let associated: ActorProfileAssociated? - /// The date the profile was last indexed. Optional. - @DateFormattingOptional public var indexedAt: Date? = nil - /// The list of metadata relating to the requesting account's relationship with the subject - /// account. Optional. - public var viewer: ActorViewerState? = nil - /// An array of labels created by the user. Optional. - public var labels: [Label]? = nil - - public init(actorDID: String, actorHandle: String, displayName: String?, description: String?, avatarImageURL: URL?, bannerImageURL: URL?, - followerCount: Int?, followCount: Int?, postCount: Int?, associated: ActorProfileAssociated?, indexedAt: Date?, viewer: ActorViewerState?, labels: [Label]?) { - self.actorDID = actorDID - self.actorHandle = actorHandle - self.displayName = displayName - self.description = description - self.avatarImageURL = avatarImageURL - self.bannerImageURL = bannerImageURL - self.followerCount = followerCount - self.followCount = followCount - self.postCount = postCount - self.associated = associated - self._indexedAt = DateFormattingOptional(wrappedValue: indexedAt) - self.viewer = viewer - self.labels = labels - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.actorDID = try container.decode(String.self, forKey: .actorDID) - self.actorHandle = try container.decode(String.self, forKey: .actorHandle) - self.displayName = try container.decodeIfPresent(String.self, forKey: .displayName) - self.description = try container.decodeIfPresent(String.self, forKey: .description) - self.avatarImageURL = try container.decodeIfPresent(URL.self, forKey: .avatarImageURL) - self.bannerImageURL = try container.decodeIfPresent(URL.self, forKey: .bannerImageURL) - self.followerCount = try container.decodeIfPresent(Int.self, forKey: .followerCount) - self.followCount = try container.decodeIfPresent(Int.self, forKey: .followCount) - self.postCount = try container.decodeIfPresent(Int.self, forKey: .postCount) - self.associated = try container.decodeIfPresent(ActorProfileAssociated.self, forKey: .associated) - self.indexedAt = try container.decodeIfPresent(DateFormattingOptional.self, forKey: .indexedAt)?.wrappedValue - self.viewer = try container.decodeIfPresent(ActorViewerState.self, forKey: .viewer) - self.labels = try container.decodeIfPresent([Label].self, forKey: .labels) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self.actorDID, forKey: .actorDID) - try container.encode(self.actorHandle, forKey: .actorHandle) - - // Truncate `displayName` to 640 characters before encoding - // `maxGraphemes`'s limit is 64, but `String.count` should respect that limit implictly - try truncatedEncodeIfPresent(self.displayName, withContainer: &container, forKey: .displayName, upToLength: 640) - - // Truncate `description` to 2560 characters before decoding - // `maxGraphemes`'s limit is 256, but `String.count` should respect that limit - try truncatedEncodeIfPresent(self.description, withContainer: &container, forKey: .description, upToLength: 2560) - try container.encodeIfPresent(self.avatarImageURL, forKey: .avatarImageURL) - try container.encodeIfPresent(self.bannerImageURL, forKey: .bannerImageURL) - try container.encodeIfPresent(self.followerCount, forKey: .followerCount) - try container.encodeIfPresent(self.followCount, forKey: .followCount) - try container.encodeIfPresent(self.postCount, forKey: .postCount) - try container.encodeIfPresent(self.associated, forKey: .associated) - try container.encodeIfPresent(self._indexedAt, forKey: .indexedAt) - try container.encodeIfPresent(self.viewer, forKey: .viewer) - try container.encodeIfPresent(self.labels, forKey: .labels) - } - - enum CodingKeys: String, CodingKey { - case actorDID = "did" - case actorHandle = "handle" - case displayName - case description - case avatarImageURL = "avatar" - case bannerImageURL = "banner" - case followerCount = "followersCount" - case followCount = "followsCount" - case postCount = "postsCount" - case associated - case indexedAt - case viewer - case labels - } -} - -/// A data model definition for an actor's associated profile. -/// -/// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/9579bec720d30e40c995d09772040212c261d6fb/lexicons/app/bsky/actor/defs.json -public struct ActorProfileAssociated: Codable { - /// The number of lists associated with the user. Optional. - public let lists: Int? - /// The number of feed generators associated with the user. Optional. - public let feedGenerators: Int? - /// Indicates whether the user account is a labeler. Optional. - public let isActorLabeler: Bool? - - enum CodingKeys: String, CodingKey { - case lists - case feedGenerators = "feedgens" - case isActorLabeler = "labeler" - } -} - -/// A data model for an actor viewer state definition. -/// -/// - Note: From the AT Protocol specification: "Metadata about the requesting account's -/// relationship with the subject account. Only has meaningful content for authed requests." -/// -/// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/9579bec720d30e40c995d09772040212c261d6fb/lexicons/app/bsky/actor/defs.json -public struct ActorViewerState: Codable { - /// Indicates whether the requesting account has been muted by the subject account. Optional. - public let isMuted: Bool? = nil - // TODO: Figure out what this is about. - /// An array of lists that the subject account is muted by. - public let mutedByArray: GraphListViewBasic? = nil - /// Indicates whether the requesting account has been blocked by the subject account. Optional. - public let isBlocked: Bool? = nil - // TODO: Figure out what this is about. - /// A URI. - public let blockingURI: String? = nil - /// An array of the subject account's lists. - public let blockingByArray: GraphListViewBasic? = nil - // TODO: Figure out what this is about. - /// A URI. - public let followingURI: String? = nil - // TODO: Figure out what this is about. - /// A URI. - public let followedByURI: String? = nil - - enum CodingKeys: String, CodingKey { - case isMuted = "muted" - case mutedByArray = "mutedByList" - case isBlocked = "blockedBy" - case blockingURI = "blocking" - case blockingByArray = "blockingByList" - case followingURI = "following" - case followedByURI = "followedBy" - } -} - -/// A data model for a preferences definition. -/// -/// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/9579bec720d30e40c995d09772040212c261d6fb/lexicons/app/bsky/actor/defs.json -public struct ActorPreferences: Codable { - /// An array of different preferences the user can set. - public let preferences: [ActorPreferenceUnion] - - public init(preferences: [ActorPreferenceUnion]) { - self.preferences = preferences - } -} - -/// A data model for an "Adult Content" preference definition. -/// -/// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/9579bec720d30e40c995d09772040212c261d6fb/lexicons/app/bsky/actor/defs.json -public struct AdultContentPreferences: Codable { - /// The identifier of the lexicon. - /// - /// - Warning: The value must not change. - public let type: String = "app.bsky.actor.defs#adultContentPref" - /// Indicates whether the user will be able to see adult content in their feed. Set to `false` - /// by default. - public var isAdultContentEnabled: Bool = false - - public init(isAdultContentEnabled: Bool) { - self.isAdultContentEnabled = isAdultContentEnabled - } - - enum CodingKeys: String, CodingKey { - case type = "$type" - case isAdultContentEnabled = "enabled" - } -} - -/// A data model for a "Content Label" preference definition. -/// -/// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/9579bec720d30e40c995d09772040212c261d6fb/lexicons/app/bsky/actor/defs.json -public struct ContentLabelPreferences: Codable { - /// The identifier of the lexicon. - /// - /// - Warning: The value must not change. - public let type: String = "app.bsky.actor.defs#contentLabelPref" - /// The decentralized identifier of the labeler that this preference applies to. - /// - /// - Note: If this field is empty, then the preferences apply to all labels. - /// - /// - Note: According to the AT Protocol specifications: "Which labeler does this preference - /// apply to? If undefined, applies globally." - public let labelerDID: String? - /// The name of the content label. - public let label: String - /// Indicates the visibility of the label's content. - public let visibility: Visibility - - public init(labelerDID: String?, label: String, visibility: Visibility) { - self.labelerDID = labelerDID - self.label = label - self.visibility = visibility - } - /// Determines how visible a label's content is. - public enum Visibility: String, Codable { - /// Indicates the content can be ignored. - case ignore = "ignore" - /// Indicates the content can be seen without restriction. - case show = "show" - /// Indicates the content can be seen, but will ask if the user wants to view it. - case warn = "warn" - /// Indicates the content is fully invisible by the user. - case hide = "hide" - } - - enum CodingKeys: String, CodingKey { - case type = "$type" - case labelerDID = "labelerDid" - case label - case visibility - } -} - -/// A data model for a "Saved Feeds" preference definition. -/// -/// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/9579bec720d30e40c995d09772040212c261d6fb/lexicons/app/bsky/actor/defs.json -public struct SavedFeedsPreferences: Codable { - /// The identifier of the lexicon. - /// - /// - Warning: The value must not change. - public let type: String = "app.bsky.actor.defs#savedFeedsPref" - /// An array of feed URIs that have been saved and pinned. - public let pinned: [String] - /// An array of feed URIs that have been saved. - public let saved: [String] - // TODO: Find out more about what this does. - /// The index number of the timeline for the list of feeds. Optional. - public var timelineIndex: Int? = nil - - public init(pinned: [String], saved: [String], timelineIndex: Int?) { - self.pinned = pinned - self.saved = saved - self.timelineIndex = timelineIndex - } - - enum CodingKeys: String, CodingKey { - case type = "$type" - case pinned - case saved - case timelineIndex - } -} - -/// A data model for a "Personal Details" preference definition. -/// -/// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/9579bec720d30e40c995d09772040212c261d6fb/lexicons/app/bsky/actor/defs.json -public struct PersonalDetailsPreferences: Codable { - /// The identifier of the lexicon. - /// - /// - Warning: The value must not change. - public let type: String = "app.bsky.actor.defs#personalDetailsPref" - /// The birth date of the user. Optional. - /// - /// - Note: From the AT Protocol specification: "The birth date of account owner." - @DateFormattingOptional public var birthDate: Date? = nil - - public init(birthDate: Date) { - self._birthDate = DateFormattingOptional(wrappedValue: birthDate) - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.birthDate = try container.decodeIfPresent(DateFormattingOptional.self, forKey: .birthDate)?.wrappedValue - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encodeIfPresent(self._birthDate, forKey: .birthDate) - } - - enum CodingKeys: String, CodingKey { - case type = "$type" - case birthDate - } -} - -/// A data model for a "Feed View" preference definition. -/// -/// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/9579bec720d30e40c995d09772040212c261d6fb/lexicons/app/bsky/actor/defs.json -public struct FeedViewPreferences: Codable { - /// The identifier of the lexicon. - /// - /// - Warning: The value must not change. - public let type: String = "app.bsky.actor.defs#feedViewPref" - /// The feed's identifier (typically the URI). - /// - /// - Note:From the AT Protocol specification: "The URI of the feed, or an identifier which - /// describes the feed." - public let feedURI: String - /// Indicates whether the replies are hidden from the user. Optional. - /// - /// - Note: From the AT Protocol specification: "Hide replies in the feed." - public let areRepliesHidden: Bool? = nil - /// Indicates whether replies from users you don't follow are hidden from the user. Optional. - /// - /// - Note: From the AT Protocol specification: "Hide replies in the feed if they are not by - /// followed users." - public let areUnfollowedRepliesHidden: Bool? = true - /// Indicates how many likes a post needs in order for the user to see the reply. Optional. - /// - /// - Note: From the AT Protocol specification: "Hide replies in the feed if they do not have - /// this number of likes." - public let hideRepliesByLikeCount: Int? = nil - /// Indicates whether reposts are hidden from the user. Optional. - /// - /// - Note: From the AT Protocol specification: "Hide reposts in the feed." - public let areRepostsHidden: Bool? = nil - /// Indicates whether quote posts are hidden from the user. Optional. - /// - /// - Note: From the AT Protocol specification: "Hide quote posts in the feed." - public let areQuotePostsHidden: Bool? = nil - - enum CodingKeys: String, CodingKey { - case type = "$type" - case feedURI = "feed" - case areRepliesHidden = "hideReplies" - case areUnfollowedRepliesHidden = "hideRepliesByUnfollowed" - case hideRepliesByLikeCount - case areRepostsHidden = "hideReposts" - case areQuotePostsHidden = "hideQuotePosts" - } -} - -/// A data model for a "Thread View" preference definition. -/// -/// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/9579bec720d30e40c995d09772040212c261d6fb/lexicons/app/bsky/actor/defs.json -public struct ThreadViewPreferences: Codable { - /// The identifier of the lexicon. - /// - /// - Warning: The value must not change. - public let type: String = "app.bsky.actor.defs#threadViewPref" - /// The sorting mode of a thread. Optional. - /// - /// - Note: From the AT Protocol specification: "Sorting mode for threads." - public let sortingMode: SortingMode? = nil - /// Indicates whether users you follow are prioritized over other users. Optional. - /// - /// - Note: From the AT Protocol specification: "Show followed users at the top of - /// all replies." - public let areFollowedUsersPrioritized: Bool? = nil - - /// The sorting mode for a thread. - public enum SortingMode: String, Codable { - /// Indicates the thread will be sorted from the oldest post. - case oldest = "oldest" - /// Indicates the thread will be sorted from the newest post. - case newest = "newest" - /// Indicates the thread will be sorted from the posts with the most number of likes. - case mostLikes = "most-likes" - /// Indicates the thread will be completely random. - case random = "random" - } - - enum CodingKeys: String, CodingKey { - case type = "$type" - case sortingMode = "sort" - case areFollowedUsersPrioritized = "prioritizeFollowedUsers" - } -} - -/// A data model for an "Interest View" preference definition. -/// -/// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/9579bec720d30e40c995d09772040212c261d6fb/lexicons/app/bsky/actor/defs.json -public struct InterestViewPreferences: Codable { - /// The identifier of the lexicon. - /// - /// - Warning: The value must not change. - public let type: String = "app.bsky.actor.defs#interestsPref" - /// An array of interest tags. - /// - /// - Note: According to AT Protocol's specifications: "A list of tags which describe the - /// account owner's interests gathered during onboarding." - /// - Important: Current maximum limit is 100 tags. Current maximum length for each tag name - /// is 64 characters. - public let tags: [String] - - public init(tags: [String]) { - self.tags = tags - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.tags = try container.decode([String].self, forKey: .tags) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - // Truncate `tags` to 640 characters before encoding. - // `maxGraphemes`'s limit is 64, but `String.count` should respect that limit implictly. - // Then, truncate `tags` to 100 items before encoding. - try truncatedEncode( - self.tags.map { $0.truncated(toLength: 640) }, - withContainer: &container, forKey: .tags, upToLength: 100) - } - - enum CodingKeys: String, CodingKey { - case type = "$type" - case tags - } -} - -/// A data model for a definition of the muted word's target. -/// -/// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/9579bec720d30e40c995d09772040212c261d6fb/lexicons/app/bsky/actor/defs.json -public enum MutedWordTarget: Codable { - case content - case tag - case other(String) - - public init(from decoder: Decoder) throws { - let container = try decoder.singleValueContainer() - let value = try container.decode(String.self) - - switch value { - case "content": - self = .content - case "tag": - self = .tag - // Handle other known cases - default: - self = .other(value) - } - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - switch self { - case .content: - try container.encode("content") - case .tag: - try container.encode("tag") - case .other(let other): - // Truncate `other` to 640 characters before decoding - // `maxGraphemes`'s limit is 64, but `String.count` should respect that limit - let truncatedOther = other.truncated(toLength: 640) - try container.encode(truncatedOther) - } - } -} - -/// A data model for a muted word definition. -/// -/// - Note: According to the AT Protocol specifications: "A word that the account owner has muted." -/// -/// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/9579bec720d30e40c995d09772040212c261d6fb/lexicons/app/bsky/actor/defs.json -public struct MutedWord: Codable { - public let value: String - public let targets: [MutedWordTarget] - - public init(value: String, targets: [MutedWordTarget]) { - self.value = value - self.targets = targets - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.value = try container.decode(String.self, forKey: .value) - self.targets = try container.decode([MutedWordTarget].self, forKey: .targets) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - // Truncate `value` to 1000 characters before decoding - // `maxGraphemes`'s limit is 100, but `String.count` should respect that limit - try truncatedEncode(self.value, withContainer: &container, forKey: .value, upToLength: 1000) - try container.encode(self.targets, forKey: .targets) - } - - enum CodingKeys: CodingKey { - case value - case targets - } -} - -/// A data model for a "Muted Words" preference definition. -/// -/// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/9579bec720d30e40c995d09772040212c261d6fb/lexicons/app/bsky/actor/defs.json -public struct MutedWordsPreferences: Codable { - /// The identifier of the lexicon. - /// - /// - Warning: The value must not change. - public let type: String = "app.bsky.actor.defs#mutedWordsPref" - /// An array of items the user has muted. - /// - /// - Note: According to the AT Protocol specifications: "A list of words the account owner - /// has muted." - public let mutedItems: [MutedWord] - - enum CodingKeys: String, CodingKey { - case type = "$type" - case mutedItems = "items" - } -} - -/// A data model for a "Hidden Posts" preference definition. -/// -/// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/9579bec720d30e40c995d09772040212c261d6fb/lexicons/app/bsky/actor/defs.json -public struct HiddenPostsPreferences: Codable { - /// The identifier of the lexicon. - /// - /// - Warning: The value must not change. - public let type: String = "app.bsky.actor.defs#hiddenPostsPref" - /// An array of URIs related to posts that the user wants to hide. - /// - /// - Note: According to the AT Protocol specifications: "A list of URIs of posts the account - /// owner has hidden." - public let items: [String] - - enum CodingKeys: String, CodingKey { - case type = "$type" - case items - } -} - -/// A data model for a "Labelers" preference definition. -/// -/// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/9579bec720d30e40c995d09772040212c261d6fb/lexicons/app/bsky/actor/defs.json -public struct LabelersPreferences: Codable { - /// An array of labeler items. - public let labelers: [String] -} - -/// A data model definition for a labeler item. -/// -/// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/9579bec720d30e40c995d09772040212c261d6fb/lexicons/app/bsky/actor/defs.json -public struct LabelersPreferenceItem: Codable { - /// The decentralized identifier (DID) of the labeler. - public let atDID: String -} - -// MARK: - Union types -/// A reference containing the list of preferences. -/// -/// - SeeAlso: This is based on the [`app.bsky.actor.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/9579bec720d30e40c995d09772040212c261d6fb/lexicons/app/bsky/actor/defs.json -public enum ActorPreferenceUnion: Codable { - /// The "Adult Content" preference. - case adultContent(AdultContentPreferences) - /// The "Content Label" preference. - case contentLabel(ContentLabelPreferences) - /// The "Saved Feeds" preference. - case savedFeeds(SavedFeedsPreferences) - /// The "Personal Details" preference. - case personalDetails(PersonalDetailsPreferences) - /// The "Feed View" preference. - case feedView(FeedViewPreferences) - /// The "Thread View" preference. - case threadView(ThreadViewPreferences) - /// The "Interest View" preference. - case interestViewPreferences(InterestViewPreferences) - /// The "Muted Words" preference. - case mutedWordsPreferences(MutedWordsPreferences) - /// The Hidden Posts" preference. - case hiddenPostsPreferences(HiddenPostsPreferences) - - // Implement custom decoding - public init(from decoder: Decoder) throws { - let container = try decoder.singleValueContainer() - - if let value = try? container.decode(AdultContentPreferences.self) { - self = .adultContent(value) - } else if let value = try? container.decode(ContentLabelPreferences.self) { - self = .contentLabel(value) - } else if let value = try? container.decode(SavedFeedsPreferences.self) { - self = .savedFeeds(value) - } else if let value = try? container.decode(PersonalDetailsPreferences.self) { - self = .personalDetails(value) - } else if let value = try? container.decode(FeedViewPreferences.self) { - self = .feedView(value) - } else if let value = try? container.decode(ThreadViewPreferences.self) { - self = .threadView(value) - } else if let value = try? container.decode(InterestViewPreferences.self) { - self = .interestViewPreferences(value) - } else if let value = try? container.decode(MutedWordsPreferences.self) { - self = .mutedWordsPreferences(value) - } else if let value = try? container.decode(HiddenPostsPreferences.self) { - self = .hiddenPostsPreferences(value) - } else { - throw DecodingError.typeMismatch( - ActorPreferenceUnion.self, DecodingError.Context( - codingPath: decoder.codingPath, debugDescription: "Unknown ActorPreference type")) - } - } - - // Implement custom encoding - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - - switch self { - case .adultContent(let preference): - try container.encode(preference) - case .contentLabel(let preference): - try container.encode(preference) - case .savedFeeds(let preference): - try container.encode(preference) - case .personalDetails(let preference): - try container.encode(preference) - case .feedView(let preference): - try container.encode(preference) - case .threadView(let preference): - try container.encode(preference) - case .interestViewPreferences(let preference): - try container.encode(preference) - case .mutedWordsPreferences(let preference): - try container.encode(preference) - case .hiddenPostsPreferences(let preference): - try container.encode(preference) - } - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/BskyActorGetPreferences.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/BskyActorGetPreferences.swift deleted file mode 100644 index 87516eb1dc..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/BskyActorGetPreferences.swift +++ /dev/null @@ -1,23 +0,0 @@ -// -// BskyActorGetPreferences.swift -// -// -// Created by Christopher Jr Riley on 2024-02-18. -// - -import Foundation - -// MARK: - -/// A data model definition for the output of getting preferences. -/// -/// - Note: According to the AT Protocol specifications: "Get private preferences attached to the -/// current account. Expected use is synchronization between multiple devices, and -/// import/export during account migration. Requires auth." -/// -/// - SeeAlso: This is based on the [`app.bsky.actor.getPreferences`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/getPreferences.json -public struct ActorGetPreferencesOutput: Codable { - /// The list of preferences in the user's account. - public let preference: ActorPreferences -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/BskyActorGetProfile.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/BskyActorGetProfile.swift deleted file mode 100644 index b68d67f8e9..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/BskyActorGetProfile.swift +++ /dev/null @@ -1,21 +0,0 @@ -// -// BskyActorGetProfile.swift.swift -// -// -// Created by Christopher Jr Riley on 2024-02-18. -// - -import Foundation - -/// A data model definition for the output for a detailed profile view for the user. -/// -/// - Note: According to the AT Protocol specifications: "Get detailed profile view of an actor. -/// Does not require auth, but contains relevant metadata with auth." -/// -/// - SeeAlso: This is based on the [`app.bsky.actor.getProfile`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/getProfile.json -public struct ActorGetProfileOutput: Codable { - /// A detailed profile view of the user. - public let actorProfileView: ActorProfileViewDetailed -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/BskyActorGetProfiles.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/BskyActorGetProfiles.swift deleted file mode 100644 index af0461000f..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/BskyActorGetProfiles.swift +++ /dev/null @@ -1,21 +0,0 @@ -// -// BskyActorGetProfiles.swift -// -// -// Created by Christopher Jr Riley on 2024-02-19. -// - -import Foundation - -/// A data model definition for the output of detailed profile views for multiple users. -/// -/// - Note: According to the AT Protocol specifications: "Get detailed profile views of -/// multiple actors." -/// -/// - SeeAlso: This is based on the [`app.bsky.actor.getProfiles`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/getProfiles.json -public struct ActorGetProfilesOutput: Codable { - /// An array of detailed profile views for several users. - public let profiles: [ActorProfileViewDetailed] -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/BskyActorGetSuggestions.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/BskyActorGetSuggestions.swift deleted file mode 100644 index 282b26c8d7..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/BskyActorGetSuggestions.swift +++ /dev/null @@ -1,23 +0,0 @@ -// -// BskyActorGetSuggestions.swift -// -// -// Created by Christopher Jr Riley on 2024-02-20. -// - -import Foundation - -/// A data model for the output of the list of suggested users to follow. -/// -/// - Note: According to the AT Protocol specifications: "Get a list of suggested actors. -/// Expected use is discovery of accounts to follow during new account onboarding." -/// -/// - SeeAlso: This is based on the [`app.bsky.actor.getSuggestions`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/getSuggestions.json -public struct ActorGetSuggestionsOutput: Codable { - /// The mark used to indicate the starting point for the next set of results. Optional. - public let cursor: String? - /// An array of actors. - public let actors: [ActorProfileView] -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/BskyActorProfile.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/BskyActorProfile.swift deleted file mode 100644 index 593ef54420..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/BskyActorProfile.swift +++ /dev/null @@ -1,45 +0,0 @@ -// -// BskyActorProfile.swift -// -// -// Created by Christopher Jr Riley on 2024-02-22. -// - -import Foundation - -/// The main data model definition for an actor. -/// -/// - Note: According to the AT Protocol specifications: "A declaration of a Bluesky -/// account profile." -/// -/// - SeeAlso: This is based on the [`app.bsky.actor.profile`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/profile.json -public struct ActorProfile: Codable { - /// The display name of the profile. Optional. - public let displayName: String? - /// The description of the profile. Optional. - /// - /// - Note: According to the AT Protocol specifications: "Free-form profile - /// description text." - public let description: String? - /// The avatar image URL of the profile. Optional. - /// - /// - Note: According to the AT Protocol specifications: "Small image to be displayed next - /// to posts from account. AKA, 'profile picture'" - /// - /// - Note: Only JPEGs and PNGs are accepted. - public let avatarBlob: BlobContainer? - /// The banner image URL of the profile. Optional. - /// - /// - Note: According to the AT Protocol specifications: "Larger horizontal image to display - /// behind profile view." - /// - /// - Note: Only JPEGs and PNGs are accepted. - public let bannerBlob: BlobContainer? - /// An array of user-defined labels. Optional. - /// - /// - Note: According to the AT Protocol specifications: "Self-label values, specific to the - /// Bluesky application, on the overall account." - public let labels: [SelfLabels] -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/BskyActorPutPreferences.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/BskyActorPutPreferences.swift deleted file mode 100644 index dd515e0ab3..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/BskyActorPutPreferences.swift +++ /dev/null @@ -1,34 +0,0 @@ -// -// BskyActorPutPreferences.swift -// -// -// Created by Christopher Jr Riley on 2024-02-22. -// - -import Foundation - -/// The main data model definition for editing user preferences. -/// -/// - Note: According to the AT Protocol specifications: "Set the private preferences attached to -/// the account." -/// -/// - SeeAlso: This is based on the [`app.bsky.actor.putPreferences`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/putPreferences.json -public struct ActorPutPreferences: Codable { - /// The identifier of the lexicon. - /// - /// - Warning: The value must not change. - public let type: String = "app.bsky.actor.putPreferences" - /// A list of preferences by the user. - public let preferences: [ActorPreferenceUnion] - - public init(preferences: [ActorPreferenceUnion]) { - self.preferences = preferences - } - - enum CodingKeys: String, CodingKey { - case type = "$type" - case preferences - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/BskyActorSearchActors.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/BskyActorSearchActors.swift deleted file mode 100644 index cea8f6804f..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/BskyActorSearchActors.swift +++ /dev/null @@ -1,20 +0,0 @@ -// -// BskyActorSearchActors.swift -// -// -// Created by Christopher Jr Riley on 2024-02-23. -// - -import Foundation - -/// A data model definition for the output of searching for actors matching the search criteria. -/// -/// - SeeAlso: This is based on the [`app.bsky.actor.searchActors`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/searchActors.json -public struct ActorSearchActorsOutput: Codable { - /// The mark used to indicate the starting point for the next set of results. Optional. - public let cursor: String - /// An array of actors. - public let actors: [ActorProfileView] -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/BskyActorSearchActorsTypeahead.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/BskyActorSearchActorsTypeahead.swift deleted file mode 100644 index 11c2f9d7bb..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/BskyActorSearchActorsTypeahead.swift +++ /dev/null @@ -1,19 +0,0 @@ -// -// BskyActorSearchActorsTypeahead.swift -// -// -// Created by Christopher Jr Riley on 2024-02-23. -// - -import Foundation - -/// A data model definition for the output of searching for actors matching the prefixed -/// search criteria. -/// -/// - SeeAlso: This is based on the [`app.bsky.actor.searchActorsTypeahead`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/actor/searchActorsTypeahead.json -public struct ActorSearchActorsTypeaheadOutput: Codable { - /// An array of actors. - public let actors: [ActorProfileViewBasic] -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/BskyEmbedExternal.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/BskyEmbedExternal.swift deleted file mode 100644 index 51140d5189..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/BskyEmbedExternal.swift +++ /dev/null @@ -1,96 +0,0 @@ -// -// BskyEmbedExternal.swift -// -// -// Created by Christopher Jr Riley on 2024-01-26. -// - -import Foundation - -// MARK: - Main definition -/// The main data model definition for external embeds. -/// -/// - Note: According to the AT Protocol specifications: "A representation of some externally -/// linked content (eg, a URL and 'card'), embedded in a Bluesky record (eg, a post)." -/// -/// - SeeAlso: This is based on the [`app.bsky.embed.external`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/external.json -public struct EmbedExternal: Codable { - /// The identifier of the lexicon. - /// - /// - Warning: The value must not change. - public let type: String = "app.bsky.embed.external" - /// The external content needed to be embeeded. - public let external: External - - enum CodingKeys: String, CodingKey { - case type = "$type" - case external - } -} -// MARK: - -/// A data model for an external definition. -/// -/// - SeeAlso: This is based on the [`app.bsky.embed.external`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/external.json -public struct External: Codable { - /// The URI of the external content. - public let embedURI: String - /// The title of the external content. - public let title: String - /// The description of the external content. - public let description: String - /// The thumbnail image of the external content. - /// - /// - Warning: The image size can't be higher than 1 MB. Failure to do so will result in the - /// image failing to upload. - public let thumbnailImage: UploadBlobOutput? - - enum CodingKeys: String, CodingKey { - case embedURI = "uri" - case title - case description - case thumbnailImage = "thumb" - } -} - -/// A data model for an external view definition. -/// -/// - SeeAlso: This is based on the [`app.bsky.embed.external`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/external.json -public struct EmbedExternalView: Codable { - /// The identifier of the lexicon. - /// - /// - Warning: The value must not change. - public let type: String = "app.bsky.embed.external#view" - - /// The external content embedded in a post. - public let external: ViewExternal - - enum CodingKeys: String, CodingKey { - case type = "$type" - case external - } -} - -/// A data model for a definition for the external content. -public struct ViewExternal: Codable { - /// The URI of the external content. - public let embedURI: String - /// The title of the external content. - public let title: String - /// The description of the external content. - public let description: String - /// The thumbnail image URL of the external content. - public let thumbnailImageURL: URL? - - enum CodingKeys: String, CodingKey { - case embedURI = "uri" - case title - case description - case thumbnailImageURL = "thumb" - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/BskyEmbedImages.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/BskyEmbedImages.swift deleted file mode 100644 index 07e25845fc..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/BskyEmbedImages.swift +++ /dev/null @@ -1,144 +0,0 @@ -// -// BskyEmbedImages.swift -// -// -// Created by Christopher Jr Riley on 2024-01-26. -// - -import Foundation - -// MARK: - Main definition -/// The main data model definition for image embeds. -/// -/// - Note: According to the AT Protocol specifications: "A set of images embedded in a Bluesky -/// record (eg, a post)." -/// -/// - SeeAlso: This is based on the [`app.bsky.embed.images`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/images.json -public struct EmbedImages: Codable { - /// The identifier of the lexicon. - /// - /// - Warning: The value must not change. - public let type: String = "app.bsky.embed.images" - /// An array of images to embed. - /// - ///- Note: Current maximum upload count is 4 images. - public let images: [EmbedImage] - - public init(images: [EmbedImage]) { - self.images = images - } - - enum CodingKeys: String, CodingKey { - case type = "$type" - case images - } -} - -// MARK: - -/// A data model for an external definition. -/// -/// - SeeAlso: This is based on the [`app.bsky.embed.images`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/images.json -public struct EmbedImage: Codable { - /// The image that needs to be uploaded. - /// - /// - Warning: The image size can't be higher than 1 MB. Failure to do so will result in the - /// image failing to upload. - public let image: UploadBlobOutput - /// The alternative text for the image. - /// - /// - Note: From the AT Protocol specification: "Alt text description of the image, - /// for accessibility." - public let altText: String - /// The aspect ratio of the image. Optional. - public let aspectRatio: AspectRatio? - - public init(image: UploadBlobOutput, altText: String, aspectRatio: AspectRatio?) { - self.image = image - self.altText = altText - self.aspectRatio = aspectRatio - } - - enum CodingKeys: String, CodingKey { - case image - case altText = "alt" - case aspectRatio - } -} - -/// A data model for the aspect ratio definition. -/// -/// - Note: From the AT Protocol specification: "width:height represents an aspect ratio. -/// It may be approximate, and may not correspond to absolute dimensions in any given unit." -/// -/// - SeeAlso: This is based on the [`app.bsky.embed.images`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/images.json -public struct AspectRatio: Codable { - /// The width of the image. - public let width: Int - /// The height of the image. - public let height: Int - - public init(width: Int, height: Int) { - self.width = width - self.height = height - } -} - -/// A data model for the embed images definition. -/// -/// - SeeAlso: This is based on the [`app.bsky.embed.images`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/images.json -public struct EmbedImagesView: Codable { - /// The identifier of the lexicon. - /// - /// - Warning: The value must not change. -// public let type: String = "app.bsky.embed.images#view" - /// An array of images to be viewed. - public let images: [ViewImage] -} - -/// A data model for a definition related to viewing an image. -/// -/// - SeeAlso: This is based on the [`app.bsky.embed.images`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/images.json -public struct ViewImage: Codable { - /// The URI of the image's thumbnail. - /// - /// - Note: From the AT Protocol specification: "Fully-qualified URL where a thumbnail of the - /// image can be fetched. For example, CDN location provided by the App View." - public let thumbnailImageURL: URL - /// The URI of the fully-sized image. - /// - /// - Note: From the AT Protocol specification: "Fully-qualified URL where a large version of - /// the image can be fetched. May or may not be the exact original blob. For example, - /// CDN location provided by the App View." - public let fullSizeImageURL: URL - /// /// The alternative text for the image. - /// - /// - Note: From the AT Protocol specification: "Alt text description of the image, - /// for accessibility." - public let altText: String - /// The aspect ratio of the image. Optional. - public let aspectRatio: AspectRatio? - - public init(thumbnailImageURL: URL, fullSizeImageURL: URL, altText: String, aspectRatio: AspectRatio?) { - self.thumbnailImageURL = thumbnailImageURL - self.fullSizeImageURL = fullSizeImageURL - self.altText = altText - self.aspectRatio = aspectRatio - } - - enum CodingKeys: String, CodingKey { - case thumbnailImageURL = "thumb" - case fullSizeImageURL = "fullsize" - case altText = "alt" - case aspectRatio - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/BskyEmbedRecord.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/BskyEmbedRecord.swift deleted file mode 100644 index 651d4900cd..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/BskyEmbedRecord.swift +++ /dev/null @@ -1,243 +0,0 @@ -// -// BskyEmbedRecord.swift -// -// -// Created by Christopher Jr Riley on 2024-01-26. -// - -import Foundation - -// MARK: - Main definition -/// The main data model definition for record embeds. -/// -/// - Note: According to the AT Protocol specifications: "A representation of a record embedded in -/// a Bluesky record (eg, a post). For example, a quote-post, or sharing a feed generator record." -/// -/// - SeeAlso: This is based on the [`app.bsky.embed.record`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/record.json -public struct EmbedRecord: Codable { - /// The identifier of the lexicon. - /// - /// - Warning: The value must not change. - public let type: String = "app.bsky.embed.record" - /// The strong reference of the record. - public let record: StrongReference - - enum CodingKeys: String, CodingKey { - case type = "$type" - case record - } -} - -// MARK: - -/// A data model for a view definition. -/// -/// - SeeAlso: This is based on the [`app.bsky.embed.record`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/record.json -public struct EmbedRecordView: Codable { - /// The identifier of the lexicon. - /// - /// - Warning: The value must not change. - public let type: String = "app.bsky.embed.record#view" - /// The record of a specific type. - public let record: RecordViewUnion - - enum CodingKeys: String, CodingKey { - case type = "$type" - case record - } -} - -/// A data model for a record definition in an embed. -/// -/// - SeeAlso: This is based on the [`app.bsky.embed.record`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/record.json -public struct ViewRecord: Codable { - /// The identifier of the lexicon. - /// - /// - Warning: The value must not change. - public let type: String = "app.bsky.embed.record#viewRecord" - /// The URI of the record. - public let recordURI: String - /// The CID of the record. - public let cidHash: String - /// The creator of the record. - public let author: ActorProfileViewBasic - // TODO: Find out what specific type falls under this variable. - /// The value of the record. - /// - /// - Note: According to the AT Protocol specifications: "The record data itself." - public let value: UnknownType - /// An array of labels attached to the record. - public let labels: [Label]? - /// The number of replies for the record. Optional. - public let replyCount: Int? - /// The number of reposts for the record. Optional. - public let repostCount: Int? - /// The number of likes for the record. Optional. - public let likeCount: Int? - /// An array of embed views of various types. - public let embeds: [EmbedViewUnion]? - /// The date the record was last indexed. - @DateFormatting public var indexedAt: Date - - public init(recordURI: String, cidHash: String, author: ActorProfileViewBasic, value: UnknownType, labels: [Label]?, replyCount: Int?, - repostCount: Int?, likeCount: Int?, embeds: [EmbedViewUnion]?, indexedAt: Date) { - self.recordURI = recordURI - self.cidHash = cidHash - self.author = author - self.value = value - self.labels = labels - self.replyCount = replyCount - self.repostCount = repostCount - self.likeCount = likeCount - self.embeds = embeds - self._indexedAt = DateFormatting(wrappedValue: indexedAt) - } - - public init(from decoder: any Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.recordURI = try container.decode(String.self, forKey: .recordURI) - self.cidHash = try container.decode(String.self, forKey: .cidHash) - self.author = try container.decode(ActorProfileViewBasic.self, forKey: .author) - self.value = try container.decode(UnknownType.self, forKey: .value) - self.labels = try container.decodeIfPresent([Label].self, forKey: .labels) - self.replyCount = try container.decodeIfPresent(Int.self, forKey: .replyCount) - self.repostCount = try container.decodeIfPresent(Int.self, forKey: .repostCount) - self.likeCount = try container.decodeIfPresent(Int.self, forKey: .likeCount) - self.embeds = try container.decodeIfPresent([EmbedViewUnion].self, forKey: .embeds) - self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue - } - - public func encode(to encoder: any Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self.recordURI, forKey: .recordURI) - try container.encode(self.cidHash, forKey: .cidHash) - try container.encode(self.author, forKey: .author) - try container.encode(self.value, forKey: .value) - try container.encodeIfPresent(self.labels, forKey: .labels) - try container.encodeIfPresent(self.replyCount, forKey: .replyCount) - try container.encodeIfPresent(self.repostCount, forKey: .repostCount) - try container.encodeIfPresent(self.likeCount, forKey: .likeCount) - try container.encodeIfPresent(self.embeds, forKey: .embeds) - try container.encode(self._indexedAt, forKey: .indexedAt) - } - - enum CodingKeys: String, CodingKey { - case type = "$type" - case recordURI = "uri" - case cidHash = "cid" - case author - case value - case labels - case replyCount - case repostCount - case likeCount - case embeds = "embeds" - case indexedAt - } -} - -/// A data model for a definition of a record that was unable to be found. -/// -/// - SeeAlso: This is based on the [`app.bsky.embed.record`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/record.json -public struct ViewNotFound: Codable { - /// The URI of the record. - public let recordURI: String - /// Indicates whether the record was found. - public let isRecordNotFound: Bool - - enum CodingKeys: String, CodingKey { - case recordURI = "uri" - case isRecordNotFound = "notFound" - } -} - -/// A data model for a definition of a record that has been blocked. -/// -/// - SeeAlso: This is based on the [`app.bsky.embed.record`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/record.json -public struct ViewBlocked: Codable { - /// The URI of the record. - public let recordURI: String - /// Indicates whether the record has been blocked. - public let isRecordBlocked: Bool - /// The author of the record. - public let recordAuthor: FeedBlockedAuthor - - enum CodingKeys: String, CodingKey { - case recordURI = "uri" - case isRecordBlocked = "blocked" - case recordAuthor = "author" - } -} - -// MARK: - Union types -/// A reference containing the list of the status of a record. -/// -/// - SeeAlso: This is based on the [`app.bsky.embed.record`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/record.json -public enum RecordViewUnion: Codable { - /// A normal record type. - case viewRecord(ViewRecord) - /// A record that may not have been found. - case viewNotFound(ViewNotFound) - /// A record that may have been blocked. - case viewBlocked(ViewBlocked) - /// A generator view. - case generatorView(FeedGeneratorView) - /// A list view. - case listView(GraphListView) - /// A labeler view. - case labelerView(LabelerView) - - public init(from decoder: Decoder) throws { - let container = try decoder.singleValueContainer() - - if let value = try? container.decode(ViewRecord.self) { - self = .viewRecord(value) - } else if let value = try? container.decode(ViewNotFound.self) { - self = .viewNotFound(value) - } else if let value = try? container.decode(ViewBlocked.self) { - self = .viewBlocked(value) - } else if let value = try? container.decode(FeedGeneratorView.self) { - self = .generatorView(value) - } else if let value = try? container.decode(GraphListView.self) { - self = .listView(value) - } else if let value = try? container.decode(LabelerView.self) { - self = .labelerView(value) - } else { - throw DecodingError.typeMismatch( - RecordViewUnion.self, DecodingError.Context( - codingPath: decoder.codingPath, debugDescription: "Unknown RecordViewUnion type")) - } - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - - switch self { - case .viewRecord(let viewRecord): - try container.encode(viewRecord) - case .viewNotFound(let viewRecord): - try container.encode(viewRecord) - case .viewBlocked(let viewRecord): - try container.encode(viewRecord) - case .generatorView(let viewRecord): - try container.encode(viewRecord) - case .listView(let viewRecord): - try container.encode(viewRecord) - case .labelerView(let labelerView): - try container.encode(labelerView) - } - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/BskyEmbedRecordWithMedia.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/BskyEmbedRecordWithMedia.swift deleted file mode 100644 index 6f66f4b060..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Embed/BskyEmbedRecordWithMedia.swift +++ /dev/null @@ -1,133 +0,0 @@ -// -// BskyEmbedRecordWithMedia.swift -// -// -// Created by Christopher Jr Riley on 2024-01-27. -// - -import Foundation - -// MARK: - Main definition -/// The main data model definition for a record embedded with some form of compatible media. -/// -/// - Note: According to the AT Protocol specifications: "A representation of a record embedded in -/// a Bluesky record (eg, a post), alongside other compatible embeds. For example, a quote post -/// and image, or a quote post and external URL card." -/// -/// - SeeAlso: This is based on the [`app.bsky.embed.recordWithMedia][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/recordWithMedia.json -public struct EmbedRecordWithMedia: Codable { - /// The identifier of the lexicon. - /// - /// - Warning: The value must not change. - public let type: String = "app.bsky.embed.recordWithMedia" - /// The record that will be embedded. - public let record: EmbedRecord - /// The media of a specific type. - public let media: MediaUnion - - enum CodingKeys: String, CodingKey { - case type = "$type" - case record - case media - } -} - -// MARK: - -/// A data model for a definition which contains an embedded record and embedded media. -/// -/// - SeeAlso: This is based on the [`app.bsky.embed.recordWithMedia`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/recordWithMedia.json -public struct EmbedRecordWithMediaView: Codable { - /// The identifier of the lexicon. - /// - /// - Warning: The value must not change. - public let type: String = "app.bsky.embed.recordWithMedia#view" - /// The embeded record. - public let record: EmbedRecordView - /// The embedded media. - public let media: MediaViewUnion - - enum CodingKeys: String, CodingKey { - case type = "$type" - case record - case media - } -} - -// MARK: - Union Types -/// A reference containing the list of the types of compatible media. -/// -/// - SeeAlso: This is based on the [`app.bsky.embed.recordWithMedia`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/recordWithMedia.json -public enum MediaUnion: Codable { - /// An image that will be embedded. - case embedImages(EmbedImages) - /// An external link that will be embedded. - case embedExternal(EmbedExternal) - - public init(from decoder: Decoder) throws { - let container = try decoder.singleValueContainer() - - if let value = try? container.decode(EmbedImages.self) { - self = .embedImages(value) - } else if let value = try? container.decode(EmbedExternal.self) { - self = .embedExternal(value) - } else { - throw DecodingError.typeMismatch( - PostUnion.self, DecodingError.Context( - codingPath: decoder.codingPath, debugDescription: "Unknown MediaUnion type")) - } - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - - switch self { - case .embedImages(let media): - try container.encode(media) - case .embedExternal(let media): - try container.encode(media) - } - } -} - -/// A reference containing the list of the types of compatible media that can be viewed. -/// -/// - SeeAlso: This is based on the [`app.bsky.embed.recordWithMedia`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/recordWithMedia.json -public enum MediaViewUnion: Codable { - /// An image that's been embedded. - case embedImagesView(EmbedImagesView) - /// An external link that's been embedded. - case embedExternalView(EmbedExternalView) - - public init(from decoder: Decoder) throws { - let container = try decoder.singleValueContainer() - - if let value = try? container.decode(EmbedImagesView.self) { - self = .embedImagesView(value) - } else if let value = try? container.decode(EmbedExternalView.self) { - self = .embedExternalView(value) - } else { - throw DecodingError.typeMismatch( - PostUnion.self, DecodingError.Context( - codingPath: decoder.codingPath, debugDescription: "Unknown MediaViewUnion type")) - } - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - - switch self { - case .embedImagesView(let mediaView): - try container.encode(mediaView) - case .embedExternalView(let mediaView): - try container.encode(mediaView) - } - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedDefs.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedDefs.swift index acde044801..76d60689bc 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedDefs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedDefs.swift @@ -396,7 +396,7 @@ extension AppBskyLexicon.Feed { public var description: String? /// An array of the facets within the feed generator's description. - public let descriptionFacets: [Facet]? + public let descriptionFacets: [AppBskyLexicon.RichText.Facet]? /// The avatar image URL of the feed generator. public var avatarImageURL: URL? @@ -411,7 +411,7 @@ extension AppBskyLexicon.Feed { public let canAcceptInteractions: Bool? /// An array of labels. Optional. - public let labels: [Label]? + public let labels: [ComAtprotoLexicon.Label.LabelDefinition]? /// The viewer's state for the feed generator. public var viewer: GeneratorViewerStateDefinition? @@ -420,7 +420,8 @@ extension AppBskyLexicon.Feed { @DateFormatting public var indexedAt: Date public init(feedURI: String, cidHash: String, feedDID: String, creator: AppBskyLexicon.Actor.ProfileViewDefinition, displayName: String, - description: String?, descriptionFacets: [Facet]?, avatarImageURL: URL?, likeCount: Int?, canAcceptInteractions: Bool?, labels: [Label]?, + description: String?, descriptionFacets: [AppBskyLexicon.RichText.Facet]?, avatarImageURL: URL?, likeCount: Int?, + canAcceptInteractions: Bool?, labels: [ComAtprotoLexicon.Label.LabelDefinition]?, viewer: GeneratorViewerStateDefinition?, indexedAt: Date) { self.feedURI = feedURI self.cidHash = cidHash @@ -446,11 +447,11 @@ extension AppBskyLexicon.Feed { self.creator = try container.decode(AppBskyLexicon.Actor.ProfileViewDefinition.self, forKey: .creator) self.displayName = try container.decode(String.self, forKey: .displayName) self.description = try container.decodeIfPresent(String.self, forKey: .description) - self.descriptionFacets = try container.decodeIfPresent([Facet].self, forKey: .descriptionFacets) + self.descriptionFacets = try container.decodeIfPresent([AppBskyLexicon.RichText.Facet].self, forKey: .descriptionFacets) self.avatarImageURL = try container.decodeIfPresent(URL.self, forKey: .avatarImageURL) self.likeCount = try container.decodeIfPresent(Int.self, forKey: .likeCount) self.canAcceptInteractions = try container.decodeIfPresent(Bool.self, forKey: .canAcceptInteractions) - self.labels = try container.decodeIfPresent([Label].self, forKey: .labels) + self.labels = try container.decodeIfPresent([ComAtprotoLexicon.Label.LabelDefinition].self, forKey: .labels) self.viewer = try container.decodeIfPresent(GeneratorViewerStateDefinition.self, forKey: .viewer) self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue } @@ -570,7 +571,7 @@ extension AppBskyLexicon.Feed { // TODO: Make sure this is correct. /// An array of user lists. - public let lists: [GraphListViewBasic] + public let lists: [AppBskyLexicon.Graph.ListViewBasicDefinition] enum CodingKeys: String, CodingKey { case threadgateURI = "uri" diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGenerator.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGenerator.swift index 9501143a28..16c32a814e 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGenerator.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGenerator.swift @@ -41,7 +41,7 @@ extension AppBskyLexicon.Feed { public let description: String? /// An array of the facets within the feed generator's description. Optional. - public let descriptionFacets: [Facet]? + public let descriptionFacets: [AppBskyLexicon.RichText.Facet]? /// The URL of the avatar image. Optional. public let avatarImageURL: URL? @@ -58,7 +58,7 @@ extension AppBskyLexicon.Feed { /// The date and time the feed was created. @DateFormatting public var createdAt: Date - public init(feedDID: String, displayName: String, description: String?, descriptionFacets: [Facet]?, avatarImageURL: URL?, + public init(feedDID: String, displayName: String, description: String?, descriptionFacets: [AppBskyLexicon.RichText.Facet]?, avatarImageURL: URL?, canAcceptInteractions: Bool?, labels: ATUnion.GeneratorLabelsUnion?, createdAt: Date) { self.feedDID = feedDID self.displayName = displayName @@ -76,7 +76,7 @@ extension AppBskyLexicon.Feed { self.feedDID = try container.decode(String.self, forKey: .feedDID) self.displayName = try container.decode(String.self, forKey: .displayName) self.description = try container.decodeIfPresent(String.self, forKey: .description) - self.descriptionFacets = try container.decodeIfPresent([Facet].self, forKey: .descriptionFacets) + self.descriptionFacets = try container.decodeIfPresent([AppBskyLexicon.RichText.Facet].self, forKey: .descriptionFacets) self.avatarImageURL = try container.decodeIfPresent(URL.self, forKey: .avatarImageURL) self.canAcceptInteractions = try container.decodeIfPresent(Bool.self, forKey: .canAcceptInteractions) self.labels = try container.decodeIfPresent(ATUnion.GeneratorLabelsUnion.self, forKey: .labels) diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetActorLikes.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetActorLikes.swift index c9408bd5fb..168f9af593 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetActorLikes.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedGetActorLikes.swift @@ -23,6 +23,6 @@ extension AppBskyLexicon.Feed { public let cursor: String? /// An array of like records. - public let feed: [FeedViewPost] + public let feed: [AppBskyLexicon.Feed.FeedViewPostDefinition] } } diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedRepost.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedRepost.swift index a9602aed63..7738d55758 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedRepost.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedRepost.swift @@ -25,14 +25,14 @@ extension AppBskyLexicon.Feed { public static private(set) var type: String = "app.bsky.feed.repost" /// The strong reference of the repost record. - public let subject: StrongReference + public let subject: ComAtprotoLexicon.Repository.StrongReference /// The date the like record was created. /// /// This is the date where the user "liked" a post. @DateFormatting public var createdAt: Date - public init(subject: StrongReference, createdAt: Date) { + public init(subject: ComAtprotoLexicon.Repository.StrongReference, createdAt: Date) { self.subject = subject self._createdAt = DateFormatting(wrappedValue: createdAt) } @@ -40,7 +40,7 @@ extension AppBskyLexicon.Feed { public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) - self.subject = try container.decode(StrongReference.self, forKey: .subject) + self.subject = try container.decode(ComAtprotoLexicon.Repository.StrongReference.self, forKey: .subject) self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue } diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedDefs.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedDefs.swift deleted file mode 100644 index 2cc524dff3..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedDefs.swift +++ /dev/null @@ -1,770 +0,0 @@ -// -// BskyFeedDefs.swift -// -// -// Created by Christopher Jr Riley on 2024-01-25. -// - -import Foundation - -/// A data model for a post view definition. -/// -/// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/defs.json -public struct FeedPostView: Codable { - /// The URI of the post. - public let postURI: String - /// The CID of the post. - public let cidHash: String - /// The author of the post. This will give the basic details of the post author. - public let author: ActorProfileViewBasic - /// The record data itself. - public let record: FeedPost - /// An embed view of a specific type. Optional. - public var embed: EmbedViewUnion? = nil - /// The number of replies in the post. Optional. - public var replyCount: Int? = nil - /// The number of reposts in the post. Optional. - public var repostCount: Int? = nil - /// The number of likes in the post. Optional. - public var likeCount: Int? = nil - /// The last time the post has been indexed. - @DateFormatting public var indexedAt: Date - /// The viewer's interaction with the post. Optional. - public var viewer: FeedViewerState? = nil - /// An array of labels attached to the post. Optional. - public var labels: [Label]? = nil - /// The ruleset of who can reply to the post. Optional. - public var threadgate: FeedThreadgateView? = nil - - public init(postURI: String, cidHash: String, author: ActorProfileViewBasic, record: FeedPost, embed: EmbedViewUnion?, replyCount: Int?, - repostCount: Int?, likeCount: Int?, indexedAt: Date, viewer: FeedViewerState?, labels: [Label]?, threadgate: FeedThreadgateView?) { - self.postURI = postURI - self.cidHash = cidHash - self.author = author - self.record = record - self.embed = embed - self.replyCount = replyCount - self.repostCount = repostCount - self.likeCount = likeCount - self._indexedAt = DateFormatting(wrappedValue: indexedAt) - self.viewer = viewer - self.labels = labels - self.threadgate = threadgate - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.postURI = try container.decode(String.self, forKey: .postURI) - self.cidHash = try container.decode(String.self, forKey: .cidHash) - self.author = try container.decode(ActorProfileViewBasic.self, forKey: .author) - self.record = try container.decode(FeedPost.self, forKey: .record) - self.embed = try container.decodeIfPresent(EmbedViewUnion.self, forKey: .embed) - self.replyCount = try container.decodeIfPresent(Int.self, forKey: .replyCount) - self.repostCount = try container.decodeIfPresent(Int.self, forKey: .repostCount) - self.likeCount = try container.decodeIfPresent(Int.self, forKey: .likeCount) - self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue - self.viewer = try container.decodeIfPresent(FeedViewerState.self, forKey: .viewer) - self.labels = try container.decodeIfPresent([Label].self, forKey: .labels) - self.threadgate = try container.decodeIfPresent(FeedThreadgateView.self, forKey: .threadgate) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self.postURI, forKey: .postURI) - try container.encode(self.cidHash, forKey: .cidHash) - try container.encode(self.author, forKey: .author) - try container.encode(self.record, forKey: .record) - try container.encodeIfPresent(self.embed, forKey: .embed) - try container.encodeIfPresent(self.replyCount, forKey: .replyCount) - try container.encodeIfPresent(self.repostCount, forKey: .repostCount) - try container.encodeIfPresent(self.likeCount, forKey: .likeCount) - try container.encode(self._indexedAt, forKey: .indexedAt) - try container.encodeIfPresent(self.viewer, forKey: .viewer) - try container.encodeIfPresent(self.labels, forKey: .labels) - try container.encodeIfPresent(self.threadgate, forKey: .threadgate) - } - - enum CodingKeys: String, CodingKey { - case postURI = "uri" - case cidHash = "cid" - case author - case record - case embed - case replyCount - case repostCount - case likeCount - case indexedAt - case viewer - case labels - case threadgate - } -} - -/// A data model for a viewer state definition. -/// -/// - Note: According to the AT Protocol specifications: "Metadata about the requesting account's -/// relationship with the subject content. Only has meaningful content for authed requests." -/// -/// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/defs.json -public struct FeedViewerState: Codable { - /// The URI of the requesting account's repost of the subject account's post. Optional. - public let repostURI: String? = nil - /// The URI of the requesting account's like of the subject account's post. Optional. - public let likeURI: String? = nil - /// Indicates whether the requesting account can reply to the account's post. Optional. - public let areRepliesDisabled: Bool? = nil - - enum CodingKeys: String, CodingKey { - case repostURI = "repost" - case likeURI = "like" - case areRepliesDisabled = "replyDisabled" - } -} - -/// A data model for a definition of a feed's view. -/// -/// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/defs.json -public struct FeedViewPost: Codable { - /// The post contained in a feed. - public let post: FeedPostView - /// The reply reference for the post, if it's a reply. Optional. - public var reply: FeedReplyReference? = nil - // TODO: Check to see if this is correct. - /// The user who reposted the post. Optional. - public var reason: FeedReasonRepost? = nil - /// The feed generator's context. Optional - /// - /// - Note: According to the AT Protocol specifications: "Context provided by feed generator - /// that may be passed back alongside interactions." - public let feedContext: String? - - public init(post: FeedPostView, reply: FeedReplyReference? = nil, reason: FeedReasonRepost? = nil, feedContext: String?) { - self.post = post - self.reply = reply - self.reason = reason - self.feedContext = feedContext - } - - public init(from decoder: any Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.post = try container.decode(FeedPostView.self, forKey: .post) - self.reply = try container.decodeIfPresent(FeedReplyReference.self, forKey: .reply) - self.reason = try container.decodeIfPresent(FeedReasonRepost.self, forKey: .reason) - self.feedContext = try container.decodeIfPresent(String.self, forKey: .feedContext) - } - - public func encode(to encoder: any Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self.post, forKey: .post) - try container.encodeIfPresent(self.reply, forKey: .reply) - try container.encodeIfPresent(self.reason, forKey: .reason) - // Truncate `description` to 2000 characters before encoding - // `maxGraphemes`'s limit is 300, but `String.count` should respect that limit - try truncatedEncodeIfPresent(self.feedContext, withContainer: &container, forKey: .feedContext, upToLength: 2000) - } - - public enum CodingKeys: CodingKey { - case post - case reply - case reason - case feedContext - } -} - -/// A data model for a reply reference definition. -/// -/// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/defs.json -public struct FeedReplyReference: Codable { - /// The original post of the thread. - public let root: PostUnion - // TODO: Fix up the note's message. - /// The direct post that the user's post is replying to. - /// - /// - Note: If `parent` and `root` are identical, the post is a direct reply to the original - /// post of the thread. - public let parent: PostUnion - /// The author of the parent's post. - /// - /// - Note: According to the AT Protocol specifications: "When parent is a reply to another - /// post, this is the author of that post." - public let grandparentAuthor: ActorProfileViewBasic -} - -/// A data model for a definition for a very stripped down version of a repost. -/// -/// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/defs.json -public struct FeedReasonRepost: Codable { - /// The basic details of the user who reposted the post. - public let by: ActorProfileViewBasic - /// The last time the repost was indexed. - @DateFormatting public var indexedAt: Date - - public init(by: ActorProfileViewBasic, indexedAt: Date) { - self.by = by - self._indexedAt = DateFormatting(wrappedValue: indexedAt) - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.by = try container.decode(ActorProfileViewBasic.self, forKey: .by) - self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue - } - - enum CodingKeys: CodingKey { - case by - case indexedAt - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self.by, forKey: .by) - try container.encode(self._indexedAt, forKey: .indexedAt) - } -} - -/// A data model for a definition of a hydrated version of a repost. -/// -/// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/defs.json -public struct FeedThreadViewPost: Codable { - /// The post contained in a thread. - public let post: FeedPostView - /// The direct post that the user's post is replying to. Optional. - public var parent: ThreadPostUnion? = nil - /// An array of posts of various types. Optional. - public var replies: [ThreadPostUnion]? = nil -} - -/// A data model for a definition of a post that may not have been found. -/// -/// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/defs.json -public struct FeedNotFoundPost: Codable { - /// The URI of the post. - public let feedURI: String - /// Indicates whether the post wasn't found. Defaults to `true`. - public private(set) var isNotFound: Bool = true - - public init(feedURI: String, isNotFound: Bool = true) { - self.feedURI = feedURI - self.isNotFound = isNotFound - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - feedURI = try container.decode(String.self, forKey: .feedURI) - isNotFound = (try? container.decodeIfPresent(Bool.self, forKey: .isNotFound)) ?? true - } - - enum CodingKeys: String, CodingKey { - case feedURI = "uri" - case isNotFound = "notFound" - } -} - -/// A data model for a definition of a post that may have been blocked. -/// -/// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/defs.json -public struct FeedBlockedPost: Codable { - /// The URI of the post. - public let feedURI: String - /// Indicates whether this post has been blocked from the user. Defaults to `true`. - public private(set) var isBlocked: Bool = true - /// The author of the post. - public let author: FeedBlockedAuthor - - public init(feedURI: String, isBlocked: Bool = true, author: FeedBlockedAuthor) { - self.feedURI = feedURI - self.isBlocked = isBlocked - self.author = author - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.feedURI = try container.decode(String.self, forKey: .feedURI) - self.isBlocked = (try? container.decode(Bool.self, forKey: .isBlocked)) ?? true - self.author = try container.decode(FeedBlockedAuthor.self, forKey: .author) - } - - enum CodingKeys: String, CodingKey { - case feedURI = "uri" - case isBlocked = "blocked" - case author - } -} - -/// The data model of a blocked author definition. -/// -/// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/defs.json -public struct FeedBlockedAuthor: Codable { - /// The URI of the author. - public let authorDID: String - /// The viewer state of the user. Optional. - public var viewer: ActorViewerState? = nil - - enum CodingKeys: String, CodingKey { - case authorDID = "did" - case viewer - } -} - -/// The data model of a feed generator definition. -/// -/// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/defs.json -public struct FeedGeneratorView: Codable { - /// The URI of the feed generator. - public let feedURI: String - /// The CID of the feed generator. - public let cidHash: String - /// The decentralized identifier (DID) of the feed generator. - public let feedDID: String - /// The author of the feed generator. - public let creator: ActorProfileView - /// The display name of the feed generator. - public let displayName: String - /// The description of the feed generator. Optional. - public var description: String? = nil - /// An array of the facets within the feed generator's description. - public let descriptionFacets: [Facet]? - /// The avatar image URL of the feed generator. - public var avatarImageURL: URL? = nil - /// The number of likes for the feed generator. - public var likeCount: Int? = nil - /// Indicates whether the feed generator can accept interactions. - /// - /// - Note: According to the AT Protocol specifications: "Context that will be passed through - /// to client and may be passed to feed generator back alongside interactions." - public let canAcceptInteractions: Bool? - /// An array of labels. Optional. - public let labels: [Label]? - /// The viewer's state for the feed generator. - public var viewer: FeedGeneratorViewerState? = nil - /// The last time the feed generator was indexed. - @DateFormatting public var indexedAt: Date - - public init(feedURI: String, cidHash: String, feedDID: String, creator: ActorProfileView, displayName: String, description: String?, - descriptionFacets: [Facet]?, avatarImageURL: URL?, likeCount: Int?, canAcceptInteractions: Bool?, labels: [Label]?, - viewer: FeedGeneratorViewerState?, indexedAt: Date) { - self.feedURI = feedURI - self.cidHash = cidHash - self.feedDID = feedDID - self.creator = creator - self.displayName = displayName - self.description = description - self.descriptionFacets = descriptionFacets - self.avatarImageURL = avatarImageURL - self.likeCount = likeCount - self.canAcceptInteractions = canAcceptInteractions - self.labels = labels - self.viewer = viewer - self._indexedAt = DateFormatting(wrappedValue: indexedAt) - } - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.feedURI = try container.decode(String.self, forKey: .feedURI) - self.cidHash = try container.decode(String.self, forKey: .cidHash) - self.feedDID = try container.decode(String.self, forKey: .feedDID) - self.creator = try container.decode(ActorProfileView.self, forKey: .creator) - self.displayName = try container.decode(String.self, forKey: .displayName) - self.description = try container.decodeIfPresent(String.self, forKey: .description) - self.descriptionFacets = try container.decodeIfPresent([Facet].self, forKey: .descriptionFacets) - self.avatarImageURL = try container.decodeIfPresent(URL.self, forKey: .avatarImageURL) - self.likeCount = try container.decodeIfPresent(Int.self, forKey: .likeCount) - self.canAcceptInteractions = try container.decodeIfPresent(Bool.self, forKey: .canAcceptInteractions) - self.labels = try container.decodeIfPresent([Label].self, forKey: .labels) - self.viewer = try container.decodeIfPresent(FeedGeneratorViewerState.self, forKey: .viewer) - self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self.feedURI, forKey: .feedURI) - try container.encode(self.cidHash, forKey: .cidHash) - try container.encode(self.feedDID, forKey: .feedDID) - try container.encode(self.creator, forKey: .creator) - try container.encode(self.displayName, forKey: .displayName) - - // Truncate `description` to 3000 characters before encoding - // `maxGraphemes`'s limit is 300, but `String.count` should respect that limit - try truncatedEncodeIfPresent(self.description, withContainer: &container, forKey: .description, upToLength: 3000) - - try container.encodeIfPresent(self.descriptionFacets, forKey: .descriptionFacets) - try container.encodeIfPresent(self.avatarImageURL, forKey: .avatarImageURL) - - // Assuming `likeCount` is not nil, only encode it if it's 0 or higher - if let likeCount = self.likeCount, likeCount >= 0 { - try container.encode(likeCount, forKey: .likeCount) - } - try container.encodeIfPresent(self.canAcceptInteractions, forKey: .canAcceptInteractions) - try container.encodeIfPresent(self.labels, forKey: .labels) - try container.encodeIfPresent(self.viewer, forKey: .viewer) - try container.encode(self._indexedAt, forKey: .indexedAt) - } - - enum CodingKeys: String, CodingKey { - case feedURI = "uri" - case cidHash = "cid" - case feedDID = "did" - case creator - case displayName - case description - case descriptionFacets = "descriptionFacets" - case avatarImageURL = "avatar" - case likeCount - case canAcceptInteractions = "acceptsInteractions" - case labels - case viewer - case indexedAt - } -} - -/// The data model of a definition for the viewer's state of the feed generator. -/// -/// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/defs.json -public struct FeedGeneratorViewerState: Codable { - /// The URI of the viewer's like, if they liked the feed generator. Optional. - public var likeURI: String? = nil - - enum CodingKeys: String, CodingKey { - case likeURI = "like" - } -} - -/// The data model of a feed's skeleton -public struct FeedSkeletonFeedPost: Codable { - /// The URI of the post in the feed generator. - /// - /// - Note: This refers to the original post's URI. If the post is a repost, then `reason` - /// will contain a value. - public let postURI: String - /// The indication that the post was a repost. Optional. - public var reason: FeedSkeletonReasonRepost? = nil - - enum CodingKeys: String, CodingKey { - case postURI = "post" - case reason - } -} - -/// The data model of a definition for a respost in a feed generator. -/// -/// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/defs.json -public struct FeedSkeletonReasonRepost: Codable { - /// The URI of the repost. - /// - /// This property uniquely identifies the repost itself, separate from the original post's URI. - public let repostURI: String - - enum CodingKeys: String, CodingKey { - case repostURI = "repost" - } -} - -/// The data model of a feed threadgate view definition. -/// -/// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/defs.json -public struct FeedThreadgateView: Codable { - /// The URI of the feed's threadgate. - public let threadgateURI: String - /// The CID of the feed's threadgate. - public let cidHash: String - /// The record of the feed's threadgate - public let record: UnknownType - // TODO: Make sure this is correct. - /// An array of user lists. - public let lists: [GraphListViewBasic] - - enum CodingKeys: String, CodingKey { - case threadgateURI = "uri" - case cidHash = "cid" - case record = "record" - case lists = "lists" - } -} - -/// The main data model definition for an interaction for an item in a feed generator. -/// -/// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/defs.json -public struct FeedInteraction: Codable { - /// The item itself. Optional. - public let item: String? - /// The interaction event of the feed generator. Optional. - public let event: FeedInteractionEvent? - /// The feed generator's context. Optional. - /// - /// - Note: According to the AT Protocol specifications: "Context on a feed item that was orginally - /// supplied by the feed generator on getFeedSkeleton." - public let feedContext: String? - - public init(item: String, event: FeedInteractionEvent, feedContext: String) { - self.item = item - self.event = event - self.feedContext = feedContext - } - - public init(from decoder: any Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.item = try container.decode(String.self, forKey: .item) - self.event = try container.decode(FeedInteractionEvent.self, forKey: .event) - self.feedContext = try container.decode(String.self, forKey: .feedContext) - } - - public func encode(to encoder: any Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self.item, forKey: .item) - try container.encode(self.event, forKey: .event) - // Truncate `description` to 2000 characters before encoding - // `maxGraphemes`'s limit is 300, but `String.count` should respect that limit - try truncatedEncodeIfPresent(self.feedContext, withContainer: &container, forKey: .feedContext, upToLength: 2000) - } - - enum CodingKeys: CodingKey { - case item - case event - case feedContext - } -} - -/// A data model definition for an interaction event. -/// -/// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/defs.json -public enum FeedInteractionEvent: Codable { - /// Indicates the feed generator should request less content similar to the feed's item. - /// - /// - Note: According to the AT Protocol specifications: "Request that less content like the - /// given feed item be shown in the feed." - case requestLess - /// Indicates the feed generator should request more content similar to the feed's item. - /// - /// - Note: According to the AT Protocol specifications: "Request that more content like the - /// given feed item be shown in the feed." - case requestMore - /// Indicates the feed generator clicked on the feed's item. - /// - /// - Note: According to the AT Protocol specifications: "User clicked through to the - /// feed item." - case clickthroughItem - /// Indicates the user clicked on the author of the feed's item. - /// - /// - Note: According to the AT Protocol specifications: "User clicked through to the author - /// of the feed item." - case clickthroughAuthor - /// Indicates the user clicked on the reposter of the feed's item. - /// - /// - Note: According to the AT Protocol specifications: "User clicked through to the reposter - /// of the feed item." - case clickthroughReposter - /// Indicates the user clicked on the embedded content of the feed's item. - /// - /// - Note: According to the AT Protocol specifications: "User clicked through to the embedded - /// content of the feed item." - case clickthroughEmbed - /// Indicates the user has viewed the item in the feed. - /// - /// - Note: According to the AT Protocol specifications: "Feed item was seen by user." - case interactionSeen - /// Indicates the user has liked the item of the feed. - /// - /// - Note: According to the AT Protocol specifications: "User liked the feed item." - case interactionLike - /// Indicates the user has reposted the item of the feed. - /// - /// - Note: According to the AT Protocol specifications: "User reposted the feed item." - case interactionRepost - /// Indicates the user has replied to the item of the feed. - /// - /// - Note: According to the AT Protocol specifications: "User replied to the feed item." - case interactionReply - /// Indicates the user has quote posted the feed's item. - /// - /// - Note: According to the AT Protocol specifications: "User quoted the feed item." - case interactionQuote - /// Indicates the user has shared the feed's item. - /// - /// - Note: According to the AT Protocol specifications: "User shared the feed item." - case interactionShare -} - -// MARK: - Union Types -/// A reference containing the list of the types of embeds. -/// -/// - Note: This is based on the following lexicons:\ -///\- `app.bsky.embed.record`\ -///\- `app.bsky.feed.defs` -/// -/// - SeeAlso: The lexicons can be viewed in their GitHub repo pages:\ -/// \- [`app.bsky.embed.record`][embed_record]\ -/// \- [`app.bsky.feed.defs`][feed_def] -/// -/// [embed_record]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/embed/record.json -/// [feed_def]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/defs.json -public enum EmbedViewUnion: Codable { - /// The view of an external embed. - case embedExternalView(EmbedExternalView) - /// The view of an image embed. - case embedImagesView(EmbedImagesView) - /// The view of a record embed. - case embedRecordView(EmbedRecordView) - /// The view of a record embed alongside an embed of some compatible media. - case embedRecordWithMediaView(EmbedRecordWithMediaView) - - public init(from decoder: Decoder) throws { - let container = try decoder.singleValueContainer() - - if let value = try? container.decode(EmbedExternalView.self) { - self = .embedExternalView(value) - } else if let value = try? container.decode(EmbedImagesView.self) { - self = .embedImagesView(value) - } else if let value = try? container.decode(EmbedRecordView.self) { - print("EmbedView.embedRecordView is about to be read.") - self = .embedRecordView(value) - } else if let value = try? container.decode(EmbedRecordWithMediaView.self) { - self = .embedRecordWithMediaView(value) - } else { - throw DecodingError.typeMismatch( - EmbedViewUnion.self, DecodingError.Context( - codingPath: decoder.codingPath, debugDescription: "Unknown EmbedView type")) - } - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - - switch self { - case .embedExternalView(let embedView): - try container.encode(embedView) - case .embedImagesView(let embedView): - try container.encode(embedView) - case .embedRecordView(let embedView): - try container.encode(embedView) - case .embedRecordWithMediaView(let embedView): - try container.encode(embedView) - } - } -} - -/// A reference containing the list of the states of a post. -/// -/// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/defs.json -public enum PostUnion: Codable { - /// The view of a post. - case postView(FeedPostView) - /// The view of a post that may not have been found. - case notFoundPost(FeedNotFoundPost) - /// The view of a post that's been blocked by the post author. - case blockedPost(FeedBlockedPost) - - public init(from decoder: Decoder) throws { - let container = try decoder.singleValueContainer() - - if let value = try? container.decode(FeedPostView.self) { - self = .postView(value) - } else if let value = try? container.decode(FeedNotFoundPost.self) { - self = .notFoundPost(value) - } else if let value = try? container.decode(FeedBlockedPost.self) { - self = .blockedPost(value) - } else { - throw DecodingError.typeMismatch( - PostUnion.self, DecodingError.Context( - codingPath: decoder.codingPath, debugDescription: "Unknown PostUnion type")) - } - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - - switch self { - case .postView(let union): - try container.encode(union) - case .notFoundPost(let union): - try container.encode(union) - case .blockedPost(let union): - try container.encode(union) - } - } -} - -/// A reference containing the list of the states of a post. -/// -/// - SeeAlso: This is based on the [`app.bsky.feed.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/defs.json -public indirect enum ThreadPostUnion: Codable { - /// The view of a post thread. - case threadViewPost(FeedThreadViewPost) - /// The view of a post that may not have been found. - case notFoundPost(FeedNotFoundPost) - /// The view of a post that's been blocked by the post author. - case blockedPost(FeedBlockedPost) - - public init(from decoder: Decoder) throws { - let container = try decoder.singleValueContainer() - - if let value = try? container.decode(FeedThreadViewPost.self) { - self = .threadViewPost(value) - } else if let value = try? container.decode(FeedNotFoundPost.self) { - self = .notFoundPost(value) - } else if let value = try? container.decode(FeedBlockedPost.self) { - self = .blockedPost(value) - } else { - throw DecodingError.typeMismatch( - ThreadPostUnion.self, DecodingError.Context( - codingPath: decoder.codingPath, debugDescription: "Unknown ThreadPostUnion type")) - } - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - - switch self { - case .threadViewPost(let union): - try container.encode(union) - case .notFoundPost(let union): - try container.encode(union) - case .blockedPost(let union): - try container.encode(union) - } - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedDescribeFeedGenerator.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedDescribeFeedGenerator.swift deleted file mode 100644 index 19e6ae8197..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedDescribeFeedGenerator.swift +++ /dev/null @@ -1,51 +0,0 @@ -// -// BskyFeedDescribeFeedGenerator.swift -// -// -// Created by Christopher Jr Riley on 2024-03-03. -// - -import Foundation - -// TODO: Figure out a proper way of doing this. -/// A data model definition for the output ofretrieving information about a feed generator. -/// -/// - Note: According to the AT Protocol specifications: "Get information about a feed generator, -/// including policies and offered feed URIs. Does not require auth; implemented by -/// Feed Generator services (not App View)." -/// -/// - SeeAlso: This is based on the [`app.bsky.feed.describeFeedGenerator`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/describeFeedGenerator.json -public struct FeedDescribeFeedGeneratorOutput: Codable { - /// The decentralized identifier (DID) of the feed generator. - public let atDID: String - /// An array of feed generators. - public let feeds: [FeedDescribeFeedGeneratorFeed] - /// The URL of the Privacy Policy and Terms of Service. Optional. - public let links: FeedDescribeFeedGeneratorLinks? - - enum CodingKeys: String, CodingKey { - case atDID = "did" - case feeds - case links - } -} - -/// A data model definiion for the feed generator. -public struct FeedDescribeFeedGeneratorFeed: Codable { - /// The URI of the feed. - public let feedURI: String - - enum CodingKeys: String, CodingKey { - case feedURI = "uri" - } -} - -/// A data model definition for the Privacy Policy and Terms of Service URLs. -public struct FeedDescribeFeedGeneratorLinks: Codable { - /// The URL to the Privacy Policy. - public let privacyPolicy: URL - /// The URL to the Terms of Service. - public let termsOfService: URL -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGenerator.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGenerator.swift deleted file mode 100644 index c918c4d5e7..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGenerator.swift +++ /dev/null @@ -1,103 +0,0 @@ -// -// BskyFeedGenerator.swift -// -// -// Created by Christopher Jr Riley on 2024-03-04. -// - -import Foundation - -/// The main data model definition for a feed generator record. -/// -/// - Note: According to the AT Protocol specifications: "Record declaring of the existence of a -/// feed generator, and containing metadata about it. The record can exist in any repository." -/// -/// - SeeAlso: This is based on the [`app.bsky.feed.generator`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/generator.json -public struct FeedGenerator: ATRecordProtocol { - /// The identifier of the lexicon. - /// - /// - Warning: The value must not change. - public static private(set) var type: String = "app.bsky.feed.generator" - /// The decentralized identifier (DID) of the feed. - public let feedDID: String - /// The display name of the feed. - /// - /// - Important: Current maximum lenth is 24 characters. This library will automatically - /// truncate the `String` to the maximum length if it does go over the limit. - public let displayName: String - /// The description of the feed. Optional. - /// - /// - Important: Current maximum lenth is 300 characters. This library will automatically - /// truncate the `String` to the maximum length if it does go over the limit. - public let description: String? - /// An array of the facets within the feed generator's description. Optional. - public let descriptionFacets: [Facet]? - /// The URL of the avatar image. Optional. - public let avatarImageURL: URL? - /// Indicates whether the feed generator can accept interactions. - /// - /// - Note: According to the AT Protocol specifications: "Declaration that a feed accepts - /// feedback interactions from a client through `app.bsky.feed.sendInteractions`" - public let canAcceptInteractions: Bool? - /// An array of labels created by the user. Optional. - public let labels: [SelfLabels]? - /// The date and time the feed was created. - @DateFormatting public var createdAt: Date - - public init(feedDID: String, displayName: String, description: String?, descriptionFacets: [Facet]?, avatarImageURL: URL?, - canAcceptInteractions: Bool?, labels: [SelfLabels]?, createdAt: Date) { - self.feedDID = feedDID - self.displayName = displayName - self.description = description - self.descriptionFacets = descriptionFacets - self.avatarImageURL = avatarImageURL - self.canAcceptInteractions = canAcceptInteractions - self.labels = labels - self._createdAt = DateFormatting(wrappedValue: createdAt) - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.feedDID = try container.decode(String.self, forKey: .feedDID) - self.displayName = try container.decode(String.self, forKey: .displayName) - self.description = try container.decodeIfPresent(String.self, forKey: .description) - self.descriptionFacets = try container.decodeIfPresent([Facet].self, forKey: .descriptionFacets) - self.avatarImageURL = try container.decodeIfPresent(URL.self, forKey: .avatarImageURL) - self.canAcceptInteractions = try container.decodeIfPresent(Bool.self, forKey: .canAcceptInteractions) - self.labels = try container.decodeIfPresent([SelfLabels].self, forKey: .labels) - self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - -// try container.encode(self.type, forKey: .type) - try container.encode(self.feedDID, forKey: .feedDID) - // Truncate `displayName` to 240 characters before encoding - // `maxGraphemes`'s limit is 24, but `String.count` should respect that limit implictly - try truncatedEncode(self.displayName, withContainer: &container, forKey: .description, upToLength: 240) - // Truncate `displayName` to 3,000 characters before encoding - // `maxGraphemes`'s limit is 300, but `String.count` should respect that limit implictly - try truncatedEncodeIfPresent(self.description, withContainer: &container, forKey: .description, upToLength: 3_000) - try container.encodeIfPresent(self.descriptionFacets, forKey: .descriptionFacets) - try container.encodeIfPresent(self.avatarImageURL, forKey: .avatarImageURL) - try container.encodeIfPresent(self.canAcceptInteractions, forKey: .canAcceptInteractions) - try container.encodeIfPresent(self.labels, forKey: .labels) - try container.encode(self._createdAt, forKey: .createdAt) - } - - enum CodingKeys: String, CodingKey { - case type = "$type" - case feedDID = "did" - case displayName - case description - case descriptionFacets - case avatarImageURL = "avatar" - case canAcceptInteractions = "acceptsInteractions" - case labels - case createdAt - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetActorFeeds.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetActorFeeds.swift deleted file mode 100644 index fcb460efaf..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetActorFeeds.swift +++ /dev/null @@ -1,23 +0,0 @@ -// -// BskyFeedGetActorFeeds.swift -// -// -// Created by Christopher Jr Riley on 2024-03-04. -// - -import Foundation - -/// The main data model definition for the output of retrieving a feed list by a user. -/// -/// - Note: According to the AT Protocol specifications: "Get a list of feeds (feed generator -/// records) created by the actor (in the actor's repo)." -/// -/// - SeeAlso: This is based on the [`app.bsky.feed.getActorFeeds`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getActorFeeds.json -public struct FeedGetActorFeedsOutput: Codable { - /// The mark used to indicate the starting point for the next set of results. Optional. - public let cursor: String? - /// An array of feeds. - public let feeds: [FeedGeneratorView] -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetActorLikes.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetActorLikes.swift deleted file mode 100644 index 20a972964e..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetActorLikes.swift +++ /dev/null @@ -1,23 +0,0 @@ -// -// BskyFeedGetActorLikes.swift -// -// -// Created by Christopher Jr Riley on 2024-03-04. -// - -import Foundation - -/// The main data model definition for the output of seeing all of a user account's likes. -/// -/// - Note: According to the AT Protocol specifications: "Get a list of posts liked by an actor. -/// Does not require auth." -/// -/// - SeeAlso: This is based on the [`app.bsky.feed.getActorLikes`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getActorLikes.json -public struct FeedGetActorLikesOutput: Codable { - /// The mark used to indicate the starting point for the next set of result. Optional. - public let cursor: String? - /// An array of like records. - public let feed: [FeedViewPost] -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetAuthorFeed.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetAuthorFeed.swift deleted file mode 100644 index 97b7bf01c5..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetAuthorFeed.swift +++ /dev/null @@ -1,38 +0,0 @@ -// -// BskyFeedGetAuthorFeed.swift -// -// -// Created by Christopher Jr Riley on 2024-03-04. -// - -import Foundation - -/// The main data model definition for the output of seeing the user account's posts and reposts. -/// -/// - Note: According to the AT Protocol specifications: "Get a view of an actor's 'author feed' -/// (post and reposts by the author). Does not require auth." -/// -/// - SeeAlso: This is based on the [`app.bsky.feed.getAuthorFeed`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getAuthorFeed.json -public struct FeedGetAuthorFeedOutput: Codable { - /// The mark used to indicate the starting point for the next set of result. Optional. - public let cursor: String? - /// An array of like records. - public let feed: [FeedViewPost] -} - -/// Indicates the kind of combinations of posts and reposts for the feed's array. -/// -/// - Note: According to the AT Protocol specifications: "Combinations of post/repost types to -/// include in response." -public enum FeedGetAuthorFeedFilter: String { - /// Indicates the array of feeds will contain posts with replies. - case postsWithReplies = "posts_with_replies" - /// Indicates the array of feeds will contain posts with no replies. - case postsWithNoReplies = "posts_no_replies" - /// Indicates the array of feeds will contain posts with media. - case postsWithMedia = "posts_with_media" - /// Indicates the array of feeds will contain posts that are threads. - case postAndAuthorThreads = "posts_and_author_threads" -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetFeed.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetFeed.swift deleted file mode 100644 index 1ab2e9af9d..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetFeed.swift +++ /dev/null @@ -1,23 +0,0 @@ -// -// BskyFeedGetFeed.swift -// -// -// Created by Christopher Jr Riley on 2024-03-04. -// - -import Foundation - -/// The main data model definition for the output of viewing the selected feed generator. -/// -/// - Note: According to the AT Protocol specifications: "Get a hydrated feed from an actor's -/// selected feed generator. Implemented by App View." -/// -/// - SeeAlso: This is based on the [`app.bsky.feed.getFeed`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getFeed.json -public struct FeedGetFeedOutput: Codable { - /// The mark used to indicate the starting point for the next set of result. Optional. - public let cursor: String? - /// An array of posts in the feed. - public let feed: [FeedViewPost] -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetFeedGenerator.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetFeedGenerator.swift deleted file mode 100644 index b187d1dfef..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetFeedGenerator.swift +++ /dev/null @@ -1,33 +0,0 @@ -// -// BskyFeedGetFeedGenerator.swift -// -// -// Created by Christopher Jr Riley on 2024-03-04. -// - -import Foundation - -/// The main data model definition for the output of getting information about a given -/// feed generator. -/// -/// - Note: According to the AT Protocol specifications: "Get information about a feed -/// generator. Implemented by AppView." -/// -/// - SeeAlso: This is based on the [`app.bsky.feed.getFeedGenerator`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getFeedGenerator.json -public struct FeedGetFeedGeneratorOutput: Codable { - /// The general information about the feed generator.. - public let view: FeedGeneratorView - /// Indicates whether the feed generator is currently online. - /// - /// - Note: According to the AT Protocol specifications: "Indicates whether the feed generator - /// service has been online recently, or else seems to be inactive." - public let isOnline: Bool - /// Indicates whether the feed generator is compatible with the record declaration. - /// - /// - Note: According to the AT Protocol specifications: "Indicates whether the feed generator - /// service is compatible with the record declaration." - public let isValid: Bool - -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetFeedGenerators.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetFeedGenerators.swift deleted file mode 100644 index 753d9fc137..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetFeedGenerators.swift +++ /dev/null @@ -1,22 +0,0 @@ -// -// BskyFeedGetFeedGenerators.swift -// -// -// Created by Christopher Jr Riley on 2024-03-04. -// - -import Foundation - -/// The main data model definition for the output of getting information about several -/// feed generators. -/// -/// - Note: According to the AT Protocol specifications: "Get information about a list of -/// feed generators." -/// -/// - SeeAlso: This is based on the [`app.bsky.feed.getFeedGenerators`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getFeedGenerator.json -public struct FeedGetFeedGeneratorsOutput: Codable { - /// An array of feed generators. - public let feeds: [FeedGeneratorView] -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetFeedSkeleton.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetFeedSkeleton.swift deleted file mode 100644 index 2fd9f2bea1..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetFeedSkeleton.swift +++ /dev/null @@ -1,24 +0,0 @@ -// -// BskyFeedGetFeedSkeleton.swift -// -// -// Created by Christopher Jr Riley on 2024-03-04. -// - -import Foundation - -/// The main data model definition for the output of getting a skeleton for a feed generator. -/// -/// - Note: According to the AT Protocol specifications: "Get a skeleton of a feed provided by a -/// feed generator. Auth is optional, depending on provider requirements, and provides the DID of -/// the requester. Implemented by Feed Generator Service." -/// -/// - SeeAlso: This is based on the [`app.bsky.feed.getFeedSkeleton`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getFeedSkeleton.json -public struct FeedGetFeedSkeletonOutput: Codable { - /// The mark used to indicate the starting point for the next set of result. Optional. - public let cursor: String? - /// An array of skeleton feeds. - public let feed: [FeedSkeletonFeedPost] -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetLikes.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetLikes.swift deleted file mode 100644 index ce7b0ed677..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetLikes.swift +++ /dev/null @@ -1,70 +0,0 @@ -// -// BskyFeedGetLikes.swift -// -// -// Created by Christopher Jr Riley on 2024-03-04. -// - -import Foundation - -/// The main data model definition for the output of retrieving like records of a specific subject. -/// -/// - Note: According to the AT Protocol specifications: "Get like records which reference a -/// subject (by AT-URI and CID)." -/// -/// - SeeAlso: This is based on the [`app.bsky.feed.getLikes`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getLikes.json -public struct FeedGetLikesOutput: Codable { - /// The URI of the record. - public let recordURI: String - /// The CID hash of the record. - public let recordCID: String? - /// The mark used to indicate the starting point for the next set of results. - public let cursor: String? - /// An array of like records. - public let likes: [FeedGetLikesLike] - - enum CodingKeys: String, CodingKey { - case recordURI = "uri" - case recordCID = "cid" - case cursor - case likes - } -} - -/// A data model definition of the like record itself. -public struct FeedGetLikesLike: Codable { - /// The date and time the like record was indexed. - @DateFormatting public var indexedAt: Date - /// The date and time the like record was created. - @DateFormatting public var createdAt: Date - /// The user that created the like record. - public let actor: ActorProfileView - - public init(indexedAt: Date, createdAt: Date, actor: ActorProfileView) { - self._indexedAt = DateFormatting(wrappedValue: indexedAt) - self._createdAt = DateFormatting(wrappedValue: createdAt) - self.actor = actor - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue - self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue - self.actor = try container.decode(ActorProfileView.self, forKey: .actor) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(self._indexedAt, forKey: .indexedAt) - try container.encode(self._createdAt, forKey: .createdAt) - try container.encode(self.actor, forKey: .actor) - } - - public enum CodingKeys: CodingKey { - case indexedAt - case createdAt - case actor - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetListFeed.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetListFeed.swift deleted file mode 100644 index 9be4a42bf5..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetListFeed.swift +++ /dev/null @@ -1,25 +0,0 @@ -// -// BskyFeedGetListFeed.swift -// -// -// Created by Christopher Jr Riley on 2024-03-06. -// - -import Foundation - -/// The main data model definition for the output of retireving recent posts and reposts from a -/// given feed. -/// -/// - Note: According to the AT Protocol specifications: "Get a feed of recent posts from a list -/// (posts and reposts from any actors on the list). -/// Does not require auth." -/// -/// - SeeAlso: This is based on the [`app.bsky.feed.getListFeed`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getListFeed.json -public struct FeedGetListFeedOutput: Codable { - /// The mark used to indicate the starting point for the next set of results. Optional. - public let cursor: String? - /// An array of posts in a feed. - public let feed: [FeedViewPost] -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetPostThread.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetPostThread.swift deleted file mode 100644 index 746489f8be..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetPostThread.swift +++ /dev/null @@ -1,60 +0,0 @@ -// -// BskyFeedGetPostThread.swift -// -// -// Created by Christopher Jr Riley on 2024-03-05. -// - -import Foundation - -/// The main data model definition for the output of retrieving a post thread. -/// -/// - Note: According to the AT Protocol specifications: "Get posts in a thread. Does not require -/// auth, but additional metadata and filtering will be applied for authed requests." -/// -/// - SeeAlso: This is based on the [`app.bsky.feed.getPostThread`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getPostThread.json -public struct FeedGetPostThreadOutput: Codable { - /// The post thread itself. - public let thread: FeedGetPostThreadUnion -} - -/// A reference containing the list of the state of a post thread. -public enum FeedGetPostThreadUnion: Codable { - /// A post thread. - case threadViewPost(FeedThreadViewPost) - /// The post thread wasn't found. - case notFoundPost(FeedNotFoundPost) - /// The post thread was made by someone who blocked the user account. - case blockedPost(FeedBlockedPost) - - public init(from decoder: Decoder) throws { - let container = try decoder.singleValueContainer() - - if let value = try? container.decode(FeedThreadViewPost.self) { - self = .threadViewPost(value) - } else if let value = try? container.decode(FeedNotFoundPost.self) { - self = .notFoundPost(value) - } else if let value = try? container.decode(FeedBlockedPost.self) { - self = .blockedPost(value) - } else { - throw DecodingError.typeMismatch( - FeedGetPostThreadUnion.self, DecodingError.Context( - codingPath: decoder.codingPath, debugDescription: "Unknown FeedGetPostThread type")) - } - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - - switch self { - case .threadViewPost(let threadViewPost): - try container.encode(threadViewPost) - case .notFoundPost(let notFoundPost): - try container.encode(notFoundPost) - case .blockedPost(let blockedPost): - try container.encode(blockedPost) - } - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetPosts.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetPosts.swift deleted file mode 100644 index c7bea1ae24..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetPosts.swift +++ /dev/null @@ -1,22 +0,0 @@ -// -// BskyFeedGetPosts.swift -// -// -// Created by Christopher Jr Riley on 2024-03-06. -// - -import Foundation - -/// The main data model definition for the output of getting a hydrated array of posts. -/// -/// - Note: According to the AT Protocol specifications: "Gets post views for a specified list -/// of posts (by AT-URI). This is sometimes referred to as 'hydrating' -/// a 'feed skeleton'." -/// -/// - SeeAlso: This is based on the [`app.bsky.feed.getPosts`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getPosts.json -public struct FeedGetPostsOutput: Codable { - /// An array of hydrated posts. - public let posts: [FeedPostView] -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetRepostedBy.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetRepostedBy.swift deleted file mode 100644 index de80d2a2a4..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetRepostedBy.swift +++ /dev/null @@ -1,34 +0,0 @@ -// -// BskyFeedGetRepostedBy.swift -// -// -// Created by Christopher Jr Riley on 2024-03-06. -// - -import Foundation - -/// The main data model definition for the output of retrieving an array of users who have -/// reposted the given post. -/// -/// - Note: According to the AT Protocol specifications: "Get a list of reposts for a given post." -/// -/// - SeeAlso: This is based on the [`app.bsky.feed.getRepostedBy`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getRepostedBy.json -public struct FeedGetRepostedBy: Codable { - /// The URI of the post record. - public let postURI: String - /// The CID hash of the post record. - public let postCID: String? - /// The mark used to indicate the starting point for the next set of results. Optional. - public let cursor: String? - /// An array of user accounts who reported the post record. - public let repostedBy: [ActorProfileView] - - enum CodingKeys:String, CodingKey { - case postURI = "uri" - case postCID = "cid" - case cursor - case repostedBy - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetSuggestedFeeds.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetSuggestedFeeds.swift deleted file mode 100644 index 9d1db7b0ce..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetSuggestedFeeds.swift +++ /dev/null @@ -1,24 +0,0 @@ -// -// BskyFeedGetSuggestedFeeds.swift -// -// -// Created by Christopher Jr Riley on 2024-03-06. -// - -import Foundation - -/// The main data model definition for the output of getting a list of feed generators suggested -/// for the user account. -/// -/// - Note: According to the AT Protocol specifications: "Get a list of suggested feeds -/// (feed generators) for the requesting account." -/// -/// - SeeAlso: This is based on the [`app.bsky.feed.getSuggestedFeeds`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getSuggestedFeeds.json -public struct FeedGetSuggestedFeedsOutput: Codable { - /// The mark used to indicate the starting point for the next set of result. Optional. - public let cursor: String? - /// An array of feed generators. - public let feeds: [FeedGeneratorView] -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetTimeline.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetTimeline.swift deleted file mode 100644 index 22b4a6effc..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedGetTimeline.swift +++ /dev/null @@ -1,23 +0,0 @@ -// -// BskyFeedGetTimeline.swift -// -// -// Created by Christopher Jr Riley on 2024-03-06. -// - -import Foundation - -/// The main data model definition for the output of getting the user account's timeline. -/// -/// - Note: According to the AT Protocol specifications: "Get a view of the requesting account's -/// home timeline. This is expected to be some form of reverse-chronological feed." -/// -/// - SeeAlso: This is based on the [`app.bsky.feed.getTimeline`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getTimeline.json -public struct FeedGetTimelineOutput: Codable { - /// The mark used to indicate the starting point for the next set of results. Optional. - public let cursor: String? - /// An array of post records. - public let feed: [FeedViewPost] -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedLike.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedLike.swift deleted file mode 100644 index 130847abfa..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedLike.swift +++ /dev/null @@ -1,59 +0,0 @@ -// -// BskyFeedLike.swift -// -// -// Created by Christopher Jr Riley on 2024-02-08. -// - -import Foundation - -// MARK: - Main definition -/// The record model definition for a like record. -/// -/// - Note: According to the AT Protocol specifications: "Record declaring a 'like' of a piece -/// of subject content." -/// -/// - SeeAlso: This is based on the [`app.bsky.feed.like`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/like.json -public struct FeedLike: ATRecordProtocol { - /// The identifier of the lexicon. - /// - /// - Warning: The value must not change. - public static private(set) var type: String = "app.bsky.feed.like" - /// The strong reference of the like. - /// - /// - Note: According to the AT Protocol specifications: "Record declaring a 'like' of a piece - /// of subject content." - public let subject: StrongReference - /// The date the like record was created. - /// - /// This is the date where the user "liked" a post. - @DateFormatting public var createdAt: Date - - public init(subject: StrongReference, createdAt: Date) { - self.subject = subject - self._createdAt = DateFormatting(wrappedValue: createdAt) - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.subject = try container.decode(StrongReference.self, forKey: .subject) - self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - -// try container.encode(self.type, forKey: .type) - try container.encode(self.subject, forKey: .subject) - try container.encode(self._createdAt, forKey: .createdAt) - } - - enum CodingKeys: String, CodingKey { - case type = "$type" - case subject - case createdAt - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedPost.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedPost.swift deleted file mode 100644 index 5209a53266..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedPost.swift +++ /dev/null @@ -1,250 +0,0 @@ -// -// BskyFeedPost.swift -// -// -// Created by Christopher Jr Riley on 2024-01-27. -// - -import Foundation - -// MARK: - Main definition -/// The record model definition for a post record. -/// -/// - Note: According to the AT Protocol specifications: "Record containing a Bluesky post." -/// -/// - SeeAlso: This is based on the [`app.bsky.feed.post`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/post.json -public struct FeedPost: ATRecordProtocol { - /// The identifier of the lexicon. - /// - /// - Warning: The value must not change. - public static private(set) var type: String = "app.bsky.feed.post" - /// The text contained in the post. - /// - /// - Note: According to the AT Protocol specifications: "The primary post content. May be - /// an empty string, if there are embeds." - /// - /// - Important: Current maximum length is 300 characters. This library will automatically - /// truncate the `String` to the maximum length if it does go over the limit. - public let text: String - /// An array of facets contained in the post's text. Optional. - /// - /// - Note: According to the AT Protocol specifications: "Annotations of text (mentions, URLs, - /// hashtags, etc)" - public var facets: [Facet]? = nil - /// The references to posts when replying. Optional. - public var reply: ReplyReference? = nil - /// The embed of the post. Optional. - public var embed: EmbedUnion? = nil - /// An array of languages the post text contains. Optional. - /// - /// - Note: According to the AT Protocol specifications: "Indicates human language of post - /// primary text content." - /// - /// - Important: Current maximum length is 3 languages. This library will automatically - /// truncate the `Array` to the maximum number of items if it does go over the limit. - public var languages: [String]? = nil - /// An array of user-defined labels. Optional. - /// - /// - Note: According to the AT Protocol specifications: "Self-label values for this post. - /// Effectively content warnings." - public var labels: FeedLabelUnion? = nil - /// An array of user-defined tags. Optional. - /// - /// - Note: According to the AT Protocol specifications: "Additional hashtags, in addition to - /// any included in post text and facets." - /// - /// - Important: Current maximum length is 8 tags. Current maximum length of the tag name is - /// 64 characters. This library will automatically truncate the `Array`and `String` - /// respectively to the maximum length if it does go over the limit. - public var tags: [String]? = nil - /// The date the post was created. - /// - /// - Note: According to the AT Protocol specifications: "Client-declared timestamp when this - /// post was originally created." - @DateFormatting public var createdAt: Date - - public init(text: String, facets: [Facet]? = nil, reply: ReplyReference? = nil, embed: EmbedUnion? = nil, languages: [String]? = nil, - labels: FeedLabelUnion? = nil, tags: [String]? = nil, createdAt: Date) { - self.text = text - self.facets = facets - self.reply = reply - self.embed = embed - self.languages = languages - self.labels = labels - self.tags = tags - self._createdAt = DateFormatting(wrappedValue: createdAt) - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.text = try container.decode(String.self, forKey: .text) - self.facets = try container.decodeIfPresent([Facet].self, forKey: .facets) - self.reply = try container.decodeIfPresent(ReplyReference.self, forKey: .reply) - self.embed = try container.decodeIfPresent(EmbedUnion.self, forKey: .embed) - self.languages = try container.decodeIfPresent([String].self, forKey: .languages) - self.labels = try container.decodeIfPresent(FeedLabelUnion.self, forKey: .labels) - self.tags = try container.decodeIfPresent([String].self, forKey: .tags) - self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - -// try container.encode(self.type, forKey: .type) - try container.encode(self.text, forKey: .text) - // Truncate `tags` to 3000 characters before encoding - // `maxGraphemes`'s limit is 300, but `String.count` should respect that limit implictly - try truncatedEncode(self.text, withContainer: &container, forKey: .text, upToLength: 300) - try container.encodeIfPresent(self.facets, forKey: .facets) - try container.encodeIfPresent(self.reply, forKey: .reply) - try container.encodeIfPresent(self.embed, forKey: .embed) - // Truncate `langs` to 3 items before encoding. - try truncatedEncodeIfPresent(self.languages, withContainer: &container, forKey: .languages, upToLength: 3) - try container.encodeIfPresent(self.labels, forKey: .labels) - - // Truncate `tags` to 640 characters before encoding - // `maxGraphemes`'s limit is 64, but `String.count` should respect that limit implictly - // Then, truncate `tags` to 8 items before encoding - try truncatedEncodeIfPresent( - self.tags.map { $0.truncated(toLength: 640) }, - withContainer: &container, forKey: .tags, upToLength: 8) - - try container.encode(self._createdAt, forKey: .createdAt) - } - - enum CodingKeys: String, CodingKey { - case type = "$type" - case text - case entities - case facets - case reply - case embed - case languages = "langs" - case labels - case tags - case createdAt - } -} - -// MARK: - -/// A data model for a reply reference definition. -/// -/// - SeeAlso: This is based on the [`app.bsky.feed.post`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/post.json -public struct ReplyReference: Codable { - /// The original post of the thread. - public let root: StrongReference - /// The direct post that the user's post is replying to. - /// - /// - Note: If `parent` and `root` are identical, the post is a direct reply to the original - /// post of the thread. - public let parent: StrongReference - - public init(root: StrongReference, parent: StrongReference) { - self.root = root - self.parent = parent - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.root = try container.decode(StrongReference.self, forKey: .root) - self.parent = try container.decode(StrongReference.self, forKey: .parent) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self.root, forKey: .root) - try container.encode(self.parent, forKey: .parent) - } - - enum CodingKeys: CodingKey { - case root - case parent - } -} - -// MARK: - Union type -/// A reference containing the list of types of embeds. -/// -/// - SeeAlso: This is based on the [`app.bsky.feed.post`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/post.json -public enum EmbedUnion: Codable { - /// An image embed. - case images(EmbedImages) - /// An external embed. - case external(EmbedExternal) - /// A record embed. - case record(EmbedRecord) - /// A embed with both a record and some compatible media. - case recordWithMedia(EmbedRecordWithMedia) - - public init(from decoder: Decoder) throws { - let container = try decoder.singleValueContainer() - - if let imagesValue = try? container.decode(EmbedImages.self) { - self = .images(imagesValue) - } else if let externalValue = try? container.decode(EmbedExternal.self) { - self = .external(externalValue) - } else if let recordValue = try? container.decode(EmbedRecord.self) { - self = .record(recordValue) - } else if let recordWithMediaValue = try? container.decode(EmbedRecordWithMedia.self) { - self = .recordWithMedia(recordWithMediaValue) - } else { - throw DecodingError.typeMismatch( - EmbedUnion.self, DecodingError.Context( - codingPath: decoder.codingPath, debugDescription: "Unknown EmbedUnion type")) - } - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - - switch self { - case .images(let imagesValue): - try container.encode(imagesValue) - case .external(let externalValue): - try container.encode(externalValue) - case .record(let recordValue): - try container.encode(recordValue) - case .recordWithMedia(let recordWithMediaValue): - try container.encode(recordWithMediaValue) - } - } -} - -/// A reference containing the list of user-defined labels. -/// -/// - SeeAlso: This is based on the [`app.bsky.feed.post`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/post.json -public enum FeedLabelUnion: Codable { - /// An array of user-defined labels. - case selfLabels(SelfLabels) - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - let selfLabelsValue = try container.decode(SelfLabels.self, forKey: .selfLabels) - self = .selfLabels(selfLabelsValue) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - - switch self { - case .selfLabels(let selfLabelsValue): - try container.encode(selfLabelsValue) - } - } - - enum CodingKeys: String, CodingKey { - case selfLabels - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedRepost.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedRepost.swift deleted file mode 100644 index e0d5fde853..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedRepost.swift +++ /dev/null @@ -1,54 +0,0 @@ -// -// BskyFeedRepost.swift -// -// -// Created by Christopher Jr Riley on 2024-03-06. -// - -import Foundation - -/// The record model definition for a repost record on Bluesky. -/// -/// - Note: According to the AT Protocol specifications: "Record representing a 'repost' of an -/// existing Bluesky post." -/// -/// - SeeAlso: This is based on the [`app.bsky.feed.repost`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/repost.json -public struct FeedRepost: ATRecordProtocol { - /// The identifier of the lexicon. - /// - /// - Warning: The value must not change. - public static private(set) var type: String = "app.bsky.feed.repost" - /// The strong reference of the repost record. - public let subject: StrongReference - /// The date the like record was created. - /// - /// This is the date where the user "liked" a post. - @DateFormatting public var createdAt: Date - - public init(subject: StrongReference, createdAt: Date) { - self.subject = subject - self._createdAt = DateFormatting(wrappedValue: createdAt) - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - self.subject = try container.decode(StrongReference.self, forKey: .subject) - self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - -// try container.encode(self.type, forKey: .type) - try container.encode(self.subject, forKey: .subject) - try container.encode(self._createdAt, forKey: .createdAt) - } - - enum CodingKeys: String, CodingKey { - case type = "$type" - case subject - case createdAt - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedSearchPosts.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedSearchPosts.swift deleted file mode 100644 index e8ea4a99a7..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedSearchPosts.swift +++ /dev/null @@ -1,43 +0,0 @@ -// -// BskyFeedSearchPosts.swift -// -// -// Created by Christopher Jr Riley on 2024-03-06. -// - -import Foundation - -/// The main data model definition for the output of the results of the post search query. -/// -/// - Note: According to the AT Protocol specifications: "Find posts matching search criteria, -/// returning views of those posts." -/// -/// - SeeAlso: This is based on the [`app.bsky.feed.searchPosts`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/searchPosts.json -public struct FeedSearchPostsOutput: Codable { - /// The mark used to indicate the starting point for the next set of results. Optional. - /// - /// - Note: According to the AT Protocol specifications: "Optional pagination mechanism; - /// may not necessarily allow scrolling through entire result set." - public let cursor: String? - /// The number of times the query appears. Optional. - /// - /// - Note: According to the AT Protocol specifications: "Count of search hits. Optional, - /// may be rounded/truncated, and may not be possible to paginate through all hits." - public let hitsTotal: Int? - /// An array of post records in the results. - public let posts: [FeedPostView] -} - -/// Determines the ranking order for the search results. -/// -/// - Note: According to the AT Protocol specifications: "Specifies the ranking order of results." -/// -/// - SeeAlso: This is based on the [`app.bsky.feed.searchPosts`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/searchPosts.json -public enum FeedSearchPostsSortRanking: String { - case top - case latest -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedSendInteractions.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedSendInteractions.swift deleted file mode 100644 index 6f3bb6343b..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedSendInteractions.swift +++ /dev/null @@ -1,28 +0,0 @@ -// -// BskyFeedSendInteractions.swift -// -// -// Created by Christopher Jr Riley on 2024-04-15. -// - -import Foundation - -/// The request body model definition for sending interactions to a feed generator. -/// -/// - Note: According to the AT Protocol specifications: "end information about interactions with -/// feed items back to the feed generator that served them." -/// -/// - SeeAlso: This is based on the [`app.bsky.feed.sendInteractions`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/sendInteractions.json -public struct FeedSendInteractions: Codable { - /// An array of interactions. - public let interactions: [FeedInteraction] -} - -/// The output model definition for sending interactions to a feed generator. -/// -/// - SeeAlso: This is based on the [`app.bsky.feed.sendInteractions`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/sendInteractions.json -public struct FeedSendInteractionsOutput: Codable {} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedThreadgate.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedThreadgate.swift deleted file mode 100644 index 4d186e4bed..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/BskyFeedThreadgate.swift +++ /dev/null @@ -1,114 +0,0 @@ -// -// BskyFeedThreadgate.swift -// -// -// Created by Christopher Jr Riley on 2024-03-06. -// - -import Foundation - -/// The main data model definition for a threadgate record. -/// -/// - Note: According to the AT Protocol specifications: "Record defining interaction gating rules -/// for a thread (aka, reply controls). The record key (rkey) of the threadgate record must match -/// the record key of the thread's root post, and that record must be in the same repository." -/// -/// - SeeAlso: This is based on the [`app.bsky.feed.threadgate`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/threadgate.json -public struct FeedThreadgate: ATRecordProtocol { - /// The identifier of the lexicon. - /// - /// - Warning: The value must not change. - public static private(set) var type: String = "app.bsky.feed.threadgate" - /// The URI of a post record. - public let post: String - public let allow: [ThreadgateUnion] - @DateFormatting public var createdAt: Date - - public init(post: String, allow: [ThreadgateUnion], createdAt: Date) { - self.post = post - self.allow = allow - self._createdAt = DateFormatting(wrappedValue: createdAt) - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.post = try container.decode(String.self, forKey: .post) - self.allow = try container.decode([ThreadgateUnion].self, forKey: .allow) - self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - -// try container.encode(self.type, forKey: .type) - try container.encode(self.post, forKey: .post) - try container.encode(self.allow, forKey: .allow) - try container.encode(self._createdAt, forKey: .createdAt) - } - - enum CodingKeys: String, CodingKey { - case type = "$type" - case post - case allow - case createdAt - } -} - -/// A rule that indicates whether users that the post author mentions can reply to the post. -/// -/// - Note: According to the AT Protocol specifications: "Allow replies from actors mentioned -/// in your post." -public struct FeedThreadgateMentionRule: Codable {} - -/// A rule that indicates whether users that the post author is following can reply to the post. -/// -/// - Note: According to the AT Protocol specifications: "Allow replies from actors you follow." -public struct FeedThreadgateFollowingRule: Codable {} - -/// A rule that indicates whether users that are on a specific list made by the post author can -/// reply to the post. -/// -/// - Note: According to the AT Protocol specifications: "Allow replies from actors on a list." -public struct FeedThreadgateListRule: Codable { - public let list: String -} - - -/// A reference containing the list of thread rules for a post. -public enum ThreadgateUnion: Codable { - case mentionRule(FeedThreadgateMentionRule) - case followingRule(FeedThreadgateFollowingRule) - case listRule(FeedThreadgateListRule) - - public init(from decoder: Decoder) throws { - let container = try decoder.singleValueContainer() - - if let value = try? container.decode(FeedThreadgateMentionRule.self) { - self = .mentionRule(value) - } else if let value = try? container.decode(FeedThreadgateFollowingRule.self) { - self = .followingRule(value) - } else if let value = try? container.decode(FeedThreadgateListRule.self) { - self = .listRule(value) - } else { - throw DecodingError.typeMismatch( - EmbedViewUnion.self, DecodingError.Context( - codingPath: decoder.codingPath, debugDescription: "Unknown ThreadgateUnion type")) - } - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - - switch self { - case .mentionRule(let embedView): - try container.encode(embedView) - case .followingRule(let embedView): - try container.encode(embedView) - case .listRule(let embedView): - try container.encode(embedView) - } - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphDefs.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphDefs.swift index b6299c6f30..937b718e60 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphDefs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphDefs.swift @@ -119,7 +119,7 @@ extension AppBskyLexicon.Graph { public var description: String? /// An array of facets contained in the post's text. Optional. - public var descriptionFacets: [Facet]? + public var descriptionFacets: [AppBskyLexicon.RichText.Facet]? /// The avatar image URL of the user list. Optional. public var avatarImageURL: URL? @@ -131,7 +131,8 @@ extension AppBskyLexicon.Graph { @DateFormatting public var indexedAt: Date public init(listURI: String, cidHash: String, creator: AppBskyLexicon.Actor.ProfileViewDefinition, name: String, purpose: ListPurpose, - description: String?, descriptionFacets: [Facet]?, avatarImageURL: URL?, viewer: ListViewerStateDefinition?, indexedAt: Date) { + description: String?, descriptionFacets: [AppBskyLexicon.RichText.Facet]?, avatarImageURL: URL?, + viewer: ListViewerStateDefinition?, indexedAt: Date) { self.listURI = listURI self.cidHash = cidHash self.creator = creator @@ -153,7 +154,7 @@ extension AppBskyLexicon.Graph { self.name = try container.decode(String.self, forKey: .name) self.purpose = try container.decode(ListPurpose.self, forKey: .purpose) self.description = try container.decodeIfPresent(String.self, forKey: .description) - self.descriptionFacets = try container.decodeIfPresent([Facet].self, forKey: .descriptionFacets) + self.descriptionFacets = try container.decodeIfPresent([AppBskyLexicon.RichText.Facet].self, forKey: .descriptionFacets) self.avatarImageURL = try container.decodeIfPresent(URL.self, forKey: .avatarImageURL) self.viewer = try container.decodeIfPresent(ListViewerStateDefinition.self, forKey: .viewer) self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphList.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphList.swift index 1781dcaa26..3888e2f916 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphList.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/AppBskyGraphList.swift @@ -41,7 +41,7 @@ extension AppBskyLexicon.Graph { public let description: String? /// An array of facets contained within the description. Optional. - public let descriptionFacets: [Facet]? + public let descriptionFacets: [AppBskyLexicon.RichText.Facet]? /// The avatar image of the list. Optional. public let avatarImage: ComAtprotoLexicon.Repository.UploadBlobOutput? @@ -52,7 +52,7 @@ extension AppBskyLexicon.Graph { /// The date and time the list was created. @DateFormatting public var createdAt: Date - public init(name: String, purpose: ListPurpose, description: String?, descriptionFacets: [Facet]?, + public init(name: String, purpose: ListPurpose, description: String?, descriptionFacets: [AppBskyLexicon.RichText.Facet]?, avatarImage: ComAtprotoLexicon.Repository.UploadBlobOutput?, labels: ATUnion.ListLabelsUnion, createdAt: Date) { self.name = name self.purpose = purpose @@ -69,7 +69,7 @@ extension AppBskyLexicon.Graph { self.name = try container.decode(String.self, forKey: .name) self.purpose = try container.decode(ListPurpose.self, forKey: .purpose) self.description = try container.decodeIfPresent(String.self, forKey: .description) - self.descriptionFacets = try container.decodeIfPresent([Facet].self, forKey: .descriptionFacets) + self.descriptionFacets = try container.decodeIfPresent([AppBskyLexicon.RichText.Facet].self, forKey: .descriptionFacets) self.avatarImage = try container.decodeIfPresent(ComAtprotoLexicon.Repository.UploadBlobOutput.self, forKey: .avatarImage) self.labels = try container.decode(ATUnion.ListLabelsUnion.self, forKey: .labels) self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphBlock.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphBlock.swift deleted file mode 100644 index 3b42ab03a0..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphBlock.swift +++ /dev/null @@ -1,55 +0,0 @@ -// -// BskyGraphBlock.swift -// -// -// Created by Christopher Jr Riley on 2024-03-08. -// - -import Foundation - -/// The main data model definition for a block record. -/// -/// - Note: According to the AT Protocol specifications: "Record declaring a 'block' relationship -/// against another account. NOTE: blocks are public in Bluesky; see blog posts for details." -/// -/// - SeeAlso: This is based on the [`app.bsky.graph.block`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/block.json -public struct GraphBlock: ATRecordProtocol { - /// The identifier of the lexicon. - /// - /// - Warning: The value must not change. - public static private(set) var type: String = "app.bsky.graph.block" - /// The decentralized identifier(DID) of the subject that has been blocked. - /// - /// - Note: According to the AT Protocol specifications: "DID of the account to be blocked." - public let subjectDID: String - /// The date and time the block record was created. - @DateFormatting public var createdAt: Date - - public init(subjectDID: String, createdAt: Date) { - self.subjectDID = subjectDID - self._createdAt = DateFormatting(wrappedValue: createdAt) - } - - public init(from decoder: any Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.subjectDID = try container.decode(String.self, forKey: .subjectDID) - self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue - } - - public func encode(to encoder: any Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - -// try container.encode(self.type, forKey: .type) - try container.encode(self.subjectDID, forKey: .subjectDID) - try container.encode(self._createdAt, forKey: .createdAt) - } - - enum CodingKeys: String, CodingKey { - case type = "$type" - case subjectDID = "subject" - case createdAt - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphDefs.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphDefs.swift deleted file mode 100644 index 4babafaab3..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphDefs.swift +++ /dev/null @@ -1,273 +0,0 @@ -// -// BskyGraphDefs.swift -// -// -// Created by Christopher Jr Riley on 2024-01-25. -// - -import Foundation - -/// A data model for a basic list view definition. -/// -/// - SeeAlso: This is based on the [`app.bsky.graph.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/defs.json -public struct GraphListViewBasic: Codable { - /// The URI of a user list. - public let actorURI: String - /// The CID of a user list. - public let cidHash: String - /// The name of the list. - public let name: String - /// The purpose of the user list. - /// - /// - Important: Current maximum length is 64 characters. This library will truncate the - /// `String` to the maximum number of characters if it does go over. - public let purpose: GraphListPurpose - /// The avatar image URL of the user list. Optional. - public let avatarImageURL: URL? - /// The viewer's state of the user list. Optional. - public var viewer: GraphListViewerState? = nil - /// The late time the user list was indexed. - @DateFormattingOptional public var indexedAt: Date? = nil - - public init(actorURI: String, cidHash: String, name: String, purpose: GraphListPurpose, avatarImageURL: URL?, viewer: GraphListViewerState?, - indexedAt: Date?) { - self.actorURI = actorURI - self.cidHash = cidHash - self.name = name - self.purpose = purpose - self.avatarImageURL = avatarImageURL - self.viewer = viewer - self._indexedAt = DateFormattingOptional(wrappedValue: indexedAt) - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.actorURI = try container.decode(String.self, forKey: .actorURI) - self.cidHash = try container.decode(String.self, forKey: .cidHash) - self.name = try container.decode(String.self, forKey: .name) - self.purpose = try container.decode(GraphListPurpose.self, forKey: .purpose) - self.avatarImageURL = try container.decodeIfPresent(URL.self, forKey: .avatarImageURL) - self.viewer = try container.decodeIfPresent(GraphListViewerState.self, forKey: .viewer) - self.indexedAt = try container.decodeIfPresent(DateFormattingOptional.self, forKey: .indexedAt)?.wrappedValue - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self.actorURI, forKey: .actorURI) - try container.encode(self.cidHash, forKey: .cidHash) - try container.encode(self.name, forKey: .name) - // - try truncatedEncode(self.name, withContainer: &container, forKey: .name, upToLength: 64) - try container.encode(self.purpose, forKey: .purpose) - try container.encodeIfPresent(self.avatarImageURL, forKey: .avatarImageURL) - try container.encodeIfPresent(self.viewer, forKey: .viewer) - try container.encode(self._indexedAt, forKey: .indexedAt) - } - - enum CodingKeys: String, CodingKey { - case actorURI = "uri" - case cidHash = "cid" - case name = "name" - case purpose = "purpose" - case avatarImageURL = "avatar" - case viewer = "viewer" - case indexedAt - } -} - -/// A data model for a definition of the view of a user list. -/// -/// - SeeAlso: This is based on the [`app.bsky.graph.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/defs.json -public struct GraphListView: Codable { - /// The URI of the user list. - public let listURI: String - /// The CID of the user list. - public let cidHash: String - /// The creator of the user list. - public let creator: ActorProfileView - /// The name of the user list. - /// - /// - Important: Current maximum length is 64 characters. This library will truncate the - /// `String` to the maximum number of characters if it does go over. - public let name: String - /// The purpose of the user list. - public let purpose: GraphListPurpose - /// The description of the user list. Optional. - /// - /// - Important: Current maximum length is 300 characters. This library will truncate the - /// `String` to the maximum number of characters if it does go over. - public var description: String? = nil - /// An array of facets contained in the post's text. Optional. - public var descriptionFacets: [Facet]? = nil - /// The avatar image URL of the user list. Optional. - public var avatarImageURL: URL? = nil - /// The viewer's state of the user list. Optional. - public var viewer: GraphListViewerState? = nil - /// The late time the user list was indexed. - @DateFormatting public var indexedAt: Date - - public init(listURI: String, cidHash: String, creator: ActorProfileView, name: String, purpose: GraphListPurpose, description: String?, - descriptionFacets: [Facet]?, avatarImageURL: URL?, viewer: GraphListViewerState?, indexedAt: Date) { - self.listURI = listURI - self.cidHash = cidHash - self.creator = creator - self.name = name - self.purpose = purpose - self.description = description - self.descriptionFacets = descriptionFacets - self.avatarImageURL = avatarImageURL - self.viewer = viewer - self._indexedAt = DateFormatting(wrappedValue: indexedAt) - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.listURI = try container.decode(String.self, forKey: .listURI) - self.cidHash = try container.decode(String.self, forKey: .cidHash) - self.creator = try container.decode(ActorProfileView.self, forKey: .creator) - self.name = try container.decode(String.self, forKey: .name) - self.purpose = try container.decode(GraphListPurpose.self, forKey: .purpose) - self.description = try container.decodeIfPresent(String.self, forKey: .description) - self.descriptionFacets = try container.decodeIfPresent([Facet].self, forKey: .descriptionFacets) - self.avatarImageURL = try container.decodeIfPresent(URL.self, forKey: .avatarImageURL) - self.viewer = try container.decodeIfPresent(GraphListViewerState.self, forKey: .viewer) - self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self.listURI, forKey: .listURI) - try container.encode(self.cidHash, forKey: .cidHash) - try container.encode(self.creator, forKey: .creator) - // Truncate `name` to 64 characters before encoding. - try truncatedEncode(self.name, withContainer: &container, forKey: .name, upToLength: 64) - try container.encode(self.purpose, forKey: .purpose) - - // Truncate `description` to 3000 characters before encoding - // `maxGraphemes`'s limit is 300, but `String.count` should respect that limit - try truncatedEncodeIfPresent(self.description, withContainer: &container, forKey: .description, upToLength: 3000) - try container.encodeIfPresent(self.descriptionFacets, forKey: .descriptionFacets) - try container.encodeIfPresent(self.avatarImageURL, forKey: .avatarImageURL) - try container.encodeIfPresent(self.viewer, forKey: .viewer) - try container.encode(self._indexedAt, forKey: .indexedAt) - } - - enum CodingKeys: String, CodingKey { - case listURI = "uri" - case cidHash = "cid" - case creator = "creator" - case name = "name" - case purpose = "purpose" - case description = "description" - case descriptionFacets = "descriptionFacets" - case avatarImageURL = "avatar" - case viewer = "viewer" - case indexedAt = "indexedAt" - } -} - -/// A data model for the definition of an item with in a user list. -/// -/// - SeeAlso: This is based on the [`app.bsky.graph.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/defs.json -public struct GraphListItemView: Codable { - /// The URI of the user list item. - public let listItemURI: String - /// A user in the user list item. - public let subject: ActorProfileView - - enum CodingKeys: String, CodingKey { - case listItemURI = "uri" - case subject - } -} - -/// A data model of the definition of the user list's purpose. -/// -/// - SeeAlso: This is based on the [`app.bsky.graph.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/defs.json -public enum GraphListPurpose: String, Codable { - /// An array of actors to apply an aggregate moderation action (mute/block) on. - case modlist = "app.bsky.graph.defs#modlist" - - /// An array of actors used for curation purposes such as list feeds or interaction gating. - case curatelist = "app.bsky.graph.defs#curatelist" -} - - -/// A data model of a definition for a viewer's state of a user list. -/// -/// - SeeAlso: This is based on the [`app.bsky.graph.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/defs.json -public struct GraphListViewerState: Codable { - /// Indicates whether the user is muted. Optional. - public var isMuted: Bool? = nil - /// The URI of the block record if the user has blocked the user list. Optional - public var blockedURI: String? = nil - - enum CodingKeys: String, CodingKey { - case isMuted = "muted" - case blockedURI = "blocked" - } -} - -/// A data model for a definition of a user that may not have been found in the user list. -/// -/// - SeeAlso: This is based on the [`app.bsky.graph.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/defs.json -public struct GraphNotFoundActor: Codable { - /// The URI of the user. - /// - /// - Note: According to the AT Protocol specifications: "indicates that a handle or DID could - /// not be resolved", - public let actorURI: String - /// Indicates whether the user is not found. - public let isNotFound: Bool - - enum CodingKeys: String, CodingKey { - case actorURI = "actor" - case isNotFound = "notFound" - } -} - -/// A data model for the graph relationship definition. -/// -/// - Note: According to the AT Protocol specifications: "lists the bi-directional graph -/// relationships between one actor (not indicated in the object), and the target actors (the DID -/// included in the object)" -/// -/// - SeeAlso: This is based on the [`app.bsky.graph.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/defs.json -public struct GraphRelationship: Codable { - /// The decentralized identifier (DID) of the target user. - public let actorDID: String - /// The URI of the follow record, if the first user is following the target user. Optional. - /// - /// - Note: According to the AT Protocol specifications: "if the actor follows this DID, this - /// is the AT-URI of the follow record" - public let followingURI: String? - /// The URI of the follow record, if the target user is following the first user. Optional. - /// - /// - Note: According to the AT Protocol specifications: "if the actor is followed by this - /// DID, contains the AT-URI of the follow record" - public let followedByURI: String? - - enum CodingKeys: String, CodingKey { - case actorDID = "did" - case followingURI = "following" - case followedByURI = "followedBy" - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphFollow.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphFollow.swift deleted file mode 100644 index 40724e6852..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphFollow.swift +++ /dev/null @@ -1,52 +0,0 @@ -// -// BskyGraphFollow.swift -// -// -// Created by Christopher Jr Riley on 2024-03-08. -// - -import Foundation - -/// The main data model definition for a follow record. -/// -/// - Note: According to the AT Protocol specifications: "Record declaring a social 'follow' -/// relationship of another account. Duplicate follows will be ignored by the AppView." -/// -/// - SeeAlso: This is based on the [`app.bsky.graph.follow`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/follow.json -public struct GraphFollow: ATRecordProtocol { - /// The identifier of the lexicon. - /// - /// - Warning: The value must not change. - public static private(set) var type: String = "app.bsky.graph.follow" - - /// The subject that the user account wants to "follow." - public let subjectDID: String - /// The date and time the record was created. - @DateFormatting public var createdAt: Date - - public init(subjectDID: String, createdAt: Date) { - self.subjectDID = subjectDID - self._createdAt = DateFormatting(wrappedValue: createdAt) - } - - public init(from decoder: any Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.subjectDID = try container.decode(String.self, forKey: .subjectDID) - self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue - } - - public func encode(to encoder: any Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self.subjectDID, forKey: .subjectDID) - try container.encode(self._createdAt, forKey: .createdAt) - } - - enum CodingKeys: String, CodingKey { - case subjectDID = "subject" - case createdAt - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphGetBlocks.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphGetBlocks.swift deleted file mode 100644 index b394d69e45..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphGetBlocks.swift +++ /dev/null @@ -1,24 +0,0 @@ -// -// BskyGraphGetBlocks.swift -// -// -// Created by Christopher Jr Riley on 2024-03-08. -// - -import Foundation - -/// The main data model definition for the output of getting all of the users that have been -/// blocked by the user account. -/// -/// - Note: According to the AT Protocol specifications: "Enumerates which accounts the -/// requesting account is currently blocking. Requires auth." -/// -/// - SeeAlso: This is based on the [`app.bsky.graph.getBlocks`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/getBlocks.json -public struct GraphGetBlocksOutput: Codable { - /// The mark used to indicate the starting point for the next set of results. Optional. - public let cursor: String? - /// An array of profiles that have been blocked by the user account. - public let blocks: [ActorProfileView] -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphGetFollowers.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphGetFollowers.swift deleted file mode 100644 index 50c9907ae2..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphGetFollowers.swift +++ /dev/null @@ -1,25 +0,0 @@ -// -// BskyGraphGetFollowers.swift -// -// -// Created by Christopher Jr Riley on 2024-03-08. -// - -import Foundation - -/// The main data model definition for the output of getting all of the user account's followers. -/// -/// - Note: According to the AT Protocol specifications: "Enumerates accounts which follow a -/// specified account (actor)." -/// -/// - SeeAlso: This is based on the [`app.bsky.graph.getFollowers`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/getFollowers.json -public struct GraphGetFollowersOutput: Codable { - /// The user account itself. - public let subject: ActorProfileView - /// The mark used to indicate the starting point for the next set of results. Optional. - public let cursor: String? - /// An array of user accounts that follow the user account. - public let followers: [ActorProfileView] -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphGetFollows.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphGetFollows.swift deleted file mode 100644 index 14e8d2ddea..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphGetFollows.swift +++ /dev/null @@ -1,26 +0,0 @@ -// -// BskyGraphGetFollows.swift -// -// -// Created by Christopher Jr Riley on 2024-03-08. -// - -import Foundation - -/// The main data model definition for the output for grabbing all of the accounts the user -/// account follows. -/// -/// - Note: According to the AT Protocol specifications: "Enumerates accounts which a specified -/// account (actor) follows." -/// -/// - SeeAlso: This is based on the [`app.bsky.graph.getFollows`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/getFollows.json -public struct GraphFollowsOutput: Codable { - /// The user account itself. - public let subject: ActorProfileView - /// The mark used to indicate the starting point for the next set of results. Optional. - public let cursor: String? - /// An array of user accounts that the user account follows. - public let follows: [ActorProfileView] -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphGetList.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphGetList.swift deleted file mode 100644 index f5991c6697..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphGetList.swift +++ /dev/null @@ -1,25 +0,0 @@ -// -// BskyGraphGetList.swift -// -// -// Created by Christopher Jr Riley on 2024-03-09. -// - -import Foundation - -/// The main data model definition for the output of grabbing the list view. -/// -/// - Note: According to the AT Protocol specifications: "Gets a 'view' (with additional context) -/// of a specified list." -/// -/// - SeeAlso: This is based on the [`app.bsky.graph.getList`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/getList.json -public struct GraphGetListOutput: Codable { - /// The mark used to indicate the starting point for the next set of results. Optional. - public let cursor: String? - /// The metadata of the list. - public let list: GraphListView - /// An array of list items. - public let items: [GraphListItemView] -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphGetListBlocks.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphGetListBlocks.swift deleted file mode 100644 index fb92814ff7..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphGetListBlocks.swift +++ /dev/null @@ -1,24 +0,0 @@ -// -// BskyGraphGetListBlocks.swift -// -// -// Created by Christopher Jr Riley on 2024-03-10. -// - -import Foundation - -/// The main data model definition for the output of getting the moderator lists that the user -/// account is blocking. -/// -/// - Note: According to the AT Protocol specifications: "Get mod lists that the requesting -/// account (actor) is blocking. Requires auth." -/// -/// - SeeAlso: This is based on the [`app.bsky.graph.getListBlocks`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/getListBlocks.json -public struct GraphGetListBlocksOutput: Codable { - /// The mark used to indicate the starting point for the next set of results. Optional. - public let cursor: String? - /// An array of lists that the user account is blocking. - public let lists: [GraphListView] -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphGetListMutes.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphGetListMutes.swift deleted file mode 100644 index bf03bc39db..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphGetListMutes.swift +++ /dev/null @@ -1,24 +0,0 @@ -// -// BskyGraphGetListMutes.swift -// -// -// Created by Christopher Jr Riley on 2024-03-10. -// - -import Foundation - -/// The main data model definition for the output of grabbing the moderator list that the user -/// account is currently muting. -/// -/// - Note: According to the AT Protocol specifications: "Enumerates mod lists that the requesting -/// account (actor) currently has muted. Requires auth." -/// -/// - SeeAlso: This is based on the [`app.bsky.graph.getListMutes`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/getListMutes.json -public struct GraphGetListMutesOutput: Codable { - /// The mark used to indicate the starting point for the next set of results. Optional. - public let cursor: String? - /// An array of lists the user account is muting. - public let lists: [GraphListView] -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphGetLists.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphGetLists.swift deleted file mode 100644 index 75942d3b6c..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphGetLists.swift +++ /dev/null @@ -1,24 +0,0 @@ -// -// BskyGraphGetLists.swift -// -// -// Created by Christopher Jr Riley on 2024-03-10. -// - -import Foundation - -/// The main data model definition for the output of retrieving the lists created by the -/// user account. -/// -/// - Note: According to the AT Protocol specifications: "Enumerates the lists created by a -/// specified account (actor)." -/// -/// - SeeAlso: This is based on the [`app.bsky.graph.getLists`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/getLists.json -public struct GraphGetListsOutput: Codable { - /// The mark used to indicate the starting point for the next set of results. Optional. - public let cursor: String? - /// An array of lists created by the user account. - public let lists: [GraphListView] -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphGetMutes.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphGetMutes.swift deleted file mode 100644 index 1080c7ba79..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphGetMutes.swift +++ /dev/null @@ -1,24 +0,0 @@ -// -// BskyGraphGetMutes.swift -// -// -// Created by Christopher Jr Riley on 2024-03-10. -// - -import Foundation - -/// The main data model definition for the output of retrieving all accounts the user account is -/// currently muting. -/// -/// - Note: According to the AT Protocol specifications: "Enumerates accounts that the requesting -/// account (actor) currently has muted. Requires auth." -/// -/// - SeeAlso: This is based on the [`app.bsky.graph.getMutes`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/getMutes.json -public struct GraphGetMutesOutput: Codable { - /// The mark used to indicate the starting point for the next set of results. Optional. - public let cursor: String? - /// An array of accounts the user account is muting. - public let mutes: [ActorProfileView] -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphGetRelationships.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphGetRelationships.swift deleted file mode 100644 index 231d045e71..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphGetRelationships.swift +++ /dev/null @@ -1,56 +0,0 @@ -// -// BskyGraphGetRelationships.swift -// -// -// Created by Christopher Jr Riley on 2024-03-10. -// - -import Foundation - -/// The main data model definition for the output of the public relationship between two -/// user accounts. -/// -/// - Note: According to the AT Protocol specifications: "Enumerates public relationships between -/// one account, and a list of other accounts. Does not require auth." -/// -/// - SeeAlso: This is based on the [`app.bsky.graph.getRelationships`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/getRelationships.json -public struct GraphGetRelationships: Codable { - /// The decentralized identifier (DID) of the user account. - public let actor: String? - /// The metadata containing the relationship between mutliple user accounts. - public let relationships: [GraphRelationshipUnion] -} - - -/// A reference containing the list of relationships of multiple user accounts. -public enum GraphRelationshipUnion: Codable { - case relationship(GraphRelationship) - case notFoundActor(GraphNotFoundActor) - - public init(from decoder: Decoder) throws { - let container = try decoder.singleValueContainer() - - if let value = try? container.decode(GraphRelationship.self) { - self = .relationship(value) - } else if let value = try? container.decode(GraphNotFoundActor.self) { - self = .notFoundActor(value) - } else { - throw DecodingError.typeMismatch( - ActorPreferenceUnion.self, DecodingError.Context( - codingPath: decoder.codingPath, debugDescription: "Unknown GraphRelationshipUnion type")) - } - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - - switch self { - case .relationship(let relationship): - try container.encode(relationship) - case .notFoundActor(let notFoundActor): - try container.encode(notFoundActor) - } - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphGetSuggestedFollowsByActor.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphGetSuggestedFollowsByActor.swift deleted file mode 100644 index 0b1ef1c56b..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphGetSuggestedFollowsByActor.swift +++ /dev/null @@ -1,23 +0,0 @@ -// -// BskyGraphGetSuggestedFollowsByActor.swift -// -// -// Created by Christopher Jr Riley on 2024-03-10. -// - -import Foundation - -/// The main data model definition for the output of getting the list of user accounts that -/// requesting user account is suggested to follow. -/// -/// - Note: According to the AT Protocol specifications: "Enumerates follows similar to a given -/// account (actor). Expected use is to recommend additional accounts immediately after following -/// one account." -/// -/// - SeeAlso: This is based on the [`app.bsky.graph.getSuggestedFollowsByActor`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/getSuggestedFollowsByActor.json -public struct GraphGetSuggestedFollowsByActorOutput: Codable { - /// An array of user accounts the requesting user account is suggested to follow. - public let suggestions: [ActorProfileView] -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphList.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphList.swift deleted file mode 100644 index 3c7af951f6..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphList.swift +++ /dev/null @@ -1,90 +0,0 @@ -// -// BskyGraphList.swift -// -// -// Created by Christopher Jr Riley on 2024-03-10. -// - -import Foundation - -/// The main data model definition for a list record. -/// -/// - Note: According to the AT Protocol specifications: "Record representing a list of accounts -/// (actors). Scope includes both moderation-oriented lists and curration-oriented lists." -/// -/// - SeeAlso: This is based on the [`app.bsky.graph.list`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/list.json -public struct GraphList: ATRecordProtocol { - /// The identifier of the lexicon. - /// - /// - Warning: The value must not change. - public static private(set) var type: String = "app.bsky.graph.list" - /// The name of the list. - /// - /// - Note: According to the AT Protocol specifications: "Display name for list; can not be empty." - public let name: String - /// The purpose of the list. - /// - /// - Note: According to the AT Protocol specifications: "Defines the purpose of the list - /// (aka, moderation-oriented or curration-oriented)." - public let purpose: GraphListPurpose - /// The description of the list. Optional. - public let description: String? - /// An array of facets contained within the description. Optional. - public let descriptionFacets: [Facet]? - /// The avatar image of the list. Optional. - public let avatarImage: UploadBlobOutput? - /// The user-defined labels for the list. Optional. - public let labels: SelfLabels - /// The date and time the list was created. - @DateFormatting public var createdAt: Date - - public init(name: String, purpose: GraphListPurpose, description: String?, descriptionFacets: [Facet]?, avatarImage: UploadBlobOutput?, - labels: SelfLabels, createdAt: Date) { - self.name = name - self.purpose = purpose - self.description = description - self.descriptionFacets = descriptionFacets - self.avatarImage = avatarImage - self.labels = labels - self._createdAt = DateFormatting(wrappedValue: createdAt) - } - - public init(from decoder: any Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.name = try container.decode(String.self, forKey: .name) - self.purpose = try container.decode(GraphListPurpose.self, forKey: .purpose) - self.description = try container.decodeIfPresent(String.self, forKey: .description) - self.descriptionFacets = try container.decodeIfPresent([Facet].self, forKey: .descriptionFacets) - self.avatarImage = try container.decodeIfPresent(UploadBlobOutput.self, forKey: .avatarImage) - self.labels = try container.decode(SelfLabels.self, forKey: .labels) - self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue - } - - public func encode(to encoder: any Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - -// try container.encode(self.type, forKey: .type) - try container.encode(self.name, forKey: .name) - try container.encode(self.purpose, forKey: .purpose) - try container.encodeIfPresent(self.description, forKey: .description) - try container.encodeIfPresent(self.descriptionFacets, forKey: .descriptionFacets) - try container.encodeIfPresent(self.avatarImage, forKey: .avatarImage) - try container.encode(self.labels, forKey: .labels) - try container.encode(self._createdAt, forKey: .createdAt) - } - - enum CodingKeys: String, CodingKey { - case type = "$type" - case name - case purpose - case description - case descriptionFacets - case avatarImage = "avatar" - case labels - case createdAt - } - -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphListblock.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphListblock.swift deleted file mode 100644 index ac92d3cc7b..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphListblock.swift +++ /dev/null @@ -1,56 +0,0 @@ -// -// BskyGraphListblock.swift -// -// -// Created by Christopher Jr Riley on 2024-03-10. -// - -import Foundation - -/// The main data model definition for a blocking list record. -/// -/// - Note: According to the AT Protocol specifications: "Record representing a block relationship -/// against an entire [...] list of accounts (actors)." -/// -/// - SeeAlso: This is based on the [`app.bsky.graph.listblock`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/listblock.json -public struct GraphListBlock: ATRecordProtocol { - /// The identifier of the lexicon. - /// - /// - Warning: The value must not change. - public static private(set) var type: String = "app.bsky.graph.listblock" - /// The decentralized identifier (DID) of the moderator list record. - /// - /// - Note: According to the AT Protocol specifications: "Reference (AT-URI) to the mod - /// list record." - public let subjectDID: String - /// The date and time the record was created. - @DateFormatting public var createdAt: Date - - public init(subjectDID: String, createdAt: Date) { - self.subjectDID = subjectDID - self._createdAt = DateFormatting(wrappedValue: createdAt) - } - - public init(from decoder: any Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.subjectDID = try container.decode(String.self, forKey: .subjectDID) - self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue - } - - public func encode(to encoder: any Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - -// try container.encode(self.type, forKey: .type) - try container.encode(self.subjectDID, forKey: .subjectDID) - try container.encode(self._createdAt, forKey: .createdAt) - } - - enum CodingKeys: String, CodingKey { - case type = "$type" - case subjectDID = "subject" - case createdAt - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphListitem.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphListitem.swift deleted file mode 100644 index 924ecf74c5..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphListitem.swift +++ /dev/null @@ -1,65 +0,0 @@ -// -// BskyGraphListitem.swift -// -// -// Created by Christopher Jr Riley on 2024-03-10. -// - -import Foundation - -/// The main data model definition for a list item record. -/// -/// - Note: According to the AT Protocol specifications: "Record representing an account's -/// inclusion on a specific list. The AppView will ignore duplicate listitem records." -/// -/// - SeeAlso: This is based on the [`app.bsky.graph.listitem`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/listitem.json -public struct GraphListItem: ATRecordProtocol { - /// The identifier of the lexicon. - /// - /// - Warning: The value must not change. - public static private(set) var type: String = "app.bsky.graph.listitem" - /// The decentralized identifier (DID) of the account that's in a list. - /// - /// - Note: According to the AT Protocol specifications: "The account which is included on - /// the list." - public let subjectDID: String - /// The decentralized identifier (DID) of the list record. - /// - /// - Note: According to the AT Protocol specifications: "The account which is included on - /// the list." - public let list: String - /// The date and time the record was created. - @DateFormatting public var createdAt: Date - - public init(subjectDID: String, list: String, createdAt: Date) { - self.subjectDID = subjectDID - self.list = list - self._createdAt = DateFormatting(wrappedValue: createdAt) - } - - public init(from decoder: any Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.subjectDID = try container.decode(String.self, forKey: .subjectDID) - self.list = try container.decode(String.self, forKey: .list) - self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue - } - - public func encode(to encoder: any Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - -// try container.encode(self.type, forKey: .type) - try container.encode(self.subjectDID, forKey: .subjectDID) - try container.encode(self.list, forKey: .list) - try container.encode(self._createdAt, forKey: .createdAt) - } - - enum CodingKeys: String, CodingKey { - case type = "$type" - case subjectDID = "subject" - case list - case createdAt - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphMuteActor.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphMuteActor.swift deleted file mode 100644 index 30be3b6ed7..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphMuteActor.swift +++ /dev/null @@ -1,25 +0,0 @@ -// -// BskyGraphMuteActor.swift -// -// -// Created by Christopher Jr Riley on 2024-03-10. -// - -import Foundation - -/// The main data model definition for muting a user account. -/// -/// - Note: According to the AT Protocol specifications: "Creates a mute relationship for the -/// specified account. Mutes are private in Bluesky. Requires auth." -/// -/// - SeeAlso: This is based on the [`app.bsky.graph.muteActor`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/muteActor.json -public struct GraphMuteActor: Codable { - /// The decentralized identifier (DID) or handle of a user account. - public let actorDID: String - - enum CodingKeys: String, CodingKey { - case actorDID = "actor" - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphMuteActorList.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphMuteActorList.swift deleted file mode 100644 index 92204ac038..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphMuteActorList.swift +++ /dev/null @@ -1,25 +0,0 @@ -// -// BskyGraphMuteActorList.swift -// -// -// Created by Christopher Jr Riley on 2024-03-10. -// - -import Foundation - -/// The main data model definition for muting a list. -/// -/// - Note: According to the AT Protocol specifications: "Creates a mute relationship for the -/// specified list of accounts. Mutes are private in Bluesky. Requires auth." -/// -/// - SeeAlso: This is based on the [`app.bsky.graph.muteActorList`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/muteActor.json -public struct GraphMuteActorList: Codable { - /// The URI of a list. - public let listURI: String - - enum CodingKeys: String, CodingKey { - case listURI = "list" - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphUnmuteActor.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphUnmuteActor.swift deleted file mode 100644 index 018afcf718..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphUnmuteActor.swift +++ /dev/null @@ -1,25 +0,0 @@ -// -// BskyGraphUnmuteActor.swift -// -// -// Created by Christopher Jr Riley on 2024-03-10. -// - -import Foundation - -/// The main data model definition for unmuting a user account. -/// -/// - Note: According to the AT Protocol specifications: "Unmutes the specified account. -/// Requires auth." -/// -/// - SeeAlso: This is based on the [`app.bsky.graph.unmuteActor`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/unmuteActor.json -public struct GraphUnmuteActor: Codable { - /// The decentralized identifier (DID) or handle of a user account. - public let actorDID: String - - enum CodingKeys: String, CodingKey { - case actorDID = "actor" - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphUnmuteActorList.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphUnmuteActorList.swift deleted file mode 100644 index 43c1b0be25..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Graph/BskyGraphUnmuteActorList.swift +++ /dev/null @@ -1,26 +0,0 @@ -// -// BskyGraphUnmuteActorList.swift -// -// -// Created by Christopher Jr Riley on 2024-03-10. -// - -import Foundation - -/// The main data model definition for unmuting a list of user accounts. -/// -/// - Note: According to the AT Protocol specifications: "Unmutes the specified list of -/// accounts. Requires auth." -/// -/// - SeeAlso: This is based on the [`app.bsky.graph.unmuteActorList`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/graph/unmuteActorList.json -public struct GraphUnmuteActorList: Codable { - /// The URI of a list. - public let listURI: String - - enum CodingKeys: String, CodingKey { - case listURI = "list" - } -} - diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerDefs.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerDefs.swift index 34436b7914..12e124d073 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerDefs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/AppBskyLabelerDefs.swift @@ -110,7 +110,7 @@ extension AppBskyLexicon.Labeler { public let likeCount: Int? /// The viewer state of the labeler. Optional. - public let viewer: LabelerViewerState? + public let viewer: AppBskyLexicon.Labeler.LabelerViewerStateDefinition? /// The date and time the labeler was last indexed. @DateFormatting public var indexedAt: Date @@ -119,7 +119,8 @@ extension AppBskyLexicon.Labeler { public let labels: [ComAtprotoLexicon.Label.LabelDefinition]? public init(labelerURI: String, labelerCIDHash: String, creator: AppBskyLexicon.Actor.ProfileViewDefinition, policies: LabelerPolicies, - likeCount: Int?, viewer: LabelerViewerState?, indexedAt: Date, labels: [ComAtprotoLexicon.Label.LabelDefinition]?) { + likeCount: Int?, viewer: AppBskyLexicon.Labeler.LabelerViewerStateDefinition?, indexedAt: Date, + labels: [ComAtprotoLexicon.Label.LabelDefinition]?) { self.labelerURI = labelerURI self.labelerCIDHash = labelerCIDHash self.creator = creator @@ -138,7 +139,7 @@ extension AppBskyLexicon.Labeler { self.creator = try container.decode(AppBskyLexicon.Actor.ProfileViewDefinition.self, forKey: .creator) self.policies = try container.decode(LabelerPolicies.self, forKey: .policies) self.likeCount = try container.decodeIfPresent(Int.self, forKey: .likeCount) - self.viewer = try container.decodeIfPresent(LabelerViewerState.self, forKey: .viewer) + self.viewer = try container.decodeIfPresent(AppBskyLexicon.Labeler.LabelerViewerStateDefinition.self, forKey: .viewer) self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue self.labels = try container.decodeIfPresent([ComAtprotoLexicon.Label.LabelDefinition].self, forKey: .labels) } diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/BskyLabelerDefs.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/BskyLabelerDefs.swift deleted file mode 100644 index b109e031be..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/BskyLabelerDefs.swift +++ /dev/null @@ -1,186 +0,0 @@ -// -// BskyLabelerDefs.swift -// -// -// Created by Christopher Jr Riley on 2024-03-14. -// - -import Foundation - -/// A data model definition for a labeler view. -/// -/// - SeeAlso: This is based on the [`app.bsky.labeler.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/labeler/defs.json -public struct LabelerView: Codable { - /// The URI of the labeler. - public let labelerURI: String - /// The CID hash of the labeler. - public let labelerCIDHash: String - /// The creator of the labeler. - public let creator: ActorProfileView - /// The number of likes for the labeler. Optional. - public let likeCount: Int? - /// The viewer state of the labeler. Optional. - public let viewer: LabelerViewerState? - /// The date and time the labeler was last indexed. - @DateFormatting public var indexedAt: Date - /// An array of labels. Optional. - public let labels: [Label]? - - public init(labelerURI: String, labelerCIDHash: String, creator: ActorProfileView, likeCount: Int?, viewer: LabelerViewerState?, indexedAt: Date, labels: [Label]?) { - self.labelerURI = labelerURI - self.labelerCIDHash = labelerCIDHash - self.creator = creator - self.likeCount = likeCount - self.viewer = viewer - self._indexedAt = DateFormatting(wrappedValue: indexedAt) - self.labels = labels - } - - public init(from decoder: any Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.labelerURI = try container.decode(String.self, forKey: .labelerURI) - self.labelerCIDHash = try container.decode(String.self, forKey: .labelerCIDHash) - self.creator = try container.decode(ActorProfileView.self, forKey: .creator) - self.likeCount = try container.decodeIfPresent(Int.self, forKey: .likeCount) - self.viewer = try container.decodeIfPresent(LabelerViewerState.self, forKey: .viewer) - self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue - self.labels = try container.decodeIfPresent([Label].self, forKey: .labels) - } - - public func encode(to encoder: any Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self.labelerURI, forKey: .labelerURI) - try container.encode(self.labelerCIDHash, forKey: .labelerCIDHash) - try container.encode(self.creator, forKey: .creator) - - // Assuming `likeCount` is not nil, only encode it if it's 0 or higher - if let likeCount = self.likeCount, likeCount >= 0 { - try container.encode(likeCount, forKey: .likeCount) - } - try container.encodeIfPresent(self.viewer, forKey: .viewer) - try container.encode(self._indexedAt, forKey: .indexedAt) - try container.encodeIfPresent(self.labels, forKey: .labels) - } - - enum CodingKeys: String, CodingKey { - case labelerURI = "uri" - case labelerCIDHash = "cid" - case creator - case likeCount - case viewer - case indexedAt - case labels - } -} - -/// A data model definition for a detailed labeler view. -/// -/// - SeeAlso: This is based on the [`app.bsky.labeler.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/labeler/defs.json -public struct LabelerViewDetailed: Codable { - /// The URI of the labeler. - public let labelerURI: String - /// The CID hash of the labeler. - public let labelerCIDHash: String - /// The creator of the labeler. - public let creator: ActorProfileView - /// A list of policies by the labeler. - public let policies: LabelerPolicies - /// The number of likes for the labeler. Optional. - public let likeCount: Int? - /// The viewer state of the labeler. Optional. - public let viewer: LabelerViewerState? - /// The date and time the labeler was last indexed. - @DateFormatting public var indexedAt: Date - /// An array of labels. Optional. - public let labels: [Label]? - - public init(labelerURI: String, labelerCIDHash: String, creator: ActorProfileView, policies: LabelerPolicies, likeCount: Int?, viewer: LabelerViewerState?, indexedAt: Date, labels: [Label]?) { - self.labelerURI = labelerURI - self.labelerCIDHash = labelerCIDHash - self.creator = creator - self.policies = policies - self.likeCount = likeCount - self.viewer = viewer - self._indexedAt = DateFormatting(wrappedValue: indexedAt) - self.labels = labels - } - - public init(from decoder: any Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.labelerURI = try container.decode(String.self, forKey: .labelerURI) - self.labelerCIDHash = try container.decode(String.self, forKey: .labelerCIDHash) - self.creator = try container.decode(ActorProfileView.self, forKey: .creator) - self.policies = try container.decode(LabelerPolicies.self, forKey: .policies) - self.likeCount = try container.decodeIfPresent(Int.self, forKey: .likeCount) - self.viewer = try container.decodeIfPresent(LabelerViewerState.self, forKey: .viewer) - self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue - self.labels = try container.decodeIfPresent([Label].self, forKey: .labels) - } - - public func encode(to encoder: any Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self.labelerURI, forKey: .labelerURI) - try container.encode(self.labelerCIDHash, forKey: .labelerCIDHash) - try container.encode(self.creator, forKey: .creator) - try container.encode(self.policies, forKey: .policies) - - // Assuming `likeCount` is not nil, only encode it if it's 0 or higher - if let likeCount = self.likeCount, likeCount >= 0 { - try container.encode(likeCount, forKey: .likeCount) - } - try container.encodeIfPresent(self.viewer, forKey: .viewer) - try container.encode(self._indexedAt, forKey: .indexedAt) - try container.encodeIfPresent(self.labels, forKey: .labels) - } - - enum CodingKeys: String, CodingKey { - case labelerURI = "uri" - case labelerCIDHash = "cid" - case creator - case policies - case likeCount - case viewer - case indexedAt - case labels - } -} - -/// A data model definition for a user account's view state for the labeler. -/// -/// - SeeAlso: This is based on the [`app.bsky.labeler.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/labeler/defs.json -public struct LabelerViewerState: Codable { - /// The URI of the like record, if the user liked the labeler. - public let like: String -} - -/// A data model definition for a labeler's policies. -/// -/// - SeeAlso: This is based on the [`app.bsky.labeler.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/labeler/defs.json -public struct LabelerPolicies: Codable { - /// An array of the labeler-published values. - /// - /// - Note: According to the AT Protocol specifications: "The label values which this labeler - /// publishes. May include global - /// or custom labels." - public let labelValues: [LabelValue] - /// An array of labeler-created labels. - /// - /// Labels made in here will override global definitions. - /// - /// - Note: According to the AT Protocol specifications: "Label values created by this labeler - /// and scoped exclusively to it. Labels defined here will override global label definitions - /// for this labeler." - public let labelValueDefinitions: [LabelValueDefinition] -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/BskyLabelerGetServices.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/BskyLabelerGetServices.swift deleted file mode 100644 index 9b2ac0c86e..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/BskyLabelerGetServices.swift +++ /dev/null @@ -1,54 +0,0 @@ -// -// BskyLabelerGetServices.swift -// -// -// Created by Christopher Jr Riley on 2024-03-14. -// - -import Foundation - -/// The main data model definition for the output of the labeler service information. -/// -/// - Note: According to the AT Protocol specifications: "Get information about a list of -/// labeler services." -/// -/// - SeeAlso: This is based on the [`app.bsky.labeler.getServices`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/labeler/getServices.json -public struct LabelerGetServicesOutput: Codable { - /// A labeler view. - public let views: LabelerViewUnion -} - -/// A reference containing the list of labeler views. -public enum LabelerViewUnion: Codable { - /// A labeler view. - case labelerView(LabelerView) - /// A detailed view of a labeler. - case labelerViewDetailed(LabelerViewDetailed) - - public init(from decoder: any Decoder) throws { - let container = try decoder.singleValueContainer() - - if let value = try? container.decode(LabelerView.self) { - self = .labelerView(value) - } else if let value = try? container.decode(LabelerViewDetailed.self) { - self = .labelerViewDetailed(value) - } else { - throw DecodingError.typeMismatch( - ActorPreferenceUnion.self, DecodingError.Context( - codingPath: decoder.codingPath, debugDescription: "Unknown LabelerViewUnion type")) - } - } - - public func encode(to encoder: any Encoder) throws { - var container = encoder.singleValueContainer() - - switch self { - case .labelerView(let labelerView): - try container.encode(labelerView) - case .labelerViewDetailed(let labelerViewDetailed): - try container.encode(labelerViewDetailed) - } - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/BskyLabelerService.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/BskyLabelerService.swift deleted file mode 100644 index ee2fa1415e..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Labeler/BskyLabelerService.swift +++ /dev/null @@ -1,59 +0,0 @@ -// -// BskyLabelerService.swift -// -// -// Created by Christopher Jr Riley on 2024-03-14. -// - -import Foundation - -/// The main data model definition for a labeler service record. -/// -/// - Note: According to the AT Protocol specifications: "A declaration of the existence of -/// labeler service." -/// -/// - SeeAlso: This is based on the [`app.bsky.labeler.service`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/labeler/service.json -public struct LabelerService: ATRecordProtocol { - /// The identifier of the lexicon. - /// - /// - Warning: The value must not change. - public static private(set) var type: String = "app.bsky.labeler.service" - /// The policies the labeler service adheres to. - public let policies: LabelerPolicies - /// An array of labels the labeler uses. Optional. - public let labels: [SelfLabels]? - /// The date and time the labeler service was created. - @DateFormatting public var createdAt: Date - - public init(policies: LabelerPolicies, labels: [SelfLabels], createdAt: Date) { - self.policies = policies - self.labels = labels - self._createdAt = DateFormatting(wrappedValue: createdAt) - } - - public init(from decoder: any Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.policies = try container.decode(LabelerPolicies.self, forKey: .policies) - self.labels = try container.decode([SelfLabels].self, forKey: .labels) - self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue - } - - public func encode(to encoder: any Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - -// try container.encode(self.type, forKey: .type) - try container.encode(self.policies, forKey: .policies) - try container.encode(self.labels, forKey: .labels) - try container.encode(self._createdAt, forKey: .createdAt) - } - - enum CodingKeys: String, CodingKey { - case type = "$type" - case policies - case labels - case createdAt - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/BaskyNotificationUpdateSeen.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/BaskyNotificationUpdateSeen.swift deleted file mode 100644 index 3b22e10483..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/BaskyNotificationUpdateSeen.swift +++ /dev/null @@ -1,40 +0,0 @@ -// -// BaskyNotificationUpdateSeen.swift -// -// -// Created by Christopher Jr Riley on 2024-03-15. -// - -import Foundation - -/// The main data model definition for updating the server of the user seeing the notification. -/// -/// - Note: According to the AT Protocol specifications: "Notify server that the requesting account -/// has seen notifications. Requires auth." -/// -/// - SeeAlso: This is based on the [`app.bsky.notification.updateSeen`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/notification/updateSeen.json -public struct NotificationUpdateSeen: Codable { - @DateFormatting public var seenAt: Date - - public init(seenAt: Date) { - self._seenAt = DateFormatting(wrappedValue: seenAt) - } - - public init(from decoder: any Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.seenAt = try container.decode(DateFormatting.self, forKey: .seenAt).wrappedValue - } - - public func encode(to encoder: any Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self._seenAt, forKey: .seenAt) - } - - enum CodingKeys: CodingKey { - case seenAt - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/BskyNotificationGetUnreadCount.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/BskyNotificationGetUnreadCount.swift deleted file mode 100644 index 66cdcfb820..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/BskyNotificationGetUnreadCount.swift +++ /dev/null @@ -1,20 +0,0 @@ -// -// BskyNotificationGetUnreadCount.swift -// -// -// Created by Christopher Jr Riley on 2024-03-15. -// - -import Foundation - -/// The main data model definition for the output of counting the unread notifications. -/// -/// - Note: According to the AT Protocol specifications: "Count the number of unread -/// notifications for the requesting account. Requires auth." -/// -/// - SeeAlso: This is based on the [`app.bsky.notification.getUnreadCount`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/notification/getUnreadCount.json -public struct NotificationGetUnreadCountOutput: Codable { - public let count: Int -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/BskyNotificationListNotifications.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/BskyNotificationListNotifications.swift deleted file mode 100644 index dd3bd83f71..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/BskyNotificationListNotifications.swift +++ /dev/null @@ -1,115 +0,0 @@ -// -// BskyNotificationListNotifications.swift -// -// -// Created by Christopher Jr Riley on 2024-03-15. -// - -import Foundation - -/// The main data model definition for the output of listing notifications. -/// -/// - Note: According to the AT Protocol specifications: "Enumerate notifications for the -/// requesting account. Requires auth." -/// -/// - SeeAlso: This is based on the [`app.bsky.notification.listNotifications`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/notification/listNotifications.json -public struct NotificationListNotificationsOutput: Codable { - /// The mark used to indicate the starting point for the next set of results. Optional. - public let cursor: String? - /// An array of notifications. - public let notifications: [ATNotification] -} - -/// A data model definition for a notification. -/// -/// - SeeAlso: This is based on the [`app.bsky.notification.listNotifications`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/notification/listNotifications.json -public struct ATNotification: Codable { - /// The URI of the notification. - public let notificationURI: String - /// The CID hash of the notification. - public let notificationCID: String - /// The author of the record contained in the notification. - public let notificationAuthor: String - /// The type of notification received. - /// - /// - Note: According to the AT Protocol specifications: "Expected values are 'like', 'repost', - /// 'follow', 'mention', 'reply', and 'quote'." - public let notificationReason: Reason - /// The URI of the subject in the notification. Optional. - public let reasonSubjectURI: String? - /// The record itself that's attached to the notification. - public let record: UnknownType - /// Indicates whether or not this notification was read. - public let isRead: Bool - /// The date and time the notification was last indexed. - @DateFormatting public var indexedAt: Date - /// An array of labels. Optional. - public let labels: [Label]? - - public init(notificationURI: String, notificationCID: String, notificationAuthor: String, notificationReason: Reason, reasonSubjectURI: String, - record: UnknownType, isRead: Bool, indexedAt: Date, labels: [Label]) { - self.notificationURI = notificationURI - self.notificationCID = notificationCID - self.notificationAuthor = notificationAuthor - self.notificationReason = notificationReason - self.reasonSubjectURI = reasonSubjectURI - self.record = record - self.isRead = isRead - self._indexedAt = DateFormatting(wrappedValue: indexedAt) - self.labels = labels - } - - public init(from decoder: any Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.notificationURI = try container.decode(String.self, forKey: .notificationURI) - self.notificationCID = try container.decode(String.self, forKey: .notificationCID) - self.notificationAuthor = try container.decode(String.self, forKey: .notificationAuthor) - self.notificationReason = try container.decode(ATNotification.Reason.self, forKey: .notificationReason) - self.reasonSubjectURI = try container.decodeIfPresent(String.self, forKey: .reasonSubjectURI) - self.record = try container.decode(UnknownType.self, forKey: .record) - self.isRead = try container.decode(Bool.self, forKey: .isRead) - self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue - self.labels = try container.decodeIfPresent([Label].self, forKey: .labels) - } - - public func encode(to encoder: any Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self.notificationURI, forKey: .notificationURI) - try container.encode(self.notificationCID, forKey: .notificationCID) - try container.encode(self.notificationAuthor, forKey: .notificationAuthor) - try container.encode(self.notificationReason, forKey: .notificationReason) - try container.encodeIfPresent(self.reasonSubjectURI, forKey: .reasonSubjectURI) - try container.encode(self.record, forKey: .record) - try container.encode(self.isRead, forKey: .isRead) - try container.encode(self._indexedAt, forKey: .indexedAt) - try container.encodeIfPresent(self.labels, forKey: .labels) - } - - enum CodingKeys: String, CodingKey { - case notificationURI = "uri" - case notificationCID = "cid" - case notificationAuthor = "author" - case notificationReason = "reason" - case reasonSubjectURI = "reasonSubject" - case record - case isRead - case indexedAt - case labels - } - - // Enums - public enum Reason: String, Codable { - case like - case repost - case follow - case mention - case reply - case quote - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/BskyNotificationRegisterPush.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/BskyNotificationRegisterPush.swift deleted file mode 100644 index cc564ea41e..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Notification/BskyNotificationRegisterPush.swift +++ /dev/null @@ -1,45 +0,0 @@ -// -// BskyNotificationRegisterPush.swift -// -// -// Created by Christopher Jr Riley on 2024-01-27. -// - -import Foundation - -// MARK: - Main definition -/// The main data model definition for registering push notifications. -/// -/// - Note: According to the AT Protocol specifications: "Register to receive push notifications, -/// via a specified service, for the requesting account. Requires auth." -/// -/// - SeeAlso: This is based on the [`app.bsky.notification.registerPush`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/notification/registerPush.json -public struct RegisterPushRequest: Codable { - /// The decentralized identifier (DID) for the push notification request. - public let serviceDID: String - /// The push notification token. - public let token: String - /// The platform for the push notifications. - public let platform: Platform - /// The app ID for the push notification. - public let appID: String - - /// Represents the platform for the push notifications. - public enum Platform: String, Codable { - /// Indicates iOS as the platform. - case ios - /// Indicates Android as the platform. - case android - /// Indicates the web as the platform. - case web - } - - enum CodingKeys: String, CodingKey { - case serviceDID = "serviceDid" - case token - case platform - case appID = "appId" - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/RichText/AppBskyRichTextFacet.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/RichText/AppBskyRichTextFacet.swift index fb13518323..e84f1db356 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/RichText/AppBskyRichTextFacet.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/RichText/AppBskyRichTextFacet.swift @@ -23,9 +23,9 @@ extension AppBskyLexicon.RichText { public let index: ByteSlice /// The facet's feature type. - public let features: [FeatureUnion] + public let features: [ATUnion.FacetFeatureUnion] - public init(index: ByteSlice, features: [FeatureUnion]) { + public init(index: ByteSlice, features: [ATUnion.FacetFeatureUnion]) { self.index = index self.features = features } @@ -34,7 +34,7 @@ extension AppBskyLexicon.RichText { let container = try decoder.container(keyedBy: CodingKeys.self) self.index = try container.decode(ByteSlice.self, forKey: .index) - self.features = try container.decode([FeatureUnion].self, forKey: .features) + self.features = try container.decode([ATUnion.FacetFeatureUnion].self, forKey: .features) } public func encode(to encoder: Encoder) throws { diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/RichText/BskyRichTextFacet.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/RichText/BskyRichTextFacet.swift deleted file mode 100644 index 7bcd169dc3..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/RichText/BskyRichTextFacet.swift +++ /dev/null @@ -1,270 +0,0 @@ -// -// BskyRichTextFacet.swift -// -// -// Created by Christopher Jr Riley on 2024-01-25. -// - -import Foundation - -// MARK: - Main definition -/// The main data model definition for a facet. -/// -/// - Note: According to the AT Protocol specifications: "Annotation of a sub-string within -/// rich text." -/// -/// - SeeAlso: This is based on the [`app.bsky.richtext.facet`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/richtext/facet.json -public struct Facet: Codable { - /// The range of characters related to the facet. - public let index: ByteSlice - /// The facet's feature type. - public let features: [FeatureUnion] - - public init(index: ByteSlice, features: [FeatureUnion]) { - self.index = index - self.features = features - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.index = try container.decode(ByteSlice.self, forKey: .index) - self.features = try container.decode([FeatureUnion].self, forKey: .features) - } - - public func encode(to encoder: Encoder) throws { - - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self.index, forKey: .index) - try container.encode(self.features, forKey: .features) - } - - enum CodingKeys: String, CodingKey { - case index - case features - } -} - -// Represents the ByteSlice -/// The data model definition for the byte slice. -/// -/// - Note: According to the AT Protocol specifications: "Specifies the sub-string range a facet -/// feature applies to. Start index is inclusive, end index is exclusive. Indices are zero-indexed, -/// counting bytes of the UTF-8 encoded text. NOTE: some languages, like Javascript, use -/// UTF-16 or Unicode codepoints for string slice indexing; in these languages, convert to byte -/// arrays before working with facets." -/// -/// - SeeAlso: This is based on the [`app.bsky.richtext.facet`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/richtext/facet.json -public struct ByteSlice: Codable { - /// The start index of the byte slice. - public let byteStart: Int - /// The end index of the byte slice. - public let byteEnd: Int - - public init(byteStart: Int, byteEnd: Int) { - self.byteStart = byteStart - self.byteEnd = byteEnd - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - self.byteStart = try container.decode(Int.self, forKey: .byteStart) - self.byteEnd = try container.decode(Int.self, forKey: .byteEnd) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(self.byteStart, forKey: .byteStart) - try container.encode(self.byteEnd, forKey: .byteEnd) - } - - enum CodingKeys: String, CodingKey { - case byteStart - case byteEnd - } -} - -/// A data model protocol for Features. -/// -/// - SeeAlso: This is based on the [`app.bsky.richtext.facet`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/richtext/facet.json -internal protocol FeatureCodable: Codable { - /// The identifier of the lexicon. - /// - /// - Warning: The value must not change. - static var type: String { get } -} - - -/// A data model for the Mention feature definition. -/// -/// - Note: According to the AT Protocol specifications: "Facet feature for mention of -/// another account. The text is usually a handle, including a '@' prefix, but the facet -/// reference is a DID." -/// -/// - SeeAlso: This is based on the [`app.bsky.richtext.facet`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/richtext/facet.json -public struct Mention: FeatureCodable { - /// The decentralized identifier (DID) of the feature. - public let did: String - /// The identifier of the lexicon. - /// - /// - Warning: The value must not change. - static public var type: String = "app.bsky.richtext.facet#mention" - - public init(did: String) { - self.did = did - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.did = try container.decode(String.self, forKey: .did) - Mention.type = try container.decode(String.self, forKey: .type) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self.did, forKey: .did) - try container.encode(Mention.type, forKey: .type) - } - - enum CodingKeys: String, CodingKey { - case type = "$type" - case did - } -} - - -/// A data model for the Link feature definition. -/// -/// - Note: According to the AT Protocol specifications: "Facet feature for a URL. The text URL -/// may have been simplified or truncated, but the facet reference should be a complete URL." -/// -/// - SeeAlso: This is based on the [`app.bsky.richtext.facet`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/richtext/facet.json -public struct Link: FeatureCodable { - /// The URI of the feature. - public let uri: String - /// The identifier of the lexicon. - /// - /// - Warning: The value must not change. - static public var type: String = "app.bsky.richtext.facet#link" - - public init(uri: String) { - self.uri = uri - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.uri = try container.decode(String.self, forKey: .uri) - Link.type = try container.decode(String.self, forKey: .type) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self.uri, forKey: .uri) - try container.encode(Link.type, forKey: .type) - } - - enum CodingKeys: String, CodingKey { - case type = "$type" - case uri - } -} - -/// A data model for the Tag feature definition. -/// -/// - Note: According to the AT Protocol specifications: "Facet feature for a hashtag. The text -/// usually includes a '#' prefix, but the facet reference should not (except in the case of -/// 'double hash tags')." -/// -/// - SeeAlso: This is based on the [`app.bsky.richtext.facet`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/richtext/facet.json -public struct Tag: FeatureCodable { - /// The - public let tag: String - /// The identifier of the lexicon. - /// - /// - Warning: The value must not change. - static public var type: String = "app.bsky.richtext.facet#tag" - - public init(tag: String) { - self.tag = tag - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.tag = try container.decode(String.self, forKey: .tag) - Tag.type = try container.decode(String.self, forKey: .type) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self.tag, forKey: .tag) - try container.encode(Tag.type, forKey: .type) - } - - enum CodingKeys: String, CodingKey { - case type = "$type" - case tag - } -} - -// MARK: - Union types -/// A reference containing the list of feature types. -/// -/// - SeeAlso: This is based on the [`app.bsky.richtext.facet`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/richtext/facet.json -public enum FeatureUnion: Codable { - /// The Mention feature. - case mention(Mention) - /// The Link feature. - case link(Link) - /// The Tag feature. - case tag(Tag) - - public init(from decoder: Decoder) throws { - let container = try decoder.singleValueContainer() - - if let value = try? container.decode(Mention.self) { - self = .mention(value) - } else if let value = try? container.decode(Link.self) { - self = .link(value) - } else if let value = try? container.decode(Tag.self) { - self = .tag(value) - } else { - throw DecodingError.typeMismatch( - FeatureUnion.self, DecodingError.Context( - codingPath: decoder.codingPath, debugDescription: "Unknown FeatureUnion type")) - } - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - - switch self { - case .mention(let feature): - try container.encode(feature) - case .link(let feature): - try container.encode(feature) - case .tag(let feature): - try container.encode(feature) - } - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/BskyUnspeccedDefs.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/BskyUnspeccedDefs.swift deleted file mode 100644 index 7993fea9d1..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/BskyUnspeccedDefs.swift +++ /dev/null @@ -1,42 +0,0 @@ -// -// BskyUnspeccedDefs.swift -// -// -// Created by Christopher Jr Riley on 2024-03-17. -// - -import Foundation - -/// A data model definition for a skeleton search post. -/// -/// - Important: This is an unspecced model, and as such, this is highly volatile and may change -/// or be removed at any time. Use at your own risk. -/// -/// - SeeAlso: This is based on the [`app.bsky.unspecced.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/unspecced/defs.json -public struct UnspeccedSkeletonSearchPost: Codable { - /// The URI of the skeleton search post. - public let postURI: String - - enum CodingKeys: String, CodingKey { - case postURI = "uri" - } -} - -/// A data model definition for a skeleton search post. -/// -/// - Important: This is an unspecced model, and as such, this is highly volatile and may change -/// or be removed at any time. Use at your own risk. -/// -/// - SeeAlso: This is based on the [`app.bsky.unspecced.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/unspecced/defs.json -public struct UnspeccedSkeletonSearchActor: Codable { - /// The URI of the skeleton search actor. - public let actorDID: String - - enum CodingKeys: String, CodingKey { - case actorDID = "did" - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/BskyUnspeccedGetPopularFeedGenerators.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/BskyUnspeccedGetPopularFeedGenerators.swift deleted file mode 100644 index 8de29952af..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/BskyUnspeccedGetPopularFeedGenerators.swift +++ /dev/null @@ -1,26 +0,0 @@ -// -// BskyUnspeccedGetPopularFeedGenerators.swift -// -// -// Created by Christopher Jr Riley on 2024-03-17. -// - -import Foundation - -/// The main data model definition for the output of globally popular feed generators. -/// -/// - Note: According to the AT Protocol specifications: "An unspecced view of globally -/// popular feed generators." -/// -/// - Important: This is an unspecced model, and as such, this is highly volatile and may change -/// or be removed at any time. Use at your own risk. -/// -/// - SeeAlso: This is based on the [`app.bsky.unspecced.getPopularFeedGenerators`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/unspecced/getPopularFeedGenerators.json -public struct UnspeccedGetPopularFeedGeneratorsOutput: Codable { - /// The mark used to indicate the starting point for the next set of result. Optional. - public let cursor: String? - /// An array of feed generators. - public let feeds: [FeedGeneratorView] -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/BskyUnspeccedGetSuggestionsSkeleton.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/BskyUnspeccedGetSuggestionsSkeleton.swift deleted file mode 100644 index a7a3428846..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/BskyUnspeccedGetSuggestionsSkeleton.swift +++ /dev/null @@ -1,26 +0,0 @@ -// -// BskyUnspeccedGetSuggestionsSkeleton.swift -// -// -// Created by Christopher Jr Riley on 2024-04-16. -// - -import Foundation - -/// The main data model definition for getting a skeleton of suggestion of actors. -/// -/// - Note: According to the AT Protocol specifications: "Get a skeleton of suggested actors. -/// Intended to be called and then hydrated through app.bsky.actor.getSuggestions." -/// -/// - Important: This is an unspecced model, and as such, this is highly volatile and may change -/// or be removed at any time. Use at your own risk. -/// -/// - SeeAlso: This is based on the [`app.bsky.unspecced.getSuggestionsSkeleton`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/unspecced/getSuggestionsSkeleton.json -public struct UnspeccedGetSuggestionsSkeletonOutput: Codable { - /// The mark used to indicate the starting point for the next set of results. Optional. - public let cursor: String? - /// An array of actors. - public let actors: [UnspeccedSkeletonSearchActor] -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/BskyUnspeccedGetTaggedSuggestions.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/BskyUnspeccedGetTaggedSuggestions.swift deleted file mode 100644 index 71c607909e..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/BskyUnspeccedGetTaggedSuggestions.swift +++ /dev/null @@ -1,78 +0,0 @@ -// -// BskyUnspeccedGetTaggedSuggestions.swift -// -// -// Created by Christopher Jr Riley on 2024-03-17. -// - -import Foundation - -/// The main data model definition for the output of getting tagged suggestions. -/// -/// - Note: According to the AT Protocol specifications: "Get a list of suggestions (feeds -/// and users) tagged with categories." -/// -/// - Important: This is an unspecced model, and as such, this is highly volatile and may change -/// or be removed at any time. Use at your own risk. -/// -/// - SeeAlso: This is based on the [`app.bsky.unspecced.getTaggedSuggestions`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/unspecced/getTaggedSuggestions.json -public struct UnspeccedGetTaggedSuggestionsOutput: Codable { - /// An array of suggestions. - public let suggestions: [TaggedSuggestion] -} - -/// A data model for a tagged suggestion. -/// -/// - Important: This is an unspecced model, and as such, this is highly volatile and may change -/// or be removed at any time. Use at your own risk. -/// -/// - SeeAlso: This is based on the [`app.bsky.unspecced.getTaggedSuggestions`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/unspecced/getTaggedSuggestions.json -public struct TaggedSuggestion: Codable { - /// The tag attached to the suggestion. - public let tag: String - /// Indicates whether the suggestion is a feed generator or actor (user). - public let subjectType: SubjectType - /// The URI of the suggestion. - public let subjectURI: String - - public init(tag: String, subjectType: SubjectType, subjectURI: String) { - self.tag = tag - self.subjectType = subjectType - self.subjectURI = subjectURI - } - - public init(from decoder: any Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.tag = try container.decode(String.self, forKey: .tag) - self.subjectType = try container.decode(TaggedSuggestion.SubjectType.self, forKey: .subjectType) - self.subjectURI = try container.decode(String.self, forKey: .subjectURI) - } - - public func encode(to encoder: any Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self.tag, forKey: .tag) - try container.encode(self.subjectType, forKey: .subjectType) - try container.encode(self.subjectURI, forKey: .subjectURI) - } - - enum CodingKeys: String, CodingKey { - case tag - case subjectType - case subjectURI = "subject" - } - - // Enums - /// Indicates whether the subject of the suggestion is a feed generator or an actor (user). - public enum SubjectType: String, Codable { - /// Indicates the subject of the suggestion is an actor (user). - case actor - /// Indicates the subject of the suggestion is a feed generator. - case feed - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/BskyUnspeccedSearchActorsSkeleton.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/BskyUnspeccedSearchActorsSkeleton.swift deleted file mode 100644 index c90c520769..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/BskyUnspeccedSearchActorsSkeleton.swift +++ /dev/null @@ -1,34 +0,0 @@ -// -// BskyUnspeccedSearchActorsSkeleton.swift -// -// -// Created by Christopher Jr Riley on 2024-03-17. -// - -import Foundation - -/// The main data model definition for the output of retrieving the skeleton results of actors (users). -/// -/// - Important: This is an unspecced model, and as such, this is highly volatile and may change -/// or be removed at any time. Use at your own risk. -/// -/// - Note: According to the AT Protocol specifications: "Backend Actors (profile) search, returns -/// only skeleton." -/// -/// - SeeAlso: This is based on the [`app.bsky.unspecced.searchActorsSkeleton`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/unspecced/searchActorsSkeleton.json -public struct UnspeccedSearchActorsSkeletonOutput: Codable { - /// The mark used to indicate the starting point for the next set of result. Optional. - public let cursor: String? - /// The number of search results. - /// - /// This number may not be completely reliable, as it can be rounded or truncated. This number - /// doesn't reflect all of the possible actors that can be seen. - /// - /// - Note: According to the AT Protocol specifications: "Count of search hits. Optional, may - /// be rounded/truncated, and may not be possible to paginate through all hits." - public let hitsTotal: Int? - /// An array of actors. - public let actors: [UnspeccedSkeletonSearchActor] -} diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/BskyUnspeccedSearchPostsSkeleton.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/BskyUnspeccedSearchPostsSkeleton.swift deleted file mode 100644 index 0b4bc5efeb..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Unspecced/BskyUnspeccedSearchPostsSkeleton.swift +++ /dev/null @@ -1,46 +0,0 @@ -// -// BskyUnspeccedSearchPostsSkeleton.swift -// -// -// Created by Christopher Jr Riley on 2024-03-17. -// - -import Foundation - -/// The main data model definition for the output of retrieving the skeleton results of posts. -/// -/// - Important: This is an unspecced model, and as such, this is highly volatile and may change -/// or be removed at any time. Use at your own risk. -/// -/// - Note: According to the AT Protocol specifications: "Backend Posts search, returns -/// only skeleton." -/// -/// - SeeAlso: This is based on the [`app.bsky.unspecced.searchPostsSkeleton`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/unspecced/searchPostsSkeleton.json -public struct UnspeccedSearchPostsSkeletonOutput: Codable { - /// The mark used to indicate the starting point for the next set of result. Optional. - public let cursor: String? - /// The number of search results. - /// - /// This number may not be completely reliable, as it can be rounded or truncated. This number - /// doesn't reflect all of the possible posts that can be seen. - /// - /// - Note: According to the AT Protocol specifications: "Count of search hits. Optional, may - /// be rounded/truncated, and may not be possible to paginate through all hits." - public let hitsTotal: Int? - /// An array of posts. - public let posts: [UnspeccedSkeletonSearchPost] -} - -/// Determines the ranking order for the search results. -/// -/// - Note: According to the AT Protocol specifications: "Specifies the ranking order of results." -/// -/// - SeeAlso: This is based on the [`app.bsky.unspecced.searchPostsSkeleton`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/unspecced/searchPostsSkeleton.json -public enum UnspeccedSearchPostsSortRanking: String { - case top - case latest -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminDefs.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminDefs.swift deleted file mode 100644 index 1e2e41c054..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminDefs.swift +++ /dev/null @@ -1,599 +0,0 @@ -// -// AtprotoAdminDefs.swift -// -// -// Created by Christopher Jr Riley on 2024-01-25. -// - -import Foundation - -/// The main data model definition for admin status attributes. -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/defs.json -public struct AdminStatusAttributes: Codable { - /// Indicates whether the status attributes are being applied. - public let isApplied: Bool - /// The reference of the attributes. - public let reference: String? = nil - - enum CodingKeys: String, CodingKey { - case isApplied = "applied" - case reference = "ref" - } -} - -/// A data model for a report view definition. -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/defs.json -public struct AdminReportView: Codable { - /// The ID of the report. - public let id: Int - /// The reason for the report. - public let reasonType: ModerationReasonType - /// The additional comment provided for a report. Optional. - public let comment: String? = nil - /// The handle of the subject who's related to the report. Optional. - public let subjectRepoHandle: String? = nil - /// The subject reference of the report. - public let subject: RepositoryReferencesUnion - /// The user who created the report. - public let reportedBy: String - /// The date and time the report was created. - @DateFormatting public var createdAt: Date - /// An array of action IDs that relate to resolutions. - public let resolvedByActionIDs: [Int] - - public init(id: Int, reasonType: ModerationReasonType, subject: RepositoryReferencesUnion, reportedBy: String, createdAt: Date, - resolvedByActionIDs: [Int]) { - self.id = id - self.reasonType = reasonType - self.subject = subject - self.reportedBy = reportedBy - self._createdAt = DateFormatting(wrappedValue: createdAt) - self.resolvedByActionIDs = resolvedByActionIDs - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.id = try container.decode(Int.self, forKey: .id) - self.reasonType = try container.decode(ModerationReasonType.self, forKey: .reasonType) - self.subject = try container.decode(RepositoryReferencesUnion.self, forKey: .subject) - self.reportedBy = try container.decode(String.self, forKey: .reportedBy) - self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue - self.resolvedByActionIDs = try container.decode([Int].self, forKey: .resolvedByActionIDs) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self.id, forKey: .id) - try container.encode(self.reasonType, forKey: .reasonType) - try container.encodeIfPresent(self.comment, forKey: .comment) - try container.encodeIfPresent(self.subjectRepoHandle, forKey: .subjectRepoHandle) - try container.encode(self.subject, forKey: .subject) - try container.encode(self.reportedBy, forKey: .reportedBy) - try container.encode(self._createdAt, forKey: .createdAt) - try container.encode(self.resolvedByActionIDs, forKey: .resolvedByActionIDs) - } - - enum CodingKeys: String, CodingKey { - case id - case reasonType - case comment - case subjectRepoHandle - case subject - case reportedBy - case createdAt - case resolvedByActionIDs = "resolvedByActionIds" - } -} - -/// A data model for a detailed report view definition. -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/defs.json -public struct AdminReportViewDetail: Codable { - /// The ID of a report. - public let id: Int - /// The reason for the report. - public let reasonType: ModerationReasonType - /// Any additional comments about the report. Optional. - public var comment: String? = nil - /// The subject of the report. - /// - /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ - /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ - /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ - /// \ - /// Clarifications from Bluesky are needed in order to fully understand this item. - public let subject: RepositoryViewUnion - /// The status for the subject of the report. Optional. - /// - /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ - /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ - /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ - /// \ - /// Clarifications from Bluesky are needed in order to fully understand this item. - public var subjectStatus: OzoneSubjectStatusView? = nil - /// The user who created the report. - public let reportedBy: String - /// The date and time the report was created. - @DateFormatting public var createdAt: Date - /// An array of resolved actions made in relation to the report. - public let resolvedByActions: [OzoneModerationEventView] - - public init(id: Int, reasonType: ModerationReasonType, comment: String? = nil, subject: RepositoryViewUnion, subjectStatus: OzoneSubjectStatusView? = nil, - reportedBy: String, createdAt: Date, resolvedByActions: [OzoneModerationEventView]) { - self.id = id - self.reasonType = reasonType - self.comment = comment - self.subject = subject - self.subjectStatus = subjectStatus - self.reportedBy = reportedBy - self._createdAt = DateFormatting(wrappedValue: createdAt) - self.resolvedByActions = resolvedByActions - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.id = try container.decode(Int.self, forKey: .id) - self.reasonType = try container.decode(ModerationReasonType.self, forKey: .reasonType) - self.comment = try container.decodeIfPresent(String.self, forKey: .comment) - self.subject = try container.decode(RepositoryViewUnion.self, forKey: .subject) - self.subjectStatus = try container.decodeIfPresent(OzoneSubjectStatusView.self, forKey: .subjectStatus) - self.reportedBy = try container.decode(String.self, forKey: .reportedBy) - self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue - self.resolvedByActions = try container.decode([OzoneModerationEventView].self, forKey: .resolvedByActions) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self.id, forKey: .id) - try container.encode(self.reasonType, forKey: .reasonType) - try container.encodeIfPresent(self.comment, forKey: .comment) - try container.encode(self.subject, forKey: .subject) - try container.encodeIfPresent(self.subjectStatus, forKey: .subjectStatus) - try container.encode(self.reportedBy, forKey: .reportedBy) - try container.encode(self._createdAt, forKey: .createdAt) - try container.encode(self.resolvedByActions, forKey: .resolvedByActions) - } - - enum CodingKeys: CodingKey { - case id - case reasonType - case comment - case subject - case subjectStatus - case reportedBy - case createdAt - case resolvedByActions - } -} - -/// A data model for a definition of an account view. -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/defs.json -public struct AdminAccountView: Codable { - /// The decentralized identifier (DID) of the user. - public let actorDID: String - /// The handle of the user. - public let handle: String - /// The email of the user. Optional. - public var email: String? = nil - /// The user's related records. Optional. - /// - /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ - /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ - /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ - /// \ - /// Clarifications from Bluesky are needed in order to fully understand this item. - public var relatedRecords: [UnknownType]? = nil - /// The date and time the user was last indexed. - @DateFormatting public var indexedAt: Date - /// The invite code used by the user to sign up. Optional. - public var invitedBy: ServerInviteCode? = nil - /// An array of invite codes held by the user. Optional. - public var invites: [ServerInviteCode]? = nil - /// Indicates whether the invite codes held by the user are diabled. Optional. - public var areInvitesDisabled: Bool? = nil - /// The date and time the email of the user was confirmed. Optional. - @DateFormattingOptional public var emailConfirmedAt: Date? = nil - /// Any notes related to inviting the user. Optional. - public var inviteNote: String? = nil - - public init(actorDID: String, handle: String, email: String?, relatedRecords: [UnknownType]?, indexedAt: Date, invitedBy: ServerInviteCode?, - invites: [ServerInviteCode]?, areInvitesDisabled: Bool?, emailConfirmedAt: Date? = nil, inviteNote: String?) { - self.actorDID = actorDID - self.handle = handle - self.email = email - self.relatedRecords = relatedRecords - self._indexedAt = DateFormatting(wrappedValue: indexedAt) - self.invitedBy = invitedBy - self.invites = invites - self.areInvitesDisabled = areInvitesDisabled - self._emailConfirmedAt = DateFormattingOptional(wrappedValue: emailConfirmedAt) - self.inviteNote = inviteNote - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.actorDID = try container.decode(String.self, forKey: .actorDID) - self.handle = try container.decode(String.self, forKey: .handle) - self.email = try container.decodeIfPresent(String.self, forKey: .email) - self.relatedRecords = try container.decodeIfPresent([UnknownType].self, forKey: .relatedRecords) - self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue - self.invitedBy = try container.decodeIfPresent(ServerInviteCode.self, forKey: .invitedBy) - self.invites = try container.decodeIfPresent([ServerInviteCode].self, forKey: .invites) - self.areInvitesDisabled = try container.decodeIfPresent(Bool.self, forKey: .areInvitesDisabled) - self.emailConfirmedAt = try container.decodeIfPresent(DateFormattingOptional.self, forKey: .emailConfirmedAt)?.wrappedValue - self.inviteNote = try container.decodeIfPresent(String.self, forKey: .inviteNote) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self.actorDID, forKey: .actorDID) - try container.encode(self.handle, forKey: .handle) - try container.encodeIfPresent(self.email, forKey: .email) - try container.encodeIfPresent(self.relatedRecords, forKey: .relatedRecords) - try container.encode(self._indexedAt, forKey: .indexedAt) - try container.encodeIfPresent(self.invitedBy, forKey: .invitedBy) - try container.encodeIfPresent(self.invites, forKey: .invites) - try container.encodeIfPresent(self.areInvitesDisabled, forKey: .areInvitesDisabled) - try container.encode(self._emailConfirmedAt, forKey: .emailConfirmedAt) - try container.encodeIfPresent(self.inviteNote, forKey: .inviteNote) - } - - enum CodingKeys: String, CodingKey { - case actorDID = "did" - case handle - case email - case relatedRecords - case indexedAt - case invitedBy - case invites - case areInvitesDisabled = "invitesDisabled" - case emailConfirmedAt - case inviteNote - } -} - -/// A data model for a definition of a repository reference. -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/defs.json -public struct AdminRepositoryReference: Codable { - /// The decentralized identifier (DID) of the repository. - public let repositoryDID: String - - enum CodingKeys: String, CodingKey { - case repositoryDID = "did" - } -} - -/// A data model for a blob reference definition. -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/defs.json -public struct AdminRepoBlobReference: Codable { - /// The decentralized identifier (DID) of the blob reference. - public let blobDID: String - /// The CID hash of the blob reference. - public let cidHash: String - /// The URI of the record that contains the blob reference. - public let recordURI: String? - - enum CodingKeys: String, CodingKey { - case blobDID = "did" - case cidHash = "cid" - case recordURI = "recordUri" - } -} - -// MARK: - Union types -/// A reference containing the list of event views. -public enum AdminEventViewUnion: Codable { - /// A takedown event. - case moderationEventTakedown(OzoneModerationEventTakedown) - /// A reverse takedown event. - case moderationEventReverseTakedown(OzoneModerationEventReverseTakedown) - /// A comment event. - case moderationEventComment(OzoneModerationEventComment) - /// A report event. - case moderationEventReport(OzoneModerationEventReport) - /// A label event. - case moderationEventLabel(OzoneModerationEventLabel) - /// An acknowledgement event. - case moderationEventAcknowledge(OzoneModerationEventAcknowledge) - /// An escalation event. - case moderationEventEscalate(OzoneModerationEventEscalate) - /// A mute event. - case moderationEventMute(OzoneModerationEventMute) - /// An unmute event. - case moderationEventUnmute(OzoneModerationEventUnmute) - /// A mute reporter event. - case moderationEventMuteReporter(OzoneModerationEventMuteReporter) - /// An unmute reporter event. - case moderationEventUnmuteReporter(OzoneModerationEventUnmuteReporter) - /// An email event. - case moderationEventEmail(OzoneModerationEventEmail) - /// A resolve appeal event. - case moderationEventResolveAppeal(OzoneModerationEventResolveAppeal) - /// A diversion event. - case moderationEventDivert(OzoneModerationEventDivert) - - public init(from decoder: Decoder) throws { - let container = try decoder.singleValueContainer() - - if let value = try? container.decode(OzoneModerationEventTakedown.self) { - self = .moderationEventTakedown(value) - } else if let value = try? container.decode(OzoneModerationEventReverseTakedown.self) { - self = .moderationEventReverseTakedown(value) - } else if let value = try? container.decode(OzoneModerationEventComment.self) { - self = .moderationEventComment(value) - } else if let value = try? container.decode(OzoneModerationEventReport.self) { - self = .moderationEventReport(value) - } else if let value = try? container.decode(OzoneModerationEventLabel.self) { - self = .moderationEventLabel(value) - } else if let value = try? container.decode(OzoneModerationEventAcknowledge.self) { - self = .moderationEventAcknowledge(value) - } else if let value = try? container.decode(OzoneModerationEventEscalate.self) { - self = .moderationEventEscalate(value) - } else if let value = try? container.decode(OzoneModerationEventMute.self) { - self = .moderationEventMute(value) - } else if let value = try? container.decode(OzoneModerationEventUnmute.self) { - self = .moderationEventUnmute(value) - } else if let value = try? container.decode(OzoneModerationEventMuteReporter.self) { - self = .moderationEventMuteReporter(value) - } else if let value = try? container.decode(OzoneModerationEventUnmuteReporter.self) { - self = .moderationEventUnmuteReporter(value) - } else if let value = try? container.decode(OzoneModerationEventEmail.self) { - self = .moderationEventEmail(value) - } else if let value = try? container.decode(OzoneModerationEventResolveAppeal.self) { - self = .moderationEventResolveAppeal(value) - } else if let value = try? container.decode(OzoneModerationEventDivert.self) { - self = .moderationEventDivert(value) - } else { - throw DecodingError.typeMismatch( - AdminEventViewUnion.self, DecodingError.Context( - codingPath: decoder.codingPath, debugDescription: "Unknown EventViewUnion type")) - } - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - - switch self { - case .moderationEventTakedown(let moderationEventTakedown): - try container.encode(moderationEventTakedown) - case .moderationEventReverseTakedown(let moderationEventReverseTakedown): - try container.encode(moderationEventReverseTakedown) - case .moderationEventComment(let moderationEventComment): - try container.encode(moderationEventComment) - case .moderationEventReport(let moderationEventReport): - try container.encode(moderationEventReport) - case .moderationEventLabel(let moderationEventLabel): - try container.encode(moderationEventLabel) - case .moderationEventAcknowledge(let moderationEventAcknowledge): - try container.encode(moderationEventAcknowledge) - case .moderationEventEscalate(let moderationEventEscalate): - try container.encode(moderationEventEscalate) - case .moderationEventMute(let moderationEventMute): - try container.encode(moderationEventMute) - case .moderationEventUnmute(let moderationEventUnmute): - try container.encode(moderationEventUnmute) - case .moderationEventMuteReporter(let moderationEventMuteReporter): - try container.encode(moderationEventMuteReporter) - case .moderationEventUnmuteReporter(let moderationEventUnmuteReporter): - try container.encode(moderationEventUnmuteReporter) - case .moderationEventEmail(let moderationEventEmail): - try container.encode(moderationEventEmail) - case .moderationEventResolveAppeal(let moderationEventResolveAppeal): - try container.encode(moderationEventResolveAppeal) - case .moderationEventDivert(let moderationEventDivert): - try container.encode(moderationEventDivert) - } - } -} - -// Create the custom init and encode methods. -/// A reference containing the list of repository references. -public enum RepositoryReferencesUnion: Codable { - /// A repository reference. - case repositoryReference(AdminRepositoryReference) - /// A strong reference. - case strongReference(StrongReference) - - public init(from decoder: Decoder) throws { - let container = try decoder.singleValueContainer() - - if let value = try? container.decode(AdminRepositoryReference.self) { - self = .repositoryReference(value) - } else if let value = try? container.decode(StrongReference.self) { - self = .strongReference(value) - } else { - throw DecodingError.typeMismatch( - ActorPreferenceUnion.self, DecodingError.Context( - codingPath: decoder.codingPath, debugDescription: "Unknown RepositoryReferencesUnion type")) - } - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - - switch self { - case .repositoryReference(let repositoryReference): - try container.encode(repositoryReference) - case .strongReference(let strongReference): - try container.encode(strongReference) - } - } -} - -// Create the custom init and encode methods. -/// A reference containing the list of moderator events. -public enum EventViewDetailUnion: Codable { - /// A takedown event. - case moderationEventTakedown(OzoneModerationEventTakedown) - /// A reverse takedown event. - case moderationEventReverseTakedown(OzoneModerationEventReverseTakedown) - /// A comment event. - case moderationEventComment(OzoneModerationEventComment) - /// A report event. - case moderationEventReport(OzoneModerationEventReport) - /// A label event. - case moderationEventLabel(OzoneModerationEventLabel) - /// An acknowledgment event. - case moderationEventAcknowledge(OzoneModerationEventAcknowledge) - /// An escalation event. - case moderationEventEscalate(OzoneModerationEventEscalate) - /// A mute event. - case moderationEventMute(OzoneModerationEventMute) - /// A resolve appeal event. - case moderationEventResolveAppeal(OzoneModerationEventResolveAppeal) - - public init(from decoder: Decoder) throws { - let container = try decoder.singleValueContainer() - - if let value = try? container.decode(OzoneModerationEventTakedown.self) { - self = .moderationEventTakedown(value) - } else if let value = try? container.decode(OzoneModerationEventReverseTakedown.self) { - self = .moderationEventReverseTakedown(value) - } else if let value = try? container.decode(OzoneModerationEventComment.self) { - self = .moderationEventComment(value) - } else if let value = try? container.decode(OzoneModerationEventReport.self) { - self = .moderationEventReport(value) - } else if let value = try? container.decode(OzoneModerationEventLabel.self) { - self = .moderationEventLabel(value) - } else if let value = try? container.decode(OzoneModerationEventAcknowledge.self) { - self = .moderationEventAcknowledge(value) - } else if let value = try? container.decode(OzoneModerationEventEscalate.self) { - self = .moderationEventEscalate(value) - } else if let value = try? container.decode(OzoneModerationEventMute.self) { - self = .moderationEventMute(value) - } else if let value = try? container.decode(OzoneModerationEventResolveAppeal.self) { - self = .moderationEventResolveAppeal(value) - } else { - throw DecodingError.typeMismatch( - ActorPreferenceUnion.self, DecodingError.Context( - codingPath: decoder.codingPath, debugDescription: "Unknown EventViewDetailUnion type")) - } - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - - switch self { - case .moderationEventTakedown(let moderationEventTakedown): - try container.encode(moderationEventTakedown) - case .moderationEventReverseTakedown(let moderationEventDetail): - try container.encode(moderationEventDetail) - case .moderationEventComment(let moderationEventComment): - try container.encode(moderationEventComment) - case .moderationEventReport(let moderationEventReport): - try container.encode(moderationEventReport) - case .moderationEventLabel(let moderationEventLabel): - try container.encode(moderationEventLabel) - case .moderationEventAcknowledge(let moderationEventAcknowledge): - try container.encode(moderationEventAcknowledge) - case .moderationEventEscalate(let moderationEventEscalate): - try container.encode(moderationEventEscalate) - case .moderationEventMute(let moderationEventMute): - try container.encode(moderationEventMute) - case .moderationEventResolveAppeal(let moderationEventResolveAppeal): - try container.encode(moderationEventResolveAppeal) - } - } -} - -// Create the custom init and encode methods. -/// A reference containing the list of the types of repository or record views. -public enum RepositoryViewUnion: Codable { - /// A normal repository view. - case repositoryView(AdminReportView) - /// A repository view that may not have been found. - case repositoryViewNotFound(OzoneModerationRepositoryViewNotFound) - /// A normal record. - case recordView(OzoneModerationRecordView) - /// A record view that may not have been found. - case recordViewNotFound(OzoneModerationRecordViewNotFound) - - public init(from decoder: Decoder) throws { - let container = try decoder.singleValueContainer() - - if let value = try? container.decode(AdminReportView.self) { - self = .repositoryView(value) - } else if let value = try? container.decode(OzoneModerationRepositoryViewNotFound.self) { - self = .repositoryViewNotFound(value) - } else if let value = try? container.decode(OzoneModerationRecordView.self) { - self = .recordView(value) - } else if let value = try? container.decode(OzoneModerationRecordViewNotFound.self) { - self = .recordViewNotFound(value) - } else { - throw DecodingError.typeMismatch( - ActorPreferenceUnion.self, DecodingError.Context( - codingPath: decoder.codingPath, debugDescription: "Unknown RepositoryViewUnion type")) - } - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - - switch self { - case .repositoryView(let repositoryView): - try container.encode(repositoryView) - case .repositoryViewNotFound(let repositoryViewNotFound): - try container.encode(repositoryViewNotFound) - case .recordView(let recordView): - try container.encode(recordView) - case .recordViewNotFound(let recordViewNotFound): - try container.encode(recordViewNotFound) - } - } -} - -/// A reference containing the list of the types of media details. -public enum MediaDetailUnion: Codable { - /// The details for an image. - case mediaImageDetails(OzoneModerationMediaImageDetails) - /// The details for a video. - case mediaVideoDetails(OzoneModerationMediaVideoDetails) - - public init(from decoder: Decoder) throws { - let container = try decoder.singleValueContainer() - - if let value = try? container.decode(OzoneModerationMediaImageDetails.self) { - self = .mediaImageDetails(value) - } else if let value = try? container.decode(OzoneModerationMediaVideoDetails.self) { - self = .mediaVideoDetails(value) - } else { - throw DecodingError.typeMismatch( - ActorPreferenceUnion.self, DecodingError.Context( - codingPath: decoder.codingPath, debugDescription: "Unknown MediaDetailUnion type")) - } - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - - switch self { - case .mediaImageDetails(let mediaImageDetails): - try container.encode(mediaImageDetails) - case .mediaVideoDetails(let mediaVideoDetails): - try container.encode(mediaVideoDetails) - } - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminDeleteAccount.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminDeleteAccount.swift deleted file mode 100644 index caef63bd27..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminDeleteAccount.swift +++ /dev/null @@ -1,21 +0,0 @@ -// -// AtprotoAdminDeleteAccount.swift -// -// -// Created by Christopher Jr Riley on 2024-02-27. -// - -import Foundation - -/// The main data model definition for deleting a user's account as an administrator. -/// -/// - Note: According to the AT Protocol specifications: "Delete a user account as -/// an administrator." -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.deleteAccount`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/deleteAccount.json -public struct AdminDeleteAccount: Codable { - /// The decentralized identifier (DID) of the account to be deleted. - public let accountDID: String -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminDisableAccountInvites.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminDisableAccountInvites.swift deleted file mode 100644 index 4edbb2fb48..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminDisableAccountInvites.swift +++ /dev/null @@ -1,32 +0,0 @@ -// -// AtprotoAdminDisableAccountInvites.swift -// -// -// Created by Christopher Jr Riley on 2024-02-28. -// - -import Foundation - -/// The main data model definition for disabling a user account's ability to receive new -/// invite codes. -/// -/// - Note: According to the AT Protocol specifications: "Disable an account from receiving new -/// invite codes, but does not invalidate existing codes." -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.disableAccountInvites`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/disableAccountInvites.json -public struct AdminDisableAccountInvites: Codable { - /// The decentralized identifier (DID) of the user account. - public let accountDID: String - /// A comment explaining why the user won't receive new account invites. Optional. - /// - /// - Note: According to the AT Protocol specifications: "Optional reason for - /// disabled invites." - public let note: String? - - enum CodingKeys: String, CodingKey { - case accountDID = "account" - case note - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminDisableInviteCodes.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminDisableInviteCodes.swift deleted file mode 100644 index 24336747f3..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminDisableInviteCodes.swift +++ /dev/null @@ -1,29 +0,0 @@ -// -// AtprotoAdminDisableInviteCodes.swift -// -// -// Created by Christopher Jr Riley on 2024-02-28. -// - -import Foundation - -/// The main data model definition for disabling some or all of the invite codes for one or more -/// user accounts. -/// -/// - Note: According to the AT Protocol specifications: "Disable some set of codes and/or all -/// codes associated with a set of users." -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.disableInviteCodes`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/disableInviteCodes.json -public struct AdminDisableInviteCodes: Codable { - /// The invite codes to disable. - public let codes: [String] - /// The decentralized identifiers (DIDs) of the user accounts. - public let accountDIDs: [String] - - enum CodingKeys: String, CodingKey { - case codes - case accountDIDs = "accounts" - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminEnableAccountInvites.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminEnableAccountInvites.swift deleted file mode 100644 index 91110da85a..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminEnableAccountInvites.swift +++ /dev/null @@ -1,30 +0,0 @@ -// -// AtprotoAdminEnableAccountInvites.swift -// -// -// Created by Christopher Jr Riley on 2024-02-29. -// - -import Foundation - -/// The main data model definition for giving the user account access to receive invite -/// codes again. -/// -/// - Note: According to the AT Protocol specifications: "Re-enable an account's ability to -/// receive invite codes." -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.enableAccountInvites`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/enableAccountInvites.json -public struct AdminEnableAccountInvites: Codable { - /// The decentralized identifier (DID) of the account that will regain access to receiving - /// invite codes. - public let accountDID: String - /// A note as to why this action is being done. Optional. - public let note: String? - - enum CodingKeys: String, CodingKey { - case accountDID = "account" - case note - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminGetAccountInfos.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminGetAccountInfos.swift deleted file mode 100644 index 9324778620..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminGetAccountInfos.swift +++ /dev/null @@ -1,20 +0,0 @@ -// -// AtprotoAdminGetAccountInfos.swift -// -// -// Created by Christopher Jr Riley on 2024-02-29. -// - -import Foundation - -/// A data model definition for the output of retrieving an array of user accounts. -/// -/// - Note: According to the AT Protocol specifications: "Get details about some accounts." -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.getAccountInfos`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/getAccountInfos.json -public struct AdminGetAccountInfosOutput: Codable { - /// An array of user account information. - public let infos: [AdminAccountView] -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminGetInviteCodes.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminGetInviteCodes.swift deleted file mode 100644 index 008abfaf2b..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminGetInviteCodes.swift +++ /dev/null @@ -1,30 +0,0 @@ -// -// AtprotoAdminGetInviteCodes.swift -// -// -// Created by Christopher Jr Riley on 2024-02-29. -// - -import Foundation - -/// A data model definition for the output of getting the invite codes from a user account. -/// -/// - Note: According to the AT Protocol specifications: "Get an admin view of invite codes." -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.getInviteCodes`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/getInviteCodes.json -public struct AdminGetInviteCodesOutput: Codable { - /// The mark used to indicate the starting point for the next set of results. Optional. - public let cursor: String? - /// An array of invite codes. - public let codes: [ServerInviteCode] -} - -/// Sorts the invite codes by a particular order. -public enum AdminGetInviteCodesSort { - /// Sorts the invite codes by the most recently made. - case recent - /// Sorts the invite codes by the number of times it's been used. - case usage -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminGetSubjectStatus.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminGetSubjectStatus.swift deleted file mode 100644 index ddca60d9e7..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminGetSubjectStatus.swift +++ /dev/null @@ -1,60 +0,0 @@ -// -// AtprotoAdminGetSubjectStatus.swift -// -// -// Created by Christopher Jr Riley on 2024-03-01. -// - -import Foundation - -/// A data model definition for the output of getting the status of a subject as an administrator. -/// -/// - Note: According to the AT Protocol specifications: "Get the service-specific admin status of -/// a subject (account, record, or blob)." -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.getSubjectStatus`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/getSubjectStatus.json -public struct AdminGetSubjectStatusOutput: Codable { - public let subject: AdminGetSubjectStatusUnion - public let takedown: AdminStatusAttributes -} - -/// A reference containing the list of repository references. -public enum AdminGetSubjectStatusUnion: Codable { - /// A repository reference. - case repositoryReference(AdminRepositoryReference) - /// A strong reference. - case strongReference(StrongReference) - /// A repository blob reference. - case repoBlobReference(AdminRepoBlobReference) - - public init(from decoder: Decoder) throws { - let container = try decoder.singleValueContainer() - - if let value = try? container.decode(AdminRepositoryReference.self) { - self = .repositoryReference(value) - } else if let value = try? container.decode(StrongReference.self) { - self = .strongReference(value) - } else if let value = try? container.decode(AdminRepoBlobReference.self) { - self = .repoBlobReference(value) - } else { - throw DecodingError.typeMismatch( - AdminEventViewUnion.self, DecodingError.Context( - codingPath: decoder.codingPath, debugDescription: "UnknownAdminGetSubjectStatusUnion type")) - } - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - - switch self { - case .repositoryReference(let repositoryReference): - try container.encode(repositoryReference) - case .strongReference(let strongReference): - try container.encode(strongReference) - case .repoBlobReference(let repoBlobReference): - try container.encode(repoBlobReference) - } - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminQueryModerationStatuses.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminQueryModerationStatuses.swift deleted file mode 100644 index 759e8219fd..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminQueryModerationStatuses.swift +++ /dev/null @@ -1,38 +0,0 @@ -// -// AtprotoAdminQueryModerationStatuses.swift -// -// -// Created by Christopher Jr Riley on 2024-03-02. -// - -import Foundation - -/// A data model definition for the output of listing all of moderation statuses of records and repositories. -/// -/// - Note: According to the AT Protocol specifications: "View moderation statuses of subjects (record or repo)." -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.queryModerationStatuses`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/queryModerationStatuses.json -public struct AdminQueryModerationStatusesOutput: Codable { - /// The mark used to indicate the starting point for the next set of results. Optional. - public let cursor: String - /// An array of subject statuses. - public let subjectStatuses: [OzoneSubjectStatusView] -} - -/// Indicates the sorting field for the moderation status array. -public enum AdminQueryModerationStatusesSortField { - /// Indicates the moderation status array will be sorted by the last reported user. - case lastReportedAt - /// Indicates the moderation status array will be sorted by the last reviwed user. - case lastReviewedAt -} - -/// Indicates the sorting direction for the array of moderation statuses. -public enum AdminQueryModerationStatusesSortDirection: String { - /// Indicates the moderation events will be sorted in ascending order. - case ascending = "asc" - /// Indicates the moderation events will be sorted in descending order. - case descending = "desc" -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminSearchRepos.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminSearchRepos.swift deleted file mode 100644 index 8d6b79381e..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminSearchRepos.swift +++ /dev/null @@ -1,23 +0,0 @@ -// -// AtprotoAdminSearchRepos.swift -// -// -// Created by Christopher Jr Riley on 2024-03-02. -// - -import Foundation - -/// The main data model definition for the output of searching repositories. -/// -/// - Note: According to the AT Protocol specifications: "Find repositories based on a -/// search term." -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.searchRepos`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/searchRepos.json -public struct AdminSearchReposOutput: Codable { - /// The mark used to indicate the starting point for the next set of results. Optional. - public let cursor: String? - /// An array of repositories. - public let repos: OzoneModerationRepositoryView -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminSendEmail.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminSendEmail.swift deleted file mode 100644 index f36f79137d..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminSendEmail.swift +++ /dev/null @@ -1,52 +0,0 @@ -// -// AtprotoAdminSendEmail.swift -// -// -// Created by Christopher Jr Riley on 2024-03-02. -// - -import Foundation - -/// The main data model definition for sending an email to a user. -/// -/// - Note: According to the AT Protocol specifications: "Send email to a user's account email address." -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.sendEmail`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/sendEmail.json -public struct AdminSendEmail: Codable { - /// The decentralized identifier (DID) of the recipient. - public let recipientDID: String - /// The content of the email. - public let content: String - /// The subject line of the email. Optional. - public let subject: String? - /// The decentralized identifier (DID) of the sender. - public let senderDID: String - /// Any additional comments viewable to other moderators and administrators. - public let comment: String? - - enum CodingKeys: String, CodingKey { - case recipientDID = "recipientDid" - case content - case subject - case senderDID = "senderDid" - case comment - } -} - -/// A data model definition for the output of sending an email to a user. -/// -/// - Note: According to the AT Protocol specifications: "Send email to a user's account email address." -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.sendEmail`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/sendEmail.json -public struct AdminSendEmailOutput: Codable { - /// Indicates whether the email has been sent. - public let isSent: Bool - - enum CodingKeys: String, CodingKey { - case isSent = "sent" - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminUpdateAccountEmail.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminUpdateAccountEmail.swift deleted file mode 100644 index a0c8b31b77..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminUpdateAccountEmail.swift +++ /dev/null @@ -1,29 +0,0 @@ -// -// AtprotoAdminUpdateAccountEmail.swift -// -// -// Created by Christopher Jr Riley on 2024-03-02. -// - -import Foundation - -/// The main data model definition for updating the email address of a user account as -/// an administrator. -/// -/// - Note: According to the AT Protocol specifications: "Administrative action to update an -/// account's email." -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.updateAccountEmail`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/updateAccountEmail.json -public struct AdminUpdateAccountEmail: Codable { - /// The decentralized identifier (DID) of the account. - public let accountDID: String - /// The new email account the user wants to change to. - public let accountEmail: String - - enum CodingKeys: String, CodingKey { - case accountDID = "account" - case accountEmail = "email" - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminUpdateAccountHandle.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminUpdateAccountHandle.swift deleted file mode 100644 index e9b90e21aa..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminUpdateAccountHandle.swift +++ /dev/null @@ -1,29 +0,0 @@ -// -// AtprotoAdminUpdateAccountHandle.swift -// -// -// Created by Christopher Jr Riley on 2024-03-03. -// - -import Foundation - -/// The main data model definition for updating the handle of a user account as -/// an administrator. -/// -/// - Note: According to the AT Protocol specifications: "Administrative action to update -/// an account's handle." -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.updateAccountHandle`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/updateAccountHandle.json -public struct AdminUpdateAccountHandle: Codable { - /// The decentralized identifier (DID) of the account. - public let accountDID: String - /// The new account handle the user wants to change to. - public let accountHandle: String - - enum CodingKeys: String, CodingKey { - case accountDID = "did" - case accountHandle = "handle" - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminUpdateAccountPassword.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminUpdateAccountPassword.swift deleted file mode 100644 index c7adec35a7..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminUpdateAccountPassword.swift +++ /dev/null @@ -1,28 +0,0 @@ -// -// AtprotoAdminUpdateAccountPassword.swift -// -// -// Created by Christopher Jr Riley on 2024-03-03. -// - -import Foundation - -/// The main data model definition for updating the handle of a user account as an administrator. -/// -/// - Note: According to the AT Protocol specifications: "Update the password for a user account -/// as an administrator." -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.updateAccountPassword`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/updateAccountPassword.json -public struct AdminUpdateAccountPassword: Codable { - /// The decentralized identifier (DID) of the account. - public let accountDID: String - /// The new password for the user account. - public let newPassword: String - - enum CodingKeys: String, CodingKey { - case accountDID = "did" - case newPassword = "password" - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminUpdateSubjectStatus.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminUpdateSubjectStatus.swift deleted file mode 100644 index 16233bf284..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/AtprotoAdminUpdateSubjectStatus.swift +++ /dev/null @@ -1,38 +0,0 @@ -// -// AtprotoAdminUpdateSubjectStatus.swift -// -// -// Created by Christopher Jr Riley on 2024-03-03. -// - -import Foundation - -/// The main data model definition for updating a subject status of an account, record, or blob. -/// -/// - Note: According to the AT Protocol specifications: "Update the service-specific admin status -/// of a subject (account, record, or blob)." -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.updateSubjectStatus`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/updateSubjectStatus.json -public struct AdminUpdateSubjectStatus: Codable { - /// The subject associated with the subject status. - public let subject: AdminGetSubjectStatusUnion - /// The status attributes of the subject. Optional. - public let takedown: AdminStatusAttributes? -} - -/// A data model definition for the output of updating a subject status of an account, record, or blob. -/// -/// - Note: According to the AT Protocol specifications: "Update the service-specific admin status -/// of a subject (account, record, or blob)." -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.updateSubjectStatus`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/updateSubjectStatus.json -public struct AdminUpdateSubjectStatusOutput: Codable { - /// The subject associated with the subject status. - public let subject: AdminGetSubjectStatusUnion - /// The status attributes of the subject. Optional. - public let takedown: AdminStatusAttributes? -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminDefs.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminDefs.swift index ae4314e34d..33c2633657 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminDefs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminDefs.swift @@ -57,10 +57,10 @@ extension ComAtprotoLexicon.Admin { @DateFormatting public var indexedAt: Date /// The invite code used by the user to sign up. Optional. - public var invitedBy: ServerInviteCode? + public var invitedBy: ComAtprotoLexicon.Server.InviteCodeDefinition? /// An array of invite codes held by the user. Optional. - public var invites: [ServerInviteCode]? + public var invites: [ComAtprotoLexicon.Server.InviteCodeDefinition]? /// Indicates whether the invite codes held by the user are diabled. Optional. public var areInvitesDisabled: Bool? @@ -71,8 +71,9 @@ extension ComAtprotoLexicon.Admin { /// Any notes related to inviting the user. Optional. public var inviteNote: String? - public init(actorDID: String, handle: String, email: String?, relatedRecords: [UnknownType]?, indexedAt: Date, invitedBy: ServerInviteCode?, - invites: [ServerInviteCode]?, areInvitesDisabled: Bool?, emailConfirmedAt: Date? = nil, inviteNote: String?) { + public init(actorDID: String, handle: String, email: String?, relatedRecords: [UnknownType]?, indexedAt: Date, + invitedBy: ComAtprotoLexicon.Server.InviteCodeDefinition?, + invites: [ComAtprotoLexicon.Server.InviteCodeDefinition]?, areInvitesDisabled: Bool?, emailConfirmedAt: Date? = nil, inviteNote: String?) { self.actorDID = actorDID self.handle = handle self.email = email @@ -93,8 +94,8 @@ extension ComAtprotoLexicon.Admin { self.email = try container.decodeIfPresent(String.self, forKey: .email) self.relatedRecords = try container.decodeIfPresent([UnknownType].self, forKey: .relatedRecords) self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue - self.invitedBy = try container.decodeIfPresent(ServerInviteCode.self, forKey: .invitedBy) - self.invites = try container.decodeIfPresent([ServerInviteCode].self, forKey: .invites) + self.invitedBy = try container.decodeIfPresent(ComAtprotoLexicon.Server.InviteCodeDefinition.self, forKey: .invitedBy) + self.invites = try container.decodeIfPresent([ComAtprotoLexicon.Server.InviteCodeDefinition].self, forKey: .invites) self.areInvitesDisabled = try container.decodeIfPresent(Bool.self, forKey: .areInvitesDisabled) self.emailConfirmedAt = try container.decodeIfPresent(DateFormattingOptional.self, forKey: .emailConfirmedAt)?.wrappedValue self.inviteNote = try container.decodeIfPresent(String.self, forKey: .inviteNote) diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminGetAccountInfos.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminGetAccountInfos.swift index b0ba38848e..f159fe4f2e 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminGetAccountInfos.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminGetAccountInfos.swift @@ -19,6 +19,6 @@ extension ComAtprotoLexicon.Admin { public struct GetAccountInfosOutput: Codable { /// An array of user account information. - public let infos: [AdminAccountView] + public let infos: [AccountViewDefinition] } } diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminGetSubjectStatus.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminGetSubjectStatus.swift index c10b2302ad..726b76f4d3 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminGetSubjectStatus.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminGetSubjectStatus.swift @@ -23,6 +23,6 @@ extension ComAtprotoLexicon.Admin { public let subject: ATUnion.AdminGetSubjectStatusUnion /// The attributes of the takedown event. - public let takedown: AdminStatusAttributes + public let takedown: StatusAttributesDefinition } } diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminSearchRepos.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminSearchRepos.swift index c9bb5e5498..1db95856fa 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminSearchRepos.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Admin/ComAtprotoAdminSearchRepos.swift @@ -23,6 +23,11 @@ extension ComAtprotoLexicon.Admin { public let cursor: String? /// An array of repositories. - public let repos: OzoneModerationRepositoryView + public let repositories: ToolsOzoneLexicon.Moderation.RepositoryViewDefinition + + enum CodingKeys: String, CodingKey { + case cursor + case repositories = "repos" + } } } diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/AtprotoIdentityGetRecommendedDidCredentials.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/AtprotoIdentityGetRecommendedDidCredentials.swift deleted file mode 100644 index ed37376e43..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/AtprotoIdentityGetRecommendedDidCredentials.swift +++ /dev/null @@ -1,31 +0,0 @@ -// -// AtprotoIdentityGetRecommendedDidCredentials.swift -// -// -// Created by Christopher Jr Riley on 2024-03-15. -// - -import Foundation - -/// The main data model definition for the output of getting the required information of a -/// Personal Data Server's (PDS) DID document for migration. -/// -/// - Note: According to the AT Protocol specifications: "Describe the credentials that should -/// be included in the DID doc of an account that is migrating to this service." -/// -/// - SeeAlso: This is based on the [`com.atproto.identity.getRecommendedDidCredentials`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/identity/getRecommendedDidCredentials.json -public struct IdentityGetRecommendedDidCredentialsOutput: Codable { - /// The rotation keys recommended to be added in the DID document. Optional. - /// - /// - Note: According to the AT Protocol specifications: "Recommended rotation keys for PLC - /// dids. Should be undefined (or ignored) for did:webs." - public let rotationKeys: [String]? - /// An array of aliases of the user account. Optional. - public let alsoKnownAs: [String]? - /// A verification method recommeneded to be added in the DID document. Optional. - public let verificationMethods: VerificationMethod? - /// The service endpoint recommended in the DID document. Optional. - public let service: ATService? -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/AtprotoIdentityResolveHandle.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/AtprotoIdentityResolveHandle.swift deleted file mode 100644 index 2b54108269..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/AtprotoIdentityResolveHandle.swift +++ /dev/null @@ -1,35 +0,0 @@ -// -// AtprotoIdentityResolveHandle.swift -// -// -// Created by Christopher Jr Riley on 2024-01-27. -// - -import Foundation - -// MARK: - Main definition -/// The main data model definition for resolving handles. -/// -/// - Note: According to the AT Protocol specifications: "Resolves a handle (domain name) to -/// a DID." -/// -/// - SeeAlso: This is based on the [`com.atproto.identity.resolveHandle`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/identity/resolveHandle.json -public struct ResolveHandleQuery: Encodable { - /// The handle to be resolved. - /// - /// - Important: Be sure to remove the "@" before entering the value. - public let handle: String -} - -// MARK: - -/// A data model that represents the output of resolving handles. -/// -/// - SeeAlso: This is based on the [`com.atproto.identity.resolveHandle`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/identity/resolveHandle.json -public struct ResolveHandleOutput: Decodable { - /// The resolved handle's decentralized identifier (DID). - public let handleDID: String -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/AtprotoIdentitySignPLCOperation.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/AtprotoIdentitySignPLCOperation.swift deleted file mode 100644 index 3ca89706d5..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/AtprotoIdentitySignPLCOperation.swift +++ /dev/null @@ -1,45 +0,0 @@ -// -// AtprotoIdentitySignPLCOperation.swift -// -// -// Created by Christopher Jr Riley on 2024-03-16. -// - -import Foundation - -/// The main data model definition for signing a PLC operation to a DID document. -/// -/// - Note: According to the AT Protocol specifications: "Signs a PLC operation to update some -/// value(s) in the requesting DID's document." -/// -/// - SeeAlso: This is based on the [`com.atproto.identity.signPlcOperation`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/identity/signPlcOperation.json -public struct IdentitySignPLCOperation: Codable { - /// A token received from ``ATProtoKit/ATProtoKit/requestPLCOperationSignature()``. Optional. - /// - /// - Note: According to the AT Protocol specifications: "A token received - /// through com.atproto.identity.requestPlcOperationSignature" - public let token: String? - /// The rotation keys recommended to be added in the DID document. Optional. - public let rotationKeys: [String]? - /// An array of aliases of the user account. Optional. - public let alsoKnownAs: [String]? - /// A verification method recommeneded to be added in the DID document. Optional. - public let verificationMethods: VerificationMethod? - /// The service endpoint recommended in the DID document. Optional. - public let service: ATService? -} - -/// The main data model definition for the output of signing a PLC operation to a DID document. -/// -/// - Note: According to the AT Protocol specifications: "Signs a PLC operation to update some -/// value(s) in the requesting DID's document." -/// -/// - SeeAlso: This is based on the [`com.atproto.identity.signPlcOperation`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/identity/signPlcOperation.json -public struct IdentitySignPLCOperationOutput: Codable { - /// The operation itself. - public let operation: UnknownType -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/AtprotoIdentitySubmitPLCOperation.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/AtprotoIdentitySubmitPLCOperation.swift deleted file mode 100644 index 805c2d7f50..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/AtprotoIdentitySubmitPLCOperation.swift +++ /dev/null @@ -1,22 +0,0 @@ -// -// AtprotoIdentitySubmitPLCOperation.swift -// -// -// Created by Christopher Jr Riley on 2024-03-16. -// - -import Foundation - -/// The main data model definition for the output of validating a PLC operation. -/// -/// - Note: According to the AT Protocol specifications: "Validates a PLC operation to ensure -/// that it doesn't violate a service's constraints or get the identity into a bad state, then -/// submits it to the PLC registry." -/// -/// - SeeAlso: This is based on the [`com.atproto.identity.submitPlcOperation`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/identity/submitPlcOperation.json -public struct IdentitySubmitPLCOperationOutput: Codable { - /// The operation itself. - public let operation: UnknownType -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/AtprotoIdentityUpdateHandle.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/AtprotoIdentityUpdateHandle.swift deleted file mode 100644 index 3c869f3072..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/AtprotoIdentityUpdateHandle.swift +++ /dev/null @@ -1,25 +0,0 @@ -// -// AtprotoIdentityUpdateHandle.swift -// -// -// Created by Christopher Jr Riley on 2024-01-27. -// - -import Foundation - -// MARK: - Main definition -/// The main data model definition for updating a handle. -/// -/// - Note: According to the AT Protocol specifications: "Updates the current account's handle. -/// Verifies handle validity, and updates did:plc document if necessary. Implemented by PDS, -/// and requires auth." -/// -/// - SeeAlso: This is based on the [`com.atproto.identity.updateHandle`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/identity/updateHandle.json -public struct UpdateHandleQuery: Encodable { - /// The handle the user would like to change to. - /// - /// - Note: According to the AT Protocol specifications: "The new handle." - public let handle: String -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Label/AtprotoLabelDefs.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Label/AtprotoLabelDefs.swift deleted file mode 100644 index 6f24e617da..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Label/AtprotoLabelDefs.swift +++ /dev/null @@ -1,363 +0,0 @@ -// -// AtProtoLabelDefs.swift -// -// -// Created by Christopher Jr Riley on 2024-01-25. -// - -import Foundation - -/// The main data model definition for a label. -/// -/// - Note: According to the AT Protocol specifications: "Metadata tag on an atproto resource (eg, -/// repo or record)." -/// -/// - SeeAlso: This is based on the [`com.atproto.label.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/label/defs.json -public struct Label: Codable { - /// The version number of the label. Optional. - /// - /// - Note: According to the AT Protocol specifications: "The AT Protocol version of the - /// label object." - public let version: Int? - /// The decentralized identifier (DID) of the label creator. - /// - /// - Note: According to the AT Protocol specifications: "DID of the actor who created - /// this label." - public let actorDID: String - /// The URI of the resource the label applies to. - /// - /// - Note: According to the AT Protocol specifications: "AT URI of the record, repository - /// (account), or other resource that this label applies to." - public let atURI: String - /// The CID hash of the resource the label applies to. Optional. - /// - /// - Note: According to the AT Protocol specifications: "Optionally, CID specifying the - /// specific version of 'uri' resource this label applies to." - public let cidHash: String? - /// The name of the label. - /// - /// - Note: According to the AT Protocol specifications: "The short string name of the value or - /// type of this label." - /// - /// - Important: Current maximum length is 128 characters. This library will automatically - /// truncate the `String` to the maximum length if it does go over the limit. - public var name: String - /// Indicates whether this label is negating a previously-used label. Optional. - /// - /// - Note: According to the AT Protocol specifications: "If true, this is a negation label, - /// overwriting a previous label." - public let isNegated: Bool? - /// The date and time the label was created. - /// - /// - Note: According to the AT Protocol specifications: "Timestamp when this label - /// was created." - @DateFormatting public var timestamp: Date - /// The date and time the label expires on. - /// - /// - Note: According to the AT Protocol specifications: "Timestamp at which this label - /// expires (no longer applies)." - @DateFormattingOptional public var expiresOn: Date? - /// The DAG-CBOR-encoded signature. Optional. - /// - /// - Note: According to the AT Protocol specifications: "Signature of dag-cbor encoded label." - public let signature: Data? - - public init(version: Int?, actorDID: String, atURI: String, cidHash: String?, name: String, isNegated: Bool?, timestamp: Date, - expiresOn: Date?, signature: Data) { - self.version = version - self.actorDID = actorDID - self.atURI = atURI - self.cidHash = cidHash - self.name = name - self.isNegated = isNegated - self._timestamp = DateFormatting(wrappedValue: timestamp) - self._expiresOn = DateFormattingOptional(wrappedValue: expiresOn) - self.signature = signature - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.version = try container.decodeIfPresent(Int.self, forKey: .version) - self.actorDID = try container.decode(String.self, forKey: .actorDID) - self.atURI = try container.decode(String.self, forKey: .atURI) - self.cidHash = try container.decodeIfPresent(String.self, forKey: .cidHash) - self.name = try container.decode(String.self, forKey: .name) - self.isNegated = try container.decodeIfPresent(Bool.self, forKey: .isNegated) - self.timestamp = try container.decode(DateFormatting.self, forKey: .timestamp).wrappedValue - self.expiresOn = try container.decodeIfPresent(DateFormattingOptional.self, forKey: .expiresOn)?.wrappedValue - self.signature = try container.decodeIfPresent(Data.self, forKey: .signature) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encodeIfPresent(self.version, forKey: .version) - try container.encode(self.actorDID, forKey: .actorDID) - try container.encode(self.atURI, forKey: .atURI) - try container.encodeIfPresent(self.cidHash, forKey: .cidHash) - - // Truncate `name` to 128 characters before encoding - try truncatedEncode(self.name, withContainer: &container, forKey: .name, upToLength: 128) - - try container.encodeIfPresent(self.isNegated, forKey: .isNegated) - try container.encode(self._timestamp, forKey: .timestamp) - try container.encodeIfPresent(self._expiresOn, forKey: .expiresOn) - try container.encodeIfPresent(self.signature, forKey: .signature) - } - - enum CodingKeys: String, CodingKey { - case version = "ver" - case actorDID = "src" - case atURI = "uri" - case cidHash = "cid" - case name = "val" - case isNegated = "neg" - case timestamp = "cts" - case expiresOn = "exp" - case signature = "sig" - } -} - -/// A data model for a definition for an array of self-defined labels. -public struct SelfLabels: Codable { - /// An array of self-defined tags on a record. - /// - /// - Note: According to the AT Protocol specifications: "Metadata tags on an atproto record, - /// published by the author within the record." - /// - /// - Important: Current maximum length is 10 tags. This library will automatically truncate - /// the `Array` to the maximum length if it does go over the limit. - /// - /// - SeeAlso: This is based on the [`com.atproto.label.defs`][github] lexicon. - /// - /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/label/defs.json - public let values: [SelfLabel] - - public init(values: [SelfLabel]) { - self.values = values - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.values = try container.decode([SelfLabel].self, forKey: .values) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - // Truncate `values` to 10 items before encoding - try truncatedEncode(self.values, withContainer: &container, forKey: .values, upToLength: 10) - } - - enum CodingKeys: CodingKey { - case values - } -} - -/// A data model for a definition for a user-defined label. -/// -/// - Note: According to the AT Protocol specifications: "Metadata tag on an atproto record, -/// published by the author within the record. Note that schemas should use #selfLabels, -/// not #selfLabel.", -/// -/// - SeeAlso: This is based on the [`com.atproto.label.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/label/defs.json -public struct SelfLabel: Codable { - /// A user-defined label. - /// - /// - Note: According to the AT Protocol specifications: "The short string name of the value or - /// type of this label." - /// - /// - Important: Current maximum length is 128 characters. This library will automatically - /// truncate the `String` to the maximum length if it does go over the limit. - public let value: String - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - // Truncate `value` to 128 characters before encoding - try truncatedEncode(self.value, withContainer: &container, forKey: .value, upToLength: 128) - } - - enum CodingKeys: String, CodingKey { - case value = "val" - } -} - -/// A data model definition for labeler-created labels. -/// -/// - Note: According to the AT Protocol specifications: "Declares a label value and its expected -/// interpertations and behaviors." -/// -/// - SeeAlso: This is based on the [`com.atproto.label.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/label/defs.json -public struct LabelValueDefinition: Codable { - /// The value of the label. - /// - /// - Important: This field can only contain lowercased letter and the hypen (-) character. - /// This library will automatically convert uppercased letters to lowercased, as well as any - /// hashes other than the hypen into a hypen. All additional characters will be removed. - /// - /// - Note: According to the AT Protocol specifications: "The value of the label being defined. - /// Must only include lowercase ascii and the '-' character ([a-z-]+)." - public let identifier: String - // TODO: Make this into an enum. - /// The visual indicator of the label that indicates the severity. - /// - /// - Note: According to the AT Protocol specifications: "How should a client visually convey - /// this label? 'inform' means neutral and informational; 'alert' means negative and warning; - /// 'none' means show nothing." - public let severity: Severity - // TODO: Make this into an enum. - /// Indicates how much of the content should be hidden for the user. - /// - /// - Note: According to the AT Protocol specifications: "What should this label hide in the - /// UI, if applied? 'content' hides all of the target; 'media' hides the images/video/audio; - /// 'none' hides nothing." - public let blurs: Blurs - // TODO: Make this into an enum. - /// The default setting for the label. - /// - /// - Note: According to the AT Protocol specifications: "The default setting for this label." - public let defaultSetting: DefaultSetting = .warn - /// Indicates whether the "Adult Content" preference needs to be enabled in order to use - /// this label. Optional. - /// - /// - Note: According to the AT Protocol specifications: "Does the user need to have adult - /// content enabled in order to configure this label?" - public let isAdultOnly: Bool? - /// An array of localized strings for the label. Optional. - public let locales: [LabelValueDefinitionStrings] - - public func encode(to encoder: any Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - // Ensure `value` is lowercased and only has the standard hyphen (-). - // Then, truncate `value` to 100 characters before encoding. - try truncatedEncode(self.identifier.transformToLowerASCIIAndHyphen(), withContainer: &container, forKey: .identifier, upToLength: 100) - try container.encode(self.severity, forKey: .severity) - try container.encode(self.blurs, forKey: .blurs) - try container.encode(self.defaultSetting, forKey: .defaultSetting) - try container.encodeIfPresent(self.isAdultOnly, forKey: .isAdultOnly) - try container.encode(self.locales, forKey: .locales) - } - - enum CodingKeys: CodingKey { - case identifier - case severity - case blurs - case defaultSetting - case isAdultOnly - case locales - } - - // Enums - /// The visual indicator of the label that indicates the severity. - public enum Severity: String, Codable { - /// Indicates the labeler should only inform the user of the content. - case inform - /// Indicates the labeler should alert the user of the content. - case alert - /// Indicates the labeler should do nothing. - case none - } - - /// Indicates how much of the content should be hidden for the user. - public enum Blurs: String, Codable { - /// Indicates the labeler should hide the entire content from the user. - case content - /// Indicates the labeler should hide only the media of the content, but keeps the - /// text intact. - case media - /// Indicates the labeler should hide nothing. - case none - } - - /// The default setting for the label. - public enum DefaultSetting: String, Codable { - /// Indicates the user will ignore the label. - case ignore - /// Indicates the user will be warned. - case warn - /// Indicates the user will hide the label. - case hide - } -} - -/// A data model definition for a localized description of a label. -/// -/// - Note: According to the AT Protocol specifications: "Strings which describe the label in -/// the UI, localized into a specific language." -/// -/// - SeeAlso: This is based on the [`com.atproto.label.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/label/defs.json -public struct LabelValueDefinitionStrings: Codable { - /// The language code of the label's definition. - /// - /// - Note: According to the AT Protocol specifications: "The code of the language these - /// strings are written in." - public let language: Locale - /// The localized name of the label. - /// - /// - Note: According to the AT Protocol specifications: "A short human-readable name for - /// the label." - public let name: String - /// The localized description of the label. - /// - /// - Note: According to the AT Protocol specifications: "A longer description of what the - /// label means and why it might be applied." - public let description: String - - public init(from decoder: any Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.language = try container.decode(Locale.self, forKey: .language) - self.name = try container.decode(String.self, forKey: .name) - self.description = try container.decode(String.self, forKey: .description) - } - - public func encode(to encoder: any Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self.language, forKey: .language) - // Truncate `name` to 640 characters before encoding. - try truncatedEncode(self.name, withContainer: &container, forKey: .name, upToLength: 640) - - try truncatedEncode(self.description, withContainer: &container, forKey: .description, upToLength: 100_000) - } - - enum CodingKeys: String, CodingKey { - case language = "lang" - case name - case description - } -} - -/// An enumuation that defines the value of a label. -/// -/// - Note: According to the AT Protocol specifications: "Strings which describe the label in the -/// UI, localized into a specific language." -/// -/// - SeeAlso: This is based on the [`com.atproto.label.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/label/defs.json -public enum LabelValue: String, Codable { - case hide = "!hide" - case noPromote = "!no-promote" - case warn = "!warn" - case noUnauthenticated = "!no-unauthenticated" - case dmcaViolation = "dmca-violation" - case doxxing - case porn - case sexual - case nudity - case nsfl - case gore -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Label/AtprotoLabelQueryLabels.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Label/AtprotoLabelQueryLabels.swift deleted file mode 100644 index d4c711ec56..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Label/AtprotoLabelQueryLabels.swift +++ /dev/null @@ -1,22 +0,0 @@ -// -// AtprotoLabelQueryLabels.swift -// -// -// Created by Christopher Jr Riley on 2024-03-16. -// - -import Foundation - -/// The main data model definition for the output of finding relevant labels based on a given URI. -/// -/// - Note: According to the AT Protocol specifications: "Find labels relevant to the provided -/// AT-URI patterns. Public endpoint for moderation services, though may return different or -/// additional results with auth." -/// -/// - SeeAlso: This is based on the [`com.atproto.label.queryLabels`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/label/queryLabels.json -public struct LabelQueryLabelsOutput: Codable { - /// An array of labels. - public let labels: [Label] -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Label/ComAtprotoLabelDefs.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Label/ComAtprotoLabelDefs.swift index eaa5a11bbe..209772a96d 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Label/ComAtprotoLabelDefs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Label/ComAtprotoLabelDefs.swift @@ -255,7 +255,7 @@ extension ComAtprotoLexicon.Label { public let isAdultOnly: Bool? /// An array of localized strings for the label. Optional. - public let locales: [LabelValueDefinitionStrings] + public let locales: [LabelValueDefinitionStringsDefinition] public func encode(to encoder: any Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Moderation/AtprotoModerationCreateReport.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Moderation/AtprotoModerationCreateReport.swift deleted file mode 100644 index f780a039b6..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Moderation/AtprotoModerationCreateReport.swift +++ /dev/null @@ -1,107 +0,0 @@ -// -// AtprotoModerationCreateReport.swift -// -// -// Created by Christopher Jr Riley on 2024-02-25. -// - -import Foundation - -/// The main data model definition for creating a report. -/// -/// - Note: According to the AT Protocol specifications: "Submit a moderation report regarding -/// an atproto account or record. Implemented by moderation services (with PDS proxying), and -/// requires auth." -/// -/// - SeeAlso: This is based on the [`com.atproto.moderation.createReport`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/moderation/createReport.json -public struct ModerationCreateReport: Codable { - /// The reason for the report. - /// - /// - Note: According to the AT Protocol specifications: "Indicates the broad category of - /// violation the report is for." - public let reasonType: ModerationReasonType - /// Any clarifying comments accompanying the report. Optional. - /// - /// - Note: According to the AT Protocol specifications: "Additional context about the - /// content and violation." - public let reason: String? - /// The subject reference. - /// - /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ - /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ - /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ - /// \ - /// Clarifications from Bluesky are needed in order to fully understand this item. - public let subject: RepositoryReferencesUnion -} - -/// A data model definition for the output of creating a report. -/// -/// - SeeAlso: This is based on the [`com.atproto.moderation.createReport`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/moderation/createReport.json -public struct ModerationCreateReportOutput: Codable { - /// The ID of the report. - public let id: Int - /// The reason for the report. - public let reasonType: ModerationReasonType - /// The reason for the report. Optional. - public let reason: String? - /// The subject reference. - /// - /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ - /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ - /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ - /// \ - /// Clarifications from Bluesky are needed in order to fully understand this item. - public let subject: RepositoryReferencesUnion - /// The decentralized identifier (DID) of the user who created the report. - public let reportedBy: String - /// The date and time the report was created. - @DateFormatting public var createdAt: Date - - public init(id: Int, reasonType: ModerationReasonType, reason: String?, subject: RepositoryReferencesUnion, reportedBy: String, createdAt: Date) { - self.id = id - self.reasonType = reasonType - self.reason = reason - self.subject = subject - self.reportedBy = reportedBy - self._createdAt = DateFormatting(wrappedValue: createdAt) - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.id = try container.decode(Int.self, forKey: .id) - self.reasonType = try container.decode(ModerationReasonType.self, forKey: .reasonType) - self.reason = try container.decodeIfPresent(String.self, forKey: .reason) - self.subject = try container.decode(RepositoryReferencesUnion.self, forKey: .subject) - self.reportedBy = try container.decode(String.self, forKey: .reportedBy) - self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self.id, forKey: .id) - try container.encode(self.reasonType, forKey: .reasonType) - - // Truncate `reason` to 20,000 characters before encoding - // `maxGraphemes`'s limit is 2,000, but `String.count` should respect that limit implictly - try truncatedEncodeIfPresent(self.reason, withContainer: &container, forKey: .reason, upToLength: 20_000) - try container.encode(self.subject, forKey: .subject) - try container.encode(self.reportedBy, forKey: .reportedBy) - try container.encode(self._createdAt, forKey: .createdAt) - } - - public enum CodingKeys: CodingKey { - case id - case reasonType - case reason - case subject - case reportedBy - case createdAt - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Moderation/AtprotoModerationDefs.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Moderation/AtprotoModerationDefs.swift deleted file mode 100644 index 74a31ebdd2..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Moderation/AtprotoModerationDefs.swift +++ /dev/null @@ -1,57 +0,0 @@ -// -// AtprotoModerationDefs.swift -// -// -// Created by Christopher Jr Riley on 2024-01-25. -// - -import Foundation - -/// A data model for the definition of the moderator's reason for reporting. -/// -/// - SeeAlso: This is based on the [`com.atproto.moderation.defs`][github] lexicon. -/// -/// - Important: The item associated with this enum is undocumented in the AT Protocol specifications. The documentation here is based on:\ -/// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ -/// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ -/// \ -/// Clarifications from Bluesky are needed in order to fully understand this item. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/moderation/defs.json -public enum ModerationReasonType: String, Codable { - /// Indicates spam as the reason. - /// - /// - Note: According to the AT Protocol specifications: "Spam: frequent unwanted promotion, - /// replies, mentions." - case reasonSpam - /// Indicates a rule violation as the reason. - /// - /// - Note: According to the AT Protocol specifications: "Direct violation of server rules, - /// laws, terms of service." - case reasonViolation - /// Indicates misleading content as the reason. - /// - /// - Note: According to the AT Protocol specifications: "Misleading identity, - /// affiliation, or content." - case reasonMisleading - /// Indicates mislabeled/unwanted sexual content as the reason. - /// - /// - Note: According to the AT Protocol specifications: "Unwanted or mislabeled - /// sexual content." - case reasonSexual - /// Indicates rude behavior as the reason. - /// - /// - Note: According to the AT Protocol specifications: "Rude, harassing, explicit, or - /// otherwise unwelcoming behavior." - case reasonRude - /// Indicates a reason not otherwise specified. - /// - /// - Note: According to the AT Protocol specifications: "Other: reports not falling under - /// another report category." - case reasonOther - /// Indicates an appeal to a previous moderation ruling as the reason. - /// - /// - Note: According to the AT Protocol specifications: "Appeal: appeal a previously taken - /// moderation action." - case reasonAppeal -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Moderation/ComAtprotoModerationCreateReport.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Moderation/ComAtprotoModerationCreateReport.swift index 7ba223fdc5..71f9509bde 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Moderation/ComAtprotoModerationCreateReport.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Moderation/ComAtprotoModerationCreateReport.swift @@ -53,7 +53,7 @@ extension ComAtprotoLexicon.Moderation { public let id: Int /// The reason for the report. - public let reasonType: ModerationReasonType + public let reasonType: ComAtprotoLexicon.Moderation.ReasonTypeDefinition /// The reason for the report. Optional. public let reason: String? @@ -73,7 +73,8 @@ extension ComAtprotoLexicon.Moderation { /// The date and time the report was created. @DateFormatting public var createdAt: Date - public init(id: Int, reasonType: ModerationReasonType, reason: String?, subject: ATUnion.CreateReportSubjectUnion, reportedBy: String, createdAt: Date) { + public init(id: Int, reasonType: ComAtprotoLexicon.Moderation.ReasonTypeDefinition, reason: String?, subject: ATUnion.CreateReportSubjectUnion, + reportedBy: String, createdAt: Date) { self.id = id self.reasonType = reasonType self.reason = reason @@ -86,7 +87,7 @@ extension ComAtprotoLexicon.Moderation { let container = try decoder.container(keyedBy: CodingKeys.self) self.id = try container.decode(Int.self, forKey: .id) - self.reasonType = try container.decode(ModerationReasonType.self, forKey: .reasonType) + self.reasonType = try container.decode(ComAtprotoLexicon.Moderation.ReasonTypeDefinition.self, forKey: .reasonType) self.reason = try container.decodeIfPresent(String.self, forKey: .reason) self.subject = try container.decode(ATUnion.CreateReportSubjectUnion.self, forKey: .subject) self.reportedBy = try container.decode(String.self, forKey: .reportedBy) diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/AtprotoRepoApplyWrites.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/AtprotoRepoApplyWrites.swift deleted file mode 100644 index 586259c6bc..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/AtprotoRepoApplyWrites.swift +++ /dev/null @@ -1,131 +0,0 @@ -// -// AtprotoRepoApplyWrites.swift -// -// -// Created by Christopher Jr Riley on 2024-03-11. -// - -import Foundation - -/// The main data model definition for applying batch CRUD transactions. -/// -/// - Note: According to the AT Protocol specifications: "Apply a batch transaction of repository -/// creates, updates, and deletes. Requires auth, implemented by PDS." -/// -/// - SeeAlso: This is based on the [`com.atproto.repo.applyWrites`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/repo/applyWrites.json -public struct RepoApplyWrites: Codable { - /// The decentralized identifier (DID) or handle of the repository. - /// - /// - Note: According to the AT Protocol specifications: "The handle or DID of the repo (aka, - /// current account)." - public let repositoryDID: String - /// Indicates whether the operation should be validated. Optional. Defaults to `true`. - /// - /// - Note: According to the AT Protocol specifications: "Can be set to 'false' to skip Lexicon - /// schema validation of record data, for all operations." - public let shouldValidate: Bool? - /// The write operation itself. - public let writes: [ApplyWritesUnion]? - /// Swaps out an operation based on the CID. Optional. - /// - /// - Important: If a value is entered in here, the entire operation will fail if there is no - /// matching value in the repository. - /// - /// - Note: According to the AT Protocol specifications: "If provided, the entire operation - /// will fail if the current repo commit CID does not match this value. Used to prevent - /// conflicting repo mutations." - public let swapCommit: String? - - enum CodingKeys: String, CodingKey { - case repositoryDID = "repo" - case shouldValidate = "validate" - case writes - case swapCommit - } -} - -/// A data model definition for a "Create" write operation. -public struct RepoApplyWritesCreate: Codable { - /// The NSID of the collection. - public let collection: String - /// The record key of the write operation. Optional. - public let recordKey: String? - /// The value of the write operation. - public let value: UnknownType - - enum CodingKeys: String, CodingKey { - case collection - case recordKey = "rkey" - case value - } -} - -/// A data model definition for an "Update" write operation. -public struct RepoApplyWritesUpdate: Codable { - /// The NSID of the collection. - public let collection: String - /// The record key of the write operation. - public let recordKey: String - /// The value of the write operation. - public let value: UnknownType - - enum CodingKeys: String, CodingKey { - case collection - case recordKey = "rkey" - case value - } -} - -/// A data model definition for a "Delete" write operation. -public struct RepoApplyWritesDelete: Codable { - /// The NSID of the collection. - public let collection: String - /// The record key of the write operation. - public let recordKey: String - - enum CodingKeys: String, CodingKey { - case collection - case recordKey = "rkey" - } -} - -/// A reference containing the list of write operations. -public enum ApplyWritesUnion: Codable { - /// A "Create" write operation. - case create(RepoApplyWritesCreate) - /// An "Update" write operation. - case update(RepoApplyWritesUpdate) - /// A "Delete" write operation. - case delete(RepoApplyWritesDelete) - - public init(from decoder: Decoder) throws { - let container = try decoder.singleValueContainer() - - if let value = try? container.decode(RepoApplyWritesCreate.self) { - self = .create(value) - } else if let value = try? container.decode(RepoApplyWritesUpdate.self) { - self = .update(value) - } else if let value = try? container.decode(RepoApplyWritesDelete.self) { - self = .delete(value) - } else { - throw DecodingError.typeMismatch( - EmbedViewUnion.self, DecodingError.Context( - codingPath: decoder.codingPath, debugDescription: "Unknown ApplyWritesUnion type")) - } - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - - switch self { - case .create(let embedView): - try container.encode(embedView) - case .update(let embedView): - try container.encode(embedView) - case .delete(let embedView): - try container.encode(embedView) - } - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/AtprotoRepoCreateRecord.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/AtprotoRepoCreateRecord.swift deleted file mode 100644 index 7e29cae99d..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/AtprotoRepoCreateRecord.swift +++ /dev/null @@ -1,67 +0,0 @@ -// -// AtprotoRepoCreateRecord.swift -// -// -// Created by Christopher Jr Riley on 2024-03-11. -// - -import Foundation - -/// The main data model definition for creating a record. -/// -/// - Note: According to the AT Protocol specifications: "Create a single new repository record -/// Requires auth, implemented by PDS." -/// -/// - SeeAlso: This is based on the [`com.atproto.repo.createRecord`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/repo/createRecord.json -public struct RepoCreateRecord: Codable { - /// The decentralized identifier (DID) or handle of the user account. - /// - /// - Note: According to the AT Protocol specifications: "The handle or DID of the repo - /// (aka, current account)." - public let repositoryDID: String - /// The NSID of the record. - /// - /// - Note: According to the AT Protocol specifications: "The NSID of the record collection." - public let collection: String - /// The record key of the collection. Optional. - /// - /// - Important: Current maximum length is 15 characters. This library will automatically - /// truncate the `String` to the maximum length if it does go over the limit. - /// - /// - Note: According to the AT Protocol specifications: "The Record Key." - public let recordKey: String? - /// Indicates whether the record should be validated. Optional. Defaults to `true`. - public let shouldValidate: Bool? - /// The record itself. - public let record: UnknownType - /// Swaps out an operation based on the CID. Optional. - /// - /// - Important: If a value is entered in here, the entire operation will fail if there is no - /// matching value in the repository. - /// - /// - Note: According to the AT Protocol specifications: "Compare and swap with the previous - /// commit by CID." - public let swapCommit: String? - - public func encode(to encoder: any Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self.repositoryDID, forKey: .repositoryDID) - try container.encode(self.collection, forKey: .collection) - try truncatedEncodeIfPresent(self.recordKey, withContainer: &container, forKey: .recordKey, upToLength: 15) - try container.encodeIfPresent(self.shouldValidate, forKey: .shouldValidate) - try container.encode(self.record, forKey: .record) - try container.encodeIfPresent(self.swapCommit, forKey: .swapCommit) - } - - enum CodingKeys: String, CodingKey { - case repositoryDID = "repo" - case collection - case recordKey = "rkey" - case shouldValidate = "validate" - case record - case swapCommit - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/AtprotoRepoDeleteRecord.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/AtprotoRepoDeleteRecord.swift deleted file mode 100644 index fb1b55eb2b..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/AtprotoRepoDeleteRecord.swift +++ /dev/null @@ -1,52 +0,0 @@ -// -// AtprotoRepoDeleteRecord.swift -// -// -// Created by Christopher Jr Riley on 2024-03-11. -// - -import Foundation - -/// The main data model definition for deleting a record. -/// -/// - Note: According to the AT Protocol specifications: "Delete a repository record, or ensure it -/// doesn't exist. Requires auth, implemented by PDS." -/// -/// - SeeAlso: This is based on the [`com.atproto.repo.deleteRecord`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/repo/deleteRecord.json -public struct RepoDeleteRecord: Codable { - /// The decentralized identifier (DID) or handle of the user account. - /// - /// - Note: According to the AT Protocol specifications: "The handle or DID of the repo - /// (aka, current account)." - public let repositoryDID: String - /// The NSID of the record. - /// - /// - Note: According to the AT Protocol specifications: "The NSID of the record collection." - public let collection: String - /// The record key of the record. - /// - /// - Note: According to the AT Protocol specifications: "The Record Key." - public let recordKey: String - /// Swap the record on the server with this current record based on the CID of the record on - /// the server. - /// - /// - Note: According to the AT Protocol specifications: "Compare and swap with the - /// previous record by CID." - public let swapRecord: String? - /// Swap the commit on the server with this current commit based on the CID of the commit - /// on the server. - /// - /// - Note: According to the AT Protocol specifications: "Compare and swap with the - /// previous commit by CID." - public let swapCommit: String? - - enum CodingKeys: String, CodingKey { - case repositoryDID = "repo" - case collection - case recordKey = "rkey" - case swapRecord - case swapCommit - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/AtprotoRepoDescribeRepo.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/AtprotoRepoDescribeRepo.swift deleted file mode 100644 index 09cbe5df5d..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/AtprotoRepoDescribeRepo.swift +++ /dev/null @@ -1,46 +0,0 @@ -// -// AtprotoRepoDescribeRepo.swift -// -// -// Created by Christopher Jr Riley on 2024-03-11. -// - -import Foundation - -/// The main data model definition for the output of describing the repository. -/// -/// - Note: According to the AT Protocol specifications: "Get information about an account -/// and repository, including the list of collections. Does not require auth." -/// -/// - SeeAlso: This is based on the [`com.atproto.repo.describeRepo`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/repo/describeRepo.json -public struct RepoDescribeRepoOutput: Codable { - /// The handle of the repository. - public let repositoryHandle: String - /// The decentralized identitifer (DID) of the repository. - public let repositoryDID: String - /// The DID Document of the repository. - /// - /// - Note: According to the AT Protocol specifications: "The complete DID document for - /// this account." - public let didDocument: DIDDocument - /// An array of collections related to the repository. - /// - /// - Note: According to the AT Protocol specifications: "List of all the collections (NSIDs) - /// for which this repo contains at least one record." - public let collections: [String] - /// Indicates whether the repository's handle is valid. - /// - /// - Note: According to the AT Protocol specifications: "Indicates if handle is currently - /// valid (resolves bi-directionally)." - public let isHandleCorrect: Bool - - enum CodingKeys: String, CodingKey { - case repositoryHandle = "handle" - case repositoryDID = "did" - case didDocument = "didDoc" - case collections - case isHandleCorrect = "handleIsCorrect" - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/AtprotoRepoGetRecord.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/AtprotoRepoGetRecord.swift deleted file mode 100644 index e9328a9cd3..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/AtprotoRepoGetRecord.swift +++ /dev/null @@ -1,83 +0,0 @@ -// -// AtprotoRepoGetRecord.swift -// -// -// Created by Christopher Jr Riley on 2024-01-29. -// - -import Foundation - -// MARK: - Main definition -/// The main data model definition for a record. -/// -/// - Note: According to the AT Protocol specifications: "Get a single record from a repository. -/// Does not require auth." -/// -/// - SeeAlso: This is based on the [`com.atproto.repo.getRecord`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/repo/getRecord.json -public struct RecordQuery: Codable { - /// The handle or decentralized identifier (DID) of the repo." - /// - /// - Note: According to the AT Protocol specifications: "The handle or DID of the repo." - public let repo: String - /// The NSID of the record. - /// - /// - Note: According to the AT Protocol specifications: "The NSID of the record collection." - public let collection: String - /// The record's key. - /// - //// - Note: According to the AT Protocol specifications: "The Record Key." - public let recordKey: String - /// The CID of the version of the record. Optional. If not specified, then return the most - /// recent version. - /// - /// - Note: According to the AT Protocol specifications: "The CID of the version of the record. - /// If not specified, then return the most recent version." - public let recordCID: String? = nil - - public init(repo: String, collection: String, recordKey: String) { - self.repo = repo - self.collection = collection - self.recordKey = recordKey - } - - enum CodingKeys: String, CodingKey { - case repo = "repo" - case collection = "collection" - case recordKey = "rkey" - case recordCID = "cid" - } -} - -// MARK: - -/// The main data model definition for the outpot of a record. -/// -/// - SeeAlso: This is based on the [`com.atproto.repo.getRecord`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/repo/getRecord.json -public struct RecordOutput: Codable { - /// The URI of the record. - public let recordURI: String - /// The CID hash for the record. - public let recordCID: String - /// The value for the record. - public let value: RecordValueReply? - - enum CodingKeys: String, CodingKey { - case recordURI = "uri" - case recordCID = "cid" - case value = "value" - } -} - -// MARK: - -/// The main data model definition for the outpot . -/// -/// - SeeAlso: This is based on the [`com.atproto.repo.getRecord`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/repo/getRecord.json -public struct RecordValueReply: Codable { - /// The reply reference of the record. - public let reply: ReplyReference? -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/AtprotoRepoImportRepo.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/AtprotoRepoImportRepo.swift deleted file mode 100644 index c722d6e7d8..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/AtprotoRepoImportRepo.swift +++ /dev/null @@ -1,21 +0,0 @@ -// -// AtprotoRepoImportRepo.swift -// -// -// Created by Christopher Jr Riley on 2024-03-11. -// - -import Foundation - -/// The main data model definition for importing a CAR file. -/// -/// - Note: According to the AT Protocol specifications: "Import a repo in the form of a CAR file. -/// Requires Content-Length HTTP header to be set." -/// -/// - SeeAlso: This is based on the [`com.atproto.repo.importRepo`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/repo/importRepo.json -public struct RepoImportRepo: Codable { - /// The repository data in the form of a CAR file. - public let repository: Data -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/AtprotoRepoListMissingBlobs.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/AtprotoRepoListMissingBlobs.swift deleted file mode 100644 index 78b1134275..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/AtprotoRepoListMissingBlobs.swift +++ /dev/null @@ -1,29 +0,0 @@ -// -// AtprotoRepoListMissingBlobs.swift -// -// -// Created by Christopher Jr Riley on 2024-03-11. -// - -import Foundation - -/// The main data model definition for the output of listing any missing blobs attached to the -/// user account. -/// -/// - Note: According to the AT Protocol specifications: "Returns a list of missing blobs for the -/// requesting account. Intended to be used in the account migration flow." -/// -/// - SeeAlso: This is based on the [`com.atproto.repo.listMissingBlobs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/repo/listMissingBlobs.json -public struct RepoListMissingBlobsOutput: Codable { - public let blobs: [RecordBlob] -} - -/// A data model definition for a record blob. -public struct RecordBlob: Codable { - /// The CID hash of the record. - public let recordCID: String - /// The URI of the record. - public let recordURI: String -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/AtprotoRepoListRecords.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/AtprotoRepoListRecords.swift deleted file mode 100644 index bfece951b3..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/AtprotoRepoListRecords.swift +++ /dev/null @@ -1,23 +0,0 @@ -// -// AtprotoRepoListRecords.swift -// -// -// Created by Christopher Jr Riley on 2024-03-11. -// - -import Foundation - -/// The main data model definition for the output of listing records. -/// -/// - Note: According to the AT Protocol specifications: "List a range of records in a repository, -/// matching a specific collection. Does not require auth." -/// -/// - SeeAlso: This is based on the [`com.atproto.repo.listRecords`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/repo/listRecords.json -public struct RepoListRecordsOutput: Codable { - /// The mark used to indicate the starting point for the next set of result. Optional. - public let cursor: String? - /// An array of records. - public let records: [RecordOutput] -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/AtprotoRepoPutRecord.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/AtprotoRepoPutRecord.swift deleted file mode 100644 index 3dd4689e8c..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/AtprotoRepoPutRecord.swift +++ /dev/null @@ -1,64 +0,0 @@ -// -// AtprotoRepoPutRecord.swift -// -// -// Created by Christopher Jr Riley on 2024-03-11. -// - -import Foundation - -/// The main data model definition for creating a record that replaces a previous record. -/// -/// - Note: According to the AT Protocol specifications: "Write a repository record, creating -/// or updating it as needed. Requires auth, implemented by PDS." -/// -/// - SeeAlso: This is based on the [`com.atproto.repo.putRecord`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/repo/putRecord.json -public struct RepoPutRecord: Codable { - /// The decentralized identifier (DID) or handle of the repository. - /// - /// - Note: According to the AT Protocol specifications: "The handle or DID of the repo - /// (aka, current account)." - public let repositoryDID: String - /// The NSID of the record. - /// - /// - Note: According to the AT Protocol specifications: "The NSID of the record collection." - public let collection: String - /// The record key of the collection. - /// - /// - Note: According to the AT Protocol specifications: "The Record Key." - public let recordKey: String - /// Indicates whether the record should be validated. Optional. - /// - /// - Note: According to the AT Protocol specifications: "Can be set to 'false' to skip Lexicon - /// schema validation of record data." - public let shouldValidate: Bool? - /// The record itself. - /// - /// - Note: According to the AT Protocol specifications: "The record to write." - public let record: UnknownType - /// Swaps the record in the server with the record contained in here. Optional. - /// - /// - Important: This field can be left blank. - /// - /// - Note: According to the AT Protocol specifications: "Compare and swap with the previous - /// record by CID. WARNING: nullable and optional field; may cause problems with - /// golang implementation" - public let swapRecord: String? - /// Swaps the commit in the server with the commit contained in here. Optional. - /// - /// - Note: According to the AT Protocol specifications: "Compare and swap with the previous - /// commit by CID." - public let swapCommit: String? - - enum CodingKeys: String, CodingKey { - case repositoryDID = "repo" - case collection - case recordKey = "rkey" - case shouldValidate = "validate" - case record - case swapRecord - case swapCommit - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/AtprotoRepoStrongRef.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/AtprotoRepoStrongRef.swift deleted file mode 100644 index b38293e7c5..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/AtprotoRepoStrongRef.swift +++ /dev/null @@ -1,39 +0,0 @@ -// -// AtProtoRepoStrongRef.swift -// -// -// Created by Christopher Jr Riley on 2024-01-25. -// - -import Foundation - -// MARK: - Main definition -/// The main data model definition for a strong reference. -/// -/// - Note: According to the AT Protocol specifications: "A URI with a content-hash fingerprint." -/// -/// - SeeAlso: This is based on the [`com.atproto.repo.strongRef`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/repo/strongRef.json -public struct StrongReference: Codable { - /// The URI for the record. - public let recordURI: String - /// The CID hash for the record. - public let cidHash: String - - public init(recordURI: String, cidHash: String) { - self.recordURI = recordURI - self.cidHash = cidHash - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - self.recordURI = try container.decode(String.self, forKey: .recordURI) - self.cidHash = try container.decode(String.self, forKey: .cidHash) - } - - enum CodingKeys: String, CodingKey { - case recordURI = "uri" - case cidHash = "cid" - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/AtprotoRepoUploadBlob.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/AtprotoRepoUploadBlob.swift deleted file mode 100644 index 6a8474f38b..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/AtprotoRepoUploadBlob.swift +++ /dev/null @@ -1,68 +0,0 @@ -// -// AtprotoRepoUploadBlob.swift -// -// -// Created by Christopher Jr Riley on 2024-02-05. -// - -import Foundation - -// MARK: - Main definition -/// The main data model definition for the image's query. -public struct ImageQuery: Encodable { - /// The data of the image. - public let imageData: Data - /// The file name of the image. - public let fileName: String - /// The alt text of the image, - public let altText: String? - - public init(imageData: Data, fileName: String, altText: String?) { - self.imageData = imageData - self.fileName = fileName - self.altText = altText - } -} - -// MARK: - -// TODO: Find a way to remove BlobContainer without breaking the JSON encoding. -// This will be here until a way to remove this without the issues of -// the JSON encoding are solved. -/// The container used for storing blobs within a record. -/// -/// - Note: This is a temporary measure and will be deleted once a better solution is made. -public struct BlobContainer: Codable { - /// The blob itself. - public let blob: UploadBlobOutput -} - -/// A data model for a definition of an output of uploading a blob. -public struct UploadBlobOutput: Codable { - /// The type of blob. - public let type: String? - /// The strong reference of the blob. - public let reference: BlobReference - /// The the MIME type. - /// - /// This can be a `.jpg`, `.png`, and `.gif` - public let mimeType: String - /// The size of the blob. - public let size: Int - - enum CodingKeys: String, CodingKey { - case type = "$type" - case reference = "ref" - case mimeType - case size - } -} - -/// A data model for a blob reference definition. -public struct BlobReference: Codable { - /// The link of the blob reference. - public let link: String - - enum CodingKeys: String, CodingKey { - case link = "$link" - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoApplyWrites.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoApplyWrites.swift index 9cb4a30fc0..d68f400a35 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoApplyWrites.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoApplyWrites.swift @@ -9,7 +9,7 @@ import Foundation extension ComAtprotoLexicon.Repository { - /// A request body model for applying batch CRUD transactions. + /// The main data model definition for applying batch CRUD transactions. /// /// - Note: According to the AT Protocol specifications: "Apply a batch transaction of /// repository creates, updates, and deletes. Requires auth, implemented by PDS." @@ -17,41 +17,8 @@ extension ComAtprotoLexicon.Repository { /// - SeeAlso: This is based on the [`com.atproto.repo.applyWrites`][github] lexicon. /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/repo/applyWrites.json - public struct ApplyWritesRequestBody: Codable { - - /// The decentralized identifier (DID) or handle of the repository. - /// - /// - Note: According to the AT Protocol specifications: "The handle or DID of the repo - /// (aka, current account)." - public let repositoryDID: String - - /// Indicates whether the operation should be validated. Optional. Defaults to `true`. - /// - /// - Note: According to the AT Protocol specifications: "Can be set to 'false' to skip - /// Lexicon schema validation of record data, for all operations." - public let shouldValidate: Bool? - - /// The write operation itself. - public let writes: [ATUnion.ApplyWritesUnion]? + public struct ApplyWrites: Codable { - /// Swaps out an operation based on the CID. Optional. - /// - /// - Important: If a value is entered in here, the entire operation will fail if there is - /// no matching value in the repository. - /// - /// - Note: According to the AT Protocol specifications: "If provided, the entire operation - /// will fail if the current repo commit CID does not match this value. Used to prevent - /// conflicting repo mutations." - public let swapCommit: String? - - enum CodingKeys: String, CodingKey { - case repositoryDID = "repo" - case shouldValidate = "validate" - case writes - case swapCommit - } - - // Enums /// A data model definition for a "Create" write operation. /// /// - Note: According to the AT Protocol specifications: "Operation which creates a @@ -126,4 +93,47 @@ extension ComAtprotoLexicon.Repository { } } } + + /// A request body model for applying batch CRUD transactions. + /// + /// - Note: According to the AT Protocol specifications: "Apply a batch transaction of + /// repository creates, updates, and deletes. Requires auth, implemented by PDS." + /// + /// - SeeAlso: This is based on the [`com.atproto.repo.applyWrites`][github] lexicon. + /// + /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/repo/applyWrites.json + public struct ApplyWritesRequestBody: Codable { + + /// The decentralized identifier (DID) or handle of the repository. + /// + /// - Note: According to the AT Protocol specifications: "The handle or DID of the repo + /// (aka, current account)." + public let repositoryDID: String + + /// Indicates whether the operation should be validated. Optional. Defaults to `true`. + /// + /// - Note: According to the AT Protocol specifications: "Can be set to 'false' to skip + /// Lexicon schema validation of record data, for all operations." + public let shouldValidate: Bool? + + /// The write operation itself. + public let writes: [ATUnion.ApplyWritesUnion]? + + /// Swaps out an operation based on the CID. Optional. + /// + /// - Important: If a value is entered in here, the entire operation will fail if there is + /// no matching value in the repository. + /// + /// - Note: According to the AT Protocol specifications: "If provided, the entire operation + /// will fail if the current repo commit CID does not match this value. Used to prevent + /// conflicting repo mutations." + public let swapCommit: String? + + enum CodingKeys: String, CodingKey { + case repositoryDID = "repo" + case shouldValidate = "validate" + case writes + case swapCommit + } + } } diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoListMissingBlobs.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoListMissingBlobs.swift index b0399b6502..0dc40fc1ed 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoListMissingBlobs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoListMissingBlobs.swift @@ -34,6 +34,6 @@ extension ComAtprotoLexicon.Repository { public struct ListMissingBlobsOutput: Codable { /// An array of blobs. - public let blobs: [RecordBlob] + public let blobs: [ComAtprotoLexicon.Repository.ListMissingBlobs.RecordBlob] } } diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoListRecords.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoListRecords.swift index 424720ecd4..06f7f86482 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoListRecords.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoListRecords.swift @@ -23,6 +23,6 @@ extension ComAtprotoLexicon.Repository { public let cursor: String? /// An array of records. - public let records: [RecordOutput] + public let records: [ComAtprotoLexicon.Repository.GetRecordOutput] } } diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerCheckAccountStatus.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerCheckAccountStatus.swift deleted file mode 100644 index b230f08087..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerCheckAccountStatus.swift +++ /dev/null @@ -1,65 +0,0 @@ -// -// AtprotoServerCheckAccountStatus.swift -// -// -// Created by Christopher Jr Riley on 2024-02-23. -// - -import Foundation - -/// A data model definition for the output of checking the user's account status. -/// -/// - Note: According to the AT Protocol specifications: "Returns the status of an account, especially as pertaining to import or recovery. Can be called many times over the course of an account migration. -/// Requires auth and can only be called pertaining to oneself." -/// -/// - SeeAlso: This is based on the [`com.atproto.server.checkAccountStatus`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/checkAccountStatus.json -public struct ServerCheckAccountStatusOutput: Codable { - /// Indicates whether the user's account has been activated. - public let isActivated: Bool - /// Indicates whether the user's account has a valid decentralized identifier (DID). - public let isValidDID: Bool - /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ - /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ - /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ - /// \ - /// Clarifications from Bluesky are needed in order to fully understand this item. - public let repositoryCommit: String - /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ - /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ - /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ - /// \ - /// Clarifications from Bluesky are needed in order to fully understand this item. - public let repositoryRev: String - /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ - /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ - /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ - /// \ - /// Clarifications from Bluesky are needed in order to fully understand this item. - public let repositoryBlocks: Int - /// The number of indexed records in the user's account. - public let indexedRecords: Int - /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ - /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ - /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ - /// \ - /// Clarifications from Bluesky are needed in order to fully understand this item. - public let privateStateValues: Int - /// The expected number of blobs in the user's account. - public let expectedBlobs: Int - /// The number of blobs imported into the user's account. - public let importedBlobs: Int - - enum CodingKeys: String, CodingKey { - case isActivated = "activated" - case isValidDID = "validDid" - case repositoryCommit = "repoCommit" - case repositoryRev = "repoRev" - case repositoryBlocks = "repoBlocks" - case indexedRecords - case privateStateValues - case expectedBlobs - case importedBlobs - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerConfirmEmail.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerConfirmEmail.swift deleted file mode 100644 index 80ee2fe0b9..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerConfirmEmail.swift +++ /dev/null @@ -1,22 +0,0 @@ -// -// AtprotoServerConfirmEmail.swift -// -// -// Created by Christopher Jr Riley on 2024-02-23. -// - -import Foundation - -/// The main data model of a definition for confirming emails. -/// -/// - Note: According to the AT Protocol specifications: "Confirm an email using a token from com.atproto.server.requestEmailConfirmation." -/// -/// - SeeAlso: This is based on the [`com.atproto.server.confirmEmail`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/confirmEmail.json -public struct ServerConfirmEmail: Codable { - /// The email of the user. - public let email: String - /// The token given to the user via email. - public let token: String -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerCreateAccount.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerCreateAccount.swift deleted file mode 100644 index bfd2ad791b..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerCreateAccount.swift +++ /dev/null @@ -1,73 +0,0 @@ -// -// AtprotoServerCreateAccount.swift -// -// -// Created by Christopher Jr Riley on 2024-02-23. -// - -import Foundation - -/// The main data model definition for creating an account. -/// -/// - Note: According to the AT Protocol specifications: "Create an account. Implemented by PDS." -/// -/// - SeeAlso: This is based on the [`com.atproto.server.createAccount`][github] lexicon. -/// -/// [github]: https://docs.bsky.app/docs/api/com-atproto-server-create-account -public struct ServerCreateAccount: Codable { - /// The email of the user. Optional. - public var email: String? = nil - /// The handle the user wishes to use. - /// - /// - Note: According to the AT Protocol specifications: "Requested handle for the account." - public let handle: String - /// A decentralized identifier (DID) that has existed before and will be used to be imported to the new account. Optional. - /// - /// - Note: According to the AT Protocol specifications: "Pre-existing atproto DID, being imported to a new account." - public var existingDID: String? = nil - /// The invite code for the user. Optional. - /// - /// - Note: Invite codes are no longer used in Bluesky. This is left here for legacy purposes, as well as for any federated networks that may use this feature. - public var inviteCode: String? = nil - /// A verification code. - public var verificationCode: String? = nil - /// A code that has come from a text message in the user's phone. Optional. - public var verificationPhone: String? = nil - /// The password the user will use for the account. Optional. - /// - /// - Note: According to the AT Protocol specifications: "Initial account password. May need to meet instance-specific password strength requirements." - public var password: String? = nil - /// DID PLC rotation key (aka, recovery key) to be included in PLC creation operation. Optional. - /// - /// - Note: The above documentation is taken directly from the AT Protocol apecifications. - public var recoveryKey: String? = nil - /// A signed DID PLC operation to be submitted as part of importing an existing account to this instance. NOTE: this optional field may be updated when full account migration is implemented. Optional. - /// - /// - Note: The above documentation is taken directly from the AT Protocol apecifications. - public var plcOp: UnknownType? = nil - - public init(email: String?, handle: String, existingDID: String?, inviteCode: String?, verificationCode: String?, verificationPhone: String?, - password: String?, recoveryKey: String?, plcOp: UnknownType?) { - self.email = email - self.handle = handle - self.existingDID = existingDID - self.inviteCode = inviteCode - self.verificationCode = verificationCode - self.verificationPhone = verificationCode - self.password = password - self.recoveryKey = recoveryKey - self.plcOp = plcOp - } - - enum CodingKeys: String, CodingKey { - case email - case handle - case existingDID = "did" - case inviteCode - case verificationCode - case verificationPhone - case password - case recoveryKey - case plcOp - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerCreateAppPassword.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerCreateAppPassword.swift deleted file mode 100644 index 2d131c9b8f..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerCreateAppPassword.swift +++ /dev/null @@ -1,61 +0,0 @@ -// -// AtprotoServerCreateAppPassword.swift -// -// -// Created by Christopher Jr Riley on 2024-02-24. -// - -import Foundation - -/// The main data model definition for creating an App Password. -/// -/// - Note: According to the AT Protocol specifications: "Create an App Password." -/// -/// - SeeAlso: This is based on the [`com.atproto.server.createAppPassword`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/createAppPassword.json -public struct ServerCreateAppPassword: Codable { - /// The name given to the App Password to help distingush it from others. - /// - /// - Note: According to the AT Protocol specifications: "A short name for the App Password, to help distinguish them." - public let name: String -} - -/// A data model definition for creating an App Password. -public struct ServerCreateAppPasswordOutput: Codable { - /// The name given to the App Password to help distingush it from others. - /// - /// - Note: According to the AT Protocol specifications: "A short name for the App Password, to help distinguish them." - public let name: String - /// The password itself. - public let password: String - /// The date and time the App Password was created. - @DateFormatting public var createdAt: Date - - public init(name: String, password: String, createdAt: Date) { - self.name = name - self.password = password - self._createdAt = DateFormatting(wrappedValue: createdAt) - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.name = try container.decode(String.self, forKey: .name) - self.password = try container.decode(String.self, forKey: .password) - self.createdAt = try container.decode(DateFormatting.self.self, forKey: .createdAt).wrappedValue - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(self.name, forKey: .name) - try container.encode(self.password, forKey: .password) - try container.encode(self._createdAt, forKey: .createdAt) - } - - enum CodingKeys: CodingKey { - case name - case password - case createdAt - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerCreateInviteCode.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerCreateInviteCode.swift deleted file mode 100644 index 2f71167631..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerCreateInviteCode.swift +++ /dev/null @@ -1,38 +0,0 @@ -// -// AtprotoServerCreateInviteCode.swift -// -// -// Created by Christopher Jr Riley on 2024-02-24. -// - -import Foundation - -/// The main data model definition for creating an invite code. -/// -/// - Note: According to the AT Protocol specifications: "Create invite code." -/// -/// - SeeAlso: This is based on the [`com.atproto.server.createInviteCode`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/createInviteCode.json -public struct ServerCreateInviteCode: Codable { - /// The number of times the invite code(s) can be used. - public let useCount: Int - /// The decentralized identifier (DIDs) of the user that can use the invite code. Optional. - /// - /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ - /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ - /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ - /// \ - /// Clarifications from Bluesky are needed in order to fully understand this item. - public let forAccount: [String]? -} - -/// A data model definition of the output for creating an invite code. -/// -/// - SeeAlso: This is based on the [`com.atproto.server.createInviteCode`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/createInviteCode.json -public struct ServerCreateInviteCodeOutput: Codable { - /// An array of invite codes. - public let code: [String] -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerCreateInviteCodes.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerCreateInviteCodes.swift deleted file mode 100644 index 804b8b7073..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerCreateInviteCodes.swift +++ /dev/null @@ -1,58 +0,0 @@ -// -// AtprotoServerCreateInviteCodes.swift -// -// -// Created by Christopher Jr Riley on 2024-02-24. -// - -import Foundation - -/// The main data model definition for creating invite codes. -/// -/// - Note: According to the AT Protocol specifications: "Create invite codes." -/// -/// - SeeAlso: This is based on the [`com.atproto.server.createInviteCodes`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/createInviteCodes.json -public struct ServerCreateInviteCodes: Codable { - /// The number of invite codes to create. Defaults to 1. - public var codeCount: Int = 1 - /// The number of times the invite code(s) can be used. - public let useCount: Int - /// An array of decentralized identifiers (DIDs) that can use the invite codes. Optional. - /// - /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ - /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ - /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ - /// \ - /// Clarifications from Bluesky are needed in order to fully understand this item. - public let forAccounts: [String]? -} - -/// A data model definition of the output for creating invite codes. -/// -/// - SeeAlso: This is based on the [`com.atproto.server.createInviteCodes`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/createInviteCodes.json -public struct ServerCreateInviteCodesOutput: Codable { - /// An array of invite codes. - public let codes: [ServerAccountCodes] -} - -/// A data model definition of the server invite codes generated from ``ServerCreateInviteCodes``. -/// -/// - SeeAlso: This is based on the [`com.atproto.server.createInviteCodes`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/createInviteCodes.json -public struct ServerAccountCodes: Codable { - /// The account that holds the invite codes. - /// - /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ - /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ - /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ - /// \ - /// Clarifications from Bluesky are needed in order to fully understand this item. - public let account: String - /// An array of invite codes. - public let codes: [String] -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerCreateSession.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerCreateSession.swift deleted file mode 100644 index b4f87c8031..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerCreateSession.swift +++ /dev/null @@ -1,27 +0,0 @@ -// -// AtprotoServerCreateSession.swift -// -// -// Created by Christopher Jr Riley on 2024-02-07. -// - -import Foundation - -// MARK: - Main definition -/// The main data model definition for creating a session. -/// -/// - Note: According to the AT Protocol specifications: "Create an authentication session." -/// -/// - SeeAlso: This is based on the [`com.atproto.server.createSession`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/createSession.json -public struct SessionCredentials: Encodable { - /// The indentifier of the user's account (typically a handle). - /// - /// - Note: According to the AT Protocol specifications: "Handle or other identifier supported by the server for the authenticating user." - let identifier: String - /// The App Password of the user's account. - let password: String - /// A token used for Two-Factor Authentication. Optional. - let authenticationFactorToken: String? -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerDeactivateAccount.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerDeactivateAccount.swift deleted file mode 100644 index f5cadd6a1b..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerDeactivateAccount.swift +++ /dev/null @@ -1,43 +0,0 @@ -// -// AtprotoServerDeactivateAccount.swift -// -// -// Created by Christopher Jr Riley on 2024-02-24. -// - -import Foundation - -/// The main data model definition for deactivating an account. -/// -/// - Note: According to the AT Protocol specifications: "Deactivates a currently active account. Stops serving of repo, and future writes to repo until reactivated. Used to finalize account migration with the old host -/// after the account has been activated on the new host." -/// -/// - SeeAlso: This is based on the [`com.atproto.server.deactivateAccount`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/deactivateAccount.json -public struct ServerDeactivateAccount: Codable { - /// The date and time of when the server should delete the account. - /// - /// - Note: According to the AT Protocol specifications: "A recommendation to server as to how long they should hold onto the deactivated account before deleting." - @DateFormatting public var deleteAfter: Date - - public init(deleteAfter: Date) { - self._deleteAfter = DateFormatting(wrappedValue: deleteAfter) - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.deleteAfter = try container.decode(DateFormatting.self, forKey: .deleteAfter).wrappedValue - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self.deleteAfter, forKey: .deleteAfter) - } - - enum CodingKeys: CodingKey { - case deleteAfter - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerDefs.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerDefs.swift deleted file mode 100644 index 9e2c6bbab5..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerDefs.swift +++ /dev/null @@ -1,99 +0,0 @@ -// -// AtprotoServerDefs.swift -// -// -// Created by Christopher Jr Riley on 2024-01-25. -// - -import Foundation - -// MARK: - Main definition -/// The main data model definition for a server invite code. -/// -/// - SeeAlso: This is based on the [`com.atproto.server.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/defs.json -public struct ServerInviteCode: Codable { - /// The actual invite code. - public let code: String - /// The number of codes available. - public let available: Int - /// Indicates whether the invite code is disabled. - public let isDisabled: Bool - /// The user who holds the invite codes. - public let forAccount: String - /// The name of the user who currently holds the account. - public let createdBy: String - /// The date and time the invite codes were created. - @DateFormatting public var createdAt: Date - /// An array of the invite code uses. - public let uses: [ServerInviteCodeUse] - - public init(code: String, available: Int, isDisabled: Bool, forAccount: String, createdBy: String, createdAt: Date, uses: [ServerInviteCodeUse]) { - self.code = code - self.available = available - self.isDisabled = isDisabled - self.forAccount = forAccount - self.createdBy = createdBy - self._createdAt = DateFormatting(wrappedValue: createdAt) - self.uses = uses - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.code = try container.decode(String.self, forKey: .code) - self.available = try container.decode(Int.self, forKey: .available) - self.isDisabled = try container.decode(Bool.self, forKey: .isDisabled) - self.forAccount = try container.decode(String.self, forKey: .forAccount) - self.createdBy = try container.decode(String.self, forKey: .createdBy) - self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue - self.uses = try container.decode([ServerInviteCodeUse].self, forKey: .uses) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self.code, forKey: .code) - try container.encode(self.available, forKey: .available) - try container.encode(self.isDisabled, forKey: .isDisabled) - try container.encode(self.forAccount, forKey: .forAccount) - try container.encode(self.createdBy, forKey: .createdBy) - try container.encode(self._createdAt, forKey: .createdAt) - try container.encode(self.uses, forKey: .uses) - } - - enum CodingKeys: String, CodingKey { - case code - case available - case isDisabled = "disabled" - case forAccount - case createdBy - case createdAt - case uses - } -} - -/// A data model for a definition for the invite code's use. -/// -/// - SeeAlso: This is based on the [`com.atproto.server.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/defs.json -public struct ServerInviteCodeUse: Codable { - /// Who used the invite code. - public let usedBy: String - /// The date and time the service code was used. - @DateFormatting public var usedAt: Date - - public init(usedBy: String, usedAt: Date) { - self.usedBy = usedBy - self._usedAt = DateFormatting(wrappedValue: usedAt) - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.usedBy = try container.decode(String.self, forKey: .usedBy) - self.usedAt = try container.decode(DateFormatting.self, forKey: .usedAt).wrappedValue - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerDeleteAccount.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerDeleteAccount.swift deleted file mode 100644 index 2a7f1ea016..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerDeleteAccount.swift +++ /dev/null @@ -1,30 +0,0 @@ -// -// AtprotoServerDeleteAccount.swift -// -// -// Created by Christopher Jr Riley on 2024-02-24. -// - -import Foundation - -/// The main data model definition for deleting an account. -/// -/// - Note: According to the AT Protocol specifications: "Delete an actor's account with a token and password. Can only be called after requesting a deletion token. Requires auth." -/// -/// - SeeAlso: This is based on the [`com.atproto.server.deleteAccount`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/deleteAccount.json -public struct ServerDeleteAccount: Codable { - /// The decentralized identifier (DID) of the account. - public let accountDID: String - /// The main password of the account. - /// - /// - Note: This is not the App Password. - public let accountPassword: String - /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ - /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ - /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ - /// \ - /// Clarifications from Bluesky are needed in order to fully understand this item. - public let token: String -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerDescribeServer.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerDescribeServer.swift deleted file mode 100644 index 7c0755171a..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerDescribeServer.swift +++ /dev/null @@ -1,78 +0,0 @@ -// -// AtprotoServerDescribeServer.swift -// -// -// Created by Christopher Jr Riley on 2024-02-25. -// - -import Foundation - -/// A data model definition for the output of retrieving a description of the server. -/// -/// - Note: According to the AT Protocol specifications: "Describes the server's account creation requirements and capabilities. Implemented by PDS." -/// -/// - SeeAlso: This is based on the [`com.atproto.server.describeServer`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/describeServer.json -public struct ServerDescribeServerOutput: Codable { - /// Indicates whether an invite code is required to join the server. Optional. - /// - /// - Note: According to the AT Protocol specifications: "If true, an invite code must be supplied to create an account on this instance." - public let isInviteCodeRequired: Bool? - /// Indicates whether the user is required to verify using a phone number. Optional. - /// - /// - Note: According to the AT Protocol specifications: "If true, a phone verification token must be supplied to create an account on this instance." - public let isPhoneVerificationRequired: Bool? - /// An array of available user domains. - /// - /// - Note: According to the AT Protocol specifications: "List of domain suffixes that can be used in account handles." - public let availableUserDomains: [String] - /// A group of URLs for the server's service policies. Optional. - /// - /// - Note: According to the AT Protocol specifications: "URLs of service policy documents." - public let servicePolicyURLs: ServerServicePolicyURLs - /// The contact information for the server. - /// - /// - Note: According to the AT Protocol specifications: "Contact information." - public let contactInformation: ServerContactInformation - /// The decentralized identifier (DID) of the server. - public let serverDID: String - - enum CodingKeys: String, CodingKey { - case isInviteCodeRequired = "inviteCodeRequired" - case isPhoneVerificationRequired = "phoneVerificationRequired" - case availableUserDomains - case servicePolicyURLs = "links" - case contactInformation = "contact" - case serverDID = "did" - } -} - -/// A data model definition of service policy URLs. -/// -/// - Note: According to the AT Protocol specifications: "Describes the server's account creation requirements and capabilities. Implemented by PDS." -/// -/// - SeeAlso: This is based on the [`com.atproto.server.describeServer`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/describeServer.json -public struct ServerServicePolicyURLs: Codable { - /// The URL for the server's Privacy Policy. Optional. - public let privacyPolicyURL: URL? - /// The URL for the server's Terms of Service. Optional. - public let termsOfServiceURL: URL? - - enum CodingKeys: String, CodingKey { - case privacyPolicyURL = "privacyPolicy" - case termsOfServiceURL = "termsOfService" - } -} - -/// A data model definition of the server's contact information. -/// -/// - SeeAlso: This is based on the [`com.atproto.server.describeServer`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/describeServer.json -public struct ServerContactInformation: Codable { - /// The email address users can use to contact the server owner. - public let email: String -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerGetAccountInviteCodes.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerGetAccountInviteCodes.swift deleted file mode 100644 index 94de42c099..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerGetAccountInviteCodes.swift +++ /dev/null @@ -1,18 +0,0 @@ -// -// AtprotoServerGetAccountInviteCodes.swift -// -// -// Created by Christopher Jr Riley on 2024-02-25. -// - -import Foundation - -/// A data model definition for the output of getting the invite codes of the user's account. -/// -/// - SeeAlso: This is based on the [`com.atproto.server.getAccountInviteCodes`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/getAccountInviteCodes.json -public struct ServerGetAccountInviteCodesOutput: Codable { - /// An array of the user's invite codes. - public let code: [ServerInviteCode] -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerGetServiceAuth.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerGetServiceAuth.swift deleted file mode 100644 index 7b08c32630..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerGetServiceAuth.swift +++ /dev/null @@ -1,20 +0,0 @@ -// -// AtprotoServerGetServiceAuth.swift -// -// -// Created by Christopher Jr Riley on 2024-02-25. -// - -import Foundation - -/// A data model definition for the output of getting the signed token for the service. -/// -/// - Note: According to the AT Protocol specifications: "Get a signed token on behalf of the requesting DID for the requested service." -/// -/// - SeeAlso: This is based on the [`com.atproto.server.getServiceAuth`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/getServiceAuth.json -public struct ServerGetServiceAuthOutput: Codable { - /// The token for the requested service. - public let token: String -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerListAppPasswords.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerListAppPasswords.swift deleted file mode 100644 index 6f4f0c7e2b..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerListAppPasswords.swift +++ /dev/null @@ -1,56 +0,0 @@ -// -// AtprotoServerListAppPasswords.swift -// -// -// Created by Christopher Jr Riley on 2024-02-25. -// - -import Foundation - -/// A data model definition of the of listing App Passwords. -/// -/// - Note: According to the AT Protocol specifications: "List all App Passwords." -/// -/// - SeeAlso: This is based on the [`com.atproto.server.listAppPasswords`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/listAppPasswords.json -public struct ServerListAppPasswordsOutput: Codable { - /// An array of App Passwords. - public let passwords: [ServerAppPassword] -} - -/// A data model definition of App Password information. -/// -/// - SeeAlso: This is based on the [`com.atproto.server.listAppPasswords`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/listAppPasswords.json -public struct ServerAppPassword: Codable { - /// The name associated with the App Password. - public let name: String - /// The date and date the App Password was created. - @DateFormatting public var createdAt: Date - - public init(name: String, createdAt: Date) { - self.name = name - self._createdAt = DateFormatting(wrappedValue: createdAt) - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.name = try container.decode(String.self, forKey: .name) - self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self.name, forKey: .name) - try container.encode(self._createdAt, forKey: .createdAt) - } - - enum CodingKeys: CodingKey { - case name - case createdAt - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerRequestEmailUpdate.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerRequestEmailUpdate.swift deleted file mode 100644 index 4edcf3310a..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerRequestEmailUpdate.swift +++ /dev/null @@ -1,24 +0,0 @@ -// -// AtprotoServerRequestEmailUpdate.swift -// -// -// Created by Christopher Jr Riley on 2024-02-26. -// - -import Foundation - -/// A data model definition for the output of requesting to update the user's email address. -/// -/// - Note: According to the AT Protocol specifications: "Request a token in order to update email." -/// -/// - SeeAlso: This is based on the [`com.atproto.server.requestEmailUpdate`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/requestEmailUpdate.json -public struct RequestEmailUpdateOutput: Codable { - /// Indicates whether a token is required. - public let isTokenRequired: Bool - - enum CodingKeys: String, CodingKey { - case isTokenRequired = "tokenRequired" - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerRequestPasswordReset.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerRequestPasswordReset.swift deleted file mode 100644 index a321fe1d09..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerRequestPasswordReset.swift +++ /dev/null @@ -1,20 +0,0 @@ -// -// AtprotoServerRequestPasswordReset.swift -// -// -// Created by Christopher Jr Riley on 2024-02-26. -// - -import Foundation - -/// The main data model definition for resetting the user's password. -/// -/// - Note: According to the AT Protocol specifications: "Initiate a user account password reset via email." -/// -/// - SeeAlso: This is based on the [`com.atproto.server.requestPasswordReset`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/requestPasswordReset.json -public struct ServerRequestPasswordReset: Codable { - /// The email address associated with the user's account. - public let email: String -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerReserveSigningKey.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerReserveSigningKey.swift deleted file mode 100644 index 50e4dde1b3..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerReserveSigningKey.swift +++ /dev/null @@ -1,39 +0,0 @@ -// -// AtprotoServerReserveSigningKey.swift -// -// -// Created by Christopher Jr Riley on 2024-02-25. -// - -import Foundation - -/// The main data model definition for reversing signing keys. -/// -/// - Note: According to the AT Protocol specifications: "Reserve a repo signing key, for use with account creation. Necessary so that a DID PLC update operation can be constructed during an account migraiton. -/// Public and does not require auth; implemented by PDS. NOTE: this endpoint may change when full account migration is implemented." -/// -/// - SeeAlso: This is based on the [`com.atproto.server.reserveSigningKey`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/reserveSigningKey.json -public struct ServerReserveSigningKey: Codable { - /// The decentralized identifier (DID) of the repository that will use the signing key. - /// - /// - Note: According to the AT Protocol specifications: "The DID to reserve a key for." - public let repositoryDID: String - - enum CodingKeys: String, CodingKey { - case repositoryDID = "did" - } -} - -/// A data model definition for the output of reversing a signing keys. -/// -/// - SeeAlso: This is based on the [`com.atproto.server.reserveSigningKey`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/reserveSigningKey.json -public struct ServerReserveSigningKeyOutput: Codable { - /// The signing key itself. - /// - /// - Note: According to the AT Protocol specifications: "The public key for the reserved signing key, in did:key serialization." - public let signingKey: String -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerResetPassword.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerResetPassword.swift deleted file mode 100644 index 9cf9992e11..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerResetPassword.swift +++ /dev/null @@ -1,27 +0,0 @@ -// -// AtprotoServerResetPassword.swift -// -// -// Created by Christopher Jr Riley on 2024-02-26. -// - -import Foundation - -/// The main data model definition for resetting a password. -/// -/// - Note: According to the AT Protocol specifications: "Reset a user account password using a token." -/// -/// - SeeAlso: This is based on the [`com.atproto.server.resetPassword`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/resetPassword.json -public struct ServerResetPassword: Codable { - /// The token used to reset the password. - public let token: String - /// The new password for the user's account. - public let newPassword: String - - enum CodingKeys: String, CodingKey { - case token - case newPassword = "password" - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerRevokeAppPassword.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerRevokeAppPassword.swift deleted file mode 100644 index 35a04507de..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerRevokeAppPassword.swift +++ /dev/null @@ -1,24 +0,0 @@ -// -// AtprotoServerRevokeAppPassword.swift -// -// -// Created by Christopher Jr Riley on 2024-02-27. -// - -import Foundation - -/// The main data model definition for revoking a password. -/// -/// - Note: According to the AT Protocol specifications: "Revoke an App Password by name." -/// -/// - SeeAlso: This is based on the [`com.atproto.server.revokeAppPassword`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/revokeAppPassword.json -public struct ServerRevokeAppPassword: Codable { - /// The name associated with the App Password. - public let appPasswordName: String - - enum CodingKeys: String, CodingKey { - case appPasswordName = "name" - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerUpdateEmail.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerUpdateEmail.swift deleted file mode 100644 index 110db608c2..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/AtprotoServerUpdateEmail.swift +++ /dev/null @@ -1,33 +0,0 @@ -// -// AtprotoServerUpdateEmail.swift -// -// -// Created by Christopher Jr Riley on 2024-02-27. -// - -import Foundation - -/// The main data model definition for updating the user's email address. -/// -/// - Note: According to the AT Protocol specifications: "Update an account's email." -/// -/// - SeeAlso: This is based on the [`com.atproto.server.updateEmail`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/updateEmail.json -public struct ServerUpdateEmail: Codable { - /// The email associated with the user's account. - public let email: String - /// Indicates whether Two-Factor Authentication (via email) is enabled. Optional. - public let isEmailAuthenticationFactorEnabled: Bool? - /// The token that's used if the email has been confirmed. Optional. - /// - /// - Note: According to the AT Protocol specifications: "Requires a token from com.atproto.sever.requestEmailUpdate if the account's email has - /// been confirmed." - public let token: String? - - enum CodingKeys: String, CodingKey { - case email - case isEmailAuthenticationFactorEnabled = "emailAuthFactor" - case token - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerDefs.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerDefs.swift index f86bcccbe5..81a828784f 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerDefs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerDefs.swift @@ -35,9 +35,10 @@ extension ComAtprotoLexicon.Server { @DateFormatting public var createdAt: Date /// An array of the invite code uses. - public let uses: [ServerInviteCodeUse] + public let uses: [ComAtprotoLexicon.Server.InviteCodeUseDefinition] - public init(code: String, available: Int, isDisabled: Bool, forAccount: String, createdBy: String, createdAt: Date, uses: [ServerInviteCodeUse]) { + public init(code: String, available: Int, isDisabled: Bool, forAccount: String, createdBy: String, createdAt: Date, + uses: [ComAtprotoLexicon.Server.InviteCodeUseDefinition]) { self.code = code self.available = available self.isDisabled = isDisabled @@ -56,7 +57,7 @@ extension ComAtprotoLexicon.Server { self.forAccount = try container.decode(String.self, forKey: .forAccount) self.createdBy = try container.decode(String.self, forKey: .createdBy) self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue - self.uses = try container.decode([ServerInviteCodeUse].self, forKey: .uses) + self.uses = try container.decode([ComAtprotoLexicon.Server.InviteCodeUseDefinition].self, forKey: .uses) } public func encode(to encoder: Encoder) throws { diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerGetAccountInviteCodes.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerGetAccountInviteCodes.swift index 9c241200a9..9a37494787 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerGetAccountInviteCodes.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerGetAccountInviteCodes.swift @@ -17,6 +17,6 @@ extension ComAtprotoLexicon.Server { public struct GetAccountInviteCodesOutput: Codable { /// An array of the user's invite codes. - public let code: [ServerInviteCode] + public let code: [ComAtprotoLexicon.Server.InviteCodeDefinition] } } diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/AtprotoSyncCrawler.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/AtprotoSyncCrawler.swift deleted file mode 100644 index 291fcd0696..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/AtprotoSyncCrawler.swift +++ /dev/null @@ -1,36 +0,0 @@ -// -// AtprotoSyncCrawler.swift -// -// -// Created by Christopher Jr Riley on 2024-03-14. -// - -import Foundation - -/// The main data model definition for the crawling service. -/// -/// - Note: According to the AT Protocol specifications:\ -/// `com.atproto.sync.notifyOfUpdate`: "Notify a crawling service of a recent update, and that -/// crawling should resume. Intended use is after a gap between repo stream events caused the -/// crawling service to disconnect. Does not require auth; implemented by Relay." \ -/// \ -/// `com.atproto.sync.requestCrawl`: "Request a service to persistently crawl hosted repos. -/// Expected use is new PDS instances declaring their existence to Relays. Does not require auth." -/// -/// - SeeAlso: This is based on the following lexicons:\ -/// \- [`com.atproto.sync.notifyOfUpdate`][notifyOfUpdate]\ -/// \- [`com.atproto.sync.requestCrawl`][requestCrawl] -/// -/// [notifyOfUpdate]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/sync/notifyOfUpdate.json -/// [requestCrawl]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/sync/requestCrawl.json -public struct SyncCrawler: Codable { - /// The hostname that the crawling service resides in. - /// - /// - Note: According to the AT Protocol specifications: "Hostname of the current service - /// (usually a PDS) that is notifying of update." - public let crawlingHostname: URL - - enum CodingKeys: String, CodingKey { - case crawlingHostname = "hostname" - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/AtprotoSyncGetBlob.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/AtprotoSyncGetBlob.swift deleted file mode 100644 index 82223dd76a..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/AtprotoSyncGetBlob.swift +++ /dev/null @@ -1,36 +0,0 @@ -// -// AtprotoSyncGetBlob.swift -// -// -// Created by Christopher Jr Riley on 2024-02-10. -// - -import Foundation - -// MARK: - Main definition -/// The main data model definition for getting a blob. -/// -/// - Note: According to the AT Protocol specifications: "Get a blob associated with a -/// given account. Returns the full blob as originally uploaded. Does not require auth; -/// implemented by PDS." -/// -/// - SeeAlso: This is based on the [`com.atproto.sync.getBlob`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/sync/getBlob.json -public struct BlobQuery: Encodable { - /// The decentralized identifier (DID) of the user's account. - /// - /// - Note: According to the AT Protocol specifications: "The DID of the account." - public let accountDID: String - /// The CID hash of the blob. - /// - /// - Note: According to the AT Protocol specifications: "The CID of the blob to fetch." - /// - Note: Make sure to use `BlobReference.link` if you're grabbing it straight - /// from ``UploadBlobOutput``. - public let cidHash: String - - public init(accountDID: String, cidHash: String) { - self.accountDID = accountDID - self.cidHash = cidHash - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/AtprotoSyncGetBlocks.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/AtprotoSyncGetBlocks.swift deleted file mode 100644 index 7703ae7fc6..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/AtprotoSyncGetBlocks.swift +++ /dev/null @@ -1,29 +0,0 @@ -// -// AtprotoSyncGetBlocks.swift -// -// -// Created by Christopher Jr Riley on 2024-03-12. -// - -import Foundation - -/// The main data model definition for the output of getting a repository's blocks. -/// -/// - Note: According to the AT Protocol specifications: "Get data blocks from a given repo, by -/// CID. For example, intermediate MST nodes, or records. Does not require auth; implemented -/// by PDS." -/// -/// - SeeAlso: This is based on the [`com.atproto.sync.getBlocks`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/sync/getBlocks.json -public struct SyncGetBlocksOutput: Codable { - /// The decentralized identifier (DID) of the repository. - public let repositoryDID: String - /// An array of CID hashes from the repository. - public let repositoryCIDHashes: [String] - - enum CodingKeys: String, CodingKey { - case repositoryDID = "did" - case repositoryCIDHashes = "cids" - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/AtprotoSyncGetLatestCommit.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/AtprotoSyncGetLatestCommit.swift deleted file mode 100644 index e4ada303ee..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/AtprotoSyncGetLatestCommit.swift +++ /dev/null @@ -1,28 +0,0 @@ -// -// AtprotoSyncGetLatestCommit.swift -// -// -// Created by Christopher Jr Riley on 2024-03-12. -// - -import Foundation - -/// The main data model definition for the output of getting a repository's latest commit CID. -/// -/// - Note: According to the AT Protocol specifications: "Get the current commit CID & revision -/// of the specified repo. Does not require auth." -/// -/// - SeeAlso: This is based on the [`com.atproto.sync.getLatestCommit`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/sync/getLatestCommit.json -public struct SyncGetLatestCommitOutput: Codable { - /// The commit CID of the repository. - public let commitCID: String - /// The repository's revision. - public let revision: String - - enum CodingKeys: String, CodingKey { - case commitCID = "cid" - case revision = "rev" - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/AtprotoSyncListBlobs.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/AtprotoSyncListBlobs.swift deleted file mode 100644 index 0710fccf02..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/AtprotoSyncListBlobs.swift +++ /dev/null @@ -1,28 +0,0 @@ -// -// AtprotoSyncListBlobs.swift -// -// -// Created by Christopher Jr Riley on 2024-03-13. -// - -import Foundation - -/// The main data model definition for the output of a user account's blob CID hashes. -/// -/// - Note: According to the AT Protocol specifications: "List blob CIDs for an account, since -/// some repo revision. Does not require auth; implemented by PDS." -/// -/// - SeeAlso: This is based on the [`com.atproto.sync.listBlobs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/sync/listBlobs.json -public struct SyncListBlobsOutput: Codable { - /// The mark used to indicate the starting point for the next set of results. Optional. - public let cursor: String? - /// An array of CID hashes from a user account. - public let accountCIDHashes: [String] - - enum CodingKeys: String, CodingKey { - case cursor - case accountCIDHashes = "cids" - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/AtprotoSyncListRepos.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/AtprotoSyncListRepos.swift deleted file mode 100644 index 2af96b731c..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/AtprotoSyncListRepos.swift +++ /dev/null @@ -1,48 +0,0 @@ -// -// AtprotoSyncListRepos.swift -// -// -// Created by Christopher Jr Riley on 2024-03-14. -// - -import Foundation - -/// The main data model definition for the output of listing all decentralized identifiers (DIDs), -/// revisions, and commit CID hashes of given repositiories. -/// -/// - Note: According to the AT Protocol specifications: "Enumerates all the DID, rev, and commit -/// CID for all repos hosted by this service. Does not require auth; -/// implemented by PDS and Relay." -/// -/// - SeeAlso: This is based on the [`com.atproto.sync.listRepos`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/sync/listRepos.json -public struct SyncListReposOutput: Codable { - /// The mark used to indicate the starting point for the next set of results. Optional. - public let cursor: String? - /// An array of repositories. - public let repositories: [SyncRepository] - - enum CodingKeys: String, CodingKey { - case cursor - case repositories = "repos" - } -} - -/// A data model definition for a repository. -public struct SyncRepository: Codable { - /// The decentralized identifier (DID) of the repository. - public let repositoryDID: String - /// The commit CID hash of the repository. - /// - /// - Note: According to the AT Protocol specifications: "Current repo commit CID." - public let commitCID: String - /// The repository's revision. - public let revision: String - - enum CodingKeys: String, CodingKey { - case repositoryDID = "did" - case commitCID = "head" - case revision = "rev" - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/AtprotoSyncSubscribeRepos.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/AtprotoSyncSubscribeRepos.swift deleted file mode 100644 index c4266d57b2..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Sync/AtprotoSyncSubscribeRepos.swift +++ /dev/null @@ -1,23 +0,0 @@ -// -// AtprotoSyncSubscribeRepos.swift -// -// -// Created by Christopher Jr Riley on 2024-03-14. -// - -import Foundation - -/// The main data model definition for the firehose service. -/// -/// - Note: According to the AT Protocol specifications: "Repository event stream, aka Firehose -/// endpoint. Outputs repo commits with diff data, and identity update events, for all repositories -/// on the current server. See the atproto specifications for details around stream sequencing, -/// repo versioning, CAR diff format, and more. Public and does not require auth; implemented -/// by PDS and Relay." -/// -/// - SeeAlso: This is based on the [`com.atproto.sync.subscribeRepos`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/sync/subscribeRepos.json -public struct SyncSubscribeRepos: Codable { - -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Temp/AtprotoTempCheckSignupQueue.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Temp/AtprotoTempCheckSignupQueue.swift deleted file mode 100644 index 34430d385d..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Temp/AtprotoTempCheckSignupQueue.swift +++ /dev/null @@ -1,26 +0,0 @@ -// -// AtprotoTempCheckSignupQueue.swift -// -// -// Created by Christopher Jr Riley on 2024-03-17. -// - -import Foundation - -/// The main data model definition for the output of retrieving information about the sign up queue. -/// -/// - Important: The lexicon associated with this model may be removed at any time. This may not work. -/// -/// - Note: According to the AT Protocol specifications: "Check accounts location in signup queue." -/// -/// - SeeAlso: This is based on the [`com.atproto.temp.checkSignupQueue`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/temp/checkSignupQueue.json -public struct TempCheckSignupQueueOutput: Codable { - /// Indicates whether the user with the queried username has been activated. - public let isActivated: Bool - /// The user's place in queue. Optional. - public let placeInQueue: Int? - /// The estimated amount of time before the user can use the service (in minutes). Optional. - public let estimatedTimeinMinutes: Int -} diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Temp/AtprotoTempRequestPhoneVerification.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Temp/AtprotoTempRequestPhoneVerification.swift deleted file mode 100644 index f063550f71..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Temp/AtprotoTempRequestPhoneVerification.swift +++ /dev/null @@ -1,22 +0,0 @@ -// -// AtprotoTempRequestPhoneVerification.swift -// -// -// Created by Christopher Jr Riley on 2024-03-17. -// - -import Foundation - -/// The main data model definition for requesting a text code from a phone number. -/// -/// - Important: The lexicon associated with this model may be removed at any time. This may not work. -/// -/// - Note: According to the AT Protocol specifications: "Request a verification code to be sent to the supplied phone number." -/// -/// - SeeAlso: This is based on the [`com.atproto.temp.requestPhoneVerification`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/temp/requestPhoneVerification.json -public struct TempRequestPhoneVerification: Codable { - /// The user's mobile phone number. - public let phoneNumber: String -} diff --git a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/OzoneCommunicationCreateTemplate.swift b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/OzoneCommunicationCreateTemplate.swift deleted file mode 100644 index 46597dbdab..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/OzoneCommunicationCreateTemplate.swift +++ /dev/null @@ -1,38 +0,0 @@ -// -// OzoneCommunicationCreateTemplate.swift -// -// -// Created by Christopher Jr Riley on 2024-02-27. -// - -import Foundation - -/// The main data model definition for creating a communication template. -/// -/// - Note: According to the AT Protocol specifications: "Administrative action to create a -/// new, re-usable communication (email for now) template." -/// -/// - SeeAlso: This is based on the [`tools.ozone.communication.createTemplate`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/communication/createTemplate.json -public struct CommunicationCreateTemplate: Codable { - /// The name of the template. - /// - /// - Note: According to the AT Protocol specifications: "Name of the template." - public let name: String - /// A Markdown-formatted content of the communitcation template. - /// - /// - Note: According to the AT Protocol specifications: "Content of the template, markdown - /// supported, can contain variable placeholders." - public let contentMarkdown: String - /// The subject line of the communication template. - /// - /// - Note: According to the AT Protocol specifications: "Subject of the message, used - /// in emails." - public let subject: String - /// The decentralized identifier (DID) of the creator of the communication template. Optional. - /// - /// - Note: According to the AT Protocol specifications: "DID of the user who is creating - /// the template." - public let createdBy: String? -} diff --git a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/OzoneCommunicationDefs.swift b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/OzoneCommunicationDefs.swift deleted file mode 100644 index 11b4deb829..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/OzoneCommunicationDefs.swift +++ /dev/null @@ -1,94 +0,0 @@ -// -// OzoneCommunicationDefs.swift -// -// -// Created by Christopher Jr Riley on 2024-03-14. -// - -import Foundation - -/// A data model definition for a communication template. -/// -/// - SeeAlso: This is based on the [`tools.ozone.communication.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/communication/defs.json -public struct OzoneCommunicationTemplateView: Codable { - /// The ID of the communication template. - public let id: Int - /// The name of the communication template. - /// - /// - Note: According to the AT Protocol specifications: "Name of the template." - public let name: String - /// The subject of the message. Optional. - /// - /// - Note: According to the AT Protocol specifications: "Subject of the message, used - /// in emails." - public var subject: String? = nil - /// The content of the communication template. Optional. - /// - /// This may contain Markdown placeholders and variable placeholders. - /// - /// - Note: According to the AT Protocol specifications: "Content of the template, can contain - /// markdown and variable placeholders." - public let contentMarkdown: String - /// Indicates whether the communication template has been disabled. - public let isDisabled: Bool - /// The decentralized identifier (DID) of the user who last updated the communication template. - /// - /// - Note: According to the AT Protocol specifications: "DID of the user who last updated - /// the template." - public let lastUpdatedBy: String - /// The date and time the communication template was created. - @DateFormatting public var createdAt: Date - /// The date and time the communication template was updated. - @DateFormatting public var updatedAt: Date - - public init(id: Int, name: String, subject: String? = nil, contentMarkdown: String, isDisabled: Bool, lastUpdatedBy: String, - createdAt: Date, updatedAt: Date) { - self.id = id - self.name = name - self.subject = subject - self.contentMarkdown = contentMarkdown - self.isDisabled = isDisabled - self.lastUpdatedBy = lastUpdatedBy - self._createdAt = DateFormatting(wrappedValue: createdAt) - self._updatedAt = DateFormatting(wrappedValue: updatedAt) - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.id = try container.decode(Int.self, forKey: .id) - self.name = try container.decode(String.self, forKey: .name) - self.subject = try container.decodeIfPresent(String.self, forKey: .subject) - self.contentMarkdown = try container.decode(String.self, forKey: .contentMarkdown) - self.isDisabled = try container.decode(Bool.self, forKey: .isDisabled) - self.lastUpdatedBy = try container.decode(String.self, forKey: .lastUpdatedBy) - self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue - self.updatedAt = try container.decode(DateFormatting.self, forKey: .updatedAt).wrappedValue - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self.id, forKey: .id) - try container.encode(self.name, forKey: .name) - try container.encodeIfPresent(self.subject, forKey: .subject) - try container.encode(self.contentMarkdown, forKey: .contentMarkdown) - try container.encode(self.isDisabled, forKey: .isDisabled) - try container.encode(self.lastUpdatedBy, forKey: .lastUpdatedBy) - try container.encode(self._createdAt, forKey: .createdAt) - try container.encode(self._updatedAt, forKey: .updatedAt) - } - - enum CodingKeys: String, CodingKey { - case id - case name - case subject - case contentMarkdown - case isDisabled = "disabled" - case lastUpdatedBy - case createdAt - case updatedAt - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/OzoneCommunicationDeleteTemplate.swift b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/OzoneCommunicationDeleteTemplate.swift deleted file mode 100644 index e90d20ec04..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/OzoneCommunicationDeleteTemplate.swift +++ /dev/null @@ -1,20 +0,0 @@ -// -// OzoneCommunicationDeleteTemplate.swift -// -// -// Created by Christopher Jr Riley on 2024-02-28. -// - -import Foundation - -/// The main data model definition for deleting a communication template as an administrator. -/// -/// - Note: According to the AT Protocol specifications: "Delete a communication template." -/// -/// - SeeAlso: This is based on the [`tools.ozone.communication.deleteTemplate`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/communication/deleteTemplate.json -public struct CommunicationDeleteTemplate: Codable { - /// The ID of the communication template. - public let id: String -} diff --git a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/OzoneCommunicationListTemplates.swift b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/OzoneCommunicationListTemplates.swift deleted file mode 100644 index 30713f3ef7..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/OzoneCommunicationListTemplates.swift +++ /dev/null @@ -1,20 +0,0 @@ -// -// OzoneCommunicationListTemplates.swift -// -// -// Created by Christopher Jr Riley on 2024-05-01. -// - -import Foundation - -/// The output definition for retrieves a list of communication templates. -/// -/// - Note: According to the AT Protocol specifications: "Get list of all communication templates." -/// -/// - SeeAlso: This is based on the [`tools.ozone.communication.listTemplates`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/communication/listTemplates.json -public struct CommunicationListTemplatesOutput: Codable { - /// An array of communication templates. - public let communicationTemplates: [OzoneCommunicationTemplateView] -} diff --git a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/OzoneCommunicationUpdateTemplate.swift b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/OzoneCommunicationUpdateTemplate.swift deleted file mode 100644 index 0fbf2046bd..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Communication/OzoneCommunicationUpdateTemplate.swift +++ /dev/null @@ -1,43 +0,0 @@ -// -// OzoneCommunicationUpdateTemplate.swift -// -// -// Created by Christopher Jr Riley on 2024-05-01. -// - -import Foundation - -/// The main data model definition for updating a communication template. -/// -/// - Note: According to the AT Protocol specifications: "Administrative action to update an -/// existing communication template. Allows passing partial fields to patch specific fields only." -/// -/// - SeeAlso: This is based on the [`tools.ozone.communication.updateTemplate`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/communication/updateTemplate.json -public struct CommunicationUpdateTemplate: Codable { - /// The ID of the communication template. - public let id: String - /// The name of the communication template. Optional. - public let name: String? - /// The content of the communication template. Optional. - /// - /// This may contain Markdown placeholders and variable placeholders. - public let contentMarkdown: String? - /// The subject line of the message itself. Optional. - public let subject: String? - /// The decentralized identifier (DID) of the user who updated the - /// communication template. Optional. - public let updatedBy: String? - /// Indicates whether the communication template is disabled. Optional. - public let isDisabled: Bool? - - enum CodingKeys: String, CodingKey { - case id - case name - case contentMarkdown - case subject - case updatedBy - case isDisabled = "disabled" - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/OzoneModerationDefs.swift b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/OzoneModerationDefs.swift deleted file mode 100644 index 59583bebc3..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/OzoneModerationDefs.swift +++ /dev/null @@ -1,1085 +0,0 @@ -// -// OzoneModerationDefs.swift -// -// -// Created by Christopher Jr Riley on 2024-03-14. -// - -import Foundation - -/// A data model for a moderation event view definition. -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/defs.json -public struct OzoneModerationEventView: Codable { - /// The ID of the moderator's event view. - public let id: Int - /// The type of the moderator's event view. - public let event: AdminEventViewUnion - /// The subject reference of the moderator's event view. - public let subject: RepositoryReferencesUnion - /// An array of CID hashes related to blobs for the moderator's event view. - public let subjectBlobCIDHashes: [String] - /// The creator of the event view. - public let createdBy: String - /// The date and time the event view was created. - @DateFormatting public var createdAt: Date - /// The handle of the moderator. Optional. - public var creatorHandle: String? = nil - /// The subject handle of the event view. Optional. - public var subjectHandle: String? = nil - - public init(id: Int, event: AdminEventViewUnion, subject: RepositoryReferencesUnion, subjectBlobCIDHashes: [String], createdBy: String, - createdAt: Date, creatorHandle: String?, subjectHandle: String?) { - self.id = id - self.event = event - self.subject = subject - self.subjectBlobCIDHashes = subjectBlobCIDHashes - self.createdBy = createdBy - self._createdAt = DateFormatting(wrappedValue: createdAt) - self.creatorHandle = creatorHandle - self.subjectHandle = subjectHandle - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.id = try container.decode(Int.self, forKey: .id) - self.event = try container.decode(AdminEventViewUnion.self, forKey: .event) - self.subject = try container.decode(RepositoryReferencesUnion.self, forKey: .subject) - self.subjectBlobCIDHashes = try container.decode([String].self, forKey: .subjectBlobCIDHashes) - self.createdBy = try container.decode(String.self, forKey: .createdBy) - self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue - self.creatorHandle = try container.decodeIfPresent(String.self, forKey: .creatorHandle) - self.subjectHandle = try container.decodeIfPresent(String.self, forKey: .subjectHandle) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self.id, forKey: .id) - try container.encode(self.event, forKey: .event) - try container.encode(self.subject, forKey: .subject) - try container.encode(self.subjectBlobCIDHashes, forKey: .subjectBlobCIDHashes) - try container.encode(self.createdBy, forKey: .createdBy) - try container.encode(self._createdAt, forKey: .createdAt) - try container.encodeIfPresent(self.creatorHandle, forKey: .creatorHandle) - try container.encodeIfPresent(self.subjectHandle, forKey: .subjectHandle) - } - - enum CodingKeys: String, CodingKey { - case id - case event - case subject - case subjectBlobCIDHashes = "subjectBlobCids" - case createdBy - case createdAt - case creatorHandle - case subjectHandle - } -} - -/// A data model for a detailed moderation event view definition. -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/defs.json -public struct OzoneModerationEventViewDetail: Codable { - /// The ID of the moderator's event view. - public let id: Int - /// The type of the moderator's event view. - public let event: EventViewDetailUnion - /// The subject reference of the moderator's event view. - public let subject: RepositoryViewUnion - /// An array of blobs for a moderator to look at. - public let subjectBlobs: [OzoneModerationBlobView] - /// The creator of the event view. - public let createdBy: String - /// The date and time the event view was created. - @DateFormatting public var createdAt: Date - - public init(id: Int, event: EventViewDetailUnion, subject: RepositoryViewUnion, subjectBlobs: [OzoneModerationBlobView], - createdBy: String, createdAt: Date) { - self.id = id - self.event = event - self.subject = subject - self.subjectBlobs = subjectBlobs - self.createdBy = createdBy - self._createdAt = DateFormatting(wrappedValue: createdAt) - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.id = try container.decode(Int.self, forKey: .id) - self.event = try container.decode(EventViewDetailUnion.self, forKey: .event) - self.subject = try container.decode(RepositoryViewUnion.self, forKey: .subject) - self.subjectBlobs = try container.decode([OzoneModerationBlobView].self, forKey: .subjectBlobs) - self.createdBy = try container.decode(String.self, forKey: .createdBy) - self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self.id, forKey: .id) - try container.encode(self.event, forKey: .event) - try container.encode(self.subject, forKey: .subject) - try container.encode(self.subjectBlobs, forKey: .subjectBlobs) - try container.encode(self.createdBy, forKey: .createdBy) - try container.encode(self._createdAt, forKey: .createdAt) - } - - enum CodingKeys: CodingKey { - case id - case event - case subject - case subjectBlobs - case createdBy - case createdAt - } -} - -/// A data model for a subject's status view definition. -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/defs.json -public struct OzoneSubjectStatusView: Codable { - /// The ID of the status view. - public let id: Int - /// The subject reference of the status view. - public let subject: RepositoryReferencesUnion - /// An array of CID hashes related to blobs. Optional. - public var subjectBlobCIDHashes: [String]? = nil - /// The handle of the subject related to the status. Optional. - public var subjectRepoHandle: String? = nil - /// The date and time of the last update for the status view. - /// - /// - Note: According to the AT Protocol specifications: "Timestamp referencing when the last update was made to the moderation status of the subject." - @DateFormatting public var updatedAt: Date - /// The date and time of the day the first event occured. - /// - /// - Note: According to the AT Protocol specifications: "Timestamp referencing the first moderation status impacting event was emitted on the subject." - @DateFormatting public var createdAt: Date - /// The review status of the subject. - public let reviewState: OzoneSubjectReviewState - /// Any additional comments written about the subject. Optional. - public var comment: String? = nil - /// The date and time the subject's time to be muted has been lifted. Optional. - /// - /// - Note: According to the AT Protocol specifications: "Sticky comment on the subject." - @DateFormattingOptional public var muteUntil: Date? = nil - /// The date and time until which reporting on the subject is muted. Optional. - /// - /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ - /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ - /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ - /// \ - /// Clarifications from Bluesky are needed in order to fully understand this item. - @DateFormattingOptional public var muteReportingUntil: Date? - /// The name of the reviewer that reviewed the subject. Optional. - public var lastReviewedBy: String? = nil - /// The date and time the last reviewer looked at the subject. Optional. - @DateFormattingOptional public var lastReviewedAt: Date? = nil - /// The date and time of the last report about the subject. Optional. - @DateFormattingOptional public var lastReportedAt: Date? = nil - /// The date and time of the last appeal. Optional. - @DateFormattingOptional public var lastAppealedAt: Date? = nil - /// Indicates whether the subject was taken down. Optional. - public var isTakenDown: Bool? = nil - /// Indicates whether an appeal has been made. Optional. - public var wasAppealed: Bool? = nil - /// The date and time the subject's suspension will be lifted. Optional. - @DateFormattingOptional public var suspendUntil: Date? = nil - /// An array of tags. Optional. - public var tags: [String]? = nil - - public init(id: Int, subject: RepositoryReferencesUnion, subjectBlobCIDHashes: [String]?, subjectRepoHandle: String?, updatedAt: Date, createdAt: Date, - reviewState: OzoneSubjectReviewState, comment: String?, muteUntil: Date?, muteReportingUntil: Date?, lastReviewedBy: String?, - lastReviewedAt: Date?, lastReportedAt: Date?, lastAppealedAt: Date?, isTakenDown: Bool?, wasAppealed: Bool?, suspendUntil: Date?, - tags: [String]?) { - self.id = id - self.subject = subject - self.subjectBlobCIDHashes = subjectBlobCIDHashes - self.subjectRepoHandle = subjectRepoHandle - self._updatedAt = DateFormatting(wrappedValue: updatedAt) - self._createdAt = DateFormatting(wrappedValue: createdAt) - self.reviewState = reviewState - self.comment = comment - self.muteUntil = muteUntil - self._muteReportingUntil = DateFormattingOptional(wrappedValue: muteReportingUntil) - self.lastReviewedBy = lastReviewedBy - self._lastReviewedAt = DateFormattingOptional(wrappedValue: lastReviewedAt) - self._lastReportedAt = DateFormattingOptional(wrappedValue: lastReportedAt) - self._lastAppealedAt = DateFormattingOptional(wrappedValue: lastAppealedAt) - self.isTakenDown = isTakenDown - self.wasAppealed = wasAppealed - self._suspendUntil = DateFormattingOptional(wrappedValue: suspendUntil) - self.tags = tags - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.id = try container.decode(Int.self, forKey: .id) - self.subject = try container.decode(RepositoryReferencesUnion.self, forKey: .subject) - self.subjectBlobCIDHashes = try container.decodeIfPresent([String].self, forKey: .subjectBlobCIDHashes) - self.subjectRepoHandle = try container.decodeIfPresent(String.self, forKey: .subjectRepoHandle) - self.updatedAt = try container.decode(DateFormatting.self, forKey: .updatedAt).wrappedValue - self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue - self.reviewState = try container.decode(OzoneSubjectReviewState.self, forKey: .reviewState) - self.comment = try container.decodeIfPresent(String.self, forKey: .comment) - self.muteUntil = try container.decodeIfPresent(DateFormattingOptional.self, forKey: .muteUntil)?.wrappedValue - self.muteReportingUntil = try container.decodeIfPresent(DateFormattingOptional.self, forKey: .muteReportingUntil)?.wrappedValue - self.lastReviewedBy = try container.decodeIfPresent(String.self, forKey: .lastReviewedBy) - self.lastReviewedAt = try container.decodeIfPresent(DateFormattingOptional.self, forKey: .lastReviewedAt)?.wrappedValue - self.lastReportedAt = try container.decodeIfPresent(DateFormattingOptional.self, forKey: .lastReportedAt)?.wrappedValue - self.lastAppealedAt = try container.decodeIfPresent(DateFormattingOptional.self, forKey: .lastAppealedAt)?.wrappedValue - self.isTakenDown = try container.decodeIfPresent(Bool.self, forKey: .isTakenDown) - self.wasAppealed = try container.decodeIfPresent(Bool.self, forKey: .wasAppealed) - self.suspendUntil = try container.decodeIfPresent(DateFormattingOptional.self, forKey: .suspendUntil)?.wrappedValue - self.tags = try container.decode([String].self, forKey: .tags) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self.id, forKey: .id) - try container.encode(self.subject, forKey: .subject) - try container.encodeIfPresent(self.subjectBlobCIDHashes, forKey: .subjectBlobCIDHashes) - try container.encodeIfPresent(self.subjectRepoHandle, forKey: .subjectRepoHandle) - try container.encode(self._updatedAt, forKey: .updatedAt) - try container.encode(self._createdAt, forKey: .createdAt) - try container.encode(self.reviewState, forKey: .reviewState) - try container.encodeIfPresent(self.comment, forKey: .comment) - try container.encode(self._muteUntil, forKey: .muteUntil) - try container.encodeIfPresent(self._muteReportingUntil, forKey: .muteReportingUntil) - try container.encodeIfPresent(self.lastReviewedBy, forKey: .lastReviewedBy) - try container.encode(self._lastReviewedAt, forKey: .lastReviewedAt) - try container.encode(self._lastReportedAt, forKey: .lastReportedAt) - try container.encode(self._lastAppealedAt, forKey: .lastAppealedAt) - try container.encodeIfPresent(self.isTakenDown, forKey: .isTakenDown) - try container.encodeIfPresent(self.wasAppealed, forKey: .wasAppealed) - try container.encode(self._suspendUntil, forKey: .suspendUntil) - try container.encode(self.tags, forKey: .tags) - } - - enum CodingKeys: String, CodingKey { - case id - case subject - case subjectBlobCIDHashes = "subjectBlobCids" - case subjectRepoHandle - case updatedAt - case createdAt - case reviewState - case comment - case muteUntil - case muteReportingUntil - case lastReviewedBy - case lastReviewedAt - case lastReportedAt - case lastAppealedAt - case isTakenDown = "takendown" - case wasAppealed = "appealed" - case suspendUntil - case tags - } -} - -/// A data model for the subject review state definition. -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/defs.json -public enum OzoneSubjectReviewState: String, Codable { - /// Moderator review status of a subject: Open. Indicates that the subject needs to be reviewed by a moderator. - /// - /// - Note: The above documentation was taken directly from the AT Protocol specifications. - case reviewOpen - - /// Moderator review status of a subject: Escalated. Indicates that the subject was escalated for review by a moderator. - /// - /// - Note: The above documentation was taken directly from the AT Protocol specifications. - case reviewEscalated - - /// Moderator review status of a subject: Closed. Indicates that the subject was already reviewed and resolved by a moderator. - /// - /// - Note: The above documentation was taken directly from the AT Protocol specifications. - case reviewClosed - - /// Moderator review status of a subject: Unnecessary. Indicates that the subject does not need a review at the moment but there - /// is probably some moderation related metadata available for it - /// - /// - Note: The above documentation was taken directly from the AT Protocol specifications. - case reviewNone -} - -/// A data model for an event takedown definition. -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/defs.json -public struct OzoneModerationEventTakedown: Codable { - /// Any additional comments for the takedown event. Optional. - /// - /// - Note: According to the AT Protocol specifications: "Take down a subject permanently or temporarily." - public let comment: String? - /// The amount of time (in hours) for the user to be considered takendown. Optional. - /// - /// - Note: According to the AT Protocol specifications: "Indicates how long the takedown should be in effect before automatically expiring." - public let durationInHours: Int? -} - -/// A data model for a reverse takedown event definition. -/// -/// - Note: According to the AT Protocol specifications: "Revert take down action on a subject." -/// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/defs.json -public struct OzoneModerationEventReverseTakedown: Codable { - /// Any comments for the reverse takedown event. Optional. - /// - /// - Note: According to the AT Protocol specifications: "Describe reasoning behind the reversal." - public let comment: String? -} - -/// A data model for a definition of an resolved appeal event. -/// -/// - Note: According to the AT Protocol specifications: "Resolve appeal on a subject." -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/defs.json -public struct OzoneModerationEventResolveAppeal: Codable { - /// Any comments for the moderator's appeal resolution event. Optional. - /// - /// - Note: According to the AT Protocol specifications: "Describe resolution." - public let comment: String? -} - -/// A data model for a definition of a comment event. -/// -/// - Note: According to the AT Protocol specifications: "Add a comment to a subject." -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/defs.json -public struct OzoneModerationEventComment: Codable { - /// Any comment for the moderator's comment event. - public let comment: String - /// Indicates whether the moderator event is sticky. Optional. - /// - /// - Note: According to the AT Protocol specifications: "Make the comment persistent on the subject." - public let isSticky: Bool? - - enum CodingKeys: String, CodingKey { - case comment - case isSticky = "sticky" - } -} - -/// A data model for a report event definition. -/// -/// - Note: According to the AT Protocol specifications: "Report a subject." -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/defs.json -public struct OzoneModerationEventReport: Codable { - /// Any comments for the moderator's report event. Optional. - public var comment: String? = nil - /// Indicates whether the reporter has been muted. Optional. - /// - /// - Note: According to the AT Protocol specifications: "Set to true if the reporter was muted from reporting at the time of the event. - /// These reports won't impact the reviewState of the subject." - public let isReporterMuted: Bool? - /// The type of report. - public let reportType: ModerationReasonType -} - -/// A data model for a label event definition. -/// -/// - Note: According to the AT Protocol specifications: "Apply/Negate labels on a subject" -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/defs.json -public struct OzoneModerationEventLabel: Codable { - /// Any comments for the moderator's label event. Optional. - public let comment: String? - /// An array of labels that apply to a user. - public let createLabelValues: [String] - /// An array of labels that's applied to a user for the purpose of negating. - public let negateLabelValues: [String] - - enum CodingKeys: String, CodingKey { - case comment - case createLabelValues = "createLabelVals" - case negateLabelValues = "negateLabelVals" - } -} - -/// A data model for a definition of an acknowledgement event. -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/defs.json -public struct OzoneModerationEventAcknowledge: Codable { - /// Any comments for the moderator's acknowledge event. Optional. - public var comment: String? = nil -} - -/// A data model for a definition of an escalation event. -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/defs.json -public struct OzoneModerationEventEscalate: Codable { - /// Any additional comments for escalating a report. Optional. - public var comment: String? = nil -} - -/// A data model for a definition of a mute event. -/// -/// - Note: According to the AT Protocol specifications: "Mute incoming reports on a subject." -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/defs.json -public struct OzoneModerationEventMute: Codable { - /// Any additional comments for the mute event. Optional. - public var comment: String? = nil - /// The amount of time (in hours) that the moderator has put in for muting a user. - /// - /// - Note: According to the AT Protocol specifications: "Indicates how long the subject should remain muted." - public let durationInHours: Int -} - -/// A data model for an unmute event definition. -/// -/// - Note: According to the AT Protocol specifications: "Unmute action on a subject." -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/defs.json -public struct OzoneModerationEventUnmute: Codable { - /// Any comments for the moderator's unmute event. Optional. - /// - /// - Note: According to the AT Protocol specifications: "Describe reasoning behind the reversal." - public var comment: String? = nil -} - -/// A data model definition for a mute reporter event. -/// -/// - Note: According to the AT Protocol specifications: "Mute incoming reports from an account." -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/defs.json -public struct OzoneModerationEventMuteReporter: Codable { - /// Indicates how long the account should remain muted (in hours). - /// - /// - Note: According to the AT Protocol specifications: "Indicates how long the account should remain muted." - public let durationInHours: Int - /// Any additional comments about the event. Optional. - public let comment: String? -} - -/// A data model definition for an unmute reporter event. -/// -/// - Note: According to the AT Protocol specifications: "Unmute incoming reports from an account." -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/defs.json -public struct OzoneModerationEventUnmuteReporter: Codable { - /// Any additional comments about the event. - /// - /// - Note: According to the AT Protocol specifications: "Describe reasoning behind the reversal." - public let comment: String? -} - -/// A data model for a definition of an email event. -/// -/// - Note: According to the AT Protocol specifications: "Keep a log of outgoing email to a user." -/// -/// - SeeAlso: This is based on the [`tools.ozone.moderation.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/defs.json -public struct OzoneModerationEventEmail: Codable { - /// The subject line of the email. - /// - /// - Note: According to the AT Protocol specifications: "The subject line of the email sent to the user." - public let subjectLine: String - /// The body of the email. - /// - /// - Note: According to the AT Protocol specifications: "The content of the email sent to the user." - public let content: String - /// Any additional comments about the email. Optional. - /// - /// - Note: According to the AT Protocol specifications: "Additional comment about the outgoing comm." - public var comment: String? = nil -} - -/// A data model for a definition of a diversion event. -/// -/// - Note: According to the AT Protocol specifications: "Divert a record's blobs to a 3rd party service for further scanning/tagging" -/// -/// - SeeAlso: This is based on the [`tools.ozone.moderation.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/defs.json -public struct OzoneModerationEventDivert: Codable { - /// Any additional comments about the diversion. - public let comment: String? -} - -/// A data model for a tag event definition. -/// -/// - Note: According to the AT Protocol specifications: "Add/Remove a tag on a subject." -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/defs.json -public struct OzoneModerationEventTag: Codable { - /// An array of tags to be added to the user. - /// - /// If a tag in the array already exists on the user, then the tag will be ignored. - /// - /// - Note: According to the AT Protocol specifications: "Tags to be added to the subject. If already exists, won't be duplicated." - public let add: [String] - /// An array of tags to be removed from the user. - /// - /// If a tag in the array doesn't exist on the user, then the tag will be ignored. - /// - /// - Note: According to the AT Protocol specifications: "Tags to be removed to the subject. Ignores a tag If it doesn't exist, won't be duplicated." - public let remove: [String] - /// Any additional comments about the moderator's tag event. - /// - /// - Note: According to the AT Protocol specifications: "Additional comment about added/removed tags." - public let comment: String? -} - -/// A data model for a definition of a repository view. -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/defs.json -public struct OzoneModerationRepositoryView: Codable { - /// The decentralized identifier (DID) of the user. - public let actorDID: String - /// The handle of the user. - public let handle: String - /// The email of the user. Optional. - public var email: String? = nil - /// The related records of the user. - /// - /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ - /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ - /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ - /// \ - /// Clarifications from Bluesky are needed in order to fully understand this item. - public let relatedRecords: UnknownType - /// The date and time the user was indexed. - @DateFormatting public var indexedAt: Date - /// The moderation status of the user. - public let moderation: OzoneModeration - /// The invite code used by the user to sign up. Optional. - public var invitedBy: ServerInviteCode? = nil - /// Indicates whether the invite codes held by the user are diabled. Optional. - public var areInvitesDisabled: Bool? = nil - /// The note of the invite. Optional. - public var inviteNote: String? = nil - - public init(actorDID: String, handle: String, email: String? = nil, relatedRecords: UnknownType, indexedAt: Date, moderation: OzoneModeration, - invitedBy: ServerInviteCode? = nil, areInvitesDisabled: Bool? = nil, inviteNote: String? = nil) { - self.actorDID = actorDID - self.handle = handle - self.email = email - self.relatedRecords = relatedRecords - self._indexedAt = DateFormatting(wrappedValue: indexedAt) - self.moderation = moderation - self.invitedBy = invitedBy - self.areInvitesDisabled = areInvitesDisabled - self.inviteNote = inviteNote - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.actorDID = try container.decode(String.self, forKey: .actorDID) - self.handle = try container.decode(String.self, forKey: .handle) - self.email = try container.decodeIfPresent(String.self, forKey: .email) - self.relatedRecords = try container.decode(UnknownType.self, forKey: .relatedRecords) - self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue - self.moderation = try container.decode(OzoneModeration.self, forKey: .moderation) - self.invitedBy = try container.decodeIfPresent(ServerInviteCode.self, forKey: .invitedBy) - self.areInvitesDisabled = try container.decodeIfPresent(Bool.self, forKey: .areInvitesDisabled) - self.inviteNote = try container.decodeIfPresent(String.self, forKey: .inviteNote) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self.actorDID, forKey: .actorDID) - try container.encode(self.handle, forKey: .handle) - try container.encodeIfPresent(self.email, forKey: .email) - try container.encode(self.relatedRecords, forKey: .relatedRecords) - try container.encode(self._indexedAt, forKey: .indexedAt) - try container.encode(self.moderation, forKey: .moderation) - try container.encodeIfPresent(self.invitedBy, forKey: .invitedBy) - try container.encodeIfPresent(self.areInvitesDisabled, forKey: .areInvitesDisabled) - try container.encodeIfPresent(self.inviteNote, forKey: .inviteNote) - } - - enum CodingKeys: String, CodingKey { - case actorDID = "did" - case handle - case email - case relatedRecords - case indexedAt - case moderation - case invitedBy - case areInvitesDisabled = "invitesDisabled" - case inviteNote - } -} - -/// A data model for a definition of a detailed repository view. -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/defs.json -public struct OzoneModerationRepositoryViewDetail: Codable { - /// The decentralized identifier (DID) of the user. - public let actorDID: String - /// The handle of the user. - public let handle: String - /// The email of the user. Optional. - public var email: String? = nil - /// The user's related records. - /// - /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ - /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ - /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ - /// \ - /// Clarifications from Bluesky are needed in order to fully understand this item. - public let relatedRecords: UnknownType - /// The date and time the user was last indexed. - @DateFormatting public var indexedAt: Date - /// The detailed moderation status of the user. - public let moderation: OzoneModerationDetail - /// An array of labels associated with the user. Optional. - public var labels: [Label]? = nil - /// The invite code used by the user to sign up. Optional. - public var invitedBy: ServerInviteCode? = nil - /// An array of invite codes held by the user. Optional. - public var invites: [ServerInviteCode]? = nil - /// Indicates whether the invite codes held by the user are diabled. Optional. - public var areInvitesDisabled: Bool? = nil - /// The note of the invite. Optional. - public var inviteNote: String? = nil - /// The date and time the email of the user was confirmed. Optional. - @DateFormattingOptional public var emailConfirmedAt: Date? = nil - - public init(actorDID: String, handle: String, email: String?, relatedRecords: UnknownType, indexedAt: Date, moderation: OzoneModerationDetail, - labels: [Label]?, invitedBy: ServerInviteCode?, invites: [ServerInviteCode]?, areInvitesDisabled: Bool?, inviteNote: String?, - emailConfirmedAt: Date? = nil) { - self.actorDID = actorDID - self.handle = handle - self.email = email - self.relatedRecords = relatedRecords - self._indexedAt = DateFormatting(wrappedValue: indexedAt) - self.moderation = moderation - self.labels = labels - self.invitedBy = invitedBy - self.invites = invites - self.areInvitesDisabled = areInvitesDisabled - self.inviteNote = inviteNote - self._emailConfirmedAt = DateFormattingOptional(wrappedValue: emailConfirmedAt) - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.actorDID = try container.decode(String.self, forKey: .actorDID) - self.handle = try container.decode(String.self, forKey: .handle) - self.email = try container.decodeIfPresent(String.self, forKey: .email) - self.relatedRecords = try container.decode(UnknownType.self, forKey: .relatedRecords) - self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue - self.moderation = try container.decode(OzoneModerationDetail.self, forKey: .moderation) - self.labels = try container.decodeIfPresent([Label].self, forKey: .labels) - self.invitedBy = try container.decodeIfPresent(ServerInviteCode.self, forKey: .invitedBy) - self.invites = try container.decodeIfPresent([ServerInviteCode].self, forKey: .invites) - self.areInvitesDisabled = try container.decodeIfPresent(Bool.self, forKey: .areInvitesDisabled) - self.inviteNote = try container.decodeIfPresent(String.self, forKey: .inviteNote) - self.emailConfirmedAt = try container.decodeIfPresent(DateFormattingOptional.self, forKey: .emailConfirmedAt)?.wrappedValue - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self.actorDID, forKey: .actorDID) - try container.encode(self.handle, forKey: .handle) - try container.encodeIfPresent(self.email, forKey: .email) - try container.encode(self.relatedRecords, forKey: .relatedRecords) - try container.encode(self._indexedAt, forKey: .indexedAt) - try container.encode(self.moderation, forKey: .moderation) - try container.encodeIfPresent(self.labels, forKey: .labels) - try container.encodeIfPresent(self.invitedBy, forKey: .invitedBy) - try container.encodeIfPresent(self.invites, forKey: .invites) - try container.encodeIfPresent(self.areInvitesDisabled, forKey: .areInvitesDisabled) - try container.encodeIfPresent(self.inviteNote, forKey: .inviteNote) - try container.encode(self._emailConfirmedAt, forKey: .emailConfirmedAt) - } - - enum CodingKeys: String, CodingKey { - case actorDID = "did" - case handle - case email - case relatedRecords - case indexedAt - case moderation - case labels - case invitedBy - case invites - case areInvitesDisabled = "invitesDisabled" - case inviteNote - case emailConfirmedAt - } -} - -/// A data model for a definition of a respository view that may not have been found. -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/defs.json -public struct OzoneModerationRepositoryViewNotFound: Codable { - /// The decentralized identifier (DID) of the repository. - public let repositoryDID: String - - enum CodingKeys: String, CodingKey { - case repositoryDID = "did" - } -} - -/// A data model for the definition of a record view. -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/defs.json -public struct OzoneModerationRecordView: Codable { - /// The URI of the record. - public let recordURI: String - /// The CID hash of the record. - public let cidHash: String - /// The value of the record. - /// - /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ - /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ - /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ - /// \ - /// Clarifications from Bluesky are needed in order to fully understand this item. - public let value: UnknownType - /// An array of CID hashes for blobs. - public let blobCIDHashes: [String] - /// The date and time the record is indexed. - @DateFormatting public var indexedAt: Date - /// The status of the subject. - /// - /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ - /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ - /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ - /// \ - /// Clarifications from Bluesky are needed in order to fully understand this item. - public let moderation: OzoneModeration - /// The repository view of the record. - /// - /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ - /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ - /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ - /// \ - /// Clarifications from Bluesky are needed in order to fully understand this item. - public let repository: OzoneModerationRepositoryView - - public init(recordURI: String, cidHash: String, value: UnknownType, blobCIDHashes: [String], indexedAt: Date, - moderation: OzoneModeration, repository: OzoneModerationRepositoryView) { - self.recordURI = recordURI - self.cidHash = cidHash - self.value = value - self.blobCIDHashes = blobCIDHashes - self._indexedAt = DateFormatting(wrappedValue: indexedAt) - self.moderation = moderation - self.repository = repository - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.recordURI = try container.decode(String.self, forKey: .recordURI) - self.cidHash = try container.decode(String.self, forKey: .cidHash) - self.value = try container.decode(UnknownType.self, forKey: .value) - self.blobCIDHashes = try container.decode([String].self, forKey: .blobCIDHashes) - self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue - self.moderation = try container.decode(OzoneModeration.self, forKey: .moderation) - self.repository = try container.decode(OzoneModerationRepositoryView.self, forKey: .repository) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self.recordURI, forKey: .recordURI) - try container.encode(self.cidHash, forKey: .cidHash) - try container.encode(self.value, forKey: .value) - try container.encode(self.blobCIDHashes, forKey: .blobCIDHashes) - try container.encode(self._indexedAt, forKey: .indexedAt) - try container.encode(self.moderation, forKey: .moderation) - try container.encode(self.repository, forKey: .repository) - } - - enum CodingKeys: String, CodingKey { - case recordURI = "uri" - case cidHash = "cid" - case value - case blobCIDHashes = "blobCids" - case indexedAt - case moderation - case repository = "repo" - } -} - -/// A data model for a definition a detailed view of a record. -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/defs.json -public struct OzoneModerationRecordViewDetail: Codable { - /// The URI of a record. - public let recordURI: String - /// The CID hash of the record. - public let cidHash: String - /// The value of the record. - /// - /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ - /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ - /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ - /// \ - /// Clarifications from Bluesky are needed in order to fully understand this item. - public let value: String - /// An array of CID hashes for blobs. - public let blobs: [OzoneModerationBlobView] - /// An array of labels attached to the record. Optional. - public var labels: [Label]? = nil - /// The date and time the record is indexed. - @DateFormatting public var indexedAt: Date - /// The repository view of the record. - /// - /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ - /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ - /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ - /// \ - /// Clarifications from Bluesky are needed in order to fully understand this item. - public let moderation: OzoneModerationDetail - /// The repository view of the record. - /// - /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ - /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ - /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ - /// \ - /// Clarifications from Bluesky are needed in order to fully understand this item. - public let repository: OzoneModerationRepositoryView - - public init(recordURI: String, cidHash: String, value: String, blobs: [OzoneModerationBlobView], labels: [Label]? = nil, indexedAt: Date, - moderation: OzoneModerationDetail, repository: OzoneModerationRepositoryView) { - self.recordURI = recordURI - self.cidHash = cidHash - self.value = value - self.blobs = blobs - self.labels = labels - self._indexedAt = DateFormatting(wrappedValue: indexedAt) - self.moderation = moderation - self.repository = repository - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.recordURI = try container.decode(String.self, forKey: .recordURI) - self.cidHash = try container.decode(String.self, forKey: .cidHash) - self.value = try container.decode(String.self, forKey: .value) - self.blobs = try container.decode([OzoneModerationBlobView].self, forKey: .blobs) - self.labels = try container.decodeIfPresent([Label].self, forKey: .labels) - self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue - self.moderation = try container.decode(OzoneModerationDetail.self, forKey: .moderation) - self.repository = try container.decode(OzoneModerationRepositoryView.self, forKey: .repository) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self.recordURI, forKey: .recordURI) - try container.encode(self.cidHash, forKey: .cidHash) - try container.encode(self.value, forKey: .value) - try container.encode(self.blobs, forKey: .blobs) - try container.encodeIfPresent(self.labels, forKey: .labels) - try container.encode(self._indexedAt, forKey: .indexedAt) - try container.encode(self.moderation, forKey: .moderation) - try container.encode(self.repository, forKey: .repository) - } - - enum CodingKeys: String, CodingKey { - case recordURI = "uri" - case cidHash = "cid" - case value - case blobs - case labels - case indexedAt - case moderation - case repository = "repo" - } -} - -/// A data model for a definition of a record that may not have been found. -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/defs.json -public struct OzoneModerationRecordViewNotFound: Codable { - /// The URI of the record. - public let recordURI: String - - enum CodingKeys: String, CodingKey { - case recordURI = "uri" - } -} - -/// A data model of a definition for moderation. -/// -/// - Important: The item associated with this struct is undocumented in the AT Protocol specifications. The documentation here is based on:\ -/// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ -/// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ -/// \ -/// Clarifications from Bluesky are needed in order to fully understand this item. -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/defs.json -public struct OzoneModeration: Codable { - /// The status of the subject. Optional. - /// - /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ - /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ - /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ - /// \ - /// Clarifications from Bluesky are needed in order to fully understand this item. - public var subjectStatus: OzoneSubjectStatusView? = nil -} - -/// A data model of a definition for a detailed moderation. -/// -/// - Important: The item associated with this struct is undocumented in the AT Protocol specifications. The documentation here is based on:\ -/// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ -/// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ -/// \ -/// Clarifications from Bluesky are needed in order to fully understand this item. -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/defs.json -public struct OzoneModerationDetail: Codable { - /// The status of the subject. Optional. - /// - /// - Important: The item associated with this property is undocumented in the AT Protocol specifications. The documentation here is based on:\ - /// \* **For items with some inferable context from property names or references**: its best interpretation, though not with full certainty.\ - /// \* **For items without enough context for even an educated guess**: a direct acknowledgment of their undocumented status.\ - /// \ - /// Clarifications from Bluesky are needed in order to fully understand this item. - public var subjectStatus: OzoneSubjectStatusView? = nil -} - -/// The data model for a definition of a blob view. -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/defs.json -public struct OzoneModerationBlobView: Codable { - /// The CID hash of the blob. - public let cidHash: String - /// The MIME type of the blob. - public let mimeType: String - /// The size of the blob. Written in bytes. - public let size: Int - /// The date and time the blob was created. - @DateFormatting public var createdAt: Date - /// The type of media in the blob. - public let details: MediaDetailUnion - /// The status of the subject. - public let moderation: OzoneModeration - - public init(cidHash: String, mimeType: String, size: Int, createdAt: Date, details: MediaDetailUnion, moderation: OzoneModeration) { - self.cidHash = cidHash - self.mimeType = mimeType - self.size = size - self._createdAt = DateFormatting(wrappedValue: createdAt) - self.details = details - self.moderation = moderation - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.cidHash = try container.decode(String.self, forKey: .cidHash) - self.mimeType = try container.decode(String.self, forKey: .mimeType) - self.size = try container.decode(Int.self, forKey: .size) - self.createdAt = try container.decode(DateFormatting.self, forKey: .createdAt).wrappedValue - self.details = try container.decode(MediaDetailUnion.self, forKey: .details) - self.moderation = try container.decode(OzoneModeration.self, forKey: .moderation) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(self.cidHash, forKey: .cidHash) - try container.encode(self.mimeType, forKey: .mimeType) - try container.encode(self.size, forKey: .size) - try container.encode(self._createdAt, forKey: .createdAt) - try container.encode(self.details, forKey: .details) - try container.encode(self.moderation, forKey: .moderation) - } - - enum CodingKeys: String, CodingKey { - case cidHash = "cid" - case mimeType - case size - case createdAt - case details - case moderation - } -} - -/// A data model for a definition of details for an image. -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/defs.json -public struct OzoneModerationMediaImageDetails: Codable { - /// The width of the image. - public let width: Int - /// The height of the image. - public let height: Int -} - -/// A data model for a definition of details for a video. -/// -/// - SeeAlso: This is based on the [`com.atproto.admin.defs`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/admin/defs.json -public struct OzoneModerationMediaVideoDetails: Codable { - /// The width of the video. - public let width: Int - /// The height of the video. - public let height: Int - /// The duration of the video. - public let length: Int -} diff --git a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/OzoneModerationEmitEvent.swift b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/OzoneModerationEmitEvent.swift deleted file mode 100644 index b315bb803d..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/OzoneModerationEmitEvent.swift +++ /dev/null @@ -1,33 +0,0 @@ -// -// OzoneModerationEmitEvent.swift -// -// -// Created by Christopher Jr Riley on 2024-05-01. -// - -import Foundation - -/// The main data model definition for enacting on an action against a user's account. -/// -/// - Note: According to the AT Protocol specifications: "Take a moderation action on an actor." -/// -/// - SeeAlso: This is based on the [`tools.ozone.moderation.emitEvent`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/emitEvent.json -public struct ModerationEmitEvent: Codable { - /// The type of event the moderator is taking, - public let event: AdminEventViewUnion - /// The type of repository reference. - public let subject: RepositoryReferencesUnion - /// An array of CID hashes related to blobs for the moderator's event view. Optional. - public let subjectBlobCIDHashes: [String]? - /// The decentralized identifier (DID) of the moderator taking this action. - public let createdBy: String - - enum CodingKeys: String, CodingKey { - case event - case subject - case subjectBlobCIDHashes = "subjectBlobCids" - case createdBy - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/OzoneModerationQueryEvents.swift b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/OzoneModerationQueryEvents.swift deleted file mode 100644 index 69ca02e21f..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/OzoneModerationQueryEvents.swift +++ /dev/null @@ -1,31 +0,0 @@ -// -// OzoneModerationQueryEvents.swift -// -// -// Created by Christopher Jr Riley on 2024-03-01. -// - -import Foundation - -/// The main data model definition for listing all moderation events pertaining a subject. -/// -/// - Note: According to the AT Protocol specifications: "List moderation events related -/// to a subject." -/// -/// - SeeAlso: This is based on the [`tools.ozone.moderation.queryEvents`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/queryEvents.json -public struct ModerationQueryEventsOutput: Codable { - /// The mark used to indicate the starting point for the next set of results. Optional. - public let cursor: String? - /// An array of moderator events. - public let events: [OzoneModerationEventView] -} - -/// Indicates the sorting direction for the array of moderation events. -public enum AdminQueryModerationEventSortDirection: String { - /// Indicates the moderation events will be sorted in ascending order. - case ascending = "asc" - /// Indicates the moderation events will be sorted in descending order. - case descending = "desc" -} diff --git a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/OzoneModerationQueryStatuses.swift b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/OzoneModerationQueryStatuses.swift deleted file mode 100644 index c2ae6a7ee0..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/OzoneModerationQueryStatuses.swift +++ /dev/null @@ -1,23 +0,0 @@ -// -// OzoneModerationQueryStatuses.swift -// -// -// Created by Christopher Jr Riley on 2024-05-01. -// - -import Foundation - -/// The main data model definition for listing all moderation events pertaining a subject. -/// -/// - Note: According to the AT Protocol specifications: "View moderation statuses of subjects -/// (record or repo)." -/// -/// - SeeAlso: This is based on the [`ools.ozone.moderation.queryStatuses`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/queryEvents.json -public struct ModerationQueryStatusesOutput: Codable { - /// The mark used to indicate the starting point for the next set of results. Optional. - public let cursor: String? - /// An array of subject status views. - public let subjectStatuses: [OzoneSubjectStatusView] -} diff --git a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/OzoneModerationSearchRepos.swift b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/OzoneModerationSearchRepos.swift deleted file mode 100644 index c800ba0758..0000000000 --- a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/OzoneModerationSearchRepos.swift +++ /dev/null @@ -1,28 +0,0 @@ -// -// OzoneModerationSearchRepos.swift -// -// -// Created by Christopher Jr Riley on 2024-05-01. -// - -import Foundation - -/// The output model definition for searching for repositories as an administrator or moderator. -/// -/// - Note: According to the AT Protocol specifications: "Find repositories based on a -/// search term." -/// -/// - SeeAlso: This is based on the [`tools.ozone.moderation.searchRepos`][github] lexicon. -/// -/// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/tools/ozone/moderation/searchRepos.json -public struct ModerationSearchRepositoryOutput: Codable { - /// The mark used to indicate the starting point for the next set of results. Optional. - public let cursor: String? - /// An array of repository views. - public let repositories: [OzoneModerationRepositoryView] - - enum CodingKeys: String, CodingKey { - case cursor - case repositories = "repos" - } -} diff --git a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationDefs.swift b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationDefs.swift index 153ecf7b98..f17b21ac59 100644 --- a/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationDefs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/tools.ozone/Moderation/ToolsOzoneModerationDefs.swift @@ -680,7 +680,7 @@ extension ToolsOzoneLexicon.Moderation { public let moderation: ToolsOzoneLexicon.Moderation.ModerationDefinition /// The invite code used by the user to sign up. Optional. - public var invitedBy: ServerInviteCode? + public var invitedBy: ComAtprotoLexicon.Server.InviteCodeDefinition? /// Indicates whether the invite codes held by the user are diabled. Optional. public var areInvitesDisabled: Bool? @@ -689,7 +689,7 @@ extension ToolsOzoneLexicon.Moderation { public var inviteNote: String? public init(actorDID: String, handle: String, email: String? = nil, relatedRecords: UnknownType, indexedAt: Date, - moderation: ToolsOzoneLexicon.Moderation.ModerationDefinition, invitedBy: ServerInviteCode? = nil, areInvitesDisabled: Bool? = nil, + moderation: ToolsOzoneLexicon.Moderation.ModerationDefinition, invitedBy: ComAtprotoLexicon.Server.InviteCodeDefinition? = nil, areInvitesDisabled: Bool? = nil, inviteNote: String? = nil) { self.actorDID = actorDID self.handle = handle @@ -711,7 +711,7 @@ extension ToolsOzoneLexicon.Moderation { self.relatedRecords = try container.decode(UnknownType.self, forKey: .relatedRecords) self.indexedAt = try container.decode(DateFormatting.self, forKey: .indexedAt).wrappedValue self.moderation = try container.decode(ToolsOzoneLexicon.Moderation.ModerationDefinition.self, forKey: .moderation) - self.invitedBy = try container.decodeIfPresent(ServerInviteCode.self, forKey: .invitedBy) + self.invitedBy = try container.decodeIfPresent(ComAtprotoLexicon.Server.InviteCodeDefinition.self, forKey: .invitedBy) self.areInvitesDisabled = try container.decodeIfPresent(Bool.self, forKey: .areInvitesDisabled) self.inviteNote = try container.decodeIfPresent(String.self, forKey: .inviteNote) } diff --git a/Sources/ATProtoKit/Networking/CoreAPI/CreateInviteCode.swift b/Sources/ATProtoKit/Networking/CoreAPI/CreateInviteCode.swift index b3c780b295..40c5c82900 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/CreateInviteCode.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/CreateInviteCode.swift @@ -41,7 +41,7 @@ extension ATProtoKit { } // Make sure the number isn't lower than one. - let requestBody = ServerCreateInviteCode( + let requestBody = ComAtprotoLexicon.Server.CreateInviteCodeRequestBody( useCount: codeCount > 0 ? codeCount : 1, forAccount: account ) diff --git a/Sources/ATProtoKit/Networking/CoreAPI/CreateInviteCodes.swift b/Sources/ATProtoKit/Networking/CoreAPI/CreateInviteCodes.swift index c5812d5308..2fe7e622ec 100644 --- a/Sources/ATProtoKit/Networking/CoreAPI/CreateInviteCodes.swift +++ b/Sources/ATProtoKit/Networking/CoreAPI/CreateInviteCodes.swift @@ -38,7 +38,7 @@ extension ATProtoKit { } // Make sure the number isn't lower than one. - let requestBody = ServerCreateInviteCodes( + let requestBody = ComAtprotoLexicon.Server.CreateInviteCodesRequestBody( useCount: codeCount > 0 ? codeCount : 1, forAccounts: accounts ) diff --git a/Sources/ATProtoKit/Networking/PlatformAPI/CreatePost.swift b/Sources/ATProtoKit/Networking/PlatformAPI/CreatePost.swift index 62c53e5316..6ccd7f0c49 100644 --- a/Sources/ATProtoKit/Networking/PlatformAPI/CreatePost.swift +++ b/Sources/ATProtoKit/Networking/PlatformAPI/CreatePost.swift @@ -110,7 +110,8 @@ extension ATProtoKit { /// use in a record. /// /// - Important: Each image can only be 1 MB in size. - public func uploadImages(_ images: [ImageQuery], pdsURL: String = "https://bsky.social", accessToken: String) async throws -> ATUnion.PostEmbedUnion { + public func uploadImages(_ images: [ComAtprotoLexicon.Repository.ImageQuery], pdsURL: String = "https://bsky.social", + accessToken: String) async throws -> ATUnion.PostEmbedUnion { var embedImages = [AppBskyLexicon.Embed.ImagesDefinition.Image]() for image in images { @@ -174,7 +175,7 @@ extension ATProtoKit { /// Represents a set of images to be embedded in the post. /// - Parameter images: An array of `ImageQuery` objects, each containing the image data, /// metadata, and filenames of the image. - case images(images: [ImageQuery]) + case images(images: [ComAtprotoLexicon.Repository.ImageQuery]) /// Represents an external link to be embedded in the post. /// - Parameter url: A `URL` pointing to the external content. diff --git a/Sources/ATProtoKit/Networking/SessionManager/ATProtocolConfiguration.swift b/Sources/ATProtoKit/Networking/SessionManager/ATProtocolConfiguration.swift index 1411137ceb..240e581ea6 100644 --- a/Sources/ATProtoKit/Networking/SessionManager/ATProtocolConfiguration.swift +++ b/Sources/ATProtoKit/Networking/SessionManager/ATProtocolConfiguration.swift @@ -98,7 +98,7 @@ public class ATProtocolConfiguration: ProtocolConfiguration { return .failure(ATRequestPrepareError.invalidRequestURL) } - let credentials = SessionCredentials( + let credentials = ComAtprotoLexicon.Server.CreateSessionRequestBody( identifier: handle, password: appPassword, authenticationFactorToken: authenticationFactorToken @@ -169,7 +169,7 @@ public class ATProtocolConfiguration: ProtocolConfiguration { return .failure(ATRequestPrepareError.invalidRequestURL) } - let requestBody = ServerCreateAccount( + let requestBody = ComAtprotoLexicon.Server.CreateAccountRequestBody( email: email, handle: handle, existingDID: existingDID, diff --git a/Sources/ATProtoKit/Utilities/ATFacetParser.swift b/Sources/ATProtoKit/Utilities/ATFacetParser.swift index 35685d6afa..72804b54f1 100644 --- a/Sources/ATProtoKit/Utilities/ATFacetParser.swift +++ b/Sources/ATProtoKit/Utilities/ATFacetParser.swift @@ -176,7 +176,7 @@ public class ATFacetParser { let mentionFacet = AppBskyLexicon.RichText.Facet( index: AppBskyLexicon.RichText.Facet.ByteSlice(byteStart: start, byteEnd: end), - features: [.mention(Mention(did: resolveHandleOutput.handleDID))]) + features: [.mention(AppBskyLexicon.RichText.Facet.Mention(did: resolveHandleOutput.handleDID))]) await facets.append(mentionFacet) case .failure(let error): @@ -199,7 +199,7 @@ public class ATFacetParser { let end = link["end"] as? Int { let linkFacet = AppBskyLexicon.RichText.Facet( index: AppBskyLexicon.RichText.Facet.ByteSlice(byteStart: start, byteEnd: end), - features: [.link(Link(uri: url))] + features: [.link(AppBskyLexicon.RichText.Facet.Link(uri: url))] ) await facets.append(linkFacet) @@ -218,7 +218,7 @@ public class ATFacetParser { let end = hashtag["end"] as? Int { let hashTagFacet = AppBskyLexicon.RichText.Facet( index: AppBskyLexicon.RichText.Facet.ByteSlice(byteStart: start, byteEnd: end), - features: [.tag(Tag(tag: tag))] + features: [.tag(AppBskyLexicon.RichText.Facet.Tag(tag: tag))] ) await facets.append(hashTagFacet) diff --git a/Sources/ATProtoKit/Utilities/ATImageProcessing.swift b/Sources/ATProtoKit/Utilities/ATImageProcessing.swift index 29a36d4056..63f321937d 100644 --- a/Sources/ATProtoKit/Utilities/ATImageProcessing.swift +++ b/Sources/ATProtoKit/Utilities/ATImageProcessing.swift @@ -107,7 +107,7 @@ public protocol ATImageProcessable { /// - targetFileSize: The size (in bytes) the file needs to be. /// - Returns: An ``ImageQuery``, which combines the image itself in a `Data` format and /// the alt text. - func convertToImageQuery(imagePath: String, altText: String?, targetFileSize: Int) -> ImageQuery? + func convertToImageQuery(imagePath: String, altText: String?, targetFileSize: Int) -> ComAtprotoLexicon.Repository.ImageQuery? /// Removes all EXIF and GPS metadata from the image. /// @@ -118,7 +118,7 @@ public protocol ATImageProcessable { } public extension ATImageProcessable { - func convertToImageQuery(imagePath: String, altText: String?, targetFileSize: Int = 1_000_000) -> ImageQuery? { + func convertToImageQuery(imagePath: String, altText: String?, targetFileSize: Int = 1_000_000) -> ComAtprotoLexicon.Repository.ImageQuery? { guard let image = NSImage(contentsOfFile: imagePath) else { print("Image could not be loaded.") return nil @@ -166,7 +166,7 @@ public extension ATImageProcessable { } if let imageData { - return ImageQuery(imageData: imageData, fileName: filename, altText: altText) + return ComAtprotoLexicon.Repository.ImageQuery(imageData: imageData, fileName: filename, altText: altText) } return nil