2021-10-07 13:55:10 +03:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* 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
|
2021-11-15 16:15:29 +03:00
|
|
|
* Aqua version: 0.5.0-SNAPSHOT
|
2021-10-07 13:55:10 +03:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
import { Fluence, FluencePeer } from '@fluencelabs/fluence';
|
|
|
|
import {
|
2021-10-20 23:09:56 +03:00
|
|
|
CallParams,
|
|
|
|
callFunction,
|
|
|
|
registerService,
|
|
|
|
} from '@fluencelabs/fluence/dist/internal/compilerSupport/v2';
|
2021-10-07 13:55:10 +03:00
|
|
|
|
2021-10-19 13:25:29 +03:00
|
|
|
|
2021-10-07 13:55:10 +03:00
|
|
|
// Services
|
|
|
|
|
|
|
|
export interface ComplexServiceDef {
|
2021-10-26 19:10:39 +03:00
|
|
|
call: (d: { otherValue: number; value: string; }, sd: { complex: { someNum: number; someStr: string; }; value: string; }, callParams: CallParams<'d' | 'sd'>) => { someNum: number; someStr: string; } | Promise<{ someNum: number; someStr: string; }>;
|
2021-11-04 13:13:26 +03:00
|
|
|
identity: (callParams: CallParams<null>) => { complex: { someNum: number; someStr: string; }; value: string; } | Promise<{ complex: { someNum: number; someStr: string; }; value: string; }>;
|
2021-10-07 13:55:10 +03:00
|
|
|
}
|
|
|
|
export function registerComplexService(service: ComplexServiceDef): void;
|
|
|
|
export function registerComplexService(serviceId: string, service: ComplexServiceDef): void;
|
|
|
|
export function registerComplexService(peer: FluencePeer, service: ComplexServiceDef): void;
|
|
|
|
export function registerComplexService(peer: FluencePeer, serviceId: string, service: ComplexServiceDef): void;
|
2021-10-19 13:25:29 +03:00
|
|
|
|
|
|
|
|
2021-10-07 13:55:10 +03:00
|
|
|
export function registerComplexService(...args: any) {
|
2021-10-20 23:09:56 +03:00
|
|
|
registerService(
|
|
|
|
args,
|
|
|
|
{
|
|
|
|
"defaultServiceId" : "op-ha",
|
|
|
|
"functions" : [
|
|
|
|
{
|
|
|
|
"functionName" : "call",
|
|
|
|
"argDefs" : [
|
|
|
|
{
|
|
|
|
"name" : "d",
|
|
|
|
"argType" : {
|
|
|
|
"tag" : "primitive"
|
|
|
|
}
|
2021-10-07 13:55:10 +03:00
|
|
|
},
|
2021-10-20 23:09:56 +03:00
|
|
|
{
|
|
|
|
"name" : "sd",
|
|
|
|
"argType" : {
|
|
|
|
"tag" : "primitive"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"returnType" : {
|
|
|
|
"tag" : "primitive"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"functionName" : "identity",
|
|
|
|
"argDefs" : [
|
|
|
|
],
|
|
|
|
"returnType" : {
|
|
|
|
"tag" : "primitive"
|
|
|
|
}
|
2021-10-07 13:55:10 +03:00
|
|
|
}
|
2021-10-20 23:09:56 +03:00
|
|
|
]
|
|
|
|
}
|
|
|
|
);
|
2021-10-07 13:55:10 +03:00
|
|
|
}
|
2021-10-19 13:25:29 +03:00
|
|
|
|
2021-10-07 13:55:10 +03:00
|
|
|
// Functions
|
2021-10-19 13:25:29 +03:00
|
|
|
export type DoSmthArgD = { otherValue: number; value: string; }
|
|
|
|
export type DoSmthArgD2 = { otherValue: number; value: string; }
|
|
|
|
export type DoSmthArgSd = { complex: { someNum: number; someStr: string; }; value: string; }
|
|
|
|
export type DoSmthResult = { complex: { otherValue: number; value: string; }; value: string; }
|
2021-11-25 14:44:14 +03:00
|
|
|
export function doSmth(
|
|
|
|
d: DoSmthArgD,
|
|
|
|
d2: DoSmthArgD2,
|
|
|
|
sd: DoSmthArgSd,
|
|
|
|
c: (arg0: { someNum: number; someStr: string; }, arg1: { complex: { someNum: number; someStr: string; }; value: string; }, callParams: CallParams<'arg0' | 'arg1'>) => { complex: { otherValue: number; value: string; }; value: string; } | Promise<{ complex: { otherValue: number; value: string; }; value: string; }>,
|
|
|
|
config?: {ttl?: number}
|
|
|
|
): Promise<DoSmthResult>;
|
|
|
|
|
|
|
|
export function doSmth(
|
|
|
|
peer: FluencePeer,
|
|
|
|
d: DoSmthArgD,
|
|
|
|
d2: DoSmthArgD2,
|
|
|
|
sd: DoSmthArgSd,
|
|
|
|
c: (arg0: { someNum: number; someStr: string; }, arg1: { complex: { someNum: number; someStr: string; }; value: string; }, callParams: CallParams<'arg0' | 'arg1'>) => { complex: { otherValue: number; value: string; }; value: string; } | Promise<{ complex: { otherValue: number; value: string; }; value: string; }>,
|
|
|
|
config?: {ttl?: number}
|
|
|
|
): Promise<DoSmthResult>;
|
|
|
|
|
2021-10-07 13:55:10 +03:00
|
|
|
export function doSmth(...args: any) {
|
|
|
|
|
2021-10-20 23:09:56 +03:00
|
|
|
let script = `
|
2021-11-25 14:44:14 +03:00
|
|
|
(xor
|
2021-10-07 13:55:10 +03:00
|
|
|
(seq
|
|
|
|
(seq
|
|
|
|
(seq
|
|
|
|
(seq
|
|
|
|
(seq
|
|
|
|
(seq
|
|
|
|
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
|
|
|
|
(call %init_peer_id% ("getDataSrv" "d") [] d)
|
|
|
|
)
|
|
|
|
(call %init_peer_id% ("getDataSrv" "d2") [] d2)
|
|
|
|
)
|
|
|
|
(call %init_peer_id% ("getDataSrv" "sd") [] sd)
|
|
|
|
)
|
|
|
|
(call %init_peer_id% ("op-ha" "call") [d sd] res)
|
|
|
|
)
|
|
|
|
(xor
|
|
|
|
(call %init_peer_id% ("callbackSrv" "c") [res sd] init_call_res0)
|
|
|
|
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
|
|
|
|
)
|
|
|
|
)
|
|
|
|
(xor
|
|
|
|
(call %init_peer_id% ("callbackSrv" "response") [init_call_res0])
|
|
|
|
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2])
|
|
|
|
)
|
|
|
|
)
|
|
|
|
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3])
|
|
|
|
)
|
2021-10-20 23:09:56 +03:00
|
|
|
`
|
|
|
|
return callFunction(
|
|
|
|
args,
|
|
|
|
{
|
|
|
|
"functionName" : "doSmth",
|
|
|
|
"returnType" : {
|
|
|
|
"tag" : "primitive"
|
|
|
|
},
|
|
|
|
"argDefs" : [
|
|
|
|
{
|
|
|
|
"name" : "d",
|
|
|
|
"argType" : {
|
|
|
|
"tag" : "primitive"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "d2",
|
|
|
|
"argType" : {
|
|
|
|
"tag" : "primitive"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "sd",
|
|
|
|
"argType" : {
|
|
|
|
"tag" : "primitive"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "c",
|
|
|
|
"argType" : {
|
|
|
|
"tag" : "callback",
|
|
|
|
"callback" : {
|
|
|
|
"argDefs" : [
|
|
|
|
{
|
|
|
|
"name" : "arg0",
|
|
|
|
"argType" : {
|
|
|
|
"tag" : "primitive"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "arg1",
|
|
|
|
"argType" : {
|
|
|
|
"tag" : "primitive"
|
|
|
|
}
|
2021-10-07 13:55:10 +03:00
|
|
|
}
|
2021-10-20 23:09:56 +03:00
|
|
|
],
|
|
|
|
"returnType" : {
|
|
|
|
"tag" : "primitive"
|
|
|
|
}
|
2021-10-19 13:25:29 +03:00
|
|
|
}
|
2021-10-20 23:09:56 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"names" : {
|
|
|
|
"relay" : "-relay-",
|
|
|
|
"getDataSrv" : "getDataSrv",
|
|
|
|
"callbackSrv" : "callbackSrv",
|
|
|
|
"responseSrv" : "callbackSrv",
|
|
|
|
"responseFnName" : "response",
|
|
|
|
"errorHandlingSrv" : "errorHandlingSrv",
|
|
|
|
"errorFnName" : "error"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
script
|
|
|
|
)
|
2021-10-07 13:55:10 +03:00
|
|
|
}
|