diff --git a/docs/source/aliases_db.py b/docs/source/aliases_db.py index 0fc98429..00d98451 100644 --- a/docs/source/aliases_db.py +++ b/docs/source/aliases_db.py @@ -133,6 +133,7 @@ 'models.ComAtprotoModerationDefs': 'atproto_client.models.com.atproto.moderation.defs', 'models.ComAtprotoRepoApplyWrites': 'atproto_client.models.com.atproto.repo.apply_writes', 'models.ComAtprotoRepoCreateRecord': 'atproto_client.models.com.atproto.repo.create_record', + 'models.ComAtprotoRepoDefs': 'atproto_client.models.com.atproto.repo.defs', 'models.ComAtprotoRepoDeleteRecord': 'atproto_client.models.com.atproto.repo.delete_record', 'models.ComAtprotoRepoDescribeRepo': 'atproto_client.models.com.atproto.repo.describe_repo', 'models.ComAtprotoRepoGetRecord': 'atproto_client.models.com.atproto.repo.get_record', diff --git a/docs/source/atproto/atproto_client.models.com.atproto.repo.defs.rst b/docs/source/atproto/atproto_client.models.com.atproto.repo.defs.rst new file mode 100644 index 00000000..e27d88a7 --- /dev/null +++ b/docs/source/atproto/atproto_client.models.com.atproto.repo.defs.rst @@ -0,0 +1,7 @@ +com.atproto.repo.defs +============================================ + +.. automodule:: atproto_client.models.com.atproto.repo.defs + :members: + :undoc-members: + :show-inheritance: \ No newline at end of file diff --git a/docs/source/atproto/atproto_client.models.com.atproto.repo.rst b/docs/source/atproto/atproto_client.models.com.atproto.repo.rst index e05ae4a4..7fa6e3ae 100644 --- a/docs/source/atproto/atproto_client.models.com.atproto.repo.rst +++ b/docs/source/atproto/atproto_client.models.com.atproto.repo.rst @@ -14,6 +14,7 @@ Submodules atproto_client.models.com.atproto.repo.apply_writes atproto_client.models.com.atproto.repo.create_record + atproto_client.models.com.atproto.repo.defs atproto_client.models.com.atproto.repo.delete_record atproto_client.models.com.atproto.repo.describe_repo atproto_client.models.com.atproto.repo.get_record diff --git a/lexicons/com.atproto.repo.applyWrites.json b/lexicons/com.atproto.repo.applyWrites.json index 427fc84c..26dd96c5 100644 --- a/lexicons/com.atproto.repo.applyWrites.json +++ b/lexicons/com.atproto.repo.applyWrites.json @@ -18,8 +18,7 @@ }, "validate": { "type": "boolean", - "default": true, - "description": "Can be set to 'false' to skip Lexicon schema validation of record data, for all operations." + "description": "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." }, "writes": { "type": "array", @@ -37,6 +36,27 @@ } } }, + "output": { + "encoding": "application/json", + "schema": { + "type": "object", + "required": [], + "properties": { + "commit": { + "type": "ref", + "ref": "com.atproto.repo.defs#commitMeta" + }, + "results": { + "type": "array", + "items": { + "type": "union", + "refs": ["#createResult", "#updateResult", "#deleteResult"], + "closed": true + } + } + } + } + }, "errors": [ { "name": "InvalidSwap", @@ -72,6 +92,35 @@ "collection": { "type": "string", "format": "nsid" }, "rkey": { "type": "string" } } + }, + "createResult": { + "type": "object", + "required": ["uri", "cid"], + "properties": { + "uri": { "type": "string", "format": "at-uri" }, + "cid": { "type": "string", "format": "cid" }, + "validationStatus": { + "type": "string", + "knownValues": ["valid", "unknown"] + } + } + }, + "updateResult": { + "type": "object", + "required": ["uri", "cid"], + "properties": { + "uri": { "type": "string", "format": "at-uri" }, + "cid": { "type": "string", "format": "cid" }, + "validationStatus": { + "type": "string", + "knownValues": ["valid", "unknown"] + } + } + }, + "deleteResult": { + "type": "object", + "required": [], + "properties": {} } } } diff --git a/lexicons/com.atproto.repo.createRecord.json b/lexicons/com.atproto.repo.createRecord.json index 185f5250..72900857 100644 --- a/lexicons/com.atproto.repo.createRecord.json +++ b/lexicons/com.atproto.repo.createRecord.json @@ -28,8 +28,7 @@ }, "validate": { "type": "boolean", - "default": true, - "description": "Can be set to 'false' to skip Lexicon schema validation of record data." + "description": "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." }, "record": { "type": "unknown", @@ -50,7 +49,15 @@ "required": ["uri", "cid"], "properties": { "uri": { "type": "string", "format": "at-uri" }, - "cid": { "type": "string", "format": "cid" } + "cid": { "type": "string", "format": "cid" }, + "commit": { + "type": "ref", + "ref": "com.atproto.repo.defs#commitMeta" + }, + "validationStatus": { + "type": "string", + "knownValues": ["valid", "unknown"] + } } } }, diff --git a/lexicons/com.atproto.repo.defs.json b/lexicons/com.atproto.repo.defs.json new file mode 100644 index 00000000..0f5128fb --- /dev/null +++ b/lexicons/com.atproto.repo.defs.json @@ -0,0 +1,14 @@ +{ + "lexicon": 1, + "id": "com.atproto.repo.defs", + "defs": { + "commitMeta": { + "type": "object", + "required": ["cid", "rev"], + "properties": { + "cid": { "type": "string", "format": "cid" }, + "rev": { "type": "string" } + } + } + } +} diff --git a/lexicons/com.atproto.repo.deleteRecord.json b/lexicons/com.atproto.repo.deleteRecord.json index 65b9f8f9..fb9b90b7 100644 --- a/lexicons/com.atproto.repo.deleteRecord.json +++ b/lexicons/com.atproto.repo.deleteRecord.json @@ -38,6 +38,18 @@ } } }, + "output": { + "encoding": "application/json", + "schema": { + "type": "object", + "properties": { + "commit": { + "type": "ref", + "ref": "com.atproto.repo.defs#commitMeta" + } + } + } + }, "errors": [{ "name": "InvalidSwap" }] } } diff --git a/lexicons/com.atproto.repo.putRecord.json b/lexicons/com.atproto.repo.putRecord.json index 51f11c0f..9a841f6a 100644 --- a/lexicons/com.atproto.repo.putRecord.json +++ b/lexicons/com.atproto.repo.putRecord.json @@ -29,8 +29,7 @@ }, "validate": { "type": "boolean", - "default": true, - "description": "Can be set to 'false' to skip Lexicon schema validation of record data." + "description": "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." }, "record": { "type": "unknown", @@ -56,7 +55,15 @@ "required": ["uri", "cid"], "properties": { "uri": { "type": "string", "format": "at-uri" }, - "cid": { "type": "string", "format": "cid" } + "cid": { "type": "string", "format": "cid" }, + "commit": { + "type": "ref", + "ref": "com.atproto.repo.defs#commitMeta" + }, + "validationStatus": { + "type": "string", + "knownValues": ["valid", "unknown"] + } } } }, diff --git a/packages/atproto_client/models/__init__.py b/packages/atproto_client/models/__init__.py index 9e41484f..50e7b620 100644 --- a/packages/atproto_client/models/__init__.py +++ b/packages/atproto_client/models/__init__.py @@ -140,6 +140,7 @@ from atproto_client.models.com.atproto.moderation import defs as ComAtprotoModerationDefs from atproto_client.models.com.atproto.repo import apply_writes as ComAtprotoRepoApplyWrites from atproto_client.models.com.atproto.repo import create_record as ComAtprotoRepoCreateRecord +from atproto_client.models.com.atproto.repo import defs as ComAtprotoRepoDefs from atproto_client.models.com.atproto.repo import delete_record as ComAtprotoRepoDeleteRecord from atproto_client.models.com.atproto.repo import describe_repo as ComAtprotoRepoDescribeRepo from atproto_client.models.com.atproto.repo import get_record as ComAtprotoRepoGetRecord @@ -357,6 +358,7 @@ class _Ids: ComAtprotoModerationDefs: str = 'com.atproto.moderation.defs' ComAtprotoRepoApplyWrites: str = 'com.atproto.repo.applyWrites' ComAtprotoRepoCreateRecord: str = 'com.atproto.repo.createRecord' + ComAtprotoRepoDefs: str = 'com.atproto.repo.defs' ComAtprotoRepoDeleteRecord: str = 'com.atproto.repo.deleteRecord' ComAtprotoRepoDescribeRepo: str = 'com.atproto.repo.describeRepo' ComAtprotoRepoGetRecord: str = 'com.atproto.repo.getRecord' 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 6e323d9f..7101ade0 100644 --- a/packages/atproto_client/models/com/atproto/repo/apply_writes.py +++ b/packages/atproto_client/models/com/atproto/repo/apply_writes.py @@ -35,7 +35,7 @@ class Data(base.DataModelBase): ] = None #: If provided, the entire operation will fail if the current repo commit CID does not match this value. Used to prevent conflicting repo mutations. validate_: t.Optional[ bool - ] = None #: Can be set to 'false' to skip Lexicon schema validation of record data, for all operations. + ] = None #: 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. class DataDict(t.TypedDict): @@ -55,7 +55,25 @@ class DataDict(t.TypedDict): ] #: If provided, the entire operation will fail if the current repo commit CID does not match this value. Used to prevent conflicting repo mutations. validate: te.NotRequired[ t.Optional[bool] - ] #: Can be set to 'false' to skip Lexicon schema validation of record data, for all operations. + ] #: 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. + + +class Response(base.ResponseModelBase): + """Output data model for :obj:`com.atproto.repo.applyWrites`.""" + + commit: t.Optional['models.ComAtprotoRepoDefs.CommitMeta'] = None #: Commit. + results: t.Optional[ + t.List[ + te.Annotated[ + t.Union[ + 'models.ComAtprotoRepoApplyWrites.CreateResult', + 'models.ComAtprotoRepoApplyWrites.UpdateResult', + 'models.ComAtprotoRepoApplyWrites.DeleteResult', + ], + Field(discriminator='py_type'), + ] + ] + ] = None #: Results. class Create(base.ModelBase): @@ -91,3 +109,35 @@ class Delete(base.ModelBase): py_type: t.Literal['com.atproto.repo.applyWrites#delete'] = Field( default='com.atproto.repo.applyWrites#delete', alias='$type', frozen=True ) + + +class CreateResult(base.ModelBase): + """Definition model for :obj:`com.atproto.repo.applyWrites`.""" + + cid: str #: Cid. + uri: str #: Uri. + validation_status: t.Optional[str] = None #: Validation status. + + py_type: t.Literal['com.atproto.repo.applyWrites#createResult'] = Field( + default='com.atproto.repo.applyWrites#createResult', alias='$type', frozen=True + ) + + +class UpdateResult(base.ModelBase): + """Definition model for :obj:`com.atproto.repo.applyWrites`.""" + + cid: str #: Cid. + uri: str #: Uri. + validation_status: t.Optional[str] = None #: Validation status. + + py_type: t.Literal['com.atproto.repo.applyWrites#updateResult'] = Field( + default='com.atproto.repo.applyWrites#updateResult', alias='$type', frozen=True + ) + + +class DeleteResult(base.ModelBase): + """Definition model for :obj:`com.atproto.repo.applyWrites`.""" + + py_type: t.Literal['com.atproto.repo.applyWrites#deleteResult'] = Field( + default='com.atproto.repo.applyWrites#deleteResult', 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 827a2cc2..7f5df61e 100644 --- a/packages/atproto_client/models/com/atproto/repo/create_record.py +++ b/packages/atproto_client/models/com/atproto/repo/create_record.py @@ -11,6 +11,7 @@ from pydantic import Field if t.TYPE_CHECKING: + from atproto_client import models from atproto_client.models.unknown_type import UnknownInputType from atproto_client.models import base @@ -23,7 +24,9 @@ class Data(base.DataModelBase): repo: str #: The handle or DID of the repo (aka, current account). rkey: t.Optional[str] = Field(default=None, max_length=15) #: The Record Key. swap_commit: t.Optional[str] = None #: Compare and swap with the previous commit by CID. - validate_: t.Optional[bool] = None #: Can be set to 'false' to skip Lexicon schema validation of record data. + validate_: t.Optional[ + bool + ] = None #: 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. class DataDict(t.TypedDict): @@ -34,7 +37,7 @@ class DataDict(t.TypedDict): swap_commit: te.NotRequired[t.Optional[str]] #: Compare and swap with the previous commit by CID. validate: te.NotRequired[ t.Optional[bool] - ] #: Can be set to 'false' to skip Lexicon schema validation of record data. + ] #: 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. class Response(base.ResponseModelBase): @@ -42,3 +45,5 @@ 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. diff --git a/packages/atproto_client/models/com/atproto/repo/defs.py b/packages/atproto_client/models/com/atproto/repo/defs.py new file mode 100644 index 00000000..036dd36d --- /dev/null +++ b/packages/atproto_client/models/com/atproto/repo/defs.py @@ -0,0 +1,23 @@ +################################################################## +# THIS IS THE AUTO-GENERATED CODE. DON'T EDIT IT BY HANDS! +# Copyright (C) 2024 Ilya (Marshal) . +# This file is part of Python atproto SDK. Licenced under MIT. +################################################################## + + +import typing as t + +from pydantic import Field + +from atproto_client.models import base + + +class CommitMeta(base.ModelBase): + """Definition model for :obj:`com.atproto.repo.defs`.""" + + cid: str #: Cid. + rev: str #: Rev. + + py_type: t.Literal['com.atproto.repo.defs#commitMeta'] = Field( + default='com.atproto.repo.defs#commitMeta', alias='$type', frozen=True + ) diff --git a/packages/atproto_client/models/com/atproto/repo/delete_record.py b/packages/atproto_client/models/com/atproto/repo/delete_record.py index b042f54f..7528a272 100644 --- a/packages/atproto_client/models/com/atproto/repo/delete_record.py +++ b/packages/atproto_client/models/com/atproto/repo/delete_record.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 @@ -28,3 +30,9 @@ class DataDict(t.TypedDict): rkey: str #: The Record Key. swap_commit: te.NotRequired[t.Optional[str]] #: Compare and swap with the previous commit by CID. swap_record: te.NotRequired[t.Optional[str]] #: Compare and swap with the previous record by CID. + + +class Response(base.ResponseModelBase): + """Output data model for :obj:`com.atproto.repo.deleteRecord`.""" + + commit: t.Optional['models.ComAtprotoRepoDefs.CommitMeta'] = None #: Commit. 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 d47bd314..892fb99f 100644 --- a/packages/atproto_client/models/com/atproto/repo/put_record.py +++ b/packages/atproto_client/models/com/atproto/repo/put_record.py @@ -11,6 +11,7 @@ from pydantic import Field if t.TYPE_CHECKING: + from atproto_client import models from atproto_client.models.unknown_type import UnknownInputType from atproto_client.models import base @@ -26,7 +27,9 @@ class Data(base.DataModelBase): swap_record: t.Optional[ str ] = None #: Compare and swap with the previous record by CID. WARNING: nullable and optional field; may cause problems with golang implementation. - validate_: t.Optional[bool] = None #: Can be set to 'false' to skip Lexicon schema validation of record data. + validate_: t.Optional[ + bool + ] = None #: 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. class DataDict(t.TypedDict): @@ -40,7 +43,7 @@ class DataDict(t.TypedDict): ] #: Compare and swap with the previous record by CID. WARNING: nullable and optional field; may cause problems with golang implementation. validate: te.NotRequired[ t.Optional[bool] - ] #: Can be set to 'false' to skip Lexicon schema validation of record data. + ] #: 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. class Response(base.ResponseModelBase): @@ -48,3 +51,5 @@ 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. diff --git a/packages/atproto_client/namespaces/async_ns.py b/packages/atproto_client/namespaces/async_ns.py index 43317335..2b2edce2 100644 --- a/packages/atproto_client/namespaces/async_ns.py +++ b/packages/atproto_client/namespaces/async_ns.py @@ -4973,7 +4973,7 @@ async def apply_writes( self, data: t.Union[models.ComAtprotoRepoApplyWrites.Data, models.ComAtprotoRepoApplyWrites.DataDict], **kwargs: t.Any, - ) -> bool: + ) -> 'models.ComAtprotoRepoApplyWrites.Response': """Apply a batch transaction of repository creates, updates, and deletes. Requires auth, implemented by PDS. Args: @@ -4981,7 +4981,7 @@ async def apply_writes( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`bool`: Success status. + :obj:`models.ComAtprotoRepoApplyWrites.Response`: Output model. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -4990,9 +4990,13 @@ async def apply_writes( 'models.ComAtprotoRepoApplyWrites.Data', get_or_create(data, models.ComAtprotoRepoApplyWrites.Data) ) response = await self._client.invoke_procedure( - 'com.atproto.repo.applyWrites', data=data_model, input_encoding='application/json', **kwargs + 'com.atproto.repo.applyWrites', + data=data_model, + input_encoding='application/json', + output_encoding='application/json', + **kwargs, ) - return get_response_model(response, bool) + return get_response_model(response, models.ComAtprotoRepoApplyWrites.Response) async def create_record( self, @@ -5027,7 +5031,7 @@ async def delete_record( self, data: t.Union[models.ComAtprotoRepoDeleteRecord.Data, models.ComAtprotoRepoDeleteRecord.DataDict], **kwargs: t.Any, - ) -> bool: + ) -> 'models.ComAtprotoRepoDeleteRecord.Response': """Delete a repository record, or ensure it doesn't exist. Requires auth, implemented by PDS. Args: @@ -5035,7 +5039,7 @@ async def delete_record( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`bool`: Success status. + :obj:`models.ComAtprotoRepoDeleteRecord.Response`: Output model. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -5044,9 +5048,13 @@ async def delete_record( 'models.ComAtprotoRepoDeleteRecord.Data', get_or_create(data, models.ComAtprotoRepoDeleteRecord.Data) ) response = await self._client.invoke_procedure( - 'com.atproto.repo.deleteRecord', data=data_model, input_encoding='application/json', **kwargs + 'com.atproto.repo.deleteRecord', + data=data_model, + input_encoding='application/json', + output_encoding='application/json', + **kwargs, ) - return get_response_model(response, bool) + return get_response_model(response, models.ComAtprotoRepoDeleteRecord.Response) async def describe_repo( self, diff --git a/packages/atproto_client/namespaces/sync_ns.py b/packages/atproto_client/namespaces/sync_ns.py index 46268d11..ef75eeaf 100644 --- a/packages/atproto_client/namespaces/sync_ns.py +++ b/packages/atproto_client/namespaces/sync_ns.py @@ -4973,7 +4973,7 @@ def apply_writes( self, data: t.Union[models.ComAtprotoRepoApplyWrites.Data, models.ComAtprotoRepoApplyWrites.DataDict], **kwargs: t.Any, - ) -> bool: + ) -> 'models.ComAtprotoRepoApplyWrites.Response': """Apply a batch transaction of repository creates, updates, and deletes. Requires auth, implemented by PDS. Args: @@ -4981,7 +4981,7 @@ def apply_writes( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`bool`: Success status. + :obj:`models.ComAtprotoRepoApplyWrites.Response`: Output model. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -4990,9 +4990,13 @@ def apply_writes( 'models.ComAtprotoRepoApplyWrites.Data', get_or_create(data, models.ComAtprotoRepoApplyWrites.Data) ) response = self._client.invoke_procedure( - 'com.atproto.repo.applyWrites', data=data_model, input_encoding='application/json', **kwargs + 'com.atproto.repo.applyWrites', + data=data_model, + input_encoding='application/json', + output_encoding='application/json', + **kwargs, ) - return get_response_model(response, bool) + return get_response_model(response, models.ComAtprotoRepoApplyWrites.Response) def create_record( self, @@ -5027,7 +5031,7 @@ def delete_record( self, data: t.Union[models.ComAtprotoRepoDeleteRecord.Data, models.ComAtprotoRepoDeleteRecord.DataDict], **kwargs: t.Any, - ) -> bool: + ) -> 'models.ComAtprotoRepoDeleteRecord.Response': """Delete a repository record, or ensure it doesn't exist. Requires auth, implemented by PDS. Args: @@ -5035,7 +5039,7 @@ def delete_record( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`bool`: Success status. + :obj:`models.ComAtprotoRepoDeleteRecord.Response`: Output model. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -5044,9 +5048,13 @@ def delete_record( 'models.ComAtprotoRepoDeleteRecord.Data', get_or_create(data, models.ComAtprotoRepoDeleteRecord.Data) ) response = self._client.invoke_procedure( - 'com.atproto.repo.deleteRecord', data=data_model, input_encoding='application/json', **kwargs + 'com.atproto.repo.deleteRecord', + data=data_model, + input_encoding='application/json', + output_encoding='application/json', + **kwargs, ) - return get_response_model(response, bool) + return get_response_model(response, models.ComAtprotoRepoDeleteRecord.Response) def describe_repo( self,