Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for known_values and enum of string properties in objects #391

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions packages/atproto_client/models/app/bsky/actor/defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
18 changes: 17 additions & 1 deletion packages/atproto_client/models/app/bsky/feed/defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
22 changes: 20 additions & 2 deletions packages/atproto_client/models/app/bsky/feed/get_author_feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.


Expand Down
8 changes: 6 additions & 2 deletions packages/atproto_client/models/app/bsky/feed/search_posts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion packages/atproto_client/models/app/bsky/video/defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
12 changes: 9 additions & 3 deletions packages/atproto_client/models/com/atproto/label/defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -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'.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand All @@ -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.

Expand Down
Loading
Loading