Comparing version 3.0.1 to 3.0.2
@@ -11,2 +11,6 @@ 'use strict'; | ||
var _lodash = require('lodash.camelcase'); | ||
var _lodash2 = _interopRequireDefault(_lodash); | ||
var _promiseCache = require('../utils/promiseCache'); | ||
@@ -108,2 +112,29 @@ | ||
this[_caches] = buildCaches(this); | ||
if (this.constructor.api) { | ||
var _iteratorNormalCompletion2 = true; | ||
var _didIteratorError2 = false; | ||
var _iteratorError2 = undefined; | ||
try { | ||
for (var _iterator2 = Object.keys(this.constructor.api)[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { | ||
var id = _step2.value; | ||
this[(0, _lodash2.default)('invoke ' + id)] = this.invoke.bind(this, id); | ||
} | ||
} catch (err) { | ||
_didIteratorError2 = true; | ||
_iteratorError2 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion2 && _iterator2.return) { | ||
_iterator2.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError2) { | ||
throw _iteratorError2; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
@@ -134,8 +165,8 @@ | ||
key: 'invoke', | ||
value: function invoke(method, params, context) { | ||
value: function invoke(method) { | ||
var _this = this; | ||
var proxy = function proxy(input) { | ||
return Promise.resolve(input); | ||
}; | ||
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var log = null; | ||
@@ -154,3 +185,3 @@ | ||
log('call argumengts', params); | ||
log('"' + method + '" call argumengts', params, context); | ||
} | ||
@@ -161,9 +192,9 @@ | ||
var _iteratorNormalCompletion2 = true; | ||
var _didIteratorError2 = false; | ||
var _iteratorError2 = undefined; | ||
var _iteratorNormalCompletion3 = true; | ||
var _didIteratorError3 = false; | ||
var _iteratorError3 = undefined; | ||
try { | ||
var _loop = function _loop() { | ||
var stepId = _step2.value; | ||
var stepId = _step3.value; | ||
@@ -184,4 +215,4 @@ var step = null; | ||
stepsPromise = stepsPromise.then(function (input) { | ||
if (log && step != proxy) { | ||
log('"' + stepId + '" call', input); | ||
if (log) { | ||
log('"' + stepId + '" call', input, context); | ||
} | ||
@@ -192,3 +223,3 @@ | ||
}).then(function (output) { | ||
if (log && step != proxy) { | ||
if (log) { | ||
log('"' + stepId + '" response', output); | ||
@@ -199,3 +230,3 @@ } | ||
}).catch(function (error) { | ||
if (log && step != proxy) { | ||
if (log) { | ||
log('"' + stepId + '" error', error); | ||
@@ -209,3 +240,3 @@ } | ||
for (var _iterator2 = _this[_steps][Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { | ||
for (var _iterator3 = _this[_steps][Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { | ||
var _ret = _loop(); | ||
@@ -216,12 +247,12 @@ | ||
} catch (err) { | ||
_didIteratorError2 = true; | ||
_iteratorError2 = err; | ||
_didIteratorError3 = true; | ||
_iteratorError3 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion2 && _iterator2.return) { | ||
_iterator2.return(); | ||
if (!_iteratorNormalCompletion3 && _iterator3.return) { | ||
_iterator3.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError2) { | ||
throw _iteratorError2; | ||
if (_didIteratorError3) { | ||
throw _iteratorError3; | ||
} | ||
@@ -279,9 +310,9 @@ } | ||
var _iteratorNormalCompletion3 = true; | ||
var _didIteratorError3 = false; | ||
var _iteratorError3 = undefined; | ||
var _iteratorNormalCompletion4 = true; | ||
var _didIteratorError4 = false; | ||
var _iteratorError4 = undefined; | ||
try { | ||
for (var _iterator3 = caches[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { | ||
var cache = _step3.value; | ||
for (var _iterator4 = caches[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) { | ||
var cache = _step4.value; | ||
@@ -293,12 +324,12 @@ if (cache) { | ||
} catch (err) { | ||
_didIteratorError3 = true; | ||
_iteratorError3 = err; | ||
_didIteratorError4 = true; | ||
_iteratorError4 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion3 && _iterator3.return) { | ||
_iterator3.return(); | ||
if (!_iteratorNormalCompletion4 && _iterator4.return) { | ||
_iterator4.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError3) { | ||
throw _iteratorError3; | ||
if (_didIteratorError4) { | ||
throw _iteratorError4; | ||
} | ||
@@ -305,0 +336,0 @@ } |
@@ -20,4 +20,5 @@ 'use strict'; | ||
var apiRequest = function apiRequest(params) { | ||
var headers = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var apiRequest = function apiRequest() { | ||
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
@@ -41,3 +42,3 @@ var error = null; | ||
} else { | ||
return executeRequest(headers); | ||
return executeRequest(context.headers); | ||
} | ||
@@ -44,0 +45,0 @@ }; |
@@ -46,7 +46,11 @@ 'use strict'; | ||
return function getRequestExecuteFunction(params) { | ||
return function getRequestExecuteFunction() { | ||
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var request = getRequest(params); | ||
var url = buildUrl(options.protocol, options.host, options.prefix, request.path); | ||
return function executeRequest(headers) { | ||
return function executeRequest() { | ||
var headers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var promiseCreator = function promiseCreator() { | ||
@@ -53,0 +57,0 @@ return adapter(url, _extends({}, request, { |
@@ -97,3 +97,5 @@ 'use strict'; | ||
var buildUnboundParams = function buildUnboundParams(exceptParamsSet, params) { | ||
var buildUnboundParams = function buildUnboundParams(exceptParamsSet) { | ||
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var keys = params.entries ? params.entries : Object.keys(params); | ||
@@ -202,3 +204,5 @@ var initialValue = params.entries ? new _formData2.default() : {}; | ||
return function getRequest(params) { | ||
return function getRequest() { | ||
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var paramsMap = getParamsMap(params); | ||
@@ -205,0 +209,0 @@ var request = {}; |
{ | ||
"name": "bivrost", | ||
"version": "3.0.1", | ||
"version": "3.0.2", | ||
"main": "index.js", | ||
@@ -23,3 +23,3 @@ "description": "Bivrost allows to organize a simple interface to asynchronous APIs.", | ||
"devDependencies": { | ||
"bivrost-axios-adapter": "^3.0.1" | ||
"bivrost-axios-adapter": "^3.0.2" | ||
}, | ||
@@ -37,4 +37,5 @@ "repository": { | ||
"dependencies": { | ||
"form-data": "^2.3.1" | ||
"form-data": "^2.3.1", | ||
"lodash.camelcase": "^4.3.0" | ||
} | ||
} |
@@ -0,1 +1,2 @@ | ||
import camelCase from 'lodash.camelcase'; | ||
import promiseCache from '../utils/promiseCache'; | ||
@@ -69,2 +70,8 @@ import Cache from './cache'; | ||
this[_caches] = buildCaches(this); | ||
if (this.constructor.api) { | ||
for (const id of Object.keys(this.constructor.api)) { | ||
this[camelCase(`invoke ${id}`)] = this.invoke.bind(this, id); | ||
} | ||
} | ||
} | ||
@@ -89,4 +96,3 @@ | ||
invoke(method, params, context) { | ||
const proxy = input => Promise.resolve(input); | ||
invoke(method, params = {}, context = {}) { | ||
let log = null; | ||
@@ -99,3 +105,3 @@ | ||
log('call argumengts', params); | ||
log(`"${method}" call argumengts`, params, context); | ||
} | ||
@@ -121,4 +127,4 @@ | ||
stepsPromise = stepsPromise.then(input => { | ||
if (log && step != proxy) { | ||
log(`"${stepId}" call`, input); | ||
if (log) { | ||
log(`"${stepId}" call`, input, context); | ||
} | ||
@@ -129,3 +135,3 @@ | ||
.then(output => { | ||
if (log && step != proxy) { | ||
if (log) { | ||
log(`"${stepId}" response`, output); | ||
@@ -137,3 +143,3 @@ } | ||
.catch(error => { | ||
if (log && step != proxy) { | ||
if (log) { | ||
log(`"${stepId}" error`, error); | ||
@@ -140,0 +146,0 @@ } |
@@ -8,3 +8,3 @@ import clientRequest from './clientRequest'; | ||
const apiRequest = function(params, headers = {}) { | ||
const apiRequest = function(params = {}, context = {}) { | ||
let error = null; | ||
@@ -27,3 +27,3 @@ let executeRequest = null; | ||
} else { | ||
return executeRequest(headers); | ||
return executeRequest(context.headers); | ||
} | ||
@@ -30,0 +30,0 @@ }; |
@@ -25,3 +25,3 @@ import createRequestTemplate from './createRequestTemplate'; | ||
return function getRequestExecuteFunction(params) { | ||
return function getRequestExecuteFunction(params = {}) { | ||
const request = getRequest(params); | ||
@@ -35,3 +35,3 @@ const url = buildUrl( | ||
return function executeRequest(headers) { | ||
return function executeRequest(headers = {}) { | ||
const promiseCreator = () => | ||
@@ -38,0 +38,0 @@ adapter(url, { |
@@ -34,3 +34,3 @@ import FormData from 'form-data'; | ||
const buildUnboundParams = (exceptParamsSet, params) => { | ||
const buildUnboundParams = (exceptParamsSet, params = {}) => { | ||
const keys = params.entries ? params.entries : Object.keys(params); | ||
@@ -134,3 +134,3 @@ const initialValue = params.entries ? new FormData() : {}; | ||
return function getRequest(params) { | ||
return function getRequest(params = {}) { | ||
let paramsMap = getParamsMap(params); | ||
@@ -137,0 +137,0 @@ let request = {}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
87657
2613
2
+ Addedlodash.camelcase@^4.3.0
+ Addedlodash.camelcase@4.3.0(transitive)