Skip to content
Snippets Groups Projects
Commit 99912e0a authored by Kamal Bramwell's avatar Kamal Bramwell
Browse files

Merge branch 'FE-977_api_architecture' into development

parents 8fdd9819 dcbfadbf
No related branches found
No related tags found
No related merge requests found
Showing
with 285 additions and 1 deletion
......@@ -7,6 +7,7 @@
<option name="testRunner" value="GRADLE" />
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="11" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
......
......@@ -33,6 +33,9 @@ android {
}
dependencies {
implementation(fileTree(mapOf("include" to listOf("*.jar"), "dir" to "libs")))
implementation((project(":cmix")))
api(platform(project(":depconstraints")))
kapt(platform(project(":depconstraints")))
androidTestApi(platform(project(":depconstraints")))
......
package io.elixxir.dapp
import io.elixxir.dapp.android.model.AndroidConfig
import io.elixxir.dapp.api.model.*
import io.elixxir.dapp.logger.data.Logger
import io.elixxir.dapp.api.model.CommonProperties
import io.elixxir.dapp.api.model.DappConfig
/**
* Singleton entry point to modules provided by the dApp SDK.
*/
class DappModule private constructor(
config: DappConfig,
logger: Logger = Logger.newInstance(config.loggerConfig)
) : DappApi,
AndroidConfig by config.androidConfig,
Logger by logger,
CommonProperties
{
override val accountApi: AccountApi
get() = TODO("Not yet implemented")
override val directoryApi: DirectoryApi
get() = TODO("Not yet implemented")
override val messagesApi: MessagesApi
get() = TODO("Not yet implemented")
override val networkApi: NetworkApi
get() = TODO("Not yet implemented")
override val requestsApi: RequestsApi
get() = TODO("Not yet implemented")
override val groupsApi: GroupsApi
get() = TODO("Not yet implemented")
companion object {
@Volatile
private var instance: DappModule? = null
fun getInstance(config: DappConfig): DappModule {
return instance ?: DappModule(config).apply {
instance = this
}
}
}
}
\ No newline at end of file
package io.elixxir.dapp.android.data
import android.content.Context
import io.elixxir.dapp.android.model.AndroidConfig
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers
data class DefaultAndroidConfig(
override val context: () -> Context,
override val dispatcher: CoroutineDispatcher = Dispatchers.IO,
) : AndroidConfig
\ No newline at end of file
package io.elixxir.dapp.android.model
import android.content.Context
import kotlinx.coroutines.CoroutineDispatcher
/**
* Android-specific properties used at runtime.
*/
interface AndroidConfig {
val context: () -> Context
val dispatcher: CoroutineDispatcher
}
\ No newline at end of file
package io.elixxir.dapp.api.data
import io.elixxir.dapp.api.model.AccountApi
import io.elixxir.dapp.backup.model.Backup
import io.elixxir.dapp.session.repository.SessionDataSource
import io.elixxir.dapp.user.model.User
import io.elixxir.dapp.user.model.UserUpdateData
import kotlinx.coroutines.*
internal class AccountModule(
private val sessionManager: SessionDataSource
) : AccountApi {
private val scope: CoroutineScope = CoroutineScope(
CoroutineName("AccountModule")
+ Job()
+ Dispatchers.Default
)
override fun getCurrentUser(): User {
TODO("Not yet implemented")
}
override fun createAccount(username: String) {
scope.launch {
sessionManager.createSession()
}
}
override fun restoreAccount(backup: Backup) {
TODO("Not yet implemented")
}
override fun updateAccount(updateData: UserUpdateData) {
TODO("Not yet implemented")
}
override fun deleteAccount() {
scope.launch {
sessionManager.deleteSession()
}
}
}
\ No newline at end of file
package io.elixxir.dapp.api.data
import io.elixxir.dapp.api.model.NetworkApi
import io.elixxir.dapp.network.model.ConnectionStatus
import io.elixxir.dapp.network.data.NetworkManager
import kotlinx.coroutines.CoroutineName
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.Flow
internal class NetworkModule(
private val networkManager: NetworkManager
) : NetworkApi {
private val scope: CoroutineScope = CoroutineScope(
CoroutineName("AccountModule")
+ Job()
+ Dispatchers.Default
)
override val connectionStatus: Flow<ConnectionStatus> by networkManager::connectionStatus
override fun connect(): Result<ConnectionStatus> {
TODO("Not yet implemented")
}
override fun disconnect(): Result<ConnectionStatus> {
TODO("Not yet implemented")
}
}
\ No newline at end of file
package io.elixxir.dapp.api.model
import io.elixxir.dapp.backup.model.Backup
import io.elixxir.dapp.user.model.User
import io.elixxir.dapp.user.model.UserUpdateData
interface AccountApi {
fun getCurrentUser(): User
fun createAccount(username: String)
fun restoreAccount(backup: Backup)
fun updateAccount(updateData: UserUpdateData)
fun deleteAccount()
}
\ No newline at end of file
package io.elixxir.dapp.api.model
import io.elixxir.dapp.android.model.AndroidConfig
import io.elixxir.dapp.logger.data.Logger
internal interface CommonProperties : Logger, AndroidConfig
\ No newline at end of file
package io.elixxir.dapp.api.model
interface DappApi {
val accountApi: AccountApi
val directoryApi: DirectoryApi
val messagesApi: MessagesApi
val networkApi: NetworkApi
val requestsApi: RequestsApi
val groupsApi: GroupsApi
}
\ No newline at end of file
package io.elixxir.dapp.api.model
import io.elixxir.dapp.android.model.AndroidConfig
import io.elixxir.dapp.logger.model.LoggerConfig
import io.elixxir.dapp.network.model.NetworkConfig
/**
* Describes configurable options, and satisfies dependencies for,
* modules exposed by the dApps Kotlin SDK.
*/
interface DappConfig {
val androidConfig: AndroidConfig
val loggerConfig: LoggerConfig
val networkConfig: NetworkConfig
}
\ No newline at end of file
package io.elixxir.dapp.api.model
import io.elixxir.dapp.user.model.User
import io.elixxir.dapp.user.model.UserQuery
interface DirectoryApi {
fun getContacts(): List<User>
fun findUser(params: UserQuery): User?
fun blockUser(user: User)
}
\ No newline at end of file
package io.elixxir.dapp.api.model
import io.elixxir.dapp.group.model.Group
import io.elixxir.dapp.messaging.model.Message
import io.elixxir.dapp.user.model.User
import kotlinx.coroutines.flow.Flow
interface GroupsApi {
val groupMessages: Flow<Message>
fun sendInvitation(group: Group)
fun resendInvitation(member: User)
fun joinGroup(group: Group)
fun leaveGroup(group: Group)
fun sendMessage(message: Message, group: Group)
fun retryMessage(message: Message, group: Group)
}
\ No newline at end of file
package io.elixxir.dapp.api.model
import io.elixxir.dapp.messaging.model.Message
import io.elixxir.dapp.user.model.User
import kotlinx.coroutines.flow.Flow
interface MessagesApi {
val messages: Flow<Message>
fun sendMessage(message: Message, recipient: User)
fun retryMessage(message: Message, recipient: User)
}
\ No newline at end of file
package io.elixxir.dapp.api.model
import io.elixxir.dapp.network.model.ConnectionStatus
import kotlinx.coroutines.flow.Flow
interface NetworkApi {
val connectionStatus: Flow<ConnectionStatus>
fun connect(): Result<ConnectionStatus>
fun disconnect(): Result<ConnectionStatus>
}
\ No newline at end of file
package io.elixxir.dapp.api.model
import io.elixxir.dapp.request.model.IncomingRequest
import io.elixxir.dapp.request.model.Request
import io.elixxir.dapp.request.model.OutgoingRequest
import kotlinx.coroutines.flow.Flow
interface RequestsApi {
val requests: Flow<Request>
fun sendRequest(request: OutgoingRequest)
fun acceptRequest(request: IncomingRequest)
fun retryRequest(request: Request)
}
\ No newline at end of file
package io.elixxir.dapp.api.model
interface RetryStrategy {
val maxRetries: Int
val retryDelayMs: Long
}
/**
* Remote data that is critical to the function of the SDK.
* Generally means many retries and reasonable delay to not
* overwhelm network resources.
*/
data class CriticalRemoteDataStrategy(
override val maxRetries: Int = 29,
override val retryDelayMs: Long = 1000L
) : RetryStrategy
\ No newline at end of file
package io.elixxir.dapp.backup.model
interface Backup {
}
\ No newline at end of file
package io.elixxir.dapp.bindings.data
import bindings.AuthCallbacks
interface AuthEventListener {
fun onConfirm(var1: ByteArray?, var2: ByteArray?, var3: Long, var5: Long)
fun onRequest(var1: ByteArray?, var2: ByteArray?, var3: Long, var5: Long)
fun onReset(var1: ByteArray?, var2: ByteArray?, var3: Long, var5: Long)
}
@JvmInline
internal value class AuthCallbacksAdapter(val value: AuthCallbacks)
\ No newline at end of file
package io.elixxir.dapp.bindings.data
internal interface Backup {
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment