From 3a6b8eb44a860659948b59a840e75eeb9346deee Mon Sep 17 00:00:00 2001 From: Muneyuki Noguchi Date: Sun, 1 Sep 2024 20:09:51 +0900 Subject: [PATCH] Update atproto --- atproto | 2 +- chitose/app/bsky/__init__.py | 7 ++++- chitose/app/bsky/embed/images.py | 15 ++-------- chitose/app/bsky/embed/record.py | 3 +- chitose/app/bsky/embed/record_with_media.py | 5 ++-- chitose/app/bsky/feed/defs.py | 3 +- chitose/app/bsky/feed/post.py | 3 +- chitose/com/atproto/repo/__init__.py | 6 ++-- chitose/com/atproto/repo/apply_writes.py | 32 +++++++++++++++++++-- chitose/com/atproto/repo/create_record.py | 2 +- chitose/com/atproto/repo/put_record.py | 2 +- docs/source/chitose.app.bsky.embed.rst | 16 +++++++++++ docs/source/chitose.app.bsky.rst | 1 + docs/source/chitose.com.atproto.repo.rst | 8 ++++++ 14 files changed, 79 insertions(+), 26 deletions(-) diff --git a/atproto b/atproto index ec2e426..bfbac24 160000 --- a/atproto +++ b/atproto @@ -1 +1 @@ -Subproject commit ec2e426e3273081b78841df91d69f87b6391bc9d +Subproject commit bfbac2431214a0c96dad104e7310ea10c863ac08 diff --git a/chitose/app/bsky/__init__.py b/chitose/app/bsky/__init__.py index 6f6f494..e463be9 100644 --- a/chitose/app/bsky/__init__.py +++ b/chitose/app/bsky/__init__.py @@ -10,6 +10,7 @@ from .notification import Notification_ from .richtext import Richtext_ from .unspecced import Unspecced_ +from .video import Video_ class Bsky_: """We recommend calling methods in this class via the :doc:`chitose.BskyAgent ` class instead of creating instances of this class directly.""" @@ -48,4 +49,8 @@ def richtext(self) -> Richtext_: @property def unspecced(self) -> Unspecced_: - return Unspecced_(self.call, self.subscribe) \ No newline at end of file + return Unspecced_(self.call, self.subscribe) + + @property + def video(self) -> Video_: + return Video_(self.call, self.subscribe) \ No newline at end of file diff --git a/chitose/app/bsky/embed/images.py b/chitose/app/bsky/embed/images.py index e0dc0dd..1dd233c 100644 --- a/chitose/app/bsky/embed/images.py +++ b/chitose/app/bsky/embed/images.py @@ -2,6 +2,7 @@ """A set of images embedded in a Bluesky record (eg, a post).""" from __future__ import annotations import chitose +import chitose.app.bsky.embed.defs import chitose.app.bsky.embed.images import typing @@ -21,7 +22,7 @@ class Image(chitose.Object): :param alt: Alt text description of the image, for accessibility. """ - def __init__(self, image: chitose.Blob, alt: str, aspect_ratio: typing.Optional[chitose.app.bsky.embed.images.AspectRatio]=None) -> None: + def __init__(self, image: chitose.Blob, alt: str, aspect_ratio: typing.Optional[chitose.app.bsky.embed.defs.AspectRatio]=None) -> None: self.image = image self.alt = alt self.aspect_ratio = aspect_ratio @@ -29,16 +30,6 @@ def __init__(self, image: chitose.Blob, alt: str, aspect_ratio: typing.Optional[ def to_dict(self) -> dict[str, typing.Any]: return {'image': self.image, 'alt': self.alt, 'aspectRatio': self.aspect_ratio, '$type': 'app.bsky.embed.images#image'} -class AspectRatio(chitose.Object): - """width:height represents an aspect ratio. It may be approximate, and may not correspond to absolute dimensions in any given unit.""" - - def __init__(self, width: int, height: int) -> None: - self.width = width - self.height = height - - def to_dict(self) -> dict[str, typing.Any]: - return {'width': self.width, 'height': self.height, '$type': 'app.bsky.embed.images#aspectRatio'} - class View(chitose.Object): """""" @@ -59,7 +50,7 @@ class ViewImage(chitose.Object): :param alt: Alt text description of the image, for accessibility. """ - def __init__(self, thumb: str, fullsize: str, alt: str, aspect_ratio: typing.Optional[chitose.app.bsky.embed.images.AspectRatio]=None) -> None: + def __init__(self, thumb: str, fullsize: str, alt: str, aspect_ratio: typing.Optional[chitose.app.bsky.embed.defs.AspectRatio]=None) -> None: self.thumb = thumb self.fullsize = fullsize self.alt = alt diff --git a/chitose/app/bsky/embed/record.py b/chitose/app/bsky/embed/record.py index b2d2a59..50f37be 100644 --- a/chitose/app/bsky/embed/record.py +++ b/chitose/app/bsky/embed/record.py @@ -7,6 +7,7 @@ import chitose.app.bsky.embed.images import chitose.app.bsky.embed.record import chitose.app.bsky.embed.record_with_media +import chitose.app.bsky.embed.video import chitose.app.bsky.feed.defs import chitose.app.bsky.graph.defs import chitose.app.bsky.labeler.defs @@ -39,7 +40,7 @@ class ViewRecord(chitose.Object): :param value: The record data itself. """ - def __init__(self, uri: str, cid: str, author: chitose.app.bsky.actor.defs.ProfileViewBasic, value: typing.Any, indexed_at: str, labels: typing.Optional[list[chitose.com.atproto.label.defs.Label]]=None, reply_count: typing.Optional[int]=None, repost_count: typing.Optional[int]=None, like_count: typing.Optional[int]=None, quote_count: typing.Optional[int]=None, embeds: typing.Optional[list[typing.Union[chitose.app.bsky.embed.images.View, chitose.app.bsky.embed.external.View, chitose.app.bsky.embed.record.View, chitose.app.bsky.embed.record_with_media.View]]]=None) -> None: + def __init__(self, uri: str, cid: str, author: chitose.app.bsky.actor.defs.ProfileViewBasic, value: typing.Any, indexed_at: str, labels: typing.Optional[list[chitose.com.atproto.label.defs.Label]]=None, reply_count: typing.Optional[int]=None, repost_count: typing.Optional[int]=None, like_count: typing.Optional[int]=None, quote_count: typing.Optional[int]=None, embeds: typing.Optional[list[typing.Union[chitose.app.bsky.embed.images.View, chitose.app.bsky.embed.video.View, chitose.app.bsky.embed.external.View, chitose.app.bsky.embed.record.View, chitose.app.bsky.embed.record_with_media.View]]]=None) -> None: self.uri = uri self.cid = cid self.author = author diff --git a/chitose/app/bsky/embed/record_with_media.py b/chitose/app/bsky/embed/record_with_media.py index 3b77912..bdeec44 100644 --- a/chitose/app/bsky/embed/record_with_media.py +++ b/chitose/app/bsky/embed/record_with_media.py @@ -5,12 +5,13 @@ import chitose.app.bsky.embed.external import chitose.app.bsky.embed.images import chitose.app.bsky.embed.record +import chitose.app.bsky.embed.video import typing class RecordWithMedia(chitose.Object): """""" - def __init__(self, record: chitose.app.bsky.embed.record.Record, media: typing.Union[chitose.app.bsky.embed.images.Images, chitose.app.bsky.embed.external.External]) -> None: + def __init__(self, record: chitose.app.bsky.embed.record.Record, media: typing.Union[chitose.app.bsky.embed.images.Images, chitose.app.bsky.embed.video.Video, chitose.app.bsky.embed.external.External]) -> None: self.record = record self.media = media @@ -20,7 +21,7 @@ def to_dict(self) -> dict[str, typing.Any]: class View(chitose.Object): """""" - def __init__(self, record: chitose.app.bsky.embed.record.View, media: typing.Union[chitose.app.bsky.embed.images.View, chitose.app.bsky.embed.external.View]) -> None: + def __init__(self, record: chitose.app.bsky.embed.record.View, media: typing.Union[chitose.app.bsky.embed.images.View, chitose.app.bsky.embed.video.View, chitose.app.bsky.embed.external.View]) -> None: self.record = record self.media = media diff --git a/chitose/app/bsky/feed/defs.py b/chitose/app/bsky/feed/defs.py index 23666c3..411586f 100644 --- a/chitose/app/bsky/feed/defs.py +++ b/chitose/app/bsky/feed/defs.py @@ -7,6 +7,7 @@ import chitose.app.bsky.embed.images import chitose.app.bsky.embed.record import chitose.app.bsky.embed.record_with_media +import chitose.app.bsky.embed.video import chitose.app.bsky.feed.defs import chitose.app.bsky.graph.defs import chitose.app.bsky.richtext.facet @@ -16,7 +17,7 @@ class PostView(chitose.Object): """""" - def __init__(self, uri: str, cid: str, author: chitose.app.bsky.actor.defs.ProfileViewBasic, record: typing.Any, indexed_at: str, embed: typing.Optional[typing.Union[chitose.app.bsky.embed.images.View, chitose.app.bsky.embed.external.View, chitose.app.bsky.embed.record.View, chitose.app.bsky.embed.record_with_media.View]]=None, reply_count: typing.Optional[int]=None, repost_count: typing.Optional[int]=None, like_count: typing.Optional[int]=None, quote_count: typing.Optional[int]=None, viewer: typing.Optional[chitose.app.bsky.feed.defs.ViewerState]=None, labels: typing.Optional[list[chitose.com.atproto.label.defs.Label]]=None, threadgate: typing.Optional[chitose.app.bsky.feed.defs.ThreadgateView]=None) -> None: + def __init__(self, uri: str, cid: str, author: chitose.app.bsky.actor.defs.ProfileViewBasic, record: typing.Any, indexed_at: str, embed: typing.Optional[typing.Union[chitose.app.bsky.embed.images.View, chitose.app.bsky.embed.video.View, chitose.app.bsky.embed.external.View, chitose.app.bsky.embed.record.View, chitose.app.bsky.embed.record_with_media.View]]=None, reply_count: typing.Optional[int]=None, repost_count: typing.Optional[int]=None, like_count: typing.Optional[int]=None, quote_count: typing.Optional[int]=None, viewer: typing.Optional[chitose.app.bsky.feed.defs.ViewerState]=None, labels: typing.Optional[list[chitose.com.atproto.label.defs.Label]]=None, threadgate: typing.Optional[chitose.app.bsky.feed.defs.ThreadgateView]=None) -> None: self.uri = uri self.cid = cid self.author = author diff --git a/chitose/app/bsky/feed/post.py b/chitose/app/bsky/feed/post.py index f0b1787..e66d9b3 100644 --- a/chitose/app/bsky/feed/post.py +++ b/chitose/app/bsky/feed/post.py @@ -6,6 +6,7 @@ import chitose.app.bsky.embed.images import chitose.app.bsky.embed.record import chitose.app.bsky.embed.record_with_media +import chitose.app.bsky.embed.video import chitose.app.bsky.feed.post import chitose.app.bsky.richtext.facet import chitose.com.atproto.label.defs @@ -31,7 +32,7 @@ class Post(chitose.Record): :param tags: Additional hashtags, in addition to any included in post text and facets. """ - def __init__(self, text: str, created_at: str, entities: typing.Optional[list[chitose.app.bsky.feed.post.Entity]]=None, facets: typing.Optional[list[chitose.app.bsky.richtext.facet.Facet]]=None, reply: typing.Optional[chitose.app.bsky.feed.post.ReplyRef]=None, embed: typing.Optional[typing.Union[chitose.app.bsky.embed.images.Images, chitose.app.bsky.embed.external.External, chitose.app.bsky.embed.record.Record, chitose.app.bsky.embed.record_with_media.RecordWithMedia]]=None, langs: typing.Optional[list[str]]=None, labels: typing.Optional[chitose.com.atproto.label.defs.SelfLabels]=None, tags: typing.Optional[list[str]]=None) -> None: + def __init__(self, text: str, created_at: str, entities: typing.Optional[list[chitose.app.bsky.feed.post.Entity]]=None, facets: typing.Optional[list[chitose.app.bsky.richtext.facet.Facet]]=None, reply: typing.Optional[chitose.app.bsky.feed.post.ReplyRef]=None, embed: typing.Optional[typing.Union[chitose.app.bsky.embed.images.Images, chitose.app.bsky.embed.video.Video, chitose.app.bsky.embed.external.External, chitose.app.bsky.embed.record.Record, chitose.app.bsky.embed.record_with_media.RecordWithMedia]]=None, langs: typing.Optional[list[str]]=None, labels: typing.Optional[chitose.com.atproto.label.defs.SelfLabels]=None, tags: typing.Optional[list[str]]=None) -> None: self.text = text self.created_at = created_at self.entities = entities diff --git a/chitose/com/atproto/repo/__init__.py b/chitose/com/atproto/repo/__init__.py index 56ea03e..7e5318f 100644 --- a/chitose/com/atproto/repo/__init__.py +++ b/chitose/com/atproto/repo/__init__.py @@ -38,7 +38,7 @@ def create_record(self, repo: str, collection: str, record: typing.Any, rkey: ty :param rkey: The Record Key. - :param validate: Can be set to 'false' to skip Lexicon schema validation of record data. + :param validate: Can be set to 'false' to skip Lexicon schema validation of record data, 'true' to require it, or leave unset to validate only for known Lexicons. :param swap_commit: Compare and swap with the previous commit by CID. """ @@ -72,7 +72,7 @@ def put_record(self, repo: str, collection: str, rkey: str, record: typing.Any, :param record: The record to write. - :param validate: Can be set to 'false' to skip Lexicon schema validation of record data. + :param validate: Can be set to 'false' to skip Lexicon schema validation of record data, 'true' to require it, or leave unset to validate only for known Lexicons. :param swap_record: Compare and swap with the previous record by CID. WARNING: nullable and optional field; may cause problems with golang implementation @@ -116,7 +116,7 @@ def apply_writes(self, repo: str, writes: list[typing.Union[chitose.com.atproto. :param repo: The handle or DID of the repo (aka, current account). - :param validate: Can be set to 'false' to skip Lexicon schema validation of record data, for all operations. + :param validate: Can be set to 'false' to skip Lexicon schema validation of record data across all operations, 'true' to require it, or leave unset to validate only for known Lexicons. :param swap_commit: If provided, the entire operation will fail if the current repo commit CID does not match this value. Used to prevent conflicting repo mutations. """ diff --git a/chitose/com/atproto/repo/apply_writes.py b/chitose/com/atproto/repo/apply_writes.py index f2bb075..9722ef9 100644 --- a/chitose/com/atproto/repo/apply_writes.py +++ b/chitose/com/atproto/repo/apply_writes.py @@ -11,7 +11,7 @@ def _apply_writes(call: chitose.xrpc.XrpcCall, repo: str, writes: list[typing.Un :param repo: The handle or DID of the repo (aka, current account). - :param validate: Can be set to 'false' to skip Lexicon schema validation of record data, for all operations. + :param validate: Can be set to 'false' to skip Lexicon schema validation of record data across all operations, 'true' to require it, or leave unset to validate only for known Lexicons. :param swap_commit: If provided, the entire operation will fail if the current repo commit CID does not match this value. Used to prevent conflicting repo mutations. """ @@ -47,4 +47,32 @@ def __init__(self, collection: str, rkey: str) -> None: self.rkey = rkey def to_dict(self) -> dict[str, typing.Any]: - return {'collection': self.collection, 'rkey': self.rkey, '$type': 'com.atproto.repo.applyWrites#delete'} \ No newline at end of file + return {'collection': self.collection, 'rkey': self.rkey, '$type': 'com.atproto.repo.applyWrites#delete'} + +class CreateResult(chitose.Object): + """""" + + def __init__(self, uri: str, cid: str, validation_status: typing.Optional[typing.Literal['valid', 'unknown']]=None) -> None: + self.uri = uri + self.cid = cid + self.validation_status = validation_status + + def to_dict(self) -> dict[str, typing.Any]: + return {'uri': self.uri, 'cid': self.cid, 'validationStatus': self.validation_status, '$type': 'com.atproto.repo.applyWrites#createResult'} + +class UpdateResult(chitose.Object): + """""" + + def __init__(self, uri: str, cid: str, validation_status: typing.Optional[typing.Literal['valid', 'unknown']]=None) -> None: + self.uri = uri + self.cid = cid + self.validation_status = validation_status + + def to_dict(self) -> dict[str, typing.Any]: + return {'uri': self.uri, 'cid': self.cid, 'validationStatus': self.validation_status, '$type': 'com.atproto.repo.applyWrites#updateResult'} + +class DeleteResult(chitose.Object): + """""" + + def to_dict(self) -> dict[str, typing.Any]: + return {'$type': 'com.atproto.repo.applyWrites#deleteResult'} \ No newline at end of file diff --git a/chitose/com/atproto/repo/create_record.py b/chitose/com/atproto/repo/create_record.py index 8cf33b3..cd1fed0 100644 --- a/chitose/com/atproto/repo/create_record.py +++ b/chitose/com/atproto/repo/create_record.py @@ -16,7 +16,7 @@ def _create_record(call: chitose.xrpc.XrpcCall, repo: str, collection: str, reco :param rkey: The Record Key. - :param validate: Can be set to 'false' to skip Lexicon schema validation of record data. + :param validate: Can be set to 'false' to skip Lexicon schema validation of record data, 'true' to require it, or leave unset to validate only for known Lexicons. :param swap_commit: Compare and swap with the previous commit by CID. """ diff --git a/chitose/com/atproto/repo/put_record.py b/chitose/com/atproto/repo/put_record.py index 31cb7ef..2b60239 100644 --- a/chitose/com/atproto/repo/put_record.py +++ b/chitose/com/atproto/repo/put_record.py @@ -16,7 +16,7 @@ def _put_record(call: chitose.xrpc.XrpcCall, repo: str, collection: str, rkey: s :param record: The record to write. - :param validate: Can be set to 'false' to skip Lexicon schema validation of record data. + :param validate: Can be set to 'false' to skip Lexicon schema validation of record data, 'true' to require it, or leave unset to validate only for known Lexicons. :param swap_record: Compare and swap with the previous record by CID. WARNING: nullable and optional field; may cause problems with golang implementation diff --git a/docs/source/chitose.app.bsky.embed.rst b/docs/source/chitose.app.bsky.embed.rst index 620bc1a..c018de9 100644 --- a/docs/source/chitose.app.bsky.embed.rst +++ b/docs/source/chitose.app.bsky.embed.rst @@ -4,6 +4,14 @@ chitose.app.bsky.embed package Submodules ---------- +chitose.app.bsky.embed.defs module +---------------------------------- + +.. automodule:: chitose.app.bsky.embed.defs + :members: + :undoc-members: + :show-inheritance: + chitose.app.bsky.embed.external module -------------------------------------- @@ -36,6 +44,14 @@ chitose.app.bsky.embed.record\_with\_media module :undoc-members: :show-inheritance: +chitose.app.bsky.embed.video module +----------------------------------- + +.. automodule:: chitose.app.bsky.embed.video + :members: + :undoc-members: + :show-inheritance: + Module contents --------------- diff --git a/docs/source/chitose.app.bsky.rst b/docs/source/chitose.app.bsky.rst index 4f09e37..e8fc77d 100644 --- a/docs/source/chitose.app.bsky.rst +++ b/docs/source/chitose.app.bsky.rst @@ -15,6 +15,7 @@ Subpackages chitose.app.bsky.notification chitose.app.bsky.richtext chitose.app.bsky.unspecced + chitose.app.bsky.video Module contents --------------- diff --git a/docs/source/chitose.com.atproto.repo.rst b/docs/source/chitose.com.atproto.repo.rst index 1c2463f..6f9b588 100644 --- a/docs/source/chitose.com.atproto.repo.rst +++ b/docs/source/chitose.com.atproto.repo.rst @@ -20,6 +20,14 @@ chitose.com.atproto.repo.create\_record module :undoc-members: :show-inheritance: +chitose.com.atproto.repo.defs module +------------------------------------ + +.. automodule:: chitose.com.atproto.repo.defs + :members: + :undoc-members: + :show-inheritance: + chitose.com.atproto.repo.delete\_record module ----------------------------------------------