Revert "less annotations to god of lessannotations"

This reverts commit 87230d010c.
This commit is contained in:
2020-10-16 19:39:55 +06:00
parent 9cac05f98b
commit 893fd1ac07
32 changed files with 52 additions and 25 deletions

View File

@@ -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 <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 },

View File

@@ -9,6 +9,7 @@ import kotlin.js.JsExport
typealias BodyPair<T> = Pair<SerializationStrategy<T>, T>
@JsExport
suspend fun <ResultType> HttpClient.uniget(
url: String,
resultDeserializer: DeserializationStrategy<ResultType>
@@ -25,6 +26,7 @@ fun <T> SerializationStrategy<T>.encodeUrlQueryValue(value: T) = standardKtorSer
value
)
@JsExport
suspend fun <BodyType, ResultType> HttpClient.unipost(
url: String,
bodyInfo: BodyPair<BodyType>,

View File

@@ -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,

View File

@@ -4,6 +4,7 @@ import kotlin.js.JsExport
private val schemaRegex = Regex("^[^:]*://")
@JsExport
val String.asCorrectWebSocketUrl: String
get() = if (startsWith("ws")) {
this

View File

@@ -5,12 +5,14 @@ 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) },

View File

@@ -1,14 +1,15 @@
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" }}" }
@@ -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<QueryParam>
): String = "$this${if (contains("?")) "&" else "?"}${queryParams.asUrlQuery}"
@JsExport
val String.parseUrlQuery: QueryParams
get() = split("&").map {
it.split("=").let { pair ->