Skip to content

Commit

Permalink
♻️ network モジュールに explicitApi を追加
Browse files Browse the repository at this point in the history
  • Loading branch information
tatsutakein committed Nov 23, 2023
1 parent 42bbcb2 commit e1c9e75
Show file tree
Hide file tree
Showing 20 changed files with 32 additions and 62 deletions.
2 changes: 2 additions & 0 deletions core/network/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ plugins {
android.namespace = "club.nito.core.network"

kotlin {
explicitApi()

sourceSets {
commonMain {
dependencies {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import club.nito.core.model.FetchSingleResult
import club.nito.core.model.UserInfo
import kotlinx.coroutines.flow.Flow

sealed interface AuthRemoteDataSource {
val authStatus: Flow<FetchSingleResult<AuthStatus>>
public sealed interface AuthRemoteDataSource {
public val authStatus: Flow<FetchSingleResult<AuthStatus>>

suspend fun signIn(email: String, password: String)
suspend fun signOut()
suspend fun modifyAuthUser(email: String?, password: String?): UserInfo
public suspend fun signIn(email: String, password: String)
public suspend fun signOut()
public suspend fun modifyAuthUser(email: String?, password: String?): UserInfo
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.launch
import kotlinx.datetime.Instant

class FakeAuthRemoteDataSource(
public class FakeAuthRemoteDataSource(
coroutineScope: CoroutineScope,
) : AuthRemoteDataSource {

Expand Down Expand Up @@ -61,13 +61,13 @@ class FakeAuthRemoteDataSource(
type = "type",
)

override suspend fun signIn(email: String, password: String) = _authStatus.emit(
override suspend fun signIn(email: String, password: String): Unit = _authStatus.emit(
FetchSingleResult.Success(
AuthStatus.Authenticated(session = authenticatedUserSession),
),
)

override suspend fun signOut() = _authStatus.emit(
override suspend fun signOut(): Unit = _authStatus.emit(
FetchSingleResult.Success(AuthStatus.NotAuthenticated),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import io.github.jan.supabase.gotrue.providers.builtin.Email
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map

class SupabaseAuthRemoteDataSource(
public class SupabaseAuthRemoteDataSource(
private val goTrue: GoTrue,
) : AuthRemoteDataSource {
override val authStatus: Flow<FetchSingleResult<AuthStatus>> = goTrue.sessionStatus.map {
Expand All @@ -37,12 +37,12 @@ class SupabaseAuthRemoteDataSource(
}
}

override suspend fun signIn(email: String, password: String) = goTrue.loginWith(Email) {
override suspend fun signIn(email: String, password: String): Unit = goTrue.loginWith(Email) {
this.email = email
this.password = password
}

override suspend fun signOut() = goTrue.logout()
override suspend fun signOut(): Unit = goTrue.logout()

override suspend fun modifyAuthUser(email: String?, password: String?): UserInfo = goTrue.modifyUser {
this.email = email
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import kotlinx.coroutines.SupervisorJob
import org.koin.core.module.Module
import org.koin.dsl.module

val fakeRemoteDataSourceModule: Module = module {
public val fakeRemoteDataSourceModule: Module = module {
single<AuthRemoteDataSource> {
FakeAuthRemoteDataSource(
coroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.Default),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import club.nito.core.network.user.UserRemoteDataSource
import org.koin.core.module.Module
import org.koin.dsl.module

val remoteDataSourceModule: Module = module {
public val remoteDataSourceModule: Module = module {
single<AuthRemoteDataSource> {
SupabaseAuthRemoteDataSource(
goTrue = get(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import kotlinx.serialization.json.Json
import org.koin.core.module.Module
import org.koin.dsl.module

val supabaseClientModule: Module = module {
public val supabaseClientModule: Module = module {
single<SupabaseClient> {
createNitoSupabaseClient(
json = get(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import club.nito.core.network.participation.model.NetworkParticipant
import club.nito.core.network.participation.model.createFakeNetworkParticipant
import kotlinx.coroutines.delay

data object FakeParticipantRemoteDataSource : ParticipantRemoteDataSource {
public data object FakeParticipantRemoteDataSource : ParticipantRemoteDataSource {
private const val DEFAULT_CHANGED_COUNT = 1L

override suspend fun getParticipants(scheduleId: String): List<Participant> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@ import club.nito.core.model.participant.ParticipantDeclaration
/**
* 参加情報を扱うリモートデータソース
*/
sealed interface ParticipantRemoteDataSource {
public sealed interface ParticipantRemoteDataSource {
/**
* 該当の予定の参加情報を取得する
*
* @param scheduleId 参加情報を取得するスケジュールID
*/
suspend fun getParticipants(scheduleId: String): List<Participant>
public suspend fun getParticipants(scheduleId: String): List<Participant>

/**
* 該当の予定の参加情報を取得する
*
* @param scheduleIds 参加情報を取得するスケジュールID配列
*/
suspend fun getParticipants(scheduleIds: List<String>): List<Participant>
public suspend fun getParticipants(scheduleIds: List<String>): List<Participant>

/**
* 該当のスケジュールに参加する
*
* @param declaration 参加表明データ
*/
suspend fun participate(declaration: ParticipantDeclaration): Long
public suspend fun participate(declaration: ParticipantDeclaration): Long
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import io.github.jan.supabase.SupabaseClient
import io.github.jan.supabase.postgrest.postgrest
import io.github.jan.supabase.postgrest.query.Returning

class SupabaseParticipantRemoteDataSource(
public class SupabaseParticipantRemoteDataSource(
private val client: SupabaseClient,
) : ParticipantRemoteDataSource {
private val postgrest = client.postgrest["participants"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import kotlinx.datetime.Instant
import kotlinx.datetime.TimeZone
import kotlinx.datetime.plus

data object FakeScheduleRemoteDataSource : ScheduleRemoteDataSource {
public data object FakeScheduleRemoteDataSource : ScheduleRemoteDataSource {
override suspend fun getScheduleList(
limit: Int,
order: Order,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import club.nito.core.model.Order
import club.nito.core.model.Schedule
import kotlinx.datetime.Instant

sealed interface ScheduleRemoteDataSource {
suspend fun getScheduleList(
public sealed interface ScheduleRemoteDataSource {
public suspend fun getScheduleList(
limit: Int,
order: Order = Order.DESCENDING,
after: Instant? = null,
): List<Schedule>

suspend fun getSchedule(id: String): Schedule
public suspend fun getSchedule(id: String): Schedule
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ private enum class Column(val columnName: String) {
SCHEDULED_AT(columnName = "scheduled_at"),
}

class SupabaseScheduleRemoteDataSource(
public class SupabaseScheduleRemoteDataSource(
private val client: SupabaseClient,
) : ScheduleRemoteDataSource {
private val log = Logger.withTag("SupabaseScheduleRemoteDataSource")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import club.nito.core.network.user.model.NetworkUserProfile
import club.nito.core.network.user.model.createFakeNetworkUserProfile
import kotlinx.coroutines.delay

data object FakeUserRemoteDataSource : UserRemoteDataSource {
public data object FakeUserRemoteDataSource : UserRemoteDataSource {
private const val DEFAULT_CHANGED_COUNT = 1L

override suspend fun getProfile(userId: String): UserProfile? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import club.nito.core.network.user.model.NetworkUserProfile
import io.github.jan.supabase.SupabaseClient
import io.github.jan.supabase.postgrest.postgrest

class SupabaseUserRemoteDataSource(
public class SupabaseUserRemoteDataSource(
private val client: SupabaseClient,
) : UserRemoteDataSource {
private val postgrest = client.postgrest["profiles"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import club.nito.core.model.UserProfile
/**
* ユーザープロフィールに関するリポジトリ
*/
sealed interface UserRemoteDataSource {
public sealed interface UserRemoteDataSource {
/**
* ユーザープロフィールを取得する
*/
suspend fun getProfile(userId: String): UserProfile?
public suspend fun getProfile(userId: String): UserProfile?

/**
* 複数のユーザープロフィールを取得する
*/
suspend fun getProfiles(userIds: List<String>): List<UserProfile>
public suspend fun getProfiles(userIds: List<String>): List<UserProfile>
}

This file was deleted.

0 comments on commit e1c9e75

Please sign in to comment.