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

bi-service-sdk

Package Overview
Dependencies
Maintainers
3
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bi-service-sdk - npm Package Compare versions

Comparing version 1.0.3 to 1.1.0-alpha

lib/interface.js

28

bin/bi-service-sdk.js

@@ -42,2 +42,3 @@ #!/usr/bin/env node

var files = [];
var tmplType = 'http';
var subdir = `${tmpDir.name}/${package.name}-${appName}-${package.version}`;

@@ -50,2 +51,9 @@ var buildedPackage = {

if (specs[appName].schemes instanceof Array
&& ~spec[appName].schemes.indexOf('amqp')
&& ~spec[appName].schemes.indexOf('amqps')
) {
tmplType = 'amqp';
}
packages.push(buildedPackage);

@@ -58,3 +66,3 @@ fs.mkdirSync(subdir);

});
var sdkPackage = self.renderTemplate('package',
var sdkPackage = self.renderTemplate(`${tmplType}/package`,
_.merge(

@@ -86,5 +94,6 @@ {appName: appName},

context.context = JSON.stringify(context);
var sdkModule = self.renderTemplate('module', context);
var sdkTests = self.renderTemplate('test', context);
var sdkModule = self.renderTemplate(`${tmplType}/module`, context);
var sdkTests = self.renderTemplate(`${tmplType}/test`, context);
self.lintSource(sdkModule);

@@ -300,3 +309,6 @@ fs.writeFileSync(subdir + `/${version}.js`, sdkModule);

if (!out.host.match(/^\w+:\/\//)) {
if (spec.schemes instanceof Array
&& (~spec.schemes.indexOf('http') || ~spec.schemes.indexOf('https'))
&& !out.host.match(/^\w+:\/\//)
) {
out.host = out.host && (spec.schemes.indexOf('https') !== -1 ? 'https://' : 'http://') + out.host;

@@ -322,3 +334,3 @@ }

var def = {
sdkMethodName : route.sdkMethodName,
sdkMethodName : route['x-sdkMethodName'] || route.sdkMethodName,
hasBody : ~['post', 'put', 'delete'].indexOf(method.toLowerCase()),

@@ -348,6 +360,10 @@ operationId : route.operationId,

if (~_sdkMethodNames.indexOf(route.sdkMethodName)) {
if (~_sdkMethodNames.indexOf(def.sdkMethodName)) {
throw new Error(`Duplicate route sdk method name: ${route.sdkMethodName}`);
}
if (route.hasOwnProperty('x-amqp')) {//for AMQP Route definitions
def.amqp = route['x-amqp'];
}
_sdkMethodNames.push(route.sdkMethodName);

@@ -354,0 +370,0 @@ out.paths.push(def);

@@ -7,2 +7,6 @@ # Change Log

## 1.1.0-alpha
* [ADDED] - AMQP client SDK package generation
## 1.0.3

@@ -9,0 +13,0 @@

@@ -5,6 +5,8 @@ var axios = require('axios');

var SDKRequestError = require('./lib/errors/SDKRequestError.js');
var SDKInterface = require('./lib/interface.js');
module.exports = BIServiceSDK;
module.exports.BIServiceSDK = BIServiceSDK;
module.exports.SDKRequestError = SDKRequestError;
module.exports = BIServiceSDK;
module.exports.BIServiceSDK = BIServiceSDK;
module.exports.BIServiceSDKInterface = SDKInterface;
module.exports.SDKRequestError = SDKRequestError;

@@ -68,3 +70,7 @@ /**

BIServiceSDK.prototype = Object.create(BIServiceSDK.prototype, {
constructor: BIServiceSDK
});
/**

@@ -71,0 +77,0 @@ *

{
"name": "bi-service-sdk",
"version": "1.0.3",
"version": "1.1.0-alpha",
"description": "Exposes common sdk interface & provides client sdk generator for bi-service based apps",

@@ -8,3 +8,3 @@ "main": "index.js",

"scripts": {
"test": "export NODE_ENV=test; ./node_modules/mocha/bin/_mocha --recursive --ui tdd -t 16000 -R spec tests/acceptance tests/unit",
"test": "export NODE_ENV=test; ./node_modules/mocha/bin/_mocha --recursive --ui tdd -t 32000 -R spec tests/acceptance tests/unit",
"coverage": "export NODE_ENV=test; istanbul cover -x ./bin/bi-service-sdk.js node_modules/mocha/bin/_mocha -- --recursive --ui tdd -t 16000 -R spec tests/acceptance tests/unit"

@@ -22,3 +22,3 @@ },

"engines" : {
"node" : ">=4.0.0"
"node" : ">=6.4.0"
},

@@ -31,2 +31,3 @@ "files": [

],
"license": "GPL-3.0",
"author": "Bohemia Interactive",

@@ -39,17 +40,17 @@ "private": false,

"devDependencies": {
"bi-service-doc": "^0.9.5",
"bi-service": "^0.16.1",
"bi-config": "^1.2.0",
"bi-service-doc": "^1.0.0-alpha.4",
"bi-service": "^1.0.0-alpha.8",
"bi-config": "^2.0.0-alpha",
"archiver": "^1.3.0",
"bluebird": "^3.5.0",
"chai": "^3.5.0",
"chai-as-promised": "^5.3.0",
"chai": "^4.1.2",
"chai-as-promised": "^7.1.1",
"istanbul": "^0.4.3",
"jshint": "^2.9.4",
"lodash": "^4.15.0",
"mocha": "^2.5.3",
"mocha": "^3.5.3",
"mustache": "^2.3.0",
"sinon": "^1.17.3",
"sinon-as-promised": "^4.0.0",
"sinon-chai": "^2.8.0",
"sinon": "^1.17.3",
"tmp": "0.0.31",

@@ -56,0 +57,0 @@ "yargs": "^7.1.0"

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

[![Build Status](https://travis-ci.org/BohemiaInteractive/bi-service-sdk.svg?branch=master)](https://travis-ci.org/BohemiaInteractive/bi-service-sdk)

@@ -2,0 +3,0 @@ ### Generating a SDK npm package for a `bi-service` based application

@@ -1,9 +0,10 @@

var packageJSON = require('../../../package.json');
var fs = require('fs');
var path = require('path');
var sinon = require('sinon');
var chai = require('chai');
var sinonChai = require("sinon-chai");
var childProcess = require('child_process');
var tmp = require('tmp');
const packageJSON = require('../../../package.json');
const Promise = require('bluebird');
const fs = Promise.promisifyAll(require('fs'));
const path = require('path');
const sinon = require('sinon');
const chai = require('chai');
const sinonChai = require("sinon-chai");
const childProcess = require('child_process');
const tmp = require('tmp');

@@ -18,3 +19,3 @@ var expect = chai.expect;

describe('bin/bi-service-sdk', function() {
before(function() {
before(function(done) {
var self = this;

@@ -30,5 +31,8 @@

this.sdk1FilePath = `${this.tmpDir.name}/bi-test-app1-1.0.0.zip`;
this.sdk2FilePath = `${this.tmpDir.name}/bi-test-app2-1.0.0.zip`;
prepareProjectTestCase(this.tmpDir.name + '/bi-service-app', done);
function spawn(args) {

@@ -49,2 +53,33 @@ var cmd = path.normalize(__dirname + '/../../../bin/bi-service-sdk.js');

}
function prepareProjectTestCase(dest, cb) {
let appPath = path.resolve(__dirname + '/../../bi-service-app');
if (!fs.existsSync(dest)) {
fs.mkdirSync(dest);
}
return Promise.all([
fs.readFileAsync(`${appPath}/config.json5`),
fs.readFileAsync(`${appPath}/index.js`),
fs.readFileAsync(`${appPath}/package.json`)
]).then(function(files) {
return Promise.all([
fs.writeFileAsync(`${dest}/config.json5`, files[0]),
fs.writeFileAsync(`${dest}/index.js`, files[1]),
fs.writeFileAsync(`${dest}/package.json`, files[2])
]);
}).then(function() {
const result = childProcess.spawnSync('npm', ['install'], {
cwd: dest,
env: { NODE_ENV: 'development' }
});
if (result.error) {
throw result.error;
} else if (result.status !== 0) {
throw new Error('npm install err: ' + result.stderr.toString());
}
}).asCallback(cb);
}
});

@@ -63,3 +98,3 @@

'--service',
path.resolve(__dirname + '/../../bi-service-app'),
path.resolve(this.tmpDir.name + '/bi-service-app'),
'--doc-exec',

@@ -71,3 +106,3 @@ require.resolve('bi-service-doc/bin/bi-service-doc'),

'--config',
path.resolve(__dirname + '/../../bi-service-app/config.json5')
path.resolve(this.tmpDir.name + '/bi-service-app/config.json5')
]);

@@ -115,3 +150,3 @@ });

'--service',
path.resolve(__dirname + '/../../bi-service-app'),
path.resolve(this.tmpDir.name + '/bi-service-app'),
'--doc-exec',

@@ -125,3 +160,3 @@ require.resolve('bi-service-doc/bin/bi-service-doc'),

'--config',
path.resolve(__dirname + '/../../bi-service-app/config.json5')
path.resolve(this.tmpDir.name + '/bi-service-app/config.json5')
]);

@@ -140,3 +175,3 @@

'--service',
path.resolve(__dirname + '/../../bi-service-app'),
path.resolve(this.tmpDir.name + '/bi-service-app'),
'--doc-exec',

@@ -152,3 +187,3 @@ require.resolve('bi-service-doc/bin/bi-service-doc'),

'--config',
path.resolve(__dirname + '/../../bi-service-app/config.json5')
path.resolve(this.tmpDir.name + '/bi-service-app/config.json5')
]);

@@ -155,0 +190,0 @@

@@ -7,10 +7,13 @@ /**

var Service = require('bi-service');
var config = require('bi-config');
const Service = require('bi-service');
const config = require('bi-config');
const path = require('path');
var service = module.exports = new Service(config);
config.initialize({fileConfigPath: path.resolve(__dirname + '/config.json5')});
const service = module.exports = new Service(config);
service.on('set-up', function() {
//app1
this.buildApp('app1', {validator: {definitions: {}}}).buildRouter({
this.buildApp('app1', {}).buildRouter({
url: '/',

@@ -22,3 +25,5 @@ version: 1

}).validate({
id: {$is: Number}
properties: {
id: {type: 'integer'}
}
}, 'query');

@@ -29,3 +34,3 @@

//app2
service.buildApp('app2', {validator: {definitions: {}}}).buildRouter({
service.buildApp('app2', {}).buildRouter({
url: '/',

@@ -37,3 +42,5 @@ version: 2

}).validate({
id: {$is: Number}
properties: {
id: {type: 'integer'}
}
}, 'params');

@@ -10,4 +10,7 @@ {

],
"dependencies": {
"bi-service": "^1.0.0-alpha.8"
},
"author": "Bohemia Interactive",
"private": false
}

@@ -178,3 +178,3 @@ Promise = require('bluebird');

it('should convert error response properties to camelCase', function() {
var requestStub = sinon.stub(this.sdk.axios.defaults, 'adapter').returns(Promise.reject({
var requestStub = sinon.stub(this.sdk.axios.defaults, 'adapter').rejects({
message: 'rejection test error',

@@ -190,3 +190,3 @@ response: {

}
}));
});

@@ -343,3 +343,3 @@ return this.sdk.$request({url: `status/${status}`}).should.be.rejected.then(function(err) {

this.sdk._setReqData('foo', reqData, config, 'headers');
config.should.have.deep.property('headers.foo', reqData);
config.should.have.nested.deep.property('headers.foo', reqData);
});

@@ -413,3 +413,3 @@

this.sdk._setReqData('foo', reqData, config, target);
config.should.have.deep.property('params.foo', reqData);
config.should.have.nested.deep.property('params.foo', reqData);
});

@@ -483,3 +483,3 @@

this.sdk._setReqData('foo', reqData, config, 'query');
config.should.have.deep.property('params.foo', reqData);
config.should.have.nested.deep.property('params.foo', reqData);
});

@@ -486,0 +486,0 @@

Sorry, the diff of this file is not supported yet

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