All Downloads are FREE. Search and download functionalities are using the official Maven repository.

no.kodeworks.kvarg.message.package.scala Maven / Gradle / Ivy

There is a newer version: 0.7
Show newest version
package no.kodeworks.kvarg

import no.kodeworks.kvarg.patch.Patch
import no.kodeworks.kvarg.check.Checked
import no.kodeworks.kvarg.model.Page
import io.circe.generic.JsonCodec
import shapeless._

package object message {

  sealed trait CometMessage

  sealed trait Crud

  object Crud {
    //TODO config-params?
    val commitDefault = true
    val stashDefault = true
  }

  import Crud._

  case class Save[T](
                      t: T,
                      page: Option[Page] = None,
                      // invalid saves are attempted stored as patches, thus need these two params
                      commit: Boolean = commitDefault,
                      stash: Boolean = commitDefault
                    )(implicit
                      val tt: Typeable[T]
                    ) extends Crud

  case class Update[T](
                        patch: Patch[T],
                        page: Option[Page] = None,
                        // valid patches are applied to completes
                        commit: Boolean = commitDefault,
                        // invalid patches are discarded
                        stash: Boolean = commitDefault
                      )(implicit
                        val tt: Typeable[T]
                      ) extends Crud

  case object GetAll extends Crud

  case class Get[T](id: Option[Long] = None)(implicit val tt: Typeable[T]) extends Crud

  case class Commit(id: Long) extends Crud

  case class Stash(id: Long) extends Crud

  sealed trait SaveReply[T]

  case class SaveInserted[T](data: T, diff: Patch[T], checkeds: List[Checked]) extends SaveReply[T]

  case class SaveUpdated[T](data: T, diff: Patch[T], checkeds: List[Checked]) extends SaveReply[T]

  case class IncompletelyUpdated[T](data: Patch[T], diff: Patch[T], checkeds: List[Checked]) extends SaveReply[T]

  case class UpdateStashed[T](data: Patch[T], diff: Patch[T], checkeds: List[Checked]) extends SaveReply[T]

  case object SaveUnknownId extends SaveReply[Nothing]

  case class SaveBadType(checkeds: List[Checked]) extends SaveReply[Nothing]

  case class GetAllReply[T <: HList](ts: T)

  sealed trait GetReply

  case class GetReplyList[T](ts: List[T]) extends GetReply

  case class GetReplyComplete[T](t: T) extends GetReply

  case class GetReplyPatch[T](t: Patch[T]) extends GetReply

  case object GetReplyEmpty extends GetReply

  case object GetBadType extends GetReply

  case object Die

  sealed trait InitMessage

  case object InitSuccess extends InitMessage

  case object InitFailure extends InitMessage

  case object InitTimeout extends InitMessage

  case class Role(name: String)

  case class Auth(
                   roles: List[Role]
                 )

  case class Props(auth: Auth)

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy