From 546736690c6c595fb66ec87e31645e1f14559b62 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 26 Aug 2024 23:58:53 +0600 Subject: [PATCH] continue reborn :( --- .gitignore | 1 + client/build.gradle | 1 + client/uikit/package.json | 3 +- defaultAndroidSettings.gradle | 1 + features/auth/client/build.gradle | 1 + features/common/client/build.gradle | 1 + .../common/common/SimpleInputProvider.kt | 14 +++++++-- .../common/common/FileBasedInputProvider.kt | 9 ++---- .../common/common/FileBasedInputProvider.kt | 8 ++--- features/content/binary/client/build.gradle | 1 + .../server/BinaryServerContentStorage.kt | 1 - features/content/client/build.gradle | 1 + features/content/text/client/build.gradle | 1 + .../features/files/client/ModuleLoader.kt | 2 +- .../roles/client/ClientUsersRolesStorage.kt | 2 +- .../client/ReadClientUsersRolesStorage.kt | 2 +- .../features/users/client/ModuleLoader.kt | 2 +- .../users/client/UsersStorageKtorClient.kt | 16 +++++----- .../users/common/ExposedUsersStorage.kt | 2 +- gradle/libs.versions.toml | 31 ++++++++++--------- gradle/wrapper/gradle-wrapper.properties | 2 +- mppJsProject.gradle | 1 - mppProjectWithSerialization.gradle | 1 - .../client/SimplePublicatorServiceClient.kt | 12 ++++--- .../posts/client/ClientWritePostsService.kt | 1 - .../ServerPostsServiceRoutingConfigurator.kt | 1 - 26 files changed, 65 insertions(+), 53 deletions(-) diff --git a/.gitignore b/.gitignore index e59f517f..b5650fb5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .idea +.kotlin out/* *.iml target diff --git a/client/build.gradle b/client/build.gradle index 2d27583d..54e9d760 100644 --- a/client/build.gradle +++ b/client/build.gradle @@ -3,6 +3,7 @@ plugins { id "org.jetbrains.kotlin.plugin.serialization" id "com.android.library" alias(libs.plugins.compose) + alias(libs.plugins.kt.jb.compose) } apply from: "$mppProjectWithSerializationPresetPath" diff --git a/client/uikit/package.json b/client/uikit/package.json index 90171193..24bf0d5f 100644 --- a/client/uikit/package.json +++ b/client/uikit/package.json @@ -58,5 +58,6 @@ "semver": "^7.3.2", "svgo": "^2.8.0", "watch-run": "^1.2.5" - } + }, + "packageManager": "yarn@1.22.19+sha1.4ba7fc5c6e704fce2066ecbfb0b0d8976fe62447" } diff --git a/defaultAndroidSettings.gradle b/defaultAndroidSettings.gradle index f2170660..c3f41ef8 100644 --- a/defaultAndroidSettings.gradle +++ b/defaultAndroidSettings.gradle @@ -6,6 +6,7 @@ android { defaultConfig { minSdkVersion libs.versions.android.props.minSdk.get().toInteger() + compileSdkVersion libs.versions.android.props.compileSdk.get().toInteger() targetSdkVersion libs.versions.android.props.compileSdk.get().toInteger() versionCode "${android_code_version}".toInteger() versionName "$version" diff --git a/features/auth/client/build.gradle b/features/auth/client/build.gradle index 8687f515..33beb15f 100644 --- a/features/auth/client/build.gradle +++ b/features/auth/client/build.gradle @@ -3,6 +3,7 @@ plugins { id "org.jetbrains.kotlin.plugin.serialization" id "com.android.library" alias(libs.plugins.compose) + alias(libs.plugins.kt.jb.compose) } apply from: "$mppProjectWithSerializationPresetPath" diff --git a/features/common/client/build.gradle b/features/common/client/build.gradle index 26cdd30f..a6fcbbd5 100644 --- a/features/common/client/build.gradle +++ b/features/common/client/build.gradle @@ -3,6 +3,7 @@ plugins { id "org.jetbrains.kotlin.plugin.serialization" id "com.android.library" alias(libs.plugins.compose) + alias(libs.plugins.kt.jb.compose) } apply from: "$mppProjectWithSerializationPresetPath" diff --git a/features/common/common/src/commonMain/kotlin/dev/inmo/postssystem/features/common/common/SimpleInputProvider.kt b/features/common/common/src/commonMain/kotlin/dev/inmo/postssystem/features/common/common/SimpleInputProvider.kt index 13fce4c4..c68091d0 100644 --- a/features/common/common/src/commonMain/kotlin/dev/inmo/postssystem/features/common/common/SimpleInputProvider.kt +++ b/features/common/common/src/commonMain/kotlin/dev/inmo/postssystem/features/common/common/SimpleInputProvider.kt @@ -1,6 +1,7 @@ package dev.inmo.postssystem.features.common.common import dev.inmo.micro_utils.common.MPPFile +import dev.inmo.micro_utils.common.filesize import io.ktor.utils.io.core.* import kotlinx.serialization.KSerializer import kotlinx.serialization.builtins.ByteArraySerializer @@ -27,9 +28,18 @@ class BytesBasedInputProvider( } } -@Serializable(SimpleInputProviderSerializer::class) -expect class FileBasedInputProvider : SimpleInputProvider { +internal interface FileInputProvider : SimpleInputProvider { val file: MPPFile + + override val contentBytes: Long? + get() = file.filesize +} + +@Serializable(SimpleInputProviderSerializer::class) +expect class FileBasedInputProvider : FileInputProvider { + override val file: MPPFile + + override fun invoke(): Input } @Serializable(SimpleInputProviderSerializer::class) diff --git a/features/common/common/src/jsMain/kotlin/dev/inmo/postssystem/features/common/common/FileBasedInputProvider.kt b/features/common/common/src/jsMain/kotlin/dev/inmo/postssystem/features/common/common/FileBasedInputProvider.kt index 2396c976..d3a2b737 100644 --- a/features/common/common/src/jsMain/kotlin/dev/inmo/postssystem/features/common/common/FileBasedInputProvider.kt +++ b/features/common/common/src/jsMain/kotlin/dev/inmo/postssystem/features/common/common/FileBasedInputProvider.kt @@ -7,12 +7,9 @@ import kotlinx.serialization.Serializable @Serializable(SimpleInputProviderSerializer::class) actual class FileBasedInputProvider internal constructor( - actual val file: MPPFile -) : SimpleInputProvider { - override val contentBytes: Long - get() = file.filesize - - override fun invoke(): Input = error("Files inputs must not be used directly") + actual override val file: MPPFile +) : FileInputProvider { + actual override fun invoke(): Input = error("Files inputs must not be used directly") } fun MPPFile.inputProvider() = FileBasedInputProvider(this) diff --git a/features/common/common/src/jvmMain/kotlin/dev/inmo/postssystem/features/common/common/FileBasedInputProvider.kt b/features/common/common/src/jvmMain/kotlin/dev/inmo/postssystem/features/common/common/FileBasedInputProvider.kt index d072ee8b..57f69222 100644 --- a/features/common/common/src/jvmMain/kotlin/dev/inmo/postssystem/features/common/common/FileBasedInputProvider.kt +++ b/features/common/common/src/jvmMain/kotlin/dev/inmo/postssystem/features/common/common/FileBasedInputProvider.kt @@ -8,10 +8,8 @@ import kotlinx.serialization.Serializable @Serializable(SimpleInputProviderSerializer::class) actual class FileBasedInputProvider( - actual val file: MPPFile -) : SimpleInputProvider { - override val contentBytes: Long? - get() = file.filesize + actual override val file: MPPFile +) : FileInputProvider { - override fun invoke(): Input = file.inputStream().asInput() + actual override fun invoke(): Input = file.inputStream().asInput() } diff --git a/features/content/binary/client/build.gradle b/features/content/binary/client/build.gradle index bb2ab94a..26157aa0 100644 --- a/features/content/binary/client/build.gradle +++ b/features/content/binary/client/build.gradle @@ -3,6 +3,7 @@ plugins { id "org.jetbrains.kotlin.plugin.serialization" id "com.android.library" alias(libs.plugins.compose) + alias(libs.plugins.kt.jb.compose) } apply from: "$mppProjectWithSerializationPresetPath" diff --git a/features/content/binary/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/binary/server/BinaryServerContentStorage.kt b/features/content/binary/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/binary/server/BinaryServerContentStorage.kt index a3c4aa24..60bf3fd2 100644 --- a/features/content/binary/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/binary/server/BinaryServerContentStorage.kt +++ b/features/content/binary/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/binary/server/BinaryServerContentStorage.kt @@ -6,7 +6,6 @@ import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions import dev.inmo.micro_utils.mime_types.KnownMimeTypes import dev.inmo.micro_utils.pagination.* import dev.inmo.micro_utils.repos.* -import dev.inmo.postssystem.features.common.common.FileBasedInputProvider import dev.inmo.postssystem.features.content.common.* import dev.inmo.postssystem.features.content.server.storage.ServerContentStorage import dev.inmo.postssystem.features.files.common.* diff --git a/features/content/client/build.gradle b/features/content/client/build.gradle index 4f518105..3b07e9a8 100644 --- a/features/content/client/build.gradle +++ b/features/content/client/build.gradle @@ -3,6 +3,7 @@ plugins { id "org.jetbrains.kotlin.plugin.serialization" id "com.android.library" alias(libs.plugins.compose) + alias(libs.plugins.kt.jb.compose) } apply from: "$mppProjectWithSerializationPresetPath" diff --git a/features/content/text/client/build.gradle b/features/content/text/client/build.gradle index add69bfb..0dbe1ab7 100644 --- a/features/content/text/client/build.gradle +++ b/features/content/text/client/build.gradle @@ -3,6 +3,7 @@ plugins { id "org.jetbrains.kotlin.plugin.serialization" id "com.android.library" alias(libs.plugins.compose) + alias(libs.plugins.kt.jb.compose) } apply from: "$mppProjectWithSerializationPresetPath" diff --git a/features/files/client/src/commonMain/kotlin/dev/inmo/postssystem/features/files/client/ModuleLoader.kt b/features/files/client/src/commonMain/kotlin/dev/inmo/postssystem/features/files/client/ModuleLoader.kt index d535be20..1ffbcdd1 100644 --- a/features/files/client/src/commonMain/kotlin/dev/inmo/postssystem/features/files/client/ModuleLoader.kt +++ b/features/files/client/src/commonMain/kotlin/dev/inmo/postssystem/features/files/client/ModuleLoader.kt @@ -5,5 +5,5 @@ import dev.inmo.postssystem.features.auth.client.AuthorizedQualifiers import dev.inmo.postssystem.features.files.common.storage.ReadFilesStorage val loader = AuthorizedModuleLoader { - single { ClientReadFilesStorage(get(AuthorizedQualifiers.ServerUrlQualifier), get(), get()) } + single { ClientReadFilesStorage(get(AuthorizedQualifiers.ServerUrlQualifier), get(), get(), get()) } } diff --git a/features/roles/client/src/commonMain/kotlin/dev/inmo/postssystem/features/roles/client/ClientUsersRolesStorage.kt b/features/roles/client/src/commonMain/kotlin/dev/inmo/postssystem/features/roles/client/ClientUsersRolesStorage.kt index 0c11d2e7..20f7f1a4 100644 --- a/features/roles/client/src/commonMain/kotlin/dev/inmo/postssystem/features/roles/client/ClientUsersRolesStorage.kt +++ b/features/roles/client/src/commonMain/kotlin/dev/inmo/postssystem/features/roles/client/ClientUsersRolesStorage.kt @@ -1,7 +1,7 @@ package dev.inmo.postssystem.features.roles.client import dev.inmo.postssystem.features.roles.common.* -import dev.inmo.micro_utils.ktor.client.UnifiedRequester +import io.ktor.client.* import kotlinx.serialization.KSerializer class ClientRolesStorage( diff --git a/features/roles/client/src/commonMain/kotlin/dev/inmo/postssystem/features/roles/client/ReadClientUsersRolesStorage.kt b/features/roles/client/src/commonMain/kotlin/dev/inmo/postssystem/features/roles/client/ReadClientUsersRolesStorage.kt index 9ad26a35..f30e5276 100644 --- a/features/roles/client/src/commonMain/kotlin/dev/inmo/postssystem/features/roles/client/ReadClientUsersRolesStorage.kt +++ b/features/roles/client/src/commonMain/kotlin/dev/inmo/postssystem/features/roles/client/ReadClientUsersRolesStorage.kt @@ -27,7 +27,7 @@ class ReadClientRolesStorage( buildStandardUrl( userRolesFullUrl, usersRolesGetSubjectsPathPart, - usersRolesRoleQueryParameterName to unifiedRequester.encodeUrlQueryValue(serializer, role) + usersRolesRoleQueryParameterName to role ) ).body() diff --git a/features/users/client/src/commonMain/kotlin/dev/inmo/postssystem/features/users/client/ModuleLoader.kt b/features/users/client/src/commonMain/kotlin/dev/inmo/postssystem/features/users/client/ModuleLoader.kt index ec061aed..ddb2aa07 100644 --- a/features/users/client/src/commonMain/kotlin/dev/inmo/postssystem/features/users/client/ModuleLoader.kt +++ b/features/users/client/src/commonMain/kotlin/dev/inmo/postssystem/features/users/client/ModuleLoader.kt @@ -5,5 +5,5 @@ import dev.inmo.postssystem.features.auth.client.AuthorizedQualifiers import dev.inmo.postssystem.features.users.common.ReadUsersStorage val loader = AuthorizedModuleLoader { - single { UsersStorageKtorClient(get(AuthorizedQualifiers.ServerUrlQualifier), get()) } + single { UsersStorageKtorClient(get(AuthorizedQualifiers.ServerUrlQualifier), get(), get()) } } diff --git a/features/users/client/src/commonMain/kotlin/dev/inmo/postssystem/features/users/client/UsersStorageKtorClient.kt b/features/users/client/src/commonMain/kotlin/dev/inmo/postssystem/features/users/client/UsersStorageKtorClient.kt index c3962616..aa40d31b 100644 --- a/features/users/client/src/commonMain/kotlin/dev/inmo/postssystem/features/users/client/UsersStorageKtorClient.kt +++ b/features/users/client/src/commonMain/kotlin/dev/inmo/postssystem/features/users/client/UsersStorageKtorClient.kt @@ -1,19 +1,19 @@ package dev.inmo.postssystem.features.users.client import dev.inmo.postssystem.features.users.common.* -import dev.inmo.micro_utils.ktor.client.UnifiedRequester import dev.inmo.micro_utils.ktor.common.buildStandardUrl import dev.inmo.micro_utils.repos.ReadCRUDRepo -import dev.inmo.micro_utils.repos.ktor.client.crud.KtorReadStandardCrudRepo -import kotlinx.serialization.builtins.nullable +import dev.inmo.micro_utils.repos.ktor.client.crud.KtorReadCRUDRepoClient +import io.ktor.client.* +import io.ktor.http.* class UsersStorageKtorClient( baseUrl: String, - client: HttpClient -) : ReadUsersStorage, ReadCRUDRepo by KtorReadStandardCrudRepo( + client: HttpClient, + contentType: ContentType +) : ReadUsersStorage, ReadCRUDRepo by KtorReadCRUDRepoClient( buildStandardUrl(baseUrl, usersServerPathPart), client, - User.serializer(), - User.serializer().nullable, - UserId.serializer() + contentType, + { it.long.toString() } ) diff --git a/features/users/common/src/jvmMain/kotlin/dev/inmo/postssystem/features/users/common/ExposedUsersStorage.kt b/features/users/common/src/jvmMain/kotlin/dev/inmo/postssystem/features/users/common/ExposedUsersStorage.kt index 1dabf9b8..4fc80a91 100644 --- a/features/users/common/src/jvmMain/kotlin/dev/inmo/postssystem/features/users/common/ExposedUsersStorage.kt +++ b/features/users/common/src/jvmMain/kotlin/dev/inmo/postssystem/features/users/common/ExposedUsersStorage.kt @@ -30,7 +30,7 @@ class ExposedUsersStorage(override val database: Database) : UsersStorage, Abstr initTable() } - override fun insert(value: NewUser, it: InsertStatement) { + override fun insert(value: NewUser, it: UpdateBuilder) { it[usernameColumn] = value.username.string it[firstNameColumn] = value.firstName it[lastNameColumn] = value.lastName diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 6d2a8a0d..7e36d91e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,21 +1,21 @@ [versions] -kotlin = "1.9.22" -kotlin-serialization = "1.6.2" -kotlin-coroutines = "1.7.3" -jsuikit = "0.7.4" -compose = "1.5.12" -microutils = "0.20.34" -tgbotapi = "10.0.1" -ktor = "2.3.8" -korlibs = "5.3.1" -koin = "3.5.3" -exposed = "0.47.0" +kotlin = "2.0.10" +kotlin-serialization = "1.7.1" +kotlin-coroutines = "1.8.1" +jsuikit = "0.7.6" +compose = "1.7.0-alpha02" +microutils = "0.22.0" +tgbotapi = "17.0.0" +ktor = "2.3.11" +korlibs = "5.4.0" +koin = "3.5.6" +exposed = "0.53.0" psql = "42.3.6" scrimage = "4.1.1" -dokka = "1.9.10" +dokka = "1.9.20" logback = "1.2.10" -uuid = "0.8.2" +uuid = "0.8.4" android-junit = "4.12" android-test-junit = "1.1.2" @@ -35,8 +35,8 @@ android-espresso = "3.3.0" android-test = "1.1.2" android-props-minSdk = "21" -android-props-compileSdk = "34" -android-props-buildTools = "34.0.0" +android-props-compileSdk = "35" +android-props-buildTools = "35.0.0" [libraries] @@ -113,3 +113,4 @@ buildscript-android-dexcount = { module = "com.getkeepsafe.dexcount:dexcount-gra [plugins] compose = { id = "org.jetbrains.compose", version.ref = "compose" } +kt-jb-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 8958be80..462c8661 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,4 +1,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip zipStoreBase=GRADLE_USER_HOME diff --git a/mppJsProject.gradle b/mppJsProject.gradle index 72cdddaf..9dd17d6a 100644 --- a/mppJsProject.gradle +++ b/mppJsProject.gradle @@ -26,7 +26,6 @@ kotlin { jsTest { dependencies { implementation kotlin('test-js') - implementation kotlin('test-junit') } } } diff --git a/mppProjectWithSerialization.gradle b/mppProjectWithSerialization.gradle index bd582dbf..9893cc77 100644 --- a/mppProjectWithSerialization.gradle +++ b/mppProjectWithSerialization.gradle @@ -46,7 +46,6 @@ kotlin { jsTest { dependencies { implementation kotlin('test-js') - implementation kotlin('test-junit') } } androidUnitTest { diff --git a/publicators/simple/client/src/commonMain/kotlin/dev/inmo/postssystem/publicators/simple/client/SimplePublicatorServiceClient.kt b/publicators/simple/client/src/commonMain/kotlin/dev/inmo/postssystem/publicators/simple/client/SimplePublicatorServiceClient.kt index aa554d86..7d2fb2c1 100644 --- a/publicators/simple/client/src/commonMain/kotlin/dev/inmo/postssystem/publicators/simple/client/SimplePublicatorServiceClient.kt +++ b/publicators/simple/client/src/commonMain/kotlin/dev/inmo/postssystem/publicators/simple/client/SimplePublicatorServiceClient.kt @@ -1,11 +1,13 @@ package dev.inmo.postssystem.publicators.simple.client -import dev.inmo.micro_utils.ktor.client.UnifiedRequester import dev.inmo.micro_utils.ktor.common.buildStandardUrl import dev.inmo.postssystem.features.posts.common.PostId import dev.inmo.postssystem.features.publication.common.publicatorsRootPath import dev.inmo.postssystem.publicators.simple.common.simplePublicatorPublishPathPart import dev.inmo.postssystem.publicators.simple.common.simplePublicatorRootPath +import io.ktor.client.* +import io.ktor.client.call.* +import io.ktor.client.request.* import kotlinx.serialization.builtins.serializer class SimplePublicatorServiceClient( @@ -25,9 +27,9 @@ class SimplePublicatorServiceClient( simplePublicatorPublishPathPart ) - override suspend fun publish(postId: PostId) = unifiedRequester.unipost( + override suspend fun publish(postId: PostId) = client.post( publishFullUrl, - PostId.serializer() to postId, - Unit.serializer() - ) + ) { + setBody(postId) + }.body() } diff --git a/services/posts/client/src/commonMain/kotlin/dev/inmo/postssystem/services/posts/client/ClientWritePostsService.kt b/services/posts/client/src/commonMain/kotlin/dev/inmo/postssystem/services/posts/client/ClientWritePostsService.kt index 63f67fdf..6a59bdd8 100644 --- a/services/posts/client/src/commonMain/kotlin/dev/inmo/postssystem/services/posts/client/ClientWritePostsService.kt +++ b/services/posts/client/src/commonMain/kotlin/dev/inmo/postssystem/services/posts/client/ClientWritePostsService.kt @@ -8,7 +8,6 @@ import dev.inmo.micro_utils.ktor.common.encodeHex import dev.inmo.micro_utils.repos.ktor.common.crud.createRouting import dev.inmo.micro_utils.repos.ktor.common.crud.updateRouting import dev.inmo.micro_utils.repos.ktor.common.one_to_many.removeRoute -import dev.inmo.postssystem.features.common.common.FileBasedInputProvider import dev.inmo.postssystem.features.common.common.SimpleInputProvider import dev.inmo.postssystem.features.content.common.* import dev.inmo.postssystem.features.files.common.FileId diff --git a/services/posts/server/src/jvmMain/kotlin/dev/inmo/postssystem/services/posts/server/ServerPostsServiceRoutingConfigurator.kt b/services/posts/server/src/jvmMain/kotlin/dev/inmo/postssystem/services/posts/server/ServerPostsServiceRoutingConfigurator.kt index eadd9289..28f6c438 100644 --- a/services/posts/server/src/jvmMain/kotlin/dev/inmo/postssystem/services/posts/server/ServerPostsServiceRoutingConfigurator.kt +++ b/services/posts/server/src/jvmMain/kotlin/dev/inmo/postssystem/services/posts/server/ServerPostsServiceRoutingConfigurator.kt @@ -11,7 +11,6 @@ import dev.inmo.micro_utils.repos.ktor.common.crud.createRouting import dev.inmo.micro_utils.repos.ktor.common.crud.updateRouting import dev.inmo.micro_utils.repos.ktor.common.one_to_many.removeRoute import dev.inmo.micro_utils.repos.ktor.server.crud.configureReadCRUDRepoRoutes -import dev.inmo.postssystem.features.common.common.FileBasedInputProvider import dev.inmo.postssystem.features.content.common.* import dev.inmo.postssystem.features.files.common.FileId import dev.inmo.postssystem.features.posts.common.*