mirror of
https://github.com/fluencelabs/fluence-js.git
synced 2025-04-25 17:52:13 +00:00
Fix variable injection (#39)
This commit is contained in:
parent
de0516f305
commit
f14baeb618
@ -72,13 +72,13 @@ const makeKey = (client: FluenceClient, serviceId: string, fnName: string) => {
|
|||||||
* @param { FluenceClient } client - The Fluence Client instance.
|
* @param { FluenceClient } client - The Fluence Client instance.
|
||||||
* @param { string } serviceId - The identifier of service which would be used to make calls from Aquamarine
|
* @param { string } serviceId - The identifier of service which would be used to make calls from Aquamarine
|
||||||
* @param { string } fnName - The identifier of function which would be used to make calls from Aquamarine
|
* @param { string } fnName - The identifier of function which would be used to make calls from Aquamarine
|
||||||
* @param { (args: any[], tetraplets: SecurityTetraplet[][]) => any } handler - The handler which would be called by Aquamarine infrastructure. The result is any object passed back to Aquamarine
|
* @param { (args: any[], tetraplets: SecurityTetraplet[][]) => object | boolean | number | string } handler - The handler which would be called by Aquamarine infrastructure. The result is any object passed back to Aquamarine
|
||||||
*/
|
*/
|
||||||
export const registerServiceFunction = (
|
export const registerServiceFunction = (
|
||||||
client: FluenceClient,
|
client: FluenceClient,
|
||||||
serviceId: string,
|
serviceId: string,
|
||||||
fnName: string,
|
fnName: string,
|
||||||
handler: (args: any[], tetraplets: SecurityTetraplet[][]) => any,
|
handler: (args: any[], tetraplets: SecurityTetraplet[][]) => object | boolean | number | string,
|
||||||
) => {
|
) => {
|
||||||
const unregister = client.aquaCallHandler.on(serviceId, fnName, handler);
|
const unregister = client.aquaCallHandler.on(serviceId, fnName, handler);
|
||||||
handlersUnregistratorsMap.set(makeKey(client, serviceId, fnName), unregister);
|
handlersUnregistratorsMap.set(makeKey(client, serviceId, fnName), unregister);
|
||||||
|
@ -161,7 +161,11 @@ export class RequestFlowBuilder {
|
|||||||
|
|
||||||
this.configHandler((h) => {
|
this.configHandler((h) => {
|
||||||
h.on(loadVariablesService, loadVariablesFn, (args, _) => {
|
h.on(loadVariablesService, loadVariablesFn, (args, _) => {
|
||||||
return this.variables.get(args[0]) || {};
|
if (this.variables.has(args[0])) {
|
||||||
|
return this.variables.get(args[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Error(`failed to inject variable: ${args[0]}`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user