From b6e0f890b7c921cc303ddfc4036d3c9659065387 Mon Sep 17 00:00:00 2001 From: Ilya Siamionau Date: Wed, 11 Sep 2024 08:23:24 +0200 Subject: [PATCH 1/5] Update changelog for v0.0.53 (#385) --- CHANGES.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 5de0fca9..4120fd64 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,15 @@ # Change Log +## Version 0.0.53 + +**10.09.2024** + +**⚡ Thanks to libipld 2.0.0 firehose performance should increase approximately by 30%! No changes from you are required! Check more detailed benchmark results [here](https://github.com/MarshalX/python-libipld/releases/tag/v2.0.0)** + +* Add libipld v2.0.0 support by @MarshalX in https://github.com/MarshalX/atproto/pull/315 +* Update lexicons fetched from e4d41d6 committed 2024-09-04T10:42:39Z by @MarshalX in https://github.com/MarshalX/atproto/pull/380 +* Fix firehose client stop by @MarshalX in https://github.com/MarshalX/atproto/pull/384 + ## Version 0.0.52 **01.09.2024** From 43fd5ba7622b23e5c609d3aefc14875b661ebe1a Mon Sep 17 00:00:00 2001 From: Ilya Siamionau Date: Wed, 11 Sep 2024 19:01:42 +0200 Subject: [PATCH 2/5] Make string definitions which use know_values field as not closed enum (#389) --- packages/atproto_client/models/app/bsky/actor/defs.py | 2 +- packages/atproto_client/models/app/bsky/graph/defs.py | 5 ++++- packages/atproto_client/models/com/atproto/label/defs.py | 1 + .../atproto_client/models/com/atproto/moderation/defs.py | 1 + .../atproto_client/models/tools/ozone/moderation/defs.py | 1 + packages/atproto_codegen/models/generator.py | 2 +- 6 files changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/atproto_client/models/app/bsky/actor/defs.py b/packages/atproto_client/models/app/bsky/actor/defs.py index e7926bd6..c3c0a417 100644 --- a/packages/atproto_client/models/app/bsky/actor/defs.py +++ b/packages/atproto_client/models/app/bsky/actor/defs.py @@ -257,7 +257,7 @@ class InterestsPref(base.ModelBase): ) -MutedWordTarget = t.Union[t.Literal['content'], t.Literal['tag']] #: Muted word target +MutedWordTarget = t.Union[t.Literal['content'], t.Literal['tag'], str] #: Muted word target class MutedWord(base.ModelBase): diff --git a/packages/atproto_client/models/app/bsky/graph/defs.py b/packages/atproto_client/models/app/bsky/graph/defs.py index 5242d3c4..2ab037f8 100644 --- a/packages/atproto_client/models/app/bsky/graph/defs.py +++ b/packages/atproto_client/models/app/bsky/graph/defs.py @@ -106,7 +106,10 @@ class StarterPackViewBasic(base.ModelBase): ListPurpose = t.Union[ - 'models.AppBskyGraphDefs.Modlist', 'models.AppBskyGraphDefs.Curatelist', 'models.AppBskyGraphDefs.Referencelist' + 'models.AppBskyGraphDefs.Modlist', + 'models.AppBskyGraphDefs.Curatelist', + 'models.AppBskyGraphDefs.Referencelist', + str, ] #: List purpose Modlist = t.Literal[ diff --git a/packages/atproto_client/models/com/atproto/label/defs.py b/packages/atproto_client/models/com/atproto/label/defs.py index 5c8e9aad..13a0599c 100644 --- a/packages/atproto_client/models/com/atproto/label/defs.py +++ b/packages/atproto_client/models/com/atproto/label/defs.py @@ -99,4 +99,5 @@ class LabelValueDefinitionStrings(base.ModelBase): t.Literal['nudity'], t.Literal['nsfl'], t.Literal['gore'], + str, ] #: Label value diff --git a/packages/atproto_client/models/com/atproto/moderation/defs.py b/packages/atproto_client/models/com/atproto/moderation/defs.py index 7e6bc99d..ef163b2b 100644 --- a/packages/atproto_client/models/com/atproto/moderation/defs.py +++ b/packages/atproto_client/models/com/atproto/moderation/defs.py @@ -18,6 +18,7 @@ 'models.ComAtprotoModerationDefs.ReasonRude', 'models.ComAtprotoModerationDefs.ReasonOther', 'models.ComAtprotoModerationDefs.ReasonAppeal', + str, ] #: Reason type ReasonSpam = t.Literal[ diff --git a/packages/atproto_client/models/tools/ozone/moderation/defs.py b/packages/atproto_client/models/tools/ozone/moderation/defs.py index eb56cecf..0cded8d3 100644 --- a/packages/atproto_client/models/tools/ozone/moderation/defs.py +++ b/packages/atproto_client/models/tools/ozone/moderation/defs.py @@ -140,6 +140,7 @@ class SubjectStatusView(base.ModelBase): 'models.ToolsOzoneModerationDefs.ReviewEscalated', 'models.ToolsOzoneModerationDefs.ReviewClosed', 'models.ToolsOzoneModerationDefs.ReviewNone', + str, ] #: Subject review state ReviewOpen = t.Literal[ diff --git a/packages/atproto_codegen/models/generator.py b/packages/atproto_codegen/models/generator.py index c3f1dc4e..f1edfef0 100644 --- a/packages/atproto_codegen/models/generator.py +++ b/packages/atproto_codegen/models/generator.py @@ -562,7 +562,7 @@ def _generate_def_string(nsid: NSID, def_name: str, def_model: models.LexString) union_types.append(type_) - final_type = f"t.Union[{', '.join(union_types)}]" + final_type = f"t.Union[{', '.join(union_types)}, str]" description = def_model.description if not description: From 03d9483359e48181d2bfe8d928c09a1330fb356b Mon Sep 17 00:00:00 2001 From: Ilya Siamionau Date: Wed, 11 Sep 2024 19:45:46 +0200 Subject: [PATCH 3/5] Add support for `known_values` and `enum` of string properties in objects (#391) --- .../models/app/bsky/actor/defs.py | 14 +++-- .../models/app/bsky/feed/defs.py | 18 +++++- .../models/app/bsky/feed/get_author_feed.py | 22 +++++++- .../models/app/bsky/feed/search_posts.py | 8 ++- .../bsky/notification/list_notifications.py | 13 ++++- .../app/bsky/notification/register_push.py | 4 +- .../bsky/unspecced/get_tagged_suggestions.py | 2 +- .../bsky/unspecced/search_posts_skeleton.py | 8 ++- .../models/app/bsky/video/defs.py | 4 +- .../models/chat/bsky/actor/declaration.py | 2 +- .../com/atproto/admin/get_invite_codes.py | 4 +- .../models/com/atproto/label/defs.py | 12 +++- .../com/atproto/label/subscribe_labels.py | 2 +- .../models/com/atproto/repo/apply_writes.py | 4 +- .../models/com/atproto/repo/create_record.py | 2 +- .../models/com/atproto/repo/put_record.py | 2 +- .../com/atproto/server/create_session.py | 2 +- .../models/com/atproto/server/get_session.py | 2 +- .../com/atproto/server/refresh_session.py | 4 +- .../com/atproto/sync/get_repo_status.py | 2 +- .../models/com/atproto/sync/list_repos.py | 2 +- .../com/atproto/sync/subscribe_repos.py | 6 +- .../tools/ozone/moderation/query_events.py | 4 +- .../tools/ozone/moderation/query_statuses.py | 10 ++-- .../models/tools/ozone/server/get_config.py | 9 ++- .../models/tools/ozone/team/add_member.py | 16 +++++- .../models/tools/ozone/team/defs.py | 7 ++- .../models/tools/ozone/team/update_member.py | 22 +++++++- packages/atproto_codegen/models/generator.py | 55 ++++++++++++------- 29 files changed, 193 insertions(+), 69 deletions(-) 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}', '', '', ] From d6b10b600bec41d582f06c6d9862913ae7587776 Mon Sep 17 00:00:00 2001 From: Ilya Siamionau Date: Wed, 11 Sep 2024 20:24:38 +0200 Subject: [PATCH 4/5] Fix model field default value generating in cases when this is the only one constraint (#393) --- .../models/app/bsky/actor/defs.py | 6 +++--- .../models/app/bsky/feed/get_author_feed.py | 2 +- .../models/app/bsky/feed/search_posts.py | 2 +- .../models/app/bsky/labeler/get_services.py | 2 +- .../app/bsky/unspecced/search_posts_skeleton.py | 2 +- .../chat/bsky/moderation/get_message_context.py | 4 ++-- .../com/atproto/admin/get_invite_codes.py | 2 +- .../models/com/atproto/label/defs.py | 2 +- .../com/atproto/server/create_invite_codes.py | 2 +- .../atproto/server/get_account_invite_codes.py | 4 ++-- .../tools/ozone/moderation/query_events.py | 4 ++-- .../tools/ozone/moderation/query_statuses.py | 6 ++++-- packages/atproto_codegen/models/generator.py | 17 ++++++----------- 13 files changed, 26 insertions(+), 29 deletions(-) diff --git a/packages/atproto_client/models/app/bsky/actor/defs.py b/packages/atproto_client/models/app/bsky/actor/defs.py index 15a483a3..4378193e 100644 --- a/packages/atproto_client/models/app/bsky/actor/defs.py +++ b/packages/atproto_client/models/app/bsky/actor/defs.py @@ -153,7 +153,7 @@ class KnownFollowers(base.ModelBase): class AdultContentPref(base.ModelBase): """Definition model for :obj:`app.bsky.actor.defs`.""" - enabled: bool = None #: Enabled. + enabled: bool = False #: Enabled. py_type: t.Literal['app.bsky.actor.defs#adultContentPref'] = Field( default='app.bsky.actor.defs#adultContentPref', alias='$type', frozen=True @@ -228,7 +228,7 @@ class FeedViewPref(base.ModelBase): hide_replies_by_like_count: t.Optional[ int ] = None #: Hide replies in the feed if they do not have this number of likes. - hide_replies_by_unfollowed: t.Optional[bool] = None #: Hide replies in the feed if they are not by followed users. + hide_replies_by_unfollowed: t.Optional[bool] = True #: Hide replies in the feed if they are not by followed users. hide_reposts: t.Optional[bool] = None #: Hide reposts in the feed. py_type: t.Literal['app.bsky.actor.defs#feedViewPref'] = Field( @@ -271,7 +271,7 @@ class MutedWord(base.ModelBase): value: str = Field(max_length=10000) #: The muted word itself. actor_target: t.Optional[ 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. + ] = 'all' #: Groups of users to apply the muted word to. If undefined, applies to all users. expires_at: t.Optional[ str ] = None #: The date and time at which the muted word will expire and no longer be applied. 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 dcc0b8af..54f95f81 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 @@ -28,7 +28,7 @@ class Params(base.ParamsModelBase): t.Literal['posts_and_author_threads'], str, ] - ] = None #: Combinations of post/repost types to include in response. + ] = 'posts_with_replies' #: Combinations of post/repost types to include in response. limit: t.Optional[int] = Field(default=50, ge=1, le=100) #: 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 4abba118..34f54132 100644 --- a/packages/atproto_client/models/app/bsky/feed/search_posts.py +++ b/packages/atproto_client/models/app/bsky/feed/search_posts.py @@ -40,7 +40,7 @@ class Params(base.ParamsModelBase): ] = 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[ t.Union[t.Literal['top'], t.Literal['latest'], str] - ] = None #: Specifies the ranking order of results. + ] = 'latest' #: 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. diff --git a/packages/atproto_client/models/app/bsky/labeler/get_services.py b/packages/atproto_client/models/app/bsky/labeler/get_services.py index dceec4aa..55ce8f10 100644 --- a/packages/atproto_client/models/app/bsky/labeler/get_services.py +++ b/packages/atproto_client/models/app/bsky/labeler/get_services.py @@ -19,7 +19,7 @@ class Params(base.ParamsModelBase): """Parameters model for :obj:`app.bsky.labeler.getServices`.""" dids: t.List[str] #: Dids. - detailed: t.Optional[bool] = None #: Detailed. + detailed: t.Optional[bool] = False #: Detailed. class ParamsDict(t.TypedDict): 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 d90af81f..4ac9aef1 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 @@ -40,7 +40,7 @@ class Params(base.ParamsModelBase): ] = 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[ t.Union[t.Literal['top'], t.Literal['latest'], str] - ] = None #: Specifies the ranking order of results. + ] = 'latest' #: 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. diff --git a/packages/atproto_client/models/chat/bsky/moderation/get_message_context.py b/packages/atproto_client/models/chat/bsky/moderation/get_message_context.py index a898043e..fc3d7689 100644 --- a/packages/atproto_client/models/chat/bsky/moderation/get_message_context.py +++ b/packages/atproto_client/models/chat/bsky/moderation/get_message_context.py @@ -19,8 +19,8 @@ class Params(base.ParamsModelBase): """Parameters model for :obj:`chat.bsky.moderation.getMessageContext`.""" message_id: str #: Message id. - after: t.Optional[int] = None #: After. - before: t.Optional[int] = None #: Before. + after: t.Optional[int] = 5 #: After. + before: t.Optional[int] = 5 #: Before. convo_id: t.Optional[ str ] = None #: Conversation that the message is from. NOTE: this field will eventually be required. 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 70ae920f..cb8864f4 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,7 +20,7 @@ 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[t.Union[t.Literal['recent'], t.Literal['usage'], str]] = None #: Sort. + sort: t.Optional[t.Union[t.Literal['recent'], t.Literal['usage'], str]] = 'recent' #: Sort. class ParamsDict(t.TypedDict): diff --git a/packages/atproto_client/models/com/atproto/label/defs.py b/packages/atproto_client/models/com/atproto/label/defs.py index 4e927c24..8d12b2d6 100644 --- a/packages/atproto_client/models/com/atproto/label/defs.py +++ b/packages/atproto_client/models/com/atproto/label/defs.py @@ -72,7 +72,7 @@ class LabelValueDefinition(base.ModelBase): ] = None #: Does the user need to have adult content enabled in order to configure 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. + ] = 'warn' #: 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/server/create_invite_codes.py b/packages/atproto_client/models/com/atproto/server/create_invite_codes.py index dc55beee..5b278824 100644 --- a/packages/atproto_client/models/com/atproto/server/create_invite_codes.py +++ b/packages/atproto_client/models/com/atproto/server/create_invite_codes.py @@ -18,7 +18,7 @@ class Data(base.DataModelBase): """Input data model for :obj:`com.atproto.server.createInviteCodes`.""" - code_count: int = None #: Code count. + code_count: int = 1 #: Code count. use_count: int #: Use count. for_accounts: t.Optional[t.List[str]] = None #: For accounts. diff --git a/packages/atproto_client/models/com/atproto/server/get_account_invite_codes.py b/packages/atproto_client/models/com/atproto/server/get_account_invite_codes.py index 5c4a9886..85ec4a6c 100644 --- a/packages/atproto_client/models/com/atproto/server/get_account_invite_codes.py +++ b/packages/atproto_client/models/com/atproto/server/get_account_invite_codes.py @@ -19,8 +19,8 @@ class Params(base.ParamsModelBase): create_available: t.Optional[ bool - ] = None #: Controls whether any new 'earned' but not 'created' invites should be created. - include_used: t.Optional[bool] = None #: Include used. + ] = True #: Controls whether any new 'earned' but not 'created' invites should be created. + include_used: t.Optional[bool] = True #: Include used. class ParamsDict(t.TypedDict): 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 bce30ada..a3aab459 100644 --- a/packages/atproto_client/models/tools/ozone/moderation/query_events.py +++ b/packages/atproto_client/models/tools/ozone/moderation/query_events.py @@ -32,7 +32,7 @@ class Params(base.ParamsModelBase): has_comment: t.Optional[bool] = None #: If true, only events with comments are returned. include_all_user_records: t.Optional[ bool - ] = None #: If true, events on all record types (posts, lists, profile etc.) owned by the did are returned. + ] = False #: If true, events on all record types (posts, lists, profile etc.) owned by the did are returned. limit: t.Optional[int] = Field(default=50, ge=1, le=100) #: Limit. removed_labels: t.Optional[ t.List[str] @@ -43,7 +43,7 @@ class Params(base.ParamsModelBase): report_types: t.Optional[t.List[str]] = None #: Report types. sort_direction: t.Optional[ t.Union[t.Literal['asc'], t.Literal['desc']] - ] = None #: Sort direction for the events. Defaults to descending order of created at timestamp. + ] = 'desc' #: Sort direction for the events. Defaults to descending order of created at timestamp. subject: t.Optional[str] = None #: Subject. types: t.Optional[ t.List[str] 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 dc53910a..207a412a 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,10 @@ 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[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. + sort_direction: t.Optional[t.Union[t.Literal['asc'], t.Literal['desc']]] = 'desc' #: Sort direction. + sort_field: t.Optional[ + t.Union[t.Literal['lastReviewedAt'], t.Literal['lastReportedAt']] + ] = 'lastReportedAt' #: 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. diff --git a/packages/atproto_codegen/models/generator.py b/packages/atproto_codegen/models/generator.py index f50e7dcb..c6bbd97e 100644 --- a/packages/atproto_codegen/models/generator.py +++ b/packages/atproto_codegen/models/generator.py @@ -278,7 +278,6 @@ def _get_model_field_value( # noqa: C901 min_length = field_type_def.min_length if field_type_def.max_length is not None: max_length = field_type_def.max_length - # TODO (MarshalX): support knownValue, format, enum? elif field_type == models.LexBoolean: if field_type_def.default is not None: @@ -311,21 +310,17 @@ def _get_model_field_value( # noqa: C901 if value is not_set: continue - if name != 'default': - only_default = False + str_value = f"'{value}'" if isinstance(value, str) else str(value) - value_str = f'{name}=' - if isinstance(value, str): - value_str += f"'{value}'" - elif isinstance(value, bool): - value_str += 'True' if value else 'False' + if name == 'default': + default = str_value else: - value_str += str(value) + only_default = False - values.append(value_str) + values.append(f'{name}={str_value}') if only_default: - return 'None' + return default if not values: return '' From 66644d5cb600de32956e918461bcec3c6f117bcb Mon Sep 17 00:00:00 2001 From: Ilya Siamionau Date: Wed, 11 Sep 2024 22:58:18 +0200 Subject: [PATCH 5/5] Update lexicons fetched from 62a8225 committed 2024-09-11T16:26:53Z (#394) --- lexicons/tools.ozone.moderation.defs.json | 4 +++ .../tools.ozone.moderation.queryStatuses.json | 31 +++++++++++++++---- .../models/tools/ozone/moderation/defs.py | 3 ++ .../tools/ozone/moderation/query_statuses.py | 10 ++++-- 4 files changed, 40 insertions(+), 8 deletions(-) diff --git a/lexicons/tools.ozone.moderation.defs.json b/lexicons/tools.ozone.moderation.defs.json index 83299d76..9bfabb0a 100644 --- a/lexicons/tools.ozone.moderation.defs.json +++ b/lexicons/tools.ozone.moderation.defs.json @@ -210,6 +210,10 @@ "durationInHours": { "type": "integer", "description": "Indicates how long the takedown should be in effect before automatically expiring." + }, + "acknowledgeAccountSubjects": { + "type": "boolean", + "description": "If true, all other reports on content authored by this account will be resolved (acknowledged)." } } }, diff --git a/lexicons/tools.ozone.moderation.queryStatuses.json b/lexicons/tools.ozone.moderation.queryStatuses.json index 81fc1e38..1eed9478 100644 --- a/lexicons/tools.ozone.moderation.queryStatuses.json +++ b/lexicons/tools.ozone.moderation.queryStatuses.json @@ -8,7 +8,15 @@ "parameters": { "type": "params", "properties": { - "subject": { "type": "string", "format": "uri" }, + "includeAllUserRecords": { + "type": "boolean", + "description": "All subjects belonging to the account specified in the 'subject' param will be returned." + }, + "subject": { + "type": "string", + "format": "uri", + "description": "The subject to get the status for." + }, "comment": { "type": "string", "description": "Search subjects by keyword from comments" @@ -47,7 +55,10 @@ }, "ignoreSubjects": { "type": "array", - "items": { "type": "string", "format": "uri" } + "items": { + "type": "string", + "format": "uri" + } }, "lastReviewedBy": { "type": "string", @@ -80,13 +91,19 @@ }, "tags": { "type": "array", - "items": { "type": "string" } + "items": { + "type": "string" + } }, "excludeTags": { "type": "array", - "items": { "type": "string" } + "items": { + "type": "string" + } }, - "cursor": { "type": "string" } + "cursor": { + "type": "string" + } } }, "output": { @@ -95,7 +112,9 @@ "type": "object", "required": ["subjectStatuses"], "properties": { - "cursor": { "type": "string" }, + "cursor": { + "type": "string" + }, "subjectStatuses": { "type": "array", "items": { diff --git a/packages/atproto_client/models/tools/ozone/moderation/defs.py b/packages/atproto_client/models/tools/ozone/moderation/defs.py index 0cded8d3..c500026b 100644 --- a/packages/atproto_client/models/tools/ozone/moderation/defs.py +++ b/packages/atproto_client/models/tools/ozone/moderation/defs.py @@ -163,6 +163,9 @@ class SubjectStatusView(base.ModelBase): class ModEventTakedown(base.ModelBase): """Definition model for :obj:`tools.ozone.moderation.defs`. Take down a subject permanently or temporarily.""" + acknowledge_account_subjects: t.Optional[ + bool + ] = None #: If true, all other reports on content authored by this account will be resolved (acknowledged). comment: t.Optional[str] = None #: Comment. duration_in_hours: t.Optional[ int 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 207a412a..1e3b8abb 100644 --- a/packages/atproto_client/models/tools/ozone/moderation/query_statuses.py +++ b/packages/atproto_client/models/tools/ozone/moderation/query_statuses.py @@ -23,6 +23,9 @@ class Params(base.ParamsModelBase): cursor: t.Optional[str] = None #: Cursor. exclude_tags: t.Optional[t.List[str]] = None #: Exclude tags. ignore_subjects: t.Optional[t.List[str]] = None #: Ignore subjects. + include_all_user_records: t.Optional[ + bool + ] = None #: All subjects belonging to the account specified in the 'subject' param will be returned. include_muted: t.Optional[ bool ] = None #: By default, we don't include muted subjects in the results. Set this to true to include them. @@ -38,7 +41,7 @@ class Params(base.ParamsModelBase): sort_field: t.Optional[ t.Union[t.Literal['lastReviewedAt'], t.Literal['lastReportedAt']] ] = 'lastReportedAt' #: Sort field. - subject: t.Optional[str] = None #: Subject. + subject: t.Optional[str] = None #: The subject to get the status for. tags: t.Optional[t.List[str]] = None #: Tags. takendown: t.Optional[bool] = None #: Get subjects that were taken down. @@ -49,6 +52,9 @@ class ParamsDict(t.TypedDict): cursor: te.NotRequired[t.Optional[str]] #: Cursor. exclude_tags: te.NotRequired[t.Optional[t.List[str]]] #: Exclude tags. ignore_subjects: te.NotRequired[t.Optional[t.List[str]]] #: Ignore subjects. + include_all_user_records: te.NotRequired[ + t.Optional[bool] + ] #: All subjects belonging to the account specified in the 'subject' param will be returned. include_muted: te.NotRequired[ t.Optional[bool] ] #: By default, we don't include muted subjects in the results. Set this to true to include them. @@ -68,7 +74,7 @@ class ParamsDict(t.TypedDict): sort_field: te.NotRequired[ t.Optional[t.Union[t.Literal['lastReviewedAt'], t.Literal['lastReportedAt']]] ] #: Sort field. - subject: te.NotRequired[t.Optional[str]] #: Subject. + subject: te.NotRequired[t.Optional[str]] #: The subject to get the status for. tags: te.NotRequired[t.Optional[t.List[str]]] #: Tags. takendown: te.NotRequired[t.Optional[bool]] #: Get subjects that were taken down.