Fix variable injection (#39)

This commit is contained in:
Pavel 2021-04-15 15:42:18 +03:00 committed by GitHub
parent de0516f305
commit f14baeb618
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -72,13 +72,13 @@ const makeKey = (client: FluenceClient, serviceId: string, fnName: string) => {
* @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 } 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 = (
client: FluenceClient,
serviceId: 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);
handlersUnregistratorsMap.set(makeKey(client, serviceId, fnName), unregister);

View File

@ -161,7 +161,11 @@ export class RequestFlowBuilder {
this.configHandler((h) => {
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]}`);
});
});