ouisys-engine 2.1.21 → 2.1.26
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.
- package/dist/api/click2sms.js +357 -0
- package/dist/api/index.d.ts +0 -2
- package/dist/api/index.js +88 -164
- package/dist/api/mo.js +274 -0
- package/dist/api/moRedir.js +186 -0
- package/dist/api/oneClick.js +366 -0
- package/dist/api/pin.js +493 -0
- package/dist/api/strategies.js +704 -0
- package/dist/api/ussd.js +1 -0
- package/dist/app/store.js +35 -0
- package/dist/common-types/AppThunk.d.ts +1 -2
- package/dist/features/strategies/categories/askMobileNumber.js +395 -0
- package/dist/features/strategies/categories/askOperator.js +311 -0
- package/dist/features/strategies/categories/detectOperatorByIp.js +606 -0
- package/dist/features/strategies/categories/headerEnrichment.js +670 -0
- package/dist/features/strategies/categories/typings/click2smsSliceTypes.js +12 -0
- package/dist/features/strategies/categories/typings/identifySliceTypes.js +22 -0
- package/dist/features/strategies/categories/typings/moFlowSliceTypes.js +22 -0
- package/dist/features/strategies/categories/typings/moRedirFlowSliceTypes.js +21 -0
- package/dist/features/strategies/categories/typings/oneClickSliceTypes.js +13 -0
- package/dist/features/strategies/categories/typings/pinFlowSliceTypes.js +13 -0
- package/dist/features/strategies/click2smsFlowSlice.js +172 -0
- package/dist/features/strategies/identifySlice.js +455 -0
- package/dist/features/strategies/moFlowSlice.js +196 -0
- package/dist/features/strategies/moRedirFlowSlice.js +190 -0
- package/dist/features/strategies/oneClickFlowSlice.js +277 -0
- package/dist/features/strategies/pinFlowSlice.js +313 -0
- package/dist/features/strategies/ussdFlowSlice.js +1 -0
- package/dist/flows/strategy.d.ts +1 -2
- package/dist/flows/strategy.js +1 -5
- package/dist/ips/tryGetIPRangeName.js +14 -13
- package/dist/mockServer/browser.js +48 -0
- package/dist/mockServer/handlers.js +22 -0
- package/dist/mockServer/server.js +48 -0
- package/dist/pacman/index.js +0 -1
- package/dist/reducers/click2smsFlow/utils.js +1 -3
- package/dist/reducers/moRedirFlow/utils.js +1 -1
- package/dist/reducers/oneClickFlow/utils.js +47 -19
- package/dist/reducers/pinFlow/utils.js +7 -12
- package/dist/reducers/strategy/utils.js +12 -13
- package/dist/reducers/tpayHeFlow/utils.js +1 -1
- package/dist/store/index.d.ts +1 -2
- package/dist/store/reducers.d.ts +0 -2
- package/dist/store/reducers.js +1 -4
- package/dist/test/setup.js +24 -0
- package/dist/test/test-utils.js +51 -0
- package/dist/utilities/loadScriptInnerHtml.d.ts +2 -0
- package/dist/utilities/loadScriptInnerHtml.js +18 -0
- package/package.json +1 -1
- package/src/api/index.ts +4 -37
- package/src/common-types/AppThunk.ts +1 -2
- package/src/flows/strategy.ts +1 -5
- package/src/ips/tryGetIPRangeName.ts +3 -2
- package/src/pacman/index.ts +1 -1
- package/src/reducers/click2smsFlow/utils.ts +0 -3
- package/src/reducers/moRedirFlow/utils.ts +1 -1
- package/src/reducers/oneClickFlow/utils.ts +77 -11
- package/src/reducers/pinFlow/utils.ts +2 -9
- package/src/reducers/strategy/utils.ts +2 -3
- package/src/store/index.ts +1 -2
- package/src/store/reducers.ts +1 -5
- package/src/utilities/loadScriptInnerHtml.ts +10 -0
- package/yarn.lock +5204 -0
- package/src/flows/tpayHeFlow.ts +0 -20
- package/src/reducers/tpayHeFlow/ITpayHeConstants.ts +0 -7
- package/src/reducers/tpayHeFlow/TpayHeTypes.ts +0 -135
- package/src/reducers/tpayHeFlow/index.ts +0 -207
- package/src/reducers/tpayHeFlow/utils.ts +0 -311
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _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.filter");
|
|
12
|
+
|
|
13
|
+
require("core-js/modules/es.array.includes");
|
|
14
|
+
|
|
15
|
+
require("core-js/modules/es.array.iterator");
|
|
16
|
+
|
|
17
|
+
require("core-js/modules/es.object.get-own-property-descriptor");
|
|
18
|
+
|
|
19
|
+
require("core-js/modules/es.object.get-own-property-descriptors");
|
|
20
|
+
|
|
21
|
+
require("core-js/modules/es.object.keys");
|
|
22
|
+
|
|
23
|
+
require("core-js/modules/es.object.to-string");
|
|
24
|
+
|
|
25
|
+
require("core-js/modules/es.promise");
|
|
26
|
+
|
|
27
|
+
require("core-js/modules/es.string.includes");
|
|
28
|
+
|
|
29
|
+
require("core-js/modules/es.string.iterator");
|
|
30
|
+
|
|
31
|
+
require("core-js/modules/es.weak-map");
|
|
32
|
+
|
|
33
|
+
require("core-js/modules/web.dom-collections.for-each");
|
|
34
|
+
|
|
35
|
+
require("core-js/modules/web.dom-collections.iterator");
|
|
36
|
+
|
|
37
|
+
Object.defineProperty(exports, "__esModule", {
|
|
38
|
+
value: true
|
|
39
|
+
});
|
|
40
|
+
exports.tracker = exports.pin = exports.identify = exports.default = void 0;
|
|
41
|
+
|
|
42
|
+
require("regenerator-runtime/runtime");
|
|
43
|
+
|
|
44
|
+
var _toolkit = require("@reduxjs/toolkit");
|
|
45
|
+
|
|
46
|
+
var _strategies = _interopRequireWildcard(require("../../api/strategies"));
|
|
47
|
+
|
|
48
|
+
var RDS = _interopRequireWildcard(require("../../common-types/RemoteDataState"));
|
|
49
|
+
|
|
50
|
+
var _pacman = _interopRequireDefault(require("../../pacman"));
|
|
51
|
+
|
|
52
|
+
var _askMobileNumber = require("./categories/askMobileNumber");
|
|
53
|
+
|
|
54
|
+
var _askOperator = require("./categories/askOperator");
|
|
55
|
+
|
|
56
|
+
var _detectOperatorByIp = require("./categories/detectOperatorByIp");
|
|
57
|
+
|
|
58
|
+
var _headerEnrichment = require("./categories/headerEnrichment");
|
|
59
|
+
|
|
60
|
+
var _identifySliceTypes = require("./categories/typings/identifySliceTypes");
|
|
61
|
+
|
|
62
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
63
|
+
|
|
64
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
65
|
+
|
|
66
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
|
|
67
|
+
|
|
68
|
+
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); } }
|
|
69
|
+
|
|
70
|
+
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); }); }; }
|
|
71
|
+
|
|
72
|
+
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; }
|
|
73
|
+
|
|
74
|
+
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; }
|
|
75
|
+
|
|
76
|
+
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; }
|
|
77
|
+
|
|
78
|
+
var tracker = (0, _pacman.default)(typeof window !== 'undefined' ? window : null);
|
|
79
|
+
exports.tracker = tracker;
|
|
80
|
+
|
|
81
|
+
var strategyBasedInitialState = function strategyBasedInitialState() {
|
|
82
|
+
var configs = _strategies.default.getConfig();
|
|
83
|
+
|
|
84
|
+
var strategy = configs.strategy,
|
|
85
|
+
strategyConfigs = configs.strategyConfigs;
|
|
86
|
+
|
|
87
|
+
if (strategy.includes('ask-operator')) {
|
|
88
|
+
var operators = (0, _strategies.getOperators)({
|
|
89
|
+
configs: configs
|
|
90
|
+
});
|
|
91
|
+
return {
|
|
92
|
+
type: _identifySliceTypes.StrategyStates.IDENTIFY_FLOW_BY_OPERATOR_SELECT,
|
|
93
|
+
result: {
|
|
94
|
+
operators: operators
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (strategy.indexOf('ask-mobile-number') !== -1 || strategy.indexOf('header-enrichment') !== -1) {
|
|
100
|
+
return {
|
|
101
|
+
type: _identifySliceTypes.StrategyStates.IDENTIFY_FLOW_BY_MSISDN,
|
|
102
|
+
result: RDS.NothingYet()
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (strategy.indexOf('detect-operator-by-ip') !== -1) {
|
|
107
|
+
return {
|
|
108
|
+
type: _identifySliceTypes.StrategyStates.IDENTIFY_STRATEGY,
|
|
109
|
+
result: RDS.Loading()
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
switch (strategy) {
|
|
114
|
+
// case 'pin':
|
|
115
|
+
// return {
|
|
116
|
+
// type: 'PIN',
|
|
117
|
+
// result: {
|
|
118
|
+
// nextAction: 'identifySubmitMSISDNAction',
|
|
119
|
+
// config: strategyConfigs.default.flowConfig
|
|
120
|
+
// }
|
|
121
|
+
// };
|
|
122
|
+
// case 'mo':
|
|
123
|
+
// return {
|
|
124
|
+
// type: 'MO',
|
|
125
|
+
// result: {
|
|
126
|
+
// nextAction: 'identifySubmitMSISDNAction',
|
|
127
|
+
// config: strategyConfigs.default.flowConfig
|
|
128
|
+
// }
|
|
129
|
+
// };
|
|
130
|
+
// case 'mo-redir':
|
|
131
|
+
// return {
|
|
132
|
+
// type: 'MO_REDIR',
|
|
133
|
+
// result: {
|
|
134
|
+
// nextAction: 'identifySubmitMSISDNAction',
|
|
135
|
+
// config: strategyConfigs.default.flowConfig
|
|
136
|
+
// }
|
|
137
|
+
// };
|
|
138
|
+
case 'one-click':
|
|
139
|
+
return {
|
|
140
|
+
type: _identifySliceTypes.StrategyStates.ONE_CLICK,
|
|
141
|
+
result: {
|
|
142
|
+
config: strategyConfigs.default.flowConfig
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
// case 'click2sms':
|
|
146
|
+
// return {
|
|
147
|
+
// type: 'CLICK2SMS',
|
|
148
|
+
// result: {
|
|
149
|
+
// nextAction: 'loadOc2sms',
|
|
150
|
+
// config: strategyConfigs.default.flowConfig
|
|
151
|
+
// }
|
|
152
|
+
// };
|
|
153
|
+
// case 'ussd':
|
|
154
|
+
// return {
|
|
155
|
+
// type: 'USSD',
|
|
156
|
+
// result: {
|
|
157
|
+
// nextAction: 'identifySubmitMSISDNAction',
|
|
158
|
+
// config: strategyConfigs.default.flowConfig
|
|
159
|
+
// }
|
|
160
|
+
// };
|
|
161
|
+
|
|
162
|
+
default:
|
|
163
|
+
return {
|
|
164
|
+
type: 'IDENTIFY_STRATEGY',
|
|
165
|
+
result: RDS.Loading()
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
var initialState = {
|
|
171
|
+
currentState: strategyBasedInitialState()
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
var oneClick = function oneClick(_ref) {
|
|
175
|
+
var flowObj = _ref.flowObj;
|
|
176
|
+
tracker.sendOptInFlowEvent('3G click');
|
|
177
|
+
return {
|
|
178
|
+
type: _identifySliceTypes.StrategyStates.ONE_CLICK,
|
|
179
|
+
result: {},
|
|
180
|
+
nextData: {
|
|
181
|
+
config: flowObj.flowConfig,
|
|
182
|
+
operator: flowObj.operator
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
var pin = function pin(_ref2) {
|
|
188
|
+
var flowObj = _ref2.flowObj;
|
|
189
|
+
tracker.sendOptInFlowEvent('Pin');
|
|
190
|
+
return {
|
|
191
|
+
type: _identifySliceTypes.StrategyStates.PIN,
|
|
192
|
+
result: {},
|
|
193
|
+
nextData: {
|
|
194
|
+
config: flowObj.flowConfig,
|
|
195
|
+
operator: flowObj.operator
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
exports.pin = pin;
|
|
201
|
+
|
|
202
|
+
var moRedir = function moRedir(_ref3) {
|
|
203
|
+
var flowObj = _ref3.flowObj;
|
|
204
|
+
tracker.sendOptInFlowEvent('Redirect');
|
|
205
|
+
return {
|
|
206
|
+
type: _identifySliceTypes.StrategyStates.MO_REDIR,
|
|
207
|
+
result: {},
|
|
208
|
+
nextData: {
|
|
209
|
+
config: flowObj.flowConfig,
|
|
210
|
+
operator: flowObj.operator
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
var click2sms = function click2sms(_ref4) {
|
|
216
|
+
var flowObj = _ref4.flowObj;
|
|
217
|
+
tracker.sendOptInFlowEvent('Click to sms');
|
|
218
|
+
return {
|
|
219
|
+
type: _identifySliceTypes.StrategyStates.CLICK2SMS,
|
|
220
|
+
result: {},
|
|
221
|
+
nextData: {
|
|
222
|
+
config: _objectSpread({
|
|
223
|
+
operators: [flowObj.operator]
|
|
224
|
+
}, flowObj.flowConfig),
|
|
225
|
+
operator: flowObj.operator
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
var mo = function mo(_ref5) {
|
|
231
|
+
var flowObj = _ref5.flowObj;
|
|
232
|
+
tracker.sendOptInFlowEvent('Msisdn to sms');
|
|
233
|
+
return {
|
|
234
|
+
type: _identifySliceTypes.StrategyStates.MO,
|
|
235
|
+
result: {},
|
|
236
|
+
nextData: {
|
|
237
|
+
config: flowObj.flowConfig,
|
|
238
|
+
operator: flowObj.operator
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
var identify = (0, _toolkit.createAsyncThunk)('strategy/identify',
|
|
244
|
+
/*#__PURE__*/
|
|
245
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
246
|
+
// @ts-ignore
|
|
247
|
+
function () {
|
|
248
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(configsPayload, thunkApi) {
|
|
249
|
+
var configs, strategy, strategyConfigs, defaultFlow;
|
|
250
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
251
|
+
while (1) {
|
|
252
|
+
switch (_context.prev = _context.next) {
|
|
253
|
+
case 0:
|
|
254
|
+
configs = configsPayload || (0, _strategies.getConfig)();
|
|
255
|
+
strategy = configs.strategy, strategyConfigs = configs.strategyConfigs;
|
|
256
|
+
defaultFlow = strategyConfigs.default;
|
|
257
|
+
_context.prev = 3;
|
|
258
|
+
|
|
259
|
+
if (!(strategy.indexOf('detect-operator-by-ip') !== -1)) {
|
|
260
|
+
_context.next = 6;
|
|
261
|
+
break;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
return _context.abrupt("return", (0, _detectOperatorByIp.detectOperatorByIp)({
|
|
265
|
+
configs: configs
|
|
266
|
+
}));
|
|
267
|
+
|
|
268
|
+
case 6:
|
|
269
|
+
if (!(strategy.indexOf('ask-mobile-number') !== -1)) {
|
|
270
|
+
_context.next = 8;
|
|
271
|
+
break;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
return _context.abrupt("return", (0, _askMobileNumber.askMobileNumber)({
|
|
275
|
+
configs: configs
|
|
276
|
+
}));
|
|
277
|
+
|
|
278
|
+
case 8:
|
|
279
|
+
if (!(strategy.indexOf('ask-operator') !== -1)) {
|
|
280
|
+
_context.next = 10;
|
|
281
|
+
break;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
return _context.abrupt("return", (0, _askOperator.askOperator)({
|
|
285
|
+
configs: configs
|
|
286
|
+
}));
|
|
287
|
+
|
|
288
|
+
case 10:
|
|
289
|
+
if (!(strategy.indexOf('header-enrichment') !== -1)) {
|
|
290
|
+
_context.next = 12;
|
|
291
|
+
break;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
return _context.abrupt("return", (0, _headerEnrichment.identifyUserByHe)({
|
|
295
|
+
configs: configs
|
|
296
|
+
}));
|
|
297
|
+
|
|
298
|
+
case 12:
|
|
299
|
+
_context.t0 = strategy;
|
|
300
|
+
_context.next = _context.t0 === 'pin' ? 15 : _context.t0 === 'mo' ? 16 : _context.t0 === 'mo-redir' ? 17 : _context.t0 === 'click2sms' ? 18 : _context.t0 === 'one-click' ? 19 : 20;
|
|
301
|
+
break;
|
|
302
|
+
|
|
303
|
+
case 15:
|
|
304
|
+
return _context.abrupt("return", pin({
|
|
305
|
+
flowObj: defaultFlow
|
|
306
|
+
}));
|
|
307
|
+
|
|
308
|
+
case 16:
|
|
309
|
+
return _context.abrupt("return", mo({
|
|
310
|
+
flowObj: defaultFlow
|
|
311
|
+
}));
|
|
312
|
+
|
|
313
|
+
case 17:
|
|
314
|
+
return _context.abrupt("return", moRedir({
|
|
315
|
+
flowObj: defaultFlow
|
|
316
|
+
}));
|
|
317
|
+
|
|
318
|
+
case 18:
|
|
319
|
+
return _context.abrupt("return", click2sms({
|
|
320
|
+
flowObj: defaultFlow
|
|
321
|
+
}));
|
|
322
|
+
|
|
323
|
+
case 19:
|
|
324
|
+
return _context.abrupt("return", oneClick({
|
|
325
|
+
flowObj: defaultFlow
|
|
326
|
+
}));
|
|
327
|
+
|
|
328
|
+
case 20:
|
|
329
|
+
return _context.abrupt("return", pin({
|
|
330
|
+
flowObj: defaultFlow
|
|
331
|
+
}));
|
|
332
|
+
|
|
333
|
+
case 21:
|
|
334
|
+
return _context.abrupt("return", thunkApi.rejectWithValue('identify: Strategy not supported'));
|
|
335
|
+
|
|
336
|
+
case 24:
|
|
337
|
+
_context.prev = 24;
|
|
338
|
+
_context.t1 = _context["catch"](3);
|
|
339
|
+
console.error(_context.t1);
|
|
340
|
+
return _context.abrupt("return", thunkApi.rejectWithValue('identify: Strategy not supported'));
|
|
341
|
+
|
|
342
|
+
case 28:
|
|
343
|
+
case "end":
|
|
344
|
+
return _context.stop();
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}, _callee, null, [[3, 24]]);
|
|
348
|
+
}));
|
|
349
|
+
|
|
350
|
+
return function (_x, _x2) {
|
|
351
|
+
return _ref6.apply(this, arguments);
|
|
352
|
+
};
|
|
353
|
+
}());
|
|
354
|
+
exports.identify = identify;
|
|
355
|
+
|
|
356
|
+
var handleIdentify = function handleIdentify(builder) {
|
|
357
|
+
builder.addCase(identify.pending, function (state) {
|
|
358
|
+
state.currentState = {
|
|
359
|
+
type: _identifySliceTypes.StrategyStates.IDENTIFY_STRATEGY,
|
|
360
|
+
result: RDS.Loading()
|
|
361
|
+
};
|
|
362
|
+
});
|
|
363
|
+
builder.addCase(identify.fulfilled, function (state, _ref7) {
|
|
364
|
+
var payload = _ref7.payload;
|
|
365
|
+
state.currentState = payload;
|
|
366
|
+
});
|
|
367
|
+
builder.addCase(identify.rejected, function (state, _ref8) {
|
|
368
|
+
var payload = _ref8.payload;
|
|
369
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
370
|
+
// @ts-ignore
|
|
371
|
+
state.currentState = {
|
|
372
|
+
type: _identifySliceTypes.StrategyStates.IDENTIFY_FLOW_BY_MSISDN,
|
|
373
|
+
result: RDS.Failure(payload)
|
|
374
|
+
};
|
|
375
|
+
});
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
var handleIdentifySubmitMSISDNAction = function handleIdentifySubmitMSISDNAction(builder) {
|
|
379
|
+
builder.addCase(_askMobileNumber.identifySubmitMSISDNAction.pending, function (state) {
|
|
380
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
381
|
+
// @ts-ignore
|
|
382
|
+
state.currentState = {
|
|
383
|
+
type: _identifySliceTypes.StrategyStates.IDENTIFY_FLOW_BY_MSISDN,
|
|
384
|
+
result: RDS.Loading()
|
|
385
|
+
};
|
|
386
|
+
});
|
|
387
|
+
builder.addCase(_askMobileNumber.identifySubmitMSISDNAction.fulfilled, function (state, _ref9) {
|
|
388
|
+
var payload = _ref9.payload;
|
|
389
|
+
state.currentState = payload;
|
|
390
|
+
});
|
|
391
|
+
builder.addCase(_askMobileNumber.identifySubmitMSISDNAction.rejected, function (state, _ref10) {
|
|
392
|
+
var payload = _ref10.payload;
|
|
393
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
394
|
+
// @ts-ignore
|
|
395
|
+
state.currentState = {
|
|
396
|
+
type: _identifySliceTypes.StrategyStates.IDENTIFY_FLOW_BY_MSISDN,
|
|
397
|
+
result: RDS.Failure(payload)
|
|
398
|
+
};
|
|
399
|
+
});
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
var handleSelectOperatorAction = function handleSelectOperatorAction(builder) {
|
|
403
|
+
builder.addCase(_askOperator.selectOperatorAction.pending, function (state) {
|
|
404
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
405
|
+
// @ts-ignore
|
|
406
|
+
state.currentState = {
|
|
407
|
+
type: _identifySliceTypes.StrategyStates.IDENTIFY_FLOW_BY_OPERATOR_SELECT,
|
|
408
|
+
result: RDS.Loading()
|
|
409
|
+
};
|
|
410
|
+
});
|
|
411
|
+
builder.addCase(_askOperator.selectOperatorAction.fulfilled, function (state, _ref11) {
|
|
412
|
+
var payload = _ref11.payload;
|
|
413
|
+
state.currentState = payload;
|
|
414
|
+
});
|
|
415
|
+
builder.addCase(_askOperator.selectOperatorAction.rejected, function (state, _ref12) {
|
|
416
|
+
var payload = _ref12.payload;
|
|
417
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
418
|
+
// @ts-ignore
|
|
419
|
+
state.currentState = {
|
|
420
|
+
type: _identifySliceTypes.StrategyStates.IDENTIFY_FLOW_BY_OPERATOR_SELECT,
|
|
421
|
+
result: RDS.Failure(payload)
|
|
422
|
+
};
|
|
423
|
+
});
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
var identifySlice = (0, _toolkit.createSlice)({
|
|
427
|
+
name: 'strategy',
|
|
428
|
+
initialState: initialState,
|
|
429
|
+
reducers: {// identify(state, action: PayloadAction<IStrategy>) {
|
|
430
|
+
// // state is not muteted as redux toolkit uses immuer
|
|
431
|
+
// // under the hood
|
|
432
|
+
// const configs = action.payload;
|
|
433
|
+
// const strategy = 'pin-one-click-detect-operator-by-ip';
|
|
434
|
+
// switch (strategy) {
|
|
435
|
+
// case 'pin-one-click-detect-operator-by-ip': {
|
|
436
|
+
// const newState = await pinOneClickDetectOperatorByIp({ configs });
|
|
437
|
+
// // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
438
|
+
// // @ts-ignore
|
|
439
|
+
// state.currentState = {
|
|
440
|
+
// type: StrategyStates.ONE_CLICK,
|
|
441
|
+
// result: RDS.Success(newState)
|
|
442
|
+
// };
|
|
443
|
+
// }
|
|
444
|
+
// // throw 'Strategy not supported';
|
|
445
|
+
// }
|
|
446
|
+
},
|
|
447
|
+
extraReducers: function extraReducers(builder) {
|
|
448
|
+
handleIdentify(builder);
|
|
449
|
+
handleIdentifySubmitMSISDNAction(builder);
|
|
450
|
+
handleSelectOperatorAction(builder);
|
|
451
|
+
}
|
|
452
|
+
}); // export const { identify } = identifySlice.actions;
|
|
453
|
+
|
|
454
|
+
var _default = identifySlice.reducer;
|
|
455
|
+
exports.default = _default;
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _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.filter");
|
|
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.get-own-property-descriptors");
|
|
18
|
+
|
|
19
|
+
require("core-js/modules/es.object.keys");
|
|
20
|
+
|
|
21
|
+
require("core-js/modules/es.object.to-string");
|
|
22
|
+
|
|
23
|
+
require("core-js/modules/es.promise");
|
|
24
|
+
|
|
25
|
+
require("core-js/modules/es.string.iterator");
|
|
26
|
+
|
|
27
|
+
require("core-js/modules/es.weak-map");
|
|
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.submitMSISDNAction = exports.default = exports.backToStart = void 0;
|
|
37
|
+
|
|
38
|
+
require("regenerator-runtime/runtime");
|
|
39
|
+
|
|
40
|
+
var _toolkit = require("@reduxjs/toolkit");
|
|
41
|
+
|
|
42
|
+
var _mo = _interopRequireWildcard(require("../../api/mo"));
|
|
43
|
+
|
|
44
|
+
var RDS = _interopRequireWildcard(require("../../common-types/RemoteDataState"));
|
|
45
|
+
|
|
46
|
+
var _moFlowSliceTypes = require("./categories/typings/moFlowSliceTypes");
|
|
47
|
+
|
|
48
|
+
var _identifySlice = require("./identifySlice");
|
|
49
|
+
|
|
50
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
51
|
+
|
|
52
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
|
|
53
|
+
|
|
54
|
+
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; }
|
|
55
|
+
|
|
56
|
+
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; }
|
|
57
|
+
|
|
58
|
+
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; }
|
|
59
|
+
|
|
60
|
+
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); } }
|
|
61
|
+
|
|
62
|
+
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); }); }; }
|
|
63
|
+
|
|
64
|
+
var submitMSISDNAction = (0, _toolkit.createAsyncThunk)('moFlow/submitMSISDNAction',
|
|
65
|
+
/*#__PURE__*/
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
67
|
+
// @ts-ignore
|
|
68
|
+
function () {
|
|
69
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(payload, thunkApi) {
|
|
70
|
+
var strategyState, currentState, config, msisdn, extraParams, keywordAndShortcode, errorType;
|
|
71
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
72
|
+
while (1) {
|
|
73
|
+
switch (_context.prev = _context.next) {
|
|
74
|
+
case 0:
|
|
75
|
+
strategyState = thunkApi.getState().strategy.currentState;
|
|
76
|
+
currentState = thunkApi.getState().moFlow.currentState; // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
77
|
+
// @ts-ignore
|
|
78
|
+
|
|
79
|
+
config = strategyState.nextData.config || payload.configs;
|
|
80
|
+
msisdn = payload.msisdn, extraParams = payload.extraParams;
|
|
81
|
+
_context.prev = 4;
|
|
82
|
+
|
|
83
|
+
_identifySlice.tracker.advancedInFlow('tallyman.v1-mo', 'msisdn-submitted', {
|
|
84
|
+
msisdn: msisdn
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
_context.next = 8;
|
|
88
|
+
return (0, _mo.default)(window, config, msisdn, extraParams);
|
|
89
|
+
|
|
90
|
+
case 8:
|
|
91
|
+
keywordAndShortcode = _context.sent;
|
|
92
|
+
|
|
93
|
+
_identifySlice.tracker.advancedInFlow('tallyman.v1-mo', 'msisdn-submission-success', {
|
|
94
|
+
msisdn: msisdn
|
|
95
|
+
}); // eslint-disable-next-line camelcase
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
(0, _mo.checkSubscription)(window, config).then(function (product_url) {
|
|
99
|
+
_identifySlice.tracker.advancedInFlow('tallyman.v1-mo', 'sale', {
|
|
100
|
+
msisdn: msisdn
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
setTimeout(function () {
|
|
104
|
+
// eslint-disable-next-line camelcase
|
|
105
|
+
window.location.href = product_url;
|
|
106
|
+
}, 1000);
|
|
107
|
+
});
|
|
108
|
+
return _context.abrupt("return", {
|
|
109
|
+
type: _moFlowSliceTypes.MoStates.MSISDNEntry,
|
|
110
|
+
result: _objectSpread({}, keywordAndShortcode)
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
case 14:
|
|
114
|
+
_context.prev = 14;
|
|
115
|
+
_context.t0 = _context["catch"](4);
|
|
116
|
+
console.warn(_context.t0);
|
|
117
|
+
errorType = _context.t0.type === _moFlowSliceTypes.MSISDNEntryErrorTypes.AlreadySubscribed ? _moFlowSliceTypes.MSISDNEntryErrorTypes.AlreadySubscribed : _context.t0.type === _moFlowSliceTypes.MSISDNEntryErrorTypes.InvalidMSISDN ? _moFlowSliceTypes.MSISDNEntryErrorTypes.InvalidMSISDN : _moFlowSliceTypes.MSISDNEntryErrorTypes.UnknownError;
|
|
118
|
+
|
|
119
|
+
_identifySlice.tracker.recedeInFlow('tallyman.v1-mo', 'msisdn-submission-failure', {
|
|
120
|
+
msisdn: msisdn,
|
|
121
|
+
errorType: errorType || 'UnknownError'
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
return _context.abrupt("return", thunkApi.rejectWithValue(_objectSpread(_objectSpread({}, currentState), {}, {
|
|
125
|
+
type: _moFlowSliceTypes.MoStates.MSISDNEntry,
|
|
126
|
+
result: {
|
|
127
|
+
errorType: errorType,
|
|
128
|
+
error: _context.t0,
|
|
129
|
+
productUrl: _context.t0.productUrl
|
|
130
|
+
}
|
|
131
|
+
})));
|
|
132
|
+
|
|
133
|
+
case 20:
|
|
134
|
+
case "end":
|
|
135
|
+
return _context.stop();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}, _callee, null, [[4, 14]]);
|
|
139
|
+
}));
|
|
140
|
+
|
|
141
|
+
return function (_x, _x2) {
|
|
142
|
+
return _ref.apply(this, arguments);
|
|
143
|
+
};
|
|
144
|
+
}());
|
|
145
|
+
exports.submitMSISDNAction = submitMSISDNAction;
|
|
146
|
+
|
|
147
|
+
var handleSubmitMSISDNAction = function handleSubmitMSISDNAction(builder) {
|
|
148
|
+
builder.addCase(submitMSISDNAction.pending, function (state) {
|
|
149
|
+
state.currentState = {
|
|
150
|
+
type: _moFlowSliceTypes.MoStates.MSISDNEntry,
|
|
151
|
+
result: RDS.Loading()
|
|
152
|
+
};
|
|
153
|
+
});
|
|
154
|
+
builder.addCase(submitMSISDNAction.fulfilled, function (state, _ref2) {
|
|
155
|
+
var payload = _ref2.payload;
|
|
156
|
+
state.currentState = {
|
|
157
|
+
type: _moFlowSliceTypes.MoStates.MSISDNEntry,
|
|
158
|
+
result: RDS.Success(payload.result)
|
|
159
|
+
};
|
|
160
|
+
});
|
|
161
|
+
builder.addCase(submitMSISDNAction.rejected, function (state, _ref3) {
|
|
162
|
+
var payload = _ref3.payload;
|
|
163
|
+
state.currentState = {
|
|
164
|
+
type: _moFlowSliceTypes.MoStates.MSISDNEntry,
|
|
165
|
+
result: RDS.Failure(payload.result)
|
|
166
|
+
};
|
|
167
|
+
});
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
var initialState = {
|
|
171
|
+
currentState: {
|
|
172
|
+
type: _moFlowSliceTypes.MoStates.MSISDNEntry,
|
|
173
|
+
result: RDS.NothingYet()
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
var moFlowSlice = (0, _toolkit.createSlice)({
|
|
177
|
+
name: 'moFlow',
|
|
178
|
+
initialState: initialState,
|
|
179
|
+
reducers: {
|
|
180
|
+
backToStart: function backToStart(state) {
|
|
181
|
+
_identifySlice.tracker.recedeInFlow('tallyman.v1-mo', 'mo-view-backtostart', 'requested to change phone number');
|
|
182
|
+
|
|
183
|
+
state.currentState = {
|
|
184
|
+
type: _moFlowSliceTypes.MoStates.MSISDNEntry,
|
|
185
|
+
result: RDS.NothingYet()
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
extraReducers: function extraReducers(builder) {
|
|
190
|
+
handleSubmitMSISDNAction(builder);
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
var backToStart = moFlowSlice.actions.backToStart;
|
|
194
|
+
exports.backToStart = backToStart;
|
|
195
|
+
var _default = moFlowSlice.reducer;
|
|
196
|
+
exports.default = _default;
|