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.3.2 to 0.3.3

8

CHANGELOG.md

@@ -7,7 +7,11 @@ # Changelog

## [0.3.2] - 2018.06.23
## [0.3.3] - 2019.07.17
### Changed
- Upgrading dependencies to fix vulnerability
## [0.3.2] - 2019.06.23
### Changed
- Bumping axios to fix a vulnerability
## [0.3.1] - 2018.01.17
## [0.3.1] - 2019.01.17
### Changed

@@ -14,0 +18,0 @@ - Timeouts when calling the underlying service should be retried.

"use strict";
var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = require("babel-runtime/helpers/createClass");
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _createClass3 = _interopRequireDefault(_createClass2);
var ConflictError =
/*#__PURE__*/
function () {
function ConflictError(message, data) {
(0, _classCallCheck2["default"])(this, ConflictError);
this.message = message;
this._data = data;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var ConflictError = function () {
function ConflictError(message, data) {
(0, _classCallCheck3.default)(this, ConflictError);
this.message = message;
this._data = data;
(0, _createClass2["default"])(ConflictError, [{
key: "data",
get: function get() {
return this._data;
}
(0, _createClass3.default)(ConflictError, [{
key: "data",
get: function get() {
return this._data;
}
}]);
return ConflictError;
}]);
return ConflictError;
}();
module.exports = ConflictError;
"use strict";
var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = require("babel-runtime/helpers/createClass");
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _createClass3 = _interopRequireDefault(_createClass2);
var TagNotFound =
/*#__PURE__*/
function () {
function TagNotFound(message, data) {
(0, _classCallCheck2["default"])(this, TagNotFound);
this.message = message;
this._data = data;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var TagNotFound = function () {
function TagNotFound(message, data) {
(0, _classCallCheck3.default)(this, TagNotFound);
this.message = message;
this._data = data;
(0, _createClass2["default"])(TagNotFound, [{
key: "data",
get: function get() {
return this._data;
}
(0, _createClass3.default)(TagNotFound, [{
key: "data",
get: function get() {
return this._data;
}
}]);
return TagNotFound;
}]);
return TagNotFound;
}();
module.exports = TagNotFound;

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

'use strict';
"use strict";

@@ -3,0 +3,0 @@ var Tagliatelle = require('./Tagliatelle');

@@ -1,598 +0,633 @@

'use strict';
"use strict";
var _isInteger = require('babel-runtime/core-js/number/is-integer');
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _isInteger2 = _interopRequireDefault(_isInteger);
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _assign = require('babel-runtime/core-js/object/assign');
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _assign2 = _interopRequireDefault(_assign);
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _regenerator = require('babel-runtime/regenerator');
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _regenerator2 = _interopRequireDefault(_regenerator);
var _axios = _interopRequireDefault(require("axios"));
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
var _axiosRetry = _interopRequireDefault(require("axios-retry"));
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
var _TagNotFound = _interopRequireDefault(require("./errors/TagNotFound"));
var _keys = require('babel-runtime/core-js/object/keys');
var _ConflictError = _interopRequireDefault(require("./errors/ConflictError"));
var _keys2 = _interopRequireDefault(_keys);
var _qs = _interopRequireDefault(require("qs"));
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var DEFAULT_BASE_URL = 'https://tagliatelle.trdlnk.cimpress.io';
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var Tagliatelle =
/*#__PURE__*/
function () {
function Tagliatelle(clientOptions) {
(0, _classCallCheck2["default"])(this, Tagliatelle);
var understoodOptions = ['baseUrl', 'timeout', 'retryAttempts', 'retryDelayInMs', 'autoFetchPagedResults', 'debugFunction', 'errorFunction', 'skipCache'];
var options = clientOptions || {};
var timeout = parseInt(options.timeout, 10);
var retryAttempts = parseInt(options.retryAttempts, 10);
var retryDelayInMs = parseInt(options.retryDelayInMs, 10);
this.baseUrl = options.baseUrl || DEFAULT_BASE_URL;
this.timeout = timeout >= 0 ? timeout : 3000;
this.retryAttempts = retryAttempts >= 0 ? retryAttempts : 3;
this.retryDelayInMs = retryDelayInMs >= 0 ? retryDelayInMs : 1000;
this.autoFetchPagedResults = options.autoFetchPagedResults || false;
this.skipCache = typeof options.skipCache === 'boolean' ? options.skipCache : true;
this.debugFunction = Object.keys(options).includes('debugFunction') ? options.debugFunction : console.info;
this.errorFunction = Object.keys(options).includes('errorFunction') ? options.errorFunction : console.error;
Object.keys(options).forEach(function (passedOption) {
if (understoodOptions.indexOf(passedOption) === -1) {
// eslint-disable-next-line no-console
console.error("[Tagliatelle] Option '".concat(passedOption, "' is not understood and will be ignored."));
}
});
}
var _createClass2 = require('babel-runtime/helpers/createClass');
(0, _createClass2["default"])(Tagliatelle, [{
key: "__debug",
value: function __debug() {
if (this.debugFunction) {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
var _createClass3 = _interopRequireDefault(_createClass2);
this.debugFunction.apply(this, ['[TagliatelleClient]'].concat(args));
}
}
}, {
key: "__error",
value: function __error() {
if (this.errorFunction) {
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
var _axios = require('axios');
this.errorFunction.apply(this, ['[TagliatelleClient]'].concat(args));
}
}
}, {
key: "__getAxiosInstance",
value: function __getAxiosInstance(accessToken) {
var _this = this;
var _axios2 = _interopRequireDefault(_axios);
var instance = _axios["default"].create({
baseURL: this.baseUrl,
timeout: this.timeout,
headers: {
Authorization: "Bearer ".concat(accessToken.replace('Bearer ', ''))
}
});
var _axiosRetry = require('axios-retry');
if (this.retryAttempts > 0) {
(0, _axiosRetry["default"])(instance, {
retries: this.retryAttempts,
retryDelay: function retryDelay(retryCount) {
return _this.retryDelayInMs;
},
shouldResetTimeout: true
});
}
var _axiosRetry2 = _interopRequireDefault(_axiosRetry);
return instance;
}
}, {
key: "getTags",
value: function () {
var _getTags = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee(accessToken, searchParams) {
var results, total, fullResults, retrievedCount, partial;
return _regenerator["default"].wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return this.__getTagsPartial(accessToken, searchParams);
var _TagNotFound = require('./errors/TagNotFound');
case 2:
results = _context.sent;
var _TagNotFound2 = _interopRequireDefault(_TagNotFound);
if (!(!this.autoFetchPagedResults || results.total === results.count + (results.offset || 0))) {
_context.next = 5;
break;
}
var _ConflictError = require('./errors/ConflictError');
return _context.abrupt("return", results);
var _ConflictError2 = _interopRequireDefault(_ConflictError);
case 5:
total = results.total;
fullResults = results;
retrievedCount = results.count;
var _qs = require('qs');
case 8:
if (!(retrievedCount < total)) {
_context.next = 18;
break;
}
var _qs2 = _interopRequireDefault(_qs);
searchParams.offset = retrievedCount;
_context.next = 12;
return this.__getTagsPartial(accessToken, searchParams);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
case 12:
partial = _context.sent;
retrievedCount += partial.count;
fullResults.count = retrievedCount;
fullResults.results = fullResults.results.concat(partial.results);
_context.next = 8;
break;
var DEFAULT_BASE_URL = 'https://tagliatelle.trdlnk.cimpress.io';
case 18:
return _context.abrupt("return", fullResults);
var Tagliatelle = function () {
function Tagliatelle(clientOptions) {
(0, _classCallCheck3.default)(this, Tagliatelle);
case 19:
case "end":
return _context.stop();
}
}
}, _callee, this);
}));
var understoodOptions = ['baseUrl', 'timeout', 'retryAttempts', 'retryDelayInMs', 'autoFetchPagedResults', 'debugFunction', 'errorFunction', 'skipCache'];
var options = clientOptions || {};
var timeout = parseInt(options.timeout, 10);
var retryAttempts = parseInt(options.retryAttempts, 10);
var retryDelayInMs = parseInt(options.retryDelayInMs, 10);
function getTags(_x, _x2) {
return _getTags.apply(this, arguments);
}
this.baseUrl = options.baseUrl || DEFAULT_BASE_URL;
this.timeout = timeout >= 0 ? timeout : 3000;
this.retryAttempts = retryAttempts >= 0 ? retryAttempts : 3;
this.retryDelayInMs = retryDelayInMs >= 0 ? retryDelayInMs : 1000;
this.autoFetchPagedResults = options.autoFetchPagedResults || false;
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;
return getTags;
}()
}, {
key: "__getTagsPartial",
value: function () {
var _getTagsPartial = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee2(accessToken, searchParams) {
var uris, keys, skipCacheParams, params, axiosInstance, response;
return _regenerator["default"].wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
uris = [];
(0, _keys2.default)(options).forEach(function (passedOption) {
if (understoodOptions.indexOf(passedOption) === -1) {
// eslint-disable-next-line no-console
console.error('[Tagliatelle] Option \'' + passedOption + '\' is not understood and will be ignored.');
}
});
}
(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];
if (Array.isArray(searchParams.resourceUri) && searchParams.resourceUri.length > 0) {
uris = uris.concat(searchParams.resourceUri);
} else if (searchParams.resourceUri) {
uris.push(searchParams.resourceUri);
}
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];
keys = [];
if (Array.isArray(searchParams.key) && searchParams.key.length > 0) {
keys = keys.concat(searchParams.key);
} else if (searchParams.key) {
keys.push(searchParams.key);
}
this.errorFunction.apply(this, ['[TagliatelleClient]'].concat(args));
}
}
}, {
key: '__getAxiosInstance',
value: function __getAxiosInstance(accessToken) {
var _this = this;
skipCacheParams = {};
var instance = _axios2.default.create({
baseURL: this.baseUrl,
timeout: this.timeout,
headers: {
Authorization: 'Bearer ' + accessToken.replace('Bearer ', '')
if (this.skipCache) {
skipCacheParams.skipCache = Math.random();
}
});
if (this.retryAttempts > 0) {
(0, _axiosRetry2.default)(instance, {
retries: this.retryAttempts,
retryDelay: function retryDelay(retryCount) {
return _this.retryDelayInMs;
},
shouldResetTimeout: true
params = Object.assign({}, skipCacheParams, {
namespace: searchParams.namespace ? searchParams.namespace : undefined,
key: keys.length > 0 ? keys : undefined,
resourceUri: uris.length > 0 ? uris : undefined,
offset: Number.isInteger(Number(searchParams.offset)) && Number(searchParams.offset) > 0 ? searchParams.offset : undefined
});
}
axiosInstance = this.__getAxiosInstance(accessToken);
return instance;
}
}, {
key: 'getTags',
value: function () {
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(accessToken, searchParams) {
var results, total, fullResults, retrievedCount, partial;
return _regenerator2.default.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return this.__getTagsPartial(accessToken, searchParams);
this.__debug("Calling GET ".concat(this.baseUrl, "/v0/tags ..."), params);
case 2:
results = _context.sent;
_context2.next = 11;
return axiosInstance.get("".concat(this.baseUrl, "/v0/tags"), {
params: params,
paramsSerializer: function paramsSerializer(params) {
return _qs["default"].stringify(params, {
indices: false
});
}
});
if (!(!this.autoFetchPagedResults || results.total === results.count + (results.offset || 0))) {
_context.next = 5;
break;
}
case 11:
response = _context2.sent;
return _context2.abrupt("return", response.data);
return _context.abrupt('return', results);
case 13:
case "end":
return _context2.stop();
}
}
}, _callee2, this);
}));
case 5:
total = results.total;
fullResults = results;
retrievedCount = results.count;
function __getTagsPartial(_x3, _x4) {
return _getTagsPartial.apply(this, arguments);
}
case 8:
if (!(retrievedCount < total)) {
_context.next = 18;
break;
}
return __getTagsPartial;
}()
}, {
key: "getTagsByResource",
value: function () {
var _getTagsByResource = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee3(accessToken, resourceUri) {
var namespace,
offset,
_args3 = arguments;
return _regenerator["default"].wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
namespace = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : null;
offset = _args3.length > 3 && _args3[3] !== undefined ? _args3[3] : null;
return _context3.abrupt("return", this.__getTagsPartial(accessToken, {
resourceUri: resourceUri,
namespace: namespace,
offset: offset
}));
searchParams.offset = retrievedCount;
_context.next = 12;
return this.__getTagsPartial(accessToken, searchParams);
case 3:
case "end":
return _context3.stop();
}
}
}, _callee3, this);
}));
case 12:
partial = _context.sent;
function getTagsByResource(_x5, _x6) {
return _getTagsByResource.apply(this, arguments);
}
retrievedCount += partial.count;
fullResults.count = retrievedCount;
fullResults.results = fullResults.results.concat(partial.results);
_context.next = 8;
break;
return getTagsByResource;
}()
}, {
key: "getTagsByResources",
value: function () {
var _getTagsByResources = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee4(accessToken, resourcesUriArray) {
var namespace,
offset,
_args4 = arguments;
return _regenerator["default"].wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
namespace = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : null;
offset = _args4.length > 3 && _args4[3] !== undefined ? _args4[3] : null;
return _context4.abrupt("return", this.__getTagsPartial(accessToken, {
resourceUri: resourcesUriArray,
namespace: namespace,
offset: offset
}));
case 18:
return _context.abrupt('return', fullResults);
case 19:
case 'end':
return _context.stop();
}
}
}, _callee, this);
}));
function getTags(_x, _x2) {
return _ref.apply(this, arguments);
case 3:
case "end":
return _context4.stop();
}
}
}, _callee4, this);
}));
return getTags;
}()
}, {
key: '__getTagsPartial',
value: function () {
var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(accessToken, searchParams) {
var uris, keys, skipCacheParams, params, axiosInstance, response;
return _regenerator2.default.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
uris = [];
function getTagsByResources(_x7, _x8) {
return _getTagsByResources.apply(this, arguments);
}
if (Array.isArray(searchParams.resourceUri) && searchParams.resourceUri.length > 0) {
uris = uris.concat(searchParams.resourceUri);
} else if (searchParams.resourceUri) {
uris.push(searchParams.resourceUri);
}
return getTagsByResources;
}()
}, {
key: "getTagByResourceAndKey",
value: function () {
var _getTagByResourceAndKey = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee5(accessToken, resourceUri, tagKey) {
var _this2 = this;
keys = [];
var offset,
_args5 = arguments;
return _regenerator["default"].wrap(function _callee5$(_context5) {
while (1) {
switch (_context5.prev = _context5.next) {
case 0:
offset = _args5.length > 3 && _args5[3] !== undefined ? _args5[3] : null;
return _context5.abrupt("return", this.__getTagsPartial(accessToken, {
resourceUri: resourceUri,
key: tagKey,
offset: offset
}).then(function (res) {
var results = res.results;
if (Array.isArray(searchParams.key) && searchParams.key.length > 0) {
keys = keys.concat(searchParams.key);
} else if (searchParams.key) {
keys.push(searchParams.key);
}
if (results.length === 0) {
throw new _TagNotFound["default"]();
}
skipCacheParams = {};
return results[0];
})["catch"](function (e) {
_this2.__error(e);
if (this.skipCache) {
skipCacheParams.skipCache = Math.random();
}
throw e;
}));
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);
case 2:
case "end":
return _context5.stop();
}
}
}, _callee5, this);
}));
function getTagByResourceAndKey(_x9, _x10, _x11) {
return _getTagByResourceAndKey.apply(this, arguments);
}
this.__debug('Calling GET ' + this.baseUrl + '/v0/tags ...', params);
_context2.next = 11;
return axiosInstance.get(this.baseUrl + '/v0/tags', {
params: params,
paramsSerializer: function paramsSerializer(params) {
return _qs2.default.stringify(params, { indices: false });
}
});
return getTagByResourceAndKey;
}()
}, {
key: "getTagsByKey",
value: function () {
var _getTagsByKey = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee6(accessToken, tagKey) {
var offset,
_args6 = arguments;
return _regenerator["default"].wrap(function _callee6$(_context6) {
while (1) {
switch (_context6.prev = _context6.next) {
case 0:
offset = _args6.length > 2 && _args6[2] !== undefined ? _args6[2] : null;
return _context6.abrupt("return", this.__getTagsPartial(accessToken, {
key: tagKey,
offset: offset
}));
case 11:
response = _context2.sent;
return _context2.abrupt('return', response.data);
case 13:
case 'end':
return _context2.stop();
}
}
}, _callee2, this);
}));
function __getTagsPartial(_x3, _x4) {
return _ref2.apply(this, arguments);
case 2:
case "end":
return _context6.stop();
}
}
}, _callee6, this);
}));
return __getTagsPartial;
}()
}, {
key: 'getTagsByResource',
value: function () {
var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(accessToken, resourceUri) {
var namespace = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
var offset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
return _regenerator2.default.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
return _context3.abrupt('return', this.__getTagsPartial(accessToken, { resourceUri: resourceUri, namespace: namespace, offset: offset }));
function getTagsByKey(_x12, _x13) {
return _getTagsByKey.apply(this, arguments);
}
case 1:
case 'end':
return _context3.stop();
}
}
}, _callee3, this);
}));
return getTagsByKey;
}()
}, {
key: "getTagById",
value: function () {
var _getTagById = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee7(accessToken, id) {
var axiosInstance, response;
return _regenerator["default"].wrap(function _callee7$(_context7) {
while (1) {
switch (_context7.prev = _context7.next) {
case 0:
axiosInstance = this.__getAxiosInstance(accessToken);
_context7.prev = 1;
function getTagsByResource(_x5, _x6) {
return _ref3.apply(this, arguments);
}
this.__debug("Calling ".concat(this.baseUrl, "/v0/tags/").concat(encodeURIComponent(id), " ..."));
return getTagsByResource;
}()
}, {
key: 'getTagsByResources',
value: function () {
var _ref4 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee4(accessToken, resourcesUriArray) {
var namespace = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
var offset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
return _regenerator2.default.wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
return _context4.abrupt('return', this.__getTagsPartial(accessToken, { resourceUri: resourcesUriArray, namespace: namespace, offset: offset }));
_context7.next = 5;
return axiosInstance.get("".concat(this.baseUrl, "/v0/tags/").concat(encodeURIComponent(id)));
case 1:
case 'end':
return _context4.stop();
}
}
}, _callee4, this);
}));
case 5:
response = _context7.sent;
return _context7.abrupt("return", response.data);
function getTagsByResources(_x9, _x10) {
return _ref4.apply(this, arguments);
}
case 9:
_context7.prev = 9;
_context7.t0 = _context7["catch"](1);
return getTagsByResources;
}()
}, {
key: 'getTagByResourceAndKey',
value: function () {
var _ref5 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee5(accessToken, resourceUri, tagKey) {
var _this2 = this;
this.__error(_context7.t0);
var offset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
return _regenerator2.default.wrap(function _callee5$(_context5) {
while (1) {
switch (_context5.prev = _context5.next) {
case 0:
return _context5.abrupt('return', this.__getTagsPartial(accessToken, { resourceUri: resourceUri, key: tagKey, offset: offset }).then(function (res) {
var results = res.results;
if (results.length === 0) {
throw new _TagNotFound2.default();
}
return results[0];
}).catch(function (e) {
_this2.__error(e);
throw e;
}));
if (!(_context7.t0.response && _context7.t0.response.status === 404)) {
_context7.next = 14;
break;
}
case 1:
case 'end':
return _context5.stop();
}
}
}, _callee5, this);
}));
throw new _TagNotFound["default"]();
function getTagByResourceAndKey(_x13, _x14, _x15) {
return _ref5.apply(this, arguments);
}
case 14:
throw _context7.t0;
return getTagByResourceAndKey;
}()
}, {
key: 'getTagsByKey',
value: function () {
var _ref6 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee6(accessToken, tagKey) {
var offset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
return _regenerator2.default.wrap(function _callee6$(_context6) {
while (1) {
switch (_context6.prev = _context6.next) {
case 0:
return _context6.abrupt('return', this.__getTagsPartial(accessToken, { key: tagKey, offset: offset }));
case 1:
case 'end':
return _context6.stop();
}
}
}, _callee6, this);
}));
function getTagsByKey(_x17, _x18) {
return _ref6.apply(this, arguments);
case 15:
case "end":
return _context7.stop();
}
}
}, _callee7, this, [[1, 9]]);
}));
return getTagsByKey;
}()
}, {
key: 'getTagById',
value: function () {
var _ref7 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee7(accessToken, id) {
var axiosInstance, response;
return _regenerator2.default.wrap(function _callee7$(_context7) {
while (1) {
switch (_context7.prev = _context7.next) {
case 0:
axiosInstance = this.__getAxiosInstance(accessToken);
_context7.prev = 1;
function getTagById(_x14, _x15) {
return _getTagById.apply(this, arguments);
}
this.__debug('Calling ' + this.baseUrl + '/v0/tags/' + encodeURIComponent(id) + ' ...');
_context7.next = 5;
return axiosInstance.get(this.baseUrl + '/v0/tags/' + encodeURIComponent(id));
return getTagById;
}()
}, {
key: "createOrUpdateTag",
value: function () {
var _createOrUpdateTag = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee8(accessToken, resourceUri, tagKey, tagValue) {
var _this3 = this;
case 5:
response = _context7.sent;
return _context7.abrupt('return', response.data);
return _regenerator["default"].wrap(function _callee8$(_context8) {
while (1) {
switch (_context8.prev = _context8.next) {
case 0:
return _context8.abrupt("return", this.__getTagsPartial(accessToken, {
resourceUri: resourceUri,
key: tagKey
}).then(function (res) {
var results = res.results;
case 9:
_context7.prev = 9;
_context7.t0 = _context7['catch'](1);
_this3.__debug('createOrUpdateTag for ', resourceUri, tagKey, 'found:', results);
this.__error(_context7.t0);
if (results.length === 0) {
return _this3.createTag(accessToken, resourceUri, tagKey, tagValue);
}
if (!(_context7.t0.response && _context7.t0.response.status === 404)) {
_context7.next = 14;
break;
}
if (results.length === 1) {
return _this3.updateTag(accessToken, results[0].id, resourceUri, tagKey, tagValue);
}
throw new _TagNotFound2.default();
throw new _ConflictError["default"]('Multiple tags matching.');
})["catch"](function (e) {
_this3.__error(e);
case 14:
throw _context7.t0;
throw e;
}));
case 15:
case 'end':
return _context7.stop();
}
}
}, _callee7, this, [[1, 9]]);
}));
function getTagById(_x20, _x21) {
return _ref7.apply(this, arguments);
case 1:
case "end":
return _context8.stop();
}
}
}, _callee8, this);
}));
return getTagById;
}()
}, {
key: 'createOrUpdateTag',
value: function () {
var _ref8 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee8(accessToken, resourceUri, tagKey, tagValue) {
var _this3 = this;
function createOrUpdateTag(_x16, _x17, _x18, _x19) {
return _createOrUpdateTag.apply(this, arguments);
}
return _regenerator2.default.wrap(function _callee8$(_context8) {
while (1) {
switch (_context8.prev = _context8.next) {
case 0:
return _context8.abrupt('return', this.__getTagsPartial(accessToken, { resourceUri: resourceUri, key: tagKey }).then(function (res) {
var results = res.results;
_this3.__debug('createOrUpdateTag for ', resourceUri, tagKey, 'found:', results);
if (results.length === 0) {
return _this3.createTag(accessToken, resourceUri, tagKey, tagValue);
}
if (results.length === 1) {
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;
}));
return createOrUpdateTag;
}()
}, {
key: "createTag",
value: function () {
var _createTag = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee9(accessToken, resourceUri, tagKey, tagValue) {
var axiosInstance, params, response;
return _regenerator["default"].wrap(function _callee9$(_context9) {
while (1) {
switch (_context9.prev = _context9.next) {
case 0:
axiosInstance = this.__getAxiosInstance(accessToken);
params = {
key: tagKey,
value: tagValue,
resourceUri: resourceUri
};
_context9.prev = 2;
case 1:
case 'end':
return _context8.stop();
}
}
}, _callee8, this);
}));
this.__debug("Calling POST ".concat(this.baseUrl, "/v0/tags"), params);
function createOrUpdateTag(_x22, _x23, _x24, _x25) {
return _ref8.apply(this, arguments);
}
_context9.next = 6;
return axiosInstance.post("".concat(this.baseUrl, "/v0/tags"), params);
return createOrUpdateTag;
}()
}, {
key: 'createTag',
value: function () {
var _ref9 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee9(accessToken, resourceUri, tagKey, tagValue) {
var axiosInstance, params, response;
return _regenerator2.default.wrap(function _callee9$(_context9) {
while (1) {
switch (_context9.prev = _context9.next) {
case 0:
axiosInstance = this.__getAxiosInstance(accessToken);
params = {
key: tagKey,
value: tagValue,
resourceUri: resourceUri
};
_context9.prev = 2;
case 6:
response = _context9.sent;
return _context9.abrupt("return", response.data);
this.__debug('Calling POST ' + this.baseUrl + '/v0/tags', params);
_context9.next = 6;
return axiosInstance.post(this.baseUrl + '/v0/tags', params);
case 10:
_context9.prev = 10;
_context9.t0 = _context9["catch"](2);
case 6:
response = _context9.sent;
return _context9.abrupt('return', response.data);
this.__error(_context9.t0);
case 10:
_context9.prev = 10;
_context9.t0 = _context9['catch'](2);
throw _context9.t0;
this.__error(_context9.t0);
throw _context9.t0;
case 14:
case "end":
return _context9.stop();
}
}
}, _callee9, this, [[2, 10]]);
}));
case 14:
case 'end':
return _context9.stop();
}
}
}, _callee9, this, [[2, 10]]);
}));
function createTag(_x20, _x21, _x22, _x23) {
return _createTag.apply(this, arguments);
}
function createTag(_x26, _x27, _x28, _x29) {
return _ref9.apply(this, arguments);
}
return createTag;
}()
}, {
key: "updateTag",
value: function () {
var _updateTag = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee10(accessToken, id, resourceUri, tagKey, tagValue) {
var axiosInstance, params, response;
return _regenerator["default"].wrap(function _callee10$(_context10) {
while (1) {
switch (_context10.prev = _context10.next) {
case 0:
axiosInstance = this.__getAxiosInstance(accessToken);
params = {
key: tagKey,
value: tagValue,
resourceUri: resourceUri
};
_context10.prev = 2;
return createTag;
}()
}, {
key: 'updateTag',
value: function () {
var _ref10 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee10(accessToken, id, resourceUri, tagKey, tagValue) {
var axiosInstance, params, response;
return _regenerator2.default.wrap(function _callee10$(_context10) {
while (1) {
switch (_context10.prev = _context10.next) {
case 0:
axiosInstance = this.__getAxiosInstance(accessToken);
params = {
key: tagKey,
value: tagValue,
resourceUri: resourceUri
};
_context10.prev = 2;
this.__debug("Calling PUT ".concat(this.baseUrl, "/v0/tags/").concat(encodeURIComponent(id)), params);
this.__debug('Calling PUT ' + this.baseUrl + '/v0/tags/' + encodeURIComponent(id), params);
_context10.next = 6;
return axiosInstance.put(this.baseUrl + '/v0/tags/' + encodeURIComponent(id), params);
_context10.next = 6;
return axiosInstance.put("".concat(this.baseUrl, "/v0/tags/").concat(encodeURIComponent(id)), params);
case 6:
response = _context10.sent;
return _context10.abrupt('return', response.data);
case 6:
response = _context10.sent;
return _context10.abrupt("return", response.data);
case 10:
_context10.prev = 10;
_context10.t0 = _context10['catch'](2);
case 10:
_context10.prev = 10;
_context10.t0 = _context10["catch"](2);
this.__error(_context10.t0);
throw _context10.t0;
this.__error(_context10.t0);
case 14:
case 'end':
return _context10.stop();
}
}
}, _callee10, this, [[2, 10]]);
}));
throw _context10.t0;
function updateTag(_x30, _x31, _x32, _x33, _x34) {
return _ref10.apply(this, arguments);
case 14:
case "end":
return _context10.stop();
}
}
}, _callee10, this, [[2, 10]]);
}));
return updateTag;
}()
}, {
key: 'deleteTag',
value: function () {
var _ref11 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee11(accessToken, id) {
var axiosInstance, response;
return _regenerator2.default.wrap(function _callee11$(_context11) {
while (1) {
switch (_context11.prev = _context11.next) {
case 0:
axiosInstance = this.__getAxiosInstance(accessToken);
_context11.prev = 1;
function updateTag(_x24, _x25, _x26, _x27, _x28) {
return _updateTag.apply(this, arguments);
}
this.__debug('Calling DELETE ' + this.baseUrl + '/v0/tags/' + encodeURIComponent(id));
_context11.next = 5;
return axiosInstance.delete(this.baseUrl + '/v0/tags/' + encodeURIComponent(id));
return updateTag;
}()
}, {
key: "deleteTag",
value: function () {
var _deleteTag = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee11(accessToken, id) {
var axiosInstance, response;
return _regenerator["default"].wrap(function _callee11$(_context11) {
while (1) {
switch (_context11.prev = _context11.next) {
case 0:
axiosInstance = this.__getAxiosInstance(accessToken);
_context11.prev = 1;
case 5:
response = _context11.sent;
return _context11.abrupt('return', response.data);
this.__debug("Calling DELETE ".concat(this.baseUrl, "/v0/tags/").concat(encodeURIComponent(id)));
case 9:
_context11.prev = 9;
_context11.t0 = _context11['catch'](1);
_context11.next = 5;
return axiosInstance["delete"]("".concat(this.baseUrl, "/v0/tags/").concat(encodeURIComponent(id)));
this.__error(_context11.t0);
throw _context11.t0;
case 5:
response = _context11.sent;
return _context11.abrupt("return", response.data);
case 13:
case 'end':
return _context11.stop();
}
}
}, _callee11, this, [[1, 9]]);
}));
case 9:
_context11.prev = 9;
_context11.t0 = _context11["catch"](1);
function deleteTag(_x35, _x36) {
return _ref11.apply(this, arguments);
this.__error(_context11.t0);
throw _context11.t0;
case 13:
case "end":
return _context11.stop();
}
}
}, _callee11, this, [[1, 9]]);
}));
return deleteTag;
}()
}]);
return Tagliatelle;
function deleteTag(_x29, _x30) {
return _deleteTag.apply(this, arguments);
}
return deleteTag;
}()
}]);
return Tagliatelle;
}();
module.exports = Tagliatelle;
{
"name": "cimpress-tagliatelle",
"version": "0.3.2",
"version": "0.3.3",
"description": "A thin client for Cimpress Tagliatelle service",

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

"test": "eslint --ext .js src; jest --coverage; ./node_modules/.bin/jest-coverage-ratchet",
"build": "node ./node_modules/babel-cli/bin/babel.js src -d lib --copy-files"
"build": "node ./node_modules/@babel/cli/bin/babel.js src -d lib --copy-files"
},

@@ -26,24 +26,24 @@ "author": "TrdelnikSquad@cimpress.com",

"dependencies": {
"@babel/runtime": "^7.5.4",
"axios": "^0.18.1",
"axios-retry": "^3.1.1",
"qs": "^6.5.2",
"babel-runtime": "^6.26.0"
"qs": "^6.5.2"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-eslint": "^10.0.1",
"babel-jest": "^23.6.0",
"babel-plugin-transform-async-to-generator": "^6.24.1",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.7.0",
"eslint": "^5.4.0",
"eslint-config-google": "^0.9.1",
"jest": "^23.6.0",
"@babel/cli": "^7.5.0",
"@babel/core": "^7.5.4",
"@babel/plugin-transform-runtime": "^7.5.0",
"@babel/preset-env": "^7.5.4",
"babel-eslint": "^10.0.2",
"eslint": "^6.0.1",
"eslint-config-google": "^0.13.0",
"jest": "^24.8.0",
"jest-coverage-ratchet": "^0.2.3",
"regenerator-runtime": "^0.12.1",
"xhr-mock": "^2.4.1"
},
"jest": {
"coverageDirectory": "./coverage",
"coverageReporters": [
"text"
"text-summary",
"json-summary"
],

@@ -50,0 +50,0 @@ "collectCoverageFrom": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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