mirror of
https://github.com/fluencelabs/aqua.git
synced 2025-03-15 11:40:50 +00:00
Compare commits
280 Commits
aqua-v0.11
...
main
Author | SHA1 | Date | |
---|---|---|---|
|
31a3ec9eae | ||
|
3f4abfbf4f | ||
|
cc269aec4d | ||
|
1d8019ed87 | ||
|
b0f3a8c21e | ||
|
af3fc24adb | ||
|
1c76f75d80 | ||
|
4d49279569 | ||
|
4ad0655da6 | ||
|
d6178f2203 | ||
|
223a381a47 | ||
|
77b7b9b4bd | ||
|
1563f7cdd8 | ||
|
037532fb85 | ||
|
af741c3141 | ||
|
934c20c98a | ||
|
dad8db54cf | ||
|
40cf81efe2 | ||
|
534ab1d952 | ||
|
339400fe52 | ||
|
cff7f949cc | ||
|
0d9b5241c7 | ||
|
7468f6fd18 | ||
|
e0513a6218 | ||
|
32b9043e81 | ||
|
aa986ca6e8 | ||
|
35db82c767 | ||
|
faf5b8071f | ||
|
6cc068ac36 | ||
|
9c23a9d4ef | ||
|
f0ad76189a | ||
|
04f8bd2f68 | ||
|
e9420878f8 | ||
|
1ba7ae38ec | ||
|
e6c5d0039f | ||
|
f29e44e52a | ||
|
07bea1a909 | ||
|
49729ac40a | ||
|
331d497eb5 | ||
|
9dc9e55973 | ||
|
8f06ac1cba | ||
|
cc69e696dc | ||
|
11498f0996 | ||
|
1ef0dafe2e | ||
|
0a49f22365 | ||
|
14748c7646 | ||
|
320b516807 | ||
|
d8b7c8cba3 | ||
|
92d0450481 | ||
|
6aa78eeb6f | ||
|
5c7f6a89c6 | ||
|
c444d24f89 | ||
|
a6c8e75c27 | ||
|
d7fef3db5f | ||
|
6e9689945d | ||
|
23aba18c7d | ||
|
96c1675350 | ||
|
5216637fcd | ||
|
3e9d385668 | ||
|
27f132f18a | ||
|
b22762ca6d | ||
|
df5eb29d92 | ||
|
245f6640f8 | ||
|
e2b150a786 | ||
|
82ac0b2d41 | ||
|
3cd31c5827 | ||
|
9423ffc509 | ||
|
9444ce745a | ||
|
f4cc7818f4 | ||
|
17fb77c40f | ||
|
f7194f0a54 | ||
|
d03211b492 | ||
|
a8ae49b55b | ||
|
d30b6e1b38 | ||
|
1a0b3a22c1 | ||
|
11f8d3b11b | ||
|
d828cbd3bd | ||
|
3a79239022 | ||
|
0e44e7a0b1 | ||
|
d14d36215c | ||
|
f085d207bb | ||
|
7694514d29 | ||
|
7b6c7245ec | ||
|
abcb63db3b | ||
|
27704a9169 | ||
|
f94f38327a | ||
|
e323368b69 | ||
|
ff1800c674 | ||
|
d057a5e695 | ||
|
34e274d45e | ||
|
098fac79ba | ||
|
85f3ecdf39 | ||
|
d46ee0347f | ||
|
5241f522d8 | ||
|
d5cd77bb86 | ||
|
ae32f80277 | ||
|
9aec470d38 | ||
|
851a66fb5f | ||
|
55836d5a9d | ||
|
a4d8ee7083 | ||
|
5bc01a9c02 | ||
|
33a2ca87e0 | ||
|
7fe0212761 | ||
|
6732f8f2cc | ||
|
bb013d79f7 | ||
|
f7bfa8317b | ||
|
00252fe8a7 | ||
|
2f135e4fd2 | ||
|
d97de9c83f | ||
|
409570afde | ||
|
39a23db2bf | ||
|
7689ee0fd9 | ||
|
051aa41715 | ||
|
c474a77e76 | ||
|
74d02e1f63 | ||
|
4cecab1a26 | ||
|
6329e42f56 | ||
|
9d0fb2b841 | ||
|
e65836e3c8 | ||
|
b24fcf686f | ||
|
4342812450 | ||
|
011a1d7260 | ||
|
2ac69616b5 | ||
|
2d4b2aece4 | ||
|
d7023c0f10 | ||
|
1e525fad35 | ||
|
3472f2016f | ||
|
cee444862a | ||
|
11c8970fd8 | ||
|
522d95b8e3 | ||
|
68425ed42a | ||
|
313502ecae | ||
|
a1576efad9 | ||
|
6e6b567f8e | ||
|
3b0d31325a | ||
|
e7ea1f80ac | ||
|
7ce95d0a75 | ||
|
5a3c5e6666 | ||
|
077dc8ff13 | ||
|
78ee753c7b | ||
|
634b1c17b6 | ||
|
38f77285f5 | ||
|
45ca7bbf3e | ||
|
fcdb5b0fef | ||
|
2f11a0649f | ||
|
fab46ee130 | ||
|
c83d69e689 | ||
|
441c012e01 | ||
|
679d43f7eb | ||
|
03d23eb577 | ||
|
030a0d464b | ||
|
14f3d92ef4 | ||
|
ba15d9e06a | ||
|
f39bca928a | ||
|
5f6c47ffea | ||
|
b298eebf5e | ||
|
feb7a167a2 | ||
|
c109f37efa | ||
|
1e636cc076 | ||
|
878990a837 | ||
|
b2ca1d35bf | ||
|
ca6cae96ad | ||
|
f158074c4e | ||
|
a80033b81c | ||
|
91af0bf055 | ||
|
27a781dd3f | ||
|
1c708c8bb0 | ||
|
66638afa2d | ||
|
8741c910be | ||
|
fb75bc267e | ||
|
ed9e708939 | ||
|
feccffcb00 | ||
|
594f46529d | ||
|
54ddcc8b62 | ||
|
bba6645e7a | ||
|
d1d5a35a42 | ||
|
ab9a511129 | ||
|
f2c2c07cf2 | ||
|
67d8151d94 | ||
|
3f916c78ab | ||
|
6be2a3d5da | ||
|
f8b5017918 | ||
|
d6f879ef7a | ||
|
404d5ffae2 | ||
|
1e2e35ee88 | ||
|
9f863eae43 | ||
|
03042a71f3 | ||
|
148cb0004e | ||
|
cd863ff246 | ||
|
e219752c9c | ||
|
3419607e8c | ||
|
69a808e243 | ||
|
df111adf21 | ||
|
c857807014 | ||
|
4365dcb899 | ||
|
1f23545b49 | ||
|
c1fbea1a49 | ||
|
443e65e3d8 | ||
|
77864202d1 | ||
|
5adbae0677 | ||
|
0f9ede09fb | ||
|
2a0b207633 | ||
|
3b033852f9 | ||
|
bf0b51fa5b | ||
|
5db1282c1f | ||
|
badc7d7a45 | ||
|
7a6fce27f7 | ||
|
071ba7d483 | ||
|
75b0b5760d | ||
|
8060695dbb | ||
|
019611a89c | ||
|
eb4cdb0dd1 | ||
|
f562bd40b6 | ||
|
6146f8e40a | ||
|
49c9be6dd8 | ||
|
731f424576 | ||
|
50e8bab3de | ||
|
c7fca40f67 | ||
|
a5e9354aeb | ||
|
ef4b0143ac | ||
|
d2637976c1 | ||
|
bc75611eb3 | ||
|
726230c987 | ||
|
2d5d377967 | ||
|
4e3e70f4fc | ||
|
dba12b8277 | ||
|
a5b6102422 | ||
|
fabf8d7d61 | ||
|
4c3c32b7c4 | ||
|
50ba194b86 | ||
|
cb539f1332 | ||
|
c9bf77d53c | ||
|
c097bedd47 | ||
|
63a9f42e86 | ||
|
ca52e2542c | ||
|
a804504522 | ||
|
33ab33d4c8 | ||
|
0f9c40e9d1 | ||
|
cc8610b3e6 | ||
|
b8b0fafda0 | ||
|
a7dba14c7c | ||
|
c1fe24b04d | ||
|
22f380a491 | ||
|
cef7dff098 | ||
|
742d1f35b7 | ||
|
a10d50407b | ||
|
667a8255d9 | ||
|
8ba7021cd4 | ||
|
339d3a8217 | ||
|
2985baadfc | ||
|
9fdf4e1005 | ||
|
26f943177d | ||
|
46705754e6 | ||
|
aa10706506 | ||
|
6cc3a969d2 | ||
|
b9d03cbcf0 | ||
|
4acbf4dc7e | ||
|
a70da08bdf | ||
|
4fcfaf9c7c | ||
|
e22fff7c8a | ||
|
c73a98b7a0 | ||
|
889c50734b | ||
|
017eca7056 | ||
|
bae5eed08a | ||
|
6c7147212d | ||
|
d6e3ec725c | ||
|
f1abd587b7 | ||
|
739854a20b | ||
|
45c44b3046 | ||
|
c5534a964c | ||
|
8c2240d3b1 | ||
|
e9c004452e | ||
|
e2f67b3c0f | ||
|
5f5fc494b6 | ||
|
62b16426de | ||
|
7410765606 | ||
|
0b66aa96ec | ||
|
21cb3937ac | ||
|
da0821d9d5 | ||
|
f9112851b4 |
@ -1,52 +1,54 @@
|
||||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
|
||||
// README at: https://github.com/devcontainers/templates/tree/main/src/debian
|
||||
{
|
||||
"name": "Compiler Codespace",
|
||||
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
|
||||
"image": "mcr.microsoft.com/devcontainers/base:bullseye",
|
||||
// Features to add to the dev container. More info: https://containers.dev/features.
|
||||
"features": {
|
||||
"ghcr.io/devcontainers-contrib/features/sbt-sdkman:2": {},
|
||||
"ghcr.io/devcontainers-contrib/features/scala-sdkman:2": {},
|
||||
"ghcr.io/devcontainers/features/node:1": {
|
||||
"version": "16"
|
||||
}
|
||||
},
|
||||
|
||||
// TODO: Consider writing setup script
|
||||
"postCreateCommand": "bash -i -c \"npm -g install @fluencelabs/cli@latest\"",
|
||||
|
||||
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
||||
// "forwardPorts": [],
|
||||
|
||||
// Configure tool-specific properties.
|
||||
"customizations": {
|
||||
"codespaces": {
|
||||
"repositories": {
|
||||
"fluencelabs/docs": {
|
||||
"permissions": "write-all"
|
||||
},
|
||||
"fluencelabs/aqua-vscode": {
|
||||
"permissions": "write-all"
|
||||
},
|
||||
"fluencelabs/examples": {
|
||||
"permissions": "write-all"
|
||||
},
|
||||
"fluencelabs/aqua-playground": {
|
||||
"permissions": "write-all"
|
||||
}
|
||||
}
|
||||
},
|
||||
"vscode": {
|
||||
"extensions": [
|
||||
"FluenceLabs.aqua",
|
||||
"scala-lang.scala",
|
||||
"scalameta.metals",
|
||||
"yzhang.markdown-all-in-one"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
|
||||
// "remoteUser": "root"
|
||||
}
|
||||
"name": "Compiler Codespace",
|
||||
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
|
||||
"image": "mcr.microsoft.com/devcontainers/base:bullseye",
|
||||
// Features to add to the dev container. More info: https://containers.dev/features.
|
||||
"features": {
|
||||
"ghcr.io/devcontainers-contrib/features/sbt-sdkman:2": {},
|
||||
"ghcr.io/devcontainers-contrib/features/scala-sdkman:2": {},
|
||||
"ghcr.io/devcontainers/features/node:1": {
|
||||
"version": "16"
|
||||
}
|
||||
},
|
||||
// TODO: Consider writing setup script
|
||||
"postCreateCommand": "bash -i -c \"npm -g install @fluencelabs/cli@latest\"",
|
||||
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
||||
// "forwardPorts": [],
|
||||
// Configure tool-specific properties.
|
||||
"customizations": {
|
||||
"codespaces": {
|
||||
"repositories": {
|
||||
"fluencelabs/docs": {
|
||||
"permissions": "write-all"
|
||||
},
|
||||
"fluencelabs/aqua-vscode": {
|
||||
"permissions": "write-all"
|
||||
},
|
||||
"fluencelabs/examples": {
|
||||
"permissions": "write-all"
|
||||
},
|
||||
"fluencelabs/aqua-tests": {
|
||||
"permissions": "write-all"
|
||||
},
|
||||
"fluencelabs/js-client": {
|
||||
"permissions": "write-all"
|
||||
},
|
||||
"fluencelabs/js-client-examples": {
|
||||
"permissions": "write-all"
|
||||
}
|
||||
}
|
||||
},
|
||||
"vscode": {
|
||||
"extensions": [
|
||||
"FluenceLabs.aqua",
|
||||
"scala-lang.scala",
|
||||
"scalameta.metals",
|
||||
"yzhang.markdown-all-in-one"
|
||||
]
|
||||
}
|
||||
}
|
||||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
|
||||
// "remoteUser": "root"
|
||||
}
|
140
.github/e2e/docker-compose.yml
vendored
Normal file
140
.github/e2e/docker-compose.yml
vendored
Normal file
@ -0,0 +1,140 @@
|
||||
networks:
|
||||
nox:
|
||||
driver: bridge
|
||||
ipam:
|
||||
config:
|
||||
- subnet: 10.50.10.0/24
|
||||
|
||||
services:
|
||||
nox-1:
|
||||
image: ${NOX_IMAGE}
|
||||
ports:
|
||||
- 7771:7771
|
||||
- 9991:9991
|
||||
command:
|
||||
- --enable-system-services=none
|
||||
- --aqua-pool-size=2
|
||||
- -t=7771
|
||||
- -w=9991
|
||||
- -x=10.50.10.10
|
||||
- --external-maddrs
|
||||
- /dns4/nox-1/tcp/7771
|
||||
- /dns4/nox-1/tcp/9991/ws
|
||||
- --allow-private-ips
|
||||
- --local
|
||||
# - --bootstraps=/dns/nox-1/tcp/7771
|
||||
# 12D3KooWBM3SdXWqGaawQDGQ6JprtwswEg3FWGvGhmgmMez1vRbR
|
||||
- -k=hK62afickoeP2uZbmSkAYXxxqP8ozq16VRN7qfTP719EHC5V5tjrtW57BSjUr8GvsEXmJRbtejUWyPZ2rZMyQdq
|
||||
networks:
|
||||
nox:
|
||||
ipv4_address: 10.50.10.10
|
||||
|
||||
nox-2:
|
||||
image: ${NOX_IMAGE}
|
||||
ports:
|
||||
- 7772:7772
|
||||
- 9992:9992
|
||||
command:
|
||||
- --enable-system-services=none
|
||||
- --aqua-pool-size=2
|
||||
- -t=7772
|
||||
- -w=9992
|
||||
- -x=10.50.10.20
|
||||
- --external-maddrs
|
||||
- /dns4/nox-2/tcp/7772
|
||||
- /dns4/nox-2/tcp/9992/ws
|
||||
- --allow-private-ips
|
||||
- --bootstraps=/dns/nox-1/tcp/7771
|
||||
# 12D3KooWQdpukY3p2DhDfUfDgphAqsGu5ZUrmQ4mcHSGrRag6gQK
|
||||
- -k=2WijTVdhVRzyZamWjqPx4V4iNMrajegNMwNa2PmvPSZV6RRpo5M2fsPWdQr22HVRubuJhhSw8BrWiGt6FPhFAuXy
|
||||
networks:
|
||||
nox:
|
||||
ipv4_address: 10.50.10.20
|
||||
|
||||
nox-3:
|
||||
image: ${NOX_IMAGE}
|
||||
ports:
|
||||
- 7773:7773
|
||||
- 9993:9993
|
||||
command:
|
||||
- --enable-system-services=none
|
||||
- --aqua-pool-size=2
|
||||
- -t=7773
|
||||
- -w=9993
|
||||
- -x=10.50.10.30
|
||||
- --external-maddrs
|
||||
- /dns4/nox-3/tcp/7773
|
||||
- /dns4/nox-3/tcp/9993/ws
|
||||
- --allow-private-ips
|
||||
- --bootstraps=/dns/nox-1/tcp/7771
|
||||
# 12D3KooWRT8V5awYdEZm6aAV9HWweCEbhWd7df4wehqHZXAB7yMZ
|
||||
- -k=2n2wBVanBeu2GWtvKBdrYK9DJAocgG3PrTUXMharq6TTfxqTL4sLdXL9BF23n6rsnkAY5pR9vBtx2uWYDQAiZdrX
|
||||
networks:
|
||||
nox:
|
||||
ipv4_address: 10.50.10.30
|
||||
|
||||
nox-4:
|
||||
image: ${NOX_IMAGE}
|
||||
ports:
|
||||
- 7774:7774
|
||||
- 9994:9994
|
||||
command:
|
||||
- --enable-system-services=none
|
||||
- --aqua-pool-size=2
|
||||
- -t=7774
|
||||
- -w=9994
|
||||
- -x=10.50.10.40
|
||||
- --external-maddrs
|
||||
- /dns4/nox-4/tcp/7774
|
||||
- /dns4/nox-4/tcp/9994/ws
|
||||
- --allow-private-ips
|
||||
- --bootstraps=/dns/nox-1/tcp/7771
|
||||
# 12D3KooWBzLSu9RL7wLP6oUowzCbkCj2AGBSXkHSJKuq4wwTfwof
|
||||
- -k=4zp8ucAikkjB8CmkufYiFBW4QCDUCbQG7yMjviX7W8bMyN5rfChQ2Pi5QCWThrCTbAm9uq5nbFbxtFcNZq3De4dX
|
||||
networks:
|
||||
nox:
|
||||
ipv4_address: 10.50.10.40
|
||||
|
||||
nox-5:
|
||||
image: ${NOX_IMAGE}
|
||||
ports:
|
||||
- 7775:7775
|
||||
- 9995:9995
|
||||
command:
|
||||
- --enable-system-services=none
|
||||
- --aqua-pool-size=2
|
||||
- -t=7775
|
||||
- -w=9995
|
||||
- -x=10.50.10.50
|
||||
- --external-maddrs
|
||||
- /dns4/nox-5/tcp/7775
|
||||
- /dns4/nox-5/tcp/9995/ws
|
||||
- --allow-private-ips
|
||||
- --bootstraps=/dns/nox-1/tcp/7771
|
||||
# 12D3KooWBf6hFgrnXwHkBnwPGMysP3b1NJe5HGtAWPYfwmQ2MBiU
|
||||
- -k=3ry26rm5gkJXvdqRH4FoM3ezWq4xVVsBQF7wtKq4E4pbuaa6p1F84tNqifUS7DdfJL9hs2gcdW64Wc342vHZHMUp
|
||||
networks:
|
||||
nox:
|
||||
ipv4_address: 10.50.10.50
|
||||
|
||||
nox-6:
|
||||
image: ${NOX_IMAGE}
|
||||
ports:
|
||||
- 7776:7776
|
||||
- 9996:9996
|
||||
command:
|
||||
- --enable-system-services=none
|
||||
- --aqua-pool-size=2
|
||||
- -t=7776
|
||||
- -w=9996
|
||||
- --bootstraps=/dns/nox-1/tcp/7771
|
||||
- -x=10.50.10.60
|
||||
- --external-maddrs
|
||||
- /dns4/nox-6/tcp/7776
|
||||
- /dns4/nox-6/tcp/9996/ws
|
||||
- --allow-private-ips
|
||||
# 12D3KooWPisGn7JhooWhggndz25WM7vQ2JmA121EV8jUDQ5xMovJ
|
||||
- -k=5Qh8bB1sF28uLPwr3HTvEksCeC6mAWQvebCfcgv9y6j4qKwSzNKm2tzLUg4nACUEo2KZpBw11gNCnwaAdM7o1pEn
|
||||
networks:
|
||||
nox:
|
||||
ipv4_address: 10.50.10.60
|
21
.github/pull_request_template.md
vendored
Normal file
21
.github/pull_request_template.md
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
## Description
|
||||
[Provide a brief description of the changes introduced by this pull request and the motivation behind them.]
|
||||
|
||||
## Proposed Changes
|
||||
[List the specific changes and additions introduced by this pull request.]
|
||||
|
||||
## Implementation Details
|
||||
[Provide additional details about the implementation that may be helpful to reviewers.]
|
||||
|
||||
## Checklist
|
||||
- [ ] Corresponding issue has been created and linked in PR title.
|
||||
- [ ] Proposed changes are covered by tests.
|
||||
- [ ] Documentation has been updated to reflect the changes (if applicable).
|
||||
- [ ] I have self-reviewed my code and ensured its quality.
|
||||
- [ ] I have added/updated necessary comments to aid understanding.
|
||||
|
||||
## Reviewer Checklist
|
||||
- [ ] Tests have been reviewed and are sufficient to validate the changes.
|
||||
- [ ] Documentation has been reviewed and is up to date.
|
||||
- [ ] Any questions or concerns have been addressed.
|
||||
|
2
.github/release-please/manifest.json
vendored
2
.github/release-please/manifest.json
vendored
@ -1,3 +1,3 @@
|
||||
{
|
||||
".": "0.11.1"
|
||||
".": "0.14.11"
|
||||
}
|
||||
|
36
.github/renovate.json
vendored
36
.github/renovate.json
vendored
@ -1,36 +1,8 @@
|
||||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": [
|
||||
"config:base",
|
||||
":semanticCommitTypeAll(chore)"
|
||||
"github>fluencelabs/renovate",
|
||||
"github>fluencelabs/renovate:npm"
|
||||
],
|
||||
"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
|
||||
}
|
||||
]
|
||||
"ignorePaths": ["api/aqua-api-example/**"],
|
||||
"enabledManagers": ["npm"]
|
||||
}
|
||||
|
65
.github/workflows/binary.yml
vendored
65
.github/workflows/binary.yml
vendored
@ -1,65 +0,0 @@
|
||||
name: "Publish binary aqua"
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
runs-on:
|
||||
type: string
|
||||
required: true
|
||||
arch:
|
||||
type: string
|
||||
required: true
|
||||
os:
|
||||
type: string
|
||||
required: true
|
||||
static:
|
||||
type: boolean
|
||||
required: true
|
||||
workflow_call:
|
||||
inputs:
|
||||
runs-on:
|
||||
type: string
|
||||
required: true
|
||||
arch:
|
||||
type: string
|
||||
required: true
|
||||
os:
|
||||
type: string
|
||||
required: true
|
||||
static:
|
||||
type: boolean
|
||||
required: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: "Publish aqua-native"
|
||||
runs-on: ${{ inputs.runs-on }}
|
||||
timeout-minutes: 10
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- uses: graalvm/setup-graalvm@v1
|
||||
with:
|
||||
version: '22.3.1'
|
||||
java-version: '17'
|
||||
set-java-home: true
|
||||
components: 'native-image'
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- uses: coursier/cache-action@v6
|
||||
|
||||
- uses: coursier/setup-action@v1
|
||||
with:
|
||||
apps: sbt
|
||||
|
||||
- name: build
|
||||
run: sbt "cli/GraalVMNativeImage/packageBin"
|
||||
env:
|
||||
COMPILE_STATIC: ${{ inputs.static }}
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: aqua-${{ inputs.os }}-${{ inputs.arch }}
|
||||
path: cli/cli/.jvm/target/graalvm-native-image/cli
|
41
.github/workflows/e2e.yml
vendored
41
.github/workflows/e2e.yml
vendored
@ -27,6 +27,7 @@ concurrency:
|
||||
|
||||
jobs:
|
||||
aqua:
|
||||
name: "aqua"
|
||||
if: >
|
||||
github.event_name == 'push' ||
|
||||
contains(github.event.pull_request.labels.*.name, 'e2e')
|
||||
@ -34,38 +35,20 @@ jobs:
|
||||
with:
|
||||
ref: ${{ github.ref }}
|
||||
|
||||
aqua-playground:
|
||||
fcli-snapshot:
|
||||
name: "fcli"
|
||||
needs: aqua
|
||||
uses: fluencelabs/aqua-playground/.github/workflows/tests.yml@master
|
||||
uses: fluencelabs/cli/.github/workflows/snapshot.yml@main
|
||||
with:
|
||||
aqua-version: "${{ needs.aqua.outputs.aqua-version }}"
|
||||
aqua-snapshots: "${{ needs.aqua.outputs.aqua-snapshots }}"
|
||||
|
||||
registry:
|
||||
fcli:
|
||||
needs: aqua
|
||||
uses: fluencelabs/registry/.github/workflows/tests.yml@main
|
||||
uses: fluencelabs/cli/.github/workflows/tests.yml@main
|
||||
with:
|
||||
aqua-version: "${{ needs.aqua.outputs.aqua-version }}"
|
||||
aqua-snapshots: "${{ needs.aqua.outputs.aqua-snapshots }}"
|
||||
|
||||
fluence-cli:
|
||||
needs: aqua
|
||||
uses: fluencelabs/fluence-cli/.github/workflows/tests.yml@main
|
||||
with:
|
||||
aqua-version: "${{ needs.aqua.outputs.aqua-version }}"
|
||||
|
||||
aqua-native:
|
||||
name: "aqua"
|
||||
strategy:
|
||||
matrix:
|
||||
runner:
|
||||
- runs-on: ubuntu-latest
|
||||
arch: amd64
|
||||
os: linux
|
||||
static: true
|
||||
needs:
|
||||
- aqua
|
||||
uses: ./.github/workflows/binary.yml
|
||||
with:
|
||||
runs-on: ${{ matrix.runner.runs-on }}
|
||||
arch: ${{ matrix.runner.arch }}
|
||||
os: ${{ matrix.runner.os }}
|
||||
static: ${{ matrix.runner.static }}
|
||||
# registry:
|
||||
# needs:
|
||||
# - fcli-snapshot
|
||||
# uses: fluencelabs/registry/.github/workflows/tests.yml@main
|
||||
|
2
.github/workflows/lint.yml
vendored
2
.github/workflows/lint.yml
vendored
@ -24,7 +24,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Lint actions
|
||||
uses: reviewdog/action-actionlint@v1
|
||||
|
215
.github/workflows/publish.yml
vendored
215
.github/workflows/publish.yml
vendored
@ -18,13 +18,17 @@ env:
|
||||
FORCE_COLOR: true
|
||||
|
||||
jobs:
|
||||
compile:
|
||||
publish:
|
||||
runs-on: builder
|
||||
timeout-minutes: 60
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ inputs.tag }}
|
||||
|
||||
@ -36,60 +40,11 @@ jobs:
|
||||
with:
|
||||
apps: sbt
|
||||
|
||||
- name: JS CLI build
|
||||
run: sbt cliJS/fullLinkJS
|
||||
|
||||
- name: JS API build
|
||||
run: sbt aqua-api/fullLinkJS
|
||||
|
||||
- name: JS LSP build
|
||||
run: sbt language-server-apiJS/fullLinkJS
|
||||
|
||||
- name: Upload aqua-cli artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: aqua-cli
|
||||
path: cli/cli/.js/target/scala-*/cli-opt/main.js
|
||||
|
||||
- name: Upload aqua-api artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: aqua-api
|
||||
path: api/aqua-api/target/scala-*/aqua-api-opt/main.js
|
||||
|
||||
- name: Upload aqua-lsp artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: aqua-lsp
|
||||
path: language-server/language-server-api/.js/target/scala-*/language-server-api-opt/main.js
|
||||
|
||||
aqua-cli:
|
||||
name: "Publish aqua-cli"
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 60
|
||||
|
||||
needs:
|
||||
- compile
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
ref: ${{ inputs.tag }}
|
||||
|
||||
- name: Download aqua-cli artifact
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: aqua-cli
|
||||
|
||||
- run: mv scala-*/*/main.js cli/cli-npm/aqua.js
|
||||
- name: scala-js build
|
||||
run: sbt ";language-server-apiJS/fullBundleJS;aqua-apiJS/fullBundleJS"
|
||||
|
||||
- name: Import secrets
|
||||
uses: hashicorp/vault-action@v2.5.0
|
||||
uses: hashicorp/vault-action@v3.0.0
|
||||
with:
|
||||
url: https://vault.fluence.dev
|
||||
path: jwt/github
|
||||
@ -101,148 +56,20 @@ jobs:
|
||||
secrets: |
|
||||
kv/npmjs/fluencebot token | NODE_AUTH_TOKEN
|
||||
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v3
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v4.0.0
|
||||
with:
|
||||
node-version: "16"
|
||||
version: 8
|
||||
|
||||
- name: Setup node with self-hosted npm registry
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "18"
|
||||
registry-url: "https://registry.npmjs.org"
|
||||
cache-dependency-path: "cli/cli-npm/package-lock.json"
|
||||
cache: "npm"
|
||||
cache: "pnpm"
|
||||
|
||||
- run: npm i
|
||||
working-directory: cli/cli-npm
|
||||
|
||||
- run: npm run build
|
||||
working-directory: cli/cli-npm
|
||||
- run: pnpm --filter='!integration-tests' -r i
|
||||
- run: pnpm --filter='!integration-tests' -r build
|
||||
|
||||
- name: Publish to NPM registry
|
||||
run: npm publish --access public --tag unstable
|
||||
working-directory: cli/cli-npm
|
||||
|
||||
aqua-api:
|
||||
name: "Publish aqua-api"
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 60
|
||||
|
||||
needs:
|
||||
- compile
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
ref: ${{ inputs.tag }}
|
||||
|
||||
- name: Download aqua-api artifact
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: aqua-api
|
||||
|
||||
- run: mv scala-*/*/main.js api/aqua-api-npm/aqua-api.js
|
||||
|
||||
- name: Import secrets
|
||||
uses: hashicorp/vault-action@v2.5.0
|
||||
with:
|
||||
url: https://vault.fluence.dev
|
||||
path: jwt/github
|
||||
role: ci
|
||||
method: jwt
|
||||
jwtGithubAudience: "https://github.com/fluencelabs"
|
||||
jwtTtl: 300
|
||||
exportToken: false
|
||||
secrets: |
|
||||
kv/npmjs/fluencebot token | NODE_AUTH_TOKEN
|
||||
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: "16"
|
||||
registry-url: "https://registry.npmjs.org"
|
||||
cache-dependency-path: "api/aqua-api-npm/package-lock.json"
|
||||
cache: "npm"
|
||||
|
||||
- run: npm i
|
||||
working-directory: api/aqua-api-npm
|
||||
|
||||
- name: Publish to NPM registry
|
||||
run: npm publish --access public --tag unstable
|
||||
working-directory: api/aqua-api-npm
|
||||
|
||||
aqua-lsp:
|
||||
name: "Publish aqua-lsp"
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 60
|
||||
|
||||
needs:
|
||||
- compile
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
ref: ${{ inputs.tag }}
|
||||
|
||||
- name: Download aqua-lsp artifact
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: aqua-lsp
|
||||
|
||||
- run: mv scala-*/*/main.js language-server/language-server-npm/aqua-lsp-api.js
|
||||
|
||||
- name: Import secrets
|
||||
uses: hashicorp/vault-action@v2.5.0
|
||||
with:
|
||||
url: https://vault.fluence.dev
|
||||
path: jwt/github
|
||||
role: ci
|
||||
method: jwt
|
||||
jwtGithubAudience: "https://github.com/fluencelabs"
|
||||
jwtTtl: 300
|
||||
exportToken: false
|
||||
secrets: |
|
||||
kv/npmjs/fluencebot token | NODE_AUTH_TOKEN
|
||||
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: "16"
|
||||
registry-url: "https://registry.npmjs.org"
|
||||
cache-dependency-path: "language-server/language-server-npm/package-lock.json"
|
||||
cache: "npm"
|
||||
|
||||
- run: npm i
|
||||
working-directory: language-server/language-server-npm
|
||||
|
||||
- name: Publish to NPM registry
|
||||
run: npm publish --access public --tag unstable
|
||||
working-directory: language-server/language-server-npm
|
||||
|
||||
aqua-native:
|
||||
name: "Publish aqua-native"
|
||||
strategy:
|
||||
matrix:
|
||||
runner:
|
||||
- runs-on: ubuntu-latest
|
||||
arch: amd64
|
||||
os: linux
|
||||
static: true
|
||||
- runs-on: macos-latest
|
||||
arch: amd64
|
||||
os: macos
|
||||
static: false
|
||||
needs:
|
||||
- compile
|
||||
uses: ./.github/workflows/binary.yml
|
||||
with:
|
||||
runs-on: ${{ matrix.runner.runs-on }}
|
||||
arch: ${{ matrix.runner.arch }}
|
||||
os: ${{ matrix.runner.os }}
|
||||
static: ${{ matrix.runner.static }}
|
||||
run: pnpm --filter='!integration-tests' publish --access public --tag unstable
|
||||
|
37
.github/workflows/release.yml
vendored
37
.github/workflows/release.yml
vendored
@ -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
|
||||
@ -47,9 +47,10 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ fromJson(needs.release-please.outputs.pr).headBranchName }}
|
||||
token: ${{ secrets.FLUENCEBOT_RELEASE_PLEASE_PAT }}
|
||||
|
||||
- name: Get aqua version
|
||||
id: version
|
||||
@ -61,20 +62,36 @@ jobs:
|
||||
run: |
|
||||
sed -i 's/aquaVersion =.*/aquaVersion = "${{ steps.version.outputs.version }}"/g' build.sbt
|
||||
|
||||
- name: Set cli version
|
||||
run: npm version ${{ steps.version.outputs.version }}
|
||||
working-directory: cli/cli-npm
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v4.0.0
|
||||
with:
|
||||
version: 8
|
||||
|
||||
- name: Setup node with self-hosted npm registry
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "18"
|
||||
registry-url: "https://registry.npmjs.org"
|
||||
cache: "pnpm"
|
||||
|
||||
- name: Set api version
|
||||
run: npm version ${{ steps.version.outputs.version }}
|
||||
working-directory: api/aqua-api-npm
|
||||
run: pnpm version ${{ steps.version.outputs.version }}
|
||||
working-directory: api/api-npm
|
||||
|
||||
- name: Set lsp version
|
||||
run: npm version ${{ steps.version.outputs.version }}
|
||||
run: pnpm version ${{ steps.version.outputs.version }}
|
||||
working-directory: language-server/language-server-npm
|
||||
|
||||
- name: Set aqua version in tests
|
||||
run: |
|
||||
pnpm add @fluencelabs/aqua-api@${{ steps.version.outputs.version }} --save-workspace-protocol=false
|
||||
working-directory: integration-tests
|
||||
|
||||
- name: Regenerate lock
|
||||
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 }}
|
||||
@ -116,7 +133,7 @@ jobs:
|
||||
echo "found any?:" "${{ steps.status.outputs.found }}"
|
||||
|
||||
- name: Import secrets
|
||||
uses: hashicorp/vault-action@v2.5.0
|
||||
uses: hashicorp/vault-action@v3.0.0
|
||||
with:
|
||||
url: https://vault.fluence.dev
|
||||
path: jwt/github
|
||||
|
6
.github/workflows/run-tests.yml
vendored
6
.github/workflows/run-tests.yml
vendored
@ -21,6 +21,12 @@ concurrency:
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
sbt-tests:
|
||||
name: "aqua"
|
||||
uses: ./.github/workflows/sbt-tests.yml
|
||||
with:
|
||||
ref: ${{ github.ref }}
|
||||
|
||||
tests:
|
||||
name: "aqua"
|
||||
uses: ./.github/workflows/tests.yml
|
||||
|
32
.github/workflows/sbt-tests.yml
vendored
Normal file
32
.github/workflows/sbt-tests.yml
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
name: Run sbt tests with workflow_call
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
ref:
|
||||
description: "git ref to checkout to"
|
||||
type: string
|
||||
default: "main"
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
name: "Run sbt tests"
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: fluencelabs/aqua
|
||||
ref: ${{ inputs.ref }}
|
||||
|
||||
- name: Cache Scala
|
||||
uses: coursier/cache-action@v6
|
||||
|
||||
- name: Setup Scala
|
||||
uses: coursier/setup-action@v1
|
||||
with:
|
||||
apps: sbt
|
||||
|
||||
- name: Run tests
|
||||
run: env JAVA_OPTS="-Xmx4G" sbt "headerCheckAll; test"
|
257
.github/workflows/snapshot.yml
vendored
257
.github/workflows/snapshot.yml
vendored
@ -3,37 +3,35 @@ name: Publish snapshots
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
fluence-js-version:
|
||||
description: "@fluencejs/fluence version"
|
||||
type: string
|
||||
default: "null"
|
||||
ref:
|
||||
description: "git ref to checkout to"
|
||||
type: string
|
||||
default: "main"
|
||||
outputs:
|
||||
aqua-version:
|
||||
description: "@fluencelabs/aqua version"
|
||||
value: ${{ jobs.aqua-cli.outputs.version }}
|
||||
aqua-lsp-version:
|
||||
description: "@fluencelabs/aqua-language-server-api version"
|
||||
value: ${{ jobs.aqua-lsp.outputs.version }}
|
||||
aqua-api-version:
|
||||
description: "@fluencelabs/aqua-api version"
|
||||
value: ${{ jobs.aqua-api.outputs.version }}
|
||||
aqua-snapshots:
|
||||
description: "aqua snapshots"
|
||||
value: ${{ jobs.publish.outputs.snapshots }}
|
||||
|
||||
env:
|
||||
FORCE_COLOR: true
|
||||
CI: true
|
||||
|
||||
jobs:
|
||||
compile:
|
||||
name: "Compile"
|
||||
publish:
|
||||
name: "Publish snapshots"
|
||||
runs-on: builder
|
||||
timeout-minutes: 60
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
|
||||
outputs:
|
||||
snapshots: "${{ steps.snapshot.outputs.snapshots }}"
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: fluencelabs/aqua
|
||||
ref: ${{ inputs.ref }}
|
||||
@ -50,69 +48,13 @@ jobs:
|
||||
with:
|
||||
apps: sbt
|
||||
|
||||
- name: JS CLI build
|
||||
- name: scala-js build
|
||||
env:
|
||||
SNAPSHOT: ${{ steps.version.outputs.id }}
|
||||
run: sbt cliJS/fastOptJS
|
||||
|
||||
- name: JS LSP build
|
||||
env:
|
||||
SNAPSHOT: ${{ steps.version.outputs.id }}
|
||||
run: sbt language-server-apiJS/fastOptJS
|
||||
|
||||
- name: JS API build
|
||||
env:
|
||||
SNAPSHOT: ${{ steps.version.outputs.id }}
|
||||
run: sbt aqua-api/fastOptJS
|
||||
|
||||
- name: Upload aqua-cli artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: aqua-cli
|
||||
path: cli/cli/.js/target/scala-*/cli-fastopt.js
|
||||
|
||||
- name: Upload aqua-api artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: aqua-api
|
||||
path: api/aqua-api/target/scala-*/aqua-api-fastopt.js
|
||||
|
||||
- name: Upload aqua-lsp artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: aqua-lsp
|
||||
path: language-server/language-server-api/.js/target/scala-*/language-server-api-fastopt.js
|
||||
|
||||
aqua-cli:
|
||||
name: "Publish aqua-cli"
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 60
|
||||
|
||||
needs: compile
|
||||
|
||||
outputs:
|
||||
version: "${{ steps.snapshot.outputs.version }}"
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
repository: fluencelabs/aqua
|
||||
ref: ${{ inputs.ref }}
|
||||
|
||||
- name: Download aqua-cli artifact
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: aqua-cli
|
||||
|
||||
- run: mv scala-*/cli-fastopt.js cli/cli-npm/aqua.js
|
||||
run: sbt ";language-server-apiJS/fastBundleJS;aqua-apiJS/fastBundleJS"
|
||||
|
||||
- name: Import secrets
|
||||
uses: hashicorp/vault-action@v2.5.0
|
||||
uses: hashicorp/vault-action@v3.0.0
|
||||
with:
|
||||
url: https://vault.fluence.dev
|
||||
path: jwt/github
|
||||
@ -124,163 +66,28 @@ jobs:
|
||||
secrets: |
|
||||
kv/npm-registry/basicauth/ci token | NODE_AUTH_TOKEN
|
||||
|
||||
- name: Setup node with self-hosted npm registry
|
||||
uses: actions/setup-node@v3
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v4.0.0
|
||||
with:
|
||||
node-version: "16"
|
||||
version: 8
|
||||
|
||||
- name: Setup node with self-hosted npm registry
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "18"
|
||||
registry-url: "https://npm.fluence.dev"
|
||||
cache-dependency-path: "cli/cli-npm/package-lock.json"
|
||||
cache: "npm"
|
||||
cache: "pnpm"
|
||||
|
||||
- run: npm i
|
||||
working-directory: cli/cli-npm
|
||||
- run: pnpm --filter='!integration-tests' -r i
|
||||
|
||||
- name: Set fluence-js version from branch
|
||||
if: inputs.fluence-js-version != 'null'
|
||||
working-directory: cli/cli-npm
|
||||
run: npm i --save -E @fluencelabs/fluence@${{ inputs.fluence-js-version }}
|
||||
- name: Set package version
|
||||
run: node ci.cjs bump-version ${{ steps.version.outputs.id }}
|
||||
|
||||
- run: npm run build
|
||||
working-directory: cli/cli-npm
|
||||
|
||||
- name: Generate snapshot version
|
||||
id: version
|
||||
uses: fluencelabs/github-actions/generate-snapshot-id@main
|
||||
- run: pnpm --filter='!integration-tests' -r build
|
||||
|
||||
- name: Publish snapshot
|
||||
id: snapshot
|
||||
uses: fluencelabs/github-actions/npm-publish-snapshot@main
|
||||
uses: fluencelabs/github-actions/pnpm-publish-snapshot@main
|
||||
with:
|
||||
working-directory: cli/cli-npm
|
||||
id: ${{ steps.version.outputs.id }}
|
||||
|
||||
aqua-api:
|
||||
name: "Publish aqua-api"
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 60
|
||||
|
||||
needs: compile
|
||||
|
||||
outputs:
|
||||
version: "${{ steps.snapshot.outputs.version }}"
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
repository: fluencelabs/aqua
|
||||
ref: ${{ inputs.ref }}
|
||||
|
||||
- name: Download aqua-api artifact
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: aqua-api
|
||||
|
||||
- run: mv scala-*/aqua-api-fastopt.js api/aqua-api-npm/aqua-api.js
|
||||
|
||||
- name: Import secrets
|
||||
uses: hashicorp/vault-action@v2.5.0
|
||||
with:
|
||||
url: https://vault.fluence.dev
|
||||
path: jwt/github
|
||||
role: ci
|
||||
method: jwt
|
||||
jwtGithubAudience: "https://github.com/fluencelabs"
|
||||
jwtTtl: 300
|
||||
exportToken: false
|
||||
secrets: |
|
||||
kv/npm-registry/basicauth/ci token | NODE_AUTH_TOKEN
|
||||
|
||||
- name: Setup node with self-hosted npm registry
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: "16"
|
||||
registry-url: "https://npm.fluence.dev"
|
||||
cache-dependency-path: "api/aqua-api-npm/package-lock.json"
|
||||
cache: "npm"
|
||||
|
||||
- run: npm i
|
||||
working-directory: api/aqua-api-npm
|
||||
|
||||
- name: Set fluence-js version from branch
|
||||
if: inputs.fluence-js-version != 'null'
|
||||
working-directory: cli/cli-npm
|
||||
run: npm i --save-dev -E @fluencelabs/fluence@${{ inputs.fluence-js-version }}
|
||||
|
||||
- name: Generate snapshot version
|
||||
id: version
|
||||
uses: fluencelabs/github-actions/generate-snapshot-id@main
|
||||
|
||||
- name: Publish snapshot
|
||||
id: snapshot
|
||||
uses: fluencelabs/github-actions/npm-publish-snapshot@main
|
||||
with:
|
||||
working-directory: api/aqua-api-npm
|
||||
id: ${{ steps.version.outputs.id }}
|
||||
|
||||
aqua-lsp:
|
||||
name: "Publish aqua-lsp"
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 60
|
||||
|
||||
needs: compile
|
||||
|
||||
outputs:
|
||||
version: "${{ steps.snapshot.outputs.version }}"
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
repository: fluencelabs/aqua
|
||||
ref: ${{ inputs.ref }}
|
||||
|
||||
- name: Download aqua-lsp artifact
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: aqua-lsp
|
||||
|
||||
- run: mv scala-*/language-server-api-fastopt.js language-server/language-server-npm/aqua-lsp-api.js
|
||||
|
||||
- name: Import secrets
|
||||
uses: hashicorp/vault-action@v2.5.0
|
||||
with:
|
||||
url: https://vault.fluence.dev
|
||||
path: jwt/github
|
||||
role: ci
|
||||
method: jwt
|
||||
jwtGithubAudience: "https://github.com/fluencelabs"
|
||||
jwtTtl: 300
|
||||
exportToken: false
|
||||
secrets: |
|
||||
kv/npm-registry/basicauth/ci token | NODE_AUTH_TOKEN
|
||||
|
||||
- name: Setup node with self-hosted npm registry
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: "16"
|
||||
registry-url: "https://npm.fluence.dev"
|
||||
cache-dependency-path: "language-server/language-server-npm/package-lock.json"
|
||||
cache: "npm"
|
||||
|
||||
- run: npm i
|
||||
working-directory: language-server/language-server-npm
|
||||
|
||||
- name: Generate snapshot version
|
||||
id: version
|
||||
uses: fluencelabs/github-actions/generate-snapshot-id@main
|
||||
|
||||
- name: Publish snapshot
|
||||
id: snapshot
|
||||
uses: fluencelabs/github-actions/npm-publish-snapshot@main
|
||||
with:
|
||||
working-directory: language-server/language-server-npm
|
||||
id: ${{ steps.version.outputs.id }}
|
||||
set-version: false
|
||||
|
100
.github/workflows/tests.yml
vendored
100
.github/workflows/tests.yml
vendored
@ -7,19 +7,72 @@ on:
|
||||
description: "git ref to checkout to"
|
||||
type: string
|
||||
default: "main"
|
||||
fluence-env:
|
||||
description: "Fluence enviroment to run tests agains"
|
||||
type: string
|
||||
default: "local"
|
||||
nox-image:
|
||||
description: "nox image tag"
|
||||
type: string
|
||||
default: "fluencelabs/nox:unstable"
|
||||
js-client-snapshots:
|
||||
description: "js-client snapshots"
|
||||
type: string
|
||||
default: "null"
|
||||
|
||||
env:
|
||||
FORCE_COLOR: true
|
||||
NOX_IMAGE: "${{ inputs.nox-image }}"
|
||||
FLUENCE_ENV: "${{ inputs.fluence-env }}"
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
name: "Run sbt tests"
|
||||
aqua:
|
||||
name: "Run tests"
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 60
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Import secrets
|
||||
uses: hashicorp/vault-action@v3.0.0
|
||||
with:
|
||||
url: https://vault.fluence.dev
|
||||
path: jwt/github
|
||||
role: ci
|
||||
method: jwt
|
||||
jwtGithubAudience: "https://github.com/fluencelabs"
|
||||
jwtTtl: 300
|
||||
secrets: |
|
||||
kv/docker-registry/basicauth/ci username | DOCKER_USERNAME ;
|
||||
kv/docker-registry/basicauth/ci password | DOCKER_PASSWORD ;
|
||||
kv/npm-registry/basicauth/ci token | NODE_AUTH_TOKEN;
|
||||
kv/slack/node-alerts webhook | INCOMING_WEBHOOK_URL
|
||||
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: docker.fluence.dev
|
||||
username: ${{ env.DOCKER_USERNAME }}
|
||||
password: ${{ env.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: fluencelabs/aqua
|
||||
ref: ${{ inputs.ref }}
|
||||
|
||||
- name: Pull nox image
|
||||
run: docker pull $NOX_IMAGE
|
||||
|
||||
- name: Run nox
|
||||
uses: isbang/compose-action@v2.0.0
|
||||
with:
|
||||
compose-file: ".github/e2e/docker-compose.yml"
|
||||
down-flags: "--volumes"
|
||||
|
||||
- name: Cache Scala
|
||||
uses: coursier/cache-action@v6
|
||||
|
||||
@ -28,5 +81,40 @@ jobs:
|
||||
with:
|
||||
apps: sbt
|
||||
|
||||
- name: Run tests
|
||||
run: sbt test
|
||||
- name: aqua-api build
|
||||
run: sbt "aqua-apiJS/fastBundleJS"
|
||||
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v4.0.0
|
||||
with:
|
||||
version: 8
|
||||
|
||||
- name: Setup node with self-hosted registry
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "18"
|
||||
registry-url: "https://npm.fluence.dev"
|
||||
cache: "pnpm"
|
||||
|
||||
- name: Override dependencies
|
||||
if: inputs.js-client-snapshots != 'null'
|
||||
uses: fluencelabs/github-actions/pnpm-set-dependency@main
|
||||
with:
|
||||
dependencies: |
|
||||
{
|
||||
"@fluencelabs/js-client": "${{ fromJson(inputs.js-client-snapshots)['js-client'] }}"
|
||||
}
|
||||
|
||||
- run: pnpm install --no-frozen-lockfile
|
||||
working-directory: integration-tests
|
||||
|
||||
- name: Compile aqua
|
||||
run: pnpm run compile-aqua
|
||||
working-directory: integration-tests
|
||||
|
||||
- run: pnpm run test
|
||||
working-directory: integration-tests
|
||||
|
||||
- name: Dump nox logs
|
||||
if: always()
|
||||
uses: jwalton/gh-docker-logs@v2
|
||||
|
7
.gitignore
vendored
7
.gitignore
vendored
@ -9,5 +9,10 @@ project/target
|
||||
|
||||
.DS_Store
|
||||
|
||||
npm/aqua.js
|
||||
language-server/language-server-npm/aqua-lsp-api.js
|
||||
api/api-npm/aqua-api.js
|
||||
|
||||
integration-tests/src/compiled/*
|
||||
|
||||
**/dist
|
||||
**/node_modules
|
||||
|
@ -62,9 +62,9 @@ runner {
|
||||
}
|
||||
}
|
||||
|
||||
rewrite {
|
||||
rules = [
|
||||
SortImports
|
||||
]
|
||||
}
|
||||
rewrite.rules = [Imports]
|
||||
rewrite.imports.sort = ascii
|
||||
rewrite.imports.groups = [
|
||||
["aqua\\..*"]
|
||||
]
|
||||
#runner.dialect = scala3
|
||||
|
423
CHANGELOG.md
423
CHANGELOG.md
@ -1,5 +1,428 @@
|
||||
# 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)
|
||||
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* **compiler:** Make `nil` option bottom [LNG-279] ([#968](https://github.com/fluencelabs/aqua/issues/968))
|
||||
* **compiler:** Prohibit mutating options [LNG-277] ([#960](https://github.com/fluencelabs/aqua/issues/960))
|
||||
|
||||
### Features
|
||||
|
||||
* **api:** Use `js.UndefOr` for `defaultServiceId` ([#980](https://github.com/fluencelabs/aqua/issues/980)) ([1e525fa](https://github.com/fluencelabs/aqua/commit/1e525fad35585c5401914200e8e15c50304d8688))
|
||||
* **compiler:** Allow omitting field name in struct creation [LNG-261] ([#943](https://github.com/fluencelabs/aqua/issues/943)) ([fcdb5b0](https://github.com/fluencelabs/aqua/commit/fcdb5b0fefeffc004a50bd66a6a768b36ed9d71d))
|
||||
* **compiler:** Always generate `last` argument of `fold` [LNG-265] ([#947](https://github.com/fluencelabs/aqua/issues/947)) ([78ee753](https://github.com/fluencelabs/aqua/commit/78ee753c7b3e956faf5c92f4992e51c1af4ac76a))
|
||||
* **compiler:** Generate empty calls to `responseHandlerSrv` [LNG-286] ([#979](https://github.com/fluencelabs/aqua/issues/979)) ([cee4448](https://github.com/fluencelabs/aqua/commit/cee444862a7cf2bea3f84e921b03328fd83fa108))
|
||||
* **compiler:** Make `nil` option bottom [LNG-279] ([#968](https://github.com/fluencelabs/aqua/issues/968)) ([11c8970](https://github.com/fluencelabs/aqua/commit/11c8970fd889a3acb07c0c65013d153194106e62))
|
||||
* **compiler:** Prohibit mutating options [LNG-277] ([#960](https://github.com/fluencelabs/aqua/issues/960)) ([68425ed](https://github.com/fluencelabs/aqua/commit/68425ed42a7440aefac82011bbac418ef13bd636))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **compiler:** Code generate wrong stream name in AIR [LNG-276] ([#958](https://github.com/fluencelabs/aqua/issues/958)) ([a1576ef](https://github.com/fluencelabs/aqua/commit/a1576efad9d6a3d5fb20c01182b0d0a948c50ec4))
|
||||
* **compiler:** Incorrect focus on error [LNG-274] ([#959](https://github.com/fluencelabs/aqua/issues/959)) ([6e6b567](https://github.com/fluencelabs/aqua/commit/6e6b567f8eac007b0e50fc6e2eb4e4918663016e))
|
||||
* **compiler:** Multiple closures in one function [LNG-262] ([#941](https://github.com/fluencelabs/aqua/issues/941)) ([45ca7bb](https://github.com/fluencelabs/aqua/commit/45ca7bbf3ed234b25d0f010c2bd5878f9bce9155))
|
||||
* **compiler:** Throw an error when comparing an alias and a named type with the same name [LNG-231] ([#946](https://github.com/fluencelabs/aqua/issues/946)) ([38f7728](https://github.com/fluencelabs/aqua/commit/38f77285f57410848a5f6f3333ca6a99fb5017f5))
|
||||
* **compiler:** Unknown service method call is ignored [LNG-273] ([#957](https://github.com/fluencelabs/aqua/issues/957)) ([5a3c5e6](https://github.com/fluencelabs/aqua/commit/5a3c5e6666f53ac222e297e69971e3d84499759f))
|
||||
* **deps:** update dependency @fluencelabs/js-client to v0.4.1 ([#945](https://github.com/fluencelabs/aqua/issues/945)) ([634b1c1](https://github.com/fluencelabs/aqua/commit/634b1c17b629b6f899bfe5ff17a9bdc81673acba))
|
||||
* **deps:** update dependency @fluencelabs/js-client to v0.4.2 ([#956](https://github.com/fluencelabs/aqua/issues/956)) ([077dc8f](https://github.com/fluencelabs/aqua/commit/077dc8ff131cb1c4cc6300b078232c1be93c39cd))
|
||||
* **deps:** update dependency @fluencelabs/js-client to v0.4.3 ([#966](https://github.com/fluencelabs/aqua/issues/966)) ([313502e](https://github.com/fluencelabs/aqua/commit/313502ecae4f0568af63158e6f518bc8e398953d))
|
||||
|
||||
## [0.12.4](https://github.com/fluencelabs/aqua/compare/aqua-v0.12.3...aqua-v0.12.4) (2023-10-23)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **compiler:** Handle error function exit in tracing mode [LNG-250] ([#921](https://github.com/fluencelabs/aqua/issues/921)) ([03d23eb](https://github.com/fluencelabs/aqua/commit/03d23eb577d72a3cf592254259aeb9b52b33b616))
|
||||
* **compiler:** Optimize math in compile time [LNG-245] ([#922](https://github.com/fluencelabs/aqua/issues/922)) ([5f6c47f](https://github.com/fluencelabs/aqua/commit/5f6c47ffea5ab6e32df918a33414482129b00fd7))
|
||||
* **dev:** Add PR template ([#934](https://github.com/fluencelabs/aqua/issues/934)) ([679d43f](https://github.com/fluencelabs/aqua/commit/679d43f7eb079071ca2a4174f3b8cf5e83d4e16d))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **compiler:** Fix gate inlining [LNG-253] ([#924](https://github.com/fluencelabs/aqua/issues/924)) ([b298eeb](https://github.com/fluencelabs/aqua/commit/b298eebf5ea1b4c091603ebf0cacde0957191632))
|
||||
* **compiler:** Fix topology for adjacent `on`s [LNG-257] ([#929](https://github.com/fluencelabs/aqua/issues/929)) ([ba15d9e](https://github.com/fluencelabs/aqua/commit/ba15d9e06afc38f79c95e00d48efbf8937cd251d))
|
||||
* **compiler:** fix typo ([#916](https://github.com/fluencelabs/aqua/issues/916)) ([feb7a16](https://github.com/fluencelabs/aqua/commit/feb7a167a2007d2c1d75dac6554f36d2cf5f86a5))
|
||||
* **compiler:** Passed function is not handled correctly [LNG-260] ([#940](https://github.com/fluencelabs/aqua/issues/940)) ([c83d69e](https://github.com/fluencelabs/aqua/commit/c83d69e6895d3784f02c743b89f65606c6302f4b))
|
||||
* **compiler:** Return ability arrow [LNG-258] ([#935](https://github.com/fluencelabs/aqua/issues/935)) ([fab46ee](https://github.com/fluencelabs/aqua/commit/fab46ee130d4e6b3edd33d0fab4c0f2d27ce5ad0))
|
||||
* **deps:** update dependency @fluencelabs/js-client to v0.2.1 ([#930](https://github.com/fluencelabs/aqua/issues/930)) ([14f3d92](https://github.com/fluencelabs/aqua/commit/14f3d92ef4cd3fed12cbff0164706b2cbbfdcccd))
|
||||
* **deps:** update dependency @fluencelabs/js-client to v0.3.0 ([#936](https://github.com/fluencelabs/aqua/issues/936)) ([441c012](https://github.com/fluencelabs/aqua/commit/441c012e01e6e0eff1e1e950b86241982658e80a))
|
||||
|
||||
## [0.12.3](https://github.com/fluencelabs/aqua/compare/aqua-v0.12.2...aqua-v0.12.3) (2023-09-28)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **compiler:** Make `if` propagate errors [fixes LNG-202] ([#779](https://github.com/fluencelabs/aqua/issues/779)) ([ca6cae9](https://github.com/fluencelabs/aqua/commit/ca6cae96ad27f07fe2e6c05ee1caa16153c0c991))
|
||||
* **compiler:** Replace `%last_error%` with `:error:` [fixes LNG-239] ([#883](https://github.com/fluencelabs/aqua/issues/883)) ([a80033b](https://github.com/fluencelabs/aqua/commit/a80033b81cb7f58f9bfe8665205b864c5438306e))
|
||||
* Create structs with stream maps [fixes LNG-244] ([#893](https://github.com/fluencelabs/aqua/issues/893)) ([878990a](https://github.com/fluencelabs/aqua/commit/878990a8370718b64bd26663d7813a972e7cdd49))
|
||||
* **lsp-api:** Add `infoType` ([#915](https://github.com/fluencelabs/aqua/issues/915)) ([1e636cc](https://github.com/fluencelabs/aqua/commit/1e636cc076f5ba4b0487e60fe312ff873d5c19ae))
|
||||
* **tests:** Add integration test for result error handling ([#914](https://github.com/fluencelabs/aqua/issues/914)) ([b2ca1d3](https://github.com/fluencelabs/aqua/commit/b2ca1d35bf1f6420cea673e092a9f357c6e3a742))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **compiler:** Handle errors from result handling [fixes LNG-247] ([#913](https://github.com/fluencelabs/aqua/issues/913)) ([f158074](https://github.com/fluencelabs/aqua/commit/f158074c4ecb7d02236786a809c7c387bbb65d3b))
|
||||
|
||||
## [0.12.2](https://github.com/fluencelabs/aqua/compare/aqua-v0.12.1...aqua-v0.12.2) (2023-09-25)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **aqua-api:** Use scala.js link instead of opt ([#891](https://github.com/fluencelabs/aqua/issues/891)) ([3f916c7](https://github.com/fluencelabs/aqua/commit/3f916c78ab3aa6e50d47929bf28b846bf5537868))
|
||||
* **build:** Implement custom bundle task ([#894](https://github.com/fluencelabs/aqua/issues/894)) ([67d8151](https://github.com/fluencelabs/aqua/commit/67d8151d9432971b5375794bb15394eeea94132e))
|
||||
* **compiler:** Add warnings subsystem [fixes LNG117] ([#906](https://github.com/fluencelabs/aqua/issues/906)) ([27a781d](https://github.com/fluencelabs/aqua/commit/27a781dd3f161728c111e5fe834389da69f82d8f))
|
||||
* **compiler:** Fail on internal error [fixes LNG-229] ([#905](https://github.com/fluencelabs/aqua/issues/905)) ([8741c91](https://github.com/fluencelabs/aqua/commit/8741c910bed18420cf69fd3bf0496b01148e4cf5))
|
||||
* **compiler:** Services as abilities [fixes LNG-206] ([#873](https://github.com/fluencelabs/aqua/issues/873)) ([6be2a3d](https://github.com/fluencelabs/aqua/commit/6be2a3d5da83c426761819908c0a3c3fd8dc4bf0))
|
||||
* export types from aqua-api ([#904](https://github.com/fluencelabs/aqua/issues/904)) ([594f465](https://github.com/fluencelabs/aqua/commit/594f46529d7476f8f2345e9deaa43938d7d52a47))
|
||||
* **language-server:** Pass errors to lsp context [fixes LNG-243] ([#888](https://github.com/fluencelabs/aqua/issues/888)) ([f8b5017](https://github.com/fluencelabs/aqua/commit/f8b5017918a1ec076ccc1593cca70e9e71276b36))
|
||||
* rethrow errors to capture stacktrace ([#907](https://github.com/fluencelabs/aqua/issues/907)) ([66638af](https://github.com/fluencelabs/aqua/commit/66638afa2d6ad6ca2fba1492c94b2c80fd397e39))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **compiler:** Do not restrict stream args when ability is present [fixes LNG-233] ([#902](https://github.com/fluencelabs/aqua/issues/902)) ([54ddcc8](https://github.com/fluencelabs/aqua/commit/54ddcc8b6271b1aed4b427dcc74360a0cb212eb4))
|
||||
* **compiler:** Fix arrows capture in closures [fixes LNG-242] ([#903](https://github.com/fluencelabs/aqua/issues/903)) ([ed9e708](https://github.com/fluencelabs/aqua/commit/ed9e708939d9a689b51ebd0e2ab89a8c92a07b05))
|
||||
* **deps:** update dependency @fluencelabs/js-client to v0.1.4 ([#887](https://github.com/fluencelabs/aqua/issues/887)) ([d6f879e](https://github.com/fluencelabs/aqua/commit/d6f879ef7ab7e1a8dfadc12b573cf1e51e06d9c9))
|
||||
* **deps:** update dependency @fluencelabs/js-client to v0.1.6 ([#890](https://github.com/fluencelabs/aqua/issues/890)) ([fb75bc2](https://github.com/fluencelabs/aqua/commit/fb75bc267e9b2cb0c7dbeac389b73ee33b273a11))
|
||||
* **deps:** update dependency @fluencelabs/js-client to v0.1.7 ([#908](https://github.com/fluencelabs/aqua/issues/908)) ([1c708c8](https://github.com/fluencelabs/aqua/commit/1c708c8bb03a9c7c749b814d412097498c833b36))
|
||||
|
||||
## [0.12.1](https://github.com/fluencelabs/aqua/compare/aqua-v0.12.0...aqua-v0.12.1) (2023-09-11)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **compiler:** Error on not arrow call after `<-` ([#876](https://github.com/fluencelabs/aqua/issues/876)) ([69a808e](https://github.com/fluencelabs/aqua/commit/69a808e24307b5fe312a6dfdc6041c310c33d96d))
|
||||
* **compiler:** Fix closure stream capture [fixes LNG-58] ([#857](https://github.com/fluencelabs/aqua/issues/857)) ([443e65e](https://github.com/fluencelabs/aqua/commit/443e65e3d8bca4774f5bdb6db5e526c5f2201c89))
|
||||
* **deps:** update dependency @fluencelabs/aqua-lib to v0.7.3 ([#882](https://github.com/fluencelabs/aqua/issues/882)) ([3419607](https://github.com/fluencelabs/aqua/commit/3419607e8ccd3d280d5d168d6ffb9cb9380d32a8))
|
||||
* **deps:** update dependency @fluencelabs/js-client to v0.1.1 ([#865](https://github.com/fluencelabs/aqua/issues/865)) ([1f23545](https://github.com/fluencelabs/aqua/commit/1f23545b49db2e3bb387ef9d961cac53bb75d127))
|
||||
* **deps:** update dependency @fluencelabs/js-client to v0.1.3 ([#875](https://github.com/fluencelabs/aqua/issues/875)) ([df111ad](https://github.com/fluencelabs/aqua/commit/df111adf21c1abe5fbbed7264734927a3f048ffc))
|
||||
|
||||
## [0.12.0](https://github.com/fluencelabs/aqua/compare/aqua-v0.11.11...aqua-v0.12.0) (2023-08-25)
|
||||
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* **js-client:** Move to new js-client interface ([#855](https://github.com/fluencelabs/aqua/issues/855))
|
||||
|
||||
### Features
|
||||
|
||||
* **compiler:** Restrict abilities usage [fixes LNG-208] ([#854](https://github.com/fluencelabs/aqua/issues/854)) ([2a0b207](https://github.com/fluencelabs/aqua/commit/2a0b20763396fea0ada5e14c01372dd3923b424b))
|
||||
* **js-client:** Move to new js-client interface ([#855](https://github.com/fluencelabs/aqua/issues/855)) ([0f9ede0](https://github.com/fluencelabs/aqua/commit/0f9ede09fb849915b20f87fddb95ee2514421a19))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **compiler:** Fix nested abilities [fixes LNG-220] ([#852](https://github.com/fluencelabs/aqua/issues/852)) ([bf0b51f](https://github.com/fluencelabs/aqua/commit/bf0b51fa5bca3be96cab028eaec48aa5805b1f73))
|
||||
|
||||
## [0.11.11](https://github.com/fluencelabs/aqua/compare/aqua-v0.11.10...aqua-v0.11.11) (2023-08-21)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **compiler:** Structural typing for data and abilities [fixes LNG-215] ([#843](https://github.com/fluencelabs/aqua/issues/843)) ([019611a](https://github.com/fluencelabs/aqua/commit/019611a89c31618985303d4984ed581eadad11f5))
|
||||
* parseq implementation (fixes LNG-223) ([#840](https://github.com/fluencelabs/aqua/issues/840)) ([8060695](https://github.com/fluencelabs/aqua/commit/8060695dbb0a2f34febf739eb20db8b8781b3682))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **compiler:** Generate stream restriction for scoped exprs [fixes LNG-222] ([#841](https://github.com/fluencelabs/aqua/issues/841)) ([eb4cdb0](https://github.com/fluencelabs/aqua/commit/eb4cdb0dd12987e64881bab6ff19f935e905672e))
|
||||
* **compiler:** Refactor values [fixes LNG-57] ([#821](https://github.com/fluencelabs/aqua/issues/821)) ([f562bd4](https://github.com/fluencelabs/aqua/commit/f562bd40b6df5bbfce5635c10710d91f21e3af88))
|
||||
* Fix release build command ([#834](https://github.com/fluencelabs/aqua/issues/834)) ([6146f8e](https://github.com/fluencelabs/aqua/commit/6146f8e40a59c9fecd9f40b76e6ec6398b05ca05))
|
||||
|
||||
## [0.11.9](https://github.com/fluencelabs/aqua/compare/aqua-v0.11.8...aqua-v0.11.9) (2023-08-09)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **compiler:** Add boolean algebra [fixes LNG-211] ([#814](https://github.com/fluencelabs/aqua/issues/814)) ([a5b6102](https://github.com/fluencelabs/aqua/commit/a5b610242260538ff38d62dc21b97a694d0776e3))
|
||||
* **compiler:** Add equality ops [fixes LNG-217] ([#820](https://github.com/fluencelabs/aqua/issues/820)) ([a5e9354](https://github.com/fluencelabs/aqua/commit/a5e9354aebe9291e9fc0b1d29e74972bfaa254e2))
|
||||
* **compiler:** Restrict exporting functions that return arrow types or ability types [fixes LNG-209] ([#815](https://github.com/fluencelabs/aqua/issues/815)) ([fabf8d7](https://github.com/fluencelabs/aqua/commit/fabf8d7d61ec8d70bf8e17e581c3c7371c4e6d78))
|
||||
* wrap aqua api ([#807](https://github.com/fluencelabs/aqua/issues/807)) ([c7fca40](https://github.com/fluencelabs/aqua/commit/c7fca40f670a4b5a51ab4ce188f69f550d4bf6d6))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **compiler:** Fix `if` with brackets parsing ([#812](https://github.com/fluencelabs/aqua/issues/812)) ([4c3c32b](https://github.com/fluencelabs/aqua/commit/4c3c32b7c400e87f962dc9827892a9224765e2a4))
|
||||
* **compiler:** Fix math ops for `u64` [fixes LNG-204] ([#811](https://github.com/fluencelabs/aqua/issues/811)) ([50ba194](https://github.com/fluencelabs/aqua/commit/50ba194b8610b60bcaefee401cadacb369246f79))
|
||||
* **compiler:** Nested abilities [fixes LNG-214] ([#816](https://github.com/fluencelabs/aqua/issues/816)) ([4e3e70f](https://github.com/fluencelabs/aqua/commit/4e3e70f4fc855a16238c4f84bd4f6a1102890904))
|
||||
* **compiler:** Runtime error on compilation exported functions with top types [fixes LNG-218] ([#822](https://github.com/fluencelabs/aqua/issues/822)) ([ef4b014](https://github.com/fluencelabs/aqua/commit/ef4b0143ac7cd4e1a5997d6a0f1f690ab806a315))
|
||||
|
||||
## [0.11.8](https://github.com/fluencelabs/aqua/compare/aqua-v0.11.7...aqua-v0.11.8) (2023-07-20)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **compiler:** Abilities ([#731](https://github.com/fluencelabs/aqua/issues/731)) ([63a9f42](https://github.com/fluencelabs/aqua/commit/63a9f42e86d29b741fa31135b4111bc0f38f238f))
|
||||
* **compiler:** Find and display link cycles ([#787](https://github.com/fluencelabs/aqua/issues/787)) ([667a825](https://github.com/fluencelabs/aqua/commit/667a8255d994b334dfc87bd89a970855748752fe))
|
||||
* **compiler:** Make `on` propagate errors [fixes LNG-203] ([#788](https://github.com/fluencelabs/aqua/issues/788)) ([b8b0faf](https://github.com/fluencelabs/aqua/commit/b8b0fafda0d27607ffc693e52c0dae81d23ec503))
|
||||
* **compiler:** Make topology hop with non-FFI snippet [fixes LNG-125] ([#764](https://github.com/fluencelabs/aqua/issues/764)) ([c1fe24b](https://github.com/fluencelabs/aqua/commit/c1fe24b04d8a2f711ed7b316e7ae9a4f12732421))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **ci:** use unstable nox image ([#780](https://github.com/fluencelabs/aqua/issues/780)) ([22f380a](https://github.com/fluencelabs/aqua/commit/22f380a49162d8d79cccad266b17116d9f9c7795))
|
||||
* **compiler:** Fix search for one element cycles ([#797](https://github.com/fluencelabs/aqua/issues/797)) ([33ab33d](https://github.com/fluencelabs/aqua/commit/33ab33d4c8f34743202e5acbfb2e976ab3070299))
|
||||
* **deps:** update dependency @fluencelabs/fluence-network-environment to v1.1.2 ([#786](https://github.com/fluencelabs/aqua/issues/786)) ([ca52e25](https://github.com/fluencelabs/aqua/commit/ca52e2542cc031c748c6f8c8372aff717e9c709f))
|
||||
|
||||
## [0.11.7](https://github.com/fluencelabs/aqua/compare/aqua-v0.11.6...aqua-v0.11.7) (2023-06-16)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **compiler:** Fix incorrect service method renaming [fixes LNG-199] ([#757](https://github.com/fluencelabs/aqua/issues/757)) ([e22fff7](https://github.com/fluencelabs/aqua/commit/e22fff7c8ac3b30baacd4088d96386e73985fd54))
|
||||
|
||||
## [0.11.6](https://github.com/fluencelabs/aqua/compare/aqua-v0.11.5...aqua-v0.11.6) (2023-06-15)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **compiler:** Fix SO in Topology [fixes LNG-149] ([#752](https://github.com/fluencelabs/aqua/issues/752)) ([017eca7](https://github.com/fluencelabs/aqua/commit/017eca70563d82488d6072d0db508253d984e9b2))
|
||||
* generate JS in Aqua API properly ([#755](https://github.com/fluencelabs/aqua/issues/755)) ([889c507](https://github.com/fluencelabs/aqua/commit/889c50734b56327b39d3d78903d25450bad27fa7))
|
||||
|
||||
## [0.11.5](https://github.com/fluencelabs/aqua/compare/aqua-v0.11.4...aqua-v0.11.5) (2023-06-14)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **compiler:** Fix closure passing [fixes LNG-92] ([#747](https://github.com/fluencelabs/aqua/issues/747)) ([f1abd58](https://github.com/fluencelabs/aqua/commit/f1abd587b761c23b1e27f22bfd8b21ada03a4c5d))
|
||||
* **parser:** Fix compare ops parsing ([#748](https://github.com/fluencelabs/aqua/issues/748)) ([739854a](https://github.com/fluencelabs/aqua/commit/739854a20b73c7d3cd5eec28f5a7f3ae12691987))
|
||||
|
||||
## [0.11.4](https://github.com/fluencelabs/aqua/compare/aqua-v0.11.3...aqua-v0.11.4) (2023-06-13)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **tracing:** Introduce function calls tracing [fixes LNG-169] ([#732](https://github.com/fluencelabs/aqua/issues/732)) ([e9c0044](https://github.com/fluencelabs/aqua/commit/e9c004452e48a22dfff2ddd64f1d98797ac6db84))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **aqua-api:** Compilation to js/ts for file without exports [LNG-196] ([#744](https://github.com/fluencelabs/aqua/issues/744)) ([8c2240d](https://github.com/fluencelabs/aqua/commit/8c2240d3b16e6f3f968d393aeb1136ffffc9464c))
|
||||
* **compiler:** Fix closure call compilation [fixes LNG-193] ([#741](https://github.com/fluencelabs/aqua/issues/741)) ([c5534a9](https://github.com/fluencelabs/aqua/commit/c5534a964c21d48bd944e9c62e144cbbbd58625f))
|
||||
|
||||
## [0.11.3](https://github.com/fluencelabs/aqua/compare/aqua-v0.11.2...aqua-v0.11.3) (2023-06-09)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **devcontainer:** Add js-client to devcontainer ([#736](https://github.com/fluencelabs/aqua/issues/736)) ([62b1642](https://github.com/fluencelabs/aqua/commit/62b16426deabaaadf51ee9cc673da11983535492))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **aqua-api:** Add default constants to Aqua API [LNG-194] ([#738](https://github.com/fluencelabs/aqua/issues/738)) ([5f5fc49](https://github.com/fluencelabs/aqua/commit/5f5fc494b66f649b440fd332edf8adcd39beb8e8))
|
||||
|
||||
## [0.11.2](https://github.com/fluencelabs/aqua/compare/aqua-v0.11.1...aqua-v0.11.2) (2023-06-07)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **aqua-api:** return JS and TS sources from API [LNG-164] ([#730](https://github.com/fluencelabs/aqua/issues/730)) ([0b66aa9](https://github.com/fluencelabs/aqua/commit/0b66aa96ece2ce3b1ed44ff1e183e0289b5af2d9))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **language-server:** Go-to definition for path in `use` expression [LNG-187] ([#733](https://github.com/fluencelabs/aqua/issues/733)) ([21cb393](https://github.com/fluencelabs/aqua/commit/21cb3937acadca8d245b540aac301b130969ac0b))
|
||||
|
||||
## [0.11.1](https://github.com/fluencelabs/aqua/compare/aqua-v0.11.0...aqua-v0.11.1) (2023-06-01)
|
||||
|
||||
|
||||
|
@ -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.
|
||||
|
40
INSTALL.md
40
INSTALL.md
@ -1,40 +0,0 @@
|
||||
# Installation of Aqua
|
||||
|
||||
The easiest way to use Aqua is to download the latest build from npm: [@fluencelabs/aqua](https://www.npmjs.com/package/@fluencelabs/aqua).
|
||||
|
||||
```bash
|
||||
npm i -g @fluencelabs/aqua
|
||||
aqua --input src/aqua --output src/generated
|
||||
```
|
||||
|
||||
Input directory should contain files with `.aqua` scripts.
|
||||
|
||||
Other ways of building Aqua can be found in [INSTALL.md](./INSTALL.md).
|
||||
|
||||
## Build from sources
|
||||
|
||||
If you want to build Aqua compiler from the sourcecode, you need [Scala](https://www.scala-lang.org/)'s `sbt` installed.
|
||||
|
||||
Aqua compiler itself can be compiled to and distributed either as JavaScript or Java file.
|
||||
|
||||
### Build to JS
|
||||
|
||||
Run `sbt cliJS/fullLinkOpt` to build JavaScript file. You can find the compiled file in: `cli/.js/target/scala-%scala-version%/cli-opt`.
|
||||
|
||||
Then run it with `node`:
|
||||
|
||||
```bash
|
||||
node aqua-%version_number%.js -i path/to/input/dir -o path/to/output/dir
|
||||
```
|
||||
|
||||
Javascript build is the default for Aqua.
|
||||
|
||||
### Build to JVM
|
||||
|
||||
Run `sbt cli/assembly` to build JAR file. It is located in `cli/.jvm/target/scala-%scala-version%/`
|
||||
|
||||
It requires `java` to run Aqua compiler in `.jar` file from the command line:
|
||||
|
||||
```bash
|
||||
java -jar aqua-%version_number%.jar -i path/to/input/dir -o path/to/output/dir
|
||||
```
|
798
LICENSE
798
LICENSE
@ -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/>.
|
||||
|
26
README.md
26
README.md
@ -1,23 +1,16 @@
|
||||
# Aqua
|
||||
|
||||
[](https://github.com/fluencelabs/aqua/actions/workflows/release.yml)
|
||||
[](https://www.npmjs.com/package/@fluencelabs/aqua)
|
||||
[](https://www.npmjs.com/package/@fluencelabs/aqua-api)
|
||||
|
||||
[Aqua](https://fluence.dev/docs/aqua-book/introduction) is an open-source language for distributed workflow coordination in p2p networks. Aqua programs are executed on many peers, sequentially or in parallel, forming a single-use coordination network. Applications are turned into hostless workflows over distributed function calls, which enables various levels of decentralization: from handling by a limited set of servers to complete peer-to-peer architecture by connecting user devices directly. Aqua is the core of the [Fluence](https://fluence.network/) protocol and a framework for internet or private cloud applications.
|
||||
|
||||
|
||||
## Installation and Usage
|
||||
## Usage
|
||||
|
||||
The easiest way to use Aqua is to download the latest build from npm: [@fluencelabs/aqua](https://www.npmjs.com/package/@fluencelabs/aqua).
|
||||
The easiest way to use Aqua is through [Fluence CLI](https://github.com/fluencelabs/cli) with [aqua command](https://github.com/fluencelabs/cli/blob/main/docs/commands/README.md#fluence-aqua).
|
||||
|
||||
```bash
|
||||
npm i -g @fluencelabs/aqua
|
||||
aqua --input src/aqua --output src/generated
|
||||
```
|
||||
|
||||
Input directory should contain files with `.aqua` scripts.
|
||||
|
||||
Other ways of installing Aqua can be found in [INSTALL.md](./INSTALL.md).
|
||||
Other ways of using Aqua are described in [USAGE.md](./USAGE.md).
|
||||
|
||||
|
||||
## Documentation
|
||||
@ -28,16 +21,13 @@ Comprehensive documentation and usage examples as well as a number of videos can
|
||||
## Repository Structure
|
||||
|
||||
- [**api**](./api) - Aqua API for JS
|
||||
- [aqua-api](./api/aqua-api) - Scala sources
|
||||
- [aqua-api-npm](./api/aqua-api-npm) - JS project
|
||||
- [aqua-api-example](./api/aqua-api-example) - usage example
|
||||
- [api](./api/api) - Scala sources
|
||||
- [api-npm](./api/api-npm) - JS project
|
||||
- [api-example](./api/api-example) - usage example
|
||||
- [**aqua-run**](./aqua-run) - Aqua API to run functions
|
||||
- [**backend**](./backend) - compilation backend interface
|
||||
- [backend/air](./backend/air) - generates AIR code from the middle-end model
|
||||
- [backend/ts](./backend/ts) - generates AIR code and TypeScript wrappers for use with [Fluence JS]( https://github.com/fluencelabs/fluence-js) SDK
|
||||
- [**cli**](./cli) - CLI interface
|
||||
- [cli](./cli/cli) - Scala sources
|
||||
- [cli-npm](./cli/cli-npm) - JS project
|
||||
- [**compiler**](./compiler) - compiler as a pure function made from _linker_, _semantics_ and _backend_
|
||||
- [**model**](./model) - middle-end, internal representation of the code, optimizations and transformations
|
||||
- [transform](./model/transform) - optimizations and transformations, converting model to the result, ready to be rendered
|
||||
@ -60,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.
|
||||
|
||||
|
28
USAGE.md
Normal file
28
USAGE.md
Normal file
@ -0,0 +1,28 @@
|
||||
# Usage of Aqua
|
||||
|
||||
|
||||
## Fluence CLI
|
||||
|
||||
The easiest way to use Aqua is through [Fluence CLI](https://github.com/fluencelabs/cli) with [aqua command](https://github.com/fluencelabs/cli/blob/main/docs/commands/README.md#fluence-aqua).
|
||||
|
||||
|
||||
## JS API
|
||||
|
||||
You can use Aqua compiler API directly from JS code by installing [`@fluencelabs/aqua-api` package](https://www.npmjs.com/package/@fluencelabs/aqua-api). See an example usage in [api/api-example](./api/api-example).
|
||||
|
||||
|
||||
## Build from sources
|
||||
|
||||
If you want to build Aqua compiler API from the source code, you need [Scala](https://www.scala-lang.org/)'s [`sbt`](https://www.scala-sbt.org/) installed.
|
||||
|
||||
|
||||
### Build to JS package
|
||||
|
||||
Javascript build is the default for Aqua compiler API.
|
||||
|
||||
Run `sbt "aqua-apiJS/fullBundleJS"`. It will generate JS package in `api/api-npm` directory.
|
||||
|
||||
|
||||
### Build to JVM library
|
||||
|
||||
Building Aqua compiler API as JVM lib is technically possible, but is not supported.
|
36
api/api-example/index.js
Normal file
36
api/api-example/index.js
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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'
|
||||
|
||||
// compile call
|
||||
const compilationResult = await compileAquaCallFromPath({
|
||||
filePath: 'test.aqua',
|
||||
data: { num: 3 },
|
||||
funcCall: 'getNumber(num)',
|
||||
})
|
||||
|
||||
const {
|
||||
errors,
|
||||
functionCall: { funcDef, script },
|
||||
functions,
|
||||
generatedSources,
|
||||
services,
|
||||
} = compilationResult
|
||||
|
||||
console.log(script)
|
@ -8,8 +8,8 @@
|
||||
},
|
||||
"author": "Fluence Labs",
|
||||
"type": "module",
|
||||
"license": "Apache-2.0",
|
||||
"license": "AGPL-3.0",
|
||||
"dependencies": {
|
||||
"@fluencelabs/aqua-api": "0.10.4"
|
||||
"@fluencelabs/aqua-api": "workspace:*"
|
||||
}
|
||||
}
|
3
api/api-npm/README.md
Normal file
3
api/api-npm/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# Aqua API
|
||||
|
||||
[Documentation](https://fluence.dev/docs/aqua-book/aqua-js-api)
|
145
api/api-npm/index.d.ts
vendored
Normal file
145
api/api-npm/index.d.ts
vendored
Normal file
@ -0,0 +1,145 @@
|
||||
/*
|
||||
* 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 {
|
||||
funcDef: FunctionCallDef;
|
||||
script: string;
|
||||
}
|
||||
|
||||
export declare class GeneratedSource {
|
||||
name: string;
|
||||
tsSource?: string;
|
||||
jsSource?: string;
|
||||
tsTypes?: string;
|
||||
}
|
||||
|
||||
export declare class CompilationResult {
|
||||
services: Record<string, ServiceDef>;
|
||||
functions: Record<string, 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 = {
|
||||
/** 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 */
|
||||
logLevel?: string | undefined;
|
||||
/** Do not generate a pass through the relay node. Default: false */
|
||||
noRelay?: boolean | undefined;
|
||||
/** Do not generate a wrapper that catches and displays errors. Default: false */
|
||||
noXor?: boolean | undefined;
|
||||
/** Target type for the compiler. Must be one of: ts, js, air. Default: air */
|
||||
targetType?: "ts" | "js" | "air" | undefined;
|
||||
/** Compile aqua in tracing mode (for debugging purposes). Default: false */
|
||||
tracing?: boolean | undefined;
|
||||
/** Do not generate response call if there are no returned values */
|
||||
noEmptyResponse?: boolean | undefined;
|
||||
};
|
||||
|
||||
type CodeString = {
|
||||
/** Aqua code to be compiled */
|
||||
code: string;
|
||||
};
|
||||
|
||||
export type CompileFromStringArgs = CommonArgs & CodeString;
|
||||
|
||||
/** Compile aqua code from a string */
|
||||
export declare function compileFromString(
|
||||
args: CompileFromStringArgs,
|
||||
): Promise<CompilationResult>;
|
||||
|
||||
type FilePath = {
|
||||
/** Path to the aqua file to be compiled */
|
||||
filePath: string;
|
||||
};
|
||||
|
||||
export type CompileFromPathArgs = CommonArgs & FilePath;
|
||||
|
||||
/** Compile aqua code from a file */
|
||||
export declare function compileFromPath(
|
||||
args: CompileFromPathArgs,
|
||||
): Promise<CompilationResult>;
|
||||
|
||||
type FuncCall = {
|
||||
/** Function call you want to compile. Example: someFunc("someArg") */
|
||||
funcCall: string;
|
||||
/** Args to be passed to the function (record with keys named as args you want to pass to the function) Example: { someArg: 1 } */
|
||||
data?: Record<string, unknown> | undefined;
|
||||
};
|
||||
|
||||
export type CallCompilationResult = CompilationResult & {
|
||||
functionCall: AquaFunction;
|
||||
};
|
||||
|
||||
export type CompileFuncCallFromStringArgs = CommonArgs & CodeString & FuncCall;
|
||||
|
||||
/** Compile aqua function call from a string */
|
||||
export declare function compileAquaCallFromString(
|
||||
args: CompileFuncCallFromStringArgs,
|
||||
): Promise<CallCompilationResult>;
|
||||
|
||||
export type CompileFuncCallFromPathArgs = CommonArgs & FilePath & FuncCall;
|
||||
|
||||
/** Compile aqua function call from a file */
|
||||
export declare function compileAquaCallFromPath(
|
||||
args: CompileFuncCallFromPathArgs,
|
||||
): Promise<CallCompilationResult>;
|
||||
|
||||
export {};
|
129
api/api-npm/index.js
Normal file
129
api/api-npm/index.js
Normal file
@ -0,0 +1,129 @@
|
||||
/*
|
||||
* 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({
|
||||
constants = [],
|
||||
logLevel = "info",
|
||||
noRelay = false,
|
||||
noXor = false,
|
||||
targetType = "air",
|
||||
tracing = false,
|
||||
noEmptyResponse = true,
|
||||
}) {
|
||||
return new AquaConfig(
|
||||
logLevel,
|
||||
constants,
|
||||
noXor,
|
||||
noRelay,
|
||||
{
|
||||
ts: "typescript",
|
||||
js: "javascript",
|
||||
air: "air",
|
||||
}[targetType],
|
||||
tracing,
|
||||
noEmptyResponse,
|
||||
);
|
||||
}
|
||||
|
||||
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);
|
||||
return res;
|
||||
} catch (error) {
|
||||
if (
|
||||
typeof error === "object" &&
|
||||
error !== null &&
|
||||
"message" in error &&
|
||||
typeof error.message === "string"
|
||||
) {
|
||||
throw new Error(error.message);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
export function compileFromString({ code, imports = [], ...commonArgs }) {
|
||||
return compile(
|
||||
new Input(code),
|
||||
normalizeImports(imports),
|
||||
getConfig(commonArgs),
|
||||
);
|
||||
}
|
||||
|
||||
export function compileFromPath({ filePath, imports = [], ...commonArgs }) {
|
||||
return compile(
|
||||
new Path(filePath),
|
||||
normalizeImports(imports),
|
||||
getConfig(commonArgs),
|
||||
);
|
||||
}
|
||||
|
||||
export function compileAquaCallFromString({
|
||||
code,
|
||||
funcCall,
|
||||
data,
|
||||
imports = [],
|
||||
...commonArgs
|
||||
}) {
|
||||
return compile(
|
||||
new Call(funcCall, data, new Input(code)),
|
||||
normalizeImports(imports),
|
||||
getConfig(commonArgs),
|
||||
);
|
||||
}
|
||||
|
||||
export function compileAquaCallFromPath({
|
||||
filePath,
|
||||
funcCall,
|
||||
data,
|
||||
imports = [],
|
||||
...commonArgs
|
||||
}) {
|
||||
return compile(
|
||||
new Call(funcCall, data, new Input(filePath)),
|
||||
normalizeImports(imports),
|
||||
getConfig(commonArgs),
|
||||
);
|
||||
}
|
17
api/api-npm/meta-utils.js
Normal file
17
api/api-npm/meta-utils.js
Normal file
@ -0,0 +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 = ""
|
@ -1,17 +1,16 @@
|
||||
{
|
||||
"name": "@fluencelabs/aqua-api",
|
||||
"version": "0.11.1",
|
||||
"version": "0.14.11",
|
||||
"description": "Aqua API",
|
||||
"type": "commonjs",
|
||||
"type": "module",
|
||||
"main": "index.js",
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts",
|
||||
"aqua-api.js",
|
||||
"aqua-api.d.ts",
|
||||
"meta-utils.js"
|
||||
],
|
||||
"scripts": {
|
||||
"move:scalajs": "cp ../aqua-api/target/scala-3.1.3/aqua-api-opt/main.js ./aqua-api.js",
|
||||
"move:fast": "cp ../aqua-api/target/scala-3.1.3/aqua-api-fastopt/main.js ./aqua-api.js"
|
||||
},
|
||||
"prettier": {},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/fluencelabs/aqua.git"
|
||||
@ -21,12 +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/fluence": "0.28.0"
|
||||
"@fluencelabs/interfaces": "0.12.0",
|
||||
"prettier": "3.3.0"
|
||||
}
|
||||
}
|
252
api/api/.js/src/main/scala/api/AquaAPI.scala
Normal file
252
api/api/.js/src/main/scala/api/AquaAPI.scala
Normal file
@ -0,0 +1,252 @@
|
||||
/*
|
||||
* 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 aqua.Rendering.given
|
||||
import aqua.SpanParser
|
||||
import aqua.api.TargetType.*
|
||||
import aqua.api.{APICompilation, APIResult, AquaAPIConfig, Imports}
|
||||
import aqua.backend.air.AirBackend
|
||||
import aqua.backend.api.APIBackend
|
||||
import aqua.backend.js.JavaScriptBackend
|
||||
import aqua.backend.ts.TypeScriptBackend
|
||||
import aqua.backend.{AirFunction, Backend, Generated}
|
||||
import aqua.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.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 fs2.io.file.{Files, Path}
|
||||
import scala.concurrent.ExecutionContext.Implicits.global
|
||||
import scala.concurrent.Future
|
||||
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 imports configuration
|
||||
* @param aquaConfigJS compiler config
|
||||
* @return compiler results depending on input and config
|
||||
*/
|
||||
@JSExport
|
||||
def compile(
|
||||
input: types.Input | types.Path | types.Call,
|
||||
imports: ImportsJS,
|
||||
aquaConfigJS: js.UndefOr[AquaConfig]
|
||||
): Promise[CompilationResult] = {
|
||||
aquaConfigJS.toOption
|
||||
.map(AquaConfig.fromJS)
|
||||
.getOrElse(validNec(AquaAPIConfig()))
|
||||
.traverse { config =>
|
||||
val apiImports = Imports.fromMap(
|
||||
imports.view
|
||||
.mapValues(
|
||||
_.toMap.view
|
||||
.mapValues(_.toList)
|
||||
.toMap
|
||||
)
|
||||
.toMap
|
||||
)
|
||||
|
||||
input match {
|
||||
case i: (types.Input | types.Path) =>
|
||||
compileAll(i, apiImports, config)
|
||||
case c: types.Call =>
|
||||
compileCall(c, apiImports, config)
|
||||
|
||||
}
|
||||
}
|
||||
.map(_.leftMap(errs => CompilationResult.errs(errs.toChain.toList)).merge)
|
||||
.unsafeToFuture()
|
||||
.toJSPromise
|
||||
}
|
||||
|
||||
// Compile all non-call inputs
|
||||
private def compileAll(
|
||||
input: types.Input | types.Path,
|
||||
imports: Imports,
|
||||
config: AquaAPIConfig
|
||||
): IO[CompilationResult] = {
|
||||
val backend: Backend = config.targetType match {
|
||||
case AirType => APIBackend
|
||||
case TypeScriptType => TypeScriptBackend()
|
||||
case JavaScriptType => JavaScriptBackend()
|
||||
}
|
||||
|
||||
extension (res: APIResult[Chain[AquaCompiled[FileModuleId]]])
|
||||
def toResult: CompilationResult = {
|
||||
val (warnings, result) = res.value.run
|
||||
|
||||
result.map { compiled =>
|
||||
(config.targetType match {
|
||||
case AirType => generatedToAirResult
|
||||
case TypeScriptType => compiledToTsSourceResult
|
||||
case JavaScriptType => compiledToJsSourceResult
|
||||
}).apply(compiled, warnings)
|
||||
}.leftMap(errorsToResult(_, warnings)).merge
|
||||
}
|
||||
|
||||
input match {
|
||||
case i: types.Input =>
|
||||
APICompilation
|
||||
.compileString(
|
||||
i.input,
|
||||
imports,
|
||||
config,
|
||||
backend
|
||||
)
|
||||
.map(_.toResult)
|
||||
case p: types.Path =>
|
||||
APICompilation
|
||||
.compilePath(
|
||||
p.path,
|
||||
imports,
|
||||
config,
|
||||
backend
|
||||
)
|
||||
.map(_.toResult)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Compile a function call
|
||||
private def compileCall(
|
||||
call: types.Call,
|
||||
imports: Imports,
|
||||
config: AquaAPIConfig
|
||||
): IO[CompilationResult] = {
|
||||
val path = call.input match {
|
||||
case i: types.Input => i.input
|
||||
case p: types.Path => p.path
|
||||
}
|
||||
|
||||
extension (res: APIResult[(FunctionDef, String)])
|
||||
def callToResult: CompilationResult = {
|
||||
val (warnings, result) = res.value.run
|
||||
|
||||
result.map { case (definitions, air) =>
|
||||
CompilationResult.result(
|
||||
call = Some(AquaFunction(FunctionDefJs(definitions), air)),
|
||||
warnings = warnings.toList
|
||||
)
|
||||
}.leftMap(errorsToResult(_, warnings)).merge
|
||||
}
|
||||
|
||||
APICompilation
|
||||
.compileCall(
|
||||
call.functionCall,
|
||||
path,
|
||||
imports,
|
||||
config,
|
||||
vr => VarJson.checkDataGetServices(vr, Some(call.arguments)).map(_._1)
|
||||
)
|
||||
.map(_.callToResult)
|
||||
}
|
||||
|
||||
private def errorsToResult(
|
||||
errors: NonEmptyChain[String],
|
||||
warnings: Chain[String]
|
||||
): CompilationResult = CompilationResult.errs(
|
||||
errors.toChain.toList,
|
||||
warnings.toList
|
||||
)
|
||||
|
||||
private def compiledToTsSourceResult(
|
||||
compiled: Chain[AquaCompiled[FileModuleId]],
|
||||
warnings: Chain[String]
|
||||
): CompilationResult = CompilationResult.result(
|
||||
sources = compiled.toList
|
||||
.flatMap(c =>
|
||||
c.compiled
|
||||
.find(_.suffix == TypeScriptBackend.ext)
|
||||
.map(_.content)
|
||||
.map(GeneratedSource.tsSource(c.sourceId.toString, _))
|
||||
),
|
||||
warnings = warnings.toList
|
||||
)
|
||||
|
||||
private def compiledToJsSourceResult(
|
||||
compiled: Chain[AquaCompiled[FileModuleId]],
|
||||
warnings: Chain[String]
|
||||
): CompilationResult = CompilationResult.result(
|
||||
sources = compiled.toList.flatMap { c =>
|
||||
for {
|
||||
dtsContent <- c.compiled
|
||||
.find(_.suffix == JavaScriptBackend.dtsExt)
|
||||
.map(_.content)
|
||||
jsContent <- c.compiled
|
||||
.find(_.suffix == JavaScriptBackend.ext)
|
||||
.map(_.content)
|
||||
} yield GeneratedSource.jsSource(c.sourceId.toString, jsContent, dtsContent)
|
||||
},
|
||||
warnings = warnings.toList
|
||||
)
|
||||
|
||||
private def generatedToAirResult(
|
||||
compiled: Chain[AquaCompiled[FileModuleId]],
|
||||
warnings: Chain[String]
|
||||
): CompilationResult = {
|
||||
val generated = compiled.toList.flatMap(_.compiled)
|
||||
val serviceDefs = generated.flatMap(_.services).map(s => s.name -> ServiceDefJs(s))
|
||||
val functions = generated.flatMap(
|
||||
_.air.map(as => as.name -> AquaFunction(FunctionDefJs(as.funcDef), as.air))
|
||||
)
|
||||
|
||||
CompilationResult.result(
|
||||
services = serviceDefs.toMap,
|
||||
functions = functions.toMap,
|
||||
warnings = warnings.toList
|
||||
)
|
||||
|
||||
}
|
||||
}
|
86
api/api/.js/src/main/scala/api/types/InputTypes.scala
Normal file
86
api/api/.js/src/main/scala/api/types/InputTypes.scala
Normal file
@ -0,0 +1,86 @@
|
||||
/*
|
||||
* 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 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, JSExportAll, JSExportTopLevel}
|
||||
import scala.scalajs.js.|
|
||||
|
||||
@JSExportTopLevel("Input")
|
||||
@JSExportAll
|
||||
class Input(
|
||||
val input: String
|
||||
)
|
||||
|
||||
@JSExportTopLevel("Path")
|
||||
@JSExportAll
|
||||
class Path(
|
||||
val path: String
|
||||
)
|
||||
|
||||
@JSExportTopLevel("Call")
|
||||
@JSExportAll
|
||||
class Call(
|
||||
val functionCall: String,
|
||||
val arguments: js.Dynamic,
|
||||
val input: Path | Input
|
||||
)
|
||||
|
||||
@JSExportTopLevel("AquaConfig")
|
||||
@JSExportAll
|
||||
class AquaConfig(
|
||||
val logLevel: js.UndefOr[String],
|
||||
val constants: js.UndefOr[js.Array[String]],
|
||||
val noXor: js.UndefOr[Boolean],
|
||||
val noRelay: js.UndefOr[Boolean],
|
||||
val targetType: js.UndefOr[String],
|
||||
val tracing: js.UndefOr[Boolean],
|
||||
val noEmptyResponse: js.UndefOr[Boolean]
|
||||
)
|
||||
|
||||
object AquaConfig {
|
||||
|
||||
def fromJS(cjs: AquaConfig): ValidatedNec[String, AquaAPIConfig] = {
|
||||
cjs.targetType.toOption
|
||||
.map(_.toLowerCase())
|
||||
.map {
|
||||
case "typescript" => validNec(TypeScriptType)
|
||||
case "javascript" => validNec(JavaScriptType)
|
||||
case "air" => validNec(AirType)
|
||||
case _ => invalidNec("Target can be only 'typescript', 'javascript', or 'air'")
|
||||
}
|
||||
.getOrElse(validNec(AirType))
|
||||
.map { target =>
|
||||
AquaAPIConfig(
|
||||
targetType = target,
|
||||
logLevel = cjs.logLevel.getOrElse("info"),
|
||||
constants = cjs.constants.map(_.toList).getOrElse(Nil),
|
||||
noXor = cjs.noXor.getOrElse(false),
|
||||
noRelay = cjs.noRelay.getOrElse(false),
|
||||
tracing = cjs.tracing.getOrElse(false),
|
||||
noEmptyResponse = cjs.noEmptyResponse.getOrElse(true)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
88
api/api/.js/src/main/scala/api/types/OutputTypes.scala
Normal file
88
api/api/.js/src/main/scala/api/types/OutputTypes.scala
Normal 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 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.|
|
||||
|
||||
class AquaFunction(
|
||||
val funcDef: FunctionDefJs,
|
||||
val script: String
|
||||
) extends js.Object
|
||||
|
||||
class GeneratedSource(
|
||||
val name: String,
|
||||
val tsSource: js.UndefOr[String],
|
||||
val jsSource: js.UndefOr[String],
|
||||
val tsTypes: js.UndefOr[String]
|
||||
) extends js.Object
|
||||
|
||||
object GeneratedSource {
|
||||
|
||||
def tsSource(name: String, tsSource: String) =
|
||||
new GeneratedSource(name, tsSource, null, null)
|
||||
|
||||
def jsSource(name: String, jsSource: String, tsTypes: String) =
|
||||
new GeneratedSource(name, null, jsSource, tsTypes)
|
||||
}
|
||||
|
||||
class CompilationResult(
|
||||
val services: js.Dictionary[ServiceDefJs],
|
||||
val functions: js.Dictionary[AquaFunction],
|
||||
val functionCall: js.UndefOr[AquaFunction],
|
||||
val generatedSources: js.Array[GeneratedSource],
|
||||
val errors: js.Array[String],
|
||||
val warnings: js.Array[String]
|
||||
) extends js.Object
|
||||
|
||||
object CompilationResult {
|
||||
|
||||
def result(
|
||||
services: Map[String, ServiceDefJs] = Map.empty,
|
||||
functions: Map[String, AquaFunction] = Map.empty,
|
||||
call: Option[AquaFunction] = None,
|
||||
sources: List[GeneratedSource] = List.empty,
|
||||
warnings: List[String] = List.empty
|
||||
): CompilationResult =
|
||||
new CompilationResult(
|
||||
services.toJSDictionary,
|
||||
functions.toJSDictionary,
|
||||
call.orNull,
|
||||
sources.toJSArray,
|
||||
js.Array(),
|
||||
warnings.toJSArray
|
||||
)
|
||||
|
||||
def errs(
|
||||
errors: List[String] = List.empty,
|
||||
warnings: List[String] = List.empty
|
||||
): CompilationResult =
|
||||
new CompilationResult(
|
||||
js.Dictionary.empty,
|
||||
js.Dictionary.empty,
|
||||
null,
|
||||
null,
|
||||
errors.toJSArray,
|
||||
warnings.toJSArray
|
||||
)
|
||||
}
|
70
api/api/.jvm/src/main/scala/aqua/api/Test.scala
Normal file
70
api/api/.jvm/src/main/scala/aqua/api/Test.scala
Normal file
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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
|
||||
import aqua.backend.ts.TypeScriptBackend
|
||||
import aqua.compiler.AquaCompiled
|
||||
import aqua.files.FileModuleId
|
||||
|
||||
import cats.data.Chain
|
||||
import cats.effect.{IO, IOApp}
|
||||
import fs2.io.file.{Files, Path}
|
||||
import fs2.{Stream, text}
|
||||
|
||||
object Test extends IOApp.Simple {
|
||||
|
||||
override def run: IO[Unit] = {
|
||||
|
||||
APICompilation
|
||||
.compilePath(
|
||||
"./aqua-src/antithesis.aqua",
|
||||
Imports.fromMap(Map("/" -> Map("" -> List("./aqua")))),
|
||||
AquaAPIConfig(targetType = TypeScriptType, noXor = true),
|
||||
TypeScriptBackend(false, "IFluenceClient$$")
|
||||
)
|
||||
.timed
|
||||
.flatMap { case (duration, res) =>
|
||||
println("Compilation time: " + duration.toMillis)
|
||||
val (warnings, result) = res.value.run
|
||||
|
||||
IO.delay {
|
||||
warnings.toList.foreach(println)
|
||||
} *> result.fold(
|
||||
errors =>
|
||||
IO.delay {
|
||||
errors.toChain.toList.foreach(println)
|
||||
},
|
||||
compiled => {
|
||||
val content = compiled.get(0).get.compiled.head.content
|
||||
val targetPath = Path("./target/antithesis.ts")
|
||||
|
||||
Stream
|
||||
.emit(content)
|
||||
.through(text.utf8.encode)
|
||||
.through(Files[IO].writeAll(targetPath))
|
||||
.attempt
|
||||
.compile
|
||||
.last *> IO.delay(
|
||||
println(s"File: ${targetPath.absolute.normalize}")
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
201
api/api/src/main/scala/aqua/api/APICompilation.scala
Normal file
201
api/api/src/main/scala/aqua/api/APICompilation.scala
Normal file
@ -0,0 +1,201 @@
|
||||
/*
|
||||
* 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.api.AquaAPIConfig
|
||||
import aqua.backend.api.APIBackend
|
||||
import aqua.backend.{AirFunction, Backend, Generated}
|
||||
import aqua.compiler.*
|
||||
import aqua.constants.Constants
|
||||
import aqua.definitions.FunctionDef
|
||||
import aqua.files.{AquaFileSources, AquaFilesIO, AquaStringSources, FileModuleId}
|
||||
import aqua.io.*
|
||||
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, 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.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.~>
|
||||
import fs2.io.file.{Files, Path}
|
||||
import scribe.{Level, Logging}
|
||||
|
||||
object APICompilation {
|
||||
|
||||
def compileCall(
|
||||
functionStr: String,
|
||||
pathStr: String,
|
||||
imports: Imports,
|
||||
aquaConfig: AquaAPIConfig,
|
||||
fillWithTypes: List[ValueRaw] => ValidatedNec[String, List[ValueRaw]]
|
||||
): IO[APIResult[(FunctionDef, String)]] = {
|
||||
given AquaIO[IO] = new AquaFilesIO[IO]
|
||||
|
||||
(
|
||||
LogLevels.levelFromString(aquaConfig.logLevel),
|
||||
Constants.parse(aquaConfig.constants)
|
||||
).tupled.toResult.flatTraverse { case (level, constants) =>
|
||||
val transformConfig = aquaConfig.getTransformConfig
|
||||
val config = aquaConfig.getCompilerConfig.copy(constants = constants)
|
||||
|
||||
LogFormatter.initLogger(Some(level))
|
||||
|
||||
new FuncCompiler[IO](
|
||||
Some(RelativePath(Path(pathStr))),
|
||||
imports.toIO,
|
||||
transformConfig,
|
||||
config
|
||||
).compile().map { contextV =>
|
||||
for {
|
||||
context <- contextV.toResult
|
||||
cliFunc <- CliFunc
|
||||
.fromString(functionStr)
|
||||
.toResult
|
||||
arrow <- FuncCompiler
|
||||
.findFunction(context, cliFunc)
|
||||
.toResult
|
||||
argsWithTypes <- fillWithTypes(cliFunc.args).toResult
|
||||
func = cliFunc.copy(args = argsWithTypes)
|
||||
preparer = new RunPreparer(
|
||||
func,
|
||||
arrow,
|
||||
transformConfig
|
||||
)
|
||||
ci <- preparer.prepare().toResult
|
||||
} yield ci.definitions -> ci.air
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def compilePath(
|
||||
pathStr: 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.toIO
|
||||
)
|
||||
|
||||
compileRaw(
|
||||
aquaConfig,
|
||||
sources,
|
||||
backend
|
||||
)
|
||||
}
|
||||
|
||||
def compileString(
|
||||
input: String,
|
||||
imports: Imports,
|
||||
aquaConfig: AquaAPIConfig,
|
||||
backend: Backend
|
||||
): IO[APIResult[Chain[AquaCompiled[FileModuleId]]]] = {
|
||||
given AquaIO[IO] = new AquaFilesIO[IO]
|
||||
|
||||
val path = Path("")
|
||||
|
||||
val strSources: AquaStringSources[IO] =
|
||||
new AquaStringSources(
|
||||
Map(FileModuleId(path) -> input),
|
||||
imports.toIO
|
||||
)
|
||||
|
||||
compileRaw(
|
||||
aquaConfig,
|
||||
strSources,
|
||||
backend
|
||||
)
|
||||
}
|
||||
|
||||
private def compileRaw(
|
||||
aquaConfig: AquaAPIConfig,
|
||||
sources: AquaSources[IO, AquaFileError, FileModuleId],
|
||||
backend: Backend
|
||||
): IO[APIResult[Chain[AquaCompiled[FileModuleId]]]] = (
|
||||
LogLevels.levelFromString(aquaConfig.logLevel),
|
||||
Constants.parse(aquaConfig.constants)
|
||||
).tupled.toResult.flatTraverse { case (level, constants) =>
|
||||
LogFormatter.initLogger(Some(level))
|
||||
|
||||
val transformConfig = aquaConfig.getTransformConfig
|
||||
val config = aquaConfig.getCompilerConfig.copy(constants = constants)
|
||||
|
||||
CompilerAPI
|
||||
.compile[IO, AquaFileError, FileModuleId, FileSpan.F](
|
||||
sources,
|
||||
SpanParser.parser,
|
||||
new AirValidator[IO] {
|
||||
override def init(): IO[Unit] = Applicative[IO].pure(())
|
||||
override def validate(airs: List[AirFunction]): IO[ValidatedNec[String, Unit]] =
|
||||
Applicative[IO].pure(validNec(()))
|
||||
},
|
||||
new Backend.Transform {
|
||||
override def transform(ex: AquaContext): AquaRes =
|
||||
Transform.contextRes(ex, transformConfig)
|
||||
|
||||
override def generate(aqua: AquaRes): Seq[Generated] = backend.generate(aqua)
|
||||
},
|
||||
config
|
||||
)
|
||||
.map(_.toResult)
|
||||
}
|
||||
|
||||
extension [A](v: ValidatedNec[String, A]) {
|
||||
|
||||
def toResult: APIResult[A] =
|
||||
v.toEither.toEitherT
|
||||
}
|
||||
|
||||
extension [A](v: CompileResult[FileModuleId, AquaFileError, FileSpan.F][A]) {
|
||||
|
||||
def toResult: APIResult[A] =
|
||||
v.leftMap(_.map(_.show))
|
||||
.mapK(
|
||||
new (CompileWarnings[FileSpan.F] ~> APIWarnings) {
|
||||
|
||||
override def apply[A](w: CompileWarnings[FileSpan.F][A]): APIWarnings[A] =
|
||||
w.mapWritten(_.map(_.show))
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
52
api/api/src/main/scala/aqua/api/AquaAPIConfig.scala
Normal file
52
api/api/src/main/scala/aqua/api/AquaAPIConfig.scala
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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:
|
||||
case TypeScriptType, JavaScriptType, AirType
|
||||
|
||||
case class AquaAPIConfig(
|
||||
targetType: TargetType = TargetType.AirType,
|
||||
logLevel: String = "info",
|
||||
constants: List[String] = Nil,
|
||||
noXor: Boolean = false,
|
||||
noRelay: Boolean = false,
|
||||
tracing: Boolean = false,
|
||||
noEmptyResponse: Boolean = true
|
||||
) {
|
||||
|
||||
def getTransformConfig: TransformConfig = {
|
||||
val config = TransformConfig(
|
||||
tracing = Option.when(tracing)(TransformConfig.TracingConfig.default),
|
||||
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
|
||||
}
|
||||
}
|
65
api/api/src/main/scala/aqua/api/Imports.scala
Normal file
65
api/api/src/main/scala/aqua/api/Imports.scala
Normal 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)
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
33
api/api/src/main/scala/aqua/api/package.scala
Normal file
33
api/api/src/main/scala/aqua/api/package.scala
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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}
|
||||
|
||||
package object api {
|
||||
|
||||
type APIWarnings = [A] =>> Writer[
|
||||
Chain[String],
|
||||
A
|
||||
]
|
||||
|
||||
type APIResult = [A] =>> EitherT[
|
||||
APIWarnings,
|
||||
NonEmptyChain[String],
|
||||
A
|
||||
]
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
import {
|
||||
Aqua,
|
||||
Call,
|
||||
Path,
|
||||
} from "@fluencelabs/aqua-api/aqua-api.js";
|
||||
|
||||
const aquaPath = new Path("test.aqua")
|
||||
// write function that we want to call and arguments
|
||||
const args = {num: 42}
|
||||
const call = new Call("getNumber(num)", args, aquaPath)
|
||||
|
||||
// compile call
|
||||
const compilationResult = await Aqua.compile(call, [])
|
||||
|
||||
|
||||
/*
|
||||
// Compilation result definition
|
||||
export class CompilationResult {
|
||||
// List of service definitions to register in Fluence JS Client
|
||||
services: Record<string, ServiceDef>
|
||||
// List of function definitions to call in Fluence JS Client
|
||||
functions: Record<string, AquaFunction>
|
||||
// Definition of wrapped function to call in Fluence JS Client
|
||||
functionCall?: AquaFunction
|
||||
// List of errors. All other fields will be empty if `errors` not empty
|
||||
errors: string[]
|
||||
}
|
||||
*/
|
||||
|
||||
// get function definition, that describes types of arguments and results of a function
|
||||
// and AIR script
|
||||
const {funcDef, script} = compilationResult.functionCall
|
21
api/aqua-api-example/package-lock.json
generated
21
api/aqua-api-example/package-lock.json
generated
@ -1,21 +0,0 @@
|
||||
{
|
||||
"name": "aqua-api-example",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "aqua-api-example",
|
||||
"version": "1.0.0",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@fluencelabs/aqua-api": "0.10.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@fluencelabs/aqua-api": {
|
||||
"version": "0.10.4",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/aqua-api/-/aqua-api-0.10.4.tgz",
|
||||
"integrity": "sha512-mBT/ht0mVcGqBfkrnQw9E/tqIW3RNOCDhNwjra9X5WI/TRlztU3G8Vn/odVn6YTpZWJeDwn1qN1VgLoS3VkASA=="
|
||||
}
|
||||
}
|
||||
}
|
50
api/aqua-api-npm/aqua-api.d.ts
vendored
50
api/aqua-api-npm/aqua-api.d.ts
vendored
@ -1,50 +0,0 @@
|
||||
import type {FunctionCallDef, ServiceDef} from "@fluencelabs/fluence/dist/internal/compilerSupport/v3impl/interface"
|
||||
|
||||
export class AquaConfig {
|
||||
constructor(logLevel: string, constants: string[], noXor: boolean, noRelay: boolean);
|
||||
|
||||
logLevel?: string
|
||||
constants?: string[]
|
||||
noXor?: boolean
|
||||
noRelay?: boolean
|
||||
}
|
||||
|
||||
export class AquaFunction {
|
||||
funcDef: FunctionCallDef
|
||||
script: string
|
||||
}
|
||||
|
||||
export class CompilationResult {
|
||||
services: Record<string, ServiceDef>
|
||||
functions: Record<string, AquaFunction>
|
||||
functionCall?: AquaFunction
|
||||
errors: string[]
|
||||
}
|
||||
|
||||
export class Input {
|
||||
constructor(input: string);
|
||||
|
||||
input: string
|
||||
}
|
||||
|
||||
export class Path {
|
||||
constructor(path: string);
|
||||
|
||||
path: string
|
||||
}
|
||||
|
||||
export class Call {
|
||||
constructor(functionCall: string,
|
||||
arguments: any,
|
||||
input: Input | Path);
|
||||
|
||||
functionCall: string
|
||||
arguments: any
|
||||
input: Input | Path
|
||||
}
|
||||
|
||||
export class Compiler {
|
||||
compile(input: Input | Path | Call, imports: string[], config?: AquaConfig): Promise<CompilationResult>;
|
||||
}
|
||||
|
||||
export var Aqua: Compiler;
|
@ -1 +0,0 @@
|
||||
const metaUrl = ""
|
13003
api/aqua-api-npm/package-lock.json
generated
13003
api/aqua-api-npm/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,3 +0,0 @@
|
||||
# Aqua API
|
||||
|
||||
[Documentation](https://fluence.dev/docs/aqua-book/aqua-js-api)
|
@ -1,233 +0,0 @@
|
||||
package aqua.api
|
||||
|
||||
import aqua.ErrorRendering.showError
|
||||
import aqua.api.types.{AquaAPIConfig, AquaConfig, AquaFunction, CompilationResult, Input}
|
||||
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.{CallInfo, CallPreparer, CliFunc, FuncCompiler, RunPreparer}
|
||||
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.semantics.{CompilerState, HeaderError, RulesViolated, WrongAST}
|
||||
import aqua.{AquaIO, SpanParser}
|
||||
import aqua.model.transform.{Transform, TransformConfig}
|
||||
import aqua.backend.api.APIBackend
|
||||
import cats.data.{Chain, NonEmptyChain, Validated, ValidatedNec}
|
||||
import cats.data.Validated.{Invalid, Valid, invalidNec, validNec}
|
||||
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.show.*
|
||||
import cats.syntax.traverse.*
|
||||
import fs2.io.file.{Files, Path}
|
||||
import scribe.Logging
|
||||
|
||||
import scala.concurrent.ExecutionContext.Implicits.global
|
||||
import scala.concurrent.Future
|
||||
import scala.scalajs.js.|
|
||||
import scala.scalajs.js
|
||||
import scala.scalajs.js.JSConverters.*
|
||||
import scala.scalajs.js.annotation.*
|
||||
import scala.scalajs.js.{UndefOr, undefined}
|
||||
import aqua.js.{FunctionDefJs, ServiceDefJs, VarJson}
|
||||
import aqua.model.AquaContext
|
||||
import aqua.raw.ops.CallArrowRawTag
|
||||
import aqua.raw.value.{LiteralRaw, VarRaw}
|
||||
import aqua.res.AquaRes
|
||||
import cats.Applicative
|
||||
|
||||
@JSExportTopLevel("Aqua")
|
||||
object AquaAPI extends App with Logging {
|
||||
|
||||
def getTag(serviceId: String, value: VarRaw) = {
|
||||
CallArrowRawTag.service(
|
||||
LiteralRaw.quote(serviceId),
|
||||
value.name,
|
||||
Call(List.empty, List(Call.Export(value.name, value.baseType)))
|
||||
)
|
||||
}
|
||||
|
||||
@JSExport
|
||||
def compile(
|
||||
input: types.Input | types.Path | types.Call,
|
||||
imports: js.Array[String],
|
||||
aquaConfigJS: js.UndefOr[AquaConfig]
|
||||
) = {
|
||||
val aquaConfig: AquaAPIConfig =
|
||||
aquaConfigJS.toOption.map(cjs => AquaAPIConfig.fromJS(cjs)).getOrElse(AquaAPIConfig())
|
||||
|
||||
val importsList = imports.toList
|
||||
|
||||
input match {
|
||||
case i: types.Input => compileString(i.input, importsList, aquaConfig)
|
||||
case p: types.Path => compilePath(p.path, importsList, aquaConfig)
|
||||
case c: types.Call =>
|
||||
val path = c.input match {
|
||||
case i: types.Input => i.input
|
||||
case p: types.Path => p.path
|
||||
}
|
||||
compileCall(c.functionCall, c.arguments, path, importsList, aquaConfig)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
def compileCall(
|
||||
functionStr: String,
|
||||
arguments: js.Dynamic,
|
||||
pathStr: String,
|
||||
imports: List[String],
|
||||
aquaConfig: AquaAPIConfig
|
||||
): js.Promise[CompilationResult] = {
|
||||
implicit val aio: AquaIO[IO] = new AquaFilesIO[IO]
|
||||
(
|
||||
LogLevels.levelFromString(aquaConfig.logLevel),
|
||||
Constants.parse(aquaConfig.constants)
|
||||
).mapN { (level, constants) =>
|
||||
|
||||
val transformConfig = aquaConfig.getTransformConfig.copy(constants = constants)
|
||||
|
||||
LogFormatter.initLogger(Some(level))
|
||||
|
||||
new FuncCompiler[IO](
|
||||
Some(RelativePath(Path(pathStr))),
|
||||
imports.map(Path.apply),
|
||||
transformConfig
|
||||
).compile()
|
||||
.map { contextV =>
|
||||
contextV.andThen { context =>
|
||||
CliFunc
|
||||
.fromString(functionStr)
|
||||
.leftMap(errs => NonEmptyChain.fromNonEmptyList(errs))
|
||||
.andThen { cliFunc =>
|
||||
FuncCompiler.findFunction(context, cliFunc).andThen { arrow =>
|
||||
VarJson.checkDataGetServices(cliFunc.args, Some(arguments)).andThen {
|
||||
case (argsWithTypes, _) =>
|
||||
val func = cliFunc.copy(args = argsWithTypes)
|
||||
val preparer = new RunPreparer(
|
||||
func,
|
||||
arrow,
|
||||
transformConfig
|
||||
)
|
||||
preparer.prepare().map { ci =>
|
||||
AquaFunction(FunctionDefJs(ci.definitions), ci.air)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.flatMap {
|
||||
case Valid(result) => IO.pure(CompilationResult.result(js.Dictionary(), js.Dictionary(), Some(result)))
|
||||
case Invalid(err) =>
|
||||
val errs = err.map(_.show).distinct.toChain.toList
|
||||
IO.pure(CompilationResult.errs(errs))
|
||||
}
|
||||
.unsafeToFuture()
|
||||
.toJSPromise
|
||||
} match {
|
||||
case Valid(pr) => pr
|
||||
case Invalid(err) => js.Promise.resolve(CompilationResult.errs(err.toList))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
def compilePath(
|
||||
pathStr: String,
|
||||
imports: List[String],
|
||||
aquaConfig: AquaAPIConfig
|
||||
): js.Promise[CompilationResult] = {
|
||||
implicit val aio: AquaIO[IO] = new AquaFilesIO[IO]
|
||||
val path = Path(pathStr)
|
||||
val sources = new AquaFileSources[IO](path, imports.map(Path.apply))
|
||||
compileRaw(aquaConfig, sources)
|
||||
}
|
||||
|
||||
def compileString(
|
||||
input: String,
|
||||
imports: List[String],
|
||||
aquaConfig: AquaAPIConfig
|
||||
): js.Promise[CompilationResult] = {
|
||||
implicit val aio: AquaIO[IO] = new AquaFilesIO[IO]
|
||||
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))))
|
||||
}
|
||||
}
|
||||
compileRaw(aquaConfig, strSources)
|
||||
}
|
||||
|
||||
def compileRaw(
|
||||
aquaConfig: AquaAPIConfig,
|
||||
sources: AquaSources[IO, AquaFileError, FileModuleId]
|
||||
): js.Promise[CompilationResult] = {
|
||||
|
||||
(
|
||||
LogLevels.levelFromString(aquaConfig.logLevel),
|
||||
Constants.parse(aquaConfig.constants)
|
||||
).mapN { (level, constants) =>
|
||||
|
||||
LogFormatter.initLogger(Some(level))
|
||||
|
||||
val config = AquaCompilerConf(constants)
|
||||
val transformConfig = aquaConfig.getTransformConfig
|
||||
|
||||
val proc = for {
|
||||
res <- CompilerAPI
|
||||
.compile[IO, AquaFileError, FileModuleId, FileSpan.F](
|
||||
sources,
|
||||
SpanParser.parser,
|
||||
new AirValidator[IO] {
|
||||
override def init(): IO[Unit] = Applicative[IO].pure(())
|
||||
override def validate(airs: List[AirFunction]): IO[ValidatedNec[String, Unit]] =
|
||||
Applicative[IO].pure(validNec(()))
|
||||
},
|
||||
new Backend.Transform:
|
||||
override def transform(ex: AquaContext): AquaRes =
|
||||
Transform.contextRes(ex, transformConfig)
|
||||
|
||||
override def generate(aqua: AquaRes): Seq[Generated] = APIBackend.generate(aqua)
|
||||
,
|
||||
config
|
||||
)
|
||||
jsResult <- res match {
|
||||
case Valid(compiled) =>
|
||||
val allGenerated: List[Generated] = compiled.toList.flatMap(_.compiled)
|
||||
val serviceDefs = allGenerated.flatMap(_.services).map(s => s.name -> ServiceDefJs(s))
|
||||
val functions = allGenerated.flatMap(
|
||||
_.air.map(as => (as.name, AquaFunction(FunctionDefJs(as.funcDef), as.air)))
|
||||
)
|
||||
|
||||
IO.pure(
|
||||
CompilationResult.result(
|
||||
js.Dictionary.apply(serviceDefs: _*),
|
||||
js.Dictionary.apply(functions: _*),
|
||||
None
|
||||
)
|
||||
)
|
||||
case Invalid(errChain) =>
|
||||
val errors = errChain.map(_.show).distinct.toChain.toList
|
||||
IO.pure[CompilationResult](CompilationResult.errs(errors))
|
||||
}
|
||||
} yield {
|
||||
jsResult
|
||||
}
|
||||
|
||||
proc.unsafeToFuture().toJSPromise
|
||||
} match {
|
||||
case Valid(pr) => pr
|
||||
case Invalid(err) => js.Promise.resolve(CompilationResult.errs(err.toList))
|
||||
}
|
||||
}
|
||||
}
|
@ -1,103 +0,0 @@
|
||||
package aqua.api.types
|
||||
|
||||
import aqua.api.*
|
||||
import aqua.js.{FunctionDefJs, ServiceDefJs}
|
||||
import aqua.model.transform.TransformConfig
|
||||
|
||||
import scala.scalajs.js
|
||||
import scala.scalajs.js.annotation.{JSExport, JSExportTopLevel}
|
||||
import scala.scalajs.js.|
|
||||
import scala.scalajs.js.JSConverters.*
|
||||
|
||||
@JSExportTopLevel("AquaFunction")
|
||||
case class AquaFunction(
|
||||
@JSExport
|
||||
funcDef: FunctionDefJs,
|
||||
@JSExport
|
||||
script: String
|
||||
)
|
||||
|
||||
@JSExportTopLevel("Input")
|
||||
class Input(
|
||||
@JSExport
|
||||
val input: String
|
||||
)
|
||||
|
||||
@JSExportTopLevel("Path")
|
||||
class Path(
|
||||
@JSExport
|
||||
val path: String
|
||||
)
|
||||
|
||||
@JSExportTopLevel("Call")
|
||||
class Call(
|
||||
@JSExport
|
||||
val functionCall: String,
|
||||
@JSExport
|
||||
val arguments: js.Dynamic,
|
||||
@JSExport
|
||||
val input: Path | Input
|
||||
)
|
||||
|
||||
@JSExportTopLevel("AquaConfig")
|
||||
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]
|
||||
)
|
||||
|
||||
@JSExportTopLevel("CompilationResult")
|
||||
class CompilationResult(
|
||||
@JSExport
|
||||
val services: js.Dictionary[ServiceDefJs],
|
||||
@JSExport
|
||||
val functions: js.Dictionary[AquaFunction],
|
||||
@JSExport
|
||||
val functionCall: js.UndefOr[AquaFunction],
|
||||
@JSExport
|
||||
val errors: js.Array[String]
|
||||
)
|
||||
|
||||
object CompilationResult {
|
||||
|
||||
def result(
|
||||
services: js.Dictionary[ServiceDefJs],
|
||||
functions: js.Dictionary[AquaFunction],
|
||||
call: Option[AquaFunction]
|
||||
): CompilationResult =
|
||||
new CompilationResult(services, functions, call.orNull, js.Array())
|
||||
|
||||
def errs(
|
||||
errors: List[String]
|
||||
): CompilationResult =
|
||||
CompilationResult(js.Dictionary(), js.Dictionary(), null, errors.toJSArray)
|
||||
}
|
||||
|
||||
case class AquaAPIConfig(
|
||||
logLevel: String = "info",
|
||||
constants: List[String] = Nil,
|
||||
noXor: Boolean = false,
|
||||
noRelay: Boolean = false
|
||||
) {
|
||||
|
||||
def getTransformConfig: TransformConfig =
|
||||
if (noRelay) TransformConfig(relayVarName = None, wrapWithXor = !noXor)
|
||||
else TransformConfig(wrapWithXor = !noXor)
|
||||
}
|
||||
|
||||
object AquaAPIConfig {
|
||||
|
||||
def fromJS(cjs: AquaConfig): AquaAPIConfig = {
|
||||
AquaAPIConfig(
|
||||
cjs.logLevel.getOrElse("info"),
|
||||
cjs.constants.map(_.toList).getOrElse(Nil),
|
||||
cjs.noXor.getOrElse(false),
|
||||
cjs.noRelay.getOrElse(false)
|
||||
)
|
||||
}
|
||||
}
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
@ -7,7 +23,7 @@ import aqua.model.transform.{Transform, TransformConfig}
|
||||
import aqua.model.{FuncArrow, ValueModel, VarModel}
|
||||
import aqua.parser.lexer.CallArrowToken
|
||||
import aqua.parser.lift.Span
|
||||
import aqua.raw.ops.{Call, CallArrowRawTag, FuncOp, SeqTag}
|
||||
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}
|
||||
@ -18,7 +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
|
||||
@ -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,
|
||||
|
@ -1,71 +1,90 @@
|
||||
/*
|
||||
* 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}
|
||||
import aqua.parser.lift.Span
|
||||
import aqua.raw.value.{CollectionRaw, LiteralRaw, ValueRaw, VarRaw}
|
||||
import aqua.types.{ArrayType, BottomType}
|
||||
import cats.data.{NonEmptyList, Validated, ValidatedNel}
|
||||
import cats.data.Validated.{invalid, invalidNel, validNel}
|
||||
import cats.{Id, ~>}
|
||||
import cats.syntax.traverse.*
|
||||
import aqua.types.*
|
||||
|
||||
case class CliFunc(name: String, args: List[ValueRaw] = Nil, ability: Option[String] = None)
|
||||
import cats.data.Validated.{invalid, invalidNec, validNec}
|
||||
import cats.data.{NonEmptyChain, NonEmptyList, Validated, ValidatedNec}
|
||||
import cats.syntax.comonad.*
|
||||
import cats.syntax.either.*
|
||||
import cats.syntax.option.*
|
||||
import cats.syntax.traverse.*
|
||||
import cats.syntax.validated.*
|
||||
import cats.{Id, ~>}
|
||||
|
||||
case class CliFunc(name: String, args: List[ValueRaw] = Nil)
|
||||
|
||||
object CliFunc {
|
||||
|
||||
def spanToId: Span.S ~> Id = new (Span.S ~> Id) {
|
||||
private val spanToId: Span.S ~> Id = new (Span.S ~> Id) {
|
||||
|
||||
override def apply[A](span: Span.S[A]): Id[A] = {
|
||||
span._2
|
||||
}
|
||||
override def apply[A](span: Span.S[A]): Id[A] = span.extract
|
||||
}
|
||||
|
||||
def fromString(func: String): ValidatedNel[String, CliFunc] = {
|
||||
CallArrowToken.callArrow.parseAll(func.trim) match {
|
||||
case Right(exprSpan) =>
|
||||
val expr = exprSpan.mapK(spanToId)
|
||||
|
||||
val argsV = expr.args.collect {
|
||||
def fromString(func: String): ValidatedNec[String, CliFunc] = {
|
||||
CallArrowToken.callArrow
|
||||
.parseAll(func.trim)
|
||||
.leftMap(error =>
|
||||
NonEmptyChain
|
||||
.fromNonEmptyList(error.expected)
|
||||
.map(_.context.mkString("\n"))
|
||||
)
|
||||
.toValidated
|
||||
.map(_.mapK(spanToId))
|
||||
.andThen(expr =>
|
||||
expr.args.traverse {
|
||||
case LiteralToken(value, ts) =>
|
||||
validNel(LiteralRaw(value, ts))
|
||||
case VarToken(name, _) =>
|
||||
validNel(VarRaw(name.value, BottomType))
|
||||
LiteralRaw(value, ts).validNec
|
||||
case VarToken(name) =>
|
||||
VarRaw(name.value, BottomType).validNec
|
||||
case CollectionToken(_, values) =>
|
||||
val hasVariables = values.exists {
|
||||
case LiteralToken(_, _) => false
|
||||
case _ => true
|
||||
}
|
||||
if (!hasVariables) {
|
||||
val literals = values.collect { case LiteralToken(value, ts) =>
|
||||
LiteralRaw(value, ts)
|
||||
}
|
||||
val hasSameTypesOrEmpty =
|
||||
literals.isEmpty || literals.map(_.baseType).toSet.size == 1
|
||||
|
||||
if (hasSameTypesOrEmpty) {
|
||||
validNel(
|
||||
NonEmptyList
|
||||
.fromList(literals)
|
||||
.map(l => CollectionRaw(l, ArrayType(l.head.baseType)))
|
||||
.getOrElse(ValueRaw.Nil)
|
||||
)
|
||||
} else
|
||||
invalidNel(
|
||||
"If the argument is an array, then it must contain elements of the same type."
|
||||
)
|
||||
|
||||
} else
|
||||
invalidNel(
|
||||
"Array arguments can only have numbers, strings, or booleans."
|
||||
values.traverse {
|
||||
case LiteralToken(value, ts) =>
|
||||
LiteralRaw(value, ts).some
|
||||
case _ => none
|
||||
}.toValid(
|
||||
"Array elements can only be numbers, strings, or booleans."
|
||||
).ensure(
|
||||
"If the argument is an array, then it must contain elements of the same type."
|
||||
)(_.distinctBy(_.`type`).size <= 1)
|
||||
.map(
|
||||
NonEmptyList
|
||||
.fromList(_)
|
||||
.map(l =>
|
||||
CollectionRaw(
|
||||
l,
|
||||
ArrayType(
|
||||
// FIXME: Type of Literal should always be a DataType
|
||||
l.head.baseType.asInstanceOf[DataType]
|
||||
)
|
||||
)
|
||||
)
|
||||
.getOrElse(ValueRaw.Nil)
|
||||
)
|
||||
.toValidatedNec
|
||||
case CallArrowToken(_, _, _) =>
|
||||
invalidNel("Function calls as arguments are not supported.")
|
||||
}.sequence
|
||||
argsV.andThen(args =>
|
||||
validNel(CliFunc(expr.funcName.value, args, expr.ability.map(_.name)))
|
||||
)
|
||||
|
||||
case Left(err) => invalid(err.expected.map(_.context.mkString("\n")))
|
||||
}
|
||||
"Function calls as arguments are not supported.".invalidNec
|
||||
case _ =>
|
||||
"Unsupported argument.".invalidNec
|
||||
}.map(args => CliFunc(expr.funcName.value, args))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -1,80 +1,86 @@
|
||||
/*
|
||||
* 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.ErrorRendering.showError
|
||||
import aqua.compiler.{AquaCompiler, AquaCompilerConf, 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 cats.data.Validated.{invalidNec, validNec}
|
||||
import cats.data.{Chain, NonEmptyList, Validated, ValidatedNec}
|
||||
import cats.effect.IO
|
||||
import aqua.{AquaIO, SpanParser}
|
||||
|
||||
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.option.*
|
||||
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](
|
||||
sources,
|
||||
SpanParser.parser,
|
||||
config
|
||||
)
|
||||
.map(_.leftMap(_.map(_.show)))
|
||||
CompilerAPI.compileToContext[F, AquaFileError, FileModuleId, FileSpan.F](
|
||||
sources,
|
||||
SpanParser.parser,
|
||||
config
|
||||
)
|
||||
}
|
||||
|
||||
private def compileBuiltins() = {
|
||||
private def compileBuiltins(): F[Result[Chain[AquaContext]]] =
|
||||
for {
|
||||
path <- PackagePath.builtin.getPath()
|
||||
context <- compileToContext(path, Nil)
|
||||
} yield {
|
||||
context
|
||||
}
|
||||
}
|
||||
context <- compileToContext(path)
|
||||
} yield context
|
||||
|
||||
// Compile and get only one function
|
||||
def compile(
|
||||
preludeImports: List[Path] = Nil,
|
||||
withBuiltins: Boolean = false
|
||||
): F[ValidatedNec[String, Chain[AquaContext]]] = {
|
||||
): F[Result[Chain[AquaContext]]] = {
|
||||
for {
|
||||
// compile builtins and add it to context
|
||||
builtinsV <-
|
||||
if (withBuiltins) compileBuiltins()
|
||||
else validNec[String, Chain[AquaContext]](Chain.empty).pure[F]
|
||||
compileResult <- input.map { ap =>
|
||||
else Chain.empty.pure[Result].pure[F]
|
||||
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))
|
||||
)
|
||||
}.getOrElse((Duration.Zero, validNec[String, Chain[AquaContext]](Chain.empty)).pure[F])
|
||||
(compileTime, contextV) = compileResult
|
||||
}
|
||||
(compileTime, contextV) = compileResult.orEmpty
|
||||
} yield {
|
||||
logger.debug(s"Compile time: ${compileTime.toMillis}ms")
|
||||
// add builtins to the end of context
|
||||
contextV.andThen(c => builtinsV.map(bc => c ++ bc))
|
||||
(contextV, builtinsV).mapN(_ ++ _)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -84,16 +90,9 @@ object FuncCompiler {
|
||||
def findFunction(
|
||||
contexts: Chain[AquaContext],
|
||||
func: CliFunc
|
||||
): ValidatedNec[String, FuncArrow] =
|
||||
func.ability
|
||||
.fold(
|
||||
contexts
|
||||
.collectFirstSome(_.allFuncs.get(func.name))
|
||||
)(ab => contexts.collectFirstSome(_.abilities.get(ab).flatMap(_.allFuncs.get(func.name))))
|
||||
.map(validNec)
|
||||
.getOrElse(
|
||||
Validated.invalidNec[String, FuncArrow](
|
||||
s"There is no function '${func.ability.map(_ + ".").getOrElse("")}${func.name}' or it is not exported. Check the spelling or see https://fluence.dev/docs/aqua-book/language/header/#export"
|
||||
)
|
||||
)
|
||||
): ValidatedNec[String, FuncArrow] = contexts
|
||||
.collectFirstSome(_.allFuncs.get(func.name))
|
||||
.toValidNec(
|
||||
s"There is no function '${func.name}' or it is not exported. Check the spelling or see https://fluence.dev/docs/aqua-book/language/header/#export"
|
||||
)
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -1,15 +1,31 @@
|
||||
/*
|
||||
* 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
|
||||
import aqua.parser.lift.Span
|
||||
import aqua.raw.ops.{Call, CallArrowRawTag, FuncOp, SeqTag}
|
||||
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
|
||||
|
||||
@ -101,9 +116,10 @@ class RunPreparer(
|
||||
val returnCodomain = ProductType(results.map(_.`type`))
|
||||
|
||||
// arguments is only variables, without literals
|
||||
val argumentsType = ProductType.labelled(func.args.zip(funcCallable.arrowType.domain.labelledData).collect {
|
||||
case (VarRaw(name, _), (_, t)) => (name, t)
|
||||
})
|
||||
val argumentsType =
|
||||
ProductType.labelled(func.args.zip(funcCallable.arrowType.domain.labelledData).collect {
|
||||
case (VarRaw(name, _), (_, t)) => (name, t)
|
||||
})
|
||||
|
||||
FuncArrow(
|
||||
func.name + "Run",
|
||||
|
@ -1,7 +1,24 @@
|
||||
/*
|
||||
* 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}
|
||||
import aqua.types.*
|
||||
|
||||
import cats.data.Validated.{invalidNec, validNec}
|
||||
import cats.data.{Validated, ValidatedNec}
|
||||
import cats.effect.kernel.Async
|
||||
@ -10,14 +27,11 @@ import cats.syntax.flatMap.*
|
||||
import cats.syntax.partialOrder.*
|
||||
import cats.syntax.show.*
|
||||
import cats.syntax.traverse.*
|
||||
|
||||
import scala.collection.immutable.SortedMap
|
||||
import scala.concurrent.ExecutionContext
|
||||
|
||||
object TypeValidator {
|
||||
|
||||
import aqua.types.Type.typesPartialOrder
|
||||
|
||||
/**
|
||||
* Compare and validate type from Aqua file and type generated from JSON.
|
||||
* Also, the validation will succeed if the JSON type is missing an array or an optional field.
|
||||
@ -69,7 +83,7 @@ object TypeValidator {
|
||||
case (l: OptionType, r) =>
|
||||
// if we have ?[][]string and [][][]string it must throw an error
|
||||
validateTypes(name, l.element, Some(r), Some((l, r)))
|
||||
case (l: BoxType, r: BoxType) =>
|
||||
case (l: CollectionType, r: CollectionType) =>
|
||||
validateTypes(name, l.element, Some(r.element), fullOptionType.orElse(Some(l, r)))
|
||||
|
||||
case (l, r) =>
|
||||
|
@ -1,9 +1,14 @@
|
||||
module Import3 declares *
|
||||
aqua StreamMapTest declares *
|
||||
|
||||
export foo_bar
|
||||
export main
|
||||
|
||||
use "export.aqua"
|
||||
func foo() -> %string, u64:
|
||||
map: %string
|
||||
<- map, 42
|
||||
|
||||
func foo_bar() -> string, string:
|
||||
z <- FooBars.foo()
|
||||
<- z, FooBars.DECLARE_CONST2
|
||||
func get() -> string, string:
|
||||
<- "123", "44"
|
||||
|
||||
func main() -> string:
|
||||
m <- foo()
|
||||
<- m.get("key")!
|
@ -1,3 +1,5 @@
|
||||
aqua Builtin declares *
|
||||
|
||||
-- Default public interface of Fluence nodes
|
||||
|
||||
alias Field : []string
|
||||
|
@ -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
|
@ -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"
|
@ -1,3 +1,5 @@
|
||||
aqua One
|
||||
|
||||
service OneMore:
|
||||
more_call()
|
||||
consume(s: string)
|
@ -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"
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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
|
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
@ -24,6 +40,8 @@ object Keyword {
|
||||
|
||||
case object Ap extends Keyword("ap")
|
||||
|
||||
case object Fail extends Keyword("fail")
|
||||
|
||||
case object Canon extends Keyword("canon")
|
||||
|
||||
case object Seq extends Keyword("seq")
|
||||
@ -46,8 +64,6 @@ object DataView {
|
||||
|
||||
case class Variable(name: String) extends DataView
|
||||
|
||||
case class Stream(name: String) extends DataView
|
||||
|
||||
case class VarLens(name: String, lens: String, isField: Boolean = true) extends DataView {
|
||||
def append(sublens: String): VarLens = copy(lens = lens + sublens)
|
||||
}
|
||||
@ -57,7 +73,6 @@ object DataView {
|
||||
case InitPeerId ⇒ "%init_peer_id%"
|
||||
case LastError ⇒ "%last_error%"
|
||||
case Variable(name) ⇒ name
|
||||
case Stream(name) ⇒ name
|
||||
case VarLens(name, lens, isField) ⇒
|
||||
if (isField) name + ".$" + lens
|
||||
else name + lens
|
||||
@ -90,7 +105,12 @@ object Air {
|
||||
|
||||
case class Next(label: String) extends Air(Keyword.Next)
|
||||
|
||||
case class Fold(iterable: DataView, label: String, instruction: Air, lastNextInstruction: Option[Air]) extends Air(Keyword.Fold)
|
||||
case class Fold(
|
||||
iterable: DataView,
|
||||
label: String,
|
||||
instruction: Air,
|
||||
lastNextInstruction: Air
|
||||
) extends Air(Keyword.Fold)
|
||||
|
||||
case class Match(left: DataView, right: DataView, instruction: Air) extends Air(Keyword.Match)
|
||||
|
||||
@ -106,46 +126,87 @@ object Air {
|
||||
case class Call(triplet: Triplet, args: List[DataView], result: Option[String])
|
||||
extends Air(Keyword.Call)
|
||||
|
||||
case class ApStreamMap(key: DataView, op: DataView, result: String) extends Air(Keyword.Ap)
|
||||
|
||||
case class Ap(op: DataView, result: String) extends Air(Keyword.Ap)
|
||||
|
||||
case class Fail(op: DataView) extends Air(Keyword.Fail)
|
||||
|
||||
case class Canon(op: DataView, peerId: DataView, result: String) extends Air(Keyword.Canon)
|
||||
|
||||
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 = lastInst.map(a => show(depth + 1, a)).getOrElse("")
|
||||
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.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, _))
|
||||
|
@ -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}
|
||||
|
@ -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, StreamType}
|
||||
import aqua.types.{ArrayType, CanonStreamMapType, CanonStreamType, StreamMapType, StreamType, Type}
|
||||
import cats.Eval
|
||||
import cats.data.Chain
|
||||
import cats.free.Cofree
|
||||
@ -26,14 +42,19 @@ object AirGen extends Logging {
|
||||
s".[$idx]${propertyToString(tail)}"
|
||||
}
|
||||
|
||||
def varNameToString(name: String, `type`: Type): String =
|
||||
(`type` match {
|
||||
case _: StreamType => "$" + name
|
||||
case _: CanonStreamType => "#$" + name
|
||||
case _: CanonStreamMapType => "#%" + name
|
||||
case _: StreamMapType => "%" + name
|
||||
case _ => name
|
||||
}).replace('.', '_')
|
||||
|
||||
def valueToData(vm: ValueModel): DataView = vm match {
|
||||
case LiteralModel(value, _) => DataView.StringScalar(value)
|
||||
case VarModel(name, t, property) =>
|
||||
val n = (t match {
|
||||
case _: StreamType => "$" + name
|
||||
case _: CanonStreamType => "#" + name
|
||||
case _ => name
|
||||
}).replace('.', '_')
|
||||
val n = varNameToString(name, t)
|
||||
if (property.isEmpty) DataView.Variable(n)
|
||||
else {
|
||||
val functors = property.find {
|
||||
@ -51,10 +72,8 @@ object AirGen extends Logging {
|
||||
}
|
||||
|
||||
def exportToString(exportTo: CallModel.Export): String = (exportTo match {
|
||||
case CallModel.Export(name, _: StreamType) => "$" + name
|
||||
case CallModel.Export(name, _: CanonStreamType) => "#" + name
|
||||
case CallModel.Export(name, _) => name
|
||||
}).replace('.', '_')
|
||||
case CallModel.Export(name, t) => varNameToString(name, t)
|
||||
})
|
||||
|
||||
private def folder(op: ResolvedOp, ops: Chain[AirGen]): Eval[AirGen] =
|
||||
op match {
|
||||
@ -92,13 +111,13 @@ object AirGen extends Logging {
|
||||
)
|
||||
|
||||
case FoldRes(item, iterable, mode) =>
|
||||
val m = mode.map {
|
||||
case ForModel.NullMode => NullGen
|
||||
case ForModel.NeverMode => NeverGen
|
||||
val m = mode match {
|
||||
case FoldRes.Mode.Null => NullGen
|
||||
case FoldRes.Mode.Never => NeverGen
|
||||
}
|
||||
Eval later ForGen(valueToData(iterable), item, opsToSingle(ops), m)
|
||||
case RestrictionRes(item, isStream) =>
|
||||
Eval later NewGen(item, isStream, opsToSingle(ops))
|
||||
case RestrictionRes(item, itemType) =>
|
||||
Eval later NewGen(varNameToString(item, itemType), opsToSingle(ops))
|
||||
case CallServiceRes(serviceId, funcName, CallRes(args, exportTo), peerId) =>
|
||||
Eval.later(
|
||||
ServiceCallGen(
|
||||
@ -110,11 +129,20 @@ object AirGen extends Logging {
|
||||
)
|
||||
)
|
||||
|
||||
case ApStreamMapRes(key, value, exportTo) =>
|
||||
Eval.later(
|
||||
ApStreamMapGen(valueToData(key), valueToData(value), exportToString(exportTo))
|
||||
)
|
||||
case ApRes(operand, exportTo) =>
|
||||
Eval.later(
|
||||
ApGen(valueToData(operand), exportToString(exportTo))
|
||||
)
|
||||
|
||||
case FailRes(operand) =>
|
||||
Eval.later(
|
||||
FailGen(valueToData(operand))
|
||||
)
|
||||
|
||||
case CanonRes(operand, peerId, exportTo) =>
|
||||
Eval.later(
|
||||
CanonGen(valueToData(operand), valueToData(peerId), exportToString(exportTo))
|
||||
@ -155,12 +183,24 @@ case class CommentGen(comment: String, op: AirGen) extends AirGen {
|
||||
Air.Comment(comment, op.generate)
|
||||
}
|
||||
|
||||
case class ApStreamMapGen(key: DataView, operand: DataView, result: String) extends AirGen {
|
||||
|
||||
override def generate: Air =
|
||||
Air.ApStreamMap(key, operand, result)
|
||||
}
|
||||
|
||||
case class ApGen(operand: DataView, result: String) extends AirGen {
|
||||
|
||||
override def generate: Air =
|
||||
Air.Ap(operand, result)
|
||||
}
|
||||
|
||||
case class FailGen(operand: DataView) extends AirGen {
|
||||
|
||||
override def generate: Air =
|
||||
Air.Fail(operand)
|
||||
}
|
||||
|
||||
case class CanonGen(operand: DataView, peerId: DataView, result: String) extends AirGen {
|
||||
|
||||
override def generate: Air =
|
||||
@ -179,14 +219,16 @@ case class MatchMismatchGen(
|
||||
else Air.Mismatch(left, right, body.generate)
|
||||
}
|
||||
|
||||
case class ForGen(iterable: DataView, item: String, body: AirGen, mode: Option[AirGen]) extends AirGen {
|
||||
override def generate: Air = Air.Fold(iterable, item, body.generate, mode.map(_.generate))
|
||||
case class ForGen(iterable: DataView, item: String, body: AirGen, mode: AirGen) extends AirGen {
|
||||
override def generate: Air = Air.Fold(iterable, item, body.generate, mode.generate)
|
||||
}
|
||||
|
||||
case class NewGen(item: String, isStream: Boolean, body: AirGen) extends AirGen {
|
||||
case class NewGen(name: String, body: AirGen) extends AirGen {
|
||||
|
||||
override def generate: Air =
|
||||
Air.New(if (isStream) DataView.Stream("$" + item) else DataView.Variable(item), body.generate)
|
||||
override def generate: Air = Air.New(
|
||||
DataView.Variable(name),
|
||||
body.generate
|
||||
)
|
||||
}
|
||||
|
||||
case class NextGen(item: String) extends AirGen {
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -1,12 +1,28 @@
|
||||
/*
|
||||
* 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.*
|
||||
import aqua.res.FuncRes
|
||||
import aqua.types.*
|
||||
import aqua.definitions.*
|
||||
|
||||
import io.circe.*
|
||||
import io.circe.parser.*
|
||||
import io.circe.syntax.*
|
||||
|
||||
import scala.annotation.tailrec
|
||||
|
||||
// Represents the Aqua types
|
||||
@ -16,7 +32,7 @@ sealed trait TypeDefinition {
|
||||
|
||||
object TypeDefinition {
|
||||
|
||||
implicit val encodeProdDefType: Encoder[ProductTypeDef] = {
|
||||
given Encoder[ProductTypeDef] = {
|
||||
case d @ LabeledProductTypeDef(fields) =>
|
||||
Json.obj(
|
||||
("tag", Json.fromString(d.tag)),
|
||||
@ -33,7 +49,7 @@ object TypeDefinition {
|
||||
)
|
||||
}
|
||||
|
||||
implicit val encodeDefType: Encoder[TypeDefinition] = {
|
||||
given Encoder[TypeDefinition] = {
|
||||
case d @ ScalarTypeDef(name) =>
|
||||
Json.obj(
|
||||
("tag", Json.fromString(d.tag)),
|
||||
@ -68,14 +84,14 @@ object TypeDefinition {
|
||||
)
|
||||
}
|
||||
|
||||
implicit val encodeServiceDefType: Encoder[ServiceDef] = { case ServiceDef(sId, functions, name) =>
|
||||
given Encoder[ServiceDef] = { case ServiceDef(sId, functions, name) =>
|
||||
Json.obj(
|
||||
("defaultServiceId", sId.asJson),
|
||||
("functions", encodeProdDefType(functions))
|
||||
("functions", (functions: ProductTypeDef).asJson)
|
||||
)
|
||||
}
|
||||
|
||||
implicit val encodeNamesConfig: Encoder[NamesConfig] = { case n: NamesConfig =>
|
||||
given Encoder[NamesConfig] = { case n: NamesConfig =>
|
||||
import n.*
|
||||
Json.obj(
|
||||
("relay", Json.fromString(relay)),
|
||||
@ -88,13 +104,12 @@ object TypeDefinition {
|
||||
)
|
||||
}
|
||||
|
||||
implicit val encodeFunctionDefType: Encoder[FunctionDef] = {
|
||||
case FunctionDef(fName, arrow, names) =>
|
||||
Json.obj(
|
||||
("functionName", Json.fromString(fName)),
|
||||
("arrow", encodeDefType(arrow)),
|
||||
("names", names.asJson)
|
||||
)
|
||||
given Encoder[FunctionDef] = { case FunctionDef(fName, arrow, names) =>
|
||||
Json.obj(
|
||||
("functionName", Json.fromString(fName)),
|
||||
("arrow", (arrow: TypeDefinition).asJson),
|
||||
("names", names.asJson)
|
||||
)
|
||||
}
|
||||
|
||||
def apply(t: Option[Type]): TypeDefinition = t.map(apply).getOrElse(NilTypeDef)
|
||||
@ -103,9 +118,12 @@ object TypeDefinition {
|
||||
t match {
|
||||
case OptionType(t) =>
|
||||
OptionTypeDef(TypeDefinition(t))
|
||||
case t: BoxType => ArrayTypeDef(TypeDefinition(t.element))
|
||||
case t: CollectionType => ArrayTypeDef(TypeDefinition(t.element))
|
||||
case StructType(name, fields) =>
|
||||
StructTypeDef(name, fields.toSortedMap.view.mapValues(TypeDefinition.apply).toMap)
|
||||
case AbilityType(name, fieldAndArrows) =>
|
||||
// TODO: change in union with JS side
|
||||
StructTypeDef(name, fieldAndArrows.toSortedMap.view.mapValues(TypeDefinition.apply).toMap)
|
||||
case t: ScalarType => ScalarTypeDef.fromScalar(t)
|
||||
case t: LiteralType => ScalarTypeDef.fromLiteral(t)
|
||||
case t: ProductType => ProductTypeDef(t)
|
||||
@ -195,7 +213,11 @@ case class NamesConfig(
|
||||
)
|
||||
|
||||
// Describes service
|
||||
case class ServiceDef(defaultServiceId: Option[String], functions: LabeledProductTypeDef, name: String)
|
||||
case class ServiceDef(
|
||||
defaultServiceId: Option[String],
|
||||
functions: LabeledProductTypeDef,
|
||||
name: String
|
||||
)
|
||||
|
||||
// Describes top-level function
|
||||
case class FunctionDef(
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
@ -21,13 +37,13 @@ object Header {
|
||||
val callParams =
|
||||
if (isJs) ""
|
||||
else
|
||||
"import type { IFluenceClient as IFluenceClient$$, CallParams as CallParams$$ } from '@fluencelabs/js-client.api';"
|
||||
"import type { IFluenceClient as IFluenceClient$$, CallParams as CallParams$$ } from '@fluencelabs/js-client';"
|
||||
|
||||
s"""$callParams
|
||||
|import {
|
||||
| v5_callFunction as callFunction$$$$,
|
||||
| v5_registerService as registerService$$$$,
|
||||
|} from '@fluencelabs/js-client.api';
|
||||
|} from '@fluencelabs/js-client';
|
||||
""".stripMargin
|
||||
}
|
||||
|
||||
|
@ -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}
|
||||
|
@ -1,10 +1,29 @@
|
||||
/*
|
||||
* 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
|
||||
import aqua.backend.ts.TypeScriptCommon.fixupArgName
|
||||
import aqua.backend.ts.{TSFuncTypes, TypeScriptCommon}
|
||||
import aqua.definitions.*
|
||||
import aqua.definitions.TypeDefinition.given
|
||||
import aqua.res.FuncRes
|
||||
import aqua.types.*
|
||||
|
||||
import cats.syntax.show.*
|
||||
import io.circe.*
|
||||
import io.circe.parser.*
|
||||
@ -20,8 +39,6 @@ case class OutputFunc(func: FuncRes, types: Types) {
|
||||
val funcTypes = types.funcType(func)
|
||||
|
||||
import funcTypes.*
|
||||
import aqua.definitions.TypeDefinition.*
|
||||
import aqua.definitions.*
|
||||
|
||||
def generate: (AirFunction, String) = {
|
||||
val tsAir = FuncAirGen(func).generate
|
||||
|
@ -1,8 +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.backend
|
||||
|
||||
import aqua.backend.ts.TypeScriptCommon
|
||||
import aqua.definitions.*
|
||||
import aqua.definitions.TypeDefinition.given
|
||||
import aqua.res.ServiceRes
|
||||
import aqua.types.ArrowType
|
||||
|
||||
import io.circe.*
|
||||
import io.circe.parser.*
|
||||
import io.circe.syntax.*
|
||||
@ -14,8 +33,6 @@ case class OutputService(srv: ServiceRes, types: Types) {
|
||||
private val serviceTypes = types.serviceType(srv)
|
||||
|
||||
import serviceTypes.*
|
||||
import aqua.definitions.TypeDefinition.*
|
||||
import aqua.definitions.*
|
||||
|
||||
def generate: String =
|
||||
val functions = LabeledProductTypeDef(
|
||||
|
@ -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}
|
||||
|
@ -1,13 +1,26 @@
|
||||
/*
|
||||
* 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
|
||||
import aqua.backend.*
|
||||
import aqua.res.AquaRes
|
||||
|
||||
case class JavaScriptBackend(isOldFluenceJs: Boolean, client: String = Backend.client) extends Backend {
|
||||
|
||||
val ext = ".js"
|
||||
val tsExt = ".d.ts"
|
||||
case class JavaScriptBackend(isOldFluenceJs: Boolean = false, client: String = Backend.client) extends Backend {
|
||||
val types = TypeScriptTypes(client)
|
||||
|
||||
def typesFile(res: AquaRes): Generated = {
|
||||
@ -31,13 +44,18 @@ case class JavaScriptBackend(isOldFluenceJs: Boolean, client: String = Backend.c
|
||||
|
|
||||
|/* eslint-enable */""".stripMargin
|
||||
|
||||
Generated(tsExt, body, Nil)
|
||||
Generated(JavaScriptBackend.dtsExt, body, Nil)
|
||||
}
|
||||
|
||||
override def generate(res: AquaRes): Seq[Generated] =
|
||||
if (res.isEmpty) Nil
|
||||
else {
|
||||
val (airs, script) = OutputFile(res).generate(EmptyTypes, true, isOldFluenceJs)
|
||||
Generated(ext, script, airs) :: typesFile(res) :: Nil
|
||||
Generated(JavaScriptBackend.ext, script, airs) :: typesFile(res) :: Nil
|
||||
}
|
||||
}
|
||||
|
||||
object JavaScriptBackend {
|
||||
val ext = ".js"
|
||||
val dtsExt = ".d.ts"
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -1,17 +1,35 @@
|
||||
/*
|
||||
* 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}
|
||||
import aqua.res.AquaRes
|
||||
import cats.data.NonEmptyChain
|
||||
|
||||
case class TypeScriptBackend(isOldFluenceJs: Boolean, client: String = Backend.client) extends Backend {
|
||||
|
||||
val ext = ".ts"
|
||||
case class TypeScriptBackend(isOldFluenceJs: Boolean = false, client: String = Backend.client) extends Backend {
|
||||
|
||||
override def generate(res: AquaRes): Seq[Generated] =
|
||||
if (res.isEmpty) Nil
|
||||
else {
|
||||
val (airs, script) = OutputFile(res).generate(TypeScriptTypes(client), false, isOldFluenceJs)
|
||||
Generated(ext, script, airs) :: Nil
|
||||
val (airs, script) = OutputFile(res).generate(TypeScriptTypes(client), isJs = false, isOldFluenceJs)
|
||||
Generated(TypeScriptBackend.ext, script, airs) :: Nil
|
||||
}
|
||||
}
|
||||
|
||||
object TypeScriptBackend {
|
||||
val ext = ".ts"
|
||||
}
|
||||
|
@ -1,6 +1,21 @@
|
||||
/*
|
||||
* 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.air.FuncAirGen
|
||||
import aqua.res.FuncRes
|
||||
import aqua.types.*
|
||||
import cats.syntax.show.*
|
||||
@ -36,14 +51,30 @@ object TypeScriptCommon {
|
||||
"[" + pt.toList.map(typeToTs).mkString(", ") + "]"
|
||||
case st: StructType =>
|
||||
s"{ ${st.fields.map(typeToTs).toNel.map(kv => kv._1 + ": " + kv._2 + ";").toList.mkString(" ")} }"
|
||||
case st: ScalarType if ScalarType.number(st) => "number"
|
||||
case ScalarType.bool => "boolean"
|
||||
case ScalarType.string => "string"
|
||||
case lt: LiteralType if lt.oneOf.exists(ScalarType.number) => "number"
|
||||
case lt: LiteralType if lt.oneOf(ScalarType.bool) => "boolean"
|
||||
case lt: LiteralType if lt.oneOf(ScalarType.string) => "string"
|
||||
case _: DataType => "any"
|
||||
case st: AbilityType =>
|
||||
s"{ ${st.fields.map(typeToTs).toNel.map(kv => kv._1 + ": " + kv._2 + ";").toList.mkString(" ")} }"
|
||||
case st: ScalarType => st match {
|
||||
case st: ScalarType if ScalarType.number(st) => "number"
|
||||
case ScalarType.bool => "boolean"
|
||||
case ScalarType.string => "string"
|
||||
// unreachable
|
||||
case _ => "any"
|
||||
}
|
||||
case lt: LiteralType => lt match {
|
||||
case lt: LiteralType if lt.oneOf.exists(ScalarType.number) => "number"
|
||||
case lt: LiteralType if lt.oneOf(ScalarType.bool) => "boolean"
|
||||
case lt: LiteralType if lt.oneOf(ScalarType.string) => "string"
|
||||
// unreachable
|
||||
case _ => "any"
|
||||
}
|
||||
case at: ArrowType => fnDef(at)
|
||||
case TopType => "any"
|
||||
case BottomType => "nothing"
|
||||
|
||||
// impossible. Made to avoid compilation warning
|
||||
case _: CanonStreamType => "any"
|
||||
case _: StreamMapType => "any"
|
||||
case _: ServiceType => "any"
|
||||
}
|
||||
|
||||
// TODO: handle cases if there is already peer_ or config_ variable defined
|
||||
|
@ -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}
|
||||
|
278
build.sbt
278
build.sbt
@ -1,30 +1,55 @@
|
||||
val dottyVersion = "3.3.0"
|
||||
import BundleJS.*
|
||||
|
||||
scalaVersion := dottyVersion
|
||||
val aquaVersion = "0.14.11"
|
||||
|
||||
val aquaVersion = "0.11.1"
|
||||
|
||||
val catsV = "2.8.0"
|
||||
val catsParseV = "0.3.8"
|
||||
val scalaV = "3.4.2"
|
||||
val catsV = "2.12.0"
|
||||
val catsParseV = "0.3.10"
|
||||
val monocleV = "3.1.0"
|
||||
val scalaTestV = "3.2.16"
|
||||
val fs2V = "3.7.0"
|
||||
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 := dottyVersion,
|
||||
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,123 +61,106 @@ val commons = Seq(
|
||||
"-Ykind-projector"
|
||||
// "-Xfatal-warnings"
|
||||
)
|
||||
}
|
||||
},
|
||||
// Needed to resolve snapshot versions
|
||||
resolvers ++= Resolver.sonatypeOssRepos("snapshots")
|
||||
)
|
||||
|
||||
commons
|
||||
|
||||
lazy val cli = crossProject(JSPlatform, JVMPlatform)
|
||||
.withoutSuffixFor(JVMPlatform)
|
||||
.crossType(CrossType.Pure)
|
||||
.in(file("cli/cli"))
|
||||
.enablePlugins(GraalVMNativeImagePlugin)
|
||||
.settings(commons: _*)
|
||||
.settings(
|
||||
Compile / mainClass := Some("aqua.AquaCli"),
|
||||
graalVMNativeImageOptions ++= Seq(
|
||||
"--no-fallback",
|
||||
"--diagnostics-mode",
|
||||
"--initialize-at-build-time",
|
||||
"--initialize-at-run-time=scala.util.Random$",
|
||||
"-H:-DeleteLocalSymbols",
|
||||
"-H:+PreserveFramePointer",
|
||||
"-H:+ReportExceptionStackTraces",
|
||||
"-H:+DashboardHeap",
|
||||
"-H:+DashboardCode",
|
||||
"-H:+DashboardPointsTo",
|
||||
"-H:+DashboardAll"
|
||||
) ++ sys.env
|
||||
.get("COMPILE_STATIC")
|
||||
.filter(_.trim.toLowerCase() == "true")
|
||||
.map(_ => Seq("--static"))
|
||||
.getOrElse(Seq.empty),
|
||||
libraryDependencies ++= Seq(
|
||||
"com.monovore" %%% "decline" % declineV,
|
||||
"com.monovore" %%% "decline-effect" % declineV
|
||||
)
|
||||
)
|
||||
.dependsOn(compiler, `backend-air`, `backend-ts`, io, definitions, logging, constants, `aqua-run`)
|
||||
|
||||
lazy val cliJS = cli.js
|
||||
.settings(
|
||||
scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.ESModule)),
|
||||
scalaJSUseMainModuleInitializer := true
|
||||
)
|
||||
.dependsOn(`js-exports`, `js-imports`)
|
||||
|
||||
lazy val cliJVM = cli.jvm
|
||||
.settings(
|
||||
Compile / run / mainClass := Some("aqua.AquaCli"),
|
||||
assembly / mainClass := Some("aqua.AquaCli"),
|
||||
assembly / assemblyJarName := "aqua-" + version.value + ".jar",
|
||||
libraryDependencies ++= Seq(
|
||||
)
|
||||
)
|
||||
|
||||
lazy val `aqua-run` = crossProject(JSPlatform, JVMPlatform)
|
||||
.withoutSuffixFor(JVMPlatform)
|
||||
.crossType(CrossType.Pure)
|
||||
.in(file("aqua-run"))
|
||||
.settings(commons: _*)
|
||||
.settings(commons)
|
||||
.dependsOn(compiler, `backend-air`, `backend-ts`, io, definitions, logging, constants)
|
||||
.enablePlugins(AutomateHeaderPlugin)
|
||||
|
||||
lazy val io = crossProject(JVMPlatform, JSPlatform)
|
||||
.withoutSuffixFor(JVMPlatform)
|
||||
.crossType(CrossType.Pure)
|
||||
.settings(commons: _*)
|
||||
.settings(commons)
|
||||
.settings(
|
||||
libraryDependencies ++= Seq(
|
||||
"org.typelevel" %%% "cats-effect" % catsEffectV,
|
||||
"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)
|
||||
.crossType(CrossType.Pure)
|
||||
.in(file("language-server/language-server-api"))
|
||||
.settings(commons: _*)
|
||||
.settings(commons)
|
||||
.settings(
|
||||
libraryDependencies ++= Seq(
|
||||
"org.typelevel" %%% "cats-effect" % catsEffectV,
|
||||
"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: _*)
|
||||
.settings(commons)
|
||||
.dependsOn(`backend`.js, definitions.js)
|
||||
.enablePlugins(AutomateHeaderPlugin)
|
||||
|
||||
lazy val `js-imports` = project
|
||||
.in(file("js/js-imports"))
|
||||
.enablePlugins(ScalaJSPlugin)
|
||||
.settings(commons: _*)
|
||||
.settings(commons)
|
||||
.dependsOn(`js-exports`, transform.js)
|
||||
|
||||
lazy val `aqua-api` = project
|
||||
.in(file("api/aqua-api"))
|
||||
.enablePlugins(ScalaJSPlugin)
|
||||
.settings(commons: _*)
|
||||
lazy val `aqua-api` = crossProject(JSPlatform, JVMPlatform)
|
||||
.withoutSuffixFor(JVMPlatform)
|
||||
.crossType(CrossType.Pure)
|
||||
.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.CommonJSModule)),
|
||||
scalaJSLinkerConfig ~= (
|
||||
_.withModuleKind(ModuleKind.ESModule)
|
||||
.withJSHeader(s"/*${license.text}*/\n")
|
||||
),
|
||||
scalaJSUseMainModuleInitializer := true,
|
||||
Test / test := {}
|
||||
)
|
||||
.dependsOn(`js-exports`, `aqua-run`.js, `backend-api`.js)
|
||||
.settings(addBundleJS("../../api-npm/aqua-api.js"))
|
||||
.enablePlugins(ScalaJSPlugin)
|
||||
.dependsOn(`js-exports`)
|
||||
.enablePlugins(AutomateHeaderPlugin)
|
||||
|
||||
lazy val types = crossProject(JVMPlatform, JSPlatform)
|
||||
.withoutSuffixFor(JVMPlatform)
|
||||
@ -163,106 +171,114 @@ lazy val types = crossProject(JVMPlatform, JSPlatform)
|
||||
"org.typelevel" %%% "cats-core" % catsV
|
||||
)
|
||||
)
|
||||
.dependsOn(errors)
|
||||
.enablePlugins(AutomateHeaderPlugin)
|
||||
|
||||
lazy val parser = crossProject(JVMPlatform, JSPlatform)
|
||||
.withoutSuffixFor(JVMPlatform)
|
||||
.crossType(CrossType.Pure)
|
||||
.settings(commons: _*)
|
||||
.settings(commons)
|
||||
.settings(
|
||||
libraryDependencies ++= Seq(
|
||||
"org.typelevel" %%% "cats-parse" % catsParseV,
|
||||
"org.typelevel" %%% "cats-free" % catsV
|
||||
)
|
||||
)
|
||||
.dependsOn(types)
|
||||
.dependsOn(types, helpers)
|
||||
.enablePlugins(AutomateHeaderPlugin)
|
||||
|
||||
lazy val linker = crossProject(JVMPlatform, JSPlatform)
|
||||
.withoutSuffixFor(JVMPlatform)
|
||||
.crossType(CrossType.Pure)
|
||||
.settings(commons: _*)
|
||||
.settings(commons)
|
||||
.dependsOn(parser)
|
||||
.enablePlugins(AutomateHeaderPlugin)
|
||||
|
||||
lazy val tree = crossProject(JVMPlatform, JSPlatform)
|
||||
.withoutSuffixFor(JVMPlatform)
|
||||
.crossType(CrossType.Pure)
|
||||
.in(file("model/tree"))
|
||||
.settings(commons: _*)
|
||||
.settings(commons)
|
||||
.settings(
|
||||
libraryDependencies ++= Seq(
|
||||
"org.typelevel" %%% "cats-free" % catsV
|
||||
)
|
||||
)
|
||||
.dependsOn(helpers)
|
||||
.enablePlugins(AutomateHeaderPlugin)
|
||||
|
||||
lazy val raw = crossProject(JVMPlatform, JSPlatform)
|
||||
.withoutSuffixFor(JVMPlatform)
|
||||
.crossType(CrossType.Pure)
|
||||
.in(file("model/raw"))
|
||||
.settings(commons: _*)
|
||||
.settings(commons)
|
||||
.dependsOn(types, tree)
|
||||
.enablePlugins(AutomateHeaderPlugin)
|
||||
|
||||
lazy val model = crossProject(JVMPlatform, JSPlatform)
|
||||
.withoutSuffixFor(JVMPlatform)
|
||||
.crossType(CrossType.Pure)
|
||||
.settings(commons: _*)
|
||||
.dependsOn(types, tree, raw)
|
||||
.settings(commons)
|
||||
.dependsOn(types, tree, raw, helpers, errors)
|
||||
.enablePlugins(AutomateHeaderPlugin)
|
||||
|
||||
lazy val res = crossProject(JVMPlatform, JSPlatform)
|
||||
.withoutSuffixFor(JVMPlatform)
|
||||
.crossType(CrossType.Pure)
|
||||
.in(file("model/res"))
|
||||
.settings(commons: _*)
|
||||
.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)
|
||||
.settings(commons)
|
||||
.dependsOn(raw, model, mangler)
|
||||
.enablePlugins(AutomateHeaderPlugin)
|
||||
|
||||
lazy val transform = crossProject(JVMPlatform, JSPlatform)
|
||||
.withoutSuffixFor(JVMPlatform)
|
||||
.crossType(CrossType.Pure)
|
||||
.in(file("model/transform"))
|
||||
.settings(commons: _*)
|
||||
.dependsOn(model, res, inline)
|
||||
.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)
|
||||
.settings(commons)
|
||||
.dependsOn(raw, parser, errors, mangler)
|
||||
.enablePlugins(AutomateHeaderPlugin)
|
||||
|
||||
lazy val compiler = crossProject(JVMPlatform, JSPlatform)
|
||||
.withoutSuffixFor(JVMPlatform)
|
||||
.crossType(CrossType.Pure)
|
||||
.in(file("compiler"))
|
||||
.settings(commons: _*)
|
||||
.dependsOn(semantics, linker, backend, transform % Test)
|
||||
.settings(commons)
|
||||
.dependsOn(semantics, linker, backend, transform % "test->test", res % "test->test")
|
||||
.enablePlugins(AutomateHeaderPlugin)
|
||||
|
||||
lazy val backend = crossProject(JVMPlatform, JSPlatform)
|
||||
.withoutSuffixFor(JVMPlatform)
|
||||
.crossType(CrossType.Pure)
|
||||
.in(file("backend"))
|
||||
.settings(commons: _*)
|
||||
.settings(commons)
|
||||
.enablePlugins(BuildInfoPlugin)
|
||||
.settings(
|
||||
buildInfoKeys := Seq[BuildInfoKey](version),
|
||||
buildInfoPackage := "aqua.backend"
|
||||
)
|
||||
.dependsOn(res, definitions)
|
||||
.enablePlugins(AutomateHeaderPlugin)
|
||||
|
||||
lazy val definitions = crossProject(JVMPlatform, JSPlatform)
|
||||
.withoutSuffixFor(JVMPlatform)
|
||||
.crossType(CrossType.Pure)
|
||||
.in(file("backend/definitions"))
|
||||
.settings(commons: _*)
|
||||
.settings(commons)
|
||||
.settings(
|
||||
libraryDependencies ++= Seq(
|
||||
"io.circe" %%% "circe-core",
|
||||
@ -271,49 +287,92 @@ lazy val definitions = crossProject(JVMPlatform, JSPlatform)
|
||||
).map(_ % circeVersion)
|
||||
)
|
||||
.dependsOn(res, types)
|
||||
.enablePlugins(AutomateHeaderPlugin)
|
||||
|
||||
lazy val logging = crossProject(JVMPlatform, JSPlatform)
|
||||
.withoutSuffixFor(JVMPlatform)
|
||||
.crossType(CrossType.Pure)
|
||||
.in(file("utils/logging"))
|
||||
.settings(commons: _*)
|
||||
.settings(commons)
|
||||
.settings(
|
||||
libraryDependencies ++= Seq(
|
||||
"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)
|
||||
.crossType(CrossType.Pure)
|
||||
.in(file("utils/constants"))
|
||||
.settings(commons: _*)
|
||||
.settings(commons)
|
||||
.settings(
|
||||
libraryDependencies ++= Seq(
|
||||
"org.typelevel" %%% "cats-core" % catsV
|
||||
)
|
||||
)
|
||||
.dependsOn(parser, raw)
|
||||
.enablePlugins(AutomateHeaderPlugin)
|
||||
|
||||
lazy val helpers = crossProject(JVMPlatform, JSPlatform)
|
||||
.withoutSuffixFor(JVMPlatform)
|
||||
.crossType(CrossType.Pure)
|
||||
.in(file("utils/helpers"))
|
||||
.settings(commons)
|
||||
.settings(
|
||||
libraryDependencies ++= Seq(
|
||||
"org.typelevel" %%% "cats-core" % catsV,
|
||||
"org.typelevel" %%% "cats-free" % catsV
|
||||
)
|
||||
)
|
||||
.dependsOn(errors)
|
||||
.enablePlugins(AutomateHeaderPlugin)
|
||||
|
||||
lazy val errors = crossProject(JVMPlatform, JSPlatform)
|
||||
.withoutSuffixFor(JVMPlatform)
|
||||
.crossType(CrossType.Pure)
|
||||
.in(file("utils/errors"))
|
||||
.settings(commons)
|
||||
.settings(
|
||||
libraryDependencies ++= Seq(
|
||||
"com.lihaoyi" %%% "sourcecode" % sourcecodeV
|
||||
)
|
||||
)
|
||||
.enablePlugins(AutomateHeaderPlugin)
|
||||
|
||||
lazy val `backend-air` = crossProject(JVMPlatform, JSPlatform)
|
||||
.withoutSuffixFor(JVMPlatform)
|
||||
.crossType(CrossType.Pure)
|
||||
.in(file("backend/air"))
|
||||
.settings(commons: _*)
|
||||
.settings(commons)
|
||||
.dependsOn(backend, transform)
|
||||
.enablePlugins(AutomateHeaderPlugin)
|
||||
|
||||
lazy val `backend-api` = crossProject(JVMPlatform, JSPlatform)
|
||||
.withoutSuffixFor(JVMPlatform)
|
||||
.crossType(CrossType.Pure)
|
||||
.in(file("backend/api"))
|
||||
.settings(commons: _*)
|
||||
.settings(commons)
|
||||
.dependsOn(backend, transform, `backend-air`)
|
||||
.enablePlugins(AutomateHeaderPlugin)
|
||||
|
||||
lazy val `backend-ts` = crossProject(JVMPlatform, JSPlatform)
|
||||
.withoutSuffixFor(JVMPlatform)
|
||||
.crossType(CrossType.Pure)
|
||||
.in(file("backend/ts"))
|
||||
.settings(commons: _*)
|
||||
.settings(commons)
|
||||
.settings(
|
||||
libraryDependencies ++= Seq(
|
||||
"io.circe" %%% "circe-core",
|
||||
@ -322,3 +381,4 @@ lazy val `backend-ts` = crossProject(JVMPlatform, JSPlatform)
|
||||
).map(_ % circeVersion)
|
||||
)
|
||||
.dependsOn(`backend-air`, definitions)
|
||||
.enablePlugins(AutomateHeaderPlugin)
|
||||
|
171
ci.cjs
Normal file
171
ci.cjs
Normal file
@ -0,0 +1,171 @@
|
||||
#! /usr/bin/env node
|
||||
|
||||
const fs = require("fs").promises;
|
||||
const path = require("path");
|
||||
|
||||
function printUsage() {
|
||||
console.log(
|
||||
`Usage: "ci check-consistency" or "ci bump-version %postfix%" or "ci get-version"`
|
||||
);
|
||||
}
|
||||
|
||||
let postfix;
|
||||
const mode = process.argv[2];
|
||||
|
||||
function validateArgs() {
|
||||
switch (mode) {
|
||||
case "get-version":
|
||||
return true;
|
||||
|
||||
case "bump-version":
|
||||
postfix = process.argv[3];
|
||||
if (!postfix) {
|
||||
printUsage();
|
||||
process.exit();
|
||||
}
|
||||
return true;
|
||||
|
||||
case "":
|
||||
case undefined:
|
||||
case "check-consistency":
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
const PATHS_TO_PACKAGES = [
|
||||
"./api/api-npm",
|
||||
"./language-server/language-server-npm",
|
||||
"./integration-tests"
|
||||
];
|
||||
|
||||
async function getPackageJsonsRecursive(currentPath) {
|
||||
return (
|
||||
await Promise.all(
|
||||
(await fs.readdir(currentPath, { withFileTypes: true }))
|
||||
.filter(
|
||||
(file) =>
|
||||
file.name !== "node_modules" && file.name !== "@tests" &&
|
||||
(file.isDirectory() || file.name === "package.json")
|
||||
)
|
||||
.map((file) =>
|
||||
file.isDirectory()
|
||||
? getPackageJsonsRecursive(
|
||||
path.join(currentPath, file.name)
|
||||
)
|
||||
: Promise.resolve([
|
||||
path.join(process.cwd(), currentPath, file.name),
|
||||
])
|
||||
)
|
||||
)
|
||||
).flat();
|
||||
}
|
||||
|
||||
async function getVersion(file) {
|
||||
const content = await fs.readFile(file);
|
||||
const json = JSON.parse(content);
|
||||
return [json.name, json.version];
|
||||
}
|
||||
|
||||
function processDep(obj, name, fn) {
|
||||
if (!obj) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!obj[name]) {
|
||||
return;
|
||||
}
|
||||
|
||||
fn(obj, obj[name]);
|
||||
}
|
||||
|
||||
async function getVersionsMap(allPackageJsons) {
|
||||
return new Map(await Promise.all(allPackageJsons.map(getVersion)));
|
||||
}
|
||||
|
||||
function getVersionForPackageOrThrow(versionsMap, packageName) {
|
||||
const version = versionsMap.get(packageName);
|
||||
if (!version) {
|
||||
console.log("Failed to get version for package: ", packageName);
|
||||
process.exit(1);
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
async function checkConsistency(file, versionsMap) {
|
||||
console.log("Checking: ", file);
|
||||
const content = await fs.readFile(file);
|
||||
const json = JSON.parse(content);
|
||||
|
||||
for (const [name, versionInDep] of versionsMap) {
|
||||
const check = (x, version) => {
|
||||
if (version.includes("*")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (versionInDep !== version) {
|
||||
console.log(
|
||||
`Error, versions don't match: ${name}:${version} !== ${versionInDep}`,
|
||||
file
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
};
|
||||
processDep(json.dependencies, name, check);
|
||||
processDep(json.devDependencies, name, check);
|
||||
}
|
||||
}
|
||||
|
||||
async function bumpVersions(file, versionsMap) {
|
||||
console.log("Updating: ", file);
|
||||
const content = await fs.readFile(file);
|
||||
const json = JSON.parse(content);
|
||||
|
||||
for (const [name, version] of versionsMap) {
|
||||
const update = (x) => (x[name] = `${version}-${postfix}`);
|
||||
processDep(json.dependencies, name, update);
|
||||
processDep(json.devDependencies, name, update);
|
||||
}
|
||||
|
||||
const version = getVersionForPackageOrThrow(versionsMap, json.name);
|
||||
json.version = `${version}-${postfix}`;
|
||||
|
||||
const newContent = JSON.stringify(json, undefined, 4) + "\n";
|
||||
await fs.writeFile(file, newContent);
|
||||
}
|
||||
|
||||
async function processPackageJsons(allPackageJsons, versionsMap, fn) {
|
||||
await Promise.all(allPackageJsons.map((x) => fn(x, versionsMap)));
|
||||
}
|
||||
|
||||
async function run() {
|
||||
if (!validateArgs()) {
|
||||
printUsage();
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
const packageJsons = (
|
||||
await Promise.all(PATHS_TO_PACKAGES.map(getPackageJsonsRecursive))
|
||||
).flat();
|
||||
const versionsMap = await getVersionsMap(packageJsons);
|
||||
|
||||
if (mode === "get-version") {
|
||||
const fjs = versionsMap.get("@fluencelabs/fluence");
|
||||
console.log(fjs);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("Checking versions consistency...");
|
||||
await processPackageJsons(packageJsons, versionsMap, checkConsistency);
|
||||
console.log("Versions are consistent");
|
||||
|
||||
if (mode === "bump-version") {
|
||||
console.log("Adding postfix: ", postfix);
|
||||
await processPackageJsons(packageJsons, versionsMap, bumpVersions);
|
||||
console.log("Done");
|
||||
}
|
||||
}
|
||||
|
||||
run();
|
3
cli/cli-npm/.gitignore
vendored
3
cli/cli-npm/.gitignore
vendored
@ -1,3 +0,0 @@
|
||||
*.jar
|
||||
*.tgz
|
||||
node_modules
|
@ -1,45 +0,0 @@
|
||||
## Installation
|
||||
|
||||
- run `sbt "cliJS/fullLinkJS"` in a root dir of a project after any code update (better to keep `sbt` running for faster compilation)
|
||||
- `npm` installed required
|
||||
- run `npm i` in `npm` directory
|
||||
- feel free to change `@fluencelabs/fluence` version in `package.json` file, run `npm i` after changes
|
||||
|
||||
## Run script
|
||||
|
||||
Generally, use this script to run compiled aqua compiler from a repo:
|
||||
|
||||
```
|
||||
npm run from:scalajs -- run -f "someFunction(arg1, arg2)" -i path/to/aqua --data-path path/to/args -m path/to/exports --addr /multiaddr/to/node
|
||||
```
|
||||
|
||||
- `-f or --func` is a function to call with arguments
|
||||
- `-i or --input` aqua file where function located
|
||||
- `-m or --import` imports location, could be used multiple times
|
||||
- `-a or --addr` multiaddress to a Fluence node
|
||||
- `-p or --data-path` path to a file with JSON where arguments are located
|
||||
|
||||
As example, use `test/sample.aqua` with args from `test/data.json` running on `/dns4/kras-04.fluence.dev/tcp/19001/wss/p2p/12D3KooWFEwNWcHqi9rtsmDhsYcDbRUCDXH84RC4FW6UfsFWaoHi` node:
|
||||
|
||||
```
|
||||
npm run from:scalajs -- run -f "identityArgsAndReturn(structField, stringField, numberField)" -i test/sample.aqua --data-path test/data.json --addr /dns4/kras-04.fluence.dev/tcp/19001/wss/p2p/12D3KooWFEwNWcHqi9rtsmDhsYcDbRUCDXH84RC4FW6UfsFWaoHi
|
||||
```
|
||||
|
||||
To simplify experience you can use `./aqua-run.sh` command and change all arguments straight in this file.
|
||||
|
||||
## Node addresses
|
||||
|
||||
Different Fluence network addresses could be found here: https://github.com/fluencelabs/fluence-network-environment/blob/main/src/index.ts
|
||||
|
||||
## Useful flags
|
||||
- `--print-air` to print resulted air
|
||||
- `--no-xor` to disable xor wrapping aroung service calls
|
||||
- `--sk secret_key` send request signed with specific secret key. Secret key could be created with `npm run from:scalajs -- create_keypair` or `aqua create_keypair` if you want to use installed aqua
|
||||
- `--data "json""` use instead of `--data-path` to pass arguments through command line
|
||||
- `--timeout 10000` to change timeout
|
||||
- `--log-level debug/info/..` to change log level
|
||||
|
||||
## Builtins for `aqua run`
|
||||
|
||||
You can find all builtins in aqua/run-builtins/run-builtins.aqua
|
||||
|
@ -1,14 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
FUNC='deploy(tsOracle)'
|
||||
INPUT='aqua/dist.aqua'
|
||||
DATAPATH='test/deploy.json'
|
||||
ADDR='/dns4/kras-04.fluence.dev/tcp/19001/wss/p2p/12D3KooWFEwNWcHqi9rtsmDhsYcDbRUCDXH84RC4FW6UfsFWaoHi'
|
||||
# IMPORT=
|
||||
|
||||
if [ -z "$IMPORT" ]
|
||||
then
|
||||
npm run from:scalajs -- run -f "$FUNC" -i "$INPUT" --data-path "$DATAPATH" --addr "$ADDR"
|
||||
else
|
||||
npm run from:scalajs -- run -f "$FUNC" -i "$INPUT" --data-path "$DATAPATH" --addr "$ADDR" -m "$IMPORT"
|
||||
fi
|
@ -1,96 +0,0 @@
|
||||
module ServiceDist declares *
|
||||
|
||||
import "run-builtins/run-builtins.aqua"
|
||||
import "@fluencelabs/aqua-lib/builtin.aqua"
|
||||
import "@fluencelabs/aqua-ipfs/ipfs.aqua"
|
||||
|
||||
export deploy, remove, createService, addBlueprint
|
||||
|
||||
data ModuleConf:
|
||||
name: string
|
||||
path: string
|
||||
mounted_binaries: ?[][]string
|
||||
preopened_files: ?[]string
|
||||
mapped_dirs: ?[][]string
|
||||
envs: ?[][]string
|
||||
logger_enabled: ?bool
|
||||
logging_mask: ?i32
|
||||
mem_pages_count: ?u32
|
||||
max_heap_size: ?string
|
||||
|
||||
service OpC("op"):
|
||||
array_length(arr: []ModuleConf) -> u32
|
||||
|
||||
data DeployResult:
|
||||
blueprint_id: string
|
||||
service_id: string
|
||||
|
||||
service DeployHelper("deploy_helper"):
|
||||
create_result(bid: string, sid: string) -> DeployResult
|
||||
|
||||
data ServiceConf:
|
||||
modules: []ModuleConf
|
||||
|
||||
const ON_PEER ?= HOST_PEER_ID
|
||||
|
||||
func flattenSS(input: [][]string) -> ?[][]string:
|
||||
res: *[][]string
|
||||
res <<- input
|
||||
<- res
|
||||
|
||||
func flattenS(input: []string) -> ?[]string:
|
||||
res: *[]string
|
||||
res <<- input
|
||||
<- res
|
||||
|
||||
func deploy(serviceName: string, serviceConf: ServiceConf) -> DeployResult:
|
||||
|
||||
on ON_PEER:
|
||||
multiaddr <- Ipfs.get_external_api_multiaddr()
|
||||
|
||||
mod_hashes: *[]string
|
||||
for m <- serviceConf.modules par:
|
||||
-- TODO check for cache
|
||||
Console.print(Op.concat_strings("Going to upload module: ", m.name))
|
||||
uploadRes <- LocalIpfs.uploadFile(m.path, multiaddr)
|
||||
cid = uploadRes.cid
|
||||
Console.print(Op.concat_strings(Op.concat_strings("Module '", m.name), "' was uploaded"))
|
||||
|
||||
on ON_PEER:
|
||||
hostRes <- Ipfs.get(cid)
|
||||
conf <- Dist.make_module_config(m.name, m.mem_pages_count, m.max_heap_size, m.logger_enabled, m.preopened_files, m.envs, m.mapped_dirs, m.mounted_binaries, m.logging_mask)
|
||||
mod_hash <- Dist.add_module_from_vault(hostRes.path, conf)
|
||||
mod_hashes <<- [mod_hash, m.name]
|
||||
|
||||
join mod_hashes[OpC.array_length(serviceConf.modules) - 1]
|
||||
|
||||
-- sort hashes to the same order as was in serviceConf.modules
|
||||
sorted_hashes: *string
|
||||
for m <- serviceConf.modules:
|
||||
for hash_name <- mod_hashes:
|
||||
if m.name == hash_name[1]:
|
||||
sorted_hashes <<- hash_name[0]
|
||||
|
||||
Console.print("Now time to make the blueprint...")
|
||||
on ON_PEER:
|
||||
blueprint <- Dist.make_blueprint(serviceName, sorted_hashes)
|
||||
blueprint_id <- Dist.add_blueprint(blueprint)
|
||||
service_id <- Srv.create(blueprint_id)
|
||||
|
||||
res <- DeployHelper.create_result(blueprint_id, service_id)
|
||||
<- res
|
||||
|
||||
func remove(service_id: string):
|
||||
on ON_PEER:
|
||||
Srv.remove(service_id)
|
||||
Console.print("Service was deleted")
|
||||
|
||||
func createService(blueprint_id: string) -> string:
|
||||
on ON_PEER:
|
||||
service_id <- Srv.create(blueprint_id)
|
||||
<- service_id
|
||||
|
||||
func addBlueprint(bp: AddBlueprint) -> string:
|
||||
on ON_PEER:
|
||||
blueprint_id <- Dist.add_blueprint(bp)
|
||||
<- blueprint_id
|
@ -1,18 +0,0 @@
|
||||
module IpfsExports
|
||||
|
||||
import "@fluencelabs/aqua-ipfs/ipfs-api.aqua"
|
||||
import "run-builtins/run-builtins.aqua"
|
||||
|
||||
|
||||
export uploadFile
|
||||
|
||||
const ON_PEER ?= HOST_PEER_ID
|
||||
|
||||
func uploadFile(path: string) -> UploadResult:
|
||||
on ON_PEER:
|
||||
multiaddr <- get_external_api_multiaddr(ON_PEER)
|
||||
result <- LocalIpfs.uploadFile(path, multiaddr)
|
||||
<- result
|
||||
|
||||
|
||||
|
@ -1,41 +0,0 @@
|
||||
module NetworkInfo
|
||||
|
||||
import "@fluencelabs/aqua-lib/builtin.aqua"
|
||||
|
||||
export list_modules, list_interfaces_by_peer, get_interface, list_blueprints, list_services
|
||||
|
||||
const ON_PEER ?= HOST_PEER_ID
|
||||
|
||||
func list_modules() -> []Module:
|
||||
on ON_PEER:
|
||||
res <- Dist.list_modules()
|
||||
<- res
|
||||
|
||||
func list_services() -> []Service:
|
||||
on ON_PEER:
|
||||
services <- Srv.list()
|
||||
<- services
|
||||
|
||||
func list_interfaces_by_peer(peer: PeerId) -> []Interface:
|
||||
on ON_PEER:
|
||||
services <- Srv.list()
|
||||
interfaces: *Interface
|
||||
for srv <- services:
|
||||
if srv.owner_id == peer:
|
||||
interfaces <- Srv.get_interface(srv.id)
|
||||
<- interfaces
|
||||
|
||||
func get_interface(serviceId: string) -> Interface:
|
||||
on ON_PEER:
|
||||
res <- Srv.get_interface(serviceId)
|
||||
<- res
|
||||
|
||||
func get_module_interface(moduleHash: string) -> Interface:
|
||||
on ON_PEER:
|
||||
res <- Dist.get_module_interface(moduleHash)
|
||||
<- res
|
||||
|
||||
func list_blueprints() -> []Blueprint:
|
||||
on ON_PEER:
|
||||
res <- Dist.list_blueprints()
|
||||
<- res
|
@ -1,13 +0,0 @@
|
||||
import "@fluencelabs/aqua-ipfs/ipfs.aqua"
|
||||
|
||||
-- printing strings in console
|
||||
service Console("run-console"):
|
||||
print(str: string)
|
||||
|
||||
data UploadResult:
|
||||
error: string
|
||||
cid: string
|
||||
size: u64
|
||||
|
||||
service LocalIpfs("ipfs"):
|
||||
uploadFile(path: string, multiaddr: IpfsMultiaddrResult) -> UploadResult
|
@ -1,28 +0,0 @@
|
||||
module ServiceScript declares *
|
||||
|
||||
import "run-builtins/run-builtins.aqua"
|
||||
import "@fluencelabs/aqua-lib/builtin.aqua"
|
||||
import "@fluencelabs/aqua-ipfs/ipfs.aqua"
|
||||
|
||||
export schedule, remove, list
|
||||
|
||||
const ON_PEER ?= HOST_PEER_ID
|
||||
|
||||
func schedule(air: string, interval: ?u64) -> string:
|
||||
on ON_PEER:
|
||||
res <- Script.add(air, interval)
|
||||
Console.print("Script was scheduled")
|
||||
<- res
|
||||
|
||||
func remove(script_id: string):
|
||||
on ON_PEER:
|
||||
res <- Script.remove(script_id)
|
||||
if res:
|
||||
Console.print("Script was removed")
|
||||
else:
|
||||
Console.print("No script with such ID")
|
||||
|
||||
func list() -> []ScriptInfo:
|
||||
on ON_PEER:
|
||||
res <- Script.list()
|
||||
<- res
|
@ -1,5 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
"use strict";
|
||||
|
||||
console.error("ERROR: use 'aqua' command!")
|
@ -1,32 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
"use strict";
|
||||
|
||||
handleEPIPE(process.stderr)
|
||||
handleEPIPE(process.stdout)
|
||||
function handleEPIPE(stream) {
|
||||
stream.on('error', onerror)
|
||||
function onerror(err) {
|
||||
if (err.code === 'EPIPE') {
|
||||
stream._write = noopWrite
|
||||
stream._writev = noopWritev
|
||||
stream._read = noopRead
|
||||
return stream.removeListener('error', onerror)
|
||||
}
|
||||
if (EE.listenerCount(stream, 'error') === 1) {
|
||||
stream.removeListener('error', onerror)
|
||||
stream.emit('error', err)
|
||||
}
|
||||
}
|
||||
}
|
||||
function noopWrite(chunk, enc, cb) {
|
||||
cb()
|
||||
}
|
||||
function noopRead() {
|
||||
this.push('')
|
||||
}
|
||||
function noopWritev(chunks, cb) {
|
||||
cb()
|
||||
}
|
||||
|
||||
import "./aqua.js";
|
@ -1,2 +0,0 @@
|
||||
// It should work in scala as js.`import`.meta.url, but it doesn't compile for some reasons
|
||||
export const metaUrl = import.meta.url
|
13309
cli/cli-npm/package-lock.json
generated
13309
cli/cli-npm/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user