-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restructure data layer. Custom models in
:data-common
, GraphQL sche…
…ma and queries in `:data-runtime-cloud` with mappers.
- Loading branch information
1 parent
7d465c9
commit 7b7fa95
Showing
19 changed files
with
400 additions
and
129 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,3 @@ | ||
plugins { | ||
id("kstreamlined.kmm.jvm-and-ios") | ||
} | ||
|
||
kotlin { | ||
sourceSets { | ||
commonMain { | ||
dependencies { | ||
api(project(":kmm:apollo-models")) | ||
implementation(libs.kotlinx.coroutines.core) | ||
} | ||
} | ||
} | ||
} |
11 changes: 5 additions & 6 deletions
11
...mon/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmm/data/feed/FeedRepo.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,16 @@ | ||
package io.github.reactivecircus.kstreamlined.kmm.data.feed | ||
|
||
import io.github.reactivecircus.kstreamlined.kmm.apollo.FeedEntriesQuery | ||
import io.github.reactivecircus.kstreamlined.kmm.apollo.FeedSourcesQuery | ||
import io.github.reactivecircus.kstreamlined.kmm.apollo.type.FeedSourceKey | ||
import io.github.reactivecircus.kstreamlined.kmm.data.feed.model.FeedEntry | ||
import io.github.reactivecircus.kstreamlined.kmm.data.feed.model.FeedSource | ||
|
||
interface FeedRepo { | ||
|
||
suspend fun loadFeedSources( | ||
refresh: Boolean = false | ||
): List<FeedSourcesQuery.FeedSource> | ||
): List<FeedSource> | ||
|
||
suspend fun loadFeedEntries( | ||
filters: List<FeedSourceKey>? = null, | ||
filters: List<FeedSource.Key>? = null, | ||
refresh: Boolean = false, | ||
): List<FeedEntriesQuery.FeedEntry> | ||
): List<FeedEntry> | ||
} |
43 changes: 43 additions & 0 deletions
43
.../commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmm/data/feed/model/FeedEntry.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package io.github.reactivecircus.kstreamlined.kmm.data.feed.model | ||
|
||
sealed interface FeedEntry { | ||
val id: String | ||
val title: String | ||
val publishTimestamp: String | ||
val contentUrl: String | ||
|
||
data class KotlinBlog( | ||
override val id: String, | ||
override val title: String, | ||
override val publishTimestamp: String, | ||
override val contentUrl: String, | ||
val featuredImageUrl: String, | ||
val description: String, | ||
) : FeedEntry | ||
|
||
data class KotlinYouTube( | ||
override val id: String, | ||
override val title: String, | ||
override val publishTimestamp: String, | ||
override val contentUrl: String, | ||
val thumbnailUrl: String, | ||
val description: String, | ||
) : FeedEntry | ||
|
||
data class TalkingKotlin( | ||
override val id: String, | ||
override val title: String, | ||
override val publishTimestamp: String, | ||
override val contentUrl: String, | ||
val podcastLogoUrl: String, | ||
val tags: List<String>, | ||
) : FeedEntry | ||
|
||
data class KotlinWeekly( | ||
override val id: String, | ||
override val title: String, | ||
override val publishTimestamp: String, | ||
override val contentUrl: String, | ||
val newsletterLogoUrl: String, | ||
) : FeedEntry | ||
} |
14 changes: 14 additions & 0 deletions
14
...commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmm/data/feed/model/FeedSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package io.github.reactivecircus.kstreamlined.kmm.data.feed.model | ||
|
||
data class FeedSource( | ||
val key: Key, | ||
val title: String, | ||
val description: String, | ||
) { | ||
enum class Key { | ||
KotlinBlog, | ||
KotlinYouTubeChannel, | ||
TalkingKotlinPodcast, | ||
KotlinWeekly, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...ain/kotlin/io/github/reactivecircus/kstreamlined/kmm/data/feed/mapper/FeedEntryMappers.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package io.github.reactivecircus.kstreamlined.kmm.data.feed.mapper | ||
|
||
import io.github.reactivecircus.kstreamlined.graphql.FeedEntriesQuery | ||
import io.github.reactivecircus.kstreamlined.kmm.data.feed.model.FeedEntry | ||
|
||
internal fun FeedEntriesQuery.FeedEntry.toModel(): FeedEntry { | ||
return when (this) { | ||
is FeedEntriesQuery.KotlinBlogFeedEntry -> this.toModel() | ||
is FeedEntriesQuery.KotlinYouTubeFeedEntry -> this.toModel() | ||
is FeedEntriesQuery.TalkingKotlinFeedEntry -> this.toModel() | ||
is FeedEntriesQuery.KotlinWeeklyFeedEntry -> this.toModel() | ||
else -> error("Unknown FeedEntry subtype") | ||
} | ||
} | ||
|
||
internal fun FeedEntriesQuery.KotlinBlogFeedEntry.toModel(): FeedEntry.KotlinBlog { | ||
return FeedEntry.KotlinBlog( | ||
id = this.id, | ||
title = this.title, | ||
publishTimestamp = this.publishTimestamp, | ||
contentUrl = this.contentUrl, | ||
featuredImageUrl = this.featuredImageUrl, | ||
description = this.description, | ||
) | ||
} | ||
|
||
internal fun FeedEntriesQuery.KotlinYouTubeFeedEntry.toModel(): FeedEntry.KotlinYouTube { | ||
return FeedEntry.KotlinYouTube( | ||
id = this.id, | ||
title = this.title, | ||
publishTimestamp = this.publishTimestamp, | ||
contentUrl = this.contentUrl, | ||
thumbnailUrl = this.thumbnailUrl, | ||
description = this.description, | ||
) | ||
} | ||
|
||
internal fun FeedEntriesQuery.TalkingKotlinFeedEntry.toModel(): FeedEntry.TalkingKotlin { | ||
return FeedEntry.TalkingKotlin( | ||
id = this.id, | ||
title = this.title, | ||
publishTimestamp = this.publishTimestamp, | ||
contentUrl = this.contentUrl, | ||
podcastLogoUrl = this.podcastLogoUrl, | ||
tags = this.tags, | ||
) | ||
} | ||
|
||
internal fun FeedEntriesQuery.KotlinWeeklyFeedEntry.toModel(): FeedEntry.KotlinWeekly { | ||
return FeedEntry.KotlinWeekly( | ||
id = this.id, | ||
title = this.title, | ||
publishTimestamp = this.publishTimestamp, | ||
contentUrl = this.contentUrl, | ||
newsletterLogoUrl = this.newsletterLogoUrl, | ||
) | ||
} |
28 changes: 28 additions & 0 deletions
28
...in/kotlin/io/github/reactivecircus/kstreamlined/kmm/data/feed/mapper/FeedSourceMappers.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package io.github.reactivecircus.kstreamlined.kmm.data.feed.mapper | ||
|
||
import io.github.reactivecircus.kstreamlined.graphql.FeedSourcesQuery | ||
import io.github.reactivecircus.kstreamlined.graphql.type.FeedSourceKey | ||
import io.github.reactivecircus.kstreamlined.kmm.data.feed.model.FeedSource | ||
|
||
internal fun FeedSource.Key.toApollo(): FeedSourceKey { | ||
return when (this) { | ||
FeedSource.Key.KotlinBlog -> FeedSourceKey.KOTLIN_BLOG | ||
FeedSource.Key.KotlinYouTubeChannel -> FeedSourceKey.KOTLIN_YOUTUBE_CHANNEL | ||
FeedSource.Key.TalkingKotlinPodcast -> FeedSourceKey.TALKING_KOTLIN_PODCAST | ||
FeedSource.Key.KotlinWeekly -> FeedSourceKey.KOTLIN_WEEKLY | ||
} | ||
} | ||
|
||
internal fun FeedSourcesQuery.FeedSource.toModel(): FeedSource { | ||
return FeedSource( | ||
key = when (this.key) { | ||
FeedSourceKey.KOTLIN_BLOG -> FeedSource.Key.KotlinBlog | ||
FeedSourceKey.KOTLIN_YOUTUBE_CHANNEL -> FeedSource.Key.KotlinYouTubeChannel | ||
FeedSourceKey.TALKING_KOTLIN_PODCAST -> FeedSource.Key.TalkingKotlinPodcast | ||
FeedSourceKey.KOTLIN_WEEKLY -> FeedSource.Key.KotlinWeekly | ||
else -> error("Unknown FeedSourceKey subtype") | ||
}, | ||
title = this.title, | ||
description = this.description, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.