backendless 6.5.5 → 6.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * ********************************************************************************************************************
3
- * Backendless SDK for JavaScript. Version: 6.5.5
3
+ * Backendless SDK for JavaScript. Version: 6.5.6
4
4
  *
5
5
  * Copyright 2012-2022 BACKENDLESS.COM. All Rights Reserved.
6
6
  *
@@ -1051,41 +1051,34 @@ return /******/ (function(modules) { // webpackBootstrap
1051
1051
  /******/ __webpack_require__.p = "";
1052
1052
  /******/
1053
1053
  /******/ // Load entry module and return exports
1054
- /******/ return __webpack_require__(__webpack_require__.s = 2);
1054
+ /******/ return __webpack_require__(__webpack_require__.s = 3);
1055
1055
  /******/ })
1056
1056
  /************************************************************************/
1057
1057
  /******/ ([
1058
1058
  /* 0 */
1059
- /***/ (function(module, exports, __webpack_require__) {
1059
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
1060
1060
 
1061
1061
  "use strict";
1062
-
1063
-
1064
- Object.defineProperty(exports, "__esModule", {
1065
- value: true
1066
- });
1067
-
1068
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
1069
-
1062
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return castArray; });
1063
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return isObject; });
1064
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return isFormData; });
1065
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return isStream; });
1066
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
1070
1067
  /**
1071
1068
  * Casts `value` as an array if it's not one.
1072
1069
  * Equvivalent to lodash/castArray
1073
1070
  */
1074
- var castArray = exports.castArray = function castArray(value) {
1071
+ var castArray = function castArray(value) {
1075
1072
  return Array.isArray(value) ? value : [value];
1076
1073
  };
1077
-
1078
- var isObject = exports.isObject = function isObject(value) {
1079
- return null != value && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object';
1074
+ var isObject = function isObject(value) {
1075
+ return null != value && _typeof(value) === 'object';
1080
1076
  };
1081
-
1082
- var isFormData = exports.isFormData = function isFormData(value) {
1077
+ var isFormData = function isFormData(value) {
1083
1078
  return value && value.constructor && value.constructor.toString().trim().indexOf('function FormData') === 0;
1084
1079
  };
1085
-
1086
- var isStream = exports.isStream = function isStream(value) {
1087
- var stream = __webpack_require__(6);
1088
-
1080
+ var isStream = function isStream(value) {
1081
+ var stream = __webpack_require__(5);
1089
1082
  return value instanceof stream.Stream;
1090
1083
  };
1091
1084
 
@@ -1097,288 +1090,57 @@ throw new Error('This Backendless JS SDK assembly is not intended for Node.js en
1097
1090
 
1098
1091
  /***/ }),
1099
1092
  /* 2 */
1100
- /***/ (function(module, exports, __webpack_require__) {
1093
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
1101
1094
 
1102
1095
  "use strict";
1103
-
1104
-
1105
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
1106
-
1107
- var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
1108
-
1109
- var _cache = __webpack_require__(3);
1110
-
1111
- var _cache2 = _interopRequireDefault(_cache);
1112
-
1113
- var _eventEmitter = __webpack_require__(4);
1114
-
1115
- var _eventEmitter2 = _interopRequireDefault(_eventEmitter);
1116
-
1117
- var _qs = __webpack_require__(5);
1118
-
1119
- var qs = _interopRequireWildcard(_qs);
1120
-
1121
- var _utils = __webpack_require__(0);
1122
-
1123
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
1124
-
1125
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1126
-
1096
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Request; });
1097
+ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__cache__ = __webpack_require__(10);
1098
+ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__event_emitter__ = __webpack_require__(11);
1099
+ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__qs__ = __webpack_require__(12);
1100
+ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__utils__ = __webpack_require__(0);
1101
+ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__error__ = __webpack_require__(13);
1102
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
1103
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
1104
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
1105
+ 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; } return obj; }
1127
1106
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1107
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
1108
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
1109
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
1110
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
1111
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
1112
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
1113
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
1114
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
1115
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
1128
1116
 
1129
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
1130
-
1131
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
1132
-
1133
- var CONTENT_TYPE_HEADER = 'Content-Type';
1134
- var CACHE_FLUSH_INTERVAL = 60000; //60 sec
1135
-
1136
- var cache = new _cache2.default(CACHE_FLUSH_INTERVAL);
1137
-
1138
- var ResponseError = function (_Error) {
1139
- _inherits(ResponseError, _Error);
1140
-
1141
- function ResponseError(response) {
1142
- _classCallCheck(this, ResponseError);
1143
-
1144
- var _this = _possibleConstructorReturn(this, (ResponseError.__proto__ || Object.getPrototypeOf(ResponseError)).call(this));
1145
-
1146
- var error = parseError(response);
1147
-
1148
- _this.message = error.message || error;
1149
- _this.code = error.code;
1150
-
1151
- _this.status = response.status;
1152
- _this.headers = response.headers;
1153
- _this.body = response.body;
1154
- return _this;
1155
- }
1156
-
1157
- return ResponseError;
1158
- }(Error);
1159
-
1160
- function parseError(res) {
1161
- if (res.status === 502) {
1162
- return 'No connection with server';
1163
- }
1164
-
1165
- return res.body || 'Status Code ' + res.status + ' (' + res.statusText + ')';
1166
- }
1167
-
1168
- function parseBody(res) {
1169
- try {
1170
- return _extends({}, res, { body: JSON.parse(res.body) });
1171
- } catch (e) {
1172
- return res;
1173
- }
1174
- }
1175
-
1176
- function parseHeaders(headersString) {
1177
- var parsed = {};
1178
-
1179
- if (!headersString) {
1180
- return parsed;
1181
- }
1182
-
1183
- headersString.split('\n').forEach(function (line) {
1184
- var i = line.indexOf(':');
1185
- var key = line.substr(0, i).trim();
1186
- var val = line.substr(i + 1).trim();
1187
-
1188
- if (key) {
1189
- parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
1190
- }
1191
- });
1192
-
1193
- return parsed;
1194
- }
1195
-
1196
- var sendXmlHttpRequest = function sendXmlHttpRequest(path, method, headers, body, encoding, timeout) {
1197
- return new Promise(function sendRequest(resolve, reject) {
1198
- var request = new Request.XMLHttpRequest();
1199
-
1200
- request.timeout = timeout;
1201
-
1202
- if (!encoding) {
1203
- request.responseType = 'arraybuffer';
1204
- }
1205
-
1206
- request.open(method.toUpperCase(), path, true);
1207
-
1208
- request.onload = function handleLoadEvent() {
1209
- var headers = parseHeaders(request.getAllResponseHeaders());
1210
- var _request = request,
1211
- status = _request.status,
1212
- statusText = _request.statusText;
1213
-
1214
-
1215
- var result = { status: status, statusText: statusText, headers: headers };
1216
-
1217
- if (encoding === 'utf8') {
1218
- result.body = request.response || request.responseText;
1219
- } else if (request.response) {
1220
- result.body = new Uint8Array(request.response);
1221
- }
1222
-
1223
- resolve(result);
1224
-
1225
- request = null;
1226
- };
1227
-
1228
- request.onerror = function handleErrorEvent() {
1229
- reject(new Error('Network Error'));
1230
-
1231
- request = null;
1232
- };
1233
-
1234
- request.ontimeout = function handleTimeout() {
1235
- reject(new Error('Connection aborted due to timeout'));
1236
-
1237
- request = null;
1238
- };
1239
-
1240
- Object.keys(headers).forEach(function (key) {
1241
- request.setRequestHeader(key, headers[key]);
1242
- });
1243
-
1244
- request.send(body);
1245
- });
1246
- };
1247
-
1248
- var sendNodeAPIRequest = function sendNodeAPIRequest(path, method, headers, body, encoding, timeout) {
1249
- return new Promise(function (resolve, reject) {
1250
- var u = __webpack_require__(7).parse(path);
1251
- var form = (0, _utils.isFormData)(body) && body;
1252
-
1253
- var https = u.protocol === 'https:';
1254
- var options = {
1255
- host: u.hostname,
1256
- port: u.port || (https ? 443 : 80),
1257
- path: u.pathname + (u.search || ''),
1258
- method: method,
1259
- headers: headers,
1260
- timeout: timeout
1261
- };
1262
-
1263
- var _send = function _send() {
1264
- var Buffer = __webpack_require__(1).Buffer;
1265
- var httpClient = __webpack_require__(https ? 8 : 9);
1266
-
1267
- var req = httpClient.request(options, function (res) {
1268
- var strings = [];
1269
- var buffers = [];
1270
- var bufferLength = 0;
1271
- var body = '';
1272
-
1273
- var status = res.statusCode,
1274
- statusText = res.statusMessage,
1275
- headers = res.headers;
1276
-
1277
-
1278
- res.on('data', function (chunk) {
1279
- if (!Buffer.isBuffer(chunk)) {
1280
- strings.push(chunk);
1281
- } else if (chunk.length) {
1282
- bufferLength += chunk.length;
1283
- buffers.push(chunk);
1284
- }
1285
- });
1286
-
1287
- res.on('end', function () {
1288
- if (bufferLength) {
1289
- body = Buffer.concat(buffers, bufferLength);
1290
-
1291
- if (encoding != null) {
1292
- body = body.toString(encoding);
1293
- }
1294
- } else if (strings.length) {
1295
- body = strings.join();
1296
- }
1297
-
1298
- resolve({ status: status, statusText: statusText, headers: headers, body: body });
1299
- });
1300
-
1301
- res.on('error', reject);
1302
- });
1303
-
1304
- req.on('error', reject);
1305
1117
 
1306
- req.on('timeout', function () {
1307
- req.destroy(new Error('Connection aborted due to timeout'));
1308
- });
1309
1118
 
1310
- if (body) {
1311
- if ((0, _utils.isStream)(body)) {
1312
- body.pipe(req);
1313
- return;
1314
- }
1315
1119
 
1316
- req.write(body);
1317
- }
1318
-
1319
- req.end();
1320
- };
1321
-
1322
- if (form) {
1323
- _extends(options.headers, form.getHeaders());
1324
-
1325
- form.getLength(function (err, length) {
1326
- if (!err && !isNaN(length)) {
1327
- options.headers['content-length'] = length;
1328
- }
1329
-
1330
- _send();
1331
- });
1332
- } else {
1333
- if (body && !options.headers['content-length']) {
1334
- var Buffer = __webpack_require__(1).Buffer;
1335
- options.headers['content-length'] = Buffer.byteLength(body);
1336
- }
1337
-
1338
- _send();
1339
- }
1340
- });
1341
- };
1342
-
1343
- /**
1344
- * Checks if a network request came back fine, and throws an error if not
1345
- *
1346
- * @param {object} response A response from a network request
1347
- *
1348
- * @return {object|undefined} Returns either the response, or throws an error
1349
- */
1350
- function checkStatus(response) {
1351
- if (response.status >= 200 && response.status < 300) {
1352
- return response;
1353
- }
1354
-
1355
- throw new ResponseError(response);
1356
- }
1357
1120
 
1121
+ var CONTENT_TYPE_HEADER = 'Content-Type';
1358
1122
  var REQUEST_EVENT = 'request';
1359
1123
  var RESPONSE_EVENT = 'response';
1360
1124
  var ERROR_EVENT = 'error';
1361
1125
  var DONE_EVENT = 'done';
1362
-
1363
- var Request = function (_EventEmitter) {
1126
+ var Request = /*#__PURE__*/function (_EventEmitter) {
1364
1127
  _inherits(Request, _EventEmitter);
1365
-
1128
+ var _super = _createSuper(Request);
1366
1129
  function Request(path, method, body) {
1130
+ var _this;
1367
1131
  _classCallCheck(this, Request);
1368
-
1369
- var _this2 = _possibleConstructorReturn(this, (Request.__proto__ || Object.getPrototypeOf(Request)).call(this));
1370
-
1371
- _this2.method = method;
1372
- _this2.path = path;
1373
- _this2.body = body;
1374
- _this2.tags = undefined;
1375
- _this2.unwrap = true;
1376
- _this2.cacheTTL = 0;
1377
- _this2.headers = {};
1378
- _this2.queryParams = {};
1379
- _this2.encoding = 'utf8';
1380
- _this2.timeout = 0;
1381
- return _this2;
1132
+ _this = _super.call(this);
1133
+ _this.method = method;
1134
+ _this.path = path;
1135
+ _this.body = body;
1136
+ _this.tags = undefined;
1137
+ _this.unwrap = true;
1138
+ _this.cacheTTL = 0;
1139
+ _this.headers = {};
1140
+ _this.queryParams = {};
1141
+ _this.encoding = 'utf8';
1142
+ _this.timeout = 0;
1143
+ return _this;
1382
1144
  }
1383
1145
 
1384
1146
  /**
@@ -1388,19 +1150,16 @@ var Request = function (_EventEmitter) {
1388
1150
  * @param {String} [value]
1389
1151
  * @returns {Request}
1390
1152
  */
1391
-
1392
-
1393
1153
  _createClass(Request, [{
1394
- key: 'set',
1154
+ key: "set",
1395
1155
  value: function set(key, value) {
1396
- if ((0, _utils.isObject)(key)) {
1156
+ if (Object(__WEBPACK_IMPORTED_MODULE_3__utils__["c" /* isObject */])(key)) {
1397
1157
  for (var headerName in key) {
1398
1158
  this.set(headerName, key[headerName]);
1399
1159
  }
1400
1160
  } else if (typeof value !== 'undefined') {
1401
1161
  this.headers[key] = value;
1402
1162
  }
1403
-
1404
1163
  return this;
1405
1164
  }
1406
1165
 
@@ -1412,16 +1171,13 @@ var Request = function (_EventEmitter) {
1412
1171
  * @param {Array.<String>} tags
1413
1172
  * @returns {Request}
1414
1173
  */
1415
-
1416
1174
  }, {
1417
- key: 'cacheTags',
1175
+ key: "cacheTags",
1418
1176
  value: function cacheTags() {
1419
- for (var _len = arguments.length, tags = Array(_len), _key = 0; _key < _len; _key++) {
1177
+ for (var _len = arguments.length, tags = new Array(_len), _key = 0; _key < _len; _key++) {
1420
1178
  tags[_key] = arguments[_key];
1421
1179
  }
1422
-
1423
1180
  this.tags = tags;
1424
-
1425
1181
  return this;
1426
1182
  }
1427
1183
 
@@ -1429,31 +1185,26 @@ var Request = function (_EventEmitter) {
1429
1185
  * @param {Object} queryParams
1430
1186
  * @returns {Request}
1431
1187
  */
1432
-
1433
1188
  }, {
1434
- key: 'query',
1189
+ key: "query",
1435
1190
  value: function query(queryParams) {
1436
- _extends(this.queryParams, queryParams);
1437
-
1191
+ Object.assign(this.queryParams, queryParams);
1438
1192
  return this;
1439
1193
  }
1440
1194
  }, {
1441
- key: 'form',
1195
+ key: "form",
1442
1196
  value: function form(_form) {
1443
- var _this3 = this;
1444
-
1197
+ var _this2 = this;
1445
1198
  if (_form) {
1446
- var _FormData = module.exports.FormData;
1447
-
1448
- if (_form instanceof _FormData) {
1199
+ var FormData = Request.FormData;
1200
+ if (_form instanceof FormData) {
1449
1201
  this.body = _form;
1450
1202
  } else {
1451
1203
  (function () {
1452
- var formData = new _FormData();
1453
-
1204
+ var formData = new FormData();
1454
1205
  var _loop = function _loop(formKey) {
1455
1206
  if (formKey) {
1456
- (0, _utils.castArray)(_form[formKey]).forEach(function (formValue) {
1207
+ Object(__WEBPACK_IMPORTED_MODULE_3__utils__["a" /* castArray */])(_form[formKey]).forEach(function (formValue) {
1457
1208
  if (formValue && formValue.hasOwnProperty('value') && formValue.hasOwnProperty('options')) {
1458
1209
  formData.append(formKey, formValue.value, formValue.options);
1459
1210
  } else {
@@ -1462,16 +1213,13 @@ var Request = function (_EventEmitter) {
1462
1213
  });
1463
1214
  }
1464
1215
  };
1465
-
1466
1216
  for (var formKey in _form) {
1467
1217
  _loop(formKey);
1468
1218
  }
1469
-
1470
- _this3.body = formData;
1219
+ _this2.body = formData;
1471
1220
  })();
1472
1221
  }
1473
1222
  }
1474
-
1475
1223
  return this;
1476
1224
  }
1477
1225
 
@@ -1481,14 +1229,11 @@ var Request = function (_EventEmitter) {
1481
1229
  * @param {Number} ttl Time to live for cached response. 15 seconds by default
1482
1230
  * @returns {Request}
1483
1231
  */
1484
-
1485
1232
  }, {
1486
- key: 'useCache',
1233
+ key: "useCache",
1487
1234
  value: function useCache() {
1488
1235
  var ttl = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 15000;
1489
-
1490
1236
  this.cacheTTL = ttl;
1491
-
1492
1237
  return this;
1493
1238
  }
1494
1239
 
@@ -1498,14 +1243,12 @@ var Request = function (_EventEmitter) {
1498
1243
  * @param {Boolean} reset - flag to reset cache or not
1499
1244
  * @returns {Request}
1500
1245
  */
1501
-
1502
1246
  }, {
1503
- key: 'resetCache',
1247
+ key: "resetCache",
1504
1248
  value: function resetCache(reset) {
1505
1249
  if (reset && this.tags) {
1506
- cache.deleteByTags(this.tags);
1250
+ __WEBPACK_IMPORTED_MODULE_0__cache__["a" /* cache */].deleteByTags(this.tags);
1507
1251
  }
1508
-
1509
1252
  return this;
1510
1253
  }
1511
1254
 
@@ -1515,12 +1258,10 @@ var Request = function (_EventEmitter) {
1515
1258
  * @param {String} contentType
1516
1259
  * @returns {Request}
1517
1260
  */
1518
-
1519
1261
  }, {
1520
- key: 'type',
1262
+ key: "type",
1521
1263
  value: function type(contentType) {
1522
1264
  this.set(CONTENT_TYPE_HEADER, contentType);
1523
-
1524
1265
  return this;
1525
1266
  }
1526
1267
 
@@ -1529,12 +1270,10 @@ var Request = function (_EventEmitter) {
1529
1270
  * @param {Boolean} unwrap
1530
1271
  * @returns {Request}
1531
1272
  */
1532
-
1533
1273
  }, {
1534
- key: 'unwrapBody',
1274
+ key: "unwrapBody",
1535
1275
  value: function unwrapBody(unwrap) {
1536
1276
  this.unwrap = unwrap;
1537
-
1538
1277
  return this;
1539
1278
  }
1540
1279
 
@@ -1545,12 +1284,10 @@ var Request = function (_EventEmitter) {
1545
1284
  * @param {String} encoding
1546
1285
  * @returns {Request}
1547
1286
  */
1548
-
1549
1287
  }, {
1550
- key: 'setEncoding',
1288
+ key: "setEncoding",
1551
1289
  value: function setEncoding(encoding) {
1552
1290
  this.encoding = encoding;
1553
-
1554
1291
  return this;
1555
1292
  }
1556
1293
 
@@ -1559,12 +1296,10 @@ var Request = function (_EventEmitter) {
1559
1296
  * @param {Number} ms
1560
1297
  * @returns {Request}
1561
1298
  */
1562
-
1563
1299
  }, {
1564
- key: 'setTimeout',
1300
+ key: "setTimeout",
1565
1301
  value: function setTimeout(ms) {
1566
1302
  this.timeout = ms;
1567
-
1568
1303
  return this;
1569
1304
  }
1570
1305
 
@@ -1574,53 +1309,41 @@ var Request = function (_EventEmitter) {
1574
1309
  * @param {Object} body
1575
1310
  * @returns {Promise}
1576
1311
  */
1577
-
1578
1312
  }, {
1579
- key: 'send',
1313
+ key: "send",
1580
1314
  value: function send(body) {
1581
- var _this4 = this;
1582
-
1315
+ var _this3 = this;
1583
1316
  this.emit(REQUEST_EVENT, this);
1584
-
1585
1317
  var path = this.path;
1586
- var queryString = qs.stringify(this.queryParams);
1587
-
1318
+ var queryString = __WEBPACK_IMPORTED_MODULE_2__qs__["a" /* stringify */](this.queryParams);
1588
1319
  if (queryString) {
1589
1320
  path += '?' + queryString;
1590
1321
  }
1591
-
1592
1322
  if (this.cacheTTL) {
1593
- var cached = cache.get(path);
1594
-
1323
+ var cached = __WEBPACK_IMPORTED_MODULE_0__cache__["a" /* cache */].get(path);
1595
1324
  if (cached !== undefined) {
1596
1325
  return Promise.resolve(cached);
1597
1326
  }
1598
1327
  }
1599
-
1600
1328
  var type = this.headers[CONTENT_TYPE_HEADER];
1601
-
1602
- if (!type && (0, _utils.isObject)(body) && !(0, _utils.isFormData)(body)) {
1329
+ if (!type && Object(__WEBPACK_IMPORTED_MODULE_3__utils__["c" /* isObject */])(body) && !Object(__WEBPACK_IMPORTED_MODULE_3__utils__["b" /* isFormData */])(body)) {
1603
1330
  this.type('application/json');
1604
1331
  }
1605
-
1606
1332
  if (body) {
1607
1333
  var isJSON = this.headers[CONTENT_TYPE_HEADER] === 'application/json';
1608
-
1609
1334
  body = isJSON && typeof body !== 'string' ? JSON.stringify(body) : body;
1610
1335
  }
1611
-
1612
1336
  var unwrapBody = function unwrapBody(res) {
1613
- return _this4.unwrap ? res.body : res;
1337
+ return _this3.unwrap ? res.body : res;
1614
1338
  };
1615
1339
 
1616
1340
  /**
1617
1341
  * Caches the response if required
1618
1342
  */
1619
1343
  var cacheResponse = function cacheResponse(res) {
1620
- if (_this4.cacheTTL) {
1621
- cache.set(path, res, _this4.tags, _this4.cacheTTL);
1344
+ if (_this3.cacheTTL) {
1345
+ __WEBPACK_IMPORTED_MODULE_0__cache__["a" /* cache */].set(path, res, _this3.tags, _this3.cacheTTL);
1622
1346
  }
1623
-
1624
1347
  return res;
1625
1348
  };
1626
1349
 
@@ -1628,27 +1351,22 @@ var Request = function (_EventEmitter) {
1628
1351
  * Deletes all relevant to req.cacheTags keys from the cache if this request method is not GET
1629
1352
  */
1630
1353
  var flushCache = function flushCache(res) {
1631
- if (_this4.tags && _this4.method !== 'get') {
1632
- cache.deleteByTags(_this4.tags);
1354
+ if (_this3.tags && _this3.method !== 'get') {
1355
+ __WEBPACK_IMPORTED_MODULE_0__cache__["a" /* cache */].deleteByTags(_this3.tags);
1633
1356
  }
1634
-
1635
1357
  return res;
1636
1358
  };
1637
-
1638
1359
  if (Request.verbose) {
1639
1360
  console.log(this.method.toUpperCase(), decodeURIComponent(path), body, this.headers);
1640
1361
  }
1641
-
1642
1362
  var request = Request.send(path, this.method.toUpperCase(), this.headers, body, this.encoding, this.timeout).then(parseBody).then(checkStatus).then(unwrapBody).then(cacheResponse).then(flushCache);
1643
-
1644
1363
  request.then(function (result) {
1645
- _this4.emit(RESPONSE_EVENT, result);
1646
- _this4.emit(DONE_EVENT, null, result);
1647
- }).catch(function (error) {
1648
- _this4.emit(ERROR_EVENT, error);
1649
- _this4.emit(DONE_EVENT, error);
1364
+ _this3.emit(RESPONSE_EVENT, result);
1365
+ _this3.emit(DONE_EVENT, null, result);
1366
+ })["catch"](function (error) {
1367
+ _this3.emit(ERROR_EVENT, error);
1368
+ _this3.emit(DONE_EVENT, error);
1650
1369
  });
1651
-
1652
1370
  return request;
1653
1371
  }
1654
1372
 
@@ -1659,12 +1377,10 @@ var Request = function (_EventEmitter) {
1659
1377
  * @param {Function} errorHandler
1660
1378
  * @returns {Promise}
1661
1379
  */
1662
-
1663
1380
  }, {
1664
- key: 'then',
1381
+ key: "then",
1665
1382
  value: function then(successHandler, errorHandler) {
1666
1383
  this.promise = this.promise || this.send(this.body);
1667
-
1668
1384
  return this.promise.then(successHandler, errorHandler);
1669
1385
  }
1670
1386
 
@@ -1672,63 +1388,263 @@ var Request = function (_EventEmitter) {
1672
1388
  * @param {Function} errorHandler
1673
1389
  * @returns {Promise}
1674
1390
  */
1675
-
1676
1391
  }, {
1677
- key: 'catch',
1392
+ key: "catch",
1678
1393
  value: function _catch(errorHandler) {
1679
1394
  this.promise = this.promise || this.send(this.body);
1680
-
1681
- return this.promise.catch(errorHandler);
1395
+ return this.promise["catch"](errorHandler);
1682
1396
  }
1683
1397
  }]);
1684
-
1685
1398
  return Request;
1686
- }(_eventEmitter2.default);
1399
+ }(__WEBPACK_IMPORTED_MODULE_1__event_emitter__["a" /* default */]);
1400
+ function parseBody(res) {
1401
+ try {
1402
+ return _objectSpread(_objectSpread({}, res), {}, {
1403
+ body: JSON.parse(res.body)
1404
+ });
1405
+ } catch (e) {
1406
+ return res;
1407
+ }
1408
+ }
1687
1409
 
1688
- Object.defineProperty(Request, 'FormData', {
1689
- get: function get() {
1690
- return typeof FormData !== 'undefined' ? FormData : __webpack_require__(10);
1410
+ /**
1411
+ * Checks if a network request came back fine, and throws an error if not
1412
+ *
1413
+ * @param {object} response A response from a network request
1414
+ *
1415
+ * @return {object|undefined} Returns either the response, or throws an error
1416
+ */
1417
+ function checkStatus(response) {
1418
+ if (response.status >= 200 && response.status < 300) {
1419
+ return response;
1691
1420
  }
1692
- });
1421
+ throw new __WEBPACK_IMPORTED_MODULE_4__error__["a" /* ResponseError */](response);
1422
+ }
1693
1423
 
1694
- Request.XMLHttpRequest = typeof XMLHttpRequest !== 'undefined' ? XMLHttpRequest : undefined;
1424
+ /***/ }),
1425
+ /* 3 */
1426
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
1427
+
1428
+ "use strict";
1429
+ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
1430
+ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__client_node__ = __webpack_require__(4);
1431
+ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__client_browser__ = __webpack_require__(9);
1432
+ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__request__ = __webpack_require__(2);
1695
1433
 
1696
- Request.send = function (path, method, headers, body, encoding, timeout) {
1697
- var sender = typeof Request.XMLHttpRequest !== 'undefined' ? sendXmlHttpRequest : sendNodeAPIRequest;
1698
1434
 
1435
+
1436
+ Object.defineProperty(__WEBPACK_IMPORTED_MODULE_2__request__["a" /* Request */], 'FormData', {
1437
+ get: function get() {
1438
+ return typeof FormData !== 'undefined' ? FormData : __webpack_require__(14);
1439
+ }
1440
+ });
1441
+ __WEBPACK_IMPORTED_MODULE_2__request__["a" /* Request */].XMLHttpRequest = typeof XMLHttpRequest !== 'undefined' ? XMLHttpRequest : undefined;
1442
+ __WEBPACK_IMPORTED_MODULE_2__request__["a" /* Request */].send = function (path, method, headers, body, encoding, timeout) {
1443
+ var sender = typeof __WEBPACK_IMPORTED_MODULE_2__request__["a" /* Request */].XMLHttpRequest !== 'undefined' ? __WEBPACK_IMPORTED_MODULE_1__client_browser__["a" /* sendXmlHttpRequest */] : __WEBPACK_IMPORTED_MODULE_0__client_node__["a" /* sendNodeAPIRequest */];
1699
1444
  return sender(path, method, headers, body, encoding, timeout);
1700
1445
  };
1446
+ __WEBPACK_IMPORTED_MODULE_2__request__["a" /* Request */].verbose = false;
1447
+ __WEBPACK_IMPORTED_MODULE_2__request__["a" /* Request */].methods = ['get', 'post', 'put', 'patch', 'delete'];
1448
+ __WEBPACK_IMPORTED_MODULE_2__request__["a" /* Request */].methods.forEach(function (method) {
1449
+ __WEBPACK_IMPORTED_MODULE_2__request__["a" /* Request */][method] = function (path, body) {
1450
+ return new __WEBPACK_IMPORTED_MODULE_2__request__["a" /* Request */](path, method, body);
1451
+ };
1452
+ });
1453
+ /* harmony default export */ __webpack_exports__["default"] = (__WEBPACK_IMPORTED_MODULE_2__request__["a" /* Request */]);
1701
1454
 
1702
- Request.verbose = false;
1703
- Request.methods = ['get', 'post', 'put', 'patch', 'delete'];
1455
+ /***/ }),
1456
+ /* 4 */
1457
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
1458
+
1459
+ "use strict";
1460
+ /* harmony export (immutable) */ __webpack_exports__["a"] = sendNodeAPIRequest;
1461
+ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__utils__ = __webpack_require__(0);
1462
+
1463
+ function sendNodeAPIRequest(path, method, headers, body, encoding, timeout) {
1464
+ return new Promise(function (resolve, reject) {
1465
+ var u = __webpack_require__(6).parse(path);
1466
+ var form = Object(__WEBPACK_IMPORTED_MODULE_0__utils__["b" /* isFormData */])(body) && body;
1467
+ var https = u.protocol === 'https:';
1468
+ var options = {
1469
+ host: u.hostname,
1470
+ port: u.port || (https ? 443 : 80),
1471
+ path: u.pathname + (u.search || ''),
1472
+ method: method,
1473
+ headers: headers,
1474
+ timeout: timeout
1475
+ };
1476
+ var _send = function _send() {
1477
+ var Buffer = __webpack_require__(1).Buffer;
1478
+ var httpClient = __webpack_require__(https ? 7 : 8);
1479
+ var req = httpClient.request(options, function (res) {
1480
+ var strings = [];
1481
+ var buffers = [];
1482
+ var bufferLength = 0;
1483
+ var body = '';
1484
+ var status = res.statusCode,
1485
+ statusText = res.statusMessage,
1486
+ headers = res.headers;
1487
+ res.on('data', function (chunk) {
1488
+ if (!Buffer.isBuffer(chunk)) {
1489
+ strings.push(chunk);
1490
+ } else if (chunk.length) {
1491
+ bufferLength += chunk.length;
1492
+ buffers.push(chunk);
1493
+ }
1494
+ });
1495
+ res.on('end', function () {
1496
+ if (bufferLength) {
1497
+ body = Buffer.concat(buffers, bufferLength);
1498
+ if (encoding != null) {
1499
+ body = body.toString(encoding);
1500
+ }
1501
+ } else if (strings.length) {
1502
+ body = strings.join();
1503
+ }
1504
+ resolve({
1505
+ status: status,
1506
+ statusText: statusText,
1507
+ headers: headers,
1508
+ body: body
1509
+ });
1510
+ });
1511
+ res.on('error', reject);
1512
+ });
1513
+ req.on('error', reject);
1514
+ req.on('timeout', function () {
1515
+ req.destroy(new Error('Connection aborted due to timeout'));
1516
+ });
1517
+ if (body) {
1518
+ if (Object(__WEBPACK_IMPORTED_MODULE_0__utils__["d" /* isStream */])(body)) {
1519
+ body.pipe(req);
1520
+ return;
1521
+ }
1522
+ req.write(body);
1523
+ }
1524
+ req.end();
1525
+ };
1526
+ if (form) {
1527
+ Object.assign(options.headers, form.getHeaders());
1528
+ form.getLength(function (err, length) {
1529
+ if (!err && !isNaN(length)) {
1530
+ options.headers['content-length'] = length;
1531
+ }
1532
+ _send();
1533
+ });
1534
+ } else {
1535
+ if (body && !options.headers['content-length']) {
1536
+ var Buffer = __webpack_require__(1).Buffer;
1537
+ options.headers['content-length'] = Buffer.byteLength(body);
1538
+ }
1539
+ _send();
1540
+ }
1541
+ });
1542
+ }
1543
+
1544
+ /***/ }),
1545
+ /* 5 */
1546
+ /***/ (function(module, exports) {
1547
+
1548
+ throw new Error('This Backendless JS SDK assembly is not intended for Node.js environment. You should use "lib" folder modules instead. For any questions please contact as at http://support.backendless.com/')
1704
1549
 
1705
- Request.methods.forEach(function (method) {
1706
- Request[method] = function (path, body) {
1707
- return new Request(path, method, body);
1708
- };
1709
- });
1550
+ /***/ }),
1551
+ /* 6 */
1552
+ /***/ (function(module, exports) {
1710
1553
 
1711
- module.exports = Request;
1554
+ throw new Error('This Backendless JS SDK assembly is not intended for Node.js environment. You should use "lib" folder modules instead. For any questions please contact as at http://support.backendless.com/')
1712
1555
 
1713
1556
  /***/ }),
1714
- /* 3 */
1715
- /***/ (function(module, exports, __webpack_require__) {
1557
+ /* 7 */
1558
+ /***/ (function(module, exports) {
1716
1559
 
1717
- "use strict";
1560
+ throw new Error('This Backendless JS SDK assembly is not intended for Node.js environment. You should use "lib" folder modules instead. For any questions please contact as at http://support.backendless.com/')
1718
1561
 
1562
+ /***/ }),
1563
+ /* 8 */
1564
+ /***/ (function(module, exports) {
1719
1565
 
1720
- Object.defineProperty(exports, "__esModule", {
1721
- value: true
1722
- });
1566
+ throw new Error('This Backendless JS SDK assembly is not intended for Node.js environment. You should use "lib" folder modules instead. For any questions please contact as at http://support.backendless.com/')
1723
1567
 
1724
- var _slicedToArray = function () { function sliceIterator(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"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } 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"); } }; }();
1568
+ /***/ }),
1569
+ /* 9 */
1570
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
1725
1571
 
1726
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
1572
+ "use strict";
1573
+ /* harmony export (immutable) */ __webpack_exports__["a"] = sendXmlHttpRequest;
1574
+ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__request__ = __webpack_require__(2);
1727
1575
 
1728
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1576
+ function sendXmlHttpRequest(path, method, headers, body, encoding, timeout) {
1577
+ return new Promise(function sendRequest(resolve, reject) {
1578
+ var request = new __WEBPACK_IMPORTED_MODULE_0__request__["a" /* Request */].XMLHttpRequest();
1579
+ request.timeout = timeout;
1580
+ if (!encoding) {
1581
+ request.responseType = 'arraybuffer';
1582
+ }
1583
+ request.open(method.toUpperCase(), path, true);
1584
+ request.onload = function handleLoadEvent() {
1585
+ var headers = parseHeaders(request.getAllResponseHeaders());
1586
+ var _request = request,
1587
+ status = _request.status,
1588
+ statusText = _request.statusText;
1589
+ var result = {
1590
+ status: status,
1591
+ statusText: statusText,
1592
+ headers: headers
1593
+ };
1594
+ if (encoding === 'utf8') {
1595
+ result.body = request.response || request.responseText;
1596
+ } else if (request.response) {
1597
+ result.body = new Uint8Array(request.response);
1598
+ }
1599
+ resolve(result);
1600
+ request = null;
1601
+ };
1602
+ request.onerror = function handleErrorEvent() {
1603
+ reject(new Error('Network Error'));
1604
+ request = null;
1605
+ };
1606
+ request.ontimeout = function handleTimeout() {
1607
+ reject(new Error('Connection aborted due to timeout'));
1608
+ request = null;
1609
+ };
1610
+ Object.keys(headers).forEach(function (key) {
1611
+ request.setRequestHeader(key, headers[key]);
1612
+ });
1613
+ request.send(body);
1614
+ });
1615
+ }
1616
+ function parseHeaders(headersString) {
1617
+ var parsed = {};
1618
+ if (!headersString) {
1619
+ return parsed;
1620
+ }
1621
+ headersString.split('\n').forEach(function (line) {
1622
+ var i = line.indexOf(':');
1623
+ var key = line.substr(0, i).trim();
1624
+ var val = line.substr(i + 1).trim();
1625
+ if (key) {
1626
+ parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
1627
+ }
1628
+ });
1629
+ return parsed;
1630
+ }
1729
1631
 
1730
- var DEFAULT_TTL = 30000; // 30 sec
1632
+ /***/ }),
1633
+ /* 10 */
1634
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
1731
1635
 
1636
+ "use strict";
1637
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return cache; });
1638
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
1639
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
1640
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_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; }
1641
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
1642
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
1643
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
1644
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
1645
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1646
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
1647
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
1732
1648
  /**
1733
1649
  * @typedef {Object} CacheItem
1734
1650
  * @property {*} value
@@ -1743,9 +1659,12 @@ var DEFAULT_TTL = 30000; // 30 sec
1743
1659
  * @returns {CacheItem}
1744
1660
  */
1745
1661
  var cacheItem = function cacheItem(value, tags, ttl) {
1746
- return { value: value, tags: tags, ttl: ttl };
1662
+ return {
1663
+ value: value,
1664
+ tags: tags,
1665
+ ttl: ttl
1666
+ };
1747
1667
  };
1748
-
1749
1668
  var currentTime = function currentTime() {
1750
1669
  return new Date().getTime();
1751
1670
  };
@@ -1765,11 +1684,9 @@ var tagsMatches = function tagsMatches(a, b) {
1765
1684
  if (!result && a instanceof RegExp) {
1766
1685
  result = a.test(b);
1767
1686
  }
1768
-
1769
1687
  if (!result && b instanceof RegExp) {
1770
1688
  result = b.test(a);
1771
1689
  }
1772
-
1773
1690
  return result;
1774
1691
  };
1775
1692
 
@@ -1793,39 +1710,42 @@ var tagsContainMatches = function tagsContainMatches(a, b) {
1793
1710
  * Makes it possible to assign multiple tags for a key and delete keys by tags
1794
1711
  * Optionally it starts flushing timer which cleans all outdated keys
1795
1712
  */
1796
-
1797
- var Cache = function () {
1798
-
1713
+ var Cache = /*#__PURE__*/function () {
1799
1714
  /**
1800
1715
  * @param {Number?} flushInterval
1801
1716
  */
1802
1717
  function Cache(flushInterval) {
1803
1718
  _classCallCheck(this, Cache);
1804
-
1805
- this.flushInterval = flushInterval;
1719
+ this.setFlushInterval(flushInterval);
1806
1720
 
1807
1721
  /**
1808
1722
  * @type {Map.<String, CacheItem>}
1809
1723
  */
1810
1724
  this.map = new Map();
1811
1725
  }
1812
-
1813
- /**
1814
- * @param {String} key
1815
- * @returns {*}
1816
- */
1817
-
1818
-
1819
1726
  _createClass(Cache, [{
1727
+ key: "setFlushInterval",
1728
+ value: function setFlushInterval(flushInterval) {
1729
+ this.flushInterval = flushInterval;
1730
+ if (this.flushTimer) {
1731
+ clearInterval(this.flushTimer);
1732
+ delete this.flushTimer;
1733
+ }
1734
+ }
1735
+
1736
+ /**
1737
+ * @param {String} key
1738
+ * @returns {*}
1739
+ */
1740
+ }, {
1820
1741
  key: "get",
1821
1742
  value: function get(key) {
1822
1743
  var cacheItem = this.map.get(key);
1823
-
1824
1744
  if (cacheItem) {
1825
1745
  if (cacheItem.ttl > currentTime()) {
1826
1746
  return cacheItem.value;
1827
1747
  } else {
1828
- this.map.delete(key);
1748
+ this.map["delete"](key);
1829
1749
  }
1830
1750
  }
1831
1751
  }
@@ -1836,17 +1756,12 @@ var Cache = function () {
1836
1756
  * @param {Array.<RegExp|String>=} tags
1837
1757
  * @param {Number=} ttl
1838
1758
  */
1839
-
1840
1759
  }, {
1841
1760
  key: "set",
1842
- value: function set(key, value, tags) {
1843
- var ttl = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : DEFAULT_TTL;
1844
-
1761
+ value: function set(key, value, tags, ttl) {
1845
1762
  this.map.set(key, cacheItem(value, tags, currentTime() + ttl));
1846
-
1847
1763
  if (this.flushInterval && !this.flushTimer) {
1848
1764
  this.flushTimer = setInterval(this.flush.bind(this), this.flushInterval);
1849
-
1850
1765
  if (this.flushTimer.unref) {
1851
1766
  this.flushTimer.unref();
1852
1767
  }
@@ -1856,123 +1771,103 @@ var Cache = function () {
1856
1771
  /**
1857
1772
  * @param {String} key
1858
1773
  */
1859
-
1860
1774
  }, {
1861
1775
  key: "delete",
1862
1776
  value: function _delete(key) {
1863
- this.map.delete(key);
1777
+ this.map["delete"](key);
1778
+ }
1779
+ }, {
1780
+ key: "deleteAll",
1781
+ value: function deleteAll() {
1782
+ var _iterator = _createForOfIteratorHelper(this.map),
1783
+ _step;
1784
+ try {
1785
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
1786
+ var _step$value = _slicedToArray(_step.value, 1),
1787
+ key = _step$value[0];
1788
+ this["delete"](key);
1789
+ }
1790
+ } catch (err) {
1791
+ _iterator.e(err);
1792
+ } finally {
1793
+ _iterator.f();
1794
+ }
1864
1795
  }
1865
1796
 
1866
1797
  /**
1867
1798
  * @param {Array.<String>} tags
1868
1799
  */
1869
-
1870
1800
  }, {
1871
1801
  key: "deleteByTags",
1872
1802
  value: function deleteByTags(tags) {
1873
- var _iteratorNormalCompletion = true;
1874
- var _didIteratorError = false;
1875
- var _iteratorError = undefined;
1876
-
1803
+ var _iterator2 = _createForOfIteratorHelper(this.map),
1804
+ _step2;
1877
1805
  try {
1878
- for (var _iterator = this.map[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
1879
- var _step$value = _slicedToArray(_step.value, 2),
1880
- key = _step$value[0],
1881
- value = _step$value[1];
1882
-
1806
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
1807
+ var _step2$value = _slicedToArray(_step2.value, 2),
1808
+ key = _step2$value[0],
1809
+ value = _step2$value[1];
1883
1810
  if (value.tags && tagsContainMatches(tags, value.tags)) {
1884
- this.delete(key);
1811
+ this["delete"](key);
1885
1812
  }
1886
1813
  }
1887
1814
  } catch (err) {
1888
- _didIteratorError = true;
1889
- _iteratorError = err;
1815
+ _iterator2.e(err);
1890
1816
  } finally {
1891
- try {
1892
- if (!_iteratorNormalCompletion && _iterator.return) {
1893
- _iterator.return();
1894
- }
1895
- } finally {
1896
- if (_didIteratorError) {
1897
- throw _iteratorError;
1898
- }
1899
- }
1817
+ _iterator2.f();
1900
1818
  }
1901
1819
  }
1902
1820
 
1903
1821
  /**
1904
1822
  * Deletes all outdated keys
1905
1823
  */
1906
-
1907
1824
  }, {
1908
1825
  key: "flush",
1909
1826
  value: function flush() {
1910
1827
  var now = currentTime();
1911
-
1912
- var _iteratorNormalCompletion2 = true;
1913
- var _didIteratorError2 = false;
1914
- var _iteratorError2 = undefined;
1915
-
1828
+ var _iterator3 = _createForOfIteratorHelper(this.map),
1829
+ _step3;
1916
1830
  try {
1917
- for (var _iterator2 = this.map[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
1918
- var _step2$value = _slicedToArray(_step2.value, 2),
1919
- key = _step2$value[0],
1920
- value = _step2$value[1];
1921
-
1831
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
1832
+ var _step3$value = _slicedToArray(_step3.value, 2),
1833
+ key = _step3$value[0],
1834
+ value = _step3$value[1];
1922
1835
  if (value.ttl < now) {
1923
- this.delete(key);
1836
+ this["delete"](key);
1924
1837
  }
1925
1838
  }
1926
1839
  } catch (err) {
1927
- _didIteratorError2 = true;
1928
- _iteratorError2 = err;
1840
+ _iterator3.e(err);
1929
1841
  } finally {
1930
- try {
1931
- if (!_iteratorNormalCompletion2 && _iterator2.return) {
1932
- _iterator2.return();
1933
- }
1934
- } finally {
1935
- if (_didIteratorError2) {
1936
- throw _iteratorError2;
1937
- }
1938
- }
1842
+ _iterator3.f();
1939
1843
  }
1940
1844
  }
1941
1845
  }]);
1942
-
1943
1846
  return Cache;
1944
1847
  }();
1848
+ var CACHE_FLUSH_INTERVAL = 60000; //60 sec
1945
1849
 
1946
- exports.default = Cache;
1850
+ var cache = new Cache(CACHE_FLUSH_INTERVAL);
1947
1851
 
1948
1852
  /***/ }),
1949
- /* 4 */
1950
- /***/ (function(module, exports, __webpack_require__) {
1853
+ /* 11 */
1854
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
1951
1855
 
1952
1856
  "use strict";
1953
-
1954
-
1955
- Object.defineProperty(exports, "__esModule", {
1956
- value: true
1957
- });
1958
-
1959
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
1960
-
1857
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return EventEmitter; });
1961
1858
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1962
-
1963
- var EventEmitter = function () {
1859
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
1860
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
1861
+ var EventEmitter = /*#__PURE__*/function () {
1964
1862
  function EventEmitter() {
1965
1863
  _classCallCheck(this, EventEmitter);
1966
-
1967
1864
  this.events = {};
1968
1865
  }
1969
-
1970
1866
  _createClass(EventEmitter, [{
1971
1867
  key: "on",
1972
1868
  value: function on(eventName, callback) {
1973
1869
  this.events[eventName] = this.events[eventName] || [];
1974
1870
  this.events[eventName].push(callback);
1975
-
1976
1871
  return this;
1977
1872
  }
1978
1873
  }, {
@@ -1989,90 +1884,98 @@ var EventEmitter = function () {
1989
1884
  delete this.events[eventName];
1990
1885
  }
1991
1886
  }
1992
-
1993
1887
  return this;
1994
1888
  }
1995
1889
  }, {
1996
1890
  key: "emit",
1997
1891
  value: function emit(eventName) {
1998
- for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1892
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1999
1893
  args[_key - 1] = arguments[_key];
2000
1894
  }
2001
-
2002
1895
  if (this.events[eventName]) {
2003
1896
  this.events[eventName].forEach(function (callback) {
2004
- return callback.apply(undefined, args);
1897
+ return callback.apply(void 0, args);
2005
1898
  });
2006
1899
  }
2007
1900
  }
2008
1901
  }]);
2009
-
2010
1902
  return EventEmitter;
2011
1903
  }();
2012
1904
 
2013
- exports.default = EventEmitter;
2014
1905
 
2015
1906
  /***/ }),
2016
- /* 5 */
2017
- /***/ (function(module, exports, __webpack_require__) {
1907
+ /* 12 */
1908
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
2018
1909
 
2019
1910
  "use strict";
1911
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return stringify; });
1912
+ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__utils__ = __webpack_require__(0);
2020
1913
 
2021
1914
 
2022
- Object.defineProperty(exports, "__esModule", {
2023
- value: true
2024
- });
2025
- exports.stringify = undefined;
2026
-
2027
- var _utils = __webpack_require__(0);
2028
-
2029
1915
  /**
2030
1916
  * Produces a URL query string from a given obj by iterating through the object's "own properties".
2031
1917
  * @param {Object} obj
2032
1918
  * @returns {string}
2033
1919
  */
2034
- var stringify = exports.stringify = function stringify(obj) {
1920
+ var stringify = function stringify(obj) {
2035
1921
  var tokens = [];
2036
-
2037
1922
  Object.keys(obj).forEach(function (key) {
2038
1923
  var value = obj[key];
2039
-
2040
1924
  if (value !== undefined) {
2041
- (0, _utils.castArray)(value).forEach(function (value) {
2042
- tokens.push(encodeURIComponent(key) + '=' + encodeURIComponent(value));
1925
+ Object(__WEBPACK_IMPORTED_MODULE_0__utils__["a" /* castArray */])(value).forEach(function (value) {
1926
+ tokens.push("".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(value)));
2043
1927
  });
2044
1928
  }
2045
1929
  });
2046
-
2047
1930
  return tokens.join('&');
2048
1931
  };
2049
1932
 
2050
1933
  /***/ }),
2051
- /* 6 */
2052
- /***/ (function(module, exports) {
2053
-
2054
- throw new Error('This Backendless JS SDK assembly is not intended for Node.js environment. You should use "lib" folder modules instead. For any questions please contact as at http://support.backendless.com/')
2055
-
2056
- /***/ }),
2057
- /* 7 */
2058
- /***/ (function(module, exports) {
2059
-
2060
- throw new Error('This Backendless JS SDK assembly is not intended for Node.js environment. You should use "lib" folder modules instead. For any questions please contact as at http://support.backendless.com/')
2061
-
2062
- /***/ }),
2063
- /* 8 */
2064
- /***/ (function(module, exports) {
2065
-
2066
- throw new Error('This Backendless JS SDK assembly is not intended for Node.js environment. You should use "lib" folder modules instead. For any questions please contact as at http://support.backendless.com/')
2067
-
2068
- /***/ }),
2069
- /* 9 */
2070
- /***/ (function(module, exports) {
1934
+ /* 13 */
1935
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
2071
1936
 
2072
- throw new Error('This Backendless JS SDK assembly is not intended for Node.js environment. You should use "lib" folder modules instead. For any questions please contact as at http://support.backendless.com/')
1937
+ "use strict";
1938
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return ResponseError; });
1939
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
1940
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
1941
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
1942
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1943
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
1944
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
1945
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
1946
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
1947
+ function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
1948
+ function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
1949
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
1950
+ function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
1951
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
1952
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
1953
+ var ResponseError = /*#__PURE__*/function (_Error) {
1954
+ _inherits(ResponseError, _Error);
1955
+ var _super = _createSuper(ResponseError);
1956
+ function ResponseError(response) {
1957
+ var _this;
1958
+ _classCallCheck(this, ResponseError);
1959
+ _this = _super.call(this);
1960
+ var error = parseError(response);
1961
+ _this.message = error.message || error;
1962
+ _this.code = error.code;
1963
+ _this.status = response.status;
1964
+ _this.headers = response.headers;
1965
+ _this.body = response.body;
1966
+ return _this;
1967
+ }
1968
+ return _createClass(ResponseError);
1969
+ }( /*#__PURE__*/_wrapNativeSuper(Error));
1970
+ function parseError(res) {
1971
+ if (res.status === 502) {
1972
+ return 'No connection with server';
1973
+ }
1974
+ return res.body || "Status Code ".concat(res.status, " (").concat(res.statusText, ")");
1975
+ }
2073
1976
 
2074
1977
  /***/ }),
2075
- /* 10 */
1978
+ /* 14 */
2076
1979
  /***/ (function(module, exports) {
2077
1980
 
2078
1981
  throw new Error('This Backendless JS SDK assembly is not intended for Node.js environment. You should use "lib" folder modules instead. For any questions please contact as at http://support.backendless.com/')