diff --git a/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/KeyValuesCacheRepo.kt b/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/KeyValuesCacheRepo.kt index ff2b36fbf01..1948279461c 100644 --- a/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/KeyValuesCacheRepo.kt +++ b/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/KeyValuesCacheRepo.kt @@ -8,8 +8,6 @@ import dev.inmo.micro_utils.repos.* import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.* -import kotlinx.coroutines.sync.Mutex -import kotlinx.coroutines.sync.withLock open class ReadKeyValuesCacheRepo( protected val parentRepo: ReadKeyValuesRepo, diff --git a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/OneToManyKeyValueRepo.kt b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/KeyValuesRepo.kt similarity index 62% rename from repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/OneToManyKeyValueRepo.kt rename to repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/KeyValuesRepo.kt index ce9836c59cd..1754abb70b8 100644 --- a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/OneToManyKeyValueRepo.kt +++ b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/KeyValuesRepo.kt @@ -1,11 +1,10 @@ package dev.inmo.micro_utils.repos import dev.inmo.micro_utils.pagination.* -import dev.inmo.micro_utils.pagination.utils.doForAllWithCurrentPaging import dev.inmo.micro_utils.pagination.utils.getAllWithNextPaging import kotlinx.coroutines.flow.Flow -interface ReadOneToManyKeyValueRepo : Repo { +interface ReadKeyValuesRepo : Repo { suspend fun get(k: Key, pagination: Pagination, reversed: Boolean = false): PaginationResult suspend fun keys(pagination: Pagination, reversed: Boolean = false): PaginationResult suspend fun keys(v: Value, pagination: Pagination, reversed: Boolean = false): PaginationResult @@ -36,9 +35,9 @@ interface ReadOneToManyKeyValueRepo : Repo { } } } -typealias ReadKeyValuesRepo = ReadOneToManyKeyValueRepo +typealias ReadOneToManyKeyValueRepo = ReadKeyValuesRepo -interface WriteOneToManyKeyValueRepo : Repo { +interface WriteKeyValuesRepo : Repo { val onNewValue: Flow> val onValueRemoved: Flow> val onDataCleared: Flow @@ -55,41 +54,41 @@ interface WriteOneToManyKeyValueRepo : Repo { add(toSet) } } -typealias WriteKeyValuesRepo = WriteOneToManyKeyValueRepo +typealias WriteOneToManyKeyValueRepo = WriteKeyValuesRepo -suspend inline fun > REPO.add( +suspend inline fun > REPO.add( keysAndValues: List>> ) = add(keysAndValues.toMap()) -suspend inline fun > REPO.add( +suspend inline fun > REPO.add( vararg keysAndValues: Pair> ) = add(keysAndValues.toMap()) -suspend inline fun WriteOneToManyKeyValueRepo.add( +suspend inline fun WriteKeyValuesRepo.add( k: Key, v: List ) = add(mapOf(k to v)) -suspend inline fun WriteOneToManyKeyValueRepo.add( +suspend inline fun WriteKeyValuesRepo.add( k: Key, vararg v: Value ) = add(k, v.toList()) -suspend inline fun > REPO.set( +suspend inline fun > REPO.set( keysAndValues: List>> ) = set(keysAndValues.toMap()) -suspend inline fun > REPO.set( +suspend inline fun > REPO.set( vararg keysAndValues: Pair> ) = set(keysAndValues.toMap()) -suspend inline fun WriteOneToManyKeyValueRepo.set( +suspend inline fun WriteKeyValuesRepo.set( k: Key, v: List ) = set(mapOf(k to v)) -suspend inline fun WriteOneToManyKeyValueRepo.set( +suspend inline fun WriteKeyValuesRepo.set( k: Key, vararg v: Value ) = set(k, v.toList()) -interface OneToManyKeyValueRepo : ReadOneToManyKeyValueRepo, WriteOneToManyKeyValueRepo { +interface KeyValuesRepo : ReadKeyValuesRepo, WriteKeyValuesRepo { override suspend fun clearWithValue(v: Value) { doWithPagination { val keysResult = keys(v, it) @@ -102,29 +101,29 @@ interface OneToManyKeyValueRepo : ReadOneToManyKeyValueRepo = OneToManyKeyValueRepo +typealias OneToManyKeyValueRepo = KeyValuesRepo -class DelegateBasedOneToManyKeyValueRepo( - readDelegate: ReadOneToManyKeyValueRepo, - writeDelegate: WriteOneToManyKeyValueRepo -) : OneToManyKeyValueRepo, - ReadOneToManyKeyValueRepo by readDelegate, - WriteOneToManyKeyValueRepo by writeDelegate +class DelegateBasedKeyValuesRepo( + readDelegate: ReadKeyValuesRepo, + writeDelegate: WriteKeyValuesRepo +) : KeyValuesRepo, + ReadKeyValuesRepo by readDelegate, + WriteKeyValuesRepo by writeDelegate -suspend inline fun WriteOneToManyKeyValueRepo.remove( +suspend inline fun WriteKeyValuesRepo.remove( keysAndValues: List>> ) = remove(keysAndValues.toMap()) -suspend inline fun WriteOneToManyKeyValueRepo.remove( +suspend inline fun WriteKeyValuesRepo.remove( vararg keysAndValues: Pair> ) = remove(keysAndValues.toMap()) -suspend inline fun WriteOneToManyKeyValueRepo.remove( +suspend inline fun WriteKeyValuesRepo.remove( k: Key, v: List ) = remove(mapOf(k to v)) -suspend inline fun WriteOneToManyKeyValueRepo.remove( +suspend inline fun WriteKeyValuesRepo.remove( k: Key, vararg v: Value ) = remove(k, v.toList()) diff --git a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/mappers/OneToManyKeyValueMappers.kt b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/mappers/OneToManyKeyValueMappers.kt index 74751f79518..5e5d5b44d5f 100644 --- a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/mappers/OneToManyKeyValueMappers.kt +++ b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/mappers/OneToManyKeyValueMappers.kt @@ -6,10 +6,12 @@ import dev.inmo.micro_utils.repos.* import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.map -open class MapperReadOneToManyKeyValueRepo( - private val to: ReadOneToManyKeyValueRepo, +@Deprecated("Renamed", ReplaceWith("MapperReadKeyValuesRepo", "dev.inmo.micro_utils.repos.mappers.MapperReadKeyValuesRepo")) +typealias MapperReadOneToManyKeyValueRepo = MapperReadKeyValuesRepo +open class MapperReadKeyValuesRepo( + private val to: ReadKeyValuesRepo, mapper: MapperRepo -) : ReadOneToManyKeyValueRepo, MapperRepo by mapper { +) : ReadKeyValuesRepo, MapperRepo by mapper { override suspend fun get( k: FromKey, pagination: Pagination, @@ -67,24 +69,26 @@ open class MapperReadOneToManyKeyValueRepo( } @Suppress("NOTHING_TO_INLINE") -inline fun ReadOneToManyKeyValueRepo.withMapper( +inline fun ReadKeyValuesRepo.withMapper( mapper: MapperRepo -): ReadOneToManyKeyValueRepo = MapperReadOneToManyKeyValueRepo(this, mapper) +): ReadKeyValuesRepo = MapperReadKeyValuesRepo(this, mapper) @Suppress("NOTHING_TO_INLINE") -inline fun ReadOneToManyKeyValueRepo.withMapper( +inline fun ReadKeyValuesRepo.withMapper( crossinline keyFromToTo: suspend FromKey.() -> ToKey = { this as ToKey }, crossinline valueFromToTo: suspend FromValue.() -> ToValue = { this as ToValue }, crossinline keyToToFrom: suspend ToKey.() -> FromKey = { this as FromKey }, crossinline valueToToFrom: suspend ToValue.() -> FromValue = { this as FromValue }, -): ReadOneToManyKeyValueRepo = withMapper( +): ReadKeyValuesRepo = withMapper( mapper(keyFromToTo, valueFromToTo, keyToToFrom, valueToToFrom) ) -open class MapperWriteOneToManyKeyValueRepo( - private val to: WriteOneToManyKeyValueRepo, +@Deprecated("Renamed", ReplaceWith("MapperWriteKeyValuesRepo", "dev.inmo.micro_utils.repos.mappers.MapperWriteKeyValuesRepo")) +typealias MapperWriteOneToManyKeyValueRepo = MapperWriteKeyValuesRepo +open class MapperWriteKeyValuesRepo( + private val to: WriteKeyValuesRepo, mapper: MapperRepo -) : WriteOneToManyKeyValueRepo, MapperRepo by mapper { +) : WriteKeyValuesRepo, MapperRepo by mapper { override val onNewValue: Flow> = to.onNewValue.map { (k, v) -> k.toInnerKey() to v.toInnerValue() } @@ -118,40 +122,42 @@ open class MapperWriteOneToManyKeyValueRepo( } @Suppress("NOTHING_TO_INLINE") -inline fun WriteOneToManyKeyValueRepo.withMapper( +inline fun WriteKeyValuesRepo.withMapper( mapper: MapperRepo -): WriteOneToManyKeyValueRepo = MapperWriteOneToManyKeyValueRepo(this, mapper) +): WriteKeyValuesRepo = MapperWriteKeyValuesRepo(this, mapper) @Suppress("NOTHING_TO_INLINE") -inline fun WriteOneToManyKeyValueRepo.withMapper( +inline fun WriteKeyValuesRepo.withMapper( crossinline keyFromToTo: suspend FromKey.() -> ToKey = { this as ToKey }, crossinline valueFromToTo: suspend FromValue.() -> ToValue = { this as ToValue }, crossinline keyToToFrom: suspend ToKey.() -> FromKey = { this as FromKey }, crossinline valueToToFrom: suspend ToValue.() -> FromValue = { this as FromValue }, -): WriteOneToManyKeyValueRepo = withMapper( +): WriteKeyValuesRepo = withMapper( mapper(keyFromToTo, valueFromToTo, keyToToFrom, valueToToFrom) ) +@Deprecated("Renamed", ReplaceWith("MapperKeyValuesRepo", "dev.inmo.micro_utils.repos.mappers.MapperKeyValuesRepo")) +typealias MapperOneToManyKeyValueRepo = MapperKeyValuesRepo @Suppress("DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE") -open class MapperOneToManyKeyValueRepo( - private val to: OneToManyKeyValueRepo, +open class MapperKeyValuesRepo( + private val to: KeyValuesRepo, mapper: MapperRepo -) : OneToManyKeyValueRepo, +) : KeyValuesRepo, MapperRepo by mapper, - ReadOneToManyKeyValueRepo by MapperReadOneToManyKeyValueRepo(to, mapper), - WriteOneToManyKeyValueRepo by MapperWriteOneToManyKeyValueRepo(to, mapper) + ReadKeyValuesRepo by MapperReadKeyValuesRepo(to, mapper), + WriteKeyValuesRepo by MapperWriteKeyValuesRepo(to, mapper) @Suppress("NOTHING_TO_INLINE") -inline fun OneToManyKeyValueRepo.withMapper( +inline fun KeyValuesRepo.withMapper( mapper: MapperRepo -): OneToManyKeyValueRepo = MapperOneToManyKeyValueRepo(this, mapper) +): KeyValuesRepo = MapperKeyValuesRepo(this, mapper) @Suppress("NOTHING_TO_INLINE") -inline fun OneToManyKeyValueRepo.withMapper( +inline fun KeyValuesRepo.withMapper( crossinline keyFromToTo: suspend FromKey.() -> ToKey = { this as ToKey }, crossinline valueFromToTo: suspend FromValue.() -> ToValue = { this as ToValue }, crossinline keyToToFrom: suspend ToKey.() -> FromKey = { this as FromKey }, crossinline valueToToFrom: suspend ToValue.() -> FromValue = { this as FromValue }, -): OneToManyKeyValueRepo = withMapper( +): KeyValuesRepo = withMapper( mapper(keyFromToTo, valueFromToTo, keyToToFrom, valueToToFrom) ) diff --git a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/pagination/OneToManyPaginationExtensions.kt b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/pagination/OneToManyPaginationExtensions.kt index 5a2749a0f1e..5e825390297 100644 --- a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/pagination/OneToManyPaginationExtensions.kt +++ b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/pagination/OneToManyPaginationExtensions.kt @@ -2,9 +2,9 @@ package dev.inmo.micro_utils.repos.pagination import dev.inmo.micro_utils.pagination.* import dev.inmo.micro_utils.pagination.utils.getAllWithNextPaging -import dev.inmo.micro_utils.repos.ReadOneToManyKeyValueRepo +import dev.inmo.micro_utils.repos.ReadKeyValuesRepo -suspend inline fun > REPO.getAll( +suspend inline fun > REPO.getAll( @Suppress("REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE") crossinline methodCaller: suspend REPO.(Pagination) -> PaginationResult ): List>> = getAllWithNextPaging { diff --git a/repos/common/src/main/kotlin/dev/inmo/micro_utils/repos/onetomany/OneToManyAndroidRepo.kt b/repos/common/src/main/kotlin/dev/inmo/micro_utils/repos/onetomany/OneToManyAndroidRepo.kt index 31abcac4e61..11a29614c39 100644 --- a/repos/common/src/main/kotlin/dev/inmo/micro_utils/repos/onetomany/OneToManyAndroidRepo.kt +++ b/repos/common/src/main/kotlin/dev/inmo/micro_utils/repos/onetomany/OneToManyAndroidRepo.kt @@ -9,7 +9,6 @@ import dev.inmo.micro_utils.repos.* import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.asSharedFlow -import kotlinx.coroutines.runBlocking import kotlinx.serialization.KSerializer import kotlinx.serialization.json.Json @@ -26,7 +25,7 @@ class OneToManyAndroidRepo( private val keyFromString: String.() -> Key, private val valueFromString: String.() -> Value, private val helper: SQLiteOpenHelper -) : OneToManyKeyValueRepo { +) : KeyValuesRepo { private val _onNewValue: MutableSharedFlow> = MutableSharedFlow() override val onNewValue: Flow> = _onNewValue.asSharedFlow() private val _onValueRemoved: MutableSharedFlow> = MutableSharedFlow() diff --git a/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/onetomany/ExposedOneToManyKeyValueRepo.kt b/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/onetomany/ExposedKeyValuesRepo.kt similarity index 89% rename from repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/onetomany/ExposedOneToManyKeyValueRepo.kt rename to repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/onetomany/ExposedKeyValuesRepo.kt index 0c839ea7834..6bb8bd67a63 100644 --- a/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/onetomany/ExposedOneToManyKeyValueRepo.kt +++ b/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/onetomany/ExposedKeyValuesRepo.kt @@ -1,18 +1,18 @@ package dev.inmo.micro_utils.repos.exposed.onetomany -import dev.inmo.micro_utils.repos.OneToManyKeyValueRepo +import dev.inmo.micro_utils.repos.KeyValuesRepo import dev.inmo.micro_utils.repos.exposed.ColumnAllocator import kotlinx.coroutines.flow.* import org.jetbrains.exposed.sql.* import org.jetbrains.exposed.sql.transactions.transaction -typealias ExposedKeyValuesRepo = ExposedOneToManyKeyValueRepo -open class ExposedOneToManyKeyValueRepo( +typealias ExposedOneToManyKeyValueRepo1 = ExposedKeyValuesRepo +open class ExposedKeyValuesRepo( database: Database, keyColumnAllocator: ColumnAllocator, valueColumnAllocator: ColumnAllocator, tableName: String? = null -) : OneToManyKeyValueRepo, ExposedReadOneToManyKeyValueRepo( +) : KeyValuesRepo, ExposedReadKeyValuesRepo( database, keyColumnAllocator, valueColumnAllocator, diff --git a/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/onetomany/ExposedReadOneToManyKeyValueRepo.kt b/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/onetomany/ExposedReadKeyValuesRepo.kt similarity index 85% rename from repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/onetomany/ExposedReadOneToManyKeyValueRepo.kt rename to repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/onetomany/ExposedReadKeyValuesRepo.kt index 7c8fa8a2fd7..d6903b764b3 100644 --- a/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/onetomany/ExposedReadOneToManyKeyValueRepo.kt +++ b/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/onetomany/ExposedReadKeyValuesRepo.kt @@ -1,20 +1,19 @@ package dev.inmo.micro_utils.repos.exposed.onetomany import dev.inmo.micro_utils.pagination.* -import dev.inmo.micro_utils.repos.ReadOneToManyKeyValueRepo +import dev.inmo.micro_utils.repos.ReadKeyValuesRepo import dev.inmo.micro_utils.repos.exposed.* -import dev.inmo.micro_utils.repos.exposed.keyvalue.ExposedReadKeyValueRepo import org.jetbrains.exposed.sql.* import org.jetbrains.exposed.sql.transactions.transaction -typealias ExposedReadKeyValuesRepo = ExposedReadOneToManyKeyValueRepo +typealias ExposedReadOneToManyKeyValueRepo = ExposedReadKeyValuesRepo -open class ExposedReadOneToManyKeyValueRepo( +open class ExposedReadKeyValuesRepo( override val database: Database, keyColumnAllocator: ColumnAllocator, valueColumnAllocator: ColumnAllocator, tableName: String? = null -) : ReadOneToManyKeyValueRepo, ExposedRepo, Table(tableName ?: "") { +) : ReadKeyValuesRepo, ExposedRepo, Table(tableName ?: "") { val keyColumn: Column = keyColumnAllocator() val valueColumn: Column = valueColumnAllocator() diff --git a/repos/inmemory/src/commonMain/kotlin/dev/inmo/micro_utils/repos/MapOneToManyKeyValueRepo.kt b/repos/inmemory/src/commonMain/kotlin/dev/inmo/micro_utils/repos/MapKeyValuesRepo.kt similarity index 74% rename from repos/inmemory/src/commonMain/kotlin/dev/inmo/micro_utils/repos/MapOneToManyKeyValueRepo.kt rename to repos/inmemory/src/commonMain/kotlin/dev/inmo/micro_utils/repos/MapKeyValuesRepo.kt index be4dbfd7ab0..4ab0d3ee2a4 100644 --- a/repos/inmemory/src/commonMain/kotlin/dev/inmo/micro_utils/repos/MapOneToManyKeyValueRepo.kt +++ b/repos/inmemory/src/commonMain/kotlin/dev/inmo/micro_utils/repos/MapKeyValuesRepo.kt @@ -5,9 +5,11 @@ import dev.inmo.micro_utils.pagination.utils.paginate import dev.inmo.micro_utils.pagination.utils.reverse import kotlinx.coroutines.flow.* -class MapReadOneToManyKeyValueRepo( +@Deprecated("Renamed", ReplaceWith("MapReadKeyValuesRepo", "dev.inmo.micro_utils.repos.MapReadKeyValuesRepo")) +typealias MapReadOneToManyKeyValueRepo = MapReadKeyValuesRepo +class MapReadKeyValuesRepo( private val map: Map> = emptyMap() -) : ReadOneToManyKeyValueRepo { +) : ReadKeyValuesRepo { override suspend fun get(k: Key, pagination: Pagination, reversed: Boolean): PaginationResult { val list = map[k] ?: return emptyPaginationResult() @@ -53,9 +55,11 @@ class MapReadOneToManyKeyValueRepo( override suspend fun count(): Long = map.size.toLong() } -class MapWriteOneToManyKeyValueRepo( +@Deprecated("Renamed", ReplaceWith("MapWriteKeyValuesRepo", "dev.inmo.micro_utils.repos.MapWriteKeyValuesRepo")) +typealias MapWriteOneToManyKeyValueRepo = MapWriteKeyValuesRepo +class MapWriteKeyValuesRepo( private val map: MutableMap> = mutableMapOf() -) : WriteOneToManyKeyValueRepo { +) : WriteKeyValuesRepo { private val _onNewValue: MutableSharedFlow> = MutableSharedFlow() override val onNewValue: Flow> = _onNewValue.asSharedFlow() private val _onValueRemoved: MutableSharedFlow> = MutableSharedFlow() @@ -98,12 +102,17 @@ class MapWriteOneToManyKeyValueRepo( } } -class MapOneToManyKeyValueRepo( +@Deprecated("Renamed", ReplaceWith("MapKeyValuesRepo", "dev.inmo.micro_utils.repos.MapKeyValuesRepo")) +typealias MapOneToManyKeyValueRepo1 = MapKeyValuesRepo +class MapKeyValuesRepo( private val map: MutableMap> = mutableMapOf() -) : OneToManyKeyValueRepo, - ReadOneToManyKeyValueRepo by MapReadOneToManyKeyValueRepo(map), - WriteOneToManyKeyValueRepo by MapWriteOneToManyKeyValueRepo(map) +) : KeyValuesRepo, + ReadKeyValuesRepo by MapReadKeyValuesRepo(map), + WriteKeyValuesRepo by MapWriteKeyValuesRepo(map) -fun MutableMap>.asOneToManyKeyValueRepo(): OneToManyKeyValueRepo = MapOneToManyKeyValueRepo( +fun MutableMap>.asKeyValuesRepo(): KeyValuesRepo = MapKeyValuesRepo( map { (k, v) -> k to v.toMutableList() }.toMap().toMutableMap() ) + +@Deprecated("Renamed", ReplaceWith("asKeyValuesRepo", "dev.inmo.micro_utils.repos.asKeyValuesRepo")) +fun MutableMap>.asOneToManyKeyValueRepo(): KeyValuesRepo = asKeyValuesRepo() diff --git a/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/one_to_many/KtorStandardKeyValuesRepoClient.kt b/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/one_to_many/KtorKeyValuesRepoClient.kt similarity index 76% rename from repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/one_to_many/KtorStandardKeyValuesRepoClient.kt rename to repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/one_to_many/KtorKeyValuesRepoClient.kt index 6f1e2f43087..a7863a79560 100644 --- a/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/one_to_many/KtorStandardKeyValuesRepoClient.kt +++ b/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/one_to_many/KtorKeyValuesRepoClient.kt @@ -7,10 +7,10 @@ import io.ktor.http.ContentType import io.ktor.http.encodeURLQueryComponent import kotlinx.serialization.* -class KtorStandardKeyValuesRepoClient ( - readDelegate: ReadOneToManyKeyValueRepo, - writeDelegate: WriteOneToManyKeyValueRepo -) : OneToManyKeyValueRepo by DelegateBasedOneToManyKeyValueRepo( +class KtorKeyValuesRepoClient ( + readDelegate: ReadKeyValuesRepo, + writeDelegate: WriteKeyValuesRepo +) : KeyValuesRepo by DelegateBasedKeyValuesRepo( readDelegate, writeDelegate ) { @@ -21,15 +21,15 @@ class KtorStandardKeyValuesRepoClient ( contentType: ContentType, noinline keySerializer: suspend (Key) -> String, noinline valueSerializer: suspend (Value) -> String - ) = KtorStandardKeyValuesRepoClient( - KtorReadStandardKeyValuesRepoClient( + ) = KtorKeyValuesRepoClient( + KtorReadKeyValuesRepoClient( baseUrl, httpClient, contentType, keySerializer, valueSerializer ), - KtorWriteStandardKeyValuesRepoClient( + KtorWriteKeyValuesRepoClient( baseUrl, httpClient, contentType @@ -42,7 +42,7 @@ class KtorStandardKeyValuesRepoClient ( contentType: ContentType, noinline keySerializer: suspend (Key) -> String, noinline valueSerializer: suspend (Value) -> String - ) = KtorStandardKeyValuesRepoClient( + ) = KtorKeyValuesRepoClient( buildStandardUrl(baseUrl, subpart), httpClient, contentType, @@ -52,14 +52,14 @@ class KtorStandardKeyValuesRepoClient ( } } -inline fun KtorStandardKeyValuesRepoClient( +inline fun KtorKeyValuesRepoClient( baseUrl: String, httpClient: HttpClient, contentType: ContentType, keySerializer: SerializationStrategy, valueSerializer: SerializationStrategy, serialFormat: StringFormat, -) = KtorStandardKeyValuesRepoClient( +) = KtorKeyValuesRepoClient( baseUrl, httpClient, contentType, @@ -70,14 +70,14 @@ inline fun KtorStandardKeyValuesRepoCli serialFormat.encodeToString(valueSerializer, it).encodeURLQueryComponent() } -inline fun KtorStandardKeyValuesRepoClient( +inline fun KtorKeyValuesRepoClient( baseUrl: String, httpClient: HttpClient, contentType: ContentType, keySerializer: SerializationStrategy, valueSerializer: SerializationStrategy, serialFormat: BinaryFormat, -) = KtorStandardKeyValuesRepoClient( +) = KtorKeyValuesRepoClient( baseUrl, httpClient, contentType, diff --git a/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/one_to_many/KtorOneToManyKeyValueRepo.kt b/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/one_to_many/KtorOneToManyKeyValueRepo.kt index d50c23bb7e8..5bf8155d36d 100644 --- a/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/one_to_many/KtorOneToManyKeyValueRepo.kt +++ b/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/one_to_many/KtorOneToManyKeyValueRepo.kt @@ -7,20 +7,21 @@ import dev.inmo.micro_utils.repos.* import io.ktor.client.HttpClient import kotlinx.serialization.KSerializer +@Deprecated("Should be replaced with KtorKeyValuesRepoClient") class KtorOneToManyKeyValueRepo( baseUrl: String, baseSubpart: String, unifiedRequester: UnifiedRequester, keySerializer: KSerializer, valueSerializer: KSerializer, -) : OneToManyKeyValueRepo, - ReadOneToManyKeyValueRepo by KtorReadOneToManyKeyValueRepo ( +) : KeyValuesRepo, + ReadKeyValuesRepo by KtorReadOneToManyKeyValueRepo ( "$baseUrl/$baseSubpart", unifiedRequester, keySerializer, valueSerializer, ), - WriteOneToManyKeyValueRepo by KtorWriteOneToManyKeyValueRepo ( + WriteKeyValuesRepo by KtorWriteOneToManyKeyValueRepo ( "$baseUrl/$baseSubpart", unifiedRequester, keySerializer, @@ -34,4 +35,4 @@ class KtorOneToManyKeyValueRepo( valueSerializer: KSerializer, serialFormat: StandardKtorSerialFormat = standardKtorSerialFormat ) : this (baseUrl, baseSubpart, UnifiedRequester(client, serialFormat), keySerializer, valueSerializer) -} \ No newline at end of file +} diff --git a/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/one_to_many/KtorReadStandardKeyValuesRepoClient.kt b/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/one_to_many/KtorReadKeyValuesRepoClient.kt similarity index 87% rename from repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/one_to_many/KtorReadStandardKeyValuesRepoClient.kt rename to repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/one_to_many/KtorReadKeyValuesRepoClient.kt index f05478c1ea7..3a32621a230 100644 --- a/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/one_to_many/KtorReadStandardKeyValuesRepoClient.kt +++ b/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/one_to_many/KtorReadKeyValuesRepoClient.kt @@ -2,9 +2,8 @@ package dev.inmo.micro_utils.repos.ktor.client.one_to_many import dev.inmo.micro_utils.ktor.common.* import dev.inmo.micro_utils.pagination.* -import dev.inmo.micro_utils.repos.ReadOneToManyKeyValueRepo +import dev.inmo.micro_utils.repos.ReadKeyValuesRepo import dev.inmo.micro_utils.repos.ktor.common.* -import dev.inmo.micro_utils.repos.ktor.common.crud.* import dev.inmo.micro_utils.repos.ktor.common.one_to_many.* import dev.inmo.micro_utils.repos.ktor.common.reversedParameterName import io.ktor.client.HttpClient @@ -15,7 +14,7 @@ import io.ktor.util.reflect.TypeInfo import io.ktor.util.reflect.typeInfo import kotlinx.serialization.* -class KtorReadStandardKeyValuesRepoClient( +class KtorReadKeyValuesRepoClient( private val baseUrl: String, private val httpClient: HttpClient, private val contentType: ContentType, @@ -23,7 +22,7 @@ class KtorReadStandardKeyValuesRepoClient( private val paginationResultKeysTypeInfo: TypeInfo, private val keySerializer: suspend (Key) -> String, private val valueSerializer: suspend (Value) -> String -) : ReadOneToManyKeyValueRepo { +) : ReadKeyValuesRepo { override suspend fun get( k: Key, pagination: Pagination, @@ -106,13 +105,13 @@ class KtorReadStandardKeyValuesRepoClient( }.body() } -inline fun KtorReadStandardKeyValuesRepoClient( +inline fun KtorReadKeyValuesRepoClient( baseUrl: String, httpClient: HttpClient, contentType: ContentType, noinline keySerializer: suspend (Key) -> String, noinline valueSerializer: suspend (Value) -> String -) = KtorReadStandardKeyValuesRepoClient( +) = KtorReadKeyValuesRepoClient( baseUrl, httpClient, contentType, @@ -122,14 +121,14 @@ inline fun KtorReadStandardKeyValuesRepoClient( valueSerializer ) -inline fun KtorReadStandardKeyValuesRepoClient( +inline fun KtorReadKeyValuesRepoClient( baseUrl: String, httpClient: HttpClient, idsSerializer: KSerializer, valueSerializer: KSerializer, serialFormat: StringFormat, contentType: ContentType, -) = KtorReadStandardKeyValuesRepoClient( +) = KtorReadKeyValuesRepoClient( baseUrl, httpClient, contentType, @@ -140,14 +139,14 @@ inline fun KtorReadStandardKeyValuesRepoClient( serialFormat.encodeToString(valueSerializer, it).encodeURLQueryComponent() } -inline fun KtorReadStandardKeyValuesRepoClient( +inline fun KtorReadKeyValuesRepoClient( baseUrl: String, httpClient: HttpClient, idsSerializer: KSerializer, valuesSerializer: KSerializer, serialFormat: BinaryFormat, contentType: ContentType, -) = KtorReadStandardKeyValuesRepoClient( +) = KtorReadKeyValuesRepoClient( baseUrl, httpClient, contentType, diff --git a/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/one_to_many/KtorReadOneToManyKeyValueRepo.kt b/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/one_to_many/KtorReadOneToManyKeyValueRepo.kt index 5eb413eda8c..6a91a21a208 100644 --- a/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/one_to_many/KtorReadOneToManyKeyValueRepo.kt +++ b/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/one_to_many/KtorReadOneToManyKeyValueRepo.kt @@ -3,7 +3,7 @@ package dev.inmo.micro_utils.repos.ktor.client.one_to_many import dev.inmo.micro_utils.ktor.client.* import dev.inmo.micro_utils.ktor.common.* import dev.inmo.micro_utils.pagination.* -import dev.inmo.micro_utils.repos.ReadOneToManyKeyValueRepo +import dev.inmo.micro_utils.repos.ReadKeyValuesRepo import dev.inmo.micro_utils.repos.ktor.common.keyParameterName import dev.inmo.micro_utils.repos.ktor.common.one_to_many.* import dev.inmo.micro_utils.repos.ktor.common.reversedParameterName @@ -12,12 +12,13 @@ import io.ktor.client.HttpClient import kotlinx.serialization.KSerializer import kotlinx.serialization.builtins.serializer +@Deprecated("Should be replaced with KtorReadKeyValuesRepoClient") class KtorReadOneToManyKeyValueRepo ( private val baseUrl: String, private val unifiedRequester: UnifiedRequester, private val keySerializer: KSerializer, private val valueSerializer: KSerializer -) : ReadOneToManyKeyValueRepo { +) : ReadKeyValuesRepo { private val paginationValueResultSerializer = PaginationResult.serializer(valueSerializer) private val paginationKeyResultSerializer = PaginationResult.serializer(keySerializer) @@ -104,4 +105,4 @@ class KtorReadOneToManyKeyValueRepo ( Long.serializer() ) -} \ No newline at end of file +} diff --git a/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/one_to_many/KtorWriteStandardKeyValuesRepoClient.kt b/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/one_to_many/KtorWriteKeyValuesRepoClient.kt similarity index 93% rename from repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/one_to_many/KtorWriteStandardKeyValuesRepoClient.kt rename to repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/one_to_many/KtorWriteKeyValuesRepoClient.kt index 1f77a79f57f..8b087ae452f 100644 --- a/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/one_to_many/KtorWriteStandardKeyValuesRepoClient.kt +++ b/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/one_to_many/KtorWriteKeyValuesRepoClient.kt @@ -3,7 +3,7 @@ package dev.inmo.micro_utils.repos.ktor.client.one_to_many import dev.inmo.micro_utils.ktor.client.createStandardWebsocketFlow import dev.inmo.micro_utils.ktor.client.throwOnUnsuccess import dev.inmo.micro_utils.ktor.common.* -import dev.inmo.micro_utils.repos.WriteOneToManyKeyValueRepo +import dev.inmo.micro_utils.repos.WriteKeyValuesRepo import dev.inmo.micro_utils.repos.ktor.common.one_to_many.* import io.ktor.client.HttpClient import io.ktor.client.request.post @@ -13,7 +13,7 @@ import io.ktor.util.reflect.TypeInfo import io.ktor.util.reflect.typeInfo import kotlinx.coroutines.flow.Flow -class KtorWriteStandardKeyValuesRepoClient( +class KtorWriteKeyValuesRepoClient( private val baseUrl: String, private val httpClient: HttpClient, private val contentType: ContentType, @@ -23,7 +23,7 @@ class KtorWriteStandardKeyValuesRepoClient( private val keyTypeInfo: TypeInfo, private val valueTypeInfo: TypeInfo, private val keyToValuesMapTypeInfo: TypeInfo -) : WriteOneToManyKeyValueRepo { +) : WriteKeyValuesRepo { @OptIn(InternalAPI::class) override suspend fun add(toAdd: Map>) { @@ -85,7 +85,7 @@ class KtorWriteStandardKeyValuesRepoClient( baseUrl: String, httpClient: HttpClient, contentType: ContentType - ) = KtorWriteStandardKeyValuesRepoClient( + ) = KtorWriteKeyValuesRepoClient( baseUrl, httpClient, contentType, diff --git a/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/one_to_many/KtorWriteOneToManyKeyValueRepo.kt b/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/one_to_many/KtorWriteOneToManyKeyValueRepo.kt index 1a2122d25d7..6430b7252e2 100644 --- a/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/one_to_many/KtorWriteOneToManyKeyValueRepo.kt +++ b/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/one_to_many/KtorWriteOneToManyKeyValueRepo.kt @@ -2,19 +2,20 @@ package dev.inmo.micro_utils.repos.ktor.client.one_to_many import dev.inmo.micro_utils.ktor.client.* import dev.inmo.micro_utils.ktor.common.* -import dev.inmo.micro_utils.repos.WriteOneToManyKeyValueRepo +import dev.inmo.micro_utils.repos.WriteKeyValuesRepo import dev.inmo.micro_utils.repos.ktor.common.one_to_many.* import io.ktor.client.HttpClient import kotlinx.coroutines.flow.Flow import kotlinx.serialization.KSerializer import kotlinx.serialization.builtins.* +@Deprecated("Should be replaced with KtorWriteKeyValuesRepoClient") class KtorWriteOneToManyKeyValueRepo ( private val baseUrl: String, private val unifiedRequester: UnifiedRequester, private val keySerializer: KSerializer, private val valueSerializer: KSerializer -) : WriteOneToManyKeyValueRepo { +) : WriteKeyValuesRepo { private val keyValueSerializer = PairSerializer(keySerializer, valueSerializer) private val keyValueMapSerializer = MapSerializer(keySerializer, ListSerializer(valueSerializer)) diff --git a/repos/ktor/common/src/jvmTest/kotlin/KVsTests.kt b/repos/ktor/common/src/jvmTest/kotlin/KVsTests.kt index 20a8427e3e2..1db65f3e605 100644 --- a/repos/ktor/common/src/jvmTest/kotlin/KVsTests.kt +++ b/repos/ktor/common/src/jvmTest/kotlin/KVsTests.kt @@ -1,8 +1,8 @@ import dev.inmo.micro_utils.pagination.firstPageWithOneElementPagination import dev.inmo.micro_utils.pagination.utils.getAllWithNextPaging import dev.inmo.micro_utils.repos.* -import dev.inmo.micro_utils.repos.ktor.client.one_to_many.KtorStandardKeyValuesRepoClient -import dev.inmo.micro_utils.repos.ktor.server.one_to_many.configureStandardKeyValuesRepoRoutes +import dev.inmo.micro_utils.repos.ktor.client.one_to_many.KtorKeyValuesRepoClient +import dev.inmo.micro_utils.repos.ktor.server.one_to_many.configureKeyValuesRepoRoutes import io.ktor.client.HttpClient import io.ktor.client.plugins.logging.Logging import io.ktor.http.ContentType @@ -25,7 +25,7 @@ class KVsTests { fun testKVsFunctions() { runTest { val map = mutableMapOf>() - val repo = MapOneToManyKeyValueRepo(map) + val repo = MapKeyValuesRepo(map) val server = io.ktor.server.engine.embeddedServer( CIO, 23456, @@ -38,7 +38,7 @@ class KVsTests { contentConverter = KotlinxWebsocketSerializationConverter(Json) } routing { - configureStandardKeyValuesRepoRoutes( + configureKeyValuesRepoRoutes( repo, Int.serializer(), ComplexData.serializer(), @@ -55,7 +55,7 @@ class KVsTests { contentConverter = KotlinxWebsocketSerializationConverter(Json) } } - val crudClient = KtorStandardKeyValuesRepoClient( + val crudClient = KtorKeyValuesRepoClient( "http://127.0.0.1:23456", client, ContentType.Application.Json, diff --git a/repos/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/ktor/server/one_to_many/ConfigureOneToManyKeyValueRepoRoutes.kt b/repos/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/ktor/server/one_to_many/ConfigureOneToManyKeyValueRepoRoutes.kt index 4f2c694c25d..9b68c0ac04f 100644 --- a/repos/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/ktor/server/one_to_many/ConfigureOneToManyKeyValueRepoRoutes.kt +++ b/repos/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/ktor/server/one_to_many/ConfigureOneToManyKeyValueRepoRoutes.kt @@ -4,7 +4,7 @@ import dev.inmo.micro_utils.ktor.common.StandardKtorSerialFormat import dev.inmo.micro_utils.ktor.common.standardKtorSerialFormat import dev.inmo.micro_utils.ktor.server.UnifiedRouter import dev.inmo.micro_utils.ktor.server.standardKtorSerialFormatContentType -import dev.inmo.micro_utils.repos.OneToManyKeyValueRepo +import dev.inmo.micro_utils.repos.KeyValuesRepo import io.ktor.http.ContentType import io.ktor.server.routing.Route import io.ktor.server.routing.route @@ -12,7 +12,7 @@ import kotlinx.serialization.KSerializer fun Route.configureOneToManyKeyValueRepoRoutes( baseSubpart: String, - originalRepo: OneToManyKeyValueRepo, + originalRepo: KeyValuesRepo, keySerializer: KSerializer, valueSerializer: KSerializer, unifiedRouter: UnifiedRouter @@ -25,7 +25,7 @@ fun Route.configureOneToManyKeyValueRepoRoutes( fun Route.configureOneToManyKeyValueRepoRoutes( baseSubpart: String, - originalRepo: OneToManyKeyValueRepo, + originalRepo: KeyValuesRepo, keySerializer: KSerializer, valueSerializer: KSerializer, serialFormat: StandardKtorSerialFormat = standardKtorSerialFormat, diff --git a/repos/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/ktor/server/one_to_many/ConfigureOneToManyReadKeyValueRepoRoutes.kt b/repos/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/ktor/server/one_to_many/ConfigureOneToManyReadKeyValueRepoRoutes.kt index c0795d2280b..41a035c4730 100644 --- a/repos/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/ktor/server/one_to_many/ConfigureOneToManyReadKeyValueRepoRoutes.kt +++ b/repos/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/ktor/server/one_to_many/ConfigureOneToManyReadKeyValueRepoRoutes.kt @@ -5,7 +5,7 @@ import dev.inmo.micro_utils.ktor.common.standardKtorSerialFormat import dev.inmo.micro_utils.ktor.server.* import dev.inmo.micro_utils.pagination.PaginationResult import dev.inmo.micro_utils.pagination.extractPagination -import dev.inmo.micro_utils.repos.ReadOneToManyKeyValueRepo +import dev.inmo.micro_utils.repos.ReadKeyValuesRepo import dev.inmo.micro_utils.repos.ktor.common.keyParameterName import dev.inmo.micro_utils.repos.ktor.common.one_to_many.* import dev.inmo.micro_utils.repos.ktor.common.valueParameterName @@ -18,7 +18,7 @@ import kotlinx.serialization.KSerializer import kotlinx.serialization.builtins.serializer fun Route.configureOneToManyReadKeyValueRepoRoutes( - originalRepo: ReadOneToManyKeyValueRepo, + originalRepo: ReadKeyValuesRepo, keySerializer: KSerializer, valueSerializer: KSerializer, unifiedRouter: UnifiedRouter @@ -121,7 +121,7 @@ fun Route.configureOneToManyReadKeyValueRepoRoutes( } inline fun Route.configureOneToManyReadKeyValueRepoRoutes( - originalRepo: ReadOneToManyKeyValueRepo, + originalRepo: ReadKeyValuesRepo, keySerializer: KSerializer, valueSerializer: KSerializer, serialFormat: StandardKtorSerialFormat = standardKtorSerialFormat, diff --git a/repos/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/ktor/server/one_to_many/ConfigureOneToManyWriteKeyValueRepoRoutes.kt b/repos/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/ktor/server/one_to_many/ConfigureOneToManyWriteKeyValueRepoRoutes.kt index dbef2f3e416..301350b64c4 100644 --- a/repos/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/ktor/server/one_to_many/ConfigureOneToManyWriteKeyValueRepoRoutes.kt +++ b/repos/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/ktor/server/one_to_many/ConfigureOneToManyWriteKeyValueRepoRoutes.kt @@ -3,7 +3,7 @@ package dev.inmo.micro_utils.repos.ktor.server.one_to_many import dev.inmo.micro_utils.ktor.common.StandardKtorSerialFormat import dev.inmo.micro_utils.ktor.common.standardKtorSerialFormat import dev.inmo.micro_utils.ktor.server.* -import dev.inmo.micro_utils.repos.WriteOneToManyKeyValueRepo +import dev.inmo.micro_utils.repos.WriteKeyValuesRepo import dev.inmo.micro_utils.repos.ktor.common.one_to_many.* import io.ktor.http.ContentType import io.ktor.server.routing.Route @@ -12,7 +12,7 @@ import kotlinx.serialization.KSerializer import kotlinx.serialization.builtins.* fun Route.configureOneToManyWriteKeyValueRepoRoutes( - originalRepo: WriteOneToManyKeyValueRepo, + originalRepo: WriteKeyValuesRepo, keySerializer: KSerializer, valueSerializer: KSerializer, unifiedRouter: UnifiedRouter @@ -95,7 +95,7 @@ fun Route.configureOneToManyWriteKeyValueRepoRoutes( } fun Route.configureOneToManyWriteKeyValueRepoRoutes( - originalRepo: WriteOneToManyKeyValueRepo, + originalRepo: WriteKeyValuesRepo, keySerializer: KSerializer, valueSerializer: KSerializer, serialFormat: StandardKtorSerialFormat = standardKtorSerialFormat, diff --git a/repos/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/ktor/server/one_to_many/NewKtorStandartKeyValuesRepo.kt b/repos/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/ktor/server/one_to_many/KtorKeyValuesRepoRoutes.kt similarity index 70% rename from repos/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/ktor/server/one_to_many/NewKtorStandartKeyValuesRepo.kt rename to repos/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/ktor/server/one_to_many/KtorKeyValuesRepoRoutes.kt index 625ddc25529..c0aaa389810 100644 --- a/repos/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/ktor/server/one_to_many/NewKtorStandartKeyValuesRepo.kt +++ b/repos/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/ktor/server/one_to_many/KtorKeyValuesRepoRoutes.kt @@ -6,21 +6,21 @@ import io.ktor.http.* import io.ktor.server.routing.Route import kotlinx.serialization.* -inline fun Route.configureStandardKeyValuesRepoRoutes ( - originalRepo: OneToManyKeyValueRepo, +inline fun Route.configureKeyValuesRepoRoutes ( + originalRepo: KeyValuesRepo, noinline idDeserializer: suspend (String) -> Key, noinline valueDeserializer: suspend (String) -> Value ) { - configureReadStandardKeyValuesRepoRoutes(originalRepo, idDeserializer, valueDeserializer) - configureWriteStandardKeyValuesRepoRoutes(originalRepo) + configureReadKeyValuesRepoRoutes(originalRepo, idDeserializer, valueDeserializer) + configureWriteKeyValuesRepoRoutes(originalRepo) } -inline fun Route.configureStandardKeyValuesRepoRoutes( - originalRepo: OneToManyKeyValueRepo, +inline fun Route.configureKeyValuesRepoRoutes( + originalRepo: KeyValuesRepo, idsSerializer: DeserializationStrategy, valueSerializer: DeserializationStrategy, serialFormat: StringFormat -) = configureStandardKeyValuesRepoRoutes( +) = configureKeyValuesRepoRoutes( originalRepo, { serialFormat.decodeFromString(idsSerializer, it.decodeURLQueryComponent()) @@ -30,12 +30,12 @@ inline fun Route.configureStandardKeyVa } ) -inline fun Route.configureStandardKeyValuesRepoRoutes( - originalRepo: OneToManyKeyValueRepo, +inline fun Route.configureKeyValuesRepoRoutes( + originalRepo: KeyValuesRepo, idsSerializer: DeserializationStrategy, valueSerializer: DeserializationStrategy, serialFormat: BinaryFormat -) = configureStandardKeyValuesRepoRoutes( +) = configureKeyValuesRepoRoutes( originalRepo, { serialFormat.decodeHex(idsSerializer, it) diff --git a/repos/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/ktor/server/one_to_many/NewKtorStandartReadKeyValuesRepo.kt b/repos/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/ktor/server/one_to_many/KtorReadKeyValuesRepoRoutes.kt similarity index 84% rename from repos/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/ktor/server/one_to_many/NewKtorStandartReadKeyValuesRepo.kt rename to repos/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/ktor/server/one_to_many/KtorReadKeyValuesRepoRoutes.kt index c8f5c0b7b7c..80ac3e7dfd2 100644 --- a/repos/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/ktor/server/one_to_many/NewKtorStandartReadKeyValuesRepo.kt +++ b/repos/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/ktor/server/one_to_many/KtorReadKeyValuesRepoRoutes.kt @@ -4,7 +4,7 @@ import dev.inmo.micro_utils.ktor.common.* import dev.inmo.micro_utils.ktor.server.* import dev.inmo.micro_utils.pagination.PaginationResult import dev.inmo.micro_utils.pagination.extractPagination -import dev.inmo.micro_utils.repos.ReadOneToManyKeyValueRepo +import dev.inmo.micro_utils.repos.ReadKeyValuesRepo import dev.inmo.micro_utils.repos.ktor.common.* import dev.inmo.micro_utils.repos.ktor.common.containsRoute import dev.inmo.micro_utils.repos.ktor.common.one_to_many.* @@ -18,8 +18,8 @@ import io.ktor.util.reflect.typeInfo import kotlinx.serialization.* @OptIn(InternalAPI::class) -inline fun Route.configureReadStandardKeyValuesRepoRoutes ( - originalRepo: ReadOneToManyKeyValueRepo, +inline fun Route.configureReadKeyValuesRepoRoutes ( + originalRepo: ReadKeyValuesRepo, noinline idDeserializer: suspend (String) -> Key, noinline valueDeserializer: suspend (String) -> Value ) { @@ -75,12 +75,12 @@ inline fun Route.configureReadStandardKeyValuesRepo } } -inline fun Route.configureReadStandardKeyValuesRepoRoutes( - originalRepo: ReadOneToManyKeyValueRepo, +inline fun Route.configureReadKeyValuesRepoRoutes( + originalRepo: ReadKeyValuesRepo, idsSerializer: DeserializationStrategy, valueSerializer: DeserializationStrategy, serialFormat: StringFormat -) = configureReadStandardKeyValuesRepoRoutes( +) = configureReadKeyValuesRepoRoutes( originalRepo, { serialFormat.decodeFromString(idsSerializer, it.decodeURLQueryComponent()) @@ -90,12 +90,12 @@ inline fun Route.configureReadStandardKeyValuesRepo } ) -inline fun Route.configureReadStandardKeyValuesRepoRoutes( - originalRepo: ReadOneToManyKeyValueRepo, +inline fun Route.configureReadKeyValuesRepoRoutes( + originalRepo: ReadKeyValuesRepo, idsSerializer: DeserializationStrategy, valueSerializer: DeserializationStrategy, serialFormat: BinaryFormat -) = configureReadStandardKeyValuesRepoRoutes( +) = configureReadKeyValuesRepoRoutes( originalRepo, { serialFormat.decodeHex(idsSerializer, it) diff --git a/repos/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/ktor/server/one_to_many/NewKtorStandartWriteKeyValuesRepo.kt b/repos/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/ktor/server/one_to_many/KtorWriteKeyValuesRepoRoutes.kt similarity index 90% rename from repos/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/ktor/server/one_to_many/NewKtorStandartWriteKeyValuesRepo.kt rename to repos/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/ktor/server/one_to_many/KtorWriteKeyValuesRepoRoutes.kt index a33e9062a72..440821ed17c 100644 --- a/repos/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/ktor/server/one_to_many/NewKtorStandartWriteKeyValuesRepo.kt +++ b/repos/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/ktor/server/one_to_many/KtorWriteKeyValuesRepoRoutes.kt @@ -1,7 +1,7 @@ package dev.inmo.micro_utils.repos.ktor.server.one_to_many import dev.inmo.micro_utils.ktor.server.* -import dev.inmo.micro_utils.repos.WriteOneToManyKeyValueRepo +import dev.inmo.micro_utils.repos.WriteKeyValuesRepo import dev.inmo.micro_utils.repos.ktor.common.one_to_many.* import io.ktor.http.HttpStatusCode import io.ktor.server.application.call @@ -11,8 +11,8 @@ import io.ktor.server.routing.Route import io.ktor.server.routing.post import io.ktor.util.reflect.typeInfo -inline fun Route.configureWriteStandardKeyValuesRepoRoutes ( - originalRepo: WriteOneToManyKeyValueRepo +inline fun Route.configureWriteKeyValuesRepoRoutes ( + originalRepo: WriteKeyValuesRepo ) { includeWebsocketHandling( onNewValueRoute,