diff --git a/build.gradle b/build.gradle index a2d3838b..e595f185 100644 --- a/build.gradle +++ b/build.gradle @@ -7,11 +7,12 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:7.0.4' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" - classpath "com.getkeepsafe.dexcount:dexcount-gradle-plugin:$dexcount_version" - classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version" + classpath libs.buildscript.kt.gradle + classpath libs.buildscript.kt.serialization + classpath libs.buildscript.jb.dokka + classpath libs.buildscript.gh.release + classpath libs.buildscript.android.gradle + classpath libs.buildscript.android.dexcount } } diff --git a/client/build.gradle b/client/build.gradle index 7fc6a451..2d27583d 100644 --- a/client/build.gradle +++ b/client/build.gradle @@ -40,7 +40,7 @@ kotlin { jvmMain { dependencies { - api "io.ktor:ktor-client-apache:$ktor_version" + api libs.ktor.client.apache } } diff --git a/defaultAndroidSettings.gradle b/defaultAndroidSettings.gradle index 85c77baa..389980f1 100644 --- a/defaultAndroidSettings.gradle +++ b/defaultAndroidSettings.gradle @@ -26,12 +26,12 @@ android { } } - compileSdkVersion "$android_compileSdkVersion".toInteger() - buildToolsVersion "$android_buildToolsVersion" + compileSdkVersion libs.versions.android.props.compileSdk.get().toInteger() + buildToolsVersion libs.versions.android.props.buildTools.get() defaultConfig { - minSdkVersion "$android_minSdkVersion".toInteger() - targetSdkVersion "$android_compileSdkVersion".toInteger() + minSdkVersion libs.versions.android.props.minSdk.get().toInteger() + targetSdkVersion libs.versions.android.props.compileSdk.get().toInteger() versionCode "${android_code_version}".toInteger() versionName "$version" } diff --git a/features/auth/client/src/commonMain/kotlin/dev/inmo/postssystem/features/auth/client/ui/AuthUIFSMState.kt b/features/auth/client/src/commonMain/kotlin/dev/inmo/postssystem/features/auth/client/ui/AuthUIFSMState.kt index 25830c75..0e7b5c81 100644 --- a/features/auth/client/src/commonMain/kotlin/dev/inmo/postssystem/features/auth/client/ui/AuthUIFSMState.kt +++ b/features/auth/client/src/commonMain/kotlin/dev/inmo/postssystem/features/auth/client/ui/AuthUIFSMState.kt @@ -1,14 +1,12 @@ package dev.inmo.postssystem.features.auth.client.ui import dev.inmo.postssystem.features.common.common.ui.fsm.UIFSMState +import dev.inmo.postssystem.features.common.common.ui.fsm.UIFSMStateSerializer import kotlinx.serialization.Serializable @Serializable data class AuthUIFSMState( + @Serializable(UIFSMStateSerializer::class) override val from: UIFSMState?, override val context: String = "main" -) : UIFSMState { - companion object { - val default = AuthUIFSMState(null) - } -} +) : UIFSMState diff --git a/features/auth/common/src/commonMain/kotlin/dev/inmo/postssystem/features/auth/common/AuthModels.kt b/features/auth/common/src/commonMain/kotlin/dev/inmo/postssystem/features/auth/common/AuthModels.kt index 6398c1d1..87a16e7c 100644 --- a/features/auth/common/src/commonMain/kotlin/dev/inmo/postssystem/features/auth/common/AuthModels.kt +++ b/features/auth/common/src/commonMain/kotlin/dev/inmo/postssystem/features/auth/common/AuthModels.kt @@ -3,10 +3,49 @@ package dev.inmo.postssystem.features.auth.common import com.benasher44.uuid.uuid4 import dev.inmo.postssystem.features.users.common.Username import kotlinx.serialization.* +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder import kotlin.jvm.JvmInline +@Serializable(AuthKeySerializer::class) sealed interface AuthKey +@Serializable +private data class AuthKeySurrogate( + val authCreds: AuthCreds?, + val token: AuthToken?, + val refreshToken: RefreshToken? +) + +@Serializer(AuthKey::class) +object AuthKeySerializer : KSerializer { + override val descriptor: SerialDescriptor + get() = AuthKeySurrogate.serializer().descriptor + + override fun deserialize(decoder: Decoder): AuthKey { + val surrogate = AuthKeySurrogate.serializer().deserialize(decoder) + when { + surrogate.authCreds != null -> return surrogate.authCreds + surrogate.token != null -> return surrogate.token + surrogate.refreshToken != null -> return surrogate.refreshToken + } + error("Unsupported version of auth key surrogate") + } + + override fun serialize(encoder: Encoder, value: AuthKey) { + AuthKeySurrogate.serializer().serialize( + encoder, + AuthKeySurrogate( + value as? AuthCreds, + value as? AuthToken, + value as? RefreshToken + ) + ) + } + +} + @Serializable @SerialName("authcreds") data class AuthCreds( diff --git a/features/common/client/build.gradle b/features/common/client/build.gradle index 7fc2be43..26cdd30f 100644 --- a/features/common/client/build.gradle +++ b/features/common/client/build.gradle @@ -13,8 +13,8 @@ kotlin { dependencies { api project(":postssystem.features.common.common") api libs.microutils.repos.ktor.client - api "io.ktor:ktor-client-auth:$ktor_version" - api "io.ktor:ktor-client-logging:$ktor_version" + api libs.ktor.client.auth + api libs.ktor.client.logging api libs.microutils.common.compose api libs.microutils.coroutines.compose diff --git a/features/common/common/build.gradle b/features/common/common/build.gradle index 88f2aeb6..02440b49 100644 --- a/features/common/common/build.gradle +++ b/features/common/common/build.gradle @@ -14,19 +14,19 @@ kotlin { api libs.microutils.serialization.typedserializer api libs.microutils.mimetypes api libs.klock - api "io.insert-koin:koin-core:$koin_version" - api "com.benasher44:uuid:$uuid_version" - api "io.ktor:ktor-http:$ktor_version" + api libs.koin.core + api libs.uuid + api libs.ktor.http } } jvmMain { dependencies { - api "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" + api libs.kotlin.reflect } } androidMain { dependencies { - api "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" + api libs.kotlin.reflect } } } diff --git a/features/common/server/build.gradle b/features/common/server/build.gradle index 461a4a90..1dbe1f1c 100644 --- a/features/common/server/build.gradle +++ b/features/common/server/build.gradle @@ -17,8 +17,8 @@ kotlin { } jvmMain { dependencies { - api "io.ktor:ktor-auth:$ktor_version" - api "ch.qos.logback:logback-classic:$logback_version" + api libs.ktor.auth + api libs.logback } } } diff --git a/features/users/server/build.gradle b/features/users/server/build.gradle index 286aa52c..c5ada731 100644 --- a/features/users/server/build.gradle +++ b/features/users/server/build.gradle @@ -15,8 +15,8 @@ kotlin { } jvmMain { dependencies { - api "io.ktor:ktor-auth:$ktor_version" - api "io.ktor:ktor-server-sessions:$ktor_version" + api libs.ktor.auth + api libs.ktor.server.sessions } } } diff --git a/gradle.properties b/gradle.properties index 5edb81ad..1a98b564 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,34 +7,6 @@ kotlin.incremental.js=true android.useAndroidX=true android.enableJetifier=true -# Common - -kotlin_version=1.6.10 -kotlin_serialisation_core_version=1.3.2 - -koin_version=3.1.2 -ktor_version=1.6.7 -logback_version=1.2.10 -uuid_version=0.4.0 - -# JS - -kotlinx_html_version=0.7.3 - -# ANDROID - -android_minSdkVersion=21 -android_compileSdkVersion=32 -android_buildToolsVersion=32.0.0 -dexcount_version=3.0.1 -junit_version=4.12 -test_ext_junit_version=1.1.2 -espresso_core=3.3.0 - -# Dokka - -dokka_version=1.6.10 - # Project data group=dev.inmo diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 7081be4a..c4fdc02e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -2,24 +2,44 @@ kotlin = "1.6.10" kotlin-serialization = "1.3.2" -jsuikit = "0.0.45" +jsuikit = "0.0.48" compose = "1.1.1" -microutils = "0.9.16" -tgbotapi = "0.38.9" +microutils = "0.9.18" +tgbotapi = "0.38.11" ktor = "1.6.8" -klock = "2.6.3" +klock = "2.7.0" +koin = "3.1.5" exposed = "0.37.3" psql = "42.3.0" scrimage = "4.0.31" +dokka = "1.6.10" +logback = "1.2.10" +uuid = "0.4.0" android-dexcount = "3.0.1" android-junit = "4.12" android-test-junit = "1.1.2" android-espresso-core = "3.3.0" +gh-release = "2.2.12" + +android-gradle = "7.0.4" +dexcount = "3.0.1" + +android-coreKtx = "1.7.0" +android-recyclerView = "1.2.1" +android-appCompat = "1.4.1" +android-espresso = "3.3.0" +android-test = "1.1.2" + +android-props-minSdk = "19" +android-props-compileSdk = "32" +android-props-buildTools = "32.0.0" + [libraries] kotlin-std = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" } +kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin" } kotlin-serialization = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlin-serialization" } kotlin-serialization-properties = { module = "org.jetbrains.kotlinx:kotlinx-serialization-properties", version.ref = "kotlin-serialization" } @@ -29,9 +49,21 @@ postgresql = { module = "org.postgresql:postgresql", version.ref = "psql" } exposed-jdbs = { module = "org.jetbrains.exposed:exposed-jdbc", version.ref = "exposed" } +ktor-client-apache = { module = "io.ktor:ktor-client-apache", version.ref = "ktor" } +ktor-client-auth = { module = "io.ktor:ktor-client-auth", version.ref = "ktor" } +ktor-client-logging = { module = "io.ktor:ktor-client-logging", version.ref = "ktor" } +ktor-http = { module = "io.ktor:ktor-http", version.ref = "ktor" } +ktor-auth = { module = "io.ktor:ktor-auth", version.ref = "ktor" } ktor-server-netty = { module = "io.ktor:ktor-server-netty", version.ref = "ktor" } +ktor-server-sessions = { module = "io.ktor:ktor-server-sessions", version.ref = "ktor" } ktor-websockets = { module = "io.ktor:ktor-websockets", version.ref = "ktor" } +logback = { module = "ch.qos.logback:logback-classic", version.ref = "logback" } + +uuid = { module = "com.benasher44:uuid", version.ref = "uuid" } + +koin-core = { module = "io.insert-koin:koin-core", version.ref = "koin" } + microutils-common = { module = "dev.inmo:micro_utils.common", version.ref = "microutils" } microutils-common-compose = { module = "dev.inmo:micro_utils.common.compose", version.ref = "microutils" } microutils-pagination-common = { module = "dev.inmo:micro_utils.pagination.common", version.ref = "microutils" } @@ -57,6 +89,15 @@ scrimage = { module = "com.sksamuel.scrimage:scrimage-core", version.ref = "scri androidx-test-junit = { module = "androidx.test.ext:junit", version.ref = "android-test-junit" } androidx-espresso = { module = "androidx.test.espresso:espresso-core", version.ref = "android-espresso-core" } +# classpaths + +buildscript-kt-gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" } +buildscript-kt-serialization = { module = "org.jetbrains.kotlin:kotlin-serialization", version.ref = "kotlin" } +buildscript-jb-dokka = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "dokka" } +buildscript-gh-release = { module = "com.github.breadmoirai:github-release", version.ref = "gh-release" } +buildscript-android-gradle = { module = "com.android.tools.build:gradle", version.ref = "android-gradle" } +buildscript-android-dexcount = { module = "com.getkeepsafe.dexcount:dexcount-gradle-plugin", version.ref = "dexcount" } + [plugins] compose = { id = "org.jetbrains.compose", version.ref = "compose" }