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 3.2.3 to 4.0.0

45

build/index.js

@@ -6,14 +6,4 @@ 'use strict';

var alexaSsmlJsx = require('alexa-ssml-jsx');
var alexaConstants = require('alexa-constants');
var CardType = {
LinkAccount: 'LinkAccount',
Simple: 'Simple',
Standard: 'Standard'
};
var SpeechType = {
PlainText: 'PlainText',
SSML: 'SSML'
};
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {

@@ -325,3 +315,3 @@ return typeof obj;

var _ref$type = _ref.type;
var type = _ref$type === undefined ? CardType.Simple : _ref$type;
var type = _ref$type === undefined ? alexaConstants.CardType.Simple : _ref$type;
var rest = objectWithoutProperties(_ref, ['type']);

@@ -432,7 +422,7 @@

var outputSpeech = function outputSpeech(text) {
var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : SpeechType.PlainText;
var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : alexaConstants.SpeechType.PlainText;
if (type === SpeechType.SSML || (typeof text === 'undefined' ? 'undefined' : _typeof(text)) === 'object') {
if (type === alexaConstants.SpeechType.SSML || (typeof text === 'undefined' ? 'undefined' : _typeof(text)) === 'object') {
var speech = (typeof text === 'undefined' ? 'undefined' : _typeof(text)) === 'object' ? alexaSsmlJsx.renderToString(text) : text;
return { outputSpeech: { type: SpeechType.SSML, ssml: speech } };
return { outputSpeech: { type: alexaConstants.SpeechType.SSML, ssml: speech } };
} else {

@@ -443,7 +433,12 @@ return { outputSpeech: { type: type, text: text } };

var AudioPlayer = {
var Directive = alexaConstants.AudioPlayer.Directive;
var PlayBehavior = alexaConstants.AudioPlayer.PlayBehavior;
var ClearBehavior = alexaConstants.AudioPlayer.ClearBehavior;
var AudioPlayer$1 = {
play: function play(stream) {
return {
type: 'AudioPlayer.Play',
playBehavior: 'REPLACE_ALL',
type: Directive.Play,
playBehavior: PlayBehavior.ReplaceAll,
audioItem: { stream: stream }

@@ -456,4 +451,4 @@ };

return {
type: 'AudioPlayer.Play',
playBehavior: replaceQueue ? 'REPLACE_ENQUEUED' : 'ENQUEUE',
type: Directive.Play,
playBehavior: replaceQueue ? PlayBehavior.ReplaceEnqueued : PlayBehavior.Enqueue,
audioItem: { stream: stream }

@@ -464,3 +459,3 @@ };

return {
type: 'AudioPlayer.Stop'
type: Directive.Stop
};

@@ -472,4 +467,4 @@ },

return {
type: 'AudioPlayer.ClearQueue',
clearBehavior: stopCurrent ? 'CLEAR_ALL' : 'CLEAR_ENQUEUED'
type: Directive.ClearQueue,
clearBehavior: stopCurrent ? ClearBehavior.ClearAll : ClearBehavior.ClearEnqueued
};

@@ -488,5 +483,3 @@ }

exports.CardType = CardType;
exports.SpeechType = SpeechType;
exports.AudioPlayer = AudioPlayer;
exports.AudioPlayer = AudioPlayer$1;
exports.Response = Response$1;

@@ -493,0 +486,0 @@ exports['default'] = Response$1;

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var alexaSsmlJsx=require("alexa-ssml-jsx"),CardType={LinkAccount:"LinkAccount",Simple:"Simple",Standard:"Standard"},SpeechType={PlainText:"PlainText",SSML:"SSML"},_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},asyncGenerator=function(){function e(e){this.value=e}function t(t){function n(e,t){return new Promise(function(n,s){var i={key:e,arg:t,resolve:n,reject:s,next:null};a?a=a.next=i:(o=a=i,r(e,t))})}function r(n,o){try{var a=t[n](o),i=a.value;i instanceof e?Promise.resolve(i.value).then(function(e){r("next",e)},function(e){r("throw",e)}):s(a.done?"return":"normal",a.value)}catch(e){s("throw",e)}}function s(e,t){switch(e){case"return":o.resolve({value:t,done:!0});break;case"throw":o.reject(t);break;default:o.resolve({value:t,done:!1})}o=o.next,o?r(o.key,o.arg):a=null}var o,a;this._invoke=n,"function"!=typeof t.return&&(this.return=void 0)}return"function"==typeof Symbol&&Symbol.asyncIterator&&(t.prototype[Symbol.asyncIterator]=function(){return this}),t.prototype.next=function(e){return this._invoke("next",e)},t.prototype.throw=function(e){return this._invoke("throw",e)},t.prototype.return=function(e){return this._invoke("return",e)},{wrap:function(e){return function(){return new t(e.apply(this,arguments))}},await:function(t){return new e(t)}}}(),classCallCheck=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),_extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},get=function e(t,n,r){null===t&&(t=Function.prototype);var s=Object.getOwnPropertyDescriptor(t,n);if(void 0===s){var o=Object.getPrototypeOf(t);return null===o?void 0:e(o,n,r)}if("value"in s)return s.value;var a=s.get;if(void 0!==a)return a.call(r)},objectWithoutProperties=function(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n},set=function e(t,n,r,s){var o=Object.getOwnPropertyDescriptor(t,n);if(void 0===o){var a=Object.getPrototypeOf(t);null!==a&&e(a,n,r,s)}else if("value"in o&&o.writable)o.value=r;else{var i=o.set;void 0!==i&&i.call(s,r)}return r},toConsumableArray=function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)},_class,_temp,Response$1=(_temp=_class=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};classCallCheck(this,e),this.state=t}return createClass(e,[{key:"ask",value:function(e,t){return this.say(e,t).shouldEndSession(!1)}},{key:"say",value:function(t,n){return new e(_extends({},this.state,{response:_extends({},this.state.response,{shouldEndSession:!0},outputSpeech(t,n))}))}},{key:"reprompt",value:function(t,n){return new e(_extends({},this.state,{response:_extends({},this.state.response,{reprompt:_extends({},outputSpeech(t,n))})}))}},{key:"card",value:function(t){var n=t.type,r=void 0===n?CardType.Simple:n,s=objectWithoutProperties(t,["type"]);return new e(_extends({},this.state,{response:_extends({},this.state.response,{card:_extends({},s,r&&{type:r})})}))}},{key:"attributes",value:function(t){return new e(_extends({},this.state,{sessionAttributes:_extends({},this.state.sessionAttributes,t)}))}},{key:"shouldEndSession",value:function(t){return new e(_extends({},this.state,{response:_extends({},this.state.response,{shouldEndSession:t})}))}},{key:"directives",value:function t(n){for(var r=arguments.length,s=Array(r>1?r-1:0),o=1;o<r;o++)s[o-1]=arguments[o];var t=Array.isArray(n)?n:[n].concat(s),a=this.state.response||{},i=a.directives,u=void 0===i?[]:i;return new e(_extends({},this.state,{response:_extends({},this.state.response,{directives:[].concat(toConsumableArray(u),toConsumableArray(t))})}))}},{key:"build",value:function(e){return _extends({version:"1.0"},this.state,{response:_extends({shouldEndSession:!0},this.state.response)},e||this.state.sessionAttributes?{sessionAttributes:_extends({},e,this.state.sessionAttributes)}:null)}}]),e}(),_class.ask=function(){var e;return(e=new Response$1).ask.apply(e,arguments)},_class.say=function(){var e;return(e=new Response$1).say.apply(e,arguments)},_class.card=function(){var e;return(e=new Response$1).card.apply(e,arguments)},_class.reprompt=function(){var e;return(e=new Response$1).reprompt.apply(e,arguments)},_class.shouldEndSession=function(){var e;return(e=new Response$1).shouldEndSession.apply(e,arguments)},_class.directives=function(){var e;return(e=new Response$1).directives.apply(e,arguments)},_class.build=function(e){return Object.keys(e).reduce(function(t,n){var r=e[n],s="string"==typeof r?r:r,o="string"==typeof r?void 0:r.type;switch(n){case"ask":return t.ask(s,o);case"say":return t.say(s,o);case"reprompt":return t.reprompt(s,o);case"card":return t.card(r);case"attributes":return t.attributes(r);case"shouldEndSession":return t.shouldEndSession(r);case"directives":return t.directives(r)}},new Response$1)},_temp),outputSpeech=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:SpeechType.PlainText;if(t===SpeechType.SSML||"object"===("undefined"==typeof e?"undefined":_typeof(e))){var n="object"===("undefined"==typeof e?"undefined":_typeof(e))?alexaSsmlJsx.renderToString(e):e;return{outputSpeech:{type:SpeechType.SSML,ssml:n}}}return{outputSpeech:{type:t,text:e}}},AudioPlayer={play:function(e){return{type:"AudioPlayer.Play",playBehavior:"REPLACE_ALL",audioItem:{stream:e}}},enqueue:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return{type:"AudioPlayer.Play",playBehavior:t?"REPLACE_ENQUEUED":"ENQUEUE",audioItem:{stream:e}}},stop:function(){return{type:"AudioPlayer.Stop"}},clearQueue:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return{type:"AudioPlayer.ClearQueue",clearBehavior:e?"CLEAR_ALL":"CLEAR_ENQUEUED"}}},ask$1=Response$1.ask,say$1=Response$1.say,card$1=Response$1.card,reprompt$1=Response$1.reprompt,shouldEndSession$1=Response$1.shouldEndSession,directives=Response$1.directives,build$1=Response$1.build;exports.CardType=CardType,exports.SpeechType=SpeechType,exports.AudioPlayer=AudioPlayer,exports.Response=Response$1,exports.default=Response$1,exports.ask=ask$1,exports.say=say$1,exports.card=card$1,exports.reprompt=reprompt$1,exports.shouldEndSession=shouldEndSession$1,exports.directives=directives,exports.build=build$1;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var alexaSsmlJsx=require("alexa-ssml-jsx"),alexaConstants=require("alexa-constants"),_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},asyncGenerator=function(){function e(e){this.value=e}function t(t){function r(e,t){return new Promise(function(r,s){var i={key:e,arg:t,resolve:r,reject:s,next:null};a?a=a.next=i:(o=a=i,n(e,t))})}function n(r,o){try{var a=t[r](o),i=a.value;i instanceof e?Promise.resolve(i.value).then(function(e){n("next",e)},function(e){n("throw",e)}):s(a.done?"return":"normal",a.value)}catch(e){s("throw",e)}}function s(e,t){switch(e){case"return":o.resolve({value:t,done:!0});break;case"throw":o.reject(t);break;default:o.resolve({value:t,done:!1})}o=o.next,o?n(o.key,o.arg):a=null}var o,a;this._invoke=r,"function"!=typeof t.return&&(this.return=void 0)}return"function"==typeof Symbol&&Symbol.asyncIterator&&(t.prototype[Symbol.asyncIterator]=function(){return this}),t.prototype.next=function(e){return this._invoke("next",e)},t.prototype.throw=function(e){return this._invoke("throw",e)},t.prototype.return=function(e){return this._invoke("return",e)},{wrap:function(e){return function(){return new t(e.apply(this,arguments))}},await:function(t){return new e(t)}}}(),classCallCheck=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},createClass=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),_extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},get=function e(t,r,n){null===t&&(t=Function.prototype);var s=Object.getOwnPropertyDescriptor(t,r);if(void 0===s){var o=Object.getPrototypeOf(t);return null===o?void 0:e(o,r,n)}if("value"in s)return s.value;var a=s.get;if(void 0!==a)return a.call(n)},objectWithoutProperties=function(e,t){var r={};for(var n in e)t.indexOf(n)>=0||Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n]);return r},set=function e(t,r,n,s){var o=Object.getOwnPropertyDescriptor(t,r);if(void 0===o){var a=Object.getPrototypeOf(t);null!==a&&e(a,r,n,s)}else if("value"in o&&o.writable)o.value=n;else{var i=o.set;void 0!==i&&i.call(s,n)}return n},toConsumableArray=function(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)},_class,_temp,Response$1=(_temp=_class=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};classCallCheck(this,e),this.state=t}return createClass(e,[{key:"ask",value:function(e,t){return this.say(e,t).shouldEndSession(!1)}},{key:"say",value:function(t,r){return new e(_extends({},this.state,{response:_extends({},this.state.response,{shouldEndSession:!0},outputSpeech(t,r))}))}},{key:"reprompt",value:function(t,r){return new e(_extends({},this.state,{response:_extends({},this.state.response,{reprompt:_extends({},outputSpeech(t,r))})}))}},{key:"card",value:function(t){var r=t.type,n=void 0===r?alexaConstants.CardType.Simple:r,s=objectWithoutProperties(t,["type"]);return new e(_extends({},this.state,{response:_extends({},this.state.response,{card:_extends({},s,n&&{type:n})})}))}},{key:"attributes",value:function(t){return new e(_extends({},this.state,{sessionAttributes:_extends({},this.state.sessionAttributes,t)}))}},{key:"shouldEndSession",value:function(t){return new e(_extends({},this.state,{response:_extends({},this.state.response,{shouldEndSession:t})}))}},{key:"directives",value:function t(r){for(var n=arguments.length,s=Array(n>1?n-1:0),o=1;o<n;o++)s[o-1]=arguments[o];var t=Array.isArray(r)?r:[r].concat(s),a=this.state.response||{},i=a.directives,u=void 0===i?[]:i;return new e(_extends({},this.state,{response:_extends({},this.state.response,{directives:[].concat(toConsumableArray(u),toConsumableArray(t))})}))}},{key:"build",value:function(e){return _extends({version:"1.0"},this.state,{response:_extends({shouldEndSession:!0},this.state.response)},e||this.state.sessionAttributes?{sessionAttributes:_extends({},e,this.state.sessionAttributes)}:null)}}]),e}(),_class.ask=function(){var e;return(e=new Response$1).ask.apply(e,arguments)},_class.say=function(){var e;return(e=new Response$1).say.apply(e,arguments)},_class.card=function(){var e;return(e=new Response$1).card.apply(e,arguments)},_class.reprompt=function(){var e;return(e=new Response$1).reprompt.apply(e,arguments)},_class.shouldEndSession=function(){var e;return(e=new Response$1).shouldEndSession.apply(e,arguments)},_class.directives=function(){var e;return(e=new Response$1).directives.apply(e,arguments)},_class.build=function(e){return Object.keys(e).reduce(function(t,r){var n=e[r],s="string"==typeof n?n:n,o="string"==typeof n?void 0:n.type;switch(r){case"ask":return t.ask(s,o);case"say":return t.say(s,o);case"reprompt":return t.reprompt(s,o);case"card":return t.card(n);case"attributes":return t.attributes(n);case"shouldEndSession":return t.shouldEndSession(n);case"directives":return t.directives(n)}},new Response$1)},_temp),outputSpeech=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:alexaConstants.SpeechType.PlainText;if(t===alexaConstants.SpeechType.SSML||"object"===("undefined"==typeof e?"undefined":_typeof(e))){var r="object"===("undefined"==typeof e?"undefined":_typeof(e))?alexaSsmlJsx.renderToString(e):e;return{outputSpeech:{type:alexaConstants.SpeechType.SSML,ssml:r}}}return{outputSpeech:{type:t,text:e}}},Directive=alexaConstants.AudioPlayer.Directive,PlayBehavior=alexaConstants.AudioPlayer.PlayBehavior,ClearBehavior=alexaConstants.AudioPlayer.ClearBehavior,AudioPlayer$1={play:function(e){return{type:Directive.Play,playBehavior:PlayBehavior.ReplaceAll,audioItem:{stream:e}}},enqueue:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return{type:Directive.Play,playBehavior:t?PlayBehavior.ReplaceEnqueued:PlayBehavior.Enqueue,audioItem:{stream:e}}},stop:function(){return{type:Directive.Stop}},clearQueue:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return{type:Directive.ClearQueue,clearBehavior:e?ClearBehavior.ClearAll:ClearBehavior.ClearEnqueued}}},ask$1=Response$1.ask,say$1=Response$1.say,card$1=Response$1.card,reprompt$1=Response$1.reprompt,shouldEndSession$1=Response$1.shouldEndSession,directives=Response$1.directives,build$1=Response$1.build;exports.AudioPlayer=AudioPlayer$1,exports.Response=Response$1,exports.default=Response$1,exports.ask=ask$1,exports.say=say$1,exports.card=card$1,exports.reprompt=reprompt$1,exports.shouldEndSession=shouldEndSession$1,exports.directives=directives,exports.build=build$1;
{
"name": "alexa-response",
"version": "3.2.3",
"version": "4.0.0",
"description": "Build JSON responses for Amazon Alexa, easily.",

@@ -20,4 +20,5 @@ "author": "Cameron Hunter <hello@cameronhunter.co.uk>",

"dependencies": {
"alexa-ssml-jsx": "^1.0.1"
"alexa-ssml-jsx": "^1.0.1",
"alexa-constants": "^0.3.0"
}
}

@@ -0,6 +1,9 @@

import { AudioPlayer } from 'alexa-constants';
const { Directive, PlayBehavior, ClearBehavior } = AudioPlayer;
export default {
play(stream) {
return {
type: 'AudioPlayer.Play',
playBehavior: 'REPLACE_ALL',
type: Directive.Play,
playBehavior: PlayBehavior.ReplaceAll,
audioItem: { stream }

@@ -12,4 +15,4 @@ };

return {
type: 'AudioPlayer.Play',
playBehavior: replaceQueue ? 'REPLACE_ENQUEUED' : 'ENQUEUE',
type: Directive.Play,
playBehavior: replaceQueue ? PlayBehavior.ReplaceEnqueued : PlayBehavior.Enqueue,
audioItem: { stream }

@@ -21,3 +24,3 @@ };

return {
type: 'AudioPlayer.Stop'
type: Directive.Stop
};

@@ -28,6 +31,6 @@ },

return {
type: 'AudioPlayer.ClearQueue',
clearBehavior: stopCurrent ? 'CLEAR_ALL' : 'CLEAR_ENQUEUED'
type: Directive.ClearQueue,
clearBehavior: stopCurrent ? ClearBehavior.ClearAll : ClearBehavior.ClearEnqueued
};
}
};
import Response from './Response';
export CardType from './constants/CardType';
export SpeechType from './constants/SpeechType';
export AudioPlayer from './AudioPlayer';

@@ -7,0 +4,0 @@ export Response from './Response';

import ssml, { renderToString } from 'alexa-ssml-jsx';
import CardType from './constants/CardType';
import SpeechType from './constants/SpeechType';
import { CardType, SpeechType } from 'alexa-constants';

@@ -5,0 +4,0 @@ export default class Response {

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