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