@shopgate/pwa-core 7.26.0 → 7.27.0-beta.2

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.
@@ -4,15 +4,22 @@ function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="s
4
4
  */var HttpRequest=/*#__PURE__*/function(_Request){/**
5
5
  * Initializes the HttpRequest object
6
6
  * @param {string} url The url for the request
7
- */function HttpRequest(url){var _this2;_classCallCheck(this,HttpRequest);_this2=_callSuper(this,HttpRequest);_this2.url=url;_this2.method='GET';_this2.followRedirects=false;_this2.timeout=30000;_this2.payload=null;_this2.contentType=null;_this2.createSerial(_this2.url);_this2.createEventCallbackName('httpResponse');return _this2;}/**
7
+ */function HttpRequest(url){var _this2;_classCallCheck(this,HttpRequest);_this2=_callSuper(this,HttpRequest);_this2.url=url;_this2.method='GET';_this2.followRedirects=false;_this2.timeout=30000;_this2.payload=null;_this2.contentType=null;_this2.headers=null;_this2.createSerial(_this2.url);_this2.createEventCallbackName('httpResponse');return _this2;}/**
8
8
  * Sets the payload for the HttpRequest
9
9
  * @param {Object|string} [payload={}] The payload to send with the request
10
10
  * @returns {HttpRequest}
11
11
  */_inherits(HttpRequest,_Request);return _createClass(HttpRequest,[{key:"setPayload",value:function setPayload(){var payload=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};this.payload=payload;return this;}/**
12
12
  * Sets the contentType for the HttpRequest
13
13
  * @param {string} type The contentType for request
14
+ * @deprecated Not supported anymore by app version >= 11.0.0
14
15
  * @returns {HttpRequest}
15
16
  */},{key:"setContentType",value:function setContentType(type){this.contentType=type;return this;}/**
17
+ * @typedef {Object.<string, string>} HeaderMap
18
+ */ /**
19
+ * Sets the headers for the HttpRequest.
20
+ * @param {HeaderMap} headers - An object mapping header names to values.
21
+ * @returns {HttpRequest} The current HttpRequest instance (for chaining).
22
+ */},{key:"setHeaders",value:function setHeaders(headers){if(_typeof(headers)!=='object'){logger.error('HttpRequest: setHeaders expects an object as parameter');return this;}this.headers=headers;return this;}/**
16
23
  * Sets the request method
17
24
  * @param {string} method The method string
18
25
  * @return {HttpRequest}
@@ -29,6 +36,9 @@ function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="s
29
36
  * @private
30
37
  * @return {string} The content type
31
38
  */},{key:"getContentType",value:function getContentType(){var contentType='text/plain';if(_typeof(this.payload)==='object'){contentType='application/x-www-form-urlencoded; charset=UTF-8';}return contentType;}/**
39
+ * Determines the headers for the request
40
+ * @returns {Object} The headers
41
+ */},{key:"getHeaders",value:function getHeaders(){if(!this.headers){return{};}return this.headers;}/**
32
42
  * Creates the data request body from the payload
33
43
  * @private
34
44
  * @return {string} The request body
@@ -41,7 +51,9 @@ function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="s
41
51
  * Sends the HttpRequest and returns a promise.
42
52
  * @returns {Promise}
43
53
  */},{key:"dispatch",value:function dispatch(){var _this3=this;return new Promise(function(resolve,reject){var requestCallbackName=_this3.getEventCallbackName();requestBuffer.add(_this3,_this3.serial);// Prepare the options for the request
44
- var options={url:_this3.url,serial:_this3.serial,method:_this3.method,timeout:_this3.timeout,followRedirects:_this3.followRedirects,body:_this3.getRequestBody(),contentType:_this3.contentType?_this3.contentType:_this3.getContentType()};/**
54
+ var options={url:_this3.url,serial:_this3.serial,method:_this3.method,timeout:_this3.timeout,followRedirects:_this3.followRedirects,body:_this3.getRequestBody(),// the iOS Cloud Flight app will use this over any content type passed in
55
+ // the headers and breaks if it's not set:
56
+ contentType:_this3.contentType?_this3.contentType:_this3.getContentType(),headers:_this3.getHeaders()};/**
45
57
  * The request event callback for the response call.
46
58
  * @param {Object|null} error The error object if an error happened.
47
59
  * @param {string} serial The serial that was used to identify the HttpRequest callback
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopgate/pwa-core",
3
- "version": "7.26.0",
3
+ "version": "7.27.0-beta.2",
4
4
  "description": "Core library for the Shopgate Connect PWA.",
5
5
  "author": "Support <support@shopgate.com>",
6
6
  "license": "Apache-2.0",