223 lines
6.8 KiB
TypeScript
Raw Normal View History

/**
*
* 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.9.1
*
*/
import { FluencePeer } from '@fluencelabs/fluence';
import type { CallParams$$ } from '@fluencelabs/fluence/dist/internal/compilerSupport/v4'
import {
callFunction$$,
registerService$$,
} from '@fluencelabs/fluence/dist/internal/compilerSupport/v4';
// Services
export interface UnexistedDef {
getStr: (callParams: CallParams$$<null>) => string | Promise<string>;
}
export function registerUnexisted(service: UnexistedDef): void;
export function registerUnexisted(serviceId: string, service: UnexistedDef): void;
export function registerUnexisted(peer: FluencePeer, service: UnexistedDef): void;
export function registerUnexisted(peer: FluencePeer, serviceId: string, service: UnexistedDef): void;
export function registerUnexisted(...args: any) {
registerService$$(
args,
{
"defaultServiceId" : "unex",
2022-04-12 15:41:53 +03:00
"functions" : {
"tag" : "labeledProduct",
"fields" : {
"getStr" : {
"tag" : "arrow",
"domain" : {
"tag" : "nil"
},
"codomain" : {
"tag" : "unlabeledProduct",
"items" : [
{
"tag" : "scalar",
"name" : "string"
}
]
}
}
}
2022-04-12 15:41:53 +03:00
}
}
);
}
export interface OpEDef {
identity: (s: string, callParams: CallParams$$<'s'>) => string | Promise<string>;
}
export function registerOpE(service: OpEDef): void;
export function registerOpE(serviceId: string, service: OpEDef): void;
export function registerOpE(peer: FluencePeer, service: OpEDef): void;
export function registerOpE(peer: FluencePeer, serviceId: string, service: OpEDef): void;
export function registerOpE(...args: any) {
registerService$$(
args,
{
"defaultServiceId" : "op",
2022-04-12 15:41:53 +03:00
"functions" : {
"tag" : "labeledProduct",
"fields" : {
"identity" : {
"tag" : "arrow",
"domain" : {
"tag" : "labeledProduct",
"fields" : {
"s" : {
"tag" : "scalar",
"name" : "string"
}
}
2022-04-12 15:41:53 +03:00
},
"codomain" : {
"tag" : "unlabeledProduct",
"items" : [
{
"tag" : "scalar",
"name" : "string"
}
]
}
}
}
2022-04-12 15:41:53 +03:00
}
}
);
}
// Functions
export function tryOtherwiseTest(
node_id: string,
config?: {ttl?: number}
): Promise<string>;
export function tryOtherwiseTest(
peer: FluencePeer,
node_id: string,
config?: {ttl?: number}
): Promise<string>;
export function tryOtherwiseTest(...args: any) {
let script = `
(xor
(seq
(seq
(seq
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
(call %init_peer_id% ("getDataSrv" "node_id") [] node_id)
)
(new $f
(seq
(seq
(seq
(call -relay- ("op" "noop") [])
(xor
(xor
(seq
(call node_id ("unex" "getStr") [] $f)
(call -relay- ("op" "noop") [])
)
(seq
(call node_id ("op" "identity") ["error"] $f)
(call -relay- ("op" "noop") [])
)
)
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
)
)
(new $f_test
(seq
(seq
(seq
(call %init_peer_id% ("math" "add") [0 1] f_incr)
(fold $f s
(seq
(seq
(ap s $f_test)
(canon %init_peer_id% $f_test #f_iter_canon)
)
(xor
(match #f_iter_canon.length f_incr
(null)
)
(next s)
)
)
(never)
)
)
(canon %init_peer_id% $f_test #f_result_canon)
)
(ap #f_result_canon f_gate)
)
)
)
(ap f_gate.$.[0]! f_gate_flat)
)
)
)
(xor
(call %init_peer_id% ("callbackSrv" "response") [f_gate_flat])
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2])
)
)
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3])
)
`
return callFunction$$(
args,
{
"functionName" : "tryOtherwiseTest",
2022-04-12 15:41:53 +03:00
"arrow" : {
"tag" : "arrow",
"domain" : {
"tag" : "labeledProduct",
"fields" : {
"node_id" : {
"tag" : "scalar",
"name" : "string"
}
}
2022-04-12 15:41:53 +03:00
},
"codomain" : {
"tag" : "unlabeledProduct",
"items" : [
{
"tag" : "scalar",
"name" : "string"
}
]
}
2022-04-12 15:41:53 +03:00
},
"names" : {
"relay" : "-relay-",
"getDataSrv" : "getDataSrv",
"callbackSrv" : "callbackSrv",
"responseSrv" : "callbackSrv",
"responseFnName" : "response",
"errorHandlingSrv" : "errorHandlingSrv",
"errorFnName" : "error"
}
},
script
)
}