Skip to content

Commit

Permalink
Update to version v5.2.7
Browse files Browse the repository at this point in the history
### Updated
- Security patches for npm and pip packages
- Added unit tests for JS Lambda Hook SDK
  • Loading branch information
tabdunabi committed Feb 8, 2023
2 parents 3a209d7 + 82433a6 commit e13855d
Show file tree
Hide file tree
Showing 14 changed files with 2,491 additions and 8,265 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [5.2.7] - 2023-02-08

### Updated

- Security patches for npm and pip packages
- Added unit tests for JS Lambda Hook SDK

## [5.2.6] - 2023-01-11

### Updated
Expand Down
1 change: 0 additions & 1 deletion NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ vue-template-compiler under the Massachusetts Institute of Technology (MIT) lice
vuetify under the Massachusetts Institute of Technology (MIT) license
vuex under the Massachusetts Institute of Technology (MIT) license
vuex-router-sync under the Massachusetts Institute of Technology (MIT) license
webdriverio under the Massachusetts Institute of Technology (MIT) license
webpack under the Massachusetts Institute of Technology (MIT) license
webpack-archive-plugin under the Massachusetts Institute of Technology (MIT) license
webpack-bundle-analyzer under the Massachusetts Institute of Technology (MIT) license
Expand Down
37 changes: 17 additions & 20 deletions lambda/cfn/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lambda/cfn/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"http-aws-es": "^6.0.0",
"intercept-stdout": "^0.1.2",
"json-stringify-pretty-compact": "^1.0.4",
"jszip": "^3.1.4",
"jszip": "^3.10.1",
"lodash": "^4.17.21",
"stack-utils": "^1.0.1"
},
Expand Down
10 changes: 10 additions & 0 deletions lambda/js_lambda_hook_sdk/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

module.exports = {
testEnvironment: 'node',
testMatch: ['test/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'],
collectCoverage: true,
collectCoverageFrom: ['**/*.js', '!jest.config.js', '!test/*.js', '!coverage/**/*.js'],
coverageReporters: ['text', ['lcov', { projectRoot: '../../' }]]
};
36 changes: 12 additions & 24 deletions lambda/js_lambda_hook_sdk/lambda_hook_sdk/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ module.exports = {
return this.list_user_attributes(event)
},



list_settings: function (event) {
return _.get(event, "req._settings", {})
},
Expand All @@ -49,13 +47,16 @@ module.exports = {
},

get_args: function (event) {
var args = _.get(event, "res.result.args");
let args = _.get(event, "res.result.args");
let results = [];
args.forEach(element => {
if (_isJson(element)) {
results.push(JSON.parse(element))
try{
let jsonResult = JSON.parse(element)
results.push(jsonResult)
}
else{
catch(e){
//exception thrown during parse means it's not JSON
//just push onto results
results.push(element)
}
})
Expand All @@ -71,19 +72,16 @@ module.exports = {
},

set_message: function (event, message) {
_.set(event, "res,result.a", message.plainText != undefined ? message.plainText : _.get(event, "res.a")),
_.set(event, "res.result.a", message.plainText != undefined ? message.plainText : _.get(event, "res.a"))
_.set(event, "res.result.alt.markdown", message.markDown != undefined ? message.markDown : _.get(event, "res.markdown"))
_.set(event, "res.result.alt.ssml", message.ssml != undefined ? message.ssml : _.get(event, "res.ssml"))

},


get_es_result: function (event) {
return _.get(event, "res.result")
},



get_answer_source: function(event){
return _.get(event,"res.result.answerSource")
},
Expand All @@ -104,7 +102,6 @@ module.exports = {
return this.list_session_attributes(event)
},


add_response_card_button: function (event, text, value, isQID = false, prepend = false) {
let buttons = _.get(event, "res.card.buttons", undefined)
if (buttons === undefined) {
Expand Down Expand Up @@ -139,8 +136,8 @@ module.exports = {

get_sentiment:function(event){
return {
sentiment:_.get(event,"req.sentiment"),
score: _.get(event,"req.sentimenScore")
sentiment: _.get(event,"req.sentiment"),
score: _.get(event,"req.sentimentScore")
}
},

Expand Down Expand Up @@ -168,24 +165,15 @@ module.exports = {
}

if (card.title == undefined) {
throw ("A response card was created without a title. Set the title using set_response_card_title()")
throw new Error("A response card was created without a title. Set the title using set_response_card_title()")
}

let buttons = this.list_response_card_buttons(event)

let imageUrl = this.get_response_card_imageurl(event)
if (buttons.length == 0 && imageUrl == undefined) {
throw ("If a response card is defined, either the imageUrl or buttons must be defined")
throw new Error("If a response card is defined, either the imageUrl or buttons must be defined")
}
return event
}
}

function _isJson(jsonString) {
try {
JSON.parse(jsonString);
return true; // It's a valid JSON format
} catch (e) {
return false; // It's not a valid JSON format
}
}
Loading

0 comments on commit e13855d

Please sign in to comment.