New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

alexa-response

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

alexa-response - npm Package Compare versions

Comparing version 2.0.1 to 3.0.0

53

build/index.js

@@ -52,6 +52,12 @@ 'use strict';

var SSML = 'SSML';
var PlainText = 'PlainText';
var Simple = 'Simple';
var CardType = {
LinkAccount: 'LinkAccount',
Simple: 'Simple'
};
var SpeechType = {
PlainText: 'PlainText',
SSML: 'SSML'
};
var Response = function () {

@@ -90,8 +96,11 @@ function Response() {

key: 'card',
value: function card(title, content) {
var type = arguments.length <= 2 || arguments[2] === undefined ? Simple : arguments[2];
value: function card(_ref) {
var title = _ref.title;
var content = _ref.content;
var _ref$type = _ref.type;
var type = _ref$type === undefined ? CardType.Simple : _ref$type;
return new Response(babelHelpers.extends({}, this.state, {
response: babelHelpers.extends({}, this.state.response, {
card: { type: type, title: title, content: content }
card: babelHelpers.extends({}, type && { type: type }, title && { title: title }, content && { content: content })
})

@@ -132,36 +141,37 @@ }));

Response.ask = function () {
var _ref;
var _ref2;
return (_ref = new Response()).ask.apply(_ref, arguments);
return (_ref2 = new Response()).ask.apply(_ref2, arguments);
};
Response.say = function () {
var _ref2;
var _ref3;
return (_ref2 = new Response()).say.apply(_ref2, arguments);
return (_ref3 = new Response()).say.apply(_ref3, arguments);
};
Response.card = function () {
var _ref3;
var _ref4;
return (_ref3 = new Response()).card.apply(_ref3, arguments);
return (_ref4 = new Response()).card.apply(_ref4, arguments);
};
Response.reprompt = function () {
var _ref4;
var _ref5;
return (_ref4 = new Response()).reprompt.apply(_ref4, arguments);
return (_ref5 = new Response()).reprompt.apply(_ref5, arguments);
};
Response.shouldEndSession = function () {
var _ref5;
var _ref6;
return (_ref5 = new Response()).shouldEndSession.apply(_ref5, arguments);
return (_ref6 = new Response()).shouldEndSession.apply(_ref6, arguments);
};
var outputSpeech = function outputSpeech(text) {
var type = arguments.length <= 1 || arguments[1] === undefined ? PlainText : arguments[1];
var type = arguments.length <= 1 || arguments[1] === undefined ? SpeechType.PlainText : arguments[1];
if (type === SSML || (typeof text === 'undefined' ? 'undefined' : babelHelpers.typeof(text)) === 'object') {
return { outputSpeech: { type: SSML, ssml: (typeof text === 'undefined' ? 'undefined' : babelHelpers.typeof(text)) === 'object' ? alexaSsml.renderToString(text) : text } };
if (type === SpeechType.SSML || (typeof text === 'undefined' ? 'undefined' : babelHelpers.typeof(text)) === 'object') {
var speech = (typeof text === 'undefined' ? 'undefined' : babelHelpers.typeof(text)) === 'object' ? alexaSsml.renderToString(text) : text;
return { outputSpeech: { type: SpeechType.SSML, ssml: speech } };
} else {

@@ -179,5 +189,4 @@ return { outputSpeech: { type: type, text: text } };

exports.SSML = SSML;
exports.PlainText = PlainText;
exports.Simple = Simple;
exports.CardType = CardType;
exports.SpeechType = SpeechType;
exports['default'] = Response;

@@ -184,0 +193,0 @@ exports.ask = ask;

@@ -1,1 +0,1 @@

"use strict";var alexaSsml=require("alexa-ssml"),babelHelpers={};babelHelpers["typeof"]="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},babelHelpers.classCallCheck=function(e,s){if(!(e instanceof s))throw new TypeError("Cannot call a class as a function")},babelHelpers.createClass=function(){function e(e,s){for(var t=0;t<s.length;t++){var n=s[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(s,t,n){return t&&e(s.prototype,t),n&&e(s,n),s}}(),babelHelpers["extends"]=Object.assign||function(e){for(var s=1;s<arguments.length;s++){var t=arguments[s];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e};var SSML="SSML",PlainText="PlainText",Simple="Simple",Response=function(){function e(){var s=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];babelHelpers.classCallCheck(this,e),this.state=s}return babelHelpers.createClass(e,[{key:"ask",value:function(e,s){return this.say(e,s).shouldEndSession(!1)}},{key:"say",value:function(s,t){return new e(babelHelpers["extends"]({},this.state,{response:babelHelpers["extends"]({},this.state.response,{shouldEndSession:!0},outputSpeech(s,t))}))}},{key:"reprompt",value:function(s,t){return new e(babelHelpers["extends"]({},this.state,{response:babelHelpers["extends"]({},this.state.response,{reprompt:babelHelpers["extends"]({},outputSpeech(s,t))})}))}},{key:"card",value:function(s,t){var n=arguments.length<=2||void 0===arguments[2]?Simple:arguments[2];return new e(babelHelpers["extends"]({},this.state,{response:babelHelpers["extends"]({},this.state.response,{card:{type:n,title:s,content:t}})}))}},{key:"attributes",value:function(s){return new e(babelHelpers["extends"]({},this.state,{sessionAttributes:babelHelpers["extends"]({},this.state.sessionAttributes,s)}))}},{key:"shouldEndSession",value:function(s){return new e(babelHelpers["extends"]({},this.state,{response:babelHelpers["extends"]({},this.state.response,{shouldEndSession:s})}))}},{key:"build",value:function(e){return babelHelpers["extends"]({version:"1.0"},this.state,{response:babelHelpers["extends"]({shouldEndSession:!0},this.state.response)},e||this.state.sessionAttributes?{sessionAttributes:babelHelpers["extends"]({},e,this.state.sessionAttributes)}:null)}}]),e}();Response.ask=function(){var e;return(e=new Response).ask.apply(e,arguments)},Response.say=function(){var e;return(e=new Response).say.apply(e,arguments)},Response.card=function(){var e;return(e=new Response).card.apply(e,arguments)},Response.reprompt=function(){var e;return(e=new Response).reprompt.apply(e,arguments)},Response.shouldEndSession=function(){var e;return(e=new Response).shouldEndSession.apply(e,arguments)};var outputSpeech=function(e){var s=arguments.length<=1||void 0===arguments[1]?PlainText:arguments[1];return s===SSML||"object"===("undefined"==typeof e?"undefined":babelHelpers["typeof"](e))?{outputSpeech:{type:SSML,ssml:"object"===("undefined"==typeof e?"undefined":babelHelpers["typeof"](e))?alexaSsml.renderToString(e):e}}:{outputSpeech:{type:s,text:e}}},ask=Response.ask,say=Response.say,card=Response.card,reprompt=Response.reprompt,shouldEndSession=Response.shouldEndSession;exports.SSML=SSML,exports.PlainText=PlainText,exports.Simple=Simple,exports["default"]=Response,exports.ask=ask,exports.say=say,exports.card=card,exports.reprompt=reprompt,exports.shouldEndSession=shouldEndSession;
"use strict";var alexaSsml=require("alexa-ssml"),babelHelpers={};babelHelpers["typeof"]="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},babelHelpers.classCallCheck=function(e,s){if(!(e instanceof s))throw new TypeError("Cannot call a class as a function")},babelHelpers.createClass=function(){function e(e,s){for(var t=0;t<s.length;t++){var n=s[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(s,t,n){return t&&e(s.prototype,t),n&&e(s,n),s}}(),babelHelpers["extends"]=Object.assign||function(e){for(var s=1;s<arguments.length;s++){var t=arguments[s];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e};var CardType={LinkAccount:"LinkAccount",Simple:"Simple"},SpeechType={PlainText:"PlainText",SSML:"SSML"},Response=function(){function e(){var s=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];babelHelpers.classCallCheck(this,e),this.state=s}return babelHelpers.createClass(e,[{key:"ask",value:function(e,s){return this.say(e,s).shouldEndSession(!1)}},{key:"say",value:function(s,t){return new e(babelHelpers["extends"]({},this.state,{response:babelHelpers["extends"]({},this.state.response,{shouldEndSession:!0},outputSpeech(s,t))}))}},{key:"reprompt",value:function(s,t){return new e(babelHelpers["extends"]({},this.state,{response:babelHelpers["extends"]({},this.state.response,{reprompt:babelHelpers["extends"]({},outputSpeech(s,t))})}))}},{key:"card",value:function(s){var t=s.title,n=s.content,r=s.type,o=void 0===r?CardType.Simple:r;return new e(babelHelpers["extends"]({},this.state,{response:babelHelpers["extends"]({},this.state.response,{card:babelHelpers["extends"]({},o&&{type:o},t&&{title:t},n&&{content:n})})}))}},{key:"attributes",value:function(s){return new e(babelHelpers["extends"]({},this.state,{sessionAttributes:babelHelpers["extends"]({},this.state.sessionAttributes,s)}))}},{key:"shouldEndSession",value:function(s){return new e(babelHelpers["extends"]({},this.state,{response:babelHelpers["extends"]({},this.state.response,{shouldEndSession:s})}))}},{key:"build",value:function(e){return babelHelpers["extends"]({version:"1.0"},this.state,{response:babelHelpers["extends"]({shouldEndSession:!0},this.state.response)},e||this.state.sessionAttributes?{sessionAttributes:babelHelpers["extends"]({},e,this.state.sessionAttributes)}:null)}}]),e}();Response.ask=function(){var e;return(e=new Response).ask.apply(e,arguments)},Response.say=function(){var e;return(e=new Response).say.apply(e,arguments)},Response.card=function(){var e;return(e=new Response).card.apply(e,arguments)},Response.reprompt=function(){var e;return(e=new Response).reprompt.apply(e,arguments)},Response.shouldEndSession=function(){var e;return(e=new Response).shouldEndSession.apply(e,arguments)};var outputSpeech=function(e){var s=arguments.length<=1||void 0===arguments[1]?SpeechType.PlainText:arguments[1];if(s===SpeechType.SSML||"object"===("undefined"==typeof e?"undefined":babelHelpers["typeof"](e))){var t="object"===("undefined"==typeof e?"undefined":babelHelpers["typeof"](e))?alexaSsml.renderToString(e):e;return{outputSpeech:{type:SpeechType.SSML,ssml:t}}}return{outputSpeech:{type:s,text:e}}},ask=Response.ask,say=Response.say,card=Response.card,reprompt=Response.reprompt,shouldEndSession=Response.shouldEndSession;exports.CardType=CardType,exports.SpeechType=SpeechType,exports["default"]=Response,exports.ask=ask,exports.say=say,exports.card=card,exports.reprompt=reprompt,exports.shouldEndSession=shouldEndSession;
{
"name": "alexa-response",
"version": "2.0.1",
"version": "3.0.0",
"description": "Build JSON responses for Amazon Alexa, easily.",

@@ -31,7 +31,7 @@ "author": "Cameron Hunter <hello@cameronhunter.co.uk>",

"dependencies": {
"alexa-ssml": "^0.3.2"
"alexa-ssml": "^0.5.0"
},
"devDependencies": {
"ava": "^0.12.0",
"babel-eslint": "^5.0.0",
"ava": "^0.13.0",
"babel-eslint": "^6.0.0-beta.6",
"babel-plugin-transform-react-jsx": "^6.5.2",

@@ -47,3 +47,6 @@ "babel-preset-es2015": "^6.5.0",

"rollup-plugin-uglify": "^0.2.0"
},
"ava": {
"babel": "inherit"
}
}

@@ -39,10 +39,10 @@ # Alexa Response

### card(title: String, content: String)
### card(options: Object)
Cards show up in the Alexa app. Simple cards have titles and content, you can
pass an optional third parameter for different card types.
pass an optional `type` for different card types.
```javascript
Response.say("I've put the answer to your question on your phone")
.card('Question and Answer', "Here's the answer to your question")
.card({ title: 'Question and Answer', content: "Here's the answer to your question" })
.build();

@@ -68,3 +68,3 @@ ```

Response.say("I've put the answer to your question on your phone")
.card('Question and Answer', "Here's the answer to your question")
.card({ title: 'Question and Answer', content: "Here's the answer to your question" })
.build();

@@ -71,0 +71,0 @@ ```

import { renderToString } from 'alexa-ssml';
export const SSML = 'SSML';
export const PlainText = 'PlainText';
export const Simple = 'Simple';
export const CardType = {
LinkAccount: 'LinkAccount',
Simple: 'Simple'
};
export const SpeechType = {
PlainText: 'PlainText',
SSML: 'SSML'
};
export default class Response {

@@ -43,3 +49,3 @@ static ask = (...args) => new Response().ask(...args);

card(title, content, type = Simple) {
card({ title, content, type = CardType.Simple }) {
return new Response({

@@ -49,3 +55,7 @@ ...this.state,

...this.state.response,
card: { type, title, content }
card: {
...(type && { type }),
...(title && { title }),
...(content && { content })
}
}

@@ -88,5 +98,6 @@ });

const outputSpeech = (text, type = PlainText) => {
if (type === SSML || typeof text === 'object') {
return { outputSpeech: { type: SSML, ssml: (typeof text === 'object') ? renderToString(text) : text } };
const outputSpeech = (text, type = SpeechType.PlainText) => {
if (type === SpeechType.SSML || typeof text === 'object') {
const speech = (typeof text === 'object') ? renderToString(text) : text;
return { outputSpeech: { type: SpeechType.SSML, ssml: speech } };
} else {

@@ -93,0 +104,0 @@ return { outputSpeech: { type, text } };

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc