diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 86f6dbf..362bb58 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,7 +34,8 @@ jobs: with: jvm: 21 - run: scala-cli fmt --check . - - run: scala-cli --power test . + - run: sbt test + - run: sbt "scalafix --check OrganizeImports" build: name: Build and push Docker diff --git a/.scalafix.conf b/.scalafix.conf new file mode 100644 index 0000000..665c9a2 --- /dev/null +++ b/.scalafix.conf @@ -0,0 +1 @@ +OrganizeImports.removeUnused = false diff --git a/README.md b/README.md index f82a60d..2501724 100644 --- a/README.md +++ b/README.md @@ -62,3 +62,7 @@ docker run -it --rm \ -e OPENAI_TOKEN='oai_key' \ ghcr.io/didx-xyz/dawn-patrol ``` + +## Scalafix + +To organise imports, while in sbt run: scalafix OrganizeImports diff --git a/build.sbt b/build.sbt index e3d71e7..5f2e61b 100644 --- a/build.sbt +++ b/build.sbt @@ -1,37 +1,61 @@ scalaVersion := "3.3.1" -scalacOptions ++= Seq("-Xmax-inlines", "50") +lazy val circeVersion = "0.14.6" +lazy val pureconfigVersion = "0.17.4" +lazy val redis4CatsVersion = "1.5.2" +lazy val sttpClient3Version = "3.9.1" +lazy val langchain4jVersion = "0.23.0" +lazy val xefVersion = "0.0.3" -val circeVersion = "0.14.6" -val pureconfigVersion = "0.17.4" -val redis4CatsVersion = "1.5.2" -val sttpClient3Version = "3.9.1" -val langchain4jVersion = "0.23.0" -val xefVersion = "0.0.3" +lazy val root = (project in file(".")) + .settings( + settings, + libraryDependencies ++= Seq( + "io.circe" %% "circe-core" % circeVersion, + "io.circe" %% "circe-parser" % circeVersion, + "io.circe" %% "circe-generic" % circeVersion, + "com.github.pureconfig" %% "pureconfig-core" % pureconfigVersion, + "com.github.pureconfig" %% "pureconfig-cats-effect" % pureconfigVersion, + "dev.profunktor" %% "redis4cats-effects" % redis4CatsVersion, + "dev.profunktor" %% "redis4cats-log4cats" % redis4CatsVersion, + "com.softwaremill.sttp.client4" %% "core" % "4.0.0-M6", + "com.softwaremill.sttp.client3" %% "core" % sttpClient3Version, + "com.softwaremill.sttp.client3" %% "circe" % sttpClient3Version, + "com.softwaremill.sttp.client3" %% "async-http-client-backend-cats" % sttpClient3Version, + "de.brendamour" % "jpasskit" % "0.3.3", + "com.outr" %% "scribe" % "3.12.2", + "com.lihaoyi" %% "upickle" % "3.1.3", + "dev.langchain4j" % "langchain4j" % langchain4jVersion, + "dev.langchain4j" % "langchain4j-hugging-face" % langchain4jVersion, + "com.xebia" %% "xef-scala" % xefVersion, + "com.xebia" % "xef-pdf" % xefVersion, + "com.xebia" % "xef-reasoning-jvm" % xefVersion, + "com.xebia" % "xef-openai" % xefVersion, + "ch.qos.logback" % "logback-classic" % "1.4.11", + "org.apache.logging.log4j" % "log4j-core" % "2.21.1", + "org.typelevel" %% "log4cats-slf4j" % "2.6.0", + "co.fs2" %% "fs2-core" % "3.9.3", + "org.typelevel" %% "munit-cats-effect" % "2.0.0-M4" % "test" + ) + ) -libraryDependencies ++= Seq( - "io.circe" %% "circe-core" % circeVersion, - "io.circe" %% "circe-parser" % circeVersion, - "io.circe" %% "circe-generic" % circeVersion, - "com.github.pureconfig" %% "pureconfig-core" % pureconfigVersion, - "com.github.pureconfig" %% "pureconfig-cats-effect" % pureconfigVersion, - "dev.profunktor" %% "redis4cats-effects" % redis4CatsVersion, - "dev.profunktor" %% "redis4cats-log4cats" % redis4CatsVersion, - "com.softwaremill.sttp.client4" %% "core" % "4.0.0-M6", - "com.softwaremill.sttp.client3" %% "core" % sttpClient3Version, - "com.softwaremill.sttp.client3" %% "circe" % sttpClient3Version, - "com.softwaremill.sttp.client3" %% "async-http-client-backend-cats" % sttpClient3Version, - "de.brendamour" % "jpasskit" % "0.3.3", - "com.outr" %% "scribe" % "3.12.2", - "com.lihaoyi" %% "upickle" % "3.1.3", - "dev.langchain4j" % "langchain4j" % langchain4jVersion, - "dev.langchain4j" % "langchain4j-hugging-face" % langchain4jVersion, - "com.xebia" %% "xef-scala" % xefVersion, - "com.xebia" % "xef-pdf" % xefVersion, - "com.xebia" % "xef-reasoning-jvm" % xefVersion, - "com.xebia" % "xef-openai" % xefVersion, - "ch.qos.logback" % "logback-classic" % "1.4.11", - "org.apache.logging.log4j" % "log4j-core" % "2.21.1", - "org.typelevel" %% "log4cats-slf4j" % "2.6.0", - "co.fs2" %% "fs2-core" % "3.9.3" +// Settings +lazy val compilerOptions = Seq( + "-Xmax-inlines", + "50", + "-unchecked", // Enable additional warnings where generated code depends on assumptions. + "-feature", // Emit warning and location for usages of features that should be imported explicitly. + "-language:existentials", // Existential types (besides wildcard types) can be written and inferred + "-language:higherKinds", // Allow higher-kinded types + "-language:implicitConversions", // Allow definition of implicit functions called views + "-language:postfixOps", // Allow postfix operator notation, such as 1 to 10 toList (not recommended) + "-deprecation" ) + +lazy val commonSettings = Seq( + scalacOptions ++= compilerOptions +) + +lazy val scalafixSettings = Seq(semanticdbEnabled := true) + +lazy val settings = commonSettings ++ scalafixSettings diff --git a/project/plugins.sbt b/project/plugins.sbt new file mode 100644 index 0000000..c961009 --- /dev/null +++ b/project/plugins.sbt @@ -0,0 +1,3 @@ +addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2") + +addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.11.1") diff --git a/src/main/scala/xyz/didx/ConversationPollingHandler.scala b/src/main/scala/xyz/didx/ConversationPollingHandler.scala index d7e2cea..3f24c6f 100644 --- a/src/main/scala/xyz/didx/ConversationPollingHandler.scala +++ b/src/main/scala/xyz/didx/ConversationPollingHandler.scala @@ -1,38 +1,29 @@ package xyz.didx -import scala.collection.mutable -//import io.circe._ +import cats.data.EitherT +import cats.effect.FiberIO +import cats.effect.IO +import cats.effect.Ref +import cats.implicits.* import io.circe.parser.* import io.circe.syntax.* import org.typelevel.log4cats.Logger -import org.typelevel.log4cats.slf4j.Slf4jLogger import sttp.client3.SttpBackend +import xyz.didx.ai.AiHandler +import xyz.didx.ai.model.ChatState import xyz.didx.config.ConfigReaders.* -import xyz.didx.logging.LogWriter.* import xyz.didx.didcomm.* +import xyz.didx.logging.LogWriter.* +import xyz.didx.messages.* +import xyz.didx.passkit.PasskitAgent +import xyz.didx.registry.* +import xyz.didx.signal.SignalBot import java.net.URI -import xyz.didx.signal.SignalBot -import cats.effect.kernel.Resource -import xyz.didx.connection.RedisStorage -import xyz.didx.messages.* -import cats.data.EitherT -import cats.effect.IO -import cats.implicits.* -import cats.syntax.traverse.* +import scala.collection.mutable import SignalMessageCodec.memberDecoder -import xyz.didx.registry.* import RegistryResponseCodec.encodeRegistryRequest -import xyz.didx.didcomm.Service -import xyz.didx.didcomm.ServiceEndpointNodes -import xyz.didx.registry.RegistryClient -import xyz.didx.openai.OpenAIAgent -import xyz.didx.passkit.PasskitAgent -import xyz.didx.ai.AiHandler -import xyz.didx.ai.model.ChatState -import cats.effect.Ref -import cats.effect.FiberIO class ConversationPollingHandler(using logger: Logger[IO]): val appConf = getConf(using logger) diff --git a/src/main/scala/xyz/didx/DawnPatrol.scala b/src/main/scala/xyz/didx/DawnPatrol.scala index 06cc888..af2fe1e 100644 --- a/src/main/scala/xyz/didx/DawnPatrol.scala +++ b/src/main/scala/xyz/didx/DawnPatrol.scala @@ -1,19 +1,17 @@ package xyz.didx -import cats.effect.* -import cats.effect.IOApp -import org.typelevel.log4cats.Logger -import org.typelevel.log4cats.slf4j.Slf4jLogger + import cats.effect.IO +import cats.effect.IOApp import cats.effect.std.Dispatcher import fs2.Stream - -import scala.concurrent.duration.* - -import xyz.didx.ConversationPollingHandler -import sttp.client3.asynchttpclient.cats.AsyncHttpClientCatsBackend +import org.typelevel.log4cats.Logger +import org.typelevel.log4cats.slf4j.Slf4jLogger import sttp.client3.SttpBackend -import xyz.didx.config.ConfigReaders.getConf +import sttp.client3.asynchttpclient.cats.AsyncHttpClientCatsBackend import xyz.didx.ai.handler.Opportunities +import xyz.didx.config.ConfigReaders.getConf + +import scala.concurrent.duration.* object DawnPatrol extends IOApp.Simple: // override protected def blockedThreadDetectionEnabled = true diff --git a/src/main/scala/xyz/didx/SignalBot.scala b/src/main/scala/xyz/didx/SignalBot.scala index 45199b6..5c066d0 100644 --- a/src/main/scala/xyz/didx/SignalBot.scala +++ b/src/main/scala/xyz/didx/SignalBot.scala @@ -1,27 +1,25 @@ package xyz.didx.signal import cats.data.EitherT +import cats.effect.FiberIO import cats.effect.IO +import cats.effect.Ref import cats.implicits.* +import fs2.Stream +import io.circe.syntax.* +import pureconfig.ConfigReader +import pureconfig.ConfigSource +import pureconfig.generic.derivation.default.* +import sttp.client3.* +import sttp.client3.circe.asJson +import sttp.model.StatusCode import xyz.didx.messages.SignalMessage import xyz.didx.messages.SignalMessageCodec.signalMessageDecoder import xyz.didx.messages.SignalMessageCodec.signalSendMessage import xyz.didx.messages.SignalSendMessage import xyz.didx.messages.SignalSimpleMessage -import fs2.Stream -//import io.circe.* -import io.circe.parser.* -import io.circe.syntax.* -import org.typelevel.log4cats.Logger -import org.typelevel.log4cats.slf4j.Slf4jLogger -import pureconfig.* -import pureconfig.generic.derivation.default.* -import sttp.client3.* -import sttp.client3.circe.* -import sttp.model.* + import scala.concurrent.duration._ -import cats.effect.Ref -import cats.effect.FiberIO case class SignalConfig( signalUrl: String, diff --git a/src/main/scala/xyz/didx/ai/AiHandler.scala b/src/main/scala/xyz/didx/ai/AiHandler.scala index 87499f1..c4002b0 100644 --- a/src/main/scala/xyz/didx/ai/AiHandler.scala +++ b/src/main/scala/xyz/didx/ai/AiHandler.scala @@ -1,15 +1,15 @@ package xyz.didx.ai -import scala.collection.mutable -import xyz.didx.ai.model.ChatState -import xyz.didx.ai.handler.OnboardingHandler -import xyz.didx.ai.handler.ConfirmOnboardingHandler +import cats.effect.IO import dev.langchain4j.data.segment.TextSegment -import xyz.didx.ai.embedding.EmbeddingHandler import dev.langchain4j.store.embedding.EmbeddingMatch +import xyz.didx.ai.embedding.EmbeddingHandler +import xyz.didx.ai.handler.ConfirmOnboardingHandler +import xyz.didx.ai.handler.OnboardingHandler +import xyz.didx.ai.model.ChatState import xyz.didx.ai.model.OnboardingResult -import xyz.didx.ai.model.ConfirmedOnboardingResult -import cats.effect.IO + +import scala.collection.mutable import scala.util.Try object AiHandler { diff --git a/src/main/scala/xyz/didx/ai/embedding/EmbeddingHandler.scala b/src/main/scala/xyz/didx/ai/embedding/EmbeddingHandler.scala index ce0c43b..7b7b7e8 100644 --- a/src/main/scala/xyz/didx/ai/embedding/EmbeddingHandler.scala +++ b/src/main/scala/xyz/didx/ai/embedding/EmbeddingHandler.scala @@ -1,18 +1,18 @@ package xyz.didx.ai.embedding -import scala.collection.JavaConverters._ +import dev.langchain4j.data.document.Metadata import dev.langchain4j.data.embedding.Embedding import dev.langchain4j.data.segment.TextSegment -import dev.langchain4j.store.embedding.{EmbeddingMatch, EmbeddingStore} -import dev.langchain4j.store.embedding.inmemory.InMemoryEmbeddingStore -import dev.langchain4j.model.huggingface.HuggingFaceEmbeddingModel; - import dev.langchain4j.model.embedding.EmbeddingModel -import dev.langchain4j.data.segment.TextSegment -import dev.langchain4j.data.document.Metadata +import dev.langchain4j.model.huggingface.HuggingFaceEmbeddingModel +import dev.langchain4j.model.output.Response +import dev.langchain4j.store.embedding.EmbeddingMatch +import dev.langchain4j.store.embedding.EmbeddingStore +import dev.langchain4j.store.embedding.inmemory.InMemoryEmbeddingStore import xyz.didx.ai.model.Opportunity + import java.time.Duration -import dev.langchain4j.model.output.Response +import scala.collection.JavaConverters._ object EmbeddingHandler { private val embeddingModel: EmbeddingModel = HuggingFaceEmbeddingModel diff --git a/src/main/scala/xyz/didx/ai/handler/ConfirmOnboardingResult.scala b/src/main/scala/xyz/didx/ai/handler/ConfirmOnboardingResult.scala index 6551b93..f96ea4d 100644 --- a/src/main/scala/xyz/didx/ai/handler/ConfirmOnboardingResult.scala +++ b/src/main/scala/xyz/didx/ai/handler/ConfirmOnboardingResult.scala @@ -1,13 +1,14 @@ package xyz.didx.ai.handler -import scala.collection.mutable -import com.xebia.functional.xef.prompt.PromptBuilder import com.xebia.functional.xef.prompt.Prompt +import com.xebia.functional.xef.prompt.PromptBuilder import com.xebia.functional.xef.scala.conversation.* import com.xebia.functional.xef.store.ConversationId +import xyz.didx.ai.model.AgentScript import xyz.didx.ai.model.ConfirmedOnboardingResult import xyz.didx.ai.model.OnboardingResult -import xyz.didx.ai.model.AgentScript + +import scala.collection.mutable object ConfirmOnboardingHandler { def getConfirmation( diff --git a/src/main/scala/xyz/didx/ai/handler/Onboarding.scala b/src/main/scala/xyz/didx/ai/handler/Onboarding.scala index 1cb6948..2710b79 100644 --- a/src/main/scala/xyz/didx/ai/handler/Onboarding.scala +++ b/src/main/scala/xyz/didx/ai/handler/Onboarding.scala @@ -1,12 +1,13 @@ package xyz.didx.ai.handler -import scala.collection.mutable -import com.xebia.functional.xef.prompt.PromptBuilder import com.xebia.functional.xef.prompt.Prompt +import com.xebia.functional.xef.prompt.PromptBuilder import com.xebia.functional.xef.scala.conversation.* import com.xebia.functional.xef.store.ConversationId -import xyz.didx.ai.model.OnboardingResult import xyz.didx.ai.model.AgentScript +import xyz.didx.ai.model.OnboardingResult + +import scala.collection.mutable import scala.util.Random object OnboardingHandler { diff --git a/src/main/scala/xyz/didx/ai/handler/Opportunities.scala b/src/main/scala/xyz/didx/ai/handler/Opportunities.scala index a4da0ab..fa80bc1 100644 --- a/src/main/scala/xyz/didx/ai/handler/Opportunities.scala +++ b/src/main/scala/xyz/didx/ai/handler/Opportunities.scala @@ -1,19 +1,22 @@ package xyz.didx.ai.handler -import java.util.Base64 -import java.io.{ByteArrayInputStream, ByteArrayOutputStream} -import java.util.zip.{GZIPInputStream, GZIPOutputStream} -import sttp.client4.* import cats.data.EitherT import cats.effect.IO +import io.circe +import io.circe.generic.auto._ +import io.circe.parser.decode +import sttp.client4.* import ujson.Value.Value +import xyz.didx.ai.embedding.EmbeddingHandler +import xyz.didx.ai.model.Opportunity + +import java.io.ByteArrayInputStream +import java.io.ByteArrayOutputStream +import java.util.Base64 +import java.util.zip.GZIPInputStream +import java.util.zip.GZIPOutputStream import scala.util.Try import scala.util.chaining.scalaUtilChainingOps -import io.circe.parser.decode -import io.circe.generic.auto._ -import xyz.didx.ai.model.Opportunity -import io.circe -import xyz.didx.ai.embedding.EmbeddingHandler object Opportunities { diff --git a/src/main/scala/xyz/didx/ai/model/Opportunity.scala b/src/main/scala/xyz/didx/ai/model/Opportunity.scala index 339b0b4..f2856fe 100644 --- a/src/main/scala/xyz/didx/ai/model/Opportunity.scala +++ b/src/main/scala/xyz/didx/ai/model/Opportunity.scala @@ -1,6 +1,9 @@ package xyz.didx.ai.model -import io.circe.{Decoder, DecodingFailure, HCursor} +import io.circe.Decoder +import io.circe.DecodingFailure +import io.circe.HCursor + import java.time.LocalDateTime import java.time.format.DateTimeFormatter import java.time.format.DateTimeParseException diff --git a/src/main/scala/xyz/didx/ai/openai/OpenAIAgent.scala b/src/main/scala/xyz/didx/ai/openai/OpenAIAgent.scala index 3c1ca82..df73dd4 100644 --- a/src/main/scala/xyz/didx/ai/openai/OpenAIAgent.scala +++ b/src/main/scala/xyz/didx/ai/openai/OpenAIAgent.scala @@ -5,7 +5,6 @@ import cats.effect.IO import cats.effect.Sync import cats.implicits._ import cats.implicits._ -import xyz.didx.messages.SignalSimpleMessage import io.circe.* import io.circe.syntax.* import org.typelevel.log4cats.Logger @@ -14,6 +13,7 @@ import pureconfig.* import pureconfig.generic.derivation.default.* import sttp.client3.* import sttp.client3.circe.* +import xyz.didx.messages.SignalSimpleMessage case class APIConf(apiKey: String, orgId: String) derives ConfigReader: override def toString: String = diff --git a/src/main/scala/xyz/didx/ai/openai/OpenAIMessage.scala b/src/main/scala/xyz/didx/ai/openai/OpenAIMessage.scala index 9f24ad8..3f920cd 100644 --- a/src/main/scala/xyz/didx/ai/openai/OpenAIMessage.scala +++ b/src/main/scala/xyz/didx/ai/openai/OpenAIMessage.scala @@ -1,24 +1,5 @@ package xyz.didx.openai -/* { - "id": "cmpl-6nognZq5jEzrrxtd7hkQ06vQcNOAu", - "object": "text_completion", - "created": 1677330941, - "model": "text-davinci-003", - "choices": [ - { - "text": "\nIt's important to remember to renew your drivers license before it expires. You can usually renew your license online or in person at your local DMV. Make sure to check the expiration date on your license and plan ahead so you don't miss the deadline.", - "index": 0, - "logprobs": null, - "finish_reason": "stop" - } - ], - "usage": { - "prompt_tokens": 9, - "completion_tokens": 51, - "total_tokens": 60 - } -} - */ + final case class OpenAIRequest( model: String = "text-davinci-003", prompt: String, diff --git a/src/main/scala/xyz/didx/ai/openai/OpenAIMessageCodec.scala b/src/main/scala/xyz/didx/ai/openai/OpenAIMessageCodec.scala index 0ee6046..761153a 100644 --- a/src/main/scala/xyz/didx/ai/openai/OpenAIMessageCodec.scala +++ b/src/main/scala/xyz/didx/ai/openai/OpenAIMessageCodec.scala @@ -3,8 +3,8 @@ package xyz.didx.openai import cats.* import cats.syntax.all.* import io.circe.Decoder.Result -import io.circe.syntax.* import io.circe.* +import io.circe.syntax.* object OpenAIMessageCodec { given openAIResponseDecoder: Decoder[OpenAIResponse] = diff --git a/src/main/scala/xyz/didx/config/ConfigReaders.scala b/src/main/scala/xyz/didx/config/ConfigReaders.scala index 815e6e1..d30e442 100644 --- a/src/main/scala/xyz/didx/config/ConfigReaders.scala +++ b/src/main/scala/xyz/didx/config/ConfigReaders.scala @@ -1,16 +1,19 @@ package xyz.didx.config -import java.net.URL -import java.net.URI -import pureconfig.ConfigReader -import pureconfig.ConfigSource -import pureconfig.generic.derivation.default.* import cats.data.EitherT import cats.effect.IO import org.typelevel.log4cats.Logger import org.typelevel.log4cats.slf4j.Slf4jLogger +import pureconfig.ConfigReader +import pureconfig.ConfigSource +import pureconfig.generic.derivation.default.* import sttp.client3.ResponseException -import xyz.didx.logging.LogWriter.{err, info, logNonEmptyList} +import xyz.didx.logging.LogWriter.err +import xyz.didx.logging.LogWriter.info +import xyz.didx.logging.LogWriter.logNonEmptyList + +import java.net.URI +import java.net.URL object ConfigReaders: diff --git a/src/main/scala/xyz/didx/connection/RedisStorage.scala b/src/main/scala/xyz/didx/connection/RedisStorage.scala index 7f26ed8..414cce3 100644 --- a/src/main/scala/xyz/didx/connection/RedisStorage.scala +++ b/src/main/scala/xyz/didx/connection/RedisStorage.scala @@ -1,16 +1,13 @@ package xyz.didx.connection -import dev.profunktor.redis4cats.Redis -import cats.effect.kernel.Resource import cats.effect.IO -import dev.profunktor.redis4cats.RedisCommands -import io.circe.syntax.* import cats.effect._ +import cats.effect.kernel.Resource import cats.implicits._ import dev.profunktor.redis4cats.Redis import dev.profunktor.redis4cats.RedisCommands - import dev.profunktor.redis4cats.effect.Log.Stdout._ +import io.circe.syntax.* import xyz.didx.didcomm.DIDTypes.* import scala.concurrent.duration.FiniteDuration diff --git a/src/main/scala/xyz/didx/didcomm/DIDCodec.scala b/src/main/scala/xyz/didx/didcomm/DIDCodec.scala index a86262a..fe6d196 100644 --- a/src/main/scala/xyz/didx/didcomm/DIDCodec.scala +++ b/src/main/scala/xyz/didx/didcomm/DIDCodec.scala @@ -1,23 +1,19 @@ package xyz.didx.didcomm + import cats.* import cats.syntax.all.* import io.circe.Decoder.Result import io.circe.* +import xyz.didx.didcomm.DIDDoc +import xyz.didx.didcomm.Service +import xyz.didx.didcomm.ServiceEndpoint +import xyz.didx.didcomm.ServiceEndpointDIDCommService +import xyz.didx.didcomm.ServiceEndpointDIDURL +import xyz.didx.didcomm.ServiceEndpointNodes +import xyz.didx.didcomm.ServiceEndpointURI +import xyz.didx.didcomm.VerificationMethod import java.net.URI -import xyz.didx.didcomm.{ - ServiceEndpointURI, - ServiceEndpointDIDURL, - Service, - ServiceEndpoint, - ServiceEndpointDIDCommService, - ServiceEndpointNodes, - VerificationMethod, - DIDDoc -} -//import xyz.didx.didcomm.VerificationMethodType - -//import summon.{Decoder => _, _} object DIDCodec: given encodeDIDDoc: Encoder[DIDDoc] = diff --git a/src/main/scala/xyz/didx/didcomm/DIDDoc.scala b/src/main/scala/xyz/didx/didcomm/DIDDoc.scala index 8605120..ebfe4ff 100644 --- a/src/main/scala/xyz/didx/didcomm/DIDDoc.scala +++ b/src/main/scala/xyz/didx/didcomm/DIDDoc.scala @@ -5,12 +5,10 @@ package xyz.didx.didcomm import io.circe.* import io.circe.syntax._ - -//import foundation.identity.did.VerificationRelationships -import java.net.URI -//import xyz.didx.didcomm.VerificationMethodType import xyz.didx.didcomm.DIDCodec import xyz.didx.didcomm.VerificationMethodType + +import java.net.URI import scala.util.matching.Regex //import foundation.identity.did.VerificationMethod diff --git a/src/main/scala/xyz/didx/messages/SignalMessageCodec.scala b/src/main/scala/xyz/didx/messages/SignalMessageCodec.scala index 21afb0c..79aa360 100644 --- a/src/main/scala/xyz/didx/messages/SignalMessageCodec.scala +++ b/src/main/scala/xyz/didx/messages/SignalMessageCodec.scala @@ -2,15 +2,15 @@ package xyz.didx.messages import cats.Applicative.ops.toAllApplicativeOps import cats.* -import xyz.didx.messages.Member -import xyz.didx.messages.SignalMessage -import xyz.didx.messages.SignalSendMessage import io.circe.Decoder import io.circe.Decoder.Result import io.circe.Encoder import io.circe.Json import io.circe.* import io.circe.syntax._ +import xyz.didx.messages.Member +import xyz.didx.messages.SignalMessage +import xyz.didx.messages.SignalSendMessage object SignalMessageCodec: given memberDecoder: Decoder[Member] = new Decoder[Member]: diff --git a/src/main/scala/xyz/didx/passkit/PasskitAgent.scala b/src/main/scala/xyz/didx/passkit/PasskitAgent.scala index 57f55ad..ba6865d 100644 --- a/src/main/scala/xyz/didx/passkit/PasskitAgent.scala +++ b/src/main/scala/xyz/didx/passkit/PasskitAgent.scala @@ -1,12 +1,20 @@ package xyz.didx.passkit import cats.data.EitherT -import cats.effect.{IO, Resource} -import de.brendamour.jpasskit.{PKBarcode, PKField, PKPass} -import de.brendamour.jpasskit.enums.{PKBarcodeFormat, PKPassType} +import cats.effect.IO +import cats.effect.Resource +import de.brendamour.jpasskit.PKBarcode +import de.brendamour.jpasskit.PKField +import de.brendamour.jpasskit.PKPass +import de.brendamour.jpasskit.enums.PKBarcodeFormat +import de.brendamour.jpasskit.enums.PKPassType import de.brendamour.jpasskit.passes.PKGenericPass -import de.brendamour.jpasskit.signing.{PKFileBasedSigningUtil, PKPassTemplateFolder, PKSigningInformationUtil} -import pureconfig.{ConfigReader, ConfigSource} +import de.brendamour.jpasskit.signing.PKFileBasedSigningUtil +import de.brendamour.jpasskit.signing.PKPassTemplateFolder +import de.brendamour.jpasskit.signing.PKSigningInformationUtil +import org.typelevel.log4cats.Logger +import pureconfig.ConfigReader +import pureconfig.ConfigSource import pureconfig.generic.derivation.default.* import java.awt.Color @@ -14,7 +22,6 @@ import java.io.* import java.net.URL import java.nio.charset.Charset import scala.jdk.CollectionConverters.* -import org.typelevel.log4cats.Logger import scala.util.Try case class PasskitConfig( diff --git a/src/main/scala/xyz/didx/registry/RegistryClient.scala b/src/main/scala/xyz/didx/registry/RegistryClient.scala index 4ad4829..5ff392d 100644 --- a/src/main/scala/xyz/didx/registry/RegistryClient.scala +++ b/src/main/scala/xyz/didx/registry/RegistryClient.scala @@ -3,16 +3,16 @@ package xyz.didx.registry import cats.data.EitherT import cats.effect.IO import cats.implicits.* -import xyz.didx.registry.RegistryResponse -import xyz.didx.registry.RegistryResponseCodec.registryResponseDecoder import io.circe.* import io.circe.parser.* import io.circe.syntax.* +import org.typelevel.log4cats.Logger +import org.typelevel.log4cats.slf4j.Slf4jLogger import sttp.client3.* import sttp.client3.circe.* import sttp.model.* -import org.typelevel.log4cats.Logger -import org.typelevel.log4cats.slf4j.Slf4jLogger +import xyz.didx.registry.RegistryResponse +import xyz.didx.registry.RegistryResponseCodec.registryResponseDecoder final case class RegistryClient(registryUrl: String, apiKey: String): given logger: Logger[IO] = Slf4jLogger.getLogger[IO] diff --git a/src/main/scala/xyz/didx/registry/RegistryResponse.scala b/src/main/scala/xyz/didx/registry/RegistryResponse.scala index a7eef73..a3e9080 100644 --- a/src/main/scala/xyz/didx/registry/RegistryResponse.scala +++ b/src/main/scala/xyz/didx/registry/RegistryResponse.scala @@ -3,10 +3,10 @@ package xyz.didx.registry import cats.* import cats.data.OptionT import cats.syntax.all.* -import xyz.didx.didcomm.DIDDoc import io.circe.Decoder.Result -import io.circe.syntax.* import io.circe.* +import io.circe.syntax.* +import xyz.didx.didcomm.DIDDoc /* { diff --git a/src/main/scala/xyz/didx/registry/RegistryResponseCodec.scala b/src/main/scala/xyz/didx/registry/RegistryResponseCodec.scala index 0efee05..d107ee7 100644 --- a/src/main/scala/xyz/didx/registry/RegistryResponseCodec.scala +++ b/src/main/scala/xyz/didx/registry/RegistryResponseCodec.scala @@ -1,13 +1,15 @@ package xyz.didx.registry +import cats.* +import cats.syntax.all.* +import io.circe.Decoder +import io.circe.Encoder +import io.circe.Json import io.circe.* -import io.circe.{Decoder, Json, Encoder} import io.circe.syntax.* -import cats.syntax.all.* -import cats.* import io.circe.syntax._ -import xyz.didx.didcomm.DIDCodec.encodeDIDDoc import xyz.didx.didcomm.DIDCodec +import xyz.didx.didcomm.DIDCodec.encodeDIDDoc object RegistryResponseCodec: import io.circe.generic.auto.* diff --git a/src/test/DawnSpec.test.scala b/src/test/scala/xyz/didx/DawnSpec.test.scala similarity index 100% rename from src/test/DawnSpec.test.scala rename to src/test/scala/xyz/didx/DawnSpec.test.scala index 10ce984..9fcb1ea 100644 --- a/src/test/DawnSpec.test.scala +++ b/src/test/scala/xyz/didx/DawnSpec.test.scala @@ -1,4 +1,5 @@ package xyz.didx + import munit.CatsEffectSuite class DawnSpec extends CatsEffectSuite { @@ -7,5 +8,4 @@ class DawnSpec extends CatsEffectSuite { println(x) assertEquals(1, 1) } - }