Compare commits

...

124 Commits

Author SHA1 Message Date
Anatolios Laskaris
31a3ec9eae
chore: Update renovate (#1185)
Update renovate
2024-09-04 19:36:15 +03:00
renovate[bot]
3f4abfbf4f
chore(deps): update dependency com.eed3si9n:sbt-buildinfo to v0.12.0 (#1168)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-15 11:10:09 +00:00
renovate[bot]
cc269aec4d
chore(deps): update dependency com.eed3si9n:sbt-assembly to v2.2.0 (#1167)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-15 10:37:02 +00:00
renovate[bot]
1d8019ed87
chore(deps): update dependency sbt/sbt to v1.10.1 (#1170)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-15 13:06:15 +03:00
InversionSpaces
b0f3a8c21e
fix(compiler): Fix CRDT Map in array handling [LNG-370] (#1171)
* Stricten CollectibleType

* Add test

* Add comment
2024-07-12 16:06:14 +07:00
fluencebot
af3fc24adb
chore(main): release aqua 0.14.11 (#1158)
* chore(main): release aqua 0.14.11

* chore: Bump aqua version to 0.14.11
2024-07-05 15:34:20 +02:00
InversionSpaces
1c76f75d80
feat(compiler): Allow renaming imports with qualified names [LNG-361] (#1136)
* Reverse ability search order

* Gather arrows from imported services

* Add test

* Refactor AquaContext

* Add test for abilities

* Rewrite parsing

* Update cache

* Make method private

* Use only PName in pick

* Rewrite picking (Compilation savepoint)

* Fix PName.value

* Linearize modules, make tests compile

* Make unit tests pass (Savepoint)

* Refactor a little

* Remove declared argument

* Refactor

* Move scoped to Picker

* Refactor locations to typed names

* Fix pickHeader

* Implement scoped for LspContext

* Refactor exports, rethink HeaderSem monoid

* Fix AquaContext (Savepoint)

* Fix import handling

* Remove println

* Remove unused fields

* Add header to SName.scala

* Add simple test

* Add merge test

* Add renaming test

* Refactor module to separate class

* Add comments

* Remove setAbility method

* Refactor exports handling

* Remove unnecessary variable

* Add integration tests
2024-07-03 20:41:31 +07:00
Dima
4d49279569
feat(compiler): Add feature to insert map from a function result with correct type [LNG-367] (#1159) 2024-07-01 19:58:29 +07:00
InversionSpaces
4ad0655da6
chore: Update files headers to AGPLv3 (#1161) 2024-06-24 12:20:27 +00:00
renovate[bot]
d6178f2203
chore(deps): update dependency org.scalatest:scalatest to v3.2.19 (#1165)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-06-24 11:32:03 +00:00
InversionSpaces
223a381a47
chore: Update LICENSE to AGPLv3 (#1160)
Update LICENSE to AGPLv3
2024-06-21 12:01:06 +00:00
Dima
77b7b9b4bd
fix(compiler): Push to stream in closures [LNG-365] (#1157) 2024-06-18 16:57:55 +03:00
fluencebot
1563f7cdd8
chore(main): release aqua 0.14.10 (#1152) 2024-06-07 09:35:50 +00:00
Dima
037532fb85
feat(api, lsp): Case classes exported to JS as normal JSONs (#1151) 2024-06-07 11:38:37 +03:00
fluencebot
af741c3141
chore(main): release aqua 0.14.9 (#1150) 2024-06-06 10:35:59 +00:00
Dima
934c20c98a
feat(compiler): CRDT-maps implementation (#1142) 2024-06-06 04:24:47 +00:00
renovate[bot]
dad8db54cf
chore(deps): update catsv to v2.12.0 (#1146)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-06-03 13:06:50 +00:00
Dima
40cf81efe2
chore(deps): update dependency scalajs to v0.16.0 (#1149)
update scalajs to 0.16
2024-06-03 12:31:43 +00:00
renovate[bot]
534ab1d952
chore(deps): update dependency prettier to v3.3.0 (#1147)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-06-03 12:29:13 +03:00
fluencebot
339400fe52
chore(main): release aqua 0.14.8 (#1145) 2024-05-29 06:35:44 +00:00
renovate[bot]
cff7f949cc
chore(deps): update dependency com.lihaoyi:sourcecode to v0.4.2 (#1143)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-28 17:49:50 +00:00
renovate[bot]
0d9b5241c7
chore(deps): update dependency ts-jest to v29.1.3 (#1144)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-28 17:11:00 +00:00
Dima
7468f6fd18
chore: Add extension to imports on preparing import tokens (#1139) 2024-05-20 07:55:09 +00:00
renovate[bot]
e0513a6218
chore(deps): update all github-actions (major) (#1141)
chore(deps): update all github-actions

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-20 06:54:49 +00:00
renovate[bot]
32b9043e81
chore(deps): update dependency scala to v3.4.2 (#1140)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-20 06:22:39 +00:00
fluencebot
aa986ca6e8
chore(main): release aqua 0.14.7 (#1133)
* chore(main): release aqua 0.14.7

* chore: Bump aqua version to 0.14.7
2024-05-14 12:21:03 +00:00
Dima
35db82c767
fix(lsp): Go-to-definition for used types (LNG-345) (#1128) 2024-05-14 11:36:25 +00:00
InversionSpaces
faf5b8071f
feat(compiler): Allow redeclaring services (and abilities) [LNG-360] (#1135)
* Reverse ability search order

* Gather arrows from imported services

* Add test

* Refactor AquaContext

* Add test for abilities

* Update cache
2024-05-10 12:43:52 +02:00
Dima
6cc068ac36
fix(lsp): Plugin throws OOM on big projects (#1134) 2024-05-07 11:58:37 +02:00
InversionSpaces
9c23a9d4ef
feat(compiler): Allow redeclaring functions [LNG-357] (#1127)
* Allow dots in use ... as

* Add tests

* Refactor implicits

* Use QName in module name

* Fix test

* Refactor declares

* Add PName

* Propagate nested abilities

* Fix compilation

* Do not propagate context

* Use alignCombine

* Add test

* Add more tests

* Refactor test

* Remove unused function

* Refactor test

* Refactor, add comments

* Checkout aqua-src
2024-04-25 10:40:55 +00:00
InversionSpaces
f0ad76189a
chore: Fix e2e (#1132)
Flox -> cli
2024-04-25 13:12:32 +03:00
fluencebot
04f8bd2f68
chore(main): release aqua 0.14.6 (#1111) 2024-04-19 10:03:27 +00:00
renovate[bot]
e9420878f8
chore(deps): update dependency com.github.sbt:sbt-native-packager to v1.10.0 (#1121)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-04-18 09:09:40 +00:00
renovate[bot]
1ba7ae38ec
chore(deps): update dependency com.lihaoyi:sourcecode to v0.4.1 (#1125)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-04-18 08:41:43 +00:00
Dima
e6c5d0039f
fix(compiler): Return error if SemanticError occures [LNG-356] (#1126) 2024-04-17 12:40:19 +00:00
InversionSpaces
f29e44e52a
fix(compiler): Refactor header semantics [LNG-352] (#1113)
* Initial

* Fix import

* Refactor RawSemantics

* Refactor RawSemantics

* Remove initCtx for export

* Add fromInit

* Remove setInit

* Use init ctx

* Add a hack to ModuleSem

* Remove initCtx

* Refactor HeaderSem finalization

* Remove RawContext#init

* Combine with semigroup op

* Remove unnecessary typeclass

* Remove unused typeclass

* Remove unnecessary typeclass

* Remove unnecessary monoid

* Remove contants from monoid

* Fix tests

* Remove unused monoids

* Refactor declares

* Refactor module sem

* Refactor module sem

* Update LspSemantics

* Remove unused typeclass

* Remove unnecessary method

* Add comments
2024-04-09 12:58:12 +02:00
Dima
07bea1a909
fix(lsp): Fix go-to-definition for abilities as arguments in functions [LNG-343] (#1116) 2024-04-08 12:43:30 +00:00
Dima
49729ac40a
fix(compiler): Ordering in option inliner [LNG-351] (#1114) 2024-04-08 09:24:55 +00:00
renovate[bot]
331d497eb5
fix(deps): update dependency @fluencelabs/fluence-network-environment to v1.2.1 (#1115)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-04-05 09:21:32 +00:00
InversionSpaces
9dc9e55973
fix: Allow spaces after aqua header (#1112)
* Allow spaces after aqua header

* Fix test, add spaces after star to parsing
2024-04-02 09:55:25 +00:00
Dima
8f06ac1cba
fix(compiler): Redeclare imports [LNG-344] (#1109) 2024-04-02 09:04:01 +00:00
renovate[bot]
cc69e696dc
chore(deps): update dependency co.fs2:fs2-io to v3.10.2 (#1106)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-04-02 08:22:54 +00:00
renovate[bot]
11498f0996
chore(deps): update dependency scala to v3.4.1 (#1107)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-04-02 07:52:53 +00:00
renovate[bot]
1ef0dafe2e
fix(deps): update dependency @fluencelabs/fluence-network-environment to v1.2.0 (#1110)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-04-02 07:26:46 +00:00
fluencebot
0a49f22365
chore(main): release aqua 0.14.5 (#1098)
* chore(main): release aqua 0.14.5

* chore: Bump aqua version to 0.14.5
2024-03-28 11:43:47 +00:00
Dima
14748c7646
fix(compiler): Create restrictions in inliner [LNG-346] (#1099) 2024-03-28 11:10:13 +00:00
renovate[bot]
320b516807
chore(deps): update dependency sbt/sbt to v1.9.9 (#1104)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-25 05:24:50 +00:00
renovate[bot]
d8b7c8cba3
chore(deps): update dependency co.fs2:fs2-io to v3.10.1 (#1105)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-25 07:08:35 +03:00
folex
92d0450481
fix(ci): disable system services in Nox (#1100) 2024-03-08 16:59:24 -03:00
renovate[bot]
6aa78eeb6f
fix(deps): update dependency @fluencelabs/js-client to v0.9.0 (#1088)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: drrtuy <drrtuy@gmail.com>
Co-authored-by: Valery Antopol <valery.antopol@gmail.com>
Co-authored-by: InversionSpaces <InversionSpaces@vivaldi.net>
2024-03-07 12:36:22 +00:00
InversionSpaces
5c7f6a89c6
feat(compiler): Reimplement noXor compiler flag [LNG-347] (#1096)
* Fix imports

* Remove constants

* Return constants

* Refactor

* Add config

* Do not propagate errors

* Do not propagate errors through on

* Rename hop ephemeral streams

* Add comments

* Add tests
2024-03-05 10:45:21 +07:00
fluencebot
c444d24f89
chore(main): release aqua 0.14.4 (#1095)
* chore(main): release aqua 0.14.4

* chore: Bump aqua version to 0.14.4
2024-03-01 10:24:02 +03:00
InversionSpaces
a6c8e75c27
fix(compiler): Import abilities with use [LNG-324] (#1077)
* Add IntoApply

* Savepoint

* Add backtrack

* Return ability name

* Add service resolution

* Return import ability

* Add test

* Rewrite toDottedName

* Rewrite ability resolution

* Fix offset

* Add tests

* Add test

* Add comments

* Add test

---------

Co-authored-by: Dima <dmitry.shakhtarin@fluence.ai>
2024-02-29 14:56:05 +01:00
Dima
d7fef3db5f
fix(compiler): Bug in renaming [LNG-346] (#1094) 2024-02-29 09:23:34 +00:00
fluencebot
6e9689945d
chore(main): release aqua 0.14.3 (#1092) 2024-02-29 09:00:05 +00:00
InversionSpaces
23aba18c7d
fix(compiler): Change noEmptyResponse default to true (#1093)
Change noEmptyResponse default to true
2024-02-29 11:38:37 +03:00
renovate[bot]
96c1675350
chore(deps): update dependency @fluencelabs/interfaces to v0.12.0 (#1091)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-26 13:53:04 +00:00
renovate[bot]
5216637fcd
chore(deps): update dependency @fluencelabs/aqua-lib to v0.10.2 (#1090)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-26 13:28:59 +00:00
Dima
3e9d385668
fix(language-server): Name clashing in LSP [LNG-342] (#1089) 2024-02-26 13:00:25 +00:00
fluencebot
27f132f18a
chore(main): release aqua 0.14.2 (#1087) 2024-02-21 14:43:14 +03:00
Dima
b22762ca6d
fix(compiler): Recursively find abilities [LNG-338] (#1086) 2024-02-21 14:11:21 +03:00
fluencebot
df5eb29d92
chore(main): release aqua 0.14.1 (#1064) 2024-02-20 14:15:27 +00:00
Dima
245f6640f8
feat(language-server): Resolve paths for imports (#1079) 2024-02-20 12:52:54 +00:00
renovate[bot]
e2b150a786
chore(deps): update dependency @fluencelabs/aqua-lib to v0.10.1 (#1085)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-20 12:21:30 +00:00
renovate[bot]
82ac0b2d41
chore(deps): update dependency scala to v3.4.0 (#1081)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-20 11:48:59 +00:00
Dima
3cd31c5827
feat(language-server): Add types for types in LSP API (#1078) 2024-02-20 12:02:55 +01:00
renovate[bot]
9423ffc509
chore(deps): update dependency org.scalatest:scalatest to v3.2.18 (#1073)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-12 09:30:27 +00:00
renovate[bot]
9444ce745a
chore(deps): update dependency org.scalatestplus:scalacheck-1-17 to v3.2.18.0 (#1074)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-12 09:02:50 +00:00
renovate[bot]
f4cc7818f4
fix(deps): update dependency @fluencelabs/js-client to v0.8.3 (#1072)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-12 08:43:59 +00:00
Dima
17fb77c40f
fix(compiler): Use strict to check types availability [LNG-334] (#1071) 2024-02-12 09:23:14 +01:00
Dima
f7194f0a54
feat(language-server): Support declares and exports in LSP [LNG-304, LNG-319] (#1070)
Co-authored-by: InversionSpaces <inversionspaces@vivaldi.net>
2024-02-07 09:21:42 +00:00
renovate[bot]
d03211b492
fix(deps): update dependency @fluencelabs/js-client to v0.8.1 (#1065)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-07 07:27:52 +00:00
renovate[bot]
a8ae49b55b
fix(deps): update dependency @fluencelabs/js-client to v0.8.0 (#1063)
* fix(deps): update dependency @fluencelabs/js-client to v0.8.0

* Remove npm

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Akim Mamedov <akim99999999@gmail.com>
2024-01-31 23:57:56 +07:00
fluencebot
d30b6e1b38
chore(main): release aqua 0.14.0 (#1048) 2024-01-30 12:24:50 +03:00
Dima
1a0b3a22c1
fix(compiler): Streams in closures generates wrong AIR (#1055) 2024-01-30 11:34:50 +03:00
renovate[bot]
11f8d3b11b
fix(deps): update dependency @fluencelabs/js-client to v0.7.0 (#1056)
* fix(deps): update dependency @fluencelabs/js-client to v0.7.0

* fix(ci): nox:minimal_unstable => nox:unstable

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: folex <0xdxdy@gmail.com>
2024-01-29 15:30:50 +00:00
renovate[bot]
d828cbd3bd
chore(deps): update dependency loglevel to v1.9.1 (#1058)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-29 17:15:58 +03:00
renovate[bot]
3a79239022
chore(deps): update dependency @fluencelabs/interfaces to v0.11.0 (#1057)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-29 16:33:37 +03:00
renovate[bot]
0e44e7a0b1
chore(deps): update dependency @types/node to v18.19.10 (#1060)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-29 12:21:06 +00:00
renovate[bot]
d14d36215c
chore(deps): update dependency ts-jest to v29.1.2 (#1061)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-29 12:00:36 +00:00
renovate[bot]
f085d207bb
chore(deps): update jest monorepo (#1062)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-29 11:39:20 +00:00
renovate[bot]
7694514d29
chore(deps): update all github-actions (#1059)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-29 11:17:39 +00:00
InversionSpaces
7b6c7245ec
perf(compiler): Optimize Linker [LNG-321] (#1049)
* Refactor parser

* Refactor parser

* Refactor parser

* Refactor parser

* Savepoint

* Savepoint

* Refactor

* Fix unit test

* Remove file

* Filter exported modules

* Fix test

* Restore Test.scala

* Add comments
2024-01-22 16:01:54 +01:00
Dima
abcb63db3b
perf(compiler): Inliner optimization [LNG-322] (#1047) 2024-01-22 10:08:06 +00:00
renovate[bot]
27704a9169
chore(deps): update dependency @fluencelabs/interfaces to v0.10.0 (#1051)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-19 12:45:05 +00:00
renovate[bot]
f94f38327a
fix(deps): update dependency @fluencelabs/js-client to v0.6.0 (#1050)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-19 12:31:32 +00:00
renovate[bot]
e323368b69
chore(deps): update dependency org.scala-js:sbt-scalajs to v1.15.0 (#1040)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-19 12:17:19 +00:00
renovate[bot]
ff1800c674
chore(deps): update dependency co.fs2:fs2-io to v3.10-365636d (#1039)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-19 15:02:57 +03:00
InversionSpaces
d057a5e695
feat(compiler)!: Force aqua header [LNG-308] (#1028)
* Refactor

* deprecate `module`, force `aqua`, fix integration and unit tests

* fix ImportFromSpec

* Savepoint

* Fix

* Semantic error on module header

* Refactor

* Add begin token

* Fix tests

* Remove DHT examples

* Use git aqua-lib

* Fix headers

* Fix headers

* Fix headers

* Fix headers

* Fix headers

* Fix headers

* Fix headers

* Fix test

* Unignore tests

* Update aqua-lib

---------

Co-authored-by: DieMyst <dmitry.shakhtarin@fluence.ai>
2024-01-18 10:43:23 +01:00
InversionSpaces
34e274d45e
chore(tests): Remove usage of onConnectionStateChange [LNG-291] (#1046)
Remove usage of onConnectionStateChange
2024-01-16 13:19:09 +03:00
fluencebot
098fac79ba
chore(main): release aqua 0.13.4 (#1036) 2024-01-11 11:26:38 +03:00
Dima
85f3ecdf39
fix(compiler): Add outside context to closures [LNG-317] (#1038) 2024-01-11 11:00:32 +03:00
InversionSpaces
d46ee0347f
fix(compiler): Type check arrow calls on services and abilities [LNG-315] (#1037)
* Rewrite resolveIntoArrow

* Refactor

* Refactor resolveIntoCopy

* Refactor resolveIntoIndex

* Refactor resolveIntoField

* Fix test

* Remove package-lock.json

* Add tests

* Add comment
2024-01-10 11:36:20 +01:00
Dima
5241f522d8
fix(compiler): Passing closures with abilities [LNG-314] (#1035) 2024-01-09 19:31:37 +03:00
InversionSpaces
d5cd77bb86
feat(compiler): Enhance message of type error [LNG-313] (#1033) 2024-01-09 15:15:27 +03:00
InversionSpaces
ae32f80277
feat(compiler): for ... rec [LNG-307] (#1026)
* Add parser

* Add semantics

* Add inlining

* Add range test

* Rewrite to for ... rec

* Rewrite tests

* Fix import

* Add nested test

* Remove only

* Add yes|no test

* Add multi rec test

* Add pipeline test

* Unignore tests

* Change timeouts

* Add remote rec test

* Fix integration tests

* Add parser test

* Add semantics test

* Add inlining test

* Add comment
2024-01-09 12:48:02 +01:00
fluencebot
9aec470d38
chore(main): release aqua 0.13.3 (#1025) 2023-12-25 12:51:54 +00:00
renovate[bot]
851a66fb5f
fix(deps): update dependency @fluencelabs/js-client to v0.5.5 (#1020)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-22 14:32:26 +00:00
renovate[bot]
55836d5a9d
chore(deps): update dependency @fluencelabs/aqua-lib to v0.9.0 (#1030)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-21 18:00:09 +01:00
InversionSpaces
a4d8ee7083
fix(compiler): Do not generate hop back with empty response by default [LNG-305] (#1019)
Change default flag, add test
2023-12-21 11:17:50 +00:00
InversionSpaces
5bc01a9c02
feat(lsp-api): Fix interface definition [LNG-298] (#1027)
* Fix interface definition

* Fix comment
2023-12-19 17:01:34 +01:00
InversionSpaces
33a2ca87e0
feat(api): Refactor js api interfaces (#1024)
Change types
2023-12-18 12:48:03 +01:00
fluencebot
7fe0212761
chore(main): release aqua 0.13.2 (#1016)
* chore(main): release aqua 0.13.2

* chore: Bump aqua version to 0.13.2
2023-12-15 18:27:46 +00:00
InversionSpaces
6732f8f2cc
fix(tests): Lower tests size (#1018)
* Lower tests size

* Remove prints
2023-12-14 10:27:14 +01:00
renovate[bot]
bb013d79f7
chore(deps): update dependency @fluencelabs/aqua-lib to v0.8.2 (#1017)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-14 11:35:06 +03:00
InversionSpaces
f7bfa8317b
feat(api): Accept structured imports [LNG-288] (#989)
* Refactor sources

* Fix FuncCompiler compilation

* Normalize imports

* Add relative imports

* Remove Prelude

* Remove import

* Add a log

* Add more logs

* Use snapshot of fs2

* Remove prints

* Add comments

* Savepoint

* Rewrite imports resolution

* Fix relative import

* Add comment

* Added comments

* Fix comment

* Add comments

* Refactor

* Refactor

* Add tests

* Fix tests

* Update tests

* Add comment

* Lower number of tests

* Comment, rename

* Add comment

* Add emptiness check
2023-12-13 17:19:34 +01:00
renovate[bot]
00252fe8a7
chore(deps): update all github-actions (major) (#1014)
chore(deps): update all github-actions

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-13 11:46:28 +02:00
renovate[bot]
2f135e4fd2
chore(deps): update dependency com.outr:scribe to v3.13.0 (#1008)
* chore(deps): update dependency com.outr:scribe to v3.13.0

* Fix field

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: InversionSpaces <inversionspaces@vivaldi.net>
2023-12-11 12:26:15 +01:00
renovate[bot]
d97de9c83f
chore(deps): update dependency @types/node to v18.19.3 (#1012)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-11 11:46:35 +01:00
renovate[bot]
409570afde
chore(deps): update dependency typescript to v5.3.3 (#1013)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-11 09:58:51 +00:00
renovate[bot]
39a23db2bf
chore(deps): update dependency ts-node to v10.9.2 (#1010)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-11 09:43:11 +00:00
renovate[bot]
7689ee0fd9
chore(deps): update dependency prettier to v3.1.1 (#1015)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-11 09:29:09 +00:00
fluencebot
051aa41715
chore(main): release aqua 0.13.1 (#988) 2023-12-07 16:45:46 +03:00
Anatolios Laskaris
c474a77e76
chore: Fix fcli e2e (#1006)
Fix e2e
2023-12-07 15:02:01 +02:00
Dima
74d02e1f63
feat(language-server): Pass token types to LSP [LNG-285] (#999) 2023-12-07 12:06:51 +00:00
Dima
4cecab1a26
fix(compiler): Use correct empty stream as argument [LNG-280, LNG-292] (#967) 2023-11-28 10:45:12 +00:00
renovate[bot]
6329e42f56
chore(deps): update dependency @fluencelabs/aqua-lib to v0.8.1 (#976)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Dima <dmitry.shakhtarin@fluence.ai>
2023-11-27 12:04:23 +00:00
renovate[bot]
9d0fb2b841
fix(deps): update dependency @fluencelabs/js-client to v0.5.3 (#978)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-11-27 11:48:09 +00:00
InversionSpaces
e65836e3c8
fix(tests): Fix imports in integration tests (#998)
Fix imports
2023-11-27 12:35:15 +01:00
InversionSpaces
b24fcf686f
fix(e2e): Use main branch for fcli (#987)
Use main branch
2023-11-27 13:20:13 +02:00
renovate[bot]
4342812450
chore(deps): update dependency com.eed3si9n:sbt-assembly to v2.1.5 (#991)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-11-27 14:18:54 +03:00
renovate[bot]
011a1d7260
chore(deps): update dependency @fluencelabs/interfaces to v0.9.0 (#990)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-11-27 11:07:13 +00:00
Anatolios Laskaris
2ac69616b5
chore: Fix e2e (#997)
Fix e2e
2023-11-27 12:51:37 +02:00
InversionSpaces
2d4b2aece4
fix(compiler): Allow returning resolved service as ability [LNG-266] (#977)
* Refactor

* Refactor type system

* Remove println

* Fix renaming

* Add unit tests

* Do not convert to call arrow

* Check ability

* Refactor captured values resolution

* Remove println

* Fix fields gathering

* Remove println

* Remove println

* Fix renaming, export ability

* Rename only abilities

* Fix unit tests

* Fix captured arrows renaming

* Add comments

* Refactor

* Rename only arrows

* Add comments, refactor

* Add comments

* Rename method

* Add integration test

---------

Co-authored-by: Anatolios Laskaris <github_me@nahsi.dev>
Co-authored-by: Dima <dmitry.shakhtarin@fluence.ai>
2023-11-23 10:12:44 +00:00
589 changed files with 21267 additions and 6159 deletions

View File

@ -12,6 +12,7 @@ services:
- 7771:7771
- 9991:9991
command:
- --enable-system-services=none
- --aqua-pool-size=2
- -t=7771
- -w=9991
@ -34,6 +35,7 @@ services:
- 7772:7772
- 9992:9992
command:
- --enable-system-services=none
- --aqua-pool-size=2
- -t=7772
- -w=9992
@ -55,6 +57,7 @@ services:
- 7773:7773
- 9993:9993
command:
- --enable-system-services=none
- --aqua-pool-size=2
- -t=7773
- -w=9993
@ -76,6 +79,7 @@ services:
- 7774:7774
- 9994:9994
command:
- --enable-system-services=none
- --aqua-pool-size=2
- -t=7774
- -w=9994
@ -97,6 +101,7 @@ services:
- 7775:7775
- 9995:9995
command:
- --enable-system-services=none
- --aqua-pool-size=2
- -t=7775
- -w=9995
@ -118,6 +123,7 @@ services:
- 7776:7776
- 9996:9996
command:
- --enable-system-services=none
- --aqua-pool-size=2
- -t=7776
- -w=9996

View File

@ -1,3 +1,3 @@
{
".": "0.13.0"
".": "0.14.11"
}

36
.github/renovate.json vendored
View File

@ -1,38 +1,8 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:base",
":semanticCommitTypeAll(chore)"
"github>fluencelabs/renovate",
"github>fluencelabs/renovate:npm"
],
"respectLatest": false,
"ignorePaths": ["api/aqua-api-example/**"],
"enabledManagers": ["sbt", "npm", "github-actions"],
"rangeStrategy": "pin",
"schedule": "every weekend",
"packageRules": [
{
"matchManagers": ["npm"],
"matchPackagePatterns": [
"@fluencelabs/.*"
],
"semanticCommitType": "fix",
"semanticCommitScope": "deps",
"schedule": "at any time"
},
{
"matchDepTypes": ["devDependencies"],
"prPriority": -1,
"semanticCommitType": "chore",
"semanticCommitScope": "deps"
},
{
"matchUpdateTypes": ["major"],
"prConcurrentLimit": 1
},
{
"matchManagers": ["github-actions"],
"groupName": "all github-actions",
"prPriority": -1
}
]
"enabledManagers": ["npm"]
}

View File

@ -38,20 +38,17 @@ jobs:
fcli-snapshot:
name: "fcli"
needs: aqua
uses: fluencelabs/flox/.github/workflows/snapshot.yml@main
uses: fluencelabs/cli/.github/workflows/snapshot.yml@main
with:
aqua-snapshots: "${{ needs.aqua.outputs.aqua-snapshots }}"
fcli:
needs: aqua
uses: fluencelabs/fluence-cli/.github/workflows/tests.yml@use-js-client-0.5.0
uses: fluencelabs/cli/.github/workflows/tests.yml@main
with:
aqua-snapshots: "${{ needs.aqua.outputs.aqua-snapshots }}"
ref: use-js-client-0.5.0
registry:
needs:
- fcli-snapshot
uses: fluencelabs/registry/.github/workflows/tests.yml@main
with:
fcli-version: "${{ needs.fcli-snapshot.outputs.version }}"
# registry:
# needs:
# - fcli-snapshot
# uses: fluencelabs/registry/.github/workflows/tests.yml@main

View File

@ -44,7 +44,7 @@ jobs:
run: sbt ";language-server-apiJS/fullBundleJS;aqua-apiJS/fullBundleJS"
- name: Import secrets
uses: hashicorp/vault-action@v2.7.3
uses: hashicorp/vault-action@v3.0.0
with:
url: https://vault.fluence.dev
path: jwt/github
@ -57,12 +57,12 @@ jobs:
kv/npmjs/fluencebot token | NODE_AUTH_TOKEN
- name: Setup pnpm
uses: pnpm/action-setup@v2.4.0
uses: pnpm/action-setup@v4.0.0
with:
version: 8
- name: Setup node with self-hosted npm registry
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: "18"
registry-url: "https://registry.npmjs.org"

View File

@ -24,7 +24,7 @@ jobs:
steps:
- name: Run release-please
id: release
uses: google-github-actions/release-please-action@v3
uses: google-github-actions/release-please-action@v4
with:
token: ${{ secrets.FLUENCEBOT_RELEASE_PLEASE_PAT }}
command: manifest
@ -63,12 +63,12 @@ jobs:
sed -i 's/aquaVersion =.*/aquaVersion = "${{ steps.version.outputs.version }}"/g' build.sbt
- name: Setup pnpm
uses: pnpm/action-setup@v2.4.0
uses: pnpm/action-setup@v4.0.0
with:
version: 8
- name: Setup node with self-hosted npm registry
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: "18"
registry-url: "https://registry.npmjs.org"
@ -91,7 +91,7 @@ jobs:
run: pnpm -r i
- name: Commit version bump
uses: stefanzweifel/git-auto-commit-action@v4
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "chore: Bump aqua version to ${{ steps.version.outputs.version }}"
branch: ${{ fromJson(needs.release-please.outputs.pr).headBranchName }}
@ -133,7 +133,7 @@ jobs:
echo "found any?:" "${{ steps.status.outputs.found }}"
- name: Import secrets
uses: hashicorp/vault-action@v2.7.3
uses: hashicorp/vault-action@v3.0.0
with:
url: https://vault.fluence.dev
path: jwt/github

View File

@ -29,4 +29,4 @@ jobs:
apps: sbt
- name: Run tests
run: sbt test
run: env JAVA_OPTS="-Xmx4G" sbt "headerCheckAll; test"

View File

@ -54,7 +54,7 @@ jobs:
run: sbt ";language-server-apiJS/fastBundleJS;aqua-apiJS/fastBundleJS"
- name: Import secrets
uses: hashicorp/vault-action@v2.7.3
uses: hashicorp/vault-action@v3.0.0
with:
url: https://vault.fluence.dev
path: jwt/github
@ -67,23 +67,23 @@ jobs:
kv/npm-registry/basicauth/ci token | NODE_AUTH_TOKEN
- name: Setup pnpm
uses: pnpm/action-setup@v2.4.0
uses: pnpm/action-setup@v4.0.0
with:
version: 8
- name: Setup node with self-hosted npm registry
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: "18"
registry-url: "https://npm.fluence.dev"
cache: "pnpm"
- run: pnpm -r i
- run: pnpm --filter='!integration-tests' -r i
- name: Set package version
run: node ci.cjs bump-version ${{ steps.version.outputs.id }}
- run: pnpm -r build
- run: pnpm --filter='!integration-tests' -r build
- name: Publish snapshot
id: snapshot

View File

@ -14,7 +14,7 @@ on:
nox-image:
description: "nox image tag"
type: string
default: "fluencelabs/nox:unstable_minimal"
default: "fluencelabs/nox:unstable"
js-client-snapshots:
description: "js-client snapshots"
type: string
@ -37,7 +37,7 @@ jobs:
steps:
- name: Import secrets
uses: hashicorp/vault-action@v2.7.3
uses: hashicorp/vault-action@v3.0.0
with:
url: https://vault.fluence.dev
path: jwt/github
@ -52,7 +52,7 @@ jobs:
kv/slack/node-alerts webhook | INCOMING_WEBHOOK_URL
- name: Login to DockerHub
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: docker.fluence.dev
username: ${{ env.DOCKER_USERNAME }}
@ -68,7 +68,7 @@ jobs:
run: docker pull $NOX_IMAGE
- name: Run nox
uses: isbang/compose-action@v1.5.0
uses: isbang/compose-action@v2.0.0
with:
compose-file: ".github/e2e/docker-compose.yml"
down-flags: "--volumes"
@ -85,12 +85,12 @@ jobs:
run: sbt "aqua-apiJS/fastBundleJS"
- name: Setup pnpm
uses: pnpm/action-setup@v2.4.0
uses: pnpm/action-setup@v4.0.0
with:
version: 8
- name: Setup node with self-hosted registry
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: "18"
registry-url: "https://npm.fluence.dev"

View File

@ -1,5 +1,202 @@
# Changelog
## [0.14.11](https://github.com/fluencelabs/aqua/compare/aqua-v0.14.10...aqua-v0.14.11) (2024-07-03)
### Features
* **compiler:** Add feature to insert map from a function result with correct type [LNG-367] ([#1159](https://github.com/fluencelabs/aqua/issues/1159)) ([4d49279](https://github.com/fluencelabs/aqua/commit/4d49279569b5cfbdf351e9236dd508d9bf51badc))
* **compiler:** Allow renaming imports with qualified names [LNG-361] ([#1136](https://github.com/fluencelabs/aqua/issues/1136)) ([1c76f75](https://github.com/fluencelabs/aqua/commit/1c76f75d80ae958a7eb2bf2aec5c58a5b92c438f))
### Bug Fixes
* **compiler:** Push to stream in closures [LNG-365] ([#1157](https://github.com/fluencelabs/aqua/issues/1157)) ([77b7b9b](https://github.com/fluencelabs/aqua/commit/77b7b9b4bd4e8964b6ceb681750fda27766c16b2))
## [0.14.10](https://github.com/fluencelabs/aqua/compare/aqua-v0.14.9...aqua-v0.14.10) (2024-06-07)
### Features
* **api, lsp:** Case classes exported to JS as normal JSONs ([#1151](https://github.com/fluencelabs/aqua/issues/1151)) ([037532f](https://github.com/fluencelabs/aqua/commit/037532fb858c9ef98ea536e72cc9f71e73a2cfc3))
## [0.14.9](https://github.com/fluencelabs/aqua/compare/aqua-v0.14.8...aqua-v0.14.9) (2024-06-06)
### Features
* **compiler:** CRDT-maps implementation ([#1142](https://github.com/fluencelabs/aqua/issues/1142)) ([934c20c](https://github.com/fluencelabs/aqua/commit/934c20c98a6296f12543d49fe3f438a6dcecbfaf))
## [0.14.8](https://github.com/fluencelabs/aqua/compare/aqua-v0.14.7...aqua-v0.14.8) (2024-05-29)
### Features
* **compiler:** Add extension to imports on preparing import tokens ([7468f6f](https://github.com/fluencelabs/aqua/commit/7468f6fd18a68eadfe1f94b98c19b1be9f38eee8))
## [0.14.7](https://github.com/fluencelabs/aqua/compare/aqua-v0.14.6...aqua-v0.14.7) (2024-05-14)
### Features
* **compiler:** Allow redeclaring functions [LNG-357] ([#1127](https://github.com/fluencelabs/aqua/issues/1127)) ([9c23a9d](https://github.com/fluencelabs/aqua/commit/9c23a9d4efea1b9467057645b6d31b7a0e3df95e))
* **compiler:** Allow redeclaring services (and abilities) [LNG-360] ([#1135](https://github.com/fluencelabs/aqua/issues/1135)) ([faf5b80](https://github.com/fluencelabs/aqua/commit/faf5b8071fc3e272e64355130a99cee9f2cc0f8d))
### Bug Fixes
* **lsp:** Go-to-definition for used types (LNG-345) ([#1128](https://github.com/fluencelabs/aqua/issues/1128)) ([35db82c](https://github.com/fluencelabs/aqua/commit/35db82c7676bbe2ff2b48d08dc604cfe7dd14b7f))
* **lsp:** Plugin throws OOM on big projects ([#1134](https://github.com/fluencelabs/aqua/issues/1134)) ([6cc068a](https://github.com/fluencelabs/aqua/commit/6cc068ac36a6af2a96a793278c8f721c8165b67d))
## [0.14.6](https://github.com/fluencelabs/aqua/compare/aqua-v0.14.5...aqua-v0.14.6) (2024-04-18)
### Bug Fixes
* Allow spaces after aqua header ([#1112](https://github.com/fluencelabs/aqua/issues/1112)) ([9dc9e55](https://github.com/fluencelabs/aqua/commit/9dc9e5597301d327c157780bbc2f58dda89a5e54))
* **compiler:** Ordering in option inliner [LNG-351] ([#1114](https://github.com/fluencelabs/aqua/issues/1114)) ([49729ac](https://github.com/fluencelabs/aqua/commit/49729ac40aba56d303e42fc8023170ae8b5f7fd8))
* **compiler:** Redeclare imports [LNG-344] ([#1109](https://github.com/fluencelabs/aqua/issues/1109)) ([8f06ac1](https://github.com/fluencelabs/aqua/commit/8f06ac1cba7f4ce8588c1df1befd6bb99d957f2a))
* **compiler:** Refactor header semantics [LNG-352] ([#1113](https://github.com/fluencelabs/aqua/issues/1113)) ([f29e44e](https://github.com/fluencelabs/aqua/commit/f29e44e52acd3d6519cd36feadf22414b328a6f0))
* **compiler:** Return error if SemanticError occures [LNG-356] ([#1126](https://github.com/fluencelabs/aqua/issues/1126)) ([e6c5d00](https://github.com/fluencelabs/aqua/commit/e6c5d0039f1556c9adafa1714ae048a25f252d29))
* **deps:** update dependency @fluencelabs/fluence-network-environment to v1.2.0 ([#1110](https://github.com/fluencelabs/aqua/issues/1110)) ([1ef0daf](https://github.com/fluencelabs/aqua/commit/1ef0dafe2eae21313311317cd6571d200d4a7739))
* **deps:** update dependency @fluencelabs/fluence-network-environment to v1.2.1 ([#1115](https://github.com/fluencelabs/aqua/issues/1115)) ([331d497](https://github.com/fluencelabs/aqua/commit/331d497eb5baee156a1aa09ea699e461d2d9b9c5))
* **lsp:** Fix go-to-definition for abilities as arguments in functions [LNG-343] ([#1116](https://github.com/fluencelabs/aqua/issues/1116)) ([07bea1a](https://github.com/fluencelabs/aqua/commit/07bea1a909d9d66b6eb4a32cb99a990458c3f77e))
## [0.14.5](https://github.com/fluencelabs/aqua/compare/aqua-v0.14.4...aqua-v0.14.5) (2024-03-28)
### Features
* **compiler:** Reimplement `noXor` compiler flag [LNG-347] ([#1096](https://github.com/fluencelabs/aqua/issues/1096)) ([5c7f6a8](https://github.com/fluencelabs/aqua/commit/5c7f6a89c60a199a73e7002481b9578c63ffce32))
### Bug Fixes
* **ci:** disable system services in Nox ([#1100](https://github.com/fluencelabs/aqua/issues/1100)) ([92d0450](https://github.com/fluencelabs/aqua/commit/92d04504819f75e93ac555fd8d28a02b5893d817))
* **compiler:** Create restrictions in inliner [LNG-346] ([#1099](https://github.com/fluencelabs/aqua/issues/1099)) ([14748c7](https://github.com/fluencelabs/aqua/commit/14748c7646dad9970058c298f8c919a04e54dfb7))
* **deps:** update dependency @fluencelabs/js-client to v0.9.0 ([#1088](https://github.com/fluencelabs/aqua/issues/1088)) ([6aa78ee](https://github.com/fluencelabs/aqua/commit/6aa78eeb6fae3ca7e2060ba962496b502ae54592))
## [0.14.4](https://github.com/fluencelabs/aqua/compare/aqua-v0.14.3...aqua-v0.14.4) (2024-02-29)
### Bug Fixes
* **compiler:** Bug in renaming [LNG-346] ([#1094](https://github.com/fluencelabs/aqua/issues/1094)) ([d7fef3d](https://github.com/fluencelabs/aqua/commit/d7fef3db5fda6c2dfeacac84c3cff2188538a35a))
* **compiler:** Import abilities with `use` [LNG-324] ([#1077](https://github.com/fluencelabs/aqua/issues/1077)) ([a6c8e75](https://github.com/fluencelabs/aqua/commit/a6c8e75c270efd358908f285310f1f1d177a65fb))
## [0.14.3](https://github.com/fluencelabs/aqua/compare/aqua-v0.14.2...aqua-v0.14.3) (2024-02-29)
### Bug Fixes
* **compiler:** Change `noEmptyResponse` default to `true` ([#1093](https://github.com/fluencelabs/aqua/issues/1093)) ([23aba18](https://github.com/fluencelabs/aqua/commit/23aba18c7d7fb86acd2470474f776f00a78ee9c6))
* **language-server:** Name clashing in LSP [LNG-342] ([#1089](https://github.com/fluencelabs/aqua/issues/1089)) ([3e9d385](https://github.com/fluencelabs/aqua/commit/3e9d3856685f74a6be5d0aa288cd7e4f95010901))
## [0.14.2](https://github.com/fluencelabs/aqua/compare/aqua-v0.14.1...aqua-v0.14.2) (2024-02-21)
### Bug Fixes
* **compiler:** Recursively find abilities [LNG-338] ([#1086](https://github.com/fluencelabs/aqua/issues/1086)) ([b22762c](https://github.com/fluencelabs/aqua/commit/b22762ca6d6ed443a930780c928c7b72ae6a50f6))
## [0.14.1](https://github.com/fluencelabs/aqua/compare/aqua-v0.14.0...aqua-v0.14.1) (2024-02-20)
### Features
* **language-server:** Add types for types in LSP API ([#1078](https://github.com/fluencelabs/aqua/issues/1078)) ([3cd31c5](https://github.com/fluencelabs/aqua/commit/3cd31c5827dfc8208a5cbed0722e3ddeabc7e31f))
* **language-server:** Resolve paths for imports ([#1079](https://github.com/fluencelabs/aqua/issues/1079)) ([245f664](https://github.com/fluencelabs/aqua/commit/245f6640f8f45b92338bb3bb20fbf2d73540b053))
* **language-server:** Support declares and exports in LSP [LNG-304, LNG-319] ([#1070](https://github.com/fluencelabs/aqua/issues/1070)) ([f7194f0](https://github.com/fluencelabs/aqua/commit/f7194f0a54f51b0cc8aa0b4a2b295ec027be8a63))
### Bug Fixes
* **compiler:** Use `strict` to check types availability [LNG-334] ([#1071](https://github.com/fluencelabs/aqua/issues/1071)) ([17fb77c](https://github.com/fluencelabs/aqua/commit/17fb77c40f14b6a1c9b773d58e719d3476fe5414))
* **deps:** update dependency @fluencelabs/js-client to v0.8.0 ([#1063](https://github.com/fluencelabs/aqua/issues/1063)) ([a8ae49b](https://github.com/fluencelabs/aqua/commit/a8ae49b55b86876ac3f961eb6e0b95f062466f70))
* **deps:** update dependency @fluencelabs/js-client to v0.8.1 ([#1065](https://github.com/fluencelabs/aqua/issues/1065)) ([d03211b](https://github.com/fluencelabs/aqua/commit/d03211b492725f37d5e76ffc55861f5161094aae))
* **deps:** update dependency @fluencelabs/js-client to v0.8.3 ([#1072](https://github.com/fluencelabs/aqua/issues/1072)) ([f4cc781](https://github.com/fluencelabs/aqua/commit/f4cc7818f4c9ba5b23ceaf771504bf697e767350))
## [0.14.0](https://github.com/fluencelabs/aqua/compare/aqua-v0.13.4...aqua-v0.14.0) (2024-01-30)
### ⚠ BREAKING CHANGES
* **compiler:** Force `aqua` header [LNG-308] ([#1028](https://github.com/fluencelabs/aqua/issues/1028))
### Features
* **compiler:** Force `aqua` header [LNG-308] ([#1028](https://github.com/fluencelabs/aqua/issues/1028)) ([d057a5e](https://github.com/fluencelabs/aqua/commit/d057a5e69583872f93cdb4d1220d62fe9dfdea50))
### Bug Fixes
* **compiler:** Streams in closures generates wrong AIR ([#1055](https://github.com/fluencelabs/aqua/issues/1055)) ([1a0b3a2](https://github.com/fluencelabs/aqua/commit/1a0b3a22c1ccfd07f884d04ba442899b84f1d7e2))
* **deps:** update dependency @fluencelabs/js-client to v0.6.0 ([#1050](https://github.com/fluencelabs/aqua/issues/1050)) ([f94f383](https://github.com/fluencelabs/aqua/commit/f94f38327a6c9d31ee54f44e35568aa23c8b4597))
* **deps:** update dependency @fluencelabs/js-client to v0.7.0 ([#1056](https://github.com/fluencelabs/aqua/issues/1056)) ([11f8d3b](https://github.com/fluencelabs/aqua/commit/11f8d3b11b17d682602750133d620b827cc926cf))
### Performance Improvements
* **compiler:** Inliner optimization [LNG-322] ([#1047](https://github.com/fluencelabs/aqua/issues/1047)) ([abcb63d](https://github.com/fluencelabs/aqua/commit/abcb63db3b1acbe68dd49539016b807071b24a4c))
* **compiler:** Optimize `Linker` [LNG-321] ([#1049](https://github.com/fluencelabs/aqua/issues/1049)) ([7b6c724](https://github.com/fluencelabs/aqua/commit/7b6c7245ecbce719027fffd97709b5648e15ed92))
## [0.13.4](https://github.com/fluencelabs/aqua/compare/aqua-v0.13.3...aqua-v0.13.4) (2024-01-11)
### Features
* **compiler:** `for ... rec` [LNG-307] ([#1026](https://github.com/fluencelabs/aqua/issues/1026)) ([ae32f80](https://github.com/fluencelabs/aqua/commit/ae32f8027729bfd463cddc57f857c307e1e3c709))
* **compiler:** Enhance message of type error [LNG-313] ([#1033](https://github.com/fluencelabs/aqua/issues/1033)) ([d5cd77b](https://github.com/fluencelabs/aqua/commit/d5cd77bb865433fdff46fefb48875bf8f5e585dc))
### Bug Fixes
* **compiler:** Add outside context to closures [LNG-317] ([#1038](https://github.com/fluencelabs/aqua/issues/1038)) ([85f3ecd](https://github.com/fluencelabs/aqua/commit/85f3ecdf3985c8bd3a4c68fb827968b79516f9b3))
* **compiler:** Passing closures with abilities [LNG-314] ([#1035](https://github.com/fluencelabs/aqua/issues/1035)) ([5241f52](https://github.com/fluencelabs/aqua/commit/5241f522d8bc58649f4048aada034e3cbe320eb7))
* **compiler:** Type check arrow calls on services and abilities [LNG-315] ([#1037](https://github.com/fluencelabs/aqua/issues/1037)) ([d46ee03](https://github.com/fluencelabs/aqua/commit/d46ee0347fee94055a6690a4d4b8d0e1cf29430c))
## [0.13.3](https://github.com/fluencelabs/aqua/compare/aqua-v0.13.2...aqua-v0.13.3) (2023-12-22)
### Features
* **api:** Refactor js api interfaces ([#1024](https://github.com/fluencelabs/aqua/issues/1024)) ([33a2ca8](https://github.com/fluencelabs/aqua/commit/33a2ca87e00eab7075772cce4a8c012c6a137167))
* **lsp-api:** Fix interface definition [LNG-298] ([#1027](https://github.com/fluencelabs/aqua/issues/1027)) ([5bc01a9](https://github.com/fluencelabs/aqua/commit/5bc01a9c02252add86c018fa90703cda287d1338))
### Bug Fixes
* **compiler:** Do not generate hop back with empty response by default [LNG-305] ([#1019](https://github.com/fluencelabs/aqua/issues/1019)) ([a4d8ee7](https://github.com/fluencelabs/aqua/commit/a4d8ee7083dcd050858602422986a28d6aaa9420))
* **deps:** update dependency @fluencelabs/js-client to v0.5.5 ([#1020](https://github.com/fluencelabs/aqua/issues/1020)) ([851a66f](https://github.com/fluencelabs/aqua/commit/851a66fb5fde5c448f8262fd0df8dbf15cc13d8a))
## [0.13.2](https://github.com/fluencelabs/aqua/compare/aqua-v0.13.1...aqua-v0.13.2) (2023-12-14)
### Features
* **api:** Accept structured imports [LNG-288] ([#989](https://github.com/fluencelabs/aqua/issues/989)) ([f7bfa83](https://github.com/fluencelabs/aqua/commit/f7bfa8317bb07e0dacf64343bb777c9ea8ff81b7))
### Bug Fixes
* **tests:** Lower tests size ([#1018](https://github.com/fluencelabs/aqua/issues/1018)) ([6732f8f](https://github.com/fluencelabs/aqua/commit/6732f8f2ccb5cfd371065f041b9ced5cca0d79e5))
## [0.13.1](https://github.com/fluencelabs/aqua/compare/aqua-v0.13.0...aqua-v0.13.1) (2023-12-07)
### Features
* **language-server:** Pass token types to LSP [LNG-285] ([#999](https://github.com/fluencelabs/aqua/issues/999)) ([74d02e1](https://github.com/fluencelabs/aqua/commit/74d02e1f63766ffc0f849f3d6e262030bc0deab8))
### Bug Fixes
* **compiler:** Allow returning resolved service as ability [LNG-266] ([#977](https://github.com/fluencelabs/aqua/issues/977)) ([2d4b2ae](https://github.com/fluencelabs/aqua/commit/2d4b2aece471f1879fd7e84d23b2a2ad593dac69))
* **compiler:** Use correct empty stream as argument [LNG-280, LNG-292] ([#967](https://github.com/fluencelabs/aqua/issues/967)) ([4cecab1](https://github.com/fluencelabs/aqua/commit/4cecab1a260103b57e7b0f8f1ddcc402ce189fac))
* **deps:** update dependency @fluencelabs/js-client to v0.5.3 ([#978](https://github.com/fluencelabs/aqua/issues/978)) ([9d0fb2b](https://github.com/fluencelabs/aqua/commit/9d0fb2b84124912bdcb4bc38aae6b6c1cd5d59f7))
* **e2e:** Use `main` branch for `fcli` ([#987](https://github.com/fluencelabs/aqua/issues/987)) ([b24fcf6](https://github.com/fluencelabs/aqua/commit/b24fcf686f326c2702edf6a7dfbc45ad1df9562d))
* **tests:** Fix imports in integration tests ([#998](https://github.com/fluencelabs/aqua/issues/998)) ([e65836e](https://github.com/fluencelabs/aqua/commit/e65836e3c869009786b7f7722879752d2176e04e))
## [0.13.0](https://github.com/fluencelabs/aqua/compare/aqua-v0.12.4...aqua-v0.13.0) (2023-11-22)

View File

@ -10,4 +10,4 @@ Things you need to know:
### Contributor License Agreement
When you contribute, you have to be aware that your contribution is covered by **[Apache License 2.0](./LICENSE)**, but might relicensed under few other software licenses mentioned in the **Contributor License Agreement**. In particular, you need to agree to the Contributor License Agreement. If you agree to its content, you simply have to click on the link posted by the CLA assistant as a comment to the pull request. Click it to check the CLA, then accept it on the following screen if you agree to it. The CLA assistant will save this decision for upcoming contributions and will notify you if there is any change to the CLA in the meantime.
When you contribute, you have to be aware that your contribution is covered by **[AGPLv3](./LICENSE)**, but might relicensed under few other software licenses mentioned in the **Contributor License Agreement**. In particular, you need to agree to the Contributor License Agreement. If you agree to its content, you simply have to click on the link posted by the CLA assistant as a comment to the pull request. Click it to check the CLA, then accept it on the following screen if you agree to it. The CLA assistant will save this decision for upcoming contributions and will notify you if there is any change to the CLA in the meantime.

798
LICENSE
View File

@ -1,201 +1,661 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
1. Definitions.
Preamble
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
The GNU Affero General Public License is a free, copyleft license for
software and other kinds of works, specifically designed to ensure
cooperation with the community in the case of network server software.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
our General Public Licenses are intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
Developers that use our General Public Licenses protect your rights
with two steps: (1) assert copyright on the software, and (2) offer
you this License which gives you legal permission to copy, distribute
and/or modify the software.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
A secondary benefit of defending all users' freedom is that
improvements made in alternate versions of the program, if they
receive widespread use, become available for other developers to
incorporate. Many developers of free software are heartened and
encouraged by the resulting cooperation. However, in the case of
software used on network servers, this result may fail to come about.
The GNU General Public License permits making a modified version and
letting the public access it on a server without ever releasing its
source code to the public.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
The GNU Affero General Public License is designed specifically to
ensure that, in such cases, the modified source code becomes available
to the community. It requires the operator of a network server to
provide the source code of the modified version running there to the
users of that server. Therefore, public use of a modified version, on
a publicly accessible server, gives the public access to the source
code of the modified version.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
An older license, called the Affero General Public License and
published by Affero, was designed to accomplish similar goals. This is
a different license, not a version of the Affero GPL, but Affero has
released a new version of the Affero GPL which permits relicensing under
this license.
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
The precise terms and conditions for copying, distribution and
modification follow.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
TERMS AND CONDITIONS
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
0. Definitions.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
"This License" refers to version 3 of the GNU Affero General Public License.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
A "covered work" means either the unmodified Program or a work based
on the Program.
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
1. Source Code.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
END OF TERMS AND CONDITIONS
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
APPENDIX: How to apply the Apache License to your work.
The Corresponding Source for a work in source code form is that
same work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
2. Basic Permissions.
Copyright [yyyy] [name of copyright owner]
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
http://www.apache.org/licenses/LICENSE-2.0
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the
Program, your modified version must prominently offer all users
interacting with it remotely through a computer network (if your version
supports such interaction) an opportunity to receive the Corresponding
Source of your version by providing access to the Corresponding Source
from a network server at no charge, through some standard or customary
means of facilitating copying of software. This Corresponding Source
shall include the Corresponding Source for any work covered by version 3
of the GNU General Public License that is incorporated pursuant to the
following paragraph.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the work with which it is combined will remain governed by version
3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU Affero General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU Affero General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU Affero General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU Affero General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If your software can interact with users remotely through a computer
network, you should also make sure that it provides a way for users to
get its source. For example, if your program is a web application, its
interface could display a "Source" link that leads users to an archive
of the code. There are many ways you could offer source, and different
solutions will be better for different programs; see section 13 for the
specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
<https://www.gnu.org/licenses/>.

View File

@ -50,5 +50,5 @@ Any interested person is welcome to contribute to the project. Please, make sure
## License
All software code is copyright (c) Fluence Labs, Inc. under the [Apache-2.0](./LICENSE) license.
All software code is copyright (c) Fluence Labs, Inc. under the [AGPLv3](./LICENSE) license.

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//@ts-check
import { compileAquaCallFromPath } from '@fluencelabs/aqua-api'

View File

@ -8,7 +8,7 @@
},
"author": "Fluence Labs",
"type": "module",
"license": "Apache-2.0",
"license": "AGPL-3.0",
"dependencies": {
"@fluencelabs/aqua-api": "workspace:*"
}

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { ServiceDef, FunctionCallDef } from "@fluencelabs/interfaces";
export declare class AquaFunction {
@ -15,16 +31,52 @@ export declare class GeneratedSource {
export declare class CompilationResult {
services: Record<string, ServiceDef>;
functions: Record<string, AquaFunction>;
functionCall?: AquaFunction;
errors: string[];
warnings: string[];
generatedSources: GeneratedSource[];
}
/**
* Imports configuration for the compiler.
* Structure:
* {
* "<compiled-path-prefix-1>": {
* "<import-path-prefix-1>": ["<import-path-1>", "<import-path-2>"],
* "<import-path-prefix-2>": "<import-path-3>",
* ...
* }
* ...
* }
* Import `import` written in file with path `path`
* is resolved as follows:
* 1. Try to resolve `import` as relative import from `path`
* 2. If relative resolution failed:
* a. Find **the longest** <compiled-path-prefix>
* that is a prefix of `path` in the imports configuration
* b. In obtained map, find **the longest** <import-path-prefix>
* that is a prefix of `import`
* c. Replace prefix in `import` with <import-path>
* d. Try to resolve import with obtained path
* (try a few paths if array was provided)
*
* WARNING: <compiled-path-prefix> in 2.a is compared with
* absolute normalized path of `path`, so <compiled-path-prefix>
* should be absolute normalized path as well
* NOTE: <import-path-prefix> could be empty string,
* in which case it will match any import
* NOTE: passing just an array of strings is a shorthand for
* {
* "/": {
* "": <array>
* }
* }
*/
type Imports = Record<string, Record<string, string[] | string>> | string[];
/** Common arguments for all compile functions */
type CommonArgs = {
/** Paths to directories, which you want to import .aqua files from. Example: ["./path/to/dir"] */
imports?: string[] | undefined;
/** Imports */
imports?: Imports | undefined;
/** Constants to be passed to the compiler. Example: ["CONSTANT1=1", "CONSTANT2=2"] */
constants?: string[] | undefined;
/** Set log level for the compiler. Must be one of: Must be one of: all, trace, debug, info, warn, error, off. Default: info */
@ -47,12 +99,11 @@ type CodeString = {
};
export type CompileFromStringArgs = CommonArgs & CodeString;
export type CompileFromStringReturnType = Omit<CompilationResult, "funcCall">;
/** Compile aqua code from a string */
export declare function compileFromString(
args: CompileFromStringArgs,
): Promise<CompileFromStringReturnType>;
): Promise<CompilationResult>;
type FilePath = {
/** Path to the aqua file to be compiled */
@ -60,12 +111,11 @@ type FilePath = {
};
export type CompileFromPathArgs = CommonArgs & FilePath;
export type CompileFromPathReturnType = Omit<CompilationResult, "funcCall">;
/** Compile aqua code from a file */
export declare function compileFromPath(
args: CompileFromPathArgs,
): Promise<CompileFromPathReturnType>;
): Promise<CompilationResult>;
type FuncCall = {
/** Function call you want to compile. Example: someFunc("someArg") */
@ -74,20 +124,22 @@ type FuncCall = {
data?: Record<string, unknown> | undefined;
};
export type CallCompilationResult = CompilationResult & {
functionCall: AquaFunction;
};
export type CompileFuncCallFromStringArgs = CommonArgs & CodeString & FuncCall;
export type CompileFuncCallFromStringReturnType = Required<CompilationResult>;
/** Compile aqua function call from a string */
export declare function compileAquaCallFromString(
args: CompileFuncCallFromStringArgs,
): Promise<CompileFuncCallFromStringReturnType>;
): Promise<CallCompilationResult>;
export type CompileFuncCallFromPathArgs = CommonArgs & FilePath & FuncCall;
export type CompileFuncCallFromPathReturnType = Required<CompilationResult>;
/** Compile aqua function call from a file */
export declare function compileAquaCallFromPath(
args: CompileFuncCallFromPathArgs,
): Promise<CompileFuncCallFromPathReturnType>;
): Promise<CallCompilationResult>;
export {};

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { AquaConfig, Aqua, Call, Input, Path } from "./aqua-api.js";
function getConfig({
@ -7,7 +23,7 @@ function getConfig({
noXor = false,
targetType = "air",
tracing = false,
noEmptyResponse = false,
noEmptyResponse = true,
}) {
return new AquaConfig(
logLevel,
@ -24,6 +40,33 @@ function getConfig({
);
}
function normalizeImports(imports) {
if (imports === undefined || imports === null) {
return {}; // No imports
}
if (Array.isArray(imports)) {
return {
"/": {
"": imports,
},
};
}
// Transform each inner string into an array
return Object.fromEntries(
Object.entries(imports).map(([pathPrefix, info]) => [
pathPrefix,
Object.fromEntries(
Object.entries(info).map(([importPrefix, locations]) => [
importPrefix,
Array.isArray(locations) ? locations : [locations],
]),
),
]),
);
}
async function compile(...args) {
try {
const res = await Aqua.compile(...args);
@ -42,11 +85,19 @@ async function compile(...args) {
}
export function compileFromString({ code, imports = [], ...commonArgs }) {
return compile(new Input(code), imports, getConfig(commonArgs));
return compile(
new Input(code),
normalizeImports(imports),
getConfig(commonArgs),
);
}
export function compileFromPath({ filePath, imports = [], ...commonArgs }) {
return compile(new Path(filePath), imports, getConfig(commonArgs));
return compile(
new Path(filePath),
normalizeImports(imports),
getConfig(commonArgs),
);
}
export function compileAquaCallFromString({
@ -58,7 +109,7 @@ export function compileAquaCallFromString({
}) {
return compile(
new Call(funcCall, data, new Input(code)),
imports,
normalizeImports(imports),
getConfig(commonArgs),
);
}
@ -72,7 +123,7 @@ export function compileAquaCallFromPath({
}) {
return compile(
new Call(funcCall, data, new Input(filePath)),
imports,
normalizeImports(imports),
getConfig(commonArgs),
);
}

View File

@ -1 +1,17 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
const metaUrl = ""

View File

@ -1,6 +1,6 @@
{
"name": "@fluencelabs/aqua-api",
"version": "0.13.0",
"version": "0.14.11",
"description": "Aqua API",
"type": "module",
"main": "index.js",
@ -20,13 +20,13 @@
"fluence"
],
"author": "Fluence Labs",
"license": "Apache-2.0",
"license": "AGPL-3.0",
"bugs": {
"url": "https://github.com/fluencelabs/aqua/issues"
},
"homepage": "https://github.com/fluencelabs/aqua#readme",
"devDependencies": {
"@fluencelabs/interfaces": "0.8.2",
"prettier": "3.0.0"
"@fluencelabs/interfaces": "0.12.0",
"prettier": "3.3.0"
}
}

View File

@ -1,84 +1,108 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package api
import api.types.{AquaConfig, AquaFunction, CompilationResult, GeneratedSource, Input}
import aqua.Rendering.given
import aqua.raw.value.ValueRaw
import aqua.api.{APICompilation, APIResult, AquaAPIConfig}
import aqua.SpanParser
import aqua.api.TargetType.*
import aqua.api.{APICompilation, APIResult, AquaAPIConfig, Imports}
import aqua.backend.air.AirBackend
import aqua.backend.{AirFunction, Backend, Generated}
import aqua.compiler.*
import aqua.files.{AquaFileSources, AquaFilesIO, FileModuleId}
import aqua.logging.{LogFormatter, LogLevels}
import aqua.constants.Constants
import aqua.io.*
import aqua.raw.ops.Call
import aqua.run.{CliFunc, FuncCompiler}
import aqua.parser.lexer.{LiteralToken, Token}
import aqua.parser.lift.FileSpan.F
import aqua.parser.lift.{FileSpan, Span}
import aqua.parser.{ArrowReturnError, BlockIndentError, LexerError, ParserError}
import aqua.{AquaIO, SpanParser}
import aqua.model.transform.{Transform, TransformConfig}
import aqua.backend.api.APIBackend
import aqua.backend.js.JavaScriptBackend
import aqua.backend.ts.TypeScriptBackend
import aqua.backend.{AirFunction, Backend, Generated}
import aqua.compiler.*
import aqua.constants.Constants
import aqua.definitions.FunctionDef
import aqua.files.{AquaFileSources, AquaFilesIO, FileModuleId}
import aqua.io.*
import aqua.js.{FunctionDefJs, ServiceDefJs, VarJson}
import aqua.logging.{LogFormatter, LogLevels}
import aqua.model.AquaContext
import aqua.parser.lexer.{LiteralToken, Token}
import aqua.parser.{ArrowReturnError, BlockIndentError, LexerError, ParserError}
import aqua.raw.ops.Call
import aqua.raw.ops.CallArrowRawTag
import aqua.raw.value.ValueRaw
import aqua.raw.value.{LiteralRaw, VarRaw}
import aqua.res.AquaRes
import api.types.{AquaConfig, AquaFunction, CompilationResult, GeneratedSource, Input}
import cats.Applicative
import cats.data.Validated.{Invalid, Valid, invalidNec, validNec}
import cats.data.{Chain, NonEmptyChain, Validated, ValidatedNec}
import cats.data.Validated.{invalidNec, validNec, Invalid, Valid}
import cats.syntax.applicative.*
import cats.syntax.apply.*
import cats.syntax.flatMap.*
import cats.syntax.functor.*
import cats.effect.IO
import cats.effect.unsafe.implicits.global
import cats.syntax.applicative.*
import cats.syntax.apply.*
import cats.syntax.either.*
import cats.syntax.flatMap.*
import cats.syntax.functor.*
import cats.syntax.show.*
import cats.syntax.traverse.*
import cats.syntax.either.*
import fs2.io.file.{Files, Path}
import scribe.Logging
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
import scala.scalajs.js.{|, undefined, Promise, UndefOr}
import scala.scalajs.js
import scala.scalajs.js.JSConverters.*
import scala.scalajs.js.annotation.*
import scala.scalajs.js.{Promise, UndefOr, undefined, |}
import scribe.Logging
@JSExportTopLevel("Aqua")
object AquaAPI extends App with Logging {
// See api-npm package for description of imports config
type ImportsJS = js.Dictionary[
js.Dictionary[js.Array[String]]
]
/**
* All-in-one function that support different inputs and backends
* @param input can be a path to aqua file, string with a code or a function call
* @param imports list of paths
* @param imports imports configuration
* @param aquaConfigJS compiler config
* @return compiler results depends on input and config
* @return compiler results depending on input and config
*/
@JSExport
def compile(
input: types.Input | types.Path | types.Call,
imports: js.Array[String],
imports: ImportsJS,
aquaConfigJS: js.UndefOr[AquaConfig]
): Promise[CompilationResult] = {
aquaConfigJS.toOption
.map(AquaConfig.fromJS)
.getOrElse(validNec(AquaAPIConfig()))
.traverse { config =>
val importsList = imports.toList
val apiImports = Imports.fromMap(
imports.view
.mapValues(
_.toMap.view
.mapValues(_.toList)
.toMap
)
.toMap
)
input match {
case i: (types.Input | types.Path) =>
compileAll(i, importsList, config)
compileAll(i, apiImports, config)
case c: types.Call =>
compileCall(c, importsList, config)
compileCall(c, apiImports, config)
}
}
@ -90,7 +114,7 @@ object AquaAPI extends App with Logging {
// Compile all non-call inputs
private def compileAll(
input: types.Input | types.Path,
imports: List[String],
imports: Imports,
config: AquaAPIConfig
): IO[CompilationResult] = {
val backend: Backend = config.targetType match {
@ -138,7 +162,7 @@ object AquaAPI extends App with Logging {
// Compile a function call
private def compileCall(
call: types.Call,
imports: List[String],
imports: Imports,
config: AquaAPIConfig
): IO[CompilationResult] = {
val path = call.input match {

View File

@ -1,54 +1,61 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package api.types
import aqua.api.AquaAPIConfig
import aqua.api.TargetType.*
import aqua.js.{FunctionDefJs, ServiceDefJs}
import aqua.model.transform.TransformConfig
import cats.data.Validated.{invalidNec, validNec}
import cats.data.{Chain, NonEmptyChain, Validated, ValidatedNec}
import scala.scalajs.js
import scala.scalajs.js.JSConverters.*
import scala.scalajs.js.annotation.{JSExport, JSExportTopLevel}
import scala.scalajs.js.annotation.{JSExport, JSExportAll, JSExportTopLevel}
import scala.scalajs.js.|
@JSExportTopLevel("Input")
@JSExportAll
class Input(
@JSExport
val input: String
)
@JSExportTopLevel("Path")
@JSExportAll
class Path(
@JSExport
val path: String
)
@JSExportTopLevel("Call")
@JSExportAll
class Call(
@JSExport
val functionCall: String,
@JSExport
val arguments: js.Dynamic,
@JSExport
val input: Path | Input
)
@JSExportTopLevel("AquaConfig")
@JSExportAll
class AquaConfig(
@JSExport
val logLevel: js.UndefOr[String],
@JSExport
val constants: js.UndefOr[js.Array[String]],
@JSExport
val noXor: js.UndefOr[Boolean],
@JSExport
val noRelay: js.UndefOr[Boolean],
@JSExport
val targetType: js.UndefOr[String],
@JSExport
val tracing: js.UndefOr[Boolean],
@JSExport
val noEmptyResponse: js.UndefOr[Boolean]
)
@ -72,7 +79,7 @@ object AquaConfig {
noXor = cjs.noXor.getOrElse(false),
noRelay = cjs.noRelay.getOrElse(false),
tracing = cjs.tracing.getOrElse(false),
noEmptyResponse = cjs.noEmptyResponse.getOrElse(false)
noEmptyResponse = cjs.noEmptyResponse.getOrElse(true)
)
}
}

View File

@ -1,35 +1,41 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package api.types
import aqua.js.{FunctionDefJs, ServiceDefJs}
import aqua.model.transform.TransformConfig
import cats.data.Validated.{invalidNec, validNec, Invalid, Valid}
import cats.data.{Chain, NonEmptyChain, Validated, ValidatedNec}
import scala.scalajs.js
import scala.scalajs.js.JSConverters.*
import scala.scalajs.js.annotation.{JSExport, JSExportTopLevel}
import scala.scalajs.js.|
@JSExportTopLevel("AquaFunction")
case class AquaFunction(
@JSExport
funcDef: FunctionDefJs,
@JSExport
script: String
)
class AquaFunction(
val funcDef: FunctionDefJs,
val script: String
) extends js.Object
@JSExportTopLevel("GeneratedSource")
case class GeneratedSource(
@JSExport
class GeneratedSource(
val name: String,
@JSExport
val tsSource: js.UndefOr[String],
@JSExport
val jsSource: js.UndefOr[String],
@JSExport
val tsTypes: js.UndefOr[String]
)
) extends js.Object
object GeneratedSource {
@ -40,21 +46,14 @@ object GeneratedSource {
new GeneratedSource(name, null, jsSource, tsTypes)
}
@JSExportTopLevel("CompilationResult")
class CompilationResult(
@JSExport
val services: js.Dictionary[ServiceDefJs],
@JSExport
val functions: js.Dictionary[AquaFunction],
@JSExport
val functionCall: js.UndefOr[AquaFunction],
@JSExport
val generatedSources: js.Array[GeneratedSource],
@JSExport
val errors: js.Array[String],
@JSExport
val warnings: js.Array[String]
)
) extends js.Object
object CompilationResult {

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.api
import aqua.api.TargetType.TypeScriptType
@ -6,22 +22,24 @@ import aqua.compiler.AquaCompiled
import aqua.files.FileModuleId
import cats.data.Chain
import cats.data.Validated.{Invalid, Valid}
import cats.effect.{IO, IOApp}
import fs2.io.file.{Files, Path}
import fs2.{text, Stream}
import fs2.{Stream, text}
object Test extends IOApp.Simple {
override def run: IO[Unit] = {
APICompilation
.compilePath(
"./aqua-src/antithesis.aqua",
"./aqua" :: Nil,
AquaAPIConfig(targetType = TypeScriptType),
Imports.fromMap(Map("/" -> Map("" -> List("./aqua")))),
AquaAPIConfig(targetType = TypeScriptType, noXor = true),
TypeScriptBackend(false, "IFluenceClient$$")
)
.flatMap { res =>
.timed
.flatMap { case (duration, res) =>
println("Compilation time: " + duration.toMillis)
val (warnings, result) = res.value.run
IO.delay {

View File

@ -1,50 +1,58 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.api
import aqua.Rendering.given
import aqua.raw.value.ValueRaw
import aqua.raw.ConstantRaw
import aqua.api.AquaAPIConfig
import aqua.backend.api.APIBackend
import aqua.backend.{AirFunction, Backend, Generated}
import aqua.compiler.*
import aqua.files.{AquaFileSources, AquaFilesIO, FileModuleId}
import aqua.logging.{LogFormatter, LogLevels}
import aqua.constants.Constants
import aqua.definitions.FunctionDef
import aqua.files.{AquaFileSources, AquaFilesIO, AquaStringSources, FileModuleId}
import aqua.io.*
import aqua.raw.ops.Call
import aqua.run.{CliFunc, FuncCompiler, RunPreparer}
import aqua.logging.{LogFormatter, LogLevels}
import aqua.model.AquaContext
import aqua.model.transform.{Transform, TransformConfig}
import aqua.parser.expr.AbilityExpr.p
import aqua.parser.lexer.{LiteralToken, Token}
import aqua.parser.lift.FileSpan.F
import aqua.parser.lift.{FileSpan, Span}
import aqua.parser.{ArrowReturnError, BlockIndentError, LexerError, ParserError}
import aqua.{AquaIO, SpanParser}
import aqua.model.transform.{Transform, TransformConfig}
import aqua.backend.api.APIBackend
import aqua.definitions.FunctionDef
import aqua.model.AquaContext
import aqua.parser.{ArrowReturnError, LexerError, ParserError}
import aqua.raw.ConstantRaw
import aqua.raw.ops.Call
import aqua.raw.value.ValueRaw
import aqua.res.AquaRes
import aqua.run.{CliFunc, FuncCompiler, RunPreparer}
import aqua.{AquaIO, SpanParser}
import cats.Applicative
import cats.~>
import cats.data.{
Chain,
EitherT,
NonEmptyChain,
NonEmptyList,
Validated,
ValidatedNec,
ValidatedNel,
Writer
}
import cats.data.Validated.{invalid, invalidNec, validNec, Invalid, Valid}
import cats.syntax.applicative.*
import cats.syntax.apply.*
import cats.syntax.flatMap.*
import cats.syntax.functor.*
import cats.data.*
import cats.data.Validated.*
import cats.effect.IO
import cats.effect.unsafe.implicits.global
import cats.syntax.applicative.*
import cats.syntax.apply.*
import cats.syntax.either.*
import cats.syntax.flatMap.*
import cats.syntax.functor.*
import cats.syntax.show.*
import cats.syntax.traverse.*
import cats.syntax.either.*
import cats.~>
import fs2.io.file.{Files, Path}
import scribe.{Level, Logging}
@ -53,7 +61,7 @@ object APICompilation {
def compileCall(
functionStr: String,
pathStr: String,
imports: List[String],
imports: Imports,
aquaConfig: AquaAPIConfig,
fillWithTypes: List[ValueRaw] => ValidatedNec[String, List[ValueRaw]]
): IO[APIResult[(FunctionDef, String)]] = {
@ -63,14 +71,16 @@ object APICompilation {
LogLevels.levelFromString(aquaConfig.logLevel),
Constants.parse(aquaConfig.constants)
).tupled.toResult.flatTraverse { case (level, constants) =>
val transformConfig = aquaConfig.getTransformConfig.copy(constants = constants)
val transformConfig = aquaConfig.getTransformConfig
val config = aquaConfig.getCompilerConfig.copy(constants = constants)
LogFormatter.initLogger(Some(level))
new FuncCompiler[IO](
Some(RelativePath(Path(pathStr))),
imports.map(Path.apply),
transformConfig
imports.toIO,
transformConfig,
config
).compile().map { contextV =>
for {
context <- contextV.toResult
@ -95,14 +105,17 @@ object APICompilation {
def compilePath(
pathStr: String,
imports: List[String],
imports: Imports,
aquaConfig: AquaAPIConfig,
backend: Backend
): IO[APIResult[Chain[AquaCompiled[FileModuleId]]]] = {
given AquaIO[IO] = new AquaFilesIO[IO]
val path = Path(pathStr)
val sources = new AquaFileSources[IO](path, imports.map(Path.apply))
val sources = new AquaFileSources[IO](
path,
imports.toIO
)
compileRaw(
aquaConfig,
@ -113,7 +126,7 @@ object APICompilation {
def compileString(
input: String,
imports: List[String],
imports: Imports,
aquaConfig: AquaAPIConfig,
backend: Backend
): IO[APIResult[Chain[AquaCompiled[FileModuleId]]]] = {
@ -121,12 +134,11 @@ object APICompilation {
val path = Path("")
val strSources: AquaFileSources[IO] =
new AquaFileSources[IO](path, imports.map(Path.apply)) {
override def sources: IO[ValidatedNec[AquaFileError, Chain[(FileModuleId, String)]]] = {
IO.pure(Valid(Chain.one((FileModuleId(path), input))))
}
}
val strSources: AquaStringSources[IO] =
new AquaStringSources(
Map(FileModuleId(path) -> input),
imports.toIO
)
compileRaw(
aquaConfig,
@ -146,7 +158,7 @@ object APICompilation {
LogFormatter.initLogger(Some(level))
val transformConfig = aquaConfig.getTransformConfig
val config = AquaCompilerConf(constants ++ transformConfig.constantsList)
val config = aquaConfig.getCompilerConfig.copy(constants = constants)
CompilerAPI
.compile[IO, AquaFileError, FileModuleId, FileSpan.F](

View File

@ -1,4 +1,22 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.api
import aqua.compiler.AquaCompilerConf
import aqua.model.transform.TransformConfig
enum TargetType:
@ -8,19 +26,27 @@ case class AquaAPIConfig(
targetType: TargetType = TargetType.AirType,
logLevel: String = "info",
constants: List[String] = Nil,
noXor: Boolean = false, // TODO: Remove
noXor: Boolean = false,
noRelay: Boolean = false,
tracing: Boolean = false,
noEmptyResponse: Boolean = false
noEmptyResponse: Boolean = true
) {
def getTransformConfig: TransformConfig = {
val config = TransformConfig(
tracing = Option.when(tracing)(TransformConfig.TracingConfig.default),
noEmptyResponse = noEmptyResponse
noEmptyResponse = noEmptyResponse,
noXor = noXor
)
if (noRelay) config.copy(relayVarName = None)
else config
}
def getCompilerConfig: AquaCompilerConf = {
val config = AquaCompilerConf()
if (noRelay) config.copy(relayVarName = None)
else config
}
}

View File

@ -0,0 +1,65 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.api
import aqua.files.Imports as IOImports
import fs2.io.file.Path
/**
* Imports configuration passed to the compiler
* @param settings map of path prefixes to imports settings
*/
final case class Imports(
settings: Map[Path, Imports.PathSettings]
) {
def toIO: IOImports =
IOImports(
settings.view
.mapValues(
_.toIO
)
.toMap
)
}
object Imports {
/**
* Imports settings for a single path prefix.
* @param imports map of import prefixes to locations
*/
final case class PathSettings(
imports: Map[String, List[Path]]
) {
def toIO: IOImports.PathSettings =
IOImports.PathSettings(imports)
}
def fromMap(m: Map[String, Map[String, List[String]]]): Imports =
Imports(
m.map { case (pathPrefix, settings) =>
Path(pathPrefix) -> PathSettings(
settings.map { case (importPrefix, locations) =>
importPrefix -> locations.map(Path.apply)
}
)
}
)
}

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua
import cats.data.{Chain, EitherT, NonEmptyChain, Writer}

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.run
import aqua.definitions.FunctionDef

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.run
import aqua.backend.air.FuncAirGen
@ -128,7 +144,7 @@ class CallPreparer(
FuncArrow(
config.functionWrapperName,
SeqTag.wrap((getters.map(_.leaf) :+ body :+ finisherService.leaf): _*),
SeqTag.wrap(getters.map(_.leaf) :+ body :+ finisherService.leaf*),
// no arguments and returns "ok" string
ArrowType(NilType, returnCodomain),
ret,

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.run
import aqua.parser.lexer.{CallArrowToken, CollectionToken, LiteralToken, VarToken}

View File

@ -1,46 +1,51 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.run
import aqua.Rendering.given
import aqua.compiler.{AquaCompiler, AquaCompilerConf, CompileResult, CompilerAPI}
import aqua.files.{AquaFileSources, FileModuleId}
import aqua.{AquaIO, SpanParser}
import aqua.io.{AquaFileError, AquaPath, PackagePath, Prelude}
import aqua.compiler.{AquaCompilerConf, CompileResult, CompilerAPI}
import aqua.files.{AquaFileSources, FileModuleId, Imports}
import aqua.io.{AquaFileError, AquaPath, PackagePath}
import aqua.model.transform.TransformConfig
import aqua.model.{AquaContext, FuncArrow}
import aqua.parser.lift.FileSpan
import aqua.run.CliFunc
import aqua.{AquaIO, SpanParser}
import cats.data.Validated.{invalidNec, validNec}
import cats.data.{Chain, NonEmptyList, Validated, ValidatedNec}
import cats.effect.IO
import cats.data.{Chain, ValidatedNec}
import cats.effect.kernel.{Async, Clock}
import cats.syntax.applicative.*
import cats.syntax.apply.*
import cats.syntax.flatMap.*
import cats.syntax.functor.*
import cats.syntax.monad.*
import cats.syntax.show.*
import cats.syntax.traverse.*
import cats.syntax.option.*
import cats.syntax.either.*
import cats.syntax.validated.*
import cats.syntax.apply.*
import cats.syntax.traverse.*
import fs2.io.file.{Files, Path}
import scribe.Logging
import scala.concurrent.duration.Duration
class FuncCompiler[F[_]: Files: AquaIO: Async](
input: Option[AquaPath],
imports: List[Path],
transformConfig: TransformConfig
imports: Imports,
transformConfig: TransformConfig,
config: AquaCompilerConf
) extends Logging {
type Result = [A] =>> CompileResult[FileModuleId, AquaFileError, FileSpan.F][A]
private def compileToContext(
path: Path,
imports: List[Path],
config: AquaCompilerConf = AquaCompilerConf(transformConfig.constantsList)
path: Path
): F[Result[Chain[AquaContext]]] = {
val sources = new AquaFileSources[F](path, imports)
CompilerAPI.compileToContext[F, AquaFileError, FileModuleId, FileSpan.F](
@ -53,12 +58,11 @@ class FuncCompiler[F[_]: Files: AquaIO: Async](
private def compileBuiltins(): F[Result[Chain[AquaContext]]] =
for {
path <- PackagePath.builtin.getPath()
context <- compileToContext(path, Nil)
context <- compileToContext(path)
} yield context
// Compile and get only one function
def compile(
preludeImports: List[Path] = Nil,
withBuiltins: Boolean = false
): F[Result[Chain[AquaContext]]] = {
for {
@ -69,7 +73,7 @@ class FuncCompiler[F[_]: Files: AquaIO: Async](
compileResult <- input.traverse { ap =>
// compile only context to wrap and call function later
Clock[F].timed(
ap.getPath().flatMap(p => compileToContext(p, preludeImports ++ imports))
ap.getPath().flatMap(p => compileToContext(p))
)
}
(compileTime, contextV) = compileResult.orEmpty

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.run
import aqua.logging.LogLevels

View File

@ -1,8 +1,23 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.run
import aqua.backend.air.FuncAirGen
import aqua.definitions.{FunctionDef, TypeDefinition}
import aqua.io.OutputPrinter
import aqua.model.transform.{Transform, TransformConfig}
import aqua.model.{FuncArrow, ValueModel, VarModel}
import aqua.parser.lexer.CallArrowToken
@ -10,6 +25,7 @@ import aqua.parser.lift.Span
import aqua.raw.ops.{Call, CallArrowRawTag, SeqTag}
import aqua.raw.value.{LiteralRaw, ValueRaw, VarRaw}
import aqua.types.*
import cats.data.Validated.{invalid, invalidNec, invalidNel, validNec, validNel}
import cats.data.{NonEmptyList, Validated, ValidatedNec}
import cats.effect.kernel.Async
@ -18,8 +34,7 @@ import cats.syntax.flatMap.*
import cats.syntax.partialOrder.*
import cats.syntax.show.*
import cats.syntax.traverse.*
import cats.{~>, Id}
import cats.{Id, ~>}
import scala.collection.immutable.SortedMap
import scala.concurrent.ExecutionContext

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.run
import aqua.raw.value.{LiteralRaw, ValueRaw, VarRaw}

View File

@ -1,2 +1,14 @@
func arr(strs: []string) -> []string
<- strs
aqua StreamMapTest declares *
export main
func foo() -> %string, u64:
map: %string
<- map, 42
func get() -> string, string:
<- "123", "44"
func main() -> string:
m <- foo()
<- m.get("key")!

View File

@ -1,3 +1,5 @@
aqua Builtin declares *
-- Default public interface of Fluence nodes
alias Field : []string

View File

@ -1,15 +1,8 @@
module DeclareModule declares decl_foo, decl_bar, SuperFoo, DECLARE_CONST, DECLARE_CONST2
export SuperFoo
aqua AquaName declares getWorker, Worker
const DECLARE_CONST = "declare_const"
const DECLARE_CONST2 = "declare_const2"
data Worker:
host_id: string
service SuperFoo("super_foo"):
small_foo() -> string
func getWorker() -> Worker:
<- Worker(host_id = "")
func decl_foo() -> string:
res1 <- SuperFoo.small_foo()
<- res1
func decl_bar() -> string:
<- DECLARE_CONST

View File

@ -1,7 +1,15 @@
module FooBars declares *
aqua FooBars declares *
const DECLARE_CONST = "declare_const"
const DECLARE_CONST2 = "declare_const2"
-- alias SomeStruct: string
data SomeStruct:
a: string
-- service SomeStruct("ss"):
-- a() -> string
func foo() -> string:
<- "I am MyFooBar foo"

View File

@ -1,3 +1,5 @@
aqua One
service OneMore:
more_call()
consume(s: string)

View File

@ -1,18 +1,7 @@
service Peer("peer"):
hodes: -> []string
timeout: i32, string -> string
aqua B declares timeout, someString
func test_timeout() -> string:
on HOST_PEER_ID:
nodes <- Peer.hodes()
results: *string
func timeout() -> string:
<- "hack file"
for node <- nodes par:
on node:
results <<- node
timeout: *string
join results[999]
par join results[123]
<- timeout!
func someString() -> string:
<- "sssss"

View File

@ -1,6 +1,10 @@
service GetStr("multiret-test"):
retStr(s: *string, a: *string)
aqua Import declares someFunc
service GetStr("multiret-test"):
retStr(s: []string, a: []string)
func someFunc() -> string:
<- "some func call"
func foo_wrapper():
GetStr.retStr(nil, nil)

View File

@ -41,11 +41,11 @@ func checkKeepArg() -> []string, []string:
<- a, y
-- failing Aqua code:
service TestService("test-service"):
service TestServiceRestrict("test-service"):
get_records(key: string) -> []string
func append_records(peer: string, srum: *[]string):
srum <- TestService.get_records(peer)
srum <- TestServiceRestrict.get_records(peer)
func retrieve_records(peer: string) -> [][]string:
records: *[]string

View File

@ -1,10 +0,0 @@
service TestService("test-service"):
get_records(key: string) -> []string
func append_records(peer: string, srum: *[]string):
srum <- TestService.get_records(peer)
func retrieve_records(peer: string) -> [][]string:
records: *[]string
append_records(peer, records)
<- records

View File

@ -5,11 +5,11 @@ func some_string() -> string:
<- "some_string_func"
service TestService("test-service"):
service TestServiceRename("test-service"):
get_records(key: string) -> []string
func append_records(peer: string, srum: *[]string):
srum <- TestService.get_records(peer)
srum <- TestServiceRename.get_records(peer)
func retrieve_records(peer: string) -> [][]string:
records: *[]string

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.backend
object Version {

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.backend
object Version {

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.backend.air
import cats.Show
@ -120,42 +136,77 @@ object Air {
case class Comment(comment: String, air: Air) extends Air(Keyword.NA)
private def show(depth: Int, air: Air): String = {
def showNext(a: Air) = show(depth + 1, a)
private def showInternal(space: String, sb: StringBuilder, air: Air): Unit = {
val space = " " * depth
def showNext(a: Air): Unit = showInternal(space + " ", sb, a)
air match {
case Air.Comment(c, a) =>
space + "; " + c.replace("\n", "\n" + space + "; ") + "\n" +
show(depth, a)
case _ =>
s"$space(${air.keyword.value}" +
(air match {
case Air.Null ""
case Air.Never ""
case Air.Next(label) s" $label"
case Air.New(item, inst) s" ${item.show}\n${showNext(inst)}$space"
case Air.Fold(iter, label, inst, lastInst)
val l = show(depth + 1, lastInst)
s" ${iter.show} $label\n${showNext(inst)}$l$space"
case Air.Match(left, right, inst)
s" ${left.show} ${right.show}\n${showNext(inst)}$space"
case Air.Mismatch(left, right, inst)
s" ${left.show} ${right.show}\n${showNext(inst)}$space"
case Air.Par(l, r) s"\n${showNext(l)}${showNext(r)}$space"
case Air.Seq(l, r) s"\n${showNext(l)}${showNext(r)}$space"
case Air.Xor(l, r) s"\n${showNext(l)}${showNext(r)}$space"
case Air.Call(triplet, args, res)
s" ${triplet.show} [${args.map(_.show).mkString(" ")}]${res.fold("")(" " + _)}"
case Air.Ap(operand, result) s" ${operand.show} $result"
case Air.ApStreamMap(key, operand, result) s" (${key.show} ${operand.show}) $result"
case Air.Fail(operand) => s" ${operand.show}"
case Air.Canon(operand, peerId, result) s" ${peerId.show} ${operand.show} $result"
case Air.Comment(_, _) => ";; Should not be displayed"
}) + ")\n"
}
sb.append(space)
.append("; ")
.append(c.replace("\n", "\n" + space + "; "))
.append("\n")
showInternal(space, sb, a)
case _ =>
sb.append(s"$space(${air.keyword.value}")
(air match {
case Air.Null
case Air.Never
case Air.Next(label) sb.append(s" $label")
case Air.New(item, inst)
sb.append(s" ${item.show}\n")
showNext(inst)
sb.append(space)
case Air.Fold(iter, label, inst, lastInst)
sb.append(s" ${iter.show} $label\n")
showNext(inst)
showNext(lastInst)
sb.append(space)
case Air.Match(left, right, inst)
sb.append(s" ${left.show} ${right.show}\n")
showNext(inst)
sb.append(space)
case Air.Mismatch(left, right, inst)
sb.append(s" ${left.show} ${right.show}\n")
showNext(inst)
sb.append(space)
case Air.Par(l, r)
sb.append("\n")
showNext(l)
showNext(r)
sb.append(space)
case Air.Seq(l, r)
sb.append("\n")
showNext(l)
showNext(r)
sb.append(space)
case Air.Xor(l, r)
sb.append("\n")
showNext(l)
showNext(r)
sb.append(space)
case Air.Call(triplet, args, res)
sb.append(s" ${triplet.show} [${args.map(_.show).mkString(" ")}]${res.fold("")(" " + _)}")
case Air.Ap(operand, result)
sb.append(s" ${operand.show} $result")
case Air.ApStreamMap(key, operand, result)
sb.append(s" (${key.show} ${operand.show}) $result")
case Air.Fail(operand) => sb.append(s" ${operand.show}")
case Air.Canon(operand, peerId, result)
sb.append(s" ${peerId.show} ${operand.show} $result")
case Air.Comment(_, _) => ";; Should not be displayed"
})
sb.append(")\n")
}
}
private def show(depth: Int, air: Air): String = {
val sb = StringBuilder()
val space = " " * depth
showInternal(space, sb, air)
sb.result()
}
implicit val s: Show[Air] = Show.show(show(0, _))

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.backend.air
import aqua.backend.{AirFunction, Backend, Generated, Version}

View File

@ -1,9 +1,25 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.backend.air
import aqua.model.*
import aqua.raw.ops.Call
import aqua.res.*
import aqua.types.{ArrayType, CanonStreamType, StreamMapType, StreamType, Type}
import aqua.types.{ArrayType, CanonStreamMapType, CanonStreamType, StreamMapType, StreamType, Type}
import cats.Eval
import cats.data.Chain
import cats.free.Cofree
@ -29,7 +45,8 @@ object AirGen extends Logging {
def varNameToString(name: String, `type`: Type): String =
(`type` match {
case _: StreamType => "$" + name
case _: CanonStreamType => "#" + name
case _: CanonStreamType => "#$" + name
case _: CanonStreamMapType => "#%" + name
case _: StreamMapType => "%" + name
case _ => name
}).replace('.', '_')

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.backend.air
import aqua.res.FuncRes

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.backend.api
import aqua.backend.air.AirBackend

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.definitions
import aqua.definitions.*

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.backend
import aqua.definitions.FunctionDef

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.backend
import aqua.model.AquaContext

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.backend
import aqua.definitions.ServiceDef

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.backend
object Header {

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.backend
import aqua.backend.ts.{TSFuncTypes, TSServiceTypes}

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.backend
import aqua.backend.air.FuncAirGen

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.backend
import aqua.backend.ts.TypeScriptCommon

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.backend
import aqua.backend.ts.{TSFuncTypes, TSServiceTypes}

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.backend.js
import aqua.backend.ts.TypeScriptTypes

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.backend.ts
import aqua.backend.FuncTypes

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.backend.ts
import aqua.backend.ServiceTypes

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.backend.ts
import aqua.backend.{Backend, Generated, OutputFile}

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.backend.ts
import aqua.res.FuncRes

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.backend.ts
import aqua.backend.{FuncTypes, ServiceTypes, Types}

130
build.sbt
View File

@ -1,30 +1,55 @@
import BundleJS.*
val aquaVersion = "0.13.0"
val aquaVersion = "0.14.11"
val scalaV = "3.3.1"
val catsV = "2.10.0"
val scalaV = "3.4.2"
val catsV = "2.12.0"
val catsParseV = "0.3.10"
val monocleV = "3.1.0"
val scalaTestV = "3.2.17"
val sourcecodeV = "0.3.0"
val fs2V = "3.9.3"
val scalaTestV = "3.2.19"
val scalaTestScalaCheckV = "3.2.18.0"
val sourcecodeV = "0.4.2"
// Snapshot is used to get latest fixes
val fs2V = "3.10.2"
val catsEffectV = "3.6-1f95fd7"
val declineV = "2.3.0"
val circeVersion = "0.14.2"
val scribeV = "3.7.1"
val scribeV = "3.13.0"
name := "aqua-hll"
val commons = Seq(
val orgName = "Fluence DAO"
val licenseStartYear = 2024
val licenseName = "AGPL-3.0-only"
val licenseUrl = "https://www.gnu.org/licenses/agpl-3.0.txt"
val license = HeaderLicense.AGPLv3Only(
yyyy = licenseStartYear.toString,
copyrightOwner = orgName,
licenseStyle = HeaderLicenseStyle.Detailed
)
val licenseSettings = Seq(
organizationName := orgName,
startYear := Some(licenseStartYear),
licenses += (licenseName, new URI(licenseUrl).toURL()),
headerLicense := Some(license)
)
licenseSettings
val commons = licenseSettings ++ Seq(
version := {
val aquaSnapshot = sys.env.getOrElse("SNAPSHOT", "")
if (aquaSnapshot.isEmpty()) aquaVersion else aquaVersion + "-" + aquaSnapshot,
},
scalaVersion := scalaV,
libraryDependencies ++= Seq(
"com.outr" %%% "scribe" % scribeV,
"org.scalatest" %%% "scalatest" % scalaTestV % Test
"com.outr" %%% "scribe" % scribeV,
"dev.optics" %%% "monocle-core" % monocleV,
"dev.optics" %%% "monocle-macro" % monocleV,
"org.scalatest" %%% "scalatest" % scalaTestV % Test,
"org.scalatestplus" %%% "scalacheck-1-17" % scalaTestScalaCheckV % Test
),
scalacOptions ++= {
Seq(
@ -36,17 +61,18 @@ val commons = Seq(
"-Ykind-projector"
// "-Xfatal-warnings"
)
}
},
// Needed to resolve snapshot versions
resolvers ++= Resolver.sonatypeOssRepos("snapshots")
)
commons
lazy val `aqua-run` = crossProject(JSPlatform, JVMPlatform)
.withoutSuffixFor(JVMPlatform)
.crossType(CrossType.Pure)
.in(file("aqua-run"))
.settings(commons)
.dependsOn(compiler, `backend-air`, `backend-ts`, io, definitions, logging, constants)
.enablePlugins(AutomateHeaderPlugin)
lazy val io = crossProject(JVMPlatform, JSPlatform)
.withoutSuffixFor(JVMPlatform)
@ -58,9 +84,19 @@ lazy val io = crossProject(JVMPlatform, JSPlatform)
"co.fs2" %%% "fs2-io" % fs2V
)
)
.dependsOn(compiler, parser)
.dependsOn(compiler, parser, helpers)
.enablePlugins(AutomateHeaderPlugin)
lazy val ioJS = io.js.dependsOn(`js-imports`)
lazy val ioJS = io.js
.settings(licenseSettings)
.settings(
scalaJSLinkerConfig ~= (
_.withModuleKind(ModuleKind.CommonJSModule)
.withJSHeader(s"/*${license.text}*/\n")
)
)
.dependsOn(`js-imports`)
.enablePlugins(AutomateHeaderPlugin)
lazy val `language-server-api` = crossProject(JSPlatform, JVMPlatform)
.withoutSuffixFor(JVMPlatform)
@ -73,22 +109,29 @@ lazy val `language-server-api` = crossProject(JSPlatform, JVMPlatform)
"co.fs2" %%% "fs2-io" % fs2V
)
)
.dependsOn(compiler, io)
.dependsOn(compiler, io, compiler % "test->test")
.enablePlugins(AutomateHeaderPlugin)
lazy val `language-server-apiJS` = `language-server-api`.js
.settings(licenseSettings)
.settings(
scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule)),
scalaJSUseMainModuleInitializer := true
scalaJSLinkerConfig ~= (
_.withModuleKind(ModuleKind.CommonJSModule)
.withJSHeader(s"/*${license.text}*/\n")
),
scalaJSUseMainModuleInitializer := false
)
.settings(addBundleJS("../../language-server-npm/aqua-lsp-api.js"))
.enablePlugins(ScalaJSPlugin)
.dependsOn(`js-exports`, `js-imports`)
.enablePlugins(AutomateHeaderPlugin)
lazy val `js-exports` = project
.in(file("js/js-exports"))
.enablePlugins(ScalaJSPlugin)
.settings(commons)
.dependsOn(`backend`.js, definitions.js)
.enablePlugins(AutomateHeaderPlugin)
lazy val `js-imports` = project
.in(file("js/js-imports"))
@ -102,16 +145,22 @@ lazy val `aqua-api` = crossProject(JSPlatform, JVMPlatform)
.in(file("api/api"))
.settings(commons)
.dependsOn(`aqua-run`, `backend-api`)
.enablePlugins(AutomateHeaderPlugin)
lazy val `aqua-apiJS` = `aqua-api`.js
.settings(licenseSettings)
.settings(
scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.ESModule)),
scalaJSLinkerConfig ~= (
_.withModuleKind(ModuleKind.ESModule)
.withJSHeader(s"/*${license.text}*/\n")
),
scalaJSUseMainModuleInitializer := true,
Test / test := {}
)
.settings(addBundleJS("../../api-npm/aqua-api.js"))
.enablePlugins(ScalaJSPlugin)
.dependsOn(`js-exports`)
.enablePlugins(AutomateHeaderPlugin)
lazy val types = crossProject(JVMPlatform, JSPlatform)
.withoutSuffixFor(JVMPlatform)
@ -123,6 +172,7 @@ lazy val types = crossProject(JVMPlatform, JSPlatform)
)
)
.dependsOn(errors)
.enablePlugins(AutomateHeaderPlugin)
lazy val parser = crossProject(JVMPlatform, JSPlatform)
.withoutSuffixFor(JVMPlatform)
@ -135,12 +185,14 @@ lazy val parser = crossProject(JVMPlatform, JSPlatform)
)
)
.dependsOn(types, helpers)
.enablePlugins(AutomateHeaderPlugin)
lazy val linker = crossProject(JVMPlatform, JSPlatform)
.withoutSuffixFor(JVMPlatform)
.crossType(CrossType.Pure)
.settings(commons)
.dependsOn(parser)
.enablePlugins(AutomateHeaderPlugin)
lazy val tree = crossProject(JVMPlatform, JSPlatform)
.withoutSuffixFor(JVMPlatform)
@ -153,6 +205,7 @@ lazy val tree = crossProject(JVMPlatform, JSPlatform)
)
)
.dependsOn(helpers)
.enablePlugins(AutomateHeaderPlugin)
lazy val raw = crossProject(JVMPlatform, JSPlatform)
.withoutSuffixFor(JVMPlatform)
@ -160,12 +213,14 @@ lazy val raw = crossProject(JVMPlatform, JSPlatform)
.in(file("model/raw"))
.settings(commons)
.dependsOn(types, tree)
.enablePlugins(AutomateHeaderPlugin)
lazy val model = crossProject(JVMPlatform, JSPlatform)
.withoutSuffixFor(JVMPlatform)
.crossType(CrossType.Pure)
.settings(commons)
.dependsOn(types, tree, raw, helpers, errors)
.enablePlugins(AutomateHeaderPlugin)
lazy val res = crossProject(JVMPlatform, JSPlatform)
.withoutSuffixFor(JVMPlatform)
@ -173,13 +228,15 @@ lazy val res = crossProject(JVMPlatform, JSPlatform)
.in(file("model/res"))
.settings(commons)
.dependsOn(model)
.enablePlugins(AutomateHeaderPlugin)
lazy val inline = crossProject(JVMPlatform, JSPlatform)
.withoutSuffixFor(JVMPlatform)
.crossType(CrossType.Pure)
.in(file("model/inline"))
.settings(commons)
.dependsOn(raw, model)
.dependsOn(raw, model, mangler)
.enablePlugins(AutomateHeaderPlugin)
lazy val transform = crossProject(JVMPlatform, JSPlatform)
.withoutSuffixFor(JVMPlatform)
@ -187,18 +244,14 @@ lazy val transform = crossProject(JVMPlatform, JSPlatform)
.in(file("model/transform"))
.settings(commons)
.dependsOn(model, res, inline, res % "test->test")
.enablePlugins(AutomateHeaderPlugin)
lazy val semantics = crossProject(JVMPlatform, JSPlatform)
.withoutSuffixFor(JVMPlatform)
.crossType(CrossType.Pure)
.settings(commons)
.settings(
libraryDependencies ++= Seq(
"dev.optics" %%% "monocle-core" % monocleV,
"dev.optics" %%% "monocle-macro" % monocleV
)
)
.dependsOn(raw, parser, errors)
.dependsOn(raw, parser, errors, mangler)
.enablePlugins(AutomateHeaderPlugin)
lazy val compiler = crossProject(JVMPlatform, JSPlatform)
.withoutSuffixFor(JVMPlatform)
@ -206,6 +259,7 @@ lazy val compiler = crossProject(JVMPlatform, JSPlatform)
.in(file("compiler"))
.settings(commons)
.dependsOn(semantics, linker, backend, transform % "test->test", res % "test->test")
.enablePlugins(AutomateHeaderPlugin)
lazy val backend = crossProject(JVMPlatform, JSPlatform)
.withoutSuffixFor(JVMPlatform)
@ -218,6 +272,7 @@ lazy val backend = crossProject(JVMPlatform, JSPlatform)
buildInfoPackage := "aqua.backend"
)
.dependsOn(res, definitions)
.enablePlugins(AutomateHeaderPlugin)
lazy val definitions = crossProject(JVMPlatform, JSPlatform)
.withoutSuffixFor(JVMPlatform)
@ -232,6 +287,7 @@ lazy val definitions = crossProject(JVMPlatform, JSPlatform)
).map(_ % circeVersion)
)
.dependsOn(res, types)
.enablePlugins(AutomateHeaderPlugin)
lazy val logging = crossProject(JVMPlatform, JSPlatform)
.withoutSuffixFor(JVMPlatform)
@ -243,6 +299,19 @@ lazy val logging = crossProject(JVMPlatform, JSPlatform)
"org.typelevel" %%% "cats-core" % catsV
)
)
.enablePlugins(AutomateHeaderPlugin)
lazy val mangler = crossProject(JVMPlatform, JSPlatform)
.withoutSuffixFor(JVMPlatform)
.crossType(CrossType.Pure)
.in(file("utils/mangler"))
.settings(commons)
.settings(
libraryDependencies ++= Seq(
"org.typelevel" %%% "cats-core" % catsV
)
)
.enablePlugins(AutomateHeaderPlugin)
lazy val constants = crossProject(JVMPlatform, JSPlatform)
.withoutSuffixFor(JVMPlatform)
@ -255,6 +324,7 @@ lazy val constants = crossProject(JVMPlatform, JSPlatform)
)
)
.dependsOn(parser, raw)
.enablePlugins(AutomateHeaderPlugin)
lazy val helpers = crossProject(JVMPlatform, JSPlatform)
.withoutSuffixFor(JVMPlatform)
@ -267,6 +337,8 @@ lazy val helpers = crossProject(JVMPlatform, JSPlatform)
"org.typelevel" %%% "cats-free" % catsV
)
)
.dependsOn(errors)
.enablePlugins(AutomateHeaderPlugin)
lazy val errors = crossProject(JVMPlatform, JSPlatform)
.withoutSuffixFor(JVMPlatform)
@ -278,6 +350,7 @@ lazy val errors = crossProject(JVMPlatform, JSPlatform)
"com.lihaoyi" %%% "sourcecode" % sourcecodeV
)
)
.enablePlugins(AutomateHeaderPlugin)
lazy val `backend-air` = crossProject(JVMPlatform, JSPlatform)
.withoutSuffixFor(JVMPlatform)
@ -285,6 +358,7 @@ lazy val `backend-air` = crossProject(JVMPlatform, JSPlatform)
.in(file("backend/air"))
.settings(commons)
.dependsOn(backend, transform)
.enablePlugins(AutomateHeaderPlugin)
lazy val `backend-api` = crossProject(JVMPlatform, JSPlatform)
.withoutSuffixFor(JVMPlatform)
@ -292,6 +366,7 @@ lazy val `backend-api` = crossProject(JVMPlatform, JSPlatform)
.in(file("backend/api"))
.settings(commons)
.dependsOn(backend, transform, `backend-air`)
.enablePlugins(AutomateHeaderPlugin)
lazy val `backend-ts` = crossProject(JVMPlatform, JSPlatform)
.withoutSuffixFor(JVMPlatform)
@ -306,3 +381,4 @@ lazy val `backend-ts` = crossProject(JVMPlatform, JSPlatform)
).map(_ % circeVersion)
)
.dependsOn(`backend-air`, definitions)
.enablePlugins(AutomateHeaderPlugin)

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.compiler
import aqua.backend.AirFunction

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.compiler
import aqua.backend.Generated

View File

@ -1,75 +1,67 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.compiler
import aqua.compiler.AquaError.{ParserError as AquaParserError, *}
import aqua.backend.Backend
import aqua.linker.{AquaModule, Linker, Modules}
import aqua.model.AquaContext
import aqua.parser.lift.{LiftParser, Span}
import aqua.compiler.AquaError.*
import aqua.linker.Linker
import aqua.parser.{Ast, ParserError}
import aqua.raw.RawPart.Parts
import aqua.raw.{RawContext, RawPart}
import aqua.res.AquaRes
import aqua.semantics.{CompilerState, Semantics}
import aqua.semantics.header.{HeaderHandler, HeaderSem, Picker}
import aqua.semantics.{SemanticError, SemanticWarning}
import aqua.semantics.header.Picker.setImportPaths
import aqua.semantics.header.{HeaderHandler, Picker}
import aqua.semantics.{FileId, SemanticError, Semantics}
import cats.data.*
import cats.data.Validated.{validNec, Invalid, Valid}
import cats.parse.Parser0
import cats.syntax.applicative.*
import cats.syntax.flatMap.*
import cats.syntax.functor.*
import cats.syntax.monoid.*
import cats.syntax.traverse.*
import cats.syntax.semigroup.*
import cats.syntax.either.*
import cats.{~>, Comonad, Functor, Monad, Monoid, Order}
import cats.arrow.FunctionK
import cats.data.*
import cats.syntax.either.*
import cats.syntax.functor.*
import cats.syntax.show.*
import cats.{Comonad, Monad, Monoid, Order, Show, ~>}
import scribe.Logging
class AquaCompiler[F[_]: Monad, E, I: Order, S[_]: Comonad, C: Monoid: Picker](
class AquaCompiler[F[_]: Monad, E, I: FileId, S[_]: Comonad, C: Picker](
headerHandler: HeaderHandler[S, C],
semantics: Semantics[S, C]
) extends Logging {
type Err = AquaError[I, E, S]
type Ctx = NonEmptyMap[I, C]
type CompileWarns = [A] =>> CompileWarnings[S][A]
type CompileRes = [A] =>> CompileResult[I, E, S][A]
type CompiledCtx = CompileRes[Ctx]
type CompiledCtxT = CompiledCtx => CompiledCtx
// Transpilation function for module
// (Imports contexts => Compilation result)
type TP = Map[String, C] => CompileRes[C]
private def linkModules(
modules: Modules[I, Err, CompiledCtxT],
cycleError: Linker.DepCycle[AquaModule[I, Err, CompiledCtxT]] => Err
): CompileRes[Map[I, C]] = {
logger.trace("linking modules...")
// By default, provide an empty context for this module's id
val empty: I => CompiledCtx = i => NonEmptyMap.one(i, Monoid[C].empty).pure[CompileRes]
for {
linked <- Linker
.link(modules, cycleError, empty)
.toEither
.toEitherT[CompileWarns]
res <- EitherT(
linked.toList.traverse { case (id, ctx) =>
ctx
.map(
/**
* NOTE: This should be safe
* as result for id should contain itself
*/
_.apply(id).map(id -> _).get
)
.toValidated
}.map(_.sequence.toEither)
)
} yield res.toMap
}
private def transpile(body: Ast[S], importPaths: Map[String, String]): TP =
imports =>
for {
// Process header, get initial context
headerSem <- headerHandler
.sem(imports, body.head)
.toCompileRes
// Analyze the body, with prepared initial context
_ = logger.trace("semantic processing...")
processed <- semantics
.process(body, headerSem.init)
.toCompileRes
// Handle exports, declares - finalize the resulting context
rc <- headerSem
.fin(processed)
.toCompileRes
} yield rc.setImportPaths(importPaths)
def compileRaw(
sources: AquaSources[F, E, I],
@ -77,48 +69,21 @@ class AquaCompiler[F[_]: Monad, E, I: Order, S[_]: Comonad, C: Monoid: Picker](
): F[CompileRes[Map[I, C]]] = {
logger.trace("starting resolving sources...")
new AquaParser[F, E, I, S](sources, parser)
.resolve[CompiledCtx](mod =>
context =>
for {
// Context with prepared imports
ctx <- context
imports = mod.imports.flatMap { case (fn, id) =>
ctx.apply(id).map(fn -> _)
}
header = mod.body.head
headerSem <- headerHandler
.sem(imports, header)
.toCompileRes
// Analyze the body, with prepared initial context
_ = logger.trace("semantic processing...")
processed <- semantics
.process(
mod.body,
headerSem.initCtx
)
.toCompileRes
// Handle exports, declares - finalize the resulting context
rc <- headerSem
.finCtx(processed)
.toCompileRes
/**
* Here we build a map of contexts while processing modules.
* Should not linker provide this info inside this process?
* Building this map complicates things a lot.
*/
} yield NonEmptyMap.one(mod.id, rc)
)
.value
.map(resolved =>
for {
modules <- resolved.toEitherT[CompileWarns]
linked <- linkModules(
modules,
cycle => CycleError(cycle.map(_.id))
)
} yield linked
)
val parsing = new AquaParser(sources, parser)
parsing.resolve.value.map(resolution =>
for {
// Lift resolution to CompileRes
modules <- resolution.toEitherT[CompileWarns]
// Generate transpilation functions for each module
transpiled = modules.map { m =>
val importPaths = m.imports.view.mapValues(_.show).toMap
m.copy(body = transpile(m.body, importPaths))
}
// Link modules
linked <- Linker.link(transpiled, CycleError.apply)
} yield linked
)
}
private val warningsK: semantics.Warnings ~> CompileWarns =

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.compiler
import aqua.raw.ConstantRaw
@ -6,5 +22,9 @@ import aqua.raw.ConstantRaw
* What should compiler care about during compilation before generator backend takes its role
*
* @param constantsList List of known constants
* @param relayVarName Name of the relay variable
*/
case class AquaCompilerConf(constantsList: List[ConstantRaw])
case class AquaCompilerConf(
constants: List[ConstantRaw] = Nil,
relayVarName: Option[String] = Some("-relay-")
)

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.compiler
import aqua.parser

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.compiler
import aqua.compiler.AquaError.{ParserError as AquaParserError, *}
@ -5,21 +21,22 @@ import aqua.linker.{AquaModule, Modules}
import aqua.parser.head.{FilenameExpr, ImportExpr}
import aqua.parser.lift.{LiftParser, Span}
import aqua.parser.{Ast, ParserError}
import aqua.syntax.eithert.fromValidatedF
import cats.data.{Chain, EitherNec, EitherT, NonEmptyChain, Validated, ValidatedNec}
import cats.parse.Parser0
import cats.syntax.either.*
import cats.syntax.applicative.*
import cats.syntax.flatMap.*
import cats.syntax.functor.*
import cats.syntax.monad.*
import cats.syntax.foldable.*
import cats.syntax.traverse.*
import cats.syntax.validated.*
import cats.data.Chain.*
import cats.data.Validated.*
import cats.data.{Chain, EitherNec, EitherT, NonEmptyChain, Validated, ValidatedNec}
import cats.parse.Parser0
import cats.syntax.applicative.*
import cats.syntax.either.*
import cats.syntax.flatMap.*
import cats.syntax.foldable.*
import cats.syntax.functor.*
import cats.syntax.monad.*
import cats.syntax.parallel.*
import cats.syntax.traverse.*
import cats.{~>, Comonad, Monad}
import cats.syntax.validated.*
import cats.{Comonad, Monad, ~>}
import scribe.Logging
// TODO: add tests
@ -33,108 +50,82 @@ class AquaParser[F[_]: Monad, E, I, S[_]: Comonad](
private type FE[A] = EitherT[F, NonEmptyChain[Err], A]
// Parse all the source files
private def parseSources: F[ValidatedNec[Err, Chain[(I, Body)]]] =
sources.sources.map(
_.leftMap(_.map(SourcesError.apply)).andThen(
_.traverse { case (i, s) =>
parser(i)(s).bimap(
_.map(AquaParserError.apply),
ast => i -> ast
)
}
)
// Parse one source (text)
private def parse(id: I, src: String): EitherNec[Err, (I, Body)] =
parser(id)(src).toEither.bimap(
_.map(AquaParserError.apply),
ast => id -> ast
)
// Parse all the source files
private def parseSources: FE[Chain[(I, Body)]] =
for {
srcs <- EitherT
.fromValidatedF(sources.sources)
.leftMap(_.map(SourcesError.apply))
parsed <- srcs
.parTraverse(parse.tupled)
.toEitherT
} yield parsed
// Load one module (parse, resolve imports)
private def loadModule(id: I): FE[AquaModule[I, Err, Body]] =
for {
src <- EitherT
.fromValidatedF(sources.load(id))
.leftMap(_.map(SourcesError.apply))
parsed <- parse(id, src).toEitherT
(id, ast) = parsed
resolved <- resolveImports(id, ast)
} yield resolved
// Resolve imports (not parse, just resolve) of the given file
private def resolveImports(id: I, ast: Body): F[ValidatedNec[Err, AquaModule[I, Err, Body]]] =
ast.collectHead { case fe: FilenameExpr[S] =>
private def resolveImports(id: I, ast: Body): FE[AquaModule[I, Err, Body]] =
ast.head.collect { case fe: FilenameExpr[S] =>
fe.fileValue -> fe.token
}.value.traverse { case (filename, token) =>
sources
.resolveImport(id, filename)
.map(
_.bimap(
_.map(ResolveImportsError(id, token, _): Err),
importId => importId -> (filename, ImportError(token): Err)
)
}.parTraverse { case (filename, token) =>
EitherT
.fromValidatedF(
sources.resolveImport(id, filename)
)
}.map(_.sequence.map { collected =>
AquaModule[I, Err, Body](
id,
.bimap(
_.map(ResolveImportsError(id, token, _): Err),
importId => importId -> (filename, ImportError(token): Err)
)
}.map { collected =>
AquaModule(
id = id,
// How filenames correspond to the resolved IDs
collected.map { case (i, (fn, _)) =>
imports = collected.map { case (i, (fn, _)) =>
fn -> i
}.toList.toMap[String, I],
}.toList.toMap,
// Resolved IDs to errors that point to the import in source code
collected.map { case (i, (_, err)) =>
dependsOn = collected.map { case (i, (_, err)) =>
i -> err
}.toList.toMap[I, Err],
ast
}.toList.toMap,
body = ast
)
})
// Parse sources, convert to modules
private def sourceModules: F[ValidatedNec[Err, Modules[I, Err, Body]]] =
parseSources.flatMap {
case Validated.Valid(srcs) =>
srcs.traverse { case (id, ast) =>
resolveImports(id, ast)
}.map(_.sequence)
case Validated.Invalid(errs) =>
errs.invalid.pure[F]
}.map(
_.map(
_.foldLeft(Modules[I, Err, Body]())(
_.add(_, toExport = true)
)
)
)
private def loadModule(imp: I): F[ValidatedNec[Err, AquaModule[I, Err, Body]]] =
sources
.load(imp)
.map(_.leftMap(_.map(SourcesError.apply)).andThen { src =>
parser(imp)(src).leftMap(_.map(AquaParserError.apply))
})
.flatMap {
case Validated.Valid(ast) =>
resolveImports(imp, ast)
case Validated.Invalid(errs) =>
errs.invalid.pure[F]
}
private def resolveModules(
modules: Modules[I, Err, Body]
): F[ValidatedNec[Err, Modules[I, Err, Ast[S]]]] =
modules.dependsOn.toList.traverse { case (moduleId, unresolvedErrors) =>
loadModule(moduleId).map(_.leftMap(_ ++ unresolvedErrors))
}.map(
_.sequence.map(
_.foldLeft(modules)(_ add _)
)
).flatMap {
case Validated.Valid(ms) if ms.isResolved =>
ms.validNec.pure[F]
case Validated.Valid(ms) =>
resolveModules(ms)
case err =>
err.pure[F]
}
private def resolveSources: FE[Modules[I, Err, Ast[S]]] =
// Load modules (parse, resolve imports) of all the source files
private lazy val loadModules: FE[Modules[I, Err, Body]] =
for {
ms <- EitherT(
sourceModules.map(_.toEither)
)
res <- EitherT(
resolveModules(ms).map(_.toEither)
)
} yield res
srcs <- parseSources
modules <- srcs.parTraverse(resolveImports.tupled)
} yield Modules.from(modules)
def resolve[T](
transpile: AquaModule[I, Err, Body] => T => T
): FE[Modules[I, Err, T => T]] =
resolveSources.map(_.mapModuleToBody(transpile))
// Resolve modules (load all the dependencies)
private def resolveModules(
modules: Modules[I, Err, Body]
): FE[Modules[I, Err, Ast[S]]] =
modules.iterateUntilM(ms =>
// Load all modules that are dependencies of the current modules
ms.dependsOn.toList.parTraverse { case (moduleId, unresolvedErrors) =>
loadModule(moduleId).leftMap(_ ++ unresolvedErrors)
}.map(ms.addAll) // Add all loaded modules to the current modules
)(_.isResolved)
lazy val resolve: FE[Modules[I, Err, Body]] =
loadModules >>= resolveModules
}

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.compiler
import aqua.model.AquaContext

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.compiler
import cats.data.{Chain, ValidatedNec}

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.compiler
import aqua.semantics

View File

@ -1,36 +1,41 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.compiler
import aqua.backend.Backend
import aqua.compiler.AquaError.*
import aqua.backend.{AirFunction, Backend}
import aqua.linker.{AquaModule, Linker, Modules}
import aqua.model.AquaContext
import aqua.parser.lift.{LiftParser, Span}
import aqua.parser.{Ast, ParserError}
import aqua.raw.RawPart.Parts
import aqua.raw.{RawContext, RawPart}
import aqua.res.AquaRes
import aqua.raw.{ConstantRaw, RawContext}
import aqua.semantics.header.{HeaderHandler, HeaderSem}
import aqua.semantics.{CompilerState, RawSemantics, Semantics}
import aqua.semantics.rules.locations.{DummyLocationsInterpreter, LocationsAlgebra}
import aqua.semantics.{FileId, RawSemantics}
import cats.data.*
import cats.data.Validated.{invalid, validNec, Invalid, Valid}
import cats.parse.Parser0
import cats.syntax.applicative.*
import cats.syntax.flatMap.*
import cats.syntax.foldable.*
import cats.syntax.functor.*
import cats.syntax.monoid.*
import cats.syntax.semigroup.*
import cats.syntax.traverse.*
import cats.syntax.either.*
import cats.{~>, Comonad, Monad, Monoid, Order}
import cats.syntax.flatMap.*
import cats.syntax.functor.*
import cats.syntax.traverse.*
import cats.{Comonad, Monad, Monoid, Order, Show}
import scribe.Logging
import scala.collection.MapView
object CompilerAPI extends Logging {
private def toAquaProcessed[I: Order, E, S[_]: Comonad](
private def toAquaProcessed[I: FileId, S[_]: Comonad](
filesWithContext: Map[I, RawContext]
): Chain[AquaProcessed[I]] = {
logger.trace("linking finished")
@ -38,43 +43,32 @@ object CompilerAPI extends Logging {
filesWithContext.toList
// Process all contexts maintaining Cache
.traverse { case (i, rawContext) =>
for {
cache <- State.get[AquaContext.Cache]
_ = logger.trace(s"Going to prepare exports for $i...")
(exp, expCache) = AquaContext.exportsFromRaw(rawContext, cache)
_ = logger.trace(s"AquaProcessed prepared for $i")
_ <- State.set(expCache)
} yield AquaProcessed(i, exp)
AquaContext
.exportsFromRaw(rawContext)
.map(exp => AquaProcessed(i, exp))
}
.runA(AquaContext.Cache())
.runA(AquaContext.Cache.empty)
// Convert result List to Chain
.map(Chain.fromSeq)
.value
}
private def getAquaCompiler[F[_]: Monad, E, I: Order, S[_]: Comonad](
private def getAquaCompiler[F[_]: Monad, E, I: FileId, S[_]: Comonad](
config: AquaCompilerConf
): AquaCompiler[F, E, I, S, RawContext] = {
given Monoid[RawContext] = RawContext
.implicits(
RawContext.blank.copy(
parts = Chain
.fromSeq(config.constantsList)
.map(const => RawContext.blank -> const)
)
)
.rawContextMonoid
given LocationsAlgebra[S, State[RawContext, *]] =
DummyLocationsInterpreter()
val semantics = new RawSemantics[S]()
val constants = config.constants ++ ConstantRaw.defaultConstants(config.relayVarName)
new AquaCompiler[F, E, I, S, RawContext](
new AquaCompiler(
new HeaderHandler(),
semantics
new RawSemantics(constants)
)
}
// Get result generated by backend
def compile[F[_]: Monad, E, I: Order, S[_]: Comonad](
def compile[F[_]: Monad, E, I: FileId, S[_]: Comonad](
sources: AquaSources[F, E, I],
parser: I => String => ValidatedNec[ParserError[S], Ast[S]],
airValidator: AirValidator[F],
@ -112,7 +106,7 @@ object CompilerAPI extends Logging {
} yield result
}
def compileToContext[F[_]: Monad, E, I: Order, S[_]: Comonad](
def compileToContext[F[_]: Monad, E, I: FileId, S[_]: Comonad](
sources: AquaSources[F, E, I],
parser: I => String => ValidatedNec[ParserError[S], Ast[S]],
config: AquaCompilerConf

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua
import cats.data.{Chain, EitherT, NonEmptyChain, Writer}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,234 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.compiler
import aqua.model.*
import aqua.model.transform.{ModelBuilder, TransformConfig}
import aqua.res.*
import aqua.types.*
import cats.syntax.option.*
import org.scalatest.Inside
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
class AquaModulesSpec extends CompilerSpec {
import ModelBuilder.*
// Importing empty module caused internal compiler error once
it should "sucessfully import empty module" in {
val module = s"""aqua Module
|""".stripMargin
val main = s"""aqua Main
|
|use "module"
|
|export main
|
|func main() -> i32:
| <- 42
|""".stripMargin
val src = Map("main.aqua" -> main)
val imports = Map("module.aqua" -> module)
val transformCfg = TransformConfig(relayVarName = None)
insideRes(src, imports, transformCfg)(
"main"
) { case main :: _ =>
val ap = CallModel.Export("literal_ap", LiteralType.unsigned)
val props = ap.copy(name = "literal_props")
val expected = XorRes.wrap(
respCall(transformCfg, LiteralModel.number(42), initPeer),
errorCall(transformCfg, 0, initPeer)
)
main.body.equalsOrShowDiff(expected) should be(true)
}
}
it should "merge modules on redeclaration" in {
def test(subA: String, subB: String) = {
val moduleA = s"""aqua Module.$subA declares fA
|func fA() -> i32:
| <- 42
|""".stripMargin
val moduleB = s"""aqua Module.$subB declares fB
|func fB() -> i32:
| <- 24
|""".stripMargin
val merged = s"""aqua Merged declares Module
|use "moduleA"
|use "moduleB"
""".stripMargin
val main = s"""aqua Main
|
|use "merged"
|
|export main
|
|func main() -> i32:
| <- Merged.Module.$subA.fA() + Merged.Module.$subB.fB()
|""".stripMargin
val src = Map("main.aqua" -> main)
val imports = Map(
"moduleA.aqua" -> moduleA,
"moduleB.aqua" -> moduleB,
"merged.aqua" -> merged
)
val transformCfg = TransformConfig(relayVarName = None)
insideRes(src, imports, transformCfg)(
"main"
) { case main :: _ =>
val ap = CallModel.Export("literal_ap", LiteralType.unsigned)
val props = ap.copy(name = "literal_props")
val expected = XorRes.wrap(
respCall(transformCfg, LiteralModel.number(42 + 24), initPeer),
errorCall(transformCfg, 0, initPeer)
)
main.body.equalsOrShowDiff(expected) should be(true)
}
}
test("A", "B")
test("Lib.A", "Lib.B")
test("Lib.Sub", "Lib.Sub.Path")
}
it should "allow renaming of redeclared symbols" in {
def test(
symbolRename: Option[String] = None,
moduleRename: Option[String] = None
) = {
val lib = s"""aqua Lib.Impl declares f
|func f() -> i32:
| <- 42
|""".stripMargin
val module = s"""aqua Module declares Lib
|use "lib"
|""".stripMargin
val asSymbol = symbolRename.fold("")(" as " + _)
val symbolName = symbolRename.getOrElse("Lib.Impl.f")
val asModule = moduleRename.fold("")(" as " + _)
val moduleName = moduleRename.getOrElse("Module")
val renaming = s"""aqua Renaming declares $moduleName
|use Lib.Impl.f$asSymbol from "module"$asModule
|""".stripMargin
val main = s"""aqua Main
|
|use "renaming"
|
|export main
|
|func main() -> i32:
| <- Renaming.$moduleName.$symbolName()
|""".stripMargin
val src = Map("main.aqua" -> main)
val imports = Map(
"lib.aqua" -> lib,
"module.aqua" -> module,
"renaming.aqua" -> renaming
)
val transformCfg = TransformConfig(relayVarName = None)
insideRes(src, imports, transformCfg)(
"main"
) { case main :: _ =>
val ap = CallModel.Export("literal_ap", LiteralType.unsigned)
val props = ap.copy(name = "literal_props")
val expected = XorRes.wrap(
respCall(transformCfg, LiteralModel.number(42), initPeer),
errorCall(transformCfg, 0, initPeer)
)
main.body.equalsOrShowDiff(expected) should be(true)
}
}
test()
test("g".some)
test("Lib.f".some)
test("Lib.Impl.g".some)
test("g".some, "NewLib".some)
test("Sub.Path.g".some, "NewLib.Another".some)
}
it should "allow renaming of redeclared symbols (with `import`)" in {
def test(symbolRename: Option[String] = None) = {
val lib = s"""aqua Lib.Impl declares f
|func f() -> i32:
| <- 42
|""".stripMargin
val module = s"""aqua Module declares Lib
|use "lib"
|""".stripMargin
val asSymbol = symbolRename.fold("")(" as " + _)
val symbolName = symbolRename.getOrElse("Lib.Impl.f")
val renaming = s"""aqua Renaming declares $symbolName
|import Lib.Impl.f$asSymbol from "module"
|""".stripMargin
val main = s"""aqua Main
|
|use "renaming"
|
|export main
|
|func main() -> i32:
| <- Renaming.$symbolName()
|""".stripMargin
val src = Map("main.aqua" -> main)
val imports = Map(
"lib.aqua" -> lib,
"module.aqua" -> module,
"renaming.aqua" -> renaming
)
val transformCfg = TransformConfig(relayVarName = None)
insideRes(src, imports, transformCfg)(
"main"
) { case main :: _ =>
val ap = CallModel.Export("literal_ap", LiteralType.unsigned)
val props = ap.copy(name = "literal_props")
val expected = XorRes.wrap(
respCall(transformCfg, LiteralModel.number(42), initPeer),
errorCall(transformCfg, 0, initPeer)
)
main.body.equalsOrShowDiff(expected) should be(true)
}
}
test()
test("g".some)
test("NewLib.g".some)
test("Lib.f".some)
test("Lib.Impl.g".some)
}
}

View File

@ -0,0 +1,88 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.compiler
import aqua.compiler.FileIdString.given
import aqua.model.AquaContext
import aqua.model.transform.{Transform, TransformConfig}
import aqua.parser.lift.Span
import aqua.parser.{Parser, ParserError}
import aqua.raw.ConstantRaw
import aqua.res.FuncRes
import cats.Id
import cats.data.{Chain, NonEmptyChain, Validated, ValidatedNec}
import cats.syntax.either.*
import org.scalatest.Inside
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
trait CompilerSpec extends AnyFlatSpec with Matchers with Inside {
private def aquaSource(src: Map[String, String], imports: Map[String, String]) = {
new AquaSources[Id, String, String] {
override def sources: Id[ValidatedNec[String, Chain[(String, String)]]] =
Validated.validNec(Chain.fromSeq(src.toSeq))
override def resolveImport(from: String, imp: String): Id[ValidatedNec[String, String]] =
Validated.validNec(imp)
override def load(file: String): Id[ValidatedNec[String, String]] =
Validated.fromEither(
(imports ++ src)
.get(file)
.toRight(NonEmptyChain.one(s"Cannot load imported file $file"))
)
}
}
protected def insideContext(
src: Map[String, String],
imports: Map[String, String] = Map.empty
)(test: AquaContext => Any) = {
val compiled = CompilerAPI
.compileToContext[Id, String, String, Span.S](
aquaSource(src, imports),
id => txt => Parser.parse(Parser.parserSchema)(txt),
AquaCompilerConf(ConstantRaw.defaultConstants(None))
)
.value
.value
.toValidated
inside(compiled) { case Validated.Valid(contexts) =>
inside(contexts.headOption) { case Some(ctx) =>
test(ctx)
}
}
}
protected def insideRes(
src: Map[String, String],
imports: Map[String, String] = Map.empty,
transformCfg: TransformConfig = TransformConfig()
)(funcNames: String*)(
test: PartialFunction[List[FuncRes], Any]
) = insideContext(src, imports)(ctx =>
val aquaRes = Transform.contextRes(ctx, transformCfg)
// To preserve order as in funcNames do flatMap
val funcs = funcNames.flatMap(name => aquaRes.funcs.find(_.funcName == name)).toList
inside(funcs)(test)
)
}

View File

@ -0,0 +1,27 @@
/*
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package aqua.compiler
import aqua.semantics.FileId
object FileIdString {
given FileId[String] with {
override def show(t: String): String = t
override def compare(x: String, y: String): Int = x.compare(y)
}
}

View File

@ -1,16 +0,0 @@
import "@fluencelabs/aqua-dht/pubsub.aqua"
import "@fluencelabs/aqua-dht/dht.aqua"
import "@fluencelabs/aqua-lib/builtin.aqua"
export getNeighbours, initTopicAndSubscribe, findSubscribers
func put_value(initial_peer: string, value: string) -> string:
initTopicAndSubscribe(initial_peer, value, nil, nil)
<- "OK"
func registerKeyPutValue(node_id: string, key: string, value: string, relay_id: ?string, service_id: ?string) -> []string:
nodes <- getNeighbours(key)
for n <- nodes par:
on n:
t <- Peer.timestamp_sec()
<- nodes

View File

@ -1,8 +1,8 @@
aqua Main
use DECLARE_CONST, decl_bar from "imports_exports/declare.aqua" as Declare
export handleAb, SomeService, bug214, checkAbCalls, bugLNG258_1, bugLNG258_2, bugLNG258_3, multipleAbilityWithClosure, MySrv, returnSrvAsAbility
export handleAb, SomeService, bug214, checkAbCalls, bugLNG258_1, bugLNG258_2, bugLNG258_3, multipleAbilityWithClosure
use DECLARE_CONST, decl_bar from "imports_exports/declare.aqua" as Declare
service SomeService("wed"):
getStr(s: string) -> string
@ -128,4 +128,28 @@ func multipleAbilityWithClosure() -> i8, i8:
ab2 <- createAb(2)
<- ab.arrow(), ab2.arrow()
ability MyAb:
call() -> string
service MySrv("default-id"):
call() -> string
func mySrvDefault() -> MyAb:
<- MySrv
func mySrvResolved() -> MyAb:
MySrv "resolved-id"
<- MySrv
func useMyAb{MyAb}() -> string:
<- MyAb.call()
func returnSrvAsAbility() -> []string:
result: *string
MySrvDefault <- mySrvDefault()
MySrvResolved <- mySrvResolved()
result <- useMyAb{MySrvDefault}()
result <- useMyAb{MySrvResolved}()
<- result

View File

@ -0,0 +1,49 @@
aqua M
export bugLNG314, bugLNG338
ability WorkerJob:
runOnSingleWorker(w: string) -> string
func disjoint_run{WorkerJob}() -> -> string:
run = func () -> string:
r <- WorkerJob.runOnSingleWorker("worker")
<- r
<- run
func runJob(j: -> string) -> string:
<- j()
func bugLNG314() -> string:
job2 = () -> string:
<- "strstrstr"
worker_job = WorkerJob(runOnSingleWorker = job2)
subnet_job <- disjoint_run{worker_job}()
res <- runJob(subnet_job)
<- res
ability Compute:
job() -> string
func lift() -> Compute:
job = () -> string:
<- "job done"
<- Compute(job)
ability Function:
run() -> string
func roundtrip{Function}() -> string:
res <- Function.run()
<- res
func disj{Compute}() -> Function:
run = func () -> string:
<- Compute.job()
<- Function(run = run)
func bugLNG338() -> string:
comp = lift()
fn = disj{comp}()
res <- roundtrip{fn}()
<- res

View File

@ -0,0 +1,48 @@
aqua AbilitiesClosureRename
export bugLNG346
ability Promise:
yield() -> string
func done_nil() -> string:
<- ""
func done() -> Promise:
<- Promise(yield = done_nil)
ability Compute:
yield() -> string
alias WorkerYield: -> string
alias Yield: WorkerYield -> Promise
func wait_for() -> Yield:
wait = func (cb: -> string) -> Promise:
yield = func () -> string:
e <- cb()
<- e
<- Promise(yield = yield)
<- wait
ability Function:
run(dealId: string) -> string
func simple{Compute}(yield: Yield) -> Function:
deal_run = func () -> string:
c_yield = func () -> string:
<- Compute.yield()
yieeld <- yield(c_yield)
res <- yieeld.yield()
<- res
<- Function(run = deal_run)
func bugLNG346() -> string:
res: *string
yieeld = func () -> string:
res <<- "hello"
<- ""
c = Compute(yield = yieeld)
fn = simple{c}(wait_for())
r <- fn.run("")
<- res!

View File

@ -1,24 +0,0 @@
data SomeData:
value: string
otherValue: u64
data SubData:
someStr: string
someNum: i32
data SecondData:
value: string
complex: SubData
data ThirdData:
value: string
complex: SomeData
service ComplexService("op-ha"):
call(d: SomeData, sd: SecondData) -> SubData
identity() -> SecondData
func doSmth(d: SomeData, d2: SomeData, sd: SecondData, c: SubData, SecondData -> ThirdData) -> ThirdData:
res <- ComplexService.call(d, sd)
res2 <- c(res, sd)
<- res2

View File

@ -1,3 +1,7 @@
aqua Assignment
export doSmth
data Prod:
value: string

View File

@ -1,6 +1,11 @@
aqua CallArrow
export passFunctionAsArg, reproArgsBug426
import "println.aqua"
import "@fluencelabs/aqua-lib/builtin.aqua"
-- functions like `c` are called an 'arrow function' in Aqua
-- `c` passed to a function from a client, so, it could be called only on a client
func passFunctionAsArg(node: string, str: string, c: string -> string):

View File

@ -1,3 +1,7 @@
aqua Canon
export Ser, bugLng79
data Record:
relay_id: []string
peer_id: string

View File

@ -1,18 +1,18 @@
aqua Test
export test, TestService
export test, TestServiceClosureArrowCapture
service TestService:
service TestServiceClosureArrowCapture:
call(s: string) -> string
ability TestAbility:
arrow(s: string) -> string
func returnCapture() -> string -> string:
TestService "test-service"
TestServiceClosureArrowCapture "test-service"
closure = (s: string) -> string:
<- TestService.call(s)
<- TestServiceClosureArrowCapture.call(s)
closure1 = closure
closure2 = closure1
@ -26,7 +26,7 @@ func returnCapture() -> string -> string:
s1 <- closure(s) -- capture closure
s2 <- closure3(s1) -- capture renamed closure
s3 <- Ab.arrow(s2) -- capture ability
s4 <- TestService.call(s3) -- capture service
s4 <- TestServiceClosureArrowCapture.call(s3) -- capture service
<- s4
<- capture

View File

@ -1,6 +1,6 @@
aqua ClosureReturnRename
export lng193Bug
export lng193Bug, lng365Bug
func getClosure(arg: u16, peer: string) -> u16 -> u16:
on peer:
@ -16,3 +16,44 @@ func lng193Bug(peer: string, closurePeer: string) -> u16:
res1 = a(1) + a(2) -- Call two times for
res2 = b(3) + b(4) -- bug to appear
<- res1 + res2
ability Streams:
stream: *string
map: %string
ability Adds:
addToStream(s: string)
addToMap(k: string, v: string)
func addToStreamClosure(str: *string) -> string -> ():
cl = func (s: string):
str <<- s
<- cl
func toMap(k: string, v: string) -> string, string:
<- k, v
func addToMapClosure(str: %string) -> string, string -> ():
cl = func (k: string, v: string):
str <- toMap(k, v)
<- cl
func addTo{Streams}() -> Adds:
addStream = addToStreamClosure(Streams.stream)
addMap = addToMapClosure(Streams.map)
adds = Adds(addToStream = addStream, addToMap = addMap)
<- adds
func add{Adds}(s: string, k: string):
Adds.addToStream(s)
Adds.addToMap(k, k)
func lng365Bug() -> []string, []string:
stream: *string
map: %string
ab = Streams(stream = stream, map = map)
adds <- addTo{ab}()
add{adds}("one", "1")
add{adds}("two", "2")
add{adds}("three", "3")
<- stream, map.keys()

View File

@ -0,0 +1,49 @@
aqua ClosureStreamScopes
export simpleTest, complexTest
ability Join:
join1() -> []string
ability Fork:
fork() -> Join
func simpleTest() -> []string:
fork = () -> Join:
in: *string
join1 = () -> []string:
in <<- "something in nested"
<- ["result"]
in <<- "something in"
<- Join(join1)
f = Fork(fork)
j = f.fork()
<- j.join1()
func fork() -> Join:
in: *string
out: *string
join1 = () -> []string:
inJoin: *string
for i <- in rec:
inJoin <<- i
for o <- out rec:
inJoin <<- o
join in!
par join out!
<- inJoin
in <<- "something in INSIDE"
out <<- "something out INSIDE"
<- Join(join1)
func complexTest() -> []string, []string:
out: *string
f = Fork(fork = fork)
j <- f.fork()
strs <- j.join1()
out <<- "something out OUTSIDE"
<- strs, out

View File

@ -1,9 +1,10 @@
module Closure declares *
aqua Closure declares *
export LocalSrv, closureIn, closureOut, closureBig, closureOut2, lng58Bug, multipleClosuresBugLNG262, lng317Bug
export lng325Bug, lng325BugTwoFuncs
import "@fluencelabs/aqua-lib/builtin.aqua"
export LocalSrv, closureIn, closureOut, closureBig, closureOut2, lng58Bug, multipleClosuresBugLNG262
service MyOp("op"):
identity(s: string) -> string
@ -80,4 +81,78 @@ func create(a: i8) -> -> i8:
func multipleClosuresBugLNG262() -> i8, i8:
arr1 <- create(1)
arr2 <- create(2)
<- arr1(), arr2()
<- arr1(), arr2()
ability WorkerJob:
runOnSingleWorker(w: string) -> []string
func runJob(j: -> []string) -> []string:
<- j()
func disjoint_run{WorkerJob}() -> -> []string:
run = func () -> []string:
r <- WorkerJob.runOnSingleWorker("a")
<- r
<- run
func empty() -> string:
a = "empty"
<- a
func lng317Bug() -> []string:
res: *string
outer = () -> string:
<- empty()
clos = () -> -> []string:
job2 = () -> []string:
res <- outer()
res <- MyOp.identity("identity")
<- res
<- job2
worker_job = WorkerJob(runOnSingleWorker = clos())
subnet_job <- disjoint_run{worker_job}()
finalRes <- runJob(subnet_job)
<- finalRes
ability Job:
run(s: string) -> string
func disrun(getJob: -> Job) -> Job:
j <- getJob()
<- j
func lng325Bug() -> string:
brokenStream: *string
job = () -> Job:
run = (str: string) -> string:
brokenStream <- MyOp.identity(str)
<- "run"
<- Job(run = run)
subnetJob <- disrun(job)
subnetJob.run("firstStream string")
<- brokenStream!
func secondStream() -> string:
brokenStream: *string
secondJob = () -> Job:
secondRun = (str: string) -> string:
brokenStream <- MyOp.identity(str)
<- "run"
<- Job(run = secondRun)
subnetJob <- disrun(secondJob)
subnetJob.run("secondStream string")
<- brokenStream!
func lng325BugTwoFuncs() -> string, string:
res1 <- lng325Bug()
res2 <- secondStream()
<- res1, res2

View File

@ -1,3 +1,7 @@
aqua Co
export CoService, coFunc
import "@fluencelabs/aqua-lib/builtin.aqua"
service CoService("coservice-id"):

View File

@ -1,3 +1,7 @@
aqua CollectionSugar
export arraySugar, streamSugar, optionSugar, GetArr, bugLNG59
import "@fluencelabs/aqua-lib/builtin.aqua"
func arraySugar(n: u32, m: u32) -> []u32, []u32:

View File

@ -1,3 +1,7 @@
aqua Complex
export TestS, doStuff
import "helloWorld.aqua"
import "println.aqua"
import "@fluencelabs/aqua-lib/builtin.aqua"

View File

@ -1,3 +1,7 @@
aqua Constants
export Getter, callConstant, timestampAndTtl
import "@fluencelabs/aqua-lib/builtin.aqua"
service Getter("test"):

View File

@ -1,3 +1,7 @@
aqua DataAlias
export NodeIdGetter, getAliasedData
-- set `PeerId` name to be a type alias for `string` type
alias PeerId : string

View File

@ -1,3 +1,5 @@
aqua Example
service Peer("peer"):
is_connected: string -> bool

Some files were not shown because too many files have changed in this diff Show More