services:
    akeneo_connectivity.connection.service.apps.client_provider:
        class: Akeneo\Connectivity\Connection\Infrastructure\Apps\OAuth\ClientProvider
        arguments:
            - '@fos_oauth_server.client_manager.default'

    Akeneo\Connectivity\Connection\Infrastructure\Apps\Session\AppAuthorizationSession:
        arguments:
            - '@session'

    Akeneo\Connectivity\Connection\Application\Apps\Command\CreateAppWithAuthorizationHandler:
        arguments:
            - '@validator'
            - '@Akeneo\Connectivity\Connection\Infrastructure\Apps\Session\AppAuthorizationSession'
            - '@akeneo_connectivity.connection.marketplace.get_app_query'
            - '@akeneo_connectivity.connection.service.user.create_user'
            - '@Akeneo\Connectivity\Connection\Infrastructure\Apps\User\CreateUserGroup'
            - '@Akeneo\Connectivity\Connection\Application\Apps\Service\CreateConnection'
            - '@Akeneo\Connectivity\Connection\Infrastructure\Apps\AppRoleWithScopesFactory'
            - '@akeneo_connectivity.connection.service.apps.client_provider'
            - '@Akeneo\Connectivity\Connection\Application\Apps\Service\CreateConnectedApp'

    Akeneo\Connectivity\Connection\Application\Apps\Command\ConsentAppAuthenticationHandler:
        arguments:
            - '@Akeneo\Connectivity\Connection\Infrastructure\Apps\Persistence\Query\GetAppConfirmationQuery'
            - '@Akeneo\Connectivity\Connection\Infrastructure\Apps\Session\AppAuthorizationSession'
            - '@Akeneo\Connectivity\Connection\Infrastructure\Apps\Persistence\Query\CreateUserConsentQuery'
            - '@akeneo_connectivity.connection.clock'
            - '@validator'

    Akeneo\Connectivity\Connection\Application\Apps\Command\RequestAppAuthorizationHandler:
        arguments:
            - '@validator'
            - '@Akeneo\Connectivity\Connection\Infrastructure\Apps\Session\AppAuthorizationSession'
            - '@Akeneo\Connectivity\Connection\Infrastructure\Apps\Security\ScopeMapperRegistry'
            - '@akeneo_connectivity.connection.marketplace.get_app_query'

    Akeneo\Connectivity\Connection\Application\Apps\Command\GenerateAsymmetricKeysHandler:
        arguments:
            - '@Akeneo\Connectivity\Connection\Infrastructure\Apps\AsymmetricKeysGenerator'
            - '@Akeneo\Connectivity\Connection\Infrastructure\Apps\Persistence\Query\SaveAsymmetricKeysQuery'

    Akeneo\Connectivity\Connection\Application\Apps\Command\RequestAppAuthenticationHandler:
        arguments:
            - '@Akeneo\Connectivity\Connection\Infrastructure\Apps\Persistence\Query\GetUserConsentedAuthenticationScopesQuery'
            - '@Akeneo\Connectivity\Connection\Infrastructure\Apps\Persistence\Query\CreateUserConsentQuery'
            - '@akeneo_connectivity.connection.clock'
            - '@validator'

    Akeneo\Connectivity\Connection\Application\Apps\Service\CreateConnectedApp:
        arguments:
            - '@Akeneo\Connectivity\Connection\Infrastructure\Apps\Persistence\DbalConnectedAppRepository'

    Akeneo\Connectivity\Connection\Application\Apps\Service\CreateConnection:
        arguments:
            - '@akeneo_connectivity.connection.persistence.repository.connection'
            - '@akeneo_connectivity.connection.persistence.query.select_connection_with_credentials_by_code'

    Akeneo\Connectivity\Connection\Infrastructure\Apps\AppRoleWithScopesFactory:
        arguments:
            - '@Akeneo\Connectivity\Connection\Infrastructure\Apps\Security\ScopeMapperRegistry'
            - '@pim_user.factory.role'
            - '@pim_user.saver.role_with_permissions'
        public: true

    Akeneo\Connectivity\Connection\Infrastructure\Apps\AsymmetricKeysGenerator:
        public: true

    Akeneo\Connectivity\Connection\Infrastructure\Apps\Persistence\DbalConnectedAppRepository:
        arguments:
            - '@database_connection'

    Akeneo\Connectivity\Connection\Infrastructure\Apps\Normalizer\ViolationListNormalizer: ~

    Akeneo\Connectivity\Connection\Infrastructure\Apps\OAuth\RandomCodeGenerator: ~

    Akeneo\Connectivity\Connection\Infrastructure\Apps\OAuth\AuthorizationCodeGenerator:
        arguments:
            - '@fos_oauth_server.client_manager.default'
            - '@pim_user.repository.user'
            - '@fos_oauth_server.storage.default'
            - '@Akeneo\Connectivity\Connection\Infrastructure\Apps\OAuth\RandomCodeGenerator'
            - '@akeneo_connectivity.connection.clock'

    Akeneo\Connectivity\Connection\Infrastructure\Apps\OAuth\RedirectUriWithAuthorizationCodeGenerator:
        arguments:
            - '@Akeneo\Connectivity\Connection\Infrastructure\Apps\OAuth\AuthorizationCodeGenerator'

    Akeneo\Connectivity\Connection\Infrastructure\Apps\OAuth\CreateAccessToken:
        arguments:
            - '@fos_oauth_server.storage.default'
            - '@akeneo_connectivity.connection.service.apps.client_provider'
            - '@Akeneo\Connectivity\Connection\Infrastructure\Apps\OAuth\RandomCodeGenerator'
            - '@Akeneo\Connectivity\Connection\Infrastructure\Apps\Persistence\Query\GetAppConfirmationQuery'
            - '@pim_user.repository.user'
            - '@Akeneo\Connectivity\Connection\Infrastructure\Apps\OAuth\CreateJsonWebToken'
            - '@Akeneo\Connectivity\Connection\Infrastructure\Apps\Persistence\Query\GetConnectedAppScopesQuery'
            - '@Akeneo\Connectivity\Connection\Infrastructure\Apps\Persistence\Query\GetUserConsentedAuthenticationUuidQuery'
            - '@Akeneo\Connectivity\Connection\Infrastructure\Apps\Persistence\Query\GetUserConsentedAuthenticationScopesQuery'
            - '@Akeneo\Connectivity\Connection\Infrastructure\Apps\Persistence\Query\GetAccessTokenQuery'

    Akeneo\Connectivity\Connection\Infrastructure\Apps\OAuth\CreateJsonWebToken:
        arguments:
            - '@akeneo_connectivity.connection.clock'
            - '@pim_framework.service.pim_url'
            - '@Akeneo\Connectivity\Connection\Infrastructure\Apps\Persistence\Query\GetAsymmetricKeysQuery'

    Akeneo\Connectivity\Connection\Infrastructure\Apps\User\CreateUserGroup:
        arguments:
            - '@pim_user.factory.group'
            - '@pim_user.updater.group'
            - '@pim_user.saver.group'
            - '@validator'

    Akeneo\Connectivity\Connection\Application\Apps\Command\DeleteAppHandler:
        arguments:
            - '@Akeneo\Connectivity\Connection\Infrastructure\Apps\Persistence\Query\GetAppDeletionQuery'
            - '@Akeneo\Connectivity\Connection\Infrastructure\Apps\Persistence\Query\DeleteConnectedAppQuery'
            - '@akeneo_connectivity.connection.persistence.repository.connection'
            - '@akeneo_connectivity.connection.service.user.delete_user'
            - '@akeneo_connectivity.connection.service.client.delete_client'
            - '@Akeneo\Connectivity\Connection\Infrastructure\User\Internal\DeleteUserGroup'
            - '@Akeneo\Connectivity\Connection\Infrastructure\User\Internal\DeleteUserRole'

    Akeneo\Connectivity\Connection\Infrastructure\Apps\Security\ConnectedPimUserProvider:
        arguments:
            - '@security.token_storage'

    Akeneo\Connectivity\Connection\Infrastructure\Apps\Security\ScopeMapperRegistry:
        arguments:
            - !tagged_iterator pim_api.security.scope_mapper

    # queries
    Akeneo\Connectivity\Connection\Infrastructure\Apps\Persistence\Query\GetAllConnectedAppsPublicIdsQuery:
        arguments:
            - '@database_connection'

    Akeneo\Connectivity\Connection\Infrastructure\Apps\Persistence\Query\GetAppConfirmationQuery:
        arguments:
            - '@database_connection'

    Akeneo\Connectivity\Connection\Infrastructure\Apps\Persistence\Query\DeleteConnectedAppQuery:
        arguments:
            - '@database_connection'

    Akeneo\Connectivity\Connection\Infrastructure\Apps\Persistence\Query\GetAppDeletionQuery:
        arguments:
            - '@database_connection'

    Akeneo\Connectivity\Connection\Infrastructure\Apps\Persistence\Query\GetConnectedAppScopesQuery:
        arguments:
            - '@database_connection'

    Akeneo\Connectivity\Connection\Infrastructure\Apps\Persistence\Query\GetUserConsentedAuthenticationScopesQuery:
        arguments:
            - '@database_connection'

    Akeneo\Connectivity\Connection\Infrastructure\Apps\Persistence\Query\GetUserConsentedAuthenticationUuidQuery:
        arguments:
            - '@database_connection'

    Akeneo\Connectivity\Connection\Infrastructure\Apps\Persistence\Query\CreateUserConsentQuery:
        arguments:
            - '@database_connection'

    Akeneo\Connectivity\Connection\Infrastructure\Apps\Persistence\Query\GetAsymmetricKeysQuery:
        arguments:
            - '@database_connection'

    Akeneo\Connectivity\Connection\Infrastructure\Apps\Persistence\Query\SaveAsymmetricKeysQuery:
        arguments:
            - '@database_connection'
            - '@akeneo_connectivity.connection.clock'

    Akeneo\Connectivity\Connection\Infrastructure\Apps\Persistence\Query\GetAccessTokenQuery:
        arguments:
            - '@database_connection'
