mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-11-25 19:48:45 +00:00
Revert "more annotations to god of annotations"
This reverts commit f8a8808508
.
This commit is contained in:
parent
893fd1ac07
commit
90c1731bd1
@ -12,4 +12,4 @@ function assert_success() {
|
|||||||
export RELEASE_MODE=true
|
export RELEASE_MODE=true
|
||||||
project="$1"
|
project="$1"
|
||||||
|
|
||||||
assert_success ./gradlew $project:build $project:bintrayUpload
|
assert_success ./gradlew clean "$project:clean" "$project:build" "$project:publishToMavenLocal" "$project:bintrayUpload"
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
package dev.inmo.micro_utils.common
|
package dev.inmo.micro_utils.common
|
||||||
|
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
@JsExport
|
|
||||||
fun <T> Iterable<T>.syncWith(
|
fun <T> Iterable<T>.syncWith(
|
||||||
other: Iterable<T>,
|
other: Iterable<T>,
|
||||||
removed: (List<T>) -> Unit = {},
|
removed: (List<T>) -> Unit = {},
|
||||||
|
@ -5,15 +5,12 @@ import kotlinx.serialization.builtins.ByteArraySerializer
|
|||||||
import kotlinx.serialization.descriptors.SerialDescriptor
|
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||||
import kotlinx.serialization.encoding.Decoder
|
import kotlinx.serialization.encoding.Decoder
|
||||||
import kotlinx.serialization.encoding.Encoder
|
import kotlinx.serialization.encoding.Encoder
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
typealias ByteArrayAllocator = () -> ByteArray
|
typealias ByteArrayAllocator = () -> ByteArray
|
||||||
|
|
||||||
@JsExport
|
|
||||||
val ByteArray.asAllocator: ByteArrayAllocator
|
val ByteArray.asAllocator: ByteArrayAllocator
|
||||||
get() = { this }
|
get() = { this }
|
||||||
|
|
||||||
@JsExport
|
|
||||||
object ByteArrayAllocatorSerializer : KSerializer<ByteArrayAllocator> {
|
object ByteArrayAllocatorSerializer : KSerializer<ByteArrayAllocator> {
|
||||||
private val realSerializer = ByteArraySerializer()
|
private val realSerializer = ByteArraySerializer()
|
||||||
override val descriptor: SerialDescriptor = realSerializer.descriptor
|
override val descriptor: SerialDescriptor = realSerializer.descriptor
|
||||||
|
@ -3,9 +3,7 @@ package dev.inmo.micro_utils.coroutines
|
|||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.channels.Channel
|
import kotlinx.coroutines.channels.Channel
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
@JsExport
|
|
||||||
fun <T> CoroutineScope.actor(
|
fun <T> CoroutineScope.actor(
|
||||||
channelCapacity: Int = Channel.UNLIMITED,
|
channelCapacity: Int = Channel.UNLIMITED,
|
||||||
block: suspend (T) -> Unit
|
block: suspend (T) -> Unit
|
||||||
|
@ -2,9 +2,7 @@ package dev.inmo.micro_utils.coroutines
|
|||||||
|
|
||||||
import kotlinx.coroutines.channels.*
|
import kotlinx.coroutines.channels.*
|
||||||
import kotlinx.coroutines.flow.*
|
import kotlinx.coroutines.flow.*
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
@JsExport
|
|
||||||
@Suppress("FunctionName")
|
@Suppress("FunctionName")
|
||||||
fun <T> BroadcastFlow(
|
fun <T> BroadcastFlow(
|
||||||
internalChannelSize: Int = Channel.BUFFERED
|
internalChannelSize: Int = Channel.BUFFERED
|
||||||
@ -17,7 +15,6 @@ fun <T> BroadcastFlow(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsExport
|
|
||||||
class BroadcastFlow<T> internal constructor(
|
class BroadcastFlow<T> internal constructor(
|
||||||
private val channel: BroadcastChannel<T>,
|
private val channel: BroadcastChannel<T>,
|
||||||
private val flow: Flow<T>
|
private val flow: Flow<T>
|
||||||
|
@ -4,9 +4,7 @@ import kotlinx.coroutines.CoroutineScope
|
|||||||
import kotlinx.coroutines.channels.BroadcastChannel
|
import kotlinx.coroutines.channels.BroadcastChannel
|
||||||
import kotlinx.coroutines.channels.Channel
|
import kotlinx.coroutines.channels.Channel
|
||||||
import kotlinx.coroutines.flow.*
|
import kotlinx.coroutines.flow.*
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
@JsExport
|
|
||||||
class BroadcastStateFlow<T> internal constructor(
|
class BroadcastStateFlow<T> internal constructor(
|
||||||
parentFlow: Flow<T>,
|
parentFlow: Flow<T>,
|
||||||
private val stateGetter: () -> T
|
private val stateGetter: () -> T
|
||||||
@ -15,7 +13,6 @@ class BroadcastStateFlow<T> internal constructor(
|
|||||||
get() = stateGetter()
|
get() = stateGetter()
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsExport
|
|
||||||
fun <T> BroadcastChannel<T>.asStateFlow(value: T, scope: CoroutineScope): StateFlow<T> = asFlow().let {
|
fun <T> BroadcastChannel<T>.asStateFlow(value: T, scope: CoroutineScope): StateFlow<T> = asFlow().let {
|
||||||
var state: T = value
|
var state: T = value
|
||||||
it.onEach { state = it }.launchIn(scope)
|
it.onEach { state = it }.launchIn(scope)
|
||||||
@ -24,16 +21,13 @@ fun <T> BroadcastChannel<T>.asStateFlow(value: T, scope: CoroutineScope): StateF
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsExport
|
|
||||||
fun <T> BroadcastChannel<T?>.asStateFlow(scope: CoroutineScope): StateFlow<T?> = asStateFlow(null, scope)
|
fun <T> BroadcastChannel<T?>.asStateFlow(scope: CoroutineScope): StateFlow<T?> = asStateFlow(null, scope)
|
||||||
|
|
||||||
@JsExport
|
|
||||||
fun <T> broadcastStateFlow(initial: T, scope: CoroutineScope, channelSize: Int = Channel.BUFFERED) = BroadcastChannel<T>(
|
fun <T> broadcastStateFlow(initial: T, scope: CoroutineScope, channelSize: Int = Channel.BUFFERED) = BroadcastChannel<T>(
|
||||||
channelSize
|
channelSize
|
||||||
).let {
|
).let {
|
||||||
it to it.asStateFlow(initial, scope)
|
it to it.asStateFlow(initial, scope)
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsExport
|
|
||||||
fun <T> broadcastStateFlow(scope: CoroutineScope, channelSize: Int = Channel.BUFFERED) = broadcastStateFlow<T?>(null, scope, channelSize)
|
fun <T> broadcastStateFlow(scope: CoroutineScope, channelSize: Int = Channel.BUFFERED) = broadcastStateFlow<T?>(null, scope, channelSize)
|
||||||
|
|
||||||
|
@ -2,8 +2,6 @@ package dev.inmo.micro_utils.coroutines
|
|||||||
|
|
||||||
import kotlinx.coroutines.CompletableDeferred
|
import kotlinx.coroutines.CompletableDeferred
|
||||||
import kotlinx.coroutines.Deferred
|
import kotlinx.coroutines.Deferred
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
@JsExport
|
|
||||||
val <T> T.asDeferred: Deferred<T>
|
val <T> T.asDeferred: Deferred<T>
|
||||||
get() = CompletableDeferred(this)
|
get() = CompletableDeferred(this)
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
package dev.inmo.micro_utils.coroutines
|
package dev.inmo.micro_utils.coroutines
|
||||||
|
|
||||||
import kotlin.coroutines.*
|
import kotlin.coroutines.*
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call this method in case you need to do something in common thread (like reading of file in JVM)
|
* Call this method in case you need to do something in common thread (like reading of file in JVM)
|
||||||
*/
|
*/
|
||||||
@JsExport
|
|
||||||
suspend fun <T> doOutsideOfCoroutine(block: () -> T): T = suspendCoroutine {
|
suspend fun <T> doOutsideOfCoroutine(block: () -> T): T = suspendCoroutine {
|
||||||
try {
|
try {
|
||||||
it.resume(block())
|
it.resume(block())
|
||||||
|
@ -2,7 +2,6 @@ package dev.inmo.micro_utils.coroutines
|
|||||||
|
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.supervisorScope
|
import kotlinx.coroutines.supervisorScope
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
|
|
||||||
typealias ExceptionHandler<T> = suspend (Throwable) -> T
|
typealias ExceptionHandler<T> = suspend (Throwable) -> T
|
||||||
@ -12,7 +11,6 @@ typealias ExceptionHandler<T> = suspend (Throwable) -> T
|
|||||||
* @param [onException] Will be called when happen exception inside of [block]. By default will throw exception - this
|
* @param [onException] Will be called when happen exception inside of [block]. By default will throw exception - this
|
||||||
* exception will be available for catching
|
* exception will be available for catching
|
||||||
*/
|
*/
|
||||||
@JsExport
|
|
||||||
suspend inline fun <T> safely(
|
suspend inline fun <T> safely(
|
||||||
noinline onException: ExceptionHandler<T> = { throw it },
|
noinline onException: ExceptionHandler<T> = { throw it },
|
||||||
noinline block: suspend CoroutineScope.() -> T
|
noinline block: suspend CoroutineScope.() -> T
|
||||||
|
@ -8,13 +8,11 @@ import io.ktor.http.cio.websocket.*
|
|||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.channelFlow
|
import kotlinx.coroutines.flow.channelFlow
|
||||||
import kotlinx.serialization.DeserializationStrategy
|
import kotlinx.serialization.DeserializationStrategy
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param checkReconnection This lambda will be called when it is required to reconnect to websocket to establish
|
* @param checkReconnection This lambda will be called when it is required to reconnect to websocket to establish
|
||||||
* connection. Must return true in case if must be reconnected. By default always reconnecting
|
* connection. Must return true in case if must be reconnected. By default always reconnecting
|
||||||
*/
|
*/
|
||||||
@JsExport
|
|
||||||
inline fun <T> HttpClient.createStandardWebsocketFlow(
|
inline fun <T> HttpClient.createStandardWebsocketFlow(
|
||||||
url: String,
|
url: String,
|
||||||
crossinline checkReconnection: (Throwable?) -> Boolean = { true },
|
crossinline checkReconnection: (Throwable?) -> Boolean = { true },
|
||||||
@ -62,7 +60,6 @@ inline fun <T> HttpClient.createStandardWebsocketFlow(
|
|||||||
* @param checkReconnection This lambda will be called when it is required to reconnect to websocket to establish
|
* @param checkReconnection This lambda will be called when it is required to reconnect to websocket to establish
|
||||||
* connection. Must return true in case if must be reconnected. By default always reconnecting
|
* connection. Must return true in case if must be reconnected. By default always reconnecting
|
||||||
*/
|
*/
|
||||||
@JsExport
|
|
||||||
inline fun <T> HttpClient.createStandardWebsocketFlow(
|
inline fun <T> HttpClient.createStandardWebsocketFlow(
|
||||||
url: String,
|
url: String,
|
||||||
crossinline checkReconnection: (Throwable?) -> Boolean = { true },
|
crossinline checkReconnection: (Throwable?) -> Boolean = { true },
|
||||||
|
@ -5,11 +5,9 @@ import io.ktor.client.HttpClient
|
|||||||
import io.ktor.client.request.get
|
import io.ktor.client.request.get
|
||||||
import io.ktor.client.request.post
|
import io.ktor.client.request.post
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
typealias BodyPair<T> = Pair<SerializationStrategy<T>, T>
|
typealias BodyPair<T> = Pair<SerializationStrategy<T>, T>
|
||||||
|
|
||||||
@JsExport
|
|
||||||
suspend fun <ResultType> HttpClient.uniget(
|
suspend fun <ResultType> HttpClient.uniget(
|
||||||
url: String,
|
url: String,
|
||||||
resultDeserializer: DeserializationStrategy<ResultType>
|
resultDeserializer: DeserializationStrategy<ResultType>
|
||||||
@ -20,13 +18,11 @@ suspend fun <ResultType> HttpClient.uniget(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@JsExport
|
|
||||||
fun <T> SerializationStrategy<T>.encodeUrlQueryValue(value: T) = standardKtorSerialFormat.encodeHex(
|
fun <T> SerializationStrategy<T>.encodeUrlQueryValue(value: T) = standardKtorSerialFormat.encodeHex(
|
||||||
this,
|
this,
|
||||||
value
|
value
|
||||||
)
|
)
|
||||||
|
|
||||||
@JsExport
|
|
||||||
suspend fun <BodyType, ResultType> HttpClient.unipost(
|
suspend fun <BodyType, ResultType> HttpClient.unipost(
|
||||||
url: String,
|
url: String,
|
||||||
bodyInfo: BodyPair<BodyType>,
|
bodyInfo: BodyPair<BodyType>,
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
package dev.inmo.micro_utils.ktor.common
|
package dev.inmo.micro_utils.ktor.common
|
||||||
|
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
@JsExport
|
|
||||||
fun buildStandardUrl(
|
fun buildStandardUrl(
|
||||||
basePart: String,
|
basePart: String,
|
||||||
subpart: String,
|
subpart: String,
|
||||||
@ -11,7 +8,6 @@ fun buildStandardUrl(
|
|||||||
parameters
|
parameters
|
||||||
)
|
)
|
||||||
|
|
||||||
@JsExport
|
|
||||||
fun buildStandardUrl(
|
fun buildStandardUrl(
|
||||||
basePart: String,
|
basePart: String,
|
||||||
subpart: String,
|
subpart: String,
|
||||||
@ -20,7 +16,6 @@ fun buildStandardUrl(
|
|||||||
parameters
|
parameters
|
||||||
)
|
)
|
||||||
|
|
||||||
@JsExport
|
|
||||||
fun buildStandardUrl(
|
fun buildStandardUrl(
|
||||||
basePart: String,
|
basePart: String,
|
||||||
subpart: String,
|
subpart: String,
|
||||||
|
@ -1,7 +1,3 @@
|
|||||||
package dev.inmo.micro_utils.ktor.common
|
package dev.inmo.micro_utils.ktor.common
|
||||||
|
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
@JsExport
|
|
||||||
@Deprecated("Will be removed in next major release as useless")
|
|
||||||
object CorrectCloseException : Exception()
|
object CorrectCloseException : Exception()
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
package dev.inmo.micro_utils.ktor.common
|
package dev.inmo.micro_utils.ktor.common
|
||||||
|
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
private val schemaRegex = Regex("^[^:]*://")
|
private val schemaRegex = Regex("^[^:]*://")
|
||||||
|
|
||||||
@JsExport
|
|
||||||
val String.asCorrectWebSocketUrl: String
|
val String.asCorrectWebSocketUrl: String
|
||||||
get() = if (startsWith("ws")) {
|
get() = if (startsWith("ws")) {
|
||||||
this
|
this
|
||||||
|
@ -1,18 +1,15 @@
|
|||||||
package dev.inmo.micro_utils.ktor.common
|
package dev.inmo.micro_utils.ktor.common
|
||||||
|
|
||||||
import com.soywiz.klock.DateTime
|
import com.soywiz.klock.DateTime
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
typealias FromToDateTime = Pair<DateTime?, DateTime?>
|
typealias FromToDateTime = Pair<DateTime?, DateTime?>
|
||||||
|
|
||||||
@JsExport
|
|
||||||
val FromToDateTime.asFromToUrlPart: QueryParams
|
val FromToDateTime.asFromToUrlPart: QueryParams
|
||||||
get() = mapOf(
|
get() = mapOf(
|
||||||
"from" to first ?.unixMillis ?.toString(),
|
"from" to first ?.unixMillis ?.toString(),
|
||||||
"to" to second ?.unixMillis ?.toString()
|
"to" to second ?.unixMillis ?.toString()
|
||||||
)
|
)
|
||||||
|
|
||||||
@JsExport
|
|
||||||
val QueryParams.extractFromToDateTime: FromToDateTime
|
val QueryParams.extractFromToDateTime: FromToDateTime
|
||||||
get() = FromToDateTime(
|
get() = FromToDateTime(
|
||||||
get("from") ?.toDoubleOrNull() ?.let { DateTime(it) },
|
get("from") ?.toDoubleOrNull() ?.let { DateTime(it) },
|
||||||
|
@ -1,29 +1,22 @@
|
|||||||
package dev.inmo.micro_utils.ktor.common
|
package dev.inmo.micro_utils.ktor.common
|
||||||
|
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
typealias QueryParam = Pair<String, String?>
|
typealias QueryParam = Pair<String, String?>
|
||||||
typealias QueryParams = Map<String, String?>
|
typealias QueryParams = Map<String, String?>
|
||||||
|
|
||||||
@JsExport
|
|
||||||
val QueryParams.asUrlQuery: String
|
val QueryParams.asUrlQuery: String
|
||||||
get() = keys.joinToString("&") { "${it}${get(it) ?.let { value -> "=$value" }}" }
|
get() = keys.joinToString("&") { "${it}${get(it) ?.let { value -> "=$value" }}" }
|
||||||
|
|
||||||
@JsExport
|
|
||||||
val List<QueryParam>.asUrlQuery: String
|
val List<QueryParam>.asUrlQuery: String
|
||||||
get() = joinToString("&") { (key, value) -> "${key}${value ?.let { _ -> "=$value" }}" }
|
get() = joinToString("&") { (key, value) -> "${key}${value ?.let { _ -> "=$value" }}" }
|
||||||
|
|
||||||
@JsExport
|
|
||||||
fun String.includeQueryParams(
|
fun String.includeQueryParams(
|
||||||
queryParams: QueryParams
|
queryParams: QueryParams
|
||||||
): String = "$this${if(queryParams.isNotEmpty()) "${if (contains("?")) "&" else "?"}${queryParams.asUrlQuery}" else ""}"
|
): String = "$this${if(queryParams.isNotEmpty()) "${if (contains("?")) "&" else "?"}${queryParams.asUrlQuery}" else ""}"
|
||||||
|
|
||||||
@JsExport
|
|
||||||
fun String.includeQueryParams(
|
fun String.includeQueryParams(
|
||||||
queryParams: List<QueryParam>
|
queryParams: List<QueryParam>
|
||||||
): String = "$this${if (contains("?")) "&" else "?"}${queryParams.asUrlQuery}"
|
): String = "$this${if (contains("?")) "&" else "?"}${queryParams.asUrlQuery}"
|
||||||
|
|
||||||
@JsExport
|
|
||||||
val String.parseUrlQuery: QueryParams
|
val String.parseUrlQuery: QueryParams
|
||||||
get() = split("&").map {
|
get() = split("&").map {
|
||||||
it.split("=").let { pair ->
|
it.split("=").let { pair ->
|
||||||
|
@ -2,36 +2,28 @@ package dev.inmo.micro_utils.ktor.common
|
|||||||
|
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.cbor.Cbor
|
import kotlinx.serialization.cbor.Cbor
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
typealias StandardKtorSerialFormat = BinaryFormat
|
typealias StandardKtorSerialFormat = BinaryFormat
|
||||||
typealias StandardKtorSerialInputData = ByteArray
|
typealias StandardKtorSerialInputData = ByteArray
|
||||||
@JsExport
|
|
||||||
val standardKtorSerialFormat: StandardKtorSerialFormat = Cbor { }
|
val standardKtorSerialFormat: StandardKtorSerialFormat = Cbor { }
|
||||||
|
|
||||||
@JsExport
|
|
||||||
inline fun <T> StandardKtorSerialFormat.decodeDefault(
|
inline fun <T> StandardKtorSerialFormat.decodeDefault(
|
||||||
deserializationStrategy: DeserializationStrategy<T>,
|
deserializationStrategy: DeserializationStrategy<T>,
|
||||||
input: StandardKtorSerialInputData
|
input: StandardKtorSerialInputData
|
||||||
): T = decodeFromByteArray(deserializationStrategy, input)
|
): T = decodeFromByteArray(deserializationStrategy, input)
|
||||||
|
|
||||||
@JsExport
|
|
||||||
inline fun <T> StandardKtorSerialFormat.encodeDefault(
|
inline fun <T> StandardKtorSerialFormat.encodeDefault(
|
||||||
serializationStrategy: SerializationStrategy<T>,
|
serializationStrategy: SerializationStrategy<T>,
|
||||||
data: T
|
data: T
|
||||||
): StandardKtorSerialInputData = encodeToByteArray(serializationStrategy, data)
|
): StandardKtorSerialInputData = encodeToByteArray(serializationStrategy, data)
|
||||||
|
|
||||||
@JsExport
|
|
||||||
@Deprecated("Will be removed in next major release due to useless")
|
|
||||||
val cbor = Cbor {}
|
val cbor = Cbor {}
|
||||||
|
|
||||||
@JsExport
|
|
||||||
inline fun <T> StandardKtorSerialFormat.decodeHex(
|
inline fun <T> StandardKtorSerialFormat.decodeHex(
|
||||||
deserializationStrategy: DeserializationStrategy<T>,
|
deserializationStrategy: DeserializationStrategy<T>,
|
||||||
input: String
|
input: String
|
||||||
): T = decodeFromHexString(deserializationStrategy, input)
|
): T = decodeFromHexString(deserializationStrategy, input)
|
||||||
|
|
||||||
@JsExport
|
|
||||||
inline fun <T> StandardKtorSerialFormat.encodeHex(
|
inline fun <T> StandardKtorSerialFormat.encodeHex(
|
||||||
serializationStrategy: SerializationStrategy<T>,
|
serializationStrategy: SerializationStrategy<T>,
|
||||||
data: T
|
data: T
|
||||||
|
@ -9,6 +9,13 @@ import kotlinx.coroutines.flow.Flow
|
|||||||
import kotlinx.coroutines.flow.collect
|
import kotlinx.coroutines.flow.collect
|
||||||
import kotlinx.serialization.SerializationStrategy
|
import kotlinx.serialization.SerializationStrategy
|
||||||
|
|
||||||
|
private suspend fun DefaultWebSocketSession.checkReceivedAndCloseIfExists() {
|
||||||
|
if (incoming.poll() != null) {
|
||||||
|
close()
|
||||||
|
throw CorrectCloseException
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun <T> Route.includeWebsocketHandling(
|
fun <T> Route.includeWebsocketHandling(
|
||||||
suburl: String,
|
suburl: String,
|
||||||
flow: Flow<T>,
|
flow: Flow<T>,
|
||||||
|
@ -1,17 +1,13 @@
|
|||||||
package dev.inmo.micro_utils.mime_types
|
package dev.inmo.micro_utils.mime_types
|
||||||
|
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
@JsExport
|
|
||||||
@Serializable(MimeTypeSerializer::class)
|
@Serializable(MimeTypeSerializer::class)
|
||||||
interface MimeType {
|
interface MimeType {
|
||||||
val raw: String
|
val raw: String
|
||||||
}
|
}
|
||||||
@JsExport
|
|
||||||
data class CustomMimeType(override val raw: String) : MimeType
|
data class CustomMimeType(override val raw: String) : MimeType
|
||||||
|
|
||||||
@JsExport
|
|
||||||
@Serializable(MimeTypeSerializer::class)
|
@Serializable(MimeTypeSerializer::class)
|
||||||
sealed class KnownMimeTypes(override val raw: String) : MimeType {
|
sealed class KnownMimeTypes(override val raw: String) : MimeType {
|
||||||
object Any : MimeType, KnownMimeTypes("*/*")
|
object Any : MimeType, KnownMimeTypes("*/*")
|
||||||
@ -2148,12 +2144,10 @@ internal val knownMimeTypes: Set<MimeType> = setOf(
|
|||||||
KnownMimeTypes.XConference.XCooltalk,
|
KnownMimeTypes.XConference.XCooltalk,
|
||||||
)
|
)
|
||||||
|
|
||||||
@JsExport
|
|
||||||
val knownMimeTypesMap by lazy {
|
val knownMimeTypesMap by lazy {
|
||||||
knownMimeTypes.associateBy { it.raw }
|
knownMimeTypes.associateBy { it.raw }
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsExport
|
|
||||||
fun findBuiltinMimeType(from: String): MimeType? {
|
fun findBuiltinMimeType(from: String): MimeType? {
|
||||||
return knownMimeTypesMap[from]
|
return knownMimeTypesMap[from]
|
||||||
}
|
}
|
||||||
|
@ -5,22 +5,18 @@ import kotlinx.serialization.Serializer
|
|||||||
import kotlinx.serialization.descriptors.*
|
import kotlinx.serialization.descriptors.*
|
||||||
import kotlinx.serialization.encoding.Decoder
|
import kotlinx.serialization.encoding.Decoder
|
||||||
import kotlinx.serialization.encoding.Encoder
|
import kotlinx.serialization.encoding.Encoder
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
private val mimesCache = mutableMapOf<String, MimeType>().also {
|
private val mimesCache = mutableMapOf<String, MimeType>().also {
|
||||||
knownMimeTypes.forEach { mimeType -> it[mimeType.raw] = mimeType }
|
knownMimeTypes.forEach { mimeType -> it[mimeType.raw] = mimeType }
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsExport
|
|
||||||
fun mimeType(raw: String) = mimesCache.getOrPut(raw) {
|
fun mimeType(raw: String) = mimesCache.getOrPut(raw) {
|
||||||
parseMimeType(raw)
|
parseMimeType(raw)
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsExport
|
|
||||||
internal fun parseMimeType(raw: String): MimeType = CustomMimeType(raw)
|
internal fun parseMimeType(raw: String): MimeType = CustomMimeType(raw)
|
||||||
|
|
||||||
@Serializer(MimeType::class)
|
@Serializer(MimeType::class)
|
||||||
@JsExport
|
|
||||||
object MimeTypeSerializer : KSerializer<MimeType> {
|
object MimeTypeSerializer : KSerializer<MimeType> {
|
||||||
override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("mimeType", PrimitiveKind.STRING)
|
override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("mimeType", PrimitiveKind.STRING)
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package dev.inmo.micro_utils.pagination
|
package dev.inmo.micro_utils.pagination
|
||||||
|
|
||||||
import kotlin.js.JsExport
|
|
||||||
import kotlin.math.ceil
|
import kotlin.math.ceil
|
||||||
import kotlin.math.floor
|
import kotlin.math.floor
|
||||||
|
|
||||||
@ -10,7 +9,6 @@ import kotlin.math.floor
|
|||||||
* If you want to request something, you should use [SimplePagination]. If you need to return some result including
|
* If you want to request something, you should use [SimplePagination]. If you need to return some result including
|
||||||
* pagination - [PaginationResult]
|
* pagination - [PaginationResult]
|
||||||
*/
|
*/
|
||||||
@JsExport
|
|
||||||
interface Pagination {
|
interface Pagination {
|
||||||
/**
|
/**
|
||||||
* Started with 0.
|
* Started with 0.
|
||||||
@ -27,7 +25,6 @@ interface Pagination {
|
|||||||
/**
|
/**
|
||||||
* First number in index of objects. It can be used as offset for databases or other data sources
|
* First number in index of objects. It can be used as offset for databases or other data sources
|
||||||
*/
|
*/
|
||||||
@JsExport
|
|
||||||
val Pagination.firstIndex: Int
|
val Pagination.firstIndex: Int
|
||||||
get() = page * size
|
get() = page * size
|
||||||
|
|
||||||
@ -37,21 +34,18 @@ val Pagination.firstIndex: Int
|
|||||||
* [[firstIndex], [lastIndex]]; That means, that for [Pagination] with [Pagination.size] == 10 and [Pagination.page] == 1
|
* [[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.
|
* you will retrieve [Pagination.firstIndex] == 10 and [Pagination.lastIndex] == 19.
|
||||||
*/
|
*/
|
||||||
@JsExport
|
|
||||||
val Pagination.lastIndex: Int
|
val Pagination.lastIndex: Int
|
||||||
get() = firstIndex + size - 1
|
get() = firstIndex + size - 1
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates pages count for given [datasetSize]
|
* Calculates pages count for given [datasetSize]
|
||||||
*/
|
*/
|
||||||
@JsExport
|
|
||||||
fun calculatePagesNumber(datasetSize: Long, pageSize: Int): Int {
|
fun calculatePagesNumber(datasetSize: Long, pageSize: Int): Int {
|
||||||
return ceil(datasetSize.toDouble() / pageSize).toInt()
|
return ceil(datasetSize.toDouble() / pageSize).toInt()
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Calculates pages count for given [datasetSize]
|
* Calculates pages count for given [datasetSize]
|
||||||
*/
|
*/
|
||||||
@JsExport
|
|
||||||
fun calculatePagesNumber(datasetSize: Int, pageSize: Int): Int =
|
fun calculatePagesNumber(datasetSize: Int, pageSize: Int): Int =
|
||||||
calculatePagesNumber(
|
calculatePagesNumber(
|
||||||
datasetSize.toLong(),
|
datasetSize.toLong(),
|
||||||
@ -61,7 +55,6 @@ fun calculatePagesNumber(datasetSize: Int, pageSize: Int): Int =
|
|||||||
/**
|
/**
|
||||||
* @return calculated page number which can be correctly used in [PaginationResult] as [PaginationResult.page] value
|
* @return calculated page number which can be correctly used in [PaginationResult] as [PaginationResult.page] value
|
||||||
*/
|
*/
|
||||||
@JsExport
|
|
||||||
fun calculatePage(firstIndex: Int, resultsSize: Int): Int = if (resultsSize > 0) {
|
fun calculatePage(firstIndex: Int, resultsSize: Int): Int = if (resultsSize > 0) {
|
||||||
floor(firstIndex.toFloat() / resultsSize).toInt()
|
floor(firstIndex.toFloat() / resultsSize).toInt()
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
package dev.inmo.micro_utils.pagination
|
package dev.inmo.micro_utils.pagination
|
||||||
|
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
@JsExport
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class PaginationResult<T>(
|
data class PaginationResult<T>(
|
||||||
override val page: Int,
|
override val page: Int,
|
||||||
@ -12,10 +10,8 @@ data class PaginationResult<T>(
|
|||||||
override val size: Int
|
override val size: Int
|
||||||
) : Pagination
|
) : Pagination
|
||||||
|
|
||||||
@JsExport
|
|
||||||
fun <T> emptyPaginationResult() = PaginationResult<T>(0, 0, emptyList(), 0)
|
fun <T> emptyPaginationResult() = PaginationResult<T>(0, 0, emptyList(), 0)
|
||||||
|
|
||||||
@JsExport
|
|
||||||
fun <T> List<T>.createPaginationResult(
|
fun <T> List<T>.createPaginationResult(
|
||||||
pagination: Pagination,
|
pagination: Pagination,
|
||||||
commonObjectsNumber: Long
|
commonObjectsNumber: Long
|
||||||
@ -29,7 +25,6 @@ fun <T> List<T>.createPaginationResult(
|
|||||||
pagination.size
|
pagination.size
|
||||||
)
|
)
|
||||||
|
|
||||||
@JsExport
|
|
||||||
fun <T> List<T>.createPaginationResult(
|
fun <T> List<T>.createPaginationResult(
|
||||||
firstIndex: Int,
|
firstIndex: Int,
|
||||||
commonObjectsNumber: Long
|
commonObjectsNumber: Long
|
||||||
@ -43,7 +38,6 @@ fun <T> List<T>.createPaginationResult(
|
|||||||
size
|
size
|
||||||
)
|
)
|
||||||
|
|
||||||
@JsExport
|
|
||||||
fun <T> Pair<Long, List<T>>.createPaginationResult(
|
fun <T> Pair<Long, List<T>>.createPaginationResult(
|
||||||
pagination: Pagination
|
pagination: Pagination
|
||||||
) = second.createPaginationResult(pagination, first)
|
) = second.createPaginationResult(pagination, first)
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
package dev.inmo.micro_utils.pagination
|
package dev.inmo.micro_utils.pagination
|
||||||
|
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
const val defaultSmallPageSize = 2
|
const val defaultSmallPageSize = 2
|
||||||
const val defaultMediumPageSize = 5
|
const val defaultMediumPageSize = 5
|
||||||
const val defaultLargePageSize = 10
|
const val defaultLargePageSize = 10
|
||||||
const val defaultExtraLargePageSize = 15
|
const val defaultExtraLargePageSize = 15
|
||||||
|
|
||||||
@JsExport
|
|
||||||
@Suppress("NOTHING_TO_INLINE", "FunctionName")
|
@Suppress("NOTHING_TO_INLINE", "FunctionName")
|
||||||
inline fun FirstPagePagination(size: Int = defaultMediumPageSize) =
|
inline fun FirstPagePagination(size: Int = defaultMediumPageSize) =
|
||||||
SimplePagination(
|
SimplePagination(
|
||||||
@ -16,7 +14,6 @@ inline fun FirstPagePagination(size: Int = defaultMediumPageSize) =
|
|||||||
size = size
|
size = size
|
||||||
)
|
)
|
||||||
|
|
||||||
@JsExport
|
|
||||||
@Suppress("NOTHING_TO_INLINE")
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
inline fun Pagination.nextPage() =
|
inline fun Pagination.nextPage() =
|
||||||
SimplePagination(
|
SimplePagination(
|
||||||
@ -24,14 +21,12 @@ inline fun Pagination.nextPage() =
|
|||||||
size
|
size
|
||||||
)
|
)
|
||||||
|
|
||||||
@JsExport
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class SimplePagination(
|
data class SimplePagination(
|
||||||
override val page: Int,
|
override val page: Int,
|
||||||
override val size: Int
|
override val size: Int
|
||||||
) : Pagination
|
) : Pagination
|
||||||
|
|
||||||
@JsExport
|
|
||||||
fun Pagination(
|
fun Pagination(
|
||||||
page: Int,
|
page: Int,
|
||||||
size: Int
|
size: Int
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
package dev.inmo.micro_utils.pagination
|
package dev.inmo.micro_utils.pagination
|
||||||
|
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
@JsExport
|
|
||||||
inline fun doWithPagination(
|
inline fun doWithPagination(
|
||||||
startPagination: Pagination = FirstPagePagination(),
|
startPagination: Pagination = FirstPagePagination(),
|
||||||
requestMaker: (pagination: Pagination) -> Pagination?
|
requestMaker: (pagination: Pagination) -> Pagination?
|
||||||
@ -13,7 +10,6 @@ inline fun doWithPagination(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsExport
|
|
||||||
@Suppress("NOTHING_TO_INLINE")
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
inline fun PaginationResult<*>.nextPageIfNotEmpty() = if (results.isNotEmpty()) {
|
inline fun PaginationResult<*>.nextPageIfNotEmpty() = if (results.isNotEmpty()) {
|
||||||
SimplePagination(
|
SimplePagination(
|
||||||
@ -24,7 +20,6 @@ inline fun PaginationResult<*>.nextPageIfNotEmpty() = if (results.isNotEmpty())
|
|||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsExport
|
|
||||||
@Suppress("NOTHING_TO_INLINE")
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
inline fun PaginationResult<*>.thisPageIfNotEmpty(): Pagination? = if (results.isNotEmpty()) {
|
inline fun PaginationResult<*>.thisPageIfNotEmpty(): Pagination? = if (results.isNotEmpty()) {
|
||||||
this
|
this
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
package dev.inmo.micro_utils.pagination.utils
|
package dev.inmo.micro_utils.pagination.utils
|
||||||
|
|
||||||
import dev.inmo.micro_utils.pagination.*
|
import dev.inmo.micro_utils.pagination.*
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
@JsExport
|
|
||||||
fun <T> Iterable<T>.paginate(with: Pagination): PaginationResult<T> {
|
fun <T> Iterable<T>.paginate(with: Pagination): PaginationResult<T> {
|
||||||
var i = 0
|
var i = 0
|
||||||
val result = mutableListOf<T>()
|
val result = mutableListOf<T>()
|
||||||
@ -22,7 +20,6 @@ fun <T> Iterable<T>.paginate(with: Pagination): PaginationResult<T> {
|
|||||||
return result.createPaginationResult(with, i.toLong())
|
return result.createPaginationResult(with, i.toLong())
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsExport
|
|
||||||
fun <T> List<T>.paginate(with: Pagination): PaginationResult<T> {
|
fun <T> List<T>.paginate(with: Pagination): PaginationResult<T> {
|
||||||
return subList(with.firstIndex, with.lastIndex + 1).createPaginationResult(
|
return subList(with.firstIndex, with.lastIndex + 1).createPaginationResult(
|
||||||
with,
|
with,
|
||||||
@ -30,7 +27,6 @@ fun <T> List<T>.paginate(with: Pagination): PaginationResult<T> {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsExport
|
|
||||||
fun <T> Set<T>.paginate(with: Pagination): PaginationResult<T> {
|
fun <T> Set<T>.paginate(with: Pagination): PaginationResult<T> {
|
||||||
return this.drop(with.firstIndex).take(with.size).createPaginationResult(
|
return this.drop(with.firstIndex).take(with.size).createPaginationResult(
|
||||||
with,
|
with,
|
||||||
|
@ -1,27 +1,20 @@
|
|||||||
package dev.inmo.micro_utils.pagination
|
package dev.inmo.micro_utils.pagination
|
||||||
|
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
@JsExport
|
|
||||||
const val paginationPageKey = "ppage"
|
const val paginationPageKey = "ppage"
|
||||||
@JsExport
|
|
||||||
const val paginationSizeKey = "psize"
|
const val paginationSizeKey = "psize"
|
||||||
|
|
||||||
@JsExport
|
|
||||||
val Pagination.asUrlQueryParts
|
val Pagination.asUrlQueryParts
|
||||||
get() = mapOf(
|
get() = mapOf(
|
||||||
paginationPageKey to page.toString(),
|
paginationPageKey to page.toString(),
|
||||||
paginationSizeKey to size.toString()
|
paginationSizeKey to size.toString()
|
||||||
)
|
)
|
||||||
|
|
||||||
@JsExport
|
|
||||||
val Pagination.asUrlQueryArrayParts
|
val Pagination.asUrlQueryArrayParts
|
||||||
get() = arrayOf(
|
get() = arrayOf(
|
||||||
paginationPageKey to page.toString(),
|
paginationPageKey to page.toString(),
|
||||||
paginationSizeKey to size.toString()
|
paginationSizeKey to size.toString()
|
||||||
)
|
)
|
||||||
|
|
||||||
@JsExport
|
|
||||||
val Map<String, String?>.extractPagination: Pagination
|
val Map<String, String?>.extractPagination: Pagination
|
||||||
get() = SimplePagination(
|
get() = SimplePagination(
|
||||||
get(paginationPageKey) ?.toIntOrNull() ?: 0,
|
get(paginationPageKey) ?.toIntOrNull() ?: 0,
|
||||||
|
@ -3,9 +3,7 @@ package dev.inmo.micro_utils.repos
|
|||||||
import dev.inmo.micro_utils.pagination.Pagination
|
import dev.inmo.micro_utils.pagination.Pagination
|
||||||
import dev.inmo.micro_utils.pagination.PaginationResult
|
import dev.inmo.micro_utils.pagination.PaginationResult
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
@JsExport
|
|
||||||
interface ReadOneToManyKeyValueRepo<Key, Value> : Repo {
|
interface ReadOneToManyKeyValueRepo<Key, Value> : Repo {
|
||||||
suspend fun get(k: Key, pagination: Pagination, reversed: Boolean = false): PaginationResult<Value>
|
suspend fun get(k: Key, pagination: Pagination, reversed: Boolean = false): PaginationResult<Value>
|
||||||
suspend fun keys(pagination: Pagination, reversed: Boolean = false): PaginationResult<Key>
|
suspend fun keys(pagination: Pagination, reversed: Boolean = false): PaginationResult<Key>
|
||||||
@ -17,7 +15,6 @@ interface ReadOneToManyKeyValueRepo<Key, Value> : Repo {
|
|||||||
@Deprecated("Renamed", ReplaceWith("ReadOneToManyKeyValueRepo", "dev.inmo.micro_utils.repos.ReadOneToManyKeyValueRepo"))
|
@Deprecated("Renamed", ReplaceWith("ReadOneToManyKeyValueRepo", "dev.inmo.micro_utils.repos.ReadOneToManyKeyValueRepo"))
|
||||||
typealias OneToManyReadKeyValueRepo<Key, Value> = ReadOneToManyKeyValueRepo<Key, Value>
|
typealias OneToManyReadKeyValueRepo<Key, Value> = ReadOneToManyKeyValueRepo<Key, Value>
|
||||||
|
|
||||||
@JsExport
|
|
||||||
interface WriteOneToManyKeyValueRepo<Key, Value> : Repo {
|
interface WriteOneToManyKeyValueRepo<Key, Value> : Repo {
|
||||||
val onNewValue: Flow<Pair<Key, Value>>
|
val onNewValue: Flow<Pair<Key, Value>>
|
||||||
val onValueRemoved: Flow<Pair<Key, Value>>
|
val onValueRemoved: Flow<Pair<Key, Value>>
|
||||||
@ -30,5 +27,4 @@ interface WriteOneToManyKeyValueRepo<Key, Value> : Repo {
|
|||||||
@Deprecated("Renamed", ReplaceWith("WriteOneToManyKeyValueRepo", "dev.inmo.micro_utils.repos.WriteOneToManyKeyValueRepo"))
|
@Deprecated("Renamed", ReplaceWith("WriteOneToManyKeyValueRepo", "dev.inmo.micro_utils.repos.WriteOneToManyKeyValueRepo"))
|
||||||
typealias OneToManyWriteKeyValueRepo<Key, Value> = WriteOneToManyKeyValueRepo<Key, Value>
|
typealias OneToManyWriteKeyValueRepo<Key, Value> = WriteOneToManyKeyValueRepo<Key, Value>
|
||||||
|
|
||||||
@JsExport
|
|
||||||
interface OneToManyKeyValueRepo<Key, Value> : ReadOneToManyKeyValueRepo<Key, Value>, WriteOneToManyKeyValueRepo<Key, Value>
|
interface OneToManyKeyValueRepo<Key, Value> : ReadOneToManyKeyValueRepo<Key, Value>, WriteOneToManyKeyValueRepo<Key, Value>
|
@ -1,6 +1,3 @@
|
|||||||
package dev.inmo.micro_utils.repos
|
package dev.inmo.micro_utils.repos
|
||||||
|
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
@JsExport
|
|
||||||
interface Repo
|
interface Repo
|
||||||
|
@ -3,9 +3,7 @@ package dev.inmo.micro_utils.repos
|
|||||||
import dev.inmo.micro_utils.pagination.Pagination
|
import dev.inmo.micro_utils.pagination.Pagination
|
||||||
import dev.inmo.micro_utils.pagination.PaginationResult
|
import dev.inmo.micro_utils.pagination.PaginationResult
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
@JsExport
|
|
||||||
interface ReadStandardCRUDRepo<ObjectType, IdType> : Repo {
|
interface ReadStandardCRUDRepo<ObjectType, IdType> : Repo {
|
||||||
suspend fun getByPagination(pagination: Pagination): PaginationResult<ObjectType>
|
suspend fun getByPagination(pagination: Pagination): PaginationResult<ObjectType>
|
||||||
suspend fun getById(id: IdType): ObjectType?
|
suspend fun getById(id: IdType): ObjectType?
|
||||||
@ -14,14 +12,11 @@ interface ReadStandardCRUDRepo<ObjectType, IdType> : Repo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
typealias UpdatedValuePair<IdType, ValueType> = Pair<IdType, ValueType>
|
typealias UpdatedValuePair<IdType, ValueType> = Pair<IdType, ValueType>
|
||||||
@JsExport
|
|
||||||
val <IdType> UpdatedValuePair<IdType, *>.id
|
val <IdType> UpdatedValuePair<IdType, *>.id
|
||||||
get() = first
|
get() = first
|
||||||
@JsExport
|
|
||||||
val <ValueType> UpdatedValuePair<*, ValueType>.value
|
val <ValueType> UpdatedValuePair<*, ValueType>.value
|
||||||
get() = second
|
get() = second
|
||||||
|
|
||||||
@JsExport
|
|
||||||
interface WriteStandardCRUDRepo<ObjectType, IdType, InputValueType> : Repo {
|
interface WriteStandardCRUDRepo<ObjectType, IdType, InputValueType> : Repo {
|
||||||
val newObjectsFlow: Flow<ObjectType>
|
val newObjectsFlow: Flow<ObjectType>
|
||||||
val updatedObjectsFlow: Flow<ObjectType>
|
val updatedObjectsFlow: Flow<ObjectType>
|
||||||
@ -33,19 +28,15 @@ interface WriteStandardCRUDRepo<ObjectType, IdType, InputValueType> : Repo {
|
|||||||
suspend fun deleteById(ids: List<IdType>)
|
suspend fun deleteById(ids: List<IdType>)
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsExport
|
|
||||||
suspend fun <ObjectType, IdType, InputValueType> WriteStandardCRUDRepo<ObjectType, IdType, InputValueType>.create(
|
suspend fun <ObjectType, IdType, InputValueType> WriteStandardCRUDRepo<ObjectType, IdType, InputValueType>.create(
|
||||||
vararg values: InputValueType
|
vararg values: InputValueType
|
||||||
): List<ObjectType> = create(values.toList())
|
): List<ObjectType> = create(values.toList())
|
||||||
@JsExport
|
|
||||||
suspend fun <ObjectType, IdType, InputValueType> WriteStandardCRUDRepo<ObjectType, IdType, InputValueType>.update(
|
suspend fun <ObjectType, IdType, InputValueType> WriteStandardCRUDRepo<ObjectType, IdType, InputValueType>.update(
|
||||||
vararg values: UpdatedValuePair<IdType, InputValueType>
|
vararg values: UpdatedValuePair<IdType, InputValueType>
|
||||||
): List<ObjectType> = update(values.toList())
|
): List<ObjectType> = update(values.toList())
|
||||||
@JsExport
|
|
||||||
suspend fun <ObjectType, IdType, InputValueType> WriteStandardCRUDRepo<ObjectType, IdType, InputValueType>.deleteById(
|
suspend fun <ObjectType, IdType, InputValueType> WriteStandardCRUDRepo<ObjectType, IdType, InputValueType>.deleteById(
|
||||||
vararg ids: IdType
|
vararg ids: IdType
|
||||||
) = deleteById(ids.toList())
|
) = deleteById(ids.toList())
|
||||||
|
|
||||||
@JsExport
|
|
||||||
interface StandardCRUDRepo<ObjectType, IdType, InputValueType> : ReadStandardCRUDRepo<ObjectType, IdType>,
|
interface StandardCRUDRepo<ObjectType, IdType, InputValueType> : ReadStandardCRUDRepo<ObjectType, IdType>,
|
||||||
WriteStandardCRUDRepo<ObjectType, IdType, InputValueType>
|
WriteStandardCRUDRepo<ObjectType, IdType, InputValueType>
|
@ -3,9 +3,7 @@ package dev.inmo.micro_utils.repos
|
|||||||
import dev.inmo.micro_utils.pagination.Pagination
|
import dev.inmo.micro_utils.pagination.Pagination
|
||||||
import dev.inmo.micro_utils.pagination.PaginationResult
|
import dev.inmo.micro_utils.pagination.PaginationResult
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
@JsExport
|
|
||||||
interface ReadStandardKeyValueRepo<Key, Value> : Repo {
|
interface ReadStandardKeyValueRepo<Key, Value> : Repo {
|
||||||
suspend fun get(k: Key): Value?
|
suspend fun get(k: Key): Value?
|
||||||
suspend fun values(pagination: Pagination, reversed: Boolean = false): PaginationResult<Value>
|
suspend fun values(pagination: Pagination, reversed: Boolean = false): PaginationResult<Value>
|
||||||
@ -14,7 +12,6 @@ interface ReadStandardKeyValueRepo<Key, Value> : Repo {
|
|||||||
suspend fun count(): Long
|
suspend fun count(): Long
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsExport
|
|
||||||
interface WriteStandardKeyValueRepo<Key, Value> : Repo {
|
interface WriteStandardKeyValueRepo<Key, Value> : Repo {
|
||||||
val onNewValue: Flow<Pair<Key, Value>>
|
val onNewValue: Flow<Pair<Key, Value>>
|
||||||
val onValueRemoved: Flow<Key>
|
val onValueRemoved: Flow<Key>
|
||||||
@ -23,5 +20,4 @@ interface WriteStandardKeyValueRepo<Key, Value> : Repo {
|
|||||||
suspend fun unset(k: Key)
|
suspend fun unset(k: Key)
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsExport
|
|
||||||
interface StandardKeyValueRepo<Key, Value> : ReadStandardKeyValueRepo<Key, Value>, WriteStandardKeyValueRepo<Key, Value>
|
interface StandardKeyValueRepo<Key, Value> : ReadStandardKeyValueRepo<Key, Value>, WriteStandardKeyValueRepo<Key, Value>
|
@ -2,9 +2,7 @@ package dev.inmo.micro_utils.repos.pagination
|
|||||||
|
|
||||||
import dev.inmo.micro_utils.pagination.*
|
import dev.inmo.micro_utils.pagination.*
|
||||||
import dev.inmo.micro_utils.repos.ReadStandardCRUDRepo
|
import dev.inmo.micro_utils.repos.ReadStandardCRUDRepo
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
@JsExport
|
|
||||||
suspend inline fun <T, ID, REPO : ReadStandardCRUDRepo<T, ID>> REPO.doForAll(
|
suspend inline fun <T, ID, REPO : ReadStandardCRUDRepo<T, ID>> REPO.doForAll(
|
||||||
@Suppress("REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE")
|
@Suppress("REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE")
|
||||||
methodCaller: suspend REPO.(Pagination) -> PaginationResult<T>,
|
methodCaller: suspend REPO.(Pagination) -> PaginationResult<T>,
|
||||||
@ -17,12 +15,10 @@ suspend inline fun <T, ID, REPO : ReadStandardCRUDRepo<T, ID>> REPO.doForAll(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsExport
|
|
||||||
suspend inline fun <T, ID, REPO : ReadStandardCRUDRepo<T, ID>> REPO.doForAll(
|
suspend inline fun <T, ID, REPO : ReadStandardCRUDRepo<T, ID>> REPO.doForAll(
|
||||||
block: (List<T>) -> Unit
|
block: (List<T>) -> Unit
|
||||||
) = doForAll({ getByPagination(it) }, block)
|
) = doForAll({ getByPagination(it) }, block)
|
||||||
|
|
||||||
@JsExport
|
|
||||||
suspend inline fun <T, ID, REPO : ReadStandardCRUDRepo<T, ID>> REPO.getAll(
|
suspend inline fun <T, ID, REPO : ReadStandardCRUDRepo<T, ID>> REPO.getAll(
|
||||||
@Suppress("REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE")
|
@Suppress("REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE")
|
||||||
methodCaller: suspend REPO.(Pagination) -> PaginationResult<T>
|
methodCaller: suspend REPO.(Pagination) -> PaginationResult<T>
|
||||||
|
@ -2,9 +2,7 @@ package dev.inmo.micro_utils.repos.pagination
|
|||||||
|
|
||||||
import dev.inmo.micro_utils.pagination.*
|
import dev.inmo.micro_utils.pagination.*
|
||||||
import dev.inmo.micro_utils.repos.*
|
import dev.inmo.micro_utils.repos.*
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
@JsExport
|
|
||||||
suspend inline fun <Key, Value, REPO : ReadStandardKeyValueRepo<Key, Value>> REPO.doForAll(
|
suspend inline fun <Key, Value, REPO : ReadStandardKeyValueRepo<Key, Value>> REPO.doForAll(
|
||||||
@Suppress("REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE")
|
@Suppress("REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE")
|
||||||
methodCaller: suspend REPO.(Pagination) -> PaginationResult<Key>,
|
methodCaller: suspend REPO.(Pagination) -> PaginationResult<Key>,
|
||||||
@ -17,12 +15,10 @@ suspend inline fun <Key, Value, REPO : ReadStandardKeyValueRepo<Key, Value>> REP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsExport
|
|
||||||
suspend inline fun <Key, Value, REPO : ReadStandardKeyValueRepo<Key, Value>> REPO.doForAll(
|
suspend inline fun <Key, Value, REPO : ReadStandardKeyValueRepo<Key, Value>> REPO.doForAll(
|
||||||
block: (List<Pair<Key, Value>>) -> Unit
|
block: (List<Pair<Key, Value>>) -> Unit
|
||||||
) = doForAll({ keys(it, false) }, block)
|
) = doForAll({ keys(it, false) }, block)
|
||||||
|
|
||||||
@JsExport
|
|
||||||
suspend inline fun <Key, Value, REPO : ReadStandardKeyValueRepo<Key, Value>> REPO.getAll(
|
suspend inline fun <Key, Value, REPO : ReadStandardKeyValueRepo<Key, Value>> REPO.getAll(
|
||||||
@Suppress("REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE")
|
@Suppress("REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE")
|
||||||
methodCaller: suspend REPO.(Pagination) -> PaginationResult<Key>
|
methodCaller: suspend REPO.(Pagination) -> PaginationResult<Key>
|
||||||
|
@ -2,9 +2,7 @@ package dev.inmo.micro_utils.repos.pagination
|
|||||||
|
|
||||||
import dev.inmo.micro_utils.pagination.*
|
import dev.inmo.micro_utils.pagination.*
|
||||||
import dev.inmo.micro_utils.repos.*
|
import dev.inmo.micro_utils.repos.*
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
@JsExport
|
|
||||||
suspend inline fun <Key, Value, REPO : ReadOneToManyKeyValueRepo<Key, Value>> REPO.doForAll(
|
suspend inline fun <Key, Value, REPO : ReadOneToManyKeyValueRepo<Key, Value>> REPO.doForAll(
|
||||||
@Suppress("REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE")
|
@Suppress("REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE")
|
||||||
methodCaller: suspend REPO.(Pagination) -> PaginationResult<Key>,
|
methodCaller: suspend REPO.(Pagination) -> PaginationResult<Key>,
|
||||||
@ -27,12 +25,10 @@ suspend inline fun <Key, Value, REPO : ReadOneToManyKeyValueRepo<Key, Value>> RE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsExport
|
|
||||||
suspend inline fun <Key, Value, REPO : ReadOneToManyKeyValueRepo<Key, Value>> REPO.doForAll(
|
suspend inline fun <Key, Value, REPO : ReadOneToManyKeyValueRepo<Key, Value>> REPO.doForAll(
|
||||||
block: (List<Pair<Key, List<Value>>>) -> Unit
|
block: (List<Pair<Key, List<Value>>>) -> Unit
|
||||||
) = doForAll({ keys(it, false) }, block)
|
) = doForAll({ keys(it, false) }, block)
|
||||||
|
|
||||||
@JsExport
|
|
||||||
suspend inline fun <Key, Value, REPO : ReadOneToManyKeyValueRepo<Key, Value>> REPO.getAll(
|
suspend inline fun <Key, Value, REPO : ReadOneToManyKeyValueRepo<Key, Value>> REPO.getAll(
|
||||||
@Suppress("REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE")
|
@Suppress("REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE")
|
||||||
methodCaller: suspend REPO.(Pagination) -> PaginationResult<Key>
|
methodCaller: suspend REPO.(Pagination) -> PaginationResult<Key>
|
||||||
|
@ -3,9 +3,7 @@ package dev.inmo.micro_utils.repos
|
|||||||
import dev.inmo.micro_utils.coroutines.BroadcastFlow
|
import dev.inmo.micro_utils.coroutines.BroadcastFlow
|
||||||
import dev.inmo.micro_utils.pagination.*
|
import dev.inmo.micro_utils.pagination.*
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
@JsExport
|
|
||||||
class ReadMapCRUDRepo<ObjectType, IdType>(
|
class ReadMapCRUDRepo<ObjectType, IdType>(
|
||||||
private val map: Map<IdType, ObjectType> = emptyMap()
|
private val map: Map<IdType, ObjectType> = emptyMap()
|
||||||
) : ReadStandardCRUDRepo<ObjectType, IdType> {
|
) : ReadStandardCRUDRepo<ObjectType, IdType> {
|
||||||
@ -25,7 +23,6 @@ class ReadMapCRUDRepo<ObjectType, IdType>(
|
|||||||
override suspend fun count(): Long = map.size.toLong()
|
override suspend fun count(): Long = map.size.toLong()
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsExport
|
|
||||||
abstract class WriteMapCRUDRepo<ObjectType, IdType, InputValueType>(
|
abstract class WriteMapCRUDRepo<ObjectType, IdType, InputValueType>(
|
||||||
private val map: MutableMap<IdType, ObjectType> = mutableMapOf()
|
private val map: MutableMap<IdType, ObjectType> = mutableMapOf()
|
||||||
) : WriteStandardCRUDRepo<ObjectType, IdType, InputValueType> {
|
) : WriteStandardCRUDRepo<ObjectType, IdType, InputValueType> {
|
||||||
@ -73,14 +70,12 @@ abstract class WriteMapCRUDRepo<ObjectType, IdType, InputValueType>(
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsExport
|
|
||||||
abstract class MapCRUDRepo<ObjectType, IdType, InputValueType>(
|
abstract class MapCRUDRepo<ObjectType, IdType, InputValueType>(
|
||||||
map: MutableMap<IdType, ObjectType>
|
map: MutableMap<IdType, ObjectType>
|
||||||
) : StandardCRUDRepo<ObjectType, IdType, InputValueType>,
|
) : StandardCRUDRepo<ObjectType, IdType, InputValueType>,
|
||||||
ReadStandardCRUDRepo<ObjectType, IdType> by ReadMapCRUDRepo(map),
|
ReadStandardCRUDRepo<ObjectType, IdType> by ReadMapCRUDRepo(map),
|
||||||
WriteMapCRUDRepo<ObjectType, IdType, InputValueType>(map)
|
WriteMapCRUDRepo<ObjectType, IdType, InputValueType>(map)
|
||||||
|
|
||||||
@JsExport
|
|
||||||
fun <ObjectType, IdType, InputValueType> MapCRUDRepo(
|
fun <ObjectType, IdType, InputValueType> MapCRUDRepo(
|
||||||
map: MutableMap<IdType, ObjectType>,
|
map: MutableMap<IdType, ObjectType>,
|
||||||
updateCallback: suspend (newValue: InputValueType, id: IdType, old: ObjectType) -> ObjectType,
|
updateCallback: suspend (newValue: InputValueType, id: IdType, old: ObjectType) -> ObjectType,
|
||||||
@ -95,7 +90,6 @@ fun <ObjectType, IdType, InputValueType> MapCRUDRepo(
|
|||||||
override suspend fun createObject(newValue: InputValueType): Pair<IdType, ObjectType> = createCallback(newValue)
|
override suspend fun createObject(newValue: InputValueType): Pair<IdType, ObjectType> = createCallback(newValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsExport
|
|
||||||
fun <ObjectType, IdType, InputValueType> MutableMap<IdType, ObjectType>.asCrudRepo(
|
fun <ObjectType, IdType, InputValueType> MutableMap<IdType, ObjectType>.asCrudRepo(
|
||||||
updateCallback: suspend (newValue: InputValueType, id: IdType, old: ObjectType) -> ObjectType,
|
updateCallback: suspend (newValue: InputValueType, id: IdType, old: ObjectType) -> ObjectType,
|
||||||
createCallback: suspend (newValue: InputValueType) -> Pair<IdType, ObjectType>
|
createCallback: suspend (newValue: InputValueType) -> Pair<IdType, ObjectType>
|
||||||
|
@ -3,9 +3,7 @@ package dev.inmo.micro_utils.repos
|
|||||||
import dev.inmo.micro_utils.coroutines.BroadcastFlow
|
import dev.inmo.micro_utils.coroutines.BroadcastFlow
|
||||||
import dev.inmo.micro_utils.pagination.*
|
import dev.inmo.micro_utils.pagination.*
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
@JsExport
|
|
||||||
class ReadMapKeyValueRepo<Key, Value>(
|
class ReadMapKeyValueRepo<Key, Value>(
|
||||||
private val map: Map<Key, Value> = emptyMap()
|
private val map: Map<Key, Value> = emptyMap()
|
||||||
) : ReadStandardKeyValueRepo<Key, Value> {
|
) : ReadStandardKeyValueRepo<Key, Value> {
|
||||||
@ -47,7 +45,6 @@ class ReadMapKeyValueRepo<Key, Value>(
|
|||||||
override suspend fun count(): Long = map.size.toLong()
|
override suspend fun count(): Long = map.size.toLong()
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsExport
|
|
||||||
class WriteMapKeyValueRepo<Key, Value>(
|
class WriteMapKeyValueRepo<Key, Value>(
|
||||||
private val map: MutableMap<Key, Value> = mutableMapOf()
|
private val map: MutableMap<Key, Value> = mutableMapOf()
|
||||||
) : WriteStandardKeyValueRepo<Key, Value> {
|
) : WriteStandardKeyValueRepo<Key, Value> {
|
||||||
@ -68,12 +65,10 @@ class WriteMapKeyValueRepo<Key, Value>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsExport
|
|
||||||
class MapKeyValueRepo<Key, Value>(
|
class MapKeyValueRepo<Key, Value>(
|
||||||
private val map: MutableMap<Key, Value> = mutableMapOf()
|
private val map: MutableMap<Key, Value> = mutableMapOf()
|
||||||
) : StandardKeyValueRepo<Key, Value>,
|
) : StandardKeyValueRepo<Key, Value>,
|
||||||
ReadStandardKeyValueRepo<Key, Value> by ReadMapKeyValueRepo(map),
|
ReadStandardKeyValueRepo<Key, Value> by ReadMapKeyValueRepo(map),
|
||||||
WriteStandardKeyValueRepo<Key, Value> by WriteMapKeyValueRepo(map)
|
WriteStandardKeyValueRepo<Key, Value> by WriteMapKeyValueRepo(map)
|
||||||
|
|
||||||
@JsExport
|
|
||||||
fun <K, V> MutableMap<K, V>.asKeyValueRepo(): StandardKeyValueRepo<K, V> = MapKeyValueRepo(this)
|
fun <K, V> MutableMap<K, V>.asKeyValueRepo(): StandardKeyValueRepo<K, V> = MapKeyValueRepo(this)
|
||||||
|
@ -4,9 +4,7 @@ import dev.inmo.micro_utils.coroutines.BroadcastFlow
|
|||||||
import dev.inmo.micro_utils.pagination.*
|
import dev.inmo.micro_utils.pagination.*
|
||||||
import dev.inmo.micro_utils.pagination.utils.paginate
|
import dev.inmo.micro_utils.pagination.utils.paginate
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
@JsExport
|
|
||||||
class MapReadOneToManyKeyValueRepo<Key, Value>(
|
class MapReadOneToManyKeyValueRepo<Key, Value>(
|
||||||
private val map: Map<Key, List<Value>> = emptyMap()
|
private val map: Map<Key, List<Value>> = emptyMap()
|
||||||
) : ReadOneToManyKeyValueRepo<Key, Value> {
|
) : ReadOneToManyKeyValueRepo<Key, Value> {
|
||||||
@ -46,7 +44,6 @@ class MapReadOneToManyKeyValueRepo<Key, Value>(
|
|||||||
override suspend fun count(): Long = map.size.toLong()
|
override suspend fun count(): Long = map.size.toLong()
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsExport
|
|
||||||
class MapWriteOneToManyKeyValueRepo<Key, Value>(
|
class MapWriteOneToManyKeyValueRepo<Key, Value>(
|
||||||
private val map: MutableMap<Key, MutableList<Value>> = mutableMapOf()
|
private val map: MutableMap<Key, MutableList<Value>> = mutableMapOf()
|
||||||
) : WriteOneToManyKeyValueRepo<Key, Value> {
|
) : WriteOneToManyKeyValueRepo<Key, Value> {
|
||||||
@ -74,14 +71,12 @@ class MapWriteOneToManyKeyValueRepo<Key, Value>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsExport
|
|
||||||
class MapOneToManyKeyValueRepo<Key, Value>(
|
class MapOneToManyKeyValueRepo<Key, Value>(
|
||||||
private val map: MutableMap<Key, MutableList<Value>> = mutableMapOf()
|
private val map: MutableMap<Key, MutableList<Value>> = mutableMapOf()
|
||||||
) : OneToManyKeyValueRepo<Key, Value>,
|
) : OneToManyKeyValueRepo<Key, Value>,
|
||||||
ReadOneToManyKeyValueRepo<Key, Value> by MapReadOneToManyKeyValueRepo(map),
|
ReadOneToManyKeyValueRepo<Key, Value> by MapReadOneToManyKeyValueRepo(map),
|
||||||
WriteOneToManyKeyValueRepo<Key, Value> by MapWriteOneToManyKeyValueRepo(map)
|
WriteOneToManyKeyValueRepo<Key, Value> by MapWriteOneToManyKeyValueRepo(map)
|
||||||
|
|
||||||
@JsExport
|
|
||||||
fun <K, V> MutableMap<K, List<V>>.asOneToManyKeyValueRepo(): OneToManyKeyValueRepo<K, V> = MapOneToManyKeyValueRepo(
|
fun <K, V> MutableMap<K, List<V>>.asOneToManyKeyValueRepo(): OneToManyKeyValueRepo<K, V> = MapOneToManyKeyValueRepo(
|
||||||
map { (k, v) -> k to v.toMutableList() }.toMap().toMutableMap()
|
map { (k, v) -> k to v.toMutableList() }.toMap().toMutableMap()
|
||||||
)
|
)
|
||||||
|
@ -11,9 +11,7 @@ import dev.inmo.micro_utils.repos.ktor.common.crud.*
|
|||||||
import io.ktor.client.HttpClient
|
import io.ktor.client.HttpClient
|
||||||
import kotlinx.serialization.KSerializer
|
import kotlinx.serialization.KSerializer
|
||||||
import kotlinx.serialization.builtins.serializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
@JsExport
|
|
||||||
class KtorReadStandardCrudRepo<ObjectType, IdType> (
|
class KtorReadStandardCrudRepo<ObjectType, IdType> (
|
||||||
private val baseUrl: String,
|
private val baseUrl: String,
|
||||||
private val client: HttpClient = HttpClient(),
|
private val client: HttpClient = HttpClient(),
|
||||||
|
@ -3,9 +3,7 @@ package dev.inmo.micro_utils.repos.ktor.client.crud
|
|||||||
import dev.inmo.micro_utils.repos.*
|
import dev.inmo.micro_utils.repos.*
|
||||||
import io.ktor.client.HttpClient
|
import io.ktor.client.HttpClient
|
||||||
import kotlinx.serialization.KSerializer
|
import kotlinx.serialization.KSerializer
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
@JsExport
|
|
||||||
class KtorStandardCrudRepo<ObjectType, IdType, InputValue> (
|
class KtorStandardCrudRepo<ObjectType, IdType, InputValue> (
|
||||||
baseUrl: String,
|
baseUrl: String,
|
||||||
baseSubpart: String,
|
baseSubpart: String,
|
||||||
|
@ -11,9 +11,7 @@ import io.ktor.client.HttpClient
|
|||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.serialization.KSerializer
|
import kotlinx.serialization.KSerializer
|
||||||
import kotlinx.serialization.builtins.*
|
import kotlinx.serialization.builtins.*
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
@JsExport
|
|
||||||
class KtorWriteStandardCrudRepo<ObjectType, IdType, InputValue> (
|
class KtorWriteStandardCrudRepo<ObjectType, IdType, InputValue> (
|
||||||
private val baseUrl: String,
|
private val baseUrl: String,
|
||||||
private val client: HttpClient = HttpClient(),
|
private val client: HttpClient = HttpClient(),
|
||||||
|
@ -11,9 +11,7 @@ import dev.inmo.micro_utils.repos.ktor.common.key_value.*
|
|||||||
import io.ktor.client.*
|
import io.ktor.client.*
|
||||||
import kotlinx.serialization.KSerializer
|
import kotlinx.serialization.KSerializer
|
||||||
import kotlinx.serialization.builtins.serializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
@JsExport
|
|
||||||
class KtorReadStandardKeyValueRepo<Key, Value> (
|
class KtorReadStandardKeyValueRepo<Key, Value> (
|
||||||
private var baseUrl: String,
|
private var baseUrl: String,
|
||||||
private var client: HttpClient = HttpClient(),
|
private var client: HttpClient = HttpClient(),
|
||||||
|
@ -5,9 +5,7 @@ import dev.inmo.micro_utils.repos.ReadStandardKeyValueRepo
|
|||||||
import dev.inmo.micro_utils.repos.WriteStandardKeyValueRepo
|
import dev.inmo.micro_utils.repos.WriteStandardKeyValueRepo
|
||||||
import io.ktor.client.*
|
import io.ktor.client.*
|
||||||
import kotlinx.serialization.KSerializer
|
import kotlinx.serialization.KSerializer
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
@JsExport
|
|
||||||
class KtorStandartKeyValueRepo<K, V> (
|
class KtorStandartKeyValueRepo<K, V> (
|
||||||
baseUrl: String,
|
baseUrl: String,
|
||||||
baseSubpart: String,
|
baseSubpart: String,
|
||||||
|
@ -11,9 +11,7 @@ import kotlinx.coroutines.flow.Flow
|
|||||||
import kotlinx.serialization.KSerializer
|
import kotlinx.serialization.KSerializer
|
||||||
import kotlinx.serialization.builtins.PairSerializer
|
import kotlinx.serialization.builtins.PairSerializer
|
||||||
import kotlinx.serialization.builtins.serializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
@JsExport
|
|
||||||
class KtorWriteStandardKeyValueRepo<K, V> (
|
class KtorWriteStandardKeyValueRepo<K, V> (
|
||||||
private var baseUrl: String,
|
private var baseUrl: String,
|
||||||
private var client: HttpClient = HttpClient(),
|
private var client: HttpClient = HttpClient(),
|
||||||
|
@ -5,9 +5,7 @@ import dev.inmo.micro_utils.repos.ReadOneToManyKeyValueRepo
|
|||||||
import dev.inmo.micro_utils.repos.WriteOneToManyKeyValueRepo
|
import dev.inmo.micro_utils.repos.WriteOneToManyKeyValueRepo
|
||||||
import io.ktor.client.HttpClient
|
import io.ktor.client.HttpClient
|
||||||
import kotlinx.serialization.KSerializer
|
import kotlinx.serialization.KSerializer
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
@JsExport
|
|
||||||
class KtorOneToManyKeyValueRepo<Key, Value>(
|
class KtorOneToManyKeyValueRepo<Key, Value>(
|
||||||
baseUrl: String,
|
baseUrl: String,
|
||||||
baseSubpart: String,
|
baseSubpart: String,
|
||||||
|
@ -11,9 +11,7 @@ import dev.inmo.micro_utils.repos.ktor.common.one_to_many.*
|
|||||||
import io.ktor.client.HttpClient
|
import io.ktor.client.HttpClient
|
||||||
import kotlinx.serialization.KSerializer
|
import kotlinx.serialization.KSerializer
|
||||||
import kotlinx.serialization.builtins.serializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
@JsExport
|
|
||||||
class KtorReadOneToManyKeyValueRepo<Key, Value> (
|
class KtorReadOneToManyKeyValueRepo<Key, Value> (
|
||||||
private val baseUrl: String,
|
private val baseUrl: String,
|
||||||
private val client: HttpClient = HttpClient(),
|
private val client: HttpClient = HttpClient(),
|
||||||
@ -85,4 +83,5 @@ class KtorReadOneToManyKeyValueRepo<Key, Value> (
|
|||||||
),
|
),
|
||||||
Long.serializer()
|
Long.serializer()
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
@ -11,9 +11,7 @@ import kotlinx.coroutines.flow.Flow
|
|||||||
import kotlinx.serialization.KSerializer
|
import kotlinx.serialization.KSerializer
|
||||||
import kotlinx.serialization.builtins.PairSerializer
|
import kotlinx.serialization.builtins.PairSerializer
|
||||||
import kotlinx.serialization.builtins.serializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
@JsExport
|
|
||||||
class KtorWriteOneToManyKeyValueRepo<Key, Value> (
|
class KtorWriteOneToManyKeyValueRepo<Key, Value> (
|
||||||
private val baseUrl: String,
|
private val baseUrl: String,
|
||||||
private val client: HttpClient = HttpClient(),
|
private val client: HttpClient = HttpClient(),
|
||||||
|
@ -1,12 +1,6 @@
|
|||||||
package dev.inmo.micro_utils.repos.ktor.common.crud
|
package dev.inmo.micro_utils.repos.ktor.common.crud
|
||||||
|
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
@JsExport
|
|
||||||
const val getByPaginationRouting = "getByPagination"
|
const val getByPaginationRouting = "getByPagination"
|
||||||
@JsExport
|
|
||||||
const val getByIdRouting = "getById"
|
const val getByIdRouting = "getById"
|
||||||
@JsExport
|
|
||||||
const val containsRouting = "contains"
|
const val containsRouting = "contains"
|
||||||
@JsExport
|
|
||||||
const val countRouting = "count"
|
const val countRouting = "count"
|
||||||
|
@ -1,19 +1,10 @@
|
|||||||
package dev.inmo.micro_utils.repos.ktor.common.crud
|
package dev.inmo.micro_utils.repos.ktor.common.crud
|
||||||
|
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
@JsExport
|
|
||||||
const val newObjectsFlowRouting = "newObjectsFlow"
|
const val newObjectsFlowRouting = "newObjectsFlow"
|
||||||
@JsExport
|
|
||||||
const val updatedObjectsFlowRouting = "updatedObjectsFlow"
|
const val updatedObjectsFlowRouting = "updatedObjectsFlow"
|
||||||
@JsExport
|
|
||||||
const val deletedObjectsIdsFlowRouting = "deletedObjectsIdsFlow"
|
const val deletedObjectsIdsFlowRouting = "deletedObjectsIdsFlow"
|
||||||
|
|
||||||
@JsExport
|
|
||||||
const val createRouting = "create"
|
const val createRouting = "create"
|
||||||
@JsExport
|
|
||||||
const val updateRouting = "update"
|
const val updateRouting = "update"
|
||||||
@JsExport
|
|
||||||
const val updateManyRouting = "updateMany"
|
const val updateManyRouting = "updateMany"
|
||||||
@JsExport
|
|
||||||
const val deleteByIdRouting = "deleteById"
|
const val deleteByIdRouting = "deleteById"
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
package dev.inmo.micro_utils.repos.ktor.common.key_value
|
package dev.inmo.micro_utils.repos.ktor.common.key_value
|
||||||
|
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
@JsExport
|
|
||||||
const val keyParameterName = "key"
|
const val keyParameterName = "key"
|
||||||
@JsExport
|
|
||||||
const val reversedParameterName = "reversed"
|
const val reversedParameterName = "reversed"
|
@ -1,9 +1,7 @@
|
|||||||
package dev.inmo.micro_utils.repos.ktor.common.key_value
|
package dev.inmo.micro_utils.repos.ktor.common.key_value
|
||||||
|
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
@JsExport
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class KeyValuePostObject<K, V> (
|
data class KeyValuePostObject<K, V> (
|
||||||
val key: K,
|
val key: K,
|
||||||
|
@ -1,23 +1,12 @@
|
|||||||
package dev.inmo.micro_utils.repos.ktor.common.key_value
|
package dev.inmo.micro_utils.repos.ktor.common.key_value
|
||||||
|
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
@JsExport
|
|
||||||
const val getRoute = "get"
|
const val getRoute = "get"
|
||||||
@JsExport
|
|
||||||
const val valuesRoute = "values"
|
const val valuesRoute = "values"
|
||||||
@JsExport
|
|
||||||
const val keysRoute = "keys"
|
const val keysRoute = "keys"
|
||||||
@JsExport
|
|
||||||
const val containsRoute = "contains"
|
const val containsRoute = "contains"
|
||||||
@JsExport
|
|
||||||
const val countRoute = "count"
|
const val countRoute = "count"
|
||||||
|
|
||||||
@JsExport
|
|
||||||
const val onNewValueRoute = "onNewValue"
|
const val onNewValueRoute = "onNewValue"
|
||||||
@JsExport
|
|
||||||
const val onValueRemovedRoute = "onValueRemoved"
|
const val onValueRemovedRoute = "onValueRemoved"
|
||||||
@JsExport
|
|
||||||
const val setRoute = "set"
|
const val setRoute = "set"
|
||||||
@JsExport
|
|
||||||
const val unsetRoute = "unset"
|
const val unsetRoute = "unset"
|
@ -1,10 +1,5 @@
|
|||||||
package dev.inmo.micro_utils.repos.ktor.common.one_to_many
|
package dev.inmo.micro_utils.repos.ktor.common.one_to_many
|
||||||
|
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
@JsExport
|
|
||||||
const val keyParameterName = "key"
|
const val keyParameterName = "key"
|
||||||
@JsExport
|
|
||||||
const val valueParameterName = "value"
|
const val valueParameterName = "value"
|
||||||
@JsExport
|
|
||||||
const val reversedParameterName = "reversed"
|
const val reversedParameterName = "reversed"
|
@ -1,30 +1,16 @@
|
|||||||
package dev.inmo.micro_utils.repos.ktor.common.one_to_many
|
package dev.inmo.micro_utils.repos.ktor.common.one_to_many
|
||||||
|
|
||||||
import kotlin.js.JsExport
|
|
||||||
|
|
||||||
@JsExport
|
|
||||||
const val getRoute = "get"
|
const val getRoute = "get"
|
||||||
@JsExport
|
|
||||||
const val keysRoute = "keys"
|
const val keysRoute = "keys"
|
||||||
@JsExport
|
|
||||||
const val containsByKeyRoute = "containsByKey"
|
const val containsByKeyRoute = "containsByKey"
|
||||||
@JsExport
|
|
||||||
const val containsByKeyValueRoute = "containsByKeyValue"
|
const val containsByKeyValueRoute = "containsByKeyValue"
|
||||||
@JsExport
|
|
||||||
const val countByKeyRoute = "countByKey"
|
const val countByKeyRoute = "countByKey"
|
||||||
@JsExport
|
|
||||||
const val countRoute = "count"
|
const val countRoute = "count"
|
||||||
|
|
||||||
@JsExport
|
|
||||||
const val onNewValueRoute = "onNewValue"
|
const val onNewValueRoute = "onNewValue"
|
||||||
@JsExport
|
|
||||||
const val onValueRemovedRoute = "onValueRemoved"
|
const val onValueRemovedRoute = "onValueRemoved"
|
||||||
@JsExport
|
|
||||||
const val onDataClearedRoute = "onDataCleared"
|
const val onDataClearedRoute = "onDataCleared"
|
||||||
|
|
||||||
@JsExport
|
|
||||||
const val addRoute = "add"
|
const val addRoute = "add"
|
||||||
@JsExport
|
|
||||||
const val removeRoute = "remove"
|
const val removeRoute = "remove"
|
||||||
@JsExport
|
|
||||||
const val clearRoute = "clear"
|
const val clearRoute = "clear"
|
Loading…
Reference in New Issue
Block a user