# Generated by ariadne-codegen
# Source: ../../src/graphql/operations

from typing import Any, Optional, Union

from .all_users import AllUsers
from .async_base_client import AsyncBaseClient
from .base_model import UNSET, UnsetType
from .business import Business
from .businesses import Businesses
from .case_studies import CaseStudies
from .case_study import CaseStudy
from .compound import Compound
from .compounds import Compounds
from .create_business_with_relations import CreateBusinessWithRelations
from .create_case_study import CreateCaseStudy
from .create_compound import CreateCompound
from .create_episode import CreateEpisode
from .create_person import CreatePerson
from .create_product import CreateProduct
from .create_protocol import CreateProtocol
from .create_user_protocol import CreateUserProtocol
from .delete_all_episodes import DeleteAllEpisodes
from .delete_business import DeleteBusiness
from .delete_compound import DeleteCompound
from .delete_episode import DeleteEpisode
from .delete_person import DeletePerson
from .delete_product import DeleteProduct
from .delete_protocol import DeleteProtocol
from .delete_user import DeleteUser
from .delete_user_profile import DeleteUserProfile
from .delete_user_protocol import DeleteUserProtocol
from .embed_business_description import EmbedBusinessDescription
from .embed_person_bio import EmbedPersonBio
from .embed_product_description import EmbedProductDescription
from .episode import Episode
from .episodes import Episodes
from .input_types import (
    BusinessCreateRelationsInput,
    BusinessUpdateRelationFieldsInput,
    BusinessUpdateWithIdsInput,
    CaseStudyCreateWithOptionalIdsInput,
    CaseStudyUpdateWithOptionalIdsInput,
    CompoundCreateWithIdsInput,
    CompoundUpdateRelationFieldsInput,
    CompoundUpdateWithIdsInput,
    CreateUserProtocolInput,
    CursorPageInput,
    EpisodeCreateWithIdsInput,
    EpisodeUpdateRelationFieldsInput,
    EpisodeUpdateWithIdsInput,
    PersonCreateInput,
    PersonUpdateInput,
    ProductCreateWithIdsInput,
    ProductUpdateRelationFieldsInput,
    ProductUpdateWithIdsInput,
    ProtocolCreateWithIdsInput,
    ProtocolUpdateRelationFieldsInput,
    ProtocolUpdateWithIdsInput,
    SavedEntitiesFilterInput,
    SaveEntityInput,
    UnsaveEntityInput,
    UpdateUserProtocolInput,
    UserProfileUpsertInput,
    UserProtocolsFilterInput,
    UserUpsertInput,
    VectorSearchArgs,
)
from .login import Login
from .me import Me
from .my_profile import MyProfile
from .my_user_protocols import MyUserProtocols
from .people import People
from .person import Person
from .product import Product
from .products import Products
from .protocol import Protocol
from .protocols import Protocols
from .register import Register
from .save_entity import SaveEntity
from .saved_entities import SavedEntities
from .unsave_entity import UnsaveEntity
from .update_business import UpdateBusiness
from .update_business_relations import UpdateBusinessRelations
from .update_case_study import UpdateCaseStudy
from .update_compound import UpdateCompound
from .update_compound_relations import UpdateCompoundRelations
from .update_episode import UpdateEpisode
from .update_episode_relations import UpdateEpisodeRelations
from .update_person import UpdatePerson
from .update_product import UpdateProduct
from .update_product_relations import UpdateProductRelations
from .update_protocol import UpdateProtocol
from .update_protocol_relations import UpdateProtocolRelations
from .update_user_protocol import UpdateUserProtocol
from .upsert_user import UpsertUser
from .upsert_user_profile import UpsertUserProfile
from .vector_search_businesses import VectorSearchBusinesses
from .vector_search_people import VectorSearchPeople
from .vector_search_products import VectorSearchProducts


def gql(q: str) -> str:
    return q


class Client(AsyncBaseClient):
    async def register(
        self,
        email: str,
        password: str,
        name: Union[Optional[str], UnsetType] = UNSET,
        **kwargs: Any
    ) -> Register:
        query = gql(
            """
            mutation Register($email: String!, $password: String!, $name: String) {
              register(email: $email, password: $password, name: $name) {
                token
                user {
                  id
                  email
                  name
                  role
                }
              }
            }
            """
        )
        variables: dict[str, object] = {
            "email": email,
            "password": password,
            "name": name,
        }
        response = await self.execute(
            query=query, operation_name="Register", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return Register.model_validate(data)

    async def login(self, email: str, password: str, **kwargs: Any) -> Login:
        query = gql(
            """
            mutation Login($email: String!, $password: String!) {
              login(email: $email, password: $password) {
                token
                user {
                  id
                  email
                  name
                  role
                }
              }
            }
            """
        )
        variables: dict[str, object] = {"email": email, "password": password}
        response = await self.execute(
            query=query, operation_name="Login", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return Login.model_validate(data)

    async def upsert_user_profile(
        self, input: UserProfileUpsertInput, **kwargs: Any
    ) -> UpsertUserProfile:
        query = gql(
            """
            mutation UpsertUserProfile($input: UserProfileUpsertInput!) {
              upsertUserProfile(input: $input) {
                id
                userId
                goals {
                  goalType
                  priority
                  notes
                }
                experienceLevel
                dietStyle
                avoidances
                timeBudget
                preferredFormats
                topicInterests
                entityPreferences {
                  likedEntityIds
                  hiddenEntityIds
                  blockedEntityIds
                }
                createdAt
                updatedAt
              }
            }
            """
        )
        variables: dict[str, object] = {"input": input}
        response = await self.execute(
            query=query,
            operation_name="UpsertUserProfile",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return UpsertUserProfile.model_validate(data)

    async def delete_user_profile(
        self, user_id: str, **kwargs: Any
    ) -> DeleteUserProfile:
        query = gql(
            """
            mutation DeleteUserProfile($userId: ID!) {
              deleteUserProfile(userId: $userId) {
                deletedCount
              }
            }
            """
        )
        variables: dict[str, object] = {"userId": user_id}
        response = await self.execute(
            query=query,
            operation_name="DeleteUserProfile",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return DeleteUserProfile.model_validate(data)

    async def delete_user(self, user_id: str, **kwargs: Any) -> DeleteUser:
        query = gql(
            """
            mutation DeleteUser($userId: ID!) {
              deleteUser(userId: $userId) {
                message
                success
              }
            }
            """
        )
        variables: dict[str, object] = {"userId": user_id}
        response = await self.execute(
            query=query, operation_name="DeleteUser", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return DeleteUser.model_validate(data)

    async def upsert_user(self, input: UserUpsertInput, **kwargs: Any) -> UpsertUser:
        query = gql(
            """
            mutation UpsertUser($input: UserUpsertInput!) {
              upsertUser(input: $input) {
                id
                email
                name
                role
              }
            }
            """
        )
        variables: dict[str, object] = {"input": input}
        response = await self.execute(
            query=query, operation_name="UpsertUser", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return UpsertUser.model_validate(data)

    async def create_business_with_relations(
        self, input: BusinessCreateRelationsInput, **kwargs: Any
    ) -> CreateBusinessWithRelations:
        query = gql(
            """
            mutation CreateBusinessWithRelations($input: BusinessCreateRelationsInput!) {
              createBusinessWithRelations(input: $input) {
                id
                name
                description
                website
              }
            }
            """
        )
        variables: dict[str, object] = {"input": input}
        response = await self.execute(
            query=query,
            operation_name="CreateBusinessWithRelations",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return CreateBusinessWithRelations.model_validate(data)

    async def update_business(
        self, input: BusinessUpdateWithIdsInput, **kwargs: Any
    ) -> UpdateBusiness:
        query = gql(
            """
            mutation UpdateBusiness($input: BusinessUpdateWithIdsInput!) {
              updateBusiness(input: $input) {
                id
                name
                description
                website
              }
            }
            """
        )
        variables: dict[str, object] = {"input": input}
        response = await self.execute(
            query=query, operation_name="UpdateBusiness", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return UpdateBusiness.model_validate(data)

    async def update_business_relations(
        self, input: BusinessUpdateRelationFieldsInput, **kwargs: Any
    ) -> UpdateBusinessRelations:
        query = gql(
            """
            mutation UpdateBusinessRelations($input: BusinessUpdateRelationFieldsInput!) {
              updateBusinessRelations(input: $input) {
                id
                name
                description
                website
              }
            }
            """
        )
        variables: dict[str, object] = {"input": input}
        response = await self.execute(
            query=query,
            operation_name="UpdateBusinessRelations",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return UpdateBusinessRelations.model_validate(data)

    async def delete_business(self, id: str, **kwargs: Any) -> DeleteBusiness:
        query = gql(
            """
            mutation DeleteBusiness($id: ID!) {
              deleteBusiness(id: $id) {
                deletedCount
              }
            }
            """
        )
        variables: dict[str, object] = {"id": id}
        response = await self.execute(
            query=query, operation_name="DeleteBusiness", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return DeleteBusiness.model_validate(data)

    async def create_product(
        self, input: ProductCreateWithIdsInput, **kwargs: Any
    ) -> CreateProduct:
        query = gql(
            """
            mutation CreateProduct($input: ProductCreateWithIdsInput!) {
              createProduct(input: $input) {
                id
                name
                description
                ingredients
              }
            }
            """
        )
        variables: dict[str, object] = {"input": input}
        response = await self.execute(
            query=query, operation_name="CreateProduct", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return CreateProduct.model_validate(data)

    async def update_product(
        self, input: ProductUpdateWithIdsInput, **kwargs: Any
    ) -> UpdateProduct:
        query = gql(
            """
            mutation UpdateProduct($input: ProductUpdateWithIdsInput!) {
              updateProduct(input: $input) {
                id
                name
                description
                ingredients
              }
            }
            """
        )
        variables: dict[str, object] = {"input": input}
        response = await self.execute(
            query=query, operation_name="UpdateProduct", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return UpdateProduct.model_validate(data)

    async def update_product_relations(
        self, input: ProductUpdateRelationFieldsInput, **kwargs: Any
    ) -> UpdateProductRelations:
        query = gql(
            """
            mutation UpdateProductRelations($input: ProductUpdateRelationFieldsInput!) {
              updateProductRelations(input: $input) {
                id
                name
                description
              }
            }
            """
        )
        variables: dict[str, object] = {"input": input}
        response = await self.execute(
            query=query,
            operation_name="UpdateProductRelations",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return UpdateProductRelations.model_validate(data)

    async def delete_product(self, id: str, **kwargs: Any) -> DeleteProduct:
        query = gql(
            """
            mutation DeleteProduct($id: ID!) {
              deleteProduct(id: $id) {
                id
                name
              }
            }
            """
        )
        variables: dict[str, object] = {"id": id}
        response = await self.execute(
            query=query, operation_name="DeleteProduct", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return DeleteProduct.model_validate(data)

    async def embed_product_description(
        self, product_id: str, **kwargs: Any
    ) -> EmbedProductDescription:
        query = gql(
            """
            mutation EmbedProductDescription($productId: ID!) {
              embedProductDescription(productId: $productId) {
                id
                name
                description
              }
            }
            """
        )
        variables: dict[str, object] = {"productId": product_id}
        response = await self.execute(
            query=query,
            operation_name="EmbedProductDescription",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return EmbedProductDescription.model_validate(data)

    async def create_person(
        self, input: PersonCreateInput, **kwargs: Any
    ) -> CreatePerson:
        query = gql(
            """
            mutation CreatePerson($input: PersonCreateInput!) {
              createPerson(input: $input) {
                id
                name
                role
                bio
              }
            }
            """
        )
        variables: dict[str, object] = {"input": input}
        response = await self.execute(
            query=query, operation_name="CreatePerson", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return CreatePerson.model_validate(data)

    async def update_person(
        self, input: PersonUpdateInput, **kwargs: Any
    ) -> UpdatePerson:
        query = gql(
            """
            mutation UpdatePerson($input: PersonUpdateInput!) {
              updatePerson(input: $input) {
                id
                name
                role
                bio
              }
            }
            """
        )
        variables: dict[str, object] = {"input": input}
        response = await self.execute(
            query=query, operation_name="UpdatePerson", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return UpdatePerson.model_validate(data)

    async def delete_person(self, id: str, **kwargs: Any) -> DeletePerson:
        query = gql(
            """
            mutation DeletePerson($id: ID!) {
              deletePerson(id: $id) {
                id
                name
              }
            }
            """
        )
        variables: dict[str, object] = {"id": id}
        response = await self.execute(
            query=query, operation_name="DeletePerson", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return DeletePerson.model_validate(data)

    async def embed_person_bio(self, person_id: str, **kwargs: Any) -> EmbedPersonBio:
        query = gql(
            """
            mutation EmbedPersonBio($personId: ID!) {
              embedPersonBio(personId: $personId) {
                id
                name
                bio
              }
            }
            """
        )
        variables: dict[str, object] = {"personId": person_id}
        response = await self.execute(
            query=query, operation_name="EmbedPersonBio", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return EmbedPersonBio.model_validate(data)

    async def create_episode(
        self, input: EpisodeCreateWithIdsInput, **kwargs: Any
    ) -> CreateEpisode:
        query = gql(
            """
            mutation CreateEpisode($input: EpisodeCreateWithIdsInput!) {
              createEpisode(input: $input) {
                id
                episodeTitle
                channelName
                episodeNumber
              }
            }
            """
        )
        variables: dict[str, object] = {"input": input}
        response = await self.execute(
            query=query, operation_name="CreateEpisode", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return CreateEpisode.model_validate(data)

    async def update_episode(
        self, input: EpisodeUpdateWithIdsInput, **kwargs: Any
    ) -> UpdateEpisode:
        query = gql(
            """
            mutation UpdateEpisode($input: EpisodeUpdateWithIdsInput!) {
              updateEpisode(input: $input) {
                id
                episodeTitle
                channelName
                episodeNumber
              }
            }
            """
        )
        variables: dict[str, object] = {"input": input}
        response = await self.execute(
            query=query, operation_name="UpdateEpisode", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return UpdateEpisode.model_validate(data)

    async def update_episode_relations(
        self, input: EpisodeUpdateRelationFieldsInput, **kwargs: Any
    ) -> UpdateEpisodeRelations:
        query = gql(
            """
            mutation UpdateEpisodeRelations($input: EpisodeUpdateRelationFieldsInput!) {
              updateEpisodeRelations(input: $input) {
                id
                episodeTitle
                channelName
              }
            }
            """
        )
        variables: dict[str, object] = {"input": input}
        response = await self.execute(
            query=query,
            operation_name="UpdateEpisodeRelations",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return UpdateEpisodeRelations.model_validate(data)

    async def delete_episode(self, identifier: str, **kwargs: Any) -> DeleteEpisode:
        query = gql(
            """
            mutation DeleteEpisode($identifier: String!) {
              deleteEpisode(identifier: $identifier) {
                id
                episodeTitle
              }
            }
            """
        )
        variables: dict[str, object] = {"identifier": identifier}
        response = await self.execute(
            query=query, operation_name="DeleteEpisode", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return DeleteEpisode.model_validate(data)

    async def delete_all_episodes(self, **kwargs: Any) -> DeleteAllEpisodes:
        query = gql(
            """
            mutation DeleteAllEpisodes {
              deleteAllEpisodes {
                deletedCount
              }
            }
            """
        )
        variables: dict[str, object] = {}
        response = await self.execute(
            query=query,
            operation_name="DeleteAllEpisodes",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return DeleteAllEpisodes.model_validate(data)

    async def create_compound(
        self, input: CompoundCreateWithIdsInput, **kwargs: Any
    ) -> CreateCompound:
        query = gql(
            """
            mutation CreateCompound($input: CompoundCreateWithIdsInput!) {
              createCompound(input: $input) {
                id
                name
                description
                aliases
              }
            }
            """
        )
        variables: dict[str, object] = {"input": input}
        response = await self.execute(
            query=query, operation_name="CreateCompound", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return CreateCompound.model_validate(data)

    async def update_compound(
        self, input: CompoundUpdateWithIdsInput, **kwargs: Any
    ) -> UpdateCompound:
        query = gql(
            """
            mutation UpdateCompound($input: CompoundUpdateWithIdsInput!) {
              updateCompound(input: $input) {
                id
                name
                description
                aliases
              }
            }
            """
        )
        variables: dict[str, object] = {"input": input}
        response = await self.execute(
            query=query, operation_name="UpdateCompound", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return UpdateCompound.model_validate(data)

    async def update_compound_relations(
        self, input: CompoundUpdateRelationFieldsInput, **kwargs: Any
    ) -> UpdateCompoundRelations:
        query = gql(
            """
            mutation UpdateCompoundRelations($input: CompoundUpdateRelationFieldsInput!) {
              updateCompoundRelations(input: $input) {
                id
                name
                description
              }
            }
            """
        )
        variables: dict[str, object] = {"input": input}
        response = await self.execute(
            query=query,
            operation_name="UpdateCompoundRelations",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return UpdateCompoundRelations.model_validate(data)

    async def delete_compound(self, id: str, **kwargs: Any) -> DeleteCompound:
        query = gql(
            """
            mutation DeleteCompound($id: ID!) {
              deleteCompound(id: $id) {
                id
                name
              }
            }
            """
        )
        variables: dict[str, object] = {"id": id}
        response = await self.execute(
            query=query, operation_name="DeleteCompound", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return DeleteCompound.model_validate(data)

    async def create_protocol(
        self, input: ProtocolCreateWithIdsInput, **kwargs: Any
    ) -> CreateProtocol:
        query = gql(
            """
            mutation CreateProtocol($input: ProtocolCreateWithIdsInput!) {
              createProtocol(input: $input) {
                id
                name
                description
                categories
                goals
              }
            }
            """
        )
        variables: dict[str, object] = {"input": input}
        response = await self.execute(
            query=query, operation_name="CreateProtocol", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return CreateProtocol.model_validate(data)

    async def update_protocol(
        self, input: ProtocolUpdateWithIdsInput, **kwargs: Any
    ) -> UpdateProtocol:
        query = gql(
            """
            mutation UpdateProtocol($input: ProtocolUpdateWithIdsInput!) {
              updateProtocol(input: $input) {
                id
                name
                description
                categories
                goals
                steps
                cautions
                aliases
                sourceUrl
                stepsStructured {
                  label
                  timeOfDay
                  items {
                    type
                    refId
                    nameOverride
                    dosage
                    timing
                    notes
                    itemEntity {
                      __typename
                      ... on Product {
                        id
                        name
                        description
                      }
                      ... on Compound {
                        id
                        name
                        description
                      }
                    }
                  }
                }
                evidenceRefs {
                  type
                  refId
                  label
                  url
                  episodeId
                  timestamps
                  notes
                  evidenceRefEntity {
                    __typename
                    ... on Article {
                      id
                      title
                      articleSummary: summary
                    }
                    ... on CaseStudy {
                      id
                      title
                      summary
                    }
                    ... on Episode {
                      id
                      episodeTitle
                      channelName
                    }
                    ... on External {
                      url
                      label
                    }
                  }
                }
                safety {
                  warnings
                  contraindications
                  interactions
                  notes
                }
                products {
                  id
                  name
                }
                compounds {
                  id
                  name
                }
              }
            }
            """
        )
        variables: dict[str, object] = {"input": input}
        response = await self.execute(
            query=query, operation_name="UpdateProtocol", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return UpdateProtocol.model_validate(data)

    async def update_protocol_relations(
        self, input: ProtocolUpdateRelationFieldsInput, **kwargs: Any
    ) -> UpdateProtocolRelations:
        query = gql(
            """
            mutation UpdateProtocolRelations($input: ProtocolUpdateRelationFieldsInput!) {
              updateProtocolRelations(input: $input) {
                id
                name
                products {
                  id
                  name
                }
                compounds {
                  id
                  name
                }
              }
            }
            """
        )
        variables: dict[str, object] = {"input": input}
        response = await self.execute(
            query=query,
            operation_name="UpdateProtocolRelations",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return UpdateProtocolRelations.model_validate(data)

    async def delete_protocol(self, id: str, **kwargs: Any) -> DeleteProtocol:
        query = gql(
            """
            mutation DeleteProtocol($id: ID!) {
              deleteProtocol(id: $id) {
                id
                name
              }
            }
            """
        )
        variables: dict[str, object] = {"id": id}
        response = await self.execute(
            query=query, operation_name="DeleteProtocol", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return DeleteProtocol.model_validate(data)

    async def create_user_protocol(
        self, input: CreateUserProtocolInput, **kwargs: Any
    ) -> CreateUserProtocol:
        query = gql(
            """
            mutation CreateUserProtocol($input: CreateUserProtocolInput!) {
              createUserProtocol(input: $input) {
                id
                userId
                title
                goalType
                status
                sourceProtocolId
                stepsStructured {
                  label
                  timeOfDay
                  items {
                    type
                    refId
                    nameOverride
                    dosage
                    timing
                    notes
                    itemEntity {
                      __typename
                      ... on Product {
                        id
                        name
                        description
                      }
                      ... on Compound {
                        id
                        name
                        description
                      }
                    }
                  }
                }
                evidenceRefs {
                  type
                  refId
                  label
                  url
                  episodeId
                  timestamps
                  notes
                  evidenceRefEntity {
                    __typename
                    ... on Article {
                      id
                      title
                      articleSummary: summary
                    }
                    ... on CaseStudy {
                      id
                      title
                      summary
                    }
                    ... on Episode {
                      id
                      episodeTitle
                      channelName
                    }
                    ... on External {
                      url
                      label
                    }
                  }
                }
                safety {
                  warnings
                  contraindications
                  interactions
                  notes
                }
                lastEditedAt
                createdAt
                updatedAt
              }
            }
            """
        )
        variables: dict[str, object] = {"input": input}
        response = await self.execute(
            query=query,
            operation_name="CreateUserProtocol",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return CreateUserProtocol.model_validate(data)

    async def update_user_protocol(
        self, input: UpdateUserProtocolInput, **kwargs: Any
    ) -> UpdateUserProtocol:
        query = gql(
            """
            mutation UpdateUserProtocol($input: UpdateUserProtocolInput!) {
              updateUserProtocol(input: $input) {
                id
                userId
                title
                goalType
                status
                sourceProtocolId
                stepsStructured {
                  label
                  timeOfDay
                  items {
                    type
                    refId
                    nameOverride
                    dosage
                    timing
                    notes
                    itemEntity {
                      __typename
                      ... on Product {
                        id
                        name
                        description
                      }
                      ... on Compound {
                        id
                        name
                        description
                      }
                    }
                  }
                }
                evidenceRefs {
                  type
                  refId
                  label
                  url
                  episodeId
                  timestamps
                  notes
                  evidenceRefEntity {
                    __typename
                    ... on Article {
                      id
                      title
                      articleSummary: summary
                    }
                    ... on CaseStudy {
                      id
                      title
                      summary
                    }
                    ... on Episode {
                      id
                      episodeTitle
                      channelName
                    }
                    ... on External {
                      url
                      label
                    }
                  }
                }
                safety {
                  warnings
                  contraindications
                  interactions
                  notes
                }
                lastEditedAt
                createdAt
                updatedAt
              }
            }
            """
        )
        variables: dict[str, object] = {"input": input}
        response = await self.execute(
            query=query,
            operation_name="UpdateUserProtocol",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return UpdateUserProtocol.model_validate(data)

    async def delete_user_protocol(self, id: str, **kwargs: Any) -> DeleteUserProtocol:
        query = gql(
            """
            mutation DeleteUserProtocol($id: ID!) {
              deleteUserProtocol(id: $id)
            }
            """
        )
        variables: dict[str, object] = {"id": id}
        response = await self.execute(
            query=query,
            operation_name="DeleteUserProtocol",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return DeleteUserProtocol.model_validate(data)

    async def create_case_study(
        self, input: CaseStudyCreateWithOptionalIdsInput, **kwargs: Any
    ) -> CreateCaseStudy:
        query = gql(
            """
            mutation CreateCaseStudy($input: CaseStudyCreateWithOptionalIdsInput!) {
              createCaseStudy(input: $input) {
                id
                title
                summary
                url
                sourceType
              }
            }
            """
        )
        variables: dict[str, object] = {"input": input}
        response = await self.execute(
            query=query, operation_name="CreateCaseStudy", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return CreateCaseStudy.model_validate(data)

    async def update_case_study(
        self, input: CaseStudyUpdateWithOptionalIdsInput, **kwargs: Any
    ) -> UpdateCaseStudy:
        query = gql(
            """
            mutation UpdateCaseStudy($input: CaseStudyUpdateWithOptionalIdsInput!) {
              updateCaseStudy(input: $input) {
                id
                title
                summary
                url
                sourceType
              }
            }
            """
        )
        variables: dict[str, object] = {"input": input}
        response = await self.execute(
            query=query, operation_name="UpdateCaseStudy", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return UpdateCaseStudy.model_validate(data)

    async def embed_business_description(
        self, business_id: str, **kwargs: Any
    ) -> EmbedBusinessDescription:
        query = gql(
            """
            mutation EmbedBusinessDescription($businessId: ID!) {
              embedBusinessDescription(businessId: $businessId) {
                id
                name
                description
              }
            }
            """
        )
        variables: dict[str, object] = {"businessId": business_id}
        response = await self.execute(
            query=query,
            operation_name="EmbedBusinessDescription",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return EmbedBusinessDescription.model_validate(data)

    async def save_entity(self, input: SaveEntityInput, **kwargs: Any) -> SaveEntity:
        query = gql(
            """
            mutation SaveEntity($input: SaveEntityInput!) {
              saveEntity(input: $input) {
                id
                userId
                targetType
                targetId
                note
                tags
                pinned
                source
                createdAt
                updatedAt
              }
            }
            """
        )
        variables: dict[str, object] = {"input": input}
        response = await self.execute(
            query=query, operation_name="SaveEntity", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return SaveEntity.model_validate(data)

    async def unsave_entity(
        self, input: UnsaveEntityInput, **kwargs: Any
    ) -> UnsaveEntity:
        query = gql(
            """
            mutation UnsaveEntity($input: UnsaveEntityInput!) {
              unsaveEntity(input: $input)
            }
            """
        )
        variables: dict[str, object] = {"input": input}
        response = await self.execute(
            query=query, operation_name="UnsaveEntity", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return UnsaveEntity.model_validate(data)

    async def me(self, **kwargs: Any) -> Me:
        query = gql(
            """
            query Me {
              me {
                id
                email
                name
                role
                profile {
                  id
                  userId
                  goals {
                    goalType
                    priority
                    notes
                  }
                  experienceLevel
                  dietStyle
                  avoidances
                  timeBudget
                  preferredFormats
                  topicInterests
                  entityPreferences {
                    likedEntityIds
                    hiddenEntityIds
                    blockedEntityIds
                  }
                  createdAt
                  updatedAt
                }
              }
            }
            """
        )
        variables: dict[str, object] = {}
        response = await self.execute(
            query=query, operation_name="Me", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return Me.model_validate(data)

    async def my_profile(self, **kwargs: Any) -> MyProfile:
        query = gql(
            """
            query MyProfile {
              myProfile {
                id
                userId
                goals {
                  goalType
                  priority
                  notes
                }
                experienceLevel
                dietStyle
                avoidances
                timeBudget
                preferredFormats
                topicInterests
                entityPreferences {
                  likedEntityIds
                  hiddenEntityIds
                  blockedEntityIds
                }
                createdAt
                updatedAt
              }
            }
            """
        )
        variables: dict[str, object] = {}
        response = await self.execute(
            query=query, operation_name="MyProfile", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return MyProfile.model_validate(data)

    async def business(self, id: str, **kwargs: Any) -> Business:
        query = gql(
            """
            query Business($id: ID!) {
              business(id: $id) {
                id
                name
                description
                website
                mediaLinks {
                  url
                  description
                }
                products {
                  id
                  name
                  description
                }
                owners {
                  id
                  name
                  role
                }
                executives {
                  role
                  title
                  person {
                    id
                    name
                    role
                  }
                }
                sponsoredEpisodes {
                  id
                  episodeTitle
                  channelName
                }
              }
            }
            """
        )
        variables: dict[str, object] = {"id": id}
        response = await self.execute(
            query=query, operation_name="Business", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return Business.model_validate(data)

    async def businesses(
        self,
        limit: Union[Optional[int], UnsetType] = UNSET,
        offset: Union[Optional[int], UnsetType] = UNSET,
        **kwargs: Any
    ) -> Businesses:
        query = gql(
            """
            query Businesses($limit: Int, $offset: Int) {
              businesses(limit: $limit, offset: $offset) {
                id
                name
                description
                website
              }
            }
            """
        )
        variables: dict[str, object] = {"limit": limit, "offset": offset}
        response = await self.execute(
            query=query, operation_name="Businesses", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return Businesses.model_validate(data)

    async def product(self, id: str, **kwargs: Any) -> Product:
        query = gql(
            """
            query Product($id: ID!) {
              product(id: $id) {
                id
                name
                description
                ingredients
                sourceUrl
                mediaLinks {
                  url
                  description
                }
                business {
                  id
                  name
                  description
                }
                compounds {
                  id
                  name
                  description
                }
                sponsorEpisodes {
                  id
                  episodeTitle
                  channelName
                }
              }
            }
            """
        )
        variables: dict[str, object] = {"id": id}
        response = await self.execute(
            query=query, operation_name="Product", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return Product.model_validate(data)

    async def products(
        self,
        limit: Union[Optional[int], UnsetType] = UNSET,
        offset: Union[Optional[int], UnsetType] = UNSET,
        **kwargs: Any
    ) -> Products:
        query = gql(
            """
            query Products($limit: Int, $offset: Int) {
              products(limit: $limit, offset: $offset) {
                id
                name
                description
                ingredients
              }
            }
            """
        )
        variables: dict[str, object] = {"limit": limit, "offset": offset}
        response = await self.execute(
            query=query, operation_name="Products", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return Products.model_validate(data)

    async def person(self, id: str, **kwargs: Any) -> Person:
        query = gql(
            """
            query Person($id: ID!) {
              person(id: $id) {
                id
                name
                role
                bio
                mediaLinks {
                  url
                  description
                }
                businesses {
                  id
                  name
                  description
                }
                episodes {
                  id
                  episodeTitle
                  channelName
                }
              }
            }
            """
        )
        variables: dict[str, object] = {"id": id}
        response = await self.execute(
            query=query, operation_name="Person", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return Person.model_validate(data)

    async def people(
        self,
        limit: Union[Optional[int], UnsetType] = UNSET,
        offset: Union[Optional[int], UnsetType] = UNSET,
        **kwargs: Any
    ) -> People:
        query = gql(
            """
            query People($limit: Int, $offset: Int) {
              people(limit: $limit, offset: $offset) {
                id
                name
                role
              }
            }
            """
        )
        variables: dict[str, object] = {"limit": limit, "offset": offset}
        response = await self.execute(
            query=query, operation_name="People", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return People.model_validate(data)

    async def episode(self, id: str, **kwargs: Any) -> Episode:
        query = gql(
            """
            query Episode($id: ID!) {
              episode(id: $id) {
                id
                channelName
                episodeNumber
                episodeTitle
                episodeTranscriptUrl
                episodePageUrl
                webPageSummary
                webPageTimelines {
                  from
                  to
                  title
                  description
                }
                sponsorLinkObjects {
                  text
                  links
                  hasCodeDave
                  code
                  brand
                  discountPercent
                }
                takeaways
                s3TranscriptKey
                s3TranscriptUrl
                youtubeVideoId
                youtubeWatchUrl
                youtubeEmbedUrl
                mediaLinks {
                  url
                  description
                }
                publishedAt
                guests {
                  id
                  name
                  role
                }
                summaryShort
                summaryDetailed
                publishedSummary
                businessLinks
                sponsorBusinesses {
                  id
                  name
                  description
                }
                protocols {
                  id
                  name
                  description
                }
              }
            }
            """
        )
        variables: dict[str, object] = {"id": id}
        response = await self.execute(
            query=query, operation_name="Episode", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return Episode.model_validate(data)

    async def episodes(
        self,
        limit: Union[Optional[int], UnsetType] = UNSET,
        offset: Union[Optional[int], UnsetType] = UNSET,
        **kwargs: Any
    ) -> Episodes:
        query = gql(
            """
            query Episodes($limit: Int, $offset: Int) {
              episodes(limit: $limit, offset: $offset) {
                id
                episodeTitle
                channelName
                episodeNumber
                publishedAt
              }
            }
            """
        )
        variables: dict[str, object] = {"limit": limit, "offset": offset}
        response = await self.execute(
            query=query, operation_name="Episodes", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return Episodes.model_validate(data)

    async def compound(self, id: str, **kwargs: Any) -> Compound:
        query = gql(
            """
            query Compound($id: ID!) {
              compound(id: $id) {
                id
                name
                description
                aliases
                mediaLinks {
                  url
                  description
                }
                products {
                  id
                  name
                  description
                }
                caseStudies {
                  id
                  title
                  summary
                }
              }
            }
            """
        )
        variables: dict[str, object] = {"id": id}
        response = await self.execute(
            query=query, operation_name="Compound", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return Compound.model_validate(data)

    async def compounds(
        self,
        limit: Union[Optional[int], UnsetType] = UNSET,
        offset: Union[Optional[int], UnsetType] = UNSET,
        **kwargs: Any
    ) -> Compounds:
        query = gql(
            """
            query Compounds($limit: Int, $offset: Int) {
              compounds(limit: $limit, offset: $offset) {
                id
                name
                description
                aliases
              }
            }
            """
        )
        variables: dict[str, object] = {"limit": limit, "offset": offset}
        response = await self.execute(
            query=query, operation_name="Compounds", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return Compounds.model_validate(data)

    async def protocol(self, id: str, **kwargs: Any) -> Protocol:
        query = gql(
            """
            query Protocol($id: ID!) {
              protocol(id: $id) {
                id
                name
                description
                categories
                goals
                steps
                cautions
                aliases
                sourceUrl
                stepsStructured {
                  label
                  timeOfDay
                  items {
                    type
                    refId
                    nameOverride
                    dosage
                    timing
                    notes
                    itemEntity {
                      __typename
                      ... on Product {
                        id
                        name
                        description
                      }
                      ... on Compound {
                        id
                        name
                        description
                      }
                    }
                  }
                }
                evidenceRefs {
                  type
                  refId
                  label
                  url
                  episodeId
                  timestamps
                  notes
                  evidenceRefEntity {
                    __typename
                    ... on Article {
                      id
                      title
                      summary
                    }
                    ... on CaseStudy {
                      id
                      title
                      summary
                    }
                    ... on Episode {
                      id
                      episodeTitle
                      channelName
                    }
                    ... on External {
                      url
                      label
                    }
                  }
                }
                safety {
                  warnings
                  contraindications
                  interactions
                  notes
                }
                products {
                  id
                  name
                  description
                }
                compounds {
                  id
                  name
                  description
                }
              }
            }
            """
        )
        variables: dict[str, object] = {"id": id}
        response = await self.execute(
            query=query, operation_name="Protocol", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return Protocol.model_validate(data)

    async def protocols(
        self,
        limit: Union[Optional[int], UnsetType] = UNSET,
        offset: Union[Optional[int], UnsetType] = UNSET,
        **kwargs: Any
    ) -> Protocols:
        query = gql(
            """
            query Protocols($limit: Int, $offset: Int) {
              protocols(limit: $limit, offset: $offset) {
                id
                name
                description
                categories
                goals
              }
            }
            """
        )
        variables: dict[str, object] = {"limit": limit, "offset": offset}
        response = await self.execute(
            query=query, operation_name="Protocols", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return Protocols.model_validate(data)

    async def case_study(self, id: str, **kwargs: Any) -> CaseStudy:
        query = gql(
            """
            query CaseStudy($id: ID!) {
              caseStudy(id: $id) {
                id
                title
                summary
                url
                sourceType
                mediaLinks {
                  url
                  description
                }
                episodes {
                  id
                  episodeTitle
                  channelName
                }
                compounds {
                  id
                  name
                  description
                }
                products {
                  id
                  name
                  description
                }
                protocols {
                  id
                  name
                  description
                }
              }
            }
            """
        )
        variables: dict[str, object] = {"id": id}
        response = await self.execute(
            query=query, operation_name="CaseStudy", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return CaseStudy.model_validate(data)

    async def case_studies(
        self,
        limit: Union[Optional[int], UnsetType] = UNSET,
        offset: Union[Optional[int], UnsetType] = UNSET,
        **kwargs: Any
    ) -> CaseStudies:
        query = gql(
            """
            query CaseStudies($limit: Int, $offset: Int) {
              caseStudies(limit: $limit, offset: $offset) {
                id
                title
                summary
                url
              }
            }
            """
        )
        variables: dict[str, object] = {"limit": limit, "offset": offset}
        response = await self.execute(
            query=query, operation_name="CaseStudies", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return CaseStudies.model_validate(data)

    async def vector_search_products(
        self, args: VectorSearchArgs, **kwargs: Any
    ) -> VectorSearchProducts:
        query = gql(
            """
            query VectorSearchProducts($args: VectorSearchArgs!) {
              vectorSearchProducts(args: $args) {
                id
                name
                description
                score
              }
            }
            """
        )
        variables: dict[str, object] = {"args": args}
        response = await self.execute(
            query=query,
            operation_name="VectorSearchProducts",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return VectorSearchProducts.model_validate(data)

    async def vector_search_businesses(
        self, args: VectorSearchArgs, **kwargs: Any
    ) -> VectorSearchBusinesses:
        query = gql(
            """
            query VectorSearchBusinesses($args: VectorSearchArgs!) {
              vectorSearchBusinesses(args: $args) {
                id
                name
                description
                score
              }
            }
            """
        )
        variables: dict[str, object] = {"args": args}
        response = await self.execute(
            query=query,
            operation_name="VectorSearchBusinesses",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return VectorSearchBusinesses.model_validate(data)

    async def vector_search_people(
        self, args: VectorSearchArgs, **kwargs: Any
    ) -> VectorSearchPeople:
        query = gql(
            """
            query VectorSearchPeople($args: VectorSearchArgs!) {
              vectorSearchPeople(args: $args) {
                id
                name
                bio
                score
              }
            }
            """
        )
        variables: dict[str, object] = {"args": args}
        response = await self.execute(
            query=query,
            operation_name="VectorSearchPeople",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return VectorSearchPeople.model_validate(data)

    async def saved_entities(
        self,
        filter: Union[Optional[SavedEntitiesFilterInput], UnsetType] = UNSET,
        page: Union[Optional[CursorPageInput], UnsetType] = UNSET,
        **kwargs: Any
    ) -> SavedEntities:
        query = gql(
            """
            query SavedEntities($filter: SavedEntitiesFilterInput, $page: CursorPageInput) {
              savedEntities(filter: $filter, page: $page) {
                edges {
                  cursor
                  node {
                    id
                    userId
                    targetType
                    targetId
                    note
                    tags
                    pinned
                    source
                    createdAt
                    updatedAt
                    target {
                      __typename
                      ... on Product {
                        id
                        name
                        description
                      }
                      ... on Compound {
                        id
                        name
                        description
                      }
                      ... on CaseStudy {
                        id
                        title
                        summary
                      }
                      ... on Protocol {
                        id
                        name
                        description
                      }
                      ... on Person {
                        id
                        name
                        role
                      }
                      ... on Business {
                        id
                        name
                        description
                      }
                      ... on Episode {
                        id
                        episodeTitle
                        channelName
                      }
                      ... on Article {
                        id
                        title
                        summary
                      }
                    }
                  }
                }
                pageInfo {
                  hasNextPage
                  endCursor
                }
              }
            }
            """
        )
        variables: dict[str, object] = {"filter": filter, "page": page}
        response = await self.execute(
            query=query, operation_name="SavedEntities", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return SavedEntities.model_validate(data)

    async def my_user_protocols(
        self,
        filter: Union[Optional[UserProtocolsFilterInput], UnsetType] = UNSET,
        page: Union[Optional[CursorPageInput], UnsetType] = UNSET,
        **kwargs: Any
    ) -> MyUserProtocols:
        query = gql(
            """
            query MyUserProtocols($filter: UserProtocolsFilterInput, $page: CursorPageInput) {
              myUserProtocols(filter: $filter, page: $page) {
                edges {
                  cursor
                  node {
                    id
                    userId
                    title
                    goalType
                    status
                    sourceProtocolId
                    stepsStructured {
                      label
                      timeOfDay
                      items {
                        type
                        refId
                        nameOverride
                        dosage
                        timing
                        notes
                        itemEntity {
                          __typename
                          ... on Product {
                            id
                            name
                            description
                          }
                          ... on Compound {
                            id
                            name
                            description
                          }
                        }
                      }
                    }
                    evidenceRefs {
                      type
                      refId
                      label
                      url
                      episodeId
                      timestamps
                      notes
                      evidenceRefEntity {
                        __typename
                        ... on Article {
                          id
                          title
                          summary
                        }
                        ... on CaseStudy {
                          id
                          title
                          summary
                        }
                        ... on Episode {
                          id
                          episodeTitle
                          channelName
                        }
                        ... on External {
                          url
                          label
                        }
                      }
                    }
                    safety {
                      warnings
                      contraindications
                      interactions
                      notes
                    }
                    lastEditedAt
                    createdAt
                    updatedAt
                  }
                }
                pageInfo {
                  hasNextPage
                  endCursor
                }
              }
            }
            """
        )
        variables: dict[str, object] = {"filter": filter, "page": page}
        response = await self.execute(
            query=query, operation_name="MyUserProtocols", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return MyUserProtocols.model_validate(data)

    async def all_users(
        self,
        limit: Union[Optional[int], UnsetType] = UNSET,
        offset: Union[Optional[int], UnsetType] = UNSET,
        **kwargs: Any
    ) -> AllUsers:
        query = gql(
            """
            query AllUsers($limit: Int, $offset: Int) {
              allUsers(limit: $limit, offset: $offset) {
                id
                email
                name
                role
              }
            }
            """
        )
        variables: dict[str, object] = {"limit": limit, "offset": offset}
        response = await self.execute(
            query=query, operation_name="AllUsers", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return AllUsers.model_validate(data)
