backendless 6.5.4 → 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.
- package/dist/backendless.js +436 -539
- package/dist/backendless.js.map +1 -1
- package/dist/backendless.min.js +2 -2
- package/es/urls.js +1 -1
- package/lib/urls.js +1 -1
- package/package.json +2 -2
- package/src/urls.js +1 -1
package/dist/backendless.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* ********************************************************************************************************************
|
|
3
|
-
* Backendless SDK for JavaScript. Version: 6.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 =
|
|
1054
|
+
/******/ return __webpack_require__(__webpack_require__.s = 3);
|
|
1055
1055
|
/******/ })
|
|
1056
1056
|
/************************************************************************/
|
|
1057
1057
|
/******/ ([
|
|
1058
1058
|
/* 0 */
|
|
1059
|
-
/***/ (function(module,
|
|
1059
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1060
1060
|
|
|
1061
1061
|
"use strict";
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
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 =
|
|
1071
|
+
var castArray = function castArray(value) {
|
|
1075
1072
|
return Array.isArray(value) ? value : [value];
|
|
1076
1073
|
};
|
|
1077
|
-
|
|
1078
|
-
|
|
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
|
|
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,294 +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,
|
|
1093
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1101
1094
|
|
|
1102
1095
|
"use strict";
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
var
|
|
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
|
-
function encodePathname(pathname) {
|
|
1249
|
-
return pathname.split('/').map(function (v) {
|
|
1250
|
-
return encodeURIComponent(decodeURIComponent(v));
|
|
1251
|
-
}).join('/');
|
|
1252
|
-
}
|
|
1253
|
-
|
|
1254
|
-
var sendNodeAPIRequest = function sendNodeAPIRequest(path, method, headers, body, encoding, timeout) {
|
|
1255
|
-
return new Promise(function (resolve, reject) {
|
|
1256
|
-
var u = __webpack_require__(7).parse(path);
|
|
1257
|
-
var form = (0, _utils.isFormData)(body) && body;
|
|
1258
|
-
|
|
1259
|
-
var https = u.protocol === 'https:';
|
|
1260
|
-
var options = {
|
|
1261
|
-
host: u.hostname,
|
|
1262
|
-
port: u.port || (https ? 443 : 80),
|
|
1263
|
-
path: encodePathname(u.pathname) + (u.search || ''),
|
|
1264
|
-
method: method,
|
|
1265
|
-
headers: headers,
|
|
1266
|
-
timeout: timeout
|
|
1267
|
-
};
|
|
1268
|
-
|
|
1269
|
-
var _send = function _send() {
|
|
1270
|
-
var Buffer = __webpack_require__(1).Buffer;
|
|
1271
|
-
var httpClient = __webpack_require__(https ? 8 : 9);
|
|
1272
|
-
|
|
1273
|
-
var req = httpClient.request(options, function (res) {
|
|
1274
|
-
var strings = [];
|
|
1275
|
-
var buffers = [];
|
|
1276
|
-
var bufferLength = 0;
|
|
1277
|
-
var body = '';
|
|
1278
|
-
|
|
1279
|
-
var status = res.statusCode,
|
|
1280
|
-
statusText = res.statusMessage,
|
|
1281
|
-
headers = res.headers;
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
res.on('data', function (chunk) {
|
|
1285
|
-
if (!Buffer.isBuffer(chunk)) {
|
|
1286
|
-
strings.push(chunk);
|
|
1287
|
-
} else if (chunk.length) {
|
|
1288
|
-
bufferLength += chunk.length;
|
|
1289
|
-
buffers.push(chunk);
|
|
1290
|
-
}
|
|
1291
|
-
});
|
|
1292
|
-
|
|
1293
|
-
res.on('end', function () {
|
|
1294
|
-
if (bufferLength) {
|
|
1295
|
-
body = Buffer.concat(buffers, bufferLength);
|
|
1296
|
-
|
|
1297
|
-
if (encoding != null) {
|
|
1298
|
-
body = body.toString(encoding);
|
|
1299
|
-
}
|
|
1300
|
-
} else if (strings.length) {
|
|
1301
|
-
body = strings.join();
|
|
1302
|
-
}
|
|
1303
|
-
|
|
1304
|
-
resolve({ status: status, statusText: statusText, headers: headers, body: body });
|
|
1305
|
-
});
|
|
1306
|
-
|
|
1307
|
-
res.on('error', reject);
|
|
1308
|
-
});
|
|
1309
|
-
|
|
1310
|
-
req.on('error', reject);
|
|
1311
1117
|
|
|
1312
|
-
req.on('timeout', function () {
|
|
1313
|
-
req.destroy(new Error('Connection aborted due to timeout'));
|
|
1314
|
-
});
|
|
1315
1118
|
|
|
1316
|
-
if (body) {
|
|
1317
|
-
if ((0, _utils.isStream)(body)) {
|
|
1318
|
-
body.pipe(req);
|
|
1319
|
-
return;
|
|
1320
|
-
}
|
|
1321
1119
|
|
|
1322
|
-
req.write(body);
|
|
1323
|
-
}
|
|
1324
|
-
|
|
1325
|
-
req.end();
|
|
1326
|
-
};
|
|
1327
|
-
|
|
1328
|
-
if (form) {
|
|
1329
|
-
_extends(options.headers, form.getHeaders());
|
|
1330
|
-
|
|
1331
|
-
form.getLength(function (err, length) {
|
|
1332
|
-
if (!err && !isNaN(length)) {
|
|
1333
|
-
options.headers['content-length'] = length;
|
|
1334
|
-
}
|
|
1335
|
-
|
|
1336
|
-
_send();
|
|
1337
|
-
});
|
|
1338
|
-
} else {
|
|
1339
|
-
if (body && !options.headers['content-length']) {
|
|
1340
|
-
var Buffer = __webpack_require__(1).Buffer;
|
|
1341
|
-
options.headers['content-length'] = Buffer.byteLength(body);
|
|
1342
|
-
}
|
|
1343
|
-
|
|
1344
|
-
_send();
|
|
1345
|
-
}
|
|
1346
|
-
});
|
|
1347
|
-
};
|
|
1348
|
-
|
|
1349
|
-
/**
|
|
1350
|
-
* Checks if a network request came back fine, and throws an error if not
|
|
1351
|
-
*
|
|
1352
|
-
* @param {object} response A response from a network request
|
|
1353
|
-
*
|
|
1354
|
-
* @return {object|undefined} Returns either the response, or throws an error
|
|
1355
|
-
*/
|
|
1356
|
-
function checkStatus(response) {
|
|
1357
|
-
if (response.status >= 200 && response.status < 300) {
|
|
1358
|
-
return response;
|
|
1359
|
-
}
|
|
1360
|
-
|
|
1361
|
-
throw new ResponseError(response);
|
|
1362
|
-
}
|
|
1363
1120
|
|
|
1121
|
+
var CONTENT_TYPE_HEADER = 'Content-Type';
|
|
1364
1122
|
var REQUEST_EVENT = 'request';
|
|
1365
1123
|
var RESPONSE_EVENT = 'response';
|
|
1366
1124
|
var ERROR_EVENT = 'error';
|
|
1367
1125
|
var DONE_EVENT = 'done';
|
|
1368
|
-
|
|
1369
|
-
var Request = function (_EventEmitter) {
|
|
1126
|
+
var Request = /*#__PURE__*/function (_EventEmitter) {
|
|
1370
1127
|
_inherits(Request, _EventEmitter);
|
|
1371
|
-
|
|
1128
|
+
var _super = _createSuper(Request);
|
|
1372
1129
|
function Request(path, method, body) {
|
|
1130
|
+
var _this;
|
|
1373
1131
|
_classCallCheck(this, Request);
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
_this2.timeout = 0;
|
|
1387
|
-
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;
|
|
1388
1144
|
}
|
|
1389
1145
|
|
|
1390
1146
|
/**
|
|
@@ -1394,19 +1150,16 @@ var Request = function (_EventEmitter) {
|
|
|
1394
1150
|
* @param {String} [value]
|
|
1395
1151
|
* @returns {Request}
|
|
1396
1152
|
*/
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
1153
|
_createClass(Request, [{
|
|
1400
|
-
key:
|
|
1154
|
+
key: "set",
|
|
1401
1155
|
value: function set(key, value) {
|
|
1402
|
-
if ((
|
|
1156
|
+
if (Object(__WEBPACK_IMPORTED_MODULE_3__utils__["c" /* isObject */])(key)) {
|
|
1403
1157
|
for (var headerName in key) {
|
|
1404
1158
|
this.set(headerName, key[headerName]);
|
|
1405
1159
|
}
|
|
1406
1160
|
} else if (typeof value !== 'undefined') {
|
|
1407
1161
|
this.headers[key] = value;
|
|
1408
1162
|
}
|
|
1409
|
-
|
|
1410
1163
|
return this;
|
|
1411
1164
|
}
|
|
1412
1165
|
|
|
@@ -1418,16 +1171,13 @@ var Request = function (_EventEmitter) {
|
|
|
1418
1171
|
* @param {Array.<String>} tags
|
|
1419
1172
|
* @returns {Request}
|
|
1420
1173
|
*/
|
|
1421
|
-
|
|
1422
1174
|
}, {
|
|
1423
|
-
key:
|
|
1175
|
+
key: "cacheTags",
|
|
1424
1176
|
value: function cacheTags() {
|
|
1425
|
-
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++) {
|
|
1426
1178
|
tags[_key] = arguments[_key];
|
|
1427
1179
|
}
|
|
1428
|
-
|
|
1429
1180
|
this.tags = tags;
|
|
1430
|
-
|
|
1431
1181
|
return this;
|
|
1432
1182
|
}
|
|
1433
1183
|
|
|
@@ -1435,31 +1185,26 @@ var Request = function (_EventEmitter) {
|
|
|
1435
1185
|
* @param {Object} queryParams
|
|
1436
1186
|
* @returns {Request}
|
|
1437
1187
|
*/
|
|
1438
|
-
|
|
1439
1188
|
}, {
|
|
1440
|
-
key:
|
|
1189
|
+
key: "query",
|
|
1441
1190
|
value: function query(queryParams) {
|
|
1442
|
-
|
|
1443
|
-
|
|
1191
|
+
Object.assign(this.queryParams, queryParams);
|
|
1444
1192
|
return this;
|
|
1445
1193
|
}
|
|
1446
1194
|
}, {
|
|
1447
|
-
key:
|
|
1195
|
+
key: "form",
|
|
1448
1196
|
value: function form(_form) {
|
|
1449
|
-
var
|
|
1450
|
-
|
|
1197
|
+
var _this2 = this;
|
|
1451
1198
|
if (_form) {
|
|
1452
|
-
var
|
|
1453
|
-
|
|
1454
|
-
if (_form instanceof _FormData) {
|
|
1199
|
+
var FormData = Request.FormData;
|
|
1200
|
+
if (_form instanceof FormData) {
|
|
1455
1201
|
this.body = _form;
|
|
1456
1202
|
} else {
|
|
1457
1203
|
(function () {
|
|
1458
|
-
var formData = new
|
|
1459
|
-
|
|
1204
|
+
var formData = new FormData();
|
|
1460
1205
|
var _loop = function _loop(formKey) {
|
|
1461
1206
|
if (formKey) {
|
|
1462
|
-
(
|
|
1207
|
+
Object(__WEBPACK_IMPORTED_MODULE_3__utils__["a" /* castArray */])(_form[formKey]).forEach(function (formValue) {
|
|
1463
1208
|
if (formValue && formValue.hasOwnProperty('value') && formValue.hasOwnProperty('options')) {
|
|
1464
1209
|
formData.append(formKey, formValue.value, formValue.options);
|
|
1465
1210
|
} else {
|
|
@@ -1468,16 +1213,13 @@ var Request = function (_EventEmitter) {
|
|
|
1468
1213
|
});
|
|
1469
1214
|
}
|
|
1470
1215
|
};
|
|
1471
|
-
|
|
1472
1216
|
for (var formKey in _form) {
|
|
1473
1217
|
_loop(formKey);
|
|
1474
1218
|
}
|
|
1475
|
-
|
|
1476
|
-
_this3.body = formData;
|
|
1219
|
+
_this2.body = formData;
|
|
1477
1220
|
})();
|
|
1478
1221
|
}
|
|
1479
1222
|
}
|
|
1480
|
-
|
|
1481
1223
|
return this;
|
|
1482
1224
|
}
|
|
1483
1225
|
|
|
@@ -1487,14 +1229,11 @@ var Request = function (_EventEmitter) {
|
|
|
1487
1229
|
* @param {Number} ttl Time to live for cached response. 15 seconds by default
|
|
1488
1230
|
* @returns {Request}
|
|
1489
1231
|
*/
|
|
1490
|
-
|
|
1491
1232
|
}, {
|
|
1492
|
-
key:
|
|
1233
|
+
key: "useCache",
|
|
1493
1234
|
value: function useCache() {
|
|
1494
1235
|
var ttl = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 15000;
|
|
1495
|
-
|
|
1496
1236
|
this.cacheTTL = ttl;
|
|
1497
|
-
|
|
1498
1237
|
return this;
|
|
1499
1238
|
}
|
|
1500
1239
|
|
|
@@ -1504,14 +1243,12 @@ var Request = function (_EventEmitter) {
|
|
|
1504
1243
|
* @param {Boolean} reset - flag to reset cache or not
|
|
1505
1244
|
* @returns {Request}
|
|
1506
1245
|
*/
|
|
1507
|
-
|
|
1508
1246
|
}, {
|
|
1509
|
-
key:
|
|
1247
|
+
key: "resetCache",
|
|
1510
1248
|
value: function resetCache(reset) {
|
|
1511
1249
|
if (reset && this.tags) {
|
|
1512
|
-
cache.deleteByTags(this.tags);
|
|
1250
|
+
__WEBPACK_IMPORTED_MODULE_0__cache__["a" /* cache */].deleteByTags(this.tags);
|
|
1513
1251
|
}
|
|
1514
|
-
|
|
1515
1252
|
return this;
|
|
1516
1253
|
}
|
|
1517
1254
|
|
|
@@ -1521,12 +1258,10 @@ var Request = function (_EventEmitter) {
|
|
|
1521
1258
|
* @param {String} contentType
|
|
1522
1259
|
* @returns {Request}
|
|
1523
1260
|
*/
|
|
1524
|
-
|
|
1525
1261
|
}, {
|
|
1526
|
-
key:
|
|
1262
|
+
key: "type",
|
|
1527
1263
|
value: function type(contentType) {
|
|
1528
1264
|
this.set(CONTENT_TYPE_HEADER, contentType);
|
|
1529
|
-
|
|
1530
1265
|
return this;
|
|
1531
1266
|
}
|
|
1532
1267
|
|
|
@@ -1535,12 +1270,10 @@ var Request = function (_EventEmitter) {
|
|
|
1535
1270
|
* @param {Boolean} unwrap
|
|
1536
1271
|
* @returns {Request}
|
|
1537
1272
|
*/
|
|
1538
|
-
|
|
1539
1273
|
}, {
|
|
1540
|
-
key:
|
|
1274
|
+
key: "unwrapBody",
|
|
1541
1275
|
value: function unwrapBody(unwrap) {
|
|
1542
1276
|
this.unwrap = unwrap;
|
|
1543
|
-
|
|
1544
1277
|
return this;
|
|
1545
1278
|
}
|
|
1546
1279
|
|
|
@@ -1551,12 +1284,10 @@ var Request = function (_EventEmitter) {
|
|
|
1551
1284
|
* @param {String} encoding
|
|
1552
1285
|
* @returns {Request}
|
|
1553
1286
|
*/
|
|
1554
|
-
|
|
1555
1287
|
}, {
|
|
1556
|
-
key:
|
|
1288
|
+
key: "setEncoding",
|
|
1557
1289
|
value: function setEncoding(encoding) {
|
|
1558
1290
|
this.encoding = encoding;
|
|
1559
|
-
|
|
1560
1291
|
return this;
|
|
1561
1292
|
}
|
|
1562
1293
|
|
|
@@ -1565,12 +1296,10 @@ var Request = function (_EventEmitter) {
|
|
|
1565
1296
|
* @param {Number} ms
|
|
1566
1297
|
* @returns {Request}
|
|
1567
1298
|
*/
|
|
1568
|
-
|
|
1569
1299
|
}, {
|
|
1570
|
-
key:
|
|
1300
|
+
key: "setTimeout",
|
|
1571
1301
|
value: function setTimeout(ms) {
|
|
1572
1302
|
this.timeout = ms;
|
|
1573
|
-
|
|
1574
1303
|
return this;
|
|
1575
1304
|
}
|
|
1576
1305
|
|
|
@@ -1580,53 +1309,41 @@ var Request = function (_EventEmitter) {
|
|
|
1580
1309
|
* @param {Object} body
|
|
1581
1310
|
* @returns {Promise}
|
|
1582
1311
|
*/
|
|
1583
|
-
|
|
1584
1312
|
}, {
|
|
1585
|
-
key:
|
|
1313
|
+
key: "send",
|
|
1586
1314
|
value: function send(body) {
|
|
1587
|
-
var
|
|
1588
|
-
|
|
1315
|
+
var _this3 = this;
|
|
1589
1316
|
this.emit(REQUEST_EVENT, this);
|
|
1590
|
-
|
|
1591
1317
|
var path = this.path;
|
|
1592
|
-
var queryString =
|
|
1593
|
-
|
|
1318
|
+
var queryString = __WEBPACK_IMPORTED_MODULE_2__qs__["a" /* stringify */](this.queryParams);
|
|
1594
1319
|
if (queryString) {
|
|
1595
1320
|
path += '?' + queryString;
|
|
1596
1321
|
}
|
|
1597
|
-
|
|
1598
1322
|
if (this.cacheTTL) {
|
|
1599
|
-
var cached = cache.get(path);
|
|
1600
|
-
|
|
1323
|
+
var cached = __WEBPACK_IMPORTED_MODULE_0__cache__["a" /* cache */].get(path);
|
|
1601
1324
|
if (cached !== undefined) {
|
|
1602
1325
|
return Promise.resolve(cached);
|
|
1603
1326
|
}
|
|
1604
1327
|
}
|
|
1605
|
-
|
|
1606
1328
|
var type = this.headers[CONTENT_TYPE_HEADER];
|
|
1607
|
-
|
|
1608
|
-
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)) {
|
|
1609
1330
|
this.type('application/json');
|
|
1610
1331
|
}
|
|
1611
|
-
|
|
1612
1332
|
if (body) {
|
|
1613
1333
|
var isJSON = this.headers[CONTENT_TYPE_HEADER] === 'application/json';
|
|
1614
|
-
|
|
1615
1334
|
body = isJSON && typeof body !== 'string' ? JSON.stringify(body) : body;
|
|
1616
1335
|
}
|
|
1617
|
-
|
|
1618
1336
|
var unwrapBody = function unwrapBody(res) {
|
|
1619
|
-
return
|
|
1337
|
+
return _this3.unwrap ? res.body : res;
|
|
1620
1338
|
};
|
|
1621
1339
|
|
|
1622
1340
|
/**
|
|
1623
1341
|
* Caches the response if required
|
|
1624
1342
|
*/
|
|
1625
1343
|
var cacheResponse = function cacheResponse(res) {
|
|
1626
|
-
if (
|
|
1627
|
-
cache.set(path, res,
|
|
1344
|
+
if (_this3.cacheTTL) {
|
|
1345
|
+
__WEBPACK_IMPORTED_MODULE_0__cache__["a" /* cache */].set(path, res, _this3.tags, _this3.cacheTTL);
|
|
1628
1346
|
}
|
|
1629
|
-
|
|
1630
1347
|
return res;
|
|
1631
1348
|
};
|
|
1632
1349
|
|
|
@@ -1634,27 +1351,22 @@ var Request = function (_EventEmitter) {
|
|
|
1634
1351
|
* Deletes all relevant to req.cacheTags keys from the cache if this request method is not GET
|
|
1635
1352
|
*/
|
|
1636
1353
|
var flushCache = function flushCache(res) {
|
|
1637
|
-
if (
|
|
1638
|
-
cache.deleteByTags(
|
|
1354
|
+
if (_this3.tags && _this3.method !== 'get') {
|
|
1355
|
+
__WEBPACK_IMPORTED_MODULE_0__cache__["a" /* cache */].deleteByTags(_this3.tags);
|
|
1639
1356
|
}
|
|
1640
|
-
|
|
1641
1357
|
return res;
|
|
1642
1358
|
};
|
|
1643
|
-
|
|
1644
1359
|
if (Request.verbose) {
|
|
1645
1360
|
console.log(this.method.toUpperCase(), decodeURIComponent(path), body, this.headers);
|
|
1646
1361
|
}
|
|
1647
|
-
|
|
1648
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);
|
|
1649
|
-
|
|
1650
1363
|
request.then(function (result) {
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
})
|
|
1654
|
-
|
|
1655
|
-
|
|
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);
|
|
1656
1369
|
});
|
|
1657
|
-
|
|
1658
1370
|
return request;
|
|
1659
1371
|
}
|
|
1660
1372
|
|
|
@@ -1665,12 +1377,10 @@ var Request = function (_EventEmitter) {
|
|
|
1665
1377
|
* @param {Function} errorHandler
|
|
1666
1378
|
* @returns {Promise}
|
|
1667
1379
|
*/
|
|
1668
|
-
|
|
1669
1380
|
}, {
|
|
1670
|
-
key:
|
|
1381
|
+
key: "then",
|
|
1671
1382
|
value: function then(successHandler, errorHandler) {
|
|
1672
1383
|
this.promise = this.promise || this.send(this.body);
|
|
1673
|
-
|
|
1674
1384
|
return this.promise.then(successHandler, errorHandler);
|
|
1675
1385
|
}
|
|
1676
1386
|
|
|
@@ -1678,63 +1388,263 @@ var Request = function (_EventEmitter) {
|
|
|
1678
1388
|
* @param {Function} errorHandler
|
|
1679
1389
|
* @returns {Promise}
|
|
1680
1390
|
*/
|
|
1681
|
-
|
|
1682
1391
|
}, {
|
|
1683
|
-
key:
|
|
1392
|
+
key: "catch",
|
|
1684
1393
|
value: function _catch(errorHandler) {
|
|
1685
1394
|
this.promise = this.promise || this.send(this.body);
|
|
1686
|
-
|
|
1687
|
-
return this.promise.catch(errorHandler);
|
|
1395
|
+
return this.promise["catch"](errorHandler);
|
|
1688
1396
|
}
|
|
1689
1397
|
}]);
|
|
1690
|
-
|
|
1691
1398
|
return Request;
|
|
1692
|
-
}(
|
|
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
|
+
}
|
|
1693
1409
|
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
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;
|
|
1697
1420
|
}
|
|
1698
|
-
|
|
1421
|
+
throw new __WEBPACK_IMPORTED_MODULE_4__error__["a" /* ResponseError */](response);
|
|
1422
|
+
}
|
|
1699
1423
|
|
|
1700
|
-
|
|
1424
|
+
/***/ }),
|
|
1425
|
+
/* 3 */
|
|
1426
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1701
1427
|
|
|
1702
|
-
|
|
1703
|
-
|
|
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);
|
|
1704
1433
|
|
|
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 */];
|
|
1705
1444
|
return sender(path, method, headers, body, encoding, timeout);
|
|
1706
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 */]);
|
|
1707
1454
|
|
|
1708
|
-
|
|
1709
|
-
|
|
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/')
|
|
1710
1549
|
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
};
|
|
1715
|
-
});
|
|
1550
|
+
/***/ }),
|
|
1551
|
+
/* 6 */
|
|
1552
|
+
/***/ (function(module, exports) {
|
|
1716
1553
|
|
|
1717
|
-
|
|
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/')
|
|
1718
1555
|
|
|
1719
1556
|
/***/ }),
|
|
1720
|
-
/*
|
|
1721
|
-
/***/ (function(module, exports
|
|
1557
|
+
/* 7 */
|
|
1558
|
+
/***/ (function(module, exports) {
|
|
1722
1559
|
|
|
1723
|
-
|
|
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/')
|
|
1724
1561
|
|
|
1562
|
+
/***/ }),
|
|
1563
|
+
/* 8 */
|
|
1564
|
+
/***/ (function(module, exports) {
|
|
1725
1565
|
|
|
1726
|
-
|
|
1727
|
-
value: true
|
|
1728
|
-
});
|
|
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/')
|
|
1729
1567
|
|
|
1730
|
-
|
|
1568
|
+
/***/ }),
|
|
1569
|
+
/* 9 */
|
|
1570
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1731
1571
|
|
|
1732
|
-
|
|
1572
|
+
"use strict";
|
|
1573
|
+
/* harmony export (immutable) */ __webpack_exports__["a"] = sendXmlHttpRequest;
|
|
1574
|
+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__request__ = __webpack_require__(2);
|
|
1733
1575
|
|
|
1734
|
-
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
|
+
}
|
|
1735
1631
|
|
|
1736
|
-
|
|
1632
|
+
/***/ }),
|
|
1633
|
+
/* 10 */
|
|
1634
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1737
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; }
|
|
1738
1648
|
/**
|
|
1739
1649
|
* @typedef {Object} CacheItem
|
|
1740
1650
|
* @property {*} value
|
|
@@ -1749,9 +1659,12 @@ var DEFAULT_TTL = 30000; // 30 sec
|
|
|
1749
1659
|
* @returns {CacheItem}
|
|
1750
1660
|
*/
|
|
1751
1661
|
var cacheItem = function cacheItem(value, tags, ttl) {
|
|
1752
|
-
return {
|
|
1662
|
+
return {
|
|
1663
|
+
value: value,
|
|
1664
|
+
tags: tags,
|
|
1665
|
+
ttl: ttl
|
|
1666
|
+
};
|
|
1753
1667
|
};
|
|
1754
|
-
|
|
1755
1668
|
var currentTime = function currentTime() {
|
|
1756
1669
|
return new Date().getTime();
|
|
1757
1670
|
};
|
|
@@ -1771,11 +1684,9 @@ var tagsMatches = function tagsMatches(a, b) {
|
|
|
1771
1684
|
if (!result && a instanceof RegExp) {
|
|
1772
1685
|
result = a.test(b);
|
|
1773
1686
|
}
|
|
1774
|
-
|
|
1775
1687
|
if (!result && b instanceof RegExp) {
|
|
1776
1688
|
result = b.test(a);
|
|
1777
1689
|
}
|
|
1778
|
-
|
|
1779
1690
|
return result;
|
|
1780
1691
|
};
|
|
1781
1692
|
|
|
@@ -1799,39 +1710,42 @@ var tagsContainMatches = function tagsContainMatches(a, b) {
|
|
|
1799
1710
|
* Makes it possible to assign multiple tags for a key and delete keys by tags
|
|
1800
1711
|
* Optionally it starts flushing timer which cleans all outdated keys
|
|
1801
1712
|
*/
|
|
1802
|
-
|
|
1803
|
-
var Cache = function () {
|
|
1804
|
-
|
|
1713
|
+
var Cache = /*#__PURE__*/function () {
|
|
1805
1714
|
/**
|
|
1806
1715
|
* @param {Number?} flushInterval
|
|
1807
1716
|
*/
|
|
1808
1717
|
function Cache(flushInterval) {
|
|
1809
1718
|
_classCallCheck(this, Cache);
|
|
1810
|
-
|
|
1811
|
-
this.flushInterval = flushInterval;
|
|
1719
|
+
this.setFlushInterval(flushInterval);
|
|
1812
1720
|
|
|
1813
1721
|
/**
|
|
1814
1722
|
* @type {Map.<String, CacheItem>}
|
|
1815
1723
|
*/
|
|
1816
1724
|
this.map = new Map();
|
|
1817
1725
|
}
|
|
1818
|
-
|
|
1819
|
-
/**
|
|
1820
|
-
* @param {String} key
|
|
1821
|
-
* @returns {*}
|
|
1822
|
-
*/
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
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
|
+
}, {
|
|
1826
1741
|
key: "get",
|
|
1827
1742
|
value: function get(key) {
|
|
1828
1743
|
var cacheItem = this.map.get(key);
|
|
1829
|
-
|
|
1830
1744
|
if (cacheItem) {
|
|
1831
1745
|
if (cacheItem.ttl > currentTime()) {
|
|
1832
1746
|
return cacheItem.value;
|
|
1833
1747
|
} else {
|
|
1834
|
-
this.map
|
|
1748
|
+
this.map["delete"](key);
|
|
1835
1749
|
}
|
|
1836
1750
|
}
|
|
1837
1751
|
}
|
|
@@ -1842,17 +1756,12 @@ var Cache = function () {
|
|
|
1842
1756
|
* @param {Array.<RegExp|String>=} tags
|
|
1843
1757
|
* @param {Number=} ttl
|
|
1844
1758
|
*/
|
|
1845
|
-
|
|
1846
1759
|
}, {
|
|
1847
1760
|
key: "set",
|
|
1848
|
-
value: function set(key, value, tags) {
|
|
1849
|
-
var ttl = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : DEFAULT_TTL;
|
|
1850
|
-
|
|
1761
|
+
value: function set(key, value, tags, ttl) {
|
|
1851
1762
|
this.map.set(key, cacheItem(value, tags, currentTime() + ttl));
|
|
1852
|
-
|
|
1853
1763
|
if (this.flushInterval && !this.flushTimer) {
|
|
1854
1764
|
this.flushTimer = setInterval(this.flush.bind(this), this.flushInterval);
|
|
1855
|
-
|
|
1856
1765
|
if (this.flushTimer.unref) {
|
|
1857
1766
|
this.flushTimer.unref();
|
|
1858
1767
|
}
|
|
@@ -1862,123 +1771,103 @@ var Cache = function () {
|
|
|
1862
1771
|
/**
|
|
1863
1772
|
* @param {String} key
|
|
1864
1773
|
*/
|
|
1865
|
-
|
|
1866
1774
|
}, {
|
|
1867
1775
|
key: "delete",
|
|
1868
1776
|
value: function _delete(key) {
|
|
1869
|
-
this.map
|
|
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
|
+
}
|
|
1870
1795
|
}
|
|
1871
1796
|
|
|
1872
1797
|
/**
|
|
1873
1798
|
* @param {Array.<String>} tags
|
|
1874
1799
|
*/
|
|
1875
|
-
|
|
1876
1800
|
}, {
|
|
1877
1801
|
key: "deleteByTags",
|
|
1878
1802
|
value: function deleteByTags(tags) {
|
|
1879
|
-
var
|
|
1880
|
-
|
|
1881
|
-
var _iteratorError = undefined;
|
|
1882
|
-
|
|
1803
|
+
var _iterator2 = _createForOfIteratorHelper(this.map),
|
|
1804
|
+
_step2;
|
|
1883
1805
|
try {
|
|
1884
|
-
for (
|
|
1885
|
-
var
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
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];
|
|
1889
1810
|
if (value.tags && tagsContainMatches(tags, value.tags)) {
|
|
1890
|
-
this
|
|
1811
|
+
this["delete"](key);
|
|
1891
1812
|
}
|
|
1892
1813
|
}
|
|
1893
1814
|
} catch (err) {
|
|
1894
|
-
|
|
1895
|
-
_iteratorError = err;
|
|
1815
|
+
_iterator2.e(err);
|
|
1896
1816
|
} finally {
|
|
1897
|
-
|
|
1898
|
-
if (!_iteratorNormalCompletion && _iterator.return) {
|
|
1899
|
-
_iterator.return();
|
|
1900
|
-
}
|
|
1901
|
-
} finally {
|
|
1902
|
-
if (_didIteratorError) {
|
|
1903
|
-
throw _iteratorError;
|
|
1904
|
-
}
|
|
1905
|
-
}
|
|
1817
|
+
_iterator2.f();
|
|
1906
1818
|
}
|
|
1907
1819
|
}
|
|
1908
1820
|
|
|
1909
1821
|
/**
|
|
1910
1822
|
* Deletes all outdated keys
|
|
1911
1823
|
*/
|
|
1912
|
-
|
|
1913
1824
|
}, {
|
|
1914
1825
|
key: "flush",
|
|
1915
1826
|
value: function flush() {
|
|
1916
1827
|
var now = currentTime();
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
var _didIteratorError2 = false;
|
|
1920
|
-
var _iteratorError2 = undefined;
|
|
1921
|
-
|
|
1828
|
+
var _iterator3 = _createForOfIteratorHelper(this.map),
|
|
1829
|
+
_step3;
|
|
1922
1830
|
try {
|
|
1923
|
-
for (
|
|
1924
|
-
var
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
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];
|
|
1928
1835
|
if (value.ttl < now) {
|
|
1929
|
-
this
|
|
1836
|
+
this["delete"](key);
|
|
1930
1837
|
}
|
|
1931
1838
|
}
|
|
1932
1839
|
} catch (err) {
|
|
1933
|
-
|
|
1934
|
-
_iteratorError2 = err;
|
|
1840
|
+
_iterator3.e(err);
|
|
1935
1841
|
} finally {
|
|
1936
|
-
|
|
1937
|
-
if (!_iteratorNormalCompletion2 && _iterator2.return) {
|
|
1938
|
-
_iterator2.return();
|
|
1939
|
-
}
|
|
1940
|
-
} finally {
|
|
1941
|
-
if (_didIteratorError2) {
|
|
1942
|
-
throw _iteratorError2;
|
|
1943
|
-
}
|
|
1944
|
-
}
|
|
1842
|
+
_iterator3.f();
|
|
1945
1843
|
}
|
|
1946
1844
|
}
|
|
1947
1845
|
}]);
|
|
1948
|
-
|
|
1949
1846
|
return Cache;
|
|
1950
1847
|
}();
|
|
1848
|
+
var CACHE_FLUSH_INTERVAL = 60000; //60 sec
|
|
1951
1849
|
|
|
1952
|
-
|
|
1850
|
+
var cache = new Cache(CACHE_FLUSH_INTERVAL);
|
|
1953
1851
|
|
|
1954
1852
|
/***/ }),
|
|
1955
|
-
/*
|
|
1956
|
-
/***/ (function(module,
|
|
1853
|
+
/* 11 */
|
|
1854
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1957
1855
|
|
|
1958
1856
|
"use strict";
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
Object.defineProperty(exports, "__esModule", {
|
|
1962
|
-
value: true
|
|
1963
|
-
});
|
|
1964
|
-
|
|
1965
|
-
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; }; }();
|
|
1966
|
-
|
|
1857
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return EventEmitter; });
|
|
1967
1858
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
1968
|
-
|
|
1969
|
-
|
|
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 () {
|
|
1970
1862
|
function EventEmitter() {
|
|
1971
1863
|
_classCallCheck(this, EventEmitter);
|
|
1972
|
-
|
|
1973
1864
|
this.events = {};
|
|
1974
1865
|
}
|
|
1975
|
-
|
|
1976
1866
|
_createClass(EventEmitter, [{
|
|
1977
1867
|
key: "on",
|
|
1978
1868
|
value: function on(eventName, callback) {
|
|
1979
1869
|
this.events[eventName] = this.events[eventName] || [];
|
|
1980
1870
|
this.events[eventName].push(callback);
|
|
1981
|
-
|
|
1982
1871
|
return this;
|
|
1983
1872
|
}
|
|
1984
1873
|
}, {
|
|
@@ -1995,90 +1884,98 @@ var EventEmitter = function () {
|
|
|
1995
1884
|
delete this.events[eventName];
|
|
1996
1885
|
}
|
|
1997
1886
|
}
|
|
1998
|
-
|
|
1999
1887
|
return this;
|
|
2000
1888
|
}
|
|
2001
1889
|
}, {
|
|
2002
1890
|
key: "emit",
|
|
2003
1891
|
value: function emit(eventName) {
|
|
2004
|
-
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++) {
|
|
2005
1893
|
args[_key - 1] = arguments[_key];
|
|
2006
1894
|
}
|
|
2007
|
-
|
|
2008
1895
|
if (this.events[eventName]) {
|
|
2009
1896
|
this.events[eventName].forEach(function (callback) {
|
|
2010
|
-
return callback.apply(
|
|
1897
|
+
return callback.apply(void 0, args);
|
|
2011
1898
|
});
|
|
2012
1899
|
}
|
|
2013
1900
|
}
|
|
2014
1901
|
}]);
|
|
2015
|
-
|
|
2016
1902
|
return EventEmitter;
|
|
2017
1903
|
}();
|
|
2018
1904
|
|
|
2019
|
-
exports.default = EventEmitter;
|
|
2020
1905
|
|
|
2021
1906
|
/***/ }),
|
|
2022
|
-
/*
|
|
2023
|
-
/***/ (function(module,
|
|
1907
|
+
/* 12 */
|
|
1908
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
2024
1909
|
|
|
2025
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);
|
|
2026
1913
|
|
|
2027
1914
|
|
|
2028
|
-
Object.defineProperty(exports, "__esModule", {
|
|
2029
|
-
value: true
|
|
2030
|
-
});
|
|
2031
|
-
exports.stringify = undefined;
|
|
2032
|
-
|
|
2033
|
-
var _utils = __webpack_require__(0);
|
|
2034
|
-
|
|
2035
1915
|
/**
|
|
2036
1916
|
* Produces a URL query string from a given obj by iterating through the object's "own properties".
|
|
2037
1917
|
* @param {Object} obj
|
|
2038
1918
|
* @returns {string}
|
|
2039
1919
|
*/
|
|
2040
|
-
var stringify =
|
|
1920
|
+
var stringify = function stringify(obj) {
|
|
2041
1921
|
var tokens = [];
|
|
2042
|
-
|
|
2043
1922
|
Object.keys(obj).forEach(function (key) {
|
|
2044
1923
|
var value = obj[key];
|
|
2045
|
-
|
|
2046
1924
|
if (value !== undefined) {
|
|
2047
|
-
(
|
|
2048
|
-
tokens.push(encodeURIComponent(key)
|
|
1925
|
+
Object(__WEBPACK_IMPORTED_MODULE_0__utils__["a" /* castArray */])(value).forEach(function (value) {
|
|
1926
|
+
tokens.push("".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(value)));
|
|
2049
1927
|
});
|
|
2050
1928
|
}
|
|
2051
1929
|
});
|
|
2052
|
-
|
|
2053
1930
|
return tokens.join('&');
|
|
2054
1931
|
};
|
|
2055
1932
|
|
|
2056
1933
|
/***/ }),
|
|
2057
|
-
/*
|
|
2058
|
-
/***/ (function(module,
|
|
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
|
-
/* 7 */
|
|
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
|
-
/* 8 */
|
|
2070
|
-
/***/ (function(module, exports) {
|
|
2071
|
-
|
|
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/')
|
|
2073
|
-
|
|
2074
|
-
/***/ }),
|
|
2075
|
-
/* 9 */
|
|
2076
|
-
/***/ (function(module, exports) {
|
|
1934
|
+
/* 13 */
|
|
1935
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
2077
1936
|
|
|
2078
|
-
|
|
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
|
+
}
|
|
2079
1976
|
|
|
2080
1977
|
/***/ }),
|
|
2081
|
-
/*
|
|
1978
|
+
/* 14 */
|
|
2082
1979
|
/***/ (function(module, exports) {
|
|
2083
1980
|
|
|
2084
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/')
|
|
@@ -24712,7 +24609,7 @@ var Urls = /*#__PURE__*/function () {
|
|
|
24712
24609
|
}, {
|
|
24713
24610
|
key: "dataTableObject",
|
|
24714
24611
|
value: function dataTableObject(tableName, objectId) {
|
|
24715
|
-
return "".concat(this.dataTable(tableName), "/").concat(objectId);
|
|
24612
|
+
return "".concat(this.dataTable(tableName), "/").concat(encodeURIComponent(objectId));
|
|
24716
24613
|
}
|
|
24717
24614
|
}, {
|
|
24718
24615
|
key: "dataTableObjectRelation",
|