@shopgate/pwa-core 7.30.0-alpha.6 → 7.30.0-alpha.8

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.
Files changed (85) hide show
  1. package/classes/AppCommand/index.js +115 -11
  2. package/classes/AppCommand/spec.js +260 -6
  3. package/classes/AppCommandRequest/index.js +129 -20
  4. package/classes/AppPermissionsRequest/AppPermissionsRequest.js +45 -7
  5. package/classes/AppPermissionsRequest/GetAppPermissionsRequest.js +48 -9
  6. package/classes/AppPermissionsRequest/RequestAppPermissionsRequest.js +54 -9
  7. package/classes/Bridge/index.js +34 -4
  8. package/classes/Bridge/spec.js +24 -1
  9. package/classes/BrightnessRequest/index.js +59 -10
  10. package/classes/BrightnessRequest/spec.js +111 -6
  11. package/classes/BrowserConnector/index.js +180 -26
  12. package/classes/Conditioner/index.js +74 -8
  13. package/classes/Conditioner/spec.js +75 -1
  14. package/classes/DataRequest/index.js +116 -13
  15. package/classes/DevServerBridge/index.js +86 -9
  16. package/classes/DevServerBridge/spec.js +231 -14
  17. package/classes/ErrorManager/index.js +144 -20
  18. package/classes/ErrorManager/spec.js +244 -2
  19. package/classes/Event/index.js +101 -15
  20. package/classes/HttpRequest/index.js +182 -21
  21. package/classes/PipelineDependencies/index.js +42 -6
  22. package/classes/PipelineDependencies/spec.js +46 -3
  23. package/classes/PipelineManager/index.js +517 -71
  24. package/classes/PipelineManager/spec.js +733 -15
  25. package/classes/PipelineRequest/index.js +167 -19
  26. package/classes/PipelineRequest/mock.js +118 -21
  27. package/classes/PipelineRequest/spec.js +333 -2
  28. package/classes/PipelineSequence/index.js +34 -6
  29. package/classes/Request/index.js +61 -13
  30. package/classes/RequestBuffer/index.js +43 -6
  31. package/classes/RequestManager/index.js +216 -33
  32. package/classes/RequestManager/spec.js +188 -1
  33. package/classes/Scanner/index.js +246 -67
  34. package/classes/ScannerEvent/index.js +23 -9
  35. package/classes/ScannerEventHandler/index.js +39 -16
  36. package/classes/ScannerEventListener/index.js +84 -24
  37. package/classes/ScannerManager/ScanProcessingError.js +11 -3
  38. package/classes/ScannerManager/index.js +133 -21
  39. package/classes/WebStorageRequest/index.js +76 -9
  40. package/commands/analyticsSetCustomValues.js +8 -2
  41. package/commands/appPermissions.js +10 -3
  42. package/commands/brightness.js +33 -5
  43. package/commands/broadcastEvent.js +8 -2
  44. package/commands/cleanTab.js +11 -3
  45. package/commands/closeInAppBrowser.js +22 -2
  46. package/commands/flushTab.js +8 -2
  47. package/commands/getWebStorageEntry.js +11 -2
  48. package/commands/hideMenuBar.js +8 -2
  49. package/commands/hideNavigationBar.js +8 -2
  50. package/commands/hideSplashScreen.js +8 -2
  51. package/commands/onload.js +13 -3
  52. package/commands/openAppSettings.js +8 -2
  53. package/commands/openPage.js +8 -2
  54. package/commands/openPageExtern.js +8 -2
  55. package/commands/performCommandsAfterDelay.js +11 -3
  56. package/commands/plotProjects.js +65 -7
  57. package/commands/popTabToRoot.js +11 -3
  58. package/commands/registerEvents.js +10 -2
  59. package/commands/scanner.js +76 -7
  60. package/commands/setCookie.js +8 -2
  61. package/commands/setDebugLoggingEnabled.js +8 -2
  62. package/commands/setScrollingEnabled.js +7 -2
  63. package/commands/setWebStorageEntry.js +8 -2
  64. package/commands/shareItem.js +18 -2
  65. package/commands/showNavigationBar.js +8 -2
  66. package/commands/showTab.js +13 -2
  67. package/commands/unifiedTracking.js +128 -30
  68. package/constants/AppCommands.js +6 -1
  69. package/constants/AppEvents.js +9 -1
  70. package/constants/AppPermissions.js +57 -13
  71. package/constants/Command.js +1 -1
  72. package/constants/ErrorHandleTypes.js +2 -1
  73. package/constants/ErrorManager.js +15 -1
  74. package/constants/Pipeline.js +52 -17
  75. package/constants/ProcessTypes.js +3 -1
  76. package/constants/RequestManagerModes.js +19 -7
  77. package/constants/RequestTypes.js +2 -1
  78. package/constants/Scanner.js +39 -10
  79. package/constants/Trilean.js +6 -1
  80. package/emitters/ui.js +2 -1
  81. package/helpers/index.js +66 -8
  82. package/helpers/logGroup.js +56 -8
  83. package/helpers/version.js +216 -22
  84. package/index.js +60 -5
  85. package/package.json +1 -1
@@ -1,55 +1,203 @@
1
- function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a 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);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _callSuper(_this,derived,args){function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){return false;}}derived=_getPrototypeOf(derived);return _possibleConstructorReturn(_this,isNativeReflectConstruct()?Reflect.construct(derived,args||[],_getPrototypeOf(_this).constructor):derived.apply(_this,args));}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}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}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}import Request from"../Request";import pipelineManager from"../PipelineManager";import{CURRENT_VERSION}from"../../constants/Pipeline";import*as processTypes from"../../constants/ProcessTypes";import*as errorHandleTypes from"../../constants/ErrorHandleTypes";import{logger}from"../../helpers";export var DEFAULT_VERSION=CURRENT_VERSION;export var DEFAULT_RETRIES=3;export var DEFAULT_MAX_RETRIES=5;export var DEFAULT_INPUT={};export var DEFAULT_TIMEOUT=20000;export var DEFAULT_MAX_TIMEOUT=30000;export var DEFAULT_PROCESSED=processTypes.PROCESS_ALWAYS;export var DEFAULT_HANDLE_ERROR=errorHandleTypes.ERROR_HANDLE_DEFAULT;/**
1
+ import Request from "../Request";
2
+ import pipelineManager from "../PipelineManager";
3
+ import { CURRENT_VERSION } from "../../constants/Pipeline";
4
+ import * as processTypes from "../../constants/ProcessTypes";
5
+ import * as errorHandleTypes from "../../constants/ErrorHandleTypes";
6
+ import { logger } from "../../helpers";
7
+ export const DEFAULT_VERSION = CURRENT_VERSION;
8
+ export const DEFAULT_RETRIES = 3;
9
+ export const DEFAULT_MAX_RETRIES = 5;
10
+ export const DEFAULT_INPUT = {};
11
+ export const DEFAULT_TIMEOUT = 20000;
12
+ export const DEFAULT_MAX_TIMEOUT = 30000;
13
+ export const DEFAULT_PROCESSED = processTypes.PROCESS_ALWAYS;
14
+ export const DEFAULT_HANDLE_ERROR = errorHandleTypes.ERROR_HANDLE_DEFAULT;
15
+
16
+ /**
2
17
  * Defines a pipeline request.
3
18
  * @class
4
- */var PipelineRequest=/*#__PURE__*/function(_Request){/**
19
+ */
20
+ class PipelineRequest extends Request {
21
+ /**
5
22
  * @param {string} name The pipeline name. Excluding the version.
6
- */function PipelineRequest(name){var _this2;_classCallCheck(this,PipelineRequest);if(!name)throw new Error('The \'name\' parameter is not set!');_this2=_callSuper(this,PipelineRequest);_this2.name=name;_this2.version=DEFAULT_VERSION;_this2.input=DEFAULT_INPUT;_this2.trusted=false;_this2.retries=DEFAULT_RETRIES;_this2.timeout=DEFAULT_TIMEOUT;_this2.process=DEFAULT_PROCESSED;_this2.handleErrors=DEFAULT_HANDLE_ERROR;_this2.errorBlacklist=[];_this2.responseBehavior={success:null,error:null};return _this2;}/**
23
+ */
24
+ constructor(name) {
25
+ if (!name) throw new Error('The \'name\' parameter is not set!');
26
+ super();
27
+ this.name = name;
28
+ this.version = DEFAULT_VERSION;
29
+ this.input = DEFAULT_INPUT;
30
+ this.trusted = false;
31
+ this.retries = DEFAULT_RETRIES;
32
+ this.timeout = DEFAULT_TIMEOUT;
33
+ this.process = DEFAULT_PROCESSED;
34
+ this.handleErrors = DEFAULT_HANDLE_ERROR;
35
+ this.errorBlacklist = [];
36
+ this.responseBehavior = {
37
+ success: null,
38
+ error: null
39
+ };
40
+ }
41
+
42
+ /**
7
43
  * @param {number} version The version number of the pipeline request.
8
44
  * @return {PipelineRequest}
9
- */_inherits(PipelineRequest,_Request);return _createClass(PipelineRequest,[{key:"setVersion",value:function setVersion(){var version=arguments.length>0&&arguments[0]!==undefined?arguments[0]:DEFAULT_VERSION;if(typeof version!=='number')throw new TypeError("Expected 'number'. Received: '".concat(_typeof(version),"'"));if(version<0)throw new Error("Expected positive integer. Received: '".concat(version,"'"));if(version===0)throw new Error('Has to be > 0!');this.version=version;return this;}/**
45
+ */
46
+ setVersion(version = DEFAULT_VERSION) {
47
+ if (typeof version !== 'number') throw new TypeError(`Expected 'number'. Received: '${typeof version}'`);
48
+ if (version < 0) throw new Error(`Expected positive integer. Received: '${version}'`);
49
+ if (version === 0) throw new Error('Has to be > 0!');
50
+ this.version = version;
51
+ return this;
52
+ }
53
+
54
+ /**
10
55
  * @param {Object} [input={}] The payload to send with the request.
11
56
  * @returns {PipelineRequest}
12
- */},{key:"setInput",value:function setInput(){var input=arguments.length>0&&arguments[0]!==undefined?arguments[0]:DEFAULT_INPUT;if(_typeof(input)!=='object'||input.constructor!==Object){throw new TypeError("Expected 'object'. Received: '".concat(_typeof(input),"'"));}this.input=input;return this;}/**
57
+ */
58
+ setInput(input = DEFAULT_INPUT) {
59
+ if (typeof input !== 'object' || input.constructor !== Object) {
60
+ throw new TypeError(`Expected 'object'. Received: '${typeof input}'`);
61
+ }
62
+ this.input = input;
63
+ return this;
64
+ }
65
+
66
+ /**
13
67
  * @return {PipelineRequest}
14
- */},{key:"setTrusted",value:function setTrusted(){this.trusted=true;return this;}/**
68
+ */
69
+ setTrusted() {
70
+ this.trusted = true;
71
+ return this;
72
+ }
73
+
74
+ /**
15
75
  * @param {number} retries The number of retries this pipeline request should perform.
16
76
  * @return {PipelineRequest}
17
- */},{key:"setRetries",value:function setRetries(){var retries=arguments.length>0&&arguments[0]!==undefined?arguments[0]:DEFAULT_RETRIES;if(typeof retries!=='number')throw new TypeError("Expected 'number'. Received: '".concat(_typeof(retries),"'"));if(retries<0)throw new Error("Expected positive integer. Received: '".concat(retries,"'"));if(retries>=DEFAULT_MAX_RETRIES)throw new Error("Max retries exceeded. Received: '".concat(retries,"'"));this.retries=Math.min(retries,DEFAULT_MAX_RETRIES);return this;}/**
77
+ */
78
+ setRetries(retries = DEFAULT_RETRIES) {
79
+ if (typeof retries !== 'number') throw new TypeError(`Expected 'number'. Received: '${typeof retries}'`);
80
+ if (retries < 0) throw new Error(`Expected positive integer. Received: '${retries}'`);
81
+ if (retries >= DEFAULT_MAX_RETRIES) throw new Error(`Max retries exceeded. Received: '${retries}'`);
82
+ this.retries = Math.min(retries, DEFAULT_MAX_RETRIES);
83
+ return this;
84
+ }
85
+
86
+ /**
18
87
  * @param {number} timeout The timeout (ms) that the request will wait before canceling.
19
88
  * @return {PipelineRequest}
20
- */},{key:"setTimeout",value:function setTimeout(){var timeout=arguments.length>0&&arguments[0]!==undefined?arguments[0]:DEFAULT_TIMEOUT;if(typeof timeout!=='number')throw new TypeError("Expected 'number'. Received: '".concat(_typeof(timeout),"'"));if(timeout<0)throw new Error("Expected positive integer. Received: '".concat(timeout,"'"));if(timeout>DEFAULT_MAX_TIMEOUT)throw new Error("Max timeout exceeded. Received: '".concat(timeout,"'"));this.timeout=Math.min(timeout,DEFAULT_MAX_TIMEOUT);return this;}/**
89
+ */
90
+ setTimeout(timeout = DEFAULT_TIMEOUT) {
91
+ if (typeof timeout !== 'number') throw new TypeError(`Expected 'number'. Received: '${typeof timeout}'`);
92
+ if (timeout < 0) throw new Error(`Expected positive integer. Received: '${timeout}'`);
93
+ if (timeout > DEFAULT_MAX_TIMEOUT) throw new Error(`Max timeout exceeded. Received: '${timeout}'`);
94
+ this.timeout = Math.min(timeout, DEFAULT_MAX_TIMEOUT);
95
+ return this;
96
+ }
97
+
98
+ /**
21
99
  * @param {string} processed The response process type.
22
100
  * @return {PipelineRequest}
23
- */},{key:"setResponseProcessed",value:function setResponseProcessed(){var processed=arguments.length>0&&arguments[0]!==undefined?arguments[0]:DEFAULT_PROCESSED;if(typeof processed!=='string')throw new TypeError("Expected 'string'. Received: '".concat(_typeof(processed),"'"));if(!Object.values(processTypes).includes(processed)){throw new Error("The value '".concat(processed,"' is not supported!"));}this.process=processed;return this;}/**
101
+ */
102
+ setResponseProcessed(processed = DEFAULT_PROCESSED) {
103
+ if (typeof processed !== 'string') throw new TypeError(`Expected 'string'. Received: '${typeof processed}'`);
104
+ if (!Object.values(processTypes).includes(processed)) {
105
+ throw new Error(`The value '${processed}' is not supported!`);
106
+ }
107
+ this.process = processed;
108
+ return this;
109
+ }
110
+
111
+ /**
24
112
  * Sets a blacklist of error codes that should not be handled internally.
25
113
  * Can be used for custom error handling outside.
26
114
  * @param {Object} errors - Array of error codes
27
115
  * @return {PipelineRequest}
28
- */},{key:"setErrorBlacklist",value:function setErrorBlacklist(){var errors=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];this.errorBlacklist=errors;return this;}/**
116
+ */
117
+ setErrorBlacklist(errors = []) {
118
+ this.errorBlacklist = errors;
119
+ return this;
120
+ }
121
+
122
+ /**
29
123
  * @param {string} handle The handle errors type.
30
124
  * @return {PipelineRequest}
31
- */},{key:"setHandleErrors",value:function setHandleErrors(){var handle=arguments.length>0&&arguments[0]!==undefined?arguments[0]:errorHandleTypes.ERROR_HANDLE_DEFAULT;if(typeof handle!=='string')throw new TypeError("Expected 'string'. Received: '".concat(_typeof(handle),"'"));if(!Object.values(errorHandleTypes).includes(handle)){throw new Error("The value '".concat(handle,"' is not supported!"));}this.handleErrors=handle;return this;}/**
125
+ */
126
+ setHandleErrors(handle = errorHandleTypes.ERROR_HANDLE_DEFAULT) {
127
+ if (typeof handle !== 'string') throw new TypeError(`Expected 'string'. Received: '${typeof handle}'`);
128
+ if (!Object.values(errorHandleTypes).includes(handle)) {
129
+ throw new Error(`The value '${handle}' is not supported!`);
130
+ }
131
+ this.handleErrors = handle;
132
+ return this;
133
+ }
134
+
135
+ /**
32
136
  * Sets a flag to suppress errors.
33
137
  * When true, no EVENT_PIPELINE_ERROR would be triggered.
34
- * @param {bool} value Value.
138
+ * @param {boolean} value Value.
35
139
  * @return {PipelineRequest}
36
140
  * @deprecated
37
- */},{key:"setSuppressErrors",value:function setSuppressErrors(value){logger.warn('Deprecated: setSuppressErrors() will be removed. Use setHandleErrors() instead!');var handle=value?errorHandleTypes.ERROR_HANDLE_SUPPRESS:errorHandleTypes.ERROR_HANDLE_DEFAULT;this.setHandleErrors(handle);return this;}/**
141
+ */
142
+ setSuppressErrors(value) {
143
+ logger.warn('Deprecated: setSuppressErrors() will be removed. Use setHandleErrors() instead!');
144
+ const handle = value ? errorHandleTypes.ERROR_HANDLE_SUPPRESS : errorHandleTypes.ERROR_HANDLE_DEFAULT;
145
+ this.setHandleErrors(handle);
146
+ return this;
147
+ }
148
+
149
+ /**
38
150
  * @param {Object} errors - Array of error codes
39
151
  * @return {PipelineRequest}
40
152
  * @deprecated
41
- */},{key:"setHandledErrors",value:function setHandledErrors(errors){logger.warn('Deprecated: setHandledErrors() will be removed in favor of setErrorBlacklist()!');this.setErrorBlacklist(errors);return this;}/**
153
+ */
154
+ setHandledErrors(errors) {
155
+ logger.warn('Deprecated: setHandledErrors() will be removed in favor of setErrorBlacklist()!');
156
+ this.setErrorBlacklist(errors);
157
+ return this;
158
+ }
159
+
160
+ /**
42
161
  * Allows to register callbacks to be executed in case of pipeline response error or success.
43
162
  * @param {Object} behaviors The desired behaviors
44
163
  * @return {PipelineRequest}
45
- */},{key:"setResponseBehavior",value:function setResponseBehavior(){var behaviors=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};this.responseBehavior=_extends({},this.responseBehavior,{},behaviors);return this;}/**
164
+ */
165
+ setResponseBehavior(behaviors = {}) {
166
+ this.responseBehavior = {
167
+ ...this.responseBehavior,
168
+ ...behaviors
169
+ };
170
+ return this;
171
+ }
172
+
173
+ /**
46
174
  * @returns {Function|null}
47
- */},{key:"getSuccessResponseBehavior",value:function getSuccessResponseBehavior(){var _this$responseBehavio;return((_this$responseBehavio=this.responseBehavior)===null||_this$responseBehavio===void 0?void 0:_this$responseBehavio.success)||null;}/**
175
+ */
176
+ getSuccessResponseBehavior() {
177
+ return this.responseBehavior?.success || null;
178
+ }
179
+
180
+ /**
48
181
  * @returns {Function|null}
49
- */},{key:"getErrorResponseBehavior",value:function getErrorResponseBehavior(){var _this$responseBehavio2;return((_this$responseBehavio2=this.responseBehavior)===null||_this$responseBehavio2===void 0?void 0:_this$responseBehavio2.error)||null;}/**
182
+ */
183
+ getErrorResponseBehavior() {
184
+ return this.responseBehavior?.error || null;
185
+ }
186
+
187
+ /**
50
188
  * Checks if the request has currently running dependencies.
51
189
  * @return {boolean}
52
- */},{key:"hasRunningDependencies",value:function hasRunningDependencies(){return pipelineManager.hasRunningDependencies(this.name);}/**
190
+ */
191
+ hasRunningDependencies() {
192
+ return pipelineManager.hasRunningDependencies(this.name);
193
+ }
194
+
195
+ /**
53
196
  * Dispatches the pipeline.
54
197
  * @return {Promise}
55
- */},{key:"dispatch",value:function dispatch(){return pipelineManager.add(this);}}]);}(Request);export default PipelineRequest;
198
+ */
199
+ dispatch() {
200
+ return pipelineManager.add(this);
201
+ }
202
+ }
203
+ export default PipelineRequest;
@@ -1,56 +1,153 @@
1
- function _callSuper(_this,derived,args){function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){return false;}}derived=_getPrototypeOf(derived);return _possibleConstructorReturn(_this,isNativeReflectConstruct()?Reflect.construct(derived,args||[],_getPrototypeOf(_this).constructor):derived.apply(_this,args));}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}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}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a 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);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}import{logger}from"../../helpers";import*as errorHandleTypes from"../../constants/ErrorHandleTypes";import*as processTypes from"../../constants/ProcessTypes";/**
1
+ import { logger } from "../../helpers";
2
+ import * as errorHandleTypes from "../../constants/ErrorHandleTypes";
3
+ import * as processTypes from "../../constants/ProcessTypes";
4
+
5
+ /**
2
6
  * Mocked PipelineRequest.
3
7
  * Use it any time you need to mock a PipelineRequest.
4
8
  *
5
9
  * For more information and usage examples, please check the README.
6
- */var MockedPipelineRequest=/*#__PURE__*/function(){/**
10
+ */
11
+ class MockedPipelineRequest {
12
+ /**
13
+ * Getter for mockedDispatchResolver which is an additional helper function for custom, mock-only
14
+ * `dispatch()` resolver.
15
+ * @return {Function}
16
+ */
17
+ static get mockedDispatchResolver() {
18
+ return () => {};
19
+ }
20
+
21
+ /**
7
22
  * Initializes the MockedPipelineRequest object.
8
23
  * @param {string} name The pipeline name.
9
- */function MockedPipelineRequest(name){_classCallCheck(this,MockedPipelineRequest);this.name=name;this.input={};this.handleErrors=errorHandleTypes.ERROR_HANDLE_DEFAULT;this.errorBlacklist=[];this.process=processTypes.DEFAULT_PROCESSED;this.timeout=undefined;}/**
24
+ */
25
+ constructor(name) {
26
+ this.name = name;
27
+ this.input = {};
28
+ this.handleErrors = errorHandleTypes.ERROR_HANDLE_DEFAULT;
29
+ this.errorBlacklist = [];
30
+ this.process = processTypes.DEFAULT_PROCESSED;
31
+ this.timeout = undefined;
32
+ }
33
+
34
+ /**
10
35
  * Sets the payload for the MockedPipelineRequest.
11
36
  * @param {Object} [mockedInput={}] The payload to send with the request.
12
37
  * @returns {MockedPipelineRequest}
13
- */return _createClass(MockedPipelineRequest,[{key:"setInput",value:function setInput(){var mockedInput=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};this.input=mockedInput;return this;}/**
38
+ */
39
+ setInput(mockedInput = {}) {
40
+ this.input = mockedInput;
41
+ return this;
42
+ }
43
+
44
+ /**
14
45
  * Sets a timeout.
15
46
  * @param {number} timeout Timeout.
16
47
  * @returns {MockedPipelineRequest}
17
- */},{key:"setTimeout",value:function setTimeout(timeout){this.timeout=timeout;return this;}/**
48
+ */
49
+ setTimeout(timeout) {
50
+ this.timeout = timeout;
51
+ return this;
52
+ }
53
+
54
+ /**
18
55
  * @param {number} retries The number of retries this pipeline request should perform.
19
56
  * @return {PipelineRequest}
20
- */},{key:"setRetries",value:function setRetries(){var retries=arguments.length>0&&arguments[0]!==undefined?arguments[0]:3;if(typeof retries!=='number')throw new TypeError("Expected 'number'. Received: '".concat(_typeof(retries),"'"));if(retries<0)throw new Error("Expected positive integer. Received: '".concat(retries,"'"));if(retries>=5)throw new Error("Max retries exceeded. Received: '".concat(retries,"'"));this.retries=Math.min(retries,5);return this;}/**
57
+ */
58
+ setRetries(retries = 3) {
59
+ if (typeof retries !== 'number') throw new TypeError(`Expected 'number'. Received: '${typeof retries}'`);
60
+ if (retries < 0) throw new Error(`Expected positive integer. Received: '${retries}'`);
61
+ if (retries >= 5) throw new Error(`Max retries exceeded. Received: '${retries}'`);
62
+ this.retries = Math.min(retries, 5);
63
+ return this;
64
+ }
65
+
66
+ /**
21
67
  * Returns promise and calls `MockedPipelineRequest.mockedDispatchResolver()`.
22
68
  * @returns {Promise}
23
- */},{key:"dispatch",value:function dispatch(){var _this=this;return new Promise(function(resolve,reject){_this.constructor.mockedDispatchResolver(_this,resolve,reject);});}/**
69
+ */
70
+ dispatch() {
71
+ return new Promise((resolve, reject) => {
72
+ this.constructor.mockedDispatchResolver(this, resolve, reject);
73
+ });
74
+ }
75
+
76
+ /**
24
77
  * @param {string} processed The response process type.
25
78
  * @return {PipelineRequest}
26
- */},{key:"setResponseProcessed",value:function setResponseProcessed(){var processed=arguments.length>0&&arguments[0]!==undefined?arguments[0]:processTypes.DEFAULT_PROCESSED;if(typeof processed!=='string')throw new TypeError("Expected 'string'. Received: '".concat(_typeof(processed),"'"));if(!Object.values(processTypes).includes(processed)){throw new Error("The value '".concat(processed,"' is not supported!"));}this.process=processed;return this;}/**
79
+ */
80
+ setResponseProcessed(processed = processTypes.DEFAULT_PROCESSED) {
81
+ if (typeof processed !== 'string') throw new TypeError(`Expected 'string'. Received: '${typeof processed}'`);
82
+ if (!Object.values(processTypes).includes(processed)) {
83
+ throw new Error(`The value '${processed}' is not supported!`);
84
+ }
85
+ this.process = processed;
86
+ return this;
87
+ }
88
+
89
+ /**
27
90
  * Sets a blacklist of error codes that should not be handled internally.
28
91
  * Can be used for custom error handling outside.
29
92
  * @param {Object} errors - Array of error codes
30
93
  * @return {PipelineRequest}
31
- */},{key:"setErrorBlacklist",value:function setErrorBlacklist(){var errors=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];this.errorBlacklist=errors;return this;}/**
94
+ */
95
+ setErrorBlacklist(errors = []) {
96
+ this.errorBlacklist = errors;
97
+ return this;
98
+ }
99
+
100
+ /**
32
101
  * @param {string} handle The handle errors type.
33
102
  * @return {PipelineRequest}
34
- */},{key:"setHandleErrors",value:function setHandleErrors(){var handle=arguments.length>0&&arguments[0]!==undefined?arguments[0]:errorHandleTypes.ERROR_HANDLE_DEFAULT;if(typeof handle!=='string')throw new TypeError("Expected 'string'. Received: '".concat(_typeof(handle),"'"));if(!Object.values(errorHandleTypes).includes(handle)){throw new Error("The value '".concat(handle,"' is not supported!"));}this.handleErrors=handle;return this;}/**
103
+ */
104
+ setHandleErrors(handle = errorHandleTypes.ERROR_HANDLE_DEFAULT) {
105
+ if (typeof handle !== 'string') throw new TypeError(`Expected 'string'. Received: '${typeof handle}'`);
106
+ if (!Object.values(errorHandleTypes).includes(handle)) {
107
+ throw new Error(`The value '${handle}' is not supported!`);
108
+ }
109
+ this.handleErrors = handle;
110
+ return this;
111
+ }
112
+
113
+ /**
35
114
  * Sets handled errors.
36
115
  * @param {Array} errors Blacklisted errors.
37
116
  * @returns {MockedPipelineRequest}
38
117
  * @deprecated
39
- */},{key:"setHandledErrors",value:function setHandledErrors(){var errors=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];logger.warn('Deprecated: setHandledErrors() will be removed in favor of setErrorBlacklist()!');this.setErrorBlacklist(errors);return this;}/**
118
+ */
119
+ setHandledErrors(errors = []) {
120
+ logger.warn('Deprecated: setHandledErrors() will be removed in favor of setErrorBlacklist()!');
121
+ this.setErrorBlacklist(errors);
122
+ return this;
123
+ }
124
+
125
+ /**
40
126
  * Sets a flag to suppress errors.
41
127
  * When true, no EVENT_PIPELINE_ERROR would be triggered.
42
- * @param {bool} value Value.
128
+ * @param {boolean} value Value.
43
129
  * @return {PipelineRequest}
44
130
  * @deprecated
45
- */},{key:"setSuppressErrors",value:function setSuppressErrors(value){logger.warn('Deprecated: setSuppressErrors() will be removed. Use setHandleErrors() instead!');var handle=value?errorHandleTypes.ERROR_HANDLE_SUPPRESS:errorHandleTypes.ERROR_HANDLE_DEFAULT;this.setHandleErrors(handle);return this;}}],[{key:"mockedDispatchResolver",get:/**
46
- * Getter for mockedDispatchResolver which is an additional helper function for custom, mock-only
47
- * `dispatch()` resolver.
48
- * @return {Function}
49
- */function get(){return function(){};}}]);}();/**
131
+ */
132
+ setSuppressErrors(value) {
133
+ logger.warn('Deprecated: setSuppressErrors() will be removed. Use setHandleErrors() instead!');
134
+ const handle = value ? errorHandleTypes.ERROR_HANDLE_SUPPRESS : errorHandleTypes.ERROR_HANDLE_DEFAULT;
135
+ this.setHandleErrors(handle);
136
+ return this;
137
+ }
138
+ }
139
+
140
+ /**
50
141
  * Factory which creates an instance of MockedPipelineRequest.
51
142
  * @param {Function} callback Resolver callback.
52
143
  * @returns {MockedPipelineRequest}
53
- */export var mockedPipelineRequestFactory=function mockedPipelineRequestFactory(callback){return(/*#__PURE__*/function(_MockedPipelineReques){function _class(){_classCallCheck(this,_class);return _callSuper(this,_class,arguments);}_inherits(_class,_MockedPipelineReques);return _createClass(_class,null,[{key:"mockedDispatchResolver",get:/**
54
- * Getter for custom mocked resolver.
55
- * @return {Function}
56
- */function get(){return callback;}}]);}(MockedPipelineRequest));};
144
+ */
145
+ export const mockedPipelineRequestFactory = callback => class extends MockedPipelineRequest {
146
+ /**
147
+ * Getter for custom mocked resolver.
148
+ * @return {Function}
149
+ */
150
+ static get mockedDispatchResolver() {
151
+ return callback;
152
+ }
153
+ };