dump compiled

This commit is contained in:
DieMyst
2021-10-19 13:25:29 +03:00
parent cc595d3a93
commit e25bbc43f6
43 changed files with 2884 additions and 3347 deletions

View File

@ -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.3.1-231
* Aqua version: 0.3.2-SNAPSHOT
*
*/
import { Fluence, FluencePeer } from '@fluencelabs/fluence';
@ -11,11 +11,12 @@ import {
ResultCodes,
RequestFlow,
RequestFlowBuilder,
CallParams,
CallParams
} from '@fluencelabs/fluence/dist/internal/compilerSupport/v1';
function missingFields(obj: any, fields: string[]): string[] {
return fields.filter((f) => !(f in obj));
return fields.filter(f => !(f in obj))
}
// Services
@ -23,11 +24,12 @@ function missingFields(obj: any, fields: string[]): string[] {
export interface TestoDef {
getString: (arg0: string, callParams: CallParams<'arg0'>) => string;
}
export function registerTesto(service: TestoDef): void;
export function registerTesto(serviceId: string, service: TestoDef): void;
export function registerTesto(peer: FluencePeer, service: TestoDef): void;
export function registerTesto(peer: FluencePeer, serviceId: string, service: TestoDef): void;
export function registerTesto(...args: any) {
let peer: FluencePeer;
let serviceId: any;
@ -43,7 +45,7 @@ export function registerTesto(...args: any) {
} else if (typeof args[1] === 'string') {
serviceId = args[1];
} else {
serviceId = 'testo';
serviceId = "testo"
}
// Figuring out which overload is the service.
@ -51,7 +53,7 @@ export function registerTesto(...args: any) {
// If the first argument is peer, we are checking further. The second argument might either be
// an object, that it must be the service object
// or a string, which is the service id. In that case the service is the third argument
if (!FluencePeer.isInstance(args[0]) && typeof args[0] === 'object') {
if (!(FluencePeer.isInstance(args[0])) && typeof args[0] === 'object') {
service = args[0];
} else if (typeof args[1] === 'object') {
service = args[1];
@ -61,10 +63,7 @@ export function registerTesto(...args: any) {
const incorrectServiceDefinitions = missingFields(service, ['getString']);
if (!!incorrectServiceDefinitions.length) {
throw new Error(
'Error registering service Testo: missing functions: ' +
incorrectServiceDefinitions.map((d) => "'" + d + "'").join(', '),
);
throw new Error("Error registering service Testo: missing functions: " + incorrectServiceDefinitions.map((d) => "'" + d + "'").join(", "))
}
peer.internals.callServiceHandler.use((req, resp, next) => {
@ -77,25 +76,28 @@ export function registerTesto(...args: any) {
const callParams = {
...req.particleContext,
tetraplets: {
arg0: req.tetraplets[0],
arg0: req.tetraplets[0]
},
};
resp.retCode = ResultCodes.success;
resp.result = service.getString(req.args[0], callParams);
resp.result = service.getString(req.args[0], callParams)
}
next();
});
}
export interface LocalPrintDef {
print: (arg0: string, callParams: CallParams<'arg0'>) => void;
}
export function registerLocalPrint(service: LocalPrintDef): void;
export function registerLocalPrint(serviceId: string, service: LocalPrintDef): void;
export function registerLocalPrint(peer: FluencePeer, service: LocalPrintDef): void;
export function registerLocalPrint(peer: FluencePeer, serviceId: string, service: LocalPrintDef): void;
export function registerLocalPrint(...args: any) {
let peer: FluencePeer;
let serviceId: any;
@ -111,7 +113,7 @@ export function registerLocalPrint(...args: any) {
} else if (typeof args[1] === 'string') {
serviceId = args[1];
} else {
serviceId = 'lp';
serviceId = "lp"
}
// Figuring out which overload is the service.
@ -119,7 +121,7 @@ export function registerLocalPrint(...args: any) {
// If the first argument is peer, we are checking further. The second argument might either be
// an object, that it must be the service object
// or a string, which is the service id. In that case the service is the third argument
if (!FluencePeer.isInstance(args[0]) && typeof args[0] === 'object') {
if (!(FluencePeer.isInstance(args[0])) && typeof args[0] === 'object') {
service = args[0];
} else if (typeof args[1] === 'object') {
service = args[1];
@ -129,10 +131,7 @@ export function registerLocalPrint(...args: any) {
const incorrectServiceDefinitions = missingFields(service, ['print']);
if (!!incorrectServiceDefinitions.length) {
throw new Error(
'Error registering service LocalPrint: missing functions: ' +
incorrectServiceDefinitions.map((d) => "'" + d + "'").join(', '),
);
throw new Error("Error registering service LocalPrint: missing functions: " + incorrectServiceDefinitions.map((d) => "'" + d + "'").join(", "))
}
peer.internals.callServiceHandler.use((req, resp, next) => {
@ -145,35 +144,22 @@ export function registerLocalPrint(...args: any) {
const callParams = {
...req.particleContext,
tetraplets: {
arg0: req.tetraplets[0],
arg0: req.tetraplets[0]
},
};
resp.retCode = ResultCodes.success;
service.print(req.args[0], callParams);
resp.result = {};
service.print(req.args[0], callParams); resp.result = {}
}
next();
});
}
// Functions
export function topologyTest(
me: string,
myRelay: string,
friend: string,
friendRelay: string,
config?: { ttl?: number },
): Promise<string>;
export function topologyTest(
peer: FluencePeer,
me: string,
myRelay: string,
friend: string,
friendRelay: string,
config?: { ttl?: number },
): Promise<string>;
export function topologyTest(me: string, myRelay: string, friend: string, friendRelay: string, config?: {ttl?: number}): Promise<string>;
export function topologyTest(peer: FluencePeer, me: string, myRelay: string, friend: string, friendRelay: string, config?: {ttl?: number}): Promise<string>;
export function topologyTest(...args: any) {
let peer: FluencePeer;
let me: any;
@ -200,9 +186,8 @@ export function topologyTest(...args: any) {
let request: RequestFlow;
const promise = new Promise<string>((resolve, reject) => {
const r = new RequestFlowBuilder()
.disableInjections()
.withRawScript(
`
.disableInjections()
.withRawScript(`
(xor
(seq
(seq
@ -259,42 +244,34 @@ export function topologyTest(...args: any) {
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3])
)
`,
)
.configHandler((h) => {
h.on('getDataSrv', '-relay-', () => {
return peer.getStatus().relayPeerId;
});
h.on('getDataSrv', 'me', () => {
return me;
});
h.on('getDataSrv', 'myRelay', () => {
return myRelay;
});
h.on('getDataSrv', 'friend', () => {
return friend;
});
h.on('getDataSrv', 'friendRelay', () => {
return friendRelay;
});
h.onEvent('callbackSrv', 'response', (args) => {
const [res] = args;
resolve(res);
});
h.onEvent('errorHandlingSrv', 'error', (args) => {
const [err] = args;
reject(err);
});
})
.handleScriptError(reject)
.handleTimeout(() => {
reject('Request timed out for topologyTest');
});
)
.configHandler((h) => {
h.on('getDataSrv', '-relay-', () => {
return peer.getStatus().relayPeerId;
});
h.on('getDataSrv', 'me', () => {return me;});
h.on('getDataSrv', 'myRelay', () => {return myRelay;});
h.on('getDataSrv', 'friend', () => {return friend;});
h.on('getDataSrv', 'friendRelay', () => {return friendRelay;});
h.onEvent('callbackSrv', 'response', (args) => {
const [res] = args;
resolve(res);
});
h.onEvent('errorHandlingSrv', 'error', (args) => {
const [err] = args;
reject(err);
});
})
.handleScriptError(reject)
.handleTimeout(() => {
reject('Request timed out for topologyTest');
})
if (config && config.ttl) {
r.withTTL(config.ttl);
}
if (config && config.ttl) {
r.withTTL(config.ttl)
}
request = r.build();
request = r.build();
});
peer.internals.initiateFlow(request!);
return promise;