ATProtoKit icon indicating copy to clipboard operation
ATProtoKit copied to clipboard

[Feature Enhancement]: Re-organize Lexicon Models

Open MasterJ93 opened this issue 1 year ago • 0 comments

Summary

No response

Pain points

Currently, the structure of the models work out like this:

  • The file name of the applicable model(s) contains the domain name, the subdomain, and the name of the lexicon's file name from bluesky-social's atproto repository.
  • The model contains the subdomain of the lexicon, followed by the name of the lexicon's action, according to the lexicon itself.

This creates an issue of inconsistencies in naming (as a few models may end up having the same names) which can lead to user confusion.

The solution is to re-organize them in the following way:

  • Create four structs: AppBskyLexicon, ComAtprotoLexicon, ToolsOzoneLexicon, and ChatBskyLexicon.
  • Create extensions for each, which will contain structs for the subdomain.
  • Create extensions for each action struct, which will also contain structs. This time, the struct names will be the name of the lexicon action.
  • Anything that the lexicon has which are relevant to the specific action will be within the applicable action struct.
  • The main struct within the subdomain struct will have a prefix or suffix attached to it, depending on the kind of model it is:
    • Models that are used for request bodies will have the RequestBody suffix.
    • Models that are used as an output will have the Output suffix.
    • Models that are records will have the Record suffix.
    • Models that are definitions will have the Definition suffix.
    • Models that represent the part of the lexicon that's under the main property will have the Main prefix, unless it's used for any of the above use cases.
  • Anything in the lexicon that's under the query property will not be part of this reorganization.
    • These properties resides in the lexicon methods as parameters.

Below are a few examples.

app.bsky.graph.getMutes

  • A file named Lexicons.swift will contain the following structs: AppBskyLexicon, ComAtprotoLexicon, ToolsOzoneLexicon, and ChatBskyLexicon.
  • Another file that's named AppBskyLexicon.swift will contain an extension to AppBskyLexicon. In it will contain the structs for all of the subdomains (examples: Actor, Embed, Feed, Graph, etc.).
  • Another file named AppBskyGraphGetMutes.swift will contain an extension to AppBskyLexicon.Graph. In it, the struct will be named GetMutesOutput.

app.bsky.embed.external

  • A file named Lexicons.swift will contain the following structs: AppBskyLexicon, ComAtprotoLexicon, ToolsOzoneLexicon, and ChatBskyLexicon.
  • Another file that's named AppBskyLexicon.swift will contain an extension to AppBskyLexicon. In it will contain the structs for all of the subdomains (examples: Actor, Embed, Feed, Graph, etc.).
  • Another file named AppBskyEmbedExternal.swift will contain an extension to AppBskyLexicon.Embed. In it are several structs, which are named the following:
    • MainExternal
    • External
    • ExternalView
    • ViewExternal

app.bsky.actor.defs

  • A file named Lexicons.swift will contain the following structs: AppBskyLexicon, ComAtprotoLexicon, ToolsOzoneLexicon, and ChatBskyLexicon.
  • Another file that's named AppBskyLexicon.swift will contain an extension to AppBskyLexicon. In it will contain the structs for all of the subdomains (examples: Actor, Embed, Feed, Graph, etc.).
  • Another file named AppBskyActorDefs.swift will contain an extension to AppBskyLexicon.Actor. The list will be too long to write, but examples would include:
    • ProfileViewBasicDefinition
    • ProfileAssociatedDefinition
    • AdultContentPreferencesDefinition
    • InterestViewPreferencesDefinition
    • MutedWordsPreferencesDefinition
    • MutedWord (since this is related to MutedWordsPreferencesDefinition)

app.bsky.graph.unmuteActor

  • A file named Lexicons.swift will contain the following structs: AppBskyLexicon, ComAtprotoLexicon,ToolsOzoneLexicon, and ChatBskyLexicon.
  • Another file that's named AppBskyLexicon.swift will contain an extension to AppBskyLexicon. In it will contain the structs for all of the subdomains (examples: Actor, Embed, Feed, Graph, etc.).
  • Another file named AppBskyGraphUnmuteActor.swift will contain an extension to AppBskyLexicon.Graph. In it is a struct, named UnmuteActorRequestBody.

Considered Alternatives

No response

Is this a breaking change?

Yes

Library Examples

No response

Additional Context

Please note that this should not be started until version 0.11.0 is out. This should also be in a specific branch, which should be merged into the lexicon branch.

The tasks include:

  • [ ] Update the ATProtoKit API Design Guidelines to follow the design changes being made in here.

  • [x] Create a file named Lexicons.swift

    • [x] Add AppBskyLexicon
    • [x] Add ComAtprotoLexicon
    • [x] Add ToolsOzoneLexicon
    • [x] Add ChatBskyLexicon
  • [x] Create files named [TLD][Domain]Lexicon.swift and include the following structs:

    • [x] For AppBskyLexicon.swift:
      • [x] Actor
      • [x] Embed
      • [x] Feed
      • [x] Labeler
      • [x] Notification
      • [x] RichText
      • [x] Unspecced
    • [x] For ComAtprotoLexicon.swift:
      • [x] Admin
      • [x] Identity
      • [x] Label
      • [x] Moderation
      • [x] Repo
      • [x] Server
      • [x] Sync
      • [x] Temp
    • [x] For ToolsOzoneLexicon.swift:
      • [x] Communication
      • [x] Moderation
    • [x] For ChatBskyLexicon.swift:
      • [x] Actor
      • [x] Convo
      • [x] Moderation

Lexicons to re-organize:

  • [x] app.bsky.actor.*

    • [x] app.bsky.actor.defs
    • [x] app.bsky.actor.getPreferences
    • [x] app.bsky.actor.getProfile
    • [x] app.bsky.actor.getProfiles
    • [x] app.bsky.actor.getSuggestions
    • [x] app.bsky.actor.profile
    • [x] app.bsky.actor.putPreferences
    • [x] app.bsky.actor.searchActors
    • [x] app.bsky.actor.searchActorsTypeahead
  • [x] app.bsky.embed.*

    • [x] app.bsky.embed.external
    • [x] app.bsky.embed.images
    • [x] app.bsky.embed.record
    • [x] app.bsky.embed.recordWithMedia
  • [x] app.bsky.feed.*

    • [x] app.bsky.feed.defs
    • [x] app.bsky.feed.describeFeedGenerator
    • [x] app.bsky.feed.generator
    • [x] app.bsky.feed.getActorFeeds
    • [x] app.bsky.feed.getActorLikes
    • [x] app.bsky.feed.getAuthorFeed
    • [x] app.bsky.feed.getFeed
    • [x] app.bsky.feed.getFeedGenerator
    • [x] app.bsky.feed.getFeedGenerators
    • [x] app.bsky.feed.getFeedSkeleton
    • [x] app.bsky.feed.getLikes
    • [x] app.bsky.feed.getListFeed
    • [x] app.bsky.feed.getPosts
    • [x] app.bsky.feed.getPostThread
    • [x] app.bsky.feed.getRepostedBy
    • [x] app.bsky.feed.getSuggestedFeeds
    • [x] app.bsky.feed.getTimeline
    • [x] app.bsky.feed.like
    • [x] app.bsky.feed.post
    • [x] app.bsky.feed.repost
    • [x] app.bsky.feed.searchPosts
    • [x] app.bsky.feed.sendInteractions
    • [x] app.bsky.feed.threadgate
  • [x] app.bsky.graph.*

    • [x] app.bsky.graph.block
    • [x] app.bsky.graph.defs
    • [x] app.bsky.graph.follow
    • [x] app.bsky.graph.getBlocks
    • [x] app.bsky.graph.getFollowers
    • [x] app.bsky.graph.getFollows
    • [x] app.bsky.graph.getList
    • [x] app.bsky.graph.getListBlocks
    • [x] app.bsky.graph.getListMutes
    • [x] app.bsky.graph.getLists
    • [x] app.bsky.graph.getMutes
    • [x] app.bsky.graph.getRelationships
    • [x] app.bsky.graph.getSuggestedFollowsByActor
    • [x] app.bsky.graph.list
    • [x] app.bsky.graph.listblock
    • [x] app.bsky.graph.listitem
    • [x] app.bsky.graph.muteActor
    • [x] app.bsky.graph.muteActorList
    • [x] app.bsky.graph.unmuteActor
    • [x] app.bsky.graph.unmuteActorList
  • [x] app.bsky.labeler.*

    • [x] app.bsky.labeler.defs
    • [x] app.bsky.labeler.getServices
    • [x] app.bsky.labeler.service
  • [x] app.bsky.notification.*

    • [x] app.bsky.notification.updateSeen
    • [x] app.bsky.notification.getUnreadCount
    • [x] app.bsky.notification.listNotifications
    • [x] app.bsky.notification.registerPush
  • [x] app.bsky.richtext.*

    • [x] app.bsky.richtext.facet
  • [x] app.bsky.unspecced.*

    • [x] app.bsky.unspecced.defs
    • [x] app.bsky.unspecced.getPopularFeedGenerators
    • [x] app.bsky.unspecced.getSuggestionsSkeleton
    • [x] app.bsky.unspecced.getTaggedSuggestions
    • [x] app.bsky.unspecced.searchActorsSkeleton
    • [x] app.bsky.unspecced.searchPostsSkeleton
  • [x] com.atproto.admin.*

    • [x] com.atproto.admin.defs
    • [x] com.atproto.admin.deleteAccount
    • [x] com.atproto.admin.disableAccountInvites
    • [x] com.atproto.admin.disableInviteCodes
    • [x] com.atproto.admin.enableAccountInvites
    • [x] com.atproto.admin.getAccountInfos
    • [x] com.atproto.admin.getInviteCodes
    • [x] com.atproto.admin.getSubjectStatus
    • [x] com.atproto.admin.queryModerationStatuses
    • [x] com.atproto.admin.searchRepos
    • [x] com.atproto.admin.sendEmail
    • [x] com.atproto.admin.updateAccountEmail
    • [x] com.atproto.admin.updateAccountHandle
    • [x] com.atproto.admin.updateAccountPassword
    • [x] com.atproto.admin.updateSubjectStatus
  • [x] com.atproto.identity.*

    • [x] com.atproto.identity.getRecommendedDidCredentials
    • [x] com.atproto.identity.resolveHandle
    • [x] com.atproto.identity.signPlcOperation
    • [x] com.atproto.identity.submitPlcOperation
    • [x] com.atproto.identity.updateHandle
  • [x] com.atproto.label.*

    • [x] com.atproto.label.defs
    • [x] com.atproto.label.queryLabels
  • [x] com.atproto.moderation.*

    • [x] com.atproto.moderation.createReport
    • [x] com.atproto.moderation.defs
  • [x] com.atproto.repo.*

    • [x] com.atproto.repo.applyWrites
    • [x] com.atproto.repo.createRecord
    • [x] com.atproto.repo.deleteRecord
    • [x] com.atproto.repo.describeRepo
    • [x] com.atproto.repo.getRecord
    • [x] com.atproto.repo.importRepo
    • [x] com.atproto.repo.listMissingBlobs
    • [x] com.atproto.repo.listRecords
    • [x] com.atproto.repo.putRecord
    • [x] com.atproto.repo.strongRef
    • [x] com.atproto.repo.uploadBlob
  • [x] com.atproto.server.*

    • [x] com.atproto.server.checkAccountStatus
    • [x] com.atproto.server.confirmEmail
    • [x] com.atproto.server.createAccount
    • [x] com.atproto.server.createAppPassword
    • [x] com.atproto.server.createInviteCode
    • [x] com.atproto.server.createInviteCodes
    • [x] com.atproto.server.createSession
    • [x] com.atproto.server.deactivateAccount
    • [x] com.atproto.server.defs
    • [x] com.atproto.server.deleteAccount
    • [x] com.atproto.server.describeServer
    • [x] com.atproto.server.getAccountInviteCodes
    • [x] com.atproto.server.getServiceAuth
    • [x] com.atproto.server.listAppPasswords
    • [x] com.atproto.server.requestEmailUpdate
    • [x] com.atproto.server.requestPasswordReset
    • [x] com.atproto.server.reserveSigningKey
    • [x] com.atproto.server.resetPassword
    • [x] com.atproto.server.revokeAppPassword
    • [x] com.atproto.server.updateEmail
  • [x] com.atproto.sync.*

    • [x] com.atproto.sync.notifyOfUpdate
    • [x] com.atproto.sync.requestCrawl
    • [x] com.atproto.sync.getBlob
    • [x] com.atproto.sync.getBlocks
    • [x] com.atproto.sync.getLatestCommit
    • [x] com.atproto.sync.listBlobs
    • [x] com.atproto.sync.listRepos
  • [x] com.atproto.temp.*

    • [x] com.atproto.temp.checkSignupQueue
    • [x] com.atproto.temp.requestPhoneVerification
  • [x] tools.ozone.communication.*

    • [x] tools.ozone.communication.createTemplate
    • [x] tools.ozone.communication.defs
    • [x] tools.ozone.communication.deleteTemplate
    • [x] tools.ozone.communication.listTemplates
    • [x] tools.ozone.communication.updateTemplate
  • [x] tools.ozone.moderation.*

    • [x] tools.ozone.moderation.defs
    • [x] tools.ozone.moderation.emitEvent
    • [x] tools.ozone.moderation.queryEvents
    • [x] tools.ozone.moderation.queryStatuses
    • [x] tools.ozone.moderation.searchRepos
  • [x] chat.bsky.actor.*

    • [x] chat.bsky.actor.declaration
    • [x] chat.bsky.actor.defs
    • [x] chat.bsky.actor.deleteAccount
    • [x] chat.bsky.actor.exportAccountData
  • [x] chat.bsky.convo.*

    • [x] chat.bsky.convo.defs
    • [x] chat.bsky.convo.deleteMessageForSelf
    • [x] chat.bsky.convo.getConvo
    • [x] chat.bsky.convo.getConvoForMembers
    • [x] chat.bsky.convo.getLog
    • [x] chat.bsky.convo.getMessages
    • [x] chat.bsky.convo.leaveConvo
    • [x] chat.bsky.convo.listConvos
    • [x] chat.bsky.convo.muteConvo
    • [x] chat.bsky.convo.sendMessage
    • [x] chat.bsky.convo.sendMessageBatch
    • [x] chat.bsky.convo.unmuteConvo
    • [x] chat.bsky.convo.updateRead
  • [x] chat.bsky.moderation.*

    • [x] chat.bsky.moderation.getActorMetadata
    • [x] chat.bsky.moderation.getMessageContext
    • [x] chat.bsky.moderation.updateActorAccess

MasterJ93 avatar May 13 '24 09:05 MasterJ93