@webex/http-core 3.0.0-bnr.4 → 3.0.0
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/.eslintrc.js +6 -0
- package/babel.config.js +3 -0
- package/dist/http-error-subtypes.js.map +1 -1
- package/dist/http-error.js +21 -22
- package/dist/http-error.js.map +1 -1
- package/dist/index.js +58 -13
- package/dist/index.js.map +1 -1
- package/dist/interceptors/http-status.js +4 -3
- package/dist/interceptors/http-status.js.map +1 -1
- package/dist/lib/detect.js.map +1 -1
- package/dist/lib/interceptor.js +6 -4
- package/dist/lib/interceptor.js.map +1 -1
- package/dist/lib/xhr.js +7 -3
- package/dist/lib/xhr.js.map +1 -1
- package/dist/progress-event.js +6 -2
- package/dist/progress-event.js.map +1 -1
- package/dist/request/index.js +3 -30
- package/dist/request/index.js.map +1 -1
- package/dist/request/request.js.map +1 -1
- package/dist/request/request.shim.js +13 -11
- package/dist/request/request.shim.js.map +1 -1
- package/dist/request/utils.js +91 -0
- package/dist/request/utils.js.map +1 -0
- package/jest.config.js +3 -0
- package/package.json +31 -13
- package/process +1 -0
- package/src/index.js +55 -0
- package/src/lib/xhr.js +5 -1
- package/src/request/index.js +4 -36
- package/src/request/request.shim.js +5 -2
- package/src/request/utils.ts +78 -0
- package/test/integration/spec/request.js +2 -1
- package/test/unit/spec/index.js +58 -0
- package/test/unit/spec/request/request.shim.js +28 -0
- package/test/unit/spec/request/utils.js +77 -0
- package/dist/types/http-error-subtypes.d.ts +0 -8
- package/dist/types/http-error.d.ts +0 -41
- package/dist/types/index.d.ts +0 -7
- package/dist/types/interceptors/http-status.d.ts +0 -17
- package/dist/types/lib/detect.d.ts +0 -6
- package/dist/types/lib/interceptor.d.ts +0 -51
- package/dist/types/lib/xhr.d.ts +0 -6
- package/dist/types/progress-event.d.ts +0 -18
- package/dist/types/request/index.d.ts +0 -5
- package/dist/types/request/request.d.ts +0 -6
- package/dist/types/request/request.shim.d.ts +0 -6
package/.eslintrc.js
ADDED
package/babel.config.js
ADDED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["makeSubTypes","Base","NetworkOrCORSError","BadRequest","Unauthorized","PaymentRequired","Forbidden","NotFound","MethodNotAllowed","NotAcceptable","ProxyAuthenticationRequired","RequestTimeout","Conflict","Gone","LengthRequired","PreconditionFailed","RequestEntityTooLarge","RequestUriTooLong","UnsupportedMediaType","RequestRangeNotSatisfiable","ExpectationFailed","TooManyRequests","InternalServerError","NotImplemented","BadGateway","ServiceUnavailable","GatewayTimeout","HttpVersionNotSupported","select","statusCode","E","toString","split","shift"],"sources":["http-error-subtypes.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/**\n * @param {Error} Base\n * @returns {undefined}\n */\nexport default function makeSubTypes(Base) {\n /**\n * NetworkOrCORSError\n */\n class NetworkOrCORSError extends Base {}\n /**\n * BadRequest\n */\n class BadRequest extends Base {}\n /**\n * Unauthorized\n */\n class Unauthorized extends BadRequest {}\n /**\n * PaymentRequired\n */\n class PaymentRequired extends BadRequest {}\n /**\n * Forbidden\n */\n class Forbidden extends BadRequest {}\n /**\n * NotFound\n */\n class NotFound extends BadRequest {}\n /**\n * MethodNotAllowed\n */\n class MethodNotAllowed extends BadRequest {}\n /**\n * NotAcceptable\n */\n class NotAcceptable extends BadRequest {}\n /**\n * ProxyAuthenticationRequired\n */\n class ProxyAuthenticationRequired extends BadRequest {}\n /**\n * RequestTimeout\n */\n class RequestTimeout extends BadRequest {}\n /**\n * Conflict\n */\n class Conflict extends BadRequest {}\n /**\n * Gone\n */\n class Gone extends BadRequest {}\n /**\n * LengthRequired\n */\n class LengthRequired extends BadRequest {}\n /**\n * PreconditionFailed\n */\n class PreconditionFailed extends BadRequest {}\n /**\n * RequestEntityTooLarge\n */\n class RequestEntityTooLarge extends BadRequest {}\n /**\n * RequestUriTooLong\n */\n class RequestUriTooLong extends BadRequest {}\n /**\n * UnsupportedMediaType\n */\n class UnsupportedMediaType extends BadRequest {}\n /**\n * RequestRangeNotSatisfiable\n */\n class RequestRangeNotSatisfiable extends BadRequest {}\n /**\n * ExpectationFailed\n */\n class ExpectationFailed extends BadRequest {}\n /**\n * TooManyRequests\n */\n class TooManyRequests extends BadRequest {}\n /**\n * InternalServerError\n */\n class InternalServerError extends Base {}\n /**\n * NotImplemented\n */\n class NotImplemented extends InternalServerError {}\n /**\n * BadGateway\n */\n class BadGateway extends InternalServerError {}\n /**\n * ServiceUnavailable\n */\n class ServiceUnavailable extends InternalServerError {}\n /**\n * GatewayTimeout\n */\n class GatewayTimeout extends InternalServerError {}\n /**\n * HttpVersionNotSupported\n */\n class HttpVersionNotSupported extends InternalServerError {}\n\n Object.assign(Base, {\n 0: NetworkOrCORSError,\n NetworkOrCORSError,\n 400: BadRequest,\n BadRequest,\n 401: Unauthorized,\n Unauthorized,\n 402: PaymentRequired,\n PaymentRequired,\n 403: Forbidden,\n Forbidden,\n 404: NotFound,\n NotFound,\n 405: MethodNotAllowed,\n MethodNotAllowed,\n 406: NotAcceptable,\n NotAcceptable,\n 407: ProxyAuthenticationRequired,\n ProxyAuthenticationRequired,\n 408: RequestTimeout,\n RequestTimeout,\n 409: Conflict,\n Conflict,\n 410: Gone,\n Gone,\n 411: LengthRequired,\n LengthRequired,\n 412: PreconditionFailed,\n PreconditionFailed,\n 413: RequestEntityTooLarge,\n RequestEntityTooLarge,\n 414: RequestUriTooLong,\n RequestUriTooLong,\n 415: UnsupportedMediaType,\n UnsupportedMediaType,\n 416: RequestRangeNotSatisfiable,\n RequestRangeNotSatisfiable,\n 417: ExpectationFailed,\n ExpectationFailed,\n 429: TooManyRequests,\n TooManyRequests,\n 500: InternalServerError,\n InternalServerError,\n 501: NotImplemented,\n NotImplemented,\n 502: BadGateway,\n BadGateway,\n 503: ServiceUnavailable,\n ServiceUnavailable,\n 504: GatewayTimeout,\n GatewayTimeout,\n 505: HttpVersionNotSupported,\n HttpVersionNotSupported,\n select(statusCode) {\n if (typeof statusCode === 'undefined' || statusCode === null) {\n return Base;\n }\n\n statusCode = statusCode.statusCode || statusCode;\n const E = Base[statusCode];\n\n if (E) {\n return E;\n }\n\n // Fallback to the default for the category (e.g. BadRequest for 429)\n statusCode = `${statusCode.toString().split('').shift()}00`;\n statusCode = parseInt(statusCode, 10);\n\n return Base[statusCode] || Base;\n },\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACe,SAASA,YAAY,CAACC,IAAI,EAAE;EACzC;AACF;AACA;EAFE,IAGMC,kBAAkB;IAAA;IAAA;IAAA;MAAA;MAAA;IAAA;IAAA;EAAA,EAASD,IAAI;EACrC;AACF;AACA;EAFE,IAGME,UAAU;IAAA;IAAA;IAAA;MAAA;MAAA;IAAA;IAAA;EAAA,EAASF,IAAI;EAC7B;AACF;AACA;EAFE,IAGMG,YAAY;IAAA;IAAA;IAAA;MAAA;MAAA;IAAA;IAAA;EAAA,EAASD,UAAU;EACrC;AACF;AACA;EAFE,IAGME,eAAe;IAAA;IAAA;IAAA;MAAA;MAAA;IAAA;IAAA;EAAA,EAASF,UAAU;EACxC;AACF;AACA;EAFE,IAGMG,SAAS;IAAA;IAAA;IAAA;MAAA;MAAA;IAAA;IAAA;EAAA,EAASH,UAAU;EAClC;AACF;AACA;EAFE,IAGMI,QAAQ;IAAA;IAAA;IAAA;MAAA;MAAA;IAAA;IAAA;EAAA,EAASJ,UAAU;EACjC;AACF;AACA;EAFE,IAGMK,gBAAgB;IAAA;IAAA;IAAA;MAAA;MAAA;IAAA;IAAA;EAAA,EAASL,UAAU;EACzC;AACF;AACA;EAFE,IAGMM,aAAa;IAAA;IAAA;IAAA;MAAA;MAAA;IAAA;IAAA;EAAA,EAASN,UAAU;EACtC;AACF;AACA;EAFE,IAGMO,2BAA2B;IAAA;IAAA;IAAA;MAAA;MAAA;IAAA;IAAA;EAAA,EAASP,UAAU;EACpD;AACF;AACA;EAFE,IAGMQ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","default","_super","_createSuper","_classCallCheck2","apply","arguments","_createClass2","BadRequest","_Base2","_super2","Unauthorized","_BadRequest","_super3","PaymentRequired","_BadRequest2","_super4","Forbidden","_BadRequest3","_super5","NotFound","_BadRequest4","_super6","MethodNotAllowed","_BadRequest5","_super7","NotAcceptable","_BadRequest6","_super8","ProxyAuthenticationRequired","_BadRequest7","_super9","RequestTimeout","_BadRequest8","_super10","Conflict","_BadRequest9","_super11","Gone","_BadRequest10","_super12","LengthRequired","_BadRequest11","_super13","PreconditionFailed","_BadRequest12","_super14","RequestEntityTooLarge","_BadRequest13","_super15","RequestUriTooLong","_BadRequest14","_super16","UnsupportedMediaType","_BadRequest15","_super17","RequestRangeNotSatisfiable","_BadRequest16","_super18","ExpectationFailed","_BadRequest17","_super19","TooManyRequests","_BadRequest18","_super20","InternalServerError","_Base3","_super21","NotImplemented","_InternalServerError","_super22","BadGateway","_InternalServerError2","_super23","ServiceUnavailable","_InternalServerError3","_super24","GatewayTimeout","_InternalServerError4","_super25","HttpVersionNotSupported","_InternalServerError5","_super26","_assign","select","statusCode","E","concat","toString","split","shift","_parseInt2"],"sources":["http-error-subtypes.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/**\n * @param {Error} Base\n * @returns {undefined}\n */\nexport default function makeSubTypes(Base) {\n /**\n * NetworkOrCORSError\n */\n class NetworkOrCORSError extends Base {}\n /**\n * BadRequest\n */\n class BadRequest extends Base {}\n /**\n * Unauthorized\n */\n class Unauthorized extends BadRequest {}\n /**\n * PaymentRequired\n */\n class PaymentRequired extends BadRequest {}\n /**\n * Forbidden\n */\n class Forbidden extends BadRequest {}\n /**\n * NotFound\n */\n class NotFound extends BadRequest {}\n /**\n * MethodNotAllowed\n */\n class MethodNotAllowed extends BadRequest {}\n /**\n * NotAcceptable\n */\n class NotAcceptable extends BadRequest {}\n /**\n * ProxyAuthenticationRequired\n */\n class ProxyAuthenticationRequired extends BadRequest {}\n /**\n * RequestTimeout\n */\n class RequestTimeout extends BadRequest {}\n /**\n * Conflict\n */\n class Conflict extends BadRequest {}\n /**\n * Gone\n */\n class Gone extends BadRequest {}\n /**\n * LengthRequired\n */\n class LengthRequired extends BadRequest {}\n /**\n * PreconditionFailed\n */\n class PreconditionFailed extends BadRequest {}\n /**\n * RequestEntityTooLarge\n */\n class RequestEntityTooLarge extends BadRequest {}\n /**\n * RequestUriTooLong\n */\n class RequestUriTooLong extends BadRequest {}\n /**\n * UnsupportedMediaType\n */\n class UnsupportedMediaType extends BadRequest {}\n /**\n * RequestRangeNotSatisfiable\n */\n class RequestRangeNotSatisfiable extends BadRequest {}\n /**\n * ExpectationFailed\n */\n class ExpectationFailed extends BadRequest {}\n /**\n * TooManyRequests\n */\n class TooManyRequests extends BadRequest {}\n /**\n * InternalServerError\n */\n class InternalServerError extends Base {}\n /**\n * NotImplemented\n */\n class NotImplemented extends InternalServerError {}\n /**\n * BadGateway\n */\n class BadGateway extends InternalServerError {}\n /**\n * ServiceUnavailable\n */\n class ServiceUnavailable extends InternalServerError {}\n /**\n * GatewayTimeout\n */\n class GatewayTimeout extends InternalServerError {}\n /**\n * HttpVersionNotSupported\n */\n class HttpVersionNotSupported extends InternalServerError {}\n\n Object.assign(Base, {\n 0: NetworkOrCORSError,\n NetworkOrCORSError,\n 400: BadRequest,\n BadRequest,\n 401: Unauthorized,\n Unauthorized,\n 402: PaymentRequired,\n PaymentRequired,\n 403: Forbidden,\n Forbidden,\n 404: NotFound,\n NotFound,\n 405: MethodNotAllowed,\n MethodNotAllowed,\n 406: NotAcceptable,\n NotAcceptable,\n 407: ProxyAuthenticationRequired,\n ProxyAuthenticationRequired,\n 408: RequestTimeout,\n RequestTimeout,\n 409: Conflict,\n Conflict,\n 410: Gone,\n Gone,\n 411: LengthRequired,\n LengthRequired,\n 412: PreconditionFailed,\n PreconditionFailed,\n 413: RequestEntityTooLarge,\n RequestEntityTooLarge,\n 414: RequestUriTooLong,\n RequestUriTooLong,\n 415: UnsupportedMediaType,\n UnsupportedMediaType,\n 416: RequestRangeNotSatisfiable,\n RequestRangeNotSatisfiable,\n 417: ExpectationFailed,\n ExpectationFailed,\n 429: TooManyRequests,\n TooManyRequests,\n 500: InternalServerError,\n InternalServerError,\n 501: NotImplemented,\n NotImplemented,\n 502: BadGateway,\n BadGateway,\n 503: ServiceUnavailable,\n ServiceUnavailable,\n 504: GatewayTimeout,\n GatewayTimeout,\n 505: HttpVersionNotSupported,\n HttpVersionNotSupported,\n select(statusCode) {\n if (typeof statusCode === 'undefined' || statusCode === null) {\n return Base;\n }\n\n statusCode = statusCode.statusCode || statusCode;\n const E = Base[statusCode];\n\n if (E) {\n return E;\n }\n\n // Fallback to the default for the category (e.g. BadRequest for 429)\n statusCode = `${statusCode.toString().split('').shift()}00`;\n statusCode = parseInt(statusCode, 10);\n\n return Base[statusCode] || Base;\n },\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACe,SAASA,YAAYA,CAACC,IAAI,EAAE;EACzC;AACF;AACA;EAFE,IAGMC,kBAAkB,0BAAAC,KAAA;IAAA,IAAAC,UAAA,CAAAC,OAAA,EAAAH,kBAAA,EAAAC,KAAA;IAAA,IAAAG,MAAA,GAAAC,YAAA,CAAAL,kBAAA;IAAA,SAAAA,mBAAA;MAAA,IAAAM,gBAAA,CAAAH,OAAA,QAAAH,kBAAA;MAAA,OAAAI,MAAA,CAAAG,KAAA,OAAAC,SAAA;IAAA;IAAA,WAAAC,aAAA,CAAAN,OAAA,EAAAH,kBAAA;EAAA,EAASD,IAAI;EACrC;AACF;AACA;EAFE,IAGMW,UAAU,0BAAAC,MAAA;IAAA,IAAAT,UAAA,CAAAC,OAAA,EAAAO,UAAA,EAAAC,MAAA;IAAA,IAAAC,OAAA,GAAAP,YAAA,CAAAK,UAAA;IAAA,SAAAA,WAAA;MAAA,IAAAJ,gBAAA,CAAAH,OAAA,QAAAO,UAAA;MAAA,OAAAE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AG,EAAEG,kBAAkB;IACvBA,kBAAkB,EAAlBA,kBAAkB;IAClB,GAAG,EAAEG,cAAc;IACnBA,cAAc,EAAdA,cAAc;IACd,GAAG,EAAEG,uBAAuB;IAC5BA,uBAAuB,EAAvBA,uBAAuB;IACvBI,MAAM,WAAAA,OAACC,UAAU,EAAE;MACjB,IAAI,OAAOA,UAAU,KAAK,WAAW,IAAIA,UAAU,KAAK,IAAI,EAAE;QAC5D,OAAOxF,IAAI;MACb;MAEAwF,UAAU,GAAGA,UAAU,CAACA,UAAU,IAAIA,UAAU;MAChD,IAAMC,CAAC,GAAGzF,IAAI,CAACwF,UAAU,CAAC;MAE1B,IAAIC,CAAC,EAAE;QACL,OAAOA,CAAC;MACV;;MAEA;MACAD,UAAU,MAAAE,MAAA,CAAMF,UAAU,CAACG,QAAQ,CAAC,CAAC,CAACC,KAAK,CAAC,EAAE,CAAC,CAACC,KAAK,CAAC,CAAC,OAAI;MAC3DL,UAAU,GAAG,IAAAM,UAAA,CAAA1F,OAAA,EAASoF,UAAU,EAAE,EAAE,CAAC;MAErC,OAAOxF,IAAI,CAACwF,UAAU,CAAC,IAAIxF,IAAI;IACjC;EACF,CAAC,CAAC;AACJ"}
|
package/dist/http-error.js
CHANGED
|
@@ -17,16 +17,18 @@ var _inherits2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/
|
|
|
17
17
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/possibleConstructorReturn"));
|
|
18
18
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/getPrototypeOf"));
|
|
19
19
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
|
|
20
|
-
var
|
|
20
|
+
var _lodash = require("lodash");
|
|
21
21
|
var _common = require("@webex/common");
|
|
22
22
|
var _httpErrorSubtypes = _interopRequireDefault(require("./http-error-subtypes"));
|
|
23
23
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
24
|
-
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; } }
|
|
24
|
+
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; } } /*!
|
|
25
|
+
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
26
|
+
*/
|
|
25
27
|
/**
|
|
26
28
|
* Base HttpError class. Unlikely to be thrown directly, but handy for general
|
|
27
29
|
* type comparison.
|
|
28
30
|
*/
|
|
29
|
-
var HttpError = /*#__PURE__*/function (_Exception) {
|
|
31
|
+
var HttpError = exports.default = /*#__PURE__*/function (_Exception) {
|
|
30
32
|
(0, _inherits2.default)(HttpError, _Exception);
|
|
31
33
|
var _super = _createSuper(HttpError);
|
|
32
34
|
function HttpError() {
|
|
@@ -36,23 +38,6 @@ var HttpError = /*#__PURE__*/function (_Exception) {
|
|
|
36
38
|
(0, _createClass2.default)(HttpError, [{
|
|
37
39
|
key: "parse",
|
|
38
40
|
value:
|
|
39
|
-
/**
|
|
40
|
-
* @example Extend via
|
|
41
|
-
* MyError extends HttpError {
|
|
42
|
-
* static errorKeys = HttpError.errorKeys.concat([
|
|
43
|
-
* `key1`,
|
|
44
|
-
* `key2`
|
|
45
|
-
* ])
|
|
46
|
-
* }
|
|
47
|
-
*
|
|
48
|
-
* @type {Array}
|
|
49
|
-
*/
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Default error string if no error can be extracted from the http response
|
|
53
|
-
* @type {string}
|
|
54
|
-
*/
|
|
55
|
-
|
|
56
41
|
/**
|
|
57
42
|
* Parses HttpResponse objects for useful information (status, headers, etc)
|
|
58
43
|
* as well as attempting to extract a useful error message.
|
|
@@ -143,7 +128,7 @@ var HttpError = /*#__PURE__*/function (_Exception) {
|
|
|
143
128
|
key: "parseObject",
|
|
144
129
|
value: function parseObject(body) {
|
|
145
130
|
// Search body for common names of error strings
|
|
146
|
-
var messages = (0, _values.default)((0,
|
|
131
|
+
var messages = (0, _values.default)((0, _lodash.pick)(body, HttpError.errorKeys));
|
|
147
132
|
|
|
148
133
|
// If no error candidate was found, stringify the entire body
|
|
149
134
|
if (messages.length === 0) {
|
|
@@ -164,8 +149,22 @@ var HttpError = /*#__PURE__*/function (_Exception) {
|
|
|
164
149
|
}]);
|
|
165
150
|
return HttpError;
|
|
166
151
|
}(_common.Exception);
|
|
167
|
-
|
|
152
|
+
/**
|
|
153
|
+
* @example Extend via
|
|
154
|
+
* MyError extends HttpError {
|
|
155
|
+
* static errorKeys = HttpError.errorKeys.concat([
|
|
156
|
+
* `key1`,
|
|
157
|
+
* `key2`
|
|
158
|
+
* ])
|
|
159
|
+
* }
|
|
160
|
+
*
|
|
161
|
+
* @type {Array}
|
|
162
|
+
*/
|
|
168
163
|
(0, _defineProperty2.default)(HttpError, "errorKeys", ['error', 'errorString', 'response', 'errorResponse', 'message', 'msg']);
|
|
164
|
+
/**
|
|
165
|
+
* Default error string if no error can be extracted from the http response
|
|
166
|
+
* @type {string}
|
|
167
|
+
*/
|
|
169
168
|
(0, _defineProperty2.default)(HttpError, "defaultMessage", 'An error was received while trying to fulfill the request');
|
|
170
169
|
(0, _httpErrorSubtypes.default)(HttpError);
|
|
171
170
|
HttpError.makeSubTypes = _httpErrorSubtypes.default;
|
package/dist/http-error.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["HttpError","res","body","message","
|
|
1
|
+
{"version":3,"names":["_lodash","require","_common","_httpErrorSubtypes","_interopRequireDefault","_createSuper","Derived","hasNativeReflectConstruct","_isNativeReflectConstruct","_createSuperInternal","Super","_getPrototypeOf2","default","result","NewTarget","constructor","_Reflect$construct","arguments","apply","_possibleConstructorReturn2","Reflect","sham","Proxy","Boolean","prototype","valueOf","call","e","HttpError","exports","_Exception","_inherits2","_super","_classCallCheck2","_createClass2","key","value","parse","res","body","message","_typeof2","JSON","parseObject","err","defaultMessage","_defineProperties","enumerable","httpVersion","headers","rawHeaders","trailers","rawTrailers","method","url","statusCode","statusMessage","socket","_res","messages","_values","pick","errorKeys","length","_stringify","Exception","_defineProperty2","makeSubTypes"],"sources":["http-error.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {pick} from 'lodash';\nimport {Exception} from '@webex/common';\n\nimport makeSubTypes from './http-error-subtypes';\n\n/**\n * Base HttpError class. Unlikely to be thrown directly, but handy for general\n * type comparison.\n */\nexport default class HttpError extends Exception {\n /**\n * @example Extend via\n * MyError extends HttpError {\n * static errorKeys = HttpError.errorKeys.concat([\n * `key1`,\n * `key2`\n * ])\n * }\n *\n * @type {Array}\n */\n static errorKeys = ['error', 'errorString', 'response', 'errorResponse', 'message', 'msg'];\n\n /**\n * Default error string if no error can be extracted from the http response\n * @type {string}\n */\n static defaultMessage = 'An error was received while trying to fulfill the request';\n\n /**\n * Parses HttpResponse objects for useful information (status, headers, etc)\n * as well as attempting to extract a useful error message.\n * @param {HttpResponse} res\n * @returns {string}\n */\n parse(res) {\n // complexity is high here because of all the default values below.\n /* eslint complexity: [0] */\n let {body} = res;\n let message;\n\n switch (typeof body) {\n case 'string':\n try {\n body = JSON.parse(body);\n message = this.parseObject(body);\n } catch (err) {\n message = body;\n }\n break;\n case 'object':\n message = this.parseObject(body);\n break;\n default:\n }\n\n if (!message) {\n message = this.defaultMessage;\n }\n\n Object.defineProperties(this, {\n body: {\n enumerable: false,\n value: body,\n },\n httpVersion: {\n enumerable: false,\n value: res.httpVersion,\n },\n headers: {\n enumerable: false,\n value: res.headers || {},\n },\n rawHeaders: {\n enumerable: false,\n value: res.rawHeaders || [],\n },\n trailers: {\n enumerable: false,\n value: res.trailers || {},\n },\n rawTrailers: {\n enumerable: false,\n value: res.rawTrailers || [],\n },\n method: {\n enumerable: false,\n value: res.method,\n },\n url: {\n enumerable: false,\n value: res.url,\n },\n statusCode: {\n enumerable: false,\n value: res.statusCode,\n },\n statusMessage: {\n enumerable: false,\n value: res.statusMessage,\n },\n socket: {\n enumerable: false,\n value: res.socket,\n },\n _res: {\n enumerable: false,\n value: res,\n },\n });\n\n return message;\n }\n\n /**\n * Recursively parses an error body looking for a likely error candidate\n * @param {object} body\n * @returns {string}\n */\n parseObject(body) {\n // Search body for common names of error strings\n const messages = Object.values(pick(body, HttpError.errorKeys));\n\n // If no error candidate was found, stringify the entire body\n if (messages.length === 0) {\n return JSON.stringify(body, null, 2);\n }\n\n // Assume the first key found was the error explanation\n const message = messages[0];\n\n // If the explanation is an object, recurse and try again\n if (typeof message === 'object') {\n return this.parseObject(message);\n }\n\n // Return the first key\n return message;\n }\n}\n\nmakeSubTypes(HttpError);\nHttpError.makeSubTypes = makeSubTypes;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAIA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAEA,IAAAE,kBAAA,GAAAC,sBAAA,CAAAH,OAAA;AAAiD,SAAAI,aAAAC,OAAA,QAAAC,yBAAA,GAAAC,yBAAA,oBAAAC,qBAAA,QAAAC,KAAA,OAAAC,gBAAA,CAAAC,OAAA,EAAAN,OAAA,GAAAO,MAAA,MAAAN,yBAAA,QAAAO,SAAA,OAAAH,gBAAA,CAAAC,OAAA,QAAAG,WAAA,EAAAF,MAAA,GAAAG,kBAAA,CAAAN,KAAA,E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;AACA;AACA;AACA;EAJE;IAAAL,GAAA;IAAAC,KAAA,EAKA,SAAAO,YAAYJ,IAAI,EAAE;MAChB;MACA,IAAMoB,QAAQ,GAAG,IAAAC,OAAA,CAAAhD,OAAA,EAAc,IAAAiD,YAAI,EAACtB,IAAI,EAAEX,SAAS,CAACkC,SAAS,CAAC,CAAC;;MAE/D;MACA,IAAIH,QAAQ,CAACI,MAAM,KAAK,CAAC,EAAE;QACzB,OAAO,IAAAC,UAAA,CAAApD,OAAA,EAAe2B,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;MACtC;;MAEA;MACA,IAAMC,OAAO,GAAGmB,QAAQ,CAAC,CAAC,CAAC;;MAE3B;MACA,IAAI,IAAAlB,QAAA,CAAA7B,OAAA,EAAO4B,OAAO,MAAK,QAAQ,EAAE;QAC/B,OAAO,IAAI,CAACG,WAAW,CAACH,OAAO,CAAC;MAClC;;MAEA;MACA,OAAOA,OAAO;IAChB;EAAC;EAAA,OAAAZ,SAAA;AAAA,EAjIoCqC,iBAAS;AAC9C;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAVE,IAAAC,gBAAA,CAAAtD,OAAA,EADmBgB,SAAS,eAYT,CAAC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,EAAE,KAAK,CAAC;AAE1F;AACF;AACA;AACA;AAHE,IAAAsC,gBAAA,CAAAtD,OAAA,EAdmBgB,SAAS,oBAkBJ,2DAA2D;AAkHrF,IAAAuC,0BAAY,EAACvC,SAAS,CAAC;AACvBA,SAAS,CAACuC,YAAY,GAAGA,0BAAY"}
|
package/dist/index.js
CHANGED
|
@@ -36,25 +36,27 @@ _Object$defineProperty(exports, "detect", {
|
|
|
36
36
|
return _detect.default;
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
|
-
exports.request = void 0;
|
|
39
|
+
exports.setTimingsAndFetch = exports.request = exports.protoprepareFetchOptions = void 0;
|
|
40
40
|
var _getOwnPropertyDescriptor = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/reflect/get-own-property-descriptor"));
|
|
41
41
|
var _defineProperty = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/reflect/define-property"));
|
|
42
42
|
var _deleteProperty = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/reflect/delete-property"));
|
|
43
|
-
var
|
|
44
|
-
var _defaults2 = _interopRequireDefault(require("lodash/defaults"));
|
|
45
|
-
var _curry2 = _interopRequireDefault(require("lodash/curry"));
|
|
46
|
-
var _assign2 = _interopRequireDefault(require("lodash/assign"));
|
|
43
|
+
var _lodash = require("lodash");
|
|
47
44
|
var _httpStatus = _interopRequireDefault(require("./interceptors/http-status"));
|
|
48
45
|
var _request2 = _interopRequireDefault(require("./request"));
|
|
46
|
+
var _utils = require("./request/utils");
|
|
49
47
|
var _progressEvent = _interopRequireDefault(require("./progress-event"));
|
|
50
48
|
var _interceptor = _interopRequireDefault(require("./lib/interceptor"));
|
|
51
49
|
var _httpError = _interopRequireDefault(require("./http-error"));
|
|
52
50
|
var _detect = _interopRequireDefault(require("./lib/detect"));
|
|
51
|
+
/*!
|
|
52
|
+
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
53
|
+
*/
|
|
54
|
+
|
|
53
55
|
// Curry protorequest so we generate a function with default options built in.
|
|
54
|
-
var protorequest = (0,
|
|
56
|
+
var protorequest = (0, _lodash.curry)(function protorequest(defaultOptions, options) {
|
|
55
57
|
// allow for options to be a string (and therefore expect options in the third
|
|
56
58
|
// position) to match request's api.
|
|
57
|
-
if ((0,
|
|
59
|
+
if ((0, _lodash.isString)(options)) {
|
|
58
60
|
var uri = options;
|
|
59
61
|
|
|
60
62
|
/* eslint prefer-rest-params: [0] */
|
|
@@ -65,27 +67,70 @@ var protorequest = (0, _curry2.default)(function protorequest(defaultOptions, op
|
|
|
65
67
|
// Hide useless elements from logs
|
|
66
68
|
['download', 'interceptors', 'logger', 'upload'].forEach(function (prop) {
|
|
67
69
|
var descriptor = (0, _getOwnPropertyDescriptor.default)(options, prop);
|
|
68
|
-
descriptor = (0,
|
|
70
|
+
descriptor = (0, _lodash.assign)({}, descriptor, {
|
|
69
71
|
enumerable: false,
|
|
70
72
|
writable: true
|
|
71
73
|
});
|
|
72
74
|
(0, _defineProperty.default)(options, prop, descriptor);
|
|
73
75
|
});
|
|
74
|
-
(0,
|
|
76
|
+
(0, _lodash.defaults)(options, defaultOptions);
|
|
75
77
|
if (!options.json && options.json !== false) {
|
|
76
78
|
(0, _deleteProperty.default)(options, 'json');
|
|
77
79
|
}
|
|
78
80
|
options.logger = options.logger || this.logger || console;
|
|
79
81
|
return (0, _request2.default)(options);
|
|
80
82
|
});
|
|
83
|
+
var protoprepareFetchOptions = exports.protoprepareFetchOptions = (0, _lodash.curry)(function protoprepareFetchOptions(defaultOptions, options) {
|
|
84
|
+
// Hide useless elements from logs
|
|
85
|
+
['download', 'interceptors', 'logger', 'upload'].forEach(function (prop) {
|
|
86
|
+
var descriptor = (0, _getOwnPropertyDescriptor.default)(options, prop);
|
|
87
|
+
descriptor = (0, _lodash.assign)({}, descriptor, {
|
|
88
|
+
enumerable: false,
|
|
89
|
+
writable: true
|
|
90
|
+
});
|
|
91
|
+
(0, _defineProperty.default)(options, prop, descriptor);
|
|
92
|
+
});
|
|
93
|
+
(0, _lodash.defaults)(options, defaultOptions);
|
|
94
|
+
options.logger = options.logger || this.logger || console;
|
|
95
|
+
return (0, _utils.prepareFetchOptions)(options);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Sets the $timings value(s) before the request/fetch.
|
|
100
|
+
* This function is only useful if you are about to send a request
|
|
101
|
+
* using prepared fetch options; normally it is done in webex.request();
|
|
102
|
+
*
|
|
103
|
+
* @param {any} options
|
|
104
|
+
* @returns {any} the updated options object
|
|
105
|
+
*/
|
|
106
|
+
var setRequestTimings = function setRequestTimings(options) {
|
|
107
|
+
var now = new Date().getTime();
|
|
108
|
+
options.$timings = options.$timings || {};
|
|
109
|
+
options.$timings.requestStart = now;
|
|
110
|
+
options.$timings.networkStart = now;
|
|
111
|
+
return options;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Submits a metric from pre-built request options via the fetch API. Updates
|
|
116
|
+
* the "$timings" values to Date.now() since the existing times were set when
|
|
117
|
+
* the options were built (not submitted).
|
|
118
|
+
*
|
|
119
|
+
* @param {any} options - the pre-built request options for submitting a metric
|
|
120
|
+
* @returns {Promise} promise that resolves to a response object
|
|
121
|
+
*/
|
|
122
|
+
var setTimingsAndFetch = exports.setTimingsAndFetch = function setTimingsAndFetch(options) {
|
|
123
|
+
var opts = setRequestTimings(options);
|
|
124
|
+
|
|
125
|
+
// call the fetch API
|
|
126
|
+
return fetch(opts.uri, opts);
|
|
127
|
+
};
|
|
81
128
|
var defaultOptions = {
|
|
82
129
|
json: true,
|
|
83
130
|
interceptors: [
|
|
84
131
|
// Reminder: this is supposed to be an instantiated interceptor.
|
|
85
132
|
_httpStatus.default.create()]
|
|
86
133
|
};
|
|
87
|
-
var defaults = protorequest;
|
|
88
|
-
exports.
|
|
89
|
-
var request = protorequest(defaultOptions);
|
|
90
|
-
exports.request = request;
|
|
134
|
+
var defaults = exports.defaults = protorequest;
|
|
135
|
+
var request = exports.request = protorequest(defaultOptions);
|
|
91
136
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["protorequest","defaultOptions","options","uri","arguments","forEach","prop","descriptor","enumerable","writable","json","logger","console","_request","interceptors","HttpStatusInterceptor","create","defaults","request"],"sources":["index.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {assign, curry, defaults as lodashDefaults, isString} from 'lodash';\n\nimport HttpStatusInterceptor from './interceptors/http-status';\nimport _request from './request';\n\n// Curry protorequest so we generate a function with default options built in.\nconst protorequest = curry(function protorequest(defaultOptions, options) {\n // allow for options to be a string (and therefore expect options in the third\n // position) to match request's api.\n if (isString(options)) {\n const uri = options;\n\n /* eslint prefer-rest-params: [0] */\n options = arguments[2] || {};\n options.uri = uri;\n }\n\n // Hide useless elements from logs\n ['download', 'interceptors', 'logger', 'upload'].forEach((prop) => {\n let descriptor = Reflect.getOwnPropertyDescriptor(options, prop);\n\n descriptor = assign({}, descriptor, {\n enumerable: false,\n writable: true,\n });\n Reflect.defineProperty(options, prop, descriptor);\n });\n\n lodashDefaults(options, defaultOptions);\n\n if (!options.json && options.json !== false) {\n Reflect.deleteProperty(options, 'json');\n }\n\n options.logger = options.logger || this.logger || console;\n\n return _request(options);\n});\n\nconst defaultOptions = {\n json: true,\n interceptors: [\n // Reminder: this is supposed to be an instantiated interceptor.\n HttpStatusInterceptor.create(),\n ],\n};\n\nexport const defaults = protorequest;\nexport const request = protorequest(defaultOptions);\nexport {default as ProgressEvent} from './progress-event';\nexport {default as Interceptor} from './lib/interceptor';\nexport {default as HttpError} from './http-error';\nexport {default as HttpStatusInterceptor} from './interceptors/http-status';\nexport {default as detect} from './lib/detect';\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_lodash","require","_httpStatus","_interopRequireDefault","_request2","_utils","_progressEvent","_interceptor","_httpError","_detect","protorequest","curry","defaultOptions","options","isString","uri","arguments","forEach","prop","descriptor","_getOwnPropertyDescriptor","default","assign","enumerable","writable","_defineProperty","lodashDefaults","json","_deleteProperty","logger","console","_request","protoprepareFetchOptions","exports","_prepareFetchOptions","setRequestTimings","now","Date","getTime","$timings","requestStart","networkStart","setTimingsAndFetch","opts","fetch","interceptors","HttpStatusInterceptor","create","defaults","request"],"sources":["index.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {assign, curry, defaults as lodashDefaults, isString} from 'lodash';\n\nimport HttpStatusInterceptor from './interceptors/http-status';\nimport _request from './request';\nimport {prepareFetchOptions as _prepareFetchOptions} from './request/utils';\n\n// Curry protorequest so we generate a function with default options built in.\nconst protorequest = curry(function protorequest(defaultOptions, options) {\n // allow for options to be a string (and therefore expect options in the third\n // position) to match request's api.\n if (isString(options)) {\n const uri = options;\n\n /* eslint prefer-rest-params: [0] */\n options = arguments[2] || {};\n options.uri = uri;\n }\n\n // Hide useless elements from logs\n ['download', 'interceptors', 'logger', 'upload'].forEach((prop) => {\n let descriptor = Reflect.getOwnPropertyDescriptor(options, prop);\n\n descriptor = assign({}, descriptor, {\n enumerable: false,\n writable: true,\n });\n Reflect.defineProperty(options, prop, descriptor);\n });\n\n lodashDefaults(options, defaultOptions);\n\n if (!options.json && options.json !== false) {\n Reflect.deleteProperty(options, 'json');\n }\n\n options.logger = options.logger || this.logger || console;\n\n return _request(options);\n});\n\nexport const protoprepareFetchOptions = curry(function protoprepareFetchOptions(\n defaultOptions,\n options\n) {\n // Hide useless elements from logs\n ['download', 'interceptors', 'logger', 'upload'].forEach((prop) => {\n let descriptor = Reflect.getOwnPropertyDescriptor(options, prop);\n\n descriptor = assign({}, descriptor, {\n enumerable: false,\n writable: true,\n });\n Reflect.defineProperty(options, prop, descriptor);\n });\n\n lodashDefaults(options, defaultOptions);\n\n options.logger = options.logger || this.logger || console;\n\n return _prepareFetchOptions(options);\n});\n\n/**\n * Sets the $timings value(s) before the request/fetch.\n * This function is only useful if you are about to send a request\n * using prepared fetch options; normally it is done in webex.request();\n *\n * @param {any} options\n * @returns {any} the updated options object\n */\nconst setRequestTimings = (options) => {\n const now = new Date().getTime();\n options.$timings = options.$timings || {};\n options.$timings.requestStart = now;\n options.$timings.networkStart = now;\n\n return options;\n};\n\n/**\n * Submits a metric from pre-built request options via the fetch API. Updates\n * the \"$timings\" values to Date.now() since the existing times were set when\n * the options were built (not submitted).\n *\n * @param {any} options - the pre-built request options for submitting a metric\n * @returns {Promise} promise that resolves to a response object\n */\nexport const setTimingsAndFetch = (options) => {\n const opts = setRequestTimings(options);\n\n // call the fetch API\n return fetch(opts.uri, opts);\n};\n\nconst defaultOptions = {\n json: true,\n interceptors: [\n // Reminder: this is supposed to be an instantiated interceptor.\n HttpStatusInterceptor.create(),\n ],\n};\n\nexport const defaults = protorequest;\nexport const request = protorequest(defaultOptions);\nexport {default as ProgressEvent} from './progress-event';\nexport {default as Interceptor} from './lib/interceptor';\nexport {default as HttpError} from './http-error';\nexport {default as HttpStatusInterceptor} from './interceptors/http-status';\nexport {default as detect} from './lib/detect';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,SAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAoGA,IAAAK,cAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,YAAA,GAAAJ,sBAAA,CAAAF,OAAA;AACA,IAAAO,UAAA,GAAAL,sBAAA,CAAAF,OAAA;AAEA,IAAAQ,OAAA,GAAAN,sBAAA,CAAAF,OAAA;AAhHA;AACA;AACA;;AAQA;AACA,IAAMS,YAAY,GAAG,IAAAC,aAAK,EAAC,SAASD,YAAYA,CAACE,cAAc,EAAEC,OAAO,EAAE;EACxE;EACA;EACA,IAAI,IAAAC,gBAAQ,EAACD,OAAO,CAAC,EAAE;IACrB,IAAME,GAAG,GAAGF,OAAO;;IAEnB;IACAA,OAAO,GAAGG,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAC5BH,OAAO,CAACE,GAAG,GAAGA,GAAG;EACnB;;EAEA;EACA,CAAC,UAAU,EAAE,cAAc,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAACE,OAAO,CAAC,UAACC,IAAI,EAAK;IACjE,IAAIC,UAAU,GAAG,IAAAC,yBAAA,CAAAC,OAAA,EAAiCR,OAAO,EAAEK,IAAI,CAAC;IAEhEC,UAAU,GAAG,IAAAG,cAAM,EAAC,CAAC,C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AO;EAEzD,OAAO,IAAAI,0BAAoB,EAACrB,OAAO,CAAC;AACtC,CAAC,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMsB,iBAAiB,GAAG,SAApBA,iBAAiBA,CAAItB,OAAO,EAAK;EACrC,IAAMuB,GAAG,GAAG,IAAIC,IAAI,CAAC,CAAC,CAACC,OAAO,CAAC,CAAC;EAChCzB,OAAO,CAAC0B,QAAQ,GAAG1B,OAAO,CAAC0B,QAAQ,IAAI,CAAC,CAAC;EACzC1B,OAAO,CAAC0B,QAAQ,CAACC,YAAY,GAAGJ,GAAG;EACnCvB,OAAO,CAAC0B,QAAQ,CAACE,YAAY,GAAGL,GAAG;EAEnC,OAAOvB,OAAO;AAChB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,IAAM6B,kBAAkB,GAAAT,OAAA,CAAAS,kBAAA,GAAG,SAArBA,kBAAkBA,CAAI7B,OAAO,EAAK;EAC7C,IAAM8B,IAAI,GAAGR,iBAAiB,CAACtB,OAAO,CAAC;;EAEvC;EACA,OAAO+B,KAAK,CAACD,IAAI,CAAC5B,GAAG,EAAE4B,IAAI,CAAC;AAC9B,CAAC;AAED,IAAM/B,cAAc,GAAG;EACrBe,IAAI,EAAE,IAAI;EACVkB,YAAY,EAAE;EACZ;EACAC,mBAAqB,CAACC,MAAM,CAAC,CAAC;AAElC,CAAC;AAEM,IAAMC,QAAQ,GAAAf,OAAA,CAAAe,QAAA,GAAGtC,YAAY;AAC7B,IAAMuC,OAAO,GAAAhB,OAAA,CAAAgB,OAAA,GAAGvC,YAAY,CAACE,cAAc,CAAC"}
|
|
@@ -18,13 +18,15 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs2/he
|
|
|
18
18
|
var _httpError = _interopRequireDefault(require("../http-error"));
|
|
19
19
|
var _interceptor = _interopRequireDefault(require("../lib/interceptor"));
|
|
20
20
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
21
|
-
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; } }
|
|
21
|
+
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; } } /*!
|
|
22
|
+
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
23
|
+
*/
|
|
22
24
|
var LOCUS_REDIRECT_ERROR = 2000002;
|
|
23
25
|
|
|
24
26
|
/**
|
|
25
27
|
* @class
|
|
26
28
|
*/
|
|
27
|
-
var HttpStatusInterceptor = /*#__PURE__*/function (_Interceptor) {
|
|
29
|
+
var HttpStatusInterceptor = exports.default = /*#__PURE__*/function (_Interceptor) {
|
|
28
30
|
(0, _inherits2.default)(HttpStatusInterceptor, _Interceptor);
|
|
29
31
|
var _super = _createSuper(HttpStatusInterceptor);
|
|
30
32
|
/**
|
|
@@ -81,5 +83,4 @@ var HttpStatusInterceptor = /*#__PURE__*/function (_Interceptor) {
|
|
|
81
83
|
}]);
|
|
82
84
|
return HttpStatusInterceptor;
|
|
83
85
|
}(_interceptor.default);
|
|
84
|
-
exports.default = HttpStatusInterceptor;
|
|
85
86
|
//# sourceMappingURL=http-status.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["LOCUS_REDIRECT_ERROR","HttpStatusInterceptor","webex","options","ErrorConstructor","error","HttpError","value","response","statusCode","resolve","body","errorCode","reject","select","Interceptor"],"sources":["http-status.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport HttpError from '../http-error';\nimport Interceptor from '../lib/interceptor';\n\nconst LOCUS_REDIRECT_ERROR = 2000002;\n\n/**\n * @class\n */\nexport default class HttpStatusInterceptor extends Interceptor {\n /**\n * @param {Object} webex\n * @param {Object} options\n * @returns {HttpStatusInterceptor}\n */\n constructor(webex, options) {\n super(webex);\n const ErrorConstructor = (options && (options.error || options.ErrorConstructor)) || HttpError;\n\n Object.defineProperties(this, {\n ErrorConstructor: {\n value: ErrorConstructor,\n },\n });\n }\n\n /**\n * @param {Object} options\n * @returns {HttpStatusInterceptor}\n */\n static create(options) {\n return new HttpStatusInterceptor(this, options);\n }\n\n /**\n * @param {Object} options\n * @param {HttpResponse} response\n * @returns {Promise}\n */\n onResponse(options, response) {\n if (response.statusCode) {\n if (response.statusCode < 400) {\n return Promise.resolve(response);\n }\n // to handle locus redirects\n if (\n response.statusCode === 404 &&\n response.body &&\n response.body.errorCode === LOCUS_REDIRECT_ERROR\n ) {\n return Promise.resolve(response);\n }\n }\n\n // Note: the extra parenthesis below are required to make sure `new` is\n // applied to the correct method (i.e., the result of `select()`, not\n // `select()` itself).\n return Promise.reject(new (this.ErrorConstructor.select(response.statusCode))(response));\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAIA;AACA;AAA6C;AAAA;
|
|
1
|
+
{"version":3,"names":["_httpError","_interopRequireDefault","require","_interceptor","_createSuper","Derived","hasNativeReflectConstruct","_isNativeReflectConstruct","_createSuperInternal","Super","_getPrototypeOf2","default","result","NewTarget","constructor","_Reflect$construct","arguments","apply","_possibleConstructorReturn2","Reflect","sham","Proxy","Boolean","prototype","valueOf","call","e","LOCUS_REDIRECT_ERROR","HttpStatusInterceptor","exports","_Interceptor","_inherits2","_super","webex","options","_this","_classCallCheck2","ErrorConstructor","error","HttpError","_defineProperties","_assertThisInitialized2","value","_createClass2","key","onResponse","response","statusCode","_promise","resolve","body","errorCode","reject","select","create","Interceptor"],"sources":["http-status.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport HttpError from '../http-error';\nimport Interceptor from '../lib/interceptor';\n\nconst LOCUS_REDIRECT_ERROR = 2000002;\n\n/**\n * @class\n */\nexport default class HttpStatusInterceptor extends Interceptor {\n /**\n * @param {Object} webex\n * @param {Object} options\n * @returns {HttpStatusInterceptor}\n */\n constructor(webex, options) {\n super(webex);\n const ErrorConstructor = (options && (options.error || options.ErrorConstructor)) || HttpError;\n\n Object.defineProperties(this, {\n ErrorConstructor: {\n value: ErrorConstructor,\n },\n });\n }\n\n /**\n * @param {Object} options\n * @returns {HttpStatusInterceptor}\n */\n static create(options) {\n return new HttpStatusInterceptor(this, options);\n }\n\n /**\n * @param {Object} options\n * @param {HttpResponse} response\n * @returns {Promise}\n */\n onResponse(options, response) {\n if (response.statusCode) {\n if (response.statusCode < 400) {\n return Promise.resolve(response);\n }\n // to handle locus redirects\n if (\n response.statusCode === 404 &&\n response.body &&\n response.body.errorCode === LOCUS_REDIRECT_ERROR\n ) {\n return Promise.resolve(response);\n }\n }\n\n // Note: the extra parenthesis below are required to make sure `new` is\n // applied to the correct method (i.e., the result of `select()`, not\n // `select()` itself).\n return Promise.reject(new (this.ErrorConstructor.select(response.statusCode))(response));\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAIA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAF,sBAAA,CAAAC,OAAA;AAA6C,SAAAE,aAAAC,OAAA,QAAAC,yBAAA,GAAAC,yBAAA,oBAAAC,qBAAA,QAAAC,KAAA,OAAAC,gBAAA,CAAAC,OAAA,EAAAN,OAAA,GAAAO,MAAA,MAAAN,yBAAA,QAAAO,SAAA,OAAAH,gBAAA,CAAAC,OA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AG,WAAWX,OAAO,EAAEY,QAAQ,EAAE;MAC5B,IAAIA,QAAQ,CAACC,UAAU,EAAE;QACvB,IAAID,QAAQ,CAACC,UAAU,GAAG,GAAG,EAAE;UAC7B,OAAOC,QAAA,CAAArC,OAAA,CAAQsC,OAAO,CAACH,QAAQ,CAAC;QAClC;QACA;QACA,IACEA,QAAQ,CAACC,UAAU,KAAK,GAAG,IAC3BD,QAAQ,CAACI,IAAI,IACbJ,QAAQ,CAACI,IAAI,CAACC,SAAS,KAAKxB,oBAAoB,EAChD;UACA,OAAOqB,QAAA,CAAArC,OAAA,CAAQsC,OAAO,CAACH,QAAQ,CAAC;QAClC;MACF;;MAEA;MACA;MACA;MACA,OAAOE,QAAA,CAAArC,OAAA,CAAQyC,MAAM,CAAC,KAAK,IAAI,CAACf,gBAAgB,CAACgB,MAAM,CAACP,QAAQ,CAACC,UAAU,CAAC,EAAED,QAAQ,CAAC,CAAC;IAC1F;EAAC;IAAAF,GAAA;IAAAF,KAAA,EA5BD,SAAAY,OAAcpB,OAAO,EAAE;MACrB,OAAO,IAAIN,qBAAqB,CAAC,IAAI,EAAEM,OAAO,CAAC;IACjD;EAAC;EAAA,OAAAN,qBAAA;AAAA,EAvBgD2B,oBAAW"}
|
package/dist/lib/detect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["detect","buffer","Blob","ArrayBuffer","Uint8Array","Error","type","fromBuffer","
|
|
1
|
+
{"version":3,"names":["_fileType","require","detect","_x","_detect","apply","arguments","_asyncToGenerator2","default","_regenerator","mark","_callee","buffer","fileType","wrap","_callee$","_context","prev","next","Blob","ArrayBuffer","Uint8Array","Error","abrupt","type","fromBuffer","sent","mime","stop"],"sources":["detect.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {fromBuffer} from 'file-type';\n\n/**\n * Determine mimeType for the specified buffer;\n * @param {Buffer|Uint8Array|ArrayBuffer} buffer\n * @returns {Promise<string>}\n */\nexport default async function detect(buffer) {\n if (\n !(buffer instanceof Blob) &&\n !(buffer instanceof ArrayBuffer) &&\n !(buffer instanceof Uint8Array)\n ) {\n throw new Error('`detect` requires a buffer of type Blob, ArrayBuffer, or Uint8Array');\n }\n\n if (buffer instanceof Blob) {\n return buffer.type;\n }\n\n // `fromBuffer()` can take a buffer that is either a ArrayBuffer or Uinit8Array\n const fileType = await fromBuffer(buffer);\n\n if (!fileType) {\n return 'application/octet-stream';\n }\n\n return fileType.mime;\n}\n"],"mappings":";;;;;;;;;;AAIA,IAAAA,SAAA,GAAAC,OAAA;AAJA;AACA;AACA;AAIA;AACA;AACA;AACA;AACA;AAJA,SAK8BC,MAAMA,CAAAC,EAAA;EAAA,OAAAC,OAAA,CAAAC,KAAA,OAAAC,SAAA;AAAA;AAAA,SAAAF,QAAA;EAAAA,OAAA,OAAAG,kBAAA,CAAAC,OAAA,gBAAAC,YAAA,CAAAD,OAAA,CAAAE,IAAA,CAArB,SAAAC,QAAsBC,MAAM;IAAA,IAAAC,QAAA;IAAA,OAAAJ,YAAA,CAAAD,OAAA,CAAAM,IAAA,UAAAC,SAAAC,QAAA;MAAA,kBAAAA,QAAA,CAAAC,IAAA,GAAAD,QAAA,CAAAE,IAAA;QAAA;UAAA,MAEvC,EAAEN,MAAM,YAAYO,IAAI,CAAC,IACzB,EAAEP,MAAM,YAAYQ,WAAW,CAAC,IAChC,EAAER,MAAM,YAAYS,UAAU,CAAC;YAAAL,QAAA,CAAAE,IAAA;YAAA;UAAA;UAAA,MAEzB,IAAII,KAAK,CAAC,qEAAqE,CAAC;QAAA;UAAA,MAGpFV,MAAM,YAAYO,IAAI;YAAAH,QAAA,CAAAE,IAAA;YAAA;UAAA;UAAA,OAAAF,QAAA,CAAAO,MAAA,WACjBX,MAAM,CAACY,IAAI;QAAA;UAAAR,QAAA,CAAAE,IAAA;UAAA,OAIG,IAAAO,oBAAU,EAACb,MAAM,CAAC;QAAA;UAAnCC,QAAQ,GAAAG,QAAA,CAAAU,IAAA;UAAA,IAETb,QAAQ;YAAAG,QAAA,CAAAE,IAAA;YAAA;UAAA;UAAA,OAAAF,QAAA,CAAAO,MAAA,WACJ,0BAA0B;QAAA;UAAA,OAAAP,QAAA,CAAAO,MAAA,WAG5BV,QAAQ,CAACc,IAAI;QAAA;QAAA;UAAA,OAAAX,QAAA,CAAAY,IAAA;MAAA;IAAA,GAAAjB,OAAA;EAAA,CACrB;EAAA,OAAAP,OAAA,CAAAC,KAAA,OAAAC,SAAA;AAAA"}
|
package/dist/lib/interceptor.js
CHANGED
|
@@ -12,11 +12,14 @@ var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/
|
|
|
12
12
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
13
13
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
|
|
14
14
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
|
|
15
|
-
var
|
|
15
|
+
var _lodash = require("lodash");
|
|
16
|
+
/*!
|
|
17
|
+
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
18
|
+
*/
|
|
16
19
|
/**
|
|
17
20
|
* @class
|
|
18
21
|
*/
|
|
19
|
-
var Interceptor = /*#__PURE__*/function () {
|
|
22
|
+
var Interceptor = exports.default = /*#__PURE__*/function () {
|
|
20
23
|
/**
|
|
21
24
|
* @constructor
|
|
22
25
|
* @param {Object} attrs
|
|
@@ -47,7 +50,7 @@ var Interceptor = /*#__PURE__*/function () {
|
|
|
47
50
|
key: "logOptions",
|
|
48
51
|
value: function logOptions() {
|
|
49
52
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
50
|
-
var logger = (0,
|
|
53
|
+
var logger = (0, _lodash.get)(this, 'webex.logger', console);
|
|
51
54
|
if (!process.env.ENABLE_VERBOSE_NETWORK_LOGGING || !logger) {
|
|
52
55
|
return;
|
|
53
56
|
}
|
|
@@ -116,5 +119,4 @@ var Interceptor = /*#__PURE__*/function () {
|
|
|
116
119
|
}]);
|
|
117
120
|
return Interceptor;
|
|
118
121
|
}();
|
|
119
|
-
exports.default = Interceptor;
|
|
120
122
|
//# sourceMappingURL=interceptor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Interceptor","attrs","forEach","key","value","enumerable","options","logger","console","process","env","ENABLE_VERBOSE_NETWORK_LOGGING","info","constructor","name","resolve","reason","reject","response","Error"],"sources":["interceptor.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {get} from 'lodash';\n\n/**\n * @class\n */\nexport default class Interceptor {\n /**\n * @constructor\n * @param {Object} attrs\n * @returns {UrlInterceptor}\n */\n constructor(attrs) {\n if (attrs) {\n Object.keys(attrs).forEach((key) => {\n const value = attrs[key];\n\n Reflect.defineProperty(this, key, {\n enumerable: true,\n value,\n });\n });\n }\n }\n\n /**\n * Logs the options of a request. This should be utilized\n * during the intercepting process, but can be used at any\n * time otherwise.\n * @param {object} options\n * @returns {void}\n */\n logOptions(options = {}) {\n const logger = get(this, 'webex.logger', console);\n\n if (!process.env.ENABLE_VERBOSE_NETWORK_LOGGING || !logger) {\n return;\n }\n\n // prepend a header for the interceptor\n logger.info('/***** Interceptor ****************************************************\\\\');\n\n logger.info(`${this.constructor.name} - ${JSON.stringify(options, null, 2)}`);\n }\n\n /**\n * @abstract\n * @returns {Interceptor}\n */\n static create() {\n throw new Error('`Interceptor.create()` must be defined');\n }\n\n /**\n * Transform request options before sending them\n * @param {Object} options\n * @returns {Promise<Object>}\n */\n onRequest(options) {\n return Promise.resolve(options);\n }\n\n /**\n * Handle request failures\n * @param {Object} options\n * @param {Error} reason\n * @returns {RejectedPromise<Error>}\n */\n onRequestError(options, reason) {\n return Promise.reject(reason);\n }\n\n /**\n * Transform response before returning it\n * @param {Object} options\n * @param {HttpResponse} response\n * @returns {Promise<HttpResponse>}\n */\n onResponse(options, response) {\n return Promise.resolve(response);\n }\n\n /**\n * Handle response errors\n * @param {Object} options\n * @param {WebexHttpError} reason\n * @returns {Promise<WebexHttpError>}\n */\n onResponseError(options, reason) {\n return Promise.reject(reason);\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_lodash","require","Interceptor","exports","default","attrs","_this","_classCallCheck2","_keys","forEach","key","value","_defineProperty","enumerable","_createClass2","logOptions","options","arguments","length","undefined","logger","get","console","process","env","ENABLE_VERBOSE_NETWORK_LOGGING","info","concat","constructor","name","_stringify","onRequest","_promise","resolve","onRequestError","reason","reject","onResponse","response","onResponseError","create","Error"],"sources":["interceptor.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {get} from 'lodash';\n\n/**\n * @class\n */\nexport default class Interceptor {\n /**\n * @constructor\n * @param {Object} attrs\n * @returns {UrlInterceptor}\n */\n constructor(attrs) {\n if (attrs) {\n Object.keys(attrs).forEach((key) => {\n const value = attrs[key];\n\n Reflect.defineProperty(this, key, {\n enumerable: true,\n value,\n });\n });\n }\n }\n\n /**\n * Logs the options of a request. This should be utilized\n * during the intercepting process, but can be used at any\n * time otherwise.\n * @param {object} options\n * @returns {void}\n */\n logOptions(options = {}) {\n const logger = get(this, 'webex.logger', console);\n\n if (!process.env.ENABLE_VERBOSE_NETWORK_LOGGING || !logger) {\n return;\n }\n\n // prepend a header for the interceptor\n logger.info('/***** Interceptor ****************************************************\\\\');\n\n logger.info(`${this.constructor.name} - ${JSON.stringify(options, null, 2)}`);\n }\n\n /**\n * @abstract\n * @returns {Interceptor}\n */\n static create() {\n throw new Error('`Interceptor.create()` must be defined');\n }\n\n /**\n * Transform request options before sending them\n * @param {Object} options\n * @returns {Promise<Object>}\n */\n onRequest(options) {\n return Promise.resolve(options);\n }\n\n /**\n * Handle request failures\n * @param {Object} options\n * @param {Error} reason\n * @returns {RejectedPromise<Error>}\n */\n onRequestError(options, reason) {\n return Promise.reject(reason);\n }\n\n /**\n * Transform response before returning it\n * @param {Object} options\n * @param {HttpResponse} response\n * @returns {Promise<HttpResponse>}\n */\n onResponse(options, response) {\n return Promise.resolve(response);\n }\n\n /**\n * Handle response errors\n * @param {Object} options\n * @param {WebexHttpError} reason\n * @returns {Promise<WebexHttpError>}\n */\n onResponseError(options, reason) {\n return Promise.reject(reason);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAIA,IAAAA,OAAA,GAAAC,OAAA;AAJA;AACA;AACA;AAIA;AACA;AACA;AAFA,IAGqBC,WAAW,GAAAC,OAAA,CAAAC,OAAA;EAC9B;AACF;AACA;AACA;AACA;EACE,SAAAF,YAAYG,KAAK,EAAE;IAAA,IAAAC,KAAA;IAAA,IAAAC,gBAAA,CAAAH,OAAA,QAAAF,WAAA;IACjB,IAAIG,KAAK,EAAE;MACT,IAAAG,KAAA,CAAAJ,OAAA,EAAYC,KAAK,CAAC,CAACI,OAAO,CAAC,UAACC,GAAG,EAAK;QAClC,IAAMC,KAAK,GAAGN,KAAK,CAACK,GAAG,CAAC;QAExB,IAAAE,eAAA,CAAAR,OAAA,EAAuBE,KAAI,EAAEI,GAAG,EAAE;UAChCG,UAAU,EAAE,IAAI;UAChBF,KAAK,EAALA;QACF,CAAC,CAAC;MACJ,CAAC,CAAC;IACJ;EACF;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EANE,IAAAG,aAAA,CAAAV,OAAA,EAAAF,WAAA;IAAAQ,GAAA;IAAAC,KAAA,EAOA,SAAAI,WAAA,EAAyB;MAAA,IAAdC,OAAO,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;MACrB,IAAMG,MAAM,GAAG,IAAAC,WAAG,EAAC,IAAI,EAAE,cAAc,EAAEC,OAAO,CAAC;MAEjD,IAAI,CAACC,OAAO,CAACC,GAAG,CAACC,8BAA8B,IAAI,CAACL,MAAM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function errorFunc(evt) {
|
|
100
100
|
clearTimeout(timeoutTimer);
|
|
101
101
|
if (!(evt instanceof Error)) {
|
|
102
|
-
|
|
102
|
+
if (evt instanceof ProgressEvent) {
|
|
103
|
+
var _evt$target;
|
|
104
|
+
evt = new Error("XMLHttpRequest Error: ProgressEvent: loaded=".concat(evt.loaded, ", total=").concat(evt.total, ", lengthComputable=").concat(evt.lengthComputable, ", target.readyState=").concat((_evt$target = evt.target) === null || _evt$target === void 0 ? void 0 : _evt$target.readyState));
|
|
105
|
+
} else {
|
|
106
|
+
evt = new Error('' + (evt || 'Unknown XMLHttpRequest Error'));
|
|
107
|
+
}
|
|
103
108
|
}
|
|
104
109
|
evt.statusCode = 0;
|
|
105
110
|
return callback(evt, failureResponse);
|
|
@@ -231,6 +236,5 @@ function getXml(xhr) {
|
|
|
231
236
|
return null;
|
|
232
237
|
}
|
|
233
238
|
function noop() {}
|
|
234
|
-
var _default = createXHR;
|
|
235
|
-
exports.default = _default;
|
|
239
|
+
var _default = exports.default = createXHR;
|
|
236
240
|
//# sourceMappingURL=xhr.js.map
|
package/dist/lib/xhr.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["window","require","isFunction","parseHeaders","xtend","createXHR","XMLHttpRequest","noop","XDomainRequest","forEachArray","method","uri","options","callback","initParams","toUpperCase","_createXHR","array","iterator","i","length","isEmpty","obj","hasOwnProperty","params","Error","called","cbOnce","err","response","body","readystatechange","xhr","readyState","setTimeout","loadFunc","getBody","undefined","responseText","getXml","isJson","JSON","parse","e","errorFunc","evt","clearTimeout","timeoutTimer","statusCode","failureResponse","aborted","status","useXDR","headers","url","rawRequest","getAllResponseHeaders","cors","key","data","sync","json","onreadystatechange","onload","onerror","onprogress","onabort","ontimeout","open","username","password","withCredentials","timeout","abort","code","setRequestHeader","responseType","beforeSend","send","responseXML","firefoxBugTakenEffect","documentElement","nodeName"],"sources":["xhr.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n// Need to fork xhr to support environments with full object freezing; namely,\n// SalesForce's Aura and Locker environment.\n\n// See https://github.com/naugtur/xhr for license information\n\n// Maintain the original code style of https://github.com/naugtur/xhr since\n// we're trying to diverge as little as possible.\n/* eslint-disable */\n\n'use strict';\nvar window = require('global/window');\nvar isFunction = require('is-function');\nvar parseHeaders = require('parse-headers');\nvar xtend = require('xtend');\n\ncreateXHR.XMLHttpRequest = window.XMLHttpRequest || noop;\ncreateXHR.XDomainRequest =\n 'withCredentials' in new createXHR.XMLHttpRequest()\n ? createXHR.XMLHttpRequest\n : window.XDomainRequest;\n\nforEachArray(['get', 'put', 'post', 'patch', 'head', 'delete'], function (method) {\n createXHR[method === 'delete' ? 'del' : method] = function (uri, options, callback) {\n options = initParams(uri, options, callback);\n options.method = method.toUpperCase();\n return _createXHR(options);\n };\n});\n\nfunction forEachArray(array, iterator) {\n for (var i = 0; i < array.length; i += 1) {\n iterator(array[i]);\n }\n}\n\nfunction isEmpty(obj) {\n for (var i in obj) {\n if (obj.hasOwnProperty(i)) return false;\n }\n return true;\n}\n\nfunction initParams(uri, options, callback) {\n var params = uri;\n\n if (isFunction(options)) {\n callback = options;\n if (typeof uri === 'string') {\n params = {uri: uri};\n }\n } else {\n params = xtend(options, {uri: uri});\n }\n\n params.callback = callback;\n return params;\n}\n\nfunction createXHR(uri, options, callback) {\n options = initParams(uri, options, callback);\n return _createXHR(options);\n}\n\nfunction _createXHR(options) {\n if (typeof options.callback === 'undefined') {\n throw new Error('callback argument missing');\n }\n\n var called = false;\n var callback = function cbOnce(err, response, body) {\n if (!called) {\n called = true;\n options.callback(err, response, body);\n }\n };\n\n function readystatechange() {\n if (xhr.readyState === 4) {\n setTimeout(loadFunc, 0);\n }\n }\n\n function getBody() {\n // Chrome with requestType=blob throws errors arround when even testing access to responseText\n var body = undefined;\n\n if (xhr.response) {\n body = xhr.response;\n } else {\n body = xhr.responseText || getXml(xhr);\n }\n\n if (isJson) {\n try {\n body = JSON.parse(body);\n } catch (e) {}\n }\n\n return body;\n }\n\n function errorFunc(evt) {\n clearTimeout(timeoutTimer);\n if (!(evt instanceof Error)) {\n evt = new Error('' + (evt || 'Unknown XMLHttpRequest Error'));\n }\n evt.statusCode = 0;\n return callback(evt, failureResponse);\n }\n\n // will load the data & process the response in a special response object\n function loadFunc() {\n if (aborted) return;\n var status;\n clearTimeout(timeoutTimer);\n if (options.useXDR && xhr.status === undefined) {\n //IE8 CORS GET successful response doesn't have a status field, but body is fine\n status = 200;\n } else {\n status = xhr.status === 1223 ? 204 : xhr.status;\n }\n var response = failureResponse;\n var err = null;\n\n if (status !== 0) {\n response = {\n body: getBody(),\n statusCode: status,\n method: method,\n headers: {},\n url: uri,\n rawRequest: xhr,\n };\n if (xhr.getAllResponseHeaders) {\n //remember xhr can in fact be XDR for CORS in IE\n response.headers = parseHeaders(xhr.getAllResponseHeaders());\n }\n } else {\n err = new Error('Internal XMLHttpRequest Error');\n }\n return callback(err, response, response.body);\n }\n\n var xhr = options.xhr || null;\n\n if (!xhr) {\n if (options.cors || options.useXDR) {\n xhr = new createXHR.XDomainRequest();\n } else {\n xhr = new createXHR.XMLHttpRequest();\n }\n }\n\n var key;\n var aborted;\n var uri = options.uri || options.url;\n var method = options.method || 'GET';\n var body = options.body || options.data;\n var headers = options.headers || {};\n var sync = !!options.sync;\n var isJson = false;\n var timeoutTimer;\n var failureResponse = {\n body: undefined,\n headers: {},\n statusCode: 0,\n method: method,\n url: uri,\n rawRequest: xhr,\n };\n\n if ('json' in options && options.json !== false) {\n isJson = true;\n headers['accept'] || headers['Accept'] || (headers['Accept'] = 'application/json'); //Don't override existing accept header declared by user\n if (method !== 'GET' && method !== 'HEAD') {\n headers['content-type'] ||\n headers['Content-Type'] ||\n (headers['Content-Type'] = 'application/json'); //Don't override existing accept header declared by user\n body = JSON.stringify(options.json === true ? body : options.json);\n }\n }\n\n xhr.onreadystatechange = readystatechange;\n xhr.onload = loadFunc;\n xhr.onerror = errorFunc;\n // IE9 must have onprogress be set to a unique function.\n xhr.onprogress = function () {\n // IE must die\n };\n xhr.onabort = function () {\n aborted = true;\n };\n xhr.ontimeout = errorFunc;\n xhr.open(method, uri, !sync, options.username, options.password);\n //has to be after open\n if (!sync) {\n xhr.withCredentials = !!options.withCredentials;\n }\n // Cannot set timeout with sync request\n // not setting timeout on the xhr object, because of old webkits etc. not handling that correctly\n // both npm's request and jquery 1.x use this kind of timeout, so this is being consistent\n if (!sync && options.timeout > 0) {\n timeoutTimer = setTimeout(function () {\n if (aborted) return;\n aborted = true; //IE9 may still call readystatechange\n xhr.abort('timeout');\n var e = new Error('XMLHttpRequest timeout');\n e.code = 'ETIMEDOUT';\n errorFunc(e);\n }, options.timeout);\n }\n\n if (xhr.setRequestHeader) {\n for (key in headers) {\n if (headers.hasOwnProperty(key)) {\n xhr.setRequestHeader(key, headers[key]);\n }\n }\n } else if (options.headers && !isEmpty(options.headers)) {\n throw new Error('Headers cannot be set on an XDomainRequest object');\n }\n\n if ('responseType' in options) {\n xhr.responseType = options.responseType;\n }\n\n if ('beforeSend' in options && typeof options.beforeSend === 'function') {\n options.beforeSend(xhr);\n }\n\n // Microsoft Edge browser sends \"undefined\" when send is called with undefined value.\n // XMLHttpRequest spec says to pass null as body to indicate no body\n // See https://github.com/naugtur/xhr/issues/100.\n xhr.send(body || null);\n\n return xhr;\n}\n\nfunction getXml(xhr) {\n if (xhr.responseType === 'document') {\n return xhr.responseXML;\n }\n var firefoxBugTakenEffect =\n xhr.responseXML && xhr.responseXML.documentElement.nodeName === 'parsererror';\n if (xhr.responseType === '' && !firefoxBugTakenEffect) {\n return xhr.responseXML;\n }\n\n return null;\n}\n\nfunction noop() {}\n\nexport default createXHR;\n"],"mappings":"AAAA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA,YAAY;;AAAC;AAAA;AAAA;EAAA;AAAA;AAAA;AAAA;AACb,IAAIA,MAAM,GAAGC,OAAO,CAAC,eAAe,CAA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Q,KAAK,aAAa;EAC/E,IAAIlD,GAAG,CAAC4C,YAAY,KAAK,EAAE,IAAI,CAACI,qBAAqB,EAAE;IACrD,OAAOhD,GAAG,CAAC+C,WAAW;EACxB;EAEA,OAAO,IAAI;AACb;AAEA,SAASxE,IAAI,GAAG,CAAC;AAAC,eAEHF,SAAS;AAAA"}
|
|
1
|
+
{"version":3,"names":["_Object$defineProperty","require","_interopRequireDefault","exports","value","default","_stringify","window","isFunction","parseHeaders","xtend","createXHR","XMLHttpRequest","noop","XDomainRequest","forEachArray","method","uri","options","callback","initParams","toUpperCase","_createXHR","array","iterator","i","length","isEmpty","obj","hasOwnProperty","params","Error","called","cbOnce","err","response","body","readystatechange","xhr","readyState","setTimeout","loadFunc","getBody","undefined","responseText","getXml","isJson","JSON","parse","e","errorFunc","evt","clearTimeout","timeoutTimer","ProgressEvent","_evt$target","concat","loaded","total","lengthComputable","target","statusCode","failureResponse","aborted","status","useXDR","headers","url","rawRequest","getAllResponseHeaders","cors","key","data","sync","json","onreadystatechange","onload","onerror","onprogress","onabort","ontimeout","open","username","password","withCredentials","timeout","abort","code","setRequestHeader","responseType","beforeSend","send","responseXML","firefoxBugTakenEffect","documentElement","nodeName","_default"],"sources":["xhr.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n// Need to fork xhr to support environments with full object freezing; namely,\n// SalesForce's Aura and Locker environment.\n\n// See https://github.com/naugtur/xhr for license information\n\n// Maintain the original code style of https://github.com/naugtur/xhr since\n// we're trying to diverge as little as possible.\n/* eslint-disable */\n\n'use strict';\nvar window = require('global/window');\nvar isFunction = require('is-function');\nvar parseHeaders = require('parse-headers');\nvar xtend = require('xtend');\n\ncreateXHR.XMLHttpRequest = window.XMLHttpRequest || noop;\ncreateXHR.XDomainRequest =\n 'withCredentials' in new createXHR.XMLHttpRequest()\n ? createXHR.XMLHttpRequest\n : window.XDomainRequest;\n\nforEachArray(['get', 'put', 'post', 'patch', 'head', 'delete'], function (method) {\n createXHR[method === 'delete' ? 'del' : method] = function (uri, options, callback) {\n options = initParams(uri, options, callback);\n options.method = method.toUpperCase();\n return _createXHR(options);\n };\n});\n\nfunction forEachArray(array, iterator) {\n for (var i = 0; i < array.length; i += 1) {\n iterator(array[i]);\n }\n}\n\nfunction isEmpty(obj) {\n for (var i in obj) {\n if (obj.hasOwnProperty(i)) return false;\n }\n return true;\n}\n\nfunction initParams(uri, options, callback) {\n var params = uri;\n\n if (isFunction(options)) {\n callback = options;\n if (typeof uri === 'string') {\n params = {uri: uri};\n }\n } else {\n params = xtend(options, {uri: uri});\n }\n\n params.callback = callback;\n return params;\n}\n\nfunction createXHR(uri, options, callback) {\n options = initParams(uri, options, callback);\n return _createXHR(options);\n}\n\nfunction _createXHR(options) {\n if (typeof options.callback === 'undefined') {\n throw new Error('callback argument missing');\n }\n\n var called = false;\n var callback = function cbOnce(err, response, body) {\n if (!called) {\n called = true;\n options.callback(err, response, body);\n }\n };\n\n function readystatechange() {\n if (xhr.readyState === 4) {\n setTimeout(loadFunc, 0);\n }\n }\n\n function getBody() {\n // Chrome with requestType=blob throws errors arround when even testing access to responseText\n var body = undefined;\n\n if (xhr.response) {\n body = xhr.response;\n } else {\n body = xhr.responseText || getXml(xhr);\n }\n\n if (isJson) {\n try {\n body = JSON.parse(body);\n } catch (e) {}\n }\n\n return body;\n }\n\n function errorFunc(evt) {\n clearTimeout(timeoutTimer);\n if (!(evt instanceof Error)) {\n if (evt instanceof ProgressEvent) {\n evt = new Error(`XMLHttpRequest Error: ProgressEvent: loaded=${evt.loaded}, total=${evt.total}, lengthComputable=${evt.lengthComputable}, target.readyState=${evt.target?.readyState}`)\n } else {\n evt = new Error('' + (evt || 'Unknown XMLHttpRequest Error'));\n }\n }\n evt.statusCode = 0;\n return callback(evt, failureResponse);\n }\n\n // will load the data & process the response in a special response object\n function loadFunc() {\n if (aborted) return;\n var status;\n clearTimeout(timeoutTimer);\n if (options.useXDR && xhr.status === undefined) {\n //IE8 CORS GET successful response doesn't have a status field, but body is fine\n status = 200;\n } else {\n status = xhr.status === 1223 ? 204 : xhr.status;\n }\n var response = failureResponse;\n var err = null;\n\n if (status !== 0) {\n response = {\n body: getBody(),\n statusCode: status,\n method: method,\n headers: {},\n url: uri,\n rawRequest: xhr,\n };\n if (xhr.getAllResponseHeaders) {\n //remember xhr can in fact be XDR for CORS in IE\n response.headers = parseHeaders(xhr.getAllResponseHeaders());\n }\n } else {\n err = new Error('Internal XMLHttpRequest Error');\n }\n return callback(err, response, response.body);\n }\n\n var xhr = options.xhr || null;\n\n if (!xhr) {\n if (options.cors || options.useXDR) {\n xhr = new createXHR.XDomainRequest();\n } else {\n xhr = new createXHR.XMLHttpRequest();\n }\n }\n\n var key;\n var aborted;\n var uri = options.uri || options.url;\n var method = options.method || 'GET';\n var body = options.body || options.data;\n var headers = options.headers || {};\n var sync = !!options.sync;\n var isJson = false;\n var timeoutTimer;\n var failureResponse = {\n body: undefined,\n headers: {},\n statusCode: 0,\n method: method,\n url: uri,\n rawRequest: xhr,\n };\n\n if ('json' in options && options.json !== false) {\n isJson = true;\n headers['accept'] || headers['Accept'] || (headers['Accept'] = 'application/json'); //Don't override existing accept header declared by user\n if (method !== 'GET' && method !== 'HEAD') {\n headers['content-type'] ||\n headers['Content-Type'] ||\n (headers['Content-Type'] = 'application/json'); //Don't override existing accept header declared by user\n body = JSON.stringify(options.json === true ? body : options.json);\n }\n }\n\n xhr.onreadystatechange = readystatechange;\n xhr.onload = loadFunc;\n xhr.onerror = errorFunc;\n // IE9 must have onprogress be set to a unique function.\n xhr.onprogress = function () {\n // IE must die\n };\n xhr.onabort = function () {\n aborted = true;\n };\n xhr.ontimeout = errorFunc;\n xhr.open(method, uri, !sync, options.username, options.password);\n //has to be after open\n if (!sync) {\n xhr.withCredentials = !!options.withCredentials;\n }\n // Cannot set timeout with sync request\n // not setting timeout on the xhr object, because of old webkits etc. not handling that correctly\n // both npm's request and jquery 1.x use this kind of timeout, so this is being consistent\n if (!sync && options.timeout > 0) {\n timeoutTimer = setTimeout(function () {\n if (aborted) return;\n aborted = true; //IE9 may still call readystatechange\n xhr.abort('timeout');\n var e = new Error('XMLHttpRequest timeout');\n e.code = 'ETIMEDOUT';\n errorFunc(e);\n }, options.timeout);\n }\n\n if (xhr.setRequestHeader) {\n for (key in headers) {\n if (headers.hasOwnProperty(key)) {\n xhr.setRequestHeader(key, headers[key]);\n }\n }\n } else if (options.headers && !isEmpty(options.headers)) {\n throw new Error('Headers cannot be set on an XDomainRequest object');\n }\n\n if ('responseType' in options) {\n xhr.responseType = options.responseType;\n }\n\n if ('beforeSend' in options && typeof options.beforeSend === 'function') {\n options.beforeSend(xhr);\n }\n\n // Microsoft Edge browser sends \"undefined\" when send is called with undefined value.\n // XMLHttpRequest spec says to pass null as body to indicate no body\n // See https://github.com/naugtur/xhr/issues/100.\n xhr.send(body || null);\n\n return xhr;\n}\n\nfunction getXml(xhr) {\n if (xhr.responseType === 'document') {\n return xhr.responseXML;\n }\n var firefoxBugTakenEffect =\n xhr.responseXML && xhr.responseXML.documentElement.nodeName === 'parsererror';\n if (xhr.responseType === '' && !firefoxBugTakenEffect) {\n return xhr.responseXML;\n }\n\n return null;\n}\n\nfunction noop() {}\n\nexport default createXHR;\n"],"mappings":"AAAA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA,YAAY;;AAAC,IAAAA,sBAAA,GAAAC,OAAA;AAAA,IAAAC,sBAAA,GAAAD,OAAA;AAAAD,sBAAA,CAAAG,OAAA;EAAAC,KAAA;AAAA;AAAAD,OAAA,CAAAE,OAAA;AAAA,IAAAC,UAAA,GAAAJ,sBAAA,CAAAD,OAAA;AACb,IAAIM,MAAM,GAAGN,OAAO,CAAC,eAAe,CAAC;AACrC,IAAIO,UAAU,GAAGP,OAAO,CAAC,aAAa,CAAC;AACvC,IAAIQ,YAAY,GAAGR,OAAO,CAAC,eAAe,CAAC;AAC3C,IAAIS,KAAK,GAAGT,OAAO,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IAAI,CAACvD,IAAI,IAAI,IAAI,CAAC;EAEtB,OAAOE,GAAG;AACZ;AAEA,SAASO,MAAMA,CAACP,GAAG,EAAE;EACnB,IAAIA,GAAG,CAACmD,YAAY,KAAK,UAAU,EAAE;IACnC,OAAOnD,GAAG,CAACsD,WAAW;EACxB;EACA,IAAIC,qBAAqB,GACvBvD,GAAG,CAACsD,WAAW,IAAItD,GAAG,CAACsD,WAAW,CAACE,eAAe,CAACC,QAAQ,KAAK,aAAa;EAC/E,IAAIzD,GAAG,CAACmD,YAAY,KAAK,EAAE,IAAI,CAACI,qBAAqB,EAAE;IACrD,OAAOvD,GAAG,CAACsD,WAAW;EACxB;EAEA,OAAO,IAAI;AACb;AAEA,SAAS/E,IAAIA,CAAA,EAAG,CAAC;AAAC,IAAAmF,QAAA,GAAA7F,OAAA,CAAAE,OAAA,GAEHM,SAAS"}
|
package/dist/progress-event.js
CHANGED
|
@@ -8,7 +8,11 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.default = ProgressEvent;
|
|
9
9
|
var _defineProperties = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/define-properties"));
|
|
10
10
|
var _isNan = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/number/is-nan"));
|
|
11
|
-
var
|
|
11
|
+
var _lodash = require("lodash");
|
|
12
|
+
/*!
|
|
13
|
+
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
14
|
+
*/
|
|
15
|
+
|
|
12
16
|
/**
|
|
13
17
|
* Object of the same shape as web browser ProgressEvents
|
|
14
18
|
* @class ProgressEvent
|
|
@@ -30,7 +34,7 @@ function ProgressEvent(loaded, total) {
|
|
|
30
34
|
},
|
|
31
35
|
lengthComputable: {
|
|
32
36
|
enumerable: true,
|
|
33
|
-
value: (0,
|
|
37
|
+
value: (0, _lodash.isNumber)(loaded) && !(0, _isNan.default)(loaded) && (0, _lodash.isNumber)(total) && !(0, _isNan.default)(total) && total > 0,
|
|
34
38
|
writable: false
|
|
35
39
|
}
|
|
36
40
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ProgressEvent","loaded","total","enumerable","value","writable","lengthComputable"],"sources":["progress-event.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {isNumber} from 'lodash';\n\n/**\n * Object of the same shape as web browser ProgressEvents\n * @class ProgressEvent\n * @param {integer} loaded\n * @param {integer} total\n * @returns {ProgressEvent}\n */\nexport default function ProgressEvent(loaded, total) {\n Object.defineProperties(this, {\n loaded: {\n enumerable: true,\n value: loaded,\n writable: false,\n },\n total: {\n enumerable: true,\n value: total,\n writable: false,\n },\n lengthComputable: {\n enumerable: true,\n value:\n isNumber(loaded) &&\n !Number.isNaN(loaded) &&\n isNumber(total) &&\n !Number.isNaN(total) &&\n total > 0,\n writable: false,\n },\n });\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_lodash","require","ProgressEvent","loaded","total","_defineProperties","default","enumerable","value","writable","lengthComputable","isNumber","_isNan"],"sources":["progress-event.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {isNumber} from 'lodash';\n\n/**\n * Object of the same shape as web browser ProgressEvents\n * @class ProgressEvent\n * @param {integer} loaded\n * @param {integer} total\n * @returns {ProgressEvent}\n */\nexport default function ProgressEvent(loaded, total) {\n Object.defineProperties(this, {\n loaded: {\n enumerable: true,\n value: loaded,\n writable: false,\n },\n total: {\n enumerable: true,\n value: total,\n writable: false,\n },\n lengthComputable: {\n enumerable: true,\n value:\n isNumber(loaded) &&\n !Number.isNaN(loaded) &&\n isNumber(total) &&\n !Number.isNaN(total) &&\n total > 0,\n writable: false,\n },\n });\n}\n"],"mappings":";;;;;;;;;;AAIA,IAAAA,OAAA,GAAAC,OAAA;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASC,aAAaA,CAACC,MAAM,EAAEC,KAAK,EAAE;EACnD,IAAAC,iBAAA,CAAAC,OAAA,EAAwB,IAAI,EAAE;IAC5BH,MAAM,EAAE;MACNI,UAAU,EAAE,IAAI;MAChBC,KAAK,EAAEL,MAAM;MACbM,QAAQ,EAAE;IACZ,CAAC;IACDL,KAAK,EAAE;MACLG,UAAU,EAAE,IAAI;MAChBC,KAAK,EAAEJ,KAAK;MACZK,QAAQ,EAAE;IACZ,CAAC;IACDC,gBAAgB,EAAE;MAChBH,UAAU,EAAE,IAAI;MAChBC,KAAK,EACH,IAAAG,gBAAQ,EAACR,MAAM,CAAC,IAChB,CAAC,IAAAS,MAAA,CAAAN,OAAA,EAAaH,MAAM,CAAC,IACrB,IAAAQ,gBAAQ,EAACP,KAAK,CAAC,IACf,CAAC,IAAAQ,MAAA,CAAAN,OAAA,EAAaF,KAAK,CAAC,IACpBA,KAAK,GAAG,CAAC;MACXK,QAAQ,EAAE;IACZ;EACF,CAAC,CAAC;AACJ"}
|