From 85d3068c7b090c34572ec85f726994c596a51dca Mon Sep 17 00:00:00 2001 From: Pavel Murygin Date: Thu, 15 Apr 2021 13:57:25 +0300 Subject: [PATCH 1/2] Fix variable injection --- src/internal/RequestFlowBuilder.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/internal/RequestFlowBuilder.ts b/src/internal/RequestFlowBuilder.ts index bce64d09b..acb34de2d 100644 --- a/src/internal/RequestFlowBuilder.ts +++ b/src/internal/RequestFlowBuilder.ts @@ -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]}`); }); }); From 448ce8ca69d2eae48eb0028cb0f98b07ffd044f7 Mon Sep 17 00:00:00 2001 From: Pavel Murygin Date: Thu, 15 Apr 2021 13:59:12 +0300 Subject: [PATCH 2/2] get rid of any in registerServiceFunction return type --- src/api.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api.ts b/src/api.ts index 0e3bfa359..434457774 100644 --- a/src/api.ts +++ b/src/api.ts @@ -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);