ouisys-engine 4.7.0-alpha.1 → 4.7.0-alpha.11

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 (70) hide show
  1. package/dist/RemoteDataState-lcf8PfJd.js +2 -0
  2. package/dist/{RemoteDataState-CwHLI23e.js.map → RemoteDataState-lcf8PfJd.js.map} +1 -1
  3. package/dist/bupperizeCountry-CEtt0MKz.js +2 -0
  4. package/dist/bupperizeCountry-CEtt0MKz.js.map +1 -0
  5. package/dist/checkSubscriptionByRockmanIdOnly-BwR1un1L.js +2 -0
  6. package/dist/{checkSubscriptionByRockmanIdOnly-C89Ph9cV.js.map → checkSubscriptionByRockmanIdOnly-BwR1un1L.js.map} +1 -1
  7. package/dist/checkSubscriptionHander.js +1 -52
  8. package/dist/checkSubscriptionHander.js.map +1 -1
  9. package/dist/click2smsFlow.js +1 -245
  10. package/dist/click2smsFlow.js.map +1 -1
  11. package/dist/creditCardFlow.js +1 -247
  12. package/dist/creditCardFlow.js.map +1 -1
  13. package/dist/getConfig.js +1 -13
  14. package/dist/getConfig.js.map +1 -1
  15. package/dist/handleClickChainFlow.js +1 -31
  16. package/dist/handleClickChainFlow.js.map +1 -1
  17. package/dist/handleSubmitNumber.js +1 -64
  18. package/dist/handleSubmitNumber.js.map +1 -1
  19. package/dist/helpers-xPhGBX-B.js +2 -0
  20. package/dist/helpers-xPhGBX-B.js.map +1 -0
  21. package/dist/loadScriptInnerHtml-BzQm-AFb.js +2 -0
  22. package/dist/loadScriptInnerHtml-BzQm-AFb.js.map +1 -0
  23. package/dist/loadScriptSrc-Da4autZd.js +2 -0
  24. package/dist/loadScriptSrc-Da4autZd.js.map +1 -0
  25. package/dist/moFlow.js +1 -274
  26. package/dist/moFlow.js.map +1 -1
  27. package/dist/moRedirFlow.js +1 -224
  28. package/dist/moRedirFlow.js.map +1 -1
  29. package/dist/oneClickFlow.js +1 -463
  30. package/dist/oneClickFlow.js.map +1 -1
  31. package/dist/pinFlow.js +1 -696
  32. package/dist/pinFlow.js.map +1 -1
  33. package/dist/searchToObject.js +1 -18
  34. package/dist/searchToObject.js.map +1 -1
  35. package/dist/storeMsisdn-Cjq8_qYH.js +2 -0
  36. package/dist/{storeMsisdn-ChiBh8mI.js.map → storeMsisdn-Cjq8_qYH.js.map} +1 -1
  37. package/dist/strategy.js +1 -49
  38. package/dist/strategy.js.map +1 -1
  39. package/dist/strategySlice-Dw14E22-.js +2 -0
  40. package/dist/strategySlice-Dw14E22-.js.map +1 -0
  41. package/dist/tracker-DaaILhEr.js +2 -0
  42. package/dist/tracker-DaaILhEr.js.map +1 -0
  43. package/dist/tracker.js +1 -4
  44. package/dist/tracker.js.map +1 -1
  45. package/dist/tryGetIPRangeName-QW-9NgzE.js +2 -0
  46. package/dist/tryGetIPRangeName-QW-9NgzE.js.map +1 -0
  47. package/dist/types/{OneClickTypes-DF0jodl-.d.ts → OneClickTypes-DjOesaHp.d.ts} +1 -1
  48. package/dist/types/{StrategyTypes-BEIYqoJV.d.ts → StrategyTypes-CbOgk0N4.d.ts} +3 -2
  49. package/dist/types/click2smsFlow.d.ts +3 -3
  50. package/dist/types/handleSubmitNumber.d.ts +3 -3
  51. package/dist/types/oneClickFlow.d.ts +2 -2
  52. package/dist/types/strategy.d.ts +12 -4
  53. package/dist/ussdFlow.js +1 -210
  54. package/dist/ussdFlow.js.map +1 -1
  55. package/package.json +6 -6
  56. package/dist/RemoteDataState-CwHLI23e.js +0 -75
  57. package/dist/bupperizeCountry-CCDIOHP6.js +0 -4
  58. package/dist/bupperizeCountry-CCDIOHP6.js.map +0 -1
  59. package/dist/checkSubscriptionByRockmanIdOnly-C89Ph9cV.js +0 -27
  60. package/dist/helpers-J_h-ZgxH.js +0 -29
  61. package/dist/helpers-J_h-ZgxH.js.map +0 -1
  62. package/dist/loadScriptInnerHtml-DPcoY467.js +0 -26
  63. package/dist/loadScriptInnerHtml-DPcoY467.js.map +0 -1
  64. package/dist/storeMsisdn-ChiBh8mI.js +0 -58
  65. package/dist/strategySlice-bF74rxDK.js +0 -842
  66. package/dist/strategySlice-bF74rxDK.js.map +0 -1
  67. package/dist/tracker-B_zsMRN2.js +0 -79
  68. package/dist/tracker-B_zsMRN2.js.map +0 -1
  69. package/dist/tryGetIPRangeName-C69HEG5W.js +0 -42
  70. package/dist/tryGetIPRangeName-C69HEG5W.js.map +0 -1
@@ -1,842 +0,0 @@
1
- import { __awaiter, __generator, __assign } from 'tslib';
2
- import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
3
- import { N as NothingYet, S as Success, L as Loading, F as Failure } from './RemoteDataState-CwHLI23e.js';
4
- import { searchToObject } from './searchToObject.js';
5
- import { getConfig } from './getConfig.js';
6
- import 'awesome-phonenumber';
7
- import { t as tryGetIPRangeName } from './tryGetIPRangeName-C69HEG5W.js';
8
- import { t as tracker } from './tracker-B_zsMRN2.js';
9
-
10
- var PossibleTypes;
11
- (function (PossibleTypes) {
12
- PossibleTypes["IDENTIFY_STRATEGY"] = "IDENTIFY_STRATEGY";
13
- PossibleTypes["IDENTIFY_FLOW_BY_MSISDN"] = "IDENTIFY_FLOW_BY_MSISDN";
14
- PossibleTypes["IDENTIFY_FLOW_BY_OPERATOR_SELECT"] = "IDENTIFY_FLOW_BY_OPERATOR_SELECT";
15
- PossibleTypes["PIN"] = "PIN";
16
- PossibleTypes["MO"] = "MO";
17
- PossibleTypes["MO_REDIR"] = "MO_REDIR";
18
- PossibleTypes["ONE_CLICK"] = "ONE_CLICK";
19
- PossibleTypes["CLICK2SMS"] = "CLICK2SMS";
20
- PossibleTypes["USSD"] = "USSD";
21
- PossibleTypes["TPAY_HE"] = "TPAY_HE";
22
- PossibleTypes["CREDIT_CARD"] = "CREDIT_CARD";
23
- })(PossibleTypes || (PossibleTypes = {}));
24
-
25
- var identify = function (_a) {
26
- var window = _a.window, slug = _a.slug, country = _a.country, msisdn = _a.msisdn, device = _a.device, offer = _a.offer, rockmanId = _a.rockmanId;
27
- return __awaiter(void 0, void 0, void 0, function () {
28
- var languageCode, locationHref, host, params, urlParams, url, response;
29
- return __generator(this, function (_b) {
30
- switch (_b.label) {
31
- case 0:
32
- languageCode = window.languageCode ? "&language_code=".concat(window.languageCode) : '';
33
- locationHref = encodeURIComponent(window.location.href);
34
- host = window.DEV_BASE_URL || '';
35
- params = {
36
- action: 'identify',
37
- slug: slug,
38
- country: country,
39
- msisdn: msisdn,
40
- device: device,
41
- offerId: offer,
42
- rockman_id: rockmanId,
43
- page: locationHref,
44
- language_code: languageCode
45
- };
46
- urlParams = new URLSearchParams(params).toString();
47
- url = "".concat(host, "/tallyman/v1/?").concat(urlParams);
48
- return [4 /*yield*/, fetch(url)];
49
- case 1:
50
- response = _b.sent();
51
- return [2 /*return*/, response.json()];
52
- }
53
- });
54
- });
55
- };
56
-
57
- function determineFlowByMsidn(_a) {
58
- var _b, _c, _d, _e;
59
- var window = _a.window, internationalMSISDN = _a.internationalMSISDN, configs = _a.configs;
60
- return __awaiter(this, void 0, void 0, function () {
61
- var submissionError, msisdn, defaultFlowConfig, config, operatorsConfig, indentifyFlow, theResult, flow, cannotDetect, hlrError, submissionError, flowObj, flowObj, submissionError;
62
- var _this = this;
63
- return __generator(this, function (_f) {
64
- switch (_f.label) {
65
- case 0:
66
- if (!internationalMSISDN) {
67
- submissionError = new Error("Error in submitMSISDN() identify action");
68
- submissionError.type = 'SEInvalidMSISDN';
69
- throw submissionError;
70
- }
71
- msisdn = ((_b = internationalMSISDN.match(/\d+/gi)) === null || _b === void 0 ? void 0 : _b.join('')) || '';
72
- defaultFlowConfig = (_c = configs === null || configs === void 0 ? void 0 : configs.strategyConfigs) === null || _c === void 0 ? void 0 : _c.default;
73
- config = defaultFlowConfig.flowConfig;
74
- operatorsConfig = (_d = configs === null || configs === void 0 ? void 0 : configs.strategyConfigs) === null || _d === void 0 ? void 0 : _d.operators;
75
- indentifyFlow = function () { return __awaiter(_this, void 0, void 0, function () {
76
- var slug, country, device, rockmanId, offer, flowOperatorResult;
77
- return __generator(this, function (_a) {
78
- switch (_a.label) {
79
- case 0:
80
- slug = config.slug, country = config.country, device = config.device;
81
- rockmanId = window.pac_analytics.visitor.rockmanId;
82
- offer = window.pac_analytics.visitor.offer;
83
- return [4 /*yield*/, identify({
84
- window: window,
85
- slug: slug,
86
- country: country,
87
- msisdn: msisdn,
88
- device: device,
89
- offer: offer,
90
- rockmanId: rockmanId
91
- })];
92
- case 1:
93
- flowOperatorResult = _a.sent();
94
- return [2 /*return*/, flowOperatorResult];
95
- }
96
- });
97
- }); };
98
- return [4 /*yield*/, indentifyFlow()];
99
- case 1:
100
- theResult = _f.sent();
101
- flow = operatorsConfig[theResult.operator] ? operatorsConfig[theResult.operator] : null;
102
- cannotDetect = theResult.success === false && theResult.message === 'Operator could not be found for the given MSISDN';
103
- hlrError = theResult.success === false && ((_e = theResult.message) === null || _e === void 0 ? void 0 : _e.indexOf('HLR did not find the operator for given MSISDN')) !== -1;
104
- if (cannotDetect || hlrError) {
105
- submissionError = new Error("Error in submitMSISDN() identify action");
106
- submissionError.type = 'FlowDetectFailed';
107
- submissionError.msisdn = msisdn;
108
- throw submissionError;
109
- }
110
- else if (flow !== null) {
111
- flowObj = __assign({ operator: theResult.operator, default: defaultFlowConfig }, flow);
112
- // @ts-ignore
113
- return [2 /*return*/, flowObj];
114
- }
115
- else if (flow === null) {
116
- flowObj = __assign({ operator: theResult.operator }, defaultFlowConfig);
117
- // @ts-ignore
118
- return [2 /*return*/, flowObj];
119
- }
120
- else {
121
- submissionError = new Error("Error in submitMSISDN() identify action");
122
- submissionError.type = 'SEInvalidMSISDN';
123
- throw submissionError;
124
- }
125
- }
126
- });
127
- });
128
- }
129
- function determineFlowByOperator(_a) {
130
- var _b, _c;
131
- var configs = _a.configs, operator = _a.operator;
132
- var defaultFlowConfig = (_b = configs === null || configs === void 0 ? void 0 : configs.strategyConfigs) === null || _b === void 0 ? void 0 : _b.default;
133
- var operatorsConfig = (_c = configs === null || configs === void 0 ? void 0 : configs.strategyConfigs) === null || _c === void 0 ? void 0 : _c.operators;
134
- var flowObj = __assign({ operator: operator === null || operator === void 0 ? void 0 : operator.toUpperCase(), default: defaultFlowConfig }, operatorsConfig[operator === null || operator === void 0 ? void 0 : operator.toUpperCase()]);
135
- // @ts-ignore
136
- return flowObj;
137
- }
138
- function determineFlowByOperatorFromIp(_a) {
139
- var window = _a.window, configs = _a.configs;
140
- return __awaiter(this, void 0, void 0, function () {
141
- var operator, flowObj;
142
- return __generator(this, function (_b) {
143
- switch (_b.label) {
144
- case 0: return [4 /*yield*/, tryGetIPRangeName(window.pac_analytics.visitor)];
145
- case 1:
146
- operator = _b.sent();
147
- flowObj = determineFlowByOperator({
148
- configs: configs,
149
- operator: operator ? operator.toUpperCase() : ''
150
- });
151
- return [2 /*return*/, flowObj];
152
- }
153
- });
154
- });
155
- }
156
- function getOperators(_a) {
157
- var _b;
158
- var configs = _a.configs;
159
- var operatorsConfig = (_b = configs === null || configs === void 0 ? void 0 : configs.strategyConfigs) === null || _b === void 0 ? void 0 : _b.operators;
160
- var operators = Object.keys(operatorsConfig);
161
- return operators;
162
- }
163
- // export const mockedPinFlow: StrategyState = {
164
- // currentState: {
165
- // type: PossibleTypes.PIN,
166
- // result: RDS.NothingYet(),
167
- // data: {
168
- // config: mockConfig('pin')
169
- // }
170
- // }
171
- // };
172
- // export const mockedMoFlow: StrategyState = {
173
- // currentState: {
174
- // type: PossibleTypes.MO,
175
- // result: RDS.NothingYet(),
176
- // data: {
177
- // config: mockConfig('mo')
178
- // }
179
- // }
180
- // };
181
- // export const mockedUssdFlow: StrategyState = {
182
- // currentState: {
183
- // type: PossibleTypes.USSD,
184
- // result: RDS.NothingYet(),
185
- // data: {
186
- // config: mockConfig('ussd')
187
- // }
188
- // }
189
- // };
190
- // export const mockedMoRdirFlow: StrategyState = {
191
- // currentState: {
192
- // type: PossibleTypes.MO_REDIR,
193
- // result: RDS.NothingYet(),
194
- // data: {
195
- // config: mockConfig('moRedir')
196
- // }
197
- // }
198
- // };
199
- // export const mockedClick2smsFlow: StrategyState = {
200
- // currentState: {
201
- // type: PossibleTypes.CLICK2SMS,
202
- // result: RDS.NothingYet(),
203
- // data: {
204
- // config: mockConfig('click2sms')
205
- // }
206
- // }
207
- // };
208
- // export const mockedOneClickFlow: StrategyState = {
209
- // currentState: {
210
- // type: PossibleTypes.ONE_CLICK,
211
- // result: RDS.NothingYet(),
212
- // data: {
213
- // config: mockConfig('oneClick')
214
- // }
215
- // }
216
- // };
217
- // export const mockedCreditCardFlow: StrategyState = {
218
- // currentState: {
219
- // type: PossibleTypes.CREDIT_CARD,
220
- // result: RDS.NothingYet(),
221
- // data: {
222
- // config: mockConfig('creditCard')
223
- // }
224
- // }
225
- // };
226
- // export const mockedMOFlow : State = { type: "MO", result:moFlow(mockTracker, mockConfig("mo"))}
227
- // export const mockedOneClickFlow : State = { type: "ONECLICK", result:oneClickFlow(mockTracker, mockConfig("oneClick"), {"testextraparams":"1"})}
228
- // export const mockedClick2smsFlow : State = { type: "CLICK2SMS", result:click2smsFlow(mockTracker, mockConfig("click2sms"))}
229
- // export const mockedMORedirFlow : State = { type: "MOREDIR", result:moRedirFlow(mockTracker, mockConfig("moRedir"))}
230
-
231
- var askMobileNumber = function () { return ({
232
- type: PossibleTypes.IDENTIFY_FLOW_BY_MSISDN,
233
- result: NothingYet()
234
- }); };
235
- var submitMSISDNAction = createAsyncThunk('strategy/submitMSISDNAction', function (_a, _b) {
236
- var window = _a.window, msisdn = _a.msisdn;
237
- var rejectWithValue = _b.rejectWithValue;
238
- return __awaiter(void 0, void 0, void 0, function () {
239
- var configs, strategy, flowObj, ex_1, errorType;
240
- return __generator(this, function (_c) {
241
- switch (_c.label) {
242
- case 0:
243
- _c.trys.push([0, 2, , 3]);
244
- configs = getConfig();
245
- strategy = configs.strategy;
246
- return [4 /*yield*/, determineFlowByMsidn({ window: window, internationalMSISDN: msisdn, configs: configs })];
247
- case 1:
248
- flowObj = _c.sent();
249
- switch (strategy) {
250
- case 'pin-mo-redir-ask-mobile-number':
251
- return [2 /*return*/, pinMoRedirAskMobileNumber(flowObj, msisdn)];
252
- case 'pin-mo-ask-mobile-number':
253
- return [2 /*return*/, pinMoAskMobileNumber(flowObj, msisdn)];
254
- case 'pin-combo-ask-mobile-number':
255
- return [2 /*return*/, pinComboAskMobileNumber(flowObj, msisdn)];
256
- case 'mo-redir-mo-click2sms-one-click-detect-operator-by-ip-or-msisdn':
257
- return [2 /*return*/, moRedirMoClick2smsOneClickDetectOperatorByIpOrMsisdn(flowObj, msisdn)];
258
- case 'pin-mo-mo-redir-ask-mobile-number':
259
- return [2 /*return*/, pinMoMoRedirAskMobileNumber(flowObj, msisdn)];
260
- case 'pin-click2sms-ask-mobile-number':
261
- return [2 /*return*/, pinClick2smsAskMobileNumber(flowObj, msisdn)];
262
- default:
263
- return [2 /*return*/, rejectWithValue('Unknown strategy')];
264
- }
265
- case 2:
266
- ex_1 = _c.sent();
267
- errorType = void 0;
268
- switch (ex_1.type) {
269
- case 'SEAlreadySubscribed':
270
- errorType = 'AlreadySubscribed';
271
- break;
272
- case 'SEInvalidMSISDN':
273
- errorType = 'InvalidMSISDN';
274
- break;
275
- default:
276
- errorType = 'UnknownError';
277
- }
278
- return [2 /*return*/, rejectWithValue({
279
- errorType: errorType,
280
- error: ex_1,
281
- productUrl: ex_1.productUrl
282
- })];
283
- case 3: return [2 /*return*/];
284
- }
285
- });
286
- });
287
- });
288
- var pinMoAskMobileNumber = function (flowObj, msisdn) {
289
- switch (flowObj.flow) {
290
- case 'pin':
291
- tracker.sendOptInFlowEvent('Pin');
292
- return {
293
- type: PossibleTypes.PIN,
294
- result: NothingYet(),
295
- data: __assign({ config: flowObj.flowConfig, msisdn: msisdn }, (flowObj.operator && { operator: flowObj.operator }))
296
- };
297
- case 'mo':
298
- tracker.sendOptInFlowEvent('Msisdn to sms');
299
- return {
300
- type: PossibleTypes.MO,
301
- result: NothingYet(),
302
- data: __assign({ config: flowObj.flowConfig, msisdn: msisdn }, (flowObj.operator && { operator: flowObj.operator }))
303
- };
304
- default:
305
- tracker.sendOptInFlowEvent('Pin');
306
- return {
307
- type: PossibleTypes.PIN,
308
- result: NothingYet(),
309
- data: __assign({ config: flowObj.flowConfig }, (flowObj.operator && { operator: flowObj.operator }))
310
- };
311
- }
312
- };
313
- var pinComboAskMobileNumber = function (flowObj, msisdn) {
314
- switch (flowObj.flow) {
315
- case 'pin':
316
- tracker.sendOptInFlowEvent('Pin');
317
- return {
318
- type: PossibleTypes.PIN,
319
- result: NothingYet(),
320
- data: __assign({ config: flowObj.flowConfig, msisdn: msisdn }, (flowObj.operator && { operator: flowObj.operator }))
321
- };
322
- default:
323
- tracker.sendOptInFlowEvent('Pin');
324
- return {
325
- type: PossibleTypes.PIN,
326
- result: NothingYet(),
327
- data: __assign({ config: flowObj.flowConfig }, (flowObj.operator && { operator: flowObj.operator }))
328
- };
329
- }
330
- };
331
- var pinMoRedirAskMobileNumber = function (flowObj, msisdn) {
332
- switch (flowObj.flow) {
333
- case 'pin':
334
- tracker.sendOptInFlowEvent('Pin');
335
- return {
336
- type: PossibleTypes.PIN,
337
- result: NothingYet(),
338
- data: {
339
- config: flowObj.flowConfig,
340
- msisdn: msisdn
341
- }
342
- };
343
- case 'moRedir':
344
- tracker.sendOptInFlowEvent('Redirect');
345
- return {
346
- type: PossibleTypes.MO_REDIR,
347
- result: NothingYet(),
348
- data: {
349
- config: flowObj.flowConfig
350
- }
351
- };
352
- default:
353
- tracker.sendOptInFlowEvent('Pin');
354
- return {
355
- type: PossibleTypes.PIN,
356
- result: NothingYet(),
357
- data: {
358
- config: flowObj.flowConfig
359
- }
360
- };
361
- }
362
- };
363
- var pinMoMoRedirAskMobileNumber = function (flowObj, msisdn) {
364
- switch (flowObj.flow) {
365
- case 'pin':
366
- tracker.sendOptInFlowEvent('Pin');
367
- return {
368
- type: PossibleTypes.PIN,
369
- result: NothingYet(),
370
- data: {
371
- config: flowObj.flowConfig,
372
- msisdn: msisdn
373
- }
374
- };
375
- case 'moRedir':
376
- tracker.sendOptInFlowEvent('Redirect');
377
- return {
378
- type: PossibleTypes.MO_REDIR,
379
- result: NothingYet(),
380
- data: {
381
- config: flowObj.flowConfig,
382
- msisdn: msisdn
383
- }
384
- };
385
- case 'mo':
386
- tracker.sendOptInFlowEvent('Msisdn to sms');
387
- return {
388
- type: PossibleTypes.MO,
389
- result: NothingYet(),
390
- data: {
391
- config: flowObj.flowConfig,
392
- msisdn: msisdn
393
- }
394
- };
395
- default:
396
- tracker.sendOptInFlowEvent('Pin');
397
- return {
398
- type: PossibleTypes.PIN,
399
- result: NothingYet(),
400
- data: {
401
- config: flowObj.flowConfig
402
- }
403
- };
404
- }
405
- };
406
- var moRedirMoClick2smsOneClickDetectOperatorByIpOrMsisdn = function (flowObj, msisdn) {
407
- switch (flowObj.flowOnWifi) {
408
- case 'moRedir':
409
- tracker.sendOptInFlowEvent('Redirect');
410
- return {
411
- type: PossibleTypes.MO_REDIR,
412
- result: NothingYet(),
413
- data: {
414
- config: flowObj.flowConfig,
415
- msisdn: msisdn
416
- }
417
- };
418
- case 'mo':
419
- tracker.sendOptInFlowEvent('Msisdn to sms');
420
- return {
421
- type: PossibleTypes.MO,
422
- result: NothingYet(),
423
- data: {
424
- config: flowObj.flowConfig,
425
- msisdn: msisdn
426
- }
427
- };
428
- default:
429
- tracker.sendOptInFlowEvent('Redirect');
430
- return {
431
- type: PossibleTypes.MO_REDIR,
432
- result: NothingYet(),
433
- data: {
434
- config: flowObj.flowConfig,
435
- rockman_id: flowObj.rockman_id
436
- }
437
- };
438
- }
439
- };
440
- var pinClick2smsAskMobileNumber = function (flowObj, msisdn) {
441
- switch (flowObj.flow) {
442
- case 'pin':
443
- tracker.sendOptInFlowEvent('Pin');
444
- return {
445
- type: PossibleTypes.PIN,
446
- result: NothingYet(),
447
- data: {
448
- config: flowObj.flowConfig,
449
- msisdn: msisdn
450
- }
451
- };
452
- case 'click2sms':
453
- tracker.sendOptInFlowEvent('Click to sms');
454
- return {
455
- type: PossibleTypes.CLICK2SMS,
456
- result: NothingYet(),
457
- data: {
458
- config: flowObj.flowConfig,
459
- msisdn: msisdn
460
- }
461
- };
462
- default:
463
- tracker.sendOptInFlowEvent('Pin');
464
- return {
465
- type: PossibleTypes.CLICK2SMS,
466
- result: NothingYet(),
467
- data: {
468
- config: flowObj.flowConfig
469
- }
470
- };
471
- }
472
- };
473
-
474
- var askOperator = function () {
475
- var configs = getConfig();
476
- var operators = getOperators({ configs: configs });
477
- return {
478
- type: PossibleTypes.IDENTIFY_FLOW_BY_OPERATOR_SELECT,
479
- result: NothingYet(),
480
- data: {
481
- operators: operators
482
- }
483
- };
484
- };
485
- var selectOperatorAction = createAsyncThunk('strategy/selectOperatorAction', function (_a, _b) {
486
- var operator = _a.operator;
487
- var rejectWithValue = _b.rejectWithValue;
488
- return __awaiter(void 0, void 0, void 0, function () {
489
- var configs, flowObj, errorType;
490
- return __generator(this, function (_c) {
491
- try {
492
- configs = getConfig();
493
- flowObj = determineFlowByOperator({
494
- configs: configs,
495
- operator: operator
496
- });
497
- switch (flowObj.flow) {
498
- case 'pin':
499
- tracker.sendOptInFlowEvent('Pin');
500
- return [2 /*return*/, {
501
- type: PossibleTypes.PIN,
502
- result: {
503
- config: flowObj.flowConfig,
504
- operator: operator
505
- }
506
- }];
507
- case 'mo':
508
- tracker.sendOptInFlowEvent('Msisdn to sms');
509
- return [2 /*return*/, {
510
- type: PossibleTypes.MO,
511
- result: {
512
- config: flowObj.flowConfig,
513
- operator: operator
514
- }
515
- }];
516
- case 'click2sms':
517
- tracker.sendOptInFlowEvent('Click to sms');
518
- return [2 /*return*/, {
519
- type: PossibleTypes.CLICK2SMS,
520
- result: {
521
- config: __assign({ operators: [operator] }, flowObj.flowConfig),
522
- operator: operator
523
- }
524
- }];
525
- case 'oneClick':
526
- tracker.sendOptInFlowEvent('3G click');
527
- return [2 /*return*/, {
528
- type: PossibleTypes.ONE_CLICK,
529
- result: {
530
- config: flowObj.flowConfig,
531
- operator: operator,
532
- autoRedirect: true
533
- }
534
- }];
535
- default:
536
- tracker.sendOptInFlowEvent('Pin');
537
- return [2 /*return*/, {
538
- type: PossibleTypes.PIN,
539
- result: NothingYet()
540
- }];
541
- }
542
- }
543
- catch (ex) {
544
- errorType = 'UnkownError';
545
- return [2 /*return*/, rejectWithValue({
546
- errorType: errorType,
547
- error: ex.toString()
548
- })];
549
- }
550
- return [2 /*return*/];
551
- });
552
- });
553
- });
554
-
555
- // @ts-ignore
556
- var trackerEventMapping = {
557
- mo: 'Msisdn to sms',
558
- pin: 'Pin',
559
- oneClick: '3G click',
560
- moRedir: 'Redirect',
561
- click2sms: 'Click to sms',
562
- ussd: 'Msisdn to sms'
563
- };
564
- var flowMapping = {
565
- mo: PossibleTypes.MO,
566
- pin: PossibleTypes.PIN,
567
- oneClick: PossibleTypes.ONE_CLICK,
568
- moRedir: PossibleTypes.MO_REDIR,
569
- click2sms: PossibleTypes.CLICK2SMS,
570
- ussd: PossibleTypes.USSD,
571
- creditCard: PossibleTypes.CREDIT_CARD
572
- };
573
- var detectOperatorByIp = function () { return __awaiter(void 0, void 0, void 0, function () {
574
- var configs, flowObj, getTrackerEventName, flowType, event_1, ex_1;
575
- return __generator(this, function (_a) {
576
- switch (_a.label) {
577
- case 0:
578
- _a.trys.push([0, 2, , 3]);
579
- configs = getConfig();
580
- return [4 /*yield*/, determineFlowByOperatorFromIp({
581
- window: window,
582
- configs: configs
583
- })];
584
- case 1:
585
- flowObj = _a.sent();
586
- getTrackerEventName = function (flowType) { return trackerEventMapping[flowType]; };
587
- flowType = flowObj.flow;
588
- event_1 = getTrackerEventName(flowType);
589
- tracker.sendOptInFlowEvent(event_1);
590
- return [2 /*return*/, {
591
- type: flowMapping[flowType],
592
- result: NothingYet(),
593
- data: {
594
- config: flowObj.flowConfig,
595
- operator: flowObj.operator
596
- }
597
- }];
598
- case 2:
599
- ex_1 = _a.sent();
600
- console.error('SSSSS', ex_1);
601
- return [3 /*break*/, 3];
602
- case 3: return [2 /*return*/];
603
- }
604
- });
605
- }); };
606
-
607
- var initialState = {
608
- currentState: {
609
- type: PossibleTypes.IDENTIFY_STRATEGY,
610
- result: NothingYet(),
611
- data: undefined
612
- }
613
- };
614
- var mockStrategyStateByUrlParam = function () {
615
- var search = searchToObject(window);
616
- if (search['mock-flow'] !== undefined) {
617
- if (search.operator !== undefined) {
618
- window.operator = search.operator;
619
- }
620
- switch (search['mock-flow']) {
621
- case 'pin':
622
- return {
623
- type: PossibleTypes.PIN,
624
- result: Success({})
625
- };
626
- case 'mo':
627
- return {
628
- type: PossibleTypes.MO,
629
- result: Success({})
630
- };
631
- case 'moredir':
632
- return {
633
- type: PossibleTypes.MO_REDIR,
634
- result: Success({})
635
- };
636
- case 'oneclick':
637
- return {
638
- type: PossibleTypes.ONE_CLICK,
639
- result: Success({})
640
- };
641
- case 'click2sms':
642
- return {
643
- type: PossibleTypes.CLICK2SMS,
644
- result: Success({})
645
- };
646
- case 'ussd':
647
- return {
648
- type: PossibleTypes.USSD,
649
- result: Success({})
650
- };
651
- case 'creditcard':
652
- return {
653
- type: PossibleTypes.CREDIT_CARD,
654
- result: Success({})
655
- };
656
- default:
657
- throw new Error('(mockStrategyStateByUrlParam) Strategy Mock Flow not supported');
658
- }
659
- }
660
- };
661
- /**
662
- * Identify Strategy
663
- * @returns {type: 'strategy/identifyStrategy', payload: {type: PossibleTypes.MO, result: IdentifyFlowOptionsResult}}
664
- * - Add type
665
- * - Makes a decision on which strategy to use in order to identify the flow
666
- * - Strategy could be asking user's phone number, selecting an operator etc
667
- * - all with the intension of getting the flow and its configuration
668
- * - Flows are usually tied to an operator in the pages config.json
669
- * - But they could also be single flows
670
- *
671
- */
672
- var identifyStrategy = createAsyncThunk('strategy/identifyStrategy', function () { return __awaiter(void 0, void 0, void 0, function () {
673
- var configs, strategy, strategyConfigs, search, flowObj, strategyResult;
674
- var _a, _b, _c, _d, _e, _f, _g, _h;
675
- return __generator(this, function (_j) {
676
- configs = getConfig();
677
- strategy = configs.strategy, strategyConfigs = configs.strategyConfigs;
678
- search = searchToObject(window);
679
- if (search['mock-flow'] !== undefined) {
680
- return [2 /*return*/, mockStrategyStateByUrlParam()];
681
- }
682
- if ((search['show-pin-entry'] && search['show-pin-entry'] === '1') ||
683
- (search['show-thank-you'] && search['show-thank-you'] === '1')) {
684
- flowObj = determineFlowByOperator({
685
- configs: configs,
686
- operator: search.operator
687
- });
688
- strategyResult = {
689
- type: PossibleTypes.PIN,
690
- result: Success({}),
691
- data: {
692
- config: (flowObj === null || flowObj === void 0 ? void 0 : flowObj.flowConfig) || ((_a = strategyConfigs === null || strategyConfigs === void 0 ? void 0 : strategyConfigs.default) === null || _a === void 0 ? void 0 : _a.flowConfig)
693
- }
694
- };
695
- return [2 /*return*/, strategyResult];
696
- }
697
- if (strategy.includes('ask-operator')) {
698
- return [2 /*return*/, askOperator()];
699
- }
700
- if (strategy.includes('detect-operator-by-ip')) {
701
- return [2 /*return*/, detectOperatorByIp()];
702
- }
703
- if (strategy === null || strategy === void 0 ? void 0 : strategy.includes('ask-mobile-number')) {
704
- return [2 /*return*/, askMobileNumber()];
705
- }
706
- switch (strategy) {
707
- case 'pin': {
708
- return [2 /*return*/, {
709
- type: PossibleTypes.PIN,
710
- result: Success({}),
711
- data: {
712
- config: (_b = strategyConfigs === null || strategyConfigs === void 0 ? void 0 : strategyConfigs.default) === null || _b === void 0 ? void 0 : _b.flowConfig
713
- }
714
- }];
715
- }
716
- case 'mo':
717
- return [2 /*return*/, {
718
- type: PossibleTypes.MO,
719
- result: Success({}),
720
- data: {
721
- config: (_c = strategyConfigs === null || strategyConfigs === void 0 ? void 0 : strategyConfigs.default) === null || _c === void 0 ? void 0 : _c.flowConfig
722
- }
723
- }];
724
- case 'mo-redir':
725
- return [2 /*return*/, {
726
- type: PossibleTypes.MO_REDIR,
727
- result: Success({}),
728
- data: {
729
- config: (_d = strategyConfigs === null || strategyConfigs === void 0 ? void 0 : strategyConfigs.default) === null || _d === void 0 ? void 0 : _d.flowConfig
730
- }
731
- }];
732
- case 'one-click':
733
- return [2 /*return*/, {
734
- type: PossibleTypes.ONE_CLICK,
735
- result: Success({}),
736
- data: {
737
- config: (_e = strategyConfigs === null || strategyConfigs === void 0 ? void 0 : strategyConfigs.default) === null || _e === void 0 ? void 0 : _e.flowConfig
738
- }
739
- }];
740
- case 'click2sms':
741
- return [2 /*return*/, {
742
- type: PossibleTypes.CLICK2SMS,
743
- result: Success({}),
744
- data: {
745
- config: (_f = strategyConfigs === null || strategyConfigs === void 0 ? void 0 : strategyConfigs.default) === null || _f === void 0 ? void 0 : _f.flowConfig
746
- }
747
- }];
748
- case 'ussd':
749
- return [2 /*return*/, {
750
- type: PossibleTypes.USSD,
751
- result: Success({}),
752
- data: {
753
- config: (_g = strategyConfigs === null || strategyConfigs === void 0 ? void 0 : strategyConfigs.default) === null || _g === void 0 ? void 0 : _g.flowConfig
754
- }
755
- }];
756
- case 'credit-card':
757
- return [2 /*return*/, {
758
- type: PossibleTypes.CREDIT_CARD,
759
- result: Success({}),
760
- data: {
761
- config: (_h = strategyConfigs === null || strategyConfigs === void 0 ? void 0 : strategyConfigs.default) === null || _h === void 0 ? void 0 : _h.flowConfig
762
- }
763
- }];
764
- default:
765
- throw new Error('Strategy not supported');
766
- }
767
- });
768
- }); });
769
- var setStrategyExtraData = createAsyncThunk('strategy/setStrategyExtraData', function (_a) {
770
- var type = _a.type, data = _a.data;
771
- return __awaiter(void 0, void 0, void 0, function () {
772
- return __generator(this, function (_b) {
773
- return [2 /*return*/, ({
774
- type: type,
775
- result: NothingYet(),
776
- data: data
777
- })];
778
- });
779
- });
780
- });
781
- var strategySlice = createSlice({
782
- name: 'strategy',
783
- initialState: initialState,
784
- reducers: {
785
- // Define synchronous reducers as needed
786
- },
787
- extraReducers: function (builder) {
788
- builder
789
- .addCase(identifyStrategy.pending, function (state) {
790
- state.currentState = {
791
- type: PossibleTypes.IDENTIFY_STRATEGY,
792
- result: Loading()
793
- };
794
- })
795
- .addCase(identifyStrategy.fulfilled, function (state, action) {
796
- state.currentState = action.payload;
797
- })
798
- .addCase(identifyStrategy.rejected, function (state, action) {
799
- state.currentState = {
800
- type: PossibleTypes.IDENTIFY_STRATEGY,
801
- result: Failure(action.error.message)
802
- };
803
- })
804
- .addCase(submitMSISDNAction.pending, function (state) {
805
- state.currentState = {
806
- type: PossibleTypes.IDENTIFY_FLOW_BY_MSISDN,
807
- result: Loading()
808
- };
809
- })
810
- .addCase(submitMSISDNAction.fulfilled, function (state, action) {
811
- state.currentState = action.payload;
812
- })
813
- .addCase(submitMSISDNAction.rejected, function (state, action) {
814
- state.currentState = {
815
- type: PossibleTypes.IDENTIFY_FLOW_BY_MSISDN,
816
- result: Failure(action.payload)
817
- };
818
- })
819
- .addCase(setStrategyExtraData.fulfilled, function (state, action) {
820
- state.currentState = action.payload;
821
- })
822
- .addCase(selectOperatorAction.pending, function (state) {
823
- state.currentState = {
824
- type: PossibleTypes.IDENTIFY_FLOW_BY_OPERATOR_SELECT,
825
- result: Loading()
826
- };
827
- })
828
- .addCase(selectOperatorAction.fulfilled, function (state, action) {
829
- state.currentState = action.payload;
830
- })
831
- .addCase(selectOperatorAction.rejected, function (state, action) {
832
- state.currentState = {
833
- type: PossibleTypes.IDENTIFY_FLOW_BY_OPERATOR_SELECT,
834
- result: Failure(action.payload)
835
- };
836
- });
837
- }
838
- });
839
- var strategyReducer = strategySlice.reducer;
840
-
841
- export { PossibleTypes as P, selectOperatorAction as a, strategyReducer as b, setStrategyExtraData as c, identifyStrategy as i, submitMSISDNAction as s };
842
- //# sourceMappingURL=strategySlice-bF74rxDK.js.map