ouisys-engine 2.1.75 → 3.0.1

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 (66) hide show
  1. package/.eslintrc.js +0 -2
  2. package/.nvmrc +1 -1
  3. package/dist/@types/window.d.js +5 -1
  4. package/dist/api/index.js +80 -48
  5. package/dist/common-types/AppThunk.js +5 -1
  6. package/dist/common-types/Either.js +5 -1
  7. package/dist/common-types/IError.js +5 -1
  8. package/dist/common-types/ITracker.js +3 -0
  9. package/dist/common-types/IVisitor.js +5 -1
  10. package/dist/common-types/RemoteDataState.js +3 -3
  11. package/dist/ips/tryGetIPRangeName.js +37 -5
  12. package/dist/pacman/index.js +16 -14
  13. package/dist/pacman/queryString.js +12 -10
  14. package/dist/reducers/click2smsFlow/Click2smsTypes.js +5 -1
  15. package/dist/reducers/click2smsFlow/IClick2smsConstants.js +5 -1
  16. package/dist/reducers/click2smsFlow/index.d.ts +1 -1
  17. package/dist/reducers/click2smsFlow/index.js +41 -25
  18. package/dist/reducers/click2smsFlow/utils.js +53 -31
  19. package/dist/reducers/moFlow/IMoConstants.js +5 -1
  20. package/dist/reducers/moFlow/MoTypes.js +5 -1
  21. package/dist/reducers/moFlow/index.d.ts +1 -1
  22. package/dist/reducers/moFlow/index.js +41 -25
  23. package/dist/reducers/moFlow/utils.js +57 -39
  24. package/dist/reducers/moRedirFlow/IMoRedirConstants.js +5 -1
  25. package/dist/reducers/moRedirFlow/MoRedirTypes.js +5 -1
  26. package/dist/reducers/moRedirFlow/index.d.ts +1 -1
  27. package/dist/reducers/moRedirFlow/index.js +37 -19
  28. package/dist/reducers/moRedirFlow/utils.js +48 -32
  29. package/dist/reducers/oneClickFlow/IOneClickConstants.js +5 -1
  30. package/dist/reducers/oneClickFlow/OneClickTypes.js +5 -1
  31. package/dist/reducers/oneClickFlow/index.d.ts +1 -1
  32. package/dist/reducers/oneClickFlow/index.js +44 -28
  33. package/dist/reducers/oneClickFlow/utils.js +49 -35
  34. package/dist/reducers/pinFlow/IPinConstants.js +5 -1
  35. package/dist/reducers/pinFlow/PinTypes.js +5 -1
  36. package/dist/reducers/pinFlow/index.d.ts +1 -1
  37. package/dist/reducers/pinFlow/index.js +75 -47
  38. package/dist/reducers/pinFlow/utils.js +63 -47
  39. package/dist/reducers/strategy/IStategyActionContants.js +5 -1
  40. package/dist/reducers/strategy/StrategyTypes.d.ts +4 -2
  41. package/dist/reducers/strategy/StrategyTypes.js +5 -1
  42. package/dist/reducers/strategy/index.d.ts +2 -2
  43. package/dist/reducers/strategy/index.js +67 -45
  44. package/dist/reducers/strategy/strategies/ask_mobile_number.js +39 -23
  45. package/dist/reducers/strategy/strategies/ask_operator.js +41 -25
  46. package/dist/reducers/strategy/strategies/detect_operator_by_ip.js +50 -33
  47. package/dist/reducers/strategy/strategies/header_enrichment.js +42 -24
  48. package/dist/reducers/strategy/utils.js +72 -54
  49. package/dist/reducers/ussdFlow/IUssdConstants.js +5 -1
  50. package/dist/reducers/ussdFlow/UssdTypes.js +5 -1
  51. package/dist/reducers/ussdFlow/index.d.ts +1 -1
  52. package/dist/reducers/ussdFlow/index.js +41 -25
  53. package/dist/reducers/ussdFlow/utils.js +53 -35
  54. package/dist/store/index.js +16 -16
  55. package/dist/utilities/handleSubmitNumber.js +6 -6
  56. package/dist/utilities/index.d.ts +2 -0
  57. package/dist/utilities/index.js +24 -2
  58. package/package.json +63 -58
  59. package/prettier.config.js +1 -1
  60. package/src/reducers/pinFlow/index.ts +12 -1
  61. package/src/reducers/pinFlow/utils.ts +0 -1
  62. package/src/reducers/strategy/StrategyTypes.ts +4 -2
  63. package/src/reducers/strategy/index.ts +6 -3
  64. package/src/reducers/strategy/strategies/detect_operator_by_ip.ts +0 -1
  65. package/src/utilities/index.ts +87 -0
  66. package/tsconfig.json +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ouisys-engine",
3
- "version": "2.1.75",
3
+ "version": "3.0.1",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "directories": "dist dev-tools",
@@ -11,78 +11,83 @@
11
11
  "build:init": "tsc --init --declaration --allowSyntheticDefaultImports --target esnext --outDir dist",
12
12
  "release": "ts-node ./src/dev-tools/publish-package",
13
13
  "manage:configs": "ts-node ./src/test-tools/configure-page-strategy.ts",
14
+ "lint": "eslint --fix 'src/**/*.{ts,tsx}'",
14
15
  "format": "prettier --write ."
15
16
  },
16
17
  "author": "",
17
18
  "license": "ISC",
18
19
  "dependencies": {
19
- "awesome-phonenumber": "^2.53.0",
20
- "pacman-client": "^1.5.4",
21
- "react-addons-update": "^15.6.2",
22
- "redux": "^4.1.1",
20
+ "awesome-phonenumber": "^3.2.0",
21
+ "immutability-helper": "^3.1.1",
22
+ "pacman-client": "^1.5.6",
23
+ "react-addons-update": "^15.6.3",
24
+ "redux": "^4.2.0",
23
25
  "redux-logger": "^3.0.6",
24
- "redux-thunk": "^2.3.0",
25
- "rxjs": "^6.3.3",
26
- "rxjs-compat": "^6.3.3",
27
- "typescript": "^4.4.3",
28
- "uuid": "^3.3.2"
26
+ "redux-thunk": "^2.4.1",
27
+ "rxjs": "^7.5.5",
28
+ "rxjs-compat": "^6.6.7",
29
+ "typescript": "^4.7.4",
30
+ "uuid": "^8.3.2"
29
31
  },
30
32
  "devDependencies": {
31
- "@babel/cli": "7.5.5",
32
- "@babel/core": "7.5.5",
33
- "@babel/plugin-proposal-class-properties": "7.5.5",
34
- "@babel/plugin-transform-member-expression-literals": "^7.7.4",
35
- "@babel/preset-env": "7.5.5",
36
- "@babel/preset-typescript": "7.3.3",
37
- "@babel/runtime": "7.5.5",
38
- "@reduxjs/toolkit": "https://pkg.csb.dev/reduxjs/redux-toolkit/commit/933aa4a1/@reduxjs/toolkit",
39
- "@types/chai": "^4.1.7",
40
- "@types/crypto-js": "^4.0.1",
41
- "@types/fs-extra": "^7.0.0",
42
- "@types/inquirer": "^6.5.0",
43
- "@types/mocha": "^5.2.5",
44
- "@types/node": "^16.9.4",
45
- "@types/node-fetch": "^2.5.7",
46
- "@types/ramda": "^0.25.42",
47
- "@types/react": "^16.8.6",
48
- "@types/react-addons-update": "^0.14.20",
49
- "@types/react-dom": "^16.8.2",
50
- "@types/react-redux": "^7.1.8",
51
- "@types/react-test-renderer": "^16.0.3",
52
- "@types/redux-logger": "^3.0.7",
53
- "@types/redux-mock-store": "^1.0.2",
54
- "@types/uuid": "^8.0.0",
55
- "chai": "^4.2.0",
56
- "core-js": "3.6.5",
57
- "eslint": "^7.16.0",
58
- "eslint-config-airbnb": "^18.2.1",
59
- "eslint-config-prettier": "^7.1.0",
60
- "eslint-plugin-import": "^2.22.1",
61
- "eslint-plugin-jest": "^24.1.3",
62
- "eslint-plugin-jsx-a11y": "^6.4.1",
63
- "eslint-plugin-prettier": "^3.3.0",
64
- "eslint-plugin-react": "^7.21.5",
65
- "eslint-plugin-react-hooks": "^4.2.0",
66
- "eslint-plugin-testing-library": "^3.10.1",
67
- "eslint-webpack-plugin": "^2.5.2",
68
- "jsdom": "^13.2.0",
33
+ "@babel/cli": "7.18.6",
34
+ "@babel/core": "7.18.6",
35
+ "@babel/plugin-proposal-class-properties": "7.18.6",
36
+ "@babel/plugin-transform-member-expression-literals": "^7.18.6",
37
+ "@babel/preset-env": "7.18.6",
38
+ "@babel/preset-typescript": "7.18.6",
39
+ "@babel/runtime": "7.18.6",
40
+ "@reduxjs/toolkit": "1.8.3",
41
+ "@types/chai": "^4.3.1",
42
+ "@types/crypto-js": "^4.1.1",
43
+ "@types/fs-extra": "^9.0.13",
44
+ "@types/inquirer": "^8.2.1",
45
+ "@types/mocha": "^9.1.1",
46
+ "@types/node": "^18.0.3",
47
+ "@types/node-fetch": "^2.6.2",
48
+ "@types/ramda": "^0.28.15",
49
+ "@types/react": "^18.0.15",
50
+ "@types/react-dom": "^18.0.6",
51
+ "@types/react-redux": "^7.1.24",
52
+ "@types/react-test-renderer": "^18.0.0",
53
+ "@types/redux-logger": "^3.0.9",
54
+ "@types/redux-mock-store": "^1.0.3",
55
+ "@types/uuid": "^8.3.4",
56
+ "chai": "^4.3.6",
57
+ "core-js": "3.23.4",
58
+ "eslint": "^8.19.0",
59
+ "eslint-config-airbnb": "^19.0.4",
60
+ "eslint-config-prettier": "^8.5.0",
61
+ "eslint-plugin-import": "^2.26.0",
62
+ "eslint-plugin-jest": "^26.5.3",
63
+ "eslint-plugin-jsx-a11y": "^6.6.0",
64
+ "eslint-plugin-prettier": "^4.2.1",
65
+ "eslint-plugin-react": "^7.30.1",
66
+ "eslint-plugin-react-hooks": "^4.6.0",
67
+ "eslint-plugin-testing-library": "^5.5.1",
68
+ "eslint-webpack-plugin": "^3.2.0",
69
+ "jsdom": "^20.0.0",
69
70
  "jsdom-global": "^3.0.2",
70
- "msw": "^0.35.0",
71
- "prettier": "^2.4.1",
72
- "prettier-plugin-organize-imports": "^2.3.3",
73
- "react-test-renderer": "^16.7.0",
71
+ "msw": "^0.43.1",
72
+ "prettier": "^2.7.1",
73
+ "prettier-plugin-organize-imports": "^3.0.0",
74
+ "react-test-renderer": "^18.2.0",
74
75
  "redux-cli-logger": "^2.1.0",
75
76
  "redux-mock-store": "^1.5.4",
76
- "ts-node": "^8.0.2",
77
- "yarn": "^1.17.3"
77
+ "ts-node": "^10.8.2"
78
78
  },
79
79
  "resolutions": {
80
- "@types/react": "^16.7.13",
81
- "@types/react-dom": "^16.0.11",
82
- "react": "16.8.3",
83
- "react-dom": "16.8.3"
80
+ "@types/react": "^18.0.14",
81
+ "@types/react-dom": "^18.0.5",
82
+ "react": "^18.2.0",
83
+ "react-dom": "^18.2.0"
84
84
  },
85
85
  "proxy": "http://localhost:3030/",
86
+ "husky": {
87
+ "hooks": {
88
+ "pre-commit": "lint-staged"
89
+ }
90
+ },
86
91
  "lint-staged": {
87
92
  "*": "prettier --ignore-unknown --write",
88
93
  "src/**/*.{ts,tsx}": "eslint --fix"
@@ -4,4 +4,4 @@ module.exports = {
4
4
  "singleQuote": true,
5
5
  "printWidth": 120,
6
6
  "tabWidth": 2
7
- };
7
+ };
@@ -5,15 +5,26 @@ import { MSISDNEntryFailure, MSISDNEntryErrorTypes, PINEntryFailure, PINEntrySuc
5
5
  import { AppThunk } from "../../common-types/AppThunk";
6
6
  import submitMSISDN, { mockedCompletedState, mockedMSISDNEntryFailure, mockedPINState, submitPIN } from "./utils";
7
7
  import { genericHandler, tracker } from "../strategy";
8
+ import { getSAOperatorByMsisdnPrefix } from "../../utilities";
9
+ import { determineFlowByOperator } from "../strategy/utils";
8
10
 
9
11
 
12
+ const getConfigByMsisdnPrefix = (msisdn:string)=>{
13
+ const operatorByPrefix = getSAOperatorByMsisdnPrefix(msisdn);
14
+ const flowObj = determineFlowByOperator(operatorByPrefix);
15
+ return flowObj.flowConfig;
16
+ }
17
+
10
18
  //ACTION CREATORS
11
19
  export function submitMSISDNAction(msisdn:string, extraParams?:IHash):AppThunk{
12
20
  return async (dispatch, store)=>{
13
21
  const {currentState} = store().strategy;
14
22
  const pinFlowCurrentState = store().pinFlow.currentState;
15
23
  if(currentState.type === "PIN"){
16
- const config = currentState.result.config;
24
+ const { config: configByStrategy, isUseMsisdnPrefix } = currentState.result;
25
+
26
+ const config = isUseMsisdnPrefix ? getConfigByMsisdnPrefix(msisdn) : configByStrategy;
27
+
17
28
  const pinMaxLengthByOp:{[key:string]:number} = {
18
29
  "SA_MOBILY":6,
19
30
  "SA_STC":4,
@@ -73,7 +73,6 @@ async function submitMSISDNOnce(window: Window, config: IConfig, internationalMS
73
73
  const search = (window.location.search.indexOf("redirect-back=1") == -1) ? (window.location.search.substr(1) || '') : ''
74
74
  const extraParamsQs = !extraParams ? '' : '&' + Object.keys(extraParams).map(k => `${k}=${extraParams[k]}`).join('&')
75
75
  const uniqid = (!!uniqidResult && uniqidResult != "") ? `&mcpUniqid=${uniqidResult}` : '';
76
-
77
76
 
78
77
 
79
78
  const result: IMSISDNSubmissionResult = await window.tallymanApi.triggerPin(host, country, slug, device, offer, msisdn, rockmanId, extraParamsQs, search, uniqid)
@@ -4,9 +4,9 @@ import { AppThunk } from "../../common-types/AppThunk";
4
4
 
5
5
  export type IIdentifyResult = {
6
6
  operator: string;
7
- flow: string;
7
+ flow?: string;
8
8
  success: boolean;
9
- rockman_id: string;
9
+ rockman_id?: string;
10
10
  message?:string;
11
11
  }
12
12
 
@@ -46,6 +46,7 @@ export type StrategyConfig = {
46
46
  [key:string]:IFlow;
47
47
  };
48
48
  default:IFlow;
49
+ isUseMsisdnPrefix?:boolean;
49
50
  }
50
51
  // export type IStrategy = IPinStrategy | IMoStrategy;
51
52
 
@@ -111,6 +112,7 @@ export type IdentifyFlowOptionsResult<F> = {
111
112
  rockman_id?:string;
112
113
  isHeaderEnrichmentSuccess?:boolean;
113
114
  autoRedirect?:boolean;
115
+ isUseMsisdnPrefix?: boolean;
114
116
  }
115
117
 
116
118
 
@@ -21,7 +21,7 @@ import ask_mobile_number,
21
21
  {
22
22
  submitMSISDNAction
23
23
  } from "./strategies/ask_mobile_number";
24
- import update from "react-addons-update";
24
+ import update from 'immutability-helper';
25
25
  import mkTracker from "../../pacman";
26
26
  import detect_operator_by_ip from "./strategies/detect_operator_by_ip";
27
27
  import { loadOc2sms } from "../click2smsFlow";
@@ -100,6 +100,7 @@ export function mockStrategyStateByUrlParam():AppThunk {
100
100
  export function identifyStrategy():AppThunk {
101
101
  return async (dispatch)=>{
102
102
  const { strategy, strategyConfigs } = getConfig();
103
+ const { isUseMsisdnPrefix } = strategyConfigs;
103
104
  const search = searchToObject() as IMockFlowParams<IMockPinFlowStates>;
104
105
 
105
106
  if(search["mock-flow"] !== undefined){
@@ -138,7 +139,8 @@ export function identifyStrategy():AppThunk {
138
139
  type:"PIN",
139
140
  result: {
140
141
  nextAction:"submitMSISDNAction",
141
- config:strategyConfigs.default.flowConfig
142
+ config:strategyConfigs.default.flowConfig,
143
+ isUseMsisdnPrefix
142
144
  }
143
145
  }
144
146
  });
@@ -270,8 +272,9 @@ export function checkSubscriptionAction(trackingArgs:{flow: string, action: stri
270
272
  }
271
273
  export function genericHandler<S,P>(state:S, payload:P){
272
274
  return update(state, {
275
+ //@ts-ignore
273
276
  currentState:{
274
- $set:payload,
277
+ $set: payload
275
278
  }
276
279
  });
277
280
  }
@@ -2,7 +2,6 @@ import * as RDS from "../../../common-types/RemoteDataState";
2
2
 
3
3
  import {getConfig, determineFlowByOperatorFromIp } from "../utils";
4
4
  import { AppThunk } from "../../../common-types/AppThunk";
5
- import update from "react-addons-update";
6
5
  import {
7
6
  IFlow
8
7
  } from "../StrategyTypes";
@@ -24,4 +24,91 @@ export const setOnLoadUtilities = (config:IConfig)=>{
24
24
  loadMcpShield(window, config);
25
25
  }
26
26
  }
27
+ }
28
+
29
+ export type SAOperators = 'SA_VIRGIN' | 'SA_MOBILY' | 'SA_STC' | 'SA_ZAIN';
30
+ const sa_prefix_operator_map = new Map<string, SAOperators>([
31
+ ['966571', 'SA_VIRGIN']
32
+ , ['966500', 'SA_STC']
33
+ , ['966501', 'SA_STC']
34
+ , ['966502', 'SA_STC']
35
+ , ['966503', 'SA_STC']
36
+ , ['966504', 'SA_STC']
37
+ , ['966505', 'SA_STC']
38
+ , ['966506', 'SA_STC']
39
+ , ['966507', 'SA_STC']
40
+ , ['966508', 'SA_STC']
41
+ , ['966509', 'SA_STC']
42
+ , ['966512', 'SA_STC']
43
+ , ['966514', 'SA_STC']
44
+ , ['966515', 'SA_STC']
45
+ , ['966517', 'SA_STC']
46
+ , ['966530', 'SA_STC']
47
+ , ['966531', 'SA_STC']
48
+ , ['966532', 'SA_STC']
49
+ , ['966533', 'SA_STC']
50
+ , ['966534', 'SA_STC']
51
+ , ['966535', 'SA_STC']
52
+ , ['966536', 'SA_STC']
53
+ , ['966537', 'SA_STC']
54
+ , ['966538', 'SA_STC']
55
+ , ['966539', 'SA_STC']
56
+ , ['966540', 'SA_MOBILY']
57
+ , ['966541', 'SA_MOBILY']
58
+ , ['966542', 'SA_MOBILY']
59
+ , ['966543', 'SA_MOBILY']
60
+ , ['966544', 'SA_MOBILY']
61
+ , ['966545', 'SA_MOBILY']
62
+ , ['966546', 'SA_MOBILY']
63
+ , ['966547', 'SA_MOBILY']
64
+ , ['966548', 'SA_MOBILY']
65
+ , ['966549', 'SA_MOBILY']
66
+ , ['966550', 'SA_STC']
67
+ , ['966551', 'SA_STC']
68
+ , ['966552', 'SA_STC']
69
+ , ['966553', 'SA_STC']
70
+ , ['966554', 'SA_STC']
71
+ , ['966555', 'SA_STC']
72
+ , ['966556', 'SA_STC']
73
+ , ['966557', 'SA_STC']
74
+ , ['966558', 'SA_STC']
75
+ , ['966559', 'SA_STC']
76
+ , ['966560', 'SA_MOBILY']
77
+ , ['966561', 'SA_MOBILY']
78
+ , ['966562', 'SA_MOBILY']
79
+ , ['966563', 'SA_MOBILY']
80
+ , ['966564', 'SA_MOBILY']
81
+ , ['966565', 'SA_MOBILY']
82
+ , ['966566', 'SA_MOBILY']
83
+ , ['966567', 'SA_MOBILY']
84
+ , ['966568', 'SA_MOBILY']
85
+ , ['966569', 'SA_MOBILY']
86
+ , ['966570', 'SA_VIRGIN']
87
+ , ['966572', 'SA_VIRGIN']
88
+ , ['966573', 'SA_VIRGIN']
89
+ , ['966580', 'SA_ZAIN']
90
+ , ['966581', 'SA_ZAIN']
91
+ , ['966582', 'SA_ZAIN']
92
+ , ['966583', 'SA_ZAIN']
93
+ , ['966586', 'SA_ZAIN']
94
+ , ['966588', 'SA_ZAIN']
95
+ , ['966589', 'SA_ZAIN']
96
+ , ['966590', 'SA_ZAIN']
97
+ , ['966591', 'SA_ZAIN']
98
+ , ['966592', 'SA_ZAIN']
99
+ , ['966593', 'SA_ZAIN']
100
+ , ['966594', 'SA_ZAIN']
101
+ , ['966595', 'SA_ZAIN']
102
+ , ['966596', 'SA_ZAIN']
103
+ , ['966597', 'SA_ZAIN']
104
+ , ['966598', 'SA_ZAIN']
105
+ , ['966599', 'SA_ZAIN']
106
+ ]);
107
+
108
+ export function getSAOperatorByMsisdnPrefix(msisdn: string) : SAOperators | undefined {
109
+ if(msisdn[0] === "0") {
110
+ msisdn = "966" + msisdn.substring(1);
111
+ }
112
+ const prefix = msisdn.substring(0, 6)
113
+ return sa_prefix_operator_map.get(prefix);
27
114
  }
package/tsconfig.json CHANGED
@@ -17,5 +17,5 @@
17
17
  "typeRoots": ["node_modules/@types", "src/@types"]
18
18
  },
19
19
  "include": ["src/**/*", "dev-tools/**/*"],
20
- "exclude": [ "node_modules", "webpack/**/*"]
20
+ "exclude": [ "node_modules/**/*", "webpack/**/*"]
21
21
  }