Skip to content

Commit

Permalink
Update atproto
Browse files Browse the repository at this point in the history
  • Loading branch information
mnogu committed Sep 1, 2024
1 parent f9bee1b commit 3a6b8eb
Show file tree
Hide file tree
Showing 14 changed files with 79 additions and 26 deletions.
2 changes: 1 addition & 1 deletion atproto
Submodule atproto updated 248 files
7 changes: 6 additions & 1 deletion chitose/app/bsky/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <chitose>` class instead of creating instances of this class directly."""
Expand Down Expand Up @@ -48,4 +49,8 @@ def richtext(self) -> Richtext_:

@property
def unspecced(self) -> Unspecced_:
return Unspecced_(self.call, self.subscribe)
return Unspecced_(self.call, self.subscribe)

@property
def video(self) -> Video_:
return Video_(self.call, self.subscribe)
15 changes: 3 additions & 12 deletions chitose/app/bsky/embed/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -21,24 +22,14 @@ 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

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):
""""""

Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion chitose/app/bsky/embed/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions chitose/app/bsky/embed/record_with_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
3 changes: 2 additions & 1 deletion chitose/app/bsky/feed/defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion chitose/app/bsky/feed/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions chitose/com/atproto/repo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
"""
Expand Down
32 changes: 30 additions & 2 deletions chitose/com/atproto/repo/apply_writes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
Expand Down Expand Up @@ -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'}
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'}
2 changes: 1 addition & 1 deletion chitose/com/atproto/repo/create_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
Expand Down
2 changes: 1 addition & 1 deletion chitose/com/atproto/repo/put_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions docs/source/chitose.app.bsky.embed.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
--------------------------------------

Expand Down Expand Up @@ -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
---------------

Expand Down
1 change: 1 addition & 0 deletions docs/source/chitose.app.bsky.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Subpackages
chitose.app.bsky.notification
chitose.app.bsky.richtext
chitose.app.bsky.unspecced
chitose.app.bsky.video

Module contents
---------------
Expand Down
8 changes: 8 additions & 0 deletions docs/source/chitose.com.atproto.repo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
----------------------------------------------

Expand Down

0 comments on commit 3a6b8eb

Please sign in to comment.