Merge pull request #1297 from eikek/update-sbt-plugin

Update sbt-openapi-schema plugin to 0.9.0
This commit is contained in:
mergify[bot] 2022-01-17 17:08:04 +00:00 committed by GitHub
commit 44e599dc86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 53 additions and 37 deletions

View File

@ -5567,7 +5567,6 @@ components:
type: array
items:
type: string
format: ident
ShareSecret:
description: |
@ -5811,8 +5810,8 @@ components:
ItemsAndRefs:
description: |
Holds a list of item ids and a list of ids of some other
related entity (e.g. tags).
Holds a list of item ids and a list of names or ids of some
other related entity (e.g. tags).
required:
- items
- refs
@ -5826,7 +5825,6 @@ components:
type: array
items:
type: string
format: ident
ItemsAndRef:
description: |
Holds a list of item ids and a single optional id of some

View File

@ -0,0 +1,20 @@
/*
* Copyright 2020 Eike K. & Contributors
*
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
package docspell.restserver.conv
import cats.data.NonEmptyList
import cats.effect._
trait NonEmptyListSupport {
def requireNonEmpty[F[_]: Sync, A](list: List[A]): F[NonEmptyList[A]] =
NonEmptyList.fromList(list) match {
case Some(nel) => Sync[F].pure(nel)
case None =>
Sync[F].raiseError(new IllegalArgumentException("Empty list not allowed"))
}
}

View File

@ -12,14 +12,14 @@ import cats.implicits._
import docspell.backend.BackendApp
import docspell.backend.auth.AuthToken
import docspell.restapi.model._
import docspell.restserver.conv.MultiIdSupport
import docspell.restserver.conv.NonEmptyListSupport
import org.http4s.HttpRoutes
import org.http4s.circe.CirceEntityDecoder._
import org.http4s.circe.CirceEntityEncoder._
import org.http4s.dsl.Http4sDsl
object AttachmentMultiRoutes extends MultiIdSupport {
object AttachmentMultiRoutes extends NonEmptyListSupport {
def apply[F[_]: Async](
backend: BackendApp[F],
@ -32,7 +32,7 @@ object AttachmentMultiRoutes extends MultiIdSupport {
HttpRoutes.of { case req @ POST -> Root / "delete" =>
for {
json <- req.as[IdList]
attachments <- readIds[F](json.ids)
attachments <- requireNonEmpty(json.ids)
n <- backend.item.deleteAttachmentMultiple(attachments, user.account.collective)
res = BasicResult(
n > 0,

View File

@ -62,7 +62,7 @@ object CollectiveRoutes {
settings.emptyTrash.minAge
)
),
settings.passwords.map(Password.apply)
settings.passwords
)
res <-
backend.collective
@ -90,7 +90,7 @@ object CollectiveRoutes {
trash.schedule,
trash.minAge
),
settDb.map(_.passwords).getOrElse(Nil).map(_.pass)
settDb.map(_.passwords).getOrElse(Nil)
)
)
resp <- sett.toResponse()

View File

@ -15,7 +15,7 @@ import docspell.backend.ops.OCustomFields.{RemoveValue, SetValue}
import docspell.common._
import docspell.restapi.model._
import docspell.restserver.Config
import docspell.restserver.conv.{Conversions, MultiIdSupport}
import docspell.restserver.conv.{Conversions, MultiIdSupport, NonEmptyListSupport}
import docspell.restserver.http4s.ClientRequestInfo
import org.http4s.HttpRoutes
@ -24,7 +24,7 @@ import org.http4s.circe.CirceEntityEncoder._
import org.http4s.dsl.Http4sDsl
import org.log4s.getLogger
object ItemMultiRoutes extends MultiIdSupport {
object ItemMultiRoutes extends NonEmptyListSupport with MultiIdSupport {
private[this] val log4sLogger = getLogger
def apply[F[_]: Async](
@ -39,7 +39,7 @@ object ItemMultiRoutes extends MultiIdSupport {
case req @ PUT -> Root / "confirm" =>
for {
json <- req.as[IdList]
data <- readIds[F](json.ids)
data <- requireNonEmpty(json.ids)
res <- backend.item.setStates(
data,
ItemState.Confirmed,
@ -51,7 +51,7 @@ object ItemMultiRoutes extends MultiIdSupport {
case req @ PUT -> Root / "unconfirm" =>
for {
json <- req.as[IdList]
data <- readIds[F](json.ids)
data <- requireNonEmpty(json.ids)
res <- backend.item.setStates(
data,
ItemState.Created,
@ -63,7 +63,7 @@ object ItemMultiRoutes extends MultiIdSupport {
case req @ PUT -> Root / "tags" =>
for {
json <- req.as[ItemsAndRefs]
items <- readIds[F](json.items)
items <- requireNonEmpty(json.items)
res <- backend.item.setTagsMultipleItems(
items,
json.refs,
@ -77,7 +77,7 @@ object ItemMultiRoutes extends MultiIdSupport {
case req @ POST -> Root / "tags" =>
for {
json <- req.as[ItemsAndRefs]
items <- readIds[F](json.items)
items <- requireNonEmpty(json.items)
res <- backend.item.linkTagsMultipleItems(
items,
json.refs,
@ -91,7 +91,7 @@ object ItemMultiRoutes extends MultiIdSupport {
case req @ POST -> Root / "tagsremove" =>
for {
json <- req.as[ItemsAndRefs]
items <- readIds[F](json.items)
items <- requireNonEmpty(json.items)
res <- backend.item.removeTagsMultipleItems(
items,
json.refs,
@ -105,7 +105,7 @@ object ItemMultiRoutes extends MultiIdSupport {
case req @ PUT -> Root / "name" =>
for {
json <- req.as[ItemsAndName]
items <- readIds[F](json.items)
items <- requireNonEmpty(json.items)
res <- backend.item.setNameMultiple(
items,
json.name.notEmpty.getOrElse(""),
@ -117,7 +117,7 @@ object ItemMultiRoutes extends MultiIdSupport {
case req @ PUT -> Root / "folder" =>
for {
json <- req.as[ItemsAndRef]
items <- readIds[F](json.items)
items <- requireNonEmpty(json.items)
res <- backend.item.setFolderMultiple(items, json.ref, user.account.collective)
resp <- Ok(Conversions.basicResult(res, "Folder updated"))
} yield resp
@ -125,7 +125,7 @@ object ItemMultiRoutes extends MultiIdSupport {
case req @ PUT -> Root / "direction" =>
for {
json <- req.as[ItemsAndDirection]
items <- readIds[F](json.items)
items <- requireNonEmpty(json.items)
res <- backend.item.setDirection(items, json.direction, user.account.collective)
resp <- Ok(Conversions.basicResult(res, "Direction updated"))
} yield resp
@ -133,7 +133,7 @@ object ItemMultiRoutes extends MultiIdSupport {
case req @ PUT -> Root / "date" =>
for {
json <- req.as[ItemsAndDate]
items <- readIds[F](json.items)
items <- requireNonEmpty(json.items)
res <- backend.item.setItemDate(items, json.date, user.account.collective)
resp <- Ok(Conversions.basicResult(res, "Item date updated"))
} yield resp
@ -141,7 +141,7 @@ object ItemMultiRoutes extends MultiIdSupport {
case req @ PUT -> Root / "duedate" =>
for {
json <- req.as[ItemsAndDate]
items <- readIds[F](json.items)
items <- requireNonEmpty(json.items)
res <- backend.item.setItemDueDate(items, json.date, user.account.collective)
resp <- Ok(Conversions.basicResult(res, "Item due date updated"))
} yield resp
@ -149,7 +149,7 @@ object ItemMultiRoutes extends MultiIdSupport {
case req @ PUT -> Root / "corrOrg" =>
for {
json <- req.as[ItemsAndRef]
items <- readIds[F](json.items)
items <- requireNonEmpty(json.items)
res <- backend.item.setCorrOrg(items, json.ref, user.account.collective)
resp <- Ok(Conversions.basicResult(res, "Correspondent organization updated"))
} yield resp
@ -157,7 +157,7 @@ object ItemMultiRoutes extends MultiIdSupport {
case req @ PUT -> Root / "corrPerson" =>
for {
json <- req.as[ItemsAndRef]
items <- readIds[F](json.items)
items <- requireNonEmpty(json.items)
res <- backend.item.setCorrPerson(items, json.ref, user.account.collective)
resp <- Ok(Conversions.basicResult(res, "Correspondent person updated"))
} yield resp
@ -165,7 +165,7 @@ object ItemMultiRoutes extends MultiIdSupport {
case req @ PUT -> Root / "concPerson" =>
for {
json <- req.as[ItemsAndRef]
items <- readIds[F](json.items)
items <- requireNonEmpty(json.items)
res <- backend.item.setConcPerson(items, json.ref, user.account.collective)
resp <- Ok(Conversions.basicResult(res, "Concerned person updated"))
} yield resp
@ -173,7 +173,7 @@ object ItemMultiRoutes extends MultiIdSupport {
case req @ PUT -> Root / "concEquipment" =>
for {
json <- req.as[ItemsAndRef]
items <- readIds[F](json.items)
items <- requireNonEmpty(json.items)
res <- backend.item.setConcEquip(items, json.ref, user.account.collective)
resp <- Ok(Conversions.basicResult(res, "Concerned equipment updated"))
} yield resp
@ -181,7 +181,7 @@ object ItemMultiRoutes extends MultiIdSupport {
case req @ POST -> Root / "reprocess" =>
for {
json <- req.as[IdList]
items <- readIds[F](json.ids)
items <- requireNonEmpty(json.ids)
res <- backend.item.reprocessAll(items, user.account, true)
resp <- Ok(Conversions.basicResult(res, "Re-process task(s) submitted."))
} yield resp
@ -189,7 +189,7 @@ object ItemMultiRoutes extends MultiIdSupport {
case req @ POST -> Root / "deleteAll" =>
for {
json <- req.as[IdList]
items <- readIds[F](json.ids)
items <- requireNonEmpty(json.ids)
n <- backend.item.setDeletedState(items, user.account.collective)
res = BasicResult(
n > 0,
@ -201,7 +201,7 @@ object ItemMultiRoutes extends MultiIdSupport {
case req @ POST -> Root / "restoreAll" =>
for {
json <- req.as[IdList]
items <- readIds[F](json.ids)
items <- requireNonEmpty(json.ids)
res <- backend.item.restore(items, user.account.collective)
resp <- Ok(Conversions.basicResult(res, "Item(s) deleted"))
} yield resp
@ -209,7 +209,7 @@ object ItemMultiRoutes extends MultiIdSupport {
case req @ PUT -> Root / "customfield" =>
for {
json <- req.as[ItemsAndFieldValue]
items <- readIds[F](json.items)
items <- requireNonEmpty(json.items)
res <- backend.customFields.setValueMultiple(
items,
SetValue(json.field.field, json.field.value, user.account.collective)
@ -222,7 +222,7 @@ object ItemMultiRoutes extends MultiIdSupport {
case req @ POST -> Root / "customfieldremove" =>
for {
json <- req.as[ItemsAndName]
items <- readIds[F](json.items)
items <- requireNonEmpty(json.items)
field <- readId[F](json.name)
res <- backend.customFields.deleteValue(
RemoveValue(field, items, user.account.collective)
@ -235,7 +235,7 @@ object ItemMultiRoutes extends MultiIdSupport {
case req @ POST -> Root / "merge" =>
for {
json <- req.as[IdList]
items <- readIds[F](json.ids)
items <- requireNonEmpty(json.ids)
logger = Logger.log4s(log4sLogger)
res <- backend.item.merge(logger, items, user.account.collective)
resp <- Ok(Conversions.basicResult(res, "Items merged"))

View File

@ -390,9 +390,8 @@ object ItemRoutes {
case req @ POST -> Root / Ident(id) / "reprocess" =>
for {
data <- req.as[IdList]
ids = data.ids.flatMap(s => Ident.fromString(s).toOption)
_ <- logger.fdebug(s"Re-process item ${id.id}")
res <- backend.item.reprocess(id, ids, user.account, true)
res <- backend.item.reprocess(id, data.ids, user.account, true)
resp <- Ok(Conversions.basicResult(res, "Re-process task submitted."))
} yield resp

View File

@ -46,10 +46,9 @@ object MailSendRoutes {
rec <- s.recipients.traverse(MailAddress.parse)
cc <- s.cc.traverse(MailAddress.parse)
bcc <- s.bcc.traverse(MailAddress.parse)
fileIds <- s.attachmentIds.traverse(Ident.fromString)
sel =
if (s.addAllAttachments) AttachSelection.All
else AttachSelection.Selected(fileIds)
else AttachSelection.Selected(s.attachmentIds)
} yield ItemMail(item, s.subject, rec, cc, bcc, s.body, sel)
def convertOut(res: SendResult): BasicResult =

View File

@ -73,7 +73,7 @@ object UserRoutes {
AccountId(user.account.collective, username)
)
resp <- Ok(
DeleteUserData(data.ownedFolders.map(_.id), data.sentMails, data.shares)
DeleteUserData(data.ownedFolders, data.sentMails, data.shares)
)
} yield resp
}

View File

@ -1,6 +1,6 @@
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.34")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0")
addSbtPlugin("com.github.eikek" % "sbt-openapi-schema" % "0.8.2")
addSbtPlugin("com.github.eikek" % "sbt-openapi-schema" % "0.9.0")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2")
addSbtPlugin("com.github.sbt" % "sbt-release" % "1.1.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.2")