UNPKG

@cognigy/rest-api-client

Version:

Cognigy REST-Client

30 lines 1.17 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.storeQuestionAnswer = void 0; const BaseContext_1 = require("../../../../../helper/BaseContext"); /** * Stores the question answer into the Context and/or Input */ const storeQuestionAnswer = ({ storeResultInContext, contextKey, context, result, input }) => { if (storeResultInContext && contextKey) { // check whether contextKey or inputKey is a deep query and set // storage location accordingly let location = context; let target = contextKey; // this is a deep query if (target.indexOf(".") > -1) { const splits = target.split("."); location = BaseContext_1.BaseContext.findLocationPathStateless(splits, true, location); target = splits[splits.length - 1]; } location[target] = result; // always store result also in input to allow for // easy handling in conditions etc. input.result = result; } else { input.result = result; } }; exports.storeQuestionAnswer = storeQuestionAnswer; //# sourceMappingURL=storeQuestionAnswer.js.map