diff --git a/aqua/examples/imports_exports/exports.aqua b/aqua/examples/imports_exports/exports.aqua index 8d7ef42..838fcc2 100644 --- a/aqua/examples/imports_exports/exports.aqua +++ b/aqua/examples/imports_exports/exports.aqua @@ -4,6 +4,8 @@ module Exports declares * export some_string as string_from_lib export MyExportSrv +const EXPORT_CONST = "export_const" + service MyExportSrv("my_export_srv"): another_str() -> string diff --git a/aqua/examples/imports_exports/imports.aqua b/aqua/examples/imports_exports/imports.aqua index 7a7a5a0..2cc61de 100644 --- a/aqua/examples/imports_exports/imports.aqua +++ b/aqua/examples/imports_exports/imports.aqua @@ -1,7 +1,7 @@ import decl_foo, decl_bar from "declare.aqua" use SuperFoo from "declare.aqua" as Declare import Op as Noop from "@fluencelabs/aqua-lib/builtin.aqua" -import some_string, MyExportSrv from "exports.aqua" +import some_string, MyExportSrv, EXPORT_CONST from "exports.aqua" service StringService("string_service"): concat(a: string, b: string) -> string @@ -12,4 +12,5 @@ func concat_foobars() -> string: res3 <- StringService.concat(res1, res2) res4 <- Declare.SuperFoo.small_foo() res5 <- StringService.concat(res3, res4) - <- res5 \ No newline at end of file + res6 <- StringService.concat(res5, EXPORT_CONST) + <- res6 \ No newline at end of file diff --git a/src/compiled/examples/assignment.ts b/src/compiled/examples/assignment.ts index ad67ecd..fc08046 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.2.1-SNAPSHOT + * Aqua version: 0.2.2-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; diff --git a/src/compiled/examples/callArrow.ts b/src/compiled/examples/callArrow.ts index b97c33f..da7ebef 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.2.1-SNAPSHOT + * Aqua version: 0.2.2-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; diff --git a/src/compiled/examples/co.ts b/src/compiled/examples/co.ts index 7b2256e..e77392e 100644 --- a/src/compiled/examples/co.ts +++ b/src/compiled/examples/co.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.2.1-SNAPSHOT + * Aqua version: 0.2.2-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; diff --git a/src/compiled/examples/complex.ts b/src/compiled/examples/complex.ts index b1b96e4..d01a501 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.2.1-SNAPSHOT + * Aqua version: 0.2.2-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; diff --git a/src/compiled/examples/constants.ts b/src/compiled/examples/constants.ts index 45909ea..d1ae7c8 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.2.1-SNAPSHOT + * Aqua version: 0.2.2-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; diff --git a/src/compiled/examples/dataAlias.ts b/src/compiled/examples/dataAlias.ts index 94cfd0d..4c82648 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.2.1-SNAPSHOT + * Aqua version: 0.2.2-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; diff --git a/src/compiled/examples/example.ts b/src/compiled/examples/example.ts index e9cc060..b2872dc 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.2.1-SNAPSHOT + * Aqua version: 0.2.2-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; diff --git a/src/compiled/examples/fldist-sample.ts b/src/compiled/examples/fldist-sample.ts index 3a8f411..8f0b738 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.2.1-SNAPSHOT + * Aqua version: 0.2.2-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; diff --git a/src/compiled/examples/fold.ts b/src/compiled/examples/fold.ts index d8854fd..8360dda 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.2.1-SNAPSHOT + * Aqua version: 0.2.2-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; diff --git a/src/compiled/examples/foldJoin.ts b/src/compiled/examples/foldJoin.ts index 4c17b7d..6f56d6d 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.2.1-SNAPSHOT + * Aqua version: 0.2.2-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; diff --git a/src/compiled/examples/func.ts b/src/compiled/examples/func.ts index b89244b..72c72b2 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.2.1-SNAPSHOT + * Aqua version: 0.2.2-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; diff --git a/src/compiled/examples/helloWorld.ts b/src/compiled/examples/helloWorld.ts index 98e392d..0c86db3 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.2.1-SNAPSHOT + * Aqua version: 0.2.2-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; diff --git a/src/compiled/examples/if.ts b/src/compiled/examples/if.ts index 6e90818..8125dc9 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.2.1-SNAPSHOT + * Aqua version: 0.2.2-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; diff --git a/src/compiled/examples/imports_exports/exports.ts b/src/compiled/examples/imports_exports/exports.ts new file mode 100644 index 0000000..1bfd48f --- /dev/null +++ b/src/compiled/examples/imports_exports/exports.ts @@ -0,0 +1,74 @@ +/** + * + * 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.2.2-SNAPSHOT + * + */ +import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; +import { RequestFlowBuilder } from '@fluencelabs/fluence/dist/api.unstable'; +import { RequestFlow } from '@fluencelabs/fluence/dist/internal/RequestFlow'; + + +// Services + +//MyExportSrv +//defaultId = "my_export_srv" + +//another_str: () => string +//END MyExportSrv + + + +// Functions + +export async function string_from_lib(client: FluenceClient, config?: {ttl?: number}): Promise { + let request: RequestFlow; + const promise = new Promise((resolve, reject) => { + const r = new RequestFlowBuilder() + .disableInjections() + .withRawScript( + ` +(xor + (seq + (call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-) + (xor + (call %init_peer_id% ("callbackSrv" "response") ["some_string_func"]) + (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1]) + ) + ) + (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2]) +) + + `, + ) + .configHandler((h) => { + h.on('getDataSrv', '-relay-', () => { + return client.relayPeerId!; + }); + + h.onEvent('callbackSrv', 'response', (args) => { + const [res] = args; + resolve(res); +}); + + h.onEvent('errorHandlingSrv', 'error', (args) => { + // assuming error is the single argument + const [err] = args; + reject(err); + }); + }) + .handleScriptError(reject) + .handleTimeout(() => { + reject('Request timed out for string_from_lib'); + }) + if(config && config.ttl) { + r.withTTL(config.ttl) + } + request = r.build(); + }); + await client.initiateFlow(request!); + return promise; +} + diff --git a/src/compiled/examples/imports_exports/gen/OneMore.ts b/src/compiled/examples/imports_exports/gen/OneMore.ts new file mode 100644 index 0000000..7745814 --- /dev/null +++ b/src/compiled/examples/imports_exports/gen/OneMore.ts @@ -0,0 +1,25 @@ +/** + * + * 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.2.2-SNAPSHOT + * + */ +import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; +import { RequestFlowBuilder } from '@fluencelabs/fluence/dist/api.unstable'; +import { RequestFlow } from '@fluencelabs/fluence/dist/internal/RequestFlow'; + + +// Services + +//OneMore +//defaultId = undefined + +//more_call: () => void +//END OneMore + + + +// Functions + diff --git a/src/compiled/examples/imports_exports/import2.ts b/src/compiled/examples/imports_exports/import2.ts new file mode 100644 index 0000000..b199ecf --- /dev/null +++ b/src/compiled/examples/imports_exports/import2.ts @@ -0,0 +1,130 @@ +/** + * + * 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.2.2-SNAPSHOT + * + */ +import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; +import { RequestFlowBuilder } from '@fluencelabs/fluence/dist/api.unstable'; +import { RequestFlow } from '@fluencelabs/fluence/dist/internal/RequestFlow'; + + +// Services + + +// Functions + +export async function wrap(client: FluenceClient, config?: {ttl?: number}): Promise { + let request: RequestFlow; + const promise = new Promise((resolve, reject) => { + const r = new RequestFlowBuilder() + .disableInjections() + .withRawScript( + ` +(xor + (seq + (seq + (seq + (call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-) + (call %init_peer_id% ("hello" "more_call") []) + ) + (call %init_peer_id% ("ohmygod" "more_call") []) + ) + (xor + (call %init_peer_id% ("callbackSrv" "response") ["I am MyFooBar foo"]) + (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1]) + ) + ) + (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2]) +) + + `, + ) + .configHandler((h) => { + h.on('getDataSrv', '-relay-', () => { + return client.relayPeerId!; + }); + + h.onEvent('callbackSrv', 'response', (args) => { + const [res] = args; + resolve(res); +}); + + h.onEvent('errorHandlingSrv', 'error', (args) => { + // assuming error is the single argument + const [err] = args; + reject(err); + }); + }) + .handleScriptError(reject) + .handleTimeout(() => { + reject('Request timed out for wrap'); + }) + if(config && config.ttl) { + r.withTTL(config.ttl) + } + request = r.build(); + }); + await client.initiateFlow(request!); + return promise; +} + + + +export async function barfoo(client: FluenceClient, config?: {ttl?: number}): Promise { + let request: RequestFlow; + const promise = new Promise((resolve, reject) => { + const r = new RequestFlowBuilder() + .disableInjections() + .withRawScript( + ` +(xor + (seq + (seq + (seq + (call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-) + (ap "I am MyFooBar foo" $res) + ) + (ap " I am MyFooBar bar" $res) + ) + (xor + (call %init_peer_id% ("callbackSrv" "response") [$res]) + (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1]) + ) + ) + (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2]) +) + + `, + ) + .configHandler((h) => { + h.on('getDataSrv', '-relay-', () => { + return client.relayPeerId!; + }); + + h.onEvent('callbackSrv', 'response', (args) => { + const [res] = args; + resolve(res); +}); + + h.onEvent('errorHandlingSrv', 'error', (args) => { + // assuming error is the single argument + const [err] = args; + reject(err); + }); + }) + .handleScriptError(reject) + .handleTimeout(() => { + reject('Request timed out for barfoo'); + }) + if(config && config.ttl) { + r.withTTL(config.ttl) + } + request = r.build(); + }); + await client.initiateFlow(request!); + return promise; +} + diff --git a/src/compiled/examples/imports_exports/imports.ts b/src/compiled/examples/imports_exports/imports.ts new file mode 100644 index 0000000..2b6ec6b --- /dev/null +++ b/src/compiled/examples/imports_exports/imports.ts @@ -0,0 +1,86 @@ +/** + * + * 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.2.2-SNAPSHOT + * + */ +import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; +import { RequestFlowBuilder } from '@fluencelabs/fluence/dist/api.unstable'; +import { RequestFlow } from '@fluencelabs/fluence/dist/internal/RequestFlow'; + + +// Services + +//StringService +//defaultId = "string_service" + +//concat: (a: string, b: string) => string +//END StringService + + + +// Functions + +export async function concat_foobars(client: FluenceClient, config?: {ttl?: number}): Promise { + let request: RequestFlow; + const promise = new Promise((resolve, reject) => { + const r = new RequestFlowBuilder() + .disableInjections() + .withRawScript( + ` +(xor + (seq + (seq + (seq + (seq + (seq + (call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-) + (call %init_peer_id% ("string_service" "concat") ["declare all foo" "declare all bar"] res3) + ) + (call %init_peer_id% ("super_foo" "small_foo") [] res4) + ) + (call %init_peer_id% ("string_service" "concat") [res3 res4] res5) + ) + (call %init_peer_id% ("string_service" "concat") [res5 "export_const"] res6) + ) + (xor + (call %init_peer_id% ("callbackSrv" "response") [res6]) + (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1]) + ) + ) + (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2]) +) + + `, + ) + .configHandler((h) => { + h.on('getDataSrv', '-relay-', () => { + return client.relayPeerId!; + }); + + h.onEvent('callbackSrv', 'response', (args) => { + const [res] = args; + resolve(res); +}); + + h.onEvent('errorHandlingSrv', 'error', (args) => { + // assuming error is the single argument + const [err] = args; + reject(err); + }); + }) + .handleScriptError(reject) + .handleTimeout(() => { + reject('Request timed out for concat_foobars'); + }) + if(config && config.ttl) { + r.withTTL(config.ttl) + } + request = r.build(); + }); + await client.initiateFlow(request!); + return promise; +} + diff --git a/src/compiled/examples/imports_exports/subImport.ts b/src/compiled/examples/imports_exports/subImport.ts new file mode 100644 index 0000000..a0d7a65 --- /dev/null +++ b/src/compiled/examples/imports_exports/subImport.ts @@ -0,0 +1,77 @@ +/** + * + * 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.2.2-SNAPSHOT + * + */ +import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; +import { RequestFlowBuilder } from '@fluencelabs/fluence/dist/api.unstable'; +import { RequestFlow } from '@fluencelabs/fluence/dist/internal/RequestFlow'; + + +// Services + +//SubService +//defaultId = "sub_service" + +//sub: (s: string) => {one:string;two:number} +//END SubService + + + +// Functions + +export async function subImport(client: FluenceClient, config?: {ttl?: number}): Promise<{one:string;two:number}> { + let request: RequestFlow; + const promise = new Promise<{one:string;two:number}>((resolve, reject) => { + const r = new RequestFlowBuilder() + .disableInjections() + .withRawScript( + ` +(xor + (seq + (seq + (call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-) + (call %init_peer_id% ("sub_service" "sub") ["some thing"] res) + ) + (xor + (call %init_peer_id% ("callbackSrv" "response") [res]) + (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1]) + ) + ) + (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2]) +) + + `, + ) + .configHandler((h) => { + h.on('getDataSrv', '-relay-', () => { + return client.relayPeerId!; + }); + + h.onEvent('callbackSrv', 'response', (args) => { + const [res] = args; + resolve(res); +}); + + h.onEvent('errorHandlingSrv', 'error', (args) => { + // assuming error is the single argument + const [err] = args; + reject(err); + }); + }) + .handleScriptError(reject) + .handleTimeout(() => { + reject('Request timed out for subImport'); + }) + if(config && config.ttl) { + r.withTTL(config.ttl) + } + request = r.build(); + }); + await client.initiateFlow(request!); + return promise; +} + diff --git a/src/compiled/examples/multiReturn.ts b/src/compiled/examples/multiReturn.ts index 5d51d55..c2bb559 100644 --- a/src/compiled/examples/multiReturn.ts +++ b/src/compiled/examples/multiReturn.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.2.1-SNAPSHOT + * Aqua version: 0.2.2-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; diff --git a/src/compiled/examples/nestedFuncs.ts b/src/compiled/examples/nestedFuncs.ts index 150de4c..2dd1f75 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.2.1-SNAPSHOT + * Aqua version: 0.2.2-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; diff --git a/src/compiled/examples/on.ts b/src/compiled/examples/on.ts index 09aa876..34b2f1b 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.2.1-SNAPSHOT + * Aqua version: 0.2.2-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; diff --git a/src/compiled/examples/option.ts b/src/compiled/examples/option.ts index e615409..bad652a 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.2.1-SNAPSHOT + * Aqua version: 0.2.2-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; diff --git a/src/compiled/examples/par.ts b/src/compiled/examples/par.ts index a6de681..115fcce 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.2.1-SNAPSHOT + * Aqua version: 0.2.2-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; diff --git a/src/compiled/examples/passArgs.ts b/src/compiled/examples/passArgs.ts index acc1db3..b1405ab 100644 --- a/src/compiled/examples/passArgs.ts +++ b/src/compiled/examples/passArgs.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.2.1-SNAPSHOT + * Aqua version: 0.2.2-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; diff --git a/src/compiled/examples/println.ts b/src/compiled/examples/println.ts index 97ff609..ff14f13 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.2.1-SNAPSHOT + * Aqua version: 0.2.2-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; diff --git a/src/compiled/examples/pushToStream.ts b/src/compiled/examples/pushToStream.ts index 0b52ed2..97e983f 100644 --- a/src/compiled/examples/pushToStream.ts +++ b/src/compiled/examples/pushToStream.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.2.1-SNAPSHOT + * Aqua version: 0.2.2-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; diff --git a/src/compiled/examples/returnLiteral.ts b/src/compiled/examples/returnLiteral.ts new file mode 100644 index 0000000..ee45e71 --- /dev/null +++ b/src/compiled/examples/returnLiteral.ts @@ -0,0 +1,67 @@ +/** + * + * 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.2.2-SNAPSHOT + * + */ +import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; +import { RequestFlowBuilder } from '@fluencelabs/fluence/dist/api.unstable'; +import { RequestFlow } from '@fluencelabs/fluence/dist/internal/RequestFlow'; + + +// Services + + +// Functions + +export async function returnLiteral(client: FluenceClient, config?: {ttl?: number}): Promise { + let request: RequestFlow; + const promise = new Promise((resolve, reject) => { + const r = new RequestFlowBuilder() + .disableInjections() + .withRawScript( + ` +(xor + (seq + (call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-) + (xor + (call %init_peer_id% ("callbackSrv" "response") ["some literal"]) + (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1]) + ) + ) + (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2]) +) + + `, + ) + .configHandler((h) => { + h.on('getDataSrv', '-relay-', () => { + return client.relayPeerId!; + }); + + h.onEvent('callbackSrv', 'response', (args) => { + const [res] = args; + resolve(res); +}); + + h.onEvent('errorHandlingSrv', 'error', (args) => { + // assuming error is the single argument + const [err] = args; + reject(err); + }); + }) + .handleScriptError(reject) + .handleTimeout(() => { + reject('Request timed out for returnLiteral'); + }) + if(config && config.ttl) { + r.withTTL(config.ttl) + } + request = r.build(); + }); + await client.initiateFlow(request!); + return promise; +} + diff --git a/src/compiled/examples/stream.ts b/src/compiled/examples/stream.ts index 1e16482..0372e1a 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.2.1-SNAPSHOT + * Aqua version: 0.2.2-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; diff --git a/src/compiled/examples/streamArgs.ts b/src/compiled/examples/streamArgs.ts index e457129..ce62ec3 100644 --- a/src/compiled/examples/streamArgs.ts +++ b/src/compiled/examples/streamArgs.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.2.1-SNAPSHOT + * Aqua version: 0.2.2-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; diff --git a/src/compiled/examples/streamResults.ts b/src/compiled/examples/streamResults.ts index dcd744f..e154fd5 100644 --- a/src/compiled/examples/streamResults.ts +++ b/src/compiled/examples/streamResults.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.2.1-SNAPSHOT + * Aqua version: 0.2.2-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; diff --git a/src/compiled/examples/subImportUsage.ts b/src/compiled/examples/subImportUsage.ts new file mode 100644 index 0000000..5acea05 --- /dev/null +++ b/src/compiled/examples/subImportUsage.ts @@ -0,0 +1,86 @@ +/** + * + * 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.2.2-SNAPSHOT + * + */ +import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; +import { RequestFlowBuilder } from '@fluencelabs/fluence/dist/api.unstable'; +import { RequestFlow } from '@fluencelabs/fluence/dist/internal/RequestFlow'; + + +// Services + +//ConcatSubs +//defaultId = "concat_subs" + +//get_some: (s: string, sr: {one:string;two:number}) => {one:string;two:number} +//END ConcatSubs + + + +// Functions + +export async function subImportUsage(client: FluenceClient, s: string, config?: {ttl?: number}): Promise<{one:string;two:number}> { + let request: RequestFlow; + const promise = new Promise<{one:string;two:number}>((resolve, reject) => { + const r = new RequestFlowBuilder() + .disableInjections() + .withRawScript( + ` +(xor + (seq + (seq + (seq + (seq + (seq + (call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-) + (call %init_peer_id% ("getDataSrv" "s") [] s) + ) + (call %init_peer_id% ("sub_service" "sub") [s] sr1) + ) + (call %init_peer_id% ("sub_service" "sub") ["some thing"] res) + ) + (call %init_peer_id% ("concat_subs" "get_some") [sr1.$.one! res] result) + ) + (xor + (call %init_peer_id% ("callbackSrv" "response") [result]) + (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1]) + ) + ) + (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2]) +) + + `, + ) + .configHandler((h) => { + h.on('getDataSrv', '-relay-', () => { + return client.relayPeerId!; + }); + h.on('getDataSrv', 's', () => {return s;}); + h.onEvent('callbackSrv', 'response', (args) => { + const [res] = args; + resolve(res); +}); + + h.onEvent('errorHandlingSrv', 'error', (args) => { + // assuming error is the single argument + const [err] = args; + reject(err); + }); + }) + .handleScriptError(reject) + .handleTimeout(() => { + reject('Request timed out for subImportUsage'); + }) + if(config && config.ttl) { + r.withTTL(config.ttl) + } + request = r.build(); + }); + await client.initiateFlow(request!); + return promise; +} + diff --git a/src/compiled/examples/topology.ts b/src/compiled/examples/topology.ts index ebb2254..3daf7d4 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.2.1-SNAPSHOT + * Aqua version: 0.2.2-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; diff --git a/src/compiled/examples/tryCatch.ts b/src/compiled/examples/tryCatch.ts index a716027..6a95e3a 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.2.1-SNAPSHOT + * Aqua version: 0.2.2-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; diff --git a/src/compiled/examples/tryOtherwise.ts b/src/compiled/examples/tryOtherwise.ts index b730501..c35c45c 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.2.1-SNAPSHOT + * Aqua version: 0.2.2-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; diff --git a/src/compiled/examples/via.ts b/src/compiled/examples/via.ts index 791fcf4..5c27d50 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.2.1-SNAPSHOT + * Aqua version: 0.2.2-SNAPSHOT * */ import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence'; diff --git a/src/run-examples.ts b/src/run-examples.ts index 151ff36..2ad44c2 100644 --- a/src/run-examples.ts +++ b/src/run-examples.ts @@ -215,7 +215,7 @@ const main = async () => { checkCall("multiReturnResult", multiReturnResult, [ [ 'some-str', 'random-str', 'some-str' ], 5, 'some-str', [ 1, 2 ], null, 10], cb) - checkCall("declareResult", declareResult, 'declare all foodeclare all barsmall_foo', cb) + checkCall("declareResult", declareResult, 'declare all foodeclare all barsmall_fooexport_const', cb) checkCall("subImportResult", subImportResult, { one: "random_string", two: 42 }, cb)