mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2025-09-03 23:29:46 +00:00
less annotations to god of lessannotations
This commit is contained in:
@@ -9,6 +9,7 @@ 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
|
||||
@@ -63,6 +64,7 @@ inline fun <T> HttpClient.createStandardWebsocketFlow(
|
||||
* connection. Must return true in case if must be reconnected. By default always reconnecting
|
||||
*/
|
||||
@JsExport
|
||||
@JsName("createStandardWebsocketFlowWithDeserializer")
|
||||
inline fun <T> HttpClient.createStandardWebsocketFlow(
|
||||
url: String,
|
||||
crossinline checkReconnection: (Throwable?) -> Boolean = { true },
|
||||
|
@@ -9,7 +9,6 @@ import kotlin.js.JsExport
|
||||
|
||||
typealias BodyPair<T> = Pair<SerializationStrategy<T>, T>
|
||||
|
||||
@JsExport
|
||||
suspend fun <ResultType> HttpClient.uniget(
|
||||
url: String,
|
||||
resultDeserializer: DeserializationStrategy<ResultType>
|
||||
@@ -26,7 +25,6 @@ fun <T> SerializationStrategy<T>.encodeUrlQueryValue(value: T) = standardKtorSer
|
||||
value
|
||||
)
|
||||
|
||||
@JsExport
|
||||
suspend fun <BodyType, ResultType> HttpClient.unipost(
|
||||
url: String,
|
||||
bodyInfo: BodyPair<BodyType>,
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package dev.inmo.micro_utils.ktor.common
|
||||
|
||||
import kotlin.js.JsExport
|
||||
import kotlin.js.JsName
|
||||
|
||||
@JsExport
|
||||
fun buildStandardUrl(
|
||||
@@ -12,6 +13,7 @@ fun buildStandardUrl(
|
||||
)
|
||||
|
||||
@JsExport
|
||||
@JsName("buildStandardUrlWithParametersList")
|
||||
fun buildStandardUrl(
|
||||
basePart: String,
|
||||
subpart: String,
|
||||
@@ -21,6 +23,7 @@ fun buildStandardUrl(
|
||||
)
|
||||
|
||||
@JsExport
|
||||
@JsName("buildStandardUrlWithParametersVararg")
|
||||
fun buildStandardUrl(
|
||||
basePart: String,
|
||||
subpart: String,
|
||||
|
@@ -4,7 +4,6 @@ import kotlin.js.JsExport
|
||||
|
||||
private val schemaRegex = Regex("^[^:]*://")
|
||||
|
||||
@JsExport
|
||||
val String.asCorrectWebSocketUrl: String
|
||||
get() = if (startsWith("ws")) {
|
||||
this
|
||||
|
@@ -5,14 +5,12 @@ import kotlin.js.JsExport
|
||||
|
||||
typealias FromToDateTime = Pair<DateTime?, DateTime?>
|
||||
|
||||
@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) },
|
||||
|
@@ -1,15 +1,14 @@
|
||||
package dev.inmo.micro_utils.ktor.common
|
||||
|
||||
import kotlin.js.JsExport
|
||||
import kotlin.js.JsName
|
||||
|
||||
typealias QueryParam = Pair<String, String?>
|
||||
typealias QueryParams = Map<String, String?>
|
||||
|
||||
@JsExport
|
||||
val QueryParams.asUrlQuery: String
|
||||
get() = keys.joinToString("&") { "${it}${get(it) ?.let { value -> "=$value" }}" }
|
||||
|
||||
@JsExport
|
||||
val List<QueryParam>.asUrlQuery: String
|
||||
get() = joinToString("&") { (key, value) -> "${key}${value ?.let { _ -> "=$value" }}" }
|
||||
|
||||
@@ -19,11 +18,11 @@ fun String.includeQueryParams(
|
||||
): String = "$this${if(queryParams.isNotEmpty()) "${if (contains("?")) "&" else "?"}${queryParams.asUrlQuery}" else ""}"
|
||||
|
||||
@JsExport
|
||||
@JsName("includeQueryParamsWithList")
|
||||
fun String.includeQueryParams(
|
||||
queryParams: List<QueryParam>
|
||||
): String = "$this${if (contains("?")) "&" else "?"}${queryParams.asUrlQuery}"
|
||||
|
||||
@JsExport
|
||||
val String.parseUrlQuery: QueryParams
|
||||
get() = split("&").map {
|
||||
it.split("=").let { pair ->
|
||||
|
Reference in New Issue
Block a user