From 6c6d5c9f8915b79ae692b238130ebf79fc5bf523 Mon Sep 17 00:00:00 2001 From: Yang Date: Sun, 7 Jan 2024 16:24:03 +0800 Subject: [PATCH] `feed-datasource` -> `networking`. --- android/app/build.gradle.kts | 8 ++-- .../kstreamlined/android/di/EdgeDataModule.kt | 8 ++-- .../android/di/CloudDataModule.kt | 8 ++-- .../android/di/NetworkingModule.kt | 2 +- .../kstreamlined/android/di/DataModule.kt | 6 +-- .../kstreamlined/android/di/MockDataModule.kt | 8 ++-- kmp/data/build.gradle.kts | 2 +- .../kmp/data/feed/FeedRepository.kt | 8 ++-- .../mapper/KotlinWeeklyIssueItemMappers.kt | 2 +- .../KotlinWeeklyIssueItemMappersTest.kt | 2 +- .../kmp/feed/datasource/FeedDataSource.kt | 21 ---------- .../kmp/feed/datasource/EdgeFeedDataSource.kt | 23 ----------- .../cloud/build.gradle.kts | 2 +- .../commonMain/graphql/FeedEntries.graphql | 0 .../commonMain/graphql/FeedSources.graphql | 0 .../graphql/KotlinWeeklyIssue.graphql | 0 .../src/commonMain/graphql/schema.graphqls | 0 .../kmp/networking/CloudFeedService.kt} | 22 +++++------ .../networking/apollo}/ApolloClientConfigs.kt | 2 +- .../networking/apollo}/DefaultFetchPolicy.kt | 2 +- .../networking}/mapper/FeedEntryMappers.kt | 4 +- .../networking}/mapper/FeedSourceMappers.kt | 4 +- .../mapper/KotlinWeeklyIssueEntryMappers.kt | 4 +- .../kmp/networking/CloudFeedServiceTest.kt} | 38 +++++++++---------- .../mapper/FeedEntryMappersTest.kt | 4 +- .../mapper/FeedSourceMappersTest.kt | 4 +- .../KotlinWeeklyIssueEntryMappersTest.kt | 4 +- .../common/build.gradle.kts | 0 .../kmp/networking/FeedService.kt | 21 ++++++++++ .../kmp/networking}/model/FeedEntry.kt | 2 +- .../kmp/networking}/model/FeedSource.kt | 2 +- .../model/KotlinWeeklyIssueEntry.kt | 2 +- .../edge/build.gradle.kts | 2 +- .../kmp/networking/EdgeFeedService.kt | 23 +++++++++++ .../testing/build.gradle.kts | 2 +- .../kmp/networking}/FakeFeedData.kt | 8 ++-- .../kmp/networking/FakeFeedService.kt} | 16 ++++---- .../kmp/networking/FakeFeedServiceTest.kt} | 30 +++++++-------- settings.gradle.kts | 12 +++--- 39 files changed, 154 insertions(+), 154 deletions(-) delete mode 100644 kmp/feed-datasource/common/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/FeedDataSource.kt delete mode 100644 kmp/feed-datasource/edge/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/EdgeFeedDataSource.kt rename kmp/{feed-datasource => networking}/cloud/build.gradle.kts (95%) rename kmp/{feed-datasource => networking}/cloud/src/commonMain/graphql/FeedEntries.graphql (100%) rename kmp/{feed-datasource => networking}/cloud/src/commonMain/graphql/FeedSources.graphql (100%) rename kmp/{feed-datasource => networking}/cloud/src/commonMain/graphql/KotlinWeeklyIssue.graphql (100%) rename kmp/{feed-datasource => networking}/cloud/src/commonMain/graphql/schema.graphqls (100%) rename kmp/{feed-datasource/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/CloudFeedDataSource.kt => networking/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/CloudFeedService.kt} (66%) rename kmp/{feed-datasource/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/networking => networking/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/apollo}/ApolloClientConfigs.kt (88%) rename kmp/{feed-datasource/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/networking => networking/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/apollo}/DefaultFetchPolicy.kt (86%) rename kmp/{feed-datasource/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource => networking/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking}/mapper/FeedEntryMappers.kt (92%) rename kmp/{feed-datasource/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource => networking/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking}/mapper/FeedSourceMappers.kt (87%) rename kmp/{feed-datasource/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource => networking/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking}/mapper/KotlinWeeklyIssueEntryMappers.kt (85%) rename kmp/{feed-datasource/cloud/src/commonTest/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/CloudFeedDataSourceTest.kt => networking/cloud/src/commonTest/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/CloudFeedServiceTest.kt} (87%) rename kmp/{feed-datasource/cloud/src/commonTest/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource => networking/cloud/src/commonTest/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking}/mapper/FeedEntryMappersTest.kt (96%) rename kmp/{feed-datasource/cloud/src/commonTest/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource => networking/cloud/src/commonTest/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking}/mapper/FeedSourceMappersTest.kt (92%) rename kmp/{feed-datasource/cloud/src/commonTest/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource => networking/cloud/src/commonTest/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking}/mapper/KotlinWeeklyIssueEntryMappersTest.kt (95%) rename kmp/{feed-datasource => networking}/common/build.gradle.kts (100%) create mode 100644 kmp/networking/common/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/FeedService.kt rename kmp/{feed-datasource/common/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource => networking/common/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking}/model/FeedEntry.kt (94%) rename kmp/{feed-datasource/common/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource => networking/common/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking}/model/FeedSource.kt (77%) rename kmp/{feed-datasource/common/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource => networking/common/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking}/model/KotlinWeeklyIssueEntry.kt (80%) rename kmp/{feed-datasource => networking}/edge/build.gradle.kts (87%) create mode 100644 kmp/networking/edge/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/EdgeFeedService.kt rename kmp/{feed-datasource => networking}/testing/build.gradle.kts (86%) rename kmp/{feed-datasource/testing/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource => networking/testing/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking}/FakeFeedData.kt (94%) rename kmp/{feed-datasource/testing/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/FakeFeedDataSource.kt => networking/testing/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/FakeFeedService.kt} (53%) rename kmp/{feed-datasource/testing/src/commonTest/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/FakeFeedDataSourceTest.kt => networking/testing/src/commonTest/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/FakeFeedServiceTest.kt} (57%) diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index 0fd3c661..1d5ac2ff 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -227,10 +227,10 @@ androidComponents { } dependencies { - mockImplementation(project(":kmp:feed-datasource:testing")) - demoImplementation(project(":kmp:feed-datasource:edge")) - devImplementation(project(":kmp:feed-datasource:cloud")) - prodImplementation(project(":kmp:feed-datasource:cloud")) + mockImplementation(project(":kmp:networking:testing")) + demoImplementation(project(":kmp:networking:edge")) + devImplementation(project(":kmp:networking:cloud")) + prodImplementation(project(":kmp:networking:cloud")) implementation(project(":kmp:persistence")) implementation(project(":kmp:data")) diff --git a/android/app/src/demo/java/io/github/reactivecircus/kstreamlined/android/di/EdgeDataModule.kt b/android/app/src/demo/java/io/github/reactivecircus/kstreamlined/android/di/EdgeDataModule.kt index 64dc91b5..8c8aeeb1 100644 --- a/android/app/src/demo/java/io/github/reactivecircus/kstreamlined/android/di/EdgeDataModule.kt +++ b/android/app/src/demo/java/io/github/reactivecircus/kstreamlined/android/di/EdgeDataModule.kt @@ -4,8 +4,8 @@ import dagger.Module import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.components.SingletonComponent -import io.github.reactivecircus.kstreamlined.kmp.feed.datasource.EdgeFeedDataSource -import io.github.reactivecircus.kstreamlined.kmp.feed.datasource.FeedDataSource +import io.github.reactivecircus.kstreamlined.kmp.networking.EdgeFeedService +import io.github.reactivecircus.kstreamlined.kmp.networking.FeedService import javax.inject.Singleton @Module @@ -14,7 +14,7 @@ object EdgeDataModule { @Provides @Singleton - fun feedDataSource(): FeedDataSource { - return EdgeFeedDataSource() + fun feedService(): FeedService { + return EdgeFeedService() } } diff --git a/android/app/src/devAndProd/java/io/github/reactivecircus/kstreamlined/android/di/CloudDataModule.kt b/android/app/src/devAndProd/java/io/github/reactivecircus/kstreamlined/android/di/CloudDataModule.kt index d2421f66..fe37818e 100644 --- a/android/app/src/devAndProd/java/io/github/reactivecircus/kstreamlined/android/di/CloudDataModule.kt +++ b/android/app/src/devAndProd/java/io/github/reactivecircus/kstreamlined/android/di/CloudDataModule.kt @@ -5,8 +5,8 @@ import dagger.Module import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.components.SingletonComponent -import io.github.reactivecircus.kstreamlined.kmp.feed.datasource.CloudFeedDataSource -import io.github.reactivecircus.kstreamlined.kmp.feed.datasource.FeedDataSource +import io.github.reactivecircus.kstreamlined.kmp.networking.CloudFeedService +import io.github.reactivecircus.kstreamlined.kmp.networking.FeedService import javax.inject.Singleton @Module @@ -15,7 +15,7 @@ object CloudDataModule { @Provides @Singleton - fun feedDataSource(apolloClient: ApolloClient): FeedDataSource { - return CloudFeedDataSource(apolloClient) + fun feedService(apolloClient: ApolloClient): FeedService { + return CloudFeedService(apolloClient) } } diff --git a/android/app/src/devAndProd/java/io/github/reactivecircus/kstreamlined/android/di/NetworkingModule.kt b/android/app/src/devAndProd/java/io/github/reactivecircus/kstreamlined/android/di/NetworkingModule.kt index a7f20dec..6d59931c 100644 --- a/android/app/src/devAndProd/java/io/github/reactivecircus/kstreamlined/android/di/NetworkingModule.kt +++ b/android/app/src/devAndProd/java/io/github/reactivecircus/kstreamlined/android/di/NetworkingModule.kt @@ -9,7 +9,7 @@ import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.components.SingletonComponent import io.github.reactivecircus.kstreamlined.android.BuildConfig -import io.github.reactivecircus.kstreamlined.kmp.feed.datasource.networking.ApolloClientConfigs +import io.github.reactivecircus.kstreamlined.kmp.networking.apollo.ApolloClientConfigs import javax.inject.Singleton import kotlin.time.DurationUnit import kotlin.time.toDuration diff --git a/android/app/src/main/java/io/github/reactivecircus/kstreamlined/android/di/DataModule.kt b/android/app/src/main/java/io/github/reactivecircus/kstreamlined/android/di/DataModule.kt index b5d640b8..0607b2f0 100644 --- a/android/app/src/main/java/io/github/reactivecircus/kstreamlined/android/di/DataModule.kt +++ b/android/app/src/main/java/io/github/reactivecircus/kstreamlined/android/di/DataModule.kt @@ -5,7 +5,7 @@ import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.components.SingletonComponent import io.github.reactivecircus.kstreamlined.kmp.data.feed.FeedRepository -import io.github.reactivecircus.kstreamlined.kmp.feed.datasource.FeedDataSource +import io.github.reactivecircus.kstreamlined.kmp.networking.FeedService import javax.inject.Singleton @Module @@ -14,7 +14,7 @@ object DataModule { @Provides @Singleton - fun feedRepository(feedDataSource: FeedDataSource): FeedRepository { - return FeedRepository(feedDataSource) + fun feedRepository(feedService: FeedService): FeedRepository { + return FeedRepository(feedService) } } diff --git a/android/app/src/mock/java/io/github/reactivecircus/kstreamlined/android/di/MockDataModule.kt b/android/app/src/mock/java/io/github/reactivecircus/kstreamlined/android/di/MockDataModule.kt index 7c472174..97c24c4e 100644 --- a/android/app/src/mock/java/io/github/reactivecircus/kstreamlined/android/di/MockDataModule.kt +++ b/android/app/src/mock/java/io/github/reactivecircus/kstreamlined/android/di/MockDataModule.kt @@ -4,8 +4,8 @@ import dagger.Module import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.components.SingletonComponent -import io.github.reactivecircus.kstreamlined.kmp.feed.datasource.FakeFeedDataSource -import io.github.reactivecircus.kstreamlined.kmp.feed.datasource.FeedDataSource +import io.github.reactivecircus.kstreamlined.kmp.networking.FakeFeedService +import io.github.reactivecircus.kstreamlined.kmp.networking.FeedService import javax.inject.Singleton @Module @@ -14,7 +14,7 @@ object MockDataModule { @Provides @Singleton - fun feedDataSource(): FeedDataSource { - return FakeFeedDataSource() + fun feedService(): FeedService { + return FakeFeedService() } } diff --git a/kmp/data/build.gradle.kts b/kmp/data/build.gradle.kts index 46ddec1d..47db30f2 100644 --- a/kmp/data/build.gradle.kts +++ b/kmp/data/build.gradle.kts @@ -7,7 +7,7 @@ kotlin { sourceSets { commonMain { dependencies { - implementation(project(":kmp:feed-datasource:common")) + implementation(project(":kmp:networking:common")) implementation(project(":kmp:persistence")) api(project(":kmp:model")) implementation(libs.kotlinx.coroutines.core) diff --git a/kmp/data/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/data/feed/FeedRepository.kt b/kmp/data/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/data/feed/FeedRepository.kt index 54aaf7ae..722a0784 100644 --- a/kmp/data/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/data/feed/FeedRepository.kt +++ b/kmp/data/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/data/feed/FeedRepository.kt @@ -2,22 +2,22 @@ package io.github.reactivecircus.kstreamlined.kmp.data.feed import co.touchlab.kermit.Logger import io.github.reactivecircus.kstreamlined.kmp.data.feed.mapper.asExternalModel -import io.github.reactivecircus.kstreamlined.kmp.feed.datasource.FeedDataSource import io.github.reactivecircus.kstreamlined.kmp.model.feed.FeedItem import io.github.reactivecircus.kstreamlined.kmp.model.feed.FeedOrigin import io.github.reactivecircus.kstreamlined.kmp.model.feed.KotlinWeeklyIssueItem +import io.github.reactivecircus.kstreamlined.kmp.networking.FeedService import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.emptyFlow import kotlinx.datetime.toInstant public class FeedRepository( - private val feedDataSource: FeedDataSource + private val feedService: FeedService ) { public val feedSyncState: Flow = emptyFlow() public suspend fun syncNow() { - feedDataSource.loadFeedEntries(null, true).also { + feedService.fetchFeedEntries(null, true).also { Logger.i("<>") it.forEach { entry -> Logger.i("${entry::class.simpleName}: ${entry.title}, ${entry.publishTime}}") @@ -72,7 +72,7 @@ public class FeedRepository( public suspend fun loadKotlinWeeklyIssue(url: String): List { // TODO persist fetched entry to DB - return feedDataSource.loadKotlinWeeklyIssue(url).map { + return feedService.fetchKotlinWeeklyIssue(url).map { it.asExternalModel() } } diff --git a/kmp/data/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/data/feed/mapper/KotlinWeeklyIssueItemMappers.kt b/kmp/data/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/data/feed/mapper/KotlinWeeklyIssueItemMappers.kt index e5dc9017..b4909bac 100644 --- a/kmp/data/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/data/feed/mapper/KotlinWeeklyIssueItemMappers.kt +++ b/kmp/data/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/data/feed/mapper/KotlinWeeklyIssueItemMappers.kt @@ -1,7 +1,7 @@ package io.github.reactivecircus.kstreamlined.kmp.data.feed.mapper -import io.github.reactivecircus.kstreamlined.kmp.feed.datasource.model.KotlinWeeklyIssueEntry import io.github.reactivecircus.kstreamlined.kmp.model.feed.KotlinWeeklyIssueItem +import io.github.reactivecircus.kstreamlined.kmp.networking.model.KotlinWeeklyIssueEntry internal fun KotlinWeeklyIssueEntry.asExternalModel(): KotlinWeeklyIssueItem { return KotlinWeeklyIssueItem( diff --git a/kmp/data/src/commonTest/kotlin/io/github/reactivecircus/kstreamlined/kmp/data/feed/mapper/KotlinWeeklyIssueItemMappersTest.kt b/kmp/data/src/commonTest/kotlin/io/github/reactivecircus/kstreamlined/kmp/data/feed/mapper/KotlinWeeklyIssueItemMappersTest.kt index d0f5daad..74e10820 100644 --- a/kmp/data/src/commonTest/kotlin/io/github/reactivecircus/kstreamlined/kmp/data/feed/mapper/KotlinWeeklyIssueItemMappersTest.kt +++ b/kmp/data/src/commonTest/kotlin/io/github/reactivecircus/kstreamlined/kmp/data/feed/mapper/KotlinWeeklyIssueItemMappersTest.kt @@ -1,7 +1,7 @@ package io.github.reactivecircus.kstreamlined.kmp.data.feed.mapper -import io.github.reactivecircus.kstreamlined.kmp.feed.datasource.model.KotlinWeeklyIssueEntry import io.github.reactivecircus.kstreamlined.kmp.model.feed.KotlinWeeklyIssueItem +import io.github.reactivecircus.kstreamlined.kmp.networking.model.KotlinWeeklyIssueEntry import kotlin.test.Test import kotlin.test.assertEquals diff --git a/kmp/feed-datasource/common/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/FeedDataSource.kt b/kmp/feed-datasource/common/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/FeedDataSource.kt deleted file mode 100644 index b481906f..00000000 --- a/kmp/feed-datasource/common/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/FeedDataSource.kt +++ /dev/null @@ -1,21 +0,0 @@ -package io.github.reactivecircus.kstreamlined.kmp.feed.datasource - -import io.github.reactivecircus.kstreamlined.kmp.feed.datasource.model.FeedEntry -import io.github.reactivecircus.kstreamlined.kmp.feed.datasource.model.FeedSource -import io.github.reactivecircus.kstreamlined.kmp.feed.datasource.model.KotlinWeeklyIssueEntry - -public interface FeedDataSource { - - public suspend fun loadFeedOrigins( - refresh: Boolean = false - ): List - - public suspend fun loadFeedEntries( - filters: List? = null, - refresh: Boolean = false, - ): List - - public suspend fun loadKotlinWeeklyIssue( - url: String - ): List -} diff --git a/kmp/feed-datasource/edge/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/EdgeFeedDataSource.kt b/kmp/feed-datasource/edge/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/EdgeFeedDataSource.kt deleted file mode 100644 index 3e6f592e..00000000 --- a/kmp/feed-datasource/edge/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/EdgeFeedDataSource.kt +++ /dev/null @@ -1,23 +0,0 @@ -package io.github.reactivecircus.kstreamlined.kmp.feed.datasource - -import io.github.reactivecircus.kstreamlined.kmp.feed.datasource.model.FeedEntry -import io.github.reactivecircus.kstreamlined.kmp.feed.datasource.model.FeedSource -import io.github.reactivecircus.kstreamlined.kmp.feed.datasource.model.KotlinWeeklyIssueEntry - -public class EdgeFeedDataSource : FeedDataSource { - - override suspend fun loadFeedOrigins(refresh: Boolean): List { - TODO() - } - - override suspend fun loadFeedEntries( - filters: List?, - refresh: Boolean, - ): List { - TODO() - } - - override suspend fun loadKotlinWeeklyIssue(url: String): List { - TODO() - } -} diff --git a/kmp/feed-datasource/cloud/build.gradle.kts b/kmp/networking/cloud/build.gradle.kts similarity index 95% rename from kmp/feed-datasource/cloud/build.gradle.kts rename to kmp/networking/cloud/build.gradle.kts index c5f8d6f8..c3a8635a 100644 --- a/kmp/feed-datasource/cloud/build.gradle.kts +++ b/kmp/networking/cloud/build.gradle.kts @@ -28,7 +28,7 @@ kotlin { sourceSets { commonMain { dependencies { - api(project(":kmp:feed-datasource:common")) + api(project(":kmp:networking:common")) api(libs.apollo.runtime) api(libs.apollo.normalizedCache) implementation(libs.apollo.adapters) diff --git a/kmp/feed-datasource/cloud/src/commonMain/graphql/FeedEntries.graphql b/kmp/networking/cloud/src/commonMain/graphql/FeedEntries.graphql similarity index 100% rename from kmp/feed-datasource/cloud/src/commonMain/graphql/FeedEntries.graphql rename to kmp/networking/cloud/src/commonMain/graphql/FeedEntries.graphql diff --git a/kmp/feed-datasource/cloud/src/commonMain/graphql/FeedSources.graphql b/kmp/networking/cloud/src/commonMain/graphql/FeedSources.graphql similarity index 100% rename from kmp/feed-datasource/cloud/src/commonMain/graphql/FeedSources.graphql rename to kmp/networking/cloud/src/commonMain/graphql/FeedSources.graphql diff --git a/kmp/feed-datasource/cloud/src/commonMain/graphql/KotlinWeeklyIssue.graphql b/kmp/networking/cloud/src/commonMain/graphql/KotlinWeeklyIssue.graphql similarity index 100% rename from kmp/feed-datasource/cloud/src/commonMain/graphql/KotlinWeeklyIssue.graphql rename to kmp/networking/cloud/src/commonMain/graphql/KotlinWeeklyIssue.graphql diff --git a/kmp/feed-datasource/cloud/src/commonMain/graphql/schema.graphqls b/kmp/networking/cloud/src/commonMain/graphql/schema.graphqls similarity index 100% rename from kmp/feed-datasource/cloud/src/commonMain/graphql/schema.graphqls rename to kmp/networking/cloud/src/commonMain/graphql/schema.graphqls diff --git a/kmp/feed-datasource/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/CloudFeedDataSource.kt b/kmp/networking/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/CloudFeedService.kt similarity index 66% rename from kmp/feed-datasource/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/CloudFeedDataSource.kt rename to kmp/networking/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/CloudFeedService.kt index 05e9aae9..90e49d9e 100644 --- a/kmp/feed-datasource/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/CloudFeedDataSource.kt +++ b/kmp/networking/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/CloudFeedService.kt @@ -1,4 +1,4 @@ -package io.github.reactivecircus.kstreamlined.kmp.feed.datasource +package io.github.reactivecircus.kstreamlined.kmp.networking import co.touchlab.kermit.Logger import com.apollographql.apollo3.ApolloClient @@ -6,16 +6,16 @@ import com.apollographql.apollo3.api.Optional import io.github.reactivecircus.kstreamlined.graphql.FeedEntriesQuery import io.github.reactivecircus.kstreamlined.graphql.FeedSourcesQuery import io.github.reactivecircus.kstreamlined.graphql.KotlinWeeklyIssueQuery -import io.github.reactivecircus.kstreamlined.kmp.feed.datasource.mapper.asApolloModel -import io.github.reactivecircus.kstreamlined.kmp.feed.datasource.mapper.asExternalModel -import io.github.reactivecircus.kstreamlined.kmp.feed.datasource.model.FeedEntry -import io.github.reactivecircus.kstreamlined.kmp.feed.datasource.model.FeedSource -import io.github.reactivecircus.kstreamlined.kmp.feed.datasource.model.KotlinWeeklyIssueEntry -import io.github.reactivecircus.kstreamlined.kmp.feed.datasource.networking.defaultFetchPolicy +import io.github.reactivecircus.kstreamlined.kmp.networking.apollo.defaultFetchPolicy +import io.github.reactivecircus.kstreamlined.kmp.networking.mapper.asApolloModel +import io.github.reactivecircus.kstreamlined.kmp.networking.mapper.asExternalModel +import io.github.reactivecircus.kstreamlined.kmp.networking.model.FeedEntry +import io.github.reactivecircus.kstreamlined.kmp.networking.model.FeedSource +import io.github.reactivecircus.kstreamlined.kmp.networking.model.KotlinWeeklyIssueEntry -public class CloudFeedDataSource(private val apolloClient: ApolloClient) : FeedDataSource { +public class CloudFeedService(private val apolloClient: ApolloClient) : FeedService { - override suspend fun loadFeedOrigins(refresh: Boolean): List { + override suspend fun fetchFeedOrigins(refresh: Boolean): List { return runCatching { apolloClient.query(FeedSourcesQuery()) .defaultFetchPolicy(refresh) @@ -27,7 +27,7 @@ public class CloudFeedDataSource(private val apolloClient: ApolloClient) : FeedD }.getOrThrow().mapNotNull { it.asExternalModel() } } - override suspend fun loadFeedEntries( + override suspend fun fetchFeedEntries( filters: List?, refresh: Boolean, ): List { @@ -46,7 +46,7 @@ public class CloudFeedDataSource(private val apolloClient: ApolloClient) : FeedD }.getOrThrow().map { it.asExternalModel() } } - override suspend fun loadKotlinWeeklyIssue( + override suspend fun fetchKotlinWeeklyIssue( url: String ): List { return runCatching { diff --git a/kmp/feed-datasource/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/networking/ApolloClientConfigs.kt b/kmp/networking/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/apollo/ApolloClientConfigs.kt similarity index 88% rename from kmp/feed-datasource/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/networking/ApolloClientConfigs.kt rename to kmp/networking/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/apollo/ApolloClientConfigs.kt index df51e07f..e96028fa 100644 --- a/kmp/feed-datasource/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/networking/ApolloClientConfigs.kt +++ b/kmp/networking/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/apollo/ApolloClientConfigs.kt @@ -1,4 +1,4 @@ -package io.github.reactivecircus.kstreamlined.kmp.feed.datasource.networking +package io.github.reactivecircus.kstreamlined.kmp.networking.apollo import com.apollographql.apollo3.cache.normalized.ApolloStore import com.apollographql.apollo3.cache.normalized.api.MemoryCacheFactory diff --git a/kmp/feed-datasource/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/networking/DefaultFetchPolicy.kt b/kmp/networking/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/apollo/DefaultFetchPolicy.kt similarity index 86% rename from kmp/feed-datasource/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/networking/DefaultFetchPolicy.kt rename to kmp/networking/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/apollo/DefaultFetchPolicy.kt index 49de5c6c..2f4c8d30 100644 --- a/kmp/feed-datasource/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/networking/DefaultFetchPolicy.kt +++ b/kmp/networking/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/apollo/DefaultFetchPolicy.kt @@ -1,4 +1,4 @@ -package io.github.reactivecircus.kstreamlined.kmp.feed.datasource.networking +package io.github.reactivecircus.kstreamlined.kmp.networking.apollo import com.apollographql.apollo3.ApolloCall import com.apollographql.apollo3.api.Operation diff --git a/kmp/feed-datasource/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/mapper/FeedEntryMappers.kt b/kmp/networking/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/mapper/FeedEntryMappers.kt similarity index 92% rename from kmp/feed-datasource/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/mapper/FeedEntryMappers.kt rename to kmp/networking/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/mapper/FeedEntryMappers.kt index 6d706316..d43b3aa5 100644 --- a/kmp/feed-datasource/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/mapper/FeedEntryMappers.kt +++ b/kmp/networking/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/mapper/FeedEntryMappers.kt @@ -1,7 +1,7 @@ -package io.github.reactivecircus.kstreamlined.kmp.feed.datasource.mapper +package io.github.reactivecircus.kstreamlined.kmp.networking.mapper import io.github.reactivecircus.kstreamlined.graphql.FeedEntriesQuery -import io.github.reactivecircus.kstreamlined.kmp.feed.datasource.model.FeedEntry +import io.github.reactivecircus.kstreamlined.kmp.networking.model.FeedEntry internal fun FeedEntriesQuery.FeedEntry.asExternalModel(): FeedEntry { return when (this) { diff --git a/kmp/feed-datasource/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/mapper/FeedSourceMappers.kt b/kmp/networking/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/mapper/FeedSourceMappers.kt similarity index 87% rename from kmp/feed-datasource/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/mapper/FeedSourceMappers.kt rename to kmp/networking/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/mapper/FeedSourceMappers.kt index 962ca521..d77a480a 100644 --- a/kmp/feed-datasource/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/mapper/FeedSourceMappers.kt +++ b/kmp/networking/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/mapper/FeedSourceMappers.kt @@ -1,8 +1,8 @@ -package io.github.reactivecircus.kstreamlined.kmp.feed.datasource.mapper +package io.github.reactivecircus.kstreamlined.kmp.networking.mapper import io.github.reactivecircus.kstreamlined.graphql.FeedSourcesQuery import io.github.reactivecircus.kstreamlined.graphql.type.FeedSourceKey -import io.github.reactivecircus.kstreamlined.kmp.feed.datasource.model.FeedSource +import io.github.reactivecircus.kstreamlined.kmp.networking.model.FeedSource internal fun FeedSource.Key.asApolloModel(): FeedSourceKey { return when (this) { diff --git a/kmp/feed-datasource/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/mapper/KotlinWeeklyIssueEntryMappers.kt b/kmp/networking/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/mapper/KotlinWeeklyIssueEntryMappers.kt similarity index 85% rename from kmp/feed-datasource/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/mapper/KotlinWeeklyIssueEntryMappers.kt rename to kmp/networking/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/mapper/KotlinWeeklyIssueEntryMappers.kt index 6df56b32..601b1f09 100644 --- a/kmp/feed-datasource/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/mapper/KotlinWeeklyIssueEntryMappers.kt +++ b/kmp/networking/cloud/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/mapper/KotlinWeeklyIssueEntryMappers.kt @@ -1,8 +1,8 @@ -package io.github.reactivecircus.kstreamlined.kmp.feed.datasource.mapper +package io.github.reactivecircus.kstreamlined.kmp.networking.mapper import io.github.reactivecircus.kstreamlined.graphql.KotlinWeeklyIssueQuery import io.github.reactivecircus.kstreamlined.graphql.type.KotlinWeeklyIssueEntryGroup -import io.github.reactivecircus.kstreamlined.kmp.feed.datasource.model.KotlinWeeklyIssueEntry +import io.github.reactivecircus.kstreamlined.kmp.networking.model.KotlinWeeklyIssueEntry internal fun KotlinWeeklyIssueQuery.KotlinWeeklyIssueEntry.asExternalModel(): KotlinWeeklyIssueEntry? { return KotlinWeeklyIssueEntry( diff --git a/kmp/feed-datasource/cloud/src/commonTest/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/CloudFeedDataSourceTest.kt b/kmp/networking/cloud/src/commonTest/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/CloudFeedServiceTest.kt similarity index 87% rename from kmp/feed-datasource/cloud/src/commonTest/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/CloudFeedDataSourceTest.kt rename to kmp/networking/cloud/src/commonTest/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/CloudFeedServiceTest.kt index a502d30e..42a79ed9 100644 --- a/kmp/feed-datasource/cloud/src/commonTest/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/CloudFeedDataSourceTest.kt +++ b/kmp/networking/cloud/src/commonTest/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/CloudFeedServiceTest.kt @@ -1,4 +1,4 @@ -package io.github.reactivecircus.kstreamlined.kmp.feed.datasource +package io.github.reactivecircus.kstreamlined.kmp.networking import com.apollographql.apollo3.ApolloClient import com.apollographql.apollo3.cache.normalized.api.MemoryCacheFactory @@ -17,7 +17,7 @@ import io.github.reactivecircus.kstreamlined.graphql.type.buildFeedSource import io.github.reactivecircus.kstreamlined.graphql.type.buildKotlinBlog import io.github.reactivecircus.kstreamlined.graphql.type.buildKotlinWeeklyIssueEntry import io.github.reactivecircus.kstreamlined.graphql.type.buildKotlinYouTube -import io.github.reactivecircus.kstreamlined.kmp.feed.datasource.mapper.asExternalModel +import io.github.reactivecircus.kstreamlined.kmp.networking.mapper.asExternalModel import io.github.reactivecircus.kstreamlined.kmp.test.utils.runTest import kotlinx.datetime.toInstant import kotlin.test.Test @@ -25,11 +25,11 @@ import kotlin.test.assertEquals import kotlin.test.assertFailsWith import kotlin.test.assertTrue -class CloudFeedDataSourceTest { +class CloudFeedServiceTest { private lateinit var mockServer: MockServer - private lateinit var cloudFeedDataSource: CloudFeedDataSource + private lateinit var cloudFeedService: CloudFeedService private val dummyFeedSources = FeedSourcesQuery.Data { feedSources = listOf( @@ -70,7 +70,7 @@ class CloudFeedDataSourceTest { private suspend fun setUp() { mockServer = MockServer() - cloudFeedDataSource = CloudFeedDataSource( + cloudFeedService = CloudFeedService( apolloClient = ApolloClient.Builder() .serverUrl(mockServer.url()) .normalizedCache(MemoryCacheFactory()) @@ -88,7 +88,7 @@ class CloudFeedDataSourceTest { mockServer.enqueueData( FeedSourcesQuery.Data(feedSources = dummyFeedSources) ) - val actual = cloudFeedDataSource.loadFeedOrigins(refresh = true) + val actual = cloudFeedService.fetchFeedOrigins(refresh = true) assertEquals(dummyFeedSources.map { it.asExternalModel() }, actual) } @@ -97,7 +97,7 @@ class CloudFeedDataSourceTest { runTest(before = { setUp() }, after = { tearDown() }) { mockServer.enqueueString(statusCode = 404) val exception = assertFailsWith { - cloudFeedDataSource.loadFeedOrigins(refresh = true) + cloudFeedService.fetchFeedOrigins(refresh = true) } assertEquals(404, (exception.cause as ApolloHttpException).statusCode) } @@ -108,7 +108,7 @@ class CloudFeedDataSourceTest { mockServer.enqueueData( FeedSourcesQuery.Data(feedSources = dummyFeedSources) ) - val actual = cloudFeedDataSource.loadFeedOrigins(refresh = false) + val actual = cloudFeedService.fetchFeedOrigins(refresh = false) assertEquals(dummyFeedSources.map { it.asExternalModel() }, actual) } @@ -119,11 +119,11 @@ class CloudFeedDataSourceTest { mockServer.enqueueData( FeedSourcesQuery.Data(feedSources = dummyFeedSources) ) - cloudFeedDataSource.loadFeedOrigins(refresh = false) + cloudFeedService.fetchFeedOrigins(refresh = false) // 2nd request to consume cache mockServer.enqueueString(statusCode = 404) - val actual = cloudFeedDataSource.loadFeedOrigins(refresh = false) + val actual = cloudFeedService.fetchFeedOrigins(refresh = false) assertEquals(dummyFeedSources.map { it.asExternalModel() }, actual) } @@ -132,7 +132,7 @@ class CloudFeedDataSourceTest { runTest(before = { setUp() }, after = { tearDown() }) { mockServer.enqueueString(statusCode = 404) val exception = assertFailsWith { - cloudFeedDataSource.loadFeedOrigins(refresh = false) + cloudFeedService.fetchFeedOrigins(refresh = false) } assertTrue(exception.cause is CacheMissException) } @@ -143,7 +143,7 @@ class CloudFeedDataSourceTest { mockServer.enqueueData( FeedEntriesQuery.Data(feedEntries = dummyFeedEntries) ) - val actual = cloudFeedDataSource.loadFeedEntries( + val actual = cloudFeedService.fetchFeedEntries( filters = null, refresh = true, ) @@ -155,7 +155,7 @@ class CloudFeedDataSourceTest { runTest(before = { setUp() }, after = { tearDown() }) { mockServer.enqueueString(statusCode = 404) val exception = assertFailsWith { - cloudFeedDataSource.loadFeedEntries( + cloudFeedService.fetchFeedEntries( filters = null, refresh = true, ) @@ -169,7 +169,7 @@ class CloudFeedDataSourceTest { mockServer.enqueueData( FeedEntriesQuery.Data(feedEntries = dummyFeedEntries) ) - val actual = cloudFeedDataSource.loadFeedEntries( + val actual = cloudFeedService.fetchFeedEntries( filters = null, refresh = false, ) @@ -183,14 +183,14 @@ class CloudFeedDataSourceTest { mockServer.enqueueData( FeedEntriesQuery.Data(feedEntries = dummyFeedEntries) ) - cloudFeedDataSource.loadFeedEntries( + cloudFeedService.fetchFeedEntries( filters = null, refresh = false, ) // 2nd request to consume cache mockServer.enqueueString(statusCode = 404) - val actual = cloudFeedDataSource.loadFeedEntries( + val actual = cloudFeedService.fetchFeedEntries( filters = null, refresh = false, ) @@ -202,7 +202,7 @@ class CloudFeedDataSourceTest { runTest(before = { setUp() }, after = { tearDown() }) { mockServer.enqueueString(statusCode = 404) val exception = assertFailsWith { - cloudFeedDataSource.loadFeedEntries( + cloudFeedService.fetchFeedEntries( filters = null, refresh = false, ) @@ -216,7 +216,7 @@ class CloudFeedDataSourceTest { mockServer.enqueueData( KotlinWeeklyIssueQuery.Data(kotlinWeeklyIssueEntries = dummyKotlinWeeklyEntries) ) - val actual = cloudFeedDataSource.loadKotlinWeeklyIssue(url = "url") + val actual = cloudFeedService.fetchKotlinWeeklyIssue(url = "url") assertEquals(dummyKotlinWeeklyEntries.map { it.asExternalModel() }, actual) } @@ -225,7 +225,7 @@ class CloudFeedDataSourceTest { runTest(before = { setUp() }, after = { tearDown() }) { mockServer.enqueueString(statusCode = 404) val exception = assertFailsWith { - cloudFeedDataSource.loadKotlinWeeklyIssue(url = "url") + cloudFeedService.fetchKotlinWeeklyIssue(url = "url") } val apolloHttpException = exception.cause?.suppressedExceptions ?.first { it is ApolloHttpException } as ApolloHttpException diff --git a/kmp/feed-datasource/cloud/src/commonTest/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/mapper/FeedEntryMappersTest.kt b/kmp/networking/cloud/src/commonTest/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/mapper/FeedEntryMappersTest.kt similarity index 96% rename from kmp/feed-datasource/cloud/src/commonTest/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/mapper/FeedEntryMappersTest.kt rename to kmp/networking/cloud/src/commonTest/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/mapper/FeedEntryMappersTest.kt index f483e7a5..a28cac2c 100644 --- a/kmp/feed-datasource/cloud/src/commonTest/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/mapper/FeedEntryMappersTest.kt +++ b/kmp/networking/cloud/src/commonTest/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/mapper/FeedEntryMappersTest.kt @@ -1,11 +1,11 @@ -package io.github.reactivecircus.kstreamlined.kmp.feed.datasource.mapper +package io.github.reactivecircus.kstreamlined.kmp.networking.mapper import io.github.reactivecircus.kstreamlined.graphql.FeedEntriesQuery import io.github.reactivecircus.kstreamlined.graphql.type.buildKotlinBlog import io.github.reactivecircus.kstreamlined.graphql.type.buildKotlinWeekly import io.github.reactivecircus.kstreamlined.graphql.type.buildKotlinYouTube import io.github.reactivecircus.kstreamlined.graphql.type.buildTalkingKotlin -import io.github.reactivecircus.kstreamlined.kmp.feed.datasource.model.FeedEntry +import io.github.reactivecircus.kstreamlined.kmp.networking.model.FeedEntry import kotlinx.datetime.toInstant import kotlin.test.Test import kotlin.test.assertEquals diff --git a/kmp/feed-datasource/cloud/src/commonTest/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/mapper/FeedSourceMappersTest.kt b/kmp/networking/cloud/src/commonTest/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/mapper/FeedSourceMappersTest.kt similarity index 92% rename from kmp/feed-datasource/cloud/src/commonTest/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/mapper/FeedSourceMappersTest.kt rename to kmp/networking/cloud/src/commonTest/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/mapper/FeedSourceMappersTest.kt index c0d98546..5993c93c 100644 --- a/kmp/feed-datasource/cloud/src/commonTest/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/mapper/FeedSourceMappersTest.kt +++ b/kmp/networking/cloud/src/commonTest/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/mapper/FeedSourceMappersTest.kt @@ -1,8 +1,8 @@ -package io.github.reactivecircus.kstreamlined.kmp.feed.datasource.mapper +package io.github.reactivecircus.kstreamlined.kmp.networking.mapper import io.github.reactivecircus.kstreamlined.graphql.FeedSourcesQuery import io.github.reactivecircus.kstreamlined.graphql.type.FeedSourceKey -import io.github.reactivecircus.kstreamlined.kmp.feed.datasource.model.FeedSource +import io.github.reactivecircus.kstreamlined.kmp.networking.model.FeedSource import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertNull diff --git a/kmp/feed-datasource/cloud/src/commonTest/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/mapper/KotlinWeeklyIssueEntryMappersTest.kt b/kmp/networking/cloud/src/commonTest/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/mapper/KotlinWeeklyIssueEntryMappersTest.kt similarity index 95% rename from kmp/feed-datasource/cloud/src/commonTest/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/mapper/KotlinWeeklyIssueEntryMappersTest.kt rename to kmp/networking/cloud/src/commonTest/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/mapper/KotlinWeeklyIssueEntryMappersTest.kt index 19e995cb..083c7567 100644 --- a/kmp/feed-datasource/cloud/src/commonTest/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/mapper/KotlinWeeklyIssueEntryMappersTest.kt +++ b/kmp/networking/cloud/src/commonTest/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/mapper/KotlinWeeklyIssueEntryMappersTest.kt @@ -1,8 +1,8 @@ -package io.github.reactivecircus.kstreamlined.kmp.feed.datasource.mapper +package io.github.reactivecircus.kstreamlined.kmp.networking.mapper import io.github.reactivecircus.kstreamlined.graphql.KotlinWeeklyIssueQuery import io.github.reactivecircus.kstreamlined.graphql.type.KotlinWeeklyIssueEntryGroup -import io.github.reactivecircus.kstreamlined.kmp.feed.datasource.model.KotlinWeeklyIssueEntry +import io.github.reactivecircus.kstreamlined.kmp.networking.model.KotlinWeeklyIssueEntry import kotlin.test.Test import kotlin.test.assertEquals diff --git a/kmp/feed-datasource/common/build.gradle.kts b/kmp/networking/common/build.gradle.kts similarity index 100% rename from kmp/feed-datasource/common/build.gradle.kts rename to kmp/networking/common/build.gradle.kts diff --git a/kmp/networking/common/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/FeedService.kt b/kmp/networking/common/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/FeedService.kt new file mode 100644 index 00000000..6daed228 --- /dev/null +++ b/kmp/networking/common/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/FeedService.kt @@ -0,0 +1,21 @@ +package io.github.reactivecircus.kstreamlined.kmp.networking + +import io.github.reactivecircus.kstreamlined.kmp.networking.model.FeedEntry +import io.github.reactivecircus.kstreamlined.kmp.networking.model.FeedSource +import io.github.reactivecircus.kstreamlined.kmp.networking.model.KotlinWeeklyIssueEntry + +public interface FeedService { + + public suspend fun fetchFeedOrigins( + refresh: Boolean = false + ): List + + public suspend fun fetchFeedEntries( + filters: List? = null, + refresh: Boolean = false, + ): List + + public suspend fun fetchKotlinWeeklyIssue( + url: String + ): List +} diff --git a/kmp/feed-datasource/common/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/model/FeedEntry.kt b/kmp/networking/common/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/model/FeedEntry.kt similarity index 94% rename from kmp/feed-datasource/common/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/model/FeedEntry.kt rename to kmp/networking/common/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/model/FeedEntry.kt index 5cdcb94b..3b6a51b0 100644 --- a/kmp/feed-datasource/common/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/model/FeedEntry.kt +++ b/kmp/networking/common/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/model/FeedEntry.kt @@ -1,4 +1,4 @@ -package io.github.reactivecircus.kstreamlined.kmp.feed.datasource.model +package io.github.reactivecircus.kstreamlined.kmp.networking.model import kotlinx.datetime.Instant diff --git a/kmp/feed-datasource/common/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/model/FeedSource.kt b/kmp/networking/common/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/model/FeedSource.kt similarity index 77% rename from kmp/feed-datasource/common/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/model/FeedSource.kt rename to kmp/networking/common/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/model/FeedSource.kt index 84677ee3..8c563ac2 100644 --- a/kmp/feed-datasource/common/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/model/FeedSource.kt +++ b/kmp/networking/common/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/model/FeedSource.kt @@ -1,4 +1,4 @@ -package io.github.reactivecircus.kstreamlined.kmp.feed.datasource.model +package io.github.reactivecircus.kstreamlined.kmp.networking.model public data class FeedSource( val key: Key, diff --git a/kmp/feed-datasource/common/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/model/KotlinWeeklyIssueEntry.kt b/kmp/networking/common/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/model/KotlinWeeklyIssueEntry.kt similarity index 80% rename from kmp/feed-datasource/common/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/model/KotlinWeeklyIssueEntry.kt rename to kmp/networking/common/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/model/KotlinWeeklyIssueEntry.kt index b304bb4b..c96d7988 100644 --- a/kmp/feed-datasource/common/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/model/KotlinWeeklyIssueEntry.kt +++ b/kmp/networking/common/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/model/KotlinWeeklyIssueEntry.kt @@ -1,4 +1,4 @@ -package io.github.reactivecircus.kstreamlined.kmp.feed.datasource.model +package io.github.reactivecircus.kstreamlined.kmp.networking.model public data class KotlinWeeklyIssueEntry( val title: String, diff --git a/kmp/feed-datasource/edge/build.gradle.kts b/kmp/networking/edge/build.gradle.kts similarity index 87% rename from kmp/feed-datasource/edge/build.gradle.kts rename to kmp/networking/edge/build.gradle.kts index 5acfbb75..b2ad3ecd 100644 --- a/kmp/feed-datasource/edge/build.gradle.kts +++ b/kmp/networking/edge/build.gradle.kts @@ -7,7 +7,7 @@ kotlin { sourceSets { commonMain { dependencies { - api(project(":kmp:feed-datasource:common")) + api(project(":kmp:networking:common")) implementation(libs.kotlinx.coroutines.core) implementation(libs.kermit) } diff --git a/kmp/networking/edge/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/EdgeFeedService.kt b/kmp/networking/edge/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/EdgeFeedService.kt new file mode 100644 index 00000000..57991a0a --- /dev/null +++ b/kmp/networking/edge/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/EdgeFeedService.kt @@ -0,0 +1,23 @@ +package io.github.reactivecircus.kstreamlined.kmp.networking + +import io.github.reactivecircus.kstreamlined.kmp.networking.model.FeedEntry +import io.github.reactivecircus.kstreamlined.kmp.networking.model.FeedSource +import io.github.reactivecircus.kstreamlined.kmp.networking.model.KotlinWeeklyIssueEntry + +public class EdgeFeedService : FeedService { + + override suspend fun fetchFeedOrigins(refresh: Boolean): List { + TODO() + } + + override suspend fun fetchFeedEntries( + filters: List?, + refresh: Boolean, + ): List { + TODO() + } + + override suspend fun fetchKotlinWeeklyIssue(url: String): List { + TODO() + } +} diff --git a/kmp/feed-datasource/testing/build.gradle.kts b/kmp/networking/testing/build.gradle.kts similarity index 86% rename from kmp/feed-datasource/testing/build.gradle.kts rename to kmp/networking/testing/build.gradle.kts index 37424146..7c5afaae 100644 --- a/kmp/feed-datasource/testing/build.gradle.kts +++ b/kmp/networking/testing/build.gradle.kts @@ -7,7 +7,7 @@ kotlin { sourceSets { commonMain { dependencies { - api(project(":kmp:feed-datasource:common")) + api(project(":kmp:networking:common")) implementation(libs.kotlinx.coroutines.core) } } diff --git a/kmp/feed-datasource/testing/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/FakeFeedData.kt b/kmp/networking/testing/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/FakeFeedData.kt similarity index 94% rename from kmp/feed-datasource/testing/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/FakeFeedData.kt rename to kmp/networking/testing/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/FakeFeedData.kt index 92dad27c..1227a516 100644 --- a/kmp/feed-datasource/testing/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/FakeFeedData.kt +++ b/kmp/networking/testing/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/FakeFeedData.kt @@ -1,10 +1,10 @@ @file:Suppress("MaximumLineLength", "MaxLineLength") -package io.github.reactivecircus.kstreamlined.kmp.feed.datasource +package io.github.reactivecircus.kstreamlined.kmp.networking -import io.github.reactivecircus.kstreamlined.kmp.feed.datasource.model.FeedEntry -import io.github.reactivecircus.kstreamlined.kmp.feed.datasource.model.FeedSource -import io.github.reactivecircus.kstreamlined.kmp.feed.datasource.model.KotlinWeeklyIssueEntry +import io.github.reactivecircus.kstreamlined.kmp.networking.model.FeedEntry +import io.github.reactivecircus.kstreamlined.kmp.networking.model.FeedSource +import io.github.reactivecircus.kstreamlined.kmp.networking.model.KotlinWeeklyIssueEntry import kotlinx.datetime.toInstant public val FakeFeedSources: List = listOf( diff --git a/kmp/feed-datasource/testing/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/FakeFeedDataSource.kt b/kmp/networking/testing/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/FakeFeedService.kt similarity index 53% rename from kmp/feed-datasource/testing/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/FakeFeedDataSource.kt rename to kmp/networking/testing/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/FakeFeedService.kt index 8e6d6c3b..d4106743 100644 --- a/kmp/feed-datasource/testing/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/FakeFeedDataSource.kt +++ b/kmp/networking/testing/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/FakeFeedService.kt @@ -1,10 +1,10 @@ -package io.github.reactivecircus.kstreamlined.kmp.feed.datasource +package io.github.reactivecircus.kstreamlined.kmp.networking -import io.github.reactivecircus.kstreamlined.kmp.feed.datasource.model.FeedEntry -import io.github.reactivecircus.kstreamlined.kmp.feed.datasource.model.FeedSource -import io.github.reactivecircus.kstreamlined.kmp.feed.datasource.model.KotlinWeeklyIssueEntry +import io.github.reactivecircus.kstreamlined.kmp.networking.model.FeedEntry +import io.github.reactivecircus.kstreamlined.kmp.networking.model.FeedSource +import io.github.reactivecircus.kstreamlined.kmp.networking.model.KotlinWeeklyIssueEntry -public class FakeFeedDataSource : FeedDataSource { +public class FakeFeedService : FeedService { public var nextFeedSourcesResponse: suspend () -> List = { FakeFeedSources @@ -22,18 +22,18 @@ public class FakeFeedDataSource : FeedDataSource { FakeKotlinWeeklyIssueEntries } - override suspend fun loadFeedOrigins(refresh: Boolean): List { + override suspend fun fetchFeedOrigins(refresh: Boolean): List { return nextFeedSourcesResponse() } - override suspend fun loadFeedEntries( + override suspend fun fetchFeedEntries( filters: List?, refresh: Boolean, ): List { return nextFeedEntriesResponse(filters) } - override suspend fun loadKotlinWeeklyIssue(url: String): List { + override suspend fun fetchKotlinWeeklyIssue(url: String): List { return nextKotlinWeeklyIssueResponse(url) } } diff --git a/kmp/feed-datasource/testing/src/commonTest/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/FakeFeedDataSourceTest.kt b/kmp/networking/testing/src/commonTest/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/FakeFeedServiceTest.kt similarity index 57% rename from kmp/feed-datasource/testing/src/commonTest/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/FakeFeedDataSourceTest.kt rename to kmp/networking/testing/src/commonTest/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/FakeFeedServiceTest.kt index fa2159a0..2e3d3769 100644 --- a/kmp/feed-datasource/testing/src/commonTest/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/datasource/FakeFeedDataSourceTest.kt +++ b/kmp/networking/testing/src/commonTest/kotlin/io/github/reactivecircus/kstreamlined/kmp/networking/FakeFeedServiceTest.kt @@ -1,68 +1,68 @@ -package io.github.reactivecircus.kstreamlined.kmp.feed.datasource +package io.github.reactivecircus.kstreamlined.kmp.networking import kotlinx.coroutines.test.runTest import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFailsWith -class FakeFeedDataSourceTest { +class FakeFeedServiceTest { - private val fakeFeedDataSource = FakeFeedDataSource() + private val fakeFeedService = FakeFeedService() @Test fun `returns expected response when nextFeedSourcesResponse succeeds`() = runTest { - fakeFeedDataSource.nextFeedSourcesResponse = { + fakeFeedService.nextFeedSourcesResponse = { FakeFeedSources } assertEquals( FakeFeedSources, - fakeFeedDataSource.loadFeedOrigins(), + fakeFeedService.fetchFeedOrigins(), ) } @Test fun `throws exception when nextFeedSourcesResponse fails`() = runTest { - fakeFeedDataSource.nextFeedSourcesResponse = { throw IllegalStateException() } + fakeFeedService.nextFeedSourcesResponse = { throw IllegalStateException() } assertFailsWith { - fakeFeedDataSource.loadFeedOrigins() + fakeFeedService.fetchFeedOrigins() } } @Test fun `returns expected response when nextFeedEntriesResponse succeeds`() = runTest { - fakeFeedDataSource.nextFeedEntriesResponse = { + fakeFeedService.nextFeedEntriesResponse = { FakeFeedEntries } assertEquals( FakeFeedEntries, - fakeFeedDataSource.loadFeedEntries(), + fakeFeedService.fetchFeedEntries(), ) } @Test fun `throws exception when nextFeedEntriesResponse fails`() = runTest { - fakeFeedDataSource.nextFeedEntriesResponse = { throw IllegalStateException() } + fakeFeedService.nextFeedEntriesResponse = { throw IllegalStateException() } assertFailsWith { - fakeFeedDataSource.loadFeedEntries() + fakeFeedService.fetchFeedEntries() } } @Test fun `returns expected response when nextKotlinWeeklyIssueResponse succeeds`() = runTest { - fakeFeedDataSource.nextKotlinWeeklyIssueResponse = { + fakeFeedService.nextKotlinWeeklyIssueResponse = { FakeKotlinWeeklyIssueEntries } assertEquals( FakeKotlinWeeklyIssueEntries, - fakeFeedDataSource.loadKotlinWeeklyIssue("url"), + fakeFeedService.fetchKotlinWeeklyIssue("url"), ) } @Test fun `throws exception when nextKotlinWeeklyIssueResponse fails`() = runTest { - fakeFeedDataSource.nextKotlinWeeklyIssueResponse = { throw IllegalStateException() } + fakeFeedService.nextKotlinWeeklyIssueResponse = { throw IllegalStateException() } assertFailsWith { - fakeFeedDataSource.loadKotlinWeeklyIssue("url") + fakeFeedService.fetchKotlinWeeklyIssue("url") } } } diff --git a/settings.gradle.kts b/settings.gradle.kts index e4a0d561..7b448a4c 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -59,14 +59,14 @@ plugins { rootProject.name = "kstreamlined-mobile" // KMP -include(":kmp:core-utils") include(":kmp:data") -include(":kmp:feed-datasource:common") -include(":kmp:feed-datasource:cloud") -include(":kmp:feed-datasource:edge") -include(":kmp:feed-datasource:testing") -include(":kmp:model") +include(":kmp:networking:common") +include(":kmp:networking:cloud") +include(":kmp:networking:edge") +include(":kmp:networking:testing") include(":kmp:persistence") +include(":kmp:model") +include(":kmp:core-utils") include(":kmp:presentation:common") include(":kmp:presentation:content-viewer") include(":kmp:presentation:home")