Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

alexa-ssml

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

alexa-ssml - npm Package Compare versions

Comparing version 0.3.1 to 0.3.2

.eslintrc

19

lib/renderToString.js

@@ -13,6 +13,2 @@ 'use strict';

var _XMLStringifier = require('xmlbuilder/lib/XMLStringifier');
var _XMLStringifier2 = _interopRequireDefault(_XMLStringifier);
var _each = require('lodash/each');

@@ -34,11 +30,11 @@

// just kebab-cases all attributes and tag names
var stringify = {
var customStringifyOptions = {
eleName: function eleName() {
var val = arguments.length <= 0 || arguments[0] === undefined ? "" : arguments[0];
var val = arguments.length <= 0 || arguments[0] === undefined ? '' : arguments[0];
val = (0, _kebabCase2.default)(val || "");
val = (0, _kebabCase2.default)(val || ''); // eslint-disable-line no-param-reassign
return this.assertLegalChar(val);
},
attName: function attName(val) {
val = (0, _kebabCase2.default)(val || "");
val = (0, _kebabCase2.default)(val || ''); // eslint-disable-line no-param-reassign
return val;

@@ -71,6 +67,9 @@ }

function renderToString(data) {
if ((0, _get2.default)(data, 'tag') !== 'speak') throw new Error('SSML must start with a "speak" tag, currently "' + rootTag + '"');
var rootTag = (0, _get2.default)(data, 'tag');
if (rootTag !== 'speak') {
throw new Error('SSML must start with a \'speak\' tag, currently \'' + rootTag + '\'');
}
var xml = _xmlbuilder2.default.create(data.tag, {
stringify: stringify,
stringify: customStringifyOptions,
headless: true

@@ -77,0 +76,0 @@ });

@@ -14,5 +14,5 @@ 'use strict';

var _flatten = require('lodash/flatten');
var _flattenDeep = require('lodash/flattenDeep');
var _flatten2 = _interopRequireDefault(_flatten);
var _flattenDeep2 = _interopRequireDefault(_flattenDeep);

@@ -34,23 +34,29 @@ var _schema = require('./schema');

var children = (0, _flatten2.default)(args.length ? args : (0, _get2.default)(props, 'children', []));
var children = (0, _flattenDeep2.default)(args.length ? args : (0, _get2.default)(props, 'children', []));
// handle custom elements (only functions for now)
if (typeof tag === "function") return tag(_extends({}, props, { children: children }));
if (typeof tag === 'function') {
return tag(_extends({}, props, { children: children }));
}
// make sure we have a valid tag
if (typeof tag !== "string") throw new Error('Invalid tag: ' + tag);
if (typeof tag !== 'string') {
throw new Error('Invalid tag: ' + tag);
}
// make sure we have a known tag
var type = schemas[tag.toLowerCase()];
if (!type) throw new Error('Unknown tag: ' + tag);
if (!type) {
throw new Error('Unknown tag: ' + tag);
}
// validate and transform props
props = (0, _validateProps.validateProps)(props, type.schema);
props = type.transform(props);
var newProps = (0, _validateProps.validateProps)(props, type.schema);
newProps = type.transform(newProps);
return {
children: children,
tag: type.tag,
props: props,
children: children
props: newProps
};
}

@@ -17,11 +17,11 @@ 'use strict';

var schema = exports.schema = {
"title": "audio",
"description": "",
title: 'audio',
description: '',
"type": "object",
"required": ["src"],
"properties": {
"src": {
"type": "string",
"pattern": "^https.*?"
type: 'object',
required: ['src'],
properties: {
src: {
type: 'string',
pattern: '^https.*?'
}

@@ -28,0 +28,0 @@ }

@@ -17,10 +17,10 @@ 'use strict';

var schema = exports.schema = {
"title": "p",
"description": "",
title: 'p',
description: '',
"type": "object",
"required": [],
"properties": {}
type: 'object',
required: [],
properties: {}
};
var transform = exports.transform = _identity2.default;

@@ -8,26 +8,18 @@ 'use strict';

});
exports.transform = exports.schema = exports.tag = undefined;
var _identity = require('lodash/identity');
var _identity2 = _interopRequireDefault(_identity);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var tag = exports.tag = 'break';
var schema = exports.schema = {
"title": "pause",
"description": "",
title: 'pause',
description: '',
"required": [],
"type": "object",
"properties": {
"strength": {
"enum": ["none", "x-weak", "weak", "medium", "strong", "x-strong"]
required: [],
type: 'object',
properties: {
strength: {
enum: ['none', 'x-weak', 'weak', 'medium', 'strong', 'x-strong']
},
"time": {
"type": "integer",
"min": 0,
"max": 10000
time: {
type: 'integer',
min: 0,
max: 10000
}

@@ -38,5 +30,5 @@ }

var transform = exports.transform = function transform(props) {
if ("time" in props) {
if ('time' in props) {
var time = props.time + 'ms';
props = _extends({}, props, { time: time });
return _extends({}, props, { time: time });
}

@@ -43,0 +35,0 @@

@@ -17,14 +17,14 @@ 'use strict';

var schema = exports.schema = {
"title": "phoneme",
"description": "",
title: 'phoneme',
description: '',
"type": "object",
"required": [],
"properties": {
"alphabet": {
"enum": ["ipa", "x-sampa", "nt-sampa"]
type: 'object',
required: [],
properties: {
alphabet: {
enum: ['ipa', 'x-sampa', 'nt-sampa']
},
"ph": {
"type": "string"
ph: {
type: 'string'
}

@@ -31,0 +31,0 @@ }

@@ -17,10 +17,10 @@ 'use strict';

var schema = exports.schema = {
"title": "s",
"description": "",
title: 's',
description: '',
"type": "object",
"required": [],
"properties": {}
type: 'object',
required: [],
properties: {}
};
var transform = exports.transform = _identity2.default;

@@ -17,14 +17,14 @@ 'use strict';

var schema = exports.schema = {
"title": "sayAs",
"description": "",
title: 'sayAs',
description: '',
"type": "object",
"required": [],
"properties": {
"interpretAs": {
"enum": ["characters", "spell-out", "cardinal", "number", "ordinal", "digits", "fraction", "unit", "date", "time", "telephone", "address"]
type: 'object',
required: [],
properties: {
interpretAs: {
enum: ['characters', 'spell-out', 'cardinal', 'number', 'ordinal', 'digits', 'fraction', 'unit', 'date', 'time', 'telephone', 'address']
},
"format": {
"enum": ["mdy", "dmy", "ymd", "md", "dm", "ym", "my", "d", "m", "y"]
format: {
enum: ['mdy', 'dmy', 'ymd', 'md', 'dm', 'ym', 'my', 'd', 'm', 'y']
}

@@ -31,0 +31,0 @@ }

@@ -17,10 +17,10 @@ 'use strict';

var schema = exports.schema = {
"title": "speak",
"description": "",
title: 'speak',
description: '',
"type": "object",
"required": [],
"properties": {}
type: 'object',
required: [],
properties: {}
};
var transform = exports.transform = _identity2.default;

@@ -17,10 +17,10 @@ 'use strict';

var schema = exports.schema = {
"title": "w",
"description": "",
title: 'w',
description: '',
"type": "object",
"required": [],
"properties": {
"role": {
"enum": ["ivona:VB", "ivona:VBD", "ivona:NN", "ivona:SENSE_1"]
type: 'object',
required: [],
properties: {
role: {
enum: ['ivona:VB', 'ivona:VBD', 'ivona:NN', 'ivona:SENSE_1']
}

@@ -27,0 +27,0 @@ }

@@ -25,5 +25,5 @@ 'use strict';

function validateProps(props, schema) {
props = (0, _omit2.default)(props, 'children');
var itemProps = (0, _omit2.default)(props, 'children'); // TODO add child count validation too?
var _tv4$validateResult = _tv2.default.validateResult(props, schema, false, true);
var _tv4$validateResult = _tv2.default.validateResult(itemProps, schema, false, true);

@@ -33,5 +33,12 @@ var error = _tv4$validateResult.error;

if (error) {
if (error.dataPath) throw new Error('Unknown property: ' + error.dataPath.slice(1));
if (error.dataPath) {
var propName = error.dataPath.slice(1);
throw new Error('Unknown property: ' + propName);
}
if (error.srcPath) throw new Error('Invalid value for property ' + error.srcPath.slice(1) + ': ' + error.message);
if (error.srcPath) {
var propName = error.srcPath.slice(1);
var reason = error.message;
throw new Error('Invalid value for property ' + propName + ': ' + reason);
}

@@ -41,3 +48,3 @@ throw new Error(error.message);

return props;
return itemProps;
}
{
"name": "alexa-ssml",
"version": "0.3.1",
"version": "0.3.2",
"description": "JSX for Alexa Skills Kit SSML",

@@ -42,2 +42,3 @@ "main": "lib/index.js",

"babel-cli": "^6.4.5",
"babel-eslint": "^4.1.8",
"babel-plugin-transform-react-jsx": "^6.4.0",

@@ -48,4 +49,7 @@ "babel-preset-es2015": "^6.3.13",

"chai": "^3.4.1",
"eslint": "^1.10.3",
"eslint-config-airbnb": "^4.0.0",
"eslint-plugin-react": "^3.16.1",
"mocha": "^2.4.4"
}
}
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