-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
1,281 additions
and
262 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
# Package burden | ||
/node_modules | ||
/lib | ||
npm-debug.log | ||
|
||
# Build files | ||
report | ||
|
||
# IDE Files | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
verbose: false | ||
instrumentation: | ||
root: lib | ||
extensions: | ||
- .js | ||
default-excludes: true | ||
excludes: [] | ||
embed-source: false | ||
variable: __coverage__ | ||
compact: true | ||
preserve-comments: false | ||
complete-copy: false | ||
save-baseline: false | ||
baseline-file: ./report/coverage/coverage-baseline.json | ||
include-all-sources: false | ||
include-pid: false | ||
es-modules: false | ||
reporting: | ||
print: summary | ||
reports: | ||
- lcov | ||
dir: ./report/coverage | ||
watermarks: | ||
statements: [50, 80] | ||
lines: [50, 80] | ||
functions: [50, 80] | ||
branches: [50, 80] | ||
report-config: | ||
clover: {file: clover.xml} | ||
cobertura: {file: cobertura-coverage.xml} | ||
json: {file: coverage-final.json} | ||
json-summary: {file: coverage-summary.json} | ||
lcovonly: {file: lcov.info} | ||
teamcity: {file: null, blockName: Code Coverage Summary} | ||
text: {file: null, maxCols: 0} | ||
text-lcov: {file: lcov.info} | ||
text-summary: {file: null} | ||
hooks: | ||
hook-run-in-context: false | ||
post-require-hook: null | ||
handle-sigint: false | ||
check: | ||
global: | ||
statements: 0 | ||
lines: 0 | ||
branches: 0 | ||
functions: 0 | ||
excludes: [] | ||
each: | ||
statements: 0 | ||
lines: 0 | ||
branches: 0 | ||
functions: 0 | ||
excludes: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
# Package burden | ||
/node_modules | ||
/src | ||
npm-debug.log | ||
test | ||
|
||
# Build files | ||
report | ||
|
||
# IDE Files | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
language: node_js | ||
node_js: | ||
- "0.12" | ||
before_script: npm i | ||
script: | ||
- npm test | ||
- npm run test:coverage | ||
env: | ||
global: | ||
secure: nM4VCsngmj/bCQq8eIlDRLVg7wb6ndKmjMX2WAytzuewvd7F9+0+mho9m+NQw7o604Xx5IKQGfW4eoR2NWoBhQiv3WbNnDgC/GKRDv6xERLm0wJSzwQGwa2ZPfCweuJwbH/Fjf+HOYRo8mNfRGqT15LIVb3gBS3osmMgvreQLcQe8TKTyQLfmdwREvhtCZWS29mYFivdJnvTVfmdo1oEEsGw9hNOQBM5S23Y0I8/yYkAjvtEiTw2qlAVrXdEjMGQagprB2AGW4zH4EXd5bTnC6n/RQ2XFmTI+BOBQ+PkDXxNi/ENvmkJE1ra3gmluAc6HtHHfK3eCSmeuKq95vYQr1iXpHD3o30HOwlqsegJjUfX0nHpciDpxEheMYf4jbnjHI90PIQvhka7BXjk30atOIch1WJFBkx8DSxumeVHw1DbL3nP533ixeWhMnAwZBSznJNrLbXFwpPBlhvGy7A950b7HVYwgn9riYICi20ZFjXWU3aew7e4+DeasdB9tz54h8xOmDFEg3PQf9cwPtayLVjzOaB1YsPYrizQMwFxNPBrlOCNHDNvYnarnSMQQzAKJ3SohiiSPGrm+PT0LvvJd9+gRofcUcCEAju+9H6Ge+Y0LYd2FzH0onGMgswGd1SsPur/efwydDMloDsrY3QolxAkrCyocSJmTUvpwe3g4LM= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Change Log | ||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](http://keepachangelog.com/) | ||
and this project adheres to [Semantic Versioning](http://semver.org/). | ||
|
||
## [0.1.0] | ||
### Added | ||
- HTTP REST client | ||
- Logger common functionality | ||
- SLF4J-alike Logger |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,144 @@ | ||
# Unofficial VoxEngine SDK | ||
# (Unofficial) VoxEngine SDK | ||
|
||
This repository contains simple SDK to easen development of VoxImplant | ||
scenarios. | ||
This repository contains simple SDK to ease development of VoxImplant | ||
scenarios. | ||
|
||
Currently it consists of an advanced promise-based HTTP client (relatively to | ||
raw `Net` namespace) and slf4j-alike logger. | ||
|
||
It may be installed via classic npm call | ||
|
||
```bash | ||
npm i @ama-team/voxengine-sdk --save | ||
``` | ||
|
||
And required as any other package: | ||
|
||
```js | ||
var sdk = require('@ama-team/voxengine-sdk'); | ||
``` | ||
|
||
## SLF4J-alike Logger | ||
|
||
This library wraps standard `Logger` and adds support for log levels | ||
(that shouldn't be very useful, but who knows) and log message | ||
parameters (substitutions): | ||
|
||
```js | ||
var logger = new sdk.logger.Slf4j('logger-name'); | ||
|
||
// ... | ||
|
||
call.addEventListener(CallEvents.Connected, function(event) { | ||
logger.info('{} has responded in {} seconds (event: {})', user, timer.elapsed(), event); | ||
}); | ||
``` | ||
|
||
This logger provides `.trace()`, `.debug()`, `.notice()`, `.info()`, | ||
`.warn()`, `.error()` and `.log(logger.Level.*, pattern, substitutions...)` | ||
methods. | ||
|
||
## REST client | ||
|
||
Provided client exploits `Net` inhabitant capabilities to provide more | ||
fresh interface: | ||
|
||
```js | ||
var options = { | ||
baseUrl: 'http://backend/api/v1', | ||
// following stuff is purely optional | ||
attempts: 5, | ||
methodOverrideHeader: 'X-HTTP-Method-Override', | ||
logger: logger, | ||
serializer: { | ||
serialize: function (object) { | ||
return JSON.stringify(object); | ||
}, | ||
deserialize: function (string) { | ||
return JSON.parse(string); | ||
} | ||
}, | ||
fixedHeaders: { | ||
'Content-Type': 'application/json' | ||
} | ||
}, | ||
client = new sdk.http.rest.RestClient(Net.asyncHttpRequest, options); | ||
|
||
client.put('/conversation/12345/finished', {timestamp: new Date().getTime()}, {'X-Entity-Version': '12'}) | ||
.then(function (response) { | ||
logger.info('Received response: {}', response); | ||
}, function (error) { | ||
logger.error('Failed to perform request: {}', error); | ||
VoxEngine.terminate(); | ||
}); | ||
``` | ||
|
||
REST client exposes main `.request(http.Method.*, route, payload, [query], [headers])` | ||
method, as well as shortcuts `.get(route, [query], [headers])`, | ||
`.create(route, [payload], [headers])`, | ||
`.set(route, [payload], [headers])`, and | ||
`.delete(route, [payload], [headers])`. `http.Method.*` is a single | ||
string map, so you can use any HTTP method you may invent via | ||
`.request()` method. | ||
|
||
## How do i require this stuff in VoxEngine? | ||
|
||
If you don't already know, VoxImplant scripts are basically just a | ||
single file which is executed on external trigger. This limits your | ||
ability to `require` anything, including this particular library, but | ||
you can always bundle things down with a build tool of your choice. | ||
I personally use Webpack, but was recommended of Browserify as well, | ||
and, of course good old Grunt and Gulp should work too. | ||
|
||
Don't forget that VoxImplant has scenario size limit of 128 kb, so | ||
don't require anything at sight, don't forget to minify things | ||
you require adn don't forget to strip comments off. | ||
|
||
## ES5 | ||
|
||
This repository is developed as ES5 module because it is implied that | ||
built code would be injected directly in VoxImplant scenarios, which, in | ||
turn, do not support ES6 yet, and transpiling would dramatically harden | ||
bug hunt. | ||
|
||
## Testing | ||
|
||
This package is using Mocha with Chai for test running, Istanbul for | ||
recording coverage metrics and Allure framework for reporting. If you | ||
want full-blown feedback, use `npm run test:report` to generate Allure | ||
report (don't forget to install | ||
[allure-commandline][allure-commandline] before), it will be placed in | ||
`report/allure` directory. | ||
|
||
## Anything else? | ||
|
||
We have [@ama-team/voxengine-definitions][@definitions] package that | ||
helps with autocompletion. Also, | ||
[scenario framework][@scenario-framework] and | ||
[script publishing tool][@publisher] were being developed at the moment | ||
these lines were written, so there is probability that there is another | ||
useful tool for you. | ||
|
||
There is no particular roadmap for this project, so you may use GitHub | ||
issues to propose any ideas you got. However, there is not much time | ||
that could be devoted to this project. | ||
|
||
## Self-esteem badge fund | ||
|
||
[![npm (scoped)](https://img.shields.io/npm/v/@ama-team/voxengine-sdk.svg)](https://www.npmjs.com/package/@ama-team/voxengine-sdk) | ||
|
||
### Master branch / stable | ||
|
||
[![Build Status](https://travis-ci.org/ama-team/voxengine-sdk.svg?branch=master)](https://travis-ci.org/ama-team/voxengine-sdk) | ||
[![Coverage Status](https://coveralls.io/repos/github/ama-team/voxengine-sdk/badge.svg?branch=master)](https://coveralls.io/github/ama-team/voxengine-sdk?branch=master) | ||
[![Code Climate](https://codeclimate.com/github/ama-team/voxengine-sdk/badges/gpa.svg)](https://codeclimate.com/github/ama-team/voxengine-sdk) | ||
|
||
### Dev branch / incubating | ||
|
||
[![Build Status](https://travis-ci.org/ama-team/voxengine-sdk.svg?branch=dev)](https://travis-ci.org/ama-team/voxengine-sdk) | ||
[![Coverage Status](https://coveralls.io/repos/github/ama-team/voxengine-sdk/badge.svg?branch=dev)](https://coveralls.io/github/ama-team/voxengine-sdk?branch=dev) | ||
|
||
[allure-commandline]: http://wiki.qatools.ru/display/AL/Allure+Commandline | ||
[@definitions]: https://github.com/ama-team/voxengine-definitions | ||
[@scenario-framework]: https://github.com/ama-team/voxengine-scenario-framework | ||
[@publisher]: https://github.com/ama-team/voximplant-publisher |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
module.exports = require('./lib'); | ||
exports = module.exports = require('./lib'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** | ||
* @callback netHttpRequestAsync | ||
* @param {string} url | ||
* @param {Net.HttpRequestOptions} options | ||
* @return {Promise} | ||
*/ | ||
|
||
/** | ||
* Header collection. When returned by internal methods, values are always present as an array. | ||
* | ||
* @typedef {Object.<string, string|string[]>} Headers | ||
*/ | ||
|
||
/** | ||
* @typedef {Object.<string, string|string[]>} Query | ||
*/ | ||
|
||
/** | ||
* Simple response wrapper | ||
* | ||
* @typedef {Object} Response | ||
* | ||
* @property {Number} code Response code | ||
* @property {Headers} headers Response headers | ||
* @property {Object|null} payload Decoded response payload | ||
*/ | ||
|
||
/** | ||
* Simple request wrapper | ||
* | ||
* @typedef {Object} Request | ||
* | ||
* @property {string} url Url to execute request against | ||
* @property {Method} method HTTP method | ||
* @property {Query|null} query Request query | ||
* @property {Headers|null} headers Request headers | ||
* @property {Object|null} payload Serialized request payload | ||
*/ | ||
|
||
/** | ||
* @enum {string} | ||
* @readonly | ||
*/ | ||
var Method = { | ||
Get: 'GET', | ||
Post: 'POST', | ||
Put: 'PUT', | ||
Delete: 'DELETE' | ||
}; | ||
|
||
exports = module.exports = { | ||
Method: Method | ||
}; |
Oops, something went wrong.