├── .devcontainer
└── devcontainer.json
├── .github
├── actionlint.yaml
├── e2e
│ └── docker-compose.yml
├── pull_request_template.md
├── release-please
│ ├── config.json
│ └── manifest.json
├── renovate.json
└── workflows
│ ├── e2e.yml
│ ├── lint.yml
│ ├── publish.yml
│ ├── release.yml
│ ├── run-tests.yml
│ ├── sbt-tests.yml
│ ├── snapshot.yml
│ └── tests.yml
├── .gitignore
├── .jvmopts
├── .scalafmt.conf
├── .vscode
└── settings.json
├── CHANGELOG.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── USAGE.md
├── api
├── api-example
│ ├── index.js
│ ├── package.json
│ ├── readme.md
│ └── test.aqua
├── api-npm
│ ├── README.md
│ ├── index.d.ts
│ ├── index.js
│ ├── meta-utils.js
│ └── package.json
└── api
│ ├── .js
│ └── src
│ │ └── main
│ │ └── scala
│ │ └── api
│ │ ├── AquaAPI.scala
│ │ └── types
│ │ ├── InputTypes.scala
│ │ └── OutputTypes.scala
│ ├── .jvm
│ └── src
│ │ └── main
│ │ └── scala
│ │ └── aqua
│ │ └── api
│ │ └── Test.scala
│ └── src
│ └── main
│ └── scala
│ └── aqua
│ └── api
│ ├── APICompilation.scala
│ ├── AquaAPIConfig.scala
│ ├── Imports.scala
│ └── package.scala
├── aqua-run
└── src
│ └── main
│ └── scala
│ └── aqua
│ └── run
│ ├── CallInfo.scala
│ ├── CallPreparer.scala
│ ├── CliFunc.scala
│ ├── FuncCompiler.scala
│ ├── RunConfig.scala
│ ├── RunPreparer.scala
│ └── TypeValidator.scala
├── aqua-src
├── antithesis.aqua
├── builtin.aqua
├── call_arrow.aqua
├── closure.aqua
├── declare.aqua
├── export.aqua
├── exports.aqua
├── foldJoin.aqua
├── gen
│ └── OneMore.aqua
├── hack.aqua
├── import-empty.aqua
├── import.aqua
├── imports.aqua
├── join.aqua
├── nopingback.aqua
├── on.aqua
├── parfold.aqua
├── restrict.aqua
├── ret.aqua
├── so.aqua
├── streamCallback.aqua
├── test.aqua
├── test
│ ├── export2.aqua
│ ├── export_service.aqua
│ ├── rename.aqua
│ ├── service_call.aqua
│ └── wrong-par.aqua
├── via.aqua
└── xor.aqua
├── backend
├── .js
│ └── src
│ │ └── main
│ │ └── scala
│ │ └── aqua
│ │ └── backend
│ │ └── Version.scala
├── .jvm
│ └── src
│ │ └── main
│ │ └── scala
│ │ └── aqua
│ │ └── backend
│ │ └── Version.scala
├── air
│ └── src
│ │ └── main
│ │ └── scala
│ │ └── aqua
│ │ └── backend
│ │ └── air
│ │ ├── Air.scala
│ │ ├── AirBackend.scala
│ │ ├── AirGen.scala
│ │ └── FuncAirGen.scala
├── api
│ └── src
│ │ └── main
│ │ └── scala
│ │ └── aqua
│ │ └── backend
│ │ └── api
│ │ └── APIBackend.scala
├── definitions
│ └── src
│ │ └── main
│ │ └── scala
│ │ └── aqua
│ │ └── definitions
│ │ └── Definitions.scala
├── src
│ └── main
│ │ └── scala
│ │ └── aqua
│ │ └── backend
│ │ ├── AirFunction.scala
│ │ ├── Backend.scala
│ │ └── Generated.scala
└── ts
│ └── src
│ └── main
│ └── scala
│ └── aqua
│ └── backend
│ ├── Header.scala
│ ├── OutputFile.scala
│ ├── OutputFunc.scala
│ ├── OutputService.scala
│ ├── Types.scala
│ ├── js
│ └── JavaScriptBackend.scala
│ └── ts
│ ├── TSFuncTypes.scala
│ ├── TSServiceTypes.scala
│ ├── TypeScriptBackend.scala
│ ├── TypeScriptCommon.scala
│ └── TypeScriptTypes.scala
├── build.sbt
├── ci.cjs
├── compiler
└── src
│ ├── main
│ └── scala
│ │ └── aqua
│ │ └── compiler
│ │ ├── AirValidator.scala
│ │ ├── AquaCompiled.scala
│ │ ├── AquaCompiler.scala
│ │ ├── AquaCompilerConf.scala
│ │ ├── AquaError.scala
│ │ ├── AquaParser.scala
│ │ ├── AquaProcessed.scala
│ │ ├── AquaSources.scala
│ │ ├── AquaWarning.scala
│ │ ├── CompilerAPI.scala
│ │ └── package.scala
│ └── test
│ └── scala
│ └── aqua
│ └── compiler
│ ├── AquaCompilerSpec.scala
│ ├── AquaModulesSpec.scala
│ ├── CompilerSpec.scala
│ └── FileIdString.scala
├── integration-tests
├── .gitignore
├── .npmignore
├── .prettierrc.cjs
├── LICENSE
├── README.md
├── aqua
│ └── examples
│ │ ├── abilities.aqua
│ │ ├── abilitiesClosure.aqua
│ │ ├── abilitiesClosureRename.aqua
│ │ ├── assignment.aqua
│ │ ├── boolAlgebra.aqua
│ │ ├── callArrow.aqua
│ │ ├── canon.aqua
│ │ ├── closureArrowCapture.aqua
│ │ ├── closureReturnRename.aqua
│ │ ├── closureStreamScopes.aqua
│ │ ├── closures.aqua
│ │ ├── co.aqua
│ │ ├── collectionSugar.aqua
│ │ ├── complex.aqua
│ │ ├── constants.aqua
│ │ ├── dataAlias.aqua
│ │ ├── errorClear.aqua
│ │ ├── example.aqua
│ │ ├── fold.aqua
│ │ ├── foldJoin.aqua
│ │ ├── func.aqua
│ │ ├── funcs.aqua
│ │ ├── functors.aqua
│ │ ├── handleResultError.aqua
│ │ ├── helloWorld.aqua
│ │ ├── if.aqua
│ │ ├── ifPropagateErrors.aqua
│ │ ├── imports_exports
│ │ ├── declare.aqua
│ │ ├── export2.aqua
│ │ ├── export3.aqua
│ │ ├── exports.aqua
│ │ ├── gen
│ │ │ └── OneMore.aqua
│ │ ├── import2.aqua
│ │ ├── import3.aqua
│ │ ├── imports-empty.aqua
│ │ ├── imports.aqua
│ │ ├── modules
│ │ │ ├── libA.aqua
│ │ │ ├── libAB.aqua
│ │ │ ├── libB.aqua
│ │ │ ├── libExport.aqua
│ │ │ ├── libMerge.aqua
│ │ │ ├── libRename.aqua
│ │ │ ├── libSubA.aqua
│ │ │ ├── libSubB.aqua
│ │ │ └── main.aqua
│ │ └── subImport.aqua
│ │ ├── join.aqua
│ │ ├── math.aqua
│ │ ├── multiReturn.aqua
│ │ ├── nestedData.aqua
│ │ ├── nestedFuncs.aqua
│ │ ├── object.aqua
│ │ ├── on.aqua
│ │ ├── onErrorPropagation.aqua
│ │ ├── option.aqua
│ │ ├── options
│ │ └── option_gen.aqua
│ │ ├── par.aqua
│ │ ├── parseq.aqua
│ │ ├── passArgs.aqua
│ │ ├── println.aqua
│ │ ├── pushToStream.aqua
│ │ ├── recursiveStreams
│ │ ├── multiRec.aqua
│ │ ├── nested.aqua
│ │ ├── pipeline.aqua
│ │ ├── range.aqua
│ │ ├── remoteRec.aqua
│ │ └── yesNo.aqua
│ │ ├── redeclare
│ │ ├── import.aqua
│ │ ├── redeclare.aqua
│ │ └── useDeclare.aqua
│ │ ├── renameVars.aqua
│ │ ├── returnArrow.aqua
│ │ ├── returnLiteral.aqua
│ │ ├── servicesAsAbilities.aqua
│ │ ├── stream.aqua
│ │ ├── streamArgs.aqua
│ │ ├── streamCallback.aqua
│ │ ├── streamCan.aqua
│ │ ├── streamCapture.aqua
│ │ ├── streamMap.aqua
│ │ ├── streamMapAbilities.aqua
│ │ ├── streamMapCapture.aqua
│ │ ├── streamMapRestriction.aqua
│ │ ├── streamRestriction.aqua
│ │ ├── streamResults.aqua
│ │ ├── streamReturn.aqua
│ │ ├── streamScopes.aqua
│ │ ├── structuraltyping.aqua
│ │ ├── subImportUsage.aqua
│ │ ├── topbottom.aqua
│ │ ├── topology.aqua
│ │ ├── tryCatch.aqua
│ │ ├── tryOtherwise.aqua
│ │ └── via.aqua
├── jest.config.cjs
├── lsp-aqua
│ └── types.aqua
├── package.json
├── src
│ ├── __test__
│ │ ├── examples.spec.ts
│ │ └── lsp-types.spec.ts
│ ├── compile.ts
│ ├── config.ts
│ ├── examples
│ │ ├── abilityCall.ts
│ │ ├── abilityClosureCall.ts
│ │ ├── abilityClosureRenameCall.ts
│ │ ├── assignment.ts
│ │ ├── boolAlgebra.ts
│ │ ├── callArrowCall.ts
│ │ ├── canonCall.ts
│ │ ├── closureArrowCapture.ts
│ │ ├── closureReturnRename.ts
│ │ ├── closureStreamScopesCall.ts
│ │ ├── closures.ts
│ │ ├── coCall.ts
│ │ ├── collectionSugarCall.ts
│ │ ├── complex.ts
│ │ ├── constantsCall.ts
│ │ ├── dataAliasCall.ts
│ │ ├── declareCall.ts
│ │ ├── errorClear.ts
│ │ ├── foldCall.ts
│ │ ├── foldJoinCall.ts
│ │ ├── funcCall.ts
│ │ ├── funcsCall.ts
│ │ ├── functorsCall.ts
│ │ ├── handleResultError.ts
│ │ ├── helloWorldCall.ts
│ │ ├── ifCall.ts
│ │ ├── ifPropagateErrors.ts
│ │ ├── import2Call.ts
│ │ ├── joinCall.ts
│ │ ├── mathCall.ts
│ │ ├── modules.ts
│ │ ├── multiReturnCall.ts
│ │ ├── nestedDataCall.ts
│ │ ├── nestedFuncsCall.ts
│ │ ├── objectCall.ts
│ │ ├── onCall.ts
│ │ ├── onErrorPropagation.ts
│ │ ├── optionsCall.ts
│ │ ├── parCall.ts
│ │ ├── parSeqCall.ts
│ │ ├── passArgsCall.ts
│ │ ├── pushToStreamCall.ts
│ │ ├── recursiveStreams
│ │ │ ├── multiRecStreamCall.ts
│ │ │ ├── nestedCall.ts
│ │ │ ├── pipelineCall.ts
│ │ │ ├── rangeCall.ts
│ │ │ ├── remoteRecCall.ts
│ │ │ └── yesNoStreamCall.ts
│ │ ├── renameVars.ts
│ │ ├── returnArrowCall.ts
│ │ ├── returnLiteralCall.ts
│ │ ├── servicesAsAbilities.ts
│ │ ├── streamArgsCall.ts
│ │ ├── streamCall.ts
│ │ ├── streamCallback.ts
│ │ ├── streamCanCall.ts
│ │ ├── streamCapture.ts
│ │ ├── streamMapAbilitiesCall.ts
│ │ ├── streamMapCall.ts
│ │ ├── streamMapCapture.ts
│ │ ├── streamMapRestrictionsCall.ts
│ │ ├── streamRestrictionsCall.ts
│ │ ├── streamResultsCall.ts
│ │ ├── streamReturn.ts
│ │ ├── streamScopes.ts
│ │ ├── structuralTypingCall.ts
│ │ ├── subImportUsageCall.ts
│ │ ├── topologyCall.ts
│ │ ├── tryCatchCall.ts
│ │ ├── tryOtherwiseCall.ts
│ │ ├── useOptionalCall.ts
│ │ └── viaCall.ts
│ ├── index.ts
│ └── local-nodes.ts
└── tsconfig.json
├── io
├── .js
│ └── src
│ │ └── main
│ │ └── scala
│ │ └── aqua
│ │ └── PlatformPackagePath.scala
├── .jvm
│ └── src
│ │ └── main
│ │ └── scala
│ │ └── aqua
│ │ └── PlatformPackagePath.scala
└── src
│ ├── main
│ └── scala
│ │ └── aqua
│ │ ├── AquaIO.scala
│ │ ├── Rendering.scala
│ │ ├── SpanParser.scala
│ │ ├── files
│ │ ├── AquaFileSources.scala
│ │ ├── AquaFilesIO.scala
│ │ ├── FileModuleId.scala
│ │ └── Imports.scala
│ │ └── io
│ │ ├── AquaFileError.scala
│ │ ├── AquaPath.scala
│ │ └── OutputPrinter.scala
│ └── test
│ └── scala
│ └── aqua
│ ├── ImportsSpec.scala
│ └── RenderingSpec.scala
├── js
├── js-exports
│ └── src
│ │ └── main
│ │ └── scala
│ │ └── aqua
│ │ └── js
│ │ ├── Definitions.scala
│ │ ├── JsonEncoder.scala
│ │ └── VarJson.scala
└── js-imports
│ └── src
│ └── main
│ └── scala
│ └── aqua
│ └── js
│ ├── CallJsFunction.scala
│ ├── Conversions.scala
│ ├── FluenceEnvironment.scala
│ ├── FluenceJsTypes.scala
│ └── Npm.scala
├── language-server
├── language-server-api
│ ├── .js
│ │ └── src
│ │ │ └── main
│ │ │ └── scala
│ │ │ └── aqua
│ │ │ └── lsp
│ │ │ ├── AquaLSP.scala
│ │ │ ├── OutputTypes.scala
│ │ │ ├── ResultHelper.scala
│ │ │ └── TypeJs.scala
│ ├── .jvm
│ │ └── src
│ │ │ └── main
│ │ │ └── scala
│ │ │ └── aqua
│ │ │ └── lsp
│ │ │ └── Test.scala
│ └── src
│ │ ├── main
│ │ └── scala
│ │ │ └── aqua
│ │ │ └── lsp
│ │ │ ├── LSPCompiler.scala
│ │ │ ├── LocationsInterpreter.scala
│ │ │ ├── LspContext.scala
│ │ │ ├── LspSemantics.scala
│ │ │ └── TokenImportPath.scala
│ │ └── test
│ │ └── scala
│ │ └── aqua
│ │ └── lsp
│ │ ├── AquaLSPSpec.scala
│ │ ├── FileLSPSpec.scala
│ │ └── Utils.scala
└── language-server-npm
│ ├── aqua-lsp-api.d.ts
│ └── package.json
├── linker
└── src
│ ├── main
│ └── scala
│ │ └── aqua
│ │ └── linker
│ │ ├── AquaModule.scala
│ │ ├── Linker.scala
│ │ └── Modules.scala
│ └── test
│ └── scala
│ └── aqua
│ └── linker
│ └── LinkerSpec.scala
├── model
├── inline
│ └── src
│ │ ├── main
│ │ └── scala
│ │ │ └── aqua
│ │ │ └── model
│ │ │ └── inline
│ │ │ ├── ArrowInliner.scala
│ │ │ ├── Inline.scala
│ │ │ ├── MakeStructRawInliner.scala
│ │ │ ├── RawValueInliner.scala
│ │ │ ├── TagInliner.scala
│ │ │ ├── raw
│ │ │ ├── ApplyBinaryOpRawInliner.scala
│ │ │ ├── ApplyFunctorRawInliner.scala
│ │ │ ├── ApplyIntoCopyRawInliner.scala
│ │ │ ├── ApplyPropertiesRawInliner.scala
│ │ │ ├── ApplyStreamMapRawInliner.scala
│ │ │ ├── ApplyUnaryOpRawInliner.scala
│ │ │ ├── CallArrowRawInliner.scala
│ │ │ ├── CallServiceRawInliner.scala
│ │ │ ├── CollectionRawInliner.scala
│ │ │ ├── MakeAbilityRawInliner.scala
│ │ │ ├── RawInliner.scala
│ │ │ ├── StreamGateInliner.scala
│ │ │ └── StreamRawInliner.scala
│ │ │ ├── state
│ │ │ ├── Arrows.scala
│ │ │ ├── Config.scala
│ │ │ ├── Counter.scala
│ │ │ ├── Exports.scala
│ │ │ ├── InliningState.scala
│ │ │ ├── Mangler.scala
│ │ │ └── Scoped.scala
│ │ │ └── tag
│ │ │ ├── ForTagInliner.scala
│ │ │ ├── IfTagInliner.scala
│ │ │ ├── OnTagInliner.scala
│ │ │ ├── StreamRestrictions.scala
│ │ │ └── TryTagInliner.scala
│ │ └── test
│ │ └── scala
│ │ └── aqua
│ │ └── model
│ │ └── inline
│ │ ├── ArrowInlinerSpec.scala
│ │ ├── CollectionRawInlinerSpec.scala
│ │ ├── CopyInlinerSpec.scala
│ │ ├── MakeStructInlinerSpec.scala
│ │ ├── ManglerSpec.scala
│ │ ├── ModelBuilder.scala
│ │ ├── RawBuilder.scala
│ │ ├── RawValueInlinerSpec.scala
│ │ └── TagInlinerSpec.scala
├── raw
│ └── src
│ │ └── main
│ │ └── scala
│ │ └── aqua
│ │ └── raw
│ │ ├── ConstantRaw.scala
│ │ ├── ErroredPart.scala
│ │ ├── Raw.scala
│ │ ├── RawContext.scala
│ │ ├── RawPart.scala
│ │ ├── ServiceRaw.scala
│ │ ├── TypeRaw.scala
│ │ ├── arrow
│ │ ├── ArrowRaw.scala
│ │ └── FuncRaw.scala
│ │ ├── ops
│ │ ├── Call.scala
│ │ ├── FuncOp.scala
│ │ ├── RawTag.scala
│ │ └── RawTagGivens.scala
│ │ └── value
│ │ ├── Optimization.scala
│ │ ├── PropertyRaw.scala
│ │ └── ValueRaw.scala
├── res
│ └── src
│ │ ├── main
│ │ └── scala
│ │ │ └── aqua
│ │ │ └── res
│ │ │ ├── AquaRes.scala
│ │ │ ├── CallRes.scala
│ │ │ ├── FuncRes.scala
│ │ │ ├── MakeRes.scala
│ │ │ ├── ResolvedOp.scala
│ │ │ └── ServiceRes.scala
│ │ └── test
│ │ └── scala
│ │ └── aqua
│ │ └── res
│ │ └── ResBuilder.scala
├── src
│ └── main
│ │ └── scala
│ │ └── aqua
│ │ └── model
│ │ ├── AquaContext.scala
│ │ ├── ArgsCall.scala
│ │ ├── CallModel.scala
│ │ ├── FuncArrow.scala
│ │ ├── OpModel.scala
│ │ ├── ServiceModel.scala
│ │ └── ValueModel.scala
├── transform
│ ├── img.png
│ ├── readme.md
│ └── src
│ │ ├── main
│ │ └── scala
│ │ │ └── aqua
│ │ │ └── model
│ │ │ └── transform
│ │ │ ├── Transform.scala
│ │ │ ├── TransformConfig.scala
│ │ │ ├── cursor
│ │ │ ├── ChainCursor.scala
│ │ │ └── ChainZipper.scala
│ │ │ ├── funcop
│ │ │ ├── OpTransform.scala
│ │ │ └── Tracing.scala
│ │ │ ├── pre
│ │ │ ├── ArgsProvider.scala
│ │ │ ├── ErrorHandler.scala
│ │ │ ├── FuncPreTransformer.scala
│ │ │ ├── InitPeerCallable.scala
│ │ │ ├── PreTransform.scala
│ │ │ └── ResultsHandler.scala
│ │ │ └── topology
│ │ │ ├── OpModelTreeCursor.scala
│ │ │ ├── PathFinder.scala
│ │ │ ├── Topology.scala
│ │ │ ├── TopologyPath.scala
│ │ │ └── strategy
│ │ │ ├── After.scala
│ │ │ ├── Before.scala
│ │ │ ├── Begins.scala
│ │ │ ├── Default.scala
│ │ │ ├── Ends.scala
│ │ │ ├── Fail.scala
│ │ │ ├── For.scala
│ │ │ ├── ParGroup.scala
│ │ │ ├── ParGroupBranch.scala
│ │ │ ├── Root.scala
│ │ │ ├── SeqGroup.scala
│ │ │ ├── SeqGroupBranch.scala
│ │ │ ├── SeqNext.scala
│ │ │ ├── XorBranch.scala
│ │ │ └── XorGroup.scala
│ │ └── test
│ │ └── scala
│ │ └── aqua
│ │ └── model
│ │ └── transform
│ │ ├── ModelBuilder.scala
│ │ ├── TransformSpec.scala
│ │ └── topology
│ │ ├── OpModelTreeCursorSpec.scala
│ │ ├── PathFinderSpec.scala
│ │ └── TopologySpec.scala
└── tree
│ └── src
│ └── main
│ └── scala
│ └── aqua
│ └── tree
│ ├── TreeNode.scala
│ └── TreeNodeCompanion.scala
├── parser
└── src
│ ├── main
│ └── scala
│ │ └── aqua
│ │ └── parser
│ │ ├── Ast.scala
│ │ ├── Expr.scala
│ │ ├── ListToTreeConverter.scala
│ │ ├── Parser.scala
│ │ ├── ParserError.scala
│ │ ├── expr
│ │ ├── AbilityExpr.scala
│ │ ├── AliasExpr.scala
│ │ ├── ArrowTypeExpr.scala
│ │ ├── ConstantExpr.scala
│ │ ├── DataStructExpr.scala
│ │ ├── FieldTypeExpr.scala
│ │ ├── FuncExpr.scala
│ │ ├── RootExpr.scala
│ │ ├── ServiceExpr.scala
│ │ └── func
│ │ │ ├── ArrowExpr.scala
│ │ │ ├── AssignmentExpr.scala
│ │ │ ├── CallArrowExpr.scala
│ │ │ ├── CatchExpr.scala
│ │ │ ├── ClosureExpr.scala
│ │ │ ├── CoExpr.scala
│ │ │ ├── DeclareStreamExpr.scala
│ │ │ ├── ElseOtherwiseExpr.scala
│ │ │ ├── ForExpr.scala
│ │ │ ├── IfExpr.scala
│ │ │ ├── JoinExpr.scala
│ │ │ ├── OnExpr.scala
│ │ │ ├── ParExpr.scala
│ │ │ ├── ParSeqExpr.scala
│ │ │ ├── PushToStreamExpr.scala
│ │ │ ├── ReturnExpr.scala
│ │ │ ├── ServiceIdExpr.scala
│ │ │ └── TryExpr.scala
│ │ ├── head
│ │ ├── ExportExpr.scala
│ │ ├── FilenameExpr.scala
│ │ ├── FromExpr.scala
│ │ ├── Header.scala
│ │ ├── HeaderExpr.scala
│ │ ├── ImportExpr.scala
│ │ ├── ImportFromExpr.scala
│ │ ├── ModuleExpr.scala
│ │ ├── UseExpr.scala
│ │ └── UseFromExpr.scala
│ │ ├── lexer
│ │ ├── Ability.scala
│ │ ├── Arg.scala
│ │ ├── Name.scala
│ │ ├── NamedArg.scala
│ │ ├── PropertyOp.scala
│ │ ├── QName.scala
│ │ ├── Token.scala
│ │ ├── TypeToken.scala
│ │ └── ValueToken.scala
│ │ └── lift
│ │ ├── FileSpan.scala
│ │ ├── LiftParser.scala
│ │ └── Span.scala
│ └── test
│ └── scala
│ └── aqua
│ ├── AquaSpec.scala
│ └── parser
│ ├── AbilityIdExprSpec.scala
│ ├── AbilityValueExprSpec.scala
│ ├── AliasExprSpec.scala
│ ├── ArrowTypeExprSpec.scala
│ ├── AssignmentExprSpec.scala
│ ├── CallArrowSpec.scala
│ ├── ClosureExprSpec.scala
│ ├── CoExprSpec.scala
│ ├── CollectionExprSpec.scala
│ ├── DataStructExprSpec.scala
│ ├── ElseOtherwiseExprSpec.scala
│ ├── FieldTypeExprSpec.scala
│ ├── ForExprSpec.scala
│ ├── FuncExprSpec.scala
│ ├── IfExprSpec.scala
│ ├── IntoArrowSpec.scala
│ ├── OnExprSpec.scala
│ ├── ParExprSpec.scala
│ ├── ParSecExprSpec.scala
│ ├── PushToStreamExprSpec.scala
│ ├── ReturnExprSpec.scala
│ ├── ServiceExprSpec.scala
│ ├── StructValueExprSpec.scala
│ ├── ValueTokenComplexSpec.scala
│ ├── head
│ ├── FromSpec.scala
│ ├── ImportFromSpec.scala
│ ├── ModuleSpec.scala
│ └── UseSpec.scala
│ └── lexer
│ ├── PropertyOpSpec.scala
│ ├── TokenSpec.scala
│ ├── TypeTokenSpec.scala
│ ├── ValueTokenSpec.scala
│ └── VarLambdaSpec.scala
├── pnpm-lock.yaml
├── pnpm-workspace.yaml
├── project
├── BundleJS.scala
├── build.properties
└── plugins.sbt
├── semantics
└── src
│ ├── main
│ └── scala
│ │ └── aqua
│ │ └── semantics
│ │ ├── CompilerState.scala
│ │ ├── ExprSem.scala
│ │ ├── FileId.scala
│ │ ├── Levenshtein.scala
│ │ ├── Prog.scala
│ │ ├── RawSemantics.scala
│ │ ├── SemanticError.scala
│ │ ├── SemanticWarning.scala
│ │ ├── Semantics.scala
│ │ ├── expr
│ │ ├── AbilitySem.scala
│ │ ├── AliasSem.scala
│ │ ├── ArrowTypeSem.scala
│ │ ├── ConstantSem.scala
│ │ ├── DataStructSem.scala
│ │ ├── FieldTypeSem.scala
│ │ ├── RootSem.scala
│ │ ├── ServiceSem.scala
│ │ └── func
│ │ │ ├── ArrowSem.scala
│ │ │ ├── AssignmentSem.scala
│ │ │ ├── CallArrowSem.scala
│ │ │ ├── CatchSem.scala
│ │ │ ├── ClosureSem.scala
│ │ │ ├── CoSem.scala
│ │ │ ├── DeclareStreamSem.scala
│ │ │ ├── ElseOtherwiseSem.scala
│ │ │ ├── ForSem.scala
│ │ │ ├── FuncSem.scala
│ │ │ ├── IfSem.scala
│ │ │ ├── JoinSem.scala
│ │ │ ├── OnSem.scala
│ │ │ ├── ParSem.scala
│ │ │ ├── ParSeqSem.scala
│ │ │ ├── PushToStreamSem.scala
│ │ │ ├── ReturnSem.scala
│ │ │ ├── ServiceIdSem.scala
│ │ │ └── TrySem.scala
│ │ ├── header
│ │ ├── ExportSem.scala
│ │ ├── HeaderHandler.scala
│ │ ├── HeaderSem.scala
│ │ ├── ModuleSem.scala
│ │ ├── Picker.scala
│ │ └── package.scala
│ │ └── rules
│ │ ├── StackInterpreter.scala
│ │ ├── ValuesAlgebra.scala
│ │ ├── abilities
│ │ ├── AbilitiesAlgebra.scala
│ │ ├── AbilitiesInterpreter.scala
│ │ └── AbilitiesState.scala
│ │ ├── definitions
│ │ ├── DefinitionsAlgebra.scala
│ │ ├── DefinitionsInterpreter.scala
│ │ └── DefinitionsState.scala
│ │ ├── locations
│ │ ├── DummyLocationsInterpreter.scala
│ │ ├── LocationsAlgebra.scala
│ │ ├── LocationsState.scala
│ │ ├── VariableInfo.scala
│ │ └── Variables.scala
│ │ ├── mangler
│ │ ├── ManglerAlgebra.scala
│ │ └── ManglerInterpreter.scala
│ │ ├── names
│ │ ├── NamesAlgebra.scala
│ │ ├── NamesInterpreter.scala
│ │ └── NamesState.scala
│ │ ├── report
│ │ ├── ReportAlgebra.scala
│ │ ├── ReportInterpreter.scala
│ │ └── ReportState.scala
│ │ └── types
│ │ ├── TypeResolution.scala
│ │ ├── TypesAlgebra.scala
│ │ ├── TypesInterpreter.scala
│ │ └── TypesState.scala
│ └── test
│ └── scala
│ └── aqua
│ └── semantics
│ ├── ArrowSemSpec.scala
│ ├── ClosureSemSpec.scala
│ ├── HeaderSpec.scala
│ ├── SemanticsSpec.scala
│ ├── TypeResolutionSpec.scala
│ ├── Utils.scala
│ └── ValuesAlgebraSpec.scala
├── types
└── src
│ ├── main
│ └── scala
│ │ └── aqua
│ │ └── types
│ │ ├── CompareTypes.scala
│ │ ├── IntersectTypes.scala
│ │ ├── ScalarsCombine.scala
│ │ ├── Type.scala
│ │ └── UniteTypes.scala
│ └── test
│ └── scala
│ └── aqua
│ └── types
│ ├── IntersectTypesSpec.scala
│ ├── TypeSpec.scala
│ ├── TypeVarianceSpec.scala
│ ├── UniteTypesSpec.scala
│ └── package.scala
└── utils
├── constants
└── src
│ └── main
│ └── scala
│ └── aqua.constants
│ └── Constants.scala
├── errors
└── src
│ └── main
│ └── scala
│ └── aqua
│ └── errors
│ └── Errors.scala
├── helpers
└── src
│ └── main
│ └── scala
│ └── aqua
│ └── helpers
│ ├── data
│ ├── PName.scala
│ └── SName.scala
│ ├── ext
│ └── Extension.scala
│ ├── syntax
│ ├── eithert.scala
│ ├── list.scala
│ ├── optiont.scala
│ └── reader.scala
│ └── tree
│ └── Tree.scala
├── logging
└── src
│ └── main
│ └── scala
│ └── aqua
│ └── logging
│ ├── LogFormatter.scala
│ ├── LogLevel.scala
│ └── LogLevels.scala
└── mangler
└── src
└── main
└── scala
└── aqua
└── mangler
└── ManglerState.scala
/.github/actionlint.yaml:
--------------------------------------------------------------------------------
1 | self-hosted-runner:
2 | labels:
3 | - builder
4 |
--------------------------------------------------------------------------------
/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | ## Description
2 | [Provide a brief description of the changes introduced by this pull request and the motivation behind them.]
3 |
4 | ## Proposed Changes
5 | [List the specific changes and additions introduced by this pull request.]
6 |
7 | ## Implementation Details
8 | [Provide additional details about the implementation that may be helpful to reviewers.]
9 |
10 | ## Checklist
11 | - [ ] Corresponding issue has been created and linked in PR title.
12 | - [ ] Proposed changes are covered by tests.
13 | - [ ] Documentation has been updated to reflect the changes (if applicable).
14 | - [ ] I have self-reviewed my code and ensured its quality.
15 | - [ ] I have added/updated necessary comments to aid understanding.
16 |
17 | ## Reviewer Checklist
18 | - [ ] Tests have been reviewed and are sufficient to validate the changes.
19 | - [ ] Documentation has been reviewed and is up to date.
20 | - [ ] Any questions or concerns have been addressed.
21 |
22 |
--------------------------------------------------------------------------------
/.github/release-please/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "bootstrap-sha": "20e0c63e6a6cdb103e417c3d3081ed6ba4c84a97",
3 | "release-type": "simple",
4 | "bump-minor-pre-major": true,
5 | "bump-patch-for-minor-pre-major": true,
6 | "packages": {
7 | ".": {
8 | "component": "aqua"
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/.github/release-please/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | ".": "0.14.11"
3 | }
4 |
--------------------------------------------------------------------------------
/.github/renovate.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": [
3 | "github>fluencelabs/renovate",
4 | "github>fluencelabs/renovate:npm"
5 | ],
6 | "ignorePaths": ["api/aqua-api-example/**"],
7 | "enabledManagers": ["npm"]
8 | }
9 |
--------------------------------------------------------------------------------
/.github/workflows/lint.yml:
--------------------------------------------------------------------------------
1 | name: lint
2 |
3 | on:
4 | pull_request:
5 | types:
6 | - opened
7 | - edited
8 | - synchronize
9 |
10 | concurrency:
11 | group: "${{ github.workflow }}-${{ github.ref }}"
12 | cancel-in-progress: true
13 |
14 | jobs:
15 | pr:
16 | name: Validate PR title
17 | runs-on: ubuntu-latest
18 | steps:
19 | - uses: amannn/action-semantic-pull-request@v5
20 | env:
21 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22 |
23 | reviewdog:
24 | runs-on: ubuntu-latest
25 | steps:
26 | - name: Checkout
27 | uses: actions/checkout@v4
28 |
29 | - name: Lint actions
30 | uses: reviewdog/action-actionlint@v1
31 | env:
32 | SHELLCHECK_OPTS: "-e SC2086"
33 | with:
34 | reporter: github-pr-check
35 | fail_on_error: true
36 |
--------------------------------------------------------------------------------
/.github/workflows/run-tests.yml:
--------------------------------------------------------------------------------
1 | name: "test"
2 |
3 | on:
4 | pull_request:
5 | paths-ignore:
6 | - "**.md"
7 | - ".github/**"
8 | - "!.github/workflows/tests.yml"
9 | - "!.github/workflows/run-tests.yml"
10 | push:
11 | branches:
12 | - "main"
13 | paths-ignore:
14 | - "**.md"
15 | - ".github/**"
16 | - "!.github/workflows/tests.yml"
17 | - "!.github/workflows/run-tests.yml"
18 |
19 | concurrency:
20 | group: "${{ github.workflow }}-${{ github.ref }}"
21 | cancel-in-progress: true
22 |
23 | jobs:
24 | sbt-tests:
25 | name: "aqua"
26 | uses: ./.github/workflows/sbt-tests.yml
27 | with:
28 | ref: ${{ github.ref }}
29 |
30 | tests:
31 | name: "aqua"
32 | uses: ./.github/workflows/tests.yml
33 | with:
34 | ref: ${{ github.ref }}
35 |
--------------------------------------------------------------------------------
/.github/workflows/sbt-tests.yml:
--------------------------------------------------------------------------------
1 | name: Run sbt tests with workflow_call
2 |
3 | on:
4 | workflow_call:
5 | inputs:
6 | ref:
7 | description: "git ref to checkout to"
8 | type: string
9 | default: "main"
10 |
11 | jobs:
12 | tests:
13 | name: "Run sbt tests"
14 | runs-on: ubuntu-latest
15 |
16 | steps:
17 | - name: Checkout repository
18 | uses: actions/checkout@v4
19 | with:
20 | repository: fluencelabs/aqua
21 | ref: ${{ inputs.ref }}
22 |
23 | - name: Cache Scala
24 | uses: coursier/cache-action@v6
25 |
26 | - name: Setup Scala
27 | uses: coursier/setup-action@v1
28 | with:
29 | apps: sbt
30 |
31 | - name: Run tests
32 | run: env JAVA_OPTS="-Xmx4G" sbt "headerCheckAll; test"
33 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea
2 | .bsp
3 | .metals
4 | .vscode
5 | .bloop
6 | metals.sbt
7 | target
8 | project/target
9 |
10 | .DS_Store
11 |
12 | language-server/language-server-npm/aqua-lsp-api.js
13 | api/api-npm/aqua-api.js
14 |
15 | integration-tests/src/compiled/*
16 |
17 | **/dist
18 | **/node_modules
19 |
--------------------------------------------------------------------------------
/.jvmopts:
--------------------------------------------------------------------------------
1 | -Dfile.encoding=UTF8
2 | -Xms1G
3 | -Xmx6G
4 | -XX:ReservedCodeCacheSize=500M
5 | -XX:+TieredCompilation
6 | -XX:+UseParallelGC
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "files.watcherExclude": {
3 | "**/target": true
4 | }
5 | }
--------------------------------------------------------------------------------
/USAGE.md:
--------------------------------------------------------------------------------
1 | # Usage of Aqua
2 |
3 |
4 | ## Fluence CLI
5 |
6 | The easiest way to use Aqua is through [Fluence CLI](https://github.com/fluencelabs/cli) with [aqua command](https://github.com/fluencelabs/cli/blob/main/docs/commands/README.md#fluence-aqua).
7 |
8 |
9 | ## JS API
10 |
11 | You can use Aqua compiler API directly from JS code by installing [`@fluencelabs/aqua-api` package](https://www.npmjs.com/package/@fluencelabs/aqua-api). See an example usage in [api/api-example](./api/api-example).
12 |
13 |
14 | ## Build from sources
15 |
16 | If you want to build Aqua compiler API from the source code, you need [Scala](https://www.scala-lang.org/)'s [`sbt`](https://www.scala-sbt.org/) installed.
17 |
18 |
19 | ### Build to JS package
20 |
21 | Javascript build is the default for Aqua compiler API.
22 |
23 | Run `sbt "aqua-apiJS/fullBundleJS"`. It will generate JS package in `api/api-npm` directory.
24 |
25 |
26 | ### Build to JVM library
27 |
28 | Building Aqua compiler API as JVM lib is technically possible, but is not supported.
29 |
--------------------------------------------------------------------------------
/api/api-example/index.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | //@ts-check
18 |
19 | import { compileAquaCallFromPath } from '@fluencelabs/aqua-api'
20 |
21 | // compile call
22 | const compilationResult = await compileAquaCallFromPath({
23 | filePath: 'test.aqua',
24 | data: { num: 3 },
25 | funcCall: 'getNumber(num)',
26 | })
27 |
28 | const {
29 | errors,
30 | functionCall: { funcDef, script },
31 | functions,
32 | generatedSources,
33 | services,
34 | } = compilationResult
35 |
36 | console.log(script)
37 |
--------------------------------------------------------------------------------
/api/api-example/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "aqua-api-example",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "call": "node index.js"
8 | },
9 | "author": "Fluence Labs",
10 | "type": "module",
11 | "license": "AGPL-3.0",
12 | "dependencies": {
13 | "@fluencelabs/aqua-api": "workspace:*"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/api/api-example/readme.md:
--------------------------------------------------------------------------------
1 | ## Aqua API Example
2 |
3 | An example of how to use Aqua API with Fluence Client.
4 | Documentation and description [here](https://fluence.dev/docs/aqua-book/aqua-js-api).
--------------------------------------------------------------------------------
/api/api-example/test.aqua:
--------------------------------------------------------------------------------
1 | func getNumber(number: u32) -> u32:
2 | <- number
--------------------------------------------------------------------------------
/api/api-npm/README.md:
--------------------------------------------------------------------------------
1 | # Aqua API
2 |
3 | [Documentation](https://fluence.dev/docs/aqua-book/aqua-js-api)
4 |
--------------------------------------------------------------------------------
/api/api-npm/meta-utils.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | const metaUrl = ""
18 |
--------------------------------------------------------------------------------
/api/api-npm/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@fluencelabs/aqua-api",
3 | "version": "0.14.11",
4 | "description": "Aqua API",
5 | "type": "module",
6 | "main": "index.js",
7 | "files": [
8 | "index.js",
9 | "index.d.ts",
10 | "aqua-api.js",
11 | "meta-utils.js"
12 | ],
13 | "prettier": {},
14 | "repository": {
15 | "type": "git",
16 | "url": "git+https://github.com/fluencelabs/aqua.git"
17 | },
18 | "keywords": [
19 | "aqua",
20 | "fluence"
21 | ],
22 | "author": "Fluence Labs",
23 | "license": "AGPL-3.0",
24 | "bugs": {
25 | "url": "https://github.com/fluencelabs/aqua/issues"
26 | },
27 | "homepage": "https://github.com/fluencelabs/aqua#readme",
28 | "devDependencies": {
29 | "@fluencelabs/interfaces": "0.12.0",
30 | "prettier": "3.3.0"
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/api/api/src/main/scala/aqua/api/package.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua
18 |
19 | import cats.data.{Chain, EitherT, NonEmptyChain, Writer}
20 |
21 | package object api {
22 |
23 | type APIWarnings = [A] =>> Writer[
24 | Chain[String],
25 | A
26 | ]
27 |
28 | type APIResult = [A] =>> EitherT[
29 | APIWarnings,
30 | NonEmptyChain[String],
31 | A
32 | ]
33 | }
34 |
--------------------------------------------------------------------------------
/aqua-run/src/main/scala/aqua/run/CallInfo.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.run
18 | import aqua.definitions.FunctionDef
19 |
20 | case class CallInfo(
21 | name: String,
22 | air: String,
23 | definitions: FunctionDef,
24 | config: RunConfig
25 | )
26 |
27 | case class RunInfo(
28 | name: String,
29 | air: String,
30 | definitions: FunctionDef
31 | )
32 |
--------------------------------------------------------------------------------
/aqua-src/antithesis.aqua:
--------------------------------------------------------------------------------
1 | aqua StreamMapTest declares *
2 |
3 | export main
4 |
5 | func foo() -> %string, u64:
6 | map: %string
7 | <- map, 42
8 |
9 | func get() -> string, string:
10 | <- "123", "44"
11 |
12 | func main() -> string:
13 | m <- foo()
14 | <- m.get("key")!
--------------------------------------------------------------------------------
/aqua-src/call_arrow.aqua:
--------------------------------------------------------------------------------
1 | module CallArrow
2 |
3 | export order
4 |
5 |
6 | service Experiment("exp"):
7 | get_num: -> u32
8 | get_arr: -> []string
9 |
10 | --func get_num() -> u32:
11 | -- <- Experiment.get_num()
12 |
13 | --func by_idx() -> string:
14 | -- x <- Experiment.get_arr()
15 | -- <- x[Experiment.get_num()+get_num()]
16 |
17 | func order() -> i32:
18 | <- (5-2)*2-10+(3-1)*5
--------------------------------------------------------------------------------
/aqua-src/declare.aqua:
--------------------------------------------------------------------------------
1 | aqua AquaName declares getWorker, Worker
2 |
3 | data Worker:
4 | host_id: string
5 |
6 | func getWorker() -> Worker:
7 | <- Worker(host_id = "")
8 |
9 |
--------------------------------------------------------------------------------
/aqua-src/export.aqua:
--------------------------------------------------------------------------------
1 | aqua FooBars declares *
2 |
3 | const DECLARE_CONST = "declare_const"
4 | const DECLARE_CONST2 = "declare_const2"
5 |
6 | -- alias SomeStruct: string
7 |
8 | data SomeStruct:
9 | a: string
10 |
11 | -- service SomeStruct("ss"):
12 | -- a() -> string
13 |
14 | func foo() -> string:
15 | <- "I am MyFooBar foo"
--------------------------------------------------------------------------------
/aqua-src/exports.aqua:
--------------------------------------------------------------------------------
1 | module Exports declares some_string, MyExportSrv, EXPORT_CONST, some_random_func
2 |
3 | export some_string as string_from_lib
4 | export MyExportSrv
5 |
6 | const EXPORT_CONST = "export_const"
7 |
8 | service MyExportSrv("my_export_srv"):
9 | another_str() -> string
10 |
11 | func some_string() -> string:
12 | <- "some_string_func"
13 |
14 | func some_random_func() -> string:
15 | <- "wow, so random"
--------------------------------------------------------------------------------
/aqua-src/foldJoin.aqua:
--------------------------------------------------------------------------------
1 |
2 | service Op2("op"):
3 | identity(s: u64)
4 | neighborhood: -> []string
5 | timestamp: -> u64
6 |
7 | func getTwoResults(node: string) -> []u64:
8 | on node:
9 | nodes <- Op2.neighborhood()
10 | res: *u64
11 | for n <- nodes par:
12 | on n:
13 | try:
14 | res <- Op2.timestamp()
15 | Op2.identity(res!)
16 | Op2.identity(res!1)
17 | Op2.identity(res!2)
18 | <- res
--------------------------------------------------------------------------------
/aqua-src/gen/OneMore.aqua:
--------------------------------------------------------------------------------
1 | aqua One
2 |
3 | service OneMore:
4 | more_call()
5 | consume(s: string)
--------------------------------------------------------------------------------
/aqua-src/hack.aqua:
--------------------------------------------------------------------------------
1 | aqua B declares timeout, someString
2 |
3 | func timeout() -> string:
4 | <- "hack file"
5 |
6 | func someString() -> string:
7 | <- "sssss"
--------------------------------------------------------------------------------
/aqua-src/import-empty.aqua:
--------------------------------------------------------------------------------
1 | -- import.aqua
2 | module Import.Test
3 | import foo from "export"
4 | --import someFunc from "ret"
5 |
6 | use foo as f from "export" as Exp
7 |
8 | use "export"
9 |
10 | export foo as barfoo
--------------------------------------------------------------------------------
/aqua-src/import.aqua:
--------------------------------------------------------------------------------
1 | aqua Import declares someFunc
2 |
3 | service GetStr("multiret-test"):
4 | retStr(s: []string, a: []string)
5 |
6 | func someFunc() -> string:
7 | <- "some func call"
8 |
9 | func foo_wrapper():
10 | GetStr.retStr(nil, nil)
11 |
12 | func invalid_append() -> *string:
13 | stream: *string
14 | cream: *string
15 | dream: *string
16 | str: *string
17 | asdasd: *string
18 | GetStr.retStr(stream, nil)
19 | <- stream
--------------------------------------------------------------------------------
/aqua-src/imports.aqua:
--------------------------------------------------------------------------------
1 | import decl_foo, decl_bar from "declare.aqua"
2 | use DECLARE_CONST, SuperFoo, DECLARE_CONST2 as DC2 from "declare.aqua" as Declare
3 | import Op as Noop from "builtin.aqua"
4 | import some_string, MyExportSrv, EXPORT_CONST from "exports.aqua"
5 |
6 | service StringService("string_service"):
7 | concat(a: string, b: string) -> string
8 |
9 | func concat_foobars() -> string:
10 | res1 <- decl_foo()
11 | res2 <- decl_bar()
12 | res3 <- StringService.concat(res1, res2)
13 | res4 <- Declare.SuperFoo.small_foo()
14 | res5 <- StringService.concat(res3, res4)
15 | res6 <- StringService.concat(res5, EXPORT_CONST)
16 | res7 <- StringService.concat(res6, Declare.DECLARE_CONST)
17 | res8 <- StringService.concat(res7, Declare.DC2)
18 | <- res8
--------------------------------------------------------------------------------
/aqua-src/join.aqua:
--------------------------------------------------------------------------------
1 | import "builtin.aqua"
2 |
3 | func joinIdxLocal(idx: i16, nodes: []string) -> []string:
4 | nodes2: *string
5 | for node <- nodes par:
6 | nodes2 <<- node
7 | join nodes2[idx], nodes
8 | <- nodes2
9 |
--------------------------------------------------------------------------------
/aqua-src/nopingback.aqua:
--------------------------------------------------------------------------------
1 | service HelloWorld("hello-srv"):
2 | hello: string -> string
3 |
4 | data Info:
5 | external: []string
6 |
7 | func sayHello(info: Info) -> string:
8 | -- execute computation on a Peer in the network
9 | on "hello-peer":
10 | comp <- HelloWorld.hello(info.external!)
11 |
12 | -- send the result to target browser in the background
13 | co on "target-peer" via "target-relay":
14 | res <- HelloWorld.hello(%init_peer_id%)
15 |
16 | join comp
17 |
18 | -- send the result to the initiator
19 | <- comp
--------------------------------------------------------------------------------
/aqua-src/on.aqua:
--------------------------------------------------------------------------------
1 | import "builtin.aqua"
2 |
3 | func getPeerExternalAddresses(otherNodePeerId: string) -> []string:
4 | on otherNodePeerId:
5 | res <- Peer.identify()
6 | <- res.external_addresses
7 |
8 | -- it is possible to use `via` to built complex routes
9 | func getDistantAddresses(target: string, viaNode: string) -> []string:
10 | on target via viaNode:
11 | res <- Peer.identify()
12 | <- res.external_addresses
--------------------------------------------------------------------------------
/aqua-src/parfold.aqua:
--------------------------------------------------------------------------------
1 |
2 | service Moo("tools"):
3 | bla() -> []string
4 |
5 | func foo():
6 | ss <- Moo.bla()
7 | on HOST_PEER_ID:
8 | for s <- ss par:
9 | on s:
10 | Moo.bla()
--------------------------------------------------------------------------------
/aqua-src/restrict.aqua:
--------------------------------------------------------------------------------
1 | module Restrict
2 |
3 | export withLoop, buildOptUsage, checkKeepReturn, checkKeepArg, retrieve_records
4 |
5 |
6 | func withLoop(xs: []string):
7 | for x <- xs:
8 | s: *string
9 | s <<- x
10 |
11 | func buildOpt() -> ?string:
12 | s: *string
13 | s <<- "none"
14 | <- s
15 |
16 | func buildOptUsage():
17 | a <- buildOpt()
18 | b <- buildOpt()
19 | for x <- b:
20 | z <- buildOpt()
21 |
22 | func keepReturn() -> *string:
23 | s: *string
24 | s <<- "should be not restricted"
25 | <- s
26 |
27 | func checkKeepReturn() -> []string:
28 | s <- keepReturn()
29 | s <<- "and more"
30 | <- s
31 |
32 | func keepArg(arg: *string) -> []string:
33 | arg <<- "push more"
34 | <- arg
35 |
36 | func checkKeepArg() -> []string, []string:
37 | a: *string
38 | keepArg(a)
39 | y <- keepArg(a)
40 | a <<- "more"
41 | <- a, y
42 |
43 | -- failing Aqua code:
44 | service TestServiceRestrict("test-service"):
45 | get_records(key: string) -> []string
46 |
47 | func append_records(peer: string, srum: *[]string):
48 | srum <- TestServiceRestrict.get_records(peer)
49 |
50 | func retrieve_records(peer: string) -> [][]string:
51 | records: *[]string
52 | append_records(peer, records)
53 | <- records
54 |
--------------------------------------------------------------------------------
/aqua-src/ret.aqua:
--------------------------------------------------------------------------------
1 | module Ret declares *
2 |
3 | export getTwoResults
4 |
5 | service Peer("peer"):
6 | timestamp_sec: -> u64
7 |
8 | func getTwoResults() -> u64:
9 | on "other node":
10 | res <- Peer.timestamp_sec()
11 | <- res
--------------------------------------------------------------------------------
/aqua-src/so.aqua:
--------------------------------------------------------------------------------
1 | service Kademlia("kad"):
2 | neighborhood: -> []string
3 |
4 | service Peer("peer"):
5 | timestamp_sec: -> u64
6 |
7 | service Op2("op"):
8 | identity: u64 -> u64
9 |
10 | func getTwoResults(node: string) -> []u64:
11 | on node:
12 | nodes <- Kademlia.neighborhood()
13 | res: *u64
14 | for n <- nodes par:
15 | on n:
16 | try:
17 | res <- Peer.timestamp_sec()
18 | Op2.identity(res!)
19 | Op2.identity(res!1)
20 | Op2.identity(res!2)
21 | <- res
22 |
23 |
24 | func makeArray() -> []u64:
25 | <- [1, 3, 5]
26 |
27 |
28 | func makeOption() -> ?u64:
29 | <- ?[1, 3, 5]
30 |
31 | func makeStream() -> *u64:
32 | <- *[1, 3, 5]
--------------------------------------------------------------------------------
/aqua-src/streamCallback.aqua:
--------------------------------------------------------------------------------
1 | module Ret declares *
2 |
3 | export someFunc
4 |
5 | func someFunc(cb: []string -> ()):
6 | ifaces: *string
7 | cb(ifaces)
--------------------------------------------------------------------------------
/aqua-src/test.aqua:
--------------------------------------------------------------------------------
1 | import "@fluencelabs/aqua-ipfs/ipfs.aqua"
2 |
3 | service Console("run-console"):
4 | print(res: IpfsGetResult)
5 |
6 | service ConsoleOp("run-console"):
7 | print(arr: []string)
8 |
9 |
10 | func something(node: string) -> string:
11 | service_id: *string
12 | on HOST_PEER_ID:
13 | res <- Ipfs.get("1234")
14 | if res.error == "":
15 | service_id <<- "0x"
16 | else:
17 | service_id <<- "1x"
18 | ConsoleOp.print(service_id)
19 | Console.print(res)
20 | <- service_id!
--------------------------------------------------------------------------------
/aqua-src/test/export2.aqua:
--------------------------------------------------------------------------------
1 | module Export declares foobar, foo
2 |
3 | func bar() -> string:
4 | <- " I am MyFooBar bar"
5 |
6 | func foo() -> string:
7 | <- "I am MyFooBar foo"
8 |
9 | func foobar() -> []string:
10 | res: *string
11 | res <- foo()
12 | res <- bar()
13 | <- res
14 |
--------------------------------------------------------------------------------
/aqua-src/test/export_service.aqua:
--------------------------------------------------------------------------------
1 | module Closure declares *
2 |
3 | export LocalSrv
4 |
5 | service LocalSrv("local_srv"):
6 | inside: -> ()
7 |
8 | -- MyOp shouldn't be exported in TS
9 | service MyOp("op"):
10 | identity(s: string) -> string
--------------------------------------------------------------------------------
/aqua-src/test/rename.aqua:
--------------------------------------------------------------------------------
1 | export some_string as string_from_lib
2 |
3 | -- some_string must be renamed as string_from_lib in TS
4 | func some_string() -> string:
5 | <- "some_string_func"
6 |
7 |
8 | service TestServiceRename("test-service"):
9 | get_records(key: string) -> []string
10 |
11 | func append_records(peer: string, srum: *[]string):
12 | srum <- TestServiceRename.get_records(peer)
13 |
14 | func retrieve_records(peer: string) -> [][]string:
15 | records: *[]string
16 | -- srum in `append_records` should be renamed as `records` in resulted AIR
17 | append_records(peer, records)
18 | <- records
19 |
--------------------------------------------------------------------------------
/aqua-src/test/service_call.aqua:
--------------------------------------------------------------------------------
1 | module Import
2 | import foobar from "export2.aqua"
3 |
4 | use foo as f from "export2.aqua" as Exp
5 |
6 | import "../gen/OneMore.aqua"
7 |
8 | export foo_wrapper as wrap, foobar as barfoo
9 |
10 | func foo_wrapper() -> string:
11 | z <- Exp.f()
12 | OneMore "hello"
13 | OneMore.more_call()
14 | -- Exp.f() returns literal, this func must return literal in AIR as well
15 | <- z
--------------------------------------------------------------------------------
/aqua-src/test/wrong-par.aqua:
--------------------------------------------------------------------------------
1 | service MyOp("op"):
2 | identity(s: string) -> string
3 |
4 | service Op("op"):
5 | noop: -> ()
6 |
7 | -- peers is of size 2
8 | func gather_values(peers: []string, another_peer: string) -> []string:
9 | values: *string
10 |
11 | for peer <- peers par:
12 | on peer:
13 | Op.noop()
14 | values <<- "hello"
15 |
16 | on another_peer:
17 | MyOp.identity(values!1)
18 | <- values
--------------------------------------------------------------------------------
/aqua-src/via.aqua:
--------------------------------------------------------------------------------
1 | service MyOp("op"):
2 | identity(s: string) -> string
3 |
4 | func viaArr(viaAr: []string) -> string:
5 | on "custom node" via viaAr:
6 | p <- MyOp.identity("123")
7 | <- p
--------------------------------------------------------------------------------
/aqua-src/xor.aqua:
--------------------------------------------------------------------------------
1 | service OpR("op"):
2 | identity: string -> string
3 |
4 | func ifCorrectXorWrap(node: string) -> string:
5 | service_id: *string
6 | on node:
7 | res <- OpR.identity("1234")
8 | if res == "":
9 | service_id <<- "0x"
10 | else:
11 | service_id <<- "1x"
12 | <- service_id!
--------------------------------------------------------------------------------
/backend/.js/src/main/scala/aqua/backend/Version.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.backend
18 |
19 | object Version {
20 | lazy val version = BuildInfo.version
21 | }
22 |
--------------------------------------------------------------------------------
/backend/.jvm/src/main/scala/aqua/backend/Version.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.backend
18 |
19 | object Version {
20 |
21 | lazy val version = BuildInfo.version
22 | }
23 |
--------------------------------------------------------------------------------
/backend/air/src/main/scala/aqua/backend/air/FuncAirGen.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.backend.air
18 |
19 | import aqua.res.FuncRes
20 |
21 | case class FuncAirGen(func: FuncRes) {
22 |
23 | /**
24 | * Generates AIR from the function body
25 | */
26 | def generate: Air =
27 | AirGen(
28 | func.body
29 | ).generate
30 | }
31 |
--------------------------------------------------------------------------------
/backend/src/main/scala/aqua/backend/AirFunction.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.backend
18 |
19 | import aqua.definitions.FunctionDef
20 |
21 | case class AirFunction(name: String, air: String, funcDef: FunctionDef)
22 |
--------------------------------------------------------------------------------
/backend/src/main/scala/aqua/backend/Generated.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.backend
18 |
19 | import aqua.definitions.ServiceDef
20 |
21 | /**
22 | * Compilation result
23 | *
24 | * @param suffix extension or another info that will be added to a resulted file
25 | * @param content compiled code
26 | */
27 | case class Generated(suffix: String, content: String, air: List[AirFunction], services: List[ServiceDef] = Nil)
28 |
--------------------------------------------------------------------------------
/backend/ts/src/main/scala/aqua/backend/ts/TypeScriptTypes.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.backend.ts
18 |
19 | import aqua.backend.{FuncTypes, ServiceTypes, Types}
20 | import aqua.res.{FuncRes, ServiceRes}
21 |
22 | case class TypeScriptTypes(client: String) extends Types {
23 | override def typed(field: String, t: String): String = s"$field: $t"
24 | override def generic(field: String, t: String): String = s"$field<$t>"
25 | override def bang(field: String): String = s"$field!"
26 | def funcType(f: FuncRes): FuncTypes = TSFuncTypes(f, client)
27 | def serviceType(s: ServiceRes): ServiceTypes = TSServiceTypes(s, client)
28 | }
29 |
--------------------------------------------------------------------------------
/compiler/src/main/scala/aqua/compiler/AirValidator.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.compiler
18 |
19 | import aqua.backend.AirFunction
20 | import cats.data.ValidatedNec
21 |
22 |
23 | trait AirValidator[F[_]] {
24 | def init(): F[Unit]
25 |
26 | def validate(
27 | airs: List[AirFunction]
28 | ): F[ValidatedNec[String, Unit]]
29 | }
30 |
--------------------------------------------------------------------------------
/compiler/src/main/scala/aqua/compiler/AquaCompiled.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.compiler
18 |
19 | import aqua.backend.Generated
20 |
21 | case class AquaCompiled[+I](
22 | sourceId: I,
23 | compiled: Seq[Generated],
24 | funcsCount: Int,
25 | servicesCount: Int
26 | )
27 |
--------------------------------------------------------------------------------
/compiler/src/main/scala/aqua/compiler/AquaCompilerConf.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.compiler
18 |
19 | import aqua.raw.ConstantRaw
20 |
21 | /**
22 | * What should compiler care about during compilation – before generator backend takes its role
23 | *
24 | * @param constantsList List of known constants
25 | * @param relayVarName Name of the relay variable
26 | */
27 | case class AquaCompilerConf(
28 | constants: List[ConstantRaw] = Nil,
29 | relayVarName: Option[String] = Some("-relay-")
30 | )
31 |
--------------------------------------------------------------------------------
/compiler/src/main/scala/aqua/compiler/AquaProcessed.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.compiler
18 |
19 | import aqua.model.AquaContext
20 |
21 | case class AquaProcessed[I](id: I, context: AquaContext) {
22 | def hasOutput: Boolean = context.funcs.nonEmpty || context.services.nonEmpty
23 | }
24 |
--------------------------------------------------------------------------------
/compiler/src/main/scala/aqua/compiler/AquaSources.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.compiler
18 |
19 | import cats.data.{Chain, ValidatedNec}
20 |
21 | trait AquaSources[F[_], Err, I] {
22 | // Read the sources in the sources directory as (Id, String Content) pairs
23 | def sources: F[ValidatedNec[Err, Chain[(I, String)]]]
24 |
25 | // Resolve id of the imported imp string from I file
26 | def resolveImport(from: I, imp: String): F[ValidatedNec[Err, I]]
27 |
28 | // Load file by its resolved I
29 | def load(file: I): F[ValidatedNec[Err, String]]
30 | }
31 |
--------------------------------------------------------------------------------
/compiler/src/main/scala/aqua/compiler/AquaWarning.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.compiler
18 |
19 | import aqua.semantics
20 |
21 | enum AquaWarning[S[_]] {
22 | case CompileWarning(warning: semantics.SemanticWarning[S])
23 | }
24 |
--------------------------------------------------------------------------------
/compiler/src/main/scala/aqua/compiler/package.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua
18 |
19 | import cats.data.{Chain, EitherT, NonEmptyChain, Writer}
20 |
21 | package object compiler {
22 |
23 | type CompileWarnings[S[_]] =
24 | [A] =>> Writer[Chain[AquaWarning[S]], A]
25 |
26 | type CompileResult[I, E, S[_]] =
27 | [A] =>> EitherT[CompileWarnings[S], NonEmptyChain[AquaError[I, E, S]], A]
28 | }
29 |
--------------------------------------------------------------------------------
/compiler/src/test/scala/aqua/compiler/FileIdString.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.compiler
18 |
19 | import aqua.semantics.FileId
20 |
21 | object FileIdString {
22 | given FileId[String] with {
23 | override def show(t: String): String = t
24 |
25 | override def compare(x: String, y: String): Int = x.compare(y)
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/integration-tests/.npmignore:
--------------------------------------------------------------------------------
1 | .idea
2 | .gitignore
3 | node_modules
4 | types
5 |
6 | src/
7 |
8 | tsconfig.json
9 | webpack.config.js
10 |
11 | bundle
12 | pkg
13 |
14 | .eslintignore
15 | .eslintrc.js
--------------------------------------------------------------------------------
/integration-tests/.prettierrc.cjs:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | semi: true,
3 | trailingComma: 'all',
4 | singleQuote: true,
5 | printWidth: 120,
6 | tabWidth: 4,
7 | useTabs: false,
8 | };
9 |
--------------------------------------------------------------------------------
/integration-tests/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2021 Fluence Labs
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 |
5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 |
7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/integration-tests/README.md:
--------------------------------------------------------------------------------
1 | # Aqua playground
2 |
3 | Repository demonstrating the how to start writing aqua and integrate it into a typescript application
4 |
5 | ## Getting started
6 |
7 | Install dependencies
8 |
9 | ```
10 | npm install
11 | ```
12 |
13 | To compile the aqua files execute
14 |
15 | ```
16 | npm run compile-aqua
17 | ```
18 |
19 | To start the `index.ts` execute
20 |
21 | ```
22 | npm run run
23 | ```
24 |
25 | To run all examples in `example` directory
26 | ```
27 | npm run exec
28 | ```
29 |
30 | If everything works correctly logs without errors will be printed on a screen:
31 |
32 | Then you can add or modify `aqua` files in `aqua` directory, these files will be compiled into `/src/compiled` and you can use it in a TypeScript in your preferable way.
33 |
34 | ## Project structure
35 |
36 | Aqua source files are located in `src/aqua`directory.
37 |
38 | Aqua files are compiled into .ts located in `/src/compiled` directory.
39 |
40 | Entry point to use aqua compiled files from TypeScript: `/src/index.ts`
41 |
42 | Code that call all examples and check results: `/src/run-examples.ts`
43 |
44 | ## References
45 |
46 | Documentation for the compiler can be found in the official repo: https://github.com/fluencelabs/aqua
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/abilitiesClosure.aqua:
--------------------------------------------------------------------------------
1 | aqua M
2 |
3 | export bugLNG314, bugLNG338
4 |
5 | ability WorkerJob:
6 | runOnSingleWorker(w: string) -> string
7 |
8 | func disjoint_run{WorkerJob}() -> -> string:
9 | run = func () -> string:
10 | r <- WorkerJob.runOnSingleWorker("worker")
11 | <- r
12 | <- run
13 |
14 | func runJob(j: -> string) -> string:
15 | <- j()
16 |
17 | func bugLNG314() -> string:
18 | job2 = () -> string:
19 | <- "strstrstr"
20 | worker_job = WorkerJob(runOnSingleWorker = job2)
21 | subnet_job <- disjoint_run{worker_job}()
22 | res <- runJob(subnet_job)
23 | <- res
24 |
25 | ability Compute:
26 | job() -> string
27 |
28 | func lift() -> Compute:
29 | job = () -> string:
30 | <- "job done"
31 | <- Compute(job)
32 |
33 | ability Function:
34 | run() -> string
35 |
36 | func roundtrip{Function}() -> string:
37 | res <- Function.run()
38 | <- res
39 |
40 | func disj{Compute}() -> Function:
41 | run = func () -> string:
42 | <- Compute.job()
43 | <- Function(run = run)
44 |
45 | func bugLNG338() -> string:
46 | comp = lift()
47 | fn = disj{comp}()
48 | res <- roundtrip{fn}()
49 | <- res
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/abilitiesClosureRename.aqua:
--------------------------------------------------------------------------------
1 | aqua AbilitiesClosureRename
2 |
3 | export bugLNG346
4 |
5 | ability Promise:
6 | yield() -> string
7 |
8 | func done_nil() -> string:
9 | <- ""
10 |
11 | func done() -> Promise:
12 | <- Promise(yield = done_nil)
13 |
14 | ability Compute:
15 | yield() -> string
16 |
17 | alias WorkerYield: -> string
18 | alias Yield: WorkerYield -> Promise
19 |
20 | func wait_for() -> Yield:
21 | wait = func (cb: -> string) -> Promise:
22 | yield = func () -> string:
23 | e <- cb()
24 | <- e
25 | <- Promise(yield = yield)
26 | <- wait
27 |
28 | ability Function:
29 | run(dealId: string) -> string
30 |
31 | func simple{Compute}(yield: Yield) -> Function:
32 | deal_run = func () -> string:
33 | c_yield = func () -> string:
34 | <- Compute.yield()
35 | yieeld <- yield(c_yield)
36 | res <- yieeld.yield()
37 | <- res
38 | <- Function(run = deal_run)
39 |
40 | func bugLNG346() -> string:
41 | res: *string
42 | yieeld = func () -> string:
43 | res <<- "hello"
44 | <- ""
45 | c = Compute(yield = yieeld)
46 | fn = simple{c}(wait_for())
47 | r <- fn.run("")
48 | <- res!
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/assignment.aqua:
--------------------------------------------------------------------------------
1 | aqua Assignment
2 |
3 | export doSmth
4 |
5 | data Prod:
6 | value: string
7 |
8 | service OpHa("op"):
9 | array(a: string, b: string) -> []string
10 | identity(a: string) -> string
11 |
12 | func doSmth(arg: Prod) -> []string:
13 | v = arg.value
14 | a <- OpHa.identity(v)
15 | b = "hello"
16 | res <- OpHa.array(a, b)
17 | <- res
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/callArrow.aqua:
--------------------------------------------------------------------------------
1 | aqua CallArrow
2 |
3 | export passFunctionAsArg, reproArgsBug426
4 |
5 | import "println.aqua"
6 | import "@fluencelabs/aqua-lib/builtin.aqua"
7 |
8 |
9 | -- functions like `c` are called an 'arrow function' in Aqua
10 | -- `c` passed to a function from a client, so, it could be called only on a client
11 | func passFunctionAsArg(node: string, str: string, c: string -> string):
12 | on node:
13 | Peer.identify()
14 | -- we go here back on a client
15 | res <- c(str)
16 | -- then return on a node
17 | Peer.identify()
18 | print(res)
19 |
20 | func reproArgsBug426(log: string -> (), arg: string):
21 | log(arg)
22 |
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/canon.aqua:
--------------------------------------------------------------------------------
1 | aqua Canon
2 |
3 | export Ser, bugLng79
4 |
5 | data Record:
6 | relay_id: []string
7 | peer_id: string
8 |
9 | service Ser("ser"):
10 | getRecord: -> Record
11 |
12 | func bugLng79(log: string -> ()) -> u32:
13 | stream: *Record
14 | stream <- Ser.getRecord()
15 | someone = stream[0]
16 | on someone.peer_id via someone.relay_id:
17 | a = 1 + 1
18 | <- a
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/closureArrowCapture.aqua:
--------------------------------------------------------------------------------
1 | aqua Test
2 |
3 | export test, TestServiceClosureArrowCapture
4 |
5 | service TestServiceClosureArrowCapture:
6 | call(s: string) -> string
7 |
8 | ability TestAbility:
9 | arrow(s: string) -> string
10 |
11 | func returnCapture() -> string -> string:
12 | TestServiceClosureArrowCapture "test-service"
13 |
14 | closure = (s: string) -> string:
15 | <- TestServiceClosureArrowCapture.call(s)
16 |
17 | closure1 = closure
18 | closure2 = closure1
19 | closure3 = closure2
20 |
21 | Ab = TestAbility(
22 | arrow = closure
23 | )
24 |
25 | capture = (s: string) -> string:
26 | s1 <- closure(s) -- capture closure
27 | s2 <- closure3(s1) -- capture renamed closure
28 | s3 <- Ab.arrow(s2) -- capture ability
29 | s4 <- TestServiceClosureArrowCapture.call(s3) -- capture service
30 | <- s4
31 |
32 | <- capture
33 |
34 | func test(s: string) -> string:
35 | capture <- returnCapture()
36 | <- capture(s)
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/closureStreamScopes.aqua:
--------------------------------------------------------------------------------
1 | aqua ClosureStreamScopes
2 |
3 | export simpleTest, complexTest
4 |
5 | ability Join:
6 | join1() -> []string
7 |
8 | ability Fork:
9 | fork() -> Join
10 |
11 | func simpleTest() -> []string:
12 |
13 | fork = () -> Join:
14 | in: *string
15 | join1 = () -> []string:
16 |
17 | in <<- "something in nested"
18 |
19 | <- ["result"]
20 | in <<- "something in"
21 | <- Join(join1)
22 | f = Fork(fork)
23 |
24 | j = f.fork()
25 | <- j.join1()
26 |
27 | func fork() -> Join:
28 | in: *string
29 | out: *string
30 | join1 = () -> []string:
31 | inJoin: *string
32 | for i <- in rec:
33 | inJoin <<- i
34 | for o <- out rec:
35 | inJoin <<- o
36 | join in!
37 | par join out!
38 | <- inJoin
39 | in <<- "something in INSIDE"
40 | out <<- "something out INSIDE"
41 | <- Join(join1)
42 |
43 | func complexTest() -> []string, []string:
44 | out: *string
45 | f = Fork(fork = fork)
46 | j <- f.fork()
47 | strs <- j.join1()
48 | out <<- "something out OUTSIDE"
49 | <- strs, out
50 |
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/co.aqua:
--------------------------------------------------------------------------------
1 | aqua Co
2 |
3 | export CoService, coFunc
4 |
5 | import "@fluencelabs/aqua-lib/builtin.aqua"
6 |
7 | service CoService("coservice-id"):
8 | call: -> string
9 |
10 | -- here we go to another node and not waiting for execution there
11 | -- all `ParService.call()` will be executed instantly
12 | func coFunc( node: string, c: Info -> () ):
13 | y <- CoService.call()
14 | on node:
15 | t <- Peer.identify()
16 | co c(t)
17 | x <- CoService.call()
18 |
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/collectionSugar.aqua:
--------------------------------------------------------------------------------
1 | aqua CollectionSugar
2 |
3 | export arraySugar, streamSugar, optionSugar, GetArr, bugLNG59
4 |
5 | import "@fluencelabs/aqua-lib/builtin.aqua"
6 |
7 | func arraySugar(n: u32, m: u32) -> []u32, []u32:
8 | arr = [1,2,n]
9 | str: *u32
10 | for i <- [4,5,m]:
11 | str <<- i
12 | <- arr, str
13 |
14 | func streamSugar(n: u32, m: u32) -> []u32, []u32:
15 | arr = *[1,2,n]
16 | str: *u32
17 | for i <- *[4,5,m]:
18 | str <<- i
19 | <- arr, str
20 |
21 | func optionSugar(numSome: ?u32, strSome: ?string, numNone: ?u32, strNone: ?string) -> []u32, []string, []string:
22 | arr = ?[numNone!, numSome!]
23 | str: *string
24 | str2 = ?[strNone!, strNone!, strNone!, strNone!, strNone!]
25 | for i <- ?[strSome!,strNone!, "random string"]:
26 | str <<- i
27 |
28 | for i <- ?[strNone!,strNone!]:
29 | str <<- i
30 | <- arr, str, str2
31 |
32 | service OpO("op"):
33 | identity: string -> string
34 |
35 | service GetArr("getArr"):
36 | getArr: -> []string
37 |
38 | func getNeighbours() -> []string:
39 | nodes <- GetArr.getArr()
40 | <- nodes
41 |
42 | func bugLNG59() -> string:
43 | nodes <- getNeighbours()
44 | n = nodes[1]
45 | on n via [HOST_PEER_ID]:
46 | res <- OpO.identity("some str")
47 | <- res
48 |
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/constants.aqua:
--------------------------------------------------------------------------------
1 | aqua Constants
2 |
3 | export Getter, callConstant, timestampAndTtl
4 |
5 | import "@fluencelabs/aqua-lib/builtin.aqua"
6 |
7 | service Getter("test"):
8 | createStr: u32 -> string
9 |
10 | service OpO("op"):
11 | identity: string -> string
12 |
13 | service OpN("op"):
14 | identity: i32 -> i32
15 |
16 | -- a question mark means that this constant could be rewritten before this definition
17 | const ANOTHER_CONST ?= "default-str"
18 | const UNIQUE_CONST ?= 5
19 |
20 | func callConstant() -> []string:
21 | res: *string
22 | res <- Getter.createStr(UNIQUE_CONST)
23 | res <- OpO.identity(ANOTHER_CONST)
24 | <- res
25 |
26 | func timestampAndTtl() -> u32, u64:
27 | Op.noop()
28 | <- PARTICLE_TTL, PARTICLE_TIMESTAMP
29 |
30 | const A = 2
31 | const B = -3
32 |
33 | func compareConstants():
34 | if A == B:
35 | OpN.identity(A)
36 | else:
37 | OpN.identity(B)
38 |
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/dataAlias.aqua:
--------------------------------------------------------------------------------
1 | aqua DataAlias
2 |
3 | export NodeIdGetter, getAliasedData
4 |
5 | -- set `PeerId` name to be a type alias for `string` type
6 | alias PeerId : string
7 |
8 | -- define data structure (ADT)
9 | data NodeId:
10 | peerId: PeerId
11 | name: string
12 |
13 | -- define service `NodeIdGetter` that will be callable on local client via `somesrv` service id
14 | service NodeIdGetter("somesrv"):
15 | get: -> NodeId
16 |
17 | -- showcases a function that gets data structure from a local service,
18 | -- and then retrieves aliased data type from that structure
19 | func getAliasedData() -> PeerId:
20 | res <- NodeIdGetter.get()
21 | <- res.peerId
22 |
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/errorClear.aqua:
--------------------------------------------------------------------------------
1 | aqua ErrorClear
2 |
3 | export errorClearTest, FailService
4 |
5 | service FailService("fail-srv"):
6 | call(s: string) -> string
7 |
8 | func errorClearTest(node: string, relay: string) -> string, i64:
9 | stream: *string
10 | code: *i64
11 |
12 | on node via relay:
13 | try:
14 | stream <- FailService.call("fail")
15 | otherwise:
16 | stream <- FailService.call("handle")
17 |
18 | code <<- LAST_ERROR.error_code
19 |
20 | <- stream!, code!
21 |
22 |
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/example.aqua:
--------------------------------------------------------------------------------
1 | aqua Example
2 |
3 | service Peer("peer"):
4 | is_connected: string -> bool
5 |
6 | service Op("op"):
7 | identity: -> ()
8 |
9 | data User:
10 | peer_id: string
11 | relay_id: string
12 | name: string
13 |
14 | service Test("test"):
15 | getUserList: -> []User
16 | doSomething: -> bool
17 |
18 | func betterMessage(relay: string):
19 | on relay:
20 | isOnline <- Peer.is_connected(relay)
21 | if isOnline:
22 | Test.doSomething()
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/fold.aqua:
--------------------------------------------------------------------------------
1 | aqua Fold
2 |
3 | export iterateAndPrint, iterateAndPrintParallel, forBug499
4 |
5 | import "println.aqua"
6 | import "@fluencelabs/aqua-lib/builtin.aqua"
7 |
8 | -- showcases `for` instruction that compiles to `fold` in AIR
9 | func iterateAndPrint(strings: []string):
10 | for s <- strings:
11 | print(s)
12 |
13 | func iterateAndPrintParallel(nodes: []string, c: Info -> ()):
14 | for s <- nodes par:
15 | on s:
16 | ads <- Peer.identify()
17 | c(ads)
18 |
19 | func to_i_64(i: u32) -> i64:
20 | <- i
21 |
22 | func forBug499() -> []i64:
23 | num = 5
24 | numbers: *i64
25 | for i <- [""]:
26 | ali64 <- to_i_64(num)
27 | numbers <<- ali64
28 | <- numbers
29 |
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/foldJoin.aqua:
--------------------------------------------------------------------------------
1 | aqua FoldJoin
2 |
3 | export getTwoResults
4 |
5 | import "@fluencelabs/aqua-lib/builtin.aqua"
6 |
7 | service Op2("op"):
8 | identity(s: u64)
9 |
10 | func getTwoResults(node: string) -> []u64:
11 | on node:
12 | nodes <- Kademlia.neighborhood(%init_peer_id%, nil, nil)
13 | res: *u64
14 | for n <- nodes par:
15 | on n:
16 | try:
17 | res <- Peer.timestamp_sec()
18 | join res!2
19 | <- res
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/func.aqua:
--------------------------------------------------------------------------------
1 | aqua Func
2 |
3 | export TestSrv, testFunc
4 |
5 | service TestSrv("test-service-id"):
6 | str: -> string
7 |
8 | func testFunc() -> string:
9 | res <- TestSrv.str()
10 | <- res
11 |
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/functors.aqua:
--------------------------------------------------------------------------------
1 | aqua Functors
2 |
3 | export lng119Bug
4 |
5 | func lng119Bug() -> []u32:
6 | nums = [1,2,3,4,5]
7 | results: *u32
8 | results <<- 1
9 | join results[nums.length-5]
10 | <- results
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/handleResultError.aqua:
--------------------------------------------------------------------------------
1 | aqua HandleResultError
2 |
3 | export handleResultError
4 |
5 | -- t = true, f = false
6 | func handleResultError(t: bool, f: bool) -> string:
7 | opt: *[]string
8 |
9 | if t == f: -- false
10 | opt <<- ["unreachable"]
11 | else:
12 | opt <<- nil
13 |
14 | result = opt!
15 |
16 | -- should fail
17 | <- result[0]
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/helloWorld.aqua:
--------------------------------------------------------------------------------
1 | aqua HelloWorld
2 |
3 | export StringExtra, helloWorld
4 |
5 | service StringExtra("service-id"):
6 | addNameToHello: string -> string
7 |
8 | func helloWorld(name: string) -> string:
9 | res <- StringExtra.addNameToHello(name)
10 | <- res
11 |
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/if.aqua:
--------------------------------------------------------------------------------
1 | aqua If
2 |
3 | export ifElseCall, ifElseNumCall, ifCorrectXorWrap, bugLNG69
4 |
5 | import "println.aqua"
6 | import "@fluencelabs/aqua-lib/builtin.aqua"
7 |
8 | service OpR("op"):
9 | identity(s: string) -> string
10 |
11 | func ifElseCall(condition: bool):
12 | if condition:
13 | Println.print("it is true")
14 | else:
15 | Println.print("it is false")
16 |
17 | func ifElseNumCall(condition: u32):
18 | if condition == 1:
19 | Println.print("it is 1")
20 | else:
21 | Println.print("it is not 1")
22 |
23 | func ifCorrectXorWrap(node: string) -> string:
24 | service_id: *string
25 | on node:
26 | res <- OpR.identity("1234")
27 | if res == "":
28 | service_id <<- "0x"
29 | else:
30 | service_id <<- "1x"
31 | <- service_id!
32 |
33 | func bugLNG69(other_node: PeerId) -> bool:
34 | on other_node:
35 | Op.noop()
36 |
37 | if false:
38 | Op.noop()
39 |
40 | <- true
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/ifPropagateErrors.aqua:
--------------------------------------------------------------------------------
1 | aqua IfPropagateErrors
2 |
3 | export ifPropagateErrors, TestService
4 |
5 | service TestService("test-srv"):
6 | call(s: string) -> string
7 |
8 | func ifPropagateErrors() -> []string:
9 | stream: *string
10 |
11 | a <- TestService.call("a")
12 | b <- TestService.call("b")
13 |
14 | try:
15 | if a == b || a == "a": -- true
16 | stream <- TestService.call("fail")
17 | else:
18 | stream <- TestService.call("else1")
19 | otherwise:
20 | stream <- TestService.call("otherwise1")
21 |
22 | try:
23 | if a != b: -- true
24 | stream <- TestService.call("fail")
25 | otherwise:
26 | stream <- TestService.call("otherwise2")
27 |
28 | try:
29 | if b == "b": --true
30 | if a == "a": -- true
31 | stream <- TestService.call("fail")
32 | else:
33 | stream <- TestService.call("else3")
34 | else:
35 | stream <- TestService.call("else4")
36 | otherwise:
37 | stream <- TestService.call("otherwise3")
38 |
39 | <- stream
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/imports_exports/declare.aqua:
--------------------------------------------------------------------------------
1 | aqua FooBars declares decl_foo, decl_bar, SuperFoo, DECLARE_CONST, DECLARE_CONST2
2 | export SuperFoo
3 |
4 | const DECLARE_CONST = "declare_const"
5 | const DECLARE_CONST2 = "declare_const2"
6 |
7 | service SuperFoo("super_foo"):
8 | small_foo() -> string
9 |
10 | func decl_foo() -> string:
11 | res1 <- SuperFoo.small_foo()
12 | <- res1
13 |
14 | func decl_bar() -> string:
15 | <- "declare all bar"
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/imports_exports/export2.aqua:
--------------------------------------------------------------------------------
1 | aqua Export declares foobar, foo
2 |
3 | import Op as Noop from "@fluencelabs/aqua-lib/builtin.aqua"
4 |
5 | func bar() -> string:
6 | <- " I am MyFooBar bar"
7 |
8 | func foo() -> string:
9 | <- "I am MyFooBar foo"
10 |
11 | func foobar() -> []string:
12 | Noop.noop()
13 | res: *string
14 | res <- foo()
15 | res <- bar()
16 | <- res
17 |
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/imports_exports/export3.aqua:
--------------------------------------------------------------------------------
1 | -- exports3.aqua
2 | aqua Export3 declares *
3 |
4 | import Op as Noop from "@fluencelabs/aqua-lib/builtin.aqua"
5 |
6 | func foo() -> string:
7 | Noop.noop()
8 | <- "I am MyFooBar foo"
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/imports_exports/exports.aqua:
--------------------------------------------------------------------------------
1 | aqua Exports declares some_string, MyExportSrv, EXPORT_CONST, some_random_func
2 |
3 | import Op as Noop from "@fluencelabs/aqua-lib/builtin.aqua"
4 |
5 | export some_string as string_from_lib
6 | export MyExportSrv
7 |
8 | const EXPORT_CONST = "export_const"
9 |
10 | service MyExportSrv("my_export_srv"):
11 | another_str() -> string
12 |
13 | func some_string() -> string:
14 | Noop.noop()
15 | <- "some_string_func"
16 |
17 | func some_random_func() -> string:
18 | <- "wow, so random"
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/imports_exports/gen/OneMore.aqua:
--------------------------------------------------------------------------------
1 | aqua OneMore declares OneMore
2 |
3 | service OneMore:
4 | more_call()
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/imports_exports/import2.aqua:
--------------------------------------------------------------------------------
1 | aqua Import
2 | import foobar from "export2.aqua"
3 |
4 | use foo as f from "export2.aqua" as Exp
5 |
6 | import "gen/OneMore.aqua"
7 |
8 | import OneMore as OM from "gen/OneMore.aqua"
9 |
10 | export foo_wrapper as wrap, foobar as barfoo
11 |
12 | func foo_wrapper() -> string:
13 | z <- Exp.f()
14 | OneMore "hello"
15 | OneMore.more_call()
16 | OM "ohmygod"
17 | OM.more_call()
18 | <- z
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/imports_exports/import3.aqua:
--------------------------------------------------------------------------------
1 | -- imports3.aqua
2 | aqua Import3 declares *
3 | import Op as Noop from "@fluencelabs/aqua-lib/builtin.aqua"
4 |
5 | export foo_wrapper
6 |
7 | use "export3.aqua"
8 |
9 | func foo_wrapper() -> string:
10 | Noop.noop()
11 | z <- Export3.foo()
12 | <- z
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/imports_exports/imports-empty.aqua:
--------------------------------------------------------------------------------
1 | aqua ImportsEmpty
2 |
3 | import decl_foo, decl_bar from "declare.aqua"
4 | use DECLARE_CONST, SuperFoo, DECLARE_CONST2 as DC2 from "declare.aqua" as Declare
5 | import Op as Noop from "@fluencelabs/aqua-lib/builtin.aqua"
6 | import some_string, MyExportSrv, EXPORT_CONST, some_random_func from "exports.aqua"
7 |
8 | export some_string as some_str, some_random_func, MyExportSrv, EXPORT_CONST
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/imports_exports/imports.aqua:
--------------------------------------------------------------------------------
1 | aqua Imports
2 |
3 | export StringService, concat_foobars
4 |
5 | import decl_foo, decl_bar from "declare.aqua"
6 | use DECLARE_CONST, SuperFoo, DECLARE_CONST2 as DC2 from "declare.aqua" as Declare
7 | import Op as Noop from "@fluencelabs/aqua-lib/builtin.aqua"
8 | import some_string, MyExportSrv, EXPORT_CONST from "exports.aqua"
9 | use "export3.aqua"
10 |
11 | service StringService("string_service"):
12 | concat(a: string, b: string) -> string
13 |
14 | func concat_foobars() -> string:
15 | Noop.noop()
16 | Export3.foo()
17 | res1 <- decl_foo()
18 | res2 <- decl_bar()
19 | res3 <- StringService.concat(res1, res2)
20 | res4 <- Declare.SuperFoo.small_foo()
21 | Noop.noop()
22 | res5 <- StringService.concat(res3, res4)
23 | res6 <- StringService.concat(res5, EXPORT_CONST)
24 | res7 <- StringService.concat(res6, Declare.DECLARE_CONST)
25 | Noop.noop()
26 | res8 <- StringService.concat(res7, Declare.DC2)
27 | <- res8
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/imports_exports/modules/libA.aqua:
--------------------------------------------------------------------------------
1 | aqua LibA.SubA declares f
2 |
3 | func f() -> i32:
4 | <- 37
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/imports_exports/modules/libAB.aqua:
--------------------------------------------------------------------------------
1 | aqua LibAB declares LibA, LibB
2 |
3 | use "libA"
4 | use "libB"
5 |
6 |
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/imports_exports/modules/libB.aqua:
--------------------------------------------------------------------------------
1 | aqua LibB.SubB declares g
2 |
3 | func g() -> i32:
4 | <- 73
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/imports_exports/modules/libExport.aqua:
--------------------------------------------------------------------------------
1 | aqua Export.Me.Please declares exp
2 |
3 | func exp() -> i32:
4 | <- 7
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/imports_exports/modules/libMerge.aqua:
--------------------------------------------------------------------------------
1 | aqua Merge declares Lib
2 |
3 | use "libSubA"
4 | use "libSubB"
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/imports_exports/modules/libRename.aqua:
--------------------------------------------------------------------------------
1 | aqua Rename declares AB
2 |
3 | use LibA as A, LibB as B from "libAB" as AB
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/imports_exports/modules/libSubA.aqua:
--------------------------------------------------------------------------------
1 | aqua Lib.Sub.A declares f
2 |
3 | func f() -> i32:
4 | <- 42
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/imports_exports/modules/libSubB.aqua:
--------------------------------------------------------------------------------
1 | aqua Lib.Sub.B declares g
2 |
3 | func g() -> i32:
4 | <- 24
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/imports_exports/modules/main.aqua:
--------------------------------------------------------------------------------
1 | aqua Main
2 |
3 | use "libMerge" as M
4 | use "libRename" as R
5 | use "libExport"
6 |
7 | export merged
8 | export renamed
9 | export Export.Me.Please.exp as exported
10 |
11 | func merged() -> i32:
12 | <- M.Lib.Sub.A.f() + M.Lib.Sub.B.g()
13 |
14 | func renamed() -> i32:
15 | <- R.AB.A.SubA.f() + R.AB.B.SubB.g()
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/imports_exports/subImport.aqua:
--------------------------------------------------------------------------------
1 | aqua SubImport declares *
2 |
3 | alias SomeString : string
4 |
5 | data SomeResult:
6 | one: SomeString
7 | two: u32
8 |
9 | service SubService("sub_service"):
10 | sub(s: SomeString) -> SomeResult
11 |
12 | func subImport() -> SomeResult:
13 | res <- SubService.sub("some thing")
14 | <- res
15 |
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/join.aqua:
--------------------------------------------------------------------------------
1 | aqua Join
2 |
3 | export joinIdxLocal, joinIdxRelay, joinIdx
4 |
5 | import "@fluencelabs/aqua-lib/builtin.aqua"
6 |
7 | func joinIdxLocal(idx: i16, nodes: []string) -> []string:
8 | nodes2: *string
9 | for node <- nodes par:
10 | nodes2 <<- node
11 | join nodes2[idx], nodes
12 | <- nodes2
13 |
14 | func joinIdxRelay(idx: i16, nodes: []string) -> []string:
15 | on HOST_PEER_ID:
16 | nodes2: *string
17 | for node <- nodes par:
18 | nodes2 <<- node
19 | join nodes2[idx], nodes
20 | <- nodes2
21 |
22 | func joinIdx(idx: i16, nodes: []string) -> []Info:
23 | infos: *Info
24 | nodes2: *string
25 | for node <- nodes par:
26 | on node:
27 | infos <- Peer.identify()
28 | nodes2 <<- node
29 | join infos[idx-1+1], nodes2[idx-1+1]
30 | <- infos
31 |
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/multiReturn.aqua:
--------------------------------------------------------------------------------
1 | aqua MultiReturn
2 |
3 | export GetStr, GetNum, multiReturnFunc
4 |
5 | import "@fluencelabs/aqua-lib/builtin.aqua"
6 |
7 | service GetStr("multiret-test"):
8 | retStr: string -> string
9 |
10 | service GetNum("multiret-num"):
11 | retNum: -> u8
12 |
13 | const SOME_NUM = 5
14 | const SOME_STR = "some-str"
15 |
16 | func tupleFunc() -> string, u8:
17 | str <- GetStr.retStr(SOME_STR)
18 | n <- GetNum.retNum()
19 | <- str, n
20 |
21 | func multiReturnFunc(somethingToReturn: []u8, smthOption: ?string) -> []string, u8, string, []u8, ?string, u8 :
22 | res: *string
23 | res <- GetStr.retStr(SOME_STR)
24 | res <- GetStr.retStr("random-str")
25 | res, tNum <- tupleFunc()
26 | <- res, SOME_NUM, SOME_STR, somethingToReturn, smthOption, tNum
27 |
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/nestedData.aqua:
--------------------------------------------------------------------------------
1 | aqua NestedData
2 |
3 | export Test, test
4 |
5 | data NestedType:
6 | val: string
7 |
8 | data NestedStruct:
9 | one: NestedType
10 |
11 | service Test("service"):
12 | test1() -> NestedStruct
13 | test2(arg1: NestedType, arg2: string) -> NestedStruct
14 |
15 | func test3() -> NestedType:
16 | res <- Test.test1()
17 | <- res.one
18 |
19 | func test() -> NestedStruct:
20 | struct <- test3()
21 | res <- Test.test2(struct, struct.val)
22 | <- res
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/nestedFuncs.aqua:
--------------------------------------------------------------------------------
1 | aqua NestedFuncs
2 |
3 | export OpH, d
4 |
5 | import "@fluencelabs/aqua-lib/builtin.aqua"
6 |
7 | service OpH("opa"):
8 | identity(s: string) -> string
9 |
10 | func a(b: string) -> string:
11 | c <- OpH.identity(b)
12 | <- c
13 |
14 | func d(e: string) -> string:
15 | f <- a(e)
16 | <- f
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/on.aqua:
--------------------------------------------------------------------------------
1 | aqua On
2 |
3 | export getPeerExternalAddresses
4 |
5 | import "@fluencelabs/aqua-lib/builtin.aqua"
6 |
7 | func getPeerExternalAddresses(otherNodePeerId: string) -> []string:
8 | on otherNodePeerId:
9 | res <- Peer.identify()
10 | <- res.external_addresses
11 |
12 | -- it is possible to use `via` to built complex routes
13 | func getDistantAddresses(target: string, viaNode: string) -> []string:
14 | on target via viaNode:
15 | res <- Peer.identify()
16 | <- res.external_addresses
17 |
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/onErrorPropagation.aqua:
--------------------------------------------------------------------------------
1 | aqua OnErrorPropagation
2 |
3 | export Test, onPropagate, nestedOnPropagate, seqOnPropagate
4 |
5 | service Test("test-service"):
6 | fail(err: string)
7 |
8 | func onPropagate(peer: string, relay: string) -> u16:
9 | res: *u16
10 | on peer via relay:
11 | res <<- 0 + 1
12 | Test.fail("propagated error")
13 | res <<- 0 + 2
14 |
15 | join res[3] -- Unreachable
16 |
17 | <- res[3]
18 |
19 | func nestedOnPropagate(peer: string, relay: string, iPeer: string, iRelay: string, friend: string) -> u16:
20 | res: *u16
21 | on iPeer via iRelay:
22 | res <<- 40 + 2
23 | on friend:
24 | res <<- 2 + 40
25 | on peer via relay:
26 | Test.fail("propagated error")
27 | res <<- 30 + 7
28 |
29 | join res[3] -- Unreachable
30 |
31 | <- res[3]
32 |
33 | func seqOnPropagate(peer: string, relay: string, iPeer: string, iRelay: string) -> u16:
34 | res: *u16
35 | on iPeer via iRelay:
36 | res <<- 40 + 2
37 | on peer via relay:
38 | Test.fail("propagated error")
39 | res <<- 30 + 7
40 |
41 | join res[2] -- Unreachable
42 |
43 | <- res[2]
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/option.aqua:
--------------------------------------------------------------------------------
1 | aqua Option
2 |
3 | export SomeS, useOptional, returnOptional, returnNone, getDefault, getArg
4 |
5 | import "@fluencelabs/aqua-lib/builtin.aqua"
6 |
7 | service SomeS("test2"):
8 | getStr: ?string -> ?string
9 | getStr1: -> ?string
10 | getStr2: string -> string
11 | checkU32(u: ?u32)
12 |
13 | func checkU32AndU8(a: ?u8):
14 | SomeS.checkU32(a)
15 |
16 | func useOptional(opt: ?string) -> string:
17 | res <- SomeS.getStr(opt)
18 | for i <- opt:
19 | SomeS.getStr2(i)
20 | <- res!
21 |
22 | func returnOptional() -> ?string:
23 | res <- SomeS.getStr1()
24 | <- res
25 |
26 | func returnNone() -> ?string:
27 | result: *string
28 | Op.noop()
29 | <- result
30 |
31 | func reward(amount: ?u32) -> u32:
32 | result = ?[amount! / 10, 42]
33 | <- result!
34 |
35 | func getArg(a: u32) -> u32:
36 | <- reward(?[a])
37 |
38 | func getDefault() -> u32:
39 | <- reward(?[])
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/options/option_gen.aqua:
--------------------------------------------------------------------------------
1 | aqua OptionGen
2 |
3 | export OptionString, emptyString, checkEmpty, checkNoneEmpty
4 |
5 | service OptionString("opt_str"):
6 | checkOption(str: ?string) -> string
7 |
8 | func emptyString() -> ?string:
9 | valueEmpty: *string
10 | <- valueEmpty
11 |
12 | func checkEmpty() -> string:
13 | empty <- emptyString()
14 | res <- OptionString.checkOption(empty)
15 | <- res
16 |
17 | func stringAsOption(str: string) -> ?string:
18 | valueEmpty: *string
19 | valueEmpty <<- str
20 | <- valueEmpty
21 |
22 | func checkNoneEmpty(str: string) -> string:
23 | nonEmpty <- stringAsOption(str)
24 | res <- OptionString.checkOption(nonEmpty)
25 | <- res
26 |
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/par.aqua:
--------------------------------------------------------------------------------
1 | aqua Par
2 |
3 | export ParService, parFunc, testTimeout
4 |
5 | import "@fluencelabs/aqua-lib/builtin.aqua"
6 |
7 | service ParService("parservice-id"):
8 | call: -> string
9 |
10 | -- here we go to another node and not waiting for execution there
11 | -- all `ParService.call()` will be executed instantly
12 | func parFunc( node: string, c: Info -> () ):
13 | y <- ParService.call()
14 | par on node:
15 | t <- Peer.identify()
16 | c(t)
17 | par x <- ParService.call()
18 |
19 | func testTimeout(nodes: []string) -> string:
20 | on HOST_PEER_ID:
21 |
22 | results: *Info
23 |
24 | for node <- nodes par:
25 | on node:
26 | results <- Peer.identify()
27 |
28 | timeout: *string
29 | join results[999]
30 | par timeout <- Peer.timeout(400, "timeout")
31 |
32 | status: *string
33 | if timeout == nil:
34 | status <<- "ok"
35 | else:
36 | status <<- timeout!
37 |
38 | <- status!
39 |
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/parseq.aqua:
--------------------------------------------------------------------------------
1 | aqua ParSeq
2 |
3 | export testParSeq
4 |
5 | import "@fluencelabs/aqua-lib/builtin.aqua"
6 |
7 | func testParSeq(relay1: string, relay2: string, relay3: string) -> string:
8 | relays = [relay1, relay2, relay3]
9 | stream: *u64
10 | stream2: *u64
11 | parseq r <- relays on r:
12 | stream <- Peer.timestamp_ms()
13 |
14 | for r <- relays par:
15 | on r:
16 | join stream[relays.length - 1]
17 | stream2 <<- Peer.timestamp_ms()
18 |
19 | join stream2[relays.length - 1]
20 | <- "ok"
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/passArgs.aqua:
--------------------------------------------------------------------------------
1 | aqua PassArgs
2 |
3 | export AquaDHT, create_client_util, bugLNG60
4 |
5 | import Op from "@fluencelabs/aqua-lib/builtin.aqua"
6 |
7 | service AquaDHT("test-dht"):
8 | put_host_value(key: string, value: string, service_id: []string) -> string
9 |
10 | func putHostValue(key: string, value: string, service_id: ?string) -> string:
11 | res <- AquaDHT.put_host_value(key, value, service_id)
12 | <- res
13 |
14 | func create_client_util(service_id: string) -> string:
15 | res <- putHostValue("client-util", service_id, nil)
16 | <- res
17 |
18 | func wait(successful: *bool, n: i16):
19 | join successful[n - 1]
20 |
21 | func bugLNG60(node: string) -> bool:
22 | successful: *bool
23 | nodes = [node]
24 | for n <- nodes:
25 | successful <<- true
26 |
27 | wait(successful, 1)
28 | <- true
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/println.aqua:
--------------------------------------------------------------------------------
1 | aqua Println declares *
2 |
3 | export Println, print
4 |
5 | service Println("println-service-id"):
6 | print: string -> ()
7 |
8 | func print(str: string):
9 | Println.print(str)
10 |
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/pushToStream.aqua:
--------------------------------------------------------------------------------
1 | aqua PushToStream
2 |
3 | export OpA, get_results
4 |
5 | service OpA("pop"):
6 | get_str() -> string
7 |
8 | func get_results() -> []string:
9 | results: *string
10 | results <<- "hello"
11 | str <- OpA.get_str()
12 | results <<- str
13 | <- results
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/recursiveStreams/multiRec.aqua:
--------------------------------------------------------------------------------
1 | aqua MultiRec
2 |
3 | export TestServiceMultiRec, multiRecStream
4 |
5 | service TestServiceMultiRec("test-srv"):
6 | handle(i: i32) -> []i32
7 |
8 | func multiRecStream(init: i32, target: i32) -> []i32:
9 | result: *string
10 | loop: *i32
11 |
12 | loop <<- init
13 | for l <- loop rec:
14 | news <- TestServiceMultiRec.handle(l)
15 | for n <- news:
16 | loop <<- n
17 | if l == target:
18 | result <<- "done"
19 |
20 | join result!
21 |
22 | <- loop
23 |
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/recursiveStreams/nested.aqua:
--------------------------------------------------------------------------------
1 | aqua Nested
2 |
3 | export nested
4 |
5 | func nested(n: u32) -> []u32:
6 | result: *u32
7 | iterator: *u32
8 |
9 | iterator <<- 0
10 | for i <- iterator rec:
11 | if i < n:
12 | for j <- iterator rec:
13 | result <<- j
14 | iterator <<- i + 1
15 |
16 | if n > 0:
17 | join result[n * (n + 1) / 2 - 1]
18 |
19 | <- result
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/recursiveStreams/pipeline.aqua:
--------------------------------------------------------------------------------
1 | aqua Pipeline
2 |
3 | export pipelineStream
4 |
5 | func pipelineStream(init: i32, target: i32) -> []i32:
6 | result: *string
7 |
8 | loop1: *i32
9 | loop2: *i32
10 | loop3: *i32
11 |
12 | loop1 <<- init
13 | for l <- loop1 rec:
14 | if l < target:
15 | loop1 <<- l + 1
16 | loop2 <<- l * 3
17 |
18 | for l <- loop2 rec:
19 | loop3 <<- l
20 | loop3 <<- l + 1
21 | loop3 <<- l + 2
22 |
23 | for l <- loop3 rec:
24 | if l == target:
25 | result <<- "success"
26 |
27 | join result!
28 |
29 | <- loop3
30 |
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/recursiveStreams/range.aqua:
--------------------------------------------------------------------------------
1 | aqua Range
2 |
3 | export range
4 |
5 | func range(a: i32, b: i32) -> []i32:
6 | result: *i32
7 | iterator: *i32
8 |
9 | iterator <<- a
10 | for i <- iterator rec:
11 | if i < b:
12 | result <<- i
13 | iterator <<- i + 1
14 |
15 | if b > a:
16 | join result[b - a - 1]
17 |
18 | <- result
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/recursiveStreams/remoteRec.aqua:
--------------------------------------------------------------------------------
1 | aqua RemoteRec
2 |
3 | export RemoteSrv, remoteRecStream
4 |
5 | service RemoteSrv("remote-srv"):
6 | handle(i: i32) -> i32
7 |
8 | func remoteRecStream(init: i32, target: i32, friend: string, friendRelay: string) -> []i32:
9 | loop: *i32
10 |
11 | loop <<- init
12 | for l <- loop rec:
13 | on friend via friendRelay:
14 | if l < target:
15 | loop <- RemoteSrv.handle(l)
16 |
17 | join loop[target - init]
18 |
19 | <- loop
20 |
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/recursiveStreams/yesNo.aqua:
--------------------------------------------------------------------------------
1 | aqua YesNo
2 |
3 | export YesNoService, yesNoStream
4 |
5 | service YesNoService("yesno"):
6 | get() -> string
7 |
8 | func yesNoStream() -> []string:
9 | result: *string
10 | loop: *string
11 |
12 | loop <<- "yes"
13 | for l <- loop rec:
14 | if l == "yes":
15 | loop <- YesNoService.get()
16 | else:
17 | result <<- "success"
18 |
19 | join result!
20 |
21 | <- loop
22 |
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/redeclare/import.aqua:
--------------------------------------------------------------------------------
1 | aqua Import declares someFunc
2 |
3 | func someFunc() -> string:
4 | <- "some func"
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/redeclare/redeclare.aqua:
--------------------------------------------------------------------------------
1 | aqua Redeclare declares someFunc
2 |
3 | import someFunc from "import.aqua"
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/redeclare/useDeclare.aqua:
--------------------------------------------------------------------------------
1 | aqua UseDeclare declares someFunc
2 |
3 | import someFunc from "redeclare.aqua"
4 |
5 | export someFunc
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/renameVars.aqua:
--------------------------------------------------------------------------------
1 | aqua RenameVars
2 |
3 | export rename_s
4 |
5 | func append_func(s: *string):
6 | s <<- "ok"
7 |
8 | func append(s: string, closure: *string -> ()) -> *string:
9 | status: *string
10 |
11 | append_func(status)
12 | closure(status)
13 |
14 | <- status
15 |
16 | func rename_s() -> []string:
17 | on HOST_PEER_ID:
18 | append_closure = (s: *string):
19 | s <<- "ok"
20 | -- s inside append_func and append_closure
21 | -- are not related to this s and should be
22 | -- renamed to `status` and not `s-`
23 | s = "s"
24 | res <- append(s, append_closure)
25 | <- res
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/returnArrow.aqua:
--------------------------------------------------------------------------------
1 | aqua ReturnArrow
2 |
3 | export callReturnedArrow, callReturnedChainArrow
4 |
5 | import "@fluencelabs/aqua-lib/builtin.aqua"
6 |
7 | func returnCall(arg: string) -> string -> string, string:
8 | str <- Op.concat_strings(arg, " literal")
9 | closure = (s: string) -> string, string:
10 | <- s, Op.concat_strings(s, str)
11 | <- closure
12 |
13 | func callReturnedArrow(argForFunc: string, argForClosure: string) -> string, string:
14 | a = returnCall(argForFunc)
15 | b, c <- a(argForClosure)
16 | <- b, c
17 |
18 | func secondReturnCall(arg: string) -> (string -> string, string), (string -> string, string), (string -> string, string):
19 | str <- Op.concat_strings(arg, " second literal")
20 | closure = (s: string) -> string, string:
21 | <- s, Op.concat_strings(s, str)
22 | b = closure
23 | a = returnCall(" from second")
24 | <- b, closure, a
25 |
26 | func callReturnedChainArrow(argForFirst: string, argForSecond: string) -> string, string, string, string, string, string, string, string:
27 | first = returnCall(argForFirst)
28 | second, third, fourth <- secondReturnCall(argForSecond)
29 | a, b <- first("first")
30 | c, d <- second("second")
31 | e, f <- third("third")
32 | g, h <- fourth("fourth")
33 | <- a, b, c, d, e, f, g, h
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/returnLiteral.aqua:
--------------------------------------------------------------------------------
1 | aqua ReturnLiteral
2 |
3 | export returnLiteral
4 |
5 | func returnLiteral() -> string:
6 | <- "some literal"
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/streamCallback.aqua:
--------------------------------------------------------------------------------
1 | aqua Ret declares *
2 |
3 | export someFunc
4 |
5 | func someFunc(cb: []string -> ()):
6 | ifaces: *string
7 | cb(ifaces)
8 |
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/streamCan.aqua:
--------------------------------------------------------------------------------
1 | aqua StreamCan
2 |
3 | export accumRes, bugLNG63, bugLNG63_2, bugLNG63_3
4 |
5 | func toOpt(s: string) -> ?string:
6 | str: *string
7 | str <<- s
8 | <- str
9 |
10 | func accumRes() -> *?string:
11 | res_accum: *?string
12 | a <- toOpt("a")
13 | res_accum <<- a
14 | res_accum <- toOpt("b")
15 | res_accum <<- nil
16 | <- res_accum
17 |
18 | func returnCanStream() -> string:
19 | status: *string
20 | status <<- "ok"
21 | stat = status!
22 | <- stat
23 |
24 | service Op1("op"):
25 | array_length(array: []string) -> u32
26 |
27 | func bugLNG63() -> string:
28 | res <- returnCanStream()
29 | <- res
30 |
31 | func returnMultipleStreamResults() -> string, []string, []string, []string:
32 | status: *string
33 | status <<- "ok"
34 | stat = status!
35 | <- stat, status, [status!, stat], [status!, "no", status!]
36 |
37 | func bugLNG63_2() -> string, []string, []string:
38 | res, res2, res3, res4 <- returnMultipleStreamResults()
39 | <- res, res2, res4
40 |
41 | func bugLNG63_3() -> string, u32, []u32:
42 | status: *string
43 | status <<- "ok"
44 | stat = status!
45 | num: *u32
46 | num <<- 2
47 | res = [Op1.array_length(status), num!]
48 | <- status!, Op1.array_length(status), [Op1.array_length(status), 3, num!]
49 |
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/streamCapture.aqua:
--------------------------------------------------------------------------------
1 | aqua StreamCapture
2 |
3 | export testStreamCaptureSimple, testStreamCaptureReturn
4 |
5 | -- SIMPLE
6 |
7 | func useCaptureSimple(push: string -> ()):
8 | push("two")
9 |
10 | func testStreamCaptureSimple() -> []string:
11 | stream: *string
12 |
13 | stream <<- "one"
14 |
15 | push = (s: string):
16 | stream <<- s
17 |
18 | useCaptureSimple(push)
19 | push("three")
20 |
21 | <- stream
22 |
23 | -- RETURN
24 |
25 | func captureStream() -> (string -> []string):
26 | stream: *string
27 |
28 | stream <<- "one"
29 |
30 | capture = (s: string) -> []string:
31 | stream <<- s
32 | <- stream
33 |
34 | capture("two")
35 |
36 | <- capture
37 |
38 | func useCaptureReturn(capture: string -> []string):
39 | capture("three")
40 |
41 | func rereturnCapture() -> (string -> []string):
42 | capture <- captureStream()
43 | useCaptureReturn(capture)
44 | capture("four")
45 | <- capture
46 |
47 | func testStreamCaptureReturn() -> []string:
48 | on HOST_PEER_ID:
49 | capture <- rereturnCapture()
50 | <- capture("five")
51 |
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/streamMapAbilities.aqua:
--------------------------------------------------------------------------------
1 | aqua StreamMapAbilities
2 |
3 | export streamMapAbilityTest
4 |
5 | ability Streams:
6 | stream: *string
7 | map: %string
8 |
9 | ability Adds:
10 | addToStream(s: string)
11 | addToMap(k: string, v: string)
12 |
13 | func addToStreamClosure(str: *string) -> string -> ():
14 | cl = func (s: string):
15 | str <<- s
16 | <- cl
17 |
18 | func addToMapClosure(str: %string) -> string, string -> ():
19 | cl = func (k: string, v: string):
20 | str <<- k, v
21 | <- cl
22 |
23 | func addTo{Streams}() -> Adds:
24 | addStream = addToStreamClosure(Streams.stream)
25 | addMap = addToMapClosure(Streams.map)
26 | adds = Adds(addToStream = addStream, addToMap = addMap)
27 | <- adds
28 |
29 | func add{Adds}(s: string, k: string):
30 | Adds.addToStream(s)
31 | Adds.addToMap(k, k)
32 |
33 | func streamMapAbilityTest() -> []string, []string:
34 | stream: *string
35 | map: %string
36 | ab = Streams(stream = stream, map = map)
37 | adds <- addTo{ab}()
38 | add{adds}("one", "1")
39 | add{adds}("two", "2")
40 | add{adds}("three", "3")
41 | <- stream, map.keys()
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/streamMapCapture.aqua:
--------------------------------------------------------------------------------
1 | aqua StreamMapCapture
2 |
3 | export testStreamMapCaptureSimple, testStreamMapCaptureReturn
4 |
5 | -- SIMPLE
6 |
7 | func useCaptureSimple(push: string, string -> ()):
8 | push("two", "2")
9 |
10 | func testStreamMapCaptureSimple() -> []string:
11 | stream: %string
12 |
13 | stream <<- "one", "1"
14 |
15 | push = (s: string, n: string):
16 | stream <<- s, n
17 |
18 | useCaptureSimple(push)
19 | push("three", "3")
20 |
21 | <- stream.keys()
22 |
23 | -- RETURN
24 |
25 | func captureStream() -> (string, string -> []string):
26 | stream: %string
27 |
28 | stream <<- "one", "1"
29 |
30 | capture = (s: string, n: string) -> []string:
31 | stream <<- s, n
32 | <- stream.keys()
33 |
34 | capture("two", "2")
35 |
36 | <- capture
37 |
38 | func useCaptureReturn(capture: string, string -> []string):
39 | capture("three", "3")
40 |
41 | func rereturnCapture() -> (string, string -> []string):
42 | capture <- captureStream()
43 | useCaptureReturn(capture)
44 | capture("four", "4")
45 | <- capture
46 |
47 | func testStreamMapCaptureReturn() -> []string:
48 | on HOST_PEER_ID:
49 | capture <- rereturnCapture()
50 | <- capture("five", "5")
51 |
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/streamMapRestriction.aqua:
--------------------------------------------------------------------------------
1 | aqua StreamRestriction
2 |
3 | export streamMapRes
4 |
5 | func streamMapFold(arr: []string) -> %string:
6 | res: %string
7 | for n <- arr:
8 | res <<- n, n
9 | <- res
10 |
11 | func streamMapRes(arr: []string) -> []string, []string:
12 | res: %string
13 | res2 <- streamMapFold(arr)
14 | <- res.keys(), res2.keys()
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/streamRestriction.aqua:
--------------------------------------------------------------------------------
1 | aqua StreamRestriction
2 |
3 | export streamFold, streamRes
4 |
5 | func streamFold(arr: []string) -> []string:
6 | res: *string
7 | for n <- arr:
8 | res <<- n
9 | <- res
10 |
11 | func streamRes(arr: []string) -> []string, []string:
12 | res: *string
13 | res2 <- streamFold(arr)
14 | <- res, res2
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/streamResults.aqua:
--------------------------------------------------------------------------------
1 | aqua StreamResults
2 |
3 | export DTGetter, use_name1, use_name2
4 |
5 | data DT:
6 | field: string
7 |
8 | service DTGetter("get-dt"):
9 | get_dt(s: string) -> DT
10 |
11 | func use_name1(name: string) -> string:
12 | results <- DTGetter.get_dt(name)
13 | <- results.field
14 |
15 | func use_name2(name: string) -> []string:
16 | results: *string
17 | results <- use_name1(name)
18 | results <- use_name1(name)
19 | results <- use_name1(name)
20 | <- results
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/streamReturn.aqua:
--------------------------------------------------------------------------------
1 | aqua StreamReturn
2 |
3 | export testReturnStream
4 |
5 | func returnStream() -> *string:
6 | stream: *string
7 | stream <<- "one"
8 | <- stream
9 |
10 | func useStream(stream: *string) -> *string:
11 | stream <<- "two"
12 | <- stream
13 |
14 | func rereturnStream() -> *string:
15 | stream <- returnStream()
16 | useStream(stream)
17 | stream <<- "three"
18 | <- stream
19 |
20 | func testReturnStream() -> []string:
21 | on HOST_PEER_ID:
22 | stream <- rereturnStream()
23 | stream <<- "four"
24 | <- stream
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/structuraltyping.aqua:
--------------------------------------------------------------------------------
1 | aqua Aaa
2 |
3 | export structuralTypingTest
4 |
5 | import "@fluencelabs/aqua-lib/builtin.aqua"
6 |
7 | data WideData:
8 | s: string
9 | n: u32
10 |
11 | data ExactData:
12 | s: string
13 |
14 | ability ExactAbility:
15 | s: string
16 | arr(s: string, s2: string, s3: string, s4: string) -> string
17 | exact: ExactData
18 |
19 | ability WideAbility:
20 | s: string
21 | arr(s: string, s2: string, s3: string, s4: string) -> string
22 | g: string
23 | exact: WideData
24 |
25 | func ss(s1: string, s2: string, s3: string, s4: string) -> string:
26 | <- Op.concat_strings(Op.concat_strings(Op.concat_strings(s1, s2), s3), s4)
27 |
28 | func main{ExactAbility}(someData: ExactData, secondData: ExactData) -> string:
29 | <- ExactAbility.arr(someData.s, ExactAbility.exact.s, secondData.s, ExactAbility.s)
30 |
31 | func structuralTypingTest() -> string:
32 | wd = WideData(s = "some_string", n = 32)
33 |
34 | WAbility = WideAbility(s = "ab_string", g = "", arr = ss, exact = wd)
35 | <- main{WAbility}(wd, WAbility.exact)
36 |
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/subImportUsage.aqua:
--------------------------------------------------------------------------------
1 | aqua SubImportUsage
2 |
3 | export subImportUsage, ConcatSubs
4 |
5 | import "imports_exports/subImport.aqua"
6 |
7 | service ConcatSubs("concat_subs"):
8 | get_some(s: SomeString, sr: SomeResult) -> SomeResult
9 |
10 | func subImportUsage(s: SomeString) -> SomeResult:
11 | sr1 <- SubService.sub(s)
12 | sr2 <- subImport()
13 | result <- ConcatSubs.get_some(sr1.one, sr2)
14 | <- result
15 |
16 |
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/topbottom.aqua:
--------------------------------------------------------------------------------
1 | aqua TopBottom
2 |
3 | export S, topBottom
4 |
5 | -- this file should just compile
6 |
7 | service S(""):
8 | top(t: ⊤) -> ⊤
9 | bottom(b: ⊥) -> ⊥
10 |
11 | func topBottom(t: ⊤, b: ⊥) -> ⊤, ⊥:
12 | <- S.top(t), S.bottom(b)
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/tryCatch.aqua:
--------------------------------------------------------------------------------
1 | aqua TryCatch
2 |
3 | export tryCatchTest
4 |
5 | import "@fluencelabs/aqua-lib/builtin.aqua"
6 |
7 | service Unexisted("unex"):
8 | getStr() -> string
9 |
10 | data LastError:
11 | instruction: string
12 | message: string
13 | peer_id: string
14 |
15 | service OpA("op"):
16 | identity(s: string) -> string
17 |
18 | func tryCatchTest(node_id: string) -> []string:
19 | on node_id:
20 | f: *string
21 | try:
22 | f <- Unexisted.getStr()
23 | catch err:
24 | c: *string
25 | f <- OpA.identity(err.message)
26 | -- check if the call takes place on the node
27 | i <- Peer.identify()
28 | f <- OpA.identity(i.external_addresses!)
29 | <- f
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/tryOtherwise.aqua:
--------------------------------------------------------------------------------
1 | aqua TryOtherwise
2 |
3 | export tryOtherwiseTest
4 |
5 | service Unexisted("unex"):
6 | getStr() -> string
7 |
8 | data LastError:
9 | instruction: string
10 | msg: string
11 | peer_id: string
12 |
13 | service OpE("op"):
14 | identity(s: string) -> string
15 |
16 | func tryOtherwiseTest(node_id: string) -> string:
17 | on node_id:
18 | f: *string
19 | try:
20 | f <- Unexisted.getStr()
21 | otherwise:
22 | f <- OpE.identity("error")
23 | <- f!
--------------------------------------------------------------------------------
/integration-tests/aqua/examples/via.aqua:
--------------------------------------------------------------------------------
1 | aqua Via
2 |
3 | export viaArr, viaStream, viaOpt
4 |
5 | import "@fluencelabs/aqua-lib/builtin.aqua"
6 |
7 | func viaArr(node_id: string, viaAr: []string) -> Info:
8 | on node_id via viaAr:
9 | p <- Peer.identify()
10 | <- p
11 |
12 | func viaStream(node_id: string, viaStr: *string) -> Info:
13 | on node_id via viaStr:
14 | p <- Peer.identify()
15 | <- p
16 |
17 | func viaOpt(node_id: string, viaOpt: ?string) -> Info:
18 | on node_id via viaOpt:
19 | p <- Peer.identify()
20 | <- p
--------------------------------------------------------------------------------
/integration-tests/jest.config.cjs:
--------------------------------------------------------------------------------
1 | /** @type {import('ts-jest').JestConfigWithTsJest} */
2 | module.exports = {
3 | extensionsToTreatAsEsm: ['.ts'],
4 | "preset": "ts-jest/presets/default-esm",
5 | "moduleNameMapper": {
6 | "^(\\.{1,2}/.*)\\.js$": "$1"
7 | },
8 | "transform": {
9 | "^.+\\.tsx?$": [
10 | "ts-jest",
11 | {
12 | "useESM": true
13 | }
14 | ]
15 | }
16 |
17 | };
18 |
19 |
--------------------------------------------------------------------------------
/integration-tests/lsp-aqua/types.aqua:
--------------------------------------------------------------------------------
1 | aqua Types
2 |
3 | alias Top: ⊤
4 | alias Bottom: ⊥
5 |
6 | alias Number: u32
7 | alias String: string
8 | alias Array: []string
9 | alias Stream: *string
10 | alias Option: ?string
11 |
12 | data Struct:
13 | a: Number
14 | b: String
15 | c: Array
16 | d: Option
17 |
18 | service Srv("srv"):
19 | noop(srvArg: string)
20 |
21 | ability Ability:
22 | a: Number
23 | b: String
24 |
25 | func nilArrow():
26 | Srv.noop("")
27 |
28 | func fullArrow(a: string, b: u32) -> string, u32:
29 | <- a, b
30 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/abilityClosureCall.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import {
18 | bugLNG314, bugLNG338
19 | } from "../compiled/examples/abilitiesClosure.js";
20 |
21 | export async function bugLNG314Call(): Promise {
22 | return await bugLNG314();
23 | }
24 |
25 | export async function bugLNG338Call(): Promise {
26 | return await bugLNG338();
27 | }
28 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/abilityClosureRenameCall.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import {
18 | bugLNG346
19 | } from "../compiled/examples/abilitiesClosureRename.js";
20 |
21 | export async function bugLNG346Call(): Promise {
22 | return await bugLNG346();
23 | }
24 |
25 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/assignment.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import { doSmth } from "../compiled/examples/assignment.js";
18 |
19 | export async function assignmentCall(): Promise {
20 | return await doSmth({ value: "abc" }, { ttl: 6000 });
21 | }
22 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/canonCall.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import { bugLng79, registerSer } from "../compiled/examples/canon.js";
18 |
19 | export async function bugLng79Call(
20 | pid: string,
21 | relay: string,
22 | ): Promise {
23 | registerSer({
24 | getRecord: () => {
25 | return { peer_id: pid, relay_id: [relay] };
26 | },
27 | });
28 | return await bugLng79((s) => {
29 | console.log(s);
30 | });
31 | }
32 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/closureArrowCapture.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import {
18 | test,
19 | registerTestServiceClosureArrowCapture,
20 | } from "../compiled/examples/closureArrowCapture.js";
21 |
22 | export async function closureArrowCaptureCall(s: string) {
23 | registerTestServiceClosureArrowCapture("test-service", {
24 | call: (s: string) => {
25 | return "call: " + s;
26 | },
27 | });
28 |
29 | return await test(s);
30 | }
31 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/closureReturnRename.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import { lng193Bug, lng365Bug } from "../compiled/examples/closureReturnRename.js";
18 | import { config } from "../config.js";
19 |
20 | const relays = config.relays;
21 |
22 | export async function lng193BugCall(): Promise {
23 | return lng193Bug(relays[4].peerId, relays[5].peerId);
24 | }
25 |
26 | export async function lng365BugCall() {
27 | return lng365Bug();
28 | }
29 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/closureStreamScopesCall.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import {
18 | simpleTest,
19 | complexTest
20 | } from "../compiled/examples/closureStreamScopes.js";
21 |
22 | export async function complexStreamScopeCall(): Promise<[string[], string[]]> {
23 | return complexTest();
24 | }
25 |
26 | export async function simpleStreamScopeCall(): Promise {
27 | return simpleTest();
28 | }
29 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/coCall.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import { parFunc } from "../compiled/examples/par.js";
18 | import { registerCoService } from "../compiled/examples/co.js";
19 | import { relay1 } from "../__test__/examples.spec.js";
20 |
21 | export async function coCall(): Promise {
22 | registerCoService({
23 | call: () => {
24 | return "hello";
25 | },
26 | });
27 |
28 | return new Promise((resolve, reject) => {
29 | parFunc(
30 | relay1.peerId,
31 | (c) => {
32 | resolve(c.external_addresses);
33 | },
34 | { ttl: 60000 },
35 | );
36 | });
37 | }
38 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/complex.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import { doStuff, registerTestS } from "../compiled/examples/complex.js";
18 |
19 | export async function complexCall(selfPeerId: string, relayPeerId: string) {
20 | registerTestS({
21 | t: (arg0) => {
22 | return arg0;
23 | },
24 | multiline: (a, b, c) => {
25 | return b;
26 | },
27 | });
28 |
29 | return await doStuff(
30 | relayPeerId,
31 | selfPeerId,
32 | true,
33 | true,
34 | ["1", "2"],
35 | ["3", "4"],
36 | "some str",
37 | );
38 | }
39 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/constantsCall.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import {
18 | callConstant,
19 | registerGetter,
20 | timestampAndTtl,
21 | } from "../compiled/examples/constants.js";
22 |
23 | export async function constantsCall(): Promise {
24 | registerGetter({
25 | createStr: (arg0) => {
26 | return "" + arg0;
27 | },
28 | });
29 |
30 | return await callConstant();
31 | }
32 |
33 | export async function particleTtlAndTimestampCall(
34 | ttl: number,
35 | ): Promise<[number, number]> {
36 | return await timestampAndTtl({ ttl: ttl });
37 | }
38 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/dataAliasCall.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import {
18 | getAliasedData,
19 | registerNodeIdGetter,
20 | } from "../compiled/examples/dataAlias.js";
21 |
22 | export async function dataAliasCall() {
23 | registerNodeIdGetter({
24 | get: () => {
25 | return {
26 | peerId: "peer id str",
27 | name: "name str",
28 | };
29 | },
30 | });
31 |
32 | return await getAliasedData();
33 | }
34 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/errorClear.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import { IFluenceClient } from "@fluencelabs/js-client";
18 | import {
19 | errorClearTest,
20 | registerFailService,
21 | } from "../compiled/examples/errorClear.js";
22 |
23 | export async function errorClearCall(peer: IFluenceClient) {
24 | registerFailService(peer, {
25 | call: (s: string) => {
26 | if (s === "fail") return Promise.reject(s);
27 | else return Promise.resolve(s);
28 | },
29 | });
30 |
31 | return await errorClearTest(peer.getPeerId(), peer.getRelayPeerId());
32 | }
33 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/foldJoinCall.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import { getTwoResults } from "../compiled/examples/foldJoin.js";
18 |
19 | export async function foldJoinCall(relayPeerId: string): Promise {
20 | return await getTwoResults(relayPeerId, { ttl: 16000 });
21 | }
22 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/funcCall.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import { testFunc, registerTestSrv } from "../compiled/examples/func.js";
18 |
19 | export async function funcCall() {
20 | registerTestSrv({
21 | str: () => {
22 | return `some str`;
23 | },
24 | });
25 |
26 | return await testFunc();
27 | }
28 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/functorsCall.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import { lng119Bug } from "../compiled/examples/functors.js";
18 |
19 | export async function bugLng119Call(): Promise {
20 | return lng119Bug();
21 | }
22 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/handleResultError.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import { handleResultError } from "../compiled/examples/handleResultError.js";
18 |
19 | export async function handleResultErrorCall() {
20 | return await handleResultError(true, false);
21 | }
22 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/helloWorldCall.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import {
18 | helloWorld,
19 | registerStringExtra,
20 | } from "../compiled/examples/helloWorld.js";
21 |
22 | export async function helloWorldCall() {
23 | // helloWorld.aqua
24 | registerStringExtra({
25 | addNameToHello: (args0) => {
26 | return `Hello, ${args0}!`;
27 | },
28 | });
29 |
30 | return await helloWorld("NAME");
31 | }
32 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/ifCall.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import {
18 | bugLNG69,
19 | ifCorrectXorWrap,
20 | ifElseCall,
21 | ifElseNumCall,
22 | } from "../compiled/examples/if.js";
23 |
24 | export async function ifCall() {
25 | await ifElseCall(false);
26 | await ifElseCall(true);
27 |
28 | await ifElseNumCall(1);
29 | await ifElseNumCall(5);
30 | }
31 |
32 | export async function ifWrapCall(node: string) {
33 | return ifCorrectXorWrap(node);
34 | }
35 |
36 | export async function bugNG69Call(node: string): Promise {
37 | return bugLNG69(node);
38 | }
39 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/ifPropagateErrors.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import {
18 | ifPropagateErrors,
19 | registerTestService,
20 | } from "../compiled/examples/ifPropagateErrors.js";
21 |
22 | export async function ifPropagateErrorsCall() {
23 | registerTestService({
24 | call: (s) => {
25 | if (s == "fail") return Promise.reject(s);
26 | else return Promise.resolve(s);
27 | },
28 | });
29 |
30 | return await ifPropagateErrors();
31 | }
32 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/import2Call.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import { registerOneMore } from "../compiled/examples/imports_exports/gen/OneMore.js";
18 | import { barfoo, wrap } from "../compiled/examples/imports_exports/import2.js";
19 |
20 | export async function import2Call() {
21 | registerOneMore("hello", {
22 | more_call: () => {},
23 | });
24 |
25 | registerOneMore("ohmygod", {
26 | more_call: () => {},
27 | });
28 |
29 | let first = await wrap();
30 | let second = await barfoo();
31 |
32 | return { first, second };
33 | }
34 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/modules.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import {
18 | renamed, merged, exported
19 | } from "../compiled/examples/imports_exports/modules/main.js";
20 |
21 | export async function renamedCall(): Promise {
22 | return await renamed();
23 | }
24 |
25 | export async function mergedCall(): Promise {
26 | return await merged();
27 | }
28 |
29 | export async function exportedCall(): Promise {
30 | return await exported();
31 | }
--------------------------------------------------------------------------------
/integration-tests/src/examples/multiReturnCall.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import {
18 | multiReturnFunc,
19 | registerGetStr,
20 | registerGetNum,
21 | } from "../compiled/examples/multiReturn.js";
22 |
23 | export async function multiReturnCall(): Promise<
24 | [string[], number, string, number[], string | null, number]
25 | > {
26 | registerGetStr({
27 | retStr: (args0) => {
28 | return args0;
29 | },
30 | });
31 |
32 | registerGetNum({
33 | retNum: () => {
34 | return 10;
35 | },
36 | });
37 |
38 | return await multiReturnFunc([1, 2], null);
39 | }
40 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/nestedDataCall.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import {
18 | test,
19 | registerTest,
20 | TestResult,
21 | } from "../compiled/examples/nestedData.js";
22 |
23 | export async function nestedDataCall(): Promise {
24 | let nested = {
25 | one: {
26 | val: "hello",
27 | },
28 | };
29 | registerTest({
30 | test1: () => {
31 | return nested;
32 | },
33 | test2: (arg1: { val: string }, arg2: string) => {
34 | let res = {
35 | one: {
36 | val: arg1.val + arg2,
37 | },
38 | };
39 | return res;
40 | },
41 | });
42 |
43 | return await test();
44 | }
45 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/nestedFuncsCall.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import { d, registerOpH } from "../compiled/examples/nestedFuncs.js";
18 |
19 | export async function nestedFuncsCall(): Promise {
20 | registerOpH({
21 | identity: (args0) => {
22 | return args0;
23 | },
24 | });
25 |
26 | return await d("some-str");
27 | }
28 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/objectCall.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import {
18 | getObj,
19 | getObjAssign,
20 | getObjRelay,
21 | getObjFor,
22 | } from "../compiled/examples/object.js";
23 |
24 | export async function getObjCall() {
25 | return await getObj();
26 | }
27 |
28 | export async function getObjRelayCall() {
29 | return await getObjRelay();
30 | }
31 |
32 | export async function getObjAssignCall() {
33 | return await getObjAssign();
34 | }
35 |
36 | export async function getObjForCall() {
37 | return await getObjFor();
38 | }
39 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/onCall.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import { getPeerExternalAddresses } from "../compiled/examples/on.js";
18 |
19 | export async function onCall(relayPeerId: string): Promise {
20 | return await getPeerExternalAddresses(relayPeerId);
21 | }
22 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/parSeqCall.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import {
18 | testParSeq
19 | } from "../compiled/examples/parseq.js";
20 | import { config } from "../config.js";
21 |
22 | const relays = config.relays;
23 |
24 | export async function testParSeqCall() {
25 | return testParSeq(relays[3].peerId, relays[4].peerId, relays[5].peerId)
26 | }
--------------------------------------------------------------------------------
/integration-tests/src/examples/passArgsCall.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import {
18 | bugLNG60,
19 | create_client_util,
20 | registerAquaDHT,
21 | } from "../compiled/examples/passArgs.js";
22 |
23 | export async function passArgsCall() {
24 | registerAquaDHT({
25 | put_host_value: (args0, args1) => {
26 | return args0 + args1;
27 | },
28 | });
29 |
30 | return await create_client_util("sid");
31 | }
32 |
33 | export async function bugLNG60Call(relayPeerId: string): Promise {
34 | return bugLNG60(relayPeerId, { ttl: 10000 });
35 | }
36 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/pushToStreamCall.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import { get_results, registerOpA } from "../compiled/examples/pushToStream.js";
18 |
19 | export async function pushToStreamCall() {
20 | registerOpA({
21 | get_str: () => {
22 | return "get_string";
23 | },
24 | });
25 |
26 | return await get_results();
27 | }
28 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/recursiveStreams/multiRecStreamCall.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import {
18 | multiRecStream,
19 | registerTestServiceMultiRec,
20 | } from "../../compiled/examples/recursiveStreams/multiRec.js";
21 |
22 | export async function multiRecStreamCall(
23 | init: number,
24 | target: number,
25 | handle: (i: number) => number[],
26 | ): Promise {
27 | registerTestServiceMultiRec({ handle });
28 |
29 | return await multiRecStream(init, target);
30 | }
31 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/recursiveStreams/nestedCall.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import { nested } from "../../compiled/examples/recursiveStreams/nested.js";
18 |
19 | export async function nestedCall(n: number): Promise {
20 | return await nested(n);
21 | }
22 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/recursiveStreams/pipelineCall.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import { pipelineStream } from "../../compiled/examples/recursiveStreams/pipeline.js";
18 |
19 | export async function pipelineStreamCall(
20 | init: number,
21 | target: number,
22 | ): Promise {
23 | return await pipelineStream(init, target);
24 | }
25 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/recursiveStreams/rangeCall.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import { range } from "../../compiled/examples/recursiveStreams/range.js";
18 |
19 | export async function rangeCall(a: number, b: number): Promise {
20 | return await range(a, b);
21 | }
22 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/recursiveStreams/remoteRecCall.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import { IFluenceClient } from "@fluencelabs/js-client";
18 | import { remoteRecStream } from "../../compiled/examples/recursiveStreams/remoteRec.js";
19 |
20 | export async function remoteRecStreamCall(
21 | init: number,
22 | target: number,
23 | peer: IFluenceClient,
24 | ): Promise {
25 | return await remoteRecStream(
26 | init,
27 | target,
28 | peer.getPeerId(),
29 | peer.getRelayPeerId(),
30 | );
31 | }
32 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/recursiveStreams/yesNoStreamCall.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import {
18 | yesNoStream,
19 | registerYesNoService,
20 | } from "../../compiled/examples/recursiveStreams/yesNo.js";
21 |
22 | export async function yesNoStreamCall(limit: number): Promise {
23 | let i = 1;
24 | registerYesNoService({
25 | get: () => {
26 | i += 1;
27 | return i > limit ? "no" : "yes";
28 | },
29 | });
30 |
31 | return await yesNoStream();
32 | }
33 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/renameVars.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import { rename_s } from "../compiled/examples/renameVars.js";
18 |
19 | export async function renameVarsCall(): Promise {
20 | return await rename_s();
21 | }
22 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/returnArrowCall.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import {
18 | callReturnedArrow,
19 | callReturnedChainArrow,
20 | } from "../compiled/examples/returnArrow.js";
21 |
22 | export async function returnArrowCall(): Promise<[string, string]> {
23 | return await callReturnedArrow("arg for func ", "arg for closure ");
24 | }
25 |
26 | export async function returnArrowChainCall(): Promise<
27 | [string, string, string, string, string, string, string, string]
28 | > {
29 | return await callReturnedChainArrow("arg for func1 ", "arg for func2 ");
30 | }
31 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/returnLiteralCall.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import { returnLiteral } from "../compiled/examples/returnLiteral.js";
18 |
19 | export async function literalCall() {
20 | return returnLiteral();
21 | }
22 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/streamCallback.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import { someFunc } from "../compiled/examples/streamCallback.js";
18 |
19 | export async function streamCallbackCall(): Promise {
20 | return new Promise((resolve, reject) => {
21 | someFunc((a: string[]) => {
22 | resolve(a);
23 | });
24 | });
25 | }
26 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/streamCanCall.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import {
18 | accumRes,
19 | bugLNG63,
20 | bugLNG63_2,
21 | bugLNG63_3,
22 | } from "../compiled/examples/streamCan.js";
23 |
24 | export async function streamCanCall() {
25 | return await accumRes();
26 | }
27 |
28 | export async function bugLNG63Call(): Promise {
29 | return await bugLNG63();
30 | }
31 |
32 | export async function bugLNG63_2Call(): Promise<[string, string[], string[]]> {
33 | return await bugLNG63_2();
34 | }
35 |
36 | export async function bugLNG63_3Call(): Promise<[string, number, number[]]> {
37 | return await bugLNG63_3();
38 | }
39 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/streamCapture.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import {
18 | testStreamCaptureSimple,
19 | testStreamCaptureReturn,
20 | } from "../compiled/examples/streamCapture.js";
21 |
22 | export async function streamCaptureSimpleCall() {
23 | return await testStreamCaptureSimple();
24 | }
25 |
26 | export async function streamCaptureReturnCall() {
27 | return await testStreamCaptureReturn();
28 | }
29 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/streamMapAbilitiesCall.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import {
18 | streamMapAbilityTest
19 | } from "../compiled/examples/streamMapAbilities.js";
20 |
21 | export async function streamMapAbilityTestCall() {
22 | return await streamMapAbilityTest();
23 | }
24 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/streamMapCapture.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import {
18 | testStreamMapCaptureSimple,
19 | testStreamMapCaptureReturn,
20 | } from "../compiled/examples/streamMapCapture.js";
21 |
22 | export async function streamMapCaptureSimpleCall() {
23 | return await testStreamMapCaptureSimple();
24 | }
25 |
26 | export async function streamMapCaptureReturnCall() {
27 | return await testStreamMapCaptureReturn();
28 | }
29 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/streamMapRestrictionsCall.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import { streamMapRes } from "../compiled/examples/streamMapRestriction.js";
18 |
19 | export async function streamMapResCall(): Promise {
20 | return await streamMapRes(["a", "b", "c"]);
21 | }
22 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/streamRestrictionsCall.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import { streamRes } from "../compiled/examples/streamRestriction.js";
18 |
19 | export async function streamResCall(): Promise {
20 | return await streamRes(["a", "b", "c"]);
21 | }
22 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/streamResultsCall.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import {
18 | use_name2,
19 | registerDTGetter,
20 | } from "../compiled/examples/streamResults.js";
21 |
22 | export async function streamResultsCall() {
23 | registerDTGetter({
24 | get_dt: (args0) => {
25 | return {
26 | field: args0,
27 | };
28 | },
29 | });
30 |
31 | return await use_name2("new_name");
32 | }
33 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/streamReturn.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import { testReturnStream } from "../compiled/examples/streamReturn.js";
18 |
19 | export async function streamReturnCall() {
20 | return await testReturnStream();
21 | }
22 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/structuralTypingCall.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import { structuralTypingTest } from "../compiled/examples/structuraltyping.js";
18 |
19 | export async function structuralTypingCall(): Promise {
20 | return await structuralTypingTest();
21 | }
22 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/tryCatchCall.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import { tryCatchTest } from "../compiled/examples/tryCatch.js";
18 |
19 | export async function tryCatchCall(relayPeerId: string): Promise {
20 | return await tryCatchTest(relayPeerId, { ttl: 60000 });
21 | }
22 |
--------------------------------------------------------------------------------
/integration-tests/src/examples/tryOtherwiseCall.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | import { tryOtherwiseTest } from "../compiled/examples/tryOtherwise.js";
18 |
19 | export async function tryOtherwiseCall(relayPeerId: string): Promise {
20 | return await tryOtherwiseTest(relayPeerId, { ttl: 60000 });
21 | }
22 |
--------------------------------------------------------------------------------
/integration-tests/src/index.ts:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | /*
4 | * Copyright (C) 2024 Fluence DAO
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Affero General Public License as
8 | * published by the Free Software Foundation, version 3.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU Affero General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Affero General Public License
16 | * along with this program. If not, see .
17 | */
18 |
19 | const main = async () => {
20 | process.exit(0);
21 | };
22 |
23 | main().catch((err) => {
24 | console.log(err);
25 | process.exit(1);
26 | });
27 |
--------------------------------------------------------------------------------
/integration-tests/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "allowJs": true,
4 | "target": "ESNext",
5 | "module": "ESNext",
6 | "lib": ["es2015", "dom"],
7 | "declaration": true,
8 | "outDir": "dist",
9 | "moduleResolution": "nodenext",
10 | "strict": true,
11 | "esModuleInterop": true,
12 | "noImplicitAny": false,
13 | "strictNullChecks": false,
14 | "skipLibCheck": true
15 | },
16 | "exclude": [
17 | "node_modules",
18 | "dist",
19 | "bundle"
20 | ],
21 | "include": ["src/**/*"],
22 | "ts-node": {
23 | "esm": true
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/io/.jvm/src/main/scala/aqua/PlatformPackagePath.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua
18 |
19 | import cats.effect.kernel.Async
20 | import fs2.io.file.Path
21 | import cats.syntax.applicative.*
22 |
23 | object PlatformPackagePath {
24 | def getPackagePath[F[_]: Async](path: String): F[Path] = Path("").pure[F]
25 | def getGlobalNodeModulePath: List[Path] = Nil
26 | }
27 |
--------------------------------------------------------------------------------
/io/src/main/scala/aqua/AquaIO.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua
18 |
19 | import aqua.io.AquaFileError
20 |
21 | import cats.data.{Chain, EitherT, ValidatedNec}
22 | import fs2.io.file.Path
23 |
24 | trait AquaIO[F[_]] {
25 | def readFile(file: Path): EitherT[F, AquaFileError, String]
26 |
27 | def resolve(paths: List[Path]): EitherT[F, AquaFileError, Path]
28 |
29 | def listAqua(path: Path): EitherT[F, AquaFileError, Chain[Path]]
30 |
31 | def writeFile(file: Path, content: String): EitherT[F, AquaFileError, Unit]
32 | }
33 |
34 | object AquaIO {
35 | def apply[F[_]](using aio: AquaIO[F]): AquaIO[F] = aio
36 | }
37 |
--------------------------------------------------------------------------------
/io/src/main/scala/aqua/files/FileModuleId.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.files
18 |
19 | import aqua.semantics.FileId
20 | import fs2.io.file.Path
21 | import cats.{Order, Show}
22 |
23 | case class FileModuleId private (file: Path) {
24 | override def toString: String = s"$file"
25 | }
26 |
27 | object FileModuleId {
28 |
29 | given FileId[FileModuleId] with {
30 | override def compare(x: FileModuleId, y: FileModuleId): Int =
31 | x.file.toString.compareTo(y.file.toString)
32 |
33 | override def show(t: FileModuleId): String = t.toString
34 | }
35 |
36 | def apply(file: Path): FileModuleId =
37 | new FileModuleId(file.absolute.normalize)
38 | }
39 |
--------------------------------------------------------------------------------
/io/src/main/scala/aqua/io/OutputPrinter.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.io
18 |
19 | import cats.effect.std.Console
20 |
21 | // Uses to print outputs in CLI
22 | // TODO: add F[_], cause it is effect
23 | object OutputPrinter {
24 |
25 | def print(str: String): Unit = {
26 | println(str)
27 | }
28 |
29 | def errorF[F[_]: Console](str: String): F[Unit] = {
30 | Console[F].errorln(scala.Console.RED + str + scala.Console.RESET)
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/js/js-imports/src/main/scala/aqua/js/Conversions.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.js
18 |
19 | import scala.scalajs.js
20 | import scala.scalajs.js.annotation.JSImport
21 |
22 | object Conversions {
23 |
24 | @js.native
25 | @JSImport("@fluencelabs/fluence/dist/internal/compilerSupport/v3impl/conversions.js", "ts2aqua")
26 | def ts2aqua(value: js.Dynamic, `type`: TypeDefinitionJs): js.Dynamic = js.native
27 | }
28 |
--------------------------------------------------------------------------------
/language-server/language-server-api/src/test/scala/aqua/lsp/Utils.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.lsp
18 |
19 | object Utils {
20 |
21 | def getByPosition(code: String, str: String, position: Int): Option[(Int, Int)] = {
22 | str.r.findAllMatchIn(code).toList.lift(position).map(r => (r.start, r.end))
23 | }
24 |
25 | extension [T](o: Option[T]) {
26 |
27 | def tapNone(f: => Unit): Option[T] =
28 | o.orElse {
29 | f; None
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/language-server/language-server-npm/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@fluencelabs/aqua-language-server-api",
3 | "version": "0.14.11",
4 | "description": "Aqua Language Server API",
5 | "type": "commonjs",
6 | "files": [
7 | "aqua-lsp-api.js",
8 | "aqua-lsp-api.d.ts"
9 | ],
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/fluencelabs/aqua.git"
13 | },
14 | "keywords": [
15 | "aqua",
16 | "fluence"
17 | ],
18 | "author": "Fluence Labs",
19 | "license": "AGPL-3.0",
20 | "bugs": {
21 | "url": "https://github.com/fluencelabs/aqua/issues"
22 | },
23 | "homepage": "https://github.com/fluencelabs/aqua#readme"
24 | }
25 |
--------------------------------------------------------------------------------
/linker/src/main/scala/aqua/linker/AquaModule.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.linker
18 |
19 | case class AquaModule[I, E, T](id: I, imports: Map[String, I], dependsOn: Map[I, E], body: T)
20 |
--------------------------------------------------------------------------------
/model/inline/src/main/scala/aqua/model/inline/raw/RawInliner.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.model.inline.raw
18 |
19 | import aqua.model.ValueModel
20 | import aqua.model.inline.Inline
21 | import aqua.model.inline.state.*
22 | import aqua.raw.value.ValueRaw
23 |
24 | import cats.data.State
25 |
26 | trait RawInliner[T <: ValueRaw] {
27 |
28 | def apply[S: Mangler: Exports: Arrows: Config](
29 | raw: T,
30 | propertiesAllowed: Boolean = true
31 | ): State[S, (ValueModel, Inline)]
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/model/inline/src/main/scala/aqua/model/inline/tag/TryTagInliner.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.model.inline.tag
18 |
19 | import aqua.model.inline.state.{Arrows, Config, Exports, Mangler}
20 | import aqua.model.inline.TagInliner.TagInlined
21 | import aqua.model.XorModel
22 | import cats.data.State
23 |
24 | object TryTagInliner {
25 | def inlined[S: Mangler: Exports: Arrows: Config]: State[S, TagInlined[S]] =
26 | State.pure(TagInlined.Around(model = StreamRestrictions.restrictStreams(XorModel.wrap)))
27 | }
28 |
--------------------------------------------------------------------------------
/model/inline/src/test/scala/aqua/model/inline/ModelBuilder.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.model.inline
18 |
19 | import aqua.model.{CallModel, CallServiceModel, LiteralModel, ValueModel, VarModel}
20 |
21 | object ModelBuilder {
22 |
23 | def add(l: ValueModel, r: ValueModel)(o: VarModel): CallServiceModel =
24 | CallServiceModel(
25 | serviceId = "math",
26 | funcName = "add",
27 | args = List(l, r),
28 | result = o
29 | )
30 | }
31 |
--------------------------------------------------------------------------------
/model/inline/src/test/scala/aqua/model/inline/RawBuilder.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.model.inline
18 |
19 | import aqua.raw.value.{ApplyBinaryOpRaw, ValueRaw}
20 | import aqua.types.{ArrowType, ProductType, ScalarType}
21 |
22 | object RawBuilder {
23 |
24 | def add(l: ValueRaw, r: ValueRaw): ValueRaw =
25 | ApplyBinaryOpRaw.Add(l, r)
26 | }
27 |
--------------------------------------------------------------------------------
/model/raw/src/main/scala/aqua/raw/ErroredPart.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.raw
18 |
19 | import aqua.types.{BottomType, Type}
20 |
21 | // Part for structures that have errors inside but must be registered in context
22 | case class ErroredPart(name: String) extends RawPart {
23 | override def rawPartType: Type = BottomType
24 |
25 | override def rename(s: String): RawPart = copy(name = s)
26 |
27 | def addAbilityName(s: String): RawPart = this
28 | }
29 |
--------------------------------------------------------------------------------
/model/raw/src/main/scala/aqua/raw/ServiceRaw.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.raw
18 |
19 | import aqua.types.{ServiceType, Type}
20 | import aqua.raw.value.ValueRaw
21 |
22 | case class ServiceRaw(
23 | name: String,
24 | `type`: ServiceType,
25 | defaultId: Option[ValueRaw]
26 | ) extends RawPart {
27 | def rawPartType: ServiceType = `type`
28 |
29 | override def rename(s: String): RawPart = copy(name = s)
30 |
31 | def addAbilityName(s: String): RawPart = copy(`type` = Type.addAbilityNameService(s, `type`))
32 | }
33 |
--------------------------------------------------------------------------------
/model/raw/src/main/scala/aqua/raw/TypeRaw.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.raw
18 |
19 | import aqua.types.Type
20 |
21 | case class TypeRaw(name: String, `type`: Type) extends RawPart {
22 | override def rename(s: String): RawPart = copy(name = s)
23 |
24 | override def rawPartType: Type = `type`
25 |
26 | def addAbilityName(s: String): RawPart = copy(`type` = Type.addAbilityName(s, `type`))
27 | }
28 |
--------------------------------------------------------------------------------
/model/raw/src/main/scala/aqua/raw/arrow/ArrowRaw.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.raw.arrow
18 |
19 | import aqua.raw.ops.RawTag
20 | import aqua.types.ArrowType
21 | import aqua.raw.Raw
22 | import aqua.raw.value.ValueRaw
23 |
24 | case class ArrowRaw(
25 | `type`: ArrowType,
26 | ret: List[ValueRaw],
27 | body: RawTag.Tree
28 | ) extends Raw
29 |
--------------------------------------------------------------------------------
/model/raw/src/main/scala/aqua/raw/ops/FuncOp.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.raw.ops
18 |
19 | import aqua.raw.Raw
20 | import aqua.raw.ops
21 | import aqua.raw.value.{ValueRaw, VarRaw}
22 | import cats.Eval
23 | import cats.data.Chain
24 | import cats.free.Cofree
25 | import cats.instances.tuple.*
26 | import cats.kernel.Semigroup
27 | import cats.syntax.apply.*
28 | import cats.syntax.flatMap.*
29 | import cats.syntax.functor.*
30 | import cats.syntax.traverse.*
31 | import cats.Monad
32 | import cats.data.State
33 | import cats.data.StateT
34 |
35 | case class FuncOp(tree: RawTag.Tree) extends Raw
36 |
--------------------------------------------------------------------------------
/model/res/src/main/scala/aqua/res/AquaRes.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.res
18 |
19 | import cats.data.Chain
20 |
21 | // TODO: doc
22 | case class AquaRes(funcs: Chain[FuncRes], services: Chain[ServiceRes]) {
23 | def isEmpty: Boolean = funcs.isEmpty && services.isEmpty
24 | }
25 |
26 | object AquaRes {
27 | private val blank = AquaRes(Chain.nil, Chain.nil)
28 | }
29 |
--------------------------------------------------------------------------------
/model/res/src/main/scala/aqua/res/CallRes.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.res
18 |
19 | import aqua.model.{CallModel, ValueModel}
20 |
21 | // TODO docs
22 | case class CallRes(args: List[ValueModel], exportTo: Option[CallModel.Export]) {
23 | override def toString: String = s"[${args.mkString(" ")}]${exportTo.fold("")(" " + _)}"
24 | }
25 |
--------------------------------------------------------------------------------
/model/res/src/main/scala/aqua/res/ServiceRes.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.res
18 |
19 | import aqua.model.{LiteralModel, ServiceModel}
20 | import aqua.types.{ArrowType, ScalarType}
21 |
22 | // TODO: docs
23 | case class ServiceRes(name: String, members: List[(String, ArrowType)], defaultId: Option[String])
24 |
25 | object ServiceRes {
26 |
27 | def fromModel(sm: ServiceModel): ServiceRes =
28 | ServiceRes(
29 | name = sm.name,
30 | members = sm.`type`.arrows.toList,
31 | defaultId = sm.defaultId.collect {
32 | case LiteralModel(value, t) if ScalarType.string.acceptsValueOf(t) =>
33 | value
34 | }
35 | )
36 | }
37 |
--------------------------------------------------------------------------------
/model/src/main/scala/aqua/model/ServiceModel.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.model
18 |
19 | import aqua.types.ServiceType
20 |
21 | case class ServiceModel(
22 | name: String,
23 | `type`: ServiceType,
24 | defaultId: Option[ValueModel]
25 | )
26 |
--------------------------------------------------------------------------------
/model/transform/img.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluencelabs/aqua/31a3ec9eae8e384f408ca3ba635a057f07b831b0/model/transform/img.png
--------------------------------------------------------------------------------
/model/transform/src/main/scala/aqua/model/transform/pre/PreTransform.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.model.transform.pre
18 |
19 | import aqua.raw.ops.RawTag
20 |
21 | trait PreTransform {
22 | def transform(op: RawTag.Tree): RawTag.Tree
23 | }
24 |
--------------------------------------------------------------------------------
/model/transform/src/main/scala/aqua/model/transform/topology/strategy/Before.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.model.transform.topology.strategy
18 |
19 | import aqua.model.transform.topology.Topology
20 | import aqua.model.transform.topology.TopologyPath
21 | import aqua.model.OnModel
22 |
23 | import cats.Eval
24 |
25 | trait Before {
26 |
27 | def beforeOn(current: Topology): Eval[TopologyPath] =
28 | // Go to the parent, see where it begins
29 | current.parent.map(_.beginsOn) getOrElse
30 | // This means, we have no parent; then we're where we should be
31 | current.pathOn
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/model/transform/src/main/scala/aqua/model/transform/topology/strategy/Default.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.model.transform.topology.strategy
18 |
19 | object Default extends Before with Begins with Ends with After {
20 | override def toString: String = ""
21 | }
22 |
--------------------------------------------------------------------------------
/model/transform/src/main/scala/aqua/model/transform/topology/strategy/SeqGroup.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.model.transform.topology.strategy
18 |
19 | import aqua.model.transform.topology.Topology
20 | import aqua.model.transform.topology.TopologyPath
21 | import aqua.model.OnModel
22 |
23 | import cats.Eval
24 |
25 | object SeqGroup extends Ends {
26 | override def toString: String = ""
27 |
28 | override def endsOn(current: Topology): Eval[TopologyPath] =
29 | lastChildFinally(current)
30 | }
31 |
--------------------------------------------------------------------------------
/model/transform/src/main/scala/aqua/model/transform/topology/strategy/SeqNext.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.model.transform.topology.strategy
18 |
19 | import aqua.model.transform.topology.Topology
20 | import aqua.model.transform.topology.TopologyPath
21 | import aqua.model.OnModel
22 |
23 | import cats.Eval
24 |
25 | object SeqNext extends Begins {
26 | override def toString: String = "/"
27 |
28 | override def beginsOn(current: Topology): Eval[TopologyPath] =
29 | current.parents.find(_.isForModel).map(_.beginsOn) getOrElse super.beginsOn(current)
30 | }
31 |
--------------------------------------------------------------------------------
/model/transform/src/main/scala/aqua/model/transform/topology/strategy/XorGroup.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.model.transform.topology.strategy
18 |
19 | import aqua.model.transform.topology.Topology
20 | import aqua.model.transform.topology.TopologyPath
21 | import aqua.model.OnModel
22 |
23 | import cats.Eval
24 | import cats.data.Chain
25 |
26 | object XorGroup extends Ends {
27 | override def toString: String = ""
28 |
29 | // Xor tag ends where any child ends; can't get first one as it may lead to recursion
30 | override def endsOn(current: Topology): Eval[TopologyPath] =
31 | firstChildFinally(current)
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/parser/src/main/scala/aqua/parser/head/FilenameExpr.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.parser.head
18 |
19 | import aqua.helpers.ext.Extension
20 | import aqua.parser.lexer.{LiteralToken, Token}
21 | import cats.Comonad
22 | import cats.~>
23 |
24 | trait FilenameExpr[F[_]] extends HeaderExpr[F] {
25 | def filename: LiteralToken[F]
26 |
27 | override def token: Token[F] = filename
28 |
29 | def fileValue: String = {
30 | val raw = filename.value.drop(1).dropRight(1)
31 | Extension.add(raw)
32 | }
33 |
34 | override def mapK[K[_]: Comonad](fk: F ~> K): FilenameExpr[K]
35 | }
36 |
--------------------------------------------------------------------------------
/parser/src/main/scala/aqua/parser/lexer/Arg.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.parser.lexer
18 |
19 | import aqua.parser.lift.LiftParser
20 | import aqua.parser.lift.Span
21 | import aqua.parser.lift.Span.{given, *}
22 |
23 | import Token._
24 | import cats.Comonad
25 | import cats.parse.{Parser => P}
26 |
27 | case class Arg[F[_]](name: Name[F], `type`: TypeToken[F])
28 |
29 | object Arg {
30 |
31 | val p: P[Arg[Span.S]] =
32 | ((Name.p <* ` : `) ~ TypeToken.`typedef`).map { case (name, t) =>
33 | Arg(name, t)
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/parser/src/test/scala/aqua/parser/DataStructExprSpec.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.parser
18 |
19 | import aqua.AquaSpec
20 | import aqua.parser.expr.{AliasExpr, DataStructExpr}
21 | import aqua.types.ScalarType.u32
22 | import cats.Id
23 | import org.scalatest.flatspec.AnyFlatSpec
24 | import org.scalatest.matchers.should.Matchers
25 |
26 | class DataStructExprSpec extends AnyFlatSpec with Matchers with AquaSpec {
27 |
28 | import AquaSpec.{given, *}
29 |
30 | "data struct" should "be parsed properly" in {
31 | parseDataStruct("data Smth") should be(
32 | DataStructExpr[Id]("Smth")
33 | )
34 |
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/parser/src/test/scala/aqua/parser/ReturnExprSpec.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.parser
18 |
19 | import aqua.AquaSpec
20 | import aqua.parser.expr.func.ReturnExpr
21 | import cats.Id
22 | import cats.data.NonEmptyList
23 | import org.scalatest.flatspec.AnyFlatSpec
24 | import org.scalatest.matchers.should.Matchers
25 |
26 | class ReturnExprSpec extends AnyFlatSpec with Matchers with AquaSpec {
27 | import AquaSpec._
28 |
29 | "return" should "be parsed" in {
30 | parseReturn("<- true") should be(
31 | ReturnExpr[Id](NonEmptyList.one(toBool(true)))
32 | )
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/pnpm-workspace.yaml:
--------------------------------------------------------------------------------
1 | packages:
2 | - 'api/api-npm'
3 | - 'api/api-example'
4 | - 'language-server/language-server-npm'
5 | - 'integration-tests'
6 |
--------------------------------------------------------------------------------
/project/build.properties:
--------------------------------------------------------------------------------
1 | sbt.version=1.10.1
2 |
--------------------------------------------------------------------------------
/project/plugins.sbt:
--------------------------------------------------------------------------------
1 | addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.2.0")
2 | addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.16.0")
3 | addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.3.2")
4 | addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.12.0")
5 | addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.10.0")
6 | addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.10.0")
7 |
--------------------------------------------------------------------------------
/semantics/src/main/scala/aqua/semantics/FileId.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.semantics
18 |
19 | import cats.Show
20 | import cats.kernel.Order
21 | import cats.syntax.order.*
22 |
23 | trait FileId[I] extends Show[I] with Order[I]
24 |
--------------------------------------------------------------------------------
/semantics/src/main/scala/aqua/semantics/SemanticError.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.semantics
18 |
19 | import aqua.parser.Ast
20 | import aqua.parser.lexer.Token
21 |
22 | sealed trait SemanticError[S[_]]
23 | case class RulesViolated[S[_]](token: Token[S], messages: List[String]) extends SemanticError[S]
24 | case class HeaderError[S[_]](token: Token[S], message: String) extends SemanticError[S]
25 | case class WrongAST[S[_]](ast: Ast[S]) extends SemanticError[S]
26 |
--------------------------------------------------------------------------------
/semantics/src/main/scala/aqua/semantics/SemanticWarning.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.semantics
18 |
19 | import aqua.parser.lexer.Token
20 |
21 | final case class SemanticWarning[S[_]](
22 | token: Token[S],
23 | hints: List[String]
24 | )
25 |
--------------------------------------------------------------------------------
/semantics/src/main/scala/aqua/semantics/Semantics.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.semantics
18 |
19 | import aqua.parser.Ast
20 |
21 | import cats.data.{Chain, EitherT, NonEmptyChain, Writer}
22 |
23 | trait Semantics[S[_], C] {
24 |
25 | final type Warnings = [A] =>> Writer[
26 | Chain[SemanticWarning[S]],
27 | A
28 | ]
29 |
30 | final type Result = [A] =>> EitherT[
31 | Warnings,
32 | NonEmptyChain[SemanticError[S]],
33 | A
34 | ]
35 |
36 | final type ProcessResult = Result[C]
37 |
38 | def process(
39 | ast: Ast[S],
40 | init: C
41 | ): ProcessResult
42 | }
43 |
--------------------------------------------------------------------------------
/semantics/src/main/scala/aqua/semantics/expr/func/CoSem.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.semantics.expr.func
18 |
19 | import aqua.raw.ops.{FuncOp, ParTag}
20 | import aqua.parser.expr.func.CoExpr
21 | import aqua.raw.Raw
22 | import aqua.semantics.Prog
23 | import cats.syntax.applicative.*
24 | import cats.Monad
25 |
26 | class CoSem[S[_]](val expr: CoExpr[S]) extends AnyVal {
27 |
28 | def program[Alg[_]: Monad]: Prog[Alg, Raw] =
29 | Prog.after[Alg, Raw] {
30 | case FuncOp(g) =>
31 | ParTag.Detach.wrap(g).toFuncOp.pure[Alg]
32 | case g => g.pure[Alg]
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/semantics/src/main/scala/aqua/semantics/expr/func/ParSem.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.semantics.expr.func
18 |
19 | import aqua.raw.ops.{FuncOp, ParTag}
20 | import aqua.parser.expr.func.ParExpr
21 | import aqua.raw.Raw
22 | import aqua.semantics.Prog
23 | import cats.Monad
24 | import cats.syntax.applicative.*
25 |
26 | class ParSem[S[_]](val expr: ParExpr[S]) extends AnyVal {
27 |
28 | def program[Alg[_]: Monad]: Prog[Alg, Raw] =
29 | Prog.after[Alg, Raw] {
30 | case FuncOp(g) =>
31 | ParTag.Par.wrap(g).toFuncOp.pure[Alg]
32 | case g => g.pure[Alg]
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/semantics/src/main/scala/aqua/semantics/rules/definitions/DefinitionsState.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.semantics.rules.definitions
18 |
19 | import aqua.parser.lexer.{Name, Token}
20 | import aqua.types.Type
21 |
22 | import DefinitionsState.Def
23 |
24 | case class DefinitionsState[S[_]](
25 | definitions: Map[String, Def[S]] = Map.empty[String, Def[S]]
26 | )
27 |
28 | object DefinitionsState {
29 |
30 | final case class Def[S[_]](
31 | name: Name[S],
32 | `type`: Type
33 | )
34 | }
35 |
--------------------------------------------------------------------------------
/semantics/src/main/scala/aqua/semantics/rules/mangler/ManglerAlgebra.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.semantics.rules.mangler
18 |
19 | trait ManglerAlgebra[Alg[_]] {
20 | def rename(name: String): Alg[String]
21 | }
22 |
--------------------------------------------------------------------------------
/semantics/src/main/scala/aqua/semantics/rules/mangler/ManglerInterpreter.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.semantics.rules.mangler
18 |
19 | import aqua.mangler.ManglerState
20 |
21 | import cats.data.State
22 | import monocle.Lens
23 |
24 | class ManglerInterpreter[X](using
25 | lens: Lens[X, ManglerState]
26 | ) extends ManglerAlgebra[State[X, *]] {
27 |
28 | override def rename(name: String): State[X, String] =
29 | apply(_.forbidAndRename(name))
30 |
31 | private def apply[A](f: ManglerState => (ManglerState, A)): State[X, A] =
32 | State.apply(lens.modifyF(f andThen (_.swap)) andThen (_.swap))
33 | }
34 |
--------------------------------------------------------------------------------
/semantics/src/main/scala/aqua/semantics/rules/report/ReportAlgebra.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.semantics.rules.report
18 |
19 | import aqua.parser.lexer.Token
20 |
21 | trait ReportAlgebra[S[_], Alg[_]] {
22 | def error(token: Token[S], hints: List[String]): Alg[Unit]
23 |
24 | def error(token: Token[S], hint: String): Alg[Unit] =
25 | error(token, hint :: Nil)
26 |
27 | def warning(token: Token[S], hints: List[String]): Alg[Unit]
28 |
29 | def warning(token: Token[S], hint: String): Alg[Unit] =
30 | warning(token, hint :: Nil)
31 | }
32 |
--------------------------------------------------------------------------------
/utils/helpers/src/main/scala/aqua/helpers/data/SName.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.helpers.data
18 |
19 | import aqua.errors.Errors.internalError
20 |
21 | /**
22 | * Short for SimpleName. Represents name without `.`
23 | */
24 | final case class SName private (
25 | name: String
26 | ) {
27 |
28 | lazy val toPName: PName =
29 | PName.fromSName(this)
30 | }
31 |
32 | object SName {
33 |
34 | def nameUnsafe(name: String): SName =
35 | if (name.isEmpty || name.contains("."))
36 | internalError(s"Invalid SName: $name")
37 | else SName(name)
38 | }
39 |
--------------------------------------------------------------------------------
/utils/helpers/src/main/scala/aqua/helpers/ext/Extension.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.helpers.ext
18 |
19 | object Extension {
20 |
21 | val aqua = ".aqua"
22 |
23 | // def add '.aqua' extension if there is no one
24 | def add(path: String): String = {
25 | if (path.endsWith(aqua))
26 | path
27 | else
28 | path + aqua
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/utils/helpers/src/main/scala/aqua/helpers/syntax/eithert.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.syntax
18 |
19 | import cats.Functor
20 | import cats.data.{EitherT, Validated}
21 | import cats.syntax.functor.*
22 |
23 | object eithert {
24 |
25 | extension (e: EitherT.type) {
26 |
27 | /**
28 | * Converts a `F[Validated[A, B]]` into an `EitherT[F, A, B]`.
29 | */
30 | def fromValidatedF[F[_]: Functor, A, B](v: F[Validated[A, B]]): EitherT[F, A, B] =
31 | EitherT(v.map(_.toEither))
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/utils/helpers/src/main/scala/aqua/helpers/syntax/list.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.helpers.syntax
18 |
19 | import scala.annotation.tailrec
20 |
21 | object list {
22 |
23 | extension [A](l: List[A]) {
24 |
25 | def updateFirst[B >: A](p: A => Boolean, f: A => B): List[B] = {
26 | @tailrec
27 | def update(left: List[B], right: List[A]): List[B] =
28 | right match {
29 | case a :: tail if p(a) => left.reverse ::: f(a) :: tail
30 | case a :: tail => update(a :: left, tail)
31 | case Nil => left.reverse
32 | }
33 |
34 | update(Nil, l)
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/utils/helpers/src/main/scala/aqua/helpers/syntax/reader.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.helpers.syntax
18 |
19 | import cats.data.{Reader, State}
20 |
21 | object reader {
22 |
23 | extension [S, A](r: Reader[S, A]) {
24 | def toState: State[S, A] = State.inspect(r.run)
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/utils/logging/src/main/scala/aqua/logging/LogLevel.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Fluence DAO
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as
6 | * published by the Free Software Foundation, version 3.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | */
16 |
17 | package aqua.logging
18 |
19 | import scribe.Level
20 |
21 | object LogLevel {
22 |
23 | val stringToLogLevel: Map[String, Level] = Map(
24 | ("debug" -> Level.Debug),
25 | ("trace" -> Level.Trace),
26 | ("info" -> Level.Info),
27 | ("off" -> Level.Fatal),
28 | ("warn" -> Level.Warn),
29 | ("error" -> Level.Error),
30 | ("all" -> Level.Trace)
31 | )
32 | }
33 |
--------------------------------------------------------------------------------