diff --git a/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/InputAllocator.kt b/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/InputAllocator.kt index 280754a4bd1..7e48a9caa9e 100644 --- a/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/InputAllocator.kt +++ b/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/InputAllocator.kt @@ -9,6 +9,7 @@ import kotlin.js.JsExport typealias ByteArrayAllocator = () -> ByteArray +@JsExport val ByteArray.asAllocator: ByteArrayAllocator get() = { this } diff --git a/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/BroadcastFlow.kt b/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/BroadcastFlow.kt index d65c13da9a6..e1fb966144d 100644 --- a/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/BroadcastFlow.kt +++ b/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/BroadcastFlow.kt @@ -3,10 +3,8 @@ package dev.inmo.micro_utils.coroutines import kotlinx.coroutines.channels.* import kotlinx.coroutines.flow.* import kotlin.js.JsExport -import kotlin.js.JsName @JsExport -@JsName("BroadcastFlowFactory") @Suppress("FunctionName") fun BroadcastFlow( internalChannelSize: Int = Channel.BUFFERED diff --git a/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/BroadcastStateFlow.kt b/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/BroadcastStateFlow.kt index 4b5061e1624..3df24b6d12a 100644 --- a/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/BroadcastStateFlow.kt +++ b/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/BroadcastStateFlow.kt @@ -5,7 +5,6 @@ import kotlinx.coroutines.channels.BroadcastChannel import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.flow.* import kotlin.js.JsExport -import kotlin.js.JsName @JsExport class BroadcastStateFlow internal constructor( @@ -26,7 +25,6 @@ fun BroadcastChannel.asStateFlow(value: T, scope: CoroutineScope): StateF } @JsExport -@JsName("nullableAsStateFlow") fun BroadcastChannel.asStateFlow(scope: CoroutineScope): StateFlow = asStateFlow(null, scope) @JsExport @@ -37,6 +35,5 @@ fun broadcastStateFlow(initial: T, scope: CoroutineScope, channelSize: Int = } @JsExport -@JsName("nullableBroadcastStateFlow") fun broadcastStateFlow(scope: CoroutineScope, channelSize: Int = Channel.BUFFERED) = broadcastStateFlow(null, scope, channelSize) diff --git a/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/DataAsDeferred.kt b/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/DataAsDeferred.kt index e196df51555..d529e3de77a 100644 --- a/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/DataAsDeferred.kt +++ b/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/DataAsDeferred.kt @@ -2,6 +2,8 @@ package dev.inmo.micro_utils.coroutines import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.Deferred +import kotlin.js.JsExport +@JsExport val T.asDeferred: Deferred get() = CompletableDeferred(this) diff --git a/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/DoOutsideOfCoroutine.kt b/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/DoOutsideOfCoroutine.kt index 8ee76b71811..5931053cf52 100644 --- a/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/DoOutsideOfCoroutine.kt +++ b/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/DoOutsideOfCoroutine.kt @@ -6,6 +6,7 @@ import kotlin.js.JsExport /** * Call this method in case you need to do something in common thread (like reading of file in JVM) */ +@JsExport suspend fun doOutsideOfCoroutine(block: () -> T): T = suspendCoroutine { try { it.resume(block()) diff --git a/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/HandleSafely.kt b/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/HandleSafely.kt index d9972cffab3..13738f07d9c 100644 --- a/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/HandleSafely.kt +++ b/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/HandleSafely.kt @@ -12,6 +12,7 @@ typealias ExceptionHandler = suspend (Throwable) -> T * @param [onException] Will be called when happen exception inside of [block]. By default will throw exception - this * exception will be available for catching */ +@JsExport suspend inline fun safely( noinline onException: ExceptionHandler = { throw it }, noinline block: suspend CoroutineScope.() -> T diff --git a/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/client/FlowsWebsockets.kt b/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/client/FlowsWebsockets.kt index 50b83c3bea0..d807fa3815d 100644 --- a/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/client/FlowsWebsockets.kt +++ b/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/client/FlowsWebsockets.kt @@ -9,7 +9,6 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.channelFlow import kotlinx.serialization.DeserializationStrategy import kotlin.js.JsExport -import kotlin.js.JsName /** * @param checkReconnection This lambda will be called when it is required to reconnect to websocket to establish @@ -64,7 +63,6 @@ inline fun HttpClient.createStandardWebsocketFlow( * connection. Must return true in case if must be reconnected. By default always reconnecting */ @JsExport -@JsName("createStandardWebsocketFlowWithDeserializer") inline fun HttpClient.createStandardWebsocketFlow( url: String, crossinline checkReconnection: (Throwable?) -> Boolean = { true }, diff --git a/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/client/StandardHttpClientGetPost.kt b/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/client/StandardHttpClientGetPost.kt index a32dcea460f..ce7d5196f20 100644 --- a/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/client/StandardHttpClientGetPost.kt +++ b/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/client/StandardHttpClientGetPost.kt @@ -9,6 +9,7 @@ import kotlin.js.JsExport typealias BodyPair = Pair, T> +@JsExport suspend fun HttpClient.uniget( url: String, resultDeserializer: DeserializationStrategy @@ -25,6 +26,7 @@ fun SerializationStrategy.encodeUrlQueryValue(value: T) = standardKtorSer value ) +@JsExport suspend fun HttpClient.unipost( url: String, bodyInfo: BodyPair, diff --git a/ktor/common/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/common/BuildStandardUrl.kt b/ktor/common/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/common/BuildStandardUrl.kt index ae734ea5e19..29db9c2d07e 100644 --- a/ktor/common/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/common/BuildStandardUrl.kt +++ b/ktor/common/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/common/BuildStandardUrl.kt @@ -1,7 +1,6 @@ package dev.inmo.micro_utils.ktor.common import kotlin.js.JsExport -import kotlin.js.JsName @JsExport fun buildStandardUrl( @@ -13,7 +12,6 @@ fun buildStandardUrl( ) @JsExport -@JsName("buildStandardUrlWithParametersList") fun buildStandardUrl( basePart: String, subpart: String, @@ -23,7 +21,6 @@ fun buildStandardUrl( ) @JsExport -@JsName("buildStandardUrlWithParametersVararg") fun buildStandardUrl( basePart: String, subpart: String, diff --git a/ktor/common/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/common/CorrectWebsocketUrl.kt b/ktor/common/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/common/CorrectWebsocketUrl.kt index 792aed3ead7..0466df14b51 100644 --- a/ktor/common/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/common/CorrectWebsocketUrl.kt +++ b/ktor/common/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/common/CorrectWebsocketUrl.kt @@ -4,6 +4,7 @@ import kotlin.js.JsExport private val schemaRegex = Regex("^[^:]*://") +@JsExport val String.asCorrectWebSocketUrl: String get() = if (startsWith("ws")) { this diff --git a/ktor/common/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/common/FromToDateTimeUrl.kt b/ktor/common/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/common/FromToDateTimeUrl.kt index 2a31acaefcc..dfd1503a8cf 100644 --- a/ktor/common/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/common/FromToDateTimeUrl.kt +++ b/ktor/common/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/common/FromToDateTimeUrl.kt @@ -5,12 +5,14 @@ import kotlin.js.JsExport typealias FromToDateTime = Pair +@JsExport val FromToDateTime.asFromToUrlPart: QueryParams get() = mapOf( "from" to first ?.unixMillis ?.toString(), "to" to second ?.unixMillis ?.toString() ) +@JsExport val QueryParams.extractFromToDateTime: FromToDateTime get() = FromToDateTime( get("from") ?.toDoubleOrNull() ?.let { DateTime(it) }, diff --git a/ktor/common/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/common/QueryParamsBuilder.kt b/ktor/common/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/common/QueryParamsBuilder.kt index 09425370bff..4bcfa33492b 100644 --- a/ktor/common/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/common/QueryParamsBuilder.kt +++ b/ktor/common/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/common/QueryParamsBuilder.kt @@ -1,14 +1,15 @@ package dev.inmo.micro_utils.ktor.common import kotlin.js.JsExport -import kotlin.js.JsName typealias QueryParam = Pair typealias QueryParams = Map +@JsExport val QueryParams.asUrlQuery: String get() = keys.joinToString("&") { "${it}${get(it) ?.let { value -> "=$value" }}" } +@JsExport val List.asUrlQuery: String get() = joinToString("&") { (key, value) -> "${key}${value ?.let { _ -> "=$value" }}" } @@ -18,11 +19,11 @@ fun String.includeQueryParams( ): String = "$this${if(queryParams.isNotEmpty()) "${if (contains("?")) "&" else "?"}${queryParams.asUrlQuery}" else ""}" @JsExport -@JsName("includeQueryParamsWithList") fun String.includeQueryParams( queryParams: List ): String = "$this${if (contains("?")) "&" else "?"}${queryParams.asUrlQuery}" +@JsExport val String.parseUrlQuery: QueryParams get() = split("&").map { it.split("=").let { pair -> diff --git a/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/Pagination.kt b/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/Pagination.kt index d038dce1bc1..e55389d8503 100644 --- a/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/Pagination.kt +++ b/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/Pagination.kt @@ -1,7 +1,6 @@ package dev.inmo.micro_utils.pagination import kotlin.js.JsExport -import kotlin.js.JsName import kotlin.math.ceil import kotlin.math.floor @@ -28,6 +27,7 @@ interface Pagination { /** * First number in index of objects. It can be used as offset for databases or other data sources */ +@JsExport val Pagination.firstIndex: Int get() = page * size @@ -37,6 +37,7 @@ val Pagination.firstIndex: Int * [[firstIndex], [lastIndex]]; That means, that for [Pagination] with [Pagination.size] == 10 and [Pagination.page] == 1 * you will retrieve [Pagination.firstIndex] == 10 and [Pagination.lastIndex] == 19. */ +@JsExport val Pagination.lastIndex: Int get() = firstIndex + size - 1 @@ -51,7 +52,6 @@ fun calculatePagesNumber(datasetSize: Long, pageSize: Int): Int { * Calculates pages count for given [datasetSize] */ @JsExport -@JsName("calculatePagesNumberWithInt") fun calculatePagesNumber(datasetSize: Int, pageSize: Int): Int = calculatePagesNumber( datasetSize.toLong(), diff --git a/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/PaginationResult.kt b/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/PaginationResult.kt index 4b3a60f3668..bf0fc730102 100644 --- a/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/PaginationResult.kt +++ b/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/PaginationResult.kt @@ -2,7 +2,6 @@ package dev.inmo.micro_utils.pagination import kotlinx.serialization.Serializable import kotlin.js.JsExport -import kotlin.js.JsName @JsExport @Serializable @@ -17,7 +16,6 @@ data class PaginationResult( fun emptyPaginationResult() = PaginationResult(0, 0, emptyList(), 0) @JsExport -@JsName("createPaginationResultWithPagination") fun List.createPaginationResult( pagination: Pagination, commonObjectsNumber: Long @@ -32,7 +30,6 @@ fun List.createPaginationResult( ) @JsExport -@JsName("createPaginationResultWithFirstIndex") fun List.createPaginationResult( firstIndex: Int, commonObjectsNumber: Long @@ -47,7 +44,6 @@ fun List.createPaginationResult( ) @JsExport -@JsName("createPaginationResultWithPair") fun Pair>.createPaginationResult( pagination: Pagination ) = second.createPaginationResult(pagination, first) diff --git a/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/SimplePagination.kt b/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/SimplePagination.kt index 2f0eb186782..942e9395a72 100644 --- a/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/SimplePagination.kt +++ b/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/SimplePagination.kt @@ -2,7 +2,6 @@ package dev.inmo.micro_utils.pagination import kotlinx.serialization.Serializable import kotlin.js.JsExport -import kotlin.js.JsName const val defaultSmallPageSize = 2 const val defaultMediumPageSize = 5 @@ -33,7 +32,6 @@ data class SimplePagination( ) : Pagination @JsExport -@JsName("PaginationFactory") fun Pagination( page: Int, size: Int diff --git a/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/utils/IterableExtensions.kt b/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/utils/IterableExtensions.kt index cdb5f4a02a9..db7365cf3f3 100644 --- a/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/utils/IterableExtensions.kt +++ b/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/utils/IterableExtensions.kt @@ -2,7 +2,6 @@ package dev.inmo.micro_utils.pagination.utils import dev.inmo.micro_utils.pagination.* import kotlin.js.JsExport -import kotlin.js.JsName @JsExport fun Iterable.paginate(with: Pagination): PaginationResult { @@ -24,7 +23,6 @@ fun Iterable.paginate(with: Pagination): PaginationResult { } @JsExport -@JsName("paginateList") fun List.paginate(with: Pagination): PaginationResult { return subList(with.firstIndex, with.lastIndex + 1).createPaginationResult( with, @@ -33,7 +31,6 @@ fun List.paginate(with: Pagination): PaginationResult { } @JsExport -@JsName("paginateSet") fun Set.paginate(with: Pagination): PaginationResult { return this.drop(with.firstIndex).take(with.size).createPaginationResult( with, diff --git a/pagination/ktor/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/PaginationInUrl.kt b/pagination/ktor/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/PaginationInUrl.kt index f777449759b..2dd0904face 100644 --- a/pagination/ktor/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/PaginationInUrl.kt +++ b/pagination/ktor/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/PaginationInUrl.kt @@ -7,18 +7,21 @@ const val paginationPageKey = "ppage" @JsExport const val paginationSizeKey = "psize" +@JsExport val Pagination.asUrlQueryParts get() = mapOf( paginationPageKey to page.toString(), paginationSizeKey to size.toString() ) +@JsExport val Pagination.asUrlQueryArrayParts get() = arrayOf( paginationPageKey to page.toString(), paginationSizeKey to size.toString() ) +@JsExport val Map.extractPagination: Pagination get() = SimplePagination( get(paginationPageKey) ?.toIntOrNull() ?: 0, 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/OneToManyKeyValueRepo.kt index c7ce6e66cc8..0564db7268e 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/OneToManyKeyValueRepo.kt @@ -5,6 +5,7 @@ import dev.inmo.micro_utils.pagination.PaginationResult import kotlinx.coroutines.flow.Flow import kotlin.js.JsExport +@JsExport interface ReadOneToManyKeyValueRepo : Repo { suspend fun get(k: Key, pagination: Pagination, reversed: Boolean = false): PaginationResult suspend fun keys(pagination: Pagination, reversed: Boolean = false): PaginationResult @@ -16,6 +17,7 @@ interface ReadOneToManyKeyValueRepo : Repo { @Deprecated("Renamed", ReplaceWith("ReadOneToManyKeyValueRepo", "dev.inmo.micro_utils.repos.ReadOneToManyKeyValueRepo")) typealias OneToManyReadKeyValueRepo = ReadOneToManyKeyValueRepo +@JsExport interface WriteOneToManyKeyValueRepo : Repo { val onNewValue: Flow> val onValueRemoved: Flow> @@ -28,4 +30,5 @@ interface WriteOneToManyKeyValueRepo : Repo { @Deprecated("Renamed", ReplaceWith("WriteOneToManyKeyValueRepo", "dev.inmo.micro_utils.repos.WriteOneToManyKeyValueRepo")) typealias OneToManyWriteKeyValueRepo = WriteOneToManyKeyValueRepo +@JsExport interface OneToManyKeyValueRepo : ReadOneToManyKeyValueRepo, WriteOneToManyKeyValueRepo \ No newline at end of file diff --git a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/StandartCRUDRepo.kt b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/StandartCRUDRepo.kt index a60dc2edc81..c8e93f51675 100644 --- a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/StandartCRUDRepo.kt +++ b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/StandartCRUDRepo.kt @@ -5,6 +5,7 @@ import dev.inmo.micro_utils.pagination.PaginationResult import kotlinx.coroutines.flow.Flow import kotlin.js.JsExport +@JsExport interface ReadStandardCRUDRepo : Repo { suspend fun getByPagination(pagination: Pagination): PaginationResult suspend fun getById(id: IdType): ObjectType? @@ -13,11 +14,14 @@ interface ReadStandardCRUDRepo : Repo { } typealias UpdatedValuePair = Pair +@JsExport val UpdatedValuePair.id get() = first +@JsExport val UpdatedValuePair<*, ValueType>.value get() = second +@JsExport interface WriteStandardCRUDRepo : Repo { val newObjectsFlow: Flow val updatedObjectsFlow: Flow @@ -29,12 +33,15 @@ interface WriteStandardCRUDRepo : Repo { suspend fun deleteById(ids: List) } +@JsExport suspend fun WriteStandardCRUDRepo.create( vararg values: InputValueType ): List = create(values.toList()) +@JsExport suspend fun WriteStandardCRUDRepo.update( vararg values: UpdatedValuePair ): List = update(values.toList()) +@JsExport suspend fun WriteStandardCRUDRepo.deleteById( vararg ids: IdType ) = deleteById(ids.toList()) diff --git a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/StandartKeyValueRepo.kt b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/StandartKeyValueRepo.kt index 612edd2541a..130d1bda970 100644 --- a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/StandartKeyValueRepo.kt +++ b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/StandartKeyValueRepo.kt @@ -5,6 +5,7 @@ import dev.inmo.micro_utils.pagination.PaginationResult import kotlinx.coroutines.flow.Flow import kotlin.js.JsExport +@JsExport interface ReadStandardKeyValueRepo : Repo { suspend fun get(k: Key): Value? suspend fun values(pagination: Pagination, reversed: Boolean = false): PaginationResult @@ -13,6 +14,7 @@ interface ReadStandardKeyValueRepo : Repo { suspend fun count(): Long } +@JsExport interface WriteStandardKeyValueRepo : Repo { val onNewValue: Flow> val onValueRemoved: Flow @@ -21,4 +23,5 @@ interface WriteStandardKeyValueRepo : Repo { suspend fun unset(k: Key) } +@JsExport interface StandardKeyValueRepo : ReadStandardKeyValueRepo, WriteStandardKeyValueRepo \ No newline at end of file diff --git a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/pagination/CRUDPaginationExtensions.kt b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/pagination/CRUDPaginationExtensions.kt index c45eb52244b..45a63976563 100644 --- a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/pagination/CRUDPaginationExtensions.kt +++ b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/pagination/CRUDPaginationExtensions.kt @@ -4,6 +4,7 @@ import dev.inmo.micro_utils.pagination.* import dev.inmo.micro_utils.repos.ReadStandardCRUDRepo import kotlin.js.JsExport +@JsExport suspend inline fun > REPO.doForAll( @Suppress("REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE") methodCaller: suspend REPO.(Pagination) -> PaginationResult, @@ -16,10 +17,12 @@ suspend inline fun > REPO.doForAll( } } +@JsExport suspend inline fun > REPO.doForAll( block: (List) -> Unit ) = doForAll({ getByPagination(it) }, block) +@JsExport suspend inline fun > REPO.getAll( @Suppress("REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE") methodCaller: suspend REPO.(Pagination) -> PaginationResult diff --git a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/pagination/KeyValuePaginationExtensions.kt b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/pagination/KeyValuePaginationExtensions.kt index 9c5ee16bc71..09d5a80f2b8 100644 --- a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/pagination/KeyValuePaginationExtensions.kt +++ b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/pagination/KeyValuePaginationExtensions.kt @@ -4,6 +4,7 @@ import dev.inmo.micro_utils.pagination.* import dev.inmo.micro_utils.repos.* import kotlin.js.JsExport +@JsExport suspend inline fun > REPO.doForAll( @Suppress("REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE") methodCaller: suspend REPO.(Pagination) -> PaginationResult, @@ -16,10 +17,12 @@ suspend inline fun > REP } } +@JsExport suspend inline fun > REPO.doForAll( block: (List>) -> Unit ) = doForAll({ keys(it, false) }, block) +@JsExport suspend inline fun > REPO.getAll( @Suppress("REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE") methodCaller: suspend REPO.(Pagination) -> PaginationResult 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 0b78b5a9d64..52bbfba9974 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 @@ -4,6 +4,7 @@ import dev.inmo.micro_utils.pagination.* import dev.inmo.micro_utils.repos.* import kotlin.js.JsExport +@JsExport suspend inline fun > REPO.doForAll( @Suppress("REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE") methodCaller: suspend REPO.(Pagination) -> PaginationResult, @@ -26,10 +27,12 @@ suspend inline fun > RE } } +@JsExport suspend inline fun > REPO.doForAll( block: (List>>) -> Unit ) = doForAll({ keys(it, false) }, block) +@JsExport suspend inline fun > REPO.getAll( @Suppress("REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE") methodCaller: suspend REPO.(Pagination) -> PaginationResult diff --git a/repos/inmemory/src/commonMain/kotlin/dev/inmo/micro_utils/repos/MapCRUDRepo.kt b/repos/inmemory/src/commonMain/kotlin/dev/inmo/micro_utils/repos/MapCRUDRepo.kt index 8488d09a499..77ea3788249 100644 --- a/repos/inmemory/src/commonMain/kotlin/dev/inmo/micro_utils/repos/MapCRUDRepo.kt +++ b/repos/inmemory/src/commonMain/kotlin/dev/inmo/micro_utils/repos/MapCRUDRepo.kt @@ -4,8 +4,8 @@ import dev.inmo.micro_utils.coroutines.BroadcastFlow import dev.inmo.micro_utils.pagination.* import kotlinx.coroutines.flow.Flow import kotlin.js.JsExport -import kotlin.js.JsName +@JsExport class ReadMapCRUDRepo( private val map: Map = emptyMap() ) : ReadStandardCRUDRepo { @@ -25,6 +25,7 @@ class ReadMapCRUDRepo( override suspend fun count(): Long = map.size.toLong() } +@JsExport abstract class WriteMapCRUDRepo( private val map: MutableMap = mutableMapOf() ) : WriteStandardCRUDRepo { @@ -80,7 +81,6 @@ abstract class MapCRUDRepo( WriteMapCRUDRepo(map) @JsExport -@JsName("MapCRUDRepoFactory") fun MapCRUDRepo( map: MutableMap, updateCallback: suspend (newValue: InputValueType, id: IdType, old: ObjectType) -> ObjectType, diff --git a/repos/inmemory/src/commonMain/kotlin/dev/inmo/micro_utils/repos/MapKeyValueRepo.kt b/repos/inmemory/src/commonMain/kotlin/dev/inmo/micro_utils/repos/MapKeyValueRepo.kt index 89c571bf788..6c4323f26af 100644 --- a/repos/inmemory/src/commonMain/kotlin/dev/inmo/micro_utils/repos/MapKeyValueRepo.kt +++ b/repos/inmemory/src/commonMain/kotlin/dev/inmo/micro_utils/repos/MapKeyValueRepo.kt @@ -5,6 +5,7 @@ import dev.inmo.micro_utils.pagination.* import kotlinx.coroutines.flow.Flow import kotlin.js.JsExport +@JsExport class ReadMapKeyValueRepo( private val map: Map = emptyMap() ) : ReadStandardKeyValueRepo { @@ -46,6 +47,7 @@ class ReadMapKeyValueRepo( override suspend fun count(): Long = map.size.toLong() } +@JsExport class WriteMapKeyValueRepo( private val map: MutableMap = mutableMapOf() ) : WriteStandardKeyValueRepo { 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/MapOneToManyKeyValueRepo.kt index 72952f1622b..9f9b019c946 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/MapOneToManyKeyValueRepo.kt @@ -6,6 +6,7 @@ import dev.inmo.micro_utils.pagination.utils.paginate import kotlinx.coroutines.flow.Flow import kotlin.js.JsExport +@JsExport class MapReadOneToManyKeyValueRepo( private val map: Map> = emptyMap() ) : ReadOneToManyKeyValueRepo { @@ -45,6 +46,7 @@ class MapReadOneToManyKeyValueRepo( override suspend fun count(): Long = map.size.toLong() } +@JsExport class MapWriteOneToManyKeyValueRepo( private val map: MutableMap> = mutableMapOf() ) : WriteOneToManyKeyValueRepo { diff --git a/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/crud/KtorReadStandardCrudRepo.kt b/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/crud/KtorReadStandardCrudRepo.kt index f7f6b3dcc0a..5d5f780ef31 100644 --- a/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/crud/KtorReadStandardCrudRepo.kt +++ b/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/crud/KtorReadStandardCrudRepo.kt @@ -13,6 +13,7 @@ import kotlinx.serialization.KSerializer import kotlinx.serialization.builtins.serializer import kotlin.js.JsExport +@JsExport class KtorReadStandardCrudRepo ( private val baseUrl: String, private val client: HttpClient = HttpClient(), diff --git a/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/crud/KtorWriteStandardCrudRepo.kt b/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/crud/KtorWriteStandardCrudRepo.kt index 5403c066740..717b1d1ece9 100644 --- a/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/crud/KtorWriteStandardCrudRepo.kt +++ b/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/crud/KtorWriteStandardCrudRepo.kt @@ -13,6 +13,7 @@ import kotlinx.serialization.KSerializer import kotlinx.serialization.builtins.* import kotlin.js.JsExport +@JsExport class KtorWriteStandardCrudRepo ( private val baseUrl: String, private val client: HttpClient = HttpClient(), diff --git a/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/key_value/KtorReadStandardKeyValueRepo.kt b/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/key_value/KtorReadStandardKeyValueRepo.kt index 0c2d7ea5ed3..c2886607935 100644 --- a/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/key_value/KtorReadStandardKeyValueRepo.kt +++ b/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/key_value/KtorReadStandardKeyValueRepo.kt @@ -13,6 +13,7 @@ import kotlinx.serialization.KSerializer import kotlinx.serialization.builtins.serializer import kotlin.js.JsExport +@JsExport class KtorReadStandardKeyValueRepo ( private var baseUrl: String, private var client: HttpClient = HttpClient(), diff --git a/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/key_value/KtorWriteStandardKeyValueRepo.kt b/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/key_value/KtorWriteStandardKeyValueRepo.kt index 0e8ad5ecb4a..951f9d30291 100644 --- a/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/key_value/KtorWriteStandardKeyValueRepo.kt +++ b/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/key_value/KtorWriteStandardKeyValueRepo.kt @@ -13,6 +13,7 @@ import kotlinx.serialization.builtins.PairSerializer import kotlinx.serialization.builtins.serializer import kotlin.js.JsExport +@JsExport class KtorWriteStandardKeyValueRepo ( private var baseUrl: String, private var client: HttpClient = HttpClient(), 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 7dbe82ad570..92063ec1d8f 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 @@ -13,6 +13,7 @@ import kotlinx.serialization.KSerializer import kotlinx.serialization.builtins.serializer import kotlin.js.JsExport +@JsExport class KtorReadOneToManyKeyValueRepo ( private val baseUrl: String, private val client: HttpClient = HttpClient(), 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 8e167459933..a78c6be3dd7 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 @@ -13,6 +13,7 @@ import kotlinx.serialization.builtins.PairSerializer import kotlinx.serialization.builtins.serializer import kotlin.js.JsExport +@JsExport class KtorWriteOneToManyKeyValueRepo ( private val baseUrl: String, private val client: HttpClient = HttpClient(),