Socket
Socket
Sign inDemoInstall

ivona-node

Package Overview
Dependencies
2
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.3.0 to 0.4.0

2

package.json
{
"name": "ivona-node",
"version": "0.3.0",
"version": "0.4.0",
"description": "Ivona Cloud (via Amazon services) client library for Node",

@@ -5,0 +5,0 @@ "main": "src/main.js",

@@ -9,2 +9,6 @@ # Node IVONA

- ListVoices
- PutLexicon
- GetLexicon
- DeleteLexicon
- ListLexicons

@@ -48,2 +52,44 @@ ## Installation

## Lexicons (via @UnaliWear)
```javascript
var ivona = new Ivona({
accessKey: 'IVONA_ACCESS_KEY',
secretKey: 'IVONA_SECRET_KEY'
});
// ivona.putLexicon(name, content)
// [string] name - the name of this lexicon
// [string] content - PLS xml
// [object] config (optional) - override Ivona request via 'body' value
ivona.putLexicon('newLexicon', '<?xml ... ?><lexicon>...</lexicon>')
.on('complete', function(lexicons) {
console.log(lexicons);
});
// ivona.getLexicon(name)
// [string] name - the name of this lexicon
// [object] config (optional) - override Ivona request via 'body' value
ivona.getLexicon('newLexicon')
.on('complete', function(pls) {
console.log(pls);
});
// ivona.deleteLexicon(name)
// [string] name - the name of this lexicon
// [object] config (optional) - override Ivona request via 'body' value
ivona.deleteLexicon('newLexicon')
.on('complete', function() {
console.log('Done');
});
// ivona.listLexicons()
// [object] config (optional) - override Ivona request via 'body' value
ivona.listLexicons()
.on('complete', function(lexicons) {
console.log(lexicons);
});
```
## With Proxy Support (via @kuzzmi)

@@ -64,1 +110,2 @@

- @kuzzmi
- @UnaliWear

@@ -39,2 +39,12 @@ 'use strict';

var putLexiconSettings = {
lexicon: {}
};
var getLexiconSettings = {};
var deleteLexiconSettings = {};
var listLexiconSettings = {};
/**

@@ -95,3 +105,3 @@ * Grab values of property `prop` from object `source`

for (i in source) {
if (typeof source[i] !== 'object') {
if (typeof source[i] !== 'object' || Array.isArray(source[i])) {
output[i.charAt(0)[method]() + i.substr(1)] = source[i];

@@ -158,3 +168,3 @@ } else {

if (buffer) {
if (/json/i.test(res.headers['content-type'])) {
if (/json/i.test(res.headers['content-type']) && data.length > 0) {
req.emit('complete', caseProperties(JSON.parse(data), true, true));

@@ -192,3 +202,3 @@ } else {

this.region = config.region || 'eu-west-1';
// THAT IS OPTIONAL (if proxy should be defined)

@@ -278,2 +288,115 @@ this.proxy = config.proxy || undefined;

return this.request.exec();
},
/**
* Interface to the Ivona Cloud `PutLexicon` endpoint
* @param {String} name Name of this lexicon
* @param {String} contents PLS contents
* @param {Object} config Configuration overrides
* @return {IvonaRequest} The `https.request` returned from an `IvonaRequest`
*/
putLexicon: function(name, contents, config) {
if (!config) config = {};
if (config.body) {
config.body = merge(Object.create(putLexiconSettings), config.body);
} else {
config.body = Object.create(putLexiconSettings);
}
config.body.lexicon.name = name;
config.body.lexicon.contents = contents;
// must be string for aws4
config.body = JSON.stringify(caseProperties(config.body, true));
this.request = new IvonaRequest(
this.getRequest('/PutLexicon', config),
this
);
return this.request.exec();
},
/**
* Interface to the Ivona Cloud `GetLexicons` endpoint
* @param {Object} name Name of lexicon to retrieve
* @param {Object} config Configuration overrides
* @return {IvonaRequest} The `https.request` returned from an `IvonaRequest`
*/
getLexicon: function(name, config) {
if (!config) config = {};
if (config.body) {
config.body = merge(Object.create(getLexiconSettings), config.body);
} else {
config.body = Object.create(getLexiconSettings);
}
config.body.name = name;
// must be string for aws4
config.body = JSON.stringify(caseProperties(config.body, true));
config.buffer = true;
this.request = new IvonaRequest(
this.getRequest('/GetLexicon', config || {}),
this
);
return this.request.exec();
},
/**
* Interface to the Ivona Cloud `DeleteLexicon` endpoint
* @param {Object} name Name of lexicon to retrieve
* @param {Object} config Configuration overrides
* @return {IvonaRequest} The `https.request` returned from an `IvonaRequest`
*/
deleteLexicon: function(name, config) {
if (!config) config = {};
if (config.body) {
config.body = merge(Object.create(deleteLexiconSettings), config.body);
} else {
config.body = Object.create(deleteLexiconSettings);
}
config.body.name = name;
// must be string for aws4
config.body = JSON.stringify(caseProperties(config.body, true));
config.buffer = true;
this.request = new IvonaRequest(
this.getRequest('/DeleteLexicon', config || {}),
this
);
return this.request.exec();
},
/**
* Interface to the Ivona Cloud `ListLexicons` endpoint
* @param {Object} config Configuration overrides
* @return {IvonaRequest} The `https.request` returned from an `IvonaRequest`
*/
listLexicons: function(config) {
if (!config) config = {};
if (config.body) {
config.body = merge(Object.create(listLexiconSettings), config.body);
} else {
config.body = Object.create(listLexiconSettings);
}
// must be string for aws4
config.body = JSON.stringify(caseProperties(config, true));
config.buffer = true;
this.request = new IvonaRequest(
this.getRequest('/ListLexicons', config || {}),
this
);
return this.request.exec();
}

@@ -280,0 +403,0 @@ };

@@ -19,5 +19,5 @@ var util = require('util'),

method : 'CONNECT',
path : opts.host + ':' + opts.port,
path : opts.host.host + ':' + opts.host.port,
headers : {
host: opts.host
host: opts.host.host
}

@@ -28,3 +28,3 @@ });

var cts = Tls.connect({
host: opts.host,
host: opts.host.host,
socket: socket

@@ -31,0 +31,0 @@ }, function () {

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc