diff --git a/src/compiled/examples/assignment.ts b/src/compiled/examples/assignment.ts index 1a1dd80..e69fc68 100644 --- a/src/compiled/examples/assignment.ts +++ b/src/compiled/examples/assignment.ts @@ -15,9 +15,8 @@ import { RequestFlow } from '@fluencelabs/fluence/dist/internal/RequestFlow'; export async function doSmth(client: FluenceClient, arg: {value:string}, config?: {ttl?: number}): Promise { let request: RequestFlow; const promise = new Promise((resolve, reject) => { - request = new RequestFlowBuilder() + const r = new RequestFlowBuilder() .disableInjections() - .withTTL(config?.ttl || 5000) .withRawScript( ` (xor @@ -62,7 +61,10 @@ export async function doSmth(client: FluenceClient, arg: {value:string}, config? .handleTimeout(() => { reject('Request timed out for doSmth'); }) - .build(); + if(config?.ttl) { + r.withTTL(config.ttl) + } + request = r.build(); }); await client.initiateFlow(request!); return promise; diff --git a/src/compiled/examples/callArrow.ts b/src/compiled/examples/callArrow.ts index bcd3642..ad8d933 100644 --- a/src/compiled/examples/callArrow.ts +++ b/src/compiled/examples/callArrow.ts @@ -15,9 +15,8 @@ import { RequestFlow } from '@fluencelabs/fluence/dist/internal/RequestFlow'; export async function print(client: FluenceClient, str: string, config?: {ttl?: number}): Promise { let request: RequestFlow; const promise = new Promise((resolve, reject) => { - request = new RequestFlowBuilder() + const r = new RequestFlowBuilder() .disableInjections() - .withTTL(config?.ttl || 5000) .withRawScript( ` (xor @@ -49,7 +48,10 @@ export async function print(client: FluenceClient, str: string, config?: {ttl?: .handleTimeout(() => { reject('Request timed out for print'); }) - .build(); + if(config?.ttl) { + r.withTTL(config.ttl) + } + request = r.build(); }); await client.initiateFlow(request!); return Promise.race([promise, Promise.resolve()]); @@ -60,9 +62,8 @@ export async function print(client: FluenceClient, str: string, config?: {ttl?: export async function passFunctionAsArg(client: FluenceClient, node: string, str: string, c: (arg0: string) => string, config?: {ttl?: number}): Promise { let request: RequestFlow; const promise = new Promise((resolve, reject) => { - request = new RequestFlowBuilder() + const r = new RequestFlowBuilder() .disableInjections() - .withTTL(config?.ttl || 5000) .withRawScript( ` (xor @@ -129,7 +130,10 @@ h.on('callbackSrv', 'c', (args) => {return c(args[0]);}); .handleTimeout(() => { reject('Request timed out for passFunctionAsArg'); }) - .build(); + if(config?.ttl) { + r.withTTL(config.ttl) + } + request = r.build(); }); await client.initiateFlow(request!); return Promise.race([promise, Promise.resolve()]); diff --git a/src/compiled/examples/complex.ts b/src/compiled/examples/complex.ts index 9747460..9e188cf 100644 --- a/src/compiled/examples/complex.ts +++ b/src/compiled/examples/complex.ts @@ -15,9 +15,8 @@ import { RequestFlow } from '@fluencelabs/fluence/dist/internal/RequestFlow'; export async function helloWorld(client: FluenceClient, name: string, config?: {ttl?: number}): Promise { let request: RequestFlow; const promise = new Promise((resolve, reject) => { - request = new RequestFlowBuilder() + const r = new RequestFlowBuilder() .disableInjections() - .withTTL(config?.ttl || 5000) .withRawScript( ` (xor @@ -59,7 +58,10 @@ export async function helloWorld(client: FluenceClient, name: string, config?: { .handleTimeout(() => { reject('Request timed out for helloWorld'); }) - .build(); + if(config?.ttl) { + r.withTTL(config.ttl) + } + request = r.build(); }); await client.initiateFlow(request!); return promise; @@ -70,9 +72,8 @@ export async function helloWorld(client: FluenceClient, name: string, config?: { export async function print(client: FluenceClient, str: string, config?: {ttl?: number}): Promise { let request: RequestFlow; const promise = new Promise((resolve, reject) => { - request = new RequestFlowBuilder() + const r = new RequestFlowBuilder() .disableInjections() - .withTTL(config?.ttl || 5000) .withRawScript( ` (xor @@ -104,7 +105,10 @@ export async function print(client: FluenceClient, str: string, config?: {ttl?: .handleTimeout(() => { reject('Request timed out for print'); }) - .build(); + if(config?.ttl) { + r.withTTL(config.ttl) + } + request = r.build(); }); await client.initiateFlow(request!); return Promise.race([promise, Promise.resolve()]); @@ -115,9 +119,8 @@ export async function print(client: FluenceClient, str: string, config?: {ttl?: export async function testFunc(client: FluenceClient, config?: {ttl?: number}): Promise { let request: RequestFlow; const promise = new Promise((resolve, reject) => { - request = new RequestFlowBuilder() + const r = new RequestFlowBuilder() .disableInjections() - .withTTL(config?.ttl || 5000) .withRawScript( ` (xor @@ -156,7 +159,10 @@ export async function testFunc(client: FluenceClient, config?: {ttl?: number}): .handleTimeout(() => { reject('Request timed out for testFunc'); }) - .build(); + if(config?.ttl) { + r.withTTL(config.ttl) + } + request = r.build(); }); await client.initiateFlow(request!); return promise; @@ -167,9 +173,8 @@ export async function testFunc(client: FluenceClient, config?: {ttl?: number}): export async function doStuff(client: FluenceClient, a: string, b: string, c: boolean, d: boolean, e: string[], g: string[], str: string, config?: {ttl?: number}): Promise { let request: RequestFlow; const promise = new Promise((resolve, reject) => { - request = new RequestFlowBuilder() + const r = new RequestFlowBuilder() .disableInjections() - .withTTL(config?.ttl || 5000) .withRawScript( ` (xor @@ -186,91 +191,103 @@ export async function doStuff(client: FluenceClient, a: string, b: string, c: bo (seq (seq (seq - (call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-) - (call %init_peer_id% ("getDataSrv" "a") [] a) + (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" "b") [] b) + (call %init_peer_id% ("getDataSrv" "c") [] c) ) - (call %init_peer_id% ("getDataSrv" "c") [] c) + (call %init_peer_id% ("getDataSrv" "d") [] d) ) - (call %init_peer_id% ("getDataSrv" "d") [] d) + (call %init_peer_id% ("getDataSrv" "e") [] e) ) - (call %init_peer_id% ("getDataSrv" "e") [] e) + (call %init_peer_id% ("getDataSrv" "g") [] g) ) - (call %init_peer_id% ("getDataSrv" "g") [] g) + (call %init_peer_id% ("getDataSrv" "str") [] str) ) - (call %init_peer_id% ("getDataSrv" "str") [] str) - ) - (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") []) + (par (seq (seq - (call -relay- ("op" "noop") []) - (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1]) - ) - (call -relay- ("op" "noop") []) - ) - ) - ) - ) - ) - (call -relay- ("op" "noop") []) - ) - (xor - (seq - (call -relay- ("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) - ) + (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% 2]) + (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1]) ) + (call -relay- ("op" "noop") []) ) ) - (null) ) ) - (null) + ) + (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) + ) + ) + (seq + (call -relay- ("op" "noop") []) + (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2]) + ) + ) + ) + (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") []) ) @@ -312,7 +329,10 @@ h.on('getDataSrv', 'str', () => {return str;}); .handleTimeout(() => { reject('Request timed out for doStuff'); }) - .build(); + if(config?.ttl) { + r.withTTL(config.ttl) + } + request = r.build(); }); await client.initiateFlow(request!); return promise; diff --git a/src/compiled/examples/constants.ts b/src/compiled/examples/constants.ts index 54ea580..169200f 100644 --- a/src/compiled/examples/constants.ts +++ b/src/compiled/examples/constants.ts @@ -15,9 +15,8 @@ import { RequestFlow } from '@fluencelabs/fluence/dist/internal/RequestFlow'; export async function callConstant(client: FluenceClient, config?: {ttl?: number}): Promise { let request: RequestFlow; const promise = new Promise((resolve, reject) => { - request = new RequestFlowBuilder() + const r = new RequestFlowBuilder() .disableInjections() - .withTTL(config?.ttl || 5000) .withRawScript( ` (xor @@ -59,7 +58,10 @@ export async function callConstant(client: FluenceClient, config?: {ttl?: number .handleTimeout(() => { reject('Request timed out for callConstant'); }) - .build(); + if(config?.ttl) { + r.withTTL(config.ttl) + } + request = r.build(); }); await client.initiateFlow(request!); return promise; diff --git a/src/compiled/examples/dataAlias.ts b/src/compiled/examples/dataAlias.ts index 4517aca..6b00498 100644 --- a/src/compiled/examples/dataAlias.ts +++ b/src/compiled/examples/dataAlias.ts @@ -15,9 +15,8 @@ import { RequestFlow } from '@fluencelabs/fluence/dist/internal/RequestFlow'; export async function getAliasedData(client: FluenceClient, config?: {ttl?: number}): Promise { let request: RequestFlow; const promise = new Promise((resolve, reject) => { - request = new RequestFlowBuilder() + const r = new RequestFlowBuilder() .disableInjections() - .withTTL(config?.ttl || 5000) .withRawScript( ` (xor @@ -56,7 +55,10 @@ export async function getAliasedData(client: FluenceClient, config?: {ttl?: numb .handleTimeout(() => { reject('Request timed out for getAliasedData'); }) - .build(); + if(config?.ttl) { + r.withTTL(config.ttl) + } + request = r.build(); }); await client.initiateFlow(request!); return promise; diff --git a/src/compiled/examples/example.ts b/src/compiled/examples/example.ts index 6b5e0f9..f99b552 100644 --- a/src/compiled/examples/example.ts +++ b/src/compiled/examples/example.ts @@ -15,9 +15,8 @@ import { RequestFlow } from '@fluencelabs/fluence/dist/internal/RequestFlow'; export async function betterMessage(client: FluenceClient, relay: string, config?: {ttl?: number}): Promise { let request: RequestFlow; const promise = new Promise((resolve, reject) => { - request = new RequestFlowBuilder() + const r = new RequestFlowBuilder() .disableInjections() - .withTTL(config?.ttl || 5000) .withRawScript( ` (xor @@ -72,7 +71,10 @@ export async function betterMessage(client: FluenceClient, relay: string, config .handleTimeout(() => { reject('Request timed out for betterMessage'); }) - .build(); + if(config?.ttl) { + r.withTTL(config.ttl) + } + request = r.build(); }); await client.initiateFlow(request!); return Promise.race([promise, Promise.resolve()]); diff --git a/src/compiled/examples/fldist-sample.ts b/src/compiled/examples/fldist-sample.ts index 4a400fe..99a81db 100644 --- a/src/compiled/examples/fldist-sample.ts +++ b/src/compiled/examples/fldist-sample.ts @@ -15,9 +15,8 @@ import { RequestFlow } from '@fluencelabs/fluence/dist/internal/RequestFlow'; export async function test(client: FluenceClient, node: string, config?: {ttl?: number}): Promise { let request: RequestFlow; const promise = new Promise((resolve, reject) => { - request = new RequestFlowBuilder() + const r = new RequestFlowBuilder() .disableInjections() - .withTTL(config?.ttl || 5000) .withRawScript( ` (xor @@ -64,7 +63,10 @@ export async function test(client: FluenceClient, node: string, config?: {ttl?: .handleTimeout(() => { reject('Request timed out for test'); }) - .build(); + if(config?.ttl) { + r.withTTL(config.ttl) + } + request = r.build(); }); await client.initiateFlow(request!); return Promise.race([promise, Promise.resolve()]); diff --git a/src/compiled/examples/fold.ts b/src/compiled/examples/fold.ts index 5392619..38d7d51 100644 --- a/src/compiled/examples/fold.ts +++ b/src/compiled/examples/fold.ts @@ -15,9 +15,8 @@ import { RequestFlow } from '@fluencelabs/fluence/dist/internal/RequestFlow'; export async function print(client: FluenceClient, str: string, config?: {ttl?: number}): Promise { let request: RequestFlow; const promise = new Promise((resolve, reject) => { - request = new RequestFlowBuilder() + const r = new RequestFlowBuilder() .disableInjections() - .withTTL(config?.ttl || 5000) .withRawScript( ` (xor @@ -49,7 +48,10 @@ export async function print(client: FluenceClient, str: string, config?: {ttl?: .handleTimeout(() => { reject('Request timed out for print'); }) - .build(); + if(config?.ttl) { + r.withTTL(config.ttl) + } + request = r.build(); }); await client.initiateFlow(request!); return Promise.race([promise, Promise.resolve()]); @@ -60,9 +62,8 @@ export async function print(client: FluenceClient, str: string, config?: {ttl?: export async function iterateAndPrint(client: FluenceClient, strings: string[], config?: {ttl?: number}): Promise { let request: RequestFlow; const promise = new Promise((resolve, reject) => { - request = new RequestFlowBuilder() + const r = new RequestFlowBuilder() .disableInjections() - .withTTL(config?.ttl || 5000) .withRawScript( ` (xor @@ -99,7 +100,10 @@ export async function iterateAndPrint(client: FluenceClient, strings: string[], .handleTimeout(() => { reject('Request timed out for iterateAndPrint'); }) - .build(); + if(config?.ttl) { + r.withTTL(config.ttl) + } + request = r.build(); }); await client.initiateFlow(request!); return Promise.race([promise, Promise.resolve()]); @@ -110,9 +114,8 @@ export async function iterateAndPrint(client: FluenceClient, strings: string[], export async function iterateAndPrintParallel(client: FluenceClient, nodes: string[], c: (arg0: {external_addresses:string[]}) => void, config?: {ttl?: number}): Promise { let request: RequestFlow; const promise = new Promise((resolve, reject) => { - request = new RequestFlowBuilder() + const r = new RequestFlowBuilder() .disableInjections() - .withTTL(config?.ttl || 5000) .withRawScript( ` (xor @@ -165,7 +168,10 @@ h.on('callbackSrv', 'c', (args) => {c(args[0]); return {};}); .handleTimeout(() => { reject('Request timed out for iterateAndPrintParallel'); }) - .build(); + if(config?.ttl) { + r.withTTL(config.ttl) + } + request = r.build(); }); await client.initiateFlow(request!); return Promise.race([promise, Promise.resolve()]); diff --git a/src/compiled/examples/foldJoin.ts b/src/compiled/examples/foldJoin.ts index c0e3596..268373b 100644 --- a/src/compiled/examples/foldJoin.ts +++ b/src/compiled/examples/foldJoin.ts @@ -15,9 +15,8 @@ import { RequestFlow } from '@fluencelabs/fluence/dist/internal/RequestFlow'; export async function getTwoResults(client: FluenceClient, relay: string, config?: {ttl?: number}): Promise { let request: RequestFlow; const promise = new Promise((resolve, reject) => { - request = new RequestFlowBuilder() + const r = new RequestFlowBuilder() .disableInjections() - .withTTL(config?.ttl || 5000) .withRawScript( ` (xor @@ -97,7 +96,10 @@ export async function getTwoResults(client: FluenceClient, relay: string, config .handleTimeout(() => { reject('Request timed out for getTwoResults'); }) - .build(); + if(config?.ttl) { + r.withTTL(config.ttl) + } + request = r.build(); }); await client.initiateFlow(request!); return promise; diff --git a/src/compiled/examples/func.ts b/src/compiled/examples/func.ts index 921b6de..e9295ca 100644 --- a/src/compiled/examples/func.ts +++ b/src/compiled/examples/func.ts @@ -15,9 +15,8 @@ import { RequestFlow } from '@fluencelabs/fluence/dist/internal/RequestFlow'; export async function testFunc(client: FluenceClient, config?: {ttl?: number}): Promise { let request: RequestFlow; const promise = new Promise((resolve, reject) => { - request = new RequestFlowBuilder() + const r = new RequestFlowBuilder() .disableInjections() - .withTTL(config?.ttl || 5000) .withRawScript( ` (xor @@ -56,7 +55,10 @@ export async function testFunc(client: FluenceClient, config?: {ttl?: number}): .handleTimeout(() => { reject('Request timed out for testFunc'); }) - .build(); + if(config?.ttl) { + r.withTTL(config.ttl) + } + request = r.build(); }); await client.initiateFlow(request!); return promise; diff --git a/src/compiled/examples/helloWorld.ts b/src/compiled/examples/helloWorld.ts index 5de9130..8b3d8f8 100644 --- a/src/compiled/examples/helloWorld.ts +++ b/src/compiled/examples/helloWorld.ts @@ -15,9 +15,8 @@ import { RequestFlow } from '@fluencelabs/fluence/dist/internal/RequestFlow'; export async function helloWorld(client: FluenceClient, name: string, config?: {ttl?: number}): Promise { let request: RequestFlow; const promise = new Promise((resolve, reject) => { - request = new RequestFlowBuilder() + const r = new RequestFlowBuilder() .disableInjections() - .withTTL(config?.ttl || 5000) .withRawScript( ` (xor @@ -59,7 +58,10 @@ export async function helloWorld(client: FluenceClient, name: string, config?: { .handleTimeout(() => { reject('Request timed out for helloWorld'); }) - .build(); + if(config?.ttl) { + r.withTTL(config.ttl) + } + request = r.build(); }); await client.initiateFlow(request!); return promise; diff --git a/src/compiled/examples/if.ts b/src/compiled/examples/if.ts index 8863fa0..26e9c64 100644 --- a/src/compiled/examples/if.ts +++ b/src/compiled/examples/if.ts @@ -15,9 +15,8 @@ import { RequestFlow } from '@fluencelabs/fluence/dist/internal/RequestFlow'; export async function print(client: FluenceClient, str: string, config?: {ttl?: number}): Promise { let request: RequestFlow; const promise = new Promise((resolve, reject) => { - request = new RequestFlowBuilder() + const r = new RequestFlowBuilder() .disableInjections() - .withTTL(config?.ttl || 5000) .withRawScript( ` (xor @@ -49,7 +48,10 @@ export async function print(client: FluenceClient, str: string, config?: {ttl?: .handleTimeout(() => { reject('Request timed out for print'); }) - .build(); + if(config?.ttl) { + r.withTTL(config.ttl) + } + request = r.build(); }); await client.initiateFlow(request!); return Promise.race([promise, Promise.resolve()]); @@ -60,9 +62,8 @@ export async function print(client: FluenceClient, str: string, config?: {ttl?: export async function ifElseCall(client: FluenceClient, condition: boolean, config?: {ttl?: number}): Promise { let request: RequestFlow; const promise = new Promise((resolve, reject) => { - request = new RequestFlowBuilder() + const r = new RequestFlowBuilder() .disableInjections() - .withTTL(config?.ttl || 5000) .withRawScript( ` (xor @@ -102,7 +103,10 @@ export async function ifElseCall(client: FluenceClient, condition: boolean, conf .handleTimeout(() => { reject('Request timed out for ifElseCall'); }) - .build(); + if(config?.ttl) { + r.withTTL(config.ttl) + } + request = r.build(); }); await client.initiateFlow(request!); return Promise.race([promise, Promise.resolve()]); @@ -113,9 +117,8 @@ export async function ifElseCall(client: FluenceClient, condition: boolean, conf export async function ifElseNumCall(client: FluenceClient, condition: number, config?: {ttl?: number}): Promise { let request: RequestFlow; const promise = new Promise((resolve, reject) => { - request = new RequestFlowBuilder() + const r = new RequestFlowBuilder() .disableInjections() - .withTTL(config?.ttl || 5000) .withRawScript( ` (xor @@ -155,7 +158,10 @@ export async function ifElseNumCall(client: FluenceClient, condition: number, co .handleTimeout(() => { reject('Request timed out for ifElseNumCall'); }) - .build(); + if(config?.ttl) { + r.withTTL(config.ttl) + } + request = r.build(); }); await client.initiateFlow(request!); return Promise.race([promise, Promise.resolve()]); diff --git a/src/compiled/examples/nestedFuncs.ts b/src/compiled/examples/nestedFuncs.ts index dc11722..e9e86c0 100644 --- a/src/compiled/examples/nestedFuncs.ts +++ b/src/compiled/examples/nestedFuncs.ts @@ -15,9 +15,8 @@ import { RequestFlow } from '@fluencelabs/fluence/dist/internal/RequestFlow'; export async function a(client: FluenceClient, b: string, config?: {ttl?: number}): Promise { let request: RequestFlow; const promise = new Promise((resolve, reject) => { - request = new RequestFlowBuilder() + const r = new RequestFlowBuilder() .disableInjections() - .withTTL(config?.ttl || 5000) .withRawScript( ` (xor @@ -59,7 +58,10 @@ export async function a(client: FluenceClient, b: string, config?: {ttl?: number .handleTimeout(() => { reject('Request timed out for a'); }) - .build(); + if(config?.ttl) { + r.withTTL(config.ttl) + } + request = r.build(); }); await client.initiateFlow(request!); return promise; @@ -70,9 +72,8 @@ export async function a(client: FluenceClient, b: string, config?: {ttl?: number export async function d(client: FluenceClient, e: string, config?: {ttl?: number}): Promise { let request: RequestFlow; const promise = new Promise((resolve, reject) => { - request = new RequestFlowBuilder() + const r = new RequestFlowBuilder() .disableInjections() - .withTTL(config?.ttl || 5000) .withRawScript( ` (xor @@ -114,7 +115,10 @@ export async function d(client: FluenceClient, e: string, config?: {ttl?: number .handleTimeout(() => { reject('Request timed out for d'); }) - .build(); + if(config?.ttl) { + r.withTTL(config.ttl) + } + request = r.build(); }); await client.initiateFlow(request!); return promise; diff --git a/src/compiled/examples/on.ts b/src/compiled/examples/on.ts index e942fe3..f536a4d 100644 --- a/src/compiled/examples/on.ts +++ b/src/compiled/examples/on.ts @@ -15,9 +15,8 @@ import { RequestFlow } from '@fluencelabs/fluence/dist/internal/RequestFlow'; export async function getPeerExternalAddresses(client: FluenceClient, otherNodePeerId: string, config?: {ttl?: number}): Promise { let request: RequestFlow; const promise = new Promise((resolve, reject) => { - request = new RequestFlowBuilder() + const r = new RequestFlowBuilder() .disableInjections() - .withTTL(config?.ttl || 5000) .withRawScript( ` (xor @@ -71,7 +70,10 @@ export async function getPeerExternalAddresses(client: FluenceClient, otherNodeP .handleTimeout(() => { reject('Request timed out for getPeerExternalAddresses'); }) - .build(); + if(config?.ttl) { + r.withTTL(config.ttl) + } + request = r.build(); }); await client.initiateFlow(request!); return promise; @@ -82,9 +84,8 @@ export async function getPeerExternalAddresses(client: FluenceClient, otherNodeP export async function getDistantAddresses(client: FluenceClient, target: string, viaNode: string, config?: {ttl?: number}): Promise { let request: RequestFlow; const promise = new Promise((resolve, reject) => { - request = new RequestFlowBuilder() + const r = new RequestFlowBuilder() .disableInjections() - .withTTL(config?.ttl || 5000) .withRawScript( ` (xor @@ -154,7 +155,10 @@ h.on('getDataSrv', 'viaNode', () => {return viaNode;}); .handleTimeout(() => { reject('Request timed out for getDistantAddresses'); }) - .build(); + if(config?.ttl) { + r.withTTL(config.ttl) + } + request = r.build(); }); await client.initiateFlow(request!); return promise; diff --git a/src/compiled/examples/option.ts b/src/compiled/examples/option.ts index cc44eb0..012461d 100644 --- a/src/compiled/examples/option.ts +++ b/src/compiled/examples/option.ts @@ -15,9 +15,8 @@ import { RequestFlow } from '@fluencelabs/fluence/dist/internal/RequestFlow'; export async function useOptional(client: FluenceClient, opt: string | null, config?: {ttl?: number}): Promise { let request: RequestFlow; const promise = new Promise((resolve, reject) => { - request = new RequestFlowBuilder() + const r = new RequestFlowBuilder() .disableInjections() - .withTTL(config?.ttl || 5000) .withRawScript( ` (xor @@ -67,7 +66,10 @@ export async function useOptional(client: FluenceClient, opt: string | null, con .handleTimeout(() => { reject('Request timed out for useOptional'); }) - .build(); + if(config?.ttl) { + r.withTTL(config.ttl) + } + request = r.build(); }); await client.initiateFlow(request!); return promise; diff --git a/src/compiled/examples/par.ts b/src/compiled/examples/par.ts index 53b2776..b3a1467 100644 --- a/src/compiled/examples/par.ts +++ b/src/compiled/examples/par.ts @@ -15,9 +15,8 @@ import { RequestFlow } from '@fluencelabs/fluence/dist/internal/RequestFlow'; export async function parFunc(client: FluenceClient, node: string, c: (arg0: {external_addresses:string[]}) => void, config?: {ttl?: number}): Promise { let request: RequestFlow; const promise = new Promise((resolve, reject) => { - request = new RequestFlowBuilder() + const r = new RequestFlowBuilder() .disableInjections() - .withTTL(config?.ttl || 5000) .withRawScript( ` (xor @@ -71,7 +70,10 @@ h.on('callbackSrv', 'c', (args) => {c(args[0]); return {};}); .handleTimeout(() => { reject('Request timed out for parFunc'); }) - .build(); + if(config?.ttl) { + r.withTTL(config.ttl) + } + request = r.build(); }); await client.initiateFlow(request!); return Promise.race([promise, Promise.resolve()]); diff --git a/src/compiled/examples/println.ts b/src/compiled/examples/println.ts index 0d83fa8..b318b13 100644 --- a/src/compiled/examples/println.ts +++ b/src/compiled/examples/println.ts @@ -15,9 +15,8 @@ import { RequestFlow } from '@fluencelabs/fluence/dist/internal/RequestFlow'; export async function print(client: FluenceClient, str: string, config?: {ttl?: number}): Promise { let request: RequestFlow; const promise = new Promise((resolve, reject) => { - request = new RequestFlowBuilder() + const r = new RequestFlowBuilder() .disableInjections() - .withTTL(config?.ttl || 5000) .withRawScript( ` (xor @@ -49,7 +48,10 @@ export async function print(client: FluenceClient, str: string, config?: {ttl?: .handleTimeout(() => { reject('Request timed out for print'); }) - .build(); + if(config?.ttl) { + r.withTTL(config.ttl) + } + request = r.build(); }); await client.initiateFlow(request!); return Promise.race([promise, Promise.resolve()]); diff --git a/src/compiled/examples/stream.ts b/src/compiled/examples/stream.ts index b4f3976..07403e4 100644 --- a/src/compiled/examples/stream.ts +++ b/src/compiled/examples/stream.ts @@ -15,9 +15,8 @@ import { RequestFlow } from '@fluencelabs/fluence/dist/internal/RequestFlow'; export async function checkStreams(client: FluenceClient, ch: string[], config?: {ttl?: number}): Promise { let request: RequestFlow; const promise = new Promise((resolve, reject) => { - request = new RequestFlowBuilder() + const r = new RequestFlowBuilder() .disableInjections() - .withTTL(config?.ttl || 5000) .withRawScript( ` (xor @@ -70,7 +69,10 @@ export async function checkStreams(client: FluenceClient, ch: string[], config?: .handleTimeout(() => { reject('Request timed out for checkStreams'); }) - .build(); + if(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 1980a67..bbc3e3e 100644 --- a/src/compiled/examples/topology.ts +++ b/src/compiled/examples/topology.ts @@ -15,9 +15,8 @@ import { RequestFlow } from '@fluencelabs/fluence/dist/internal/RequestFlow'; export async function topologyTest(client: FluenceClient, me: string, myRelay: string, friend: string, friendRelay: string, config?: {ttl?: number}): Promise { let request: RequestFlow; const promise = new Promise((resolve, reject) => { - request = new RequestFlowBuilder() + const r = new RequestFlowBuilder() .disableInjections() - .withTTL(config?.ttl || 5000) .withRawScript( ` (xor @@ -101,7 +100,10 @@ h.on('getDataSrv', 'friendRelay', () => {return friendRelay;}); .handleTimeout(() => { reject('Request timed out for topologyTest'); }) - .build(); + if(config?.ttl) { + r.withTTL(config.ttl) + } + request = r.build(); }); await client.initiateFlow(request!); return promise; diff --git a/src/compiled/examples/tryCatch.ts b/src/compiled/examples/tryCatch.ts index 3321b1e..aeba5ad 100644 --- a/src/compiled/examples/tryCatch.ts +++ b/src/compiled/examples/tryCatch.ts @@ -15,9 +15,8 @@ import { RequestFlow } from '@fluencelabs/fluence/dist/internal/RequestFlow'; export async function tryCatchTest(client: FluenceClient, node_id: string, config?: {ttl?: number}): Promise { let request: RequestFlow; const promise = new Promise((resolve, reject) => { - request = new RequestFlowBuilder() + const r = new RequestFlowBuilder() .disableInjections() - .withTTL(config?.ttl || 5000) .withRawScript( ` (xor @@ -80,7 +79,10 @@ export async function tryCatchTest(client: FluenceClient, node_id: string, confi .handleTimeout(() => { reject('Request timed out for tryCatchTest'); }) - .build(); + if(config?.ttl) { + r.withTTL(config.ttl) + } + request = r.build(); }); await client.initiateFlow(request!); return promise; diff --git a/src/compiled/examples/tryOtherwise.ts b/src/compiled/examples/tryOtherwise.ts index a447642..4c7316a 100644 --- a/src/compiled/examples/tryOtherwise.ts +++ b/src/compiled/examples/tryOtherwise.ts @@ -15,9 +15,8 @@ import { RequestFlow } from '@fluencelabs/fluence/dist/internal/RequestFlow'; export async function tryOtherwiseTest(client: FluenceClient, node_id: string, config?: {ttl?: number}): Promise { let request: RequestFlow; const promise = new Promise((resolve, reject) => { - request = new RequestFlowBuilder() + const r = new RequestFlowBuilder() .disableInjections() - .withTTL(config?.ttl || 5000) .withRawScript( ` (xor @@ -74,7 +73,10 @@ export async function tryOtherwiseTest(client: FluenceClient, node_id: string, c .handleTimeout(() => { reject('Request timed out for tryOtherwiseTest'); }) - .build(); + if(config?.ttl) { + r.withTTL(config.ttl) + } + request = r.build(); }); await client.initiateFlow(request!); return promise; diff --git a/src/compiled/examples/via.ts b/src/compiled/examples/via.ts index b5904a0..80bb3cd 100644 --- a/src/compiled/examples/via.ts +++ b/src/compiled/examples/via.ts @@ -15,9 +15,8 @@ import { RequestFlow } from '@fluencelabs/fluence/dist/internal/RequestFlow'; export async function viaArr(client: FluenceClient, node_id: string, viaAr: string[], config?: {ttl?: number}): Promise<{external_addresses:string[]}> { let request: RequestFlow; const promise = new Promise<{external_addresses:string[]}>((resolve, reject) => { - request = new RequestFlowBuilder() + const r = new RequestFlowBuilder() .disableInjections() - .withTTL(config?.ttl || 5000) .withRawScript( ` (xor @@ -102,7 +101,10 @@ h.on('getDataSrv', 'viaAr', () => {return viaAr;}); .handleTimeout(() => { reject('Request timed out for viaArr'); }) - .build(); + if(config?.ttl) { + r.withTTL(config.ttl) + } + request = r.build(); }); await client.initiateFlow(request!); return promise; @@ -113,9 +115,8 @@ h.on('getDataSrv', 'viaAr', () => {return viaAr;}); export async function viaStream(client: FluenceClient, node_id: string, viaStr: string[], config?: {ttl?: number}): Promise<{external_addresses:string[]}> { let request: RequestFlow; const promise = new Promise<{external_addresses:string[]}>((resolve, reject) => { - request = new RequestFlowBuilder() + const r = new RequestFlowBuilder() .disableInjections() - .withTTL(config?.ttl || 5000) .withRawScript( ` (xor @@ -208,7 +209,10 @@ h.on('getDataSrv', 'viaStr', () => {return viaStr;}); .handleTimeout(() => { reject('Request timed out for viaStream'); }) - .build(); + if(config?.ttl) { + r.withTTL(config.ttl) + } + request = r.build(); }); await client.initiateFlow(request!); return promise; @@ -219,9 +223,8 @@ h.on('getDataSrv', 'viaStr', () => {return viaStr;}); export async function viaOpt(client: FluenceClient, relay: string, node_id: string, viaOpt: string | null, config?: {ttl?: number}): Promise<{external_addresses:string[]}> { let request: RequestFlow; const promise = new Promise<{external_addresses:string[]}>((resolve, reject) => { - request = new RequestFlowBuilder() + const r = new RequestFlowBuilder() .disableInjections() - .withTTL(config?.ttl || 5000) .withRawScript( ` (xor @@ -310,7 +313,10 @@ h.on('getDataSrv', 'viaOpt', () => {return viaOpt === null ? [] : [viaOpt];}); .handleTimeout(() => { reject('Request timed out for viaOpt'); }) - .build(); + if(config?.ttl) { + r.withTTL(config.ttl) + } + request = r.build(); }); await client.initiateFlow(request!); return promise;