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 type: array
items: items:
type: string type: string
format: ident
ShareSecret: ShareSecret:
description: | description: |
@ -5811,8 +5810,8 @@ components:
ItemsAndRefs: ItemsAndRefs:
description: | description: |
Holds a list of item ids and a list of ids of some other Holds a list of item ids and a list of names or ids of some
related entity (e.g. tags). other related entity (e.g. tags).
required: required:
- items - items
- refs - refs
@ -5826,7 +5825,6 @@ components:
type: array type: array
items: items:
type: string type: string
format: ident
ItemsAndRef: ItemsAndRef:
description: | description: |
Holds a list of item ids and a single optional id of some 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.BackendApp
import docspell.backend.auth.AuthToken import docspell.backend.auth.AuthToken
import docspell.restapi.model._ import docspell.restapi.model._
import docspell.restserver.conv.MultiIdSupport import docspell.restserver.conv.NonEmptyListSupport
import org.http4s.HttpRoutes import org.http4s.HttpRoutes
import org.http4s.circe.CirceEntityDecoder._ import org.http4s.circe.CirceEntityDecoder._
import org.http4s.circe.CirceEntityEncoder._ import org.http4s.circe.CirceEntityEncoder._
import org.http4s.dsl.Http4sDsl import org.http4s.dsl.Http4sDsl
object AttachmentMultiRoutes extends MultiIdSupport { object AttachmentMultiRoutes extends NonEmptyListSupport {
def apply[F[_]: Async]( def apply[F[_]: Async](
backend: BackendApp[F], backend: BackendApp[F],
@ -32,7 +32,7 @@ object AttachmentMultiRoutes extends MultiIdSupport {
HttpRoutes.of { case req @ POST -> Root / "delete" => HttpRoutes.of { case req @ POST -> Root / "delete" =>
for { for {
json <- req.as[IdList] json <- req.as[IdList]
attachments <- readIds[F](json.ids) attachments <- requireNonEmpty(json.ids)
n <- backend.item.deleteAttachmentMultiple(attachments, user.account.collective) n <- backend.item.deleteAttachmentMultiple(attachments, user.account.collective)
res = BasicResult( res = BasicResult(
n > 0, n > 0,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.34") addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.34")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0") 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-pgp" % "2.1.2")
addSbtPlugin("com.github.sbt" % "sbt-release" % "1.1.0") addSbtPlugin("com.github.sbt" % "sbt-release" % "1.1.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.2") addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.2")