ouisys-engine 3.0.1 → 3.0.5

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 (195) hide show
  1. package/.babelrc +4 -8
  2. package/.eslintrc.js +1 -1
  3. package/.husky/pre-commit +4 -0
  4. package/.nvmrc +1 -1
  5. package/.prettierignore +2 -1
  6. package/.vscode/settings.json +1 -1
  7. package/README.md +2 -4
  8. package/dist/api/index.d.ts +5 -5
  9. package/dist/api/index.js +76 -76
  10. package/dist/common-types/AppThunk.d.ts +11 -12
  11. package/dist/common-types/IOptInFlowName.d.ts +1 -1
  12. package/dist/common-types/ITracker.js +1 -2
  13. package/dist/common-types/RemoteDataState.d.ts +4 -4
  14. package/dist/common-types/RemoteDataState.js +17 -17
  15. package/dist/flows/click2smsFlow.d.ts +2 -2
  16. package/dist/flows/moFlow.d.ts +2 -2
  17. package/dist/flows/moRedirFlow.d.ts +2 -2
  18. package/dist/flows/oneClickFlow.d.ts +2 -2
  19. package/dist/flows/pinFlow.d.ts +2 -2
  20. package/dist/flows/pinFlow.js +2 -0
  21. package/dist/flows/strategy.d.ts +8 -8
  22. package/dist/flows/ussdFlow.d.ts +2 -2
  23. package/dist/ips/tryGetIPRangeName.d.ts +1 -1
  24. package/dist/ips/tryGetIPRangeName.js +7 -5
  25. package/dist/jest.config.js +1 -1
  26. package/dist/pacman/index.d.ts +2 -2
  27. package/dist/pacman/index.js +41 -41
  28. package/dist/pacman/queryString.js +11 -9
  29. package/dist/reducers/click2smsFlow/Click2smsTypes.d.ts +19 -19
  30. package/dist/reducers/click2smsFlow/IClick2smsConstants.d.ts +1 -1
  31. package/dist/reducers/click2smsFlow/index.d.ts +2 -2
  32. package/dist/reducers/click2smsFlow/index.js +24 -24
  33. package/dist/reducers/click2smsFlow/utils.d.ts +1 -1
  34. package/dist/reducers/click2smsFlow/utils.js +30 -30
  35. package/dist/reducers/moFlow/IMoConstants.d.ts +1 -1
  36. package/dist/reducers/moFlow/MoTypes.d.ts +13 -13
  37. package/dist/reducers/moFlow/index.d.ts +3 -3
  38. package/dist/reducers/moFlow/index.js +27 -27
  39. package/dist/reducers/moFlow/utils.d.ts +1 -2
  40. package/dist/reducers/moFlow/utils.js +28 -26
  41. package/dist/reducers/moRedirFlow/IMoRedirConstants.d.ts +1 -1
  42. package/dist/reducers/moRedirFlow/MoRedirTypes.d.ts +13 -13
  43. package/dist/reducers/moRedirFlow/index.d.ts +3 -3
  44. package/dist/reducers/moRedirFlow/index.js +27 -27
  45. package/dist/reducers/moRedirFlow/utils.d.ts +1 -1
  46. package/dist/reducers/moRedirFlow/utils.js +17 -17
  47. package/dist/reducers/oneClickFlow/IOneClickConstants.d.ts +1 -1
  48. package/dist/reducers/oneClickFlow/OneClickTypes.d.ts +10 -10
  49. package/dist/reducers/oneClickFlow/index.d.ts +3 -3
  50. package/dist/reducers/oneClickFlow/index.js +75 -68
  51. package/dist/reducers/oneClickFlow/utils.d.ts +2 -2
  52. package/dist/reducers/oneClickFlow/utils.js +70 -69
  53. package/dist/reducers/pinFlow/IPinConstants.d.ts +1 -1
  54. package/dist/reducers/pinFlow/PinTypes.d.ts +24 -23
  55. package/dist/reducers/pinFlow/index.d.ts +3 -3
  56. package/dist/reducers/pinFlow/index.js +76 -76
  57. package/dist/reducers/pinFlow/utils.d.ts +1 -1
  58. package/dist/reducers/pinFlow/utils.js +61 -65
  59. package/dist/reducers/strategy/IStategyActionContants.d.ts +1 -1
  60. package/dist/reducers/strategy/StrategyTypes.d.ts +56 -56
  61. package/dist/reducers/strategy/index.d.ts +2 -2
  62. package/dist/reducers/strategy/index.js +99 -99
  63. package/dist/reducers/strategy/strategies/ask_mobile_number.d.ts +3 -2
  64. package/dist/reducers/strategy/strategies/ask_mobile_number.js +132 -74
  65. package/dist/reducers/strategy/strategies/ask_operator.d.ts +2 -2
  66. package/dist/reducers/strategy/strategies/ask_operator.js +64 -68
  67. package/dist/reducers/strategy/strategies/detect_operator_by_ip.d.ts +2 -2
  68. package/dist/reducers/strategy/strategies/detect_operator_by_ip.js +97 -97
  69. package/dist/reducers/strategy/strategies/header_enrichment.d.ts +2 -2
  70. package/dist/reducers/strategy/strategies/header_enrichment.js +116 -120
  71. package/dist/reducers/strategy/utils.d.ts +3 -3
  72. package/dist/reducers/strategy/utils.js +115 -111
  73. package/dist/reducers/ussdFlow/IUssdConstants.d.ts +1 -1
  74. package/dist/reducers/ussdFlow/UssdTypes.d.ts +13 -13
  75. package/dist/reducers/ussdFlow/index.d.ts +3 -3
  76. package/dist/reducers/ussdFlow/index.js +27 -27
  77. package/dist/reducers/ussdFlow/utils.d.ts +1 -2
  78. package/dist/reducers/ussdFlow/utils.js +19 -17
  79. package/dist/store/index.d.ts +8 -8
  80. package/dist/store/index.js +87 -83
  81. package/dist/store/reducers.d.ts +7 -7
  82. package/dist/store/reducers.js +4 -4
  83. package/dist/utilities/handleSubmitNumber.d.ts +7 -3
  84. package/dist/utilities/handleSubmitNumber.js +15 -18
  85. package/dist/utilities/index.d.ts +1 -1
  86. package/dist/utilities/index.js +13 -11
  87. package/dist/utilities/loadScriptInnerHtml.js +0 -1
  88. package/index.html +21 -28
  89. package/mockData/config.json +1 -1
  90. package/package.json +23 -15
  91. package/setupJest.js +1 -1
  92. package/tsconfig.json +2 -2
  93. package/dist/api/click2sms.js +0 -357
  94. package/dist/api/mo.js +0 -274
  95. package/dist/api/moRedir.js +0 -186
  96. package/dist/api/oneClick.js +0 -366
  97. package/dist/api/pin.js +0 -493
  98. package/dist/api/strategies.js +0 -704
  99. package/dist/api/ussd.js +0 -1
  100. package/dist/app/store.js +0 -35
  101. package/dist/features/strategies/categories/askMobileNumber.js +0 -395
  102. package/dist/features/strategies/categories/askOperator.js +0 -311
  103. package/dist/features/strategies/categories/detectOperatorByIp.js +0 -606
  104. package/dist/features/strategies/categories/headerEnrichment.js +0 -670
  105. package/dist/features/strategies/categories/typings/click2smsSliceTypes.js +0 -12
  106. package/dist/features/strategies/categories/typings/identifySliceTypes.js +0 -22
  107. package/dist/features/strategies/categories/typings/moFlowSliceTypes.js +0 -22
  108. package/dist/features/strategies/categories/typings/moRedirFlowSliceTypes.js +0 -21
  109. package/dist/features/strategies/categories/typings/oneClickSliceTypes.js +0 -13
  110. package/dist/features/strategies/categories/typings/pinFlowSliceTypes.js +0 -13
  111. package/dist/features/strategies/click2smsFlowSlice.js +0 -172
  112. package/dist/features/strategies/identifySlice.js +0 -455
  113. package/dist/features/strategies/moFlowSlice.js +0 -196
  114. package/dist/features/strategies/moRedirFlowSlice.js +0 -190
  115. package/dist/features/strategies/oneClickFlowSlice.js +0 -277
  116. package/dist/features/strategies/pinFlowSlice.js +0 -313
  117. package/dist/features/strategies/ussdFlowSlice.js +0 -1
  118. package/dist/flows/tpayHeFlow.d.ts +0 -7
  119. package/dist/flows/tpayHeFlow.js +0 -23
  120. package/dist/mockServer/browser.js +0 -48
  121. package/dist/mockServer/handlers.js +0 -22
  122. package/dist/mockServer/server.js +0 -48
  123. package/dist/reducers/tpayHeFlow/ITpayHeConstants.d.ts +0 -2
  124. package/dist/reducers/tpayHeFlow/ITpayHeConstants.js +0 -1
  125. package/dist/reducers/tpayHeFlow/TpayHeTypes.d.ts +0 -114
  126. package/dist/reducers/tpayHeFlow/TpayHeTypes.js +0 -1
  127. package/dist/reducers/tpayHeFlow/index.d.ts +0 -7
  128. package/dist/reducers/tpayHeFlow/index.js +0 -331
  129. package/dist/reducers/tpayHeFlow/utils.d.ts +0 -20
  130. package/dist/reducers/tpayHeFlow/utils.js +0 -510
  131. package/dist/test/setup.js +0 -24
  132. package/dist/test/test-utils.js +0 -51
  133. package/prettier.config.js +0 -7
  134. package/src/@types/react-tracker.d.ts +0 -16
  135. package/src/@types/redux-cli-logger.d.ts +0 -1
  136. package/src/@types/tiny-async-pool.d.ts +0 -3
  137. package/src/@types/window.d.ts +0 -74
  138. package/src/api/index.ts +0 -225
  139. package/src/common-types/AppThunk.ts +0 -19
  140. package/src/common-types/Either.ts +0 -3
  141. package/src/common-types/IError.ts +0 -5
  142. package/src/common-types/IOptInFlowName.ts +0 -1
  143. package/src/common-types/ITracker.ts +0 -10
  144. package/src/common-types/IVisitor.ts +0 -16
  145. package/src/common-types/RemoteDataState.ts +0 -88
  146. package/src/flows/click2smsFlow.ts +0 -18
  147. package/src/flows/moFlow.ts +0 -20
  148. package/src/flows/moRedirFlow.ts +0 -20
  149. package/src/flows/oneClickFlow.ts +0 -20
  150. package/src/flows/pinFlow.ts +0 -25
  151. package/src/flows/strategy.ts +0 -51
  152. package/src/flows/ussdFlow.ts +0 -20
  153. package/src/index.ts +0 -3
  154. package/src/ips/tryGetIPRangeName.ts +0 -22
  155. package/src/jest.config.js +0 -194
  156. package/src/pacman/index.ts +0 -71
  157. package/src/pacman/queryString.ts +0 -24
  158. package/src/reducers/click2smsFlow/Click2smsTypes.ts +0 -93
  159. package/src/reducers/click2smsFlow/IClick2smsConstants.ts +0 -4
  160. package/src/reducers/click2smsFlow/index.ts +0 -105
  161. package/src/reducers/click2smsFlow/utils.ts +0 -126
  162. package/src/reducers/moFlow/IMoConstants.ts +0 -7
  163. package/src/reducers/moFlow/MoTypes.ts +0 -125
  164. package/src/reducers/moFlow/index.ts +0 -150
  165. package/src/reducers/moFlow/utils.ts +0 -135
  166. package/src/reducers/moRedirFlow/IMoRedirConstants.ts +0 -7
  167. package/src/reducers/moRedirFlow/MoRedirTypes.ts +0 -99
  168. package/src/reducers/moRedirFlow/index.ts +0 -137
  169. package/src/reducers/moRedirFlow/utils.ts +0 -78
  170. package/src/reducers/oneClickFlow/IOneClickConstants.ts +0 -3
  171. package/src/reducers/oneClickFlow/OneClickTypes.ts +0 -108
  172. package/src/reducers/oneClickFlow/index.ts +0 -268
  173. package/src/reducers/oneClickFlow/utils.ts +0 -217
  174. package/src/reducers/pinFlow/IPinConstants.ts +0 -9
  175. package/src/reducers/pinFlow/PinTypes.ts +0 -189
  176. package/src/reducers/pinFlow/index.ts +0 -331
  177. package/src/reducers/pinFlow/utils.ts +0 -232
  178. package/src/reducers/strategy/IStategyActionContants.ts +0 -17
  179. package/src/reducers/strategy/StrategyTypes.ts +0 -375
  180. package/src/reducers/strategy/index.ts +0 -321
  181. package/src/reducers/strategy/strategies/ask_mobile_number.ts +0 -316
  182. package/src/reducers/strategy/strategies/ask_operator.ts +0 -195
  183. package/src/reducers/strategy/strategies/detect_operator_by_ip.ts +0 -414
  184. package/src/reducers/strategy/strategies/header_enrichment.ts +0 -489
  185. package/src/reducers/strategy/utils.ts +0 -357
  186. package/src/reducers/ussdFlow/IUssdConstants.ts +0 -7
  187. package/src/reducers/ussdFlow/UssdTypes.ts +0 -112
  188. package/src/reducers/ussdFlow/index.ts +0 -146
  189. package/src/reducers/ussdFlow/utils.ts +0 -88
  190. package/src/store/index.ts +0 -150
  191. package/src/store/reducers.ts +0 -37
  192. package/src/utilities/handleSubmitNumber.ts +0 -65
  193. package/src/utilities/index.ts +0 -114
  194. package/src/utilities/loadScriptInnerHtml.ts +0 -14
  195. package/src/utilities/loadScriptSrc.ts +0 -26
@@ -1,4 +1,4 @@
1
- import { IConfig } from "../reducers/strategy/StrategyTypes";
1
+ import { IConfig } from '../reducers/strategy/StrategyTypes';
2
2
  export declare const isDMBCheck: () => boolean;
3
3
  export declare const getHost: ({ host }: {
4
4
  host: string;
@@ -24,43 +24,45 @@ var _utils2 = require("../reducers/moRedirFlow/utils");
24
24
  var _utils3 = require("../reducers/pinFlow/utils");
25
25
 
26
26
  var isDMBCheck = function isDMBCheck() {
27
- return window.pac_analytics.visitor.xaid != null && (window.pac_analytics.visitor.xaid.toLowerCase().indexOf("dmb") != -1 || window.pac_analytics.visitor.xaid.toLowerCase().indexOf("amb")) != -1 ? true : false;
27
+ return !!(window.pac_analytics.visitor.xaid != null && (window.pac_analytics.visitor.xaid.toLowerCase().indexOf('dmb') != -1 || window.pac_analytics.visitor.xaid.toLowerCase().indexOf('amb')) != -1);
28
28
  };
29
29
 
30
30
  exports.isDMBCheck = isDMBCheck;
31
31
 
32
32
  var getHost = function getHost(_ref) {
33
33
  var host = _ref.host;
34
- var newHost = isDMBCheck() ? "de.tallymans.com" : host;
34
+ var newHost = isDMBCheck() ? 'de.tallymans.com' : host;
35
35
  return newHost;
36
36
  };
37
37
 
38
38
  exports.getHost = getHost;
39
39
 
40
40
  var setOnLoadUtilities = function setOnLoadUtilities(config) {
41
- if (typeof window != "undefined") {
42
- if (process.env.country.toLowerCase() === "cz") {
41
+ if (typeof window !== 'undefined') {
42
+ if (process.env.country.toLowerCase() === 'cz') {
43
43
  (0, _utils.getGoogleReCaptchaConfig)(config);
44
44
  }
45
45
 
46
- if (process.env.country.toLowerCase() === "a2" && process.env.NODE_ENV === "production") {
46
+ if (process.env.country.toLowerCase() === 'a2' && process.env.NODE_ENV === 'production') {
47
47
  (0, _utils2.startEvinaAgency)(config);
48
48
  }
49
49
 
50
- if (process.env.country.toLowerCase() === "sa" || process.env.country.toLowerCase() === "iq" || process.env.country.toLowerCase() === "k2") {
50
+ if (process.env.country.toLowerCase() === 'sa' || process.env.country.toLowerCase() === 'iq' || process.env.country.toLowerCase() === 'k2') {
51
51
  (0, _utils3.loadMcpShield)(window, config);
52
52
  }
53
53
  }
54
54
  };
55
55
 
56
56
  exports.setOnLoadUtilities = setOnLoadUtilities;
57
- var sa_prefix_operator_map = new Map([['966571', 'SA_VIRGIN'], ['966500', 'SA_STC'], ['966501', 'SA_STC'], ['966502', 'SA_STC'], ['966503', 'SA_STC'], ['966504', 'SA_STC'], ['966505', 'SA_STC'], ['966506', 'SA_STC'], ['966507', 'SA_STC'], ['966508', 'SA_STC'], ['966509', 'SA_STC'], ['966512', 'SA_STC'], ['966514', 'SA_STC'], ['966515', 'SA_STC'], ['966517', 'SA_STC'], ['966530', 'SA_STC'], ['966531', 'SA_STC'], ['966532', 'SA_STC'], ['966533', 'SA_STC'], ['966534', 'SA_STC'], ['966535', 'SA_STC'], ['966536', 'SA_STC'], ['966537', 'SA_STC'], ['966538', 'SA_STC'], ['966539', 'SA_STC'], ['966540', 'SA_MOBILY'], ['966541', 'SA_MOBILY'], ['966542', 'SA_MOBILY'], ['966543', 'SA_MOBILY'], ['966544', 'SA_MOBILY'], ['966545', 'SA_MOBILY'], ['966546', 'SA_MOBILY'], ['966547', 'SA_MOBILY'], ['966548', 'SA_MOBILY'], ['966549', 'SA_MOBILY'], ['966550', 'SA_STC'], ['966551', 'SA_STC'], ['966552', 'SA_STC'], ['966553', 'SA_STC'], ['966554', 'SA_STC'], ['966555', 'SA_STC'], ['966556', 'SA_STC'], ['966557', 'SA_STC'], ['966558', 'SA_STC'], ['966559', 'SA_STC'], ['966560', 'SA_MOBILY'], ['966561', 'SA_MOBILY'], ['966562', 'SA_MOBILY'], ['966563', 'SA_MOBILY'], ['966564', 'SA_MOBILY'], ['966565', 'SA_MOBILY'], ['966566', 'SA_MOBILY'], ['966567', 'SA_MOBILY'], ['966568', 'SA_MOBILY'], ['966569', 'SA_MOBILY'], ['966570', 'SA_VIRGIN'], ['966572', 'SA_VIRGIN'], ['966573', 'SA_VIRGIN'], ['966580', 'SA_ZAIN'], ['966581', 'SA_ZAIN'], ['966582', 'SA_ZAIN'], ['966583', 'SA_ZAIN'], ['966586', 'SA_ZAIN'], ['966588', 'SA_ZAIN'], ['966589', 'SA_ZAIN'], ['966590', 'SA_ZAIN'], ['966591', 'SA_ZAIN'], ['966592', 'SA_ZAIN'], ['966593', 'SA_ZAIN'], ['966594', 'SA_ZAIN'], ['966595', 'SA_ZAIN'], ['966596', 'SA_ZAIN'], ['966597', 'SA_ZAIN'], ['966598', 'SA_ZAIN'], ['966599', 'SA_ZAIN']]);
57
+ var saPrefixOperatorMap = new Map([['966571', 'SA_VIRGIN'], ['966500', 'SA_STC'], ['966501', 'SA_STC'], ['966502', 'SA_STC'], ['966503', 'SA_STC'], ['966504', 'SA_STC'], ['966505', 'SA_STC'], ['966506', 'SA_STC'], ['966507', 'SA_STC'], ['966508', 'SA_STC'], ['966509', 'SA_STC'], ['966512', 'SA_STC'], ['966514', 'SA_STC'], ['966515', 'SA_STC'], ['966517', 'SA_STC'], ['966530', 'SA_STC'], ['966531', 'SA_STC'], ['966532', 'SA_STC'], ['966533', 'SA_STC'], ['966534', 'SA_STC'], ['966535', 'SA_STC'], ['966536', 'SA_STC'], ['966537', 'SA_STC'], ['966538', 'SA_STC'], ['966539', 'SA_STC'], ['966540', 'SA_MOBILY'], ['966541', 'SA_MOBILY'], ['966542', 'SA_MOBILY'], ['966543', 'SA_MOBILY'], ['966544', 'SA_MOBILY'], ['966545', 'SA_MOBILY'], ['966546', 'SA_MOBILY'], ['966547', 'SA_MOBILY'], ['966548', 'SA_MOBILY'], ['966549', 'SA_MOBILY'], ['966550', 'SA_STC'], ['966551', 'SA_STC'], ['966552', 'SA_STC'], ['966553', 'SA_STC'], ['966554', 'SA_STC'], ['966555', 'SA_STC'], ['966556', 'SA_STC'], ['966557', 'SA_STC'], ['966558', 'SA_STC'], ['966559', 'SA_STC'], ['966560', 'SA_MOBILY'], ['966561', 'SA_MOBILY'], ['966562', 'SA_MOBILY'], ['966563', 'SA_MOBILY'], ['966564', 'SA_MOBILY'], ['966565', 'SA_MOBILY'], ['966566', 'SA_MOBILY'], ['966567', 'SA_MOBILY'], ['966568', 'SA_MOBILY'], ['966569', 'SA_MOBILY'], ['966570', 'SA_VIRGIN'], ['966572', 'SA_VIRGIN'], ['966573', 'SA_VIRGIN'], ['966580', 'SA_ZAIN'], ['966581', 'SA_ZAIN'], ['966582', 'SA_ZAIN'], ['966583', 'SA_ZAIN'], ['966586', 'SA_ZAIN'], ['966588', 'SA_ZAIN'], ['966589', 'SA_ZAIN'], ['966590', 'SA_ZAIN'], ['966591', 'SA_ZAIN'], ['966592', 'SA_ZAIN'], ['966593', 'SA_ZAIN'], ['966594', 'SA_ZAIN'], ['966595', 'SA_ZAIN'], ['966596', 'SA_ZAIN'], ['966597', 'SA_ZAIN'], ['966598', 'SA_ZAIN'], ['966599', 'SA_ZAIN']]);
58
58
 
59
59
  function getSAOperatorByMsisdnPrefix(msisdn) {
60
- if (msisdn[0] === "0") {
61
- msisdn = "966" + msisdn.substring(1);
60
+ var msisdnF = msisdn;
61
+
62
+ if (msisdnF[0] === '0') {
63
+ msisdnF = "966".concat(msisdnF.substring(1));
62
64
  }
63
65
 
64
- var prefix = msisdn.substring(0, 6);
65
- return sa_prefix_operator_map.get(prefix);
66
+ var prefix = msisdnF.substring(0, 6);
67
+ return saPrefixOperatorMap.get(prefix);
66
68
  }
@@ -15,7 +15,6 @@ var loadScriptInnerHtml = function loadScriptInnerHtml(innerHTML, isBody) {
15
15
  } else {
16
16
  var headElem = document.getElementsByTagName('head')[0];
17
17
  headElem.insertBefore(script, headElem.firstChild);
18
- console.log('loadScript');
19
18
  }
20
19
  };
21
20
 
package/index.html CHANGED
@@ -16,41 +16,34 @@
16
16
  </p>
17
17
  </div>
18
18
  <script>
19
- const valueEl = document.getElementById('value')
20
-
19
+ const valueEl = document.getElementById('value');
21
20
 
22
21
  function render() {
23
- valueEl.innerHTML = store.getState().toString()
22
+ valueEl.innerHTML = store.getState().toString();
24
23
  }
25
24
 
26
- render()
27
- store.subscribe(render)
28
-
29
- document.getElementById('increment')
30
- .addEventListener('click', function () {
31
- store.dispatch({ type: 'INCREMENT' })
32
- })
33
-
34
- document.getElementById('decrement')
35
- .addEventListener('click', function () {
36
- store.dispatch({ type: 'DECREMENT' })
37
- })
25
+ render();
26
+ store.subscribe(render);
38
27
 
39
- document.getElementById('incrementIfOdd')
40
- .addEventListener('click', function () {
41
- if (store.getState() % 2 !== 0) {
42
- store.dispatch({ type: 'INCREMENT' })
43
- }
44
- })
28
+ document.getElementById('increment').addEventListener('click', function () {
29
+ store.dispatch({ type: 'INCREMENT' });
30
+ });
45
31
 
46
- document.getElementById('incrementAsync')
47
- .addEventListener('click', function () {
48
- setTimeout(function () {
49
- store.dispatch({ type: 'INCREMENT' })
50
- }, 1000)
51
- })
32
+ document.getElementById('decrement').addEventListener('click', function () {
33
+ store.dispatch({ type: 'DECREMENT' });
34
+ });
52
35
 
36
+ document.getElementById('incrementIfOdd').addEventListener('click', function () {
37
+ if (store.getState() % 2 !== 0) {
38
+ store.dispatch({ type: 'INCREMENT' });
39
+ }
40
+ });
53
41
 
42
+ document.getElementById('incrementAsync').addEventListener('click', function () {
43
+ setTimeout(function () {
44
+ store.dispatch({ type: 'INCREMENT' });
45
+ }, 1000);
46
+ });
54
47
  </script>
55
48
  </body>
56
- </html>
49
+ </html>
@@ -25,4 +25,4 @@
25
25
  }
26
26
  }
27
27
  }
28
- }
28
+ }
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "ouisys-engine",
3
- "version": "3.0.1",
3
+ "version": "3.0.5",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "directories": "dist dev-tools",
7
7
  "scripts": {
8
+ "prepare": "husky install",
8
9
  "test": "testing=true jest",
9
10
  "build": "NODE_ENV=production npx babel ./src --out-dir dist --extensions \".ts,.tsx\" --copy-files && yarn build:types",
10
11
  "build:types": "tsc --emitDeclarationOnly",
@@ -53,24 +54,31 @@
53
54
  "@types/redux-logger": "^3.0.9",
54
55
  "@types/redux-mock-store": "^1.0.3",
55
56
  "@types/uuid": "^8.3.4",
57
+ "@typescript-eslint/eslint-plugin": "^4.19.0",
58
+ "@typescript-eslint/parser": "^4.19.0",
56
59
  "chai": "^4.3.6",
57
60
  "core-js": "3.23.4",
58
- "eslint": "^8.19.0",
59
- "eslint-config-airbnb": "^19.0.4",
60
- "eslint-config-prettier": "^8.5.0",
61
- "eslint-plugin-import": "^2.26.0",
62
- "eslint-plugin-jest": "^26.5.3",
63
- "eslint-plugin-jsx-a11y": "^6.6.0",
64
- "eslint-plugin-prettier": "^4.2.1",
65
- "eslint-plugin-react": "^7.30.1",
66
- "eslint-plugin-react-hooks": "^4.6.0",
67
- "eslint-plugin-testing-library": "^5.5.1",
61
+ "eslint": "^7.16.0",
62
+ "eslint-config-airbnb": "^18.2.1",
63
+ "eslint-config-ouisys": "0.0.1",
64
+ "eslint-config-prettier": "^7.1.0",
65
+ "eslint-plugin-import": "^2.22.1",
66
+ "eslint-plugin-jest": "^24.1.3",
67
+ "eslint-plugin-jsx-a11y": "^6.4.1",
68
+ "eslint-plugin-prettier": "^3.3.0",
69
+ "eslint-plugin-react": "^7.21.5",
70
+ "eslint-plugin-react-hooks": "^4.2.0",
71
+ "eslint-plugin-testing-library": "^3.10.1",
68
72
  "eslint-webpack-plugin": "^3.2.0",
73
+ "husky": "^8.0.1",
74
+ "jest": "^28.1.3",
69
75
  "jsdom": "^20.0.0",
70
76
  "jsdom-global": "^3.0.2",
77
+ "lint-staged": "^13.0.3",
71
78
  "msw": "^0.43.1",
72
- "prettier": "^2.7.1",
73
- "prettier-plugin-organize-imports": "^3.0.0",
79
+ "prettier": "^2.2.1",
80
+ "prettier-config-ouisys": "^0.0.1",
81
+ "prettier-plugin-organize-imports": "^1.1.1",
74
82
  "react-test-renderer": "^18.2.0",
75
83
  "redux-cli-logger": "^2.1.0",
76
84
  "redux-mock-store": "^1.5.4",
@@ -92,10 +100,10 @@
92
100
  "*": "prettier --ignore-unknown --write",
93
101
  "src/**/*.{ts,tsx}": "eslint --fix"
94
102
  },
95
- "prettier": "./prettier-config",
96
103
  "jest": {
97
104
  "testPathIgnorePatterns": [
98
105
  "dist"
99
106
  ]
100
- }
107
+ },
108
+ "prettier": "prettier-config-ouisys"
101
109
  }
package/setupJest.js CHANGED
@@ -3,4 +3,4 @@
3
3
 
4
4
  require('jest-fetch-mock').enableMocks();
5
5
  // changes default behavior of fetchMock to use the real 'fetch' implementation and not mock responses
6
- fetchMock.dontMock()
6
+ fetchMock.dontMock();
package/tsconfig.json CHANGED
@@ -13,9 +13,9 @@
13
13
  "resolveJsonModule": true,
14
14
  "esModuleInterop": true,
15
15
  "downlevelIteration": true,
16
- "lib": ["es5", "es2015", "dom", "scripthost"],
16
+ "lib": ["es5", "es2015", "dom", "scripthost"],
17
17
  "typeRoots": ["node_modules/@types", "src/@types"]
18
18
  },
19
19
  "include": ["src/**/*", "dev-tools/**/*"],
20
- "exclude": [ "node_modules/**/*", "webpack/**/*"]
20
+ "exclude": ["node_modules/**/*", "webpack/**/*"]
21
21
  }
@@ -1,357 +0,0 @@
1
- "use strict";
2
-
3
- require("core-js/modules/es.symbol");
4
-
5
- require("core-js/modules/es.array.concat");
6
-
7
- require("core-js/modules/es.array.filter");
8
-
9
- require("core-js/modules/es.array.iterator");
10
-
11
- require("core-js/modules/es.array.map");
12
-
13
- require("core-js/modules/es.object.get-own-property-descriptor");
14
-
15
- require("core-js/modules/es.object.get-own-property-descriptors");
16
-
17
- require("core-js/modules/es.object.keys");
18
-
19
- require("core-js/modules/es.object.to-string");
20
-
21
- require("core-js/modules/es.promise");
22
-
23
- require("core-js/modules/es.regexp.exec");
24
-
25
- require("core-js/modules/es.string.iterator");
26
-
27
- require("core-js/modules/es.string.search");
28
-
29
- require("core-js/modules/web.dom-collections.for-each");
30
-
31
- require("core-js/modules/web.dom-collections.iterator");
32
-
33
- Object.defineProperty(exports, "__esModule", {
34
- value: true
35
- });
36
- exports.checkSubscription = checkSubscription;
37
- exports.default = load;
38
- exports.load1 = load1;
39
-
40
- require("regenerator-runtime/runtime");
41
-
42
- var _strategies = require("./strategies");
43
-
44
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
45
-
46
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
47
-
48
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
49
-
50
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
51
-
52
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
53
-
54
- function loadOnce(_x, _x2, _x3, _x4, _x5) {
55
- return _loadOnce.apply(this, arguments);
56
- }
57
-
58
- function _loadOnce() {
59
- _loadOnce = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(window, maybeConfig, operator, keyword, shortcode) {
60
- var _keyword, _shortcode, offer, config, host, country, slug, rockmanId, search, result;
61
-
62
- return regeneratorRuntime.wrap(function _callee$(_context) {
63
- while (1) {
64
- switch (_context.prev = _context.next) {
65
- case 0:
66
- if (!(!!maybeConfig && maybeConfig.tag == 'keywordAndShortCode')) {
67
- _context.next = 3;
68
- break;
69
- }
70
-
71
- _keyword = maybeConfig.keyword, _shortcode = maybeConfig.shortcode;
72
- return _context.abrupt("return", _objectSpread({
73
- type: 'SingleSubmissionResult'
74
- }, {
75
- keyword: _keyword,
76
- shortcode: _shortcode
77
- }));
78
-
79
- case 3:
80
- offer = window.pac_analytics.visitor.offer;
81
- config = _objectSpread({
82
- offer: window.pac_analytics.visitor.offer
83
- }, maybeConfig);
84
- host = config.host, country = config.country, slug = config.slug;
85
- rockmanId = window.pac_analytics.visitor.rockmanId;
86
- search = window.location.search.substr(1) || '';
87
- _context.next = 10;
88
- return window.tallymanApi.oc2sms(host, country, slug, offer, rockmanId, keyword, operator, search);
89
-
90
- case 10:
91
- result = _context.sent;
92
-
93
- if (result.success) {
94
- _context.next = 15;
95
- break;
96
- }
97
-
98
- throw result.message;
99
-
100
- case 15:
101
- return _context.abrupt("return", _objectSpread({
102
- type: 'SingleSubmissionResult'
103
- }, {
104
- keyword: "".concat(keyword || result.displayKeyword).concat(result.uid ? " ".concat(result.uid) : ''),
105
- shortcode: result.shortcode
106
- }));
107
-
108
- case 16:
109
- case "end":
110
- return _context.stop();
111
- }
112
- }
113
- }, _callee);
114
- }));
115
- return _loadOnce.apply(this, arguments);
116
- }
117
-
118
- function right(r) {
119
- return {
120
- type: 'right',
121
- value: r
122
- };
123
- }
124
-
125
- function left(l) {
126
- return {
127
- type: 'left',
128
- value: l
129
- };
130
- }
131
-
132
- function foldEither(left, right, either) {
133
- return either.type == 'left' ? left(either.value) : right(either.value);
134
- }
135
-
136
- function loadForMultipleOperators(_x6, _x7, _x8, _x9, _x10) {
137
- return _loadForMultipleOperators.apply(this, arguments);
138
- }
139
-
140
- function _loadForMultipleOperators() {
141
- _loadForMultipleOperators = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(window, maybeConfig, operators, keyword, shortcode) {
142
- var results, finalResults, arrResult;
143
- return regeneratorRuntime.wrap(function _callee3$(_context3) {
144
- while (1) {
145
- switch (_context3.prev = _context3.next) {
146
- case 0:
147
- results = Promise.all(operators.map( /*#__PURE__*/function () {
148
- var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(o) {
149
- var singleResult;
150
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
151
- while (1) {
152
- switch (_context2.prev = _context2.next) {
153
- case 0:
154
- _context2.prev = 0;
155
- _context2.next = 3;
156
- return loadOnce(window, maybeConfig, o, keyword, shortcode);
157
-
158
- case 3:
159
- singleResult = _context2.sent;
160
- return _context2.abrupt("return", right(_objectSpread(_objectSpread({}, singleResult), {}, {
161
- operator: o
162
- })));
163
-
164
- case 7:
165
- _context2.prev = 7;
166
- _context2.t0 = _context2["catch"](0);
167
- return _context2.abrupt("return", left(_context2.t0));
168
-
169
- case 10:
170
- case "end":
171
- return _context2.stop();
172
- }
173
- }
174
- }, _callee2, null, [[0, 7]]);
175
- }));
176
-
177
- return function (_x21) {
178
- return _ref.apply(this, arguments);
179
- };
180
- }()));
181
- _context3.next = 3;
182
- return Promise.resolve(results);
183
-
184
- case 3:
185
- finalResults = _context3.sent;
186
-
187
- if (!finalResults.every(function (r) {
188
- return r.type == 'left';
189
- })) {
190
- _context3.next = 8;
191
- break;
192
- }
193
-
194
- throw finalResults[0].value;
195
-
196
- case 8:
197
- arrResult = [];
198
- finalResults.map(function (obj) {
199
- if (obj.type == 'right') {
200
- var _ref2 = obj.value,
201
- _keyword2 = _ref2.keyword,
202
- _shortcode2 = _ref2.shortcode,
203
- operator = _ref2.operator;
204
- arrResult.push({
205
- keyword: _keyword2,
206
- shortcode: _shortcode2,
207
- operator: operator
208
- });
209
- }
210
- });
211
- return _context3.abrupt("return", {
212
- type: 'MultiOperatorSubmissionResult',
213
- data: arrResult
214
- });
215
-
216
- case 11:
217
- case "end":
218
- return _context3.stop();
219
- }
220
- }
221
- }, _callee3);
222
- }));
223
- return _loadForMultipleOperators.apply(this, arguments);
224
- }
225
-
226
- function load(_x11, _x12, _x13, _x14) {
227
- return _load.apply(this, arguments);
228
- }
229
-
230
- function _load() {
231
- _load = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(window, maybeConfig, keyword, shortcode) {
232
- return regeneratorRuntime.wrap(function _callee4$(_context4) {
233
- while (1) {
234
- switch (_context4.prev = _context4.next) {
235
- case 0:
236
- if (!(!!maybeConfig && maybeConfig.tag == 'keywordAndShortCode')) {
237
- _context4.next = 2;
238
- break;
239
- }
240
-
241
- return _context4.abrupt("return", _objectSpread({
242
- type: 'SingleSubmissionResult'
243
- }, {
244
- keyword: maybeConfig.keyword,
245
- shortcode: maybeConfig.shortcode
246
- }));
247
-
248
- case 2:
249
- if (!(!!maybeConfig && maybeConfig.tag == 'keyword')) {
250
- _context4.next = 4;
251
- break;
252
- }
253
-
254
- return _context4.abrupt("return", load1(window, maybeConfig, keyword, shortcode));
255
-
256
- case 4:
257
- return _context4.abrupt("return", load1(window, maybeConfig, null, null));
258
-
259
- case 5:
260
- case "end":
261
- return _context4.stop();
262
- }
263
- }
264
- }, _callee4);
265
- }));
266
- return _load.apply(this, arguments);
267
- }
268
-
269
- function load1(_x15, _x16, _x17, _x18) {
270
- return _load2.apply(this, arguments);
271
- }
272
-
273
- function _load2() {
274
- _load2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(window, maybeConfig, keyword, shortcode) {
275
- var config, singleOperator;
276
- return regeneratorRuntime.wrap(function _callee5$(_context5) {
277
- while (1) {
278
- switch (_context5.prev = _context5.next) {
279
- case 0:
280
- config = _objectSpread({
281
- offer: window.pac_analytics.visitor.offer
282
- }, maybeConfig);
283
-
284
- if (!(config.automaticallySubmitAllOperators == true && !!config.operators && config.operators.length > 0)) {
285
- _context5.next = 3;
286
- break;
287
- }
288
-
289
- return _context5.abrupt("return", loadForMultipleOperators(window, maybeConfig, config.operators, keyword, shortcode));
290
-
291
- case 3:
292
- singleOperator = maybeConfig.operators && maybeConfig.operators.length > 0 ? maybeConfig.operators[0] : null;
293
- return _context5.abrupt("return", loadOnce(window, maybeConfig, singleOperator, keyword, shortcode));
294
-
295
- case 5:
296
- case "end":
297
- return _context5.stop();
298
- }
299
- }
300
- }, _callee5);
301
- }));
302
- return _load2.apply(this, arguments);
303
- }
304
-
305
- function checkSubscription(_x19, _x20) {
306
- return _checkSubscription.apply(this, arguments);
307
- } // {"success":true,"uid":"*5QADM","shortcode":"1901","keyword":"TIPS"}%
308
- // curl "http://w1.mozzi.com/spa-api/?country=gh&device=smart&slug=18plus-oc2sms&action=oc2sms"
309
-
310
-
311
- function _checkSubscription() {
312
- _checkSubscription = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(window, maybeConfig) {
313
- var config, host, rockmanId, check, checkResult, error;
314
- return regeneratorRuntime.wrap(function _callee6$(_context6) {
315
- while (1) {
316
- switch (_context6.prev = _context6.next) {
317
- case 0:
318
- config = _objectSpread({
319
- offer: window.pac_analytics.visitor.offer
320
- }, maybeConfig);
321
- host = config.host;
322
- rockmanId = window.pac_analytics.visitor.rockmanId;
323
-
324
- check = function check() {
325
- return window.tallymanApi.checkSubscriptionByRockmanIdOnly(host, rockmanId);
326
- };
327
-
328
- _context6.next = 6;
329
- return (0, _strategies.loop)(check, 60, function (r) {
330
- return r.success;
331
- }, 0);
332
-
333
- case 6:
334
- checkResult = _context6.sent;
335
-
336
- if (!(checkResult.success === true)) {
337
- _context6.next = 10;
338
- break;
339
- }
340
-
341
- window.location.href = checkResult.product_url;
342
- return _context6.abrupt("return", checkResult.product_url || null);
343
-
344
- case 10:
345
- error = new Error('SubscriptionFailed'.concat(":\n", checkResult.message));
346
- error.type = 'SubscriptionFailed';
347
- throw error;
348
-
349
- case 13:
350
- case "end":
351
- return _context6.stop();
352
- }
353
- }
354
- }, _callee6);
355
- }));
356
- return _checkSubscription.apply(this, arguments);
357
- }