mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
Tech | Refactoring | MW 0.9.0 with Protocol refactoring + Auth refactoring (#2242)
This commit is contained in:
parent
ab1f7b0b96
commit
06e9d65b9f
77 changed files with 5700 additions and 6104 deletions
|
@ -13,6 +13,7 @@ import com.anytypeio.anytype.domain.auth.interactor.StartAccount
|
|||
import com.anytypeio.anytype.domain.auth.repo.AuthRepository
|
||||
import com.anytypeio.anytype.domain.block.interactor.sets.StoreObjectTypes
|
||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||
import com.anytypeio.anytype.domain.config.ConfigStorage
|
||||
import com.anytypeio.anytype.domain.config.FeaturesConfigProvider
|
||||
import com.anytypeio.anytype.domain.device.PathProvider
|
||||
import com.anytypeio.anytype.features.auth.fragments.TestSetupSelectedAccountFragment
|
||||
|
@ -65,6 +66,9 @@ class SetupSelectedAccountTest {
|
|||
@Mock
|
||||
lateinit var pathProvider: PathProvider
|
||||
|
||||
@Mock
|
||||
lateinit var configStorage: ConfigStorage
|
||||
|
||||
lateinit var storeObjectTypes: StoreObjectTypes
|
||||
|
||||
@Before
|
||||
|
@ -72,7 +76,8 @@ class SetupSelectedAccountTest {
|
|||
MockitoAnnotations.openMocks(this)
|
||||
startAccount = StartAccount(
|
||||
repository = authRepository,
|
||||
featuresConfigProvider = featuresConfigProvider
|
||||
featuresConfigProvider = featuresConfigProvider,
|
||||
configStorage = configStorage
|
||||
)
|
||||
storeObjectTypes = StoreObjectTypes(
|
||||
repo = blockRepository,
|
||||
|
|
|
@ -5,10 +5,18 @@ import com.anytypeio.anytype.analytics.base.Analytics
|
|||
import com.anytypeio.anytype.core_utils.di.scope.PerFeature
|
||||
import com.anytypeio.anytype.core_utils.di.scope.PerScreen
|
||||
import com.anytypeio.anytype.domain.`object`.ObjectTypesProvider
|
||||
import com.anytypeio.anytype.domain.auth.interactor.*
|
||||
import com.anytypeio.anytype.domain.auth.interactor.ConvertWallet
|
||||
import com.anytypeio.anytype.domain.auth.interactor.CreateAccount
|
||||
import com.anytypeio.anytype.domain.auth.interactor.ObserveAccounts
|
||||
import com.anytypeio.anytype.domain.auth.interactor.RecoverWallet
|
||||
import com.anytypeio.anytype.domain.auth.interactor.SaveMnemonic
|
||||
import com.anytypeio.anytype.domain.auth.interactor.SetupWallet
|
||||
import com.anytypeio.anytype.domain.auth.interactor.StartAccount
|
||||
import com.anytypeio.anytype.domain.auth.interactor.StartLoadingAccounts
|
||||
import com.anytypeio.anytype.domain.auth.repo.AuthRepository
|
||||
import com.anytypeio.anytype.domain.block.interactor.sets.StoreObjectTypes
|
||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||
import com.anytypeio.anytype.domain.config.ConfigStorage
|
||||
import com.anytypeio.anytype.domain.config.FeaturesConfigProvider
|
||||
import com.anytypeio.anytype.domain.device.PathProvider
|
||||
import com.anytypeio.anytype.presentation.auth.account.CreateAccountViewModelFactory
|
||||
|
@ -41,6 +49,7 @@ interface AuthSubComponent {
|
|||
}
|
||||
|
||||
fun inject(fragment: InvitationFragment)
|
||||
|
||||
@ExperimentalMaterialApi
|
||||
fun inject(fragment: AboutAnalyticsFragment)
|
||||
|
||||
|
@ -261,10 +270,12 @@ object SetupSelectedAccountModule {
|
|||
@PerScreen
|
||||
fun provideSelectAccountUseCase(
|
||||
repository: AuthRepository,
|
||||
configStorage: ConfigStorage,
|
||||
featuresConfigProvider: FeaturesConfigProvider
|
||||
): StartAccount {
|
||||
return StartAccount(
|
||||
repository = repository,
|
||||
configStorage = configStorage,
|
||||
featuresConfigProvider = featuresConfigProvider
|
||||
)
|
||||
}
|
||||
|
@ -358,7 +369,7 @@ object KeychainLoginModule {
|
|||
@PerScreen
|
||||
fun provideConvertWallet(
|
||||
authRepository: AuthRepository
|
||||
) : ConvertWallet {
|
||||
): ConvertWallet {
|
||||
return ConvertWallet(
|
||||
authRepository = authRepository
|
||||
)
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.anytypeio.anytype.domain.auth.repo.AuthRepository
|
|||
import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers
|
||||
import com.anytypeio.anytype.domain.block.interactor.Move
|
||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||
import com.anytypeio.anytype.domain.config.ConfigStorage
|
||||
import com.anytypeio.anytype.domain.config.FeaturesConfigProvider
|
||||
import com.anytypeio.anytype.domain.config.GetConfig
|
||||
import com.anytypeio.anytype.domain.config.GetDebugSettings
|
||||
|
@ -107,10 +108,12 @@ object HomeDashboardModule {
|
|||
@PerScreen
|
||||
fun provideGetProfileUseCase(
|
||||
repository: BlockRepository,
|
||||
subscriptionEventChannel: SubscriptionEventChannel
|
||||
subscriptionEventChannel: SubscriptionEventChannel,
|
||||
provider: ConfigStorage
|
||||
): GetProfile = GetProfile(
|
||||
repo = repository,
|
||||
channel = subscriptionEventChannel
|
||||
channel = subscriptionEventChannel,
|
||||
provider = provider
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
|
@ -118,19 +121,23 @@ object HomeDashboardModule {
|
|||
@PerScreen
|
||||
fun provideOpenDashboardUseCase(
|
||||
repo: BlockRepository,
|
||||
auth: AuthRepository
|
||||
auth: AuthRepository,
|
||||
provider: ConfigStorage
|
||||
): OpenDashboard = OpenDashboard(
|
||||
repo = repo,
|
||||
auth = auth
|
||||
auth = auth,
|
||||
provider = provider
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
@Provides
|
||||
@PerScreen
|
||||
fun provideCloseDashboardUseCase(
|
||||
repo: BlockRepository
|
||||
repo: BlockRepository,
|
||||
provider: ConfigStorage
|
||||
): CloseDashboard = CloseDashboard(
|
||||
repo = repo
|
||||
repo = repo,
|
||||
provider = provider
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
|
@ -146,9 +153,9 @@ object HomeDashboardModule {
|
|||
@Provides
|
||||
@PerScreen
|
||||
fun getConfigUseCase(
|
||||
repo: BlockRepository
|
||||
provider: ConfigStorage
|
||||
): GetConfig = GetConfig(
|
||||
repo = repo
|
||||
provider = provider
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.anytypeio.anytype.domain.auth.interactor.LaunchAccount
|
|||
import com.anytypeio.anytype.domain.auth.interactor.Logout
|
||||
import com.anytypeio.anytype.domain.auth.repo.AuthRepository
|
||||
import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers
|
||||
import com.anytypeio.anytype.domain.config.ConfigStorage
|
||||
import com.anytypeio.anytype.domain.config.FeaturesConfigProvider
|
||||
import com.anytypeio.anytype.domain.config.UserSettingsRepository
|
||||
import com.anytypeio.anytype.domain.device.PathProvider
|
||||
|
@ -64,10 +65,12 @@ object MainEntryModule {
|
|||
fun provideLaunchAccountUseCase(
|
||||
authRepository: AuthRepository,
|
||||
pathProvider: PathProvider,
|
||||
configStorage: ConfigStorage,
|
||||
featuresConfigProvider: FeaturesConfigProvider
|
||||
): LaunchAccount = LaunchAccount(
|
||||
repository = authRepository,
|
||||
pathProvider = pathProvider,
|
||||
configStorage = configStorage,
|
||||
featuresConfigProvider = featuresConfigProvider
|
||||
)
|
||||
|
||||
|
@ -112,7 +115,11 @@ object MainEntryModule {
|
|||
@JvmStatic
|
||||
@PerScreen
|
||||
@Provides
|
||||
fun provideLogoutUseCase(repo: AuthRepository): Logout = Logout(
|
||||
repo = repo
|
||||
fun provideLogoutUseCase(
|
||||
repo: AuthRepository,
|
||||
provider: ConfigStorage
|
||||
): Logout = Logout(
|
||||
repo = repo,
|
||||
provider
|
||||
)
|
||||
}
|
|
@ -4,6 +4,7 @@ import com.anytypeio.anytype.analytics.base.Analytics
|
|||
import com.anytypeio.anytype.core_utils.di.scope.PerScreen
|
||||
import com.anytypeio.anytype.domain.`object`.ObjectTypesProvider
|
||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||
import com.anytypeio.anytype.domain.config.ConfigStorage
|
||||
import com.anytypeio.anytype.domain.config.GetConfig
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.page.navigation.GetObjectInfoWithLinks
|
||||
|
@ -59,8 +60,8 @@ object PageNavigationModule {
|
|||
@Provides
|
||||
@PerScreen
|
||||
fun getConfigUseCase(
|
||||
repo: BlockRepository
|
||||
provider: ConfigStorage
|
||||
): GetConfig = GetConfig(
|
||||
repo = repo
|
||||
provider = provider
|
||||
)
|
||||
}
|
|
@ -10,6 +10,7 @@ import com.anytypeio.anytype.domain.auth.interactor.LaunchWallet
|
|||
import com.anytypeio.anytype.domain.auth.repo.AuthRepository
|
||||
import com.anytypeio.anytype.domain.block.interactor.sets.StoreObjectTypes
|
||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||
import com.anytypeio.anytype.domain.config.ConfigStorage
|
||||
import com.anytypeio.anytype.domain.config.FeaturesConfigProvider
|
||||
import com.anytypeio.anytype.domain.config.UserSettingsRepository
|
||||
import com.anytypeio.anytype.domain.device.PathProvider
|
||||
|
@ -23,12 +24,6 @@ import dagger.Module
|
|||
import dagger.Provides
|
||||
import dagger.Subcomponent
|
||||
|
||||
/**
|
||||
* Created by Konstantin Ivanov
|
||||
* email : ki@agileburo.com
|
||||
* on 2019-10-21.
|
||||
*/
|
||||
|
||||
@PerScreen
|
||||
@Subcomponent(modules = [SplashModule::class])
|
||||
interface SplashSubComponent {
|
||||
|
@ -87,11 +82,13 @@ object SplashModule {
|
|||
fun provideLaunchAccountUseCase(
|
||||
authRepository: AuthRepository,
|
||||
pathProvider: PathProvider,
|
||||
featuresConfigProvider: FeaturesConfigProvider
|
||||
featuresConfigProvider: FeaturesConfigProvider,
|
||||
configStorage: ConfigStorage
|
||||
): LaunchAccount = LaunchAccount(
|
||||
repository = authRepository,
|
||||
pathProvider = pathProvider,
|
||||
featuresConfigProvider = featuresConfigProvider
|
||||
featuresConfigProvider = featuresConfigProvider,
|
||||
configStorage = configStorage
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.anytypeio.anytype.domain.account.DateHelper
|
|||
import com.anytypeio.anytype.domain.account.RestoreAccount
|
||||
import com.anytypeio.anytype.domain.auth.interactor.Logout
|
||||
import com.anytypeio.anytype.domain.auth.repo.AuthRepository
|
||||
import com.anytypeio.anytype.domain.config.ConfigStorage
|
||||
import com.anytypeio.anytype.ext.DefaultDateHelper
|
||||
import com.anytypeio.anytype.presentation.auth.account.DeletedAccountViewModel
|
||||
import com.anytypeio.anytype.ui.auth.account.DeletedAccountFragment
|
||||
|
@ -49,8 +50,12 @@ object DeletedAccountModule {
|
|||
@JvmStatic
|
||||
@Provides
|
||||
@PerScreen
|
||||
fun provideLogout(repo: AuthRepository): Logout = Logout(
|
||||
repo = repo
|
||||
fun provideLogout(
|
||||
repo: AuthRepository,
|
||||
provider: ConfigStorage
|
||||
): Logout = Logout(
|
||||
repo = repo,
|
||||
provider = provider
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.anytypeio.anytype.domain.account.DeleteAccount
|
|||
import com.anytypeio.anytype.domain.auth.interactor.Logout
|
||||
import com.anytypeio.anytype.domain.auth.repo.AuthRepository
|
||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||
import com.anytypeio.anytype.domain.config.ConfigStorage
|
||||
import com.anytypeio.anytype.domain.device.ClearFileCache
|
||||
import com.anytypeio.anytype.ui.settings.AccountAndDataFragment
|
||||
import com.anytypeio.anytype.ui_settings.account.AccountAndDataViewModel
|
||||
|
@ -47,9 +48,15 @@ object AccountAndDataModule {
|
|||
fun clearFileCache(repo: BlockRepository): ClearFileCache = ClearFileCache(repo)
|
||||
|
||||
@JvmStatic
|
||||
@Provides
|
||||
@PerScreen
|
||||
fun logout(repo: AuthRepository): Logout = Logout(repo)
|
||||
@Provides
|
||||
fun provideLogoutUseCase(
|
||||
repo: AuthRepository,
|
||||
provider: ConfigStorage
|
||||
): Logout = Logout(
|
||||
repo = repo,
|
||||
provider
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
@Provides
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.anytypeio.anytype.analytics.base.Analytics
|
|||
import com.anytypeio.anytype.core_utils.di.scope.PerScreen
|
||||
import com.anytypeio.anytype.domain.auth.interactor.Logout
|
||||
import com.anytypeio.anytype.domain.auth.repo.AuthRepository
|
||||
import com.anytypeio.anytype.domain.config.ConfigStorage
|
||||
import com.anytypeio.anytype.ui.settings.LogoutWarningFragment
|
||||
import com.anytypeio.anytype.ui_settings.account.LogoutWarningViewModel
|
||||
import dagger.Module
|
||||
|
@ -35,7 +36,13 @@ object LogoutWarningModule {
|
|||
): LogoutWarningViewModel.Factory = LogoutWarningViewModel.Factory(logout, analytics)
|
||||
|
||||
@JvmStatic
|
||||
@Provides
|
||||
@PerScreen
|
||||
fun logout(repo: AuthRepository): Logout = Logout(repo)
|
||||
@Provides
|
||||
fun provideLogoutUseCase(
|
||||
repo: AuthRepository,
|
||||
provider: ConfigStorage
|
||||
): Logout = Logout(
|
||||
repo = repo,
|
||||
provider
|
||||
)
|
||||
}
|
|
@ -1,11 +1,8 @@
|
|||
package com.anytypeio.anytype.di.main
|
||||
|
||||
import com.anytypeio.anytype.core_models.Config
|
||||
import com.anytypeio.anytype.data.auth.repo.config.Configuration
|
||||
import com.anytypeio.anytype.data.auth.repo.config.Configurator
|
||||
import com.anytypeio.anytype.data.auth.repo.config.GatewayProvider
|
||||
import com.anytypeio.anytype.domain.config.ConfigStorage
|
||||
import com.anytypeio.anytype.domain.config.Gateway
|
||||
import com.anytypeio.anytype.middleware.config.DefaultConfigurator
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import javax.inject.Singleton
|
||||
|
@ -16,19 +13,12 @@ object ConfigModule {
|
|||
@JvmStatic
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideApplicationConfig(configurator: Configurator): Config {
|
||||
return Configuration(configurator).init()
|
||||
}
|
||||
fun provideGateway(
|
||||
provider: ConfigStorage
|
||||
): Gateway = GatewayProvider(provider)
|
||||
|
||||
@JvmStatic
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideGateway(configurator: Configurator): Gateway = GatewayProvider(configurator)
|
||||
|
||||
@JvmStatic
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideConfigurator(): Configurator {
|
||||
return DefaultConfigurator()
|
||||
}
|
||||
fun provideConfigProvider(): ConfigStorage = ConfigStorage.CacheStorage()
|
||||
}
|
|
@ -20,7 +20,6 @@ import com.anytypeio.anytype.data.auth.repo.block.BlockDataRepository
|
|||
import com.anytypeio.anytype.data.auth.repo.block.BlockDataStoreFactory
|
||||
import com.anytypeio.anytype.data.auth.repo.block.BlockRemote
|
||||
import com.anytypeio.anytype.data.auth.repo.block.BlockRemoteDataStore
|
||||
import com.anytypeio.anytype.data.auth.repo.config.Configurator
|
||||
import com.anytypeio.anytype.data.auth.repo.unsplash.UnsplashDataRepository
|
||||
import com.anytypeio.anytype.data.auth.repo.unsplash.UnsplashRemote
|
||||
import com.anytypeio.anytype.data.auth.types.DefaultObjectTypesProvider
|
||||
|
@ -66,12 +65,10 @@ object DataModule {
|
|||
@Provides
|
||||
@Singleton
|
||||
fun provideAuthRepository(
|
||||
factory: AuthDataStoreFactory,
|
||||
configurator: Configurator
|
||||
factory: AuthDataStoreFactory
|
||||
): AuthRepository {
|
||||
return AuthDataRepository(
|
||||
factory = factory,
|
||||
configurator = configurator
|
||||
factory = factory
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
package com.anytypeio.anytype.domain.auth.model
|
||||
|
||||
import com.anytypeio.anytype.core_models.Url
|
||||
package com.anytypeio.anytype.core_models
|
||||
|
||||
/**
|
||||
* User account.
|
|
@ -0,0 +1,8 @@
|
|||
package com.anytypeio.anytype.core_models
|
||||
|
||||
data class AccountSetup(
|
||||
val account: Account,
|
||||
val config: Config,
|
||||
val features: FeaturesConfig,
|
||||
val status: AccountStatus
|
||||
)
|
|
@ -37,6 +37,7 @@ sealed class Response {
|
|||
|
||||
sealed class Set : Response() {
|
||||
data class Create(
|
||||
@Deprecated("legacy param")
|
||||
val blockId: Id?,
|
||||
val targetId: Id,
|
||||
val payload: Payload
|
||||
|
|
|
@ -11,6 +11,7 @@ dependencies {
|
|||
implementation applicationDependencies.coroutines
|
||||
|
||||
testImplementation project(":test:utils")
|
||||
testImplementation project(":test:core-models-stub")
|
||||
testImplementation unitTestDependencies.junit
|
||||
testImplementation unitTestDependencies.kotlinTest
|
||||
testImplementation unitTestDependencies.mockitoKotlin
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package com.anytypeio.anytype.data.auth.mapper
|
||||
|
||||
import com.anytypeio.anytype.core_models.Account
|
||||
import com.anytypeio.anytype.data.auth.model.AccountEntity
|
||||
import com.anytypeio.anytype.data.auth.model.FeaturesConfigEntity
|
||||
import com.anytypeio.anytype.data.auth.model.WalletEntity
|
||||
import com.anytypeio.anytype.domain.auth.model.Account
|
||||
import com.anytypeio.anytype.domain.auth.model.Wallet
|
||||
import com.anytypeio.anytype.core_models.FeaturesConfig
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.anytypeio.anytype.data.auth.repo
|
||||
|
||||
import com.anytypeio.anytype.core_models.AccountSetup
|
||||
import com.anytypeio.anytype.core_models.AccountStatus
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.data.auth.model.AccountEntity
|
||||
|
@ -12,7 +13,7 @@ class AuthCacheDataStore(private val cache: AuthCache) : AuthDataStore {
|
|||
override suspend fun startAccount(
|
||||
id: String,
|
||||
path: String
|
||||
): Triple<AccountEntity, FeaturesConfigEntity, AccountStatus> {
|
||||
): AccountSetup {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
|
|
|
@ -1,30 +1,23 @@
|
|||
package com.anytypeio.anytype.data.auth.repo
|
||||
|
||||
import com.anytypeio.anytype.core_models.Account
|
||||
import com.anytypeio.anytype.core_models.AccountSetup
|
||||
import com.anytypeio.anytype.core_models.AccountStatus
|
||||
import com.anytypeio.anytype.core_models.FeaturesConfig
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.data.auth.mapper.toDomain
|
||||
import com.anytypeio.anytype.data.auth.mapper.toEntity
|
||||
import com.anytypeio.anytype.data.auth.repo.config.Configurator
|
||||
import com.anytypeio.anytype.domain.auth.model.Account
|
||||
import com.anytypeio.anytype.domain.auth.model.Wallet
|
||||
import com.anytypeio.anytype.domain.auth.repo.AuthRepository
|
||||
import kotlinx.coroutines.flow.map
|
||||
|
||||
class AuthDataRepository(
|
||||
private val factory: AuthDataStoreFactory,
|
||||
private val configurator: Configurator
|
||||
private val factory: AuthDataStoreFactory
|
||||
) : AuthRepository {
|
||||
|
||||
override suspend fun startAccount(
|
||||
id: String, path: String
|
||||
): Triple<Account, FeaturesConfig, AccountStatus> = factory.remote.startAccount(id, path).let { triple ->
|
||||
Triple(
|
||||
first = triple.first.toDomain(),
|
||||
second = triple.second.toDomain(),
|
||||
third = triple.third
|
||||
)
|
||||
}
|
||||
): AccountSetup = factory.remote.startAccount(id, path)
|
||||
|
||||
override suspend fun createAccount(
|
||||
name: String,
|
||||
|
@ -71,7 +64,6 @@ class AuthDataRepository(
|
|||
override suspend fun getMnemonic() = factory.cache.getMnemonic()
|
||||
|
||||
override suspend fun logout(clearLocalRepositoryData: Boolean) {
|
||||
configurator.release()
|
||||
factory.remote.logout(clearLocalRepositoryData)
|
||||
factory.cache.logout(clearLocalRepositoryData)
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.anytypeio.anytype.data.auth.repo
|
||||
|
||||
import com.anytypeio.anytype.core_models.AccountSetup
|
||||
import com.anytypeio.anytype.core_models.AccountStatus
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.data.auth.model.AccountEntity
|
||||
|
@ -9,7 +10,7 @@ import kotlinx.coroutines.flow.Flow
|
|||
|
||||
interface AuthDataStore {
|
||||
|
||||
suspend fun startAccount(id: String, path: String): Triple<AccountEntity, FeaturesConfigEntity, AccountStatus>
|
||||
suspend fun startAccount(id: String, path: String): AccountSetup
|
||||
|
||||
suspend fun createAccount(name: String, avatarPath: String?, invitationCode: String): AccountEntity
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package com.anytypeio.anytype.data.auth.repo
|
||||
|
||||
import com.anytypeio.anytype.core_models.AccountSetup
|
||||
import com.anytypeio.anytype.core_models.AccountStatus
|
||||
import com.anytypeio.anytype.data.auth.model.AccountEntity
|
||||
import com.anytypeio.anytype.data.auth.model.FeaturesConfigEntity
|
||||
import com.anytypeio.anytype.data.auth.model.WalletEntity
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
interface AuthRemote {
|
||||
suspend fun startAccount(id: String, path: String): Triple<AccountEntity, FeaturesConfigEntity, AccountStatus>
|
||||
suspend fun startAccount(id: String, path: String): AccountSetup
|
||||
suspend fun createAccount(name: String, avatarPath: String?, invitationCode: String): AccountEntity
|
||||
suspend fun deleteAccount() : AccountStatus
|
||||
suspend fun restoreAccount() : AccountStatus
|
||||
|
|
|
@ -31,8 +31,6 @@ class BlockDataRepository(
|
|||
private val factory: BlockDataStoreFactory
|
||||
) : BlockRepository {
|
||||
|
||||
override suspend fun getConfig() = factory.remote.getConfig()
|
||||
|
||||
override suspend fun openDashboard(
|
||||
contextId: String,
|
||||
id: String
|
||||
|
|
|
@ -41,7 +41,6 @@ interface BlockDataStore {
|
|||
suspend fun uploadBlock(command: Command.UploadBlock): Payload
|
||||
suspend fun move(command: Command.Move): Payload
|
||||
suspend fun unlink(command: Command.Unlink): Payload
|
||||
suspend fun getConfig(): Config
|
||||
suspend fun createPage(
|
||||
ctx: Id?,
|
||||
emoji: String?,
|
||||
|
|
|
@ -38,7 +38,6 @@ interface BlockRemote {
|
|||
|
||||
suspend fun updateCheckbox(command: Command.UpdateCheckbox): Payload
|
||||
suspend fun move(command: Command.Move): Payload
|
||||
suspend fun getConfig(): Config
|
||||
suspend fun createPage(
|
||||
ctx: Id?,
|
||||
emoji: String?,
|
||||
|
|
|
@ -19,8 +19,6 @@ import com.anytypeio.anytype.core_models.SearchResult
|
|||
|
||||
class BlockRemoteDataStore(private val remote: BlockRemote) : BlockDataStore {
|
||||
|
||||
override suspend fun getConfig() = remote.getConfig()
|
||||
|
||||
override suspend fun openDashboard(
|
||||
contextId: String,
|
||||
id: String
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
package com.anytypeio.anytype.data.auth.repo.config
|
||||
|
||||
class Configuration(private val configurator: Configurator) {
|
||||
fun init() = configurator.configure()
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
package com.anytypeio.anytype.data.auth.repo.config
|
||||
|
||||
import com.anytypeio.anytype.core_models.Config
|
||||
|
||||
|
||||
interface Configurator {
|
||||
fun configure(): Config
|
||||
fun release()
|
||||
}
|
|
@ -1,7 +1,10 @@
|
|||
package com.anytypeio.anytype.data.auth.repo.config
|
||||
|
||||
import com.anytypeio.anytype.domain.config.ConfigStorage
|
||||
import com.anytypeio.anytype.domain.config.Gateway
|
||||
|
||||
class GatewayProvider(private val configurator: Configurator) : Gateway {
|
||||
override fun obtain(): String = configurator.configure().gateway
|
||||
class GatewayProvider(
|
||||
private val configStorage: ConfigStorage
|
||||
) : Gateway {
|
||||
override fun provide(): String = configStorage.get().gateway
|
||||
}
|
|
@ -1,12 +1,16 @@
|
|||
package com.anytypeio.anytype.data
|
||||
|
||||
import com.anytypeio.anytype.core_models.Account
|
||||
import com.anytypeio.anytype.core_models.AccountSetup
|
||||
import com.anytypeio.anytype.core_models.AccountStatus
|
||||
import com.anytypeio.anytype.core_models.FeaturesConfig
|
||||
import com.anytypeio.anytype.core_models.StubAccount
|
||||
import com.anytypeio.anytype.core_models.StubAccountSetup
|
||||
import com.anytypeio.anytype.core_models.StubConfig
|
||||
import com.anytypeio.anytype.core_models.StubFeatureConfig
|
||||
import com.anytypeio.anytype.data.auth.model.AccountEntity
|
||||
import com.anytypeio.anytype.data.auth.model.FeaturesConfigEntity
|
||||
import com.anytypeio.anytype.data.auth.model.WalletEntity
|
||||
import com.anytypeio.anytype.data.auth.repo.*
|
||||
import com.anytypeio.anytype.data.auth.repo.config.Configurator
|
||||
import com.anytypeio.anytype.domain.auth.model.Account
|
||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.Before
|
||||
|
@ -23,11 +27,10 @@ class AuthDataRepositoryTest {
|
|||
@Mock
|
||||
lateinit var authCache: AuthCache
|
||||
|
||||
@Mock
|
||||
lateinit var configurator: Configurator
|
||||
|
||||
lateinit var repo: AuthDataRepository
|
||||
|
||||
val config = StubConfig()
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
MockitoAnnotations.openMocks(this)
|
||||
|
@ -39,8 +42,7 @@ class AuthDataRepositoryTest {
|
|||
remote = AuthRemoteDataStore(
|
||||
authRemote = authRemote
|
||||
)
|
||||
),
|
||||
configurator = configurator
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -51,17 +53,14 @@ class AuthDataRepositoryTest {
|
|||
|
||||
val path = MockDataFactory.randomString()
|
||||
|
||||
val account = AccountEntity(
|
||||
id = id,
|
||||
name = MockDataFactory.randomString(),
|
||||
color = null
|
||||
)
|
||||
val account = StubAccount()
|
||||
|
||||
val config = FeaturesConfigEntity()
|
||||
val features = StubFeatureConfig()
|
||||
|
||||
authRemote.stub {
|
||||
onBlocking { startAccount(id = id, path = path) } doReturn Triple(
|
||||
account, config, AccountStatus.Active
|
||||
onBlocking { startAccount(id = id, path = path) } doReturn StubAccountSetup(
|
||||
account = account,
|
||||
features = features
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -131,12 +130,7 @@ class AuthDataRepositoryTest {
|
|||
@Test
|
||||
fun `should call only cache in order to save account`() = runBlocking {
|
||||
|
||||
val account = Account(
|
||||
id = MockDataFactory.randomUuid(),
|
||||
name = MockDataFactory.randomString(),
|
||||
avatar = null,
|
||||
color = null
|
||||
)
|
||||
val account = StubAccount()
|
||||
|
||||
authCache.stub {
|
||||
onBlocking { saveAccount(any()) } doReturn Unit
|
||||
|
@ -234,8 +228,6 @@ class AuthDataRepositoryTest {
|
|||
verifyNoMoreInteractions(authCache)
|
||||
verify(authRemote, times(1)).logout(false)
|
||||
verifyNoMoreInteractions(authRemote)
|
||||
verify(configurator, times(1)).release()
|
||||
verifyZeroInteractions(configurator)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package com.anytypeio.anytype.data
|
||||
|
||||
import com.anytypeio.anytype.core_models.Account
|
||||
import com.anytypeio.anytype.data.auth.mapper.toDomain
|
||||
import com.anytypeio.anytype.data.auth.mapper.toEntity
|
||||
import com.anytypeio.anytype.data.auth.model.AccountEntity
|
||||
import com.anytypeio.anytype.data.auth.model.WalletEntity
|
||||
import com.anytypeio.anytype.domain.auth.model.Account
|
||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
import org.junit.Test
|
||||
import kotlin.test.assertTrue
|
||||
|
|
|
@ -86,7 +86,7 @@ ext {
|
|||
|
||||
// Anytype
|
||||
|
||||
middleware_version = 'v0.18.3'
|
||||
middleware_version = 'v0.19.0'
|
||||
|
||||
mainApplication = [
|
||||
kotlin: "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.anytypeio.anytype.domain.auth.interactor
|
||||
|
||||
import com.anytypeio.anytype.domain.auth.model.Account
|
||||
import com.anytypeio.anytype.core_models.Account
|
||||
import com.anytypeio.anytype.domain.auth.repo.AuthRepository
|
||||
import com.anytypeio.anytype.domain.base.BaseUseCase
|
||||
import com.anytypeio.anytype.domain.base.Either
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.anytypeio.anytype.domain.auth.interactor
|
||||
|
||||
import com.anytypeio.anytype.domain.auth.model.Account
|
||||
import com.anytypeio.anytype.core_models.Account
|
||||
import com.anytypeio.anytype.domain.auth.repo.AuthRepository
|
||||
import com.anytypeio.anytype.domain.base.BaseUseCase
|
||||
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
package com.anytypeio.anytype.domain.auth.interactor
|
||||
|
||||
import com.anytypeio.anytype.core_models.Event
|
||||
import com.anytypeio.anytype.domain.auth.model.Account
|
||||
import com.anytypeio.anytype.domain.base.BaseUseCase
|
||||
import com.anytypeio.anytype.domain.base.Either
|
||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
|
||||
/** Use case for getting currently selected user account.
|
||||
*/
|
||||
@Deprecated("Incorrect use-case. Will be deleted.")
|
||||
class GetCurrentAccount(
|
||||
private val repo: BlockRepository,
|
||||
private val builder: UrlBuilder
|
||||
) : BaseUseCase<Account, BaseUseCase.None>() {
|
||||
|
||||
override suspend fun run(params: None) = try {
|
||||
Either.Right(execute())
|
||||
} catch (t: Throwable) {
|
||||
Either.Left(t)
|
||||
}
|
||||
|
||||
private suspend fun execute(): Account {
|
||||
val config = repo.getConfig()
|
||||
|
||||
val payload = repo.openProfile(config.profile)
|
||||
|
||||
val event = payload.events.first { event -> event is Event.Command.ShowObject }
|
||||
|
||||
val details = (event as Event.Command.ShowObject).details.details[config.profile]
|
||||
|
||||
val name = details?.name.orEmpty()
|
||||
|
||||
val image = details?.iconImage
|
||||
|
||||
return Account(
|
||||
id = config.profile,
|
||||
name = name,
|
||||
avatar = if (image.isNullOrEmpty()) null else builder.image(image),
|
||||
color = null
|
||||
)
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val MISSING_NAME_ERROR = "Profile name is missing"
|
||||
}
|
||||
}
|
|
@ -7,14 +7,20 @@ import com.anytypeio.anytype.domain.`object`.amend
|
|||
import com.anytypeio.anytype.domain.`object`.unset
|
||||
import com.anytypeio.anytype.domain.base.BaseUseCase
|
||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||
import com.anytypeio.anytype.domain.config.ConfigStorage
|
||||
import com.anytypeio.anytype.domain.search.SubscriptionEventChannel
|
||||
import kotlinx.coroutines.CoroutineDispatcher
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.*
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.emitAll
|
||||
import kotlinx.coroutines.flow.flow
|
||||
import kotlinx.coroutines.flow.flowOn
|
||||
import kotlinx.coroutines.flow.scan
|
||||
|
||||
/** Use case for getting currently selected user account.
|
||||
*/
|
||||
class GetProfile(
|
||||
private val provider: ConfigStorage,
|
||||
private val repo: BlockRepository,
|
||||
private val channel: SubscriptionEventChannel
|
||||
) : BaseUseCase<ObjectWrapper.Basic, GetProfile.Params>() {
|
||||
|
@ -58,7 +64,7 @@ class GetProfile(
|
|||
subscription: Id,
|
||||
keys: List<String>
|
||||
): ObjectWrapper.Basic {
|
||||
val config = repo.getConfig()
|
||||
val config = provider.get()
|
||||
val result = repo.searchObjectsByIdWithSubscription(
|
||||
subscription = subscription,
|
||||
ids = listOf(config.profile),
|
||||
|
@ -72,7 +78,7 @@ class GetProfile(
|
|||
|
||||
@Deprecated("Should not be used. Will be changed.")
|
||||
override suspend fun run(params: Params) = safe {
|
||||
val config = repo.getConfig()
|
||||
val config = provider.get()
|
||||
val result = repo.searchObjectsByIdWithSubscription(
|
||||
subscription = params.subscription,
|
||||
ids = listOf(config.profile),
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.anytypeio.anytype.domain.auth.repo.AuthRepository
|
|||
import com.anytypeio.anytype.domain.base.BaseUseCase
|
||||
import com.anytypeio.anytype.domain.base.Either
|
||||
import com.anytypeio.anytype.domain.config.FeaturesConfigProvider
|
||||
import com.anytypeio.anytype.domain.config.ConfigStorage
|
||||
import com.anytypeio.anytype.domain.device.PathProvider
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
|
@ -15,6 +16,7 @@ class LaunchAccount(
|
|||
private val repository: AuthRepository,
|
||||
private val pathProvider: PathProvider,
|
||||
private val context: CoroutineContext = Dispatchers.IO,
|
||||
private val configStorage: ConfigStorage,
|
||||
private val featuresConfigProvider: FeaturesConfigProvider
|
||||
) : BaseUseCase<String, BaseUseCase.None>(context) {
|
||||
|
||||
|
@ -22,16 +24,16 @@ class LaunchAccount(
|
|||
repository.startAccount(
|
||||
id = repository.getCurrentAccountId(),
|
||||
path = pathProvider.providePath()
|
||||
).let { pair ->
|
||||
val (account, config, status) = pair
|
||||
repository.updateAccount(account)
|
||||
).let { setup ->
|
||||
repository.updateAccount(setup.account)
|
||||
featuresConfigProvider.set(
|
||||
enableDataView = config.enableDataView ?: false,
|
||||
enableDebug = config.enableDebug ?: false,
|
||||
enableChannelSwitch = config.enableChannelSwitch ?: false,
|
||||
enableSpaces = config.enableSpaces ?: false
|
||||
enableDataView = setup.features.enableDataView ?: false,
|
||||
enableDebug = setup.features.enableDebug ?: false,
|
||||
enableChannelSwitch = setup.features.enableChannelSwitch ?: false,
|
||||
enableSpaces = setup.features.enableSpaces ?: false
|
||||
)
|
||||
Either.Right(account.id)
|
||||
configStorage.set(config = setup.config)
|
||||
Either.Right(setup.account.id)
|
||||
}
|
||||
} catch (e: Throwable) {
|
||||
Either.Left(e)
|
||||
|
|
|
@ -2,16 +2,19 @@ package com.anytypeio.anytype.domain.auth.interactor
|
|||
|
||||
import com.anytypeio.anytype.domain.auth.repo.AuthRepository
|
||||
import com.anytypeio.anytype.domain.base.Interactor
|
||||
import com.anytypeio.anytype.domain.config.ConfigStorage
|
||||
|
||||
/**
|
||||
* Use case for logging out.
|
||||
*/
|
||||
class Logout(
|
||||
private val repo: AuthRepository
|
||||
private val repo: AuthRepository,
|
||||
private val provider: ConfigStorage
|
||||
) : Interactor<Logout.Params>() {
|
||||
|
||||
override suspend fun run(params: Params) {
|
||||
repo.logout(params.clearLocalRepositoryData)
|
||||
provider.clear()
|
||||
}
|
||||
|
||||
class Params(
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.anytypeio.anytype.domain.auth.interactor
|
||||
|
||||
import com.anytypeio.anytype.domain.auth.model.Account
|
||||
import com.anytypeio.anytype.core_models.Account
|
||||
import com.anytypeio.anytype.domain.auth.repo.AuthRepository
|
||||
import com.anytypeio.anytype.domain.base.FlowUseCase
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.anytypeio.anytype.core_models.AccountStatus
|
|||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.domain.auth.repo.AuthRepository
|
||||
import com.anytypeio.anytype.domain.base.BaseUseCase
|
||||
import com.anytypeio.anytype.domain.config.ConfigStorage
|
||||
import com.anytypeio.anytype.domain.config.FeaturesConfigProvider
|
||||
|
||||
/**
|
||||
|
@ -11,25 +12,27 @@ import com.anytypeio.anytype.domain.config.FeaturesConfigProvider
|
|||
*/
|
||||
class StartAccount(
|
||||
private val repository: AuthRepository,
|
||||
private val configStorage: ConfigStorage,
|
||||
private val featuresConfigProvider: FeaturesConfigProvider
|
||||
) : BaseUseCase<Pair<Id, AccountStatus>, StartAccount.Params>() {
|
||||
) : BaseUseCase<StartAccountResult, StartAccount.Params>() {
|
||||
|
||||
override suspend fun run(params: Params) = safe {
|
||||
val (account, config, status) = repository.startAccount(
|
||||
val setup = repository.startAccount(
|
||||
id = params.id,
|
||||
path = params.path
|
||||
)
|
||||
with(repository) {
|
||||
saveAccount(account)
|
||||
setCurrentAccount(account.id)
|
||||
saveAccount(setup.account)
|
||||
setCurrentAccount(setup.account.id)
|
||||
featuresConfigProvider.set(
|
||||
enableDataView = config.enableDataView ?: false,
|
||||
enableDebug = config.enableDebug ?: false,
|
||||
enableChannelSwitch = config.enableChannelSwitch ?: false,
|
||||
enableSpaces = config.enableSpaces ?: false
|
||||
enableDataView = setup.features.enableDataView ?: false,
|
||||
enableDebug = setup.features.enableDebug ?: false,
|
||||
enableChannelSwitch = setup.features.enableChannelSwitch ?: false,
|
||||
enableSpaces = setup.features.enableSpaces ?: false
|
||||
)
|
||||
configStorage.set(config = setup.config)
|
||||
}
|
||||
Pair(account.id, status)
|
||||
StartAccountResult(setup.account.id, setup.status)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -40,4 +43,6 @@ class StartAccount(
|
|||
val id: String,
|
||||
val path: String
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
typealias StartAccountResult = Pair<Id, AccountStatus>
|
|
@ -1,9 +1,10 @@
|
|||
package com.anytypeio.anytype.domain.auth.repo
|
||||
|
||||
import com.anytypeio.anytype.core_models.Account
|
||||
import com.anytypeio.anytype.core_models.AccountSetup
|
||||
import com.anytypeio.anytype.core_models.AccountStatus
|
||||
import com.anytypeio.anytype.core_models.FeaturesConfig
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.domain.auth.model.Account
|
||||
import com.anytypeio.anytype.domain.auth.model.Wallet
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
|
@ -14,7 +15,7 @@ interface AuthRepository {
|
|||
* @param id user account id
|
||||
* @param path wallet repository path
|
||||
*/
|
||||
suspend fun startAccount(id: String, path: String): Triple<Account, FeaturesConfig, AccountStatus>
|
||||
suspend fun startAccount(id: String, path: String): AccountSetup
|
||||
|
||||
suspend fun createAccount(name: String, avatarPath: String?, invitationCode: String): Account
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.anytypeio.anytype.domain.block.interactor.sets
|
|||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.Payload
|
||||
import com.anytypeio.anytype.core_models.Position
|
||||
import com.anytypeio.anytype.core_models.Url
|
||||
import com.anytypeio.anytype.domain.base.BaseUseCase
|
||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||
|
||||
|
@ -33,6 +32,7 @@ class CreateObjectSet(
|
|||
*/
|
||||
data class Response(
|
||||
val target: Id,
|
||||
@Deprecated("legacy param")
|
||||
val block: Id?,
|
||||
val payload: Payload
|
||||
)
|
||||
|
|
|
@ -85,8 +85,6 @@ interface BlockRepository {
|
|||
|
||||
suspend fun setRelationKey(command: Command.SetRelationKey): Payload
|
||||
|
||||
suspend fun getConfig(): Config
|
||||
|
||||
suspend fun createPage(
|
||||
ctx: Id?,
|
||||
emoji: String?,
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package com.anytypeio.anytype.domain.config
|
||||
|
||||
import com.anytypeio.anytype.core_models.Config
|
||||
|
||||
interface ConfigStorage {
|
||||
fun get(): Config
|
||||
fun set(config: Config)
|
||||
fun clear()
|
||||
class CacheStorage : ConfigStorage {
|
||||
private var instance: Config? = null
|
||||
override fun get(): Config {
|
||||
return instance ?: throw IllegalStateException("Config is not initialized")
|
||||
}
|
||||
|
||||
override fun set(config: Config) {
|
||||
instance = config
|
||||
}
|
||||
|
||||
override fun clear() {
|
||||
instance = null
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
package com.anytypeio.anytype.domain.config
|
||||
|
||||
interface Gateway {
|
||||
fun obtain(): String
|
||||
fun provide(): String
|
||||
}
|
|
@ -3,14 +3,13 @@ package com.anytypeio.anytype.domain.config
|
|||
import com.anytypeio.anytype.core_models.Config
|
||||
import com.anytypeio.anytype.domain.base.BaseUseCase
|
||||
import com.anytypeio.anytype.domain.base.Either
|
||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||
|
||||
class GetConfig(
|
||||
private val repo: BlockRepository
|
||||
private val provider: ConfigStorage
|
||||
) : BaseUseCase<Config, Unit>() {
|
||||
|
||||
override suspend fun run(params: Unit) = try {
|
||||
repo.getConfig().let {
|
||||
provider.get().let {
|
||||
Either.Right(it)
|
||||
}
|
||||
} catch (t: Throwable) {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package com.anytypeio.anytype.domain.dashboard.interactor
|
||||
|
||||
import com.anytypeio.anytype.domain.base.BaseUseCase
|
||||
import com.anytypeio.anytype.domain.base.Either
|
||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||
import com.anytypeio.anytype.domain.config.ConfigStorage
|
||||
import com.anytypeio.anytype.domain.config.MainConfig
|
||||
|
||||
/**
|
||||
|
@ -11,23 +11,17 @@ import com.anytypeio.anytype.domain.config.MainConfig
|
|||
* @property repo
|
||||
*/
|
||||
class CloseDashboard(
|
||||
private val repo: BlockRepository
|
||||
private val repo: BlockRepository,
|
||||
private val provider: ConfigStorage
|
||||
) : BaseUseCase<Unit, CloseDashboard.Param>() {
|
||||
|
||||
override suspend fun run(params: Param) = try {
|
||||
if (params.id == MainConfig.HOME_DASHBOARD_ID)
|
||||
repo.getConfig().let { config ->
|
||||
repo.closeDashboard(id = config.home)
|
||||
}.let {
|
||||
Either.Right(it)
|
||||
}
|
||||
else
|
||||
repo.closeDashboard(id = params.id).let {
|
||||
Either.Right(it)
|
||||
}
|
||||
|
||||
} catch (t: Throwable) {
|
||||
Either.Left(t)
|
||||
override suspend fun run(params: Param) = safe {
|
||||
if (params.id == MainConfig.HOME_DASHBOARD_ID) {
|
||||
val config = provider.get()
|
||||
repo.closeDashboard(id = config.home)
|
||||
} else {
|
||||
repo.closeDashboard(id = params.id)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package com.anytypeio.anytype.domain.dashboard.interactor
|
||||
|
||||
import com.anytypeio.anytype.core_models.Payload
|
||||
import com.anytypeio.anytype.domain.auth.repo.AuthRepository
|
||||
import com.anytypeio.anytype.domain.base.BaseUseCase
|
||||
import com.anytypeio.anytype.domain.base.Either
|
||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||
import com.anytypeio.anytype.core_models.Payload
|
||||
import com.anytypeio.anytype.domain.auth.repo.AuthRepository
|
||||
import com.anytypeio.anytype.domain.config.ConfigStorage
|
||||
|
||||
/**
|
||||
* Use-case for opening a dashboard by sending a special request.
|
||||
|
@ -14,6 +15,7 @@ import com.anytypeio.anytype.domain.auth.repo.AuthRepository
|
|||
class OpenDashboard(
|
||||
private val repo: BlockRepository,
|
||||
private val auth: AuthRepository,
|
||||
private val provider: ConfigStorage
|
||||
) : BaseUseCase<Payload, OpenDashboard.Param?>() {
|
||||
|
||||
override suspend fun run(params: Param?) = try {
|
||||
|
@ -27,7 +29,7 @@ class OpenDashboard(
|
|||
}
|
||||
}
|
||||
else {
|
||||
repo.getConfig().let { config ->
|
||||
provider.get().let { config ->
|
||||
repo.openDashboard(
|
||||
contextId = config.home,
|
||||
id = config.home
|
||||
|
|
|
@ -12,27 +12,27 @@ class UrlBuilder(val gateway: Gateway) {
|
|||
/**
|
||||
* Builds image url for given [hash]
|
||||
*/
|
||||
fun image(hash: String?): Url = gateway.obtain() + IMAGE_PATH + hash + DEFAULT_WIDTH_PARAM
|
||||
fun image(hash: String?): Url = gateway.provide() + IMAGE_PATH + hash + DEFAULT_WIDTH_PARAM
|
||||
|
||||
/**
|
||||
* Builds original image url for given [hash]
|
||||
*/
|
||||
fun original(hash: String?): Url = gateway.obtain() + IMAGE_PATH + hash
|
||||
fun original(hash: String?): Url = gateway.provide() + IMAGE_PATH + hash
|
||||
|
||||
/**
|
||||
* Builds small image url for given [hash]
|
||||
*/
|
||||
fun thumbnail(hash: String): Url = gateway.obtain() + IMAGE_PATH + hash + THUMBNAIL_WIDTH_PARAM
|
||||
fun thumbnail(hash: String): Url = gateway.provide() + IMAGE_PATH + hash + THUMBNAIL_WIDTH_PARAM
|
||||
|
||||
/**
|
||||
* Builds file url for given [hash]
|
||||
*/
|
||||
fun file(hash: String?): Url = gateway.obtain() + FILE_PATH + hash
|
||||
fun file(hash: String?): Url = gateway.provide() + FILE_PATH + hash
|
||||
|
||||
/**
|
||||
* Builds video url for given [hash]
|
||||
*/
|
||||
fun video(hash: String?): Url = gateway.obtain() + FILE_PATH + hash
|
||||
fun video(hash: String?): Url = gateway.provide() + FILE_PATH + hash
|
||||
|
||||
companion object {
|
||||
const val IMAGE_PATH = "/image/"
|
||||
|
|
|
@ -1,13 +1,17 @@
|
|||
package com.anytypeio.anytype.domain.auth
|
||||
|
||||
import com.anytypeio.anytype.core_models.Account
|
||||
import com.anytypeio.anytype.core_models.CoroutineTestRule
|
||||
import com.anytypeio.anytype.domain.auth.interactor.CheckAuthorizationStatus
|
||||
import com.anytypeio.anytype.domain.auth.model.Account
|
||||
import com.anytypeio.anytype.domain.auth.model.AuthStatus
|
||||
import com.anytypeio.anytype.domain.auth.repo.AuthRepository
|
||||
import com.anytypeio.anytype.domain.base.Either
|
||||
import com.anytypeio.anytype.core_models.CoroutineTestRule
|
||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
import com.nhaarman.mockitokotlin2.*
|
||||
import com.nhaarman.mockitokotlin2.doReturn
|
||||
import com.nhaarman.mockitokotlin2.stub
|
||||
import com.nhaarman.mockitokotlin2.times
|
||||
import com.nhaarman.mockitokotlin2.verify
|
||||
import com.nhaarman.mockitokotlin2.verifyNoMoreInteractions
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.Before
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
package com.anytypeio.anytype.domain.auth
|
||||
|
||||
import com.anytypeio.anytype.domain.auth.interactor.CreateAccount
|
||||
import com.anytypeio.anytype.domain.auth.model.Account
|
||||
import com.anytypeio.anytype.domain.auth.repo.AuthRepository
|
||||
import com.anytypeio.anytype.core_models.Account
|
||||
import com.anytypeio.anytype.core_models.CoroutineTestRule
|
||||
import com.anytypeio.anytype.domain.auth.interactor.CreateAccount
|
||||
import com.anytypeio.anytype.domain.auth.repo.AuthRepository
|
||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
import com.nhaarman.mockitokotlin2.*
|
||||
import com.nhaarman.mockitokotlin2.doReturn
|
||||
import com.nhaarman.mockitokotlin2.stub
|
||||
import com.nhaarman.mockitokotlin2.times
|
||||
import com.nhaarman.mockitokotlin2.verify
|
||||
import com.nhaarman.mockitokotlin2.verifyNoMoreInteractions
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.Before
|
||||
|
|
|
@ -1,181 +0,0 @@
|
|||
package com.anytypeio.anytype.domain.auth
|
||||
|
||||
import com.anytypeio.anytype.domain.auth.interactor.GetCurrentAccount
|
||||
import com.anytypeio.anytype.domain.auth.model.Account
|
||||
import com.anytypeio.anytype.domain.base.BaseUseCase
|
||||
import com.anytypeio.anytype.domain.base.Either
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||
import com.anytypeio.anytype.core_models.Config
|
||||
import com.anytypeio.anytype.domain.config.Gateway
|
||||
import com.anytypeio.anytype.core_models.Event
|
||||
import com.anytypeio.anytype.core_models.Payload
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
import com.nhaarman.mockitokotlin2.doReturn
|
||||
import com.nhaarman.mockitokotlin2.stub
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.mockito.Mock
|
||||
import org.mockito.MockitoAnnotations
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
class GetCurrentAccountTest {
|
||||
|
||||
@Mock lateinit var repo: BlockRepository
|
||||
|
||||
@Mock
|
||||
lateinit var gateway: Gateway
|
||||
|
||||
lateinit var getCurrentAccount: GetCurrentAccount
|
||||
|
||||
private val config = Config(
|
||||
home = MockDataFactory.randomUuid(),
|
||||
profile = MockDataFactory.randomUuid(),
|
||||
gateway = MockDataFactory.randomString()
|
||||
)
|
||||
|
||||
private val builder: UrlBuilder get() = UrlBuilder(gateway)
|
||||
|
||||
@Before
|
||||
fun before() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
getCurrentAccount = GetCurrentAccount(
|
||||
repo = repo,
|
||||
builder = builder
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should return error if payload contains no event`() {
|
||||
|
||||
val context = MockDataFactory.randomUuid()
|
||||
|
||||
stubGetConfig()
|
||||
|
||||
stubOpenProfile(context = context)
|
||||
|
||||
val result = runBlocking {
|
||||
getCurrentAccount.invoke(BaseUseCase.None)
|
||||
}
|
||||
|
||||
assertTrue { result is Either.Left }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should create account object without avatar from data contained in details`() {
|
||||
|
||||
val context = MockDataFactory.randomUuid()
|
||||
|
||||
val name = MockDataFactory.randomString()
|
||||
|
||||
stubGetConfig()
|
||||
|
||||
stubOpenProfile(
|
||||
context = context,
|
||||
events = listOf(
|
||||
Event.Command.ShowObject(
|
||||
context = context,
|
||||
details = Block.Details(
|
||||
details = mapOf(
|
||||
config.profile to Block.Fields(
|
||||
mapOf(
|
||||
"name" to name
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
blocks = emptyList(),
|
||||
root = config.profile
|
||||
)
|
||||
|
||||
)
|
||||
)
|
||||
|
||||
val result = runBlocking {
|
||||
getCurrentAccount.invoke(BaseUseCase.None)
|
||||
}
|
||||
|
||||
val expected = Account(
|
||||
id = config.profile,
|
||||
name = name,
|
||||
avatar = null,
|
||||
color = null
|
||||
)
|
||||
|
||||
assertEquals(
|
||||
expected = Either.Right(expected),
|
||||
actual = result
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should create account object with avatar from data contained in details`() {
|
||||
|
||||
val context = MockDataFactory.randomUuid()
|
||||
|
||||
val name = MockDataFactory.randomString()
|
||||
|
||||
val avatar = MockDataFactory.randomString()
|
||||
|
||||
stubGetConfig()
|
||||
|
||||
stubOpenProfile(
|
||||
context = context,
|
||||
events = listOf(
|
||||
Event.Command.ShowObject(
|
||||
context = context,
|
||||
details = Block.Details(
|
||||
details = mapOf(
|
||||
config.profile to Block.Fields(
|
||||
mapOf(
|
||||
"name" to name,
|
||||
"iconImage" to avatar
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
blocks = emptyList(),
|
||||
root = config.profile
|
||||
)
|
||||
|
||||
)
|
||||
)
|
||||
|
||||
val result = runBlocking {
|
||||
getCurrentAccount.invoke(BaseUseCase.None)
|
||||
}
|
||||
|
||||
val expected = Account(
|
||||
id = config.profile,
|
||||
name = name,
|
||||
avatar = builder.image(avatar),
|
||||
color = null
|
||||
)
|
||||
|
||||
assertEquals(
|
||||
expected = Either.Right(expected),
|
||||
actual = result
|
||||
)
|
||||
}
|
||||
|
||||
private fun stubOpenProfile(
|
||||
context: String,
|
||||
events: List<Event> = emptyList()
|
||||
) {
|
||||
repo.stub {
|
||||
onBlocking { openProfile(config.profile) } doReturn Payload(
|
||||
context = context,
|
||||
events = events
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun stubGetConfig() {
|
||||
repo.stub {
|
||||
onBlocking { getConfig() } doReturn config
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
package com.anytypeio.anytype.domain.auth
|
||||
|
||||
import com.anytypeio.anytype.domain.auth.interactor.ObserveAccounts
|
||||
import com.anytypeio.anytype.domain.auth.model.Account
|
||||
import com.anytypeio.anytype.domain.auth.repo.AuthRepository
|
||||
import com.anytypeio.anytype.core_models.Account
|
||||
import com.anytypeio.anytype.core_models.CoroutineTestRule
|
||||
import com.anytypeio.anytype.domain.auth.interactor.ObserveAccounts
|
||||
import com.anytypeio.anytype.domain.auth.repo.AuthRepository
|
||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
import com.nhaarman.mockitokotlin2.doReturn
|
||||
import com.nhaarman.mockitokotlin2.stub
|
||||
|
|
|
@ -1,15 +1,22 @@
|
|||
package com.anytypeio.anytype.domain.auth
|
||||
|
||||
import com.anytypeio.anytype.core_models.Account
|
||||
import com.anytypeio.anytype.core_models.AccountSetup
|
||||
import com.anytypeio.anytype.core_models.AccountStatus
|
||||
import com.anytypeio.anytype.core_models.Config
|
||||
import com.anytypeio.anytype.core_models.CoroutineTestRule
|
||||
import com.anytypeio.anytype.core_models.FeaturesConfig
|
||||
import com.anytypeio.anytype.domain.auth.interactor.StartAccount
|
||||
import com.anytypeio.anytype.domain.auth.model.Account
|
||||
import com.anytypeio.anytype.domain.auth.repo.AuthRepository
|
||||
import com.anytypeio.anytype.domain.base.Either
|
||||
import com.anytypeio.anytype.domain.config.ConfigStorage
|
||||
import com.anytypeio.anytype.domain.config.FeaturesConfigProvider
|
||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
import com.nhaarman.mockitokotlin2.*
|
||||
import com.nhaarman.mockitokotlin2.doReturn
|
||||
import com.nhaarman.mockitokotlin2.stub
|
||||
import com.nhaarman.mockitokotlin2.times
|
||||
import com.nhaarman.mockitokotlin2.verify
|
||||
import com.nhaarman.mockitokotlin2.verifyNoMoreInteractions
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.Before
|
||||
|
@ -31,12 +38,25 @@ class StartAccountTest {
|
|||
@Mock
|
||||
lateinit var featuresConfigProvider: FeaturesConfigProvider
|
||||
|
||||
@Mock
|
||||
lateinit var configStorage: ConfigStorage
|
||||
|
||||
lateinit var startAccount: StartAccount
|
||||
|
||||
val config = Config(
|
||||
home = MockDataFactory.randomUuid(),
|
||||
gateway = MockDataFactory.randomUuid(),
|
||||
profile = MockDataFactory.randomUuid()
|
||||
)
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
startAccount = StartAccount(repo, featuresConfigProvider)
|
||||
startAccount = StartAccount(
|
||||
repository = repo,
|
||||
configStorage = configStorage,
|
||||
featuresConfigProvider = featuresConfigProvider
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -57,7 +77,7 @@ class StartAccountTest {
|
|||
color = null
|
||||
)
|
||||
|
||||
val config = FeaturesConfig(
|
||||
val featuresConfig = FeaturesConfig(
|
||||
enableDataView = false,
|
||||
enableDebug = false,
|
||||
enableChannelSwitch = false
|
||||
|
@ -69,7 +89,12 @@ class StartAccountTest {
|
|||
id = id,
|
||||
path = path
|
||||
)
|
||||
} doReturn Triple(account, config, AccountStatus.Active)
|
||||
} doReturn AccountSetup(
|
||||
account = account,
|
||||
features = featuresConfig,
|
||||
status = AccountStatus.Active,
|
||||
config = config
|
||||
)
|
||||
}
|
||||
|
||||
startAccount.run(params)
|
||||
|
@ -104,7 +129,7 @@ class StartAccountTest {
|
|||
color = null
|
||||
)
|
||||
|
||||
val config = FeaturesConfig(
|
||||
val featuresConfig = FeaturesConfig(
|
||||
enableDataView = false,
|
||||
enableDebug = false,
|
||||
enableChannelSwitch = false
|
||||
|
@ -116,7 +141,12 @@ class StartAccountTest {
|
|||
id = id,
|
||||
path = path
|
||||
)
|
||||
} doReturn Triple(account, config, AccountStatus.Active)
|
||||
} doReturn AccountSetup(
|
||||
account = account,
|
||||
features = featuresConfig,
|
||||
status = AccountStatus.Active,
|
||||
config = config
|
||||
)
|
||||
}
|
||||
|
||||
val result = startAccount.run(params)
|
||||
|
@ -142,7 +172,7 @@ class StartAccountTest {
|
|||
color = null
|
||||
)
|
||||
|
||||
val config = FeaturesConfig(
|
||||
val featuresConfig = FeaturesConfig(
|
||||
enableDataView = null,
|
||||
enableDebug = null,
|
||||
enableChannelSwitch = null
|
||||
|
@ -154,7 +184,12 @@ class StartAccountTest {
|
|||
id = id,
|
||||
path = path
|
||||
)
|
||||
} doReturn Triple(account, config, AccountStatus.Active)
|
||||
} doReturn AccountSetup(
|
||||
account = account,
|
||||
features = featuresConfig,
|
||||
status = AccountStatus.Active,
|
||||
config = config
|
||||
)
|
||||
}
|
||||
|
||||
val result = startAccount.run(params)
|
||||
|
@ -187,7 +222,7 @@ class StartAccountTest {
|
|||
color = null
|
||||
)
|
||||
|
||||
val config = FeaturesConfig(
|
||||
val featuresConfig = FeaturesConfig(
|
||||
enableDataView = true,
|
||||
enableDebug = false,
|
||||
enableChannelSwitch = true
|
||||
|
@ -199,7 +234,12 @@ class StartAccountTest {
|
|||
id = id,
|
||||
path = path
|
||||
)
|
||||
} doReturn Triple(account, config, AccountStatus.Active)
|
||||
} doReturn AccountSetup(
|
||||
account = account,
|
||||
features = featuresConfig,
|
||||
status = AccountStatus.Active,
|
||||
config = config
|
||||
)
|
||||
}
|
||||
|
||||
val result = startAccount.run(params)
|
||||
|
|
|
@ -4,6 +4,7 @@ import app.cash.turbine.test
|
|||
import com.anytypeio.anytype.core_models.*
|
||||
import com.anytypeio.anytype.domain.auth.interactor.GetProfile
|
||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||
import com.anytypeio.anytype.domain.config.ConfigStorage
|
||||
import com.anytypeio.anytype.domain.search.SubscriptionEventChannel
|
||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
import com.nhaarman.mockitokotlin2.doReturn
|
||||
|
@ -31,6 +32,9 @@ class GetProfileTest {
|
|||
@Mock
|
||||
lateinit var channel: SubscriptionEventChannel
|
||||
|
||||
@Mock
|
||||
lateinit var configStorage: ConfigStorage
|
||||
|
||||
private lateinit var usecase: GetProfile
|
||||
|
||||
val config = Config(
|
||||
|
@ -44,7 +48,8 @@ class GetProfileTest {
|
|||
MockitoAnnotations.initMocks(this)
|
||||
usecase = GetProfile(
|
||||
repo = repo,
|
||||
channel = channel
|
||||
channel = channel,
|
||||
provider = configStorage
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -60,8 +65,8 @@ class GetProfileTest {
|
|||
)
|
||||
)
|
||||
|
||||
repo.stub {
|
||||
onBlocking { getConfig() } doReturn config
|
||||
configStorage.stub {
|
||||
onBlocking { get() } doReturn config
|
||||
}
|
||||
|
||||
channel.stub {
|
||||
|
@ -116,8 +121,8 @@ class GetProfileTest {
|
|||
)
|
||||
)
|
||||
|
||||
repo.stub {
|
||||
onBlocking { getConfig() } doReturn config
|
||||
configStorage.stub {
|
||||
onBlocking { get() } doReturn config
|
||||
}
|
||||
|
||||
channel.stub {
|
||||
|
@ -185,8 +190,8 @@ class GetProfileTest {
|
|||
)
|
||||
)
|
||||
|
||||
repo.stub {
|
||||
onBlocking { getConfig() } doReturn config
|
||||
configStorage.stub {
|
||||
onBlocking { get() } doReturn config
|
||||
}
|
||||
|
||||
channel.stub {
|
||||
|
@ -265,8 +270,8 @@ class GetProfileTest {
|
|||
)
|
||||
)
|
||||
|
||||
repo.stub {
|
||||
onBlocking { getConfig() } doReturn config
|
||||
configStorage.stub {
|
||||
onBlocking { get() } doReturn config
|
||||
}
|
||||
|
||||
channel.stub {
|
||||
|
|
|
@ -4,11 +4,13 @@ import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
|||
import com.anytypeio.anytype.core_models.CoroutineTestRule
|
||||
import com.anytypeio.anytype.core_models.Config
|
||||
import com.anytypeio.anytype.domain.auth.repo.AuthRepository
|
||||
import com.anytypeio.anytype.domain.config.ConfigStorage
|
||||
import com.anytypeio.anytype.domain.dashboard.interactor.OpenDashboard
|
||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
import com.nhaarman.mockitokotlin2.*
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.test.runBlockingTest
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
|
@ -27,17 +29,23 @@ class OpenDashboardTest {
|
|||
@Mock
|
||||
lateinit var auth: AuthRepository
|
||||
|
||||
@Mock
|
||||
lateinit var configStorage: ConfigStorage
|
||||
|
||||
private lateinit var usecase: OpenDashboard
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
usecase = OpenDashboard(repo = repo, auth = auth)
|
||||
usecase = OpenDashboard(
|
||||
repo = repo,
|
||||
auth = auth,
|
||||
provider = configStorage
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should open a dashboard based on the given params if these are present`() =
|
||||
runBlockingTest {
|
||||
fun `should open a dashboard based on the given params if these are present`() = runTest {
|
||||
|
||||
val params = OpenDashboard.Param(
|
||||
contextId = MockDataFactory.randomUuid(),
|
||||
|
@ -46,7 +54,7 @@ class OpenDashboardTest {
|
|||
|
||||
usecase.run(params)
|
||||
|
||||
verify(repo, never()).getConfig()
|
||||
verify(configStorage, never()).get()
|
||||
verify(repo, times(1)).openDashboard(contextId = params.contextId, id = params.id)
|
||||
verifyNoMoreInteractions(repo)
|
||||
}
|
||||
|
@ -60,13 +68,13 @@ class OpenDashboardTest {
|
|||
profile = MockDataFactory.randomUuid()
|
||||
)
|
||||
|
||||
repo.stub {
|
||||
onBlocking { getConfig() } doReturn config
|
||||
configStorage.stub {
|
||||
onBlocking { get() } doReturn config
|
||||
}
|
||||
|
||||
usecase.run(null)
|
||||
|
||||
verify(repo, times(1)).getConfig()
|
||||
verify(configStorage, times(1)).get()
|
||||
verify(repo, times(1)).openDashboard(
|
||||
contextId = config.home,
|
||||
id = config.home
|
||||
|
|
|
@ -25,7 +25,7 @@ class UrlBuilderTest {
|
|||
val hash = "image001"
|
||||
|
||||
val expected =
|
||||
gateway.obtain() + UrlBuilder.IMAGE_PATH + hash + UrlBuilder.DEFAULT_WIDTH_PARAM
|
||||
gateway.provide() + UrlBuilder.IMAGE_PATH + hash + UrlBuilder.DEFAULT_WIDTH_PARAM
|
||||
val actual = urlBuilder.image(hash)
|
||||
assertEquals(expected, actual)
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ class UrlBuilderTest {
|
|||
val hash = null
|
||||
|
||||
val expected =
|
||||
gateway.obtain() + UrlBuilder.IMAGE_PATH + null + UrlBuilder.DEFAULT_WIDTH_PARAM
|
||||
gateway.provide() + UrlBuilder.IMAGE_PATH + null + UrlBuilder.DEFAULT_WIDTH_PARAM
|
||||
val actual = urlBuilder.image(hash)
|
||||
assertEquals(expected, actual)
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ class UrlBuilderTest {
|
|||
fun `should return url without hash when image hash is empty`() {
|
||||
val hash = ""
|
||||
|
||||
val expected = gateway.obtain() + UrlBuilder.IMAGE_PATH + UrlBuilder.DEFAULT_WIDTH_PARAM
|
||||
val expected = gateway.provide() + UrlBuilder.IMAGE_PATH + UrlBuilder.DEFAULT_WIDTH_PARAM
|
||||
val actual = urlBuilder.image(hash)
|
||||
assertEquals(expected, actual)
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ class UrlBuilderTest {
|
|||
fun `should return file url`() {
|
||||
val hash = "file001"
|
||||
|
||||
val expected = gateway.obtain() + UrlBuilder.FILE_PATH + hash
|
||||
val expected = gateway.provide() + UrlBuilder.FILE_PATH + hash
|
||||
val actual = urlBuilder.file(hash)
|
||||
assertEquals(expected, actual)
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ class UrlBuilderTest {
|
|||
fun `should return url with null at the end when file hash is null`() {
|
||||
val hash = null
|
||||
|
||||
val expected = gateway.obtain() + UrlBuilder.FILE_PATH + null
|
||||
val expected = gateway.provide() + UrlBuilder.FILE_PATH + null
|
||||
val actual = urlBuilder.file(hash)
|
||||
assertEquals(expected, actual)
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ class UrlBuilderTest {
|
|||
fun `should return url without hash when file hash is empty`() {
|
||||
val hash = ""
|
||||
|
||||
val expected = gateway.obtain() + UrlBuilder.FILE_PATH
|
||||
val expected = gateway.provide() + UrlBuilder.FILE_PATH
|
||||
val actual = urlBuilder.file(hash)
|
||||
assertEquals(expected, actual)
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ class UrlBuilderTest {
|
|||
fun `should return video url`() {
|
||||
val hash = "video001"
|
||||
|
||||
val expected = gateway.obtain() + UrlBuilder.FILE_PATH + hash
|
||||
val expected = gateway.provide() + UrlBuilder.FILE_PATH + hash
|
||||
val actual = urlBuilder.video(hash)
|
||||
assertEquals(expected, actual)
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ class UrlBuilderTest {
|
|||
fun `should return url with null at the end when video hash is null`() {
|
||||
val hash = null
|
||||
|
||||
val expected = gateway.obtain() + UrlBuilder.FILE_PATH + null
|
||||
val expected = gateway.provide() + UrlBuilder.FILE_PATH + null
|
||||
val actual = urlBuilder.video(hash)
|
||||
assertEquals(expected, actual)
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ class UrlBuilderTest {
|
|||
fun `should return url without hash when video hash is empty`() {
|
||||
val hash = ""
|
||||
|
||||
val expected = gateway.obtain() + UrlBuilder.FILE_PATH
|
||||
val expected = gateway.provide() + UrlBuilder.FILE_PATH
|
||||
val actual = urlBuilder.video(hash)
|
||||
assertEquals(expected, actual)
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.anytypeio.anytype.middleware
|
||||
|
||||
import anytype.Rpc
|
||||
import anytype.Rpc.UnsplashSearch
|
||||
import anytype.Rpc.Unsplash.Download
|
||||
import anytype.Rpc.Unsplash.Search
|
||||
import com.anytypeio.anytype.core_models.Hash
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.UnsplashImage
|
||||
|
@ -16,7 +16,7 @@ class UnsplashMiddleware(
|
|||
) : UnsplashRemote {
|
||||
|
||||
override fun search(query: String, limit: Int): List<UnsplashImage> {
|
||||
val request = UnsplashSearch.Request(
|
||||
val request = Search.Request(
|
||||
query = query,
|
||||
limit = limit
|
||||
).also { it.logRequest() }
|
||||
|
@ -25,7 +25,7 @@ class UnsplashMiddleware(
|
|||
}
|
||||
|
||||
override fun download(id: Id): Hash {
|
||||
val request = Rpc.UnsplashDownload.Request(pictureId = id).also { it.logRequest() }
|
||||
val request = Download.Request(pictureId = id).also { it.logRequest() }
|
||||
val response = service.unsplashDownload(request = request).also { it.logResponse() }
|
||||
return response.hash
|
||||
}
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
package com.anytypeio.anytype.middleware.auth
|
||||
|
||||
import anytype.Rpc
|
||||
import com.anytypeio.anytype.core_models.Account
|
||||
import com.anytypeio.anytype.core_models.AccountSetup
|
||||
import com.anytypeio.anytype.core_models.Config
|
||||
import com.anytypeio.anytype.core_models.FeaturesConfig
|
||||
import com.anytypeio.anytype.middleware.mappers.core
|
||||
|
||||
fun Rpc.Account.Select.Response.core(): AccountSetup {
|
||||
val acc = account
|
||||
checkNotNull(acc) { "Account can't be empty" }
|
||||
val configuration = acc.config
|
||||
checkNotNull(configuration) { "Config can't be empty" }
|
||||
val info = acc.info
|
||||
checkNotNull(info) { "Info can't be empty" }
|
||||
val status = acc.status
|
||||
checkNotNull(status) { "Status can't be empty" }
|
||||
|
||||
return AccountSetup(
|
||||
account = Account(
|
||||
id = acc.id,
|
||||
name = acc.name,
|
||||
color = acc.avatar?.color,
|
||||
avatar = null
|
||||
),
|
||||
features = FeaturesConfig(
|
||||
enableDataView = configuration.enableDataview,
|
||||
enableDebug = configuration.enableDebug,
|
||||
enableChannelSwitch = configuration.enableReleaseChannelSwitch,
|
||||
enableSpaces = configuration.enableSpaces
|
||||
),
|
||||
config = Config(
|
||||
home = info.homeObjectId,
|
||||
profile = info.profileObjectId,
|
||||
gateway = info.gatewayUrl
|
||||
),
|
||||
status = status.core()
|
||||
)
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package com.anytypeio.anytype.middleware.auth
|
||||
|
||||
import com.anytypeio.anytype.core_models.AccountSetup
|
||||
import com.anytypeio.anytype.core_models.AccountStatus
|
||||
import com.anytypeio.anytype.data.auth.model.AccountEntity
|
||||
import com.anytypeio.anytype.data.auth.model.FeaturesConfigEntity
|
||||
|
@ -21,30 +22,15 @@ class AuthMiddleware(
|
|||
) : AuthRemote {
|
||||
|
||||
override suspend fun startAccount(
|
||||
id: String,
|
||||
path: String
|
||||
): Triple<AccountEntity, FeaturesConfigEntity, AccountStatus> {
|
||||
val response = middleware.selectAccount(id, path)
|
||||
val account = AccountEntity(
|
||||
id = response.id,
|
||||
name = response.name,
|
||||
color = response.avatar?.color
|
||||
)
|
||||
val featuresConfig = FeaturesConfigEntity(
|
||||
enableDataView = response.enableDataView,
|
||||
enableDebug = response.enableDebug,
|
||||
enableChannelSwitch = response.enableChannelSwitch,
|
||||
enableSpaces = response.enableSpaces
|
||||
)
|
||||
return Triple(account, featuresConfig, response.accountStatus ?: AccountStatus.Unknown)
|
||||
}
|
||||
id: String, path: String
|
||||
): AccountSetup = middleware.accountSelect(id, path)
|
||||
|
||||
override suspend fun createAccount(
|
||||
name: String,
|
||||
avatarPath: String?,
|
||||
invitationCode: String
|
||||
) = withContext(Dispatchers.IO) {
|
||||
middleware.createAccount(name, avatarPath, invitationCode).let { response ->
|
||||
middleware.accountCreate(name, avatarPath, invitationCode).let { response ->
|
||||
AccountEntity(
|
||||
id = response.id,
|
||||
name = response.name,
|
||||
|
@ -53,11 +39,11 @@ class AuthMiddleware(
|
|||
}
|
||||
}
|
||||
|
||||
override suspend fun deleteAccount(): AccountStatus = middleware.deleteAccount()
|
||||
override suspend fun restoreAccount(): AccountStatus = middleware.restoreAccount()
|
||||
override suspend fun deleteAccount(): AccountStatus = middleware.accountDelete()
|
||||
override suspend fun restoreAccount(): AccountStatus = middleware.accountRestore()
|
||||
|
||||
override suspend fun recoverAccount() = withContext(Dispatchers.IO) {
|
||||
middleware.recoverAccount()
|
||||
middleware.accountRecover()
|
||||
}
|
||||
|
||||
override fun observeAccounts() = events
|
||||
|
@ -81,19 +67,19 @@ class AuthMiddleware(
|
|||
|
||||
override suspend fun createWallet(
|
||||
path: String
|
||||
) = WalletEntity(mnemonic = middleware.createWallet(path).mnemonic)
|
||||
) = WalletEntity(mnemonic = middleware.walletCreate(path).mnemonic)
|
||||
|
||||
override suspend fun recoverWallet(path: String, mnemonic: String) {
|
||||
middleware.recoverWallet(path, mnemonic)
|
||||
middleware.walletRecover(path, mnemonic)
|
||||
}
|
||||
|
||||
override suspend fun convertWallet(entropy: String): String = middleware.convertWallet(entropy)
|
||||
override suspend fun convertWallet(entropy: String): String = middleware.walletConvert(entropy)
|
||||
|
||||
override suspend fun logout(clearLocalRepositoryData: Boolean) {
|
||||
middleware.logout(clearLocalRepositoryData)
|
||||
middleware.accountStop(clearLocalRepositoryData)
|
||||
}
|
||||
|
||||
override suspend fun getVersion(): String {
|
||||
return middleware.getMiddlewareVersion().version
|
||||
return middleware.versionGet().version
|
||||
}
|
||||
}
|
|
@ -27,15 +27,13 @@ class BlockMiddleware(
|
|||
private val middleware: Middleware
|
||||
) : BlockRemote {
|
||||
|
||||
override suspend fun getConfig(): Config = middleware.getConfig()
|
||||
|
||||
override suspend fun openDashboard(
|
||||
contextId: String,
|
||||
id: String
|
||||
): Payload = middleware.openDashboard(contextId, id)
|
||||
): Payload = middleware.dashboardOpen(contextId, id)
|
||||
|
||||
override suspend fun closeDashboard(id: String) {
|
||||
middleware.closeDashboard(id)
|
||||
middleware.objectClose(id)
|
||||
}
|
||||
|
||||
override suspend fun createPage(
|
||||
|
@ -44,7 +42,7 @@ class BlockMiddleware(
|
|||
isDraft: Boolean?,
|
||||
type: String?,
|
||||
template: Id?
|
||||
): String = middleware.createPage(
|
||||
): String = middleware.blockLinkCreateWithObject(
|
||||
ctx = ctx,
|
||||
emoji = emoji,
|
||||
isDraft = isDraft,
|
||||
|
@ -54,23 +52,23 @@ class BlockMiddleware(
|
|||
|
||||
override suspend fun createPage(
|
||||
command: Command.CreateNewDocument
|
||||
): String = middleware.createPage(command)
|
||||
): String = middleware.objectCreate(command)
|
||||
|
||||
override suspend fun openPage(id: String): Payload = middleware.openBlock(id)
|
||||
override suspend fun openProfile(id: String): Payload = middleware.openBlock(id)
|
||||
override suspend fun openObjectSet(id: String): Payload = middleware.openBlock(id)
|
||||
override suspend fun openObjectPreview(id: Id): Payload = middleware.showBlock(id)
|
||||
override suspend fun openPage(id: String): Payload = middleware.objectOpen(id)
|
||||
override suspend fun openProfile(id: String): Payload = middleware.objectOpen(id)
|
||||
override suspend fun openObjectSet(id: String): Payload = middleware.objectOpen(id)
|
||||
override suspend fun openObjectPreview(id: Id): Payload = middleware.objectShow(id)
|
||||
|
||||
override suspend fun closePage(id: String) {
|
||||
middleware.closePage(id)
|
||||
middleware.objectClose(id)
|
||||
}
|
||||
|
||||
override suspend fun updateDocumentTitle(command: Command.UpdateTitle) {
|
||||
middleware.updateDocumentTitle(command)
|
||||
middleware.objectSetTitle(command)
|
||||
}
|
||||
|
||||
override suspend fun updateText(command: Command.UpdateText) {
|
||||
middleware.updateText(
|
||||
middleware.blockTextSetText(
|
||||
command.contextId,
|
||||
command.blockId,
|
||||
command.text,
|
||||
|
@ -79,27 +77,27 @@ class BlockMiddleware(
|
|||
}
|
||||
|
||||
override suspend fun uploadBlock(command: Command.UploadBlock): Payload =
|
||||
middleware.uploadBlock(command)
|
||||
middleware.blockUpload(command)
|
||||
|
||||
override suspend fun updateTextStyle(
|
||||
command: Command.UpdateStyle
|
||||
): Payload = middleware.updateTextStyle(command)
|
||||
): Payload = middleware.blockTextListSetStyle(command)
|
||||
|
||||
override suspend fun updateTextColor(
|
||||
command: Command.UpdateTextColor
|
||||
): Payload = middleware.updateTextColor(command)
|
||||
): Payload = middleware.blockTextListSetColor(command)
|
||||
|
||||
override suspend fun updateBackgroundColor(
|
||||
command: Command.UpdateBackgroundColor
|
||||
): Payload = middleware.updateBackgroundColor(command)
|
||||
): Payload = middleware.blockListSetBackgroundColor(command)
|
||||
|
||||
override suspend fun updateAlignment(
|
||||
command: Command.UpdateAlignment
|
||||
): Payload = middleware.updateAlignment(command)
|
||||
): Payload = middleware.blockListSetAlign(command)
|
||||
|
||||
override suspend fun updateCheckbox(
|
||||
command: Command.UpdateCheckbox
|
||||
): Payload = middleware.updateCheckbox(
|
||||
): Payload = middleware.blockTextSetChecked(
|
||||
command.context,
|
||||
command.target,
|
||||
command.isChecked
|
||||
|
@ -107,7 +105,7 @@ class BlockMiddleware(
|
|||
|
||||
override suspend fun create(
|
||||
command: Command.Create
|
||||
): Pair<String, Payload> = middleware.createBlock(
|
||||
): Pair<String, Payload> = middleware.blockCreate(
|
||||
command.context,
|
||||
command.target,
|
||||
command.position,
|
||||
|
@ -116,119 +114,119 @@ class BlockMiddleware(
|
|||
|
||||
override suspend fun createDocument(
|
||||
command: Command.CreateDocument
|
||||
): Triple<String, String, Payload> = middleware.createDocument(command)
|
||||
): Triple<String, String, Payload> = middleware.blockLinkCreateWithObject(command)
|
||||
|
||||
override suspend fun duplicate(
|
||||
command: Command.Duplicate
|
||||
): Pair<List<Id>, Payload> = middleware.duplicate(command)
|
||||
): Pair<List<Id>, Payload> = middleware.blockListDuplicate(command)
|
||||
|
||||
override suspend fun duplicateObject(id: Id) = middleware.objectDuplicate(id)
|
||||
|
||||
override suspend fun move(command: Command.Move): Payload {
|
||||
return middleware.move(command)
|
||||
return middleware.blockListMoveToExistingObject(command)
|
||||
}
|
||||
|
||||
override suspend fun unlink(
|
||||
command: Command.Unlink
|
||||
): Payload = middleware.unlink(command)
|
||||
): Payload = middleware.blockListDelete(command)
|
||||
|
||||
override suspend fun merge(
|
||||
command: Command.Merge
|
||||
): Payload = middleware.merge(command)
|
||||
): Payload = middleware.blockMerge(command)
|
||||
|
||||
override suspend fun split(
|
||||
command: Command.Split
|
||||
): Pair<String, Payload> = middleware.split(command)
|
||||
): Pair<String, Payload> = middleware.blockSplit(command)
|
||||
|
||||
override suspend fun setDocumentEmojiIcon(
|
||||
command: Command.SetDocumentEmojiIcon
|
||||
): Payload = middleware.setDocumentEmojiIcon(command)
|
||||
): Payload = middleware.objectSetEmojiIcon(command)
|
||||
|
||||
override suspend fun setDocumentImageIcon(
|
||||
command: Command.SetDocumentImageIcon
|
||||
): Payload = middleware.setDocumentImageIcon(command)
|
||||
): Payload = middleware.objectSetImageIcon(command)
|
||||
|
||||
override suspend fun setDocumentCoverColor(
|
||||
ctx: String,
|
||||
color: String
|
||||
): Payload = middleware.setDocumentCoverColor(ctx = ctx, color = color)
|
||||
): Payload = middleware.objectSetCoverColor(ctx = ctx, color = color)
|
||||
|
||||
override suspend fun setDocumentCoverGradient(
|
||||
ctx: String,
|
||||
gradient: String
|
||||
): Payload = middleware.setDocumentCoverGradient(ctx = ctx, gradient = gradient)
|
||||
): Payload = middleware.objectSetCoverGradient(ctx = ctx, gradient = gradient)
|
||||
|
||||
override suspend fun setDocumentCoverImage(
|
||||
ctx: String,
|
||||
hash: String
|
||||
): Payload = middleware.setDocumentCoverImage(ctx = ctx, hash = hash)
|
||||
): Payload = middleware.objectSetCoverImage(ctx = ctx, hash = hash)
|
||||
|
||||
override suspend fun removeDocumentCover(
|
||||
ctx: String
|
||||
): Payload = middleware.removeDocumentCover(ctx)
|
||||
): Payload = middleware.objectRemoveCover(ctx)
|
||||
|
||||
override suspend fun removeDocumentIcon(
|
||||
ctx: Id
|
||||
): Payload = middleware.removeDocumentIcon(ctx)
|
||||
): Payload = middleware.objectRemoveIcon(ctx)
|
||||
|
||||
override suspend fun setupBookmark(
|
||||
command: Command.SetupBookmark
|
||||
): Payload = middleware.setupBookmark(command)
|
||||
): Payload = middleware.blockBookmarkFetch(command)
|
||||
|
||||
override suspend fun createBookmark(
|
||||
command: Command.CreateBookmark
|
||||
): Payload = middleware.createAndSetupBookmark(command)
|
||||
): Payload = middleware.blockBookmarkCreateAndFetch(command)
|
||||
|
||||
override suspend fun undo(
|
||||
command: Command.Undo
|
||||
): Payload = middleware.undo(command)
|
||||
): Payload = middleware.objectUndo(command)
|
||||
|
||||
override suspend fun redo(
|
||||
command: Command.Redo
|
||||
): Payload = middleware.redo(command)
|
||||
): Payload = middleware.objectRedo(command)
|
||||
|
||||
override suspend fun turnIntoDocument(
|
||||
command: Command.TurnIntoDocument
|
||||
): List<String> = middleware.turnIntoDocument(command)
|
||||
): List<String> = middleware.blockListMoveToNewObject(command)
|
||||
|
||||
override suspend fun replace(
|
||||
command: Command.Replace
|
||||
): Pair<String, Payload> = middleware.replace(command)
|
||||
): Pair<String, Payload> = middleware.blockReplace(command)
|
||||
|
||||
override suspend fun paste(
|
||||
command: Command.Paste
|
||||
): Response.Clipboard.Paste = middleware.paste(command)
|
||||
): Response.Clipboard.Paste = middleware.blockPaste(command)
|
||||
|
||||
override suspend fun copy(
|
||||
command: Command.Copy
|
||||
): Response.Clipboard.Copy = middleware.copy(command)
|
||||
): Response.Clipboard.Copy = middleware.blockCopy(command)
|
||||
|
||||
override suspend fun uploadFile(
|
||||
command: Command.UploadFile
|
||||
): String = middleware.uploadFile(command).hash
|
||||
): String = middleware.fileUpload(command).hash
|
||||
|
||||
override suspend fun getObjectInfoWithLinks(pageId: String): ObjectInfoWithLinks {
|
||||
return middleware.getObjectInfoWithLinks(pageId).toCoreModel()
|
||||
return middleware.navigationGetObjectInfoWithLinks(pageId).toCoreModel()
|
||||
}
|
||||
|
||||
override suspend fun getListPages(): List<DocumentInfo> {
|
||||
return middleware.listObjects().map { it.toCoreModel() }
|
||||
return middleware.navigationListObjects().map { it.toCoreModel() }
|
||||
}
|
||||
|
||||
override suspend fun setRelationKey(command: Command.SetRelationKey): Payload {
|
||||
return middleware.setRelationKey(command)
|
||||
return middleware.blockRelationSetKey(command)
|
||||
}
|
||||
|
||||
override suspend fun updateDivider(
|
||||
command: Command.UpdateDivider
|
||||
): Payload = middleware.updateDividerStyle(command)
|
||||
): Payload = middleware.blockListSetDivStyle(command)
|
||||
|
||||
override suspend fun setFields(
|
||||
command: Command.SetFields
|
||||
): Payload = middleware.setFields(command)
|
||||
): Payload = middleware.blockListSetFields(command)
|
||||
|
||||
override suspend fun getObjectTypes(): List<ObjectType> {
|
||||
return middleware.getObjectTypes().map { it.toCoreModels() }
|
||||
return middleware.objectTypeList().map { it.toCoreModels() }
|
||||
}
|
||||
|
||||
override suspend fun createObjectType(
|
||||
|
@ -240,7 +238,7 @@ class BlockMiddleware(
|
|||
targetId: String?,
|
||||
position: Position?,
|
||||
objectType: String?
|
||||
): Response.Set.Create = middleware.createSet(
|
||||
): Response.Set.Create = middleware.objectCreateSet(
|
||||
contextId = contextId,
|
||||
targetId = targetId,
|
||||
position = position,
|
||||
|
@ -253,7 +251,7 @@ class BlockMiddleware(
|
|||
view: String,
|
||||
offset: Int,
|
||||
limit: Int
|
||||
): Payload = middleware.setActiveDataViewViewer(
|
||||
): Payload = middleware.blockDataViewActiveSet(
|
||||
contextId = context,
|
||||
blockId = block,
|
||||
viewId = view,
|
||||
|
@ -267,7 +265,7 @@ class BlockMiddleware(
|
|||
name: String,
|
||||
format: Relation.Format,
|
||||
limitObjectTypes: List<Id>
|
||||
): Pair<Id, Payload> = middleware.addNewRelationToDataView(
|
||||
): Pair<Id, Payload> = middleware.blockDataViewRelationAdd(
|
||||
context = context,
|
||||
target = target,
|
||||
format = format,
|
||||
|
@ -279,7 +277,7 @@ class BlockMiddleware(
|
|||
ctx: Id,
|
||||
dv: Id,
|
||||
relation: Id
|
||||
): Payload = middleware.addRelationToDataView(
|
||||
): Payload = middleware.blockDataViewRelationAdd(
|
||||
ctx = ctx,
|
||||
dv = dv,
|
||||
relation = relation
|
||||
|
@ -289,7 +287,7 @@ class BlockMiddleware(
|
|||
ctx: Id,
|
||||
dv: Id,
|
||||
relation: Id
|
||||
): Payload = middleware.deleteRelationFromDataView(
|
||||
): Payload = middleware.blockDataViewRelationDelete(
|
||||
ctx = ctx,
|
||||
dv = dv,
|
||||
relation = relation
|
||||
|
@ -299,7 +297,7 @@ class BlockMiddleware(
|
|||
context: String,
|
||||
target: String,
|
||||
viewer: DVViewer
|
||||
): Payload = middleware.updateDataViewViewer(
|
||||
): Payload = middleware.blockDataViewViewUpdate(
|
||||
context = context,
|
||||
target = target,
|
||||
viewer = viewer
|
||||
|
@ -309,7 +307,7 @@ class BlockMiddleware(
|
|||
context: String,
|
||||
target: String,
|
||||
viewer: DVViewer
|
||||
): Payload = middleware.duplicateDataViewViewer(
|
||||
): Payload = middleware.blockDataViewViewCreate(
|
||||
context = context,
|
||||
target = target,
|
||||
viewer = viewer
|
||||
|
@ -319,7 +317,7 @@ class BlockMiddleware(
|
|||
context: String,
|
||||
target: String,
|
||||
template: Id?
|
||||
): Map<String, Any?> = middleware.createDataViewRecord(
|
||||
): Map<String, Any?> = middleware.blockDataViewRecordCreate(
|
||||
context = context,
|
||||
target = target,
|
||||
template = template
|
||||
|
@ -330,7 +328,7 @@ class BlockMiddleware(
|
|||
target: String,
|
||||
record: String,
|
||||
values: Map<String, Any?>
|
||||
) = middleware.updateDataViewRecord(
|
||||
) = middleware.blockDataViewRecordUpdate(
|
||||
context = context,
|
||||
target = target,
|
||||
record = record,
|
||||
|
@ -342,7 +340,7 @@ class BlockMiddleware(
|
|||
target: String,
|
||||
name: String,
|
||||
type: DVViewerType
|
||||
): Payload = middleware.addDataViewViewer(
|
||||
): Payload = middleware.blockDataViewViewCreate(
|
||||
ctx = ctx,
|
||||
target = target,
|
||||
name = name,
|
||||
|
@ -353,7 +351,7 @@ class BlockMiddleware(
|
|||
ctx: String,
|
||||
dataview: String,
|
||||
viewer: String
|
||||
): Payload = middleware.removeDataViewViewer(
|
||||
): Payload = middleware.blockDataViewViewDelete(
|
||||
ctx = ctx,
|
||||
dataview = dataview,
|
||||
viewer = viewer
|
||||
|
@ -366,7 +364,7 @@ class BlockMiddleware(
|
|||
record: Id,
|
||||
name: String,
|
||||
color: String
|
||||
): Pair<Payload, Id?> = middleware.addRecordRelationOption(
|
||||
): Pair<Payload, Id?> = middleware.blockDataViewRecordRelationOptionAdd(
|
||||
ctx = ctx,
|
||||
dataview = dataview,
|
||||
relation = relation,
|
||||
|
@ -380,7 +378,7 @@ class BlockMiddleware(
|
|||
relation: Id,
|
||||
name: Id,
|
||||
color: String
|
||||
): Pair<Payload, Id?> = middleware.addObjectRelationOption(
|
||||
): Pair<Payload, Id?> = middleware.objectRelationOptionAdd(
|
||||
ctx = ctx,
|
||||
relation = relation,
|
||||
name = name,
|
||||
|
@ -394,7 +392,7 @@ class BlockMiddleware(
|
|||
offset: Int,
|
||||
limit: Int,
|
||||
keys: List<Id>
|
||||
): List<Map<String, Any?>> = middleware.searchObjects(
|
||||
): List<Map<String, Any?>> = middleware.objectSearch(
|
||||
sorts = sorts,
|
||||
filters = filters,
|
||||
fulltext = fulltext,
|
||||
|
@ -412,7 +410,7 @@ class BlockMiddleware(
|
|||
limit: Long,
|
||||
beforeId: Id?,
|
||||
afterId: Id?
|
||||
): SearchResult = middleware.searchObjectsWithSubscription(
|
||||
): SearchResult = middleware.objectSearchSubscribe(
|
||||
subscription = subscription,
|
||||
sorts = sorts,
|
||||
filters = filters,
|
||||
|
@ -427,7 +425,7 @@ class BlockMiddleware(
|
|||
subscription: Id,
|
||||
ids: List<Id>,
|
||||
keys: List<String>
|
||||
): SearchResult = middleware.searchObjectsByIdWithSubscription(
|
||||
): SearchResult = middleware.objectIdsSubscribe(
|
||||
subscription = subscription,
|
||||
ids = ids,
|
||||
keys = keys
|
||||
|
@ -435,22 +433,22 @@ class BlockMiddleware(
|
|||
|
||||
override suspend fun cancelObjectSearchSubscription(
|
||||
subscriptions: List<Id>
|
||||
) = middleware.cancelObjectSearchSubscription(subscriptions = subscriptions)
|
||||
) = middleware.objectSearchUnsubscribe(subscriptions = subscriptions)
|
||||
|
||||
override suspend fun relationListAvailable(
|
||||
ctx: Id
|
||||
): List<Relation> = middleware.relationListAvailable(ctx).map { it.toCoreModels() }
|
||||
): List<Relation> = middleware.objectRelationListAvailable(ctx).map { it.toCoreModels() }
|
||||
|
||||
override suspend fun addRelationToObject(
|
||||
ctx: Id, relation: Id
|
||||
) : Payload = middleware.addRelationToObject(ctx, relation)
|
||||
) : Payload = middleware.objectRelationAdd(ctx, relation)
|
||||
|
||||
override suspend fun addNewRelationToObject(
|
||||
ctx: Id,
|
||||
name: String,
|
||||
format: RelationFormat,
|
||||
limitObjectTypes: List<Id>
|
||||
): Pair<Id, Payload> = middleware.addNewRelationToObject(
|
||||
): Pair<Id, Payload> = middleware.objectRelationAdd(
|
||||
ctx = ctx,
|
||||
format = format,
|
||||
name = name,
|
||||
|
@ -460,13 +458,13 @@ class BlockMiddleware(
|
|||
override suspend fun deleteRelationFromObject(
|
||||
ctx: Id,
|
||||
relation: Id
|
||||
): Payload = middleware.deleteRelationFromObject(
|
||||
): Payload = middleware.objectRelationDelete(
|
||||
ctx = ctx,
|
||||
relation = relation
|
||||
)
|
||||
|
||||
override suspend fun debugSync(): String = middleware.debugSync()
|
||||
override suspend fun debugLocalStore(path: String): String = middleware.exportLocalStore(path)
|
||||
override suspend fun debugLocalStore(path: String): String = middleware.debugExportLocalStore(path)
|
||||
|
||||
override suspend fun turnInto(
|
||||
context: String,
|
||||
|
@ -482,59 +480,59 @@ class BlockMiddleware(
|
|||
ctx: Id,
|
||||
key: String,
|
||||
value: Any?
|
||||
): Payload = middleware.updateDetail(
|
||||
): Payload = middleware.objectSetDetails(
|
||||
ctx = ctx,
|
||||
key = key,
|
||||
value = value
|
||||
)
|
||||
|
||||
override suspend fun updateBlocksMark(command: Command.UpdateBlocksMark): Payload =
|
||||
middleware.blockListSetTextMarkup(command)
|
||||
middleware.blockTextListSetMark(command)
|
||||
|
||||
override suspend fun addRelationToBlock(command: Command.AddRelationToBlock): Payload =
|
||||
middleware.addRelationToBlock(command)
|
||||
middleware.blockRelationAdd(command)
|
||||
|
||||
override suspend fun setObjectTypeToObject(ctx: Id, typeId: Id): Payload =
|
||||
middleware.setObjectType(ctx = ctx, typeId = typeId)
|
||||
middleware.objectSetObjectType(ctx = ctx, typeId = typeId)
|
||||
|
||||
override suspend fun addToFeaturedRelations(
|
||||
ctx: Id,
|
||||
relations: List<Id>
|
||||
): Payload = middleware.addToFeaturedRelations(ctx, relations)
|
||||
): Payload = middleware.objectRelationAddFeatured(ctx, relations)
|
||||
|
||||
override suspend fun removeFromFeaturedRelations(
|
||||
ctx: Id,
|
||||
relations: List<Id>
|
||||
): Payload = middleware.removeFromFeaturedRelations(ctx, relations)
|
||||
): Payload = middleware.objectRelationRemoveFeatured(ctx, relations)
|
||||
|
||||
override suspend fun setObjectIsFavorite(
|
||||
ctx: Id,
|
||||
isFavorite: Boolean
|
||||
): Payload = middleware.setObjectIsFavorite(ctx = ctx, isFavorite = isFavorite)
|
||||
): Payload = middleware.objectSetIsFavorite(ctx = ctx, isFavorite = isFavorite)
|
||||
|
||||
override suspend fun setObjectIsArchived(
|
||||
ctx: Id,
|
||||
isArchived: Boolean
|
||||
): Payload = middleware.setObjectIsArchived(ctx = ctx, isArchived = isArchived)
|
||||
): Payload = middleware.objectSetIsArchived(ctx = ctx, isArchived = isArchived)
|
||||
|
||||
override suspend fun deleteObjects(targets: List<Id>) = middleware.deleteObjects(
|
||||
override suspend fun deleteObjects(targets: List<Id>) = middleware.objectListDelete(
|
||||
targets = targets
|
||||
)
|
||||
|
||||
override suspend fun setObjectListIsArchived(
|
||||
targets: List<Id>,
|
||||
isArchived: Boolean
|
||||
) = middleware.setObjectListIsArchived(
|
||||
) = middleware.objectListSetIsArchived(
|
||||
targets = targets,
|
||||
isArchived = isArchived
|
||||
)
|
||||
|
||||
override suspend fun setObjectLayout(ctx: Id, layout: ObjectType.Layout) : Payload =
|
||||
middleware.setObjectLayout(ctx, layout)
|
||||
middleware.objectSetLayout(ctx, layout)
|
||||
|
||||
override suspend fun clearFileCache() = middleware.fileListOffload()
|
||||
|
||||
override suspend fun applyTemplate(ctx: Id, template: Id) = middleware.applyTemplate(
|
||||
override suspend fun applyTemplate(ctx: Id, template: Id) = middleware.objectApplyTemplate(
|
||||
ctx = ctx,
|
||||
template = template
|
||||
)
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
package com.anytypeio.anytype.middleware.config
|
||||
|
||||
import anytype.Rpc.Config
|
||||
import com.anytypeio.anytype.data.auth.repo.config.Configurator
|
||||
import service.Service
|
||||
|
||||
typealias CoreConfig = com.anytypeio.anytype.core_models.Config
|
||||
/**
|
||||
* Obtains middleware configuration data.
|
||||
*/
|
||||
class DefaultConfigurator : Configurator {
|
||||
|
||||
override fun configure() = get()
|
||||
|
||||
private val builder: () -> CoreConfig = {
|
||||
fetchConfig().let { response ->
|
||||
CoreConfig(
|
||||
home = response.homeBlockId,
|
||||
gateway = response.gatewayUrl,
|
||||
profile = response.profileBlockId
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private var instance: CoreConfig? = null
|
||||
|
||||
fun get() = instance ?: builder().also { instance = it }
|
||||
|
||||
fun new() = builder().also { instance = it }
|
||||
|
||||
override fun release() {
|
||||
instance = null
|
||||
}
|
||||
|
||||
private fun fetchConfig(): Config.Get.Response {
|
||||
val request = Config.Get.Request()
|
||||
val encoded = Service.configGet(Config.Get.Request.ADAPTER.encode(request))
|
||||
val response = Config.Get.Response.ADAPTER.decode(encoded)
|
||||
return parseResponse(response)
|
||||
}
|
||||
|
||||
private fun parseResponse(response: Config.Get.Response): Config.Get.Response {
|
||||
val error = response.error
|
||||
return if (error != null && error.code != Config.Get.Response.Error.Code.NULL) {
|
||||
throw Exception(error.description)
|
||||
} else {
|
||||
response
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,6 @@
|
|||
package com.anytypeio.anytype.middleware.mappers
|
||||
|
||||
import anytype.Rpc.UnsplashSearch.Response.Picture
|
||||
import anytype.Rpc.Unsplash.Search.Response.Picture
|
||||
import com.anytypeio.anytype.core_models.UnsplashImage
|
||||
|
||||
fun Picture.core() : UnsplashImage = UnsplashImage(
|
||||
|
|
|
@ -1,266 +1,298 @@
|
|||
package com.anytypeio.anytype.middleware.service
|
||||
|
||||
import anytype.Rpc.ObjectDuplicate
|
||||
import anytype.Rpc.Account
|
||||
import anytype.Rpc.ApplyTemplate
|
||||
import anytype.Rpc.Block
|
||||
import anytype.Rpc.BlockList
|
||||
import anytype.Rpc.Config
|
||||
import anytype.Rpc.Debug
|
||||
import anytype.Rpc.ExportLocalstore
|
||||
import anytype.Rpc.FileList
|
||||
import anytype.Rpc.Navigation
|
||||
import anytype.Rpc.Object
|
||||
import anytype.Rpc.ObjectList
|
||||
import anytype.Rpc.ObjectType
|
||||
import anytype.Rpc.Page
|
||||
import anytype.Rpc.UnsplashDownload
|
||||
import anytype.Rpc.UnsplashSearch
|
||||
import anytype.Rpc.UploadFile
|
||||
import anytype.Rpc.Version
|
||||
import anytype.Rpc.Wallet
|
||||
import anytype.Rpc
|
||||
|
||||
/**
|
||||
* Service for interacting with the backend.
|
||||
*/
|
||||
interface MiddlewareService {
|
||||
@Throws(Exception::class)
|
||||
fun configGet(request: Config.Get.Request): Config.Get.Response
|
||||
|
||||
//region APP commands
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun walletCreate(request: Wallet.Create.Request): Wallet.Create.Response
|
||||
fun versionGet(request: Rpc.App.GetVersion.Request): Rpc.App.GetVersion.Response
|
||||
|
||||
//endregion
|
||||
|
||||
//region WALLET commands
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun walletConvert(request: Wallet.Convert.Request): Wallet.Convert.Response
|
||||
fun walletCreate(request: Rpc.Wallet.Create.Request): Rpc.Wallet.Create.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun walletRecover(request: Wallet.Recover.Request): Wallet.Recover.Response
|
||||
fun walletRecover(request: Rpc.Wallet.Recover.Request): Rpc.Wallet.Recover.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun accountCreate(request: Account.Create.Request): Account.Create.Response
|
||||
fun walletConvert(request: Rpc.Wallet.Convert.Request): Rpc.Wallet.Convert.Response
|
||||
|
||||
//endregion com
|
||||
|
||||
//region ACCOUNT commands
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun accountDelete(request: Account.Delete.Request) : Account.Delete.Response
|
||||
fun accountRecover(request: Rpc.Account.Recover.Request): Rpc.Account.Recover.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun accountSelect(request: Account.Select.Request): Account.Select.Response
|
||||
fun accountCreate(request: Rpc.Account.Create.Request): Rpc.Account.Create.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun accountRecover(request: Account.Recover.Request): Account.Recover.Response
|
||||
fun accountDelete(request: Rpc.Account.Delete.Request): Rpc.Account.Delete.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun accountStop(request: Account.Stop.Request): Account.Stop.Response
|
||||
fun accountSelect(request: Rpc.Account.Select.Request): Rpc.Account.Select.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockOpen(request: Block.Open.Request): Block.Open.Response
|
||||
fun accountStop(request: Rpc.Account.Stop.Request): Rpc.Account.Stop.Response
|
||||
|
||||
//endregion
|
||||
|
||||
//region OBJECT commands
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockShow(request: Block.Show.Request): Block.Show.Response
|
||||
fun objectOpen(request: Rpc.Object.Open.Request): Rpc.Object.Open.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockClose(request: Block.Close.Request): Block.Close.Response
|
||||
fun objectClose(request: Rpc.Object.Close.Request): Rpc.Object.Close.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockCreate(request: Block.Create.Request): Block.Create.Response
|
||||
fun objectShow(request: Rpc.Object.Show.Request): Rpc.Object.Show.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockCreatePage(request: Block.CreatePage.Request): Block.CreatePage.Response
|
||||
fun objectCreate(request: Rpc.Object.Create.Request): Rpc.Object.Create.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockSetTextText(request: Block.Set.Text.TText.Request): Block.Set.Text.TText.Response
|
||||
fun objectCreateSet(request: Rpc.Object.CreateSet.Request): Rpc.Object.CreateSet.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockSetTextChecked(request: Block.Set.Text.Checked.Request): Block.Set.Text.Checked.Response
|
||||
fun objectSearch(request: Rpc.Object.Search.Request): Rpc.Object.Search.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockSetTextColor(request: BlockList.Set.Text.Color.Request): BlockList.Set.Text.Color.Response
|
||||
fun objectSearchSubscribe(request: Rpc.Object.SearchSubscribe.Request): Rpc.Object.SearchSubscribe.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockListSetBackgroundColor(request: BlockList.Set.BackgroundColor.Request): BlockList.Set.BackgroundColor.Response
|
||||
fun objectSearchUnsubscribe(request: Rpc.Object.SearchUnsubscribe.Request): Rpc.Object.SearchUnsubscribe.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockListSetAlign(request: BlockList.Set.Align.Request): BlockList.Set.Align.Response
|
||||
fun objectIdsSubscribe(request: Rpc.Object.SubscribeIds.Request): Rpc.Object.SubscribeIds.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockListSetTextStyle(request: BlockList.Set.Text.Style.Request): BlockList.Set.Text.Style.Response
|
||||
fun objectSetDetails(request: Rpc.Object.SetDetails.Request): Rpc.Object.SetDetails.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockListSetDivStyle(request: BlockList.Set.Div.Style.Request): BlockList.Set.Div.Style.Response
|
||||
fun objectDuplicate(request: Rpc.Object.Duplicate.Request): Rpc.Object.Duplicate.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockListMove(request: BlockList.Move.Request): BlockList.Move.Response
|
||||
fun objectSetObjectType(request: Rpc.Object.SetObjectType.Request): Rpc.Object.SetObjectType.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockUnlink(request: Block.Unlink.Request): Block.Unlink.Response
|
||||
fun objectSetLayout(request: Rpc.Object.SetLayout.Request): Rpc.Object.SetLayout.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockMerge(request: Block.Merge.Request): Block.Merge.Response
|
||||
fun objectSetIsFavorite(request: Rpc.Object.SetIsFavorite.Request): Rpc.Object.SetIsFavorite.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockSplit(request: Block.Split.Request): Block.Split.Response
|
||||
fun objectSetIsArchived(request: Rpc.Object.SetIsArchived.Request): Rpc.Object.SetIsArchived.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockListDuplicate(request: BlockList.Duplicate.Request): BlockList.Duplicate.Response
|
||||
fun objectListSetIsArchived(request: Rpc.Object.ListSetIsArchived.Request): Rpc.Object.ListSetIsArchived.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun convertChildrenToPages(request: BlockList.ConvertChildrenToPages.Request): BlockList.ConvertChildrenToPages.Response
|
||||
fun objectListDelete(request: Rpc.Object.ListDelete.Request): Rpc.Object.ListDelete.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockBookmarkFetch(request: Block.Bookmark.Fetch.Request): Block.Bookmark.Fetch.Response
|
||||
fun objectApplyTemplate(request: Rpc.Object.ApplyTemplate.Request): Rpc.Object.ApplyTemplate.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockBookmarkCreateAndFetch(request: Block.Bookmark.CreateAndFetch.Request): Block.Bookmark.CreateAndFetch.Response
|
||||
fun objectUndo(request: Rpc.Object.Undo.Request): Rpc.Object.Undo.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockUpload(request: Block.Upload.Request): Block.Upload.Response
|
||||
fun objectRedo(request: Rpc.Object.Redo.Request): Rpc.Object.Redo.Response
|
||||
|
||||
//endregion
|
||||
|
||||
//region OBJECT'S RELATIONS command
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockUndo(request: Block.Undo.Request): Block.Undo.Response
|
||||
fun objectRelationAdd(request: Rpc.ObjectRelation.Add.Request): Rpc.ObjectRelation.Add.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockRedo(request: Block.Redo.Request): Block.Redo.Response
|
||||
fun objectRelationDelete(request: Rpc.ObjectRelation.Delete.Request): Rpc.ObjectRelation.Delete.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockSetDetails(request: Block.Set.Details.Request): Block.Set.Details.Response
|
||||
fun objectRelationAddFeatured(request: Rpc.ObjectRelation.AddFeatured.Request): Rpc.ObjectRelation.AddFeatured.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockPaste(request: Block.Paste.Request): Block.Paste.Response
|
||||
fun objectRelationRemoveFeatured(request: Rpc.ObjectRelation.RemoveFeatured.Request): Rpc.ObjectRelation.RemoveFeatured.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockCopy(request: Block.Copy.Request): Block.Copy.Response
|
||||
fun objectRelationListAvailable(request: Rpc.ObjectRelation.ListAvailable.Request): Rpc.ObjectRelation.ListAvailable.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun uploadFile(request: UploadFile.Request): UploadFile.Response
|
||||
fun objectRelationOptionAdd(request: Rpc.ObjectRelationOption.Add.Request): Rpc.ObjectRelationOption.Add.Response
|
||||
|
||||
//endregion
|
||||
|
||||
//region OBJECT TYPE commands
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun objectInfoWithLinks(request: Navigation.GetObjectInfoWithLinks.Request): Navigation.GetObjectInfoWithLinks.Response
|
||||
fun objectTypeCreate(request: Rpc.ObjectType.Create.Request): Rpc.ObjectType.Create.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun listObjects(request: Navigation.ListObjects.Request): Navigation.ListObjects.Response
|
||||
fun objectTypeList(request: Rpc.ObjectType.List.Request): Rpc.ObjectType.List.Response
|
||||
|
||||
//endregion
|
||||
|
||||
//region FILES commands
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun pageCreate(request: Page.Create.Request): Page.Create.Response
|
||||
fun fileListOffload(request: Rpc.File.ListOffload.Request): Rpc.File.ListOffload.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun versionGet(request: Version.Get.Request): Version.Get.Response
|
||||
fun fileUpload(request: Rpc.File.Upload.Request): Rpc.File.Upload.Response
|
||||
|
||||
//endregion
|
||||
|
||||
//region UNSPLASH commands
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockListSetFields(request: BlockList.Set.Fields.Request): BlockList.Set.Fields.Response
|
||||
fun unsplashSearch(request: Rpc.Unsplash.Search.Request): Rpc.Unsplash.Search.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun objectTypeList(request: ObjectType.List.Request): ObjectType.List.Response
|
||||
fun unsplashDownload(request: Rpc.Unsplash.Download.Request): Rpc.Unsplash.Download.Response
|
||||
|
||||
//endregion
|
||||
|
||||
//region BLOCK commands
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun objectTypeCreate(request: ObjectType.Create.Request): ObjectType.Create.Response
|
||||
fun blockCreate(request: Rpc.Block.Create.Request): Rpc.Block.Create.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockCreateSet(request: Block.CreateSet.Request): Block.CreateSet.Response
|
||||
fun blockPaste(request: Rpc.Block.Paste.Request): Rpc.Block.Paste.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockDataViewActiveSet(request: Block.Dataview.ViewSetActive.Request): Block.Dataview.ViewSetActive.Response
|
||||
fun blockCopy(request: Rpc.Block.Copy.Request): Rpc.Block.Copy.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockDataViewRelationAdd(request: Block.Dataview.RelationAdd.Request): Block.Dataview.RelationAdd.Response
|
||||
fun blockUpload(request: Rpc.Block.Upload.Request): Rpc.Block.Upload.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockDataViewRelationDelete(request: Block.Dataview.RelationDelete.Request): Block.Dataview.RelationDelete.Response
|
||||
fun blockMerge(request: Rpc.Block.Merge.Request): Rpc.Block.Merge.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockDataViewViewUpdate(request: Block.Dataview.ViewUpdate.Request): Block.Dataview.ViewUpdate.Response
|
||||
fun blockSplit(request: Rpc.Block.Split.Request): Rpc.Block.Split.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockDataViewViewDelete(request: Block.Dataview.ViewDelete.Request): Block.Dataview.ViewDelete.Response
|
||||
fun blockListDelete(request: Rpc.Block.ListDelete.Request): Rpc.Block.ListDelete.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockDataViewRecordCreate(request: Block.Dataview.RecordCreate.Request): Block.Dataview.RecordCreate.Response
|
||||
fun blockListMoveToExistingObject(request: Rpc.Block.ListMoveToExistingObject.Request): Rpc.Block.ListMoveToExistingObject.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockDataViewRecordUpdate(request: Block.Dataview.RecordUpdate.Request): Block.Dataview.RecordUpdate.Response
|
||||
fun blockListMoveToNewObject(request: Rpc.Block.ListMoveToNewObject.Request): Rpc.Block.ListMoveToNewObject.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockDataViewViewCreate(request: Block.Dataview.ViewCreate.Request): Block.Dataview.ViewCreate.Response
|
||||
fun blockListSetFields(request: Rpc.Block.ListSetFields.Request): Rpc.Block.ListSetFields.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockDataViewRecordRelationOptionAdd(request: Block.Dataview.RecordRelationOptionAdd.Request): Block.Dataview.RecordRelationOptionAdd.Response
|
||||
fun blockListSetBackgroundColor(request: Rpc.Block.ListSetBackgroundColor.Request): Rpc.Block.ListSetBackgroundColor.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun objectRelationOptionAdd(request: Object.RelationOptionAdd.Request): Object.RelationOptionAdd.Response
|
||||
fun blockListSetAlign(request: Rpc.Block.ListSetAlign.Request): Rpc.Block.ListSetAlign.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun objectSearch(request: Object.Search.Request): Object.Search.Response
|
||||
fun blockListDuplicate(request: Rpc.Block.ListDuplicate.Request): Rpc.Block.ListDuplicate.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun objectSearchSubscribe(request: Object.SearchSubscribe.Request): Object.SearchSubscribe.Response
|
||||
fun blockListTurnInto(request: Rpc.Block.ListTurnInto.Request): Rpc.Block.ListTurnInto.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun objectIdsSubscribe(request: Object.IdsSubscribe.Request): Object.IdsSubscribe.Response
|
||||
fun blockListSetDivStyle(request: Rpc.BlockDiv.ListSetStyle.Request): Rpc.BlockDiv.ListSetStyle.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun objectSearchUnsubscribe(request: Object.SearchUnsubscribe.Request): Object.SearchUnsubscribe.Response
|
||||
fun blockBookmarkFetch(request: Rpc.BlockBookmark.Fetch.Request): Rpc.BlockBookmark.Fetch.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun relationListAvailable(request: Object.RelationListAvailable.Request): Object.RelationListAvailable.Response
|
||||
fun blockBookmarkCreateAndFetch(request: Rpc.BlockBookmark.CreateAndFetch.Request): Rpc.BlockBookmark.CreateAndFetch.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun objectRelationAdd(request: Object.RelationAdd.Request) : Object.RelationAdd.Response
|
||||
fun blockLinkCreateWithObject(request: Rpc.BlockLink.CreateWithObject.Request): Rpc.BlockLink.CreateWithObject.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun objectRelationDelete(request: Object.RelationDelete.Request) : Object.RelationDelete.Response
|
||||
fun blockRelationAdd(request: Rpc.BlockRelation.Add.Request): Rpc.BlockRelation.Add.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun debugSync(request: Debug.Sync.Request) : Debug.Sync.Response
|
||||
fun blockRelationSetKey(request: Rpc.BlockRelation.SetKey.Request): Rpc.BlockRelation.SetKey.Response
|
||||
|
||||
//endregion
|
||||
|
||||
//region NAVIGATION commands
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun relationSetKey(request: Block.Relation.SetKey.Request) : Block.Relation.SetKey.Response
|
||||
fun navigationGetObjectInfoWithLinks(request: Rpc.Navigation.GetObjectInfoWithLinks.Request): Rpc.Navigation.GetObjectInfoWithLinks.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockAddRelation(request: Block.Relation.Add.Request) : Block.Relation.Add.Response
|
||||
fun navigationListObjects(request: Rpc.Navigation.ListObjects.Request): Rpc.Navigation.ListObjects.Response
|
||||
|
||||
//endregion
|
||||
|
||||
//region DATA VIEW commands
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockListTurnInto(request: BlockList.TurnInto.Request): BlockList.TurnInto.Response
|
||||
fun blockDataViewActiveSet(request: Rpc.BlockDataview.View.SetActive.Request): Rpc.BlockDataview.View.SetActive.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockListSetTextMark(request: BlockList.Set.Text.Mark.Request): BlockList.Set.Text.Mark.Response
|
||||
fun blockDataViewViewCreate(request: Rpc.BlockDataview.View.Create.Request): Rpc.BlockDataview.View.Create.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockSetObjectType(request: Block.ObjectType.Set.Request): Block.ObjectType.Set.Response
|
||||
fun blockDataViewViewUpdate(request: Rpc.BlockDataview.View.Update.Request): Rpc.BlockDataview.View.Update.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun featuredRelationsAdd(request: Object.FeaturedRelation.Add.Request): Object.FeaturedRelation.Add.Response
|
||||
fun blockDataViewViewDelete(request: Rpc.BlockDataview.View.Delete.Request): Rpc.BlockDataview.View.Delete.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun featuredRelationsRemove(request: Object.FeaturedRelation.Remove.Request): Object.FeaturedRelation.Remove.Response
|
||||
fun blockDataViewRecordCreate(request: Rpc.BlockDataviewRecord.Create.Request): Rpc.BlockDataviewRecord.Create.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun objectSetIsFavorite(request: Object.SetIsFavorite.Request): Object.SetIsFavorite.Response
|
||||
fun blockDataViewRecordUpdate(request: Rpc.BlockDataviewRecord.Update.Request): Rpc.BlockDataviewRecord.Update.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun objectSetIsArchived(request: Object.SetIsArchived.Request): Object.SetIsArchived.Response
|
||||
fun blockDataViewRecordRelationOptionAdd(request: Rpc.BlockDataviewRecord.RelationOption.Add.Request): Rpc.BlockDataviewRecord.RelationOption.Add.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun objectListSetIsArchived(request: ObjectList.Set.IsArchived.Request): ObjectList.Set.IsArchived.Response
|
||||
fun blockDataViewRelationAdd(request: Rpc.BlockDataview.Relation.Add.Request): Rpc.BlockDataview.Relation.Add.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun objectListDelete(request: ObjectList.Delete.Request): ObjectList.Delete.Response
|
||||
fun blockDataViewRelationDelete(request: Rpc.BlockDataview.Relation.Delete.Request): Rpc.BlockDataview.Relation.Delete.Response
|
||||
|
||||
//endregion
|
||||
|
||||
//region TEXT BLOCK commands
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun objectSetLayout(request: Object.SetLayout.Request): Object.SetLayout.Response
|
||||
fun blockTextSetText(request: Rpc.BlockText.SetText.Request): Rpc.BlockText.SetText.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun exportLocalStore(request: ExportLocalstore.Request): ExportLocalstore.Response
|
||||
fun blockTextSetChecked(request: Rpc.BlockText.SetChecked.Request): Rpc.BlockText.SetChecked.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun fileListOffload(request: FileList.Offload.Request): FileList.Offload.Response
|
||||
fun blockTextListSetColor(request: Rpc.BlockText.ListSetColor.Request): Rpc.BlockText.ListSetColor.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun unsplashSearch(request: UnsplashSearch.Request) : UnsplashSearch.Response
|
||||
fun blockTextListSetMark(request: Rpc.BlockText.ListSetMark.Request): Rpc.BlockText.ListSetMark.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun unsplashDownload(request: UnsplashDownload.Request) : UnsplashDownload.Response
|
||||
fun blockTextListSetStyle(request: Rpc.BlockText.ListSetStyle.Request): Rpc.BlockText.ListSetStyle.Response
|
||||
|
||||
//endregion
|
||||
|
||||
//region DEBUG commands
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun objectDuplicate(request: ObjectDuplicate.Request) : ObjectDuplicate.Response
|
||||
fun debugSync(request: Rpc.Debug.Sync.Request): Rpc.Debug.Sync.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun applyTemplate(request: ApplyTemplate.Request): ApplyTemplate.Response
|
||||
fun debugExportLocalStore(request: Rpc.Debug.ExportLocalstore.Request): Rpc.Debug.ExportLocalstore.Response
|
||||
|
||||
//endregion
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -53,7 +53,7 @@ class MiddlewareTest {
|
|||
|
||||
// TESTING
|
||||
|
||||
middleware.logout(false)
|
||||
middleware.accountStop(false)
|
||||
|
||||
verify(service, times(1)).accountStop(request)
|
||||
verifyNoMoreInteractions(service)
|
||||
|
@ -73,13 +73,13 @@ class MiddlewareTest {
|
|||
layout = null
|
||||
)
|
||||
|
||||
val response = Rpc.Block.CreatePage.Response(
|
||||
val response = Rpc.BlockLink.CreateWithObject.Response(
|
||||
blockId = MockDataFactory.randomUuid(),
|
||||
targetId = MockDataFactory.randomUuid(),
|
||||
event = ResponseEvent()
|
||||
)
|
||||
|
||||
val request = Rpc.Block.CreatePage.Request(
|
||||
val request = Rpc.BlockLink.CreateWithObject.Request(
|
||||
contextId = command.context,
|
||||
targetId = command.target,
|
||||
position = Block.Position.Inner,
|
||||
|
@ -87,14 +87,14 @@ class MiddlewareTest {
|
|||
)
|
||||
|
||||
service.stub {
|
||||
on { blockCreatePage(any()) } doReturn response
|
||||
on { blockLinkCreateWithObject(any()) } doReturn response
|
||||
}
|
||||
|
||||
// TESTING
|
||||
|
||||
val (block, target) = middleware.createDocument(command)
|
||||
val (block, target) = middleware.blockLinkCreateWithObject(command)
|
||||
|
||||
verify(service, times(1)).blockCreatePage(request)
|
||||
verify(service, times(1)).blockLinkCreateWithObject(request)
|
||||
|
||||
assertEquals(
|
||||
expected = response.blockId,
|
||||
|
@ -123,13 +123,13 @@ class MiddlewareTest {
|
|||
layout = null
|
||||
)
|
||||
|
||||
val response = Rpc.Block.CreatePage.Response(
|
||||
val response = Rpc.BlockLink.CreateWithObject.Response(
|
||||
blockId = MockDataFactory.randomUuid(),
|
||||
targetId = MockDataFactory.randomUuid(),
|
||||
event = ResponseEvent()
|
||||
)
|
||||
|
||||
val request = Rpc.Block.CreatePage.Request(
|
||||
val request = Rpc.BlockLink.CreateWithObject.Request(
|
||||
contextId = command.context,
|
||||
targetId = command.target,
|
||||
position = Block.Position.Inner,
|
||||
|
@ -137,14 +137,14 @@ class MiddlewareTest {
|
|||
)
|
||||
|
||||
service.stub {
|
||||
on { blockCreatePage(any()) } doReturn response
|
||||
on { blockLinkCreateWithObject(any()) } doReturn response
|
||||
}
|
||||
|
||||
// TESTING
|
||||
|
||||
val (block, target) = middleware.createDocument(command)
|
||||
val (block, target) = middleware.blockLinkCreateWithObject(command)
|
||||
|
||||
verify(service, times(1)).blockCreatePage(request)
|
||||
verify(service, times(1)).blockLinkCreateWithObject(request)
|
||||
|
||||
assertEquals(
|
||||
expected = response.blockId,
|
||||
|
@ -194,7 +194,7 @@ class MiddlewareTest {
|
|||
|
||||
// TESTING
|
||||
|
||||
val result = middleware.replace(command)
|
||||
val result = middleware.blockReplace(command)
|
||||
|
||||
verify(service, times(1)).blockCreate(request)
|
||||
|
||||
|
@ -217,35 +217,35 @@ class MiddlewareTest {
|
|||
emoji = MockDataFactory.randomString()
|
||||
)
|
||||
|
||||
val response = Rpc.Block.Set.Details.Response(event = ResponseEvent())
|
||||
val response = Rpc.Object.SetDetails.Response(event = ResponseEvent())
|
||||
|
||||
val emojiIconKey = "iconEmoji"
|
||||
val imageIconKey = "iconImage"
|
||||
|
||||
val emojiValue = command.emoji
|
||||
|
||||
val emojiDetail = Rpc.Block.Set.Details.Detail(
|
||||
val emojiDetail = Rpc.Object.SetDetails.Detail(
|
||||
key = emojiIconKey, value_ = emojiValue
|
||||
)
|
||||
|
||||
val imageDetail = Rpc.Block.Set.Details.Detail(
|
||||
val imageDetail = Rpc.Object.SetDetails.Detail(
|
||||
key = imageIconKey
|
||||
)
|
||||
|
||||
val request = Rpc.Block.Set.Details.Request(
|
||||
val request = Rpc.Object.SetDetails.Request(
|
||||
contextId = command.context,
|
||||
details = listOf(emojiDetail, imageDetail)
|
||||
)
|
||||
|
||||
service.stub {
|
||||
on { blockSetDetails(any()) } doReturn response
|
||||
on { objectSetDetails(any()) } doReturn response
|
||||
}
|
||||
|
||||
// TESTING
|
||||
|
||||
middleware.setDocumentEmojiIcon(command)
|
||||
middleware.objectSetEmojiIcon(command)
|
||||
|
||||
verify(service, times(1)).blockSetDetails(request)
|
||||
verify(service, times(1)).objectSetDetails(request)
|
||||
verifyNoMoreInteractions(service)
|
||||
}
|
||||
|
||||
|
@ -259,32 +259,32 @@ class MiddlewareTest {
|
|||
hash = MockDataFactory.randomUuid()
|
||||
)
|
||||
|
||||
val response = Rpc.Block.Set.Details.Response(event = ResponseEvent())
|
||||
val response = Rpc.Object.SetDetails.Response(event = ResponseEvent())
|
||||
|
||||
val imageIconKey = "iconImage"
|
||||
|
||||
val imageIconValue = command.hash
|
||||
|
||||
val imageIconDetail = Rpc.Block.Set.Details.Detail(imageIconKey,imageIconValue)
|
||||
val imageIconDetail = Rpc.Object.SetDetails.Detail(imageIconKey, imageIconValue)
|
||||
|
||||
val emojiIconKey = "iconEmoji"
|
||||
|
||||
val emojiIconDetail = Rpc.Block.Set.Details.Detail(emojiIconKey)
|
||||
val emojiIconDetail = Rpc.Object.SetDetails.Detail(emojiIconKey)
|
||||
|
||||
val request = Rpc.Block.Set.Details.Request(
|
||||
val request = Rpc.Object.SetDetails.Request(
|
||||
contextId = command.context,
|
||||
details = listOf(imageIconDetail, emojiIconDetail)
|
||||
)
|
||||
|
||||
service.stub {
|
||||
on { blockSetDetails(any()) } doReturn response
|
||||
on { objectSetDetails(any()) } doReturn response
|
||||
}
|
||||
|
||||
// TESTING
|
||||
|
||||
middleware.setDocumentImageIcon(command)
|
||||
middleware.objectSetImageIcon(command)
|
||||
|
||||
verify(service, times(1)).blockSetDetails(request)
|
||||
verify(service, times(1)).objectSetDetails(request)
|
||||
verifyNoMoreInteractions(service)
|
||||
}
|
||||
|
||||
|
@ -298,28 +298,28 @@ class MiddlewareTest {
|
|||
title = MockDataFactory.randomString()
|
||||
)
|
||||
|
||||
val response = Rpc.Block.Set.Details.Response()
|
||||
val response = Rpc.Object.SetDetails.Response()
|
||||
|
||||
val key = "name"
|
||||
|
||||
val value = command.title
|
||||
|
||||
val details = Rpc.Block.Set.Details.Detail(key, value)
|
||||
val details = Rpc.Object.SetDetails.Detail(key, value)
|
||||
|
||||
val request = Rpc.Block.Set.Details.Request(
|
||||
val request = Rpc.Object.SetDetails.Request(
|
||||
contextId = command.context,
|
||||
details = listOf(details)
|
||||
)
|
||||
|
||||
service.stub {
|
||||
on { blockSetDetails(any()) } doReturn response
|
||||
on { objectSetDetails(any()) } doReturn response
|
||||
}
|
||||
|
||||
// TESTING
|
||||
|
||||
middleware.updateDocumentTitle(command)
|
||||
middleware.objectSetTitle(command)
|
||||
|
||||
verify(service, times(1)).blockSetDetails(request)
|
||||
verify(service, times(1)).objectSetDetails(request)
|
||||
verifyNoMoreInteractions(service)
|
||||
}
|
||||
|
||||
|
@ -337,15 +337,17 @@ class MiddlewareTest {
|
|||
)
|
||||
)
|
||||
|
||||
val request = Rpc.BlockList.Set.Text.Style.Request(
|
||||
val request = Rpc.BlockText.ListSetStyle.Request(
|
||||
contextId = command.context,
|
||||
blockIds = command.targets,
|
||||
style = Block.Content.Text.Style.Checkbox
|
||||
)
|
||||
|
||||
service.stub {
|
||||
on { blockListSetTextStyle(request) } doReturn
|
||||
Rpc.BlockList.Set.Text.Style.Response(event = ResponseEvent())
|
||||
on { blockTextListSetStyle(request) } doReturn
|
||||
Rpc.BlockText.ListSetStyle.Response(
|
||||
event = ResponseEvent()
|
||||
)
|
||||
}
|
||||
|
||||
// TESTING
|
||||
|
@ -354,9 +356,9 @@ class MiddlewareTest {
|
|||
assertTrue { request.blockIds[0] == command.targets[0] }
|
||||
assertTrue { request.blockIds[1] == command.targets[1] }
|
||||
|
||||
middleware.updateTextStyle(command)
|
||||
middleware.blockTextListSetStyle(command)
|
||||
|
||||
verify(service, times(1)).blockListSetTextStyle(request)
|
||||
verify(service, times(1)).blockTextListSetStyle(request)
|
||||
verifyNoMoreInteractions(service)
|
||||
}
|
||||
|
||||
|
@ -377,7 +379,7 @@ class MiddlewareTest {
|
|||
|
||||
val position = Block.Position.Top
|
||||
|
||||
val request = Rpc.BlockList.Move.Request(
|
||||
val request = Rpc.Block.ListMoveToExistingObject.Request(
|
||||
contextId = command.ctx,
|
||||
targetContextId = command.ctx,
|
||||
position = position,
|
||||
|
@ -386,14 +388,14 @@ class MiddlewareTest {
|
|||
)
|
||||
|
||||
service.stub {
|
||||
on { blockListMove(request) } doReturn Rpc.BlockList.Move.Response(event = ResponseEvent())
|
||||
on { blockListMoveToExistingObject(request) } doReturn Rpc.Block.ListMoveToExistingObject.Response(event = ResponseEvent())
|
||||
}
|
||||
|
||||
// TESTING
|
||||
|
||||
middleware.move(command)
|
||||
middleware.blockListMoveToExistingObject(command)
|
||||
|
||||
verify(service, times(1)).blockListMove(request)
|
||||
verify(service, times(1)).blockListMoveToExistingObject(request)
|
||||
verifyNoMoreInteractions(service)
|
||||
}
|
||||
|
||||
|
@ -431,7 +433,7 @@ class MiddlewareTest {
|
|||
|
||||
// TESTING
|
||||
|
||||
middleware.paste(command)
|
||||
middleware.blockPaste(command)
|
||||
|
||||
verify(service, times(1)).blockPaste(request)
|
||||
verifyNoMoreInteractions(service)
|
||||
|
@ -466,7 +468,7 @@ class MiddlewareTest {
|
|||
|
||||
// TESTING
|
||||
|
||||
middleware.split(command)
|
||||
middleware.blockSplit(command)
|
||||
|
||||
verify(service, times(1)).blockSplit(request)
|
||||
verifyNoMoreInteractions(service)
|
||||
|
@ -484,20 +486,20 @@ class MiddlewareTest {
|
|||
type = CBlockFileType.IMAGE
|
||||
)
|
||||
|
||||
val request = Rpc.UploadFile.Request(
|
||||
val request = Rpc.File.Upload.Request(
|
||||
localPath = path,
|
||||
type = Block.Content.File.Type.Image
|
||||
)
|
||||
|
||||
service.stub {
|
||||
on { uploadFile(request) } doReturn Rpc.UploadFile.Response()
|
||||
on { fileUpload(request) } doReturn Rpc.File.Upload.Response()
|
||||
}
|
||||
|
||||
// TESTING
|
||||
|
||||
middleware.uploadFile(command)
|
||||
middleware.fileUpload(command)
|
||||
|
||||
verify(service, times(1)).uploadFile(request)
|
||||
verify(service, times(1)).fileUpload(request)
|
||||
verifyNoMoreInteractions(service)
|
||||
}
|
||||
|
||||
|
@ -513,20 +515,20 @@ class MiddlewareTest {
|
|||
type = CBlockFileType.FILE
|
||||
)
|
||||
|
||||
val request = Rpc.UploadFile.Request(
|
||||
val request = Rpc.File.Upload.Request(
|
||||
localPath = path,
|
||||
type = Block.Content.File.Type.File
|
||||
)
|
||||
|
||||
service.stub {
|
||||
on { uploadFile(request) } doReturn Rpc.UploadFile.Response()
|
||||
on { fileUpload(request) } doReturn Rpc.File.Upload.Response()
|
||||
}
|
||||
|
||||
// TESTING
|
||||
|
||||
middleware.uploadFile(command)
|
||||
middleware.fileUpload(command)
|
||||
|
||||
verify(service, times(1)).uploadFile(request)
|
||||
verify(service, times(1)).fileUpload(request)
|
||||
verifyNoMoreInteractions(service)
|
||||
}
|
||||
|
||||
|
@ -542,20 +544,20 @@ class MiddlewareTest {
|
|||
type = CBlockFileType.VIDEO
|
||||
)
|
||||
|
||||
val request = Rpc.UploadFile.Request(
|
||||
val request = Rpc.File.Upload.Request(
|
||||
localPath = path,
|
||||
type = Block.Content.File.Type.Video
|
||||
)
|
||||
|
||||
service.stub {
|
||||
on { uploadFile(request) } doReturn Rpc.UploadFile.Response()
|
||||
on { fileUpload(request) } doReturn Rpc.File.Upload.Response()
|
||||
}
|
||||
|
||||
// TESTING
|
||||
|
||||
middleware.uploadFile(command)
|
||||
middleware.fileUpload(command)
|
||||
|
||||
verify(service, times(1)).uploadFile(request)
|
||||
verify(service, times(1)).fileUpload(request)
|
||||
verifyNoMoreInteractions(service)
|
||||
}
|
||||
|
||||
|
@ -592,28 +594,28 @@ class MiddlewareTest {
|
|||
)
|
||||
|
||||
val fields = listOf(
|
||||
Rpc.BlockList.Set.Fields.Request.BlockField(
|
||||
Rpc.Block.ListSetFields.Request.BlockField(
|
||||
blockId = block1,
|
||||
fields = mapOf("lang" to "kotlin")
|
||||
),
|
||||
Rpc.BlockList.Set.Fields.Request.BlockField(
|
||||
Rpc.Block.ListSetFields.Request.BlockField(
|
||||
blockId = block2,
|
||||
fields = mapOf("lang" to "python")
|
||||
)
|
||||
)
|
||||
|
||||
val request = Rpc.BlockList.Set.Fields.Request(
|
||||
val request = Rpc.Block.ListSetFields.Request(
|
||||
contextId = ctx,
|
||||
blockFields = fields
|
||||
)
|
||||
|
||||
service.stub {
|
||||
on { blockListSetFields(request) } doReturn Rpc.BlockList.Set.Fields.Response(event = ResponseEvent())
|
||||
on { blockListSetFields(request) } doReturn Rpc.Block.ListSetFields.Response(event = ResponseEvent())
|
||||
}
|
||||
|
||||
// TESTING
|
||||
|
||||
middleware.setFields(command)
|
||||
middleware.blockListSetFields(command)
|
||||
|
||||
verify(service, times(1)).blockListSetFields(request)
|
||||
verifyNoMoreInteractions(service)
|
||||
|
|
|
@ -4,16 +4,21 @@ import androidx.lifecycle.MutableLiveData
|
|||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.anytypeio.anytype.analytics.base.Analytics
|
||||
import com.anytypeio.anytype.core_models.Account
|
||||
import com.anytypeio.anytype.core_models.exceptions.AccountIsDeletedException
|
||||
import com.anytypeio.anytype.core_utils.common.EventWrapper
|
||||
import com.anytypeio.anytype.domain.auth.interactor.ObserveAccounts
|
||||
import com.anytypeio.anytype.domain.auth.interactor.StartLoadingAccounts
|
||||
import com.anytypeio.anytype.domain.auth.model.Account
|
||||
import com.anytypeio.anytype.presentation.auth.model.SelectAccountView
|
||||
import com.anytypeio.anytype.presentation.navigation.AppNavigation
|
||||
import com.anytypeio.anytype.presentation.navigation.SupportNavigation
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.flow.*
|
||||
import kotlinx.coroutines.flow.consumeAsFlow
|
||||
import kotlinx.coroutines.flow.drop
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.flow.scan
|
||||
import kotlinx.coroutines.flow.take
|
||||
import kotlinx.coroutines.launch
|
||||
import timber.log.Timber
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import com.anytypeio.anytype.domain.config.Gateway
|
||||
|
||||
object FakeGateWay : Gateway {
|
||||
override fun obtain(): String = "anytype.io"
|
||||
override fun provide(): String = "anytype.io"
|
||||
}
|
|
@ -5,6 +5,7 @@ import com.anytypeio.anytype.domain.account.DateHelper
|
|||
import com.anytypeio.anytype.domain.account.RestoreAccount
|
||||
import com.anytypeio.anytype.domain.auth.interactor.Logout
|
||||
import com.anytypeio.anytype.domain.auth.repo.AuthRepository
|
||||
import com.anytypeio.anytype.domain.config.ConfigStorage
|
||||
import com.anytypeio.anytype.presentation.auth.account.DeletedAccountViewModel
|
||||
import com.anytypeio.anytype.presentation.util.CoroutinesTestRule
|
||||
import org.junit.Before
|
||||
|
@ -32,6 +33,9 @@ class DeleteAccountViewModelTest {
|
|||
@Mock
|
||||
lateinit var helper: DateHelper
|
||||
|
||||
@Mock
|
||||
lateinit var configStorage: ConfigStorage
|
||||
|
||||
lateinit var restoreAccount: RestoreAccount
|
||||
lateinit var logout: Logout
|
||||
|
||||
|
@ -44,7 +48,8 @@ class DeleteAccountViewModelTest {
|
|||
repo = repo
|
||||
)
|
||||
logout = Logout(
|
||||
repo = repo
|
||||
repo = repo,
|
||||
provider = configStorage
|
||||
)
|
||||
vm = DeletedAccountViewModel(
|
||||
restoreAccount = restoreAccount,
|
||||
|
|
|
@ -2,9 +2,9 @@ package com.anytypeio.anytype.presentation.auth
|
|||
|
||||
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||
import com.anytypeio.anytype.analytics.base.Analytics
|
||||
import com.anytypeio.anytype.core_models.Account
|
||||
import com.anytypeio.anytype.domain.auth.interactor.ObserveAccounts
|
||||
import com.anytypeio.anytype.domain.auth.interactor.StartLoadingAccounts
|
||||
import com.anytypeio.anytype.domain.auth.model.Account
|
||||
import com.anytypeio.anytype.presentation.auth.account.SelectAccountViewModel
|
||||
import com.anytypeio.anytype.presentation.util.CoroutinesTestRule
|
||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
|
|
|
@ -2,14 +2,17 @@ package com.anytypeio.anytype.presentation.auth
|
|||
|
||||
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||
import com.anytypeio.anytype.analytics.base.Analytics
|
||||
import com.anytypeio.anytype.core_models.Account
|
||||
import com.anytypeio.anytype.core_models.AccountSetup
|
||||
import com.anytypeio.anytype.core_models.AccountStatus
|
||||
import com.anytypeio.anytype.core_models.Config
|
||||
import com.anytypeio.anytype.core_models.FeaturesConfig
|
||||
import com.anytypeio.anytype.domain.`object`.ObjectTypesProvider
|
||||
import com.anytypeio.anytype.domain.auth.interactor.StartAccount
|
||||
import com.anytypeio.anytype.domain.auth.model.Account
|
||||
import com.anytypeio.anytype.domain.auth.repo.AuthRepository
|
||||
import com.anytypeio.anytype.domain.block.interactor.sets.StoreObjectTypes
|
||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||
import com.anytypeio.anytype.domain.config.ConfigStorage
|
||||
import com.anytypeio.anytype.domain.config.FeaturesConfigProvider
|
||||
import com.anytypeio.anytype.domain.device.PathProvider
|
||||
import com.anytypeio.anytype.presentation.auth.account.SetupSelectedAccountViewModel
|
||||
|
@ -49,6 +52,9 @@ class SetupSelectedAccountViewModelTest {
|
|||
@Mock
|
||||
lateinit var featuresConfigProvider: FeaturesConfigProvider
|
||||
|
||||
@Mock
|
||||
lateinit var configStorage: ConfigStorage
|
||||
|
||||
@Mock
|
||||
lateinit var objectTypesProvider: ObjectTypesProvider
|
||||
|
||||
|
@ -61,7 +67,8 @@ class SetupSelectedAccountViewModelTest {
|
|||
MockitoAnnotations.openMocks(this)
|
||||
startAccount = StartAccount(
|
||||
repository = authRepo,
|
||||
featuresConfigProvider = featuresConfigProvider
|
||||
featuresConfigProvider = featuresConfigProvider,
|
||||
configStorage = configStorage
|
||||
)
|
||||
storeObjectTypes = StoreObjectTypes(
|
||||
repo = blockRepo,
|
||||
|
@ -105,7 +112,7 @@ class SetupSelectedAccountViewModelTest {
|
|||
)
|
||||
}
|
||||
|
||||
// @Test
|
||||
// @Test
|
||||
fun `should hide migration-in-progress msg if succeeded to start account`() {
|
||||
|
||||
// SETUP
|
||||
|
@ -120,15 +127,20 @@ class SetupSelectedAccountViewModelTest {
|
|||
id = any(),
|
||||
path = any()
|
||||
)
|
||||
} doReturn Triple(
|
||||
Account(
|
||||
} doReturn AccountSetup(
|
||||
account = Account(
|
||||
id = MockDataFactory.randomUuid(),
|
||||
name = MockDataFactory.randomString(),
|
||||
avatar = null,
|
||||
color = null
|
||||
),
|
||||
FeaturesConfig(),
|
||||
AccountStatus.Active
|
||||
features = FeaturesConfig(),
|
||||
status = AccountStatus.Active,
|
||||
config = Config(
|
||||
home = MockDataFactory.randomUuid(),
|
||||
gateway = MockDataFactory.randomUuid(),
|
||||
profile = MockDataFactory.randomUuid()
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -150,7 +162,7 @@ class SetupSelectedAccountViewModelTest {
|
|||
)
|
||||
}
|
||||
|
||||
// @Test
|
||||
// @Test
|
||||
fun `should hide migration-in-progress msg if failed to start account`() {
|
||||
|
||||
// SETUP
|
||||
|
|
|
@ -2,13 +2,13 @@ package com.anytypeio.anytype.presentation.dashboard
|
|||
|
||||
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||
import com.anytypeio.anytype.analytics.base.Analytics
|
||||
import com.anytypeio.anytype.core_models.Account
|
||||
import com.anytypeio.anytype.core_models.Config
|
||||
import com.anytypeio.anytype.core_models.Event
|
||||
import com.anytypeio.anytype.core_models.ObjectWrapper
|
||||
import com.anytypeio.anytype.core_models.Payload
|
||||
import com.anytypeio.anytype.domain.`object`.ObjectTypesProvider
|
||||
import com.anytypeio.anytype.domain.auth.interactor.GetProfile
|
||||
import com.anytypeio.anytype.domain.auth.model.Account
|
||||
import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers
|
||||
import com.anytypeio.anytype.domain.base.Either
|
||||
import com.anytypeio.anytype.domain.block.interactor.Move
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
syntax = "proto3";
|
||||
package anytype.storage;
|
||||
option go_package = "pkg/lib/pb/storage";
|
||||
|
||||
import "models.proto";
|
||||
import "file.proto";
|
||||
import "google/protobuf/struct.proto";
|
||||
import "models.proto";
|
||||
|
||||
option go_package = "pkg/lib/pb/storage";
|
||||
|
||||
message SmartBlockSnapshot {
|
||||
map<string, uint64> state = 1;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,11 +1,10 @@
|
|||
syntax = "proto3";
|
||||
package anytype;
|
||||
|
||||
import "google/protobuf/struct.proto";
|
||||
import "models.proto";
|
||||
|
||||
option go_package = "pb";
|
||||
|
||||
import "models.proto";
|
||||
import "google/protobuf/struct.proto";
|
||||
|
||||
/*
|
||||
* Event – type of message, that could be sent from a middleware to the corresponding front-end.
|
||||
*/
|
||||
|
@ -98,7 +97,6 @@ message Event {
|
|||
google.protobuf.Struct details = 2;
|
||||
}
|
||||
|
||||
// Deprecated
|
||||
message Config {
|
||||
message Update {
|
||||
anytype.model.Account.Config config = 1;
|
||||
|
@ -306,7 +304,7 @@ message Event {
|
|||
|
||||
message Text {
|
||||
string id = 1;
|
||||
TText text = 2;
|
||||
Text text = 2;
|
||||
Style style = 3;
|
||||
Marks marks = 4;
|
||||
Checked checked = 5;
|
||||
|
@ -314,7 +312,7 @@ message Event {
|
|||
IconEmoji iconEmoji = 7;
|
||||
IconImage iconImage = 8;
|
||||
|
||||
message TText {
|
||||
message Text {
|
||||
string value = 1;
|
||||
}
|
||||
|
||||
|
@ -520,13 +518,13 @@ message Event {
|
|||
|
||||
message Text {
|
||||
string id = 1;
|
||||
TText text = 2;
|
||||
Text text = 2;
|
||||
Style style = 3;
|
||||
Marks marks = 4;
|
||||
Checked checked = 5;
|
||||
Color color = 6;
|
||||
|
||||
message TText {
|
||||
message Text {
|
||||
string value = 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
syntax = "proto3";
|
||||
package anytype.model;
|
||||
option go_package = "pkg/lib/pb/model";
|
||||
|
||||
import "google/protobuf/struct.proto";
|
||||
import "models.proto";
|
||||
|
||||
option go_package = "pkg/lib/pb/model";
|
||||
|
||||
message ObjectInfo {
|
||||
string id = 1;
|
||||
repeated string objectTypeUrls = 2; // deprecated
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
syntax = "proto3";
|
||||
package anytype.model;
|
||||
option go_package = "pkg/lib/pb/model";
|
||||
|
||||
import "google/protobuf/struct.proto";
|
||||
|
||||
option go_package = "pkg/lib/pb/model";
|
||||
|
||||
message SmartBlockSnapshotBase {
|
||||
repeated Block blocks = 1;
|
||||
google.protobuf.Struct details = 2;
|
||||
|
@ -413,6 +412,7 @@ message Account {
|
|||
Avatar avatar = 3; // Avatar of a user's account
|
||||
Config config = 4;
|
||||
Status status = 5;
|
||||
Info info = 6;
|
||||
|
||||
/**
|
||||
* Avatar of a user's account. It could be an image or color
|
||||
|
@ -423,7 +423,6 @@ message Account {
|
|||
string color = 2; // Color of the avatar, used if image not set.
|
||||
}
|
||||
}
|
||||
|
||||
message Config {
|
||||
bool enableDataview = 1;
|
||||
bool enableDebug = 2;
|
||||
|
@ -444,6 +443,18 @@ message Account {
|
|||
StartedDeletion = 2;
|
||||
Deleted = 3;
|
||||
}
|
||||
|
||||
message Info {
|
||||
string homeObjectId = 2; // home dashboard block id
|
||||
string archiveObjectId = 3; // archive block id
|
||||
string profileObjectId = 4; // profile block id
|
||||
string marketplaceTypeObjectId = 5; // marketplace type id
|
||||
string marketplaceRelationObjectId = 6; // marketplace relation id
|
||||
string marketplaceTemplateObjectId = 7; // marketplace template id
|
||||
string deviceId = 8;
|
||||
string gatewayUrl = 101; // gateway url for fetching static files
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
message LinkPreview {
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
package com.anytypeio.anytype.core_models
|
||||
|
||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
|
||||
fun StubAccountSetup(
|
||||
account : Account = StubAccount(),
|
||||
config: Config = StubConfig(),
|
||||
features: FeaturesConfig = StubFeatureConfig(),
|
||||
status: AccountStatus = AccountStatus.Active
|
||||
) : AccountSetup = AccountSetup(
|
||||
account = account,
|
||||
features = features,
|
||||
status = status,
|
||||
config = config
|
||||
)
|
||||
|
||||
fun StubAccount(
|
||||
id : Id = MockDataFactory.randomUuid(),
|
||||
name: String = MockDataFactory.randomString(),
|
||||
avatar: Url? = null,
|
||||
color: String? = null
|
||||
) : Account = Account(
|
||||
id = id,
|
||||
name = name,
|
||||
avatar = avatar,
|
||||
color = color
|
||||
)
|
||||
|
||||
fun StubConfig(
|
||||
home: Id = MockDataFactory.randomUuid(),
|
||||
profile: Id = MockDataFactory.randomUuid(),
|
||||
gateway: Url = MockDataFactory.randomUuid()
|
||||
) : Config = Config(
|
||||
home = home,
|
||||
profile = profile,
|
||||
gateway = gateway
|
||||
)
|
||||
|
||||
fun StubFeatureConfig(
|
||||
enableDataView: Boolean? = MockDataFactory.randomBoolean(),
|
||||
enableDebug: Boolean? = MockDataFactory.randomBoolean(),
|
||||
enableChannelSwitch: Boolean? = MockDataFactory.randomBoolean(),
|
||||
enableSpaces: Boolean? = MockDataFactory.randomBoolean()
|
||||
) : FeaturesConfig = FeaturesConfig(
|
||||
enableDataView = enableDataView,
|
||||
enableDebug = enableDebug,
|
||||
enableChannelSwitch = enableChannelSwitch,
|
||||
enableSpaces = enableSpaces
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue