python_dto_mappers.utils ======================== .. py:module:: python_dto_mappers.utils .. autoapi-nested-parse:: Mapping utilities for partial updates and chaining. Functions --------- .. autoapisummary:: python_dto_mappers.utils.extract_changed_fields python_dto_mappers.utils.chain_map Module Contents --------------- .. py:function:: extract_changed_fields(original: pydantic.BaseModel, update_dto: pydantic.BaseModel, exclude: Optional[Set[str]] = None) -> Dict[str, Any] Extract only changed fields for partial updates (PATCH). Compares original object with update DTO and returns only fields that have changed. Useful for HTTP PATCH operations. Args: original: Original object update_dto: Update DTO with new values exclude: Fields to exclude from comparison Returns: Dictionary with only changed fields Example: >>> original = User(id=1, name="John", email="john@example.com") >>> update = UserUpdateDTO(name="Jane", email="john@example.com") >>> changed = extract_changed_fields(original, update) >>> # {'name': 'Jane'} .. py:function:: chain_map(source: Any, through: List[Type]) -> Any Chain multiple mappings in sequence. Applies multiple type transformations in order, useful for ORM → Domain → DTO conversions. Args: source: Source object to map through: List of target types to map through Returns: Final mapped object Example: >>> # ORM → Domain → DTO >>> dto = chain_map( ... orm_user, ... through=[DomainUser, UserDTO] ... )