Remove AquaPath usage

This commit is contained in:
InversionSpaces 2023-12-05 15:49:24 +00:00
parent 4cecab1a26
commit 667f2585a4
3 changed files with 52 additions and 63 deletions

View File

@ -1,56 +1,54 @@
package api package api
import api.types.{AquaConfig, AquaFunction, CompilationResult, GeneratedSource, Input}
import aqua.Rendering.given import aqua.Rendering.given
import aqua.raw.value.ValueRaw
import aqua.api.{APICompilation, APIResult, AquaAPIConfig}
import aqua.api.TargetType.* import aqua.api.TargetType.*
import aqua.api.{APICompilation, APIResult, AquaAPIConfig}
import aqua.backend.air.AirBackend import aqua.backend.air.AirBackend
import aqua.backend.api.APIBackend
import aqua.backend.js.JavaScriptBackend
import aqua.backend.ts.TypeScriptBackend
import aqua.backend.{AirFunction, Backend, Generated} import aqua.backend.{AirFunction, Backend, Generated}
import aqua.compiler.* import aqua.compiler.*
import aqua.files.{AquaFileSources, AquaFilesIO, FileModuleId}
import aqua.logging.{LogFormatter, LogLevels}
import aqua.constants.Constants import aqua.constants.Constants
import aqua.definitions.FunctionDef
import aqua.files.{AquaFileSources, AquaFilesIO, FileModuleId}
import aqua.io.* import aqua.io.*
import aqua.raw.ops.Call import aqua.js.{FunctionDefJs, ServiceDefJs, VarJson}
import aqua.run.{CliFunc, FuncCompiler} import aqua.logging.{LogFormatter, LogLevels}
import aqua.model.AquaContext
import aqua.model.transform.{Transform, TransformConfig}
import aqua.parser.lexer.{LiteralToken, Token} import aqua.parser.lexer.{LiteralToken, Token}
import aqua.parser.lift.FileSpan.F import aqua.parser.lift.FileSpan.F
import aqua.parser.lift.{FileSpan, Span} import aqua.parser.lift.{FileSpan, Span}
import aqua.parser.{ArrowReturnError, BlockIndentError, LexerError, ParserError} import aqua.parser.{ArrowReturnError, BlockIndentError, LexerError, ParserError}
import aqua.{AquaIO, SpanParser} import aqua.raw.ops.Call
import aqua.model.transform.{Transform, TransformConfig}
import aqua.backend.api.APIBackend
import aqua.backend.js.JavaScriptBackend
import aqua.backend.ts.TypeScriptBackend
import aqua.definitions.FunctionDef
import aqua.js.{FunctionDefJs, ServiceDefJs, VarJson}
import aqua.model.AquaContext
import aqua.raw.ops.CallArrowRawTag import aqua.raw.ops.CallArrowRawTag
import aqua.raw.value.ValueRaw
import aqua.raw.value.{LiteralRaw, VarRaw} import aqua.raw.value.{LiteralRaw, VarRaw}
import aqua.res.AquaRes import aqua.res.AquaRes
import aqua.{AquaIO, SpanParser}
import api.types.{AquaConfig, AquaFunction, CompilationResult, GeneratedSource, Input}
import cats.Applicative import cats.Applicative
import cats.data.Validated.{Invalid, Valid, invalidNec, validNec}
import cats.data.{Chain, NonEmptyChain, Validated, ValidatedNec} import cats.data.{Chain, NonEmptyChain, Validated, ValidatedNec}
import cats.data.Validated.{invalidNec, validNec, Invalid, Valid}
import cats.syntax.applicative.*
import cats.syntax.apply.*
import cats.syntax.flatMap.*
import cats.syntax.functor.*
import cats.effect.IO import cats.effect.IO
import cats.effect.unsafe.implicits.global import cats.effect.unsafe.implicits.global
import cats.syntax.applicative.*
import cats.syntax.apply.*
import cats.syntax.either.*
import cats.syntax.flatMap.*
import cats.syntax.functor.*
import cats.syntax.show.* import cats.syntax.show.*
import cats.syntax.traverse.* import cats.syntax.traverse.*
import cats.syntax.either.*
import fs2.io.file.{Files, Path} import fs2.io.file.{Files, Path}
import scribe.Logging
import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future import scala.concurrent.Future
import scala.scalajs.js.{|, undefined, Promise, UndefOr}
import scala.scalajs.js import scala.scalajs.js
import scala.scalajs.js.JSConverters.* import scala.scalajs.js.JSConverters.*
import scala.scalajs.js.annotation.* import scala.scalajs.js.annotation.*
import scala.scalajs.js.{Promise, UndefOr, undefined, |}
import scribe.Logging
@JSExportTopLevel("Aqua") @JSExportTopLevel("Aqua")
object AquaAPI extends App with Logging { object AquaAPI extends App with Logging {

View File

@ -1,50 +1,42 @@
package aqua.api package aqua.api
import aqua.Rendering.given import aqua.Rendering.given
import aqua.raw.value.ValueRaw
import aqua.raw.ConstantRaw
import aqua.api.AquaAPIConfig import aqua.api.AquaAPIConfig
import aqua.backend.api.APIBackend
import aqua.backend.{AirFunction, Backend, Generated} import aqua.backend.{AirFunction, Backend, Generated}
import aqua.compiler.* import aqua.compiler.*
import aqua.files.{AquaFileSources, AquaFilesIO, FileModuleId}
import aqua.logging.{LogFormatter, LogLevels}
import aqua.constants.Constants import aqua.constants.Constants
import aqua.definitions.FunctionDef
import aqua.files.{AquaFileSources, AquaFilesIO, FileModuleId}
import aqua.io.* import aqua.io.*
import aqua.raw.ops.Call import aqua.logging.{LogFormatter, LogLevels}
import aqua.run.{CliFunc, FuncCompiler, RunPreparer} import aqua.model.AquaContext
import aqua.model.transform.{Transform, TransformConfig}
import aqua.parser.lexer.{LiteralToken, Token} import aqua.parser.lexer.{LiteralToken, Token}
import aqua.parser.lift.FileSpan.F import aqua.parser.lift.FileSpan.F
import aqua.parser.lift.{FileSpan, Span} import aqua.parser.lift.{FileSpan, Span}
import aqua.parser.{ArrowReturnError, BlockIndentError, LexerError, ParserError} import aqua.parser.{ArrowReturnError, BlockIndentError, LexerError, ParserError}
import aqua.{AquaIO, SpanParser} import aqua.raw.ConstantRaw
import aqua.model.transform.{Transform, TransformConfig} import aqua.raw.ops.Call
import aqua.backend.api.APIBackend import aqua.raw.value.ValueRaw
import aqua.definitions.FunctionDef
import aqua.model.AquaContext
import aqua.res.AquaRes import aqua.res.AquaRes
import aqua.run.{CliFunc, FuncCompiler, RunPreparer}
import aqua.{AquaIO, SpanParser}
import cats.Applicative import cats.Applicative
import cats.~> import cats.data.*
import cats.data.{ import cats.data.Validated.*
Chain,
EitherT,
NonEmptyChain,
NonEmptyList,
Validated,
ValidatedNec,
ValidatedNel,
Writer
}
import cats.data.Validated.{invalid, invalidNec, validNec, Invalid, Valid}
import cats.syntax.applicative.*
import cats.syntax.apply.*
import cats.syntax.flatMap.*
import cats.syntax.functor.*
import cats.effect.IO import cats.effect.IO
import cats.effect.unsafe.implicits.global import cats.effect.unsafe.implicits.global
import cats.syntax.applicative.*
import cats.syntax.apply.*
import cats.syntax.either.*
import cats.syntax.flatMap.*
import cats.syntax.functor.*
import cats.syntax.option.*
import cats.syntax.show.* import cats.syntax.show.*
import cats.syntax.traverse.* import cats.syntax.traverse.*
import cats.syntax.either.* import cats.~>
import fs2.io.file.{Files, Path} import fs2.io.file.{Files, Path}
import scribe.{Level, Logging} import scribe.{Level, Logging}
@ -68,7 +60,7 @@ object APICompilation {
LogFormatter.initLogger(Some(level)) LogFormatter.initLogger(Some(level))
new FuncCompiler[IO]( new FuncCompiler[IO](
Some(RelativePath(Path(pathStr))), Path(pathStr).some,
imports.map(Path.apply), imports.map(Path.apply),
transformConfig transformConfig
).compile().map { contextV => ).compile().map { contextV =>

View File

@ -3,34 +3,33 @@ package aqua.run
import aqua.Rendering.given import aqua.Rendering.given
import aqua.compiler.{AquaCompiler, AquaCompilerConf, CompileResult, CompilerAPI} import aqua.compiler.{AquaCompiler, AquaCompilerConf, CompileResult, CompilerAPI}
import aqua.files.{AquaFileSources, FileModuleId} import aqua.files.{AquaFileSources, FileModuleId}
import aqua.{AquaIO, SpanParser} import aqua.io.{AquaFileError, PackagePath, Prelude}
import aqua.io.{AquaFileError, AquaPath, PackagePath, Prelude}
import aqua.model.transform.TransformConfig import aqua.model.transform.TransformConfig
import aqua.model.{AquaContext, FuncArrow} import aqua.model.{AquaContext, FuncArrow}
import aqua.parser.lift.FileSpan import aqua.parser.lift.FileSpan
import aqua.run.CliFunc import aqua.run.CliFunc
import aqua.{AquaIO, SpanParser}
import cats.data.Validated.{invalidNec, validNec} import cats.data.Validated.{invalidNec, validNec}
import cats.data.{Chain, NonEmptyList, Validated, ValidatedNec} import cats.data.{Chain, NonEmptyList, Validated, ValidatedNec}
import cats.effect.IO import cats.effect.IO
import cats.effect.kernel.{Async, Clock} import cats.effect.kernel.{Async, Clock}
import cats.syntax.applicative.* import cats.syntax.applicative.*
import cats.syntax.apply.*
import cats.syntax.either.*
import cats.syntax.flatMap.* import cats.syntax.flatMap.*
import cats.syntax.functor.* import cats.syntax.functor.*
import cats.syntax.monad.* import cats.syntax.monad.*
import cats.syntax.option.*
import cats.syntax.show.* import cats.syntax.show.*
import cats.syntax.traverse.* import cats.syntax.traverse.*
import cats.syntax.option.*
import cats.syntax.either.*
import cats.syntax.validated.* import cats.syntax.validated.*
import cats.syntax.apply.*
import fs2.io.file.{Files, Path} import fs2.io.file.{Files, Path}
import scala.concurrent.duration.Duration
import scribe.Logging import scribe.Logging
import scala.concurrent.duration.Duration
class FuncCompiler[F[_]: Files: AquaIO: Async]( class FuncCompiler[F[_]: Files: AquaIO: Async](
input: Option[AquaPath], input: Option[Path],
imports: List[Path], imports: List[Path],
transformConfig: TransformConfig transformConfig: TransformConfig
) extends Logging { ) extends Logging {
@ -66,10 +65,10 @@ class FuncCompiler[F[_]: Files: AquaIO: Async](
builtinsV <- builtinsV <-
if (withBuiltins) compileBuiltins() if (withBuiltins) compileBuiltins()
else Chain.empty.pure[Result].pure[F] else Chain.empty.pure[Result].pure[F]
compileResult <- input.traverse { ap => compileResult <- input.traverse { ip =>
// compile only context to wrap and call function later // compile only context to wrap and call function later
Clock[F].timed( Clock[F].timed(
ap.getPath().flatMap(p => compileToContext(p, preludeImports ++ imports)) compileToContext(ip, preludeImports ++ imports)
) )
} }
(compileTime, contextV) = compileResult.orEmpty (compileTime, contextV) = compileResult.orEmpty