mirror of
https://github.com/fluencelabs/aqua-playground
synced 2025-06-23 07:31:48 +00:00
dump compiled
This commit is contained in:
@ -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 UnexistedDef {
|
||||
getStr: (callParams: CallParams<null>) => 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) {
|
||||
let peer: FluencePeer;
|
||||
let serviceId: any;
|
||||
@ -43,7 +45,7 @@ export function registerUnexisted(...args: any) {
|
||||
} else if (typeof args[1] === 'string') {
|
||||
serviceId = args[1];
|
||||
} else {
|
||||
serviceId = 'unex';
|
||||
serviceId = "unex"
|
||||
}
|
||||
|
||||
// Figuring out which overload is the service.
|
||||
@ -51,7 +53,7 @@ export function registerUnexisted(...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 registerUnexisted(...args: any) {
|
||||
|
||||
const incorrectServiceDefinitions = missingFields(service, ['getStr']);
|
||||
if (!!incorrectServiceDefinitions.length) {
|
||||
throw new Error(
|
||||
'Error registering service Unexisted: missing functions: ' +
|
||||
incorrectServiceDefinitions.map((d) => "'" + d + "'").join(', '),
|
||||
);
|
||||
throw new Error("Error registering service Unexisted: missing functions: " + incorrectServiceDefinitions.map((d) => "'" + d + "'").join(", "))
|
||||
}
|
||||
|
||||
peer.internals.callServiceHandler.use((req, resp, next) => {
|
||||
@ -76,24 +75,29 @@ export function registerUnexisted(...args: any) {
|
||||
if (req.fnName === 'getStr') {
|
||||
const callParams = {
|
||||
...req.particleContext,
|
||||
tetraplets: {},
|
||||
tetraplets: {
|
||||
|
||||
},
|
||||
};
|
||||
resp.retCode = ResultCodes.success;
|
||||
resp.result = service.getStr(callParams);
|
||||
resp.result = service.getStr(callParams)
|
||||
}
|
||||
|
||||
next();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
export interface OpADef {
|
||||
identity: (s: string, callParams: CallParams<'s'>) => string;
|
||||
}
|
||||
|
||||
export function registerOpA(service: OpADef): void;
|
||||
export function registerOpA(serviceId: string, service: OpADef): void;
|
||||
export function registerOpA(peer: FluencePeer, service: OpADef): void;
|
||||
export function registerOpA(peer: FluencePeer, serviceId: string, service: OpADef): void;
|
||||
|
||||
|
||||
export function registerOpA(...args: any) {
|
||||
let peer: FluencePeer;
|
||||
let serviceId: any;
|
||||
@ -109,7 +113,7 @@ export function registerOpA(...args: any) {
|
||||
} else if (typeof args[1] === 'string') {
|
||||
serviceId = args[1];
|
||||
} else {
|
||||
serviceId = 'op';
|
||||
serviceId = "op"
|
||||
}
|
||||
|
||||
// Figuring out which overload is the service.
|
||||
@ -117,7 +121,7 @@ export function registerOpA(...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];
|
||||
@ -127,10 +131,7 @@ export function registerOpA(...args: any) {
|
||||
|
||||
const incorrectServiceDefinitions = missingFields(service, ['identity']);
|
||||
if (!!incorrectServiceDefinitions.length) {
|
||||
throw new Error(
|
||||
'Error registering service OpA: missing functions: ' +
|
||||
incorrectServiceDefinitions.map((d) => "'" + d + "'").join(', '),
|
||||
);
|
||||
throw new Error("Error registering service OpA: missing functions: " + incorrectServiceDefinitions.map((d) => "'" + d + "'").join(", "))
|
||||
}
|
||||
|
||||
peer.internals.callServiceHandler.use((req, resp, next) => {
|
||||
@ -143,21 +144,22 @@ export function registerOpA(...args: any) {
|
||||
const callParams = {
|
||||
...req.particleContext,
|
||||
tetraplets: {
|
||||
s: req.tetraplets[0],
|
||||
s: req.tetraplets[0]
|
||||
},
|
||||
};
|
||||
resp.retCode = ResultCodes.success;
|
||||
resp.result = service.identity(req.args[0], callParams);
|
||||
resp.result = service.identity(req.args[0], callParams)
|
||||
}
|
||||
|
||||
next();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Functions
|
||||
|
||||
|
||||
export function tryCatchTest(node_id: string, config?: { ttl?: number }): Promise<string[]>;
|
||||
export function tryCatchTest(peer: FluencePeer, node_id: string, config?: { ttl?: number }): Promise<string[]>;
|
||||
export function tryCatchTest(node_id: string, config?: {ttl?: number}): Promise<string[]>;
|
||||
export function tryCatchTest(peer: FluencePeer, node_id: string, config?: {ttl?: number}): Promise<string[]>;
|
||||
export function tryCatchTest(...args: any) {
|
||||
let peer: FluencePeer;
|
||||
let node_id: any;
|
||||
@ -175,9 +177,8 @@ export function tryCatchTest(...args: any) {
|
||||
let request: RequestFlow;
|
||||
const promise = new Promise<string[]>((resolve, reject) => {
|
||||
const r = new RequestFlowBuilder()
|
||||
.disableInjections()
|
||||
.withRawScript(
|
||||
`
|
||||
.disableInjections()
|
||||
.withRawScript(`
|
||||
(xor
|
||||
(seq
|
||||
(seq
|
||||
@ -216,33 +217,31 @@ export function tryCatchTest(...args: any) {
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3])
|
||||
)
|
||||
`,
|
||||
)
|
||||
.configHandler((h) => {
|
||||
h.on('getDataSrv', '-relay-', () => {
|
||||
return peer.getStatus().relayPeerId;
|
||||
});
|
||||
h.on('getDataSrv', 'node_id', () => {
|
||||
return node_id;
|
||||
});
|
||||
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 tryCatchTest');
|
||||
});
|
||||
)
|
||||
.configHandler((h) => {
|
||||
h.on('getDataSrv', '-relay-', () => {
|
||||
return peer.getStatus().relayPeerId;
|
||||
});
|
||||
h.on('getDataSrv', 'node_id', () => {return node_id;});
|
||||
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 tryCatchTest');
|
||||
})
|
||||
|
||||
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;
|
||||
|
Reference in New Issue
Block a user