Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into 4469-migrate-json…
Browse files Browse the repository at this point in the history
…ld-serialization
  • Loading branch information
Simon Dumas committed Nov 9, 2023
2 parents 6c4ec0c + 4a8dd54 commit bb09923
Show file tree
Hide file tree
Showing 112 changed files with 568 additions and 997 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class PostgresServiceDependency(xas: Transactors) extends ServiceDependency {
sql"select version()"
.query[String]
.to[List]
.transact(xas.readCE)
.transact(xas.read)
.map {
case versionString :: _ =>
versionString match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ final class ProjectsRoutes(
// Project statistics
(pathPrefix("statistics") & get & pathEndOrSingleSlash) {
authorizeFor(ref, resources.read).apply {
val stats = projectsStatistics.get(ref).toCatsIO
val stats = projectsStatistics.get(ref)
emit(
OptionT(stats).toRight[ProjectRejection](ProjectNotFound(ref)).value
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import cats.data.NonEmptyList
import cats.effect.{Clock, ContextShift, IO, Resource, Sync, Timer}
import ch.epfl.bluebrain.nexus.delta.Main.pluginsMaxPriority
import ch.epfl.bluebrain.nexus.delta.config.AppConfig
import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration._
import ch.epfl.bluebrain.nexus.delta.kernel.utils.UUIDF
import ch.epfl.bluebrain.nexus.delta.rdf.Vocabulary.contexts
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.api.{JsonLdApi, JsonLdJavaApi}
Expand Down Expand Up @@ -65,8 +64,8 @@ class DeltaModule(appCfg: AppConfig, config: Config)(implicit classLoader: Class

implicit val scheduler: Scheduler = Scheduler.global

make[Transactors].fromResource {
Transactors.init(appCfg.database).mapK(taskToIoK)
make[Transactors].fromResource { (cs: ContextShift[IO]) =>
Transactors.init(appCfg.database)(classLoader, cs)
}

make[List[PluginDescription]].from { (pluginsDef: List[PluginDef]) => pluginsDef.map(_.info) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import cats.effect.{Clock, ContextShift, IO, Timer}
import cats.implicits._
import ch.epfl.bluebrain.nexus.delta.Main.pluginsMaxPriority
import ch.epfl.bluebrain.nexus.delta.config.AppConfig
import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration._
import ch.epfl.bluebrain.nexus.delta.kernel.utils.UUIDF
import ch.epfl.bluebrain.nexus.delta.rdf.Vocabulary.contexts
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.{ContextValue, RemoteContextResolution}
Expand Down Expand Up @@ -77,7 +76,7 @@ object ProjectsModule extends ModuleDef {
}

make[ProjectsStatistics].fromEffect { (xas: Transactors) =>
toCatsIO(ProjectsStatistics(xas))
ProjectsStatistics(xas)
}

make[ProjectProvisioning].from {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import ch.epfl.bluebrain.nexus.delta.sdk.plugin.PluginDef
import ch.epfl.bluebrain.nexus.delta.sourcing.postgres.Doobie._
import ch.epfl.bluebrain.nexus.delta.wiring.DeltaModule
import ch.epfl.bluebrain.nexus.testkit.elasticsearch.ElasticSearchContainer
import ch.epfl.bluebrain.nexus.testkit.mu.bio.ResourceFixture
import ch.epfl.bluebrain.nexus.testkit.mu.ce.ResourceFixture
import ch.epfl.bluebrain.nexus.testkit.mu.ce.CatsEffectSuite
import ch.epfl.bluebrain.nexus.testkit.mu.ce.ResourceFixture.IOFixture
import ch.epfl.bluebrain.nexus.testkit.postgres.PostgresContainer
import com.typesafe.config.impl.ConfigImpl
import izumi.distage.model.definition.{Module, ModuleDef}
import izumi.distage.model.plan.Roots
import izumi.distage.planning.solver.PlanVerifier
import monix.bio.Task
import munit.AnyFixture

import java.nio.file.{Files, Paths}
Expand Down Expand Up @@ -73,7 +73,7 @@ object MainSuite {
trait Fixture { self: CatsEffectSuite =>

// Overload config via system properties
private def acquire(postgres: PostgresContainer, elastic: ElasticSearchContainer) = Task.delay {
private def acquire(postgres: PostgresContainer, elastic: ElasticSearchContainer): IO[Unit] = IO.delay {
val resourceTypesFile = Files.createTempFile("resource-types", ".json")
Files.writeString(resourceTypesFile, """["https://neuroshapes.org/Entity"]""")
val mappingFile = Files.createTempFile("mapping", ".json")
Expand Down Expand Up @@ -105,7 +105,7 @@ object MainSuite {
}

// Resetting system properties
private def release = Task.delay {
private def release = IO.delay {
System.clearProperty("app.defaults.database.access.host")
System.clearProperty("app.defaults.database.access.port")
System.clearProperty("app.defaults.database.access.username")
Expand All @@ -131,7 +131,7 @@ object MainSuite {
_ <- Resource.make(acquire(postgres, elastic))(_ => release)
} yield ()

val main: ResourceFixture.TaskFixture[Unit] = ResourceFixture.suiteLocal("main", resource())
val main: IOFixture[Unit] = ResourceFixture.suiteLocal("main", resource())

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import akka.http.scaladsl.server.Route
import cats.effect.IO
import ch.epfl.bluebrain.nexus.delta.kernel.utils.{UUIDF, UrlUtils}
import ch.epfl.bluebrain.nexus.delta.sdk.acls.AclSimpleCheck
import ch.epfl.bluebrain.nexus.delta.sdk.acls.model.{AclAddress, AclRejection}
import ch.epfl.bluebrain.nexus.delta.sdk.acls.model.AclAddress
import ch.epfl.bluebrain.nexus.delta.sdk.directives.DeltaSchemeDirectives
import ch.epfl.bluebrain.nexus.delta.sdk.generators.ProjectGen.defaultApiMappings
import ch.epfl.bluebrain.nexus.delta.sdk.identities.IdentitiesDummy
Expand All @@ -26,8 +26,6 @@ import ch.epfl.bluebrain.nexus.delta.sourcing.model.Identity.{Anonymous, Authent
import ch.epfl.bluebrain.nexus.delta.sourcing.model.{Label, ProjectRef}
import ch.epfl.bluebrain.nexus.testkit.ce.IOFromMap
import io.circe.Json
import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration._
import monix.bio.UIO

import java.time.Instant
import java.util.UUID
Expand Down Expand Up @@ -93,13 +91,13 @@ class ProjectsRoutesSpec extends BaseRouteSpec with IOFromMap {
private val projectStats = ProjectStatistics(10, 10, Instant.EPOCH)

private val projectsStatistics: ProjectsStatistics = {
case `ref` => UIO.some(projectStats)
case _ => UIO.none
case `ref` => IO.pure(Some(projectStats))
case _ => IO.none
}

private lazy val projects = ProjectsImpl(fetchOrg, _ => UIO.unit, Set.empty, defaultApiMappings, projectsConfig, xas)
private lazy val projects = ProjectsImpl(fetchOrg, _ => IO.unit, Set.empty, defaultApiMappings, projectsConfig, xas)
private lazy val provisioning =
ProjectProvisioning(aclCheck.append(_).toBIO[AclRejection], projects, provisioningConfig)
ProjectProvisioning(aclCheck.append, projects, provisioningConfig)
private lazy val routes = Route.seal(
ProjectsRoutes(
identities,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ch.epfl.bluebrain.nexus.delta.routes
import akka.http.scaladsl.model.StatusCodes
import akka.http.scaladsl.model.headers.OAuth2BearerToken
import akka.http.scaladsl.server.Route
import cats.effect.IO
import ch.epfl.bluebrain.nexus.delta.rdf.Vocabulary.contexts
import ch.epfl.bluebrain.nexus.delta.sdk.acls.AclSimpleCheck
import ch.epfl.bluebrain.nexus.delta.sdk.acls.model.AclAddress
Expand All @@ -15,7 +16,6 @@ import ch.epfl.bluebrain.nexus.delta.sdk.quotas.{QuotasConfig, QuotasImpl}
import ch.epfl.bluebrain.nexus.delta.sdk.utils.BaseRouteSpec
import ch.epfl.bluebrain.nexus.delta.sourcing.model.Identity.{Anonymous, Authenticated, Group, User}
import ch.epfl.bluebrain.nexus.delta.sourcing.model.{Label, ProjectRef}
import monix.bio.UIO

class QuotasRoutesSpec extends BaseRouteSpec {

Expand All @@ -35,7 +35,7 @@ class QuotasRoutesSpec extends BaseRouteSpec {
ServiceAccount(User("internal", Label.unsafe("sa")))
)

private val projectsStatistics: ProjectsStatistics = (_ => UIO.none)
private val projectsStatistics: ProjectsStatistics = (_ => IO.none)

private val quotas = new QuotasImpl(projectsStatistics)

Expand Down
Loading

0 comments on commit bb09923

Please sign in to comment.