ouisys-engine 4.3.0-alpha.0 → 4.5.0-alpha.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.
Files changed (158) hide show
  1. package/dist/@types/window.d.js +1 -1
  2. package/dist/api/index.d.ts +43 -0
  3. package/dist/api/index.js +1 -728
  4. package/dist/common-types/AppThunk.d.ts +13 -0
  5. package/dist/common-types/AppThunk.js +1 -1
  6. package/dist/common-types/Either.d.ts +8 -0
  7. package/dist/common-types/Either.js +1 -1
  8. package/dist/common-types/IError.d.ts +3 -0
  9. package/dist/common-types/IError.js +1 -1
  10. package/dist/common-types/IOptInFlowName.d.ts +1 -0
  11. package/dist/common-types/ITracker.d.ts +9 -0
  12. package/dist/common-types/ITracker.js +1 -3
  13. package/dist/common-types/IVisitor.d.ts +14 -0
  14. package/dist/common-types/IVisitor.js +1 -1
  15. package/dist/common-types/RemoteDataState.d.ts +38 -0
  16. package/dist/common-types/RemoteDataState.js +1 -135
  17. package/dist/custom-hooks/useOneClickRedirectUrl.d.ts +3 -0
  18. package/dist/custom-hooks/useOneClickRedirectUrl.js +1 -0
  19. package/dist/custom-hooks/usePinEntryState.d.ts +8 -0
  20. package/dist/custom-hooks/usePinEntryState.js +1 -0
  21. package/dist/custom-hooks/useStrategyConfig.d.ts +4 -0
  22. package/dist/custom-hooks/useStrategyConfig.js +1 -0
  23. package/dist/flows/click2smsFlow.d.ts +6 -0
  24. package/dist/flows/click2smsFlow.js +1 -19
  25. package/dist/flows/creditCardFlow.d.ts +6 -0
  26. package/dist/flows/creditCardFlow.js +1 -0
  27. package/dist/flows/moFlow.d.ts +6 -0
  28. package/dist/flows/moFlow.js +1 -19
  29. package/dist/flows/moRedirFlow.d.ts +6 -0
  30. package/dist/flows/moRedirFlow.js +1 -19
  31. package/dist/flows/oneClickFlow.d.ts +7 -0
  32. package/dist/flows/oneClickFlow.js +1 -23
  33. package/dist/flows/pinFlow.d.ts +7 -0
  34. package/dist/flows/pinFlow.js +1 -23
  35. package/dist/flows/strategy.d.ts +14 -0
  36. package/dist/flows/strategy.js +1 -53
  37. package/dist/flows/ussdFlow.d.ts +6 -0
  38. package/dist/flows/ussdFlow.js +1 -19
  39. package/dist/index.d.ts +0 -0
  40. package/dist/index.js +0 -2
  41. package/dist/ips/tryGetIPRangeName.d.ts +2 -0
  42. package/dist/ips/tryGetIPRangeName.js +1 -74
  43. package/dist/jest.config.js +194 -0
  44. package/dist/pacman/index.d.ts +6 -0
  45. package/dist/pacman/index.js +1 -108
  46. package/dist/pacman/queryString.d.ts +3 -0
  47. package/dist/pacman/queryString.js +1 -45
  48. package/dist/reducers/click2smsFlow/Click2smsTypes.d.ts +76 -0
  49. package/dist/reducers/click2smsFlow/Click2smsTypes.js +1 -1
  50. package/dist/reducers/click2smsFlow/IClick2smsConstants.d.ts +2 -0
  51. package/dist/reducers/click2smsFlow/IClick2smsConstants.js +1 -1
  52. package/dist/reducers/click2smsFlow/index.d.ts +5 -0
  53. package/dist/reducers/click2smsFlow/index.js +1 -183
  54. package/dist/reducers/click2smsFlow/utils.d.ts +4 -0
  55. package/dist/reducers/click2smsFlow/utils.js +1 -357
  56. package/dist/reducers/creditCardFlow/CreditCardTypes.d.ts +79 -0
  57. package/dist/reducers/creditCardFlow/CreditCardTypes.js +1 -0
  58. package/dist/reducers/creditCardFlow/ICreditCardConstants.d.ts +2 -0
  59. package/dist/reducers/creditCardFlow/ICreditCardConstants.js +1 -0
  60. package/dist/reducers/creditCardFlow/index.d.ts +5 -0
  61. package/dist/reducers/creditCardFlow/index.js +1 -0
  62. package/dist/reducers/creditCardFlow/utils.d.ts +8 -0
  63. package/dist/reducers/creditCardFlow/utils.js +1 -0
  64. package/dist/reducers/moFlow/IMoConstants.d.ts +2 -0
  65. package/dist/reducers/moFlow/IMoConstants.js +1 -1
  66. package/dist/reducers/moFlow/MoTypes.d.ts +88 -0
  67. package/dist/reducers/moFlow/MoTypes.js +1 -1
  68. package/dist/reducers/moFlow/index.d.ts +16 -0
  69. package/dist/reducers/moFlow/index.js +1 -251
  70. package/dist/reducers/moFlow/utils.d.ts +12 -0
  71. package/dist/reducers/moFlow/utils.js +1 -284
  72. package/dist/reducers/moRedirFlow/IMoRedirConstants.d.ts +2 -0
  73. package/dist/reducers/moRedirFlow/IMoRedirConstants.js +1 -1
  74. package/dist/reducers/moRedirFlow/MoRedirTypes.d.ts +64 -0
  75. package/dist/reducers/moRedirFlow/MoRedirTypes.js +1 -1
  76. package/dist/reducers/moRedirFlow/index.d.ts +14 -0
  77. package/dist/reducers/moRedirFlow/index.js +1 -226
  78. package/dist/reducers/moRedirFlow/utils.d.ts +10 -0
  79. package/dist/reducers/moRedirFlow/utils.js +1 -186
  80. package/dist/reducers/oneClickFlow/IOneClickConstants.d.ts +2 -0
  81. package/dist/reducers/oneClickFlow/IOneClickConstants.js +1 -1
  82. package/dist/reducers/oneClickFlow/OneClickTypes.d.ts +85 -0
  83. package/dist/reducers/oneClickFlow/OneClickTypes.js +1 -1
  84. package/dist/reducers/oneClickFlow/index.d.ts +13 -0
  85. package/dist/reducers/oneClickFlow/index.js +1 -409
  86. package/dist/reducers/oneClickFlow/utils.d.ts +16 -0
  87. package/dist/reducers/oneClickFlow/utils.js +1 -366
  88. package/dist/reducers/pinFlow/IPinConstants.d.ts +2 -0
  89. package/dist/reducers/pinFlow/IPinConstants.js +1 -1
  90. package/dist/reducers/pinFlow/PinTypes.d.ts +156 -0
  91. package/dist/reducers/pinFlow/PinTypes.js +1 -1
  92. package/dist/reducers/pinFlow/index.d.ts +19 -0
  93. package/dist/reducers/pinFlow/index.js +1 -514
  94. package/dist/reducers/pinFlow/utils.d.ts +11 -0
  95. package/dist/reducers/pinFlow/utils.js +1 -494
  96. package/dist/reducers/strategy/IStategyActionContants.d.ts +2 -0
  97. package/dist/reducers/strategy/IStategyActionContants.js +1 -1
  98. package/dist/reducers/strategy/StrategyTypes.d.ts +248 -0
  99. package/dist/reducers/strategy/StrategyTypes.js +1 -1
  100. package/dist/reducers/strategy/index.d.ts +13 -0
  101. package/dist/reducers/strategy/index.js +1 -389
  102. package/dist/reducers/strategy/strategies/ask_mobile_number.d.ts +15 -0
  103. package/dist/reducers/strategy/strategies/ask_mobile_number.js +1 -403
  104. package/dist/reducers/strategy/strategies/ask_operator.d.ts +5 -0
  105. package/dist/reducers/strategy/strategies/ask_operator.js +1 -305
  106. package/dist/reducers/strategy/strategies/detect_operator_by_ip.d.ts +10 -0
  107. package/dist/reducers/strategy/strategies/detect_operator_by_ip.js +1 -459
  108. package/dist/reducers/strategy/strategies/header_enrichment.d.ts +7 -0
  109. package/dist/reducers/strategy/strategies/header_enrichment.js +1 -783
  110. package/dist/reducers/strategy/strategies/injectHeaderEnrichmentScript.d.ts +2 -0
  111. package/dist/reducers/strategy/strategies/injectHeaderEnrichmentScript.js +1 -0
  112. package/dist/reducers/strategy/utils.d.ts +30 -0
  113. package/dist/reducers/strategy/utils.js +1 -702
  114. package/dist/reducers/ussdFlow/IUssdConstants.d.ts +2 -0
  115. package/dist/reducers/ussdFlow/IUssdConstants.js +1 -1
  116. package/dist/reducers/ussdFlow/UssdTypes.d.ts +77 -0
  117. package/dist/reducers/ussdFlow/UssdTypes.js +1 -1
  118. package/dist/reducers/ussdFlow/index.d.ts +14 -0
  119. package/dist/reducers/ussdFlow/index.js +1 -251
  120. package/dist/reducers/ussdFlow/utils.d.ts +11 -0
  121. package/dist/reducers/ussdFlow/utils.js +1 -225
  122. package/dist/store/index.d.ts +14 -0
  123. package/dist/store/index.js +1 -177
  124. package/dist/store/reducers.d.ts +20 -0
  125. package/dist/store/reducers.js +1 -41
  126. package/dist/utilities/addEmpelloToken.d.ts +4 -0
  127. package/dist/utilities/addEmpelloToken.js +1 -0
  128. package/dist/utilities/handleSubmitNumber.d.ts +21 -0
  129. package/dist/utilities/handleSubmitNumber.js +1 -59
  130. package/dist/utilities/index.d.ts +14 -0
  131. package/dist/utilities/index.js +1 -0
  132. package/dist/utilities/loadScriptInnerHtml.d.ts +2 -0
  133. package/dist/utilities/loadScriptInnerHtml.js +1 -0
  134. package/dist/utilities/loadScriptSrc.d.ts +8 -0
  135. package/dist/utilities/loadScriptSrc.js +1 -0
  136. package/dist/utilities/replaceUrlParam.d.ts +1 -0
  137. package/dist/utilities/replaceUrlParam.js +1 -0
  138. package/dist/utilities/storeMsisdn.d.ts +3 -0
  139. package/dist/utilities/storeMsisdn.js +1 -0
  140. package/package.json +1 -1
  141. package/dist/app/store.js +0 -20
  142. package/dist/features/strategies/categories/askMobileNumber.js +0 -388
  143. package/dist/features/strategies/categories/askOperator.js +0 -313
  144. package/dist/features/strategies/categories/detectOperatorByIp.js +0 -599
  145. package/dist/features/strategies/categories/headerEnrichment.js +0 -665
  146. package/dist/features/strategies/categories/singleFlows/pin.js +0 -1
  147. package/dist/features/strategies/identifySlice.js +0 -355
  148. package/dist/features/strategies/pinFlowSlice.js +0 -338
  149. package/dist/flows/tpayHeFlow.js +0 -23
  150. package/dist/mockServer/browser.js +0 -48
  151. package/dist/mockServer/handlers.js +0 -22
  152. package/dist/mockServer/server.js +0 -48
  153. package/dist/reducers/tpayHeFlow/ITpayHeConstants.js +0 -1
  154. package/dist/reducers/tpayHeFlow/TpayHeTypes.js +0 -1
  155. package/dist/reducers/tpayHeFlow/index.js +0 -331
  156. package/dist/reducers/tpayHeFlow/utils.js +0 -510
  157. package/dist/test/setup.js +0 -24
  158. package/dist/test/test-utils.js +0 -51
@@ -1,355 +0,0 @@
1
- "use strict";
2
-
3
- function _typeof(obj) { "@babel/helpers - typeof"; 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); }
4
-
5
- require("core-js/modules/es.symbol");
6
-
7
- require("core-js/modules/es.symbol.description");
8
-
9
- require("core-js/modules/es.symbol.iterator");
10
-
11
- require("core-js/modules/es.array.includes");
12
-
13
- require("core-js/modules/es.array.iterator");
14
-
15
- require("core-js/modules/es.object.get-own-property-descriptor");
16
-
17
- require("core-js/modules/es.object.to-string");
18
-
19
- require("core-js/modules/es.promise");
20
-
21
- require("core-js/modules/es.string.includes");
22
-
23
- require("core-js/modules/es.string.iterator");
24
-
25
- require("core-js/modules/es.weak-map");
26
-
27
- require("core-js/modules/web.dom-collections.iterator");
28
-
29
- Object.defineProperty(exports, "__esModule", {
30
- value: true
31
- });
32
- exports.default = exports.identify = exports.StrategyStates = exports.tracker = void 0;
33
-
34
- require("regenerator-runtime/runtime");
35
-
36
- var _toolkit = require("@reduxjs/toolkit");
37
-
38
- var RDS = _interopRequireWildcard(require("../../common-types/RemoteDataState"));
39
-
40
- var _pacman = _interopRequireDefault(require("../../pacman"));
41
-
42
- var _utils = _interopRequireWildcard(require("../../reducers/strategy/utils"));
43
-
44
- var _askMobileNumber = require("./categories/askMobileNumber");
45
-
46
- var _askOperator = require("./categories/askOperator");
47
-
48
- var _detectOperatorByIp = require("./categories/detectOperatorByIp");
49
-
50
- var _headerEnrichment = require("./categories/headerEnrichment");
51
-
52
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
53
-
54
- function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
55
-
56
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
57
-
58
- 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); } }
59
-
60
- 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); }); }; }
61
-
62
- var tracker = (0, _pacman.default)(typeof window !== 'undefined' ? window : null); // enum actions {
63
- // IDENTIFY_STRATEGY_STATE = 'IDENTIFY_STRATEGY_STATE'
64
- // }
65
-
66
- exports.tracker = tracker;
67
- var StrategyStates; // interface IReturnIdentifyStrategy {
68
- // type: StrategyStates;
69
- // result: RDS.RemoteDataState<IDENTIFYFailure, IDENTIFYSuccess>;
70
- // }
71
-
72
- exports.StrategyStates = StrategyStates;
73
-
74
- (function (StrategyStates) {
75
- StrategyStates["IDENTIFY_STRATEGY"] = "IDENTIFY_STRATEGY";
76
- StrategyStates["IDENTIFY_FLOW_BY_MSISDN"] = "IDENTIFY_FLOW_BY_MSISDN";
77
- StrategyStates["IDENTIFY_FLOW_BY_OPERATOR_SELECT"] = "IDENTIFY_FLOW_BY_OPERATOR_SELECT";
78
- StrategyStates["IDENTIFY_FLOW_BY_HE"] = "IDENTIFY_FLOW_BY_HE";
79
- StrategyStates["ONE_CLICK"] = "ONE_CLICK";
80
- StrategyStates["PIN"] = "PIN";
81
- StrategyStates["MO_REDIR"] = "MO_REDIR";
82
- StrategyStates["CLICK2SMS"] = "CLICK2SMS";
83
- StrategyStates["MO"] = "MO";
84
- StrategyStates["USSD"] = "USSD";
85
- })(StrategyStates || (exports.StrategyStates = StrategyStates = {}));
86
-
87
- var strategyBasedInitialState = function strategyBasedInitialState() {
88
- var configs = _utils.default.getConfig();
89
-
90
- var strategy = configs.strategy,
91
- strategyConfigs = configs.strategyConfigs;
92
-
93
- if (strategy.includes('ask-operator')) {
94
- var operators = (0, _utils.getOperators)({
95
- configs: configs
96
- });
97
- return {
98
- type: StrategyStates.IDENTIFY_FLOW_BY_OPERATOR_SELECT,
99
- result: {
100
- operators: operators
101
- }
102
- };
103
- }
104
-
105
- if (strategy.indexOf('ask-mobile-number') !== -1 || strategy.indexOf('header-enrichment') !== -1) {
106
- return {
107
- type: StrategyStates.IDENTIFY_FLOW_BY_MSISDN,
108
- result: RDS.NothingYet(),
109
- nextData: {}
110
- };
111
- }
112
-
113
- if (strategy.indexOf('detect-operator-by-ip') !== -1) {
114
- return {
115
- type: StrategyStates.IDENTIFY_STRATEGY,
116
- result: RDS.Loading()
117
- };
118
- }
119
-
120
- switch (strategy) {
121
- // case 'pin':
122
- // return {
123
- // type: 'PIN',
124
- // result: {
125
- // nextAction: 'identifySubmitMSISDNAction',
126
- // config: strategyConfigs.default.flowConfig
127
- // }
128
- // };
129
- // case 'mo':
130
- // return {
131
- // type: 'MO',
132
- // result: {
133
- // nextAction: 'identifySubmitMSISDNAction',
134
- // config: strategyConfigs.default.flowConfig
135
- // }
136
- // };
137
- // case 'mo-redir':
138
- // return {
139
- // type: 'MO_REDIR',
140
- // result: {
141
- // nextAction: 'identifySubmitMSISDNAction',
142
- // config: strategyConfigs.default.flowConfig
143
- // }
144
- // };
145
- case 'one-click':
146
- return {
147
- type: StrategyStates.ONE_CLICK,
148
- result: {
149
- config: strategyConfigs.default.flowConfig
150
- }
151
- };
152
- // case 'click2sms':
153
- // return {
154
- // type: 'CLICK2SMS',
155
- // result: {
156
- // nextAction: 'loadOc2sms',
157
- // config: strategyConfigs.default.flowConfig
158
- // }
159
- // };
160
- // case 'ussd':
161
- // return {
162
- // type: 'USSD',
163
- // result: {
164
- // nextAction: 'identifySubmitMSISDNAction',
165
- // config: strategyConfigs.default.flowConfig
166
- // }
167
- // };
168
-
169
- default: // return {
170
- // type: 'IDENTIFY_STRATEGY',
171
- // result: RDS.Loading()
172
- // };
173
-
174
- }
175
- };
176
-
177
- var initialState = {
178
- currentState: strategyBasedInitialState()
179
- };
180
- var identify = (0, _toolkit.createAsyncThunk)('strategy/identify',
181
- /*#__PURE__*/
182
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
183
- // @ts-ignore
184
- function () {
185
- var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(configsPayload, thunkApi) {
186
- var configs, strategy;
187
- return regeneratorRuntime.wrap(function _callee$(_context) {
188
- while (1) {
189
- switch (_context.prev = _context.next) {
190
- case 0:
191
- configs = configsPayload || (0, _utils.getConfig)();
192
- strategy = configs.strategy;
193
- _context.prev = 2;
194
-
195
- if (!(strategy.indexOf('detect-operator-by-ip') !== -1)) {
196
- _context.next = 5;
197
- break;
198
- }
199
-
200
- return _context.abrupt("return", (0, _detectOperatorByIp.detectOperatorByIp)({
201
- configs: configs
202
- }));
203
-
204
- case 5:
205
- if (!(strategy.indexOf('ask-mobile-number') !== -1)) {
206
- _context.next = 7;
207
- break;
208
- }
209
-
210
- return _context.abrupt("return", (0, _askMobileNumber.askMobileNumber)({
211
- configs: configs
212
- }));
213
-
214
- case 7:
215
- if (!(strategy.indexOf('ask-operator') !== -1)) {
216
- _context.next = 9;
217
- break;
218
- }
219
-
220
- return _context.abrupt("return", (0, _askOperator.askOperator)({
221
- configs: configs
222
- }));
223
-
224
- case 9:
225
- if (!(strategy.indexOf('header-enrichment') !== -1)) {
226
- _context.next = 11;
227
- break;
228
- }
229
-
230
- return _context.abrupt("return", (0, _headerEnrichment.identifyUserByHe)({
231
- configs: configs
232
- }));
233
-
234
- case 11:
235
- return _context.abrupt("return", thunkApi.rejectWithValue('identify: Strategy not supported'));
236
-
237
- case 14:
238
- _context.prev = 14;
239
- _context.t0 = _context["catch"](2);
240
- console.error(_context.t0);
241
-
242
- case 17:
243
- case "end":
244
- return _context.stop();
245
- }
246
- }
247
- }, _callee, null, [[2, 14]]);
248
- }));
249
-
250
- return function (_x, _x2) {
251
- return _ref.apply(this, arguments);
252
- };
253
- }());
254
- exports.identify = identify;
255
-
256
- var handleIdentify = function handleIdentify(builder) {
257
- builder.addCase(identify.pending, function (state) {
258
- state.currentState = {
259
- type: StrategyStates.IDENTIFY_STRATEGY,
260
- result: RDS.Loading()
261
- };
262
- });
263
- builder.addCase(identify.fulfilled, function (state, _ref2) {
264
- var payload = _ref2.payload;
265
- state.currentState = payload;
266
- });
267
- builder.addCase(identify.rejected, function (state, _ref3) {
268
- var payload = _ref3.payload;
269
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
270
- // @ts-ignore
271
- state.currentState = {
272
- type: StrategyStates.IDENTIFY_FLOW_BY_MSISDN,
273
- result: RDS.Failure(payload)
274
- };
275
- });
276
- };
277
-
278
- var handleIdentifySubmitMSISDNAction = function handleIdentifySubmitMSISDNAction(builder) {
279
- builder.addCase(_askMobileNumber.identifySubmitMSISDNAction.pending, function (state) {
280
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
281
- // @ts-ignore
282
- state.currentState = {
283
- type: StrategyStates.IDENTIFY_FLOW_BY_MSISDN,
284
- result: RDS.Loading()
285
- };
286
- });
287
- builder.addCase(_askMobileNumber.identifySubmitMSISDNAction.fulfilled, function (state, _ref4) {
288
- var payload = _ref4.payload;
289
- state.currentState = payload;
290
- });
291
- builder.addCase(_askMobileNumber.identifySubmitMSISDNAction.rejected, function (state, _ref5) {
292
- var payload = _ref5.payload;
293
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
294
- // @ts-ignore
295
- state.currentState = {
296
- type: StrategyStates.IDENTIFY_FLOW_BY_MSISDN,
297
- result: RDS.Failure(payload)
298
- };
299
- });
300
- };
301
-
302
- var handleSelectOperatorAction = function handleSelectOperatorAction(builder) {
303
- builder.addCase(_askOperator.selectOperatorAction.pending, function (state) {
304
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
305
- // @ts-ignore
306
- state.currentState = {
307
- type: StrategyStates.IDENTIFY_FLOW_BY_OPERATOR_SELECT,
308
- result: RDS.Loading()
309
- };
310
- });
311
- builder.addCase(_askOperator.selectOperatorAction.fulfilled, function (state, _ref6) {
312
- var payload = _ref6.payload;
313
- state.currentState = payload;
314
- });
315
- builder.addCase(_askOperator.selectOperatorAction.rejected, function (state, _ref7) {
316
- var payload = _ref7.payload;
317
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
318
- // @ts-ignore
319
- state.currentState = {
320
- type: StrategyStates.IDENTIFY_FLOW_BY_OPERATOR_SELECT,
321
- result: RDS.Failure(payload)
322
- };
323
- });
324
- };
325
-
326
- var identifySlice = (0, _toolkit.createSlice)({
327
- name: 'strategy',
328
- initialState: initialState,
329
- reducers: {// identify(state, action: PayloadAction<IStrategy>) {
330
- // // state is not muteted as redux toolkit uses immuer
331
- // // under the hood
332
- // const configs = action.payload;
333
- // const strategy = 'pin-one-click-detect-operator-by-ip';
334
- // switch (strategy) {
335
- // case 'pin-one-click-detect-operator-by-ip': {
336
- // const newState = await pinOneClickDetectOperatorByIp({ configs });
337
- // // eslint-disable-next-line @typescript-eslint/ban-ts-comment
338
- // // @ts-ignore
339
- // state.currentState = {
340
- // type: StrategyStates.ONE_CLICK,
341
- // result: RDS.Success(newState)
342
- // };
343
- // }
344
- // // throw 'Strategy not supported';
345
- // }
346
- },
347
- extraReducers: function extraReducers(builder) {
348
- handleIdentify(builder);
349
- handleIdentifySubmitMSISDNAction(builder);
350
- handleSelectOperatorAction(builder);
351
- }
352
- }); // export const { identify } = identifySlice.actions;
353
-
354
- var _default = identifySlice.reducer;
355
- exports.default = _default;
@@ -1,338 +0,0 @@
1
- "use strict";
2
-
3
- function _typeof(obj) { "@babel/helpers - typeof"; 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); }
4
-
5
- require("core-js/modules/es.symbol");
6
-
7
- require("core-js/modules/es.symbol.description");
8
-
9
- require("core-js/modules/es.symbol.iterator");
10
-
11
- require("core-js/modules/es.array.includes");
12
-
13
- require("core-js/modules/es.array.iterator");
14
-
15
- require("core-js/modules/es.object.get-own-property-descriptor");
16
-
17
- require("core-js/modules/es.object.to-string");
18
-
19
- require("core-js/modules/es.promise");
20
-
21
- require("core-js/modules/es.string.includes");
22
-
23
- require("core-js/modules/es.string.iterator");
24
-
25
- require("core-js/modules/es.weak-map");
26
-
27
- require("core-js/modules/web.dom-collections.iterator");
28
-
29
- Object.defineProperty(exports, "__esModule", {
30
- value: true
31
- });
32
- exports.default = exports.identify = exports.pinOneClickDetectOperatorByIp = exports.StrategyStates = void 0;
33
-
34
- require("regenerator-runtime/runtime");
35
-
36
- var _toolkit = require("@reduxjs/toolkit");
37
-
38
- var RDS = _interopRequireWildcard(require("../../common-types/RemoteDataState"));
39
-
40
- var _utils = _interopRequireWildcard(require("../../reducers/strategy/utils"));
41
-
42
- function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
43
-
44
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
45
-
46
- 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); } }
47
-
48
- 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); }); }; }
49
-
50
- // enum actions {
51
- // IDENTIFY_STRATEGY_STATE = 'IDENTIFY_STRATEGY_STATE'
52
- // }
53
- var StrategyStates; // interface IReturnIdentifyStrategy {
54
- // type: StrategyStates;
55
- // result: RDS.RemoteDataState<IDENTIFYFailure, IDENTIFYSuccess>;
56
- // }
57
-
58
- exports.StrategyStates = StrategyStates;
59
-
60
- (function (StrategyStates) {
61
- StrategyStates["IDENTIFY_STRATEGY"] = "IDENTIFY_STRATEGY";
62
- StrategyStates["ONE_CLICK"] = "ONE_CLICK";
63
- StrategyStates["PIN"] = "PIN";
64
- })(StrategyStates || (exports.StrategyStates = StrategyStates = {}));
65
-
66
- var strategyBasedInitialState = function strategyBasedInitialState() {
67
- var configs = _utils.default.getConfig();
68
-
69
- var strategy = configs.strategy,
70
- strategyConfigs = configs.strategyConfigs; // if (strategy.includes('ask-operator')) {
71
- // const operators = getOperators({ configs });
72
- // return {
73
- // type: 'IDENTIFY_FLOW_BY_OPERATOR_SELECT',
74
- // result: { operators, nextAction: 'selectOperator' }
75
- // };
76
- // }
77
- // if (strategy.includes('ask-mobile-number') || strategy.includes('header-enrichment')) {
78
- // return {
79
- // type: 'IDENTIFY_FLOW_BY_MSISDN',
80
- // result: RDS.NothingYet(),
81
- // nextData: {
82
- // // eslint-disable-next-line @typescript-eslint/ban-ts-comment
83
- // // @ts-ignore
84
- // nextAction: 'submitMSISDNActionkjj'
85
- // }
86
- // };
87
- // }
88
-
89
- if (strategy.includes('detect-operator-by-ip')) {
90
- return {
91
- type: 'DETECT_OPERATOR_BY_IP',
92
- result: RDS.Loading()
93
- };
94
- }
95
-
96
- switch (strategy) {
97
- // case 'pin':
98
- // return {
99
- // type: 'PIN',
100
- // result: {
101
- // nextAction: 'submitMSISDNAction',
102
- // config: strategyConfigs.default.flowConfig
103
- // }
104
- // };
105
- // case 'mo':
106
- // return {
107
- // type: 'MO',
108
- // result: {
109
- // nextAction: 'submitMSISDNAction',
110
- // config: strategyConfigs.default.flowConfig
111
- // }
112
- // };
113
- // case 'mo-redir':
114
- // return {
115
- // type: 'MO_REDIR',
116
- // result: {
117
- // nextAction: 'submitMSISDNAction',
118
- // config: strategyConfigs.default.flowConfig
119
- // }
120
- // };
121
- case 'one-click':
122
- return {
123
- type: StrategyStates.ONE_CLICK,
124
- result: {
125
- config: strategyConfigs.default.flowConfig
126
- }
127
- };
128
- // case 'click2sms':
129
- // return {
130
- // type: 'CLICK2SMS',
131
- // result: {
132
- // nextAction: 'loadOc2sms',
133
- // config: strategyConfigs.default.flowConfig
134
- // }
135
- // };
136
- // case 'ussd':
137
- // return {
138
- // type: 'USSD',
139
- // result: {
140
- // nextAction: 'submitMSISDNAction',
141
- // config: strategyConfigs.default.flowConfig
142
- // }
143
- // };
144
-
145
- default: // return {
146
- // type: 'IDENTIFY_STRATEGY',
147
- // result: RDS.Loading()
148
- // };
149
-
150
- }
151
- };
152
-
153
- var initialState = {
154
- currentState: strategyBasedInitialState()
155
- };
156
-
157
- var pinOneClickDetectOperatorByIp = /*#__PURE__*/function () {
158
- var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(_ref) {
159
- var configs, strategyConfigs, defaultFlow, flowObj;
160
- return regeneratorRuntime.wrap(function _callee$(_context) {
161
- while (1) {
162
- switch (_context.prev = _context.next) {
163
- case 0:
164
- configs = _ref.configs;
165
- strategyConfigs = configs.strategyConfigs;
166
- defaultFlow = strategyConfigs.default;
167
- console.log('configs', configs);
168
- _context.prev = 4;
169
- _context.next = 7;
170
- return (0, _utils.determineFlowByOperatorFromIp)({
171
- configs: configs
172
- });
173
-
174
- case 7:
175
- flowObj = _context.sent;
176
- _context.t0 = flowObj.flow;
177
- _context.next = _context.t0 === 'pin' ? 11 : _context.t0 === 'oneClick' ? 12 : 13;
178
- break;
179
-
180
- case 11:
181
- return _context.abrupt("return", {
182
- type: StrategyStates.PIN,
183
- result: {
184
- flowConfig: flowObj.flowConfig,
185
- operator: flowObj.operator
186
- }
187
- });
188
-
189
- case 12:
190
- return _context.abrupt("return", {
191
- type: StrategyStates.ONE_CLICK,
192
- result: {
193
- flowConfig: flowObj.flowConfig,
194
- operator: flowObj.operator
195
- }
196
- });
197
-
198
- case 13:
199
- return _context.abrupt("return", {
200
- type: StrategyStates.PIN,
201
- result: {
202
- flowConfig: defaultFlow.flowConfig,
203
- operator: flowObj.operator
204
- }
205
- });
206
-
207
- case 14:
208
- _context.next = 20;
209
- break;
210
-
211
- case 16:
212
- _context.prev = 16;
213
- _context.t1 = _context["catch"](4);
214
- console.warn(_context.t1);
215
- return _context.abrupt("return", {
216
- type: StrategyStates.PIN,
217
- result: {
218
- flowConfig: defaultFlow.flowConfig
219
- }
220
- });
221
-
222
- case 20:
223
- case "end":
224
- return _context.stop();
225
- }
226
- }
227
- }, _callee, null, [[4, 16]]);
228
- }));
229
-
230
- return function pinOneClickDetectOperatorByIp(_x) {
231
- return _ref2.apply(this, arguments);
232
- };
233
- }();
234
-
235
- exports.pinOneClickDetectOperatorByIp = pinOneClickDetectOperatorByIp;
236
- var identify = (0, _toolkit.createAsyncThunk)('strategy/identify',
237
- /*#__PURE__*/
238
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
239
- // @ts-ignore
240
- function () {
241
- var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(configsPayload, thunkApi) {
242
- var configs, strategy;
243
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
244
- while (1) {
245
- switch (_context2.prev = _context2.next) {
246
- case 0:
247
- configs = configsPayload || (0, _utils.getConfig)();
248
- strategy = configs.strategy; // case 'one-click-mo-pin-detect-operator-by-ip-or-msisdn':
249
- // case 'mo-redir-one-click-detect-operator-by-ip':
250
- // case 'mo-one-click-detect-operator-by-ip':
251
- // case 'click2sms-one-click-detect-operator-by-ip':
252
- // case 'pin-mo-detect-operator-by-ip':
253
-
254
- _context2.prev = 2;
255
- _context2.t0 = strategy;
256
- _context2.next = _context2.t0 === 'pin-one-click-detect-operator-by-ip' ? 6 : 9;
257
- break;
258
-
259
- case 6:
260
- _context2.next = 8;
261
- return pinOneClickDetectOperatorByIp({
262
- configs: configs
263
- });
264
-
265
- case 8:
266
- return _context2.abrupt("return", _context2.sent);
267
-
268
- case 9:
269
- return _context2.abrupt("return", thunkApi.rejectWithValue('Opps there seems to be an error'));
270
-
271
- case 10:
272
- _context2.next = 16;
273
- break;
274
-
275
- case 12:
276
- _context2.prev = 12;
277
- _context2.t1 = _context2["catch"](2);
278
- console.error(_context2.t1); // You can choose to use the message attached to err or write a custom error
279
-
280
- return _context2.abrupt("return", thunkApi.rejectWithValue('Opps there seems to be an error'));
281
-
282
- case 16:
283
- case "end":
284
- return _context2.stop();
285
- }
286
- }
287
- }, _callee2, null, [[2, 12]]);
288
- }));
289
-
290
- return function (_x2, _x3) {
291
- return _ref3.apply(this, arguments);
292
- };
293
- }());
294
- exports.identify = identify;
295
- var identifySlice = (0, _toolkit.createSlice)({
296
- name: 'strategy',
297
- initialState: initialState,
298
- reducers: {// identify(state, action: PayloadAction<IStrategy>) {
299
- // // state is not muteted as redux toolkit uses immuer
300
- // // under the hood
301
- // const configs = action.payload;
302
- // const strategy = 'pin-one-click-detect-operator-by-ip';
303
- // switch (strategy) {
304
- // case 'pin-one-click-detect-operator-by-ip': {
305
- // const newState = await pinOneClickDetectOperatorByIp({ configs });
306
- // // eslint-disable-next-line @typescript-eslint/ban-ts-comment
307
- // // @ts-ignore
308
- // state.currentState = {
309
- // type: StrategyStates.ONE_CLICK,
310
- // result: RDS.Success(newState)
311
- // };
312
- // }
313
- // // throw 'Strategy not supported';
314
- // }
315
- },
316
- extraReducers: function extraReducers(builder) {
317
- builder.addCase(identify.pending, function (state) {
318
- state.currentState = {
319
- type: StrategyStates.IDENTIFY_STRATEGY,
320
- result: RDS.Loading()
321
- };
322
- });
323
- builder.addCase(identify.fulfilled, function (state, _ref4) {
324
- var payload = _ref4.payload;
325
- state.currentState = payload;
326
- });
327
- builder.addCase(identify.rejected, function (state, _ref5) {
328
- var payload = _ref5.payload;
329
- state.currentState = {
330
- type: StrategyStates.IDENTIFY_STRATEGY,
331
- result: RDS.Failure(payload)
332
- };
333
- });
334
- }
335
- }); // export const { identify } = identifySlice.actions;
336
-
337
- var _default = identifySlice.reducer;
338
- exports.default = _default;