diff --git a/packages/atproto_client/models/app/bsky/actor/defs.py b/packages/atproto_client/models/app/bsky/actor/defs.py index c3c0a417..15a483a3 100644 --- a/packages/atproto_client/models/app/bsky/actor/defs.py +++ b/packages/atproto_client/models/app/bsky/actor/defs.py @@ -94,7 +94,7 @@ class ProfileAssociated(base.ModelBase): class ProfileAssociatedChat(base.ModelBase): """Definition model for :obj:`app.bsky.actor.defs`.""" - allow_incoming: str #: Allow incoming. + allow_incoming: t.Union[t.Literal['all'], t.Literal['none'], t.Literal['following'], str] #: Allow incoming. py_type: t.Literal['app.bsky.actor.defs#profileAssociatedChat'] = Field( default='app.bsky.actor.defs#profileAssociatedChat', alias='$type', frozen=True @@ -164,7 +164,9 @@ class ContentLabelPref(base.ModelBase): """Definition model for :obj:`app.bsky.actor.defs`.""" label: str #: Label. - visibility: str #: Visibility. + visibility: t.Union[ + t.Literal['ignore'], t.Literal['show'], t.Literal['warn'], t.Literal['hide'], str + ] #: Visibility. labeler_did: t.Optional[str] = None #: Which labeler does this preference apply to? If undefined, applies globally. py_type: t.Literal['app.bsky.actor.defs#contentLabelPref'] = Field( @@ -177,7 +179,7 @@ class SavedFeed(base.ModelBase): id: str #: Id. pinned: bool #: Pinned. - type: str #: Type. + type: t.Union[t.Literal['feed'], t.Literal['list'], t.Literal['timeline'], str] #: Type. value: str #: Value. py_type: t.Literal['app.bsky.actor.defs#savedFeed'] = Field( @@ -238,7 +240,9 @@ class ThreadViewPref(base.ModelBase): """Definition model for :obj:`app.bsky.actor.defs`.""" prioritize_followed_users: t.Optional[bool] = None #: Show followed users at the top of all replies. - sort: t.Optional[str] = None #: Sorting mode for threads. + sort: t.Optional[ + t.Union[t.Literal['oldest'], t.Literal['newest'], t.Literal['most-likes'], t.Literal['random'], str] + ] = None #: Sorting mode for threads. py_type: t.Literal['app.bsky.actor.defs#threadViewPref'] = Field( default='app.bsky.actor.defs#threadViewPref', alias='$type', frozen=True @@ -266,7 +270,7 @@ class MutedWord(base.ModelBase): targets: t.List['models.AppBskyActorDefs.MutedWordTarget'] #: The intended targets of the muted word. value: str = Field(max_length=10000) #: The muted word itself. actor_target: t.Optional[ - str + t.Union[t.Literal['all'], t.Literal['exclude-following'], str] ] = None #: Groups of users to apply the muted word to. If undefined, applies to all users. expires_at: t.Optional[ str diff --git a/packages/atproto_client/models/app/bsky/feed/defs.py b/packages/atproto_client/models/app/bsky/feed/defs.py index e51b51ea..af7632ea 100644 --- a/packages/atproto_client/models/app/bsky/feed/defs.py +++ b/packages/atproto_client/models/app/bsky/feed/defs.py @@ -261,7 +261,23 @@ class ThreadgateView(base.ModelBase): class Interaction(base.ModelBase): """Definition model for :obj:`app.bsky.feed.defs`.""" - event: t.Optional[str] = None #: Event. + event: t.Optional[ + t.Union[ + 'models.AppBskyFeedDefs.RequestLess', + 'models.AppBskyFeedDefs.RequestMore', + 'models.AppBskyFeedDefs.ClickthroughItem', + 'models.AppBskyFeedDefs.ClickthroughAuthor', + 'models.AppBskyFeedDefs.ClickthroughReposter', + 'models.AppBskyFeedDefs.ClickthroughEmbed', + 'models.AppBskyFeedDefs.InteractionSeen', + 'models.AppBskyFeedDefs.InteractionLike', + 'models.AppBskyFeedDefs.InteractionRepost', + 'models.AppBskyFeedDefs.InteractionReply', + 'models.AppBskyFeedDefs.InteractionQuote', + 'models.AppBskyFeedDefs.InteractionShare', + str, + ] + ] = None #: Event. feed_context: t.Optional[str] = Field( default=None, max_length=2000 ) #: Context on a feed item that was originally supplied by the feed generator on getFeedSkeleton. diff --git a/packages/atproto_client/models/app/bsky/feed/get_author_feed.py b/packages/atproto_client/models/app/bsky/feed/get_author_feed.py index b959d18e..dcc0b8af 100644 --- a/packages/atproto_client/models/app/bsky/feed/get_author_feed.py +++ b/packages/atproto_client/models/app/bsky/feed/get_author_feed.py @@ -20,14 +20,32 @@ class Params(base.ParamsModelBase): actor: str #: Actor. cursor: t.Optional[str] = None #: Cursor. - filter: t.Optional[str] = None #: Combinations of post/repost types to include in response. + filter: t.Optional[ + t.Union[ + t.Literal['posts_with_replies'], + t.Literal['posts_no_replies'], + t.Literal['posts_with_media'], + t.Literal['posts_and_author_threads'], + str, + ] + ] = None #: Combinations of post/repost types to include in response. limit: t.Optional[int] = Field(default=50, ge=1, le=100) #: Limit. class ParamsDict(t.TypedDict): actor: str #: Actor. cursor: te.NotRequired[t.Optional[str]] #: Cursor. - filter: te.NotRequired[t.Optional[str]] #: Combinations of post/repost types to include in response. + filter: te.NotRequired[ + t.Optional[ + t.Union[ + t.Literal['posts_with_replies'], + t.Literal['posts_no_replies'], + t.Literal['posts_with_media'], + t.Literal['posts_and_author_threads'], + str, + ] + ] + ] #: Combinations of post/repost types to include in response. limit: te.NotRequired[t.Optional[int]] #: Limit. diff --git a/packages/atproto_client/models/app/bsky/feed/search_posts.py b/packages/atproto_client/models/app/bsky/feed/search_posts.py index d757e750..4abba118 100644 --- a/packages/atproto_client/models/app/bsky/feed/search_posts.py +++ b/packages/atproto_client/models/app/bsky/feed/search_posts.py @@ -38,7 +38,9 @@ class Params(base.ParamsModelBase): since: t.Optional[ str ] = None #: Filter results for posts after the indicated datetime (inclusive). Expected to use 'sortAt' timestamp, which may not match 'createdAt'. Can be a datetime, or just an ISO date (YYYY-MM-DD). - sort: t.Optional[str] = None #: Specifies the ranking order of results. + sort: t.Optional[ + t.Union[t.Literal['top'], t.Literal['latest'], str] + ] = None #: Specifies the ranking order of results. tag: t.Optional[ t.List[str] ] = None #: Filter to posts with the given tag (hashtag), based on rich-text facet or tag field. Do not include the hash (#) prefix. Multiple tags can be specified, with 'AND' matching. @@ -71,7 +73,9 @@ class ParamsDict(t.TypedDict): since: te.NotRequired[ t.Optional[str] ] #: Filter results for posts after the indicated datetime (inclusive). Expected to use 'sortAt' timestamp, which may not match 'createdAt'. Can be a datetime, or just an ISO date (YYYY-MM-DD). - sort: te.NotRequired[t.Optional[str]] #: Specifies the ranking order of results. + sort: te.NotRequired[ + t.Optional[t.Union[t.Literal['top'], t.Literal['latest'], str]] + ] #: Specifies the ranking order of results. tag: te.NotRequired[ t.Optional[t.List[str]] ] #: Filter to posts with the given tag (hashtag), based on rich-text facet or tag field. Do not include the hash (#) prefix. Multiple tags can be specified, with 'AND' matching. diff --git a/packages/atproto_client/models/app/bsky/notification/list_notifications.py b/packages/atproto_client/models/app/bsky/notification/list_notifications.py index 0a635261..c2edae9c 100644 --- a/packages/atproto_client/models/app/bsky/notification/list_notifications.py +++ b/packages/atproto_client/models/app/bsky/notification/list_notifications.py @@ -48,9 +48,16 @@ class Notification(base.ModelBase): cid: str #: Cid. indexed_at: str #: Indexed at. is_read: bool #: Is read. - reason: ( - str - ) #: Expected values are 'like', 'repost', 'follow', 'mention', 'reply', 'quote', and 'starterpack-joined'. + reason: t.Union[ + t.Literal['like'], + t.Literal['repost'], + t.Literal['follow'], + t.Literal['mention'], + t.Literal['reply'], + t.Literal['quote'], + t.Literal['starterpack-joined'], + str, + ] #: Expected values are 'like', 'repost', 'follow', 'mention', 'reply', 'quote', and 'starterpack-joined'. record: 'UnknownType' #: Record. uri: str #: Uri. labels: t.Optional[t.List['models.ComAtprotoLabelDefs.Label']] = None #: Labels. diff --git a/packages/atproto_client/models/app/bsky/notification/register_push.py b/packages/atproto_client/models/app/bsky/notification/register_push.py index 7eed5c4e..9df06dc3 100644 --- a/packages/atproto_client/models/app/bsky/notification/register_push.py +++ b/packages/atproto_client/models/app/bsky/notification/register_push.py @@ -14,13 +14,13 @@ class Data(base.DataModelBase): """Input data model for :obj:`app.bsky.notification.registerPush`.""" app_id: str #: App id. - platform: str #: Platform. + platform: t.Union[t.Literal['ios'], t.Literal['android'], t.Literal['web'], str] #: Platform. service_did: str #: Service did. token: str #: Token. class DataDict(t.TypedDict): app_id: str #: App id. - platform: str #: Platform. + platform: t.Union[t.Literal['ios'], t.Literal['android'], t.Literal['web'], str] #: Platform. service_did: str #: Service did. token: str #: Token. diff --git a/packages/atproto_client/models/app/bsky/unspecced/get_tagged_suggestions.py b/packages/atproto_client/models/app/bsky/unspecced/get_tagged_suggestions.py index 1000e304..7930c357 100644 --- a/packages/atproto_client/models/app/bsky/unspecced/get_tagged_suggestions.py +++ b/packages/atproto_client/models/app/bsky/unspecced/get_tagged_suggestions.py @@ -32,7 +32,7 @@ class Suggestion(base.ModelBase): """Definition model for :obj:`app.bsky.unspecced.getTaggedSuggestions`.""" subject: str #: Subject. - subject_type: str #: Subject type. + subject_type: t.Union[t.Literal['actor'], t.Literal['feed'], str] #: Subject type. tag: str #: Tag. py_type: t.Literal['app.bsky.unspecced.getTaggedSuggestions#suggestion'] = Field( diff --git a/packages/atproto_client/models/app/bsky/unspecced/search_posts_skeleton.py b/packages/atproto_client/models/app/bsky/unspecced/search_posts_skeleton.py index dc722943..d90af81f 100644 --- a/packages/atproto_client/models/app/bsky/unspecced/search_posts_skeleton.py +++ b/packages/atproto_client/models/app/bsky/unspecced/search_posts_skeleton.py @@ -38,7 +38,9 @@ class Params(base.ParamsModelBase): since: t.Optional[ str ] = None #: Filter results for posts after the indicated datetime (inclusive). Expected to use 'sortAt' timestamp, which may not match 'createdAt'. Can be a datetime, or just an ISO date (YYYY-MM-DD). - sort: t.Optional[str] = None #: Specifies the ranking order of results. + sort: t.Optional[ + t.Union[t.Literal['top'], t.Literal['latest'], str] + ] = None #: Specifies the ranking order of results. tag: t.Optional[ t.List[str] ] = None #: Filter to posts with the given tag (hashtag), based on rich-text facet or tag field. Do not include the hash (#) prefix. Multiple tags can be specified, with 'AND' matching. @@ -74,7 +76,9 @@ class ParamsDict(t.TypedDict): since: te.NotRequired[ t.Optional[str] ] #: Filter results for posts after the indicated datetime (inclusive). Expected to use 'sortAt' timestamp, which may not match 'createdAt'. Can be a datetime, or just an ISO date (YYYY-MM-DD). - sort: te.NotRequired[t.Optional[str]] #: Specifies the ranking order of results. + sort: te.NotRequired[ + t.Optional[t.Union[t.Literal['top'], t.Literal['latest'], str]] + ] #: Specifies the ranking order of results. tag: te.NotRequired[ t.Optional[t.List[str]] ] #: Filter to posts with the given tag (hashtag), based on rich-text facet or tag field. Do not include the hash (#) prefix. Multiple tags can be specified, with 'AND' matching. diff --git a/packages/atproto_client/models/app/bsky/video/defs.py b/packages/atproto_client/models/app/bsky/video/defs.py index d9c1e23e..12e02b4a 100644 --- a/packages/atproto_client/models/app/bsky/video/defs.py +++ b/packages/atproto_client/models/app/bsky/video/defs.py @@ -19,7 +19,9 @@ class JobStatus(base.ModelBase): did: str #: Did. job_id: str #: Job id. - state: str #: The state of the video processing job. All values not listed as a known value indicate that the job is in process. + state: t.Union[ + t.Literal['JOB_STATE_COMPLETED'], t.Literal['JOB_STATE_FAILED'], str + ] #: The state of the video processing job. All values not listed as a known value indicate that the job is in process. blob: t.Optional['BlobRef'] = None #: Blob. error: t.Optional[str] = None #: Error. message: t.Optional[str] = None #: Message. diff --git a/packages/atproto_client/models/chat/bsky/actor/declaration.py b/packages/atproto_client/models/chat/bsky/actor/declaration.py index c503c510..dd52e8d3 100644 --- a/packages/atproto_client/models/chat/bsky/actor/declaration.py +++ b/packages/atproto_client/models/chat/bsky/actor/declaration.py @@ -17,7 +17,7 @@ class Record(base.RecordModelBase): """Record model for :obj:`chat.bsky.actor.declaration`.""" - allow_incoming: str #: Allow incoming. + allow_incoming: t.Union[t.Literal['all'], t.Literal['none'], t.Literal['following'], str] #: Allow incoming. py_type: t.Literal['chat.bsky.actor.declaration'] = Field( default='chat.bsky.actor.declaration', alias='$type', frozen=True diff --git a/packages/atproto_client/models/com/atproto/admin/get_invite_codes.py b/packages/atproto_client/models/com/atproto/admin/get_invite_codes.py index f4e62246..70ae920f 100644 --- a/packages/atproto_client/models/com/atproto/admin/get_invite_codes.py +++ b/packages/atproto_client/models/com/atproto/admin/get_invite_codes.py @@ -20,13 +20,13 @@ class Params(base.ParamsModelBase): cursor: t.Optional[str] = None #: Cursor. limit: t.Optional[int] = Field(default=100, ge=1, le=500) #: Limit. - sort: t.Optional[str] = None #: Sort. + sort: t.Optional[t.Union[t.Literal['recent'], t.Literal['usage'], str]] = None #: Sort. class ParamsDict(t.TypedDict): cursor: te.NotRequired[t.Optional[str]] #: Cursor. limit: te.NotRequired[t.Optional[int]] #: Limit. - sort: te.NotRequired[t.Optional[str]] #: Sort. + sort: te.NotRequired[t.Optional[t.Union[t.Literal['recent'], t.Literal['usage'], str]]] #: Sort. class Response(base.ResponseModelBase): diff --git a/packages/atproto_client/models/com/atproto/label/defs.py b/packages/atproto_client/models/com/atproto/label/defs.py index 13a0599c..4e927c24 100644 --- a/packages/atproto_client/models/com/atproto/label/defs.py +++ b/packages/atproto_client/models/com/atproto/label/defs.py @@ -57,16 +57,22 @@ class SelfLabel(base.ModelBase): class LabelValueDefinition(base.ModelBase): """Definition model for :obj:`com.atproto.label.defs`. Declares a label value and its expected interpretations and behaviors.""" - blurs: str #: 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. + blurs: t.Union[ + t.Literal['content'], t.Literal['media'], t.Literal['none'], str + ] #: 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. identifier: str = Field( max_length=100 ) #: The value of the label being defined. Must only include lowercase ascii and the '-' character ([a-z-]+). locales: t.List['models.ComAtprotoLabelDefs.LabelValueDefinitionStrings'] #: Locales. - severity: str #: How should a client visually convey this label? 'inform' means neutral and informational; 'alert' means negative and warning; 'none' means show nothing. + severity: t.Union[ + t.Literal['inform'], t.Literal['alert'], t.Literal['none'], str + ] #: How should a client visually convey this label? 'inform' means neutral and informational; 'alert' means negative and warning; 'none' means show nothing. adult_only: t.Optional[ bool ] = None #: Does the user need to have adult content enabled in order to configure this label? - default_setting: t.Optional[str] = None #: The default setting for this label. + default_setting: t.Optional[ + t.Union[t.Literal['ignore'], t.Literal['warn'], t.Literal['hide'], str] + ] = None #: The default setting for this label. py_type: t.Literal['com.atproto.label.defs#labelValueDefinition'] = Field( default='com.atproto.label.defs#labelValueDefinition', alias='$type', frozen=True diff --git a/packages/atproto_client/models/com/atproto/label/subscribe_labels.py b/packages/atproto_client/models/com/atproto/label/subscribe_labels.py index e7998bb9..9e69298b 100644 --- a/packages/atproto_client/models/com/atproto/label/subscribe_labels.py +++ b/packages/atproto_client/models/com/atproto/label/subscribe_labels.py @@ -39,7 +39,7 @@ class Labels(base.ModelBase): class Info(base.ModelBase): """Definition model for :obj:`com.atproto.label.subscribeLabels`.""" - name: str #: Name. + name: t.Union[t.Literal['OutdatedCursor'], str] #: Name. message: t.Optional[str] = None #: Message. py_type: t.Literal['com.atproto.label.subscribeLabels#info'] = Field( diff --git a/packages/atproto_client/models/com/atproto/repo/apply_writes.py b/packages/atproto_client/models/com/atproto/repo/apply_writes.py index 7101ade0..83ba966b 100644 --- a/packages/atproto_client/models/com/atproto/repo/apply_writes.py +++ b/packages/atproto_client/models/com/atproto/repo/apply_writes.py @@ -116,7 +116,7 @@ class CreateResult(base.ModelBase): cid: str #: Cid. uri: str #: Uri. - validation_status: t.Optional[str] = None #: Validation status. + validation_status: t.Optional[t.Union[t.Literal['valid'], t.Literal['unknown'], str]] = None #: Validation status. py_type: t.Literal['com.atproto.repo.applyWrites#createResult'] = Field( default='com.atproto.repo.applyWrites#createResult', alias='$type', frozen=True @@ -128,7 +128,7 @@ class UpdateResult(base.ModelBase): cid: str #: Cid. uri: str #: Uri. - validation_status: t.Optional[str] = None #: Validation status. + validation_status: t.Optional[t.Union[t.Literal['valid'], t.Literal['unknown'], str]] = None #: Validation status. py_type: t.Literal['com.atproto.repo.applyWrites#updateResult'] = Field( default='com.atproto.repo.applyWrites#updateResult', alias='$type', frozen=True diff --git a/packages/atproto_client/models/com/atproto/repo/create_record.py b/packages/atproto_client/models/com/atproto/repo/create_record.py index 7f5df61e..06c9282c 100644 --- a/packages/atproto_client/models/com/atproto/repo/create_record.py +++ b/packages/atproto_client/models/com/atproto/repo/create_record.py @@ -46,4 +46,4 @@ class Response(base.ResponseModelBase): cid: str #: Cid. uri: str #: Uri. commit: t.Optional['models.ComAtprotoRepoDefs.CommitMeta'] = None #: Commit. - validation_status: t.Optional[str] = None #: Validation status. + validation_status: t.Optional[t.Union[t.Literal['valid'], t.Literal['unknown'], str]] = None #: Validation status. diff --git a/packages/atproto_client/models/com/atproto/repo/put_record.py b/packages/atproto_client/models/com/atproto/repo/put_record.py index 892fb99f..37ca69e8 100644 --- a/packages/atproto_client/models/com/atproto/repo/put_record.py +++ b/packages/atproto_client/models/com/atproto/repo/put_record.py @@ -52,4 +52,4 @@ class Response(base.ResponseModelBase): cid: str #: Cid. uri: str #: Uri. commit: t.Optional['models.ComAtprotoRepoDefs.CommitMeta'] = None #: Commit. - validation_status: t.Optional[str] = None #: Validation status. + validation_status: t.Optional[t.Union[t.Literal['valid'], t.Literal['unknown'], str]] = None #: Validation status. diff --git a/packages/atproto_client/models/com/atproto/server/create_session.py b/packages/atproto_client/models/com/atproto/server/create_session.py index 2de7a0ea..d2b4840f 100644 --- a/packages/atproto_client/models/com/atproto/server/create_session.py +++ b/packages/atproto_client/models/com/atproto/server/create_session.py @@ -41,5 +41,5 @@ class Response(base.ResponseModelBase): email_auth_factor: t.Optional[bool] = None #: Email auth factor. email_confirmed: t.Optional[bool] = None #: Email confirmed. status: t.Optional[ - str + t.Union[t.Literal['takendown'], t.Literal['suspended'], t.Literal['deactivated'], str] ] = None #: If active=false, this optional field indicates a possible reason for why the account is not active. If active=false and no status is supplied, then the host makes no claim for why the repository is no longer being hosted. diff --git a/packages/atproto_client/models/com/atproto/server/get_session.py b/packages/atproto_client/models/com/atproto/server/get_session.py index 8ca05e9a..2ffa5230 100644 --- a/packages/atproto_client/models/com/atproto/server/get_session.py +++ b/packages/atproto_client/models/com/atproto/server/get_session.py @@ -23,5 +23,5 @@ class Response(base.ResponseModelBase): email_auth_factor: t.Optional[bool] = None #: Email auth factor. email_confirmed: t.Optional[bool] = None #: Email confirmed. status: t.Optional[ - str + t.Union[t.Literal['takendown'], t.Literal['suspended'], t.Literal['deactivated'], str] ] = None #: If active=false, this optional field indicates a possible reason for why the account is not active. If active=false and no status is supplied, then the host makes no claim for why the repository is no longer being hosted. diff --git a/packages/atproto_client/models/com/atproto/server/refresh_session.py b/packages/atproto_client/models/com/atproto/server/refresh_session.py index 358b9834..64b2cb2a 100644 --- a/packages/atproto_client/models/com/atproto/server/refresh_session.py +++ b/packages/atproto_client/models/com/atproto/server/refresh_session.py @@ -21,4 +21,6 @@ class Response(base.ResponseModelBase): refresh_jwt: str #: Refresh jwt. active: t.Optional[bool] = None #: Active. did_doc: t.Optional['UnknownType'] = None #: Did doc. - status: t.Optional[str] = None #: Hosting status of the account. If not specified, then assume 'active'. + status: t.Optional[ + t.Union[t.Literal['takendown'], t.Literal['suspended'], t.Literal['deactivated'], str] + ] = None #: Hosting status of the account. If not specified, then assume 'active'. diff --git a/packages/atproto_client/models/com/atproto/sync/get_repo_status.py b/packages/atproto_client/models/com/atproto/sync/get_repo_status.py index 6993a597..909b882f 100644 --- a/packages/atproto_client/models/com/atproto/sync/get_repo_status.py +++ b/packages/atproto_client/models/com/atproto/sync/get_repo_status.py @@ -27,5 +27,5 @@ class Response(base.ResponseModelBase): did: str #: Did. rev: t.Optional[str] = None #: Optional field, the current rev of the repo, if active=true. status: t.Optional[ - str + t.Union[t.Literal['takendown'], t.Literal['suspended'], t.Literal['deactivated'], str] ] = None #: If active=false, this optional field indicates a possible reason for why the account is not active. If active=false and no status is supplied, then the host makes no claim for why the repository is no longer being hosted. diff --git a/packages/atproto_client/models/com/atproto/sync/list_repos.py b/packages/atproto_client/models/com/atproto/sync/list_repos.py index afaa6d48..846adf3d 100644 --- a/packages/atproto_client/models/com/atproto/sync/list_repos.py +++ b/packages/atproto_client/models/com/atproto/sync/list_repos.py @@ -42,7 +42,7 @@ class Repo(base.ModelBase): rev: str #: Rev. active: t.Optional[bool] = None #: Active. status: t.Optional[ - str + t.Union[t.Literal['takendown'], t.Literal['suspended'], t.Literal['deactivated'], str] ] = None #: If active=false, this optional field indicates a possible reason for why the account is not active. If active=false and no status is supplied, then the host makes no claim for why the repository is no longer being hosted. py_type: t.Literal['com.atproto.sync.listRepos#repo'] = Field( diff --git a/packages/atproto_client/models/com/atproto/sync/subscribe_repos.py b/packages/atproto_client/models/com/atproto/sync/subscribe_repos.py index d72883a7..1b702c41 100644 --- a/packages/atproto_client/models/com/atproto/sync/subscribe_repos.py +++ b/packages/atproto_client/models/com/atproto/sync/subscribe_repos.py @@ -77,7 +77,7 @@ class Account(base.ModelBase): seq: int #: Seq. time: str #: Time. status: t.Optional[ - str + t.Union[t.Literal['takendown'], t.Literal['suspended'], t.Literal['deleted'], t.Literal['deactivated'], str] ] = None #: If active=false, this optional field indicates a reason for why the account is not active. py_type: t.Literal['com.atproto.sync.subscribeRepos#account'] = Field( @@ -126,7 +126,7 @@ class Tombstone(base.ModelBase): class Info(base.ModelBase): """Definition model for :obj:`com.atproto.sync.subscribeRepos`.""" - name: str #: Name. + name: t.Union[t.Literal['OutdatedCursor'], str] #: Name. message: t.Optional[str] = None #: Message. py_type: t.Literal['com.atproto.sync.subscribeRepos#info'] = Field( @@ -137,7 +137,7 @@ class Info(base.ModelBase): class RepoOp(base.ModelBase): """Definition model for :obj:`com.atproto.sync.subscribeRepos`. A repo operation, ie a mutation of a single record.""" - action: str #: Action. + action: t.Union[t.Literal['create'], t.Literal['update'], t.Literal['delete'], str] #: Action. path: str #: Path. cid: t.Optional['CIDType'] = None #: For creates and updates, the new record CID. For deletions, null. diff --git a/packages/atproto_client/models/tools/ozone/moderation/query_events.py b/packages/atproto_client/models/tools/ozone/moderation/query_events.py index 67775e1e..bce30ada 100644 --- a/packages/atproto_client/models/tools/ozone/moderation/query_events.py +++ b/packages/atproto_client/models/tools/ozone/moderation/query_events.py @@ -42,7 +42,7 @@ class Params(base.ParamsModelBase): ] = None #: If specified, only events where all of these tags were removed are returned. report_types: t.Optional[t.List[str]] = None #: Report types. sort_direction: t.Optional[ - str + t.Union[t.Literal['asc'], t.Literal['desc']] ] = None #: Sort direction for the events. Defaults to descending order of created at timestamp. subject: t.Optional[str] = None #: Subject. types: t.Optional[ @@ -77,7 +77,7 @@ class ParamsDict(t.TypedDict): ] #: If specified, only events where all of these tags were removed are returned. report_types: te.NotRequired[t.Optional[t.List[str]]] #: Report types. sort_direction: te.NotRequired[ - t.Optional[str] + t.Optional[t.Union[t.Literal['asc'], t.Literal['desc']]] ] #: Sort direction for the events. Defaults to descending order of created at timestamp. subject: te.NotRequired[t.Optional[str]] #: Subject. types: te.NotRequired[ diff --git a/packages/atproto_client/models/tools/ozone/moderation/query_statuses.py b/packages/atproto_client/models/tools/ozone/moderation/query_statuses.py index 8f8d3ae9..dc53910a 100644 --- a/packages/atproto_client/models/tools/ozone/moderation/query_statuses.py +++ b/packages/atproto_client/models/tools/ozone/moderation/query_statuses.py @@ -34,8 +34,8 @@ class Params(base.ParamsModelBase): review_state: t.Optional[str] = None #: Specify when fetching subjects in a certain state. reviewed_after: t.Optional[str] = None #: Search subjects reviewed after a given timestamp. reviewed_before: t.Optional[str] = None #: Search subjects reviewed before a given timestamp. - sort_direction: t.Optional[str] = None #: Sort direction. - sort_field: t.Optional[str] = None #: Sort field. + sort_direction: t.Optional[t.Union[t.Literal['asc'], t.Literal['desc']]] = None #: Sort direction. + sort_field: t.Optional[t.Union[t.Literal['lastReviewedAt'], t.Literal['lastReportedAt']]] = None #: Sort field. subject: t.Optional[str] = None #: Subject. tags: t.Optional[t.List[str]] = None #: Tags. takendown: t.Optional[bool] = None #: Get subjects that were taken down. @@ -62,8 +62,10 @@ class ParamsDict(t.TypedDict): review_state: te.NotRequired[t.Optional[str]] #: Specify when fetching subjects in a certain state. reviewed_after: te.NotRequired[t.Optional[str]] #: Search subjects reviewed after a given timestamp. reviewed_before: te.NotRequired[t.Optional[str]] #: Search subjects reviewed before a given timestamp. - sort_direction: te.NotRequired[t.Optional[str]] #: Sort direction. - sort_field: te.NotRequired[t.Optional[str]] #: Sort field. + sort_direction: te.NotRequired[t.Optional[t.Union[t.Literal['asc'], t.Literal['desc']]]] #: Sort direction. + sort_field: te.NotRequired[ + t.Optional[t.Union[t.Literal['lastReviewedAt'], t.Literal['lastReportedAt']]] + ] #: Sort field. subject: te.NotRequired[t.Optional[str]] #: Subject. tags: te.NotRequired[t.Optional[t.List[str]]] #: Tags. takendown: te.NotRequired[t.Optional[bool]] #: Get subjects that were taken down. diff --git a/packages/atproto_client/models/tools/ozone/server/get_config.py b/packages/atproto_client/models/tools/ozone/server/get_config.py index 34c9c19e..cc08859c 100644 --- a/packages/atproto_client/models/tools/ozone/server/get_config.py +++ b/packages/atproto_client/models/tools/ozone/server/get_config.py @@ -37,7 +37,14 @@ class ServiceConfig(base.ModelBase): class ViewerConfig(base.ModelBase): """Definition model for :obj:`tools.ozone.server.getConfig`.""" - role: t.Optional[str] = None #: Role. + role: t.Optional[ + t.Union[ + 'models.ToolsOzoneTeamDefs.RoleAdmin', + 'models.ToolsOzoneTeamDefs.RoleModerator', + 'models.ToolsOzoneTeamDefs.RoleTriage', + str, + ] + ] = None #: Role. py_type: t.Literal['tools.ozone.server.getConfig#viewerConfig'] = Field( default='tools.ozone.server.getConfig#viewerConfig', alias='$type', frozen=True diff --git a/packages/atproto_client/models/tools/ozone/team/add_member.py b/packages/atproto_client/models/tools/ozone/team/add_member.py index 199e9794..aa801496 100644 --- a/packages/atproto_client/models/tools/ozone/team/add_member.py +++ b/packages/atproto_client/models/tools/ozone/team/add_member.py @@ -7,6 +7,8 @@ import typing as t +if t.TYPE_CHECKING: + from atproto_client import models from atproto_client.models import base @@ -14,9 +16,19 @@ class Data(base.DataModelBase): """Input data model for :obj:`tools.ozone.team.addMember`.""" did: str #: Did. - role: str #: Role. + role: t.Union[ + 'models.ToolsOzoneTeamDefs.RoleAdmin', + 'models.ToolsOzoneTeamDefs.RoleModerator', + 'models.ToolsOzoneTeamDefs.RoleTriage', + str, + ] #: Role. class DataDict(t.TypedDict): did: str #: Did. - role: str #: Role. + role: t.Union[ + 'models.ToolsOzoneTeamDefs.RoleAdmin', + 'models.ToolsOzoneTeamDefs.RoleModerator', + 'models.ToolsOzoneTeamDefs.RoleTriage', + str, + ] #: Role. diff --git a/packages/atproto_client/models/tools/ozone/team/defs.py b/packages/atproto_client/models/tools/ozone/team/defs.py index e35925f0..6d5f9e96 100644 --- a/packages/atproto_client/models/tools/ozone/team/defs.py +++ b/packages/atproto_client/models/tools/ozone/team/defs.py @@ -18,7 +18,12 @@ class Member(base.ModelBase): """Definition model for :obj:`tools.ozone.team.defs`.""" did: str #: Did. - role: str #: Role. + role: t.Union[ + 'models.ToolsOzoneTeamDefs.RoleAdmin', + 'models.ToolsOzoneTeamDefs.RoleModerator', + 'models.ToolsOzoneTeamDefs.RoleTriage', + str, + ] #: Role. created_at: t.Optional[str] = None #: Created at. disabled: t.Optional[bool] = None #: Disabled. last_updated_by: t.Optional[str] = None #: Last updated by. diff --git a/packages/atproto_client/models/tools/ozone/team/update_member.py b/packages/atproto_client/models/tools/ozone/team/update_member.py index 4e73fbca..f829a3cf 100644 --- a/packages/atproto_client/models/tools/ozone/team/update_member.py +++ b/packages/atproto_client/models/tools/ozone/team/update_member.py @@ -9,6 +9,8 @@ import typing_extensions as te +if t.TYPE_CHECKING: + from atproto_client import models from atproto_client.models import base @@ -17,10 +19,26 @@ class Data(base.DataModelBase): did: str #: Did. disabled: t.Optional[bool] = None #: Disabled. - role: t.Optional[str] = None #: Role. + role: t.Optional[ + t.Union[ + 'models.ToolsOzoneTeamDefs.RoleAdmin', + 'models.ToolsOzoneTeamDefs.RoleModerator', + 'models.ToolsOzoneTeamDefs.RoleTriage', + str, + ] + ] = None #: Role. class DataDict(t.TypedDict): did: str #: Did. disabled: te.NotRequired[t.Optional[bool]] #: Disabled. - role: te.NotRequired[t.Optional[str]] #: Role. + role: te.NotRequired[ + t.Optional[ + t.Union[ + 'models.ToolsOzoneTeamDefs.RoleAdmin', + 'models.ToolsOzoneTeamDefs.RoleModerator', + 'models.ToolsOzoneTeamDefs.RoleTriage', + str, + ] + ] + ] #: Role. diff --git a/packages/atproto_codegen/models/generator.py b/packages/atproto_codegen/models/generator.py index f1edfef0..f50e7dcb 100644 --- a/packages/atproto_codegen/models/generator.py +++ b/packages/atproto_codegen/models/generator.py @@ -127,7 +127,6 @@ def _get_typeddict_class_def(name: str, model_type: TypedDictType) -> str: _LEXICON_TYPE_TO_PRIMITIVE_TYPEHINT = { - models.LexString: 'str', models.LexInteger: 'int', models.LexBoolean: 'bool', } @@ -139,6 +138,35 @@ def _get_optional_typehint(type_hint: str, *, optional: bool) -> str: return type_hint +def _get_str_enum_typehint(nsid: NSID, field_type_def: models.LexString, *, optional: bool) -> str: + values = field_type_def.known_values or field_type_def.enum + + union_type_parts = [] + for value in values: + if '#' in value: + # reference to literal (token) + model_path, _ = _resolve_nsid_ref(nsid, value) + type_ = f"'{model_path}'" + else: + # literal + type_ = f"t.Literal['{value}']" + + union_type_parts.append(type_) + + # known_values is not closed enum + closed_enum = '' if field_type_def.enum else ', str' + return f"t.Union[{', '.join(union_type_parts)}{closed_enum}]" + + +def _get_str_typehint(nsid: NSID, field_type_def: models.LexString, *, optional: bool) -> str: + str_typehint = 'str' + + if field_type_def.known_values or field_type_def.enum: + str_typehint = _get_str_enum_typehint(nsid, field_type_def, optional=optional) + + return _get_optional_typehint(str_typehint, optional=optional) + + def _get_ref_typehint(nsid: NSID, field_type_def: models.LexRef, *, optional: bool) -> str: model_path, _ = _resolve_nsid_ref(nsid, field_type_def.ref) return _get_optional_typehint(f"'{model_path}'", optional=optional) @@ -165,7 +193,7 @@ def _get_ref_union_typehint(nsid: NSID, field_type_def: models.LexRefUnion, *, o return _get_optional_typehint(annotated_union, optional=optional) -def _get_model_field_typehint( +def _get_model_field_typehint( # noqa: C901 nsid: NSID, field_type_def: t.Union[models.LexPrimitive, models.LexArray, models.LexBlob], *, @@ -184,6 +212,9 @@ def _get_model_field_typehint( if type_hint: return _get_optional_typehint(type_hint, optional=optional) + if field_type is models.LexString: + return _get_str_typehint(nsid, field_type_def, optional=optional) + if field_type is models.LexArray: items_type_hint = _get_model_field_typehint( nsid, field_type_def.items, optional=False, is_input_type=is_input_type @@ -546,30 +577,16 @@ def _generate_def_array(nsid: NSID, def_name: str, def_model: models.LexArray) - def _generate_def_string(nsid: NSID, def_name: str, def_model: models.LexString) -> str: # FIXME(MarshalX): support more fields. only known_values field is supported for now - if not def_model.known_values: + if not def_model.known_values and not def_model.enum: return '' - union_types = [] - for known_value in def_model.known_values: - if '#' in known_value: - # reference to literal (token) - model_path, _ = _resolve_nsid_ref(nsid, known_value) - type_ = f"'{model_path}'" - else: - # literal - # FIXME(MarshalX): not used for now - type_ = f"t.Literal['{known_value}']" - - union_types.append(type_) - - final_type = f"t.Union[{', '.join(union_types)}, str]" - + type_hint = _get_str_typehint(nsid, def_model, optional=False) description = def_model.description if not description: description = gen_description_by_camel_case_name(def_name) lines = [ - f'{get_def_model_name(def_name)} = {final_type} #: {description}', + f'{get_def_model_name(def_name)} = {type_hint} #: {description}', '', '', ]