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

cimpress-tagliatelle

Package Overview
Dependencies
Maintainers
5
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cimpress-tagliatelle - npm Package Compare versions

Comparing version 0.2.1 to 0.3.0

5

CHANGELOG.md

@@ -7,2 +7,7 @@ # Changelog

## [0.3.0] - 2018.12.18
### Added
- Added support for debugFunction and errorFunction options. Defaults to console.
- Added support for skipCache option to avoid caching issues. Defaults to true.
## [0.2.1] - 2018.12.18

@@ -9,0 +14,0 @@ ### Changed

153

lib/Tagliatelle.js

@@ -59,3 +59,3 @@ 'use strict';

var understoodOptions = ['baseUrl', 'timeout', 'retryAttempts', 'retryDelayInMs', 'autoFetchPagedResults'];
var understoodOptions = ['baseUrl', 'timeout', 'retryAttempts', 'retryDelayInMs', 'autoFetchPagedResults', 'debugFunction', 'errorFunction', 'skipCache'];
var options = clientOptions || {};

@@ -72,2 +72,4 @@ var timeout = parseInt(options.timeout, 10);

this.skipCache = typeof options.skipCache === 'boolean' ? options.skipCache : true;
this.debugFunction = (0, _keys2.default)(options).includes('debugFunction') ? options.debugFunction : console.info;
this.errorFunction = (0, _keys2.default)(options).includes('errorFunction') ? options.errorFunction : console.error;

@@ -83,2 +85,24 @@ (0, _keys2.default)(options).forEach(function (passedOption) {

(0, _createClass3.default)(Tagliatelle, [{
key: '__debug',
value: function __debug() {
if (this.debugFunction) {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
this.debugFunction.apply(this, ['[TagliatelleClient]'].concat(args));
}
}
}, {
key: '__error',
value: function __error() {
if (this.errorFunction) {
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
this.errorFunction.apply(this, ['[TagliatelleClient]'].concat(args));
}
}
}, {
key: '__getAxiosInstance',

@@ -174,3 +198,3 @@ value: function __getAxiosInstance(accessToken) {

var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(accessToken, searchParams) {
var uris, keys, skipCacheParams, axiosInstance, response;
var uris, keys, skipCacheParams, params, axiosInstance, response;
return _regenerator2.default.wrap(function _callee2$(_context2) {

@@ -202,11 +226,15 @@ while (1) {

params = (0, _assign2.default)({}, skipCacheParams, {
namespace: searchParams.namespace ? searchParams.namespace : undefined,
key: keys.length > 0 ? keys : undefined,
resourceUri: uris.length > 0 ? uris : undefined,
offset: (0, _isInteger2.default)(Number(searchParams.offset)) && Number(searchParams.offset) > 0 ? searchParams.offset : undefined
});
axiosInstance = this.__getAxiosInstance(accessToken);
_context2.next = 9;
this.__debug('Calling GET ' + this.baseUrl + '/v0/tags ...', params);
_context2.next = 11;
return axiosInstance.get(this.baseUrl + '/v0/tags', {
params: (0, _assign2.default)({}, skipCacheParams, {
namespace: searchParams.namespace ? searchParams.namespace : undefined,
key: keys.length > 0 ? keys : undefined,
resourceUri: uris.length > 0 ? uris : undefined,
offset: (0, _isInteger2.default)(Number(searchParams.offset)) && Number(searchParams.offset) > 0 ? searchParams.offset : undefined
}),
params: params,
paramsSerializer: function paramsSerializer(params) {

@@ -217,7 +245,7 @@ return _qs2.default.stringify(params, { indices: false });

case 9:
case 11:
response = _context2.sent;
return _context2.abrupt('return', response.data);
case 11:
case 13:
case 'end':

@@ -292,2 +320,4 @@ return _context2.stop();

var _ref5 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee5(accessToken, resourceUri, tagKey) {
var _this2 = this;
var offset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;

@@ -304,2 +334,5 @@ return _regenerator2.default.wrap(function _callee5$(_context5) {

return results[0];
}).catch(function (e) {
_this2.__error(e);
throw e;
}));

@@ -357,15 +390,19 @@

_context7.prev = 1;
_context7.next = 4;
this.__debug('Calling ' + this.baseUrl + '/v0/tags/' + encodeURIComponent(id) + ' ...');
_context7.next = 5;
return axiosInstance.get(this.baseUrl + '/v0/tags/' + encodeURIComponent(id));
case 4:
case 5:
response = _context7.sent;
return _context7.abrupt('return', response.data);
case 8:
_context7.prev = 8;
case 9:
_context7.prev = 9;
_context7.t0 = _context7['catch'](1);
this.__error(_context7.t0);
if (!(_context7.t0.response && _context7.t0.response.status === 404)) {
_context7.next = 12;
_context7.next = 14;
break;

@@ -376,6 +413,6 @@ }

case 12:
case 14:
throw _context7.t0;
case 13:
case 15:
case 'end':

@@ -385,3 +422,3 @@ return _context7.stop();

}
}, _callee7, this, [[1, 8]]);
}, _callee7, this, [[1, 9]]);
}));

@@ -399,3 +436,3 @@

var _ref8 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee8(accessToken, resourceUri, tagKey, tagValue) {
var _this2 = this;
var _this3 = this;

@@ -408,9 +445,13 @@ return _regenerator2.default.wrap(function _callee8$(_context8) {

var results = res.results;
_this3.__debug('createOrUpdateTag for ', resourceUri, tagKey, 'found:', results);
if (results.length === 0) {
return _this2.createTag(accessToken, resourceUri, tagKey, tagValue);
return _this3.createTag(accessToken, resourceUri, tagKey, tagValue);
}
if (results.length === 1) {
return _this2.updateTag(accessToken, results[0].id, resourceUri, tagKey, tagValue);
return _this3.updateTag(accessToken, results[0].id, resourceUri, tagKey, tagValue);
}
throw new _ConflictError2.default('Multiple tags matching.');
}).catch(function (e) {
_this3.__error(e);
throw e;
}));

@@ -436,3 +477,3 @@

var _ref9 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee9(accessToken, resourceUri, tagKey, tagValue) {
var axiosInstance, response;
var axiosInstance, params, response;
return _regenerator2.default.wrap(function _callee9$(_context9) {

@@ -443,14 +484,25 @@ while (1) {

axiosInstance = this.__getAxiosInstance(accessToken);
_context9.next = 3;
return axiosInstance.post(this.baseUrl + '/v0/tags', {
params = {
key: tagKey,
value: tagValue,
resourceUri: resourceUri
});
};
_context9.prev = 2;
case 3:
this.__debug('Calling POST ' + this.baseUrl + '/v0/tags', params);
_context9.next = 6;
return axiosInstance.post(this.baseUrl + '/v0/tags', params);
case 6:
response = _context9.sent;
return _context9.abrupt('return', response.data);
case 5:
case 10:
_context9.prev = 10;
_context9.t0 = _context9['catch'](2);
this.__error(_context9.t0);
throw _context9.t0;
case 14:
case 'end':

@@ -460,3 +512,3 @@ return _context9.stop();

}
}, _callee9, this);
}, _callee9, this, [[2, 10]]);
}));

@@ -474,3 +526,3 @@

var _ref10 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee10(accessToken, id, resourceUri, tagKey, tagValue) {
var axiosInstance, response;
var axiosInstance, params, response;
return _regenerator2.default.wrap(function _callee10$(_context10) {

@@ -481,14 +533,25 @@ while (1) {

axiosInstance = this.__getAxiosInstance(accessToken);
_context10.next = 3;
return axiosInstance.put(this.baseUrl + '/v0/tags/' + encodeURIComponent(id), {
params = {
key: tagKey,
value: tagValue,
resourceUri: resourceUri
});
};
_context10.prev = 2;
case 3:
this.__debug('Calling PUT ' + this.baseUrl + '/v0/tags/' + encodeURIComponent(id), params);
_context10.next = 6;
return axiosInstance.put(this.baseUrl + '/v0/tags/' + encodeURIComponent(id), params);
case 6:
response = _context10.sent;
return _context10.abrupt('return', response.data);
case 5:
case 10:
_context10.prev = 10;
_context10.t0 = _context10['catch'](2);
this.__error(_context10.t0);
throw _context10.t0;
case 14:
case 'end':

@@ -498,3 +561,3 @@ return _context10.stop();

}
}, _callee10, this);
}, _callee10, this, [[2, 10]]);
}));

@@ -518,10 +581,20 @@

axiosInstance = this.__getAxiosInstance(accessToken);
_context11.next = 3;
_context11.prev = 1;
this.__debug('Calling DELETE ' + this.baseUrl + '/v0/tags/' + encodeURIComponent(id));
_context11.next = 5;
return axiosInstance.delete(this.baseUrl + '/v0/tags/' + encodeURIComponent(id));
case 3:
case 5:
response = _context11.sent;
return _context11.abrupt('return', response.data);
case 5:
case 9:
_context11.prev = 9;
_context11.t0 = _context11['catch'](1);
this.__error(_context11.t0);
throw _context11.t0;
case 13:
case 'end':

@@ -531,3 +604,3 @@ return _context11.stop();

}
}, _callee11, this);
}, _callee11, this, [[1, 9]]);
}));

@@ -534,0 +607,0 @@

{
"name": "cimpress-tagliatelle",
"version": "0.2.1",
"version": "0.3.0",
"description": "A thin client for Cimpress Tagliatelle service",

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

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