diff --git a/aqua/dht/dht-example.aqua b/aqua/dht/dht-example.aqua new file mode 100644 index 0000000..41a7778 --- /dev/null +++ b/aqua/dht/dht-example.aqua @@ -0,0 +1,14 @@ +import "@fluencelabs/aqua-dht/pubsub.aqua" +import "@fluencelabs/aqua-dht/dht.aqua" +import "@fluencelabs/aqua-lib/builtin.aqua" + +func put_value(initial_peer: string, value: string) -> string: + initTopicAndSubscribe(initial_peer, "some-const3", value, nil, nil) + <- "OK" + +func registerKeyPutValue(node_id: string, key: string, value: string, relay_id: ?string, service_id: ?string) -> []string: + nodes <- getNeighbours(key, node_id) + for n <- nodes par: + on n: + t <- Peer.timestamp_sec() + <- nodes \ No newline at end of file diff --git a/aqua/dht/dht.aqua b/aqua/dht/dht.aqua deleted file mode 100644 index fd3cdda..0000000 --- a/aqua/dht/dht.aqua +++ /dev/null @@ -1,8 +0,0 @@ -import "@fluencelabs/aqua-dht/pubsub.aqua" - -func put_value(initial_peer: string, value: string) -> string: - none_service_id: *string - on initial_peer: - -- Op.noop() - initTopicAndSubscribe(initial_peer, "some-const3", value, nil, nil) - <- "OK" \ No newline at end of file diff --git a/aqua/examples/passArgs.aqua b/aqua/examples/passArgs.aqua new file mode 100644 index 0000000..8c16ce1 --- /dev/null +++ b/aqua/examples/passArgs.aqua @@ -0,0 +1,10 @@ +service AquaDHT("test-dht"): + put_host_value(key: string, value: string, service_id: []string) -> string + +func putHostValue(key: string, value: string, service_id: ?string) -> string: + res <- AquaDHT.put_host_value(key, value, service_id) + <- res + +func create_client_util(service_id: string) -> string: + res <- putHostValue("client-util", service_id, nil) + <- res \ No newline at end of file diff --git a/aqua/examples/streamArgs.aqua b/aqua/examples/streamArgs.aqua new file mode 100644 index 0000000..b1cd9b9 --- /dev/null +++ b/aqua/examples/streamArgs.aqua @@ -0,0 +1,10 @@ +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 \ No newline at end of file diff --git a/aqua/examples/streamResults.aqua b/aqua/examples/streamResults.aqua new file mode 100644 index 0000000..087e40c --- /dev/null +++ b/aqua/examples/streamResults.aqua @@ -0,0 +1,16 @@ +data DT: + field: string + +service DTGetter("get-dt"): + get_dt(s: string) -> DT + +func use_name1(name: string) -> string: + results <- DTGetter.get_dt(name) + <- results.field + +func use_name2(name: string) -> []string: + results: *string + results <- use_name1(name) + results <- use_name1(name) + results <- use_name1(name) + <- results \ No newline at end of file diff --git a/src/compiled/examples/assignment.ts b/src/compiled/examples/assignment.ts index e69fc68..54cf516 100644 --- a/src/compiled/examples/assignment.ts +++ b/src/compiled/examples/assignment.ts @@ -3,7 +3,7 @@ * This file is auto-generated. Do not edit manually: changes may be erased. * Generated by Aqua compiler: https://github.com/fluencelabs/aqua/. * If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues - * Aqua version: 0.1.8-SNAPSHOT + * Aqua version: 0.1.9-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; @@ -61,7 +61,7 @@ export async function doSmth(client: FluenceClient, arg: {value:string}, config? .handleTimeout(() => { reject('Request timed out for doSmth'); }) - if(config?.ttl) { + if(config && config.ttl) { r.withTTL(config.ttl) } request = r.build(); diff --git a/src/compiled/examples/callArrow.ts b/src/compiled/examples/callArrow.ts index ad8d933..c6124d6 100644 --- a/src/compiled/examples/callArrow.ts +++ b/src/compiled/examples/callArrow.ts @@ -3,7 +3,7 @@ * This file is auto-generated. Do not edit manually: changes may be erased. * Generated by Aqua compiler: https://github.com/fluencelabs/aqua/. * If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues - * Aqua version: 0.1.8-SNAPSHOT + * Aqua version: 0.1.9-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; @@ -48,7 +48,7 @@ export async function print(client: FluenceClient, str: string, config?: {ttl?: .handleTimeout(() => { reject('Request timed out for print'); }) - if(config?.ttl) { + if(config && config.ttl) { r.withTTL(config.ttl) } request = r.build(); @@ -130,7 +130,7 @@ h.on('callbackSrv', 'c', (args) => {return c(args[0]);}); .handleTimeout(() => { reject('Request timed out for passFunctionAsArg'); }) - if(config?.ttl) { + if(config && config.ttl) { r.withTTL(config.ttl) } request = r.build(); diff --git a/src/compiled/examples/complex.ts b/src/compiled/examples/complex.ts index 9e188cf..99f2a84 100644 --- a/src/compiled/examples/complex.ts +++ b/src/compiled/examples/complex.ts @@ -3,7 +3,7 @@ * This file is auto-generated. Do not edit manually: changes may be erased. * Generated by Aqua compiler: https://github.com/fluencelabs/aqua/. * If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues - * Aqua version: 0.1.8-SNAPSHOT + * Aqua version: 0.1.9-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; @@ -58,7 +58,7 @@ export async function helloWorld(client: FluenceClient, name: string, config?: { .handleTimeout(() => { reject('Request timed out for helloWorld'); }) - if(config?.ttl) { + if(config && config.ttl) { r.withTTL(config.ttl) } request = r.build(); @@ -105,7 +105,7 @@ export async function print(client: FluenceClient, str: string, config?: {ttl?: .handleTimeout(() => { reject('Request timed out for print'); }) - if(config?.ttl) { + if(config && config.ttl) { r.withTTL(config.ttl) } request = r.build(); @@ -159,7 +159,7 @@ export async function testFunc(client: FluenceClient, config?: {ttl?: number}): .handleTimeout(() => { reject('Request timed out for testFunc'); }) - if(config?.ttl) { + if(config && config.ttl) { r.withTTL(config.ttl) } request = r.build(); @@ -191,103 +191,91 @@ export async function doStuff(client: FluenceClient, a: string, b: string, c: bo (seq (seq (seq - (seq - (call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-) - (call %init_peer_id% ("getDataSrv" "a") [] a) - ) - (call %init_peer_id% ("getDataSrv" "b") [] b) + (call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-) + (call %init_peer_id% ("getDataSrv" "a") [] a) ) - (call %init_peer_id% ("getDataSrv" "c") [] c) + (call %init_peer_id% ("getDataSrv" "b") [] b) ) - (call %init_peer_id% ("getDataSrv" "d") [] d) + (call %init_peer_id% ("getDataSrv" "c") [] c) ) - (call %init_peer_id% ("getDataSrv" "e") [] e) + (call %init_peer_id% ("getDataSrv" "d") [] d) ) - (call %init_peer_id% ("getDataSrv" "g") [] g) + (call %init_peer_id% ("getDataSrv" "e") [] e) ) - (call %init_peer_id% ("getDataSrv" "str") [] str) + (call %init_peer_id% ("getDataSrv" "g") [] g) ) + (call %init_peer_id% ("getDataSrv" "str") [] str) + ) + (par (par - (par + (seq + (seq + (call %init_peer_id% ("some-id" "t") [str] $stream) + (call -relay- ("op" "noop") []) + ) + (call b ("op" "noop") []) + ) + (call %init_peer_id% ("println-service-id" "print") [a]) + ) + (seq + (call -relay- ("op" "noop") []) + (xor + (call a ("peer" "identify") []) (seq (seq - (seq - (call %init_peer_id% ("some-id" "t") [str] $stream) - (call -relay- ("op" "noop") []) - ) - (call a ("op" "noop") []) - ) - (call b ("op" "noop") []) - ) - (call %init_peer_id% ("println-service-id" "print") [a]) - ) - (seq - (call -relay- ("op" "noop") []) - (xor - (call a ("peer" "identify") []) - (seq - (seq - (call -relay- ("op" "noop") []) - (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1]) - ) (call -relay- ("op" "noop") []) + (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1]) ) + (call -relay- ("op" "noop") []) ) ) ) ) - (call -relay- ("op" "noop") []) ) - (xor - (seq - (seq - (call -relay- ("op" "noop") []) - (call a ("op" "noop") []) - ) - (xor - (match c true - (xor - (match d true - (xor - (fold e eEl - (seq - (seq - (fold g gEl - (seq - (seq - (call b ("some-id" "t") [gEl] $stream) - (call b ("some-id" "t") [eEl] $stream) - ) - (next gEl) - ) - ) - (call b ("some-id" "t") [eEl] $stream) - ) - (next eEl) - ) - ) + (call -relay- ("op" "noop") []) + ) + (xor + (seq + (call -relay- ("op" "noop") []) + (xor + (match c true + (xor + (match d true + (xor + (fold e eEl (seq - (call -relay- ("op" "noop") []) - (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2]) + (seq + (fold g gEl + (seq + (seq + (call b ("some-id" "t") [gEl] $stream) + (call b ("some-id" "t") [eEl] $stream) + ) + (next gEl) + ) + ) + (call b ("some-id" "t") [eEl] $stream) + ) + (next eEl) ) ) + (seq + (call -relay- ("op" "noop") []) + (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2]) + ) ) - (null) ) + (null) ) - (null) ) + (null) ) - (seq - (seq - (call -relay- ("op" "noop") []) - (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3]) - ) - (call -relay- ("op" "noop") []) - ) + ) + (seq + (call -relay- ("op" "noop") []) + (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3]) ) ) - (call a ("op" "noop") []) ) (call -relay- ("op" "noop") []) ) @@ -329,7 +317,7 @@ h.on('getDataSrv', 'str', () => {return str;}); .handleTimeout(() => { reject('Request timed out for doStuff'); }) - if(config?.ttl) { + if(config && config.ttl) { r.withTTL(config.ttl) } request = r.build(); diff --git a/src/compiled/examples/constants.ts b/src/compiled/examples/constants.ts index 169200f..1c212ca 100644 --- a/src/compiled/examples/constants.ts +++ b/src/compiled/examples/constants.ts @@ -3,7 +3,7 @@ * This file is auto-generated. Do not edit manually: changes may be erased. * Generated by Aqua compiler: https://github.com/fluencelabs/aqua/. * If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues - * Aqua version: 0.1.8-SNAPSHOT + * Aqua version: 0.1.9-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; @@ -58,7 +58,7 @@ export async function callConstant(client: FluenceClient, config?: {ttl?: number .handleTimeout(() => { reject('Request timed out for callConstant'); }) - if(config?.ttl) { + if(config && config.ttl) { r.withTTL(config.ttl) } request = r.build(); diff --git a/src/compiled/examples/dataAlias.ts b/src/compiled/examples/dataAlias.ts index 6b00498..34cb279 100644 --- a/src/compiled/examples/dataAlias.ts +++ b/src/compiled/examples/dataAlias.ts @@ -3,7 +3,7 @@ * This file is auto-generated. Do not edit manually: changes may be erased. * Generated by Aqua compiler: https://github.com/fluencelabs/aqua/. * If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues - * Aqua version: 0.1.8-SNAPSHOT + * Aqua version: 0.1.9-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; @@ -55,7 +55,7 @@ export async function getAliasedData(client: FluenceClient, config?: {ttl?: numb .handleTimeout(() => { reject('Request timed out for getAliasedData'); }) - if(config?.ttl) { + if(config && config.ttl) { r.withTTL(config.ttl) } request = r.build(); diff --git a/src/compiled/examples/example.ts b/src/compiled/examples/example.ts index f99b552..a7147c9 100644 --- a/src/compiled/examples/example.ts +++ b/src/compiled/examples/example.ts @@ -3,7 +3,7 @@ * This file is auto-generated. Do not edit manually: changes may be erased. * Generated by Aqua compiler: https://github.com/fluencelabs/aqua/. * If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues - * Aqua version: 0.1.8-SNAPSHOT + * Aqua version: 0.1.9-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; @@ -71,7 +71,7 @@ export async function betterMessage(client: FluenceClient, relay: string, config .handleTimeout(() => { reject('Request timed out for betterMessage'); }) - if(config?.ttl) { + if(config && config.ttl) { r.withTTL(config.ttl) } request = r.build(); diff --git a/src/compiled/examples/fldist-sample.ts b/src/compiled/examples/fldist-sample.ts index 99a81db..11721f0 100644 --- a/src/compiled/examples/fldist-sample.ts +++ b/src/compiled/examples/fldist-sample.ts @@ -3,7 +3,7 @@ * This file is auto-generated. Do not edit manually: changes may be erased. * Generated by Aqua compiler: https://github.com/fluencelabs/aqua/. * If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues - * Aqua version: 0.1.8-SNAPSHOT + * Aqua version: 0.1.9-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; @@ -63,7 +63,7 @@ export async function test(client: FluenceClient, node: string, config?: {ttl?: .handleTimeout(() => { reject('Request timed out for test'); }) - if(config?.ttl) { + if(config && config.ttl) { r.withTTL(config.ttl) } request = r.build(); diff --git a/src/compiled/examples/fold.ts b/src/compiled/examples/fold.ts index 38d7d51..aa28aaf 100644 --- a/src/compiled/examples/fold.ts +++ b/src/compiled/examples/fold.ts @@ -3,7 +3,7 @@ * This file is auto-generated. Do not edit manually: changes may be erased. * Generated by Aqua compiler: https://github.com/fluencelabs/aqua/. * If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues - * Aqua version: 0.1.8-SNAPSHOT + * Aqua version: 0.1.9-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; @@ -48,7 +48,7 @@ export async function print(client: FluenceClient, str: string, config?: {ttl?: .handleTimeout(() => { reject('Request timed out for print'); }) - if(config?.ttl) { + if(config && config.ttl) { r.withTTL(config.ttl) } request = r.build(); @@ -100,7 +100,7 @@ export async function iterateAndPrint(client: FluenceClient, strings: string[], .handleTimeout(() => { reject('Request timed out for iterateAndPrint'); }) - if(config?.ttl) { + if(config && config.ttl) { r.withTTL(config.ttl) } request = r.build(); @@ -168,7 +168,7 @@ h.on('callbackSrv', 'c', (args) => {c(args[0]); return {};}); .handleTimeout(() => { reject('Request timed out for iterateAndPrintParallel'); }) - if(config?.ttl) { + if(config && config.ttl) { r.withTTL(config.ttl) } request = r.build(); diff --git a/src/compiled/examples/foldJoin.ts b/src/compiled/examples/foldJoin.ts index 268373b..5c2327c 100644 --- a/src/compiled/examples/foldJoin.ts +++ b/src/compiled/examples/foldJoin.ts @@ -3,7 +3,7 @@ * This file is auto-generated. Do not edit manually: changes may be erased. * Generated by Aqua compiler: https://github.com/fluencelabs/aqua/. * If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues - * Aqua version: 0.1.8-SNAPSHOT + * Aqua version: 0.1.9-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; @@ -37,7 +37,7 @@ export async function getTwoResults(client: FluenceClient, relay: string, config (seq (seq (call relay ("op" "string_to_b58") [%init_peer_id%] k) - (call relay ("kad" "neighborhood") [k false] nodes) + (call relay ("kad" "neighborhood") [k $nil $nil] nodes) ) (fold nodes n (par @@ -96,7 +96,7 @@ export async function getTwoResults(client: FluenceClient, relay: string, config .handleTimeout(() => { reject('Request timed out for getTwoResults'); }) - if(config?.ttl) { + if(config && config.ttl) { r.withTTL(config.ttl) } request = r.build(); diff --git a/src/compiled/examples/func.ts b/src/compiled/examples/func.ts index e9295ca..92702ef 100644 --- a/src/compiled/examples/func.ts +++ b/src/compiled/examples/func.ts @@ -3,7 +3,7 @@ * This file is auto-generated. Do not edit manually: changes may be erased. * Generated by Aqua compiler: https://github.com/fluencelabs/aqua/. * If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues - * Aqua version: 0.1.8-SNAPSHOT + * Aqua version: 0.1.9-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; @@ -55,7 +55,7 @@ export async function testFunc(client: FluenceClient, config?: {ttl?: number}): .handleTimeout(() => { reject('Request timed out for testFunc'); }) - if(config?.ttl) { + if(config && config.ttl) { r.withTTL(config.ttl) } request = r.build(); diff --git a/src/compiled/examples/helloWorld.ts b/src/compiled/examples/helloWorld.ts index 8b3d8f8..25f1bd0 100644 --- a/src/compiled/examples/helloWorld.ts +++ b/src/compiled/examples/helloWorld.ts @@ -3,7 +3,7 @@ * This file is auto-generated. Do not edit manually: changes may be erased. * Generated by Aqua compiler: https://github.com/fluencelabs/aqua/. * If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues - * Aqua version: 0.1.8-SNAPSHOT + * Aqua version: 0.1.9-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; @@ -58,7 +58,7 @@ export async function helloWorld(client: FluenceClient, name: string, config?: { .handleTimeout(() => { reject('Request timed out for helloWorld'); }) - if(config?.ttl) { + if(config && config.ttl) { r.withTTL(config.ttl) } request = r.build(); diff --git a/src/compiled/examples/if.ts b/src/compiled/examples/if.ts index 26e9c64..82c5b0d 100644 --- a/src/compiled/examples/if.ts +++ b/src/compiled/examples/if.ts @@ -3,7 +3,7 @@ * This file is auto-generated. Do not edit manually: changes may be erased. * Generated by Aqua compiler: https://github.com/fluencelabs/aqua/. * If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues - * Aqua version: 0.1.8-SNAPSHOT + * Aqua version: 0.1.9-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; @@ -48,7 +48,7 @@ export async function print(client: FluenceClient, str: string, config?: {ttl?: .handleTimeout(() => { reject('Request timed out for print'); }) - if(config?.ttl) { + if(config && config.ttl) { r.withTTL(config.ttl) } request = r.build(); @@ -103,7 +103,7 @@ export async function ifElseCall(client: FluenceClient, condition: boolean, conf .handleTimeout(() => { reject('Request timed out for ifElseCall'); }) - if(config?.ttl) { + if(config && config.ttl) { r.withTTL(config.ttl) } request = r.build(); @@ -158,7 +158,7 @@ export async function ifElseNumCall(client: FluenceClient, condition: number, co .handleTimeout(() => { reject('Request timed out for ifElseNumCall'); }) - if(config?.ttl) { + if(config && config.ttl) { r.withTTL(config.ttl) } request = r.build(); diff --git a/src/compiled/examples/nestedFuncs.ts b/src/compiled/examples/nestedFuncs.ts index e9e86c0..8ffc01b 100644 --- a/src/compiled/examples/nestedFuncs.ts +++ b/src/compiled/examples/nestedFuncs.ts @@ -3,7 +3,7 @@ * This file is auto-generated. Do not edit manually: changes may be erased. * Generated by Aqua compiler: https://github.com/fluencelabs/aqua/. * If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues - * Aqua version: 0.1.8-SNAPSHOT + * Aqua version: 0.1.9-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; @@ -58,7 +58,7 @@ export async function a(client: FluenceClient, b: string, config?: {ttl?: number .handleTimeout(() => { reject('Request timed out for a'); }) - if(config?.ttl) { + if(config && config.ttl) { r.withTTL(config.ttl) } request = r.build(); @@ -115,7 +115,7 @@ export async function d(client: FluenceClient, e: string, config?: {ttl?: number .handleTimeout(() => { reject('Request timed out for d'); }) - if(config?.ttl) { + if(config && config.ttl) { r.withTTL(config.ttl) } request = r.build(); diff --git a/src/compiled/examples/on.ts b/src/compiled/examples/on.ts index f536a4d..71b1230 100644 --- a/src/compiled/examples/on.ts +++ b/src/compiled/examples/on.ts @@ -3,7 +3,7 @@ * This file is auto-generated. Do not edit manually: changes may be erased. * Generated by Aqua compiler: https://github.com/fluencelabs/aqua/. * If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues - * Aqua version: 0.1.8-SNAPSHOT + * Aqua version: 0.1.9-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; @@ -70,7 +70,7 @@ export async function getPeerExternalAddresses(client: FluenceClient, otherNodeP .handleTimeout(() => { reject('Request timed out for getPeerExternalAddresses'); }) - if(config?.ttl) { + if(config && config.ttl) { r.withTTL(config.ttl) } request = r.build(); @@ -155,7 +155,7 @@ h.on('getDataSrv', 'viaNode', () => {return viaNode;}); .handleTimeout(() => { reject('Request timed out for getDistantAddresses'); }) - if(config?.ttl) { + if(config && config.ttl) { r.withTTL(config.ttl) } request = r.build(); diff --git a/src/compiled/examples/option.ts b/src/compiled/examples/option.ts index 012461d..836f098 100644 --- a/src/compiled/examples/option.ts +++ b/src/compiled/examples/option.ts @@ -3,7 +3,7 @@ * This file is auto-generated. Do not edit manually: changes may be erased. * Generated by Aqua compiler: https://github.com/fluencelabs/aqua/. * If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues - * Aqua version: 0.1.8-SNAPSHOT + * Aqua version: 0.1.9-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; @@ -66,7 +66,7 @@ export async function useOptional(client: FluenceClient, opt: string | null, con .handleTimeout(() => { reject('Request timed out for useOptional'); }) - if(config?.ttl) { + if(config && config.ttl) { r.withTTL(config.ttl) } request = r.build(); diff --git a/src/compiled/examples/par.ts b/src/compiled/examples/par.ts index b3a1467..649ab1c 100644 --- a/src/compiled/examples/par.ts +++ b/src/compiled/examples/par.ts @@ -3,7 +3,7 @@ * This file is auto-generated. Do not edit manually: changes may be erased. * Generated by Aqua compiler: https://github.com/fluencelabs/aqua/. * If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues - * Aqua version: 0.1.8-SNAPSHOT + * Aqua version: 0.1.9-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; @@ -70,7 +70,7 @@ h.on('callbackSrv', 'c', (args) => {c(args[0]); return {};}); .handleTimeout(() => { reject('Request timed out for parFunc'); }) - if(config?.ttl) { + if(config && config.ttl) { r.withTTL(config.ttl) } request = r.build(); diff --git a/src/compiled/examples/println.ts b/src/compiled/examples/println.ts index b318b13..96f3c9a 100644 --- a/src/compiled/examples/println.ts +++ b/src/compiled/examples/println.ts @@ -3,7 +3,7 @@ * This file is auto-generated. Do not edit manually: changes may be erased. * Generated by Aqua compiler: https://github.com/fluencelabs/aqua/. * If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues - * Aqua version: 0.1.8-SNAPSHOT + * Aqua version: 0.1.9-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; @@ -48,7 +48,7 @@ export async function print(client: FluenceClient, str: string, config?: {ttl?: .handleTimeout(() => { reject('Request timed out for print'); }) - if(config?.ttl) { + if(config && config.ttl) { r.withTTL(config.ttl) } request = r.build(); diff --git a/src/compiled/examples/stream.ts b/src/compiled/examples/stream.ts index 07403e4..d08edb9 100644 --- a/src/compiled/examples/stream.ts +++ b/src/compiled/examples/stream.ts @@ -3,7 +3,7 @@ * This file is auto-generated. Do not edit manually: changes may be erased. * Generated by Aqua compiler: https://github.com/fluencelabs/aqua/. * If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues - * Aqua version: 0.1.8-SNAPSHOT + * Aqua version: 0.1.9-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; @@ -69,7 +69,7 @@ export async function checkStreams(client: FluenceClient, ch: string[], config?: .handleTimeout(() => { reject('Request timed out for checkStreams'); }) - if(config?.ttl) { + if(config && config.ttl) { r.withTTL(config.ttl) } request = r.build(); diff --git a/src/compiled/examples/topology.ts b/src/compiled/examples/topology.ts index bbc3e3e..1abfac6 100644 --- a/src/compiled/examples/topology.ts +++ b/src/compiled/examples/topology.ts @@ -3,7 +3,7 @@ * This file is auto-generated. Do not edit manually: changes may be erased. * Generated by Aqua compiler: https://github.com/fluencelabs/aqua/. * If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues - * Aqua version: 0.1.8-SNAPSHOT + * Aqua version: 0.1.9-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; @@ -100,7 +100,7 @@ h.on('getDataSrv', 'friendRelay', () => {return friendRelay;}); .handleTimeout(() => { reject('Request timed out for topologyTest'); }) - if(config?.ttl) { + if(config && config.ttl) { r.withTTL(config.ttl) } request = r.build(); diff --git a/src/compiled/examples/tryCatch.ts b/src/compiled/examples/tryCatch.ts index aeba5ad..8cbfb8b 100644 --- a/src/compiled/examples/tryCatch.ts +++ b/src/compiled/examples/tryCatch.ts @@ -3,7 +3,7 @@ * This file is auto-generated. Do not edit manually: changes may be erased. * Generated by Aqua compiler: https://github.com/fluencelabs/aqua/. * If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues - * Aqua version: 0.1.8-SNAPSHOT + * Aqua version: 0.1.9-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; @@ -79,7 +79,7 @@ export async function tryCatchTest(client: FluenceClient, node_id: string, confi .handleTimeout(() => { reject('Request timed out for tryCatchTest'); }) - if(config?.ttl) { + if(config && config.ttl) { r.withTTL(config.ttl) } request = r.build(); diff --git a/src/compiled/examples/tryOtherwise.ts b/src/compiled/examples/tryOtherwise.ts index 4c7316a..2ca0875 100644 --- a/src/compiled/examples/tryOtherwise.ts +++ b/src/compiled/examples/tryOtherwise.ts @@ -3,7 +3,7 @@ * This file is auto-generated. Do not edit manually: changes may be erased. * Generated by Aqua compiler: https://github.com/fluencelabs/aqua/. * If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues - * Aqua version: 0.1.8-SNAPSHOT + * Aqua version: 0.1.9-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; @@ -73,7 +73,7 @@ export async function tryOtherwiseTest(client: FluenceClient, node_id: string, c .handleTimeout(() => { reject('Request timed out for tryOtherwiseTest'); }) - if(config?.ttl) { + if(config && config.ttl) { r.withTTL(config.ttl) } request = r.build(); diff --git a/src/compiled/examples/via.ts b/src/compiled/examples/via.ts index 80bb3cd..c9945cd 100644 --- a/src/compiled/examples/via.ts +++ b/src/compiled/examples/via.ts @@ -3,7 +3,7 @@ * This file is auto-generated. Do not edit manually: changes may be erased. * Generated by Aqua compiler: https://github.com/fluencelabs/aqua/. * If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues - * Aqua version: 0.1.8-SNAPSHOT + * Aqua version: 0.1.9-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; @@ -101,7 +101,7 @@ h.on('getDataSrv', 'viaAr', () => {return viaAr;}); .handleTimeout(() => { reject('Request timed out for viaArr'); }) - if(config?.ttl) { + if(config && config.ttl) { r.withTTL(config.ttl) } request = r.build(); @@ -209,7 +209,7 @@ h.on('getDataSrv', 'viaStr', () => {return viaStr;}); .handleTimeout(() => { reject('Request timed out for viaStream'); }) - if(config?.ttl) { + if(config && config.ttl) { r.withTTL(config.ttl) } request = r.build(); @@ -313,7 +313,7 @@ h.on('getDataSrv', 'viaOpt', () => {return viaOpt === null ? [] : [viaOpt];}); .handleTimeout(() => { reject('Request timed out for viaOpt'); }) - if(config?.ttl) { + if(config && config.ttl) { r.withTTL(config.ttl) } request = r.build(); diff --git a/src/examples/passArgsCall.ts b/src/examples/passArgsCall.ts new file mode 100644 index 0000000..caaf27c --- /dev/null +++ b/src/examples/passArgsCall.ts @@ -0,0 +1,10 @@ +import {FluenceClient, registerServiceFunction} from "@fluencelabs/fluence"; +import {create_client_util} from "../compiled/examples/passArgs"; + +export async function passArgsCall(client: FluenceClient) { + registerServiceFunction(client, "test-dht", "put_host_value", (args: any[], _) => { + return args[0] + args[1] + }) + + return await create_client_util(client, "sid") +} \ No newline at end of file diff --git a/src/examples/streamArgsCall.ts b/src/examples/streamArgsCall.ts new file mode 100644 index 0000000..ed7c1dd --- /dev/null +++ b/src/examples/streamArgsCall.ts @@ -0,0 +1,10 @@ +import {FluenceClient, registerServiceFunction} from "@fluencelabs/fluence"; +import {retrieve_records} from "../compiled/examples/streamArgs"; + +export async function streamArgsCall(client: FluenceClient) { + registerServiceFunction(client, "test-service", "get_records", (args: any[], _) => { + return [args[0], args[0]] + }) + + return await retrieve_records(client, "peer_id") +} \ No newline at end of file diff --git a/src/examples/streamResultsCall.ts b/src/examples/streamResultsCall.ts new file mode 100644 index 0000000..43d2087 --- /dev/null +++ b/src/examples/streamResultsCall.ts @@ -0,0 +1,12 @@ +import {FluenceClient, registerServiceFunction} from "@fluencelabs/fluence"; +import {use_name2} from "../compiled/examples/streamResults"; + +export async function streamResultsCall(client: FluenceClient) { + registerServiceFunction(client, "get-dt", "get_dt", (args: any[], _) => { + return { + field: args[0] + } + }) + + return await use_name2(client, "new_name") +} \ No newline at end of file diff --git a/src/run-examples.ts b/src/run-examples.ts index 7275c6b..a76040b 100644 --- a/src/run-examples.ts +++ b/src/run-examples.ts @@ -22,6 +22,9 @@ import {assignmentCall} from "./examples/assignment"; import {tryCatchCall} from "./examples/tryCatchCall"; import {tryOtherwiseCall} from "./examples/tryOtherwiseCall"; import {coCall} from "./examples/coCall"; +import {passArgsCall} from "./examples/passArgsCall"; +import {streamArgsCall} from "./examples/streamArgsCall"; +import {streamResultsCall} from "./examples/streamResultsCall"; let deepEqual = require('deep-equal') function checkCall(name: string, expected: any, actual: any, callBackOnError: () => void) { @@ -120,7 +123,14 @@ const main = async () => { // coCall.aqua let coCallResult = await coCall(client) - console.log(tryCatchResult[0]) + // passArgsCall.aqua + let passArgsResult = await passArgsCall(client) + + // streamArgs.aqua + let streamArgsResult = await streamArgsCall(client) + + // streamResults.aqua + let streamResultsResult = await streamResultsCall(client) await client.disconnect(); @@ -165,6 +175,12 @@ const main = async () => { checkCall("coCall", coCallResult, [ '/ip4/164.90.171.139/tcp/7770', '/ip4/164.90.171.139/tcp/9990/ws' ], cb) + checkCall("passArgsCall", passArgsResult, "client-utilsid", cb) + + checkCall("streamArgsCall", streamArgsResult, [["peer_id", "peer_id"]], cb) + + checkCall("streamResultsCall", streamResultsResult, ["new_name", "new_name", "new_name"], cb) + checkCallBy("tryCatchCall", tryCatchResult, (res) => { return (res[0] as string).includes("Error: Service with id 'unex' not found") && res[1] === '/ip4/164.90.171.139/tcp/7770' }, cb)