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

@commercetools/sdk-client

Package Overview
Dependencies
Maintainers
7
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@commercetools/sdk-client - npm Package Compare versions

Comparing version 1.5.8 to 1.5.9

229

dist/commercetools-sdk-client.cjs.js

@@ -9,86 +9,110 @@ 'use strict';

var METHODS = ['ACL', 'BIND', 'CHECKOUT', 'CONNECT', 'COPY', 'DELETE', 'GET', 'HEAD', 'LINK', 'LOCK', 'M-SEARCH', 'MERGE', 'MKACTIVITY', 'MKCALENDAR', 'MKCOL', 'MOVE', 'NOTIFY', 'OPTIONS', 'PATCH', 'POST', 'PROPFIND', 'PROPPATCH', 'PURGE', 'PUT', 'REBIND', 'REPORT', 'SEARCH', 'SOURCE', 'SUBSCRIBE', 'TRACE', 'UNBIND', 'UNLINK', 'UNLOCK', 'UNSUBSCRIBE'];
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
function validate(funcName, request) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : { allowedMethods: METHODS };
if (!request)
// eslint-disable-next-line max-len
throw new Error('The "' + funcName + '" function requires a "Request" object as an argument. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest');
if (typeof request.uri !== 'string')
// eslint-disable-next-line max-len
throw new Error('The "' + funcName + '" Request object requires a valid uri. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest');
if (!(options.allowedMethods.indexOf(request.method) !== -1))
// eslint-disable-next-line max-len
throw new Error('The "' + funcName + '" Request object requires a valid method. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest');
return obj;
}
var _extends = Object.assign || function (target) {
function _objectSpread(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys = Object.keys(source);
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
if (typeof Object.getOwnPropertySymbols === 'function') {
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
}));
}
ownKeys.forEach(function (key) {
_defineProperty(target, key, source[key]);
});
}
return target;
};
}
var slicedToArray = function () {
function sliceIterator(arr, i) {
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;
function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
}
try {
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
}
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"]) _i["return"]();
} finally {
if (_d) throw _e;
}
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
return _arr;
return arr2;
}
}
return function (arr, i) {
if (Array.isArray(arr)) {
return arr;
} else if (Symbol.iterator in Object(arr)) {
return sliceIterator(arr, i);
} else {
throw new TypeError("Invalid attempt to destructure non-iterable instance");
}
};
}();
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
var toConsumableArray = function (arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
function _iterableToArray(iter) {
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
}
return arr2;
} else {
return Array.from(arr);
function _iterableToArrayLimit(arr, i) {
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;
try {
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"] != null) _i["return"]();
} finally {
if (_d) throw _e;
}
}
};
/* */
return _arr;
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance");
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance");
}
var METHODS = ['ACL', 'BIND', 'CHECKOUT', 'CONNECT', 'COPY', 'DELETE', 'GET', 'HEAD', 'LINK', 'LOCK', 'M-SEARCH', 'MERGE', 'MKACTIVITY', 'MKCALENDAR', 'MKCOL', 'MOVE', 'NOTIFY', 'OPTIONS', 'PATCH', 'POST', 'PROPFIND', 'PROPPATCH', 'PURGE', 'PUT', 'REBIND', 'REPORT', 'SEARCH', 'SOURCE', 'SUBSCRIBE', 'TRACE', 'UNBIND', 'UNLINK', 'UNLOCK', 'UNSUBSCRIBE'];
function validate(funcName, request) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
allowedMethods: METHODS
};
if (!request) // eslint-disable-next-line max-len
throw new Error("The \"".concat(funcName, "\" function requires a \"Request\" object as an argument. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest"));
if (typeof request.uri !== 'string') // eslint-disable-next-line max-len
throw new Error("The \"".concat(funcName, "\" Request object requires a valid uri. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest"));
if (!options.allowedMethods.includes(request.method)) // eslint-disable-next-line max-len
throw new Error("The \"".concat(funcName, "\" Request object requires a valid method. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest"));
}
function compose() {
for (var _len = arguments.length, funcs = Array(_len), _key = 0; _key < _len; _key++) {
for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
funcs[_key] = arguments[_key];

@@ -101,8 +125,6 @@ }

});
if (funcs.length === 1) return funcs[0];
return funcs.reduce(function (a, b) {
return function () {
return a(b.apply(undefined, arguments));
return a(b.apply(void 0, arguments));
};

@@ -114,7 +136,4 @@ });

if (!options) throw new Error('Missing required options');
if (options.middlewares && !Array.isArray(options.middlewares)) throw new Error('Middlewares should be an array');
if (!options.middlewares || !Array.isArray(options.middlewares) || !options.middlewares.length) throw new Error('You need to provide at least one middleware');
return {

@@ -126,3 +145,2 @@ /*

validate('exec', request);
return new Promise(function (resolve, reject) {

@@ -145,5 +163,4 @@ var resolver = function resolver(rq, rs) {

var dispatch = compose.apply(undefined, toConsumableArray(options.middlewares))(resolver);
dispatch(request,
// Initial response shape
var dispatch = compose.apply(void 0, _toConsumableArray(options.middlewares))(resolver);
dispatch(request, // Initial response shape
{

@@ -160,21 +177,22 @@ resolve: resolve,

validate('process', request, { allowedMethods: ['GET'] });
validate('process', request, {
allowedMethods: ['GET']
});
if (typeof fn !== 'function') // eslint-disable-next-line max-len
throw new Error('The "process" function accepts a "Function" as a second argument that returns a Promise. See https://commercetools.github.io/nodejs/sdk/api/sdkClient.html#processrequest-processfn-options'); // Set default process options
if (typeof fn !== 'function')
// eslint-disable-next-line max-len
throw new Error('The "process" function accepts a "Function" as a second argument that returns a Promise. See https://commercetools.github.io/nodejs/sdk/api/sdkClient.html#processrequest-processfn-options');
// Set default process options
var opt = _extends({
var opt = _objectSpread({
total: Number.POSITIVE_INFINITY,
accumulate: true
}, processOpt);
return new Promise(function (resolve, reject) {
var _request$uri$split = request.uri.split('?'),
_request$uri$split2 = slicedToArray(_request$uri$split, 2),
_request$uri$split2 = _slicedToArray(_request$uri$split, 2),
path = _request$uri$split2[0],
queryString = _request$uri$split2[1];
var requestQuery = _extends({}, qs.parse(queryString));
var query = _extends({
var requestQuery = _objectSpread({}, qs.parse(queryString));
var query = _objectSpread({
// defaults

@@ -184,27 +202,41 @@ limit: 20

var hasFirstPageBeenProcessed = false;
var itemsToGet = opt.total;
var processPage = function processPage(lastId) {
var acc = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
// Use the lesser value between limit and itemsToGet in query
var limit = query.limit < itemsToGet ? query.limit : itemsToGet;
var originalQueryString = qs.stringify(_extends({}, query, { limit: limit }));
var originalQueryString = qs.stringify(_objectSpread({}, query, {
limit: limit
}));
var enhancedQuery = _extends({
var enhancedQuery = _objectSpread({
sort: 'id asc',
withTotal: false
}, lastId ? { where: 'id > "' + lastId + '"' } : {});
}, lastId ? {
where: "id > \"".concat(lastId, "\"")
} : {});
var enhancedQueryString = qs.stringify(enhancedQuery);
var enhancedRequest = _extends({}, request, {
uri: path + '?' + enhancedQueryString + '&' + originalQueryString
var enhancedRequest = _objectSpread({}, request, {
uri: "".concat(path, "?").concat(enhancedQueryString, "&").concat(originalQueryString)
});
_this.execute(enhancedRequest).then(function (payload) {
fn(payload).then(function (result) {
var resultsLength = payload.body.results.length;
var accumulated = void 0;
var _payload$body = payload.body,
results = _payload$body.results,
resultsLength = _payload$body.count;
if (!resultsLength && hasFirstPageBeenProcessed) {
resolve(acc || []);
return;
}
Promise.resolve(fn(payload)).then(function (result) {
hasFirstPageBeenProcessed = true;
var accumulated;
if (opt.accumulate) accumulated = acc.concat(result || []);
itemsToGet -= resultsLength;
// If there are no more items to get, it means the total number
itemsToGet -= resultsLength; // If there are no more items to get, it means the total number
// of items in the original request have been fetched so we

@@ -215,2 +247,3 @@ // resolve the promise.

// resolve the promise.
if (resultsLength < query.limit || !itemsToGet) {

@@ -221,3 +254,3 @@ resolve(accumulated || []);

var last = payload.body.results[resultsLength - 1];
var last = results[resultsLength - 1];
var newLastId = last && last.id;

@@ -227,5 +260,5 @@ processPage(newLastId, accumulated);

}).catch(reject);
};
}; // Start iterating through pages
// Start iterating through pages
processPage();

@@ -232,0 +265,0 @@ });

import qs from 'querystring';
var METHODS = ['ACL', 'BIND', 'CHECKOUT', 'CONNECT', 'COPY', 'DELETE', 'GET', 'HEAD', 'LINK', 'LOCK', 'M-SEARCH', 'MERGE', 'MKACTIVITY', 'MKCALENDAR', 'MKCOL', 'MOVE', 'NOTIFY', 'OPTIONS', 'PATCH', 'POST', 'PROPFIND', 'PROPPATCH', 'PURGE', 'PUT', 'REBIND', 'REPORT', 'SEARCH', 'SOURCE', 'SUBSCRIBE', 'TRACE', 'UNBIND', 'UNLINK', 'UNLOCK', 'UNSUBSCRIBE'];
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
function validate(funcName, request) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : { allowedMethods: METHODS };
if (!request)
// eslint-disable-next-line max-len
throw new Error('The "' + funcName + '" function requires a "Request" object as an argument. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest');
if (typeof request.uri !== 'string')
// eslint-disable-next-line max-len
throw new Error('The "' + funcName + '" Request object requires a valid uri. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest');
if (!(options.allowedMethods.indexOf(request.method) !== -1))
// eslint-disable-next-line max-len
throw new Error('The "' + funcName + '" Request object requires a valid method. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest');
return obj;
}
var _extends = Object.assign || function (target) {
function _objectSpread(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys = Object.keys(source);
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
if (typeof Object.getOwnPropertySymbols === 'function') {
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
}));
}
ownKeys.forEach(function (key) {
_defineProperty(target, key, source[key]);
});
}
return target;
};
}
var slicedToArray = function () {
function sliceIterator(arr, i) {
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;
function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
}
try {
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
}
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"]) _i["return"]();
} finally {
if (_d) throw _e;
}
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
return _arr;
return arr2;
}
}
return function (arr, i) {
if (Array.isArray(arr)) {
return arr;
} else if (Symbol.iterator in Object(arr)) {
return sliceIterator(arr, i);
} else {
throw new TypeError("Invalid attempt to destructure non-iterable instance");
}
};
}();
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
var toConsumableArray = function (arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
function _iterableToArray(iter) {
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
}
return arr2;
} else {
return Array.from(arr);
function _iterableToArrayLimit(arr, i) {
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;
try {
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"] != null) _i["return"]();
} finally {
if (_d) throw _e;
}
}
};
/* */
return _arr;
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance");
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance");
}
var METHODS = ['ACL', 'BIND', 'CHECKOUT', 'CONNECT', 'COPY', 'DELETE', 'GET', 'HEAD', 'LINK', 'LOCK', 'M-SEARCH', 'MERGE', 'MKACTIVITY', 'MKCALENDAR', 'MKCOL', 'MOVE', 'NOTIFY', 'OPTIONS', 'PATCH', 'POST', 'PROPFIND', 'PROPPATCH', 'PURGE', 'PUT', 'REBIND', 'REPORT', 'SEARCH', 'SOURCE', 'SUBSCRIBE', 'TRACE', 'UNBIND', 'UNLINK', 'UNLOCK', 'UNSUBSCRIBE'];
function validate(funcName, request) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
allowedMethods: METHODS
};
if (!request) // eslint-disable-next-line max-len
throw new Error("The \"".concat(funcName, "\" function requires a \"Request\" object as an argument. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest"));
if (typeof request.uri !== 'string') // eslint-disable-next-line max-len
throw new Error("The \"".concat(funcName, "\" Request object requires a valid uri. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest"));
if (!options.allowedMethods.includes(request.method)) // eslint-disable-next-line max-len
throw new Error("The \"".concat(funcName, "\" Request object requires a valid method. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest"));
}
function compose() {
for (var _len = arguments.length, funcs = Array(_len), _key = 0; _key < _len; _key++) {
for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
funcs[_key] = arguments[_key];

@@ -94,8 +118,6 @@ }

});
if (funcs.length === 1) return funcs[0];
return funcs.reduce(function (a, b) {
return function () {
return a(b.apply(undefined, arguments));
return a(b.apply(void 0, arguments));
};

@@ -107,7 +129,4 @@ });

if (!options) throw new Error('Missing required options');
if (options.middlewares && !Array.isArray(options.middlewares)) throw new Error('Middlewares should be an array');
if (!options.middlewares || !Array.isArray(options.middlewares) || !options.middlewares.length) throw new Error('You need to provide at least one middleware');
return {

@@ -119,3 +138,2 @@ /*

validate('exec', request);
return new Promise(function (resolve, reject) {

@@ -138,5 +156,4 @@ var resolver = function resolver(rq, rs) {

var dispatch = compose.apply(undefined, toConsumableArray(options.middlewares))(resolver);
dispatch(request,
// Initial response shape
var dispatch = compose.apply(void 0, _toConsumableArray(options.middlewares))(resolver);
dispatch(request, // Initial response shape
{

@@ -153,21 +170,22 @@ resolve: resolve,

validate('process', request, { allowedMethods: ['GET'] });
validate('process', request, {
allowedMethods: ['GET']
});
if (typeof fn !== 'function') // eslint-disable-next-line max-len
throw new Error('The "process" function accepts a "Function" as a second argument that returns a Promise. See https://commercetools.github.io/nodejs/sdk/api/sdkClient.html#processrequest-processfn-options'); // Set default process options
if (typeof fn !== 'function')
// eslint-disable-next-line max-len
throw new Error('The "process" function accepts a "Function" as a second argument that returns a Promise. See https://commercetools.github.io/nodejs/sdk/api/sdkClient.html#processrequest-processfn-options');
// Set default process options
var opt = _extends({
var opt = _objectSpread({
total: Number.POSITIVE_INFINITY,
accumulate: true
}, processOpt);
return new Promise(function (resolve, reject) {
var _request$uri$split = request.uri.split('?'),
_request$uri$split2 = slicedToArray(_request$uri$split, 2),
_request$uri$split2 = _slicedToArray(_request$uri$split, 2),
path = _request$uri$split2[0],
queryString = _request$uri$split2[1];
var requestQuery = _extends({}, qs.parse(queryString));
var query = _extends({
var requestQuery = _objectSpread({}, qs.parse(queryString));
var query = _objectSpread({
// defaults

@@ -177,27 +195,41 @@ limit: 20

var hasFirstPageBeenProcessed = false;
var itemsToGet = opt.total;
var processPage = function processPage(lastId) {
var acc = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
// Use the lesser value between limit and itemsToGet in query
var limit = query.limit < itemsToGet ? query.limit : itemsToGet;
var originalQueryString = qs.stringify(_extends({}, query, { limit: limit }));
var originalQueryString = qs.stringify(_objectSpread({}, query, {
limit: limit
}));
var enhancedQuery = _extends({
var enhancedQuery = _objectSpread({
sort: 'id asc',
withTotal: false
}, lastId ? { where: 'id > "' + lastId + '"' } : {});
}, lastId ? {
where: "id > \"".concat(lastId, "\"")
} : {});
var enhancedQueryString = qs.stringify(enhancedQuery);
var enhancedRequest = _extends({}, request, {
uri: path + '?' + enhancedQueryString + '&' + originalQueryString
var enhancedRequest = _objectSpread({}, request, {
uri: "".concat(path, "?").concat(enhancedQueryString, "&").concat(originalQueryString)
});
_this.execute(enhancedRequest).then(function (payload) {
fn(payload).then(function (result) {
var resultsLength = payload.body.results.length;
var accumulated = void 0;
var _payload$body = payload.body,
results = _payload$body.results,
resultsLength = _payload$body.count;
if (!resultsLength && hasFirstPageBeenProcessed) {
resolve(acc || []);
return;
}
Promise.resolve(fn(payload)).then(function (result) {
hasFirstPageBeenProcessed = true;
var accumulated;
if (opt.accumulate) accumulated = acc.concat(result || []);
itemsToGet -= resultsLength;
// If there are no more items to get, it means the total number
itemsToGet -= resultsLength; // If there are no more items to get, it means the total number
// of items in the original request have been fetched so we

@@ -208,2 +240,3 @@ // resolve the promise.

// resolve the promise.
if (resultsLength < query.limit || !itemsToGet) {

@@ -214,3 +247,3 @@ resolve(accumulated || []);

var last = payload.body.results[resultsLength - 1];
var last = results[resultsLength - 1];
var newLastId = last && last.id;

@@ -220,5 +253,5 @@ processPage(newLastId, accumulated);

}).catch(reject);
};
}; // Start iterating through pages
// Start iterating through pages
processPage();

@@ -225,0 +258,0 @@ });

@@ -9,86 +9,110 @@ (function (global, factory) {

var METHODS = ['ACL', 'BIND', 'CHECKOUT', 'CONNECT', 'COPY', 'DELETE', 'GET', 'HEAD', 'LINK', 'LOCK', 'M-SEARCH', 'MERGE', 'MKACTIVITY', 'MKCALENDAR', 'MKCOL', 'MOVE', 'NOTIFY', 'OPTIONS', 'PATCH', 'POST', 'PROPFIND', 'PROPPATCH', 'PURGE', 'PUT', 'REBIND', 'REPORT', 'SEARCH', 'SOURCE', 'SUBSCRIBE', 'TRACE', 'UNBIND', 'UNLINK', 'UNLOCK', 'UNSUBSCRIBE'];
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
function validate(funcName, request) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : { allowedMethods: METHODS };
if (!request)
// eslint-disable-next-line max-len
throw new Error('The "' + funcName + '" function requires a "Request" object as an argument. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest');
if (typeof request.uri !== 'string')
// eslint-disable-next-line max-len
throw new Error('The "' + funcName + '" Request object requires a valid uri. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest');
if (!(options.allowedMethods.indexOf(request.method) !== -1))
// eslint-disable-next-line max-len
throw new Error('The "' + funcName + '" Request object requires a valid method. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest');
return obj;
}
var _extends = Object.assign || function (target) {
function _objectSpread(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys = Object.keys(source);
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
if (typeof Object.getOwnPropertySymbols === 'function') {
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
}));
}
ownKeys.forEach(function (key) {
_defineProperty(target, key, source[key]);
});
}
return target;
};
}
var slicedToArray = function () {
function sliceIterator(arr, i) {
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;
function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
}
try {
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
}
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"]) _i["return"]();
} finally {
if (_d) throw _e;
}
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
return _arr;
return arr2;
}
}
return function (arr, i) {
if (Array.isArray(arr)) {
return arr;
} else if (Symbol.iterator in Object(arr)) {
return sliceIterator(arr, i);
} else {
throw new TypeError("Invalid attempt to destructure non-iterable instance");
}
};
}();
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
var toConsumableArray = function (arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
function _iterableToArray(iter) {
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
}
return arr2;
} else {
return Array.from(arr);
function _iterableToArrayLimit(arr, i) {
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;
try {
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"] != null) _i["return"]();
} finally {
if (_d) throw _e;
}
}
};
/* */
return _arr;
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance");
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance");
}
var METHODS = ['ACL', 'BIND', 'CHECKOUT', 'CONNECT', 'COPY', 'DELETE', 'GET', 'HEAD', 'LINK', 'LOCK', 'M-SEARCH', 'MERGE', 'MKACTIVITY', 'MKCALENDAR', 'MKCOL', 'MOVE', 'NOTIFY', 'OPTIONS', 'PATCH', 'POST', 'PROPFIND', 'PROPPATCH', 'PURGE', 'PUT', 'REBIND', 'REPORT', 'SEARCH', 'SOURCE', 'SUBSCRIBE', 'TRACE', 'UNBIND', 'UNLINK', 'UNLOCK', 'UNSUBSCRIBE'];
function validate(funcName, request) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
allowedMethods: METHODS
};
if (!request) // eslint-disable-next-line max-len
throw new Error("The \"".concat(funcName, "\" function requires a \"Request\" object as an argument. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest"));
if (typeof request.uri !== 'string') // eslint-disable-next-line max-len
throw new Error("The \"".concat(funcName, "\" Request object requires a valid uri. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest"));
if (!options.allowedMethods.includes(request.method)) // eslint-disable-next-line max-len
throw new Error("The \"".concat(funcName, "\" Request object requires a valid method. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest"));
}
function compose() {
for (var _len = arguments.length, funcs = Array(_len), _key = 0; _key < _len; _key++) {
for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
funcs[_key] = arguments[_key];

@@ -101,8 +125,6 @@ }

});
if (funcs.length === 1) return funcs[0];
return funcs.reduce(function (a, b) {
return function () {
return a(b.apply(undefined, arguments));
return a(b.apply(void 0, arguments));
};

@@ -114,7 +136,4 @@ });

if (!options) throw new Error('Missing required options');
if (options.middlewares && !Array.isArray(options.middlewares)) throw new Error('Middlewares should be an array');
if (!options.middlewares || !Array.isArray(options.middlewares) || !options.middlewares.length) throw new Error('You need to provide at least one middleware');
return {

@@ -126,3 +145,2 @@ /*

validate('exec', request);
return new Promise(function (resolve, reject) {

@@ -145,5 +163,4 @@ var resolver = function resolver(rq, rs) {

var dispatch = compose.apply(undefined, toConsumableArray(options.middlewares))(resolver);
dispatch(request,
// Initial response shape
var dispatch = compose.apply(void 0, _toConsumableArray(options.middlewares))(resolver);
dispatch(request, // Initial response shape
{

@@ -160,21 +177,22 @@ resolve: resolve,

validate('process', request, { allowedMethods: ['GET'] });
validate('process', request, {
allowedMethods: ['GET']
});
if (typeof fn !== 'function') // eslint-disable-next-line max-len
throw new Error('The "process" function accepts a "Function" as a second argument that returns a Promise. See https://commercetools.github.io/nodejs/sdk/api/sdkClient.html#processrequest-processfn-options'); // Set default process options
if (typeof fn !== 'function')
// eslint-disable-next-line max-len
throw new Error('The "process" function accepts a "Function" as a second argument that returns a Promise. See https://commercetools.github.io/nodejs/sdk/api/sdkClient.html#processrequest-processfn-options');
// Set default process options
var opt = _extends({
var opt = _objectSpread({
total: Number.POSITIVE_INFINITY,
accumulate: true
}, processOpt);
return new Promise(function (resolve, reject) {
var _request$uri$split = request.uri.split('?'),
_request$uri$split2 = slicedToArray(_request$uri$split, 2),
_request$uri$split2 = _slicedToArray(_request$uri$split, 2),
path = _request$uri$split2[0],
queryString = _request$uri$split2[1];
var requestQuery = _extends({}, qs.parse(queryString));
var query = _extends({
var requestQuery = _objectSpread({}, qs.parse(queryString));
var query = _objectSpread({
// defaults

@@ -184,27 +202,41 @@ limit: 20

var hasFirstPageBeenProcessed = false;
var itemsToGet = opt.total;
var processPage = function processPage(lastId) {
var acc = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
// Use the lesser value between limit and itemsToGet in query
var limit = query.limit < itemsToGet ? query.limit : itemsToGet;
var originalQueryString = qs.stringify(_extends({}, query, { limit: limit }));
var originalQueryString = qs.stringify(_objectSpread({}, query, {
limit: limit
}));
var enhancedQuery = _extends({
var enhancedQuery = _objectSpread({
sort: 'id asc',
withTotal: false
}, lastId ? { where: 'id > "' + lastId + '"' } : {});
}, lastId ? {
where: "id > \"".concat(lastId, "\"")
} : {});
var enhancedQueryString = qs.stringify(enhancedQuery);
var enhancedRequest = _extends({}, request, {
uri: path + '?' + enhancedQueryString + '&' + originalQueryString
var enhancedRequest = _objectSpread({}, request, {
uri: "".concat(path, "?").concat(enhancedQueryString, "&").concat(originalQueryString)
});
_this.execute(enhancedRequest).then(function (payload) {
fn(payload).then(function (result) {
var resultsLength = payload.body.results.length;
var accumulated = void 0;
var _payload$body = payload.body,
results = _payload$body.results,
resultsLength = _payload$body.count;
if (!resultsLength && hasFirstPageBeenProcessed) {
resolve(acc || []);
return;
}
Promise.resolve(fn(payload)).then(function (result) {
hasFirstPageBeenProcessed = true;
var accumulated;
if (opt.accumulate) accumulated = acc.concat(result || []);
itemsToGet -= resultsLength;
// If there are no more items to get, it means the total number
itemsToGet -= resultsLength; // If there are no more items to get, it means the total number
// of items in the original request have been fetched so we

@@ -215,2 +247,3 @@ // resolve the promise.

// resolve the promise.
if (resultsLength < query.limit || !itemsToGet) {

@@ -221,3 +254,3 @@ resolve(accumulated || []);

var last = payload.body.results[resultsLength - 1];
var last = results[resultsLength - 1];
var newLastId = last && last.id;

@@ -227,5 +260,5 @@ processPage(newLastId, accumulated);

}).catch(reject);
};
}; // Start iterating through pages
// Start iterating through pages
processPage();

@@ -232,0 +265,0 @@ });

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

!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("querystring")):"function"==typeof define&&define.amd?define(["exports","querystring"],r):r(e.CommercetoolsSdkClient={},e.qs)}(this,function(e,w){"use strict";w=w&&w.hasOwnProperty("default")?w.default:w;var o=["ACL","BIND","CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LINK","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCALENDAR","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REBIND","REPORT","SEARCH","SOURCE","SUBSCRIBE","TRACE","UNBIND","UNLINK","UNLOCK","UNSUBSCRIBE"];function r(e,r){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{allowedMethods:o};if(!r)throw new Error('The "'+e+'" function requires a "Request" object as an argument. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest');if("string"!=typeof r.uri)throw new Error('The "'+e+'" Request object requires a valid uri. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest');if(-1===t.allowedMethods.indexOf(r.method))throw new Error('The "'+e+'" Request object requires a valid method. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest')}var v=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},n=function(e,r){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,r){var t=[],o=!0,n=!1,i=void 0;try{for(var s,a=e[Symbol.iterator]();!(o=(s=a.next()).done)&&(t.push(s.value),!r||t.length!==r);o=!0);}catch(e){n=!0,i=e}finally{try{!o&&a.return&&a.return()}finally{if(n)throw i}}return t}(e,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")};e.createClient=function(o){if(!o)throw new Error("Missing required options");if(o.middlewares&&!Array.isArray(o.middlewares))throw new Error("Middlewares should be an array");if(!o.middlewares||!Array.isArray(o.middlewares)||!o.middlewares.length)throw new Error("You need to provide at least one middleware");return{execute:function(t){return r("exec",t),new Promise(function(e,r){(function(){for(var e=arguments.length,r=Array(e),t=0;t<e;t++)r[t]=arguments[t];return 1===(r=r.filter(function(e){return"function"==typeof e})).length?r[0]:r.reduce(function(e,r){return function(){return e(r.apply(void 0,arguments))}})}).apply(void 0,function(e){if(Array.isArray(e)){for(var r=0,t=Array(e.length);r<e.length;r++)t[r]=e[r];return t}return Array.from(e)}(o.middlewares))(function(e,r){if(r.error)r.reject(r.error);else{var t={body:r.body||{},statusCode:r.statusCode};r.headers&&(t.headers=r.headers),r.request&&(t.request=r.request),r.resolve(t)}})(t,{resolve:e,reject:r,body:void 0,error:void 0})})},process:function(h,y,e){var m=this;if(r("process",h,{allowedMethods:["GET"]}),"function"!=typeof y)throw new Error('The "process" function accepts a "Function" as a second argument that returns a Promise. See https://commercetools.github.io/nodejs/sdk/api/sdkClient.html#processrequest-processfn-options');var p=v({total:Number.POSITIVE_INFINITY,accumulate:!0},e);return new Promise(function(u,l){var e=h.uri.split("?"),r=n(e,2),c=r[0],t=r[1],o=v({},w.parse(t)),d=v({limit:20},o),f=p.total;!function s(e){var a=1<arguments.length&&void 0!==arguments[1]?arguments[1]:[],r=d.limit<f?d.limit:f,t=w.stringify(v({},d,{limit:r})),o=v({sort:"id asc",withTotal:!1},e?{where:'id > "'+e+'"'}:{}),n=w.stringify(o),i=v({},h,{uri:c+"?"+n+"&"+t});m.execute(i).then(function(i){y(i).then(function(e){var r=i.body.results.length,t=void 0;if(p.accumulate&&(t=a.concat(e||[])),f-=r,r<d.limit||!f)u(t||[]);else{var o=i.body.results[r-1],n=o&&o.id;s(n,t)}}).catch(l)}).catch(l)}()})}}},Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("querystring")):"function"==typeof define&&define.amd?define(["exports","querystring"],r):r(e.CommercetoolsSdkClient={},e.qs)}(this,function(e,y){"use strict";y=y&&y.hasOwnProperty("default")?y.default:y,require("./_fix-re-wks")("replace",2,function(n,o,s){return[function(e,r){var t=n(this),i=null==e?void 0:e[o];return void 0!==i?i.call(e,t,r):s.call(String(t),e,r)},s]});var r=require("./_global"),o=require("./_inherit-if-required"),t=require("./_object-dp").f,i=require("./_object-gopn").f,s=require("./_is-regexp"),c=require("./_flags"),u=r.RegExp,a=u,l=u.prototype,n=/a/g,f=/a/g,d=new u(n)!==n;if(require("./_descriptors")&&(!d||require("./_fails")(function(){return f[require("./_wks")("match")]=!1,u(n)!=n||u(f)==f||"/a/i"!=u(n,"i")}))){u=function(e,r){var t=this instanceof u,i=s(e),n=void 0===r;return!t&&i&&e.constructor===u&&n?e:o(d?new a(i&&!n?e.source:e,r):a((i=e instanceof u)?e.source:e,i&&n?c.call(e):r),t?this:l,u)};for(var h=function(r){r in u||t(u,r,{configurable:!0,get:function(){return a[r]},set:function(e){a[r]=e}})},p=i(a),v=0;p.length>v;)h(p[v++]);(l.constructor=u).prototype=l,require("./_redefine")(r,"RegExp",u)}function q(n){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{},r=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(o).filter(function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable}))),r.forEach(function(e){var r,t,i;r=n,i=o[t=e],t in r?Object.defineProperty(r,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[t]=i})}return n}function g(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var t=[],i=!0,n=!1,o=void 0;try{for(var s,c=e[Symbol.iterator]();!(i=(s=c.next()).done)&&(t.push(s.value),!r||t.length!==r);i=!0);}catch(e){n=!0,o=e}finally{try{i||null==c.return||c.return()}finally{if(n)throw o}}return t}(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function _(e){return function(e){if(Array.isArray(e)){for(var r=0,t=new Array(e.length);r<e.length;r++)t[r]=e[r];return t}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}require("./_set-species")("RegExp"),require("./_fix-re-wks")("split",2,function(n,o,s){var h=require("./_is-regexp"),p=s,v=[].push,e="split",_="length",m="lastIndex";if("c"=="abbc"[e](/(b)*/)[1]||4!="test"[e](/(?:)/,-1)[_]||2!="ab"[e](/(?:ab)*/)[_]||4!="."[e](/(.?)(.?)/)[_]||1<"."[e](/()()/)[_]||""[e](/.?/)[_]){var y=void 0===/()??/.exec("")[1];s=function(e,r){var t=String(this);if(void 0===e&&0===r)return[];if(!h(e))return p.call(t,e,r);var i,n,o,s,c,u=[],a=(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.unicode?"u":"")+(e.sticky?"y":""),l=0,f=void 0===r?4294967295:r>>>0,d=new RegExp(e.source,a+"g");for(y||(i=new RegExp("^"+d.source+"$(?!\\s)",a));(n=d.exec(t))&&!(l<(o=n.index+n[0][_])&&(u.push(t.slice(l,n.index)),!y&&1<n[_]&&n[0].replace(i,function(){for(c=1;c<arguments[_]-2;c++)void 0===arguments[c]&&(n[c]=void 0)}),1<n[_]&&n.index<t[_]&&v.apply(u,n.slice(1)),s=n[0][_],l=o,u[_]>=f));)d[m]===n.index&&d[m]++;return l===t[_]?!s&&d.test("")||u.push(""):u.push(t.slice(l)),u[_]>f?u.slice(0,f):u}}else"0"[e](void 0,0)[_]&&(s=function(e,r){return void 0===e&&0===r?[]:p.call(this,e,r)});return[function(e,r){var t=n(this),i=null==e?void 0:e[o];return void 0!==i?i.call(e,t,r):s.call(String(t),e,r)},s]});var m=require("./_global"),w=require("./_has"),b=require("./_cof"),E=require("./_inherit-if-required"),I=require("./_to-primitive"),j=require("./_fails"),N=require("./_object-gopn").f,x=require("./_object-gopd").f,A=require("./_object-dp").f,O=require("./_string-trim").trim,S="Number",P=m[S],C=P,T=P.prototype,R=b(require("./_object-create")(T))==S,k="trim"in String.prototype,M=function(e){var r=I(e,!1);if("string"==typeof r&&2<r.length){var t,i,n,o=(r=k?r.trim():O(r,3)).charCodeAt(0);if(43===o||45===o){if(88===(t=r.charCodeAt(2))||120===t)return NaN}else if(48===o){switch(r.charCodeAt(1)){case 66:case 98:i=2,n=49;break;case 79:case 111:i=8,n=55;break;default:return+r}for(var s,c=r.slice(2),u=0,a=c.length;u<a;u++)if((s=c.charCodeAt(u))<48||n<s)return NaN;return parseInt(c,i)}}return+r};if(!P(" 0o1")||!P("0b1")||P("+0x1")){P=function(e){var r=arguments.length<1?0:e,t=this;return t instanceof P&&(R?j(function(){T.valueOf.call(t)}):b(t)!=S)?E(new C(M(r)),t,P):M(r)};for(var F,U=require("./_descriptors")?N(C):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger".split(","),G=0;U.length>G;G++)w(C,F=U[G])&&!w(P,F)&&A(P,F,x(C,F));(P.prototype=T).constructor=P,require("./_redefine")(m,S,P)}var L,D,K,B,H=require("./_library"),V=require("./_global"),Y=require("./_ctx"),X=require("./_classof"),W=require("./_export"),$=require("./_is-object"),z=require("./_a-function"),J=require("./_an-instance"),Q=require("./_for-of"),Z=require("./_species-constructor"),ee=require("./_task").set,re=require("./_microtask")(),te=require("./_new-promise-capability"),ie=require("./_perform"),ne=require("./_user-agent"),oe=require("./_promise-resolve"),se="Promise",ce=V.TypeError,ue=V.process,ae=ue&&ue.versions,le=ae&&ae.v8||"",fe=V[se],de="process"==X(ue),he=function(){},pe=D=te.f,ve=!!function(){try{var e=fe.resolve(1),r=(e.constructor={})[require("./_wks")("species")]=function(e){e(he,he)};return(de||"function"==typeof PromiseRejectionEvent)&&e.then(he)instanceof r&&0!==le.indexOf("6.6")&&-1===ne.indexOf("Chrome/66")}catch(e){}}(),_e=function(e){var r;return!(!$(e)||"function"!=typeof(r=e.then))&&r},me=function(l,t){if(!l._n){l._n=!0;var i=l._c;re(function(){for(var u=l._v,a=1==l._s,e=0,r=function(e){var r,t,i,n=a?e.ok:e.fail,o=e.resolve,s=e.reject,c=e.domain;try{n?(a||(2==l._h&&ge(l),l._h=1),!0===n?r=u:(c&&c.enter(),r=n(u),c&&(c.exit(),i=!0)),r===e.promise?s(ce("Promise-chain cycle")):(t=_e(r))?t.call(r,o,s):o(r)):s(u)}catch(e){c&&!i&&c.exit(),s(e)}};i.length>e;)r(i[e++]);l._c=[],l._n=!1,t&&!l._h&&ye(l)})}},ye=function(o){ee.call(V,function(){var e,r,t,i=o._v,n=qe(o);if(n&&(e=ie(function(){de?ue.emit("unhandledRejection",i,o):(r=V.onunhandledrejection)?r({promise:o,reason:i}):(t=V.console)&&t.error&&t.error("Unhandled promise rejection",i)}),o._h=de||qe(o)?2:1),o._a=void 0,n&&e.e)throw e.v})},qe=function(e){return 1!==e._h&&0===(e._a||e._c).length},ge=function(r){ee.call(V,function(){var e;de?ue.emit("rejectionHandled",r):(e=V.onrejectionhandled)&&e({promise:r,reason:r._v})})},we=function(e){var r=this;r._d||(r._d=!0,(r=r._w||r)._v=e,r._s=2,r._a||(r._a=r._c.slice()),me(r,!0))},be=function e(t){var i,n=this;if(!n._d){n._d=!0,n=n._w||n;try{if(n===t)throw ce("Promise can't be resolved itself");(i=_e(t))?re(function(){var r={_w:n,_d:!1};try{i.call(t,Y(e,r,1),Y(we,r,1))}catch(e){we.call(r,e)}}):(n._v=t,n._s=1,me(n,!1))}catch(e){we.call({_w:n,_d:!1},e)}}};ve||(fe=function(e){J(this,fe,se,"_h"),z(e),L.call(this);try{e(Y(be,this,1),Y(we,this,1))}catch(e){we.call(this,e)}},(L=function(e){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1}).prototype=require("./_redefine-all")(fe.prototype,{then:function(e,r){var t=pe(Z(this,fe));return t.ok="function"!=typeof e||e,t.fail="function"==typeof r&&r,t.domain=de?ue.domain:void 0,this._c.push(t),this._a&&this._a.push(t),this._s&&me(this,!1),t.promise},catch:function(e){return this.then(void 0,e)}}),K=function(){var e=new L;this.promise=e,this.resolve=Y(be,e,1),this.reject=Y(we,e,1)},te.f=pe=function(e){return e===fe||e===B?new K(e):D(e)}),W(W.G+W.W+W.F*!ve,{Promise:fe}),require("./_set-to-string-tag")(fe,se),require("./_set-species")(se),B=require("./_core")[se],W(W.S+W.F*!ve,se,{reject:function(e){var r=pe(this);return(0,r.reject)(e),r.promise}}),W(W.S+W.F*(H||!ve),se,{resolve:function(e){return oe(H&&this===B?fe:this,e)}}),W(W.S+W.F*!(ve&&require("./_iter-detect")(function(e){fe.all(e).catch(he)})),se,{all:function(e){var s=this,r=pe(s),c=r.resolve,u=r.reject,t=ie(function(){var i=[],n=0,o=1;Q(e,!1,function(e){var r=n++,t=!1;i.push(void 0),o++,s.resolve(e).then(function(e){t||(t=!0,i[r]=e,--o||c(i))},u)}),--o||c(i)});return t.e&&u(t.v),r.promise},race:function(e){var r=this,t=pe(r),i=t.reject,n=ie(function(){Q(e,!1,function(e){r.resolve(e).then(t.resolve,i)})});return n.e&&i(n.v),t.promise}});var Ee=require("./_export"),Ie=require("./_array-includes")(!0);Ee(Ee.P,"Array",{includes:function(e){return Ie(this,e,1<arguments.length?arguments[1]:void 0)}}),require("./_add-to-unscopables")("includes");var je=require("./_export"),Ne=require("./_string-context"),xe="includes";je(je.P+je.F*require("./_fails-is-regexp")(xe),"String",{includes:function(e){return!!~Ne(this,e,xe).indexOf(e,1<arguments.length?arguments[1]:void 0)}});var Ae=["ACL","BIND","CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LINK","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCALENDAR","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REBIND","REPORT","SEARCH","SOURCE","SUBSCRIBE","TRACE","UNBIND","UNLINK","UNLOCK","UNSUBSCRIBE"];function Oe(e,r){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{allowedMethods:Ae};if(!r)throw new Error('The "'.concat(e,'" function requires a "Request" object as an argument. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest'));if("string"!=typeof r.uri)throw new Error('The "'.concat(e,'" Request object requires a valid uri. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest'));if(!t.allowedMethods.includes(r.method))throw new Error('The "'.concat(e,'" Request object requires a valid method. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest'))}e.createClient=function(i){if(!i)throw new Error("Missing required options");if(i.middlewares&&!Array.isArray(i.middlewares))throw new Error("Middlewares should be an array");if(!i.middlewares||!Array.isArray(i.middlewares)||!i.middlewares.length)throw new Error("You need to provide at least one middleware");return{execute:function(t){return Oe("exec",t),new Promise(function(e,r){(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];return 1===(r=r.filter(function(e){return"function"==typeof e})).length?r[0]:r.reduce(function(e,r){return function(){return e(r.apply(void 0,arguments))}})}).apply(void 0,_(i.middlewares))(function(e,r){if(r.error)r.reject(r.error);else{var t={body:r.body||{},statusCode:r.statusCode};r.headers&&(t.headers=r.headers),r.request&&(t.request=r.request),r.resolve(t)}})(t,{resolve:e,reject:r,body:void 0,error:void 0})})},process:function(p,v,e){var _=this;if(Oe("process",p,{allowedMethods:["GET"]}),"function"!=typeof v)throw new Error('The "process" function accepts a "Function" as a second argument that returns a Promise. See https://commercetools.github.io/nodejs/sdk/api/sdkClient.html#processrequest-processfn-options');var m=q({total:Number.POSITIVE_INFINITY,accumulate:!0},e);return new Promise(function(u,a){var e=g(p.uri.split("?"),2),l=e[0],r=e[1],f=q({limit:20},q({},y.parse(r))),d=!1,h=m.total;!function s(e){var c=1<arguments.length&&void 0!==arguments[1]?arguments[1]:[],r=f.limit<h?f.limit:h,t=y.stringify(q({},f,{limit:r})),i=q({sort:"id asc",withTotal:!1},e?{where:'id > "'.concat(e,'"')}:{}),n=y.stringify(i),o=q({},p,{uri:"".concat(l,"?").concat(n,"&").concat(t)});_.execute(o).then(function(e){var r=e.body,n=r.results,o=r.count;o||!d?Promise.resolve(v(e)).then(function(e){var r;if(d=!0,m.accumulate&&(r=c.concat(e||[])),h-=o,o<f.limit||!h)u(r||[]);else{var t=n[o-1],i=t&&t.id;s(i,r)}}).catch(a):u(c||[])}).catch(a)}()})}}},Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=commercetools-sdk-client.umd.min.js.map

@@ -7,3 +7,3 @@ {

"name": "@commercetools/sdk-client",
"version": "1.5.8",
"version": "1.5.9",
"description": "SDK Client for usage of commercetools platform API",

@@ -10,0 +10,0 @@ "keywords": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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