diff --git a/business_cases/post_creating/client/build.gradle b/business_cases/post_creating/client/build.gradle index 5b06880f..4d1dbc5b 100644 --- a/business_cases/post_creating/client/build.gradle +++ b/business_cases/post_creating/client/build.gradle @@ -8,7 +8,6 @@ buildscript { dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" - classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version" } } @@ -39,8 +38,9 @@ kotlin { dependencies { implementation kotlin('stdlib') - api projectByName("business_cases.post_creating.common") - api projectByName("core.ktor.client") + + api project(":postssystem.business_cases.post_creating.common") + api project(":postssystem.core.ktor.client") } } commonTest { diff --git a/business_cases/post_creating/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/business_cases/post_creating/client/PostCreatingClientCase.kt b/business_cases/post_creating/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/business_cases/post_creating/client/PostCreatingClientCase.kt index 58204961..fea320c9 100644 --- a/business_cases/post_creating/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/business_cases/post_creating/client/PostCreatingClientCase.kt +++ b/business_cases/post_creating/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/business_cases/post_creating/client/PostCreatingClientCase.kt @@ -4,9 +4,9 @@ import com.insanusmokrassar.postssystem.business_cases.post_creating.server.* import com.insanusmokrassar.postssystem.core.content.Content import com.insanusmokrassar.postssystem.core.post.RegisteredPost import com.insanusmokrassar.postssystem.core.publishing.TriggerId -import com.insanusmokrassar.postssystem.ktor.buildStandardUrl -import com.insanusmokrassar.postssystem.ktor.client.BodyPair -import com.insanusmokrassar.postssystem.ktor.client.unipost +import dev.inmo.micro_utils.ktor.client.BodyPair +import dev.inmo.micro_utils.ktor.client.unipost +import dev.inmo.micro_utils.ktor.common.buildStandardUrl import io.ktor.client.HttpClient class PostCreatingClientCase( diff --git a/business_cases/post_creating/common/build.gradle b/business_cases/post_creating/common/build.gradle index aaf12d95..6ae8ff13 100644 --- a/business_cases/post_creating/common/build.gradle +++ b/business_cases/post_creating/common/build.gradle @@ -8,7 +8,6 @@ buildscript { dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" - classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version" } } @@ -39,8 +38,8 @@ kotlin { dependencies { implementation kotlin('stdlib') - api projectByName("core.ktor.common") - api projectByName("publishing.ktor.common") + api project(":postssystem.core.ktor.common") + api project(":postssystem.publishing.ktor.common") } } commonTest { diff --git a/business_cases/post_creating/server/build.gradle b/business_cases/post_creating/server/build.gradle index 73678d2c..1d99462f 100644 --- a/business_cases/post_creating/server/build.gradle +++ b/business_cases/post_creating/server/build.gradle @@ -8,7 +8,6 @@ buildscript { dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" - classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version" } } @@ -32,8 +31,8 @@ repositories { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - api projectByName("business_cases.post_creating.common") - api projectByName("core.ktor.server") + api project(":postssystem.business_cases.post_creating.common") + api project(":postssystem.core.ktor.server") testImplementation "org.xerial:sqlite-jdbc:$test_sqlite_version" testImplementation "org.jetbrains.kotlin:kotlin-test" diff --git a/business_cases/post_creating/server/src/main/kotlin/com/insanusmokrassar/postssystem/business_cases/post_creating/server/PostCreatingRoutingCase.kt b/business_cases/post_creating/server/src/main/kotlin/com/insanusmokrassar/postssystem/business_cases/post_creating/server/PostCreatingRoutingCase.kt index 0cdb41e4..fa9d2af6 100644 --- a/business_cases/post_creating/server/src/main/kotlin/com/insanusmokrassar/postssystem/business_cases/post_creating/server/PostCreatingRoutingCase.kt +++ b/business_cases/post_creating/server/src/main/kotlin/com/insanusmokrassar/postssystem/business_cases/post_creating/server/PostCreatingRoutingCase.kt @@ -1,8 +1,8 @@ package com.insanusmokrassar.postssystem.business_cases.post_creating.server import com.insanusmokrassar.postssystem.core.post.RegisteredPost -import com.insanusmokrassar.postssystem.ktor.server.unianswer -import com.insanusmokrassar.postssystem.ktor.server.uniload +import dev.inmo.micro_utils.ktor.server.unianswer +import dev.inmo.micro_utils.ktor.server.uniload import io.ktor.application.call import io.ktor.routing.* import kotlinx.serialization.builtins.nullable diff --git a/core/api/build.gradle b/core/api/build.gradle index 8011ff5e..b5053a30 100644 --- a/core/api/build.gradle +++ b/core/api/build.gradle @@ -8,7 +8,6 @@ buildscript { dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" - classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version" } } @@ -42,13 +41,10 @@ kotlin { implementation kotlin('stdlib') api kotlin('reflect') - if ((project.hasProperty('RELEASE_MODE') && project.property('RELEASE_MODE') == "true") || System.getenv('RELEASE_MODE') == "true") { - api "com.insanusmokrassar:postssystem.utils.common:$core_version" - api "com.insanusmokrassar:postssystem.utils.repos.common:$core_version" - } else { - api projectByName("utils.common") - api projectByName("utils.repos.common") - } + api "com.soywiz.korlibs.klock:klock:$klockVersion" + api "dev.inmo:micro_utils.common:$microutils_version" + api "dev.inmo:micro_utils.repos.common:$microutils_version" + api "dev.inmo:micro_utils.mime_types:$microutils_version" } } commonTest { @@ -57,21 +53,11 @@ kotlin { implementation kotlin('test-annotations-common') } } - jvmMain { - dependencies { - implementation kotlin('stdlib-jdk8') - } - } jvmTest { dependencies { implementation kotlin('test-junit') } } - jsMain { - dependencies { - implementation kotlin('stdlib-js') - } - } jsTest { dependencies { implementation kotlin('test-js') diff --git a/core/api/maven.publish.gradle b/core/api/maven.publish.gradle deleted file mode 100644 index b81b338a..00000000 --- a/core/api/maven.publish.gradle +++ /dev/null @@ -1,64 +0,0 @@ -apply plugin: 'maven-publish' - -task javadocsJar(type: Jar) { - classifier = 'javadoc' -} - -afterEvaluate { - project.publishing.publications.all { - // rename artifacts - groupId "${project.group}" - if (it.name.contains('kotlinMultiplatform')) { - artifactId = "${project.name}" - } else { - artifactId = "${project.name}-$name" - } - } -} - -publishing { - publications.all { - artifact javadocsJar - - pom.withXml { - asNode().children().last() + { - resolveStrategy = Closure.DELEGATE_FIRST - - description "Core library for PostsSystem" - name "PostsSystem Core" - url "https://git.insanusmokrassar.com/PostsSystem/PostsSystemCore" - - scm { - developerConnection "scm:git:[fetch=]https://git.insanusmokrassar.com/PostsSystem/PostsSystemCore.git[push=]https://git.insanusmokrassar.com/PostsSystem/PostsSystemCore.git" - url "https://git.insanusmokrassar.com/PostsSystem/PostsSystemCore.git" - } - - developers { - - developer { - id "InsanusMokrassar" - name "Ovsiannikov Aleksei" - email "ovsyannikov.alexey95@gmail.com" - } - - - developer { - id "mi-ast" - name "Michail Astafiev" - email "astaf65@gmail.com" - } - - } - - licenses { - - license { - name "Apache Software License 2.0" - url "https://git.insanusmokrassar.com/PostsSystem/PostsSystemCore/src/master/LICENSE" - } - - } - } - } - } -} \ No newline at end of file diff --git a/core/api/publish.gradle b/core/api/publish.gradle index b8cf4528..5863597d 100644 --- a/core/api/publish.gradle +++ b/core/api/publish.gradle @@ -1,55 +1,76 @@ -apply plugin: 'com.jfrog.bintray' +apply plugin: 'maven-publish' -apply from: "maven.publish.gradle" - -bintray { - user = project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER') - key = project.hasProperty('BINTRAY_KEY') ? project.property('BINTRAY_KEY') : System.getenv('BINTRAY_KEY') - filesSpec { - from "${buildDir}/publications/" - eachFile { - String directorySubname = it.getFile().parentFile.name - if (it.getName() == "module.json") { - if (directorySubname == "kotlinMultiplatform") { - it.setPath("${project.name}/${project.version}/${project.name}-${project.version}.module") - } else { - it.setPath("${project.name}-${directorySubname}/${project.version}/${project.name}-${directorySubname}-${project.version}.module") - } - } else { - if (directorySubname == "kotlinMultiplatform" && it.getName() == "pom-default.xml") { - it.setPath("${project.name}/${project.version}/${project.name}-${project.version}.pom") - } else { - it.exclude() - } - } - } - into "${project.group}".replace(".", "/") - } - pkg { - repo = "InsanusMokrassar" - name = "${project.name}" - vcsUrl = "https://github.com/PostsSystem/PostsSystemCore" - licenses = ["Apache-2.0"] - version { - name = "${project.version}" - released = new Date() - vcsTag = "${project.version}" - gpg { - sign = true - passphrase = project.hasProperty('signing.gnupg.passphrase') ? project.property('signing.gnupg.passphrase') : System.getenv('signing.gnupg.passphrase') - } - } - } +task javadocsJar(type: Jar) { + classifier = 'javadoc' +} +task sourceJar (type : Jar) { + classifier = 'sources' } -bintrayUpload.doFirst { - publications = publishing.publications.collect { +afterEvaluate { + project.publishing.publications.all { + // rename artifacts + groupId "${project.group}" if (it.name.contains('kotlinMultiplatform')) { - null + artifactId = "${project.name}" + artifact sourceJar } else { - it.name + artifactId = "${project.name}-$name" } - } - null + } } -bintrayUpload.dependsOn publishToMavenLocal \ No newline at end of file +publishing { + publications.all { + artifact javadocsJar + + pom { + description = "Core library for PostsSystem" + name = "PostsSystem Core" + url = "https://git.insanusmokrassar.com/PostsSystem/PostsSystemCore" + + scm { + developerConnection = "scm:git:[fetch=]https://git.insanusmokrassar.com/PostsSystem/PostsSystemCore.git[push=]https://git.insanusmokrassar.com/PostsSystem/PostsSystemCore.git" + url = "https://git.insanusmokrassar.com/PostsSystem/PostsSystemCore.git" + } + + developers { + + developer { + id = "InsanusMokrassar" + name = "Ovsiannikov Aleksei" + email = "ovsyannikov.alexey95@gmail.com" + } + + + developer { + id = "mi-ast" + name = "Michail Astafiev" + email = "astaf65@gmail.com" + } + + } + + licenses { + + license { + name = "Apache Software License 2.0" + url = "https://git.insanusmokrassar.com/PostsSystem/PostsSystemCore/src/master/LICENSE" + } + + } + } + + repositories { + maven { + name = "bintray" + url = uri("https://api.bintray.com/maven/${project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER')}/InsanusMokrassar/${project.name}/;publish=0;override=0") + credentials { + username = project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER') + password = project.hasProperty('BINTRAY_KEY') ? project.property('BINTRAY_KEY') : System.getenv('BINTRAY_KEY') + } + } + } + + } +} \ No newline at end of file diff --git a/core/api/publish_config.json b/core/api/publish_config.kpsb similarity index 100% rename from core/api/publish_config.json rename to core/api/publish_config.kpsb diff --git a/core/api/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/DateTimeUtils.kt b/core/api/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/DateTimeUtils.kt new file mode 100644 index 00000000..101a53ce --- /dev/null +++ b/core/api/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/DateTimeUtils.kt @@ -0,0 +1,7 @@ +package com.insanusmokrassar.postssystem.core + +import com.soywiz.klock.DateTime + +typealias UnixMillis = Double +val MIN_DATE = DateTime(Double.MIN_VALUE) +val MAX_DATE = DateTime(Double.MAX_VALUE) diff --git a/core/api/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/IdUtils.kt b/core/api/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/IdUtils.kt index 83409218..dc4445a1 100644 --- a/core/api/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/IdUtils.kt +++ b/core/api/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/IdUtils.kt @@ -1,8 +1,9 @@ package com.insanusmokrassar.postssystem.core +import com.benasher44.uuid.uuid4 import com.insanusmokrassar.postssystem.core.content.ContentId import com.insanusmokrassar.postssystem.core.post.PostId -import com.insanusmokrassar.postssystem.utils.repos.generateId +fun generateId() = uuid4().toString() fun generatePostId(): PostId = generateId() fun generateContentId(): ContentId = generateId() diff --git a/core/api/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/content/Content.kt b/core/api/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/content/Content.kt index 9b61f70b..e21d2b06 100644 --- a/core/api/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/content/Content.kt +++ b/core/api/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/content/Content.kt @@ -1,6 +1,9 @@ package com.insanusmokrassar.postssystem.core.content -import com.insanusmokrassar.postssystem.utils.common.* +import dev.inmo.micro_utils.common.ByteArrayAllocator +import dev.inmo.micro_utils.common.ByteArrayAllocatorSerializer +import dev.inmo.micro_utils.mime_types.KnownMimeTypes +import dev.inmo.micro_utils.mime_types.MimeType import kotlinx.serialization.Serializable typealias ContentId = String diff --git a/core/api/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/content/api/ReadContentRepo.kt b/core/api/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/content/api/ReadContentRepo.kt index cbca2611..24934542 100644 --- a/core/api/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/content/api/ReadContentRepo.kt +++ b/core/api/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/content/api/ReadContentRepo.kt @@ -2,8 +2,8 @@ package com.insanusmokrassar.postssystem.core.content.api import com.insanusmokrassar.postssystem.core.content.ContentId import com.insanusmokrassar.postssystem.core.content.RegisteredContent -import com.insanusmokrassar.postssystem.utils.common.pagination.Pagination -import com.insanusmokrassar.postssystem.utils.common.pagination.PaginationResult +import dev.inmo.micro_utils.pagination.Pagination +import dev.inmo.micro_utils.pagination.PaginationResult /** * Simple read API by different properties of [com.insanusmokrassar.postssystem.core.content.Content]. diff --git a/core/api/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/post/Post.kt b/core/api/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/post/Post.kt index 9a3291cf..3f9c16b8 100644 --- a/core/api/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/post/Post.kt +++ b/core/api/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/post/Post.kt @@ -1,7 +1,7 @@ package com.insanusmokrassar.postssystem.core.post +import com.insanusmokrassar.postssystem.core.UnixMillis import com.insanusmokrassar.postssystem.core.content.ContentId -import com.insanusmokrassar.postssystem.utils.common.UnixMillis import com.soywiz.klock.DateTime import kotlinx.serialization.Serializable import kotlinx.serialization.Transient diff --git a/core/api/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/post/repo/ReadPostsRepo.kt b/core/api/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/post/repo/ReadPostsRepo.kt index 4de11d6d..42e67a52 100644 --- a/core/api/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/post/repo/ReadPostsRepo.kt +++ b/core/api/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/post/repo/ReadPostsRepo.kt @@ -1,12 +1,12 @@ package com.insanusmokrassar.postssystem.core.post.repo +import com.insanusmokrassar.postssystem.core.MAX_DATE +import com.insanusmokrassar.postssystem.core.MIN_DATE import com.insanusmokrassar.postssystem.core.content.ContentId import com.insanusmokrassar.postssystem.core.post.PostId import com.insanusmokrassar.postssystem.core.post.RegisteredPost -import com.insanusmokrassar.postssystem.utils.common.MAX_DATE -import com.insanusmokrassar.postssystem.utils.common.MIN_DATE -import com.insanusmokrassar.postssystem.utils.common.pagination.* import com.soywiz.klock.DateTime +import dev.inmo.micro_utils.pagination.* /** * Simple read API by different properties diff --git a/core/exposed/build.gradle b/core/exposed/build.gradle index c9230616..d5b6c6a8 100644 --- a/core/exposed/build.gradle +++ b/core/exposed/build.gradle @@ -8,7 +8,6 @@ buildscript { dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" - classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version" } } @@ -33,14 +32,11 @@ repositories { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - if ((project.hasProperty('RELEASE_MODE') && project.property('RELEASE_MODE') == "true") || System.getenv('RELEASE_MODE') == "true") { - api "com.insanusmokrassar:postssystem.core.api:$core_version" - api "com.insanusmokrassar:postssystem.exposed.commons:$core_version" - } else { - api projectByName("core.api") - api projectByName("exposed.commons") - } + api "dev.inmo:micro_utils.repos.exposed:$microutils_version" + api project(":postssystem.core.api") + + testImplementation "org.jetbrains.exposed:exposed-jdbc:$exposed_version" testImplementation "org.xerial:sqlite-jdbc:$test_sqlite_version" testImplementation "org.jetbrains.kotlin:kotlin-test" testImplementation "org.jetbrains.kotlin:kotlin-test-junit" diff --git a/core/exposed/maven.publish.gradle b/core/exposed/maven.publish.gradle deleted file mode 100644 index 8156d06c..00000000 --- a/core/exposed/maven.publish.gradle +++ /dev/null @@ -1,56 +0,0 @@ -apply plugin: 'maven-publish' - -task sourcesJar(type: Jar) { - from sourceSets.main.allSource - classifier = 'sources' -} - -task javadocJar(type: Jar) { - from javadoc - classifier = 'javadoc' -} - -publishing { - publications { - maven(MavenPublication) { - from components.java - - artifact sourcesJar - artifact javadocJar - - pom.withXml { - asNode().children().last() + { - resolveStrategy = Closure.DELEGATE_FIRST - - description "Exposed realisation for PostsSystem Core" - name "PostsSystem Core Exposed realization" - url "https://git.insanusmokrassar.com/PostsSystem/Core/" - - scm { - developerConnection "scm:git:[fetch=]https://git.insanusmokrassar.com/PostsSystem/Core/.git[push=]https://git.insanusmokrassar.com/PostsSystem/Core/.git" - url "https://git.insanusmokrassar.com/PostsSystem/Core/.git" - } - - developers { - - developer { - id "InsanusMokrassar" - name "Ovsiannikov Aleksei" - email "ovsyannikov.alexey95@gmail.com" - } - - } - - licenses { - - license { - name "Apache Software License 2.0" - url "https://git.insanusmokrassar.com/PostsSystem/Core/src/master/LICENSE" - } - - } - } - } - } - } -} \ No newline at end of file diff --git a/core/exposed/publish.gradle b/core/exposed/publish.gradle index fba05c9c..433d3cc7 100644 --- a/core/exposed/publish.gradle +++ b/core/exposed/publish.gradle @@ -1,39 +1,66 @@ -apply plugin: 'com.jfrog.bintray' +apply plugin: 'maven-publish' -ext { - projectBintrayDir = "${project.group}/".replace(".", "/") + "${project.name}/${project.version}" +task sourcesJar(type: Jar) { + from sourceSets.main.allSource + classifier = 'sources' } -bintray { - user = project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER') - key = project.hasProperty('BINTRAY_KEY') ? project.property('BINTRAY_KEY') : System.getenv('BINTRAY_KEY') - publications = ["maven"] - filesSpec { - into "$projectBintrayDir" - from("build/libs") { - include "**/*.asc" - } - from("build/publications/maven") { - rename 'pom-default.xml(.*)', "${project.name}-${project.version}.pom\$1" - } - } - pkg { - repo = "InsanusMokrassar" - name = "${project.name}" - vcsUrl = "https://github.com/PostsSystem/PostsSystemCore" - licenses = ["Apache-2.0"] - version { - name = "${project.version}" - released = new Date() - vcsTag = "${project.version}" - gpg { - sign = true - passphrase = project.hasProperty('signing.gnupg.passphrase') ? project.property('signing.gnupg.passphrase') : System.getenv('signing.gnupg.passphrase') +task javadocJar(type: Jar) { + from javadoc + classifier = 'javadoc' +} + +publishing { + publications { + maven(MavenPublication) { + from components.java + + artifact sourcesJar + artifact javadocJar + + pom { + resolveStrategy = Closure.DELEGATE_FIRST + + description = "Exposed realisation for PostsSystem Core" + name = "PostsSystem Core Exposed realization" + url = "https://git.insanusmokrassar.com/PostsSystem/Core/" + + scm { + developerConnection = "scm:git:[fetch=]https://git.insanusmokrassar.com/PostsSystem/Core/.git[push=]https://git.insanusmokrassar.com/PostsSystem/Core/.git" + url = "https://git.insanusmokrassar.com/PostsSystem/Core/.git" + } + + developers { + + developer { + id = "InsanusMokrassar" + name = "Ovsiannikov Aleksei" + email = "ovsyannikov.alexey95@gmail.com" + } + + } + + licenses { + + license { + name = "Apache Software License 2.0" + url = "https://git.insanusmokrassar.com/PostsSystem/Core/src/master/LICENSE" + } + + } } + + repositories { + maven { + name = "bintray" + url = uri("https://api.bintray.com/maven/${project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER')}/InsanusMokrassar/${project.name}/;publish=0;override=0") + credentials { + username = project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER') + password = project.hasProperty('BINTRAY_KEY') ? project.property('BINTRAY_KEY') : System.getenv('BINTRAY_KEY') + } + } + } + } } -} - -apply from: "maven.publish.gradle" - -bintrayUpload.dependsOn publishToMavenLocal \ No newline at end of file +} \ No newline at end of file diff --git a/core/exposed/publish_config.json b/core/exposed/publish_config.kpsb similarity index 100% rename from core/exposed/publish_config.json rename to core/exposed/publish_config.kpsb diff --git a/core/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/core/exposed/ExposedContentRepo.kt b/core/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/core/exposed/ExposedContentRepo.kt index edb218ed..97165dd1 100644 --- a/core/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/core/exposed/ExposedContentRepo.kt +++ b/core/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/core/exposed/ExposedContentRepo.kt @@ -4,8 +4,7 @@ import com.insanusmokrassar.postssystem.core.content.* import com.insanusmokrassar.postssystem.core.content.api.ContentRepo import com.insanusmokrassar.postssystem.core.exposed.content.* import com.insanusmokrassar.postssystem.core.generateContentId -import com.insanusmokrassar.postssystem.exposed.commons.paginate -import com.insanusmokrassar.postssystem.utils.common.pagination.* +import dev.inmo.micro_utils.pagination.* import kotlinx.coroutines.channels.BroadcastChannel import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.flow.Flow diff --git a/core/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/core/exposed/ExposedPostsRepo.kt b/core/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/core/exposed/ExposedPostsRepo.kt index fdabe1d7..f81c4e63 100644 --- a/core/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/core/exposed/ExposedPostsRepo.kt +++ b/core/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/core/exposed/ExposedPostsRepo.kt @@ -4,9 +4,8 @@ import com.insanusmokrassar.postssystem.core.content.ContentId import com.insanusmokrassar.postssystem.core.generatePostId import com.insanusmokrassar.postssystem.core.post.* import com.insanusmokrassar.postssystem.core.post.repo.PostsRepo -import com.insanusmokrassar.postssystem.exposed.commons.paginate -import com.insanusmokrassar.postssystem.utils.common.pagination.* import com.soywiz.klock.* +import dev.inmo.micro_utils.pagination.* import kotlinx.coroutines.channels.BroadcastChannel import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.flow.Flow diff --git a/core/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/core/exposed/content/BinaryContentHolderRepo.kt b/core/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/core/exposed/content/BinaryContentHolderRepo.kt index b2435ab0..054cda22 100644 --- a/core/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/core/exposed/content/BinaryContentHolderRepo.kt +++ b/core/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/core/exposed/content/BinaryContentHolderRepo.kt @@ -2,7 +2,7 @@ package com.insanusmokrassar.postssystem.core.exposed.content import com.insanusmokrassar.postssystem.core.content.BinaryContent import com.insanusmokrassar.postssystem.core.content.ContentId -import com.insanusmokrassar.postssystem.utils.common.mimeType +import dev.inmo.micro_utils.mime_types.mimeType import org.jetbrains.exposed.sql.* import org.jetbrains.exposed.sql.statements.api.ExposedBlob import org.jetbrains.exposed.sql.transactions.transaction diff --git a/core/ktor/client/build.gradle b/core/ktor/client/build.gradle index 5b2cb82f..d8607229 100644 --- a/core/ktor/client/build.gradle +++ b/core/ktor/client/build.gradle @@ -8,7 +8,6 @@ buildscript { dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" - classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version" } } @@ -41,13 +40,10 @@ kotlin { dependencies { implementation kotlin('stdlib') - if ((project.hasProperty('RELEASE_MODE') && project.property('RELEASE_MODE') == "true") || System.getenv('RELEASE_MODE') == "true") { - api "com.insanusmokrassar:postssystem.core.ktor.common:$core_version" - api "com.insanusmokrassar:postssystem.ktor.client:$core_version" - } else { - api projectByName("core.ktor.common") - api projectByName("ktor.client") - } + api "dev.inmo:micro_utils.pagination.ktor.common:$microutils_version" + api "dev.inmo:micro_utils.ktor.client:$microutils_version" + + api project(":postssystem.core.ktor.common") } } commonTest { diff --git a/core/ktor/client/publish.gradle b/core/ktor/client/publish.gradle index e69de29b..4d4ad979 100644 --- a/core/ktor/client/publish.gradle +++ b/core/ktor/client/publish.gradle @@ -0,0 +1,69 @@ +apply plugin: 'maven-publish' + +task javadocsJar(type: Jar) { + classifier = 'javadoc' +} +task sourceJar (type : Jar) { + classifier = 'sources' +} + +afterEvaluate { + project.publishing.publications.all { + // rename artifacts + groupId "${project.group}" + if (it.name.contains('kotlinMultiplatform')) { + artifactId = "${project.name}" + artifact sourceJar + } else { + artifactId = "${project.name}-$name" + } + } +} + +publishing { + publications.all { + artifact javadocsJar + + pom { + description = "Exposed realisation for PostsSystem Core" + name = "PostsSystem Core Exposed realization" + url = "https://git.insanusmokrassar.com/PostsSystem/Core/" + + scm { + developerConnection = "scm:git:[fetch=]https://git.insanusmokrassar.com/PostsSystem/Core/.git[push=]https://git.insanusmokrassar.com/PostsSystem/Core/.git" + url = "https://git.insanusmokrassar.com/PostsSystem/Core/.git" + } + + developers { + + developer { + id = "InsanusMokrassar" + name = "Ovsiannikov Aleksei" + email = "ovsyannikov.alexey95@gmail.com" + } + + } + + licenses { + + license { + name = "Apache Software License 2.0" + url = "https://git.insanusmokrassar.com/PostsSystem/Core/src/master/LICENSE" + } + + } + } + + repositories { + maven { + name = "bintray" + url = uri("https://api.bintray.com/maven/${project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER')}/InsanusMokrassar/${project.name}/;publish=0;override=0") + credentials { + username = project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER') + password = project.hasProperty('BINTRAY_KEY') ? project.property('BINTRAY_KEY') : System.getenv('BINTRAY_KEY') + } + } + } + + } +} \ No newline at end of file diff --git a/core/ktor/client/publish_config.json b/core/ktor/client/publish_config.kpsb similarity index 97% rename from core/ktor/client/publish_config.json rename to core/ktor/client/publish_config.kpsb index 769ff599..7f60575f 100644 --- a/core/ktor/client/publish_config.json +++ b/core/ktor/client/publish_config.kpsb @@ -1 +1 @@ -{"bintrayConfig":{"repo":"InsanusMokrassar","packageName":"${project.name}","packageVcs":"https://github.com/PostsSystem/PostsSystemCore"},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://git.insanusmokrassar.com/PostsSystem/Core/src/master/LICENSE"}],"mavenConfig":{"name":"PostsSystem Core Exposed realization","description":"Exposed realisation for PostsSystem Core","url":"https://git.insanusmokrassar.com/PostsSystem/Core/","vcsUrl":"https://git.insanusmokrassar.com/PostsSystem/Core/.git","developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}]},"type":"JVM"} \ No newline at end of file +{"bintrayConfig":{"repo":"InsanusMokrassar","packageName":"${project.name}","packageVcs":"https://github.com/PostsSystem/PostsSystemCore"},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://git.insanusmokrassar.com/PostsSystem/Core/src/master/LICENSE"}],"mavenConfig":{"name":"PostsSystem Core Exposed realization","description":"Exposed realisation for PostsSystem Core","url":"https://git.insanusmokrassar.com/PostsSystem/Core/","vcsUrl":"https://git.insanusmokrassar.com/PostsSystem/Core/.git","developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}]}} \ No newline at end of file diff --git a/core/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/ktor/client/content/ReadContentRepoKtorClient.kt b/core/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/ktor/client/content/ReadContentRepoKtorClient.kt index ec0abcbe..e2a603b9 100644 --- a/core/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/ktor/client/content/ReadContentRepoKtorClient.kt +++ b/core/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/ktor/client/content/ReadContentRepoKtorClient.kt @@ -4,10 +4,10 @@ import com.insanusmokrassar.postssystem.core.content.ContentId import com.insanusmokrassar.postssystem.core.content.RegisteredContent import com.insanusmokrassar.postssystem.core.content.api.ReadContentRepo import com.insanusmokrassar.postssystem.core.ktor.* -import com.insanusmokrassar.postssystem.ktor.* -import com.insanusmokrassar.postssystem.ktor.client.uniget -import com.insanusmokrassar.postssystem.utils.common.pagination.Pagination -import com.insanusmokrassar.postssystem.utils.common.pagination.PaginationResult +import dev.inmo.micro_utils.ktor.client.uniget +import dev.inmo.micro_utils.ktor.common.includeQueryParams +import dev.inmo.micro_utils.ktor.common.standardKtorSerialFormat +import dev.inmo.micro_utils.pagination.* import io.ktor.client.HttpClient import io.ktor.client.request.get import kotlinx.serialization.builtins.nullable diff --git a/core/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/ktor/client/content/WriteContentRepoKtorClient.kt b/core/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/ktor/client/content/WriteContentRepoKtorClient.kt index 822a3996..a6516b58 100644 --- a/core/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/ktor/client/content/WriteContentRepoKtorClient.kt +++ b/core/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/ktor/client/content/WriteContentRepoKtorClient.kt @@ -3,7 +3,7 @@ package com.insanusmokrassar.postssystem.core.ktor.client.content import com.insanusmokrassar.postssystem.core.content.* import com.insanusmokrassar.postssystem.core.content.api.WriteContentRepo import com.insanusmokrassar.postssystem.core.ktor.* -import com.insanusmokrassar.postssystem.ktor.client.* +import dev.inmo.micro_utils.ktor.client.* import io.ktor.client.HttpClient import kotlinx.coroutines.flow.Flow import kotlinx.serialization.builtins.nullable diff --git a/core/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/ktor/client/post/ReadPostsRepoKtorClient.kt b/core/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/ktor/client/post/ReadPostsRepoKtorClient.kt index 5713d975..f7b3268b 100644 --- a/core/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/ktor/client/post/ReadPostsRepoKtorClient.kt +++ b/core/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/ktor/client/post/ReadPostsRepoKtorClient.kt @@ -5,11 +5,11 @@ import com.insanusmokrassar.postssystem.core.ktor.* import com.insanusmokrassar.postssystem.core.post.PostId import com.insanusmokrassar.postssystem.core.post.RegisteredPost import com.insanusmokrassar.postssystem.core.post.repo.ReadPostsRepo -import com.insanusmokrassar.postssystem.ktor.* -import com.insanusmokrassar.postssystem.ktor.client.uniget -import com.insanusmokrassar.postssystem.utils.common.pagination.Pagination -import com.insanusmokrassar.postssystem.utils.common.pagination.PaginationResult import com.soywiz.klock.DateTime +import dev.inmo.micro_utils.ktor.client.uniget +import dev.inmo.micro_utils.ktor.common.asFromToUrlPart +import dev.inmo.micro_utils.ktor.common.buildStandardUrl +import dev.inmo.micro_utils.pagination.* import io.ktor.client.HttpClient import kotlinx.serialization.builtins.nullable diff --git a/core/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/ktor/client/post/WritePostsRepoKtorClient.kt b/core/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/ktor/client/post/WritePostsRepoKtorClient.kt index d0ff656b..09401258 100644 --- a/core/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/ktor/client/post/WritePostsRepoKtorClient.kt +++ b/core/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/ktor/client/post/WritePostsRepoKtorClient.kt @@ -3,7 +3,7 @@ package com.insanusmokrassar.postssystem.core.ktor.client.post import com.insanusmokrassar.postssystem.core.ktor.* import com.insanusmokrassar.postssystem.core.post.* import com.insanusmokrassar.postssystem.core.post.repo.WritePostsRepo -import com.insanusmokrassar.postssystem.ktor.client.* +import dev.inmo.micro_utils.ktor.client.* import io.ktor.client.HttpClient import io.ktor.client.features.websocket.WebSockets import kotlinx.coroutines.flow.Flow diff --git a/core/ktor/common/build.gradle b/core/ktor/common/build.gradle index be8b77ca..664b3484 100644 --- a/core/ktor/common/build.gradle +++ b/core/ktor/common/build.gradle @@ -8,7 +8,6 @@ buildscript { dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" - classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version" } } @@ -41,13 +40,9 @@ kotlin { dependencies { implementation kotlin('stdlib') - if ((project.hasProperty('RELEASE_MODE') && project.property('RELEASE_MODE') == "true") || System.getenv('RELEASE_MODE') == "true") { - api "com.insanusmokrassar:postssystem.ktor.common:$core_version" - api "com.insanusmokrassar:postssystem.core.api:$core_version" - } else { - api projectByName("ktor.common") - api projectByName("core.api") - } + api "dev.inmo:micro_utils.ktor.common:$microutils_version" + + api project(":postssystem.core.api") } } commonTest { diff --git a/core/ktor/common/publish.gradle b/core/ktor/common/publish.gradle index e69de29b..4d4ad979 100644 --- a/core/ktor/common/publish.gradle +++ b/core/ktor/common/publish.gradle @@ -0,0 +1,69 @@ +apply plugin: 'maven-publish' + +task javadocsJar(type: Jar) { + classifier = 'javadoc' +} +task sourceJar (type : Jar) { + classifier = 'sources' +} + +afterEvaluate { + project.publishing.publications.all { + // rename artifacts + groupId "${project.group}" + if (it.name.contains('kotlinMultiplatform')) { + artifactId = "${project.name}" + artifact sourceJar + } else { + artifactId = "${project.name}-$name" + } + } +} + +publishing { + publications.all { + artifact javadocsJar + + pom { + description = "Exposed realisation for PostsSystem Core" + name = "PostsSystem Core Exposed realization" + url = "https://git.insanusmokrassar.com/PostsSystem/Core/" + + scm { + developerConnection = "scm:git:[fetch=]https://git.insanusmokrassar.com/PostsSystem/Core/.git[push=]https://git.insanusmokrassar.com/PostsSystem/Core/.git" + url = "https://git.insanusmokrassar.com/PostsSystem/Core/.git" + } + + developers { + + developer { + id = "InsanusMokrassar" + name = "Ovsiannikov Aleksei" + email = "ovsyannikov.alexey95@gmail.com" + } + + } + + licenses { + + license { + name = "Apache Software License 2.0" + url = "https://git.insanusmokrassar.com/PostsSystem/Core/src/master/LICENSE" + } + + } + } + + repositories { + maven { + name = "bintray" + url = uri("https://api.bintray.com/maven/${project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER')}/InsanusMokrassar/${project.name}/;publish=0;override=0") + credentials { + username = project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER') + password = project.hasProperty('BINTRAY_KEY') ? project.property('BINTRAY_KEY') : System.getenv('BINTRAY_KEY') + } + } + } + + } +} \ No newline at end of file diff --git a/core/ktor/common/publish_config.json b/core/ktor/common/publish_config.kpsb similarity index 97% rename from core/ktor/common/publish_config.json rename to core/ktor/common/publish_config.kpsb index 769ff599..7f60575f 100644 --- a/core/ktor/common/publish_config.json +++ b/core/ktor/common/publish_config.kpsb @@ -1 +1 @@ -{"bintrayConfig":{"repo":"InsanusMokrassar","packageName":"${project.name}","packageVcs":"https://github.com/PostsSystem/PostsSystemCore"},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://git.insanusmokrassar.com/PostsSystem/Core/src/master/LICENSE"}],"mavenConfig":{"name":"PostsSystem Core Exposed realization","description":"Exposed realisation for PostsSystem Core","url":"https://git.insanusmokrassar.com/PostsSystem/Core/","vcsUrl":"https://git.insanusmokrassar.com/PostsSystem/Core/.git","developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}]},"type":"JVM"} \ No newline at end of file +{"bintrayConfig":{"repo":"InsanusMokrassar","packageName":"${project.name}","packageVcs":"https://github.com/PostsSystem/PostsSystemCore"},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://git.insanusmokrassar.com/PostsSystem/Core/src/master/LICENSE"}],"mavenConfig":{"name":"PostsSystem Core Exposed realization","description":"Exposed realisation for PostsSystem Core","url":"https://git.insanusmokrassar.com/PostsSystem/Core/","vcsUrl":"https://git.insanusmokrassar.com/PostsSystem/Core/.git","developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}]}} \ No newline at end of file diff --git a/core/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/ktor/Serializers.kt b/core/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/ktor/Serializers.kt index ebe0c186..007dc9f8 100644 --- a/core/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/ktor/Serializers.kt +++ b/core/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/ktor/Serializers.kt @@ -1,13 +1,14 @@ package com.insanusmokrassar.postssystem.core.ktor +import com.insanusmokrassar.postssystem.core.content.ContentId import com.insanusmokrassar.postssystem.core.content.RegisteredContent +import com.insanusmokrassar.postssystem.core.post.PostId import com.insanusmokrassar.postssystem.core.post.RegisteredPost -import com.insanusmokrassar.postssystem.ktor.setIdsSerializer -import com.insanusmokrassar.postssystem.utils.common.pagination.PaginationResult -import kotlinx.serialization.builtins.ListSerializer +import dev.inmo.micro_utils.pagination.PaginationResult +import kotlinx.serialization.builtins.* -val contentIdsSerializer = setIdsSerializer -val postIdsSerializer = setIdsSerializer +val contentIdsSerializer = SetSerializer(ContentId.serializer()) +val postIdsSerializer = SetSerializer(PostId.serializer()) val registeredPostsListSerializer = ListSerializer(RegisteredPost.serializer()) val registeredPostsPaginationResultSerializer = PaginationResult.serializer(RegisteredPost.serializer()) val registeredContentPaginationResultSerializer = PaginationResult.serializer(RegisteredContent.serializer()) diff --git a/core/ktor/server/build.gradle b/core/ktor/server/build.gradle index d5deed77..cd2c4371 100644 --- a/core/ktor/server/build.gradle +++ b/core/ktor/server/build.gradle @@ -8,7 +8,6 @@ buildscript { dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" - classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version" } } @@ -32,8 +31,10 @@ repositories { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - api projectByName("core.ktor.common") - api projectByName("ktor.server") + api "dev.inmo:micro_utils.pagination.ktor.server:$microutils_version" + api "dev.inmo:micro_utils.ktor.server:$microutils_version" + + api project(":postssystem.core.ktor.common") testImplementation "org.xerial:sqlite-jdbc:$test_sqlite_version" testImplementation "org.jetbrains.kotlin:kotlin-test" diff --git a/core/ktor/server/src/main/kotlin/com/insanusmokrassar/postssystem/core/ktor/server/content/ContentRepoRoutingConfigurator.kt b/core/ktor/server/src/main/kotlin/com/insanusmokrassar/postssystem/core/ktor/server/content/ContentRepoRoutingConfigurator.kt index 833cb6c0..0e7e7409 100644 --- a/core/ktor/server/src/main/kotlin/com/insanusmokrassar/postssystem/core/ktor/server/content/ContentRepoRoutingConfigurator.kt +++ b/core/ktor/server/src/main/kotlin/com/insanusmokrassar/postssystem/core/ktor/server/content/ContentRepoRoutingConfigurator.kt @@ -2,7 +2,7 @@ package com.insanusmokrassar.postssystem.core.ktor.server.content import com.insanusmokrassar.postssystem.core.content.api.ContentRepo import com.insanusmokrassar.postssystem.core.ktor.contentRootRoute -import com.insanusmokrassar.postssystem.ktor.server.configurators.ApplicationRoutingConfigurator +import dev.inmo.micro_utils.ktor.server.configurators.ApplicationRoutingConfigurator import io.ktor.routing.Route import io.ktor.routing.route diff --git a/core/ktor/server/src/main/kotlin/com/insanusmokrassar/postssystem/core/ktor/server/content/ReadContentRepoRoutingConfigurator.kt b/core/ktor/server/src/main/kotlin/com/insanusmokrassar/postssystem/core/ktor/server/content/ReadContentRepoRoutingConfigurator.kt index b54c04b7..37585954 100644 --- a/core/ktor/server/src/main/kotlin/com/insanusmokrassar/postssystem/core/ktor/server/content/ReadContentRepoRoutingConfigurator.kt +++ b/core/ktor/server/src/main/kotlin/com/insanusmokrassar/postssystem/core/ktor/server/content/ReadContentRepoRoutingConfigurator.kt @@ -4,8 +4,10 @@ import com.insanusmokrassar.postssystem.core.content.ContentId import com.insanusmokrassar.postssystem.core.content.RegisteredContent import com.insanusmokrassar.postssystem.core.content.api.ReadContentRepo import com.insanusmokrassar.postssystem.core.ktor.* -import com.insanusmokrassar.postssystem.ktor.server.* -import com.insanusmokrassar.postssystem.ktor.server.configurators.ApplicationRoutingConfigurator +import dev.inmo.micro_utils.ktor.server.configurators.ApplicationRoutingConfigurator +import dev.inmo.micro_utils.ktor.server.getParameterOrSendError +import dev.inmo.micro_utils.ktor.server.unianswer +import dev.inmo.micro_utils.pagination.extractPagination import io.ktor.application.call import io.ktor.routing.Route import io.ktor.routing.get diff --git a/core/ktor/server/src/main/kotlin/com/insanusmokrassar/postssystem/core/ktor/server/content/WriteContentRepoRoutingConfigurator.kt b/core/ktor/server/src/main/kotlin/com/insanusmokrassar/postssystem/core/ktor/server/content/WriteContentRepoRoutingConfigurator.kt index 573f30a1..32412376 100644 --- a/core/ktor/server/src/main/kotlin/com/insanusmokrassar/postssystem/core/ktor/server/content/WriteContentRepoRoutingConfigurator.kt +++ b/core/ktor/server/src/main/kotlin/com/insanusmokrassar/postssystem/core/ktor/server/content/WriteContentRepoRoutingConfigurator.kt @@ -3,8 +3,8 @@ package com.insanusmokrassar.postssystem.core.ktor.server.content import com.insanusmokrassar.postssystem.core.content.* import com.insanusmokrassar.postssystem.core.content.api.WriteContentRepo import com.insanusmokrassar.postssystem.core.ktor.* -import com.insanusmokrassar.postssystem.ktor.server.* -import com.insanusmokrassar.postssystem.ktor.server.configurators.ApplicationRoutingConfigurator +import dev.inmo.micro_utils.ktor.server.* +import dev.inmo.micro_utils.ktor.server.configurators.ApplicationRoutingConfigurator import io.ktor.application.call import io.ktor.routing.Route import io.ktor.routing.post diff --git a/core/ktor/server/src/main/kotlin/com/insanusmokrassar/postssystem/core/ktor/server/post/PostsRepoRoutingConfigurator.kt b/core/ktor/server/src/main/kotlin/com/insanusmokrassar/postssystem/core/ktor/server/post/PostsRepoRoutingConfigurator.kt index beb217c8..8b238505 100644 --- a/core/ktor/server/src/main/kotlin/com/insanusmokrassar/postssystem/core/ktor/server/post/PostsRepoRoutingConfigurator.kt +++ b/core/ktor/server/src/main/kotlin/com/insanusmokrassar/postssystem/core/ktor/server/post/PostsRepoRoutingConfigurator.kt @@ -2,7 +2,7 @@ package com.insanusmokrassar.postssystem.core.ktor.server.post import com.insanusmokrassar.postssystem.core.ktor.postsRootRoute import com.insanusmokrassar.postssystem.core.post.repo.PostsRepo -import com.insanusmokrassar.postssystem.ktor.server.configurators.ApplicationRoutingConfigurator +import dev.inmo.micro_utils.ktor.server.configurators.ApplicationRoutingConfigurator import io.ktor.routing.Route import io.ktor.routing.route diff --git a/core/ktor/server/src/main/kotlin/com/insanusmokrassar/postssystem/core/ktor/server/post/ReadPostsRepoRoutingConfigurator.kt b/core/ktor/server/src/main/kotlin/com/insanusmokrassar/postssystem/core/ktor/server/post/ReadPostsRepoRoutingConfigurator.kt index e4c498d4..508c553c 100644 --- a/core/ktor/server/src/main/kotlin/com/insanusmokrassar/postssystem/core/ktor/server/post/ReadPostsRepoRoutingConfigurator.kt +++ b/core/ktor/server/src/main/kotlin/com/insanusmokrassar/postssystem/core/ktor/server/post/ReadPostsRepoRoutingConfigurator.kt @@ -1,14 +1,15 @@ package com.insanusmokrassar.postssystem.core.ktor.server.post +import com.insanusmokrassar.postssystem.core.MAX_DATE +import com.insanusmokrassar.postssystem.core.MIN_DATE import com.insanusmokrassar.postssystem.core.content.ContentId import com.insanusmokrassar.postssystem.core.ktor.* import com.insanusmokrassar.postssystem.core.post.PostId import com.insanusmokrassar.postssystem.core.post.RegisteredPost import com.insanusmokrassar.postssystem.core.post.repo.ReadPostsRepo -import com.insanusmokrassar.postssystem.ktor.server.* -import com.insanusmokrassar.postssystem.ktor.server.configurators.ApplicationRoutingConfigurator -import com.insanusmokrassar.postssystem.utils.common.MAX_DATE -import com.insanusmokrassar.postssystem.utils.common.MIN_DATE +import dev.inmo.micro_utils.ktor.server.* +import dev.inmo.micro_utils.ktor.server.configurators.ApplicationRoutingConfigurator +import dev.inmo.micro_utils.pagination.extractPagination import io.ktor.application.call import io.ktor.routing.Route import io.ktor.routing.get diff --git a/core/ktor/server/src/main/kotlin/com/insanusmokrassar/postssystem/core/ktor/server/post/WritePostsRepoRoutingConfigurator.kt b/core/ktor/server/src/main/kotlin/com/insanusmokrassar/postssystem/core/ktor/server/post/WritePostsRepoRoutingConfigurator.kt index 7aa0e333..97cf3975 100644 --- a/core/ktor/server/src/main/kotlin/com/insanusmokrassar/postssystem/core/ktor/server/post/WritePostsRepoRoutingConfigurator.kt +++ b/core/ktor/server/src/main/kotlin/com/insanusmokrassar/postssystem/core/ktor/server/post/WritePostsRepoRoutingConfigurator.kt @@ -3,8 +3,8 @@ package com.insanusmokrassar.postssystem.core.ktor.server.post import com.insanusmokrassar.postssystem.core.ktor.* import com.insanusmokrassar.postssystem.core.post.* import com.insanusmokrassar.postssystem.core.post.repo.WritePostsRepo -import com.insanusmokrassar.postssystem.ktor.server.* -import com.insanusmokrassar.postssystem.ktor.server.configurators.ApplicationRoutingConfigurator +import dev.inmo.micro_utils.ktor.server.* +import dev.inmo.micro_utils.ktor.server.configurators.ApplicationRoutingConfigurator import io.ktor.application.call import io.ktor.routing.Route import io.ktor.routing.post diff --git a/exposed/commons/build.gradle b/exposed/commons/build.gradle deleted file mode 100644 index 590e2fc4..00000000 --- a/exposed/commons/build.gradle +++ /dev/null @@ -1,46 +0,0 @@ -buildscript { - repositories { - mavenLocal() - jcenter() - mavenCentral() - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" - classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version" - } -} - -plugins { - id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version" -} - -project.version = "$core_version" -project.group = "com.insanusmokrassar" - -apply plugin: "java-library" -apply plugin: "kotlin" -apply from: "./publish.gradle" - -repositories { - mavenLocal() - jcenter() - mavenCentral() - maven { url "https://kotlin.bintray.com/kotlinx" } -} - -dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - api "org.jetbrains.exposed:exposed-core:$exposed_version" - api "org.jetbrains.exposed:exposed-jdbc:$exposed_version" - - if ((project.hasProperty('RELEASE_MODE') && project.property('RELEASE_MODE') == "true") || System.getenv('RELEASE_MODE') == "true") { - api "com.insanusmokrassar:postssystem.utils.repos:$core_version" - } else { - api projectByName("utils.repos.common") - } - - testImplementation "org.jetbrains.kotlin:kotlin-test" - testImplementation "org.jetbrains.kotlin:kotlin-test-junit" -} diff --git a/exposed/commons/gradle.properties b/exposed/commons/gradle.properties deleted file mode 100644 index e69de29b..00000000 diff --git a/exposed/commons/maven.publish.gradle b/exposed/commons/maven.publish.gradle deleted file mode 100644 index 50ee129b..00000000 --- a/exposed/commons/maven.publish.gradle +++ /dev/null @@ -1,53 +0,0 @@ -apply plugin: 'maven-publish' - -task javadocsJar(type: Jar) { - classifier = 'javadoc' -} - -afterEvaluate { - project.publishing.publications.all { - // rename artifacts - groupId "${project.group}" - if (it.name.contains('kotlinMultiplatform')) { - artifactId = "${project.name}" - } else { - artifactId = "${project.name}-$name" - } - } -} - -publishing { - publications.all { - artifact javadocsJar - - pom { - description = "Common utils for all exposed modules" - name = "PostsSystem Exposed commons" - url = "https://git.insanusmokrassar.com/PostsSystem/Core/" - - scm { - developerConnection = "scm:git:[fetch=]https://git.insanusmokrassar.com/PostsSystem/Core/.git[push=]https://git.insanusmokrassar.com/PostsSystem/Core/.git" - url = "https://git.insanusmokrassar.com/PostsSystem/Core/.git" - } - - developers { - - developer { - id = "InsanusMokrassar" - name = "Ovsiannikov Aleksei" - email = "ovsyannikov.alexey95@gmail.com" - } - - } - - licenses { - - license { - name = "Apache Software License 2.0" - url = "https://git.insanusmokrassar.com/PostsSystem/Core/src/master/LICENSE" - } - - } - } - } -} \ No newline at end of file diff --git a/exposed/commons/publish.gradle b/exposed/commons/publish.gradle deleted file mode 100644 index b8cf4528..00000000 --- a/exposed/commons/publish.gradle +++ /dev/null @@ -1,55 +0,0 @@ -apply plugin: 'com.jfrog.bintray' - -apply from: "maven.publish.gradle" - -bintray { - user = project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER') - key = project.hasProperty('BINTRAY_KEY') ? project.property('BINTRAY_KEY') : System.getenv('BINTRAY_KEY') - filesSpec { - from "${buildDir}/publications/" - eachFile { - String directorySubname = it.getFile().parentFile.name - if (it.getName() == "module.json") { - if (directorySubname == "kotlinMultiplatform") { - it.setPath("${project.name}/${project.version}/${project.name}-${project.version}.module") - } else { - it.setPath("${project.name}-${directorySubname}/${project.version}/${project.name}-${directorySubname}-${project.version}.module") - } - } else { - if (directorySubname == "kotlinMultiplatform" && it.getName() == "pom-default.xml") { - it.setPath("${project.name}/${project.version}/${project.name}-${project.version}.pom") - } else { - it.exclude() - } - } - } - into "${project.group}".replace(".", "/") - } - pkg { - repo = "InsanusMokrassar" - name = "${project.name}" - vcsUrl = "https://github.com/PostsSystem/PostsSystemCore" - licenses = ["Apache-2.0"] - version { - name = "${project.version}" - released = new Date() - vcsTag = "${project.version}" - gpg { - sign = true - passphrase = project.hasProperty('signing.gnupg.passphrase') ? project.property('signing.gnupg.passphrase') : System.getenv('signing.gnupg.passphrase') - } - } - } -} - -bintrayUpload.doFirst { - publications = publishing.publications.collect { - if (it.name.contains('kotlinMultiplatform')) { - null - } else { - it.name - } - } - null -} - -bintrayUpload.dependsOn publishToMavenLocal \ No newline at end of file diff --git a/exposed/commons/publish_config.kpsb b/exposed/commons/publish_config.kpsb deleted file mode 100644 index 2bd43e2b..00000000 --- a/exposed/commons/publish_config.kpsb +++ /dev/null @@ -1 +0,0 @@ -{"bintrayConfig":{"repo":"InsanusMokrassar","packageName":"${project.name}","packageVcs":"https://github.com/PostsSystem/PostsSystemCore"},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://git.insanusmokrassar.com/PostsSystem/Core/src/master/LICENSE"}],"mavenConfig":{"name":"PostsSystem Exposed commons","description":"Common utils for all exposed modules","url":"https://git.insanusmokrassar.com/PostsSystem/Core/","vcsUrl":"https://git.insanusmokrassar.com/PostsSystem/Core/.git","developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}]},"type":"Multiplatform"} \ No newline at end of file diff --git a/exposed/commons/src/main/kotlin/com/insanusmokrassar/postssystem/exposed/commons/QueryExtensions.kt b/exposed/commons/src/main/kotlin/com/insanusmokrassar/postssystem/exposed/commons/QueryExtensions.kt deleted file mode 100644 index 6b0165c7..00000000 --- a/exposed/commons/src/main/kotlin/com/insanusmokrassar/postssystem/exposed/commons/QueryExtensions.kt +++ /dev/null @@ -1,27 +0,0 @@ -package com.insanusmokrassar.postssystem.exposed.commons - -import com.insanusmokrassar.postssystem.utils.common.pagination.* -import org.jetbrains.exposed.sql.* - -fun Query.paginate(with: Pagination, orderBy: Pair, SortOrder>? = null) = limit( - with.size, - (if (orderBy ?.second == SortOrder.DESC) { - with.lastIndex - } else { - with.firstIndex - }).toLong() -).let { - if (orderBy != null) { - it.orderBy( - orderBy.first, - orderBy.second - ) - } else { - it - } -} - -fun Query.paginate(with: Pagination, orderBy: Expression<*>?, reversed: Boolean = false) = paginate( - with, - orderBy ?.let { it to if (reversed) SortOrder.DESC else SortOrder.ASC } -) diff --git a/gradle.properties b/gradle.properties index 4a04ab1d..54793dbd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,19 +1,19 @@ kotlin.code.style=official org.gradle.parallel=true -kotlin_version=1.4.10 -kotlin_coroutines_version=1.3.9 -kotlin_serialisation_core_version=1.0.0-RC2 +kotlin_version=1.4.20 +kotlin_coroutines_version=1.4.1 +kotlin_serialisation_core_version=1.0.1 -ktor_version=1.4.1 +ktor_version=1.4.2 -klockVersion=1.12.1 -uuidVersion=0.2.2 +klockVersion=2.0.0 +uuidVersion=0.2.3 -exposed_version=0.27.1 +exposed_version=0.28.1 test_sqlite_version=3.32.3.2 +microutils_version=0.4.5 + javax_activation_version=1.1.1 -gradle_bintray_plugin_version=1.8.5 - -core_version=0.5.0 +core_version=0.6.0 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 727d0a77..51b41a81 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,4 +1,4 @@ -distributionUrl=https\://services.gradle.org/distributions/gradle-6.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStorePath=wrapper/dists diff --git a/ktor/client/build.gradle b/ktor/client/build.gradle deleted file mode 100644 index d7030639..00000000 --- a/ktor/client/build.gradle +++ /dev/null @@ -1,89 +0,0 @@ -buildscript { - repositories { - mavenLocal() - jcenter() - mavenCentral() - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" - classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version" - } -} - -plugins { - id "org.jetbrains.kotlin.multiplatform" version "$kotlin_version" - id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version" -} - -project.version = "$core_version" -project.group = "com.insanusmokrassar" - -apply from: "publish.gradle" - -repositories { - mavenLocal() - jcenter() - mavenCentral() - maven { url "https://kotlin.bintray.com/kotlinx" } -} - -kotlin { - jvm() - js (BOTH) { - browser() - nodejs() - } - - sourceSets { - commonMain { - dependencies { - implementation kotlin('stdlib') - - if ((project.hasProperty('RELEASE_MODE') && project.property('RELEASE_MODE') == "true") || System.getenv('RELEASE_MODE') == "true") { - api "com.insanusmokrassar:postssystem.ktor.common:$core_version" - } else { - api projectByName("ktor.common") - } - - api "io.ktor:ktor-client-core:$ktor_version" - api "io.ktor:ktor-client-websockets:$ktor_version" - } - } - commonTest { - dependencies { - implementation kotlin('test-common') - implementation kotlin('test-annotations-common') - } - } - jvmMain { - dependencies { - implementation kotlin('stdlib-jdk8') - - api "io.ktor:ktor-client:$ktor_version" - api "io.ktor:ktor-client-websockets-jvm:$ktor_version" - api "io.ktor:ktor-client-okhttp:$ktor_version" - } - } - jvmTest { - dependencies { - implementation kotlin('test-junit') - } - } - jsMain { - dependencies { - implementation kotlin('stdlib-js') - - api "io.ktor:ktor-client-js:$ktor_version" - api "io.ktor:ktor-client-websockets-js:$ktor_version" - } - } - jsTest { - dependencies { - implementation kotlin('test-js') - implementation kotlin('test-junit') - } - } - } -} diff --git a/ktor/client/maven.publish.gradle b/ktor/client/maven.publish.gradle deleted file mode 100644 index 50ee129b..00000000 --- a/ktor/client/maven.publish.gradle +++ /dev/null @@ -1,53 +0,0 @@ -apply plugin: 'maven-publish' - -task javadocsJar(type: Jar) { - classifier = 'javadoc' -} - -afterEvaluate { - project.publishing.publications.all { - // rename artifacts - groupId "${project.group}" - if (it.name.contains('kotlinMultiplatform')) { - artifactId = "${project.name}" - } else { - artifactId = "${project.name}-$name" - } - } -} - -publishing { - publications.all { - artifact javadocsJar - - pom { - description = "Common utils for all exposed modules" - name = "PostsSystem Exposed commons" - url = "https://git.insanusmokrassar.com/PostsSystem/Core/" - - scm { - developerConnection = "scm:git:[fetch=]https://git.insanusmokrassar.com/PostsSystem/Core/.git[push=]https://git.insanusmokrassar.com/PostsSystem/Core/.git" - url = "https://git.insanusmokrassar.com/PostsSystem/Core/.git" - } - - developers { - - developer { - id = "InsanusMokrassar" - name = "Ovsiannikov Aleksei" - email = "ovsyannikov.alexey95@gmail.com" - } - - } - - licenses { - - license { - name = "Apache Software License 2.0" - url = "https://git.insanusmokrassar.com/PostsSystem/Core/src/master/LICENSE" - } - - } - } - } -} \ No newline at end of file diff --git a/ktor/client/publish.gradle b/ktor/client/publish.gradle deleted file mode 100644 index b8cf4528..00000000 --- a/ktor/client/publish.gradle +++ /dev/null @@ -1,55 +0,0 @@ -apply plugin: 'com.jfrog.bintray' - -apply from: "maven.publish.gradle" - -bintray { - user = project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER') - key = project.hasProperty('BINTRAY_KEY') ? project.property('BINTRAY_KEY') : System.getenv('BINTRAY_KEY') - filesSpec { - from "${buildDir}/publications/" - eachFile { - String directorySubname = it.getFile().parentFile.name - if (it.getName() == "module.json") { - if (directorySubname == "kotlinMultiplatform") { - it.setPath("${project.name}/${project.version}/${project.name}-${project.version}.module") - } else { - it.setPath("${project.name}-${directorySubname}/${project.version}/${project.name}-${directorySubname}-${project.version}.module") - } - } else { - if (directorySubname == "kotlinMultiplatform" && it.getName() == "pom-default.xml") { - it.setPath("${project.name}/${project.version}/${project.name}-${project.version}.pom") - } else { - it.exclude() - } - } - } - into "${project.group}".replace(".", "/") - } - pkg { - repo = "InsanusMokrassar" - name = "${project.name}" - vcsUrl = "https://github.com/PostsSystem/PostsSystemCore" - licenses = ["Apache-2.0"] - version { - name = "${project.version}" - released = new Date() - vcsTag = "${project.version}" - gpg { - sign = true - passphrase = project.hasProperty('signing.gnupg.passphrase') ? project.property('signing.gnupg.passphrase') : System.getenv('signing.gnupg.passphrase') - } - } - } -} - -bintrayUpload.doFirst { - publications = publishing.publications.collect { - if (it.name.contains('kotlinMultiplatform')) { - null - } else { - it.name - } - } - null -} - -bintrayUpload.dependsOn publishToMavenLocal \ No newline at end of file diff --git a/ktor/client/publish_config.kpsb b/ktor/client/publish_config.kpsb deleted file mode 100644 index 2bd43e2b..00000000 --- a/ktor/client/publish_config.kpsb +++ /dev/null @@ -1 +0,0 @@ -{"bintrayConfig":{"repo":"InsanusMokrassar","packageName":"${project.name}","packageVcs":"https://github.com/PostsSystem/PostsSystemCore"},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://git.insanusmokrassar.com/PostsSystem/Core/src/master/LICENSE"}],"mavenConfig":{"name":"PostsSystem Exposed commons","description":"Common utils for all exposed modules","url":"https://git.insanusmokrassar.com/PostsSystem/Core/","vcsUrl":"https://git.insanusmokrassar.com/PostsSystem/Core/.git","developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}]},"type":"Multiplatform"} \ No newline at end of file diff --git a/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/ktor/client/FlowsWebsockets.kt b/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/ktor/client/FlowsWebsockets.kt deleted file mode 100644 index 0ae3e0c7..00000000 --- a/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/ktor/client/FlowsWebsockets.kt +++ /dev/null @@ -1,83 +0,0 @@ -package com.insanusmokrassar.postssystem.ktor.client - -import com.insanusmokrassar.postssystem.ktor.asCorrectWebSocketUrl -import com.insanusmokrassar.postssystem.ktor.standardKtorSerialFormat -import com.insanusmokrassar.postssystem.utils.common.safely -import io.ktor.client.HttpClient -import io.ktor.client.features.websocket.ws -import io.ktor.http.cio.websocket.Frame -import io.ktor.http.cio.websocket.readBytes -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.channelFlow -import kotlinx.serialization.DeserializationStrategy - -/** - * @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 - */ -inline fun HttpClient.createStandardWebsocketFlow( - url: String, - crossinline checkReconnection: (Throwable?) -> Boolean = { true }, - crossinline conversation: suspend (ByteArray) -> T -): Flow { - val correctedUrl = url.asCorrectWebSocketUrl - - return channelFlow { - val producerScope = this@channelFlow - do { - val reconnect = try { - safely( - { - throw it - } - ) { - ws( - correctedUrl - ) { - while (true) { - when (val received = incoming.receive()) { - is Frame.Binary -> producerScope.send( - conversation(received.readBytes()) - ) - else -> { - producerScope.close() - return@ws - } - } - } - } - } - checkReconnection(null) - } catch (e: Throwable) { - checkReconnection(e).also { - if (!it) { - producerScope.close(e) - } - } - } - } while (reconnect) - if (!producerScope.isClosedForSend) { - safely( - { /* do nothing */ } - ) { - producerScope.close() - } - } - } -} - -/** - * @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 - */ -inline fun HttpClient.createStandardWebsocketFlow( - url: String, - crossinline checkReconnection: (Throwable?) -> Boolean = { true }, - deserializer: DeserializationStrategy -) = createStandardWebsocketFlow( - url, - checkReconnection -) { - standardKtorSerialFormat.decodeFromByteArray(deserializer, it) -} - diff --git a/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/ktor/client/StandardHttpClientGetPost.kt b/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/ktor/client/StandardHttpClientGetPost.kt deleted file mode 100644 index 2fbb2133..00000000 --- a/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/ktor/client/StandardHttpClientGetPost.kt +++ /dev/null @@ -1,33 +0,0 @@ -package com.insanusmokrassar.postssystem.ktor.client - -import com.insanusmokrassar.postssystem.ktor.standardKtorSerialFormat -import io.ktor.client.HttpClient -import io.ktor.client.request.get -import io.ktor.client.request.post -import kotlinx.serialization.* - -typealias BodyPair = Pair, T> - -suspend fun HttpClient.uniget( - url: String, - resultDeserializer: DeserializationStrategy -) = get( - url -).let { - standardKtorSerialFormat.decodeFromByteArray(resultDeserializer, it) -} - -fun SerializationStrategy.encodeUrlQueryValue(value: T) = standardKtorSerialFormat.encodeToHexString( - this, - value -) - -suspend fun HttpClient.unipost( - url: String, - bodyInfo: BodyPair, - resultDeserializer: DeserializationStrategy -) = post(url) { - body = standardKtorSerialFormat.encodeToByteArray(bodyInfo.first, bodyInfo.second) -}.let { - standardKtorSerialFormat.decodeFromByteArray(resultDeserializer, it) -} diff --git a/ktor/common/build.gradle b/ktor/common/build.gradle deleted file mode 100644 index 08e1c71f..00000000 --- a/ktor/common/build.gradle +++ /dev/null @@ -1,79 +0,0 @@ -buildscript { - repositories { - mavenLocal() - jcenter() - mavenCentral() - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" - classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version" - } -} - -plugins { - id "org.jetbrains.kotlin.multiplatform" version "$kotlin_version" - id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version" -} - -project.version = "$core_version" -project.group = "com.insanusmokrassar" - -apply from: "publish.gradle" - -repositories { - mavenLocal() - jcenter() - mavenCentral() - maven { url "https://kotlin.bintray.com/kotlinx" } -} - -kotlin { - jvm() - js (BOTH) { - browser() - nodejs() - } - - sourceSets { - commonMain { - dependencies { - implementation kotlin('stdlib') - api "org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlin_serialisation_core_version" - api "org.jetbrains.kotlinx:kotlinx-serialization-cbor:$kotlin_serialisation_core_version" - - api projectByName("utils.common") - } - } - commonTest { - dependencies { - implementation kotlin('test-common') - implementation kotlin('test-annotations-common') - } - } - jvmMain { - dependencies { - implementation kotlin('stdlib-jdk8') -// api "org.jetbrains.kotlinx:kotlinx-serialization-cbor:$kotlin_serialisation_core_version" - } - } - jvmTest { - dependencies { - implementation kotlin('test-junit') - } - } - jsMain { - dependencies { - implementation kotlin('stdlib-js') -// api "org.jetbrains.kotlinx:kotlinx-serialization-cbor-js:$kotlin_serialisation_core_version" - } - } - jsTest { - dependencies { - implementation kotlin('test-js') - implementation kotlin('test-junit') - } - } - } -} diff --git a/ktor/common/publish.gradle b/ktor/common/publish.gradle deleted file mode 100644 index e69de29b..00000000 diff --git a/ktor/common/publish_config.kpsb b/ktor/common/publish_config.kpsb deleted file mode 100644 index 2bd43e2b..00000000 --- a/ktor/common/publish_config.kpsb +++ /dev/null @@ -1 +0,0 @@ -{"bintrayConfig":{"repo":"InsanusMokrassar","packageName":"${project.name}","packageVcs":"https://github.com/PostsSystem/PostsSystemCore"},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://git.insanusmokrassar.com/PostsSystem/Core/src/master/LICENSE"}],"mavenConfig":{"name":"PostsSystem Exposed commons","description":"Common utils for all exposed modules","url":"https://git.insanusmokrassar.com/PostsSystem/Core/","vcsUrl":"https://git.insanusmokrassar.com/PostsSystem/Core/.git","developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}]},"type":"Multiplatform"} \ No newline at end of file diff --git a/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/ktor/BuildStandardUrl.kt b/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/ktor/BuildStandardUrl.kt deleted file mode 100644 index 22be8bcc..00000000 --- a/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/ktor/BuildStandardUrl.kt +++ /dev/null @@ -1,23 +0,0 @@ -package com.insanusmokrassar.postssystem.ktor - -fun buildStandardUrl( - basePart: String, - subpart: String, - parameters: QueryParams = emptyMap() -) = "$basePart/$subpart".includeQueryParams( - parameters -) - -fun buildStandardUrl( - basePart: String, - subpart: String, - parameters: List -) = "$basePart/$subpart".includeQueryParams( - parameters -) - -fun buildStandardUrl( - basePart: String, - subpart: String, - vararg parameters: QueryParam -) = buildStandardUrl(basePart, subpart, parameters.toList()) diff --git a/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/ktor/CollectionsSerializers.kt b/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/ktor/CollectionsSerializers.kt deleted file mode 100644 index 0f0a6135..00000000 --- a/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/ktor/CollectionsSerializers.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.insanusmokrassar.postssystem.ktor - -import kotlinx.serialization.builtins.SetSerializer -import kotlinx.serialization.builtins.serializer - -val setIdsSerializer = SetSerializer(String.serializer()) diff --git a/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/ktor/CorrectCloseException.kt b/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/ktor/CorrectCloseException.kt deleted file mode 100644 index 7e3077cd..00000000 --- a/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/ktor/CorrectCloseException.kt +++ /dev/null @@ -1,3 +0,0 @@ -package com.insanusmokrassar.postssystem.ktor - -object CorrectCloseException : Exception() diff --git a/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/ktor/CorrectWebsocketUrl.kt b/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/ktor/CorrectWebsocketUrl.kt deleted file mode 100644 index 336d7b30..00000000 --- a/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/ktor/CorrectWebsocketUrl.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.insanusmokrassar.postssystem.ktor - -private val schemaRegex = Regex("[^:]*//") - -val String.asCorrectWebSocketUrl: String - get() = if (startsWith("ws")) { - this - } else { - if (contains("://")) { - replace(schemaRegex, "ws://") - } else { - "ws://$this" - } - } diff --git a/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/ktor/FromToDateTimeUrl.kt b/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/ktor/FromToDateTimeUrl.kt deleted file mode 100644 index 1a5d100a..00000000 --- a/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/ktor/FromToDateTimeUrl.kt +++ /dev/null @@ -1,17 +0,0 @@ -package com.insanusmokrassar.postssystem.ktor - -import com.soywiz.klock.DateTime - -typealias FromToDateTime = Pair - -val FromToDateTime.asFromToUrlPart: QueryParams - get() = mapOf( - "from" to first ?.unixMillis ?.toString(), - "to" to second ?.unixMillis ?.toString() - ) - -val QueryParams.extractFromToDateTime: FromToDateTime - get() = FromToDateTime( - get("from") ?.toDoubleOrNull() ?.let { DateTime(it) }, - get("to") ?.toDoubleOrNull() ?.let { DateTime(it) } - ) diff --git a/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/ktor/PaginationInUrl.kt b/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/ktor/PaginationInUrl.kt deleted file mode 100644 index 60cb0244..00000000 --- a/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/ktor/PaginationInUrl.kt +++ /dev/null @@ -1,25 +0,0 @@ -package com.insanusmokrassar.postssystem.ktor - -import com.insanusmokrassar.postssystem.utils.common.pagination.* - -private val numberRegex = Regex("[\\d]{1,10}") -private val pageRegex = Regex("page=${numberRegex.pattern}") -private val sizeRegex = Regex("size=${numberRegex.pattern}") - -val Pagination.asUrlQueryParts - get() = mapOf( - "page" to page.toString(), - "size" to size.toString() - ) - -val Pagination.asUrlQueryArrayParts - get() = arrayOf( - "page" to page.toString(), - "size" to size.toString() - ) - -val Map.extractPagination: Pagination - get() = SimplePagination( - get("page") ?.toIntOrNull() ?: 0, - get("size") ?.toIntOrNull() ?: defaultMediumPageSize - ) diff --git a/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/ktor/QueryParamsBuilder.kt b/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/ktor/QueryParamsBuilder.kt deleted file mode 100644 index 1d50ef62..00000000 --- a/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/ktor/QueryParamsBuilder.kt +++ /dev/null @@ -1,25 +0,0 @@ -package com.insanusmokrassar.postssystem.ktor - -typealias QueryParam = Pair -typealias QueryParams = Map - -val QueryParams.asUrlQuery: String - get() = keys.joinToString("&") { "${it}${get(it) ?.let { value -> "=$value" }}" } - -val List.asUrlQuery: String - get() = joinToString("&") { (key, value) -> "${key}${value ?.let { _ -> "=$value" }}" } - -fun String.includeQueryParams( - queryParams: QueryParams -): String = "$this${if (contains("?")) "&" else "?"}${queryParams.asUrlQuery}" - -fun String.includeQueryParams( - queryParams: List -): String = "$this${if (contains("?")) "&" else "?"}${queryParams.asUrlQuery}" - -val String.parseUrlQuery: QueryParams - get() = split("&").map { - it.split("=").let { pair -> - pair.first() to pair.getOrNull(1) - } - }.toMap() diff --git a/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/ktor/StandardSerializer.kt b/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/ktor/StandardSerializer.kt deleted file mode 100644 index e9dfd7d1..00000000 --- a/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/ktor/StandardSerializer.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.insanusmokrassar.postssystem.ktor - -import kotlinx.serialization.cbor.Cbor - -val standardKtorSerialFormat = Cbor diff --git a/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/ktor/WebSockets.kt b/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/ktor/WebSockets.kt deleted file mode 100644 index fc6f6446..00000000 --- a/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/ktor/WebSockets.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.insanusmokrassar.postssystem.ktor - -const val clientWebsocketHelloMessage = "Start getting of updates" -const val serverWebsocketHelloMessage = "Accepted" - -const val serverWebsocketNewMessageMessage = "NewMessage" -const val websocketFinalizationMessage = "Final" diff --git a/ktor/server/build.gradle b/ktor/server/build.gradle deleted file mode 100644 index b2750e11..00000000 --- a/ktor/server/build.gradle +++ /dev/null @@ -1,65 +0,0 @@ -buildscript { - repositories { - mavenLocal() - jcenter() - mavenCentral() - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" - classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version" - } -} - -plugins { - id "org.jetbrains.kotlin.multiplatform" version "$kotlin_version" - id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version" -} - -project.version = "$core_version" -project.group = "com.insanusmokrassar" - -apply from: "publish.gradle" - -repositories { - mavenLocal() - jcenter() - mavenCentral() - maven { url "https://kotlin.bintray.com/kotlinx" } -} - -kotlin { - jvm() - - sourceSets { - commonMain { - dependencies { - implementation kotlin('stdlib') - api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version" - - api projectByName("ktor.common") - } - } - commonTest { - dependencies { - implementation kotlin('test-common') - implementation kotlin('test-annotations-common') - } - } - - jvmMain { - dependencies { - api "io.ktor:ktor-server:$ktor_version" - api "io.ktor:ktor-server-host-common:$ktor_version" - api "io.ktor:ktor-server-netty:$ktor_version" - api "io.ktor:ktor-websockets:$ktor_version" - } - } - jvmTest { - dependencies { - implementation kotlin('test-junit') - } - } - } -} diff --git a/ktor/server/maven.publish.gradle b/ktor/server/maven.publish.gradle deleted file mode 100644 index 50ee129b..00000000 --- a/ktor/server/maven.publish.gradle +++ /dev/null @@ -1,53 +0,0 @@ -apply plugin: 'maven-publish' - -task javadocsJar(type: Jar) { - classifier = 'javadoc' -} - -afterEvaluate { - project.publishing.publications.all { - // rename artifacts - groupId "${project.group}" - if (it.name.contains('kotlinMultiplatform')) { - artifactId = "${project.name}" - } else { - artifactId = "${project.name}-$name" - } - } -} - -publishing { - publications.all { - artifact javadocsJar - - pom { - description = "Common utils for all exposed modules" - name = "PostsSystem Exposed commons" - url = "https://git.insanusmokrassar.com/PostsSystem/Core/" - - scm { - developerConnection = "scm:git:[fetch=]https://git.insanusmokrassar.com/PostsSystem/Core/.git[push=]https://git.insanusmokrassar.com/PostsSystem/Core/.git" - url = "https://git.insanusmokrassar.com/PostsSystem/Core/.git" - } - - developers { - - developer { - id = "InsanusMokrassar" - name = "Ovsiannikov Aleksei" - email = "ovsyannikov.alexey95@gmail.com" - } - - } - - licenses { - - license { - name = "Apache Software License 2.0" - url = "https://git.insanusmokrassar.com/PostsSystem/Core/src/master/LICENSE" - } - - } - } - } -} \ No newline at end of file diff --git a/ktor/server/publish.gradle b/ktor/server/publish.gradle deleted file mode 100644 index b8cf4528..00000000 --- a/ktor/server/publish.gradle +++ /dev/null @@ -1,55 +0,0 @@ -apply plugin: 'com.jfrog.bintray' - -apply from: "maven.publish.gradle" - -bintray { - user = project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER') - key = project.hasProperty('BINTRAY_KEY') ? project.property('BINTRAY_KEY') : System.getenv('BINTRAY_KEY') - filesSpec { - from "${buildDir}/publications/" - eachFile { - String directorySubname = it.getFile().parentFile.name - if (it.getName() == "module.json") { - if (directorySubname == "kotlinMultiplatform") { - it.setPath("${project.name}/${project.version}/${project.name}-${project.version}.module") - } else { - it.setPath("${project.name}-${directorySubname}/${project.version}/${project.name}-${directorySubname}-${project.version}.module") - } - } else { - if (directorySubname == "kotlinMultiplatform" && it.getName() == "pom-default.xml") { - it.setPath("${project.name}/${project.version}/${project.name}-${project.version}.pom") - } else { - it.exclude() - } - } - } - into "${project.group}".replace(".", "/") - } - pkg { - repo = "InsanusMokrassar" - name = "${project.name}" - vcsUrl = "https://github.com/PostsSystem/PostsSystemCore" - licenses = ["Apache-2.0"] - version { - name = "${project.version}" - released = new Date() - vcsTag = "${project.version}" - gpg { - sign = true - passphrase = project.hasProperty('signing.gnupg.passphrase') ? project.property('signing.gnupg.passphrase') : System.getenv('signing.gnupg.passphrase') - } - } - } -} - -bintrayUpload.doFirst { - publications = publishing.publications.collect { - if (it.name.contains('kotlinMultiplatform')) { - null - } else { - it.name - } - } - null -} - -bintrayUpload.dependsOn publishToMavenLocal \ No newline at end of file diff --git a/ktor/server/publish_config.kpsb b/ktor/server/publish_config.kpsb deleted file mode 100644 index 2bd43e2b..00000000 --- a/ktor/server/publish_config.kpsb +++ /dev/null @@ -1 +0,0 @@ -{"bintrayConfig":{"repo":"InsanusMokrassar","packageName":"${project.name}","packageVcs":"https://github.com/PostsSystem/PostsSystemCore"},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://git.insanusmokrassar.com/PostsSystem/Core/src/master/LICENSE"}],"mavenConfig":{"name":"PostsSystem Exposed commons","description":"Common utils for all exposed modules","url":"https://git.insanusmokrassar.com/PostsSystem/Core/","vcsUrl":"https://git.insanusmokrassar.com/PostsSystem/Core/.git","developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}]},"type":"Multiplatform"} \ No newline at end of file diff --git a/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/ktor/server/FlowsWebsocket.kt b/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/ktor/server/FlowsWebsocket.kt deleted file mode 100644 index a1d9c7f9..00000000 --- a/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/ktor/server/FlowsWebsocket.kt +++ /dev/null @@ -1,44 +0,0 @@ -package com.insanusmokrassar.postssystem.ktor.server - -import com.insanusmokrassar.postssystem.ktor.CorrectCloseException -import com.insanusmokrassar.postssystem.ktor.standardKtorSerialFormat -import com.insanusmokrassar.postssystem.utils.common.safely -import io.ktor.http.cio.websocket.* -import io.ktor.routing.Route -import io.ktor.websocket.webSocket -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 Route.includeWebsocketHandling( - suburl: String, - flow: Flow, - converter: (T) -> ByteArray -) { - webSocket(suburl) { - safely { - flow.collect { - checkReceivedAndCloseIfExists() - send(converter(it)) - } - } - } -} - -fun Route.includeWebsocketHandling( - suburl: String, - flow: Flow, - serializer: SerializationStrategy -) = includeWebsocketHandling( - suburl, - flow -) { - standardKtorSerialFormat.encodeToByteArray(serializer, it) -} diff --git a/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/ktor/server/FromToDateTimeInUrl.kt b/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/ktor/server/FromToDateTimeInUrl.kt deleted file mode 100644 index d35a4a96..00000000 --- a/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/ktor/server/FromToDateTimeInUrl.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.insanusmokrassar.postssystem.ktor.server - -import com.insanusmokrassar.postssystem.ktor.FromToDateTime -import com.soywiz.klock.DateTime -import io.ktor.http.Parameters - -val Parameters.extractFromToDateTime: FromToDateTime - get() = FromToDateTime( - get("from") ?.toDoubleOrNull() ?.let { DateTime(it) }, - get("to") ?.toDoubleOrNull() ?.let { DateTime(it) } - ) diff --git a/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/ktor/server/PaginationInUrl.kt b/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/ktor/server/PaginationInUrl.kt deleted file mode 100644 index b30b5691..00000000 --- a/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/ktor/server/PaginationInUrl.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.insanusmokrassar.postssystem.ktor.server - -import com.insanusmokrassar.postssystem.utils.common.pagination.* -import io.ktor.http.Parameters - -val Parameters.extractPagination: Pagination - get() = SimplePagination( - get("page") ?.toIntOrNull() ?: 0, - get("size") ?.toIntOrNull() ?: defaultMediumPageSize - ) diff --git a/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/ktor/server/ServerRoutingShortcuts.kt b/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/ktor/server/ServerRoutingShortcuts.kt deleted file mode 100644 index 88bae92b..00000000 --- a/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/ktor/server/ServerRoutingShortcuts.kt +++ /dev/null @@ -1,65 +0,0 @@ -package com.insanusmokrassar.postssystem.ktor.server - -import com.insanusmokrassar.postssystem.ktor.standardKtorSerialFormat -import io.ktor.application.ApplicationCall -import io.ktor.http.HttpStatusCode -import io.ktor.response.respond -import io.ktor.response.respondBytes -import io.ktor.util.toByteArray -import kotlinx.serialization.* - -suspend fun ApplicationCall.unianswer( - answerSerializer: SerializationStrategy, - answer: T -) { - respondBytes( - standardKtorSerialFormat.encodeToByteArray(answerSerializer, answer), - standardKtorSerialFormatContentType - ) -} - -suspend fun ApplicationCall.uniload( - deserializer: DeserializationStrategy -) = standardKtorSerialFormat.decodeFromByteArray( - deserializer, - request.receiveChannel().toByteArray() -) - -suspend fun ApplicationCall.getParameterOrSendError( - field: String -) = parameters[field].also { - if (it == null) { - respond(HttpStatusCode.BadRequest, "Request must contains $field") - } -} - -fun ApplicationCall.getQueryParameter( - field: String -) = request.queryParameters[field] - -suspend fun ApplicationCall.getQueryParameterOrSendError( - field: String -) = getQueryParameter(field).also { - if (it == null) { - respond(HttpStatusCode.BadRequest, "Request query parameters must contains $field") - } -} - -fun ApplicationCall.decodeUrlQueryValue( - field: String, - deserializer: DeserializationStrategy -) = getQueryParameter(field) ?.let { - standardKtorSerialFormat.decodeFromHexString( - deserializer, - it - ) -} - -suspend fun ApplicationCall.decodeUrlQueryValueOrSendError( - field: String, - deserializer: DeserializationStrategy -) = decodeUrlQueryValue(field, deserializer).also { - if (it == null) { - respond(HttpStatusCode.BadRequest, "Request query parameters must contains $field") - } -} diff --git a/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/ktor/server/StartServer.kt b/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/ktor/server/StartServer.kt deleted file mode 100644 index 5d81a1f7..00000000 --- a/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/ktor/server/StartServer.kt +++ /dev/null @@ -1,28 +0,0 @@ -package com.insanusmokrassar.postssystem.ktor.server - -import io.ktor.application.Application -import io.ktor.server.engine.* -import io.ktor.server.netty.Netty -import kotlin.random.Random - -fun createKtorServer( - engine: ApplicationEngineFactory, - host: String = "localhost", - port: Int = Random.nextInt(1024, 65535), - block: Application.() -> Unit -): TEngine { - val env = applicationEngineEnvironment { - module(block) - connector { - this@connector.host = host - this@connector.port = port - } - } - return embeddedServer(engine, env) -} - -fun createKtorServer( - host: String = "localhost", - port: Int = Random.nextInt(1024, 65535), - block: Application.() -> Unit -) = createKtorServer(Netty, host, port, block) diff --git a/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/ktor/server/configurators/ApplicationCachingHeadersConfigurator.kt b/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/ktor/server/configurators/ApplicationCachingHeadersConfigurator.kt deleted file mode 100644 index f62c8bcb..00000000 --- a/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/ktor/server/configurators/ApplicationCachingHeadersConfigurator.kt +++ /dev/null @@ -1,21 +0,0 @@ -package com.insanusmokrassar.postssystem.ktor.server.configurators - -import io.ktor.application.Application -import io.ktor.application.install -import io.ktor.features.CachingHeaders -import kotlinx.serialization.Contextual - -data class ApplicationCachingHeadersConfigurator( - private val elements: List<@Contextual Element> -) : KtorApplicationConfigurator{ - interface Element { operator fun CachingHeaders.Configuration.invoke() } - - override fun Application.configure() { - install(CachingHeaders) { - elements.forEach { - it.apply { invoke() } - } - } - } -} - diff --git a/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/ktor/server/configurators/ApplicationRoutingConfigurator.kt b/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/ktor/server/configurators/ApplicationRoutingConfigurator.kt deleted file mode 100644 index 48e62e28..00000000 --- a/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/ktor/server/configurators/ApplicationRoutingConfigurator.kt +++ /dev/null @@ -1,27 +0,0 @@ -package com.insanusmokrassar.postssystem.ktor.server.configurators - -import io.ktor.application.* -import io.ktor.routing.Route -import io.ktor.routing.Routing -import kotlinx.serialization.Contextual -import kotlinx.serialization.Serializable - -@Serializable -class ApplicationRoutingConfigurator( - private val elements: List<@Contextual Element> -) : KtorApplicationConfigurator { - interface Element { operator fun Route.invoke() } - - override fun Application.configure() { - try { - feature(Routing) - } catch (e: IllegalStateException) { - install(Routing) { - elements.forEach { - it.apply { invoke() } - } - } - } - } -} - diff --git a/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/ktor/server/configurators/ApplicationSessionsConfigurator.kt b/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/ktor/server/configurators/ApplicationSessionsConfigurator.kt deleted file mode 100644 index c2012a59..00000000 --- a/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/ktor/server/configurators/ApplicationSessionsConfigurator.kt +++ /dev/null @@ -1,20 +0,0 @@ -package com.insanusmokrassar.postssystem.ktor.server.configurators - -import io.ktor.application.Application -import io.ktor.application.install -import io.ktor.sessions.Sessions -import kotlinx.serialization.Contextual - -class ApplicationSessionsConfigurator( - private val elements: List<@Contextual Element> -) : KtorApplicationConfigurator { - interface Element { operator fun Sessions.Configuration.invoke() } - - override fun Application.configure() { - install(Sessions) { - elements.forEach { - it.apply { invoke() } - } - } - } -} diff --git a/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/ktor/server/configurators/KtorApplicationConfigurator.kt b/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/ktor/server/configurators/KtorApplicationConfigurator.kt deleted file mode 100644 index 9c634b5d..00000000 --- a/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/ktor/server/configurators/KtorApplicationConfigurator.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.insanusmokrassar.postssystem.ktor.server.configurators - -import io.ktor.application.Application - -interface KtorApplicationConfigurator { - fun Application.configure() -} diff --git a/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/ktor/server/configurators/StatusPagesConfigurator.kt b/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/ktor/server/configurators/StatusPagesConfigurator.kt deleted file mode 100644 index 12cc0972..00000000 --- a/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/ktor/server/configurators/StatusPagesConfigurator.kt +++ /dev/null @@ -1,21 +0,0 @@ -package com.insanusmokrassar.postssystem.ktor.server.configurators - -import io.ktor.application.Application -import io.ktor.application.install -import io.ktor.features.StatusPages -import kotlinx.serialization.Contextual - -class StatusPagesConfigurator( - private val elements: List<@Contextual Element> -) : KtorApplicationConfigurator { - interface Element { operator fun StatusPages.Configuration.invoke() } - - override fun Application.configure() { - install(StatusPages) { - elements.forEach { - it.apply { invoke() } - } - } - } -} - diff --git a/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/ktor/server/standardKtorSerialFormatContentType.kt b/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/ktor/server/standardKtorSerialFormatContentType.kt deleted file mode 100644 index e7e0e422..00000000 --- a/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/ktor/server/standardKtorSerialFormatContentType.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.insanusmokrassar.postssystem.ktor.server - -import io.ktor.http.ContentType - -val standardKtorSerialFormatContentType = ContentType.Application.Cbor diff --git a/ktor/tests/build.gradle b/ktor/tests/build.gradle deleted file mode 100644 index 81323dcc..00000000 --- a/ktor/tests/build.gradle +++ /dev/null @@ -1,39 +0,0 @@ -buildscript { - repositories { - mavenLocal() - jcenter() - mavenCentral() - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" - } -} - -plugins { - id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version" -} - -project.version = "$core_version" -project.group = "com.insanusmokrassar" - -apply plugin: "java-library" -apply plugin: "kotlin" - -repositories { - mavenLocal() - jcenter() - mavenCentral() - maven { url "https://kotlin.bintray.com/kotlinx" } -} - -dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - - api projectByName("ktor.client") - api projectByName("ktor.server") - - testImplementation "org.jetbrains.kotlin:kotlin-test" - testImplementation "org.jetbrains.kotlin:kotlin-test-junit" -} diff --git a/ktor/tests/src/test/kotlin/com/insanusmokrassar/postssystem/ktor/tests/TestsScope.kt b/ktor/tests/src/test/kotlin/com/insanusmokrassar/postssystem/ktor/tests/TestsScope.kt deleted file mode 100644 index b9f51276..00000000 --- a/ktor/tests/src/test/kotlin/com/insanusmokrassar/postssystem/ktor/tests/TestsScope.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.insanusmokrassar.postssystem.ktor.tests - -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Dispatchers - -val testsScope = CoroutineScope(Dispatchers.Default) diff --git a/ktor/tests/src/test/kotlin/com/insanusmokrassar/postssystem/ktor/tests/WebsocketsTest.kt b/ktor/tests/src/test/kotlin/com/insanusmokrassar/postssystem/ktor/tests/WebsocketsTest.kt deleted file mode 100644 index 37ae8c2a..00000000 --- a/ktor/tests/src/test/kotlin/com/insanusmokrassar/postssystem/ktor/tests/WebsocketsTest.kt +++ /dev/null @@ -1,63 +0,0 @@ -package com.insanusmokrassar.postssystem.ktor.tests - -import com.insanusmokrassar.postssystem.ktor.client.createStandardWebsocketFlow -import com.insanusmokrassar.postssystem.ktor.server.createKtorServer -import com.insanusmokrassar.postssystem.ktor.server.includeWebsocketHandling -import io.ktor.application.install -import io.ktor.client.HttpClient -import io.ktor.routing.routing -import io.ktor.websocket.WebSockets -import kotlinx.coroutines.* -import kotlinx.coroutines.channels.Channel -import kotlinx.coroutines.flow.* -import kotlinx.serialization.builtins.serializer -import org.junit.Test -import kotlin.test.assertEquals -import kotlin.test.assertNull - -class WebsocketsTest { - @Test - fun testCommonWebsocketFunctionality() { - val port = 60000 - val suburl = "test" - val dataFlowChannel = Channel(Channel.UNLIMITED) - val dataFlow = dataFlowChannel.consumeAsFlow() - val serverUrl = "127.0.0.1:$port" - val server = createKtorServer(host = "127.0.0.1", port = port) { - install(WebSockets) - routing { - includeWebsocketHandling(suburl, dataFlow, Int.serializer()) - } - }.also { - it.start(false) - } - runBlocking { - delay(100L) - } - val client = HttpClient { - install(io.ktor.client.features.websocket.WebSockets) - } - val incomingWebsocketFlow = client.createStandardWebsocketFlow( - "$serverUrl/$suburl", - { false }, // always skip reconnection - deserializer = Int.serializer() - ) - - var currentlyCheckingData: Int? = null - incomingWebsocketFlow.onEach { - assertEquals(currentlyCheckingData, it) - currentlyCheckingData = null - }.launchIn(CoroutineScope(testsScope.coroutineContext + SupervisorJob())) - runBlocking { - (0 until 100).asFlow().collect { - currentlyCheckingData = it - dataFlowChannel.send(it) - while (currentlyCheckingData != null) { - delay(10L) - } - assertNull(currentlyCheckingData) - } - } - server.stop(1000L, 1000L) - } -} diff --git a/utils/common/mimes_generator/mime_generator.py b/mimes_generator/mime_generator.py similarity index 100% rename from utils/common/mimes_generator/mime_generator.py rename to mimes_generator/mime_generator.py diff --git a/utils/common/mimes_generator/table.html b/mimes_generator/table.html similarity index 100% rename from utils/common/mimes_generator/table.html rename to mimes_generator/table.html diff --git a/publishing/api/build.gradle b/publishing/api/build.gradle index cdc63026..fc7debba 100644 --- a/publishing/api/build.gradle +++ b/publishing/api/build.gradle @@ -8,7 +8,6 @@ buildscript { dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" - classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version" } } @@ -41,11 +40,7 @@ kotlin { dependencies { implementation kotlin('stdlib') - if ((project.hasProperty('RELEASE_MODE') && project.property('RELEASE_MODE') == "true") || System.getenv('RELEASE_MODE') == "true") { - api "com.insanusmokrassar:postssystem.core.api:$core_version" - } else { - api projectByName("core.api") - } + api project(":postssystem.core.api") } } commonTest { diff --git a/publishing/api/maven.publish.gradle b/publishing/api/maven.publish.gradle deleted file mode 100644 index 87b6a8bf..00000000 --- a/publishing/api/maven.publish.gradle +++ /dev/null @@ -1,53 +0,0 @@ -apply plugin: 'maven-publish' - -task javadocsJar(type: Jar) { - classifier = 'javadoc' -} - -afterEvaluate { - project.publishing.publications.all { - // rename artifacts - groupId "${project.group}" - if (it.name.contains('kotlinMultiplatform')) { - artifactId = "${project.name}" - } else { - artifactId = "${project.name}-$name" - } - } -} - -publishing { - publications.all { - artifact javadocsJar - - pom { - description = "Publishing subsystem with necessary functionality related to publish mechanism" - name = "PostsSystem Core Publishing subsystem" - url = "https://git.insanusmokrassar.com/PostsSystem/Core/" - - scm { - developerConnection = "scm:git:[fetch=]https://git.insanusmokrassar.com/PostsSystem/Core/.git[push=]https://git.insanusmokrassar.com/PostsSystem/Core/.git" - url = "https://git.insanusmokrassar.com/PostsSystem/Core/.git" - } - - developers { - - developer { - id = "InsanusMokrassar" - name = "Ovsiannikov Aleksei" - email = "ovsyannikov.alexey95@gmail.com" - } - - } - - licenses { - - license { - name = "Apache Software License 2.0" - url = "https://git.insanusmokrassar.com/PostsSystem/Core/src/master/LICENSE" - } - - } - } - } -} \ No newline at end of file diff --git a/publishing/api/publish.gradle b/publishing/api/publish.gradle index b8cf4528..b7bf27ca 100644 --- a/publishing/api/publish.gradle +++ b/publishing/api/publish.gradle @@ -1,55 +1,69 @@ -apply plugin: 'com.jfrog.bintray' +apply plugin: 'maven-publish' -apply from: "maven.publish.gradle" - -bintray { - user = project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER') - key = project.hasProperty('BINTRAY_KEY') ? project.property('BINTRAY_KEY') : System.getenv('BINTRAY_KEY') - filesSpec { - from "${buildDir}/publications/" - eachFile { - String directorySubname = it.getFile().parentFile.name - if (it.getName() == "module.json") { - if (directorySubname == "kotlinMultiplatform") { - it.setPath("${project.name}/${project.version}/${project.name}-${project.version}.module") - } else { - it.setPath("${project.name}-${directorySubname}/${project.version}/${project.name}-${directorySubname}-${project.version}.module") - } - } else { - if (directorySubname == "kotlinMultiplatform" && it.getName() == "pom-default.xml") { - it.setPath("${project.name}/${project.version}/${project.name}-${project.version}.pom") - } else { - it.exclude() - } - } - } - into "${project.group}".replace(".", "/") - } - pkg { - repo = "InsanusMokrassar" - name = "${project.name}" - vcsUrl = "https://github.com/PostsSystem/PostsSystemCore" - licenses = ["Apache-2.0"] - version { - name = "${project.version}" - released = new Date() - vcsTag = "${project.version}" - gpg { - sign = true - passphrase = project.hasProperty('signing.gnupg.passphrase') ? project.property('signing.gnupg.passphrase') : System.getenv('signing.gnupg.passphrase') - } - } - } +task javadocsJar(type: Jar) { + classifier = 'javadoc' +} +task sourceJar (type : Jar) { + classifier = 'sources' } -bintrayUpload.doFirst { - publications = publishing.publications.collect { +afterEvaluate { + project.publishing.publications.all { + // rename artifacts + groupId "${project.group}" if (it.name.contains('kotlinMultiplatform')) { - null + artifactId = "${project.name}" + artifact sourceJar } else { - it.name + artifactId = "${project.name}-$name" } - } - null + } } -bintrayUpload.dependsOn publishToMavenLocal \ No newline at end of file +publishing { + publications.all { + artifact javadocsJar + + pom { + description = "Publishing subsystem with necessary functionality related to publish mechanism" + name = "PostsSystem Core Publishing subsystem" + url = "https://git.insanusmokrassar.com/PostsSystem/Core/" + + scm { + developerConnection = "scm:git:[fetch=]https://git.insanusmokrassar.com/PostsSystem/Core/.git[push=]https://git.insanusmokrassar.com/PostsSystem/Core/.git" + url = "https://git.insanusmokrassar.com/PostsSystem/Core/.git" + } + + developers { + + developer { + id = "InsanusMokrassar" + name = "Ovsiannikov Aleksei" + email = "ovsyannikov.alexey95@gmail.com" + } + + } + + licenses { + + license { + name = "Apache Software License 2.0" + url = "https://git.insanusmokrassar.com/PostsSystem/Core/src/master/LICENSE" + } + + } + } + + repositories { + maven { + name = "bintray" + url = uri("https://api.bintray.com/maven/${project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER')}/InsanusMokrassar/${project.name}/;publish=0;override=0") + credentials { + username = project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER') + password = project.hasProperty('BINTRAY_KEY') ? project.property('BINTRAY_KEY') : System.getenv('BINTRAY_KEY') + } + } + } + + } +} \ No newline at end of file diff --git a/publishing/exposed/build.gradle b/publishing/exposed/build.gradle index 0ec9f781..d3bfb9c3 100644 --- a/publishing/exposed/build.gradle +++ b/publishing/exposed/build.gradle @@ -8,7 +8,6 @@ buildscript { dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" - classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version" } } @@ -33,13 +32,9 @@ repositories { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - if ((project.hasProperty('RELEASE_MODE') && project.property('RELEASE_MODE') == "true") || System.getenv('RELEASE_MODE') == "true") { - api "com.insanusmokrassar:postssystem.core.publishing:$core_version" - api "com.insanusmokrassar:postssystem.exposed.commons:$core_version" - } else { - api projectByName("publishing.api") - api projectByName("exposed.commons") - } + api "dev.inmo:micro_utils.repos.exposed:$microutils_version" + + api project(":postssystem.publishing.api") testImplementation "org.xerial:sqlite-jdbc:$test_sqlite_version" testImplementation "org.jetbrains.kotlin:kotlin-test" diff --git a/publishing/exposed/maven.publish.gradle b/publishing/exposed/maven.publish.gradle deleted file mode 100644 index 09a3d849..00000000 --- a/publishing/exposed/maven.publish.gradle +++ /dev/null @@ -1,53 +0,0 @@ -apply plugin: 'maven-publish' - -task javadocsJar(type: Jar) { - classifier = 'javadoc' -} - -afterEvaluate { - project.publishing.publications.all { - // rename artifacts - groupId "${project.group}" - if (it.name.contains('kotlinMultiplatform')) { - artifactId = "${project.name}" - } else { - artifactId = "${project.name}-$name" - } - } -} - -publishing { - publications.all { - artifact javadocsJar - - pom { - description = "Exposed realisation for PostsSystem Core Publishing subsystem" - name = "PostsSystem Core Publishing Exposed realization" - url = "https://git.insanusmokrassar.com/PostsSystem/Core/" - - scm { - developerConnection = "scm:git:[fetch=]https://git.insanusmokrassar.com/PostsSystem/Core/.git[push=]https://git.insanusmokrassar.com/PostsSystem/Core/.git" - url = "https://git.insanusmokrassar.com/PostsSystem/Core/.git" - } - - developers { - - developer { - id = "InsanusMokrassar" - name = "Ovsiannikov Aleksei" - email = "ovsyannikov.alexey95@gmail.com" - } - - } - - licenses { - - license { - name = "Apache Software License 2.0" - url = "https://git.insanusmokrassar.com/PostsSystem/Core/src/master/LICENSE" - } - - } - } - } -} \ No newline at end of file diff --git a/publishing/exposed/publish.gradle b/publishing/exposed/publish.gradle index b8cf4528..0645195d 100644 --- a/publishing/exposed/publish.gradle +++ b/publishing/exposed/publish.gradle @@ -1,55 +1,69 @@ -apply plugin: 'com.jfrog.bintray' +apply plugin: 'maven-publish' -apply from: "maven.publish.gradle" - -bintray { - user = project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER') - key = project.hasProperty('BINTRAY_KEY') ? project.property('BINTRAY_KEY') : System.getenv('BINTRAY_KEY') - filesSpec { - from "${buildDir}/publications/" - eachFile { - String directorySubname = it.getFile().parentFile.name - if (it.getName() == "module.json") { - if (directorySubname == "kotlinMultiplatform") { - it.setPath("${project.name}/${project.version}/${project.name}-${project.version}.module") - } else { - it.setPath("${project.name}-${directorySubname}/${project.version}/${project.name}-${directorySubname}-${project.version}.module") - } - } else { - if (directorySubname == "kotlinMultiplatform" && it.getName() == "pom-default.xml") { - it.setPath("${project.name}/${project.version}/${project.name}-${project.version}.pom") - } else { - it.exclude() - } - } - } - into "${project.group}".replace(".", "/") - } - pkg { - repo = "InsanusMokrassar" - name = "${project.name}" - vcsUrl = "https://github.com/PostsSystem/PostsSystemCore" - licenses = ["Apache-2.0"] - version { - name = "${project.version}" - released = new Date() - vcsTag = "${project.version}" - gpg { - sign = true - passphrase = project.hasProperty('signing.gnupg.passphrase') ? project.property('signing.gnupg.passphrase') : System.getenv('signing.gnupg.passphrase') - } - } - } +task javadocsJar(type: Jar) { + classifier = 'javadoc' +} +task sourceJar (type : Jar) { + classifier = 'sources' } -bintrayUpload.doFirst { - publications = publishing.publications.collect { +afterEvaluate { + project.publishing.publications.all { + // rename artifacts + groupId "${project.group}" if (it.name.contains('kotlinMultiplatform')) { - null + artifactId = "${project.name}" + artifact sourceJar } else { - it.name + artifactId = "${project.name}-$name" } - } - null + } } -bintrayUpload.dependsOn publishToMavenLocal \ No newline at end of file +publishing { + publications.all { + artifact javadocsJar + + pom { + description = "Exposed realisation for PostsSystem Core Publishing subsystem" + name = "PostsSystem Core Publishing Exposed realization" + url = "https://git.insanusmokrassar.com/PostsSystem/Core/" + + scm { + developerConnection = "scm:git:[fetch=]https://git.insanusmokrassar.com/PostsSystem/Core/.git[push=]https://git.insanusmokrassar.com/PostsSystem/Core/.git" + url = "https://git.insanusmokrassar.com/PostsSystem/Core/.git" + } + + developers { + + developer { + id = "InsanusMokrassar" + name = "Ovsiannikov Aleksei" + email = "ovsyannikov.alexey95@gmail.com" + } + + } + + licenses { + + license { + name = "Apache Software License 2.0" + url = "https://git.insanusmokrassar.com/PostsSystem/Core/src/master/LICENSE" + } + + } + } + + repositories { + maven { + name = "bintray" + url = uri("https://api.bintray.com/maven/${project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER')}/InsanusMokrassar/${project.name}/;publish=0;override=0") + credentials { + username = project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER') + password = project.hasProperty('BINTRAY_KEY') ? project.property('BINTRAY_KEY') : System.getenv('BINTRAY_KEY') + } + } + } + + } +} \ No newline at end of file diff --git a/publishing/exposed/publish_config.kpsb b/publishing/exposed/publish_config.kpsb index 5443906e..ad2f62ac 100644 --- a/publishing/exposed/publish_config.kpsb +++ b/publishing/exposed/publish_config.kpsb @@ -1 +1 @@ -{"bintrayConfig":{"repo":"InsanusMokrassar","packageName":"${project.name}","packageVcs":"https://github.com/PostsSystem/PostsSystemCore"},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://git.insanusmokrassar.com/PostsSystem/Core/src/master/LICENSE"}],"mavenConfig":{"name":"PostsSystem Core Publishing Exposed realization","description":"Exposed realisation for PostsSystem Core Publishing subsystem","url":"https://git.insanusmokrassar.com/PostsSystem/Core/","vcsUrl":"https://git.insanusmokrassar.com/PostsSystem/Core/.git","developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}]},"type":"Multiplatform"} \ No newline at end of file +{"bintrayConfig":{"repo":"InsanusMokrassar","packageName":"${project.name}","packageVcs":"https://github.com/PostsSystem/PostsSystemCore"},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://git.insanusmokrassar.com/PostsSystem/Core/src/master/LICENSE"}],"mavenConfig":{"name":"PostsSystem Core Publishing Exposed realization","description":"Exposed realisation for PostsSystem Core Publishing subsystem","url":"https://git.insanusmokrassar.com/PostsSystem/Core/","vcsUrl":"https://git.insanusmokrassar.com/PostsSystem/Core/.git","developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}]}} \ No newline at end of file diff --git a/publishing/ktor/client/build.gradle b/publishing/ktor/client/build.gradle index 3a8f0705..af7289fe 100644 --- a/publishing/ktor/client/build.gradle +++ b/publishing/ktor/client/build.gradle @@ -8,7 +8,6 @@ buildscript { dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" - classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version" } } @@ -41,13 +40,9 @@ kotlin { dependencies { implementation kotlin('stdlib') - if ((project.hasProperty('RELEASE_MODE') && project.property('RELEASE_MODE') == "true") || System.getenv('RELEASE_MODE') == "true") { - api "com.insanusmokrassar:postssystem.core.ktor.common:$core_version" - api "com.insanusmokrassar:postssystem.ktor.client:$core_version" - } else { - api projectByName("publishing.ktor.common") - api projectByName("ktor.client") - } + api "dev.inmo:micro_utils.ktor.client:$microutils_version" + + api project(":postssystem.publishing.ktor.common") } } commonTest { diff --git a/publishing/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/publishing/ktor/client/ReadPublishingKeysRepoKtorClient.kt b/publishing/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/publishing/ktor/client/ReadPublishingKeysRepoKtorClient.kt index 87023abc..9d9e4ffa 100644 --- a/publishing/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/publishing/ktor/client/ReadPublishingKeysRepoKtorClient.kt +++ b/publishing/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/publishing/ktor/client/ReadPublishingKeysRepoKtorClient.kt @@ -3,10 +3,10 @@ package com.insanusmokrassar.postssystem.publishing.ktor.client import com.insanusmokrassar.postssystem.core.post.PostId import com.insanusmokrassar.postssystem.core.publishing.TriggerControlKey import com.insanusmokrassar.postssystem.core.publishing.repos.ReadPublishingKeysRepo -import com.insanusmokrassar.postssystem.ktor.buildStandardUrl -import com.insanusmokrassar.postssystem.ktor.client.uniget import com.insanusmokrassar.postssystem.publishing.ktor.getPostIdByTriggerControlKeyRoute import com.insanusmokrassar.postssystem.publishing.ktor.getTriggerControlKeyByPostIdRoute +import dev.inmo.micro_utils.ktor.client.uniget +import dev.inmo.micro_utils.ktor.common.buildStandardUrl import io.ktor.client.HttpClient import kotlinx.serialization.builtins.nullable import kotlinx.serialization.builtins.serializer diff --git a/publishing/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/publishing/ktor/client/WritePublishingKeysRepoKtorClient.kt b/publishing/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/publishing/ktor/client/WritePublishingKeysRepoKtorClient.kt index de281241..37fe8ffd 100644 --- a/publishing/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/publishing/ktor/client/WritePublishingKeysRepoKtorClient.kt +++ b/publishing/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/publishing/ktor/client/WritePublishingKeysRepoKtorClient.kt @@ -3,10 +3,10 @@ package com.insanusmokrassar.postssystem.publishing.ktor.client import com.insanusmokrassar.postssystem.core.post.PostId import com.insanusmokrassar.postssystem.core.publishing.TriggerControlKey import com.insanusmokrassar.postssystem.core.publishing.repos.WritePublishingKeysRepo -import com.insanusmokrassar.postssystem.ktor.buildStandardUrl -import com.insanusmokrassar.postssystem.ktor.client.BodyPair -import com.insanusmokrassar.postssystem.ktor.client.unipost import com.insanusmokrassar.postssystem.publishing.ktor.* +import dev.inmo.micro_utils.ktor.client.BodyPair +import dev.inmo.micro_utils.ktor.client.unipost +import dev.inmo.micro_utils.ktor.common.buildStandardUrl import io.ktor.client.HttpClient import kotlinx.serialization.builtins.serializer diff --git a/publishing/ktor/common/build.gradle b/publishing/ktor/common/build.gradle index 926f5045..463e6b8c 100644 --- a/publishing/ktor/common/build.gradle +++ b/publishing/ktor/common/build.gradle @@ -8,7 +8,6 @@ buildscript { dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" - classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version" } } @@ -39,13 +38,9 @@ kotlin { dependencies { implementation kotlin('stdlib') - if ((project.hasProperty('RELEASE_MODE') && project.property('RELEASE_MODE') == "true") || System.getenv('RELEASE_MODE') == "true") { - api "com.insanusmokrassar:postssystem.ktor.common:$core_version" - api "com.insanusmokrassar:postssystem.publishing.api:$core_version" - } else { - api projectByName("ktor.common") - api projectByName("publishing.api") - } + api "dev.inmo:micro_utils.ktor.common:$microutils_version" + + api project(":postssystem.publishing.api") } } commonTest { @@ -54,21 +49,11 @@ kotlin { implementation kotlin('test-annotations-common') } } - jvmMain { - dependencies { - implementation kotlin('stdlib-jdk8') - } - } jvmTest { dependencies { implementation kotlin('test-junit') } } - jsMain { - dependencies { - implementation kotlin('stdlib-js') - } - } jsTest { dependencies { implementation kotlin('test-js') diff --git a/publishing/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/publishing/ktor/Serializers.kt b/publishing/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/publishing/ktor/Serializers.kt index 1c6b1f13..9d0302d7 100644 --- a/publishing/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/publishing/ktor/Serializers.kt +++ b/publishing/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/publishing/ktor/Serializers.kt @@ -1,6 +1,9 @@ package com.insanusmokrassar.postssystem.publishing.ktor -import com.insanusmokrassar.postssystem.ktor.setIdsSerializer +import com.insanusmokrassar.postssystem.core.post.PostId +import com.insanusmokrassar.postssystem.core.publishing.TriggerControlKey +import kotlinx.serialization.builtins.SetSerializer +import kotlinx.serialization.builtins.serializer -val postsIdSerializer = setIdsSerializer -val triggerControlKeysSerializer = setIdsSerializer +val postsIdSerializer = SetSerializer(PostId.serializer()) +val triggerControlKeysSerializer = SetSerializer(TriggerControlKey.serializer()) diff --git a/publishing/ktor/server/build.gradle b/publishing/ktor/server/build.gradle index 49f65244..130c9dd4 100644 --- a/publishing/ktor/server/build.gradle +++ b/publishing/ktor/server/build.gradle @@ -8,7 +8,6 @@ buildscript { dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" - classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version" } } @@ -32,8 +31,9 @@ repositories { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - api projectByName("publishing.ktor.common") - api projectByName("ktor.server") + api "dev.inmo:micro_utils.ktor.server:$microutils_version" + + api project(":postssystem.publishing.ktor.common") testImplementation "org.xerial:sqlite-jdbc:$test_sqlite_version" testImplementation "org.jetbrains.kotlin:kotlin-test" diff --git a/publishing/ktor/server/src/main/kotlin/com/insanusmokrassar/postssystem/publishing/ktor/server/PublishingKeysRepoRoutingConfigurator.kt b/publishing/ktor/server/src/main/kotlin/com/insanusmokrassar/postssystem/publishing/ktor/server/PublishingKeysRepoRoutingConfigurator.kt index 8f5918a7..02fd9b16 100644 --- a/publishing/ktor/server/src/main/kotlin/com/insanusmokrassar/postssystem/publishing/ktor/server/PublishingKeysRepoRoutingConfigurator.kt +++ b/publishing/ktor/server/src/main/kotlin/com/insanusmokrassar/postssystem/publishing/ktor/server/PublishingKeysRepoRoutingConfigurator.kt @@ -1,8 +1,8 @@ package com.insanusmokrassar.postssystem.publishing.ktor.server import com.insanusmokrassar.postssystem.core.publishing.repos.PublishingKeysRepo -import com.insanusmokrassar.postssystem.ktor.server.configurators.ApplicationRoutingConfigurator import com.insanusmokrassar.postssystem.publishing.ktor.publishingKeysRootRoute +import dev.inmo.micro_utils.ktor.server.configurators.ApplicationRoutingConfigurator import io.ktor.routing.Route import io.ktor.routing.route diff --git a/publishing/ktor/server/src/main/kotlin/com/insanusmokrassar/postssystem/publishing/ktor/server/ReadPublishingKeysRepoRoutingConfigurator.kt b/publishing/ktor/server/src/main/kotlin/com/insanusmokrassar/postssystem/publishing/ktor/server/ReadPublishingKeysRepoRoutingConfigurator.kt index 5cc8e48b..d4dcc679 100644 --- a/publishing/ktor/server/src/main/kotlin/com/insanusmokrassar/postssystem/publishing/ktor/server/ReadPublishingKeysRepoRoutingConfigurator.kt +++ b/publishing/ktor/server/src/main/kotlin/com/insanusmokrassar/postssystem/publishing/ktor/server/ReadPublishingKeysRepoRoutingConfigurator.kt @@ -3,11 +3,11 @@ package com.insanusmokrassar.postssystem.publishing.ktor.server import com.insanusmokrassar.postssystem.core.post.PostId import com.insanusmokrassar.postssystem.core.publishing.TriggerControlKey import com.insanusmokrassar.postssystem.core.publishing.repos.ReadPublishingKeysRepo -import com.insanusmokrassar.postssystem.ktor.server.configurators.ApplicationRoutingConfigurator -import com.insanusmokrassar.postssystem.ktor.server.getParameterOrSendError -import com.insanusmokrassar.postssystem.ktor.server.unianswer import com.insanusmokrassar.postssystem.publishing.ktor.getPostIdByTriggerControlKeyRoute import com.insanusmokrassar.postssystem.publishing.ktor.getTriggerControlKeyByPostIdRoute +import dev.inmo.micro_utils.ktor.server.configurators.ApplicationRoutingConfigurator +import dev.inmo.micro_utils.ktor.server.getParameterOrSendError +import dev.inmo.micro_utils.ktor.server.unianswer import io.ktor.application.call import io.ktor.routing.Route import io.ktor.routing.get diff --git a/publishing/ktor/server/src/main/kotlin/com/insanusmokrassar/postssystem/publishing/ktor/server/WritePublishingKeysRepoRoutingConfigurator.kt b/publishing/ktor/server/src/main/kotlin/com/insanusmokrassar/postssystem/publishing/ktor/server/WritePublishingKeysRepoRoutingConfigurator.kt index 150a1fab..2dd0e4c1 100644 --- a/publishing/ktor/server/src/main/kotlin/com/insanusmokrassar/postssystem/publishing/ktor/server/WritePublishingKeysRepoRoutingConfigurator.kt +++ b/publishing/ktor/server/src/main/kotlin/com/insanusmokrassar/postssystem/publishing/ktor/server/WritePublishingKeysRepoRoutingConfigurator.kt @@ -2,9 +2,9 @@ package com.insanusmokrassar.postssystem.publishing.ktor.server import com.insanusmokrassar.postssystem.core.post.PostId import com.insanusmokrassar.postssystem.core.publishing.repos.WritePublishingKeysRepo -import com.insanusmokrassar.postssystem.ktor.server.unianswer -import com.insanusmokrassar.postssystem.ktor.server.uniload import com.insanusmokrassar.postssystem.publishing.ktor.* +import dev.inmo.micro_utils.ktor.server.unianswer +import dev.inmo.micro_utils.ktor.server.uniload import io.ktor.application.call import io.ktor.routing.Route import io.ktor.routing.post diff --git a/settings.gradle b/settings.gradle index 073e7483..cbca3cf9 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,21 +1,6 @@ rootProject.name='postssystem' String[] includes = [ - ':utils:common', - ':utils:repos', - ':utils:repos:common', - ':utils:repos:ktor:common', - ':utils:repos:ktor:client', - ':utils:repos:ktor:server', - ':utils:repos:exposed', - - ':exposed:commons', - - ':ktor:common', - ':ktor:client', - ':ktor:server', - ':ktor:tests', - ':core:api', ':core:exposed', ':core:ktor', @@ -35,8 +20,13 @@ String[] includes = [ ] -includes.each { - include it - ProjectDescriptor project = project(it) - project.name = project.projectDir.absolutePath.replace("${rootDir.absolutePath}${File.separator}", "").replace(File.separator, ".") +includes.each { originalName -> + String projectDirectory = "${rootProject.projectDir.getAbsolutePath()}${originalName.replaceAll(":", File.separator)}" + String projectName = "${rootProject.name}${originalName.replaceAll(":", ".")}" + String projectIdentifier = ":${projectName}" + include projectIdentifier + ProjectDescriptor project = project(projectIdentifier) + project.name = projectName + project.projectDir = new File(projectDirectory) + println(project) } diff --git a/utils/common/build.gradle b/utils/common/build.gradle deleted file mode 100644 index 12dcc409..00000000 --- a/utils/common/build.gradle +++ /dev/null @@ -1,78 +0,0 @@ -buildscript { - repositories { - mavenLocal() - jcenter() - mavenCentral() - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" - classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version" - } -} - -plugins { - id "org.jetbrains.kotlin.multiplatform" version "$kotlin_version" - id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version" -} - -project.version = "$core_version" -project.group = "com.insanusmokrassar" - -apply from: "publish.gradle" - -repositories { - mavenLocal() - jcenter() - mavenCentral() - maven { url "https://kotlin.bintray.com/kotlinx" } -} - -kotlin { - jvm() - js (BOTH) { - browser() - nodejs() - } - - sourceSets { - commonMain { - dependencies { - implementation kotlin('stdlib') - api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version" - api "org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlin_serialisation_core_version" - - api "com.soywiz.korlibs.klock:klock:$klockVersion" - api "com.benasher44:uuid:$uuidVersion" - } - } - commonTest { - dependencies { - implementation kotlin('test-common') - implementation kotlin('test-annotations-common') - } - } - jvmMain { - dependencies { - implementation kotlin('stdlib-jdk8') - } - } - jvmTest { - dependencies { - implementation kotlin('test-junit') - } - } - jsMain { - dependencies { - implementation kotlin('stdlib-js') - } - } - jsTest { - dependencies { - implementation kotlin('test-js') - implementation kotlin('test-junit') - } - } - } -} diff --git a/utils/common/maven.publish.gradle b/utils/common/maven.publish.gradle deleted file mode 100644 index b81b338a..00000000 --- a/utils/common/maven.publish.gradle +++ /dev/null @@ -1,64 +0,0 @@ -apply plugin: 'maven-publish' - -task javadocsJar(type: Jar) { - classifier = 'javadoc' -} - -afterEvaluate { - project.publishing.publications.all { - // rename artifacts - groupId "${project.group}" - if (it.name.contains('kotlinMultiplatform')) { - artifactId = "${project.name}" - } else { - artifactId = "${project.name}-$name" - } - } -} - -publishing { - publications.all { - artifact javadocsJar - - pom.withXml { - asNode().children().last() + { - resolveStrategy = Closure.DELEGATE_FIRST - - description "Core library for PostsSystem" - name "PostsSystem Core" - url "https://git.insanusmokrassar.com/PostsSystem/PostsSystemCore" - - scm { - developerConnection "scm:git:[fetch=]https://git.insanusmokrassar.com/PostsSystem/PostsSystemCore.git[push=]https://git.insanusmokrassar.com/PostsSystem/PostsSystemCore.git" - url "https://git.insanusmokrassar.com/PostsSystem/PostsSystemCore.git" - } - - developers { - - developer { - id "InsanusMokrassar" - name "Ovsiannikov Aleksei" - email "ovsyannikov.alexey95@gmail.com" - } - - - developer { - id "mi-ast" - name "Michail Astafiev" - email "astaf65@gmail.com" - } - - } - - licenses { - - license { - name "Apache Software License 2.0" - url "https://git.insanusmokrassar.com/PostsSystem/PostsSystemCore/src/master/LICENSE" - } - - } - } - } - } -} \ No newline at end of file diff --git a/utils/common/publish.gradle b/utils/common/publish.gradle deleted file mode 100644 index b8cf4528..00000000 --- a/utils/common/publish.gradle +++ /dev/null @@ -1,55 +0,0 @@ -apply plugin: 'com.jfrog.bintray' - -apply from: "maven.publish.gradle" - -bintray { - user = project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER') - key = project.hasProperty('BINTRAY_KEY') ? project.property('BINTRAY_KEY') : System.getenv('BINTRAY_KEY') - filesSpec { - from "${buildDir}/publications/" - eachFile { - String directorySubname = it.getFile().parentFile.name - if (it.getName() == "module.json") { - if (directorySubname == "kotlinMultiplatform") { - it.setPath("${project.name}/${project.version}/${project.name}-${project.version}.module") - } else { - it.setPath("${project.name}-${directorySubname}/${project.version}/${project.name}-${directorySubname}-${project.version}.module") - } - } else { - if (directorySubname == "kotlinMultiplatform" && it.getName() == "pom-default.xml") { - it.setPath("${project.name}/${project.version}/${project.name}-${project.version}.pom") - } else { - it.exclude() - } - } - } - into "${project.group}".replace(".", "/") - } - pkg { - repo = "InsanusMokrassar" - name = "${project.name}" - vcsUrl = "https://github.com/PostsSystem/PostsSystemCore" - licenses = ["Apache-2.0"] - version { - name = "${project.version}" - released = new Date() - vcsTag = "${project.version}" - gpg { - sign = true - passphrase = project.hasProperty('signing.gnupg.passphrase') ? project.property('signing.gnupg.passphrase') : System.getenv('signing.gnupg.passphrase') - } - } - } -} - -bintrayUpload.doFirst { - publications = publishing.publications.collect { - if (it.name.contains('kotlinMultiplatform')) { - null - } else { - it.name - } - } - null -} - -bintrayUpload.dependsOn publishToMavenLocal \ No newline at end of file diff --git a/utils/common/publish_config.json b/utils/common/publish_config.json deleted file mode 100644 index 13f4058c..00000000 --- a/utils/common/publish_config.json +++ /dev/null @@ -1 +0,0 @@ -{"bintrayConfig":{"repo":"InsanusMokrassar","packageName":"${project.name}","packageVcs":"https://github.com/PostsSystem/PostsSystemCore"},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://git.insanusmokrassar.com/PostsSystem/PostsSystemCore/src/master/LICENSE"}],"mavenConfig":{"name":"PostsSystem Core","description":"Core library for PostsSystem","url":"https://git.insanusmokrassar.com/PostsSystem/PostsSystemCore","vcsUrl":"https://git.insanusmokrassar.com/PostsSystem/PostsSystemCore.git","developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"},{"id":"mi-ast","name":"Michail Astafiev","eMail":"astaf65@gmail.com"}]}} \ No newline at end of file diff --git a/utils/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/common/ByteArrayAllocator.kt b/utils/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/common/ByteArrayAllocator.kt deleted file mode 100644 index 433b09f4..00000000 --- a/utils/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/common/ByteArrayAllocator.kt +++ /dev/null @@ -1,23 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.common - -import kotlinx.serialization.KSerializer -import kotlinx.serialization.builtins.ByteArraySerializer -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -typealias ByteArrayAllocator = () -> ByteArray - -object ByteArrayAllocatorSerializer : KSerializer { - private val realSerializer = ByteArraySerializer() - override val descriptor: SerialDescriptor = realSerializer.descriptor - - override fun deserialize(decoder: Decoder): ByteArrayAllocator { - val bytes = realSerializer.deserialize(decoder) - return { bytes } - } - - override fun serialize(encoder: Encoder, value: ByteArrayAllocator) { - encoder.encodeSerializableValue(realSerializer, value()) - } -} diff --git a/utils/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/common/DateTimeUtils.kt b/utils/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/common/DateTimeUtils.kt deleted file mode 100644 index 87084bd2..00000000 --- a/utils/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/common/DateTimeUtils.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.common - -import com.soywiz.klock.DateTime - -val MIN_DATE = DateTime(0) -val MAX_DATE = DateTime(Long.MAX_VALUE) diff --git a/utils/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/common/HandleSafely.kt b/utils/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/common/HandleSafely.kt deleted file mode 100644 index 85d804e4..00000000 --- a/utils/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/common/HandleSafely.kt +++ /dev/null @@ -1,23 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.common - -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.supervisorScope - - -typealias ExceptionHandler = suspend (Throwable) -> T -/** - * It will run [block] inside of [supervisorScope] to avoid problems with catching of exceptions - * - * @param [onException] Will be called when happen exception inside of [block]. By default will throw exception - this - * exception will be available for catching - */ -suspend inline fun safely( - noinline onException: ExceptionHandler = { throw it }, - noinline block: suspend CoroutineScope.() -> T -): T { - return try { - supervisorScope(block) - } catch (e: Throwable) { - onException(e) - } -} diff --git a/utils/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/common/KnownMimeTypes.kt b/utils/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/common/KnownMimeTypes.kt deleted file mode 100644 index cedd2f51..00000000 --- a/utils/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/common/KnownMimeTypes.kt +++ /dev/null @@ -1,1444 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.common - -import kotlinx.serialization.Serializable - -@Serializable(MimeTypeSerializer::class) -interface MimeType { - val raw: String -} -data class CustomMimeType(override val raw: String) : MimeType - -sealed class KnownMimeTypes(override val raw: String) : MimeType { - object Any : MimeType, KnownMimeTypes("*/*") - sealed class Application(raw: String) : MimeType, KnownMimeTypes(raw) { - object Any: Application ("application/*") - object AndrewInset: Application ("application/andrew-inset") - object Applixware: Application ("application/applixware") - object AtomXml: Application ("application/atom+xml") - object AtomcatXml: Application ("application/atomcat+xml") - object AtomsvcXml: Application ("application/atomsvc+xml") - object CcxmlXml: Application ("application/ccxml+xml,") - object CdmiCapability: Application ("application/cdmi-capability") - object CdmiContainer: Application ("application/cdmi-container") - object CdmiDomain: Application ("application/cdmi-domain") - object CdmiObject: Application ("application/cdmi-object") - object CdmiQueue: Application ("application/cdmi-queue") - object CuSeeme: Application ("application/cu-seeme") - object DavmountXml: Application ("application/davmount+xml") - object DsscDer: Application ("application/dssc+der") - object DsscXml: Application ("application/dssc+xml") - object Ecmascript: Application ("application/ecmascript") - object EmmaXml: Application ("application/emma+xml") - object EpubZip: Application ("application/epub+zip") - object Exi: Application ("application/exi") - object FontTdpfr: Application ("application/font-tdpfr") - object Hyperstudio: Application ("application/hyperstudio") - object Ipfix: Application ("application/ipfix") - object JavaArchive: Application ("application/java-archive") - object JavaSerializedObject: Application ("application/java-serialized-object") - object JavaVm: Application ("application/java-vm") - object Javascript: Application ("application/javascript") - object Json: Application ("application/json") - object MacBinhex40: Application ("application/mac-binhex40") - object MacCompactpro: Application ("application/mac-compactpro") - object MadsXml: Application ("application/mads+xml") - object Marc: Application ("application/marc") - object MarcxmlXml: Application ("application/marcxml+xml") - object Mathematica: Application ("application/mathematica") - object MathmlXml: Application ("application/mathml+xml") - object Mbox: Application ("application/mbox") - object MediaservercontrolXml: Application ("application/mediaservercontrol+xml") - object Metalink4Xml: Application ("application/metalink4+xml") - object MetsXml: Application ("application/mets+xml") - object ModsXml: Application ("application/mods+xml") - object Mp21: Application ("application/mp21") - object Mp4: Application ("application/mp4") - object Msword: Application ("application/msword") - object Mxf: Application ("application/mxf") - object OctetStream: Application ("application/octet-stream") - object Oda: Application ("application/oda") - object OebpsPackageXml: Application ("application/oebps-package+xml") - object Ogg: Application ("application/ogg") - object Onenote: Application ("application/onenote") - object PatchOpsErrorXml: Application ("application/patch-ops-error+xml") - object Pdf: Application ("application/pdf") - object PgpEncrypted: Application ("application/pgp-encrypted") - object PgpSignature: Application ("application/pgp-signature") - object PicsRules: Application ("application/pics-rules") - object Pkcs10: Application ("application/pkcs10") - object Pkcs7Mime: Application ("application/pkcs7-mime") - object Pkcs7Signature: Application ("application/pkcs7-signature") - object Pkcs8: Application ("application/pkcs8") - object PkixAttrCert: Application ("application/pkix-attr-cert") - object PkixCert: Application ("application/pkix-cert") - object PkixCrl: Application ("application/pkix-crl") - object PkixPkipath: Application ("application/pkix-pkipath") - object Pkixcmp: Application ("application/pkixcmp") - object PlsXml: Application ("application/pls+xml") - object Postscript: Application ("application/postscript") - object PrsCww: Application ("application/prs.cww") - object PskcXml: Application ("application/pskc+xml") - object RdfXml: Application ("application/rdf+xml") - object ReginfoXml: Application ("application/reginfo+xml") - object RelaxNgCompactSyntax: Application ("application/relax-ng-compact-syntax") - object ResourceListsXml: Application ("application/resource-lists+xml") - object ResourceListsDiffXml: Application ("application/resource-lists-diff+xml") - object RlsServicesXml: Application ("application/rls-services+xml") - object RsdXml: Application ("application/rsd+xml") - object RssXml: Application ("application/rss+xml") - object Rtf: Application ("application/rtf") - object SbmlXml: Application ("application/sbml+xml") - object ScvpCvRequest: Application ("application/scvp-cv-request") - object ScvpCvResponse: Application ("application/scvp-cv-response") - object ScvpVpRequest: Application ("application/scvp-vp-request") - object ScvpVpResponse: Application ("application/scvp-vp-response") - object Sdp: Application ("application/sdp") - object SetPaymentInitiation: Application ("application/set-payment-initiation") - object SetRegistrationInitiation: Application ("application/set-registration-initiation") - object ShfXml: Application ("application/shf+xml") - object SmilXml: Application ("application/smil+xml") - object SparqlQuery: Application ("application/sparql-query") - object SparqlResultsXml: Application ("application/sparql-results+xml") - object Srgs: Application ("application/srgs") - object SrgsXml: Application ("application/srgs+xml") - object SruXml: Application ("application/sru+xml") - object SsmlXml: Application ("application/ssml+xml") - object TeiXml: Application ("application/tei+xml") - object ThraudXml: Application ("application/thraud+xml") - object TimestampedData: Application ("application/timestamped-data") - object Vnd3gppPicBwLarge: Application ("application/vnd.3gpp.pic-bw-large") - object Vnd3gppPicBwSmall: Application ("application/vnd.3gpp.pic-bw-small") - object Vnd3gppPicBwVar: Application ("application/vnd.3gpp.pic-bw-var") - object Vnd3gpp2Tcap: Application ("application/vnd.3gpp2.tcap") - object Vnd3mPostItNotes: Application ("application/vnd.3m.post-it-notes") - object VndAccpacSimplyAso: Application ("application/vnd.accpac.simply.aso") - object VndAccpacSimplyImp: Application ("application/vnd.accpac.simply.imp") - object VndAcucobol: Application ("application/vnd.acucobol") - object VndAcucorp: Application ("application/vnd.acucorp") - object VndAdobeAirApplicationInstallerPackageZip: Application ("application/vnd.adobe.air-application-installer-package+zip") - object VndAdobeFxp: Application ("application/vnd.adobe.fxp") - object VndAdobeXdpXml: Application ("application/vnd.adobe.xdp+xml") - object VndAdobeXfdf: Application ("application/vnd.adobe.xfdf") - object VndAheadSpace: Application ("application/vnd.ahead.space") - object VndAirzipFilesecureAzf: Application ("application/vnd.airzip.filesecure.azf") - object VndAirzipFilesecureAzs: Application ("application/vnd.airzip.filesecure.azs") - object VndAmazonEbook: Application ("application/vnd.amazon.ebook") - object VndAmericandynamicsAcc: Application ("application/vnd.americandynamics.acc") - object VndAmigaAmi: Application ("application/vnd.amiga.ami") - object VndAndroidPackageArchive: Application ("application/vnd.android.package-archive") - object VndAnserWebCertificateIssueInitiation: Application ("application/vnd.anser-web-certificate-issue-initiation") - object VndAnserWebFundsTransferInitiation: Application ("application/vnd.anser-web-funds-transfer-initiation") - object VndAntixGameComponent: Application ("application/vnd.antix.game-component") - object VndAppleInstallerXml: Application ("application/vnd.apple.installer+xml") - object VndAppleMpegurl: Application ("application/vnd.apple.mpegurl") - object VndAristanetworksSwi: Application ("application/vnd.aristanetworks.swi") - object VndAudiograph: Application ("application/vnd.audiograph") - object VndBlueiceMultipass: Application ("application/vnd.blueice.multipass") - object VndBmi: Application ("application/vnd.bmi") - object VndBusinessobjects: Application ("application/vnd.businessobjects") - object VndChemdrawXml: Application ("application/vnd.chemdraw+xml") - object VndChipnutsKaraokeMmd: Application ("application/vnd.chipnuts.karaoke-mmd") - object VndCinderella: Application ("application/vnd.cinderella") - object VndClaymore: Application ("application/vnd.claymore") - object VndCloantoRp9: Application ("application/vnd.cloanto.rp9") - object VndClonkC4group: Application ("application/vnd.clonk.c4group") - object VndCluetrustCartomobileConfig: Application ("application/vnd.cluetrust.cartomobile-config") - object VndCluetrustCartomobileConfigPkg: Application ("application/vnd.cluetrust.cartomobile-config-pkg") - object VndCommonspace: Application ("application/vnd.commonspace") - object VndContactCmsg: Application ("application/vnd.contact.cmsg") - object VndCosmocaller: Application ("application/vnd.cosmocaller") - object VndCrickClicker: Application ("application/vnd.crick.clicker") - object VndCrickClickerKeyboard: Application ("application/vnd.crick.clicker.keyboard") - object VndCrickClickerPalette: Application ("application/vnd.crick.clicker.palette") - object VndCrickClickerTemplate: Application ("application/vnd.crick.clicker.template") - object VndCrickClickerWordbank: Application ("application/vnd.crick.clicker.wordbank") - object VndCriticaltoolsWbsXml: Application ("application/vnd.criticaltools.wbs+xml") - object VndCtcPosml: Application ("application/vnd.ctc-posml") - object VndCupsPpd: Application ("application/vnd.cups-ppd") - object VndCurlCar: Application ("application/vnd.curl.car") - object VndCurlPcurl: Application ("application/vnd.curl.pcurl") - object VndDataVisionRdz: Application ("application/vnd.data-vision.rdz") - object VndDenovoFcselayoutLink: Application ("application/vnd.denovo.fcselayout-link") - object VndDna: Application ("application/vnd.dna") - object VndDolbyMlp: Application ("application/vnd.dolby.mlp") - object VndDpgraph: Application ("application/vnd.dpgraph") - object VndDreamfactory: Application ("application/vnd.dreamfactory") - object VndDvbAit: Application ("application/vnd.dvb.ait") - object VndDvbService: Application ("application/vnd.dvb.service") - object VndDynageo: Application ("application/vnd.dynageo") - object VndEcowinChart: Application ("application/vnd.ecowin.chart") - object VndEnliven: Application ("application/vnd.enliven") - object VndEpsonEsf: Application ("application/vnd.epson.esf") - object VndEpsonMsf: Application ("application/vnd.epson.msf") - object VndEpsonQuickanime: Application ("application/vnd.epson.quickanime") - object VndEpsonSalt: Application ("application/vnd.epson.salt") - object VndEpsonSsf: Application ("application/vnd.epson.ssf") - object VndEszigno3Xml: Application ("application/vnd.eszigno3+xml") - object VndEzpixAlbum: Application ("application/vnd.ezpix-album") - object VndEzpixPackage: Application ("application/vnd.ezpix-package") - object VndFdf: Application ("application/vnd.fdf") - object VndFdsnSeed: Application ("application/vnd.fdsn.seed") - object VndFlographit: Application ("application/vnd.flographit") - object VndFluxtimeClip: Application ("application/vnd.fluxtime.clip") - object VndFramemaker: Application ("application/vnd.framemaker") - object VndFrogansFnc: Application ("application/vnd.frogans.fnc") - object VndFrogansLtf: Application ("application/vnd.frogans.ltf") - object VndFscWeblaunch: Application ("application/vnd.fsc.weblaunch") - object VndFujitsuOasys: Application ("application/vnd.fujitsu.oasys") - object VndFujitsuOasys2: Application ("application/vnd.fujitsu.oasys2") - object VndFujitsuOasys3: Application ("application/vnd.fujitsu.oasys3") - object VndFujitsuOasysgp: Application ("application/vnd.fujitsu.oasysgp") - object VndFujitsuOasysprs: Application ("application/vnd.fujitsu.oasysprs") - object VndFujixeroxDdd: Application ("application/vnd.fujixerox.ddd") - object VndFujixeroxDocuworks: Application ("application/vnd.fujixerox.docuworks") - object VndFujixeroxDocuworksBinder: Application ("application/vnd.fujixerox.docuworks.binder") - object VndFuzzysheet: Application ("application/vnd.fuzzysheet") - object VndGenomatixTuxedo: Application ("application/vnd.genomatix.tuxedo") - object VndGeogebraFile: Application ("application/vnd.geogebra.file") - object VndGeogebraTool: Application ("application/vnd.geogebra.tool") - object VndGeometryExplorer: Application ("application/vnd.geometry-explorer") - object VndGeonext: Application ("application/vnd.geonext") - object VndGeoplan: Application ("application/vnd.geoplan") - object VndGeospace: Application ("application/vnd.geospace") - object VndGmx: Application ("application/vnd.gmx") - object VndGoogleEarthKmlXml: Application ("application/vnd.google-earth.kml+xml") - object VndGoogleEarthKmz: Application ("application/vnd.google-earth.kmz") - object VndGrafeq: Application ("application/vnd.grafeq") - object VndGrooveAccount: Application ("application/vnd.groove-account") - object VndGrooveHelp: Application ("application/vnd.groove-help") - object VndGrooveIdentityMessage: Application ("application/vnd.groove-identity-message") - object VndGrooveInjector: Application ("application/vnd.groove-injector") - object VndGrooveToolMessage: Application ("application/vnd.groove-tool-message") - object VndGrooveToolTemplate: Application ("application/vnd.groove-tool-template") - object VndGrooveVcard: Application ("application/vnd.groove-vcard") - object VndHalXml: Application ("application/vnd.hal+xml") - object VndHandheldEntertainmentXml: Application ("application/vnd.handheld-entertainment+xml") - object VndHbci: Application ("application/vnd.hbci") - object VndHheLessonPlayer: Application ("application/vnd.hhe.lesson-player") - object VndHpHpgl: Application ("application/vnd.hp-hpgl") - object VndHpHpid: Application ("application/vnd.hp-hpid") - object VndHpHps: Application ("application/vnd.hp-hps") - object VndHpJlyt: Application ("application/vnd.hp-jlyt") - object VndHpPcl: Application ("application/vnd.hp-pcl") - object VndHpPclxl: Application ("application/vnd.hp-pclxl") - object VndHydrostatixSofData: Application ("application/vnd.hydrostatix.sof-data") - object VndHzn3dCrossword: Application ("application/vnd.hzn-3d-crossword") - object VndIbmMinipay: Application ("application/vnd.ibm.minipay") - object VndIbmModcap: Application ("application/vnd.ibm.modcap") - object VndIbmRightsManagement: Application ("application/vnd.ibm.rights-management") - object VndIbmSecureContainer: Application ("application/vnd.ibm.secure-container") - object VndIccprofile: Application ("application/vnd.iccprofile") - object VndIgloader: Application ("application/vnd.igloader") - object VndImmervisionIvp: Application ("application/vnd.immervision-ivp") - object VndImmervisionIvu: Application ("application/vnd.immervision-ivu") - object VndInsorsIgm: Application ("application/vnd.insors.igm") - object VndInterconFormnet: Application ("application/vnd.intercon.formnet") - object VndIntergeo: Application ("application/vnd.intergeo") - object VndIntuQbo: Application ("application/vnd.intu.qbo") - object VndIntuQfx: Application ("application/vnd.intu.qfx") - object VndIpunpluggedRcprofile: Application ("application/vnd.ipunplugged.rcprofile") - object VndIrepositoryPackageXml: Application ("application/vnd.irepository.package+xml") - object VndIsXpr: Application ("application/vnd.is-xpr") - object VndIsacFcs: Application ("application/vnd.isac.fcs") - object VndJam: Application ("application/vnd.jam") - object VndJcpJavameMidletRms: Application ("application/vnd.jcp.javame.midlet-rms") - object VndJisp: Application ("application/vnd.jisp") - object VndJoostJodaArchive: Application ("application/vnd.joost.joda-archive") - object VndKahootz: Application ("application/vnd.kahootz") - object VndKdeKarbon: Application ("application/vnd.kde.karbon") - object VndKdeKchart: Application ("application/vnd.kde.kchart") - object VndKdeKformula: Application ("application/vnd.kde.kformula") - object VndKdeKivio: Application ("application/vnd.kde.kivio") - object VndKdeKontour: Application ("application/vnd.kde.kontour") - object VndKdeKpresenter: Application ("application/vnd.kde.kpresenter") - object VndKdeKspread: Application ("application/vnd.kde.kspread") - object VndKdeKword: Application ("application/vnd.kde.kword") - object VndKenameaapp: Application ("application/vnd.kenameaapp") - object VndKidspiration: Application ("application/vnd.kidspiration") - object VndKinar: Application ("application/vnd.kinar") - object VndKoan: Application ("application/vnd.koan") - object VndKodakDescriptor: Application ("application/vnd.kodak-descriptor") - object VndLasLasXml: Application ("application/vnd.las.las+xml") - object VndLlamagraphicsLifeBalanceDesktop: Application ("application/vnd.llamagraphics.life-balance.desktop") - object VndLlamagraphicsLifeBalanceExchangeXml: Application ("application/vnd.llamagraphics.life-balance.exchange+xml") - object VndLotus123: Application ("application/vnd.lotus-1-2-3") - object VndLotusApproach: Application ("application/vnd.lotus-approach") - object VndLotusFreelance: Application ("application/vnd.lotus-freelance") - object VndLotusNotes: Application ("application/vnd.lotus-notes") - object VndLotusOrganizer: Application ("application/vnd.lotus-organizer") - object VndLotusScreencam: Application ("application/vnd.lotus-screencam") - object VndLotusWordpro: Application ("application/vnd.lotus-wordpro") - object VndMacportsPortpkg: Application ("application/vnd.macports.portpkg") - object VndMcd: Application ("application/vnd.mcd") - object VndMedcalcdata: Application ("application/vnd.medcalcdata") - object VndMediastationCdkey: Application ("application/vnd.mediastation.cdkey") - object VndMfer: Application ("application/vnd.mfer") - object VndMfmp: Application ("application/vnd.mfmp") - object VndMicrografxFlo: Application ("application/vnd.micrografx.flo") - object VndMicrografxIgx: Application ("application/vnd.micrografx.igx") - object VndMif: Application ("application/vnd.mif") - object VndMobiusDaf: Application ("application/vnd.mobius.daf") - object VndMobiusDis: Application ("application/vnd.mobius.dis") - object VndMobiusMbk: Application ("application/vnd.mobius.mbk") - object VndMobiusMqy: Application ("application/vnd.mobius.mqy") - object VndMobiusMsl: Application ("application/vnd.mobius.msl") - object VndMobiusPlc: Application ("application/vnd.mobius.plc") - object VndMobiusTxf: Application ("application/vnd.mobius.txf") - object VndMophunApplication: Application ("application/vnd.mophun.application") - object VndMophunCertificate: Application ("application/vnd.mophun.certificate") - object VndMozillaXulXml: Application ("application/vnd.mozilla.xul+xml") - object VndMsArtgalry: Application ("application/vnd.ms-artgalry") - object VndMsCabCompressed: Application ("application/vnd.ms-cab-compressed") - object VndMsExcel: Application ("application/vnd.ms-excel") - object VndMsExcelAddinMacroenabled12: Application ("application/vnd.ms-excel.addin.macroenabled.12") - object VndMsExcelSheetBinaryMacroenabled12: Application ("application/vnd.ms-excel.sheet.binary.macroenabled.12") - object VndMsExcelSheetMacroenabled12: Application ("application/vnd.ms-excel.sheet.macroenabled.12") - object VndMsExcelTemplateMacroenabled12: Application ("application/vnd.ms-excel.template.macroenabled.12") - object VndMsFontobject: Application ("application/vnd.ms-fontobject") - object VndMsHtmlhelp: Application ("application/vnd.ms-htmlhelp") - object VndMsIms: Application ("application/vnd.ms-ims") - object VndMsLrm: Application ("application/vnd.ms-lrm") - object VndMsOfficetheme: Application ("application/vnd.ms-officetheme") - object VndMsPkiSeccat: Application ("application/vnd.ms-pki.seccat") - object VndMsPkiStl: Application ("application/vnd.ms-pki.stl") - object VndMsPowerpoint: Application ("application/vnd.ms-powerpoint") - object VndMsPowerpointAddinMacroenabled12: Application ("application/vnd.ms-powerpoint.addin.macroenabled.12") - object VndMsPowerpointPresentationMacroenabled12: Application ("application/vnd.ms-powerpoint.presentation.macroenabled.12") - object VndMsPowerpointSlideMacroenabled12: Application ("application/vnd.ms-powerpoint.slide.macroenabled.12") - object VndMsPowerpointSlideshowMacroenabled12: Application ("application/vnd.ms-powerpoint.slideshow.macroenabled.12") - object VndMsPowerpointTemplateMacroenabled12: Application ("application/vnd.ms-powerpoint.template.macroenabled.12") - object VndMsProject: Application ("application/vnd.ms-project") - object VndMsWordDocumentMacroenabled12: Application ("application/vnd.ms-word.document.macroenabled.12") - object VndMsWordTemplateMacroenabled12: Application ("application/vnd.ms-word.template.macroenabled.12") - object VndMsWorks: Application ("application/vnd.ms-works") - object VndMsWpl: Application ("application/vnd.ms-wpl") - object VndMsXpsdocument: Application ("application/vnd.ms-xpsdocument") - object VndMseq: Application ("application/vnd.mseq") - object VndMusician: Application ("application/vnd.musician") - object VndMuveeStyle: Application ("application/vnd.muvee.style") - object VndNeurolanguageNlu: Application ("application/vnd.neurolanguage.nlu") - object VndNoblenetDirectory: Application ("application/vnd.noblenet-directory") - object VndNoblenetSealer: Application ("application/vnd.noblenet-sealer") - object VndNoblenetWeb: Application ("application/vnd.noblenet-web") - object VndNokiaNGageData: Application ("application/vnd.nokia.n-gage.data") - object VndNokiaNGageSymbianInstall: Application ("application/vnd.nokia.n-gage.symbian.install") - object VndNokiaRadioPreset: Application ("application/vnd.nokia.radio-preset") - object VndNokiaRadioPresets: Application ("application/vnd.nokia.radio-presets") - object VndNovadigmEdm: Application ("application/vnd.novadigm.edm") - object VndNovadigmEdx: Application ("application/vnd.novadigm.edx") - object VndNovadigmExt: Application ("application/vnd.novadigm.ext") - object VndOasisOpendocumentChart: Application ("application/vnd.oasis.opendocument.chart") - object VndOasisOpendocumentChartTemplate: Application ("application/vnd.oasis.opendocument.chart-template") - object VndOasisOpendocumentDatabase: Application ("application/vnd.oasis.opendocument.database") - object VndOasisOpendocumentFormula: Application ("application/vnd.oasis.opendocument.formula") - object VndOasisOpendocumentFormulaTemplate: Application ("application/vnd.oasis.opendocument.formula-template") - object VndOasisOpendocumentGraphics: Application ("application/vnd.oasis.opendocument.graphics") - object VndOasisOpendocumentGraphicsTemplate: Application ("application/vnd.oasis.opendocument.graphics-template") - object VndOasisOpendocumentImage: Application ("application/vnd.oasis.opendocument.image") - object VndOasisOpendocumentImageTemplate: Application ("application/vnd.oasis.opendocument.image-template") - object VndOasisOpendocumentPresentation: Application ("application/vnd.oasis.opendocument.presentation") - object VndOasisOpendocumentPresentationTemplate: Application ("application/vnd.oasis.opendocument.presentation-template") - object VndOasisOpendocumentSpreadsheet: Application ("application/vnd.oasis.opendocument.spreadsheet") - object VndOasisOpendocumentSpreadsheetTemplate: Application ("application/vnd.oasis.opendocument.spreadsheet-template") - object VndOasisOpendocumentText: Application ("application/vnd.oasis.opendocument.text") - object VndOasisOpendocumentTextMaster: Application ("application/vnd.oasis.opendocument.text-master") - object VndOasisOpendocumentTextTemplate: Application ("application/vnd.oasis.opendocument.text-template") - object VndOasisOpendocumentTextWeb: Application ("application/vnd.oasis.opendocument.text-web") - object VndOlpcSugar: Application ("application/vnd.olpc-sugar") - object VndOmaDd2Xml: Application ("application/vnd.oma.dd2+xml") - object VndOpenofficeorgExtension: Application ("application/vnd.openofficeorg.extension") - object VndOpenxmlformatsOfficedocumentPresentationmlPresentation: Application ("application/vnd.openxmlformats-officedocument.presentationml.presentation") - object VndOpenxmlformatsOfficedocumentPresentationmlSlide: Application ("application/vnd.openxmlformats-officedocument.presentationml.slide") - object VndOpenxmlformatsOfficedocumentPresentationmlSlideshow: Application ("application/vnd.openxmlformats-officedocument.presentationml.slideshow") - object VndOpenxmlformatsOfficedocumentPresentationmlTemplate: Application ("application/vnd.openxmlformats-officedocument.presentationml.template") - object VndOpenxmlformatsOfficedocumentSpreadsheetmlSheet: Application ("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") - object VndOpenxmlformatsOfficedocumentSpreadsheetmlTemplate: Application ("application/vnd.openxmlformats-officedocument.spreadsheetml.template") - object VndOpenxmlformatsOfficedocumentWordprocessingmlDocument: Application ("application/vnd.openxmlformats-officedocument.wordprocessingml.document") - object VndOpenxmlformatsOfficedocumentWordprocessingmlTemplate: Application ("application/vnd.openxmlformats-officedocument.wordprocessingml.template") - object VndOsgeoMapguidePackage: Application ("application/vnd.osgeo.mapguide.package") - object VndOsgiDp: Application ("application/vnd.osgi.dp") - object VndPalm: Application ("application/vnd.palm") - object VndPawaafile: Application ("application/vnd.pawaafile") - object VndPgFormat: Application ("application/vnd.pg.format") - object VndPgOsasli: Application ("application/vnd.pg.osasli") - object VndPicsel: Application ("application/vnd.picsel") - object VndPmiWidget: Application ("application/vnd.pmi.widget") - object VndPocketlearn: Application ("application/vnd.pocketlearn") - object VndPowerbuilder6: Application ("application/vnd.powerbuilder6") - object VndPreviewsystemsBox: Application ("application/vnd.previewsystems.box") - object VndProteusMagazine: Application ("application/vnd.proteus.magazine") - object VndPublishareDeltaTree: Application ("application/vnd.publishare-delta-tree") - object VndPviPtid1: Application ("application/vnd.pvi.ptid1") - object VndQuarkQuarkxpress: Application ("application/vnd.quark.quarkxpress") - object VndRealvncBed: Application ("application/vnd.realvnc.bed") - object VndRecordareMusicxml: Application ("application/vnd.recordare.musicxml") - object VndRecordareMusicxmlXml: Application ("application/vnd.recordare.musicxml+xml") - object VndRigCryptonote: Application ("application/vnd.rig.cryptonote") - object VndRimCod: Application ("application/vnd.rim.cod") - object VndRnRealmedia: Application ("application/vnd.rn-realmedia") - object VndRoute66Link66Xml: Application ("application/vnd.route66.link66+xml") - object VndSailingtrackerTrack: Application ("application/vnd.sailingtracker.track") - object VndSeemail: Application ("application/vnd.seemail") - object VndSema: Application ("application/vnd.sema") - object VndSemd: Application ("application/vnd.semd") - object VndSemf: Application ("application/vnd.semf") - object VndShanaInformedFormdata: Application ("application/vnd.shana.informed.formdata") - object VndShanaInformedFormtemplate: Application ("application/vnd.shana.informed.formtemplate") - object VndShanaInformedInterchange: Application ("application/vnd.shana.informed.interchange") - object VndShanaInformedPackage: Application ("application/vnd.shana.informed.package") - object VndSimtechMindmapper: Application ("application/vnd.simtech-mindmapper") - object VndSmaf: Application ("application/vnd.smaf") - object VndSmartTeacher: Application ("application/vnd.smart.teacher") - object VndSolentSdkmXml: Application ("application/vnd.solent.sdkm+xml") - object VndSpotfireDxp: Application ("application/vnd.spotfire.dxp") - object VndSpotfireSfs: Application ("application/vnd.spotfire.sfs") - object VndStardivisionCalc: Application ("application/vnd.stardivision.calc") - object VndStardivisionDraw: Application ("application/vnd.stardivision.draw") - object VndStardivisionImpress: Application ("application/vnd.stardivision.impress") - object VndStardivisionMath: Application ("application/vnd.stardivision.math") - object VndStardivisionWriter: Application ("application/vnd.stardivision.writer") - object VndStardivisionWriterGlobal: Application ("application/vnd.stardivision.writer-global") - object VndStepmaniaStepchart: Application ("application/vnd.stepmania.stepchart") - object VndSunXmlCalc: Application ("application/vnd.sun.xml.calc") - object VndSunXmlCalcTemplate: Application ("application/vnd.sun.xml.calc.template") - object VndSunXmlDraw: Application ("application/vnd.sun.xml.draw") - object VndSunXmlDrawTemplate: Application ("application/vnd.sun.xml.draw.template") - object VndSunXmlImpress: Application ("application/vnd.sun.xml.impress") - object VndSunXmlImpressTemplate: Application ("application/vnd.sun.xml.impress.template") - object VndSunXmlMath: Application ("application/vnd.sun.xml.math") - object VndSunXmlWriter: Application ("application/vnd.sun.xml.writer") - object VndSunXmlWriterGlobal: Application ("application/vnd.sun.xml.writer.global") - object VndSunXmlWriterTemplate: Application ("application/vnd.sun.xml.writer.template") - object VndSusCalendar: Application ("application/vnd.sus-calendar") - object VndSvd: Application ("application/vnd.svd") - object VndSymbianInstall: Application ("application/vnd.symbian.install") - object VndSyncmlXml: Application ("application/vnd.syncml+xml") - object VndSyncmlDmWbxml: Application ("application/vnd.syncml.dm+wbxml") - object VndSyncmlDmXml: Application ("application/vnd.syncml.dm+xml") - object VndTaoIntentModuleArchive: Application ("application/vnd.tao.intent-module-archive") - object VndTmobileLivetv: Application ("application/vnd.tmobile-livetv") - object VndTridTpt: Application ("application/vnd.trid.tpt") - object VndTriscapeMxs: Application ("application/vnd.triscape.mxs") - object VndTrueapp: Application ("application/vnd.trueapp") - object VndUfdl: Application ("application/vnd.ufdl") - object VndUiqTheme: Application ("application/vnd.uiq.theme") - object VndUmajin: Application ("application/vnd.umajin") - object VndUnity: Application ("application/vnd.unity") - object VndUomlXml: Application ("application/vnd.uoml+xml") - object VndVcx: Application ("application/vnd.vcx") - object VndVisio: Application ("application/vnd.visio") - object VndVisio2013: Application ("application/vnd.visio2013") - object VndVisionary: Application ("application/vnd.visionary") - object VndVsf: Application ("application/vnd.vsf") - object VndWapWbxml: Application ("application/vnd.wap.wbxml") - object VndWapWmlc: Application ("application/vnd.wap.wmlc") - object VndWapWmlscriptc: Application ("application/vnd.wap.wmlscriptc") - object VndWebturbo: Application ("application/vnd.webturbo") - object VndWolframPlayer: Application ("application/vnd.wolfram.player") - object VndWordperfect: Application ("application/vnd.wordperfect") - object VndWqd: Application ("application/vnd.wqd") - object VndWtStf: Application ("application/vnd.wt.stf") - object VndXara: Application ("application/vnd.xara") - object VndXfdl: Application ("application/vnd.xfdl") - object VndYamahaHvDic: Application ("application/vnd.yamaha.hv-dic") - object VndYamahaHvScript: Application ("application/vnd.yamaha.hv-script") - object VndYamahaHvVoice: Application ("application/vnd.yamaha.hv-voice") - object VndYamahaOpenscoreformat: Application ("application/vnd.yamaha.openscoreformat") - object VndYamahaOpenscoreformatOsfpvgXml: Application ("application/vnd.yamaha.openscoreformat.osfpvg+xml") - object VndYamahaSmafAudio: Application ("application/vnd.yamaha.smaf-audio") - object VndYamahaSmafPhrase: Application ("application/vnd.yamaha.smaf-phrase") - object VndYellowriverCustomMenu: Application ("application/vnd.yellowriver-custom-menu") - object VndZul: Application ("application/vnd.zul") - object VndZzazzDeckXml: Application ("application/vnd.zzazz.deck+xml") - object VoicexmlXml: Application ("application/voicexml+xml") - object Widget: Application ("application/widget") - object Winhlp: Application ("application/winhlp") - object WsdlXml: Application ("application/wsdl+xml") - object WspolicyXml: Application ("application/wspolicy+xml") - object X7zCompressed: Application ("application/x-7z-compressed") - object XAbiword: Application ("application/x-abiword") - object XAceCompressed: Application ("application/x-ace-compressed") - object XAuthorwareBin: Application ("application/x-authorware-bin") - object XAuthorwareMap: Application ("application/x-authorware-map") - object XAuthorwareSeg: Application ("application/x-authorware-seg") - object XBcpio: Application ("application/x-bcpio") - object XBittorrent: Application ("application/x-bittorrent") - object XBzip: Application ("application/x-bzip") - object XBzip2: Application ("application/x-bzip2") - object XCdlink: Application ("application/x-cdlink") - object XChat: Application ("application/x-chat") - object XChessPgn: Application ("application/x-chess-pgn") - object XCpio: Application ("application/x-cpio") - object XCsh: Application ("application/x-csh") - object XDebianPackage: Application ("application/x-debian-package") - object XDirector: Application ("application/x-director") - object XDoom: Application ("application/x-doom") - object XDtbncxXml: Application ("application/x-dtbncx+xml") - object XDtbookXml: Application ("application/x-dtbook+xml") - object XDtbresourceXml: Application ("application/x-dtbresource+xml") - object XDvi: Application ("application/x-dvi") - object XFontBdf: Application ("application/x-font-bdf") - object XFontGhostscript: Application ("application/x-font-ghostscript") - object XFontLinuxPsf: Application ("application/x-font-linux-psf") - object XFontOtf: Application ("application/x-font-otf") - object XFontPcf: Application ("application/x-font-pcf") - object XFontSnf: Application ("application/x-font-snf") - object XFontTtf: Application ("application/x-font-ttf") - object XFontType1: Application ("application/x-font-type1") - object XFontWoff: Application ("application/x-font-woff") - object XFuturesplash: Application ("application/x-futuresplash") - object XGnumeric: Application ("application/x-gnumeric") - object XGtar: Application ("application/x-gtar") - object XHdf: Application ("application/x-hdf") - object XJavaJnlpFile: Application ("application/x-java-jnlp-file") - object XLatex: Application ("application/x-latex") - object XMobipocketEbook: Application ("application/x-mobipocket-ebook") - object XMsApplication: Application ("application/x-ms-application") - object XMsWmd: Application ("application/x-ms-wmd") - object XMsWmz: Application ("application/x-ms-wmz") - object XMsXbap: Application ("application/x-ms-xbap") - object XMsaccess: Application ("application/x-msaccess") - object XMsbinder: Application ("application/x-msbinder") - object XMscardfile: Application ("application/x-mscardfile") - object XMsclip: Application ("application/x-msclip") - object XMsdownload: Application ("application/x-msdownload") - object XMsmediaview: Application ("application/x-msmediaview") - object XMsmetafile: Application ("application/x-msmetafile") - object XMsmoney: Application ("application/x-msmoney") - object XMspublisher: Application ("application/x-mspublisher") - object XMsschedule: Application ("application/x-msschedule") - object XMsterminal: Application ("application/x-msterminal") - object XMswrite: Application ("application/x-mswrite") - object XNetcdf: Application ("application/x-netcdf") - object XPkcs12: Application ("application/x-pkcs12") - object XPkcs7Certificates: Application ("application/x-pkcs7-certificates") - object XPkcs7Certreqresp: Application ("application/x-pkcs7-certreqresp") - object XRarCompressed: Application ("application/x-rar-compressed") - object XSh: Application ("application/x-sh") - object XShar: Application ("application/x-shar") - object XShockwaveFlash: Application ("application/x-shockwave-flash") - object XSilverlightApp: Application ("application/x-silverlight-app") - object XStuffit: Application ("application/x-stuffit") - object XStuffitx: Application ("application/x-stuffitx") - object XSv4cpio: Application ("application/x-sv4cpio") - object XSv4crc: Application ("application/x-sv4crc") - object XTar: Application ("application/x-tar") - object XTcl: Application ("application/x-tcl") - object XTex: Application ("application/x-tex") - object XTexTfm: Application ("application/x-tex-tfm") - object XTexinfo: Application ("application/x-texinfo") - object XUstar: Application ("application/x-ustar") - object XWaisSource: Application ("application/x-wais-source") - object XX509CaCert: Application ("application/x-x509-ca-cert") - object XXfig: Application ("application/x-xfig") - object XXpinstall: Application ("application/x-xpinstall") - object XcapDiffXml: Application ("application/xcap-diff+xml") - object XencXml: Application ("application/xenc+xml") - object XhtmlXml: Application ("application/xhtml+xml") - object Xml: Application ("application/xml") - object XmlDtd: Application ("application/xml-dtd") - object XopXml: Application ("application/xop+xml") - object XsltXml: Application ("application/xslt+xml") - object XspfXml: Application ("application/xspf+xml") - object XvXml: Application ("application/xv+xml") - object Yang: Application ("application/yang") - object YinXml: Application ("application/yin+xml") - object Zip: Application ("application/zip") - object XAppleDiskimage: Application ("application/x-apple-diskimage") - } - - sealed class Audio(raw: String) : MimeType, KnownMimeTypes(raw) { - object Any: Audio ("audio/*") - object Adpcm: Audio ("audio/adpcm") - object Basic: Audio ("audio/basic") - object Midi: Audio ("audio/midi") - object Mp4: Audio ("audio/mp4") - object Mpeg: Audio ("audio/mpeg") - object Ogg: Audio ("audio/ogg") - object VndDeceAudio: Audio ("audio/vnd.dece.audio") - object VndDigitalWinds: Audio ("audio/vnd.digital-winds") - object VndDra: Audio ("audio/vnd.dra") - object VndDts: Audio ("audio/vnd.dts") - object VndDtsHd: Audio ("audio/vnd.dts.hd") - object VndLucentVoice: Audio ("audio/vnd.lucent.voice") - object VndMsPlayreadyMediaPya: Audio ("audio/vnd.ms-playready.media.pya") - object VndNueraEcelp4800: Audio ("audio/vnd.nuera.ecelp4800") - object VndNueraEcelp7470: Audio ("audio/vnd.nuera.ecelp7470") - object VndNueraEcelp9600: Audio ("audio/vnd.nuera.ecelp9600") - object VndRip: Audio ("audio/vnd.rip") - object Webm: Audio ("audio/webm") - object XAac: Audio ("audio/x-aac") - object XAiff: Audio ("audio/x-aiff") - object XMpegurl: Audio ("audio/x-mpegurl") - object XMsWax: Audio ("audio/x-ms-wax") - object XMsWma: Audio ("audio/x-ms-wma") - object XPnRealaudio: Audio ("audio/x-pn-realaudio") - object XPnRealaudioPlugin: Audio ("audio/x-pn-realaudio-plugin") - object XWav: Audio ("audio/x-wav") - } - - sealed class Chemical(raw: String) : MimeType, KnownMimeTypes(raw) { - object Any: Chemical ("chemical/*") - object XCdx: Chemical ("chemical/x-cdx") - object XCif: Chemical ("chemical/x-cif") - object XCmdf: Chemical ("chemical/x-cmdf") - object XCml: Chemical ("chemical/x-cml") - object XCsml: Chemical ("chemical/x-csml") - object XXyz: Chemical ("chemical/x-xyz") - } - - sealed class Image(raw: String) : MimeType, KnownMimeTypes(raw) { - object Any: Image ("image/*") - object Bmp: Image ("image/bmp") - object Cgm: Image ("image/cgm") - object G3fax: Image ("image/g3fax") - object Gif: Image ("image/gif") - object Ief: Image ("image/ief") - object Jpeg: Image ("image/jpeg") - object Pjpeg: Image ("image/pjpeg") - object XCitrixJpeg: Image ("image/x-citrix-jpeg") - object Ktx: Image ("image/ktx") - object Png: Image ("image/png") - object XPng: Image ("image/x-png") - object XCitrixPng: Image ("image/x-citrix-png") - object PrsBtif: Image ("image/prs.btif") - object SvgXml: Image ("image/svg+xml") - object Tiff: Image ("image/tiff") - object VndAdobePhotoshop: Image ("image/vnd.adobe.photoshop") - object VndDeceGraphic: Image ("image/vnd.dece.graphic") - object VndDvbSubtitle: Image ("image/vnd.dvb.subtitle") - object VndDjvu: Image ("image/vnd.djvu") - object VndDwg: Image ("image/vnd.dwg") - object VndDxf: Image ("image/vnd.dxf") - object VndFastbidsheet: Image ("image/vnd.fastbidsheet") - object VndFpx: Image ("image/vnd.fpx") - object VndFst: Image ("image/vnd.fst") - object VndFujixeroxEdmicsMmr: Image ("image/vnd.fujixerox.edmics-mmr") - object VndFujixeroxEdmicsRlc: Image ("image/vnd.fujixerox.edmics-rlc") - object VndMsModi: Image ("image/vnd.ms-modi") - object VndNetFpx: Image ("image/vnd.net-fpx") - object VndWapWbmp: Image ("image/vnd.wap.wbmp") - object VndXiff: Image ("image/vnd.xiff") - object Webp: Image ("image/webp") - object XCmuRaster: Image ("image/x-cmu-raster") - object XCmx: Image ("image/x-cmx") - object XFreehand: Image ("image/x-freehand") - object XIcon: Image ("image/x-icon") - object XPcx: Image ("image/x-pcx") - object XPict: Image ("image/x-pict") - object XPortableAnymap: Image ("image/x-portable-anymap") - object XPortableBitmap: Image ("image/x-portable-bitmap") - object XPortableGraymap: Image ("image/x-portable-graymap") - object XPortablePixmap: Image ("image/x-portable-pixmap") - object XRgb: Image ("image/x-rgb") - object XXbitmap: Image ("image/x-xbitmap") - object XXpixmap: Image ("image/x-xpixmap") - object XXwindowdump: Image ("image/x-xwindowdump") - } - - sealed class Message(raw: String) : MimeType, KnownMimeTypes(raw) { - object Any: Message ("message/*") - object Rfc822: Message ("message/rfc822") - } - - sealed class Model(raw: String) : MimeType, KnownMimeTypes(raw) { - object Any: Model ("model/*") - object Iges: Model ("model/iges") - object Mesh: Model ("model/mesh") - object VndColladaXml: Model ("model/vnd.collada+xml") - object VndDwf: Model ("model/vnd.dwf") - object VndGdl: Model ("model/vnd.gdl") - object VndGtw: Model ("model/vnd.gtw") - object VndMts: Model ("model/vnd.mts") - object VndVtu: Model ("model/vnd.vtu") - object Vrml: Model ("model/vrml") - } - - sealed class Text(raw: String) : MimeType, KnownMimeTypes(raw) { - object Any: Text ("text/*") - object Calendar: Text ("text/calendar") - object Css: Text ("text/css") - object Csv: Text ("text/csv") - object Html: Text ("text/html") - object N3: Text ("text/n3") - object Plain: Text ("text/plain") - object PrsLinesTag: Text ("text/prs.lines.tag") - object Richtext: Text ("text/richtext") - object Sgml: Text ("text/sgml") - object TabSeparatedValues: Text ("text/tab-separated-values") - object Troff: Text ("text/troff") - object Turtle: Text ("text/turtle") - object UriList: Text ("text/uri-list") - object VndCurl: Text ("text/vnd.curl") - object VndCurlDcurl: Text ("text/vnd.curl.dcurl") - object VndCurlScurl: Text ("text/vnd.curl.scurl") - object VndCurlMcurl: Text ("text/vnd.curl.mcurl") - object VndFly: Text ("text/vnd.fly") - object VndFmiFlexstor: Text ("text/vnd.fmi.flexstor") - object VndGraphviz: Text ("text/vnd.graphviz") - object VndIn3d3dml: Text ("text/vnd.in3d.3dml") - object VndIn3dSpot: Text ("text/vnd.in3d.spot") - object VndSunJ2meAppDescriptor: Text ("text/vnd.sun.j2me.app-descriptor") - object VndWapWml: Text ("text/vnd.wap.wml") - object VndWapWmlscript: Text ("text/vnd.wap.wmlscript") - object XAsm: Text ("text/x-asm") - object XC: Text ("text/x-c") - object XFortran: Text ("text/x-fortran") - object XPascal: Text ("text/x-pascal") - object XJavaSourceJava: Text ("text/x-java-source,java") - object XSetext: Text ("text/x-setext") - object XUuencode: Text ("text/x-uuencode") - object XVcalendar: Text ("text/x-vcalendar") - object XVcard: Text ("text/x-vcard") - object PlainBas: Text ("text/plain-bas") - object Yaml: Text ("text/yaml") - } - - sealed class Video(raw: String) : MimeType, KnownMimeTypes(raw) { - object Any: Video ("video/*") - object V3gpp: Video ("video/3gpp") - object V3gpp2: Video ("video/3gpp2") - object H261: Video ("video/h261") - object H263: Video ("video/h263") - object H264: Video ("video/h264") - object Jpeg: Video ("video/jpeg") - object Jpm: Video ("video/jpm") - object Mj2: Video ("video/mj2") - object Mp4: Video ("video/mp4") - object Mpeg: Video ("video/mpeg") - object Ogg: Video ("video/ogg") - object Quicktime: Video ("video/quicktime") - object VndDeceHd: Video ("video/vnd.dece.hd") - object VndDeceMobile: Video ("video/vnd.dece.mobile") - object VndDecePd: Video ("video/vnd.dece.pd") - object VndDeceSd: Video ("video/vnd.dece.sd") - object VndDeceVideo: Video ("video/vnd.dece.video") - object VndFvt: Video ("video/vnd.fvt") - object VndMpegurl: Video ("video/vnd.mpegurl") - object VndMsPlayreadyMediaPyv: Video ("video/vnd.ms-playready.media.pyv") - object VndUvvuMp4: Video ("video/vnd.uvvu.mp4") - object VndVivo: Video ("video/vnd.vivo") - object Webm: Video ("video/webm") - object XF4v: Video ("video/x-f4v") - object XFli: Video ("video/x-fli") - object XFlv: Video ("video/x-flv") - object XM4v: Video ("video/x-m4v") - object XMsAsf: Video ("video/x-ms-asf") - object XMsWm: Video ("video/x-ms-wm") - object XMsWmv: Video ("video/x-ms-wmv") - object XMsWmx: Video ("video/x-ms-wmx") - object XMsWvx: Video ("video/x-ms-wvx") - object XMsvideo: Video ("video/x-msvideo") - object XSgiMovie: Video ("video/x-sgi-movie") - } - - sealed class XConference(raw: String) : MimeType, KnownMimeTypes(raw) { - object Any: XConference ("x-conference/*") - object XCooltalk: XConference ("x-conference/x-cooltalk") - } - - -} - -internal val knownMimeTypes: Set = setOf( - KnownMimeTypes.Any, - KnownMimeTypes.Application.AndrewInset, - KnownMimeTypes.Application.Applixware, - KnownMimeTypes.Application.AtomXml, - KnownMimeTypes.Application.AtomcatXml, - KnownMimeTypes.Application.AtomsvcXml, - KnownMimeTypes.Application.CcxmlXml, - KnownMimeTypes.Application.CdmiCapability, - KnownMimeTypes.Application.CdmiContainer, - KnownMimeTypes.Application.CdmiDomain, - KnownMimeTypes.Application.CdmiObject, - KnownMimeTypes.Application.CdmiQueue, - KnownMimeTypes.Application.CuSeeme, - KnownMimeTypes.Application.DavmountXml, - KnownMimeTypes.Application.DsscDer, - KnownMimeTypes.Application.DsscXml, - KnownMimeTypes.Application.Ecmascript, - KnownMimeTypes.Application.EmmaXml, - KnownMimeTypes.Application.EpubZip, - KnownMimeTypes.Application.Exi, - KnownMimeTypes.Application.FontTdpfr, - KnownMimeTypes.Application.Hyperstudio, - KnownMimeTypes.Application.Ipfix, - KnownMimeTypes.Application.JavaArchive, - KnownMimeTypes.Application.JavaSerializedObject, - KnownMimeTypes.Application.JavaVm, - KnownMimeTypes.Application.Javascript, - KnownMimeTypes.Application.Json, - KnownMimeTypes.Application.MacBinhex40, - KnownMimeTypes.Application.MacCompactpro, - KnownMimeTypes.Application.MadsXml, - KnownMimeTypes.Application.Marc, - KnownMimeTypes.Application.MarcxmlXml, - KnownMimeTypes.Application.Mathematica, - KnownMimeTypes.Application.MathmlXml, - KnownMimeTypes.Application.Mbox, - KnownMimeTypes.Application.MediaservercontrolXml, - KnownMimeTypes.Application.Metalink4Xml, - KnownMimeTypes.Application.MetsXml, - KnownMimeTypes.Application.ModsXml, - KnownMimeTypes.Application.Mp21, - KnownMimeTypes.Application.Mp4, - KnownMimeTypes.Application.Msword, - KnownMimeTypes.Application.Mxf, - KnownMimeTypes.Application.OctetStream, - KnownMimeTypes.Application.Oda, - KnownMimeTypes.Application.OebpsPackageXml, - KnownMimeTypes.Application.Ogg, - KnownMimeTypes.Application.Onenote, - KnownMimeTypes.Application.PatchOpsErrorXml, - KnownMimeTypes.Application.Pdf, - KnownMimeTypes.Application.PgpEncrypted, - KnownMimeTypes.Application.PgpSignature, - KnownMimeTypes.Application.PicsRules, - KnownMimeTypes.Application.Pkcs10, - KnownMimeTypes.Application.Pkcs7Mime, - KnownMimeTypes.Application.Pkcs7Signature, - KnownMimeTypes.Application.Pkcs8, - KnownMimeTypes.Application.PkixAttrCert, - KnownMimeTypes.Application.PkixCert, - KnownMimeTypes.Application.PkixCrl, - KnownMimeTypes.Application.PkixPkipath, - KnownMimeTypes.Application.Pkixcmp, - KnownMimeTypes.Application.PlsXml, - KnownMimeTypes.Application.Postscript, - KnownMimeTypes.Application.PrsCww, - KnownMimeTypes.Application.PskcXml, - KnownMimeTypes.Application.RdfXml, - KnownMimeTypes.Application.ReginfoXml, - KnownMimeTypes.Application.RelaxNgCompactSyntax, - KnownMimeTypes.Application.ResourceListsXml, - KnownMimeTypes.Application.ResourceListsDiffXml, - KnownMimeTypes.Application.RlsServicesXml, - KnownMimeTypes.Application.RsdXml, - KnownMimeTypes.Application.RssXml, - KnownMimeTypes.Application.Rtf, - KnownMimeTypes.Application.SbmlXml, - KnownMimeTypes.Application.ScvpCvRequest, - KnownMimeTypes.Application.ScvpCvResponse, - KnownMimeTypes.Application.ScvpVpRequest, - KnownMimeTypes.Application.ScvpVpResponse, - KnownMimeTypes.Application.Sdp, - KnownMimeTypes.Application.SetPaymentInitiation, - KnownMimeTypes.Application.SetRegistrationInitiation, - KnownMimeTypes.Application.ShfXml, - KnownMimeTypes.Application.SmilXml, - KnownMimeTypes.Application.SparqlQuery, - KnownMimeTypes.Application.SparqlResultsXml, - KnownMimeTypes.Application.Srgs, - KnownMimeTypes.Application.SrgsXml, - KnownMimeTypes.Application.SruXml, - KnownMimeTypes.Application.SsmlXml, - KnownMimeTypes.Application.TeiXml, - KnownMimeTypes.Application.ThraudXml, - KnownMimeTypes.Application.TimestampedData, - KnownMimeTypes.Application.Vnd3gppPicBwLarge, - KnownMimeTypes.Application.Vnd3gppPicBwSmall, - KnownMimeTypes.Application.Vnd3gppPicBwVar, - KnownMimeTypes.Application.Vnd3gpp2Tcap, - KnownMimeTypes.Application.Vnd3mPostItNotes, - KnownMimeTypes.Application.VndAccpacSimplyAso, - KnownMimeTypes.Application.VndAccpacSimplyImp, - KnownMimeTypes.Application.VndAcucobol, - KnownMimeTypes.Application.VndAcucorp, - KnownMimeTypes.Application.VndAdobeAirApplicationInstallerPackageZip, - KnownMimeTypes.Application.VndAdobeFxp, - KnownMimeTypes.Application.VndAdobeXdpXml, - KnownMimeTypes.Application.VndAdobeXfdf, - KnownMimeTypes.Application.VndAheadSpace, - KnownMimeTypes.Application.VndAirzipFilesecureAzf, - KnownMimeTypes.Application.VndAirzipFilesecureAzs, - KnownMimeTypes.Application.VndAmazonEbook, - KnownMimeTypes.Application.VndAmericandynamicsAcc, - KnownMimeTypes.Application.VndAmigaAmi, - KnownMimeTypes.Application.VndAndroidPackageArchive, - KnownMimeTypes.Application.VndAnserWebCertificateIssueInitiation, - KnownMimeTypes.Application.VndAnserWebFundsTransferInitiation, - KnownMimeTypes.Application.VndAntixGameComponent, - KnownMimeTypes.Application.VndAppleInstallerXml, - KnownMimeTypes.Application.VndAppleMpegurl, - KnownMimeTypes.Application.VndAristanetworksSwi, - KnownMimeTypes.Application.VndAudiograph, - KnownMimeTypes.Application.VndBlueiceMultipass, - KnownMimeTypes.Application.VndBmi, - KnownMimeTypes.Application.VndBusinessobjects, - KnownMimeTypes.Application.VndChemdrawXml, - KnownMimeTypes.Application.VndChipnutsKaraokeMmd, - KnownMimeTypes.Application.VndCinderella, - KnownMimeTypes.Application.VndClaymore, - KnownMimeTypes.Application.VndCloantoRp9, - KnownMimeTypes.Application.VndClonkC4group, - KnownMimeTypes.Application.VndCluetrustCartomobileConfig, - KnownMimeTypes.Application.VndCluetrustCartomobileConfigPkg, - KnownMimeTypes.Application.VndCommonspace, - KnownMimeTypes.Application.VndContactCmsg, - KnownMimeTypes.Application.VndCosmocaller, - KnownMimeTypes.Application.VndCrickClicker, - KnownMimeTypes.Application.VndCrickClickerKeyboard, - KnownMimeTypes.Application.VndCrickClickerPalette, - KnownMimeTypes.Application.VndCrickClickerTemplate, - KnownMimeTypes.Application.VndCrickClickerWordbank, - KnownMimeTypes.Application.VndCriticaltoolsWbsXml, - KnownMimeTypes.Application.VndCtcPosml, - KnownMimeTypes.Application.VndCupsPpd, - KnownMimeTypes.Application.VndCurlCar, - KnownMimeTypes.Application.VndCurlPcurl, - KnownMimeTypes.Application.VndDataVisionRdz, - KnownMimeTypes.Application.VndDenovoFcselayoutLink, - KnownMimeTypes.Application.VndDna, - KnownMimeTypes.Application.VndDolbyMlp, - KnownMimeTypes.Application.VndDpgraph, - KnownMimeTypes.Application.VndDreamfactory, - KnownMimeTypes.Application.VndDvbAit, - KnownMimeTypes.Application.VndDvbService, - KnownMimeTypes.Application.VndDynageo, - KnownMimeTypes.Application.VndEcowinChart, - KnownMimeTypes.Application.VndEnliven, - KnownMimeTypes.Application.VndEpsonEsf, - KnownMimeTypes.Application.VndEpsonMsf, - KnownMimeTypes.Application.VndEpsonQuickanime, - KnownMimeTypes.Application.VndEpsonSalt, - KnownMimeTypes.Application.VndEpsonSsf, - KnownMimeTypes.Application.VndEszigno3Xml, - KnownMimeTypes.Application.VndEzpixAlbum, - KnownMimeTypes.Application.VndEzpixPackage, - KnownMimeTypes.Application.VndFdf, - KnownMimeTypes.Application.VndFdsnSeed, - KnownMimeTypes.Application.VndFlographit, - KnownMimeTypes.Application.VndFluxtimeClip, - KnownMimeTypes.Application.VndFramemaker, - KnownMimeTypes.Application.VndFrogansFnc, - KnownMimeTypes.Application.VndFrogansLtf, - KnownMimeTypes.Application.VndFscWeblaunch, - KnownMimeTypes.Application.VndFujitsuOasys, - KnownMimeTypes.Application.VndFujitsuOasys2, - KnownMimeTypes.Application.VndFujitsuOasys3, - KnownMimeTypes.Application.VndFujitsuOasysgp, - KnownMimeTypes.Application.VndFujitsuOasysprs, - KnownMimeTypes.Application.VndFujixeroxDdd, - KnownMimeTypes.Application.VndFujixeroxDocuworks, - KnownMimeTypes.Application.VndFujixeroxDocuworksBinder, - KnownMimeTypes.Application.VndFuzzysheet, - KnownMimeTypes.Application.VndGenomatixTuxedo, - KnownMimeTypes.Application.VndGeogebraFile, - KnownMimeTypes.Application.VndGeogebraTool, - KnownMimeTypes.Application.VndGeometryExplorer, - KnownMimeTypes.Application.VndGeonext, - KnownMimeTypes.Application.VndGeoplan, - KnownMimeTypes.Application.VndGeospace, - KnownMimeTypes.Application.VndGmx, - KnownMimeTypes.Application.VndGoogleEarthKmlXml, - KnownMimeTypes.Application.VndGoogleEarthKmz, - KnownMimeTypes.Application.VndGrafeq, - KnownMimeTypes.Application.VndGrooveAccount, - KnownMimeTypes.Application.VndGrooveHelp, - KnownMimeTypes.Application.VndGrooveIdentityMessage, - KnownMimeTypes.Application.VndGrooveInjector, - KnownMimeTypes.Application.VndGrooveToolMessage, - KnownMimeTypes.Application.VndGrooveToolTemplate, - KnownMimeTypes.Application.VndGrooveVcard, - KnownMimeTypes.Application.VndHalXml, - KnownMimeTypes.Application.VndHandheldEntertainmentXml, - KnownMimeTypes.Application.VndHbci, - KnownMimeTypes.Application.VndHheLessonPlayer, - KnownMimeTypes.Application.VndHpHpgl, - KnownMimeTypes.Application.VndHpHpid, - KnownMimeTypes.Application.VndHpHps, - KnownMimeTypes.Application.VndHpJlyt, - KnownMimeTypes.Application.VndHpPcl, - KnownMimeTypes.Application.VndHpPclxl, - KnownMimeTypes.Application.VndHydrostatixSofData, - KnownMimeTypes.Application.VndHzn3dCrossword, - KnownMimeTypes.Application.VndIbmMinipay, - KnownMimeTypes.Application.VndIbmModcap, - KnownMimeTypes.Application.VndIbmRightsManagement, - KnownMimeTypes.Application.VndIbmSecureContainer, - KnownMimeTypes.Application.VndIccprofile, - KnownMimeTypes.Application.VndIgloader, - KnownMimeTypes.Application.VndImmervisionIvp, - KnownMimeTypes.Application.VndImmervisionIvu, - KnownMimeTypes.Application.VndInsorsIgm, - KnownMimeTypes.Application.VndInterconFormnet, - KnownMimeTypes.Application.VndIntergeo, - KnownMimeTypes.Application.VndIntuQbo, - KnownMimeTypes.Application.VndIntuQfx, - KnownMimeTypes.Application.VndIpunpluggedRcprofile, - KnownMimeTypes.Application.VndIrepositoryPackageXml, - KnownMimeTypes.Application.VndIsXpr, - KnownMimeTypes.Application.VndIsacFcs, - KnownMimeTypes.Application.VndJam, - KnownMimeTypes.Application.VndJcpJavameMidletRms, - KnownMimeTypes.Application.VndJisp, - KnownMimeTypes.Application.VndJoostJodaArchive, - KnownMimeTypes.Application.VndKahootz, - KnownMimeTypes.Application.VndKdeKarbon, - KnownMimeTypes.Application.VndKdeKchart, - KnownMimeTypes.Application.VndKdeKformula, - KnownMimeTypes.Application.VndKdeKivio, - KnownMimeTypes.Application.VndKdeKontour, - KnownMimeTypes.Application.VndKdeKpresenter, - KnownMimeTypes.Application.VndKdeKspread, - KnownMimeTypes.Application.VndKdeKword, - KnownMimeTypes.Application.VndKenameaapp, - KnownMimeTypes.Application.VndKidspiration, - KnownMimeTypes.Application.VndKinar, - KnownMimeTypes.Application.VndKoan, - KnownMimeTypes.Application.VndKodakDescriptor, - KnownMimeTypes.Application.VndLasLasXml, - KnownMimeTypes.Application.VndLlamagraphicsLifeBalanceDesktop, - KnownMimeTypes.Application.VndLlamagraphicsLifeBalanceExchangeXml, - KnownMimeTypes.Application.VndLotus123, - KnownMimeTypes.Application.VndLotusApproach, - KnownMimeTypes.Application.VndLotusFreelance, - KnownMimeTypes.Application.VndLotusNotes, - KnownMimeTypes.Application.VndLotusOrganizer, - KnownMimeTypes.Application.VndLotusScreencam, - KnownMimeTypes.Application.VndLotusWordpro, - KnownMimeTypes.Application.VndMacportsPortpkg, - KnownMimeTypes.Application.VndMcd, - KnownMimeTypes.Application.VndMedcalcdata, - KnownMimeTypes.Application.VndMediastationCdkey, - KnownMimeTypes.Application.VndMfer, - KnownMimeTypes.Application.VndMfmp, - KnownMimeTypes.Application.VndMicrografxFlo, - KnownMimeTypes.Application.VndMicrografxIgx, - KnownMimeTypes.Application.VndMif, - KnownMimeTypes.Application.VndMobiusDaf, - KnownMimeTypes.Application.VndMobiusDis, - KnownMimeTypes.Application.VndMobiusMbk, - KnownMimeTypes.Application.VndMobiusMqy, - KnownMimeTypes.Application.VndMobiusMsl, - KnownMimeTypes.Application.VndMobiusPlc, - KnownMimeTypes.Application.VndMobiusTxf, - KnownMimeTypes.Application.VndMophunApplication, - KnownMimeTypes.Application.VndMophunCertificate, - KnownMimeTypes.Application.VndMozillaXulXml, - KnownMimeTypes.Application.VndMsArtgalry, - KnownMimeTypes.Application.VndMsCabCompressed, - KnownMimeTypes.Application.VndMsExcel, - KnownMimeTypes.Application.VndMsExcelAddinMacroenabled12, - KnownMimeTypes.Application.VndMsExcelSheetBinaryMacroenabled12, - KnownMimeTypes.Application.VndMsExcelSheetMacroenabled12, - KnownMimeTypes.Application.VndMsExcelTemplateMacroenabled12, - KnownMimeTypes.Application.VndMsFontobject, - KnownMimeTypes.Application.VndMsHtmlhelp, - KnownMimeTypes.Application.VndMsIms, - KnownMimeTypes.Application.VndMsLrm, - KnownMimeTypes.Application.VndMsOfficetheme, - KnownMimeTypes.Application.VndMsPkiSeccat, - KnownMimeTypes.Application.VndMsPkiStl, - KnownMimeTypes.Application.VndMsPowerpoint, - KnownMimeTypes.Application.VndMsPowerpointAddinMacroenabled12, - KnownMimeTypes.Application.VndMsPowerpointPresentationMacroenabled12, - KnownMimeTypes.Application.VndMsPowerpointSlideMacroenabled12, - KnownMimeTypes.Application.VndMsPowerpointSlideshowMacroenabled12, - KnownMimeTypes.Application.VndMsPowerpointTemplateMacroenabled12, - KnownMimeTypes.Application.VndMsProject, - KnownMimeTypes.Application.VndMsWordDocumentMacroenabled12, - KnownMimeTypes.Application.VndMsWordTemplateMacroenabled12, - KnownMimeTypes.Application.VndMsWorks, - KnownMimeTypes.Application.VndMsWpl, - KnownMimeTypes.Application.VndMsXpsdocument, - KnownMimeTypes.Application.VndMseq, - KnownMimeTypes.Application.VndMusician, - KnownMimeTypes.Application.VndMuveeStyle, - KnownMimeTypes.Application.VndNeurolanguageNlu, - KnownMimeTypes.Application.VndNoblenetDirectory, - KnownMimeTypes.Application.VndNoblenetSealer, - KnownMimeTypes.Application.VndNoblenetWeb, - KnownMimeTypes.Application.VndNokiaNGageData, - KnownMimeTypes.Application.VndNokiaNGageSymbianInstall, - KnownMimeTypes.Application.VndNokiaRadioPreset, - KnownMimeTypes.Application.VndNokiaRadioPresets, - KnownMimeTypes.Application.VndNovadigmEdm, - KnownMimeTypes.Application.VndNovadigmEdx, - KnownMimeTypes.Application.VndNovadigmExt, - KnownMimeTypes.Application.VndOasisOpendocumentChart, - KnownMimeTypes.Application.VndOasisOpendocumentChartTemplate, - KnownMimeTypes.Application.VndOasisOpendocumentDatabase, - KnownMimeTypes.Application.VndOasisOpendocumentFormula, - KnownMimeTypes.Application.VndOasisOpendocumentFormulaTemplate, - KnownMimeTypes.Application.VndOasisOpendocumentGraphics, - KnownMimeTypes.Application.VndOasisOpendocumentGraphicsTemplate, - KnownMimeTypes.Application.VndOasisOpendocumentImage, - KnownMimeTypes.Application.VndOasisOpendocumentImageTemplate, - KnownMimeTypes.Application.VndOasisOpendocumentPresentation, - KnownMimeTypes.Application.VndOasisOpendocumentPresentationTemplate, - KnownMimeTypes.Application.VndOasisOpendocumentSpreadsheet, - KnownMimeTypes.Application.VndOasisOpendocumentSpreadsheetTemplate, - KnownMimeTypes.Application.VndOasisOpendocumentText, - KnownMimeTypes.Application.VndOasisOpendocumentTextMaster, - KnownMimeTypes.Application.VndOasisOpendocumentTextTemplate, - KnownMimeTypes.Application.VndOasisOpendocumentTextWeb, - KnownMimeTypes.Application.VndOlpcSugar, - KnownMimeTypes.Application.VndOmaDd2Xml, - KnownMimeTypes.Application.VndOpenofficeorgExtension, - KnownMimeTypes.Application.VndOpenxmlformatsOfficedocumentPresentationmlPresentation, - KnownMimeTypes.Application.VndOpenxmlformatsOfficedocumentPresentationmlSlide, - KnownMimeTypes.Application.VndOpenxmlformatsOfficedocumentPresentationmlSlideshow, - KnownMimeTypes.Application.VndOpenxmlformatsOfficedocumentPresentationmlTemplate, - KnownMimeTypes.Application.VndOpenxmlformatsOfficedocumentSpreadsheetmlSheet, - KnownMimeTypes.Application.VndOpenxmlformatsOfficedocumentSpreadsheetmlTemplate, - KnownMimeTypes.Application.VndOpenxmlformatsOfficedocumentWordprocessingmlDocument, - KnownMimeTypes.Application.VndOpenxmlformatsOfficedocumentWordprocessingmlTemplate, - KnownMimeTypes.Application.VndOsgeoMapguidePackage, - KnownMimeTypes.Application.VndOsgiDp, - KnownMimeTypes.Application.VndPalm, - KnownMimeTypes.Application.VndPawaafile, - KnownMimeTypes.Application.VndPgFormat, - KnownMimeTypes.Application.VndPgOsasli, - KnownMimeTypes.Application.VndPicsel, - KnownMimeTypes.Application.VndPmiWidget, - KnownMimeTypes.Application.VndPocketlearn, - KnownMimeTypes.Application.VndPowerbuilder6, - KnownMimeTypes.Application.VndPreviewsystemsBox, - KnownMimeTypes.Application.VndProteusMagazine, - KnownMimeTypes.Application.VndPublishareDeltaTree, - KnownMimeTypes.Application.VndPviPtid1, - KnownMimeTypes.Application.VndQuarkQuarkxpress, - KnownMimeTypes.Application.VndRealvncBed, - KnownMimeTypes.Application.VndRecordareMusicxml, - KnownMimeTypes.Application.VndRecordareMusicxmlXml, - KnownMimeTypes.Application.VndRigCryptonote, - KnownMimeTypes.Application.VndRimCod, - KnownMimeTypes.Application.VndRnRealmedia, - KnownMimeTypes.Application.VndRoute66Link66Xml, - KnownMimeTypes.Application.VndSailingtrackerTrack, - KnownMimeTypes.Application.VndSeemail, - KnownMimeTypes.Application.VndSema, - KnownMimeTypes.Application.VndSemd, - KnownMimeTypes.Application.VndSemf, - KnownMimeTypes.Application.VndShanaInformedFormdata, - KnownMimeTypes.Application.VndShanaInformedFormtemplate, - KnownMimeTypes.Application.VndShanaInformedInterchange, - KnownMimeTypes.Application.VndShanaInformedPackage, - KnownMimeTypes.Application.VndSimtechMindmapper, - KnownMimeTypes.Application.VndSmaf, - KnownMimeTypes.Application.VndSmartTeacher, - KnownMimeTypes.Application.VndSolentSdkmXml, - KnownMimeTypes.Application.VndSpotfireDxp, - KnownMimeTypes.Application.VndSpotfireSfs, - KnownMimeTypes.Application.VndStardivisionCalc, - KnownMimeTypes.Application.VndStardivisionDraw, - KnownMimeTypes.Application.VndStardivisionImpress, - KnownMimeTypes.Application.VndStardivisionMath, - KnownMimeTypes.Application.VndStardivisionWriter, - KnownMimeTypes.Application.VndStardivisionWriterGlobal, - KnownMimeTypes.Application.VndStepmaniaStepchart, - KnownMimeTypes.Application.VndSunXmlCalc, - KnownMimeTypes.Application.VndSunXmlCalcTemplate, - KnownMimeTypes.Application.VndSunXmlDraw, - KnownMimeTypes.Application.VndSunXmlDrawTemplate, - KnownMimeTypes.Application.VndSunXmlImpress, - KnownMimeTypes.Application.VndSunXmlImpressTemplate, - KnownMimeTypes.Application.VndSunXmlMath, - KnownMimeTypes.Application.VndSunXmlWriter, - KnownMimeTypes.Application.VndSunXmlWriterGlobal, - KnownMimeTypes.Application.VndSunXmlWriterTemplate, - KnownMimeTypes.Application.VndSusCalendar, - KnownMimeTypes.Application.VndSvd, - KnownMimeTypes.Application.VndSymbianInstall, - KnownMimeTypes.Application.VndSyncmlXml, - KnownMimeTypes.Application.VndSyncmlDmWbxml, - KnownMimeTypes.Application.VndSyncmlDmXml, - KnownMimeTypes.Application.VndTaoIntentModuleArchive, - KnownMimeTypes.Application.VndTmobileLivetv, - KnownMimeTypes.Application.VndTridTpt, - KnownMimeTypes.Application.VndTriscapeMxs, - KnownMimeTypes.Application.VndTrueapp, - KnownMimeTypes.Application.VndUfdl, - KnownMimeTypes.Application.VndUiqTheme, - KnownMimeTypes.Application.VndUmajin, - KnownMimeTypes.Application.VndUnity, - KnownMimeTypes.Application.VndUomlXml, - KnownMimeTypes.Application.VndVcx, - KnownMimeTypes.Application.VndVisio, - KnownMimeTypes.Application.VndVisio2013, - KnownMimeTypes.Application.VndVisionary, - KnownMimeTypes.Application.VndVsf, - KnownMimeTypes.Application.VndWapWbxml, - KnownMimeTypes.Application.VndWapWmlc, - KnownMimeTypes.Application.VndWapWmlscriptc, - KnownMimeTypes.Application.VndWebturbo, - KnownMimeTypes.Application.VndWolframPlayer, - KnownMimeTypes.Application.VndWordperfect, - KnownMimeTypes.Application.VndWqd, - KnownMimeTypes.Application.VndWtStf, - KnownMimeTypes.Application.VndXara, - KnownMimeTypes.Application.VndXfdl, - KnownMimeTypes.Application.VndYamahaHvDic, - KnownMimeTypes.Application.VndYamahaHvScript, - KnownMimeTypes.Application.VndYamahaHvVoice, - KnownMimeTypes.Application.VndYamahaOpenscoreformat, - KnownMimeTypes.Application.VndYamahaOpenscoreformatOsfpvgXml, - KnownMimeTypes.Application.VndYamahaSmafAudio, - KnownMimeTypes.Application.VndYamahaSmafPhrase, - KnownMimeTypes.Application.VndYellowriverCustomMenu, - KnownMimeTypes.Application.VndZul, - KnownMimeTypes.Application.VndZzazzDeckXml, - KnownMimeTypes.Application.VoicexmlXml, - KnownMimeTypes.Application.Widget, - KnownMimeTypes.Application.Winhlp, - KnownMimeTypes.Application.WsdlXml, - KnownMimeTypes.Application.WspolicyXml, - KnownMimeTypes.Application.X7zCompressed, - KnownMimeTypes.Application.XAbiword, - KnownMimeTypes.Application.XAceCompressed, - KnownMimeTypes.Application.XAuthorwareBin, - KnownMimeTypes.Application.XAuthorwareMap, - KnownMimeTypes.Application.XAuthorwareSeg, - KnownMimeTypes.Application.XBcpio, - KnownMimeTypes.Application.XBittorrent, - KnownMimeTypes.Application.XBzip, - KnownMimeTypes.Application.XBzip2, - KnownMimeTypes.Application.XCdlink, - KnownMimeTypes.Application.XChat, - KnownMimeTypes.Application.XChessPgn, - KnownMimeTypes.Application.XCpio, - KnownMimeTypes.Application.XCsh, - KnownMimeTypes.Application.XDebianPackage, - KnownMimeTypes.Application.XDirector, - KnownMimeTypes.Application.XDoom, - KnownMimeTypes.Application.XDtbncxXml, - KnownMimeTypes.Application.XDtbookXml, - KnownMimeTypes.Application.XDtbresourceXml, - KnownMimeTypes.Application.XDvi, - KnownMimeTypes.Application.XFontBdf, - KnownMimeTypes.Application.XFontGhostscript, - KnownMimeTypes.Application.XFontLinuxPsf, - KnownMimeTypes.Application.XFontOtf, - KnownMimeTypes.Application.XFontPcf, - KnownMimeTypes.Application.XFontSnf, - KnownMimeTypes.Application.XFontTtf, - KnownMimeTypes.Application.XFontType1, - KnownMimeTypes.Application.XFontWoff, - KnownMimeTypes.Application.XFuturesplash, - KnownMimeTypes.Application.XGnumeric, - KnownMimeTypes.Application.XGtar, - KnownMimeTypes.Application.XHdf, - KnownMimeTypes.Application.XJavaJnlpFile, - KnownMimeTypes.Application.XLatex, - KnownMimeTypes.Application.XMobipocketEbook, - KnownMimeTypes.Application.XMsApplication, - KnownMimeTypes.Application.XMsWmd, - KnownMimeTypes.Application.XMsWmz, - KnownMimeTypes.Application.XMsXbap, - KnownMimeTypes.Application.XMsaccess, - KnownMimeTypes.Application.XMsbinder, - KnownMimeTypes.Application.XMscardfile, - KnownMimeTypes.Application.XMsclip, - KnownMimeTypes.Application.XMsdownload, - KnownMimeTypes.Application.XMsmediaview, - KnownMimeTypes.Application.XMsmetafile, - KnownMimeTypes.Application.XMsmoney, - KnownMimeTypes.Application.XMspublisher, - KnownMimeTypes.Application.XMsschedule, - KnownMimeTypes.Application.XMsterminal, - KnownMimeTypes.Application.XMswrite, - KnownMimeTypes.Application.XNetcdf, - KnownMimeTypes.Application.XPkcs12, - KnownMimeTypes.Application.XPkcs7Certificates, - KnownMimeTypes.Application.XPkcs7Certreqresp, - KnownMimeTypes.Application.XRarCompressed, - KnownMimeTypes.Application.XSh, - KnownMimeTypes.Application.XShar, - KnownMimeTypes.Application.XShockwaveFlash, - KnownMimeTypes.Application.XSilverlightApp, - KnownMimeTypes.Application.XStuffit, - KnownMimeTypes.Application.XStuffitx, - KnownMimeTypes.Application.XSv4cpio, - KnownMimeTypes.Application.XSv4crc, - KnownMimeTypes.Application.XTar, - KnownMimeTypes.Application.XTcl, - KnownMimeTypes.Application.XTex, - KnownMimeTypes.Application.XTexTfm, - KnownMimeTypes.Application.XTexinfo, - KnownMimeTypes.Application.XUstar, - KnownMimeTypes.Application.XWaisSource, - KnownMimeTypes.Application.XX509CaCert, - KnownMimeTypes.Application.XXfig, - KnownMimeTypes.Application.XXpinstall, - KnownMimeTypes.Application.XcapDiffXml, - KnownMimeTypes.Application.XencXml, - KnownMimeTypes.Application.XhtmlXml, - KnownMimeTypes.Application.Xml, - KnownMimeTypes.Application.XmlDtd, - KnownMimeTypes.Application.XopXml, - KnownMimeTypes.Application.XsltXml, - KnownMimeTypes.Application.XspfXml, - KnownMimeTypes.Application.XvXml, - KnownMimeTypes.Application.Yang, - KnownMimeTypes.Application.YinXml, - KnownMimeTypes.Application.Zip, - KnownMimeTypes.Application.XAppleDiskimage, - KnownMimeTypes.Audio.Adpcm, - KnownMimeTypes.Audio.Basic, - KnownMimeTypes.Audio.Midi, - KnownMimeTypes.Audio.Mp4, - KnownMimeTypes.Audio.Mpeg, - KnownMimeTypes.Audio.Ogg, - KnownMimeTypes.Audio.VndDeceAudio, - KnownMimeTypes.Audio.VndDigitalWinds, - KnownMimeTypes.Audio.VndDra, - KnownMimeTypes.Audio.VndDts, - KnownMimeTypes.Audio.VndDtsHd, - KnownMimeTypes.Audio.VndLucentVoice, - KnownMimeTypes.Audio.VndMsPlayreadyMediaPya, - KnownMimeTypes.Audio.VndNueraEcelp4800, - KnownMimeTypes.Audio.VndNueraEcelp7470, - KnownMimeTypes.Audio.VndNueraEcelp9600, - KnownMimeTypes.Audio.VndRip, - KnownMimeTypes.Audio.Webm, - KnownMimeTypes.Audio.XAac, - KnownMimeTypes.Audio.XAiff, - KnownMimeTypes.Audio.XMpegurl, - KnownMimeTypes.Audio.XMsWax, - KnownMimeTypes.Audio.XMsWma, - KnownMimeTypes.Audio.XPnRealaudio, - KnownMimeTypes.Audio.XPnRealaudioPlugin, - KnownMimeTypes.Audio.XWav, - KnownMimeTypes.Chemical.XCdx, - KnownMimeTypes.Chemical.XCif, - KnownMimeTypes.Chemical.XCmdf, - KnownMimeTypes.Chemical.XCml, - KnownMimeTypes.Chemical.XCsml, - KnownMimeTypes.Chemical.XXyz, - KnownMimeTypes.Image.Bmp, - KnownMimeTypes.Image.Cgm, - KnownMimeTypes.Image.G3fax, - KnownMimeTypes.Image.Gif, - KnownMimeTypes.Image.Ief, - KnownMimeTypes.Image.Jpeg, - KnownMimeTypes.Image.Pjpeg, - KnownMimeTypes.Image.XCitrixJpeg, - KnownMimeTypes.Image.Ktx, - KnownMimeTypes.Image.Png, - KnownMimeTypes.Image.XPng, - KnownMimeTypes.Image.XCitrixPng, - KnownMimeTypes.Image.PrsBtif, - KnownMimeTypes.Image.SvgXml, - KnownMimeTypes.Image.Tiff, - KnownMimeTypes.Image.VndAdobePhotoshop, - KnownMimeTypes.Image.VndDeceGraphic, - KnownMimeTypes.Image.VndDvbSubtitle, - KnownMimeTypes.Image.VndDjvu, - KnownMimeTypes.Image.VndDwg, - KnownMimeTypes.Image.VndDxf, - KnownMimeTypes.Image.VndFastbidsheet, - KnownMimeTypes.Image.VndFpx, - KnownMimeTypes.Image.VndFst, - KnownMimeTypes.Image.VndFujixeroxEdmicsMmr, - KnownMimeTypes.Image.VndFujixeroxEdmicsRlc, - KnownMimeTypes.Image.VndMsModi, - KnownMimeTypes.Image.VndNetFpx, - KnownMimeTypes.Image.VndWapWbmp, - KnownMimeTypes.Image.VndXiff, - KnownMimeTypes.Image.Webp, - KnownMimeTypes.Image.XCmuRaster, - KnownMimeTypes.Image.XCmx, - KnownMimeTypes.Image.XFreehand, - KnownMimeTypes.Image.XIcon, - KnownMimeTypes.Image.XPcx, - KnownMimeTypes.Image.XPict, - KnownMimeTypes.Image.XPortableAnymap, - KnownMimeTypes.Image.XPortableBitmap, - KnownMimeTypes.Image.XPortableGraymap, - KnownMimeTypes.Image.XPortablePixmap, - KnownMimeTypes.Image.XRgb, - KnownMimeTypes.Image.XXbitmap, - KnownMimeTypes.Image.XXpixmap, - KnownMimeTypes.Image.XXwindowdump, - KnownMimeTypes.Message.Rfc822, - KnownMimeTypes.Model.Iges, - KnownMimeTypes.Model.Mesh, - KnownMimeTypes.Model.VndColladaXml, - KnownMimeTypes.Model.VndDwf, - KnownMimeTypes.Model.VndGdl, - KnownMimeTypes.Model.VndGtw, - KnownMimeTypes.Model.VndMts, - KnownMimeTypes.Model.VndVtu, - KnownMimeTypes.Model.Vrml, - KnownMimeTypes.Text.Calendar, - KnownMimeTypes.Text.Css, - KnownMimeTypes.Text.Csv, - KnownMimeTypes.Text.Html, - KnownMimeTypes.Text.N3, - KnownMimeTypes.Text.Plain, - KnownMimeTypes.Text.PrsLinesTag, - KnownMimeTypes.Text.Richtext, - KnownMimeTypes.Text.Sgml, - KnownMimeTypes.Text.TabSeparatedValues, - KnownMimeTypes.Text.Troff, - KnownMimeTypes.Text.Turtle, - KnownMimeTypes.Text.UriList, - KnownMimeTypes.Text.VndCurl, - KnownMimeTypes.Text.VndCurlDcurl, - KnownMimeTypes.Text.VndCurlScurl, - KnownMimeTypes.Text.VndCurlMcurl, - KnownMimeTypes.Text.VndFly, - KnownMimeTypes.Text.VndFmiFlexstor, - KnownMimeTypes.Text.VndGraphviz, - KnownMimeTypes.Text.VndIn3d3dml, - KnownMimeTypes.Text.VndIn3dSpot, - KnownMimeTypes.Text.VndSunJ2meAppDescriptor, - KnownMimeTypes.Text.VndWapWml, - KnownMimeTypes.Text.VndWapWmlscript, - KnownMimeTypes.Text.XAsm, - KnownMimeTypes.Text.XC, - KnownMimeTypes.Text.XFortran, - KnownMimeTypes.Text.XPascal, - KnownMimeTypes.Text.XJavaSourceJava, - KnownMimeTypes.Text.XSetext, - KnownMimeTypes.Text.XUuencode, - KnownMimeTypes.Text.XVcalendar, - KnownMimeTypes.Text.XVcard, - KnownMimeTypes.Text.PlainBas, - KnownMimeTypes.Text.Yaml, - KnownMimeTypes.Video.V3gpp, - KnownMimeTypes.Video.V3gpp2, - KnownMimeTypes.Video.H261, - KnownMimeTypes.Video.H263, - KnownMimeTypes.Video.H264, - KnownMimeTypes.Video.Jpeg, - KnownMimeTypes.Video.Jpm, - KnownMimeTypes.Video.Mj2, - KnownMimeTypes.Video.Mp4, - KnownMimeTypes.Video.Mpeg, - KnownMimeTypes.Video.Ogg, - KnownMimeTypes.Video.Quicktime, - KnownMimeTypes.Video.VndDeceHd, - KnownMimeTypes.Video.VndDeceMobile, - KnownMimeTypes.Video.VndDecePd, - KnownMimeTypes.Video.VndDeceSd, - KnownMimeTypes.Video.VndDeceVideo, - KnownMimeTypes.Video.VndFvt, - KnownMimeTypes.Video.VndMpegurl, - KnownMimeTypes.Video.VndMsPlayreadyMediaPyv, - KnownMimeTypes.Video.VndUvvuMp4, - KnownMimeTypes.Video.VndVivo, - KnownMimeTypes.Video.Webm, - KnownMimeTypes.Video.XF4v, - KnownMimeTypes.Video.XFli, - KnownMimeTypes.Video.XFlv, - KnownMimeTypes.Video.XM4v, - KnownMimeTypes.Video.XMsAsf, - KnownMimeTypes.Video.XMsWm, - KnownMimeTypes.Video.XMsWmv, - KnownMimeTypes.Video.XMsWmx, - KnownMimeTypes.Video.XMsWvx, - KnownMimeTypes.Video.XMsvideo, - KnownMimeTypes.Video.XSgiMovie, - KnownMimeTypes.XConference.XCooltalk, -) - -val knownMimeTypesMap by lazy { - knownMimeTypes.associateBy { it.raw } -} - -fun findBuiltinMimeType(from: String): MimeType? { - return knownMimeTypesMap[from] -} diff --git a/utils/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/common/MimeTypeTools.kt b/utils/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/common/MimeTypeTools.kt deleted file mode 100644 index f4de870b..00000000 --- a/utils/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/common/MimeTypeTools.kt +++ /dev/null @@ -1,32 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.common - -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializer -import kotlinx.serialization.descriptors.* -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder -import kotlin.collections.set - -private val mimesCache = mutableMapOf().also { - knownMimeTypes.forEach { mimeType -> it[mimeType.raw] = mimeType } -} - -fun mimeType(raw: String) = mimesCache.getOrPut(raw) { - parseMimeType(raw) -} - -internal fun parseMimeType(raw: String): MimeType = findBuiltinMimeType(raw) ?: CustomMimeType(raw) - -@Serializer(MimeType::class) -internal object MimeTypeSerializer : KSerializer { - override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("mimeType", PrimitiveKind.STRING) - - override fun deserialize(decoder: Decoder): MimeType { - val mimeType = decoder.decodeString() - return mimeType(mimeType) - } - - override fun serialize(encoder: Encoder, value: MimeType) { - encoder.encodeString(value.raw) - } -} diff --git a/utils/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/common/TimeTypeAliases.kt b/utils/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/common/TimeTypeAliases.kt deleted file mode 100644 index a44d7ee8..00000000 --- a/utils/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/common/TimeTypeAliases.kt +++ /dev/null @@ -1,3 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.common - -typealias UnixMillis = Double diff --git a/utils/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/common/pagination/Pagination.kt b/utils/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/common/pagination/Pagination.kt deleted file mode 100644 index b12086c2..00000000 --- a/utils/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/common/pagination/Pagination.kt +++ /dev/null @@ -1,61 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.common.pagination - -import kotlin.math.ceil - -/** - * Base interface of pagination - * - * If you want to request something, you should use [SimplePagination]. If you need to return some result including - * pagination - [PaginationResult] - */ -interface Pagination { - /** - * Started with 0. - * Number of page inside of pagination. Offset can be calculated as [page] * [size] - */ - val page: Int - /** - * Can be 0, but can't be < 0 - * Size of current page. Offset can be calculated as [page] * [size] - */ - val size: Int -} - -/** - * First number in index of objects. It can be used as offset for databases or other data sources - */ -val Pagination.firstIndex: Int - get() = page * size - -/** - * Last exclusive number in index of objects - * - * For [Pagination] with [Pagination.size] == 10 and [Pagination.page] == 1 - * you will retrieve [Pagination.firstIndex] == 10 and [Pagination.lastExclusiveIndex] == 20. - */ -val Pagination.lastExclusiveIndex: Int - get() = firstIndex + size - -/** - * Last number in index of objects. In fact, one [Pagination] object represent data in next range: - * - * [[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. - */ -val Pagination.lastIndex: Int - get() = lastExclusiveIndex - 1 - -/** - * Calculates pages count for given [datasetSize] - */ -fun calculatePagesNumber(datasetSize: Long, pageSize: Int): Int { - return ceil(datasetSize.toDouble() / pageSize).toInt() -} -/** - * Calculates pages count for given [datasetSize] - */ -fun calculatePagesNumber(datasetSize: Int, pageSize: Int): Int = - calculatePagesNumber( - datasetSize.toLong(), - pageSize - ) diff --git a/utils/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/common/pagination/PaginationResult.kt b/utils/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/common/pagination/PaginationResult.kt deleted file mode 100644 index b96b9889..00000000 --- a/utils/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/common/pagination/PaginationResult.kt +++ /dev/null @@ -1,21 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.common.pagination - -import kotlinx.serialization.Serializable - -@Serializable -data class PaginationResult( - override val page: Int, - val pagesNumber: Int, - val results: List, - override val size: Int -) : Pagination - -fun List.createPaginationResult( - pagination: Pagination, - commonObjectsNumber: Long -) = PaginationResult( - pagination.page, - calculatePagesNumber(commonObjectsNumber, pagination.size), - this, - pagination.size -) diff --git a/utils/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/common/pagination/SimplePagination.kt b/utils/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/common/pagination/SimplePagination.kt deleted file mode 100644 index 8c94fdcc..00000000 --- a/utils/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/common/pagination/SimplePagination.kt +++ /dev/null @@ -1,28 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.common.pagination - -import kotlinx.serialization.Serializable - -const val defaultSmallPageSize = 2 -const val defaultMediumPageSize = 5 -const val defaultLargePageSize = 10 -const val defaultExtraLargePageSize = 15 - -@Suppress("NOTHING_TO_INLINE", "FunctionName") -inline fun FirstPagePagination(size: Int = defaultMediumPageSize) = - SimplePagination( - page = 0, - size = size - ) - -@Suppress("NOTHING_TO_INLINE") -inline fun Pagination.nextPage() = - SimplePagination( - page + 1, - size - ) - -@Serializable -data class SimplePagination( - override val page: Int, - override val size: Int -) : Pagination diff --git a/utils/repos/common/build.gradle b/utils/repos/common/build.gradle deleted file mode 100644 index d51d896f..00000000 --- a/utils/repos/common/build.gradle +++ /dev/null @@ -1,75 +0,0 @@ -buildscript { - repositories { - mavenLocal() - jcenter() - mavenCentral() - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" - classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version" - } -} - -plugins { - id "org.jetbrains.kotlin.multiplatform" version "$kotlin_version" - id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version" -} - -project.version = "$core_version" -project.group = "com.insanusmokrassar" - -apply from: "publish.gradle" - -repositories { - mavenLocal() - jcenter() - mavenCentral() - maven { url "https://kotlin.bintray.com/kotlinx" } -} - -kotlin { - jvm() - js (BOTH) { - browser() - nodejs() - } - - sourceSets { - commonMain { - dependencies { - implementation kotlin('stdlib') - - api projectByName("utils.common") - } - } - commonTest { - dependencies { - implementation kotlin('test-common') - implementation kotlin('test-annotations-common') - } - } - jvmMain { - dependencies { - implementation kotlin('stdlib-jdk8') - } - } - jvmTest { - dependencies { - implementation kotlin('test-junit') - } - } - jsMain { - dependencies { - implementation kotlin('stdlib-js') - } - } - jsTest { - dependencies { - implementation kotlin('test-js') - implementation kotlin('test-junit') - } - } - } -} diff --git a/utils/repos/common/maven.publish.gradle b/utils/repos/common/maven.publish.gradle deleted file mode 100644 index c871a756..00000000 --- a/utils/repos/common/maven.publish.gradle +++ /dev/null @@ -1,60 +0,0 @@ -apply plugin: 'maven-publish' - -task javadocsJar(type: Jar) { - classifier = 'javadoc' -} - -afterEvaluate { - project.publishing.publications.all { - // rename artifacts - groupId "${project.group}" - if (it.name.contains('kotlinMultiplatform')) { - artifactId = "${project.name}" - } else { - artifactId = "${project.name}-$name" - } - } -} - -publishing { - publications.all { - artifact javadocsJar - - pom { - description = "PostsSystem Core Repos utility subproject" - name = "PostsSystem Core Repos" - url = "https://git.insanusmokrassar.com/PostsSystem/PostsSystemCore" - - scm { - developerConnection = "scm:git:[fetch=]https://git.insanusmokrassar.com/PostsSystem/PostsSystemCore.git[push=]https://git.insanusmokrassar.com/PostsSystem/PostsSystemCore.git" - url = "https://git.insanusmokrassar.com/PostsSystem/PostsSystemCore.git" - } - - developers { - - developer { - id = "InsanusMokrassar" - name = "Ovsiannikov Aleksei" - email = "ovsyannikov.alexey95@gmail.com" - } - - - developer { - id = "mi-ast" - name = "Michail Astafiev" - email = "astaf65@gmail.com" - } - - } - - licenses { - - license { - name = "Apache Software License 2.0" - url = "https://git.insanusmokrassar.com/PostsSystem/PostsSystemCore/src/master/LICENSE" - } - - } - } - } -} \ No newline at end of file diff --git a/utils/repos/common/publish.gradle b/utils/repos/common/publish.gradle deleted file mode 100644 index b8cf4528..00000000 --- a/utils/repos/common/publish.gradle +++ /dev/null @@ -1,55 +0,0 @@ -apply plugin: 'com.jfrog.bintray' - -apply from: "maven.publish.gradle" - -bintray { - user = project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER') - key = project.hasProperty('BINTRAY_KEY') ? project.property('BINTRAY_KEY') : System.getenv('BINTRAY_KEY') - filesSpec { - from "${buildDir}/publications/" - eachFile { - String directorySubname = it.getFile().parentFile.name - if (it.getName() == "module.json") { - if (directorySubname == "kotlinMultiplatform") { - it.setPath("${project.name}/${project.version}/${project.name}-${project.version}.module") - } else { - it.setPath("${project.name}-${directorySubname}/${project.version}/${project.name}-${directorySubname}-${project.version}.module") - } - } else { - if (directorySubname == "kotlinMultiplatform" && it.getName() == "pom-default.xml") { - it.setPath("${project.name}/${project.version}/${project.name}-${project.version}.pom") - } else { - it.exclude() - } - } - } - into "${project.group}".replace(".", "/") - } - pkg { - repo = "InsanusMokrassar" - name = "${project.name}" - vcsUrl = "https://github.com/PostsSystem/PostsSystemCore" - licenses = ["Apache-2.0"] - version { - name = "${project.version}" - released = new Date() - vcsTag = "${project.version}" - gpg { - sign = true - passphrase = project.hasProperty('signing.gnupg.passphrase') ? project.property('signing.gnupg.passphrase') : System.getenv('signing.gnupg.passphrase') - } - } - } -} - -bintrayUpload.doFirst { - publications = publishing.publications.collect { - if (it.name.contains('kotlinMultiplatform')) { - null - } else { - it.name - } - } - null -} - -bintrayUpload.dependsOn publishToMavenLocal \ No newline at end of file diff --git a/utils/repos/common/publish_config.kpsb b/utils/repos/common/publish_config.kpsb deleted file mode 100644 index 2004655f..00000000 --- a/utils/repos/common/publish_config.kpsb +++ /dev/null @@ -1 +0,0 @@ -{"bintrayConfig":{"repo":"InsanusMokrassar","packageName":"${project.name}","packageVcs":"https://github.com/PostsSystem/PostsSystemCore"},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://git.insanusmokrassar.com/PostsSystem/PostsSystemCore/src/master/LICENSE"}],"mavenConfig":{"name":"PostsSystem Core Repos","description":"PostsSystem Core Repos utility subproject","url":"https://git.insanusmokrassar.com/PostsSystem/PostsSystemCore","vcsUrl":"https://git.insanusmokrassar.com/PostsSystem/PostsSystemCore.git","developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"},{"id":"mi-ast","name":"Michail Astafiev","eMail":"astaf65@gmail.com"}]},"type":"Multiplatform"} \ No newline at end of file diff --git a/utils/repos/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/IdUtils.kt b/utils/repos/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/IdUtils.kt deleted file mode 100644 index 9e15140a..00000000 --- a/utils/repos/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/IdUtils.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.repos - -import com.benasher44.uuid.uuid4 - -fun generateId() = uuid4().toString() diff --git a/utils/repos/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/OneToManyKeyValueRepo.kt b/utils/repos/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/OneToManyKeyValueRepo.kt deleted file mode 100644 index bcfcb120..00000000 --- a/utils/repos/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/OneToManyKeyValueRepo.kt +++ /dev/null @@ -1,23 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.repos - -import com.insanusmokrassar.postssystem.utils.common.pagination.Pagination -import com.insanusmokrassar.postssystem.utils.common.pagination.PaginationResult - -interface OneToManyReadKeyValueRepo : Repo { - suspend fun get(k: Key, pagination: Pagination, reversed: Boolean = false): PaginationResult - suspend fun keys(pagination: Pagination, reversed: Boolean = false): PaginationResult - suspend fun contains(k: Key): Boolean - suspend fun contains(k: Key, v: Value): Boolean - suspend fun count(k: Key): Long - suspend fun count(): Long -} - -interface OneToManyWriteKeyValueRepo : - Repo { - suspend fun add(k: Key, v: Value) - suspend fun remove(k: Key, v: Value) - suspend fun clear(k: Key) -} - -interface OneToManyKeyValueRepo : OneToManyReadKeyValueRepo, - OneToManyWriteKeyValueRepo \ No newline at end of file diff --git a/utils/repos/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/Repo.kt b/utils/repos/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/Repo.kt deleted file mode 100644 index 5023cad5..00000000 --- a/utils/repos/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/Repo.kt +++ /dev/null @@ -1,4 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.repos - -interface Repo { -} \ No newline at end of file diff --git a/utils/repos/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/StandardCRUDRepo.kt b/utils/repos/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/StandardCRUDRepo.kt deleted file mode 100644 index 8e78cb93..00000000 --- a/utils/repos/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/StandardCRUDRepo.kt +++ /dev/null @@ -1,41 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.repos - -import com.insanusmokrassar.postssystem.utils.common.pagination.Pagination -import com.insanusmokrassar.postssystem.utils.common.pagination.PaginationResult -import kotlinx.coroutines.flow.Flow - -interface ReadStandardCRUDRepo : Repo { - suspend fun getByPagination(pagination: Pagination): PaginationResult - suspend fun getById(id: IdType): ObjectType? - suspend fun contains(id: IdType): Boolean -} - -typealias UpdatedValuePair = Pair -val UpdatedValuePair.id - get() = first -val UpdatedValuePair<*, ValueType>.value - get() = second - -interface WriteStandardCRUDRepo : Repo { - val newObjectsFlow: Flow - val updatedObjectsFlow: Flow - val deletedObjectsIdsFlow: Flow - - suspend fun create(values: List): List - suspend fun update(id: IdType, value: InputValueType): ObjectType? - suspend fun update(values: List>): List - suspend fun deleteById(ids: List) -} - -suspend fun WriteStandardCRUDRepo.create( - vararg values: InputValueType -): List = create(values.toList()) -suspend fun WriteStandardCRUDRepo.update( - vararg values: UpdatedValuePair -): List = update(values.toList()) -suspend fun WriteStandardCRUDRepo.deleteById( - vararg ids: IdType -) = deleteById(ids.toList()) - -interface StandardCRUDRepo : ReadStandardCRUDRepo, - WriteStandardCRUDRepo diff --git a/utils/repos/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/StandardKeyValueRepo.kt b/utils/repos/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/StandardKeyValueRepo.kt deleted file mode 100644 index 5a7b00db..00000000 --- a/utils/repos/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/StandardKeyValueRepo.kt +++ /dev/null @@ -1,24 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.repos - -import com.insanusmokrassar.postssystem.utils.common.pagination.Pagination -import com.insanusmokrassar.postssystem.utils.common.pagination.PaginationResult -import kotlinx.coroutines.flow.Flow - -interface StandardReadKeyValueRepo : Repo { - suspend fun get(k: Key): Value? - suspend fun values(pagination: Pagination, reversed: Boolean): PaginationResult - suspend fun keys(pagination: Pagination, reversed: Boolean): PaginationResult - suspend fun contains(key: Key): Boolean - suspend fun count(): Long -} - -interface StandardWriteKeyValueRepo : Repo { - val onNewValue: Flow> - val onValueRemoved: Flow - - suspend fun set(k: Key, v: Value) - suspend fun unset(k: Key) -} - -interface StandardKeyValueRepo : StandardReadKeyValueRepo, - StandardWriteKeyValueRepo \ No newline at end of file diff --git a/utils/repos/exposed/build.gradle b/utils/repos/exposed/build.gradle deleted file mode 100644 index 6da74e0a..00000000 --- a/utils/repos/exposed/build.gradle +++ /dev/null @@ -1,47 +0,0 @@ -buildscript { - repositories { - mavenLocal() - jcenter() - mavenCentral() - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" - classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version" - } -} - -plugins { - id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version" -} - -project.version = "$core_version" -project.group = "com.insanusmokrassar" - -apply plugin: "java-library" -apply plugin: "kotlin" -apply from: "./publish.gradle" - -repositories { - mavenLocal() - jcenter() - mavenCentral() - maven { url "https://kotlin.bintray.com/kotlinx" } -} - -dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - - if ((project.hasProperty('RELEASE_MODE') && project.property('RELEASE_MODE') == "true") || System.getenv('RELEASE_MODE') == "true") { - api "com.insanusmokrassar:postssystem.utils.repos:$core_version" - api "com.insanusmokrassar:postssystem.exposed.commons:$core_version" - } else { - api projectByName("utils.repos.common") - api projectByName("exposed.commons") - } - - testImplementation "org.xerial:sqlite-jdbc:$test_sqlite_version" - testImplementation "org.jetbrains.kotlin:kotlin-test" - testImplementation "org.jetbrains.kotlin:kotlin-test-junit" -} diff --git a/utils/repos/exposed/gradle.properties b/utils/repos/exposed/gradle.properties deleted file mode 100644 index abc24679..00000000 --- a/utils/repos/exposed/gradle.properties +++ /dev/null @@ -1 +0,0 @@ -test_sqlite_version=3.28.0 diff --git a/utils/repos/exposed/maven.publish.gradle b/utils/repos/exposed/maven.publish.gradle deleted file mode 100644 index 50ee129b..00000000 --- a/utils/repos/exposed/maven.publish.gradle +++ /dev/null @@ -1,53 +0,0 @@ -apply plugin: 'maven-publish' - -task javadocsJar(type: Jar) { - classifier = 'javadoc' -} - -afterEvaluate { - project.publishing.publications.all { - // rename artifacts - groupId "${project.group}" - if (it.name.contains('kotlinMultiplatform')) { - artifactId = "${project.name}" - } else { - artifactId = "${project.name}-$name" - } - } -} - -publishing { - publications.all { - artifact javadocsJar - - pom { - description = "Common utils for all exposed modules" - name = "PostsSystem Exposed commons" - url = "https://git.insanusmokrassar.com/PostsSystem/Core/" - - scm { - developerConnection = "scm:git:[fetch=]https://git.insanusmokrassar.com/PostsSystem/Core/.git[push=]https://git.insanusmokrassar.com/PostsSystem/Core/.git" - url = "https://git.insanusmokrassar.com/PostsSystem/Core/.git" - } - - developers { - - developer { - id = "InsanusMokrassar" - name = "Ovsiannikov Aleksei" - email = "ovsyannikov.alexey95@gmail.com" - } - - } - - licenses { - - license { - name = "Apache Software License 2.0" - url = "https://git.insanusmokrassar.com/PostsSystem/Core/src/master/LICENSE" - } - - } - } - } -} \ No newline at end of file diff --git a/utils/repos/exposed/publish.gradle b/utils/repos/exposed/publish.gradle deleted file mode 100644 index b8cf4528..00000000 --- a/utils/repos/exposed/publish.gradle +++ /dev/null @@ -1,55 +0,0 @@ -apply plugin: 'com.jfrog.bintray' - -apply from: "maven.publish.gradle" - -bintray { - user = project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER') - key = project.hasProperty('BINTRAY_KEY') ? project.property('BINTRAY_KEY') : System.getenv('BINTRAY_KEY') - filesSpec { - from "${buildDir}/publications/" - eachFile { - String directorySubname = it.getFile().parentFile.name - if (it.getName() == "module.json") { - if (directorySubname == "kotlinMultiplatform") { - it.setPath("${project.name}/${project.version}/${project.name}-${project.version}.module") - } else { - it.setPath("${project.name}-${directorySubname}/${project.version}/${project.name}-${directorySubname}-${project.version}.module") - } - } else { - if (directorySubname == "kotlinMultiplatform" && it.getName() == "pom-default.xml") { - it.setPath("${project.name}/${project.version}/${project.name}-${project.version}.pom") - } else { - it.exclude() - } - } - } - into "${project.group}".replace(".", "/") - } - pkg { - repo = "InsanusMokrassar" - name = "${project.name}" - vcsUrl = "https://github.com/PostsSystem/PostsSystemCore" - licenses = ["Apache-2.0"] - version { - name = "${project.version}" - released = new Date() - vcsTag = "${project.version}" - gpg { - sign = true - passphrase = project.hasProperty('signing.gnupg.passphrase') ? project.property('signing.gnupg.passphrase') : System.getenv('signing.gnupg.passphrase') - } - } - } -} - -bintrayUpload.doFirst { - publications = publishing.publications.collect { - if (it.name.contains('kotlinMultiplatform')) { - null - } else { - it.name - } - } - null -} - -bintrayUpload.dependsOn publishToMavenLocal \ No newline at end of file diff --git a/utils/repos/exposed/publish_config.kpsb b/utils/repos/exposed/publish_config.kpsb deleted file mode 100644 index 2bd43e2b..00000000 --- a/utils/repos/exposed/publish_config.kpsb +++ /dev/null @@ -1 +0,0 @@ -{"bintrayConfig":{"repo":"InsanusMokrassar","packageName":"${project.name}","packageVcs":"https://github.com/PostsSystem/PostsSystemCore"},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://git.insanusmokrassar.com/PostsSystem/Core/src/master/LICENSE"}],"mavenConfig":{"name":"PostsSystem Exposed commons","description":"Common utils for all exposed modules","url":"https://git.insanusmokrassar.com/PostsSystem/Core/","vcsUrl":"https://git.insanusmokrassar.com/PostsSystem/Core/.git","developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}]},"type":"Multiplatform"} \ No newline at end of file diff --git a/utils/repos/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/utils/repos/exposed/AbstractExposedCRUDRepo.kt b/utils/repos/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/utils/repos/exposed/AbstractExposedCRUDRepo.kt deleted file mode 100644 index 8741bc47..00000000 --- a/utils/repos/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/utils/repos/exposed/AbstractExposedCRUDRepo.kt +++ /dev/null @@ -1,13 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.repos.exposed - -import kotlinx.coroutines.channels.Channel - -abstract class AbstractExposedCRUDRepo( - flowsChannelsSize: Int = Channel.BUFFERED, - databaseName: String = "" -) : - AbstractExposedWriteCRUDRepo( - flowsChannelsSize, - databaseName - ), - ExposedCRUDRepo diff --git a/utils/repos/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/utils/repos/exposed/AbstractExposedReadCRUDRepo.kt b/utils/repos/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/utils/repos/exposed/AbstractExposedReadCRUDRepo.kt deleted file mode 100644 index 3a1c3b7e..00000000 --- a/utils/repos/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/utils/repos/exposed/AbstractExposedReadCRUDRepo.kt +++ /dev/null @@ -1,37 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.repos.exposed - -import com.insanusmokrassar.postssystem.exposed.commons.paginate -import com.insanusmokrassar.postssystem.utils.common.pagination.* -import com.insanusmokrassar.postssystem.utils.repos.ReadStandardCRUDRepo -import org.jetbrains.exposed.sql.* -import org.jetbrains.exposed.sql.transactions.transaction - -abstract class AbstractExposedReadCRUDRepo( - tableName: String -) : - ReadStandardCRUDRepo, - ExposedCRUDRepo, - Table(tableName) -{ - override suspend fun getByPagination(pagination: Pagination): PaginationResult { - return transaction(db = database) { - selectAll().paginate(pagination).map { - it.asObject - }.createPaginationResult( - pagination, - selectAll().count() - ) - } - } - override suspend fun getById(id: IdType): ObjectType? { - return transaction(db = database) { - select { - selectById(id) - }.limit(1).firstOrNull() ?.asObject - } - } - - override suspend fun contains(id: IdType): Boolean = transaction(db = database) { - select { selectById(id) }.limit(1).any() - } -} diff --git a/utils/repos/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/utils/repos/exposed/AbstractExposedWriteCRUDRepo.kt b/utils/repos/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/utils/repos/exposed/AbstractExposedWriteCRUDRepo.kt deleted file mode 100644 index abfbac76..00000000 --- a/utils/repos/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/utils/repos/exposed/AbstractExposedWriteCRUDRepo.kt +++ /dev/null @@ -1,105 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.repos.exposed - -import com.insanusmokrassar.postssystem.utils.repos.UpdatedValuePair -import com.insanusmokrassar.postssystem.utils.repos.WriteStandardCRUDRepo -import kotlinx.coroutines.channels.BroadcastChannel -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.asFlow -import org.jetbrains.exposed.sql.* -import org.jetbrains.exposed.sql.statements.InsertStatement -import org.jetbrains.exposed.sql.statements.UpdateStatement -import org.jetbrains.exposed.sql.transactions.transaction - -abstract class AbstractExposedWriteCRUDRepo( - flowsChannelsSize: Int = 64, - databaseName: String = "" -) : - AbstractExposedReadCRUDRepo(databaseName), - ExposedCRUDRepo, - WriteStandardCRUDRepo -{ - protected val newObjectsChannel = BroadcastChannel(flowsChannelsSize) - protected val updateObjectsChannel = BroadcastChannel(flowsChannelsSize) - protected val deleteObjectsIdsChannel = BroadcastChannel(flowsChannelsSize) - - override val newObjectsFlow: Flow = newObjectsChannel.asFlow() - override val updatedObjectsFlow: Flow = updateObjectsChannel.asFlow() - override val deletedObjectsIdsFlow: Flow = deleteObjectsIdsChannel.asFlow() - - abstract val InsertStatement.asObject: ObjectType - abstract val selectByIds: SqlExpressionBuilder.(List) -> Op - - protected abstract fun insert(value: InputValueType, it: InsertStatement) - protected abstract fun update(id: IdType, value: InputValueType, it: UpdateStatement) - - protected open suspend fun onBeforeCreate(value: List) {} - private fun createWithoutNotification(value: InputValueType): ObjectType { - return transaction(database) { - insert { insert(value, it) }.asObject - } - } - - override suspend fun create(values: List): List { - onBeforeCreate(values) - return transaction(db = database) { - values.map { value -> createWithoutNotification(value) } - }.also { - it.forEach { - newObjectsChannel.send(it) - } - } - } - - protected open suspend fun onBeforeUpdate(value: List>) {} - private fun updateWithoutNotification(id: IdType, value: InputValueType): ObjectType? { - return transaction(db = database) { - update( - { - selectById(this, id) - } - ) { - update(id, value, it) - } - }.let { - if (it > 0) { - select { - selectById(this, id) - }.limit(1).firstOrNull() ?.asObject - } else { - null - } - } - } - - override suspend fun update(id: IdType, value: InputValueType): ObjectType? { - onBeforeUpdate(listOf(id to value)) - return updateWithoutNotification(id, value).also { - if (it != null) { - updateObjectsChannel.send(it) - } - } - } - override suspend fun update(values: List>): List { - onBeforeUpdate(values) - return ( - transaction(db = database) { - values.map { (id, value) -> updateWithoutNotification(id, value) } - }.filter { - it != null - } as List - ).also { - it.forEach { - updateObjectsChannel.send(it) - } - } - } - protected open suspend fun onBeforeDelete(ids: List) {} - override suspend fun deleteById(ids: List) { - onBeforeDelete(ids) - transaction(db = database) { - deleteWhere(null, null) { - selectByIds(ids) - } - } - } -} \ No newline at end of file diff --git a/utils/repos/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/utils/repos/exposed/ExposedCRUDRepo.kt b/utils/repos/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/utils/repos/exposed/ExposedCRUDRepo.kt deleted file mode 100644 index 243e24c1..00000000 --- a/utils/repos/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/utils/repos/exposed/ExposedCRUDRepo.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.repos.exposed - -import org.jetbrains.exposed.sql.* - -interface ExposedCRUDRepo { - val database: Database - - val ResultRow.asObject: ObjectType - val selectById: SqlExpressionBuilder.(IdType) -> Op -} diff --git a/utils/repos/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/utils/repos/exposed/ExposedTableInitialization.kt b/utils/repos/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/utils/repos/exposed/ExposedTableInitialization.kt deleted file mode 100644 index e4ae768a..00000000 --- a/utils/repos/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/utils/repos/exposed/ExposedTableInitialization.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.repos.exposed - -import org.jetbrains.exposed.sql.* -import org.jetbrains.exposed.sql.transactions.transaction - -fun Table.initTable(database: Database) { - transaction(database) { SchemaUtils.createMissingTablesAndColumns(this@initTable) } -} diff --git a/utils/repos/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/utils/repos/exposed/keyvalue/AbstractExposedKeyValueRepo.kt b/utils/repos/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/utils/repos/exposed/keyvalue/AbstractExposedKeyValueRepo.kt deleted file mode 100644 index 0ce06a7d..00000000 --- a/utils/repos/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/utils/repos/exposed/keyvalue/AbstractExposedKeyValueRepo.kt +++ /dev/null @@ -1,48 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.repos.exposed.keyvalue - -import com.insanusmokrassar.postssystem.utils.repos.StandardKeyValueRepo -import kotlinx.coroutines.channels.BroadcastChannel -import kotlinx.coroutines.channels.Channel -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.asFlow -import org.jetbrains.exposed.sql.* -import org.jetbrains.exposed.sql.transactions.transaction - -abstract class AbstractExposedKeyValueRepo( - database: Database, - keyColumn: Column, - valueColumn: Column -) : StandardKeyValueRepo, AbstractExposedReadKeyValueRepo( - database, - keyColumn, - valueColumn -) { - private val onNewValueChannel = BroadcastChannel>(Channel.BUFFERED) - private val onValueRemovedChannel = BroadcastChannel(Channel.BUFFERED) - - override val onNewValue: Flow> = onNewValueChannel.asFlow() - override val onValueRemoved: Flow = onValueRemovedChannel.asFlow() - - override suspend fun set(k: Key, v: Value) { - transaction(db = database) { - if (select { keyColumn.eq(k) }.limit(1).any()) { - update({ keyColumn.eq(k) }) { - it[valueColumn] = v - } - } else { - insert { - it[keyColumn] = k - it[valueColumn] = v - } - } - } - onNewValueChannel.send(k to v) - } - - override suspend fun unset(k: Key) { - transaction(db = database) { - deleteWhere { keyColumn.eq(k) } - } - onValueRemovedChannel.send(k) - } -} diff --git a/utils/repos/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/utils/repos/exposed/keyvalue/AbstractExposedReadKeyValueRepo.kt b/utils/repos/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/utils/repos/exposed/keyvalue/AbstractExposedReadKeyValueRepo.kt deleted file mode 100644 index f1e42a6f..00000000 --- a/utils/repos/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/utils/repos/exposed/keyvalue/AbstractExposedReadKeyValueRepo.kt +++ /dev/null @@ -1,37 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.repos.exposed.keyvalue - -import com.insanusmokrassar.postssystem.exposed.commons.paginate -import com.insanusmokrassar.postssystem.utils.common.pagination.* -import com.insanusmokrassar.postssystem.utils.repos.StandardReadKeyValueRepo -import org.jetbrains.exposed.sql.* -import org.jetbrains.exposed.sql.transactions.transaction - -abstract class AbstractExposedReadKeyValueRepo( - protected val database: Database, - protected val keyColumn: Column, - protected val valueColumn: Column -) : StandardReadKeyValueRepo, Table() { - override val primaryKey: PrimaryKey = PrimaryKey(keyColumn, valueColumn) - - override suspend fun get(k: Key): Value? = transaction(db = database) { - select { keyColumn.eq(k) }.limit(1).firstOrNull() ?.getOrNull(valueColumn) - } - - override suspend fun contains(key: Key): Boolean = transaction(db = database) { - select { keyColumn.eq(key) }.limit(1).any() - } - - override suspend fun count(): Long = transaction(db = database) { selectAll().count() } - - override suspend fun keys(pagination: Pagination, reversed: Boolean): PaginationResult = transaction(db = database) { - selectAll().paginate(pagination, keyColumn to if (reversed) SortOrder.DESC else SortOrder.ASC).map { - it[keyColumn] - } - }.createPaginationResult(pagination, count()) - - override suspend fun values(pagination: Pagination, reversed: Boolean): PaginationResult = transaction(db = database) { - selectAll().paginate(pagination, keyColumn to if (reversed) SortOrder.DESC else SortOrder.ASC).map { - it[valueColumn] - } - }.createPaginationResult(pagination, count()) -} diff --git a/utils/repos/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/utils/repos/exposed/onetomany/AbstractOneToManyExposedKeyValueRepo.kt b/utils/repos/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/utils/repos/exposed/onetomany/AbstractOneToManyExposedKeyValueRepo.kt deleted file mode 100644 index 63b24b7b..00000000 --- a/utils/repos/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/utils/repos/exposed/onetomany/AbstractOneToManyExposedKeyValueRepo.kt +++ /dev/null @@ -1,34 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.repos.exposed.onetomany - -import com.insanusmokrassar.budgetmanager.core.utils.repo.onetomany.AbstractOneToManyExposedReadKeyValueRepo -import com.insanusmokrassar.budgetmanager.core.utils.repo.onetomany.ColumnAllocator -import com.insanusmokrassar.postssystem.utils.repos.OneToManyKeyValueRepo -import org.jetbrains.exposed.sql.* -import org.jetbrains.exposed.sql.transactions.transaction - -abstract class AbstractOneToManyExposedKeyValueRepo( - keyColumnAllocator: ColumnAllocator, - valueColumnAllocator: ColumnAllocator, - database: Database -) : OneToManyKeyValueRepo, AbstractOneToManyExposedReadKeyValueRepo( - keyColumnAllocator, - valueColumnAllocator, - database -) { - override suspend fun add(k: Key, v: Value) { - transaction(db = database) { - insert { - it[keyColumn] = k - it[valueColumn] = v - } - } - } - - override suspend fun remove(k: Key, v: Value) { - transaction(db = database) { deleteWhere { keyColumn.eq(k).and(valueColumn.eq(v)) } } - } - - override suspend fun clear(k: Key) { - transaction(db = database) { deleteWhere { keyColumn.eq(k) } } - } -} diff --git a/utils/repos/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/utils/repos/exposed/onetomany/AbstractOneToManyExposedReadKeyValueRepo.kt b/utils/repos/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/utils/repos/exposed/onetomany/AbstractOneToManyExposedReadKeyValueRepo.kt deleted file mode 100644 index 467207c4..00000000 --- a/utils/repos/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/utils/repos/exposed/onetomany/AbstractOneToManyExposedReadKeyValueRepo.kt +++ /dev/null @@ -1,48 +0,0 @@ -package com.insanusmokrassar.budgetmanager.core.utils.repo.onetomany - -import com.insanusmokrassar.postssystem.exposed.commons.paginate -import com.insanusmokrassar.postssystem.utils.common.pagination.* -import com.insanusmokrassar.postssystem.utils.repos.OneToManyReadKeyValueRepo -import org.jetbrains.exposed.sql.* -import org.jetbrains.exposed.sql.transactions.transaction - -typealias ColumnAllocator = Table.() -> Column - -abstract class AbstractOneToManyExposedReadKeyValueRepo( - keyColumnAllocator: ColumnAllocator, - valueColumnAllocator: ColumnAllocator, - protected val database: Database -) : OneToManyReadKeyValueRepo, Table() { - protected val keyColumn: Column = keyColumnAllocator() - protected val valueColumn: Column = valueColumnAllocator() - - override suspend fun count(k: Key): Long = transaction(db = database) { select { keyColumn.eq(k) }.count() } - - override suspend fun count(): Long = transaction(db = database) { selectAll().count() } - - override suspend fun get( - k: Key, - pagination: Pagination, - reversed: Boolean - ): PaginationResult = transaction(db = database) { - select { keyColumn.eq(k) }.paginate(pagination, keyColumn, reversed).map { it[valueColumn] } - }.createPaginationResult( - pagination, - count(k) - ) - - override suspend fun keys(pagination: Pagination, reversed: Boolean): PaginationResult = transaction(db = database) { - selectAll().paginate(pagination, keyColumn, reversed).map { it[keyColumn] } - }.createPaginationResult( - pagination, - count() - ) - - override suspend fun contains(k: Key): Boolean = transaction(db = database) { - select { keyColumn.eq(k) }.limit(1).any() - } - - override suspend fun contains(k: Key, v: Value): Boolean = transaction(db = database) { - select { keyColumn.eq(k).and(valueColumn.eq(v)) }.limit(1).any() - } -} diff --git a/utils/repos/ktor/client/build.gradle b/utils/repos/ktor/client/build.gradle deleted file mode 100644 index f1cd0887..00000000 --- a/utils/repos/ktor/client/build.gradle +++ /dev/null @@ -1,74 +0,0 @@ -buildscript { - repositories { - mavenLocal() - jcenter() - mavenCentral() - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" - classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version" - } -} - -plugins { - id "org.jetbrains.kotlin.multiplatform" version "$kotlin_version" - id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version" -} - -project.version = "$core_version" -project.group = "com.insanusmokrassar" - -repositories { - mavenLocal() - jcenter() - mavenCentral() - maven { url "https://kotlin.bintray.com/kotlinx" } -} - -kotlin { - jvm() - js (BOTH) { - browser() - nodejs() - } - - sourceSets { - commonMain { - dependencies { - implementation kotlin('stdlib') - - api projectByName("utils.repos.ktor.common") - api projectByName("ktor.client") - } - } - commonTest { - dependencies { - implementation kotlin('test-common') - implementation kotlin('test-annotations-common') - } - } - jvmMain { - dependencies { - implementation kotlin('stdlib-jdk8') - } - } - jvmTest { - dependencies { - implementation kotlin('test-junit') - } - } - jsMain { - dependencies { - implementation kotlin('stdlib-js') - } - } - jsTest { - dependencies { - implementation kotlin('test-js') - implementation kotlin('test-junit') - } - } - } -} diff --git a/utils/repos/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/client/crud/KtorReadStandardCrudRepo.kt b/utils/repos/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/client/crud/KtorReadStandardCrudRepo.kt deleted file mode 100644 index 65be8c49..00000000 --- a/utils/repos/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/client/crud/KtorReadStandardCrudRepo.kt +++ /dev/null @@ -1,49 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.repos.ktor.client.crud - -import com.insanusmokrassar.postssystem.ktor.* -import com.insanusmokrassar.postssystem.ktor.client.encodeUrlQueryValue -import com.insanusmokrassar.postssystem.ktor.client.uniget -import com.insanusmokrassar.postssystem.utils.common.pagination.Pagination -import com.insanusmokrassar.postssystem.utils.common.pagination.PaginationResult -import com.insanusmokrassar.postssystem.utils.repos.ReadStandardCRUDRepo -import com.insanusmokrassar.postssystem.utils.repos.ktor.common.crud.* -import io.ktor.client.HttpClient -import kotlinx.serialization.KSerializer -import kotlinx.serialization.builtins.serializer - -class KtorReadStandardCrudRepo ( - private val baseUrl: String, - private val client: HttpClient = HttpClient(), - private val objectsSerializer: KSerializer, - private val objectsSerializerNullable: KSerializer, - private val idsSerializer: KSerializer -) : ReadStandardCRUDRepo { - private val paginationResultSerializer = PaginationResult.serializer(objectsSerializer) - - override suspend fun getByPagination(pagination: Pagination): PaginationResult = client.uniget( - buildStandardUrl(baseUrl, getByPaginationRouting, pagination.asUrlQueryParts), - paginationResultSerializer - ) - - override suspend fun getById(id: IdType): ObjectType? = client.uniget( - buildStandardUrl( - baseUrl, - getByIdRouting, - mapOf( - "id" to idsSerializer.encodeUrlQueryValue(id) - ) - ), - objectsSerializerNullable - ) - - override suspend fun contains(id: IdType): Boolean = client.uniget( - buildStandardUrl( - baseUrl, - containsRouting, - mapOf( - "id" to idsSerializer.encodeUrlQueryValue(id) - ) - ), - Boolean.serializer() - ) -} diff --git a/utils/repos/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/client/crud/KtorStandardCrudRepo.kt b/utils/repos/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/client/crud/KtorStandardCrudRepo.kt deleted file mode 100644 index 34a98223..00000000 --- a/utils/repos/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/client/crud/KtorStandardCrudRepo.kt +++ /dev/null @@ -1,30 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.repos.ktor.client.crud - -import com.insanusmokrassar.postssystem.utils.repos.* -import io.ktor.client.HttpClient -import kotlinx.serialization.KSerializer - -class KtorStandardCrudRepo ( - baseUrl: String, - baseSubpart: String, - client: HttpClient, - objectsSerializer: KSerializer, - objectsNullableSerializer: KSerializer, - inputsSerializer: KSerializer, - idsSerializer: KSerializer -) : StandardCRUDRepo, - ReadStandardCRUDRepo by KtorReadStandardCrudRepo( - "$baseUrl/$baseSubpart", - client, - objectsSerializer, - objectsNullableSerializer, - idsSerializer - ), - WriteStandardCRUDRepo by KtorWriteStandardCrudRepo( - "$baseUrl/$baseSubpart", - client, - objectsSerializer, - objectsNullableSerializer, - inputsSerializer, - idsSerializer - ) diff --git a/utils/repos/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/client/crud/KtorWriteStandardCrudRepo.kt b/utils/repos/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/client/crud/KtorWriteStandardCrudRepo.kt deleted file mode 100644 index a3b79c75..00000000 --- a/utils/repos/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/client/crud/KtorWriteStandardCrudRepo.kt +++ /dev/null @@ -1,67 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.repos.ktor.client.crud - -import com.insanusmokrassar.postssystem.ktor.buildStandardUrl -import com.insanusmokrassar.postssystem.ktor.client.* -import com.insanusmokrassar.postssystem.utils.repos.UpdatedValuePair -import com.insanusmokrassar.postssystem.utils.repos.WriteStandardCRUDRepo -import com.insanusmokrassar.postssystem.utils.repos.ktor.common.crud.* -import io.ktor.client.HttpClient -import kotlinx.coroutines.flow.Flow -import kotlinx.serialization.KSerializer -import kotlinx.serialization.builtins.* - -class KtorWriteStandardCrudRepo ( - private val baseUrl: String, - private val client: HttpClient = HttpClient(), - private val objectsSerializer: KSerializer, - private val objectsNullableSerializer: KSerializer, - private val inputsSerializer: KSerializer, - private val idsSerializer: KSerializer -) : WriteStandardCRUDRepo { - private val listObjectsSerializer = ListSerializer(objectsSerializer) - private val listInputSerializer = ListSerializer(inputsSerializer) - private val listIdsSerializer = ListSerializer(idsSerializer) - private val inputUpdateSerializer = PairSerializer( - idsSerializer, - inputsSerializer - ) - private val listInputUpdateSerializer = ListSerializer(inputUpdateSerializer) - - override val newObjectsFlow: Flow = client.createStandardWebsocketFlow( - buildStandardUrl(baseUrl, newObjectsFlowRouting), - deserializer = objectsSerializer - ) - override val updatedObjectsFlow: Flow = client.createStandardWebsocketFlow( - buildStandardUrl(baseUrl, updatedObjectsFlowRouting), - deserializer = objectsSerializer - ) - override val deletedObjectsIdsFlow: Flow = client.createStandardWebsocketFlow( - buildStandardUrl(baseUrl, deletedObjectsIdsFlowRouting), - deserializer = idsSerializer - ) - - - override suspend fun create(values: List): List = client.unipost( - buildStandardUrl(baseUrl, createRouting), - BodyPair(listInputSerializer, values), - listObjectsSerializer - ) - - override suspend fun update(id: IdType, value: InputValue): ObjectType? = client.unipost( - buildStandardUrl(baseUrl, updateRouting), - BodyPair(inputUpdateSerializer, id to value), - objectsNullableSerializer - ) - - override suspend fun update(values: List>): List = client.unipost( - buildStandardUrl(baseUrl, updateManyRouting), - BodyPair(listInputUpdateSerializer, values), - listObjectsSerializer - ) - - override suspend fun deleteById(ids: List) = client.unipost( - buildStandardUrl(baseUrl, deleteByIdRouting), - BodyPair(listIdsSerializer, ids), - Unit.serializer() - ) -} diff --git a/utils/repos/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/client/key_value/KtorStandartKeyValueRepo.kt b/utils/repos/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/client/key_value/KtorStandartKeyValueRepo.kt deleted file mode 100644 index aea0e77f..00000000 --- a/utils/repos/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/client/key_value/KtorStandartKeyValueRepo.kt +++ /dev/null @@ -1,30 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.repos.ktor.client.key_value - -import com.insanusmokrassar.postssystem.utils.repos.StandardKeyValueRepo -import com.insanusmokrassar.postssystem.utils.repos.StandardReadKeyValueRepo -import com.insanusmokrassar.postssystem.utils.repos.StandardWriteKeyValueRepo -import io.ktor.client.* -import kotlinx.serialization.ContextualSerializer -import kotlinx.serialization.KSerializer - -class KtorStandartKeyValueRepo ( - baseUrl: String, - baseSubpart: String, - client: HttpClient = HttpClient(), - keySerializer: KSerializer, - valueSerializer: KSerializer, - valueNullableSerializer: KSerializer -) : StandardKeyValueRepo, - StandardReadKeyValueRepo by KtorStandartReadKeyValueRepo( - "$baseUrl/$baseSubpart", - client, - keySerializer, - valueSerializer, - valueNullableSerializer - ), - StandardWriteKeyValueRepo by KtorStandartWriteKeyValueRepo( - "$baseUrl/$baseSubpart", - client, - keySerializer, - valueSerializer - ) \ No newline at end of file diff --git a/utils/repos/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/client/key_value/KtorStandartReadKeyValueRepo.kt b/utils/repos/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/client/key_value/KtorStandartReadKeyValueRepo.kt deleted file mode 100644 index 9ab75d40..00000000 --- a/utils/repos/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/client/key_value/KtorStandartReadKeyValueRepo.kt +++ /dev/null @@ -1,73 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.repos.ktor.client.key_value - -import com.insanusmokrassar.postssystem.ktor.asUrlQueryParts -import com.insanusmokrassar.postssystem.ktor.buildStandardUrl -import com.insanusmokrassar.postssystem.ktor.client.encodeUrlQueryValue -import com.insanusmokrassar.postssystem.ktor.client.uniget -import com.insanusmokrassar.postssystem.utils.common.pagination.Pagination -import com.insanusmokrassar.postssystem.utils.common.pagination.PaginationResult -import com.insanusmokrassar.postssystem.utils.repos.StandardReadKeyValueRepo -import com.insanusmokrassar.postssystem.utils.repos.ktor.common.key_value.* -import io.ktor.client.* -import kotlinx.serialization.KSerializer -import kotlinx.serialization.builtins.serializer - -class KtorStandartReadKeyValueRepo ( - private var baseUrl: String, - private var client: HttpClient = HttpClient(), - private var keySerializer: KSerializer, - private var valueSerializer: KSerializer, - private var valueNullableSerializer: KSerializer, -) : StandardReadKeyValueRepo { - override suspend fun get(k: Key): Value? = client.uniget( - buildStandardUrl( - baseUrl, - getRoute, - mapOf( - keyParameterName to keySerializer.encodeUrlQueryValue(k) - ) - ), - valueNullableSerializer - ) - - override suspend fun values(pagination: Pagination, reversed: Boolean): PaginationResult = client.uniget( - buildStandardUrl( - baseUrl, - valuesRoute, - mapOf( - reversedParameterName to Boolean.serializer().encodeUrlQueryValue(reversed) - ) + pagination.asUrlQueryParts - ), - PaginationResult.serializer(valueSerializer) - ) - - override suspend fun keys(pagination: Pagination, reversed: Boolean): PaginationResult = client.uniget( - buildStandardUrl( - baseUrl, - keysRoute, - mapOf( - reversedParameterName to Boolean.serializer().encodeUrlQueryValue(reversed) - ) + pagination.asUrlQueryParts - ), - PaginationResult.serializer(keySerializer) - ) - - override suspend fun contains(key: Key): Boolean = client.uniget( - buildStandardUrl( - baseUrl, - containsRoute, - mapOf( - keyParameterName to keySerializer.encodeUrlQueryValue(key) - ), - ), - Boolean.serializer(), - ) - - override suspend fun count(): Long = client.uniget( - buildStandardUrl( - baseUrl, - countRoute, - ), - Long.serializer() - ) -} \ No newline at end of file diff --git a/utils/repos/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/client/key_value/KtorStandartWriteKeyValueRepo.kt b/utils/repos/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/client/key_value/KtorStandartWriteKeyValueRepo.kt deleted file mode 100644 index 918d2350..00000000 --- a/utils/repos/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/client/key_value/KtorStandartWriteKeyValueRepo.kt +++ /dev/null @@ -1,49 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.repos.ktor.client.key_value - -import com.insanusmokrassar.postssystem.ktor.buildStandardUrl -import com.insanusmokrassar.postssystem.ktor.client.BodyPair -import com.insanusmokrassar.postssystem.ktor.client.createStandardWebsocketFlow -import com.insanusmokrassar.postssystem.ktor.client.uniget -import com.insanusmokrassar.postssystem.ktor.client.unipost -import com.insanusmokrassar.postssystem.utils.repos.StandardWriteKeyValueRepo -import com.insanusmokrassar.postssystem.utils.repos.ktor.common.key_value.* -import io.ktor.client.* -import kotlinx.coroutines.flow.Flow -import kotlinx.serialization.KSerializer -import kotlinx.serialization.builtins.PairSerializer -import kotlinx.serialization.builtins.serializer - -class KtorStandartWriteKeyValueRepo ( - private var baseUrl: String, - private var client: HttpClient = HttpClient(), - private var keySerializer: KSerializer, - private var valueSerializer: KSerializer, -) : StandardWriteKeyValueRepo { - override val onNewValue: Flow> = client.createStandardWebsocketFlow( - buildStandardUrl(baseUrl, onNewValueRoute), - deserializer = PairSerializer(keySerializer, valueSerializer) - ) - - override val onValueRemoved: Flow = client.createStandardWebsocketFlow( - buildStandardUrl(baseUrl, onValueRemovedRoute), - deserializer = keySerializer - ) - - override suspend fun set(k: K, v: V) = client.unipost( - buildStandardUrl( - baseUrl, - setRoute - ), - BodyPair(KeyValuePostObject.serializer(keySerializer, valueSerializer), KeyValuePostObject(k, v)), - Unit.serializer() - ) - - override suspend fun unset(k: K) = client.unipost( - buildStandardUrl( - baseUrl, - unsetRoute, - ), - BodyPair(keySerializer, k), - Unit.serializer() - ) -} \ No newline at end of file diff --git a/utils/repos/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/client/one_to_many/KtorOneToManyKeyValueRepo.kt b/utils/repos/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/client/one_to_many/KtorOneToManyKeyValueRepo.kt deleted file mode 100644 index 02fe86e6..00000000 --- a/utils/repos/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/client/one_to_many/KtorOneToManyKeyValueRepo.kt +++ /dev/null @@ -1,25 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.repos.ktor.client.one_to_many - -import com.insanusmokrassar.postssystem.utils.repos.* -import io.ktor.client.HttpClient -import kotlinx.serialization.KSerializer - -class KtorOneToManyKeyValueRepo( - baseUrl: String, - baseSubpart: String, - client: HttpClient, - keySerializer: KSerializer, - valueSerializer: KSerializer, -) : OneToManyKeyValueRepo, - OneToManyReadKeyValueRepo by KtorOneToManyReadKeyValueRepo ( - "$baseUrl/$baseSubpart", - client, - keySerializer, - valueSerializer, - ), - OneToManyWriteKeyValueRepo by KtorOneToManyWriteKeyValueRepo ( - "$baseUrl/$baseSubpart", - client, - keySerializer, - valueSerializer, - ) \ No newline at end of file diff --git a/utils/repos/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/client/one_to_many/KtorOneToManyReadKeyValueRepo.kt b/utils/repos/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/client/one_to_many/KtorOneToManyReadKeyValueRepo.kt deleted file mode 100644 index e0736e40..00000000 --- a/utils/repos/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/client/one_to_many/KtorOneToManyReadKeyValueRepo.kt +++ /dev/null @@ -1,86 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.repos.ktor.client.one_to_many - -import com.insanusmokrassar.postssystem.ktor.* -import com.insanusmokrassar.postssystem.ktor.client.encodeUrlQueryValue -import com.insanusmokrassar.postssystem.ktor.client.uniget -import com.insanusmokrassar.postssystem.utils.common.pagination.Pagination -import com.insanusmokrassar.postssystem.utils.common.pagination.PaginationResult -import com.insanusmokrassar.postssystem.utils.repos.OneToManyReadKeyValueRepo -import com.insanusmokrassar.postssystem.utils.repos.ktor.common.one_to_many.* -import io.ktor.client.HttpClient -import kotlinx.serialization.KSerializer -import kotlinx.serialization.builtins.serializer - -class KtorOneToManyReadKeyValueRepo ( - private val baseUrl: String, - private val client: HttpClient = HttpClient(), - private val keySerializer: KSerializer, - private val valueSerializer: KSerializer, -) : OneToManyReadKeyValueRepo { - private val paginationValueResultSerializer = PaginationResult.serializer(valueSerializer) - private val paginationKeyResultSerializer = PaginationResult.serializer(keySerializer) - - override suspend fun get(k: Key, pagination: Pagination, reversed: Boolean): PaginationResult = client.uniget( - buildStandardUrl( - baseUrl, - getRoute, - mapOf( - keyParameterName to keySerializer.encodeUrlQueryValue(k), - reversedParameterName to Boolean.serializer().encodeUrlQueryValue(reversed) - ) + pagination.asUrlQueryParts - ), - paginationValueResultSerializer - ) - - override suspend fun keys(pagination: Pagination, reversed: Boolean): PaginationResult = client.uniget( - buildStandardUrl( - baseUrl, - keysRoute, - mapOf( - reversedParameterName to Boolean.serializer().encodeUrlQueryValue(reversed) - ) + pagination.asUrlQueryParts - ), - paginationKeyResultSerializer - ) - - override suspend fun contains(k: Key): Boolean = client.uniget( - buildStandardUrl( - baseUrl, - containsByKeyRoute, - mapOf(keyParameterName to keySerializer.encodeUrlQueryValue(k)) - ), - Boolean.serializer() - ) - - override suspend fun contains(k: Key, v: Value): Boolean = client.uniget( - buildStandardUrl( - baseUrl, - containsByKeyValueRoute, - mapOf( - keyParameterName to keySerializer.encodeUrlQueryValue(k), - valueParameterName to valueSerializer.encodeUrlQueryValue(v), - ) - ), - Boolean.serializer() - ) - - override suspend fun count(k: Key): Long = client.uniget( - buildStandardUrl( - baseUrl, - countByKeyRoute, - mapOf( - keyParameterName to keySerializer.encodeUrlQueryValue(k) - ) - ), - Long.serializer() - ) - - override suspend fun count(): Long = client.uniget( - buildStandardUrl( - baseUrl, - countRoute, - ), - Long.serializer() - ) - -} \ No newline at end of file diff --git a/utils/repos/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/client/one_to_many/KtorOneToManyWriteKeyValueRepo.kt b/utils/repos/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/client/one_to_many/KtorOneToManyWriteKeyValueRepo.kt deleted file mode 100644 index 586c5d34..00000000 --- a/utils/repos/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/client/one_to_many/KtorOneToManyWriteKeyValueRepo.kt +++ /dev/null @@ -1,47 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.repos.ktor.client.one_to_many - -import com.insanusmokrassar.postssystem.ktor.buildStandardUrl -import com.insanusmokrassar.postssystem.ktor.client.BodyPair -import com.insanusmokrassar.postssystem.ktor.client.unipost -import com.insanusmokrassar.postssystem.utils.repos.OneToManyWriteKeyValueRepo -import com.insanusmokrassar.postssystem.utils.repos.ktor.common.one_to_many.* -import io.ktor.client.HttpClient -import kotlinx.serialization.KSerializer -import kotlinx.serialization.builtins.PairSerializer -import kotlinx.serialization.builtins.serializer - -class KtorOneToManyWriteKeyValueRepo ( - private val baseUrl: String, - private val client: HttpClient = HttpClient(), - private val keySerializer: KSerializer, - private val valueSerializer: KSerializer, -) : OneToManyWriteKeyValueRepo { - private val keyValueSerializer = PairSerializer(keySerializer, valueSerializer) - - override suspend fun add(k: Key, v: Value) = client.unipost( - buildStandardUrl( - baseUrl, - addRoute, - ), - BodyPair(keyValueSerializer, k to v), - Unit.serializer(), - ) - - override suspend fun remove(k: Key, v: Value) = client.unipost( - buildStandardUrl( - baseUrl, - removeRoute, - ), - BodyPair(keyValueSerializer, k to v), - Unit.serializer(), - ) - - override suspend fun clear(k: Key) = client.unipost( - buildStandardUrl( - baseUrl, - clearRoute, - ), - BodyPair(keySerializer, k), - Unit.serializer(), - ) -} \ No newline at end of file diff --git a/utils/repos/ktor/common/build.gradle b/utils/repos/ktor/common/build.gradle deleted file mode 100644 index 569eb32a..00000000 --- a/utils/repos/ktor/common/build.gradle +++ /dev/null @@ -1,74 +0,0 @@ -buildscript { - repositories { - mavenLocal() - jcenter() - mavenCentral() - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" - classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version" - } -} - -plugins { - id "org.jetbrains.kotlin.multiplatform" version "$kotlin_version" - id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version" -} - -project.version = "$core_version" -project.group = "com.insanusmokrassar" - -repositories { - mavenLocal() - jcenter() - mavenCentral() - maven { url "https://kotlin.bintray.com/kotlinx" } -} - -kotlin { - jvm() - js (BOTH) { - browser() - nodejs() - } - - sourceSets { - commonMain { - dependencies { - implementation kotlin('stdlib') - - api projectByName("utils.repos.common") - api projectByName("ktor.common") - } - } - commonTest { - dependencies { - implementation kotlin('test-common') - implementation kotlin('test-annotations-common') - } - } - jvmMain { - dependencies { - implementation kotlin('stdlib-jdk8') - } - } - jvmTest { - dependencies { - implementation kotlin('test-junit') - } - } - jsMain { - dependencies { - implementation kotlin('stdlib-js') - } - } - jsTest { - dependencies { - implementation kotlin('test-js') - implementation kotlin('test-junit') - } - } - } -} diff --git a/utils/repos/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/common/crud/CrudReadRoutes.kt b/utils/repos/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/common/crud/CrudReadRoutes.kt deleted file mode 100644 index 5d2f662e..00000000 --- a/utils/repos/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/common/crud/CrudReadRoutes.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.repos.ktor.common.crud - -const val getByPaginationRouting = "getByPagination" -const val getByIdRouting = "getById" -const val containsRouting = "contains" diff --git a/utils/repos/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/common/crud/CrudWriteRoutes.kt b/utils/repos/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/common/crud/CrudWriteRoutes.kt deleted file mode 100644 index d4893237..00000000 --- a/utils/repos/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/common/crud/CrudWriteRoutes.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.repos.ktor.common.crud - -const val newObjectsFlowRouting = "newObjectsFlow" -const val updatedObjectsFlowRouting = "updatedObjectsFlow" -const val deletedObjectsIdsFlowRouting = "deletedObjectsIdsFlow" - -const val createRouting = "create" -const val updateRouting = "update" -const val updateManyRouting = "updateMany" -const val deleteByIdRouting = "deleteById" diff --git a/utils/repos/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/common/key_value/KeyValueParameterNames.kt b/utils/repos/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/common/key_value/KeyValueParameterNames.kt deleted file mode 100644 index 54d557ac..00000000 --- a/utils/repos/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/common/key_value/KeyValueParameterNames.kt +++ /dev/null @@ -1,4 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.repos.ktor.common.key_value - -const val keyParameterName = "key" -const val reversedParameterName = "reversed" \ No newline at end of file diff --git a/utils/repos/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/common/key_value/KeyValuePostObject.kt b/utils/repos/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/common/key_value/KeyValuePostObject.kt deleted file mode 100644 index 720f70b4..00000000 --- a/utils/repos/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/common/key_value/KeyValuePostObject.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.repos.ktor.common.key_value - -import kotlinx.serialization.Serializable - -@Serializable -data class KeyValuePostObject ( - val key: K, - val value: V, -) \ No newline at end of file diff --git a/utils/repos/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/common/key_value/KeyValueRoutes.kt b/utils/repos/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/common/key_value/KeyValueRoutes.kt deleted file mode 100644 index e3c724b6..00000000 --- a/utils/repos/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/common/key_value/KeyValueRoutes.kt +++ /dev/null @@ -1,12 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.repos.ktor.common.key_value - -const val getRoute = "get" -const val valuesRoute = "values" -const val keysRoute = "keys" -const val containsRoute = "contains" -const val countRoute = "count" - -const val onNewValueRoute = "onNewValue" -const val onValueRemovedRoute = "onValueRemoved" -const val setRoute = "set" -const val unsetRoute = "unset" \ No newline at end of file diff --git a/utils/repos/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/common/one_to_many/OneToManyParametersNames.kt b/utils/repos/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/common/one_to_many/OneToManyParametersNames.kt deleted file mode 100644 index ed8d43b7..00000000 --- a/utils/repos/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/common/one_to_many/OneToManyParametersNames.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.repos.ktor.common.one_to_many - -const val keyParameterName = "key" -const val valueParameterName = "value" -const val reversedParameterName = "reversed" \ No newline at end of file diff --git a/utils/repos/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/common/one_to_many/OneToManyRoutes.kt b/utils/repos/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/common/one_to_many/OneToManyRoutes.kt deleted file mode 100644 index 5b1abfb4..00000000 --- a/utils/repos/ktor/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/common/one_to_many/OneToManyRoutes.kt +++ /dev/null @@ -1,12 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.repos.ktor.common.one_to_many - -const val getRoute = "get" -const val keysRoute = "keys" -const val containsByKeyRoute = "containsByKey" -const val containsByKeyValueRoute = "containsByKeyValue" -const val countByKeyRoute = "countByKey" -const val countRoute = "count" - -const val addRoute = "add" -const val removeRoute = "remove" -const val clearRoute = "clear" \ No newline at end of file diff --git a/utils/repos/ktor/server/build.gradle b/utils/repos/ktor/server/build.gradle deleted file mode 100644 index ae343e96..00000000 --- a/utils/repos/ktor/server/build.gradle +++ /dev/null @@ -1,64 +0,0 @@ -buildscript { - repositories { - mavenLocal() - jcenter() - mavenCentral() - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" - classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version" - } -} - -plugins { - id "org.jetbrains.kotlin.multiplatform" version "$kotlin_version" - id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version" -} - -project.version = "$core_version" -project.group = "com.insanusmokrassar" - -repositories { - mavenLocal() - jcenter() - mavenCentral() - maven { url "https://kotlin.bintray.com/kotlinx" } -} - -kotlin { - jvm() - - sourceSets { - commonMain { - dependencies { - implementation kotlin('stdlib') - api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version" - - api projectByName("utils.repos.ktor.common") - api projectByName("ktor.server") - } - } - commonTest { - dependencies { - implementation kotlin('test-common') - implementation kotlin('test-annotations-common') - } - } - - jvmMain { - dependencies { - api "io.ktor:ktor-server:$ktor_version" - api "io.ktor:ktor-server-host-common:$ktor_version" - api "io.ktor:ktor-server-netty:$ktor_version" - api "io.ktor:ktor-websockets:$ktor_version" - } - } - jvmTest { - dependencies { - implementation kotlin('test-junit') - } - } - } -} diff --git a/utils/repos/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/server/crud/KtorReadStandardCrudRepo.kt b/utils/repos/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/server/crud/KtorReadStandardCrudRepo.kt deleted file mode 100644 index 6e20f166..00000000 --- a/utils/repos/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/server/crud/KtorReadStandardCrudRepo.kt +++ /dev/null @@ -1,53 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.repos.ktor.server.crud - -import com.insanusmokrassar.postssystem.ktor.server.* -import com.insanusmokrassar.postssystem.utils.common.pagination.PaginationResult -import com.insanusmokrassar.postssystem.utils.repos.ReadStandardCRUDRepo -import com.insanusmokrassar.postssystem.utils.repos.ktor.common.crud.* -import io.ktor.application.call -import io.ktor.routing.Route -import io.ktor.routing.get -import kotlinx.serialization.KSerializer -import kotlinx.serialization.builtins.serializer - -fun Route.configureReadStandardCrudRepoRoutes( - originalRepo: ReadStandardCRUDRepo, - objectsSerializer: KSerializer, - objectsNullableSerializer: KSerializer, - idsSerializer: KSerializer -) { - val paginationResultSerializer = PaginationResult.serializer(objectsSerializer) - - get(getByPaginationRouting) { - val pagination = call.request.queryParameters.extractPagination - - call.unianswer( - paginationResultSerializer, - originalRepo.getByPagination(pagination) - ) - } - - get(getByIdRouting) { - val id = call.decodeUrlQueryValueOrSendError( - "id", - idsSerializer - ) ?: return@get - - call.unianswer( - objectsNullableSerializer, - originalRepo.getById(id) - ) - } - - get(containsRouting) { - val id = call.decodeUrlQueryValueOrSendError( - "id", - idsSerializer - ) ?: return@get - - call.unianswer( - Boolean.serializer(), - originalRepo.contains(id) - ) - } -} diff --git a/utils/repos/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/server/crud/KtorStandardCrudRepo.kt b/utils/repos/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/server/crud/KtorStandardCrudRepo.kt deleted file mode 100644 index 664dba6e..00000000 --- a/utils/repos/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/server/crud/KtorStandardCrudRepo.kt +++ /dev/null @@ -1,20 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.repos.ktor.server.crud - -import com.insanusmokrassar.postssystem.utils.repos.StandardCRUDRepo -import io.ktor.routing.Route -import io.ktor.routing.route -import kotlinx.serialization.KSerializer - -fun Route.configureStandardCrudRepoRoutes( - baseSubpart: String, - originalRepo: StandardCRUDRepo, - objectsSerializer: KSerializer, - objectsNullableSerializer: KSerializer, - inputsSerializer: KSerializer, - idsSerializer: KSerializer -) { - route(baseSubpart) { - configureReadStandardCrudRepoRoutes(originalRepo, objectsSerializer, objectsNullableSerializer, idsSerializer) - configureWriteStandardCrudRepoRoutes(originalRepo, objectsSerializer, objectsNullableSerializer, inputsSerializer, idsSerializer) - } -} diff --git a/utils/repos/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/server/crud/KtorWriteStandardCrudRepo.kt b/utils/repos/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/server/crud/KtorWriteStandardCrudRepo.kt deleted file mode 100644 index d190b133..00000000 --- a/utils/repos/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/server/crud/KtorWriteStandardCrudRepo.kt +++ /dev/null @@ -1,82 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.repos.ktor.server.crud - -import com.insanusmokrassar.postssystem.ktor.server.* -import com.insanusmokrassar.postssystem.utils.repos.WriteStandardCRUDRepo -import com.insanusmokrassar.postssystem.utils.repos.ktor.common.crud.* -import io.ktor.application.call -import io.ktor.routing.Route -import io.ktor.routing.post -import kotlinx.serialization.KSerializer -import kotlinx.serialization.builtins.* - -fun Route.configureWriteStandardCrudRepoRoutes( - originalRepo: WriteStandardCRUDRepo, - objectsSerializer: KSerializer, - objectsNullableSerializer: KSerializer, - inputsSerializer: KSerializer, - idsSerializer: KSerializer -) { - val listObjectsSerializer = ListSerializer(objectsSerializer) - val listInputSerializer = ListSerializer(inputsSerializer) - val listIdsSerializer = ListSerializer(idsSerializer) - val inputUpdateSerializer = PairSerializer( - idsSerializer, - inputsSerializer - ) - val listInputUpdateSerializer = ListSerializer(inputUpdateSerializer) - - includeWebsocketHandling( - newObjectsFlowRouting, - originalRepo.newObjectsFlow, - objectsSerializer - ) - includeWebsocketHandling( - updatedObjectsFlowRouting, - originalRepo.updatedObjectsFlow, - objectsSerializer - ) - includeWebsocketHandling( - deletedObjectsIdsFlowRouting, - originalRepo.deletedObjectsIdsFlow, - idsSerializer - ) - - post(createRouting) { - call.unianswer( - listObjectsSerializer, - originalRepo.create( - call.uniload(listInputSerializer) - ) - ) - } - - post(updateRouting) { - val (id, input) = call.uniload(inputUpdateSerializer) - call.unianswer( - objectsNullableSerializer, - originalRepo.update( - id, input - ) - ) - } - - post(updateManyRouting) { - val updates = call.uniload(listInputUpdateSerializer) - call.unianswer( - listObjectsSerializer, - originalRepo.update( - updates - ) - ) - } - - post(deleteByIdRouting) { - val ids = call.uniload(listIdsSerializer) - call.unianswer( - Unit.serializer(), - originalRepo.deleteById( - ids - ) - ) - } -} diff --git a/utils/repos/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/server/key_value/KtorStandartKeyValueRepo.kt b/utils/repos/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/server/key_value/KtorStandartKeyValueRepo.kt deleted file mode 100644 index 95401505..00000000 --- a/utils/repos/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/server/key_value/KtorStandartKeyValueRepo.kt +++ /dev/null @@ -1,27 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.repos.ktor.server.key_value - -import com.insanusmokrassar.postssystem.utils.repos.StandardKeyValueRepo -import io.ktor.routing.* -import kotlinx.serialization.KSerializer - -fun Route.configureStandartKeyValueRepoRoutes( - baseSubpart: String, - originalRepo: StandardKeyValueRepo, - keySerializer: KSerializer, - valueSerializer: KSerializer, - valueNullableSerializer: KSerializer, -) { - route(baseSubpart) { - configureReadStandartKeyValueRepoRoutes( - originalRepo, - keySerializer, - valueSerializer, - valueNullableSerializer, - ) - configureWriteStandartKeyValueRepoRoutes( - originalRepo, - keySerializer, - valueSerializer, - ) - } -} \ No newline at end of file diff --git a/utils/repos/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/server/key_value/KtorStandartReadKeyValueRepo.kt b/utils/repos/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/server/key_value/KtorStandartReadKeyValueRepo.kt deleted file mode 100644 index e0e6e784..00000000 --- a/utils/repos/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/server/key_value/KtorStandartReadKeyValueRepo.kt +++ /dev/null @@ -1,74 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.repos.ktor.server.key_value - -import com.insanusmokrassar.postssystem.ktor.server.* -import com.insanusmokrassar.postssystem.utils.common.pagination.PaginationResult -import com.insanusmokrassar.postssystem.utils.repos.StandardReadKeyValueRepo -import com.insanusmokrassar.postssystem.utils.repos.ktor.common.key_value.* -import io.ktor.application.* -import io.ktor.routing.* -import kotlinx.serialization.KSerializer -import kotlinx.serialization.builtins.serializer - -fun Route.configureReadStandartKeyValueRepoRoutes ( - originalRepo: StandardReadKeyValueRepo, - keySerializer: KSerializer, - valueSerializer: KSerializer, - valueNullableSerializer: KSerializer, -) { - get(getRoute) { - val key = call.decodeUrlQueryValueOrSendError( - keyParameterName, - keySerializer - ) ?: return@get - - call.unianswer( - valueNullableSerializer, - originalRepo.get(key) - ) - } - - get(valuesRoute) { - val parination = call.request.queryParameters.extractPagination; - val reversed = call.decodeUrlQueryValueOrSendError( - reversedParameterName, - Boolean.serializer() - ) ?: return@get - - call.unianswer( - PaginationResult.serializer(valueSerializer), - originalRepo.values(parination, reversed) - ) - } - - get(keysRoute) { - val parination = call.request.queryParameters.extractPagination; - val reversed = call.decodeUrlQueryValueOrSendError( - reversedParameterName, - Boolean.serializer() - ) ?: return@get - - call.unianswer( - PaginationResult.serializer(keySerializer), - originalRepo.keys(parination, reversed) - ) - } - - get(containsRoute) { - val key = call.decodeUrlQueryValueOrSendError( - keyParameterName, - keySerializer - ) ?: return@get - - call.unianswer( - Boolean.serializer(), - originalRepo.contains(key) - ) - } - - get(countRoute) { - call.unianswer( - Long.serializer(), - originalRepo.count() - ) - } -} \ No newline at end of file diff --git a/utils/repos/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/server/key_value/KtorStandartWriteKeyValueRepo.kt b/utils/repos/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/server/key_value/KtorStandartWriteKeyValueRepo.kt deleted file mode 100644 index f74a6296..00000000 --- a/utils/repos/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/server/key_value/KtorStandartWriteKeyValueRepo.kt +++ /dev/null @@ -1,44 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.repos.ktor.server.key_value - -import com.insanusmokrassar.postssystem.ktor.server.includeWebsocketHandling -import com.insanusmokrassar.postssystem.ktor.server.uniload -import com.insanusmokrassar.postssystem.utils.repos.StandardWriteKeyValueRepo -import com.insanusmokrassar.postssystem.utils.repos.ktor.common.key_value.* -import io.ktor.application.* -import io.ktor.routing.* -import kotlinx.serialization.KSerializer -import kotlinx.serialization.builtins.PairSerializer - -fun Route.configureWriteStandartKeyValueRepoRoutes ( - originalRepo: StandardWriteKeyValueRepo, - keySerializer: KSerializer, - valueSerializer: KSerializer, -) { - includeWebsocketHandling( - onNewValueRoute, - originalRepo.onNewValue, - PairSerializer(keySerializer, valueSerializer) - ) - - includeWebsocketHandling( - onValueRemovedRoute, - originalRepo.onValueRemoved, - keySerializer - ) - - post(setRoute) { - val (key, value) = call.uniload( - KeyValuePostObject.serializer(keySerializer, valueSerializer) - ) - - originalRepo.set(key, value) - } - - post(unsetRoute) { - val key = call.uniload( - keySerializer - ) - - originalRepo.unset(key) - } -} \ No newline at end of file diff --git a/utils/repos/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/server/one_to_many/ConfigureOneToManyKeyValueRepoRoutes.kt b/utils/repos/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/server/one_to_many/ConfigureOneToManyKeyValueRepoRoutes.kt deleted file mode 100644 index 507f75c9..00000000 --- a/utils/repos/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/server/one_to_many/ConfigureOneToManyKeyValueRepoRoutes.kt +++ /dev/null @@ -1,18 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.repos.ktor.server.one_to_many - -import com.insanusmokrassar.postssystem.utils.repos.OneToManyKeyValueRepo -import io.ktor.routing.Route -import io.ktor.routing.route -import kotlinx.serialization.KSerializer - -fun Route.configureOneToManyKeyValueRepoRoutes( - baseSubpart: String, - originalRepo: OneToManyKeyValueRepo, - keySerializer: KSerializer, - valueSealizer: KSerializer, -) { - route(baseSubpart) { - configureOneToManyReadKeyValueRepoRoutes(originalRepo, keySerializer, valueSealizer) - configureOneToManyWriteKeyValueRepoRoutes(originalRepo, keySerializer, valueSealizer) - } -} \ No newline at end of file diff --git a/utils/repos/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/server/one_to_many/ConfigureOneToManyReadKeyValueRepoRoutes.kt b/utils/repos/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/server/one_to_many/ConfigureOneToManyReadKeyValueRepoRoutes.kt deleted file mode 100644 index 1a48c7f8..00000000 --- a/utils/repos/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/server/one_to_many/ConfigureOneToManyReadKeyValueRepoRoutes.kt +++ /dev/null @@ -1,99 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.repos.ktor.server.one_to_many - -import com.insanusmokrassar.postssystem.ktor.server.* -import com.insanusmokrassar.postssystem.ktor.standardKtorSerialFormat -import com.insanusmokrassar.postssystem.utils.common.pagination.PaginationResult -import com.insanusmokrassar.postssystem.utils.repos.OneToManyReadKeyValueRepo -import com.insanusmokrassar.postssystem.utils.repos.ktor.common.one_to_many.* -import io.ktor.application.call -import io.ktor.routing.Route -import io.ktor.routing.get -import kotlinx.serialization.KSerializer -import kotlinx.serialization.builtins.serializer -import kotlinx.serialization.decodeFromHexString - -fun Route.configureOneToManyReadKeyValueRepoRoutes( - originalRepo: OneToManyReadKeyValueRepo, - keySerializer: KSerializer, - valueSealizer: KSerializer, -) { - val paginationKeyResult = PaginationResult.serializer(keySerializer) - val paginationValueResult = PaginationResult.serializer(valueSealizer) - - get(getRoute) { - val pagination = call.request.queryParameters.extractPagination - val key = call.decodeUrlQueryValueOrSendError( - keyParameterName, - keySerializer - ) ?: return@get - val reversed = call.decodeUrlQueryValue( - reversedParameterName, - Boolean.serializer() - ) ?: false - - call.unianswer( - paginationValueResult, - originalRepo.get(key, pagination, reversed) - ) - } - - get(keysRoute) { - val pagination = call.request.queryParameters.extractPagination - val reversed = call.decodeUrlQueryValue( - reversedParameterName, - Boolean.serializer() - ) ?: false - - call.unianswer( - paginationKeyResult, - originalRepo.keys(pagination, reversed) - ) - } - - get(containsByKeyRoute) { - val key = call.decodeUrlQueryValueOrSendError( - keyParameterName, - keySerializer - ) ?: return@get - - call.unianswer( - Boolean.serializer(), - originalRepo.contains(key) - ) - } - - get(containsByKeyValueRoute) { - val key = call.decodeUrlQueryValueOrSendError( - keyParameterName, - keySerializer - ) ?: return@get - val value = call.decodeUrlQueryValueOrSendError( - valueParameterName, - valueSealizer - ) ?: return@get - - call.unianswer( - Boolean.serializer(), - originalRepo.contains(key, value) - ) - } - - get(countByKeyRoute) { - val key = call.decodeUrlQueryValueOrSendError( - keyParameterName, - keySerializer - ) ?: return@get - - call.unianswer( - Long.serializer(), - originalRepo.count(key) - ) - } - - get(countRoute) { - call.unianswer( - Long.serializer(), - originalRepo.count() - ) - } -} \ No newline at end of file diff --git a/utils/repos/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/server/one_to_many/ConfigureOneToManyWriteKeyValueRepoRoutes.kt b/utils/repos/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/server/one_to_many/ConfigureOneToManyWriteKeyValueRepoRoutes.kt deleted file mode 100644 index fffc3b24..00000000 --- a/utils/repos/ktor/server/src/jvmMain/kotlin/com/insanusmokrassar/postssystem/utils/repos/ktor/server/one_to_many/ConfigureOneToManyWriteKeyValueRepoRoutes.kt +++ /dev/null @@ -1,51 +0,0 @@ -package com.insanusmokrassar.postssystem.utils.repos.ktor.server.one_to_many - -import com.insanusmokrassar.postssystem.ktor.server.unianswer -import com.insanusmokrassar.postssystem.ktor.server.uniload -import com.insanusmokrassar.postssystem.utils.repos.OneToManyWriteKeyValueRepo -import com.insanusmokrassar.postssystem.utils.repos.ktor.common.one_to_many.* -import io.ktor.application.call -import io.ktor.routing.Route -import io.ktor.routing.post -import kotlinx.serialization.KSerializer -import kotlinx.serialization.builtins.PairSerializer -import kotlinx.serialization.builtins.serializer - -fun Route.configureOneToManyWriteKeyValueRepoRoutes( - originalRepo: OneToManyWriteKeyValueRepo, - keySerializer: KSerializer, - valueSealizer: KSerializer, -) { - val keyValueSerializer = PairSerializer(keySerializer, valueSealizer) - - post(addRoute) { - val obj = call.uniload( - keyValueSerializer - ) - - call.unianswer( - Unit.serializer(), - originalRepo.add(obj.first, obj.second) - ) - } - - post(removeRoute) { - val obj = call.uniload( - keyValueSerializer - ) - - call.unianswer( - Unit.serializer(), - originalRepo.remove(obj.first, obj.second), - ) - } - - post(clearRoute) { - val key = call.uniload(keySerializer) - - call.unianswer( - Unit.serializer(), - originalRepo.clear(key), - ) - } -} \ No newline at end of file