ouisys-engine 3.0.2 → 3.0.6
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/.babelrc +4 -8
- package/.eslintrc.js +1 -1
- package/.nvmrc +1 -1
- package/.prettierignore +2 -1
- package/README.md +2 -4
- package/dist/api/index.d.ts +5 -5
- package/dist/api/index.js +76 -76
- package/dist/common-types/AppThunk.d.ts +11 -12
- package/dist/common-types/IOptInFlowName.d.ts +1 -1
- package/dist/common-types/ITracker.js +1 -2
- package/dist/common-types/RemoteDataState.d.ts +4 -4
- package/dist/common-types/RemoteDataState.js +17 -17
- package/dist/flows/click2smsFlow.d.ts +2 -2
- package/dist/flows/moFlow.d.ts +2 -2
- package/dist/flows/moRedirFlow.d.ts +2 -2
- package/dist/flows/oneClickFlow.d.ts +2 -2
- package/dist/flows/pinFlow.d.ts +2 -2
- package/dist/flows/pinFlow.js +2 -0
- package/dist/flows/strategy.d.ts +8 -8
- package/dist/flows/ussdFlow.d.ts +2 -2
- package/dist/ips/tryGetIPRangeName.d.ts +1 -1
- package/dist/ips/tryGetIPRangeName.js +7 -5
- package/dist/jest.config.js +1 -1
- package/dist/pacman/index.d.ts +2 -2
- package/dist/pacman/index.js +41 -41
- package/dist/pacman/queryString.js +11 -9
- package/dist/reducers/click2smsFlow/Click2smsTypes.d.ts +19 -19
- package/dist/reducers/click2smsFlow/IClick2smsConstants.d.ts +1 -1
- package/dist/reducers/click2smsFlow/index.d.ts +2 -2
- package/dist/reducers/click2smsFlow/index.js +24 -24
- package/dist/reducers/click2smsFlow/utils.d.ts +1 -1
- package/dist/reducers/click2smsFlow/utils.js +30 -30
- package/dist/reducers/moFlow/IMoConstants.d.ts +1 -1
- package/dist/reducers/moFlow/MoTypes.d.ts +13 -13
- package/dist/reducers/moFlow/index.d.ts +3 -3
- package/dist/reducers/moFlow/index.js +27 -27
- package/dist/reducers/moFlow/utils.d.ts +1 -2
- package/dist/reducers/moFlow/utils.js +28 -26
- package/dist/reducers/moRedirFlow/IMoRedirConstants.d.ts +1 -1
- package/dist/reducers/moRedirFlow/MoRedirTypes.d.ts +13 -13
- package/dist/reducers/moRedirFlow/index.d.ts +3 -3
- package/dist/reducers/moRedirFlow/index.js +27 -27
- package/dist/reducers/moRedirFlow/utils.d.ts +1 -1
- package/dist/reducers/moRedirFlow/utils.js +17 -17
- package/dist/reducers/oneClickFlow/IOneClickConstants.d.ts +1 -1
- package/dist/reducers/oneClickFlow/OneClickTypes.d.ts +10 -10
- package/dist/reducers/oneClickFlow/index.d.ts +3 -3
- package/dist/reducers/oneClickFlow/index.js +75 -68
- package/dist/reducers/oneClickFlow/utils.d.ts +2 -2
- package/dist/reducers/oneClickFlow/utils.js +70 -69
- package/dist/reducers/pinFlow/IPinConstants.d.ts +1 -1
- package/dist/reducers/pinFlow/PinTypes.d.ts +23 -23
- package/dist/reducers/pinFlow/index.d.ts +3 -3
- package/dist/reducers/pinFlow/index.js +76 -76
- package/dist/reducers/pinFlow/utils.d.ts +1 -1
- package/dist/reducers/pinFlow/utils.js +61 -65
- package/dist/reducers/strategy/IStategyActionContants.d.ts +1 -1
- package/dist/reducers/strategy/StrategyTypes.d.ts +56 -56
- package/dist/reducers/strategy/index.d.ts +2 -2
- package/dist/reducers/strategy/index.js +99 -99
- package/dist/reducers/strategy/strategies/ask_mobile_number.d.ts +3 -2
- package/dist/reducers/strategy/strategies/ask_mobile_number.js +132 -74
- package/dist/reducers/strategy/strategies/ask_operator.d.ts +2 -2
- package/dist/reducers/strategy/strategies/ask_operator.js +64 -68
- package/dist/reducers/strategy/strategies/detect_operator_by_ip.d.ts +2 -2
- package/dist/reducers/strategy/strategies/detect_operator_by_ip.js +97 -97
- package/dist/reducers/strategy/strategies/header_enrichment.d.ts +2 -2
- package/dist/reducers/strategy/strategies/header_enrichment.js +116 -120
- package/dist/reducers/strategy/utils.d.ts +3 -3
- package/dist/reducers/strategy/utils.js +115 -111
- package/dist/reducers/ussdFlow/IUssdConstants.d.ts +1 -1
- package/dist/reducers/ussdFlow/UssdTypes.d.ts +13 -13
- package/dist/reducers/ussdFlow/index.d.ts +3 -3
- package/dist/reducers/ussdFlow/index.js +27 -27
- package/dist/reducers/ussdFlow/utils.d.ts +1 -2
- package/dist/reducers/ussdFlow/utils.js +19 -17
- package/dist/store/index.d.ts +8 -8
- package/dist/store/index.js +87 -83
- package/dist/store/reducers.d.ts +7 -7
- package/dist/store/reducers.js +4 -4
- package/dist/utilities/handleSubmitNumber.d.ts +7 -3
- package/dist/utilities/handleSubmitNumber.js +15 -18
- package/dist/utilities/index.d.ts +1 -1
- package/dist/utilities/index.js +13 -11
- package/dist/utilities/loadScriptInnerHtml.js +0 -1
- package/index.html +21 -28
- package/package.json +23 -15
- package/setupJest.js +1 -1
- package/tsconfig.json +2 -2
- package/.idea/inspectionProfiles/Project_Default.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/ouisys-engine.iml +0 -12
- package/.idea/vcs.xml +0 -6
- package/.vscode/settings.json +0 -6
- package/dist/api/click2sms.js +0 -357
- package/dist/api/mo.js +0 -274
- package/dist/api/moRedir.js +0 -186
- package/dist/api/oneClick.js +0 -366
- package/dist/api/pin.js +0 -493
- package/dist/api/strategies.js +0 -704
- package/dist/api/ussd.js +0 -1
- package/dist/app/store.js +0 -35
- package/dist/features/strategies/categories/askMobileNumber.js +0 -395
- package/dist/features/strategies/categories/askOperator.js +0 -311
- package/dist/features/strategies/categories/detectOperatorByIp.js +0 -606
- package/dist/features/strategies/categories/headerEnrichment.js +0 -670
- package/dist/features/strategies/categories/typings/click2smsSliceTypes.js +0 -12
- package/dist/features/strategies/categories/typings/identifySliceTypes.js +0 -22
- package/dist/features/strategies/categories/typings/moFlowSliceTypes.js +0 -22
- package/dist/features/strategies/categories/typings/moRedirFlowSliceTypes.js +0 -21
- package/dist/features/strategies/categories/typings/oneClickSliceTypes.js +0 -13
- package/dist/features/strategies/categories/typings/pinFlowSliceTypes.js +0 -13
- package/dist/features/strategies/click2smsFlowSlice.js +0 -172
- package/dist/features/strategies/identifySlice.js +0 -455
- package/dist/features/strategies/moFlowSlice.js +0 -196
- package/dist/features/strategies/moRedirFlowSlice.js +0 -190
- package/dist/features/strategies/oneClickFlowSlice.js +0 -277
- package/dist/features/strategies/pinFlowSlice.js +0 -313
- package/dist/features/strategies/ussdFlowSlice.js +0 -1
- package/dist/flows/tpayHeFlow.d.ts +0 -7
- package/dist/flows/tpayHeFlow.js +0 -23
- package/dist/mockServer/browser.js +0 -48
- package/dist/mockServer/handlers.js +0 -22
- package/dist/mockServer/server.js +0 -48
- package/dist/reducers/tpayHeFlow/ITpayHeConstants.d.ts +0 -2
- package/dist/reducers/tpayHeFlow/ITpayHeConstants.js +0 -1
- package/dist/reducers/tpayHeFlow/TpayHeTypes.d.ts +0 -114
- package/dist/reducers/tpayHeFlow/TpayHeTypes.js +0 -1
- package/dist/reducers/tpayHeFlow/index.d.ts +0 -7
- package/dist/reducers/tpayHeFlow/index.js +0 -331
- package/dist/reducers/tpayHeFlow/utils.d.ts +0 -20
- package/dist/reducers/tpayHeFlow/utils.js +0 -510
- package/dist/test/setup.js +0 -24
- package/dist/test/test-utils.js +0 -51
- package/mockData/config.json +0 -28
- package/prettier.config.js +0 -7
- package/src/@types/react-tracker.d.ts +0 -16
- package/src/@types/redux-cli-logger.d.ts +0 -1
- package/src/@types/tiny-async-pool.d.ts +0 -3
- package/src/@types/window.d.ts +0 -74
- package/src/api/index.ts +0 -225
- package/src/common-types/AppThunk.ts +0 -19
- package/src/common-types/Either.ts +0 -3
- package/src/common-types/IError.ts +0 -5
- package/src/common-types/IOptInFlowName.ts +0 -1
- package/src/common-types/ITracker.ts +0 -10
- package/src/common-types/IVisitor.ts +0 -16
- package/src/common-types/RemoteDataState.ts +0 -88
- package/src/flows/click2smsFlow.ts +0 -18
- package/src/flows/moFlow.ts +0 -20
- package/src/flows/moRedirFlow.ts +0 -20
- package/src/flows/oneClickFlow.ts +0 -20
- package/src/flows/pinFlow.ts +0 -25
- package/src/flows/strategy.ts +0 -51
- package/src/flows/ussdFlow.ts +0 -20
- package/src/index.ts +0 -3
- package/src/ips/tryGetIPRangeName.ts +0 -22
- package/src/jest.config.js +0 -194
- package/src/pacman/index.ts +0 -71
- package/src/pacman/queryString.ts +0 -24
- package/src/reducers/click2smsFlow/Click2smsTypes.ts +0 -93
- package/src/reducers/click2smsFlow/IClick2smsConstants.ts +0 -4
- package/src/reducers/click2smsFlow/index.ts +0 -105
- package/src/reducers/click2smsFlow/utils.ts +0 -126
- package/src/reducers/moFlow/IMoConstants.ts +0 -7
- package/src/reducers/moFlow/MoTypes.ts +0 -125
- package/src/reducers/moFlow/index.ts +0 -150
- package/src/reducers/moFlow/utils.ts +0 -135
- package/src/reducers/moRedirFlow/IMoRedirConstants.ts +0 -7
- package/src/reducers/moRedirFlow/MoRedirTypes.ts +0 -99
- package/src/reducers/moRedirFlow/index.ts +0 -137
- package/src/reducers/moRedirFlow/utils.ts +0 -78
- package/src/reducers/oneClickFlow/IOneClickConstants.ts +0 -3
- package/src/reducers/oneClickFlow/OneClickTypes.ts +0 -108
- package/src/reducers/oneClickFlow/index.ts +0 -268
- package/src/reducers/oneClickFlow/utils.ts +0 -217
- package/src/reducers/pinFlow/IPinConstants.ts +0 -9
- package/src/reducers/pinFlow/PinTypes.ts +0 -190
- package/src/reducers/pinFlow/index.ts +0 -331
- package/src/reducers/pinFlow/utils.ts +0 -232
- package/src/reducers/strategy/IStategyActionContants.ts +0 -17
- package/src/reducers/strategy/StrategyTypes.ts +0 -375
- package/src/reducers/strategy/index.ts +0 -321
- package/src/reducers/strategy/strategies/ask_mobile_number.ts +0 -316
- package/src/reducers/strategy/strategies/ask_operator.ts +0 -195
- package/src/reducers/strategy/strategies/detect_operator_by_ip.ts +0 -414
- package/src/reducers/strategy/strategies/header_enrichment.ts +0 -489
- package/src/reducers/strategy/utils.ts +0 -357
- package/src/reducers/ussdFlow/IUssdConstants.ts +0 -7
- package/src/reducers/ussdFlow/UssdTypes.ts +0 -112
- package/src/reducers/ussdFlow/index.ts +0 -146
- package/src/reducers/ussdFlow/utils.ts +0 -88
- package/src/store/index.ts +0 -150
- package/src/store/reducers.ts +0 -37
- package/src/utilities/handleSubmitNumber.ts +0 -65
- package/src/utilities/index.ts +0 -114
- package/src/utilities/loadScriptInnerHtml.ts +0 -14
- package/src/utilities/loadScriptSrc.ts +0 -26
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import IVisitor from "../common-types/IVisitor";
|
|
2
|
-
import queryString from "../pacman/queryString";
|
|
3
|
-
|
|
4
|
-
export default async function tryGetIPRangeName(visitor: IVisitor): Promise<string> {
|
|
5
|
-
|
|
6
|
-
const mockip = queryString(window.location.href, "mock-ip") || process.env.mock_ip;
|
|
7
|
-
console.log("mockip", mockip)
|
|
8
|
-
if (!visitor.ip && typeof window != "undefined") {
|
|
9
|
-
try {
|
|
10
|
-
const host = window.location.host
|
|
11
|
-
const res = await fetch(`https://${host}/api/v1/ip` + (!!mockip ? `?mock-ip=${mockip}` : "")).then(x => x.json())
|
|
12
|
-
// return isIPInRange('37.200.146.28')
|
|
13
|
-
visitor.ip = res.ip
|
|
14
|
-
visitor.ip_range_name = res.ip_range_name
|
|
15
|
-
return res.ip_range_name
|
|
16
|
-
} catch (ex) {
|
|
17
|
-
console.warn("IP Lookup failed", ex)
|
|
18
|
-
}
|
|
19
|
-
} else {
|
|
20
|
-
return visitor.ip_range_name
|
|
21
|
-
}
|
|
22
|
-
}
|
package/src/jest.config.js
DELETED
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
// For a detailed explanation regarding each configuration property, visit:
|
|
2
|
-
// https://jestjs.io/docs/en/configuration.html
|
|
3
|
-
|
|
4
|
-
module.exports = {
|
|
5
|
-
// All imported modules in your tests should be mocked automatically
|
|
6
|
-
// automock: false,
|
|
7
|
-
|
|
8
|
-
// Stop running tests after `n` failures
|
|
9
|
-
// bail: 0,
|
|
10
|
-
|
|
11
|
-
// The directory where Jest should store its cached dependency information
|
|
12
|
-
// cacheDirectory: "/private/var/folders/wr/8ghl3gfx0cldjmd7jhzs8gt80000gn/T/jest_dx",
|
|
13
|
-
|
|
14
|
-
// Automatically clear mock calls and instances between every test
|
|
15
|
-
clearMocks: true
|
|
16
|
-
|
|
17
|
-
// Indicates whether the coverage information should be collected while executing the test
|
|
18
|
-
// collectCoverage: false,
|
|
19
|
-
|
|
20
|
-
// An array of glob patterns indicating a set of files for which coverage information should be collected
|
|
21
|
-
// collectCoverageFrom: undefined,
|
|
22
|
-
|
|
23
|
-
// The directory where Jest should output its coverage files
|
|
24
|
-
coverageDirectory: 'coverage',
|
|
25
|
-
|
|
26
|
-
// An array of regexp pattern strings used to skip coverage collection
|
|
27
|
-
// coveragePathIgnorePatterns: [
|
|
28
|
-
// "/node_modules/"
|
|
29
|
-
// ],
|
|
30
|
-
|
|
31
|
-
// Indicates which provider should be used to instrument code for coverage
|
|
32
|
-
// coverageProvider: 'babel',
|
|
33
|
-
|
|
34
|
-
// A list of reporter names that Jest uses when writing coverage reports
|
|
35
|
-
// coverageReporters: [
|
|
36
|
-
// "json",
|
|
37
|
-
// "text",
|
|
38
|
-
// "lcov",
|
|
39
|
-
// "clover"
|
|
40
|
-
// ],
|
|
41
|
-
|
|
42
|
-
// An object that configures minimum threshold enforcement for coverage results
|
|
43
|
-
// coverageThreshold: undefined,
|
|
44
|
-
|
|
45
|
-
// A path to a custom dependency extractor
|
|
46
|
-
// dependencyExtractor: undefined,
|
|
47
|
-
|
|
48
|
-
// Make calling deprecated APIs throw helpful error messages
|
|
49
|
-
// errorOnDeprecated: false,
|
|
50
|
-
|
|
51
|
-
// Force coverage collection from ignored files using an array of glob patterns
|
|
52
|
-
// forceCoverageMatch: [],
|
|
53
|
-
|
|
54
|
-
collectCoverageFrom: [
|
|
55
|
-
'src/**/*.{js,ts,tsx}',
|
|
56
|
-
'!src/serviceWorker.{ts,js}',
|
|
57
|
-
'!src/storybook/**',
|
|
58
|
-
'!src/mockServer/**'
|
|
59
|
-
],
|
|
60
|
-
|
|
61
|
-
// A path to a module which exports an async function that is triggered once before all test suites
|
|
62
|
-
// globalSetup: undefined,
|
|
63
|
-
|
|
64
|
-
// A path to a module which exports an async function that is triggered once after all test suites
|
|
65
|
-
// globalTeardown: undefined,
|
|
66
|
-
|
|
67
|
-
// A set of global variables that need to be available in all test environments
|
|
68
|
-
// globals: {},
|
|
69
|
-
|
|
70
|
-
// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
|
|
71
|
-
// maxWorkers: "50%",
|
|
72
|
-
|
|
73
|
-
// An array of directory names to be searched recursively up from the requiring module's location
|
|
74
|
-
moduleDirectories: ['node_modules', 'test', __dirname],
|
|
75
|
-
|
|
76
|
-
// An array of file extensions your modules use
|
|
77
|
-
moduleFileExtensions: ['js', 'json', 'jsx', 'ts', 'tsx', 'svg', 'node'],
|
|
78
|
-
|
|
79
|
-
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
|
|
80
|
-
moduleNameMapper: {
|
|
81
|
-
'.+\\.(css|scss|png)$': 'identity-obj-proxy'
|
|
82
|
-
},
|
|
83
|
-
|
|
84
|
-
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
|
|
85
|
-
// modulePathIgnorePatterns: [],
|
|
86
|
-
|
|
87
|
-
// Activates notifications for test results
|
|
88
|
-
// notify: false,
|
|
89
|
-
|
|
90
|
-
// An enum that specifies notification mode. Requires { notify: true }
|
|
91
|
-
// notifyMode: "failure-change",
|
|
92
|
-
|
|
93
|
-
// A preset that is used as a base for Jest's configuration
|
|
94
|
-
// preset: undefined,
|
|
95
|
-
|
|
96
|
-
// Run tests from one or more projects
|
|
97
|
-
// projects: undefined,
|
|
98
|
-
|
|
99
|
-
// Use this configuration option to add custom reporters to Jest
|
|
100
|
-
// reporters: undefined,
|
|
101
|
-
|
|
102
|
-
// Automatically reset mock state between every test
|
|
103
|
-
resetMocks: true,
|
|
104
|
-
|
|
105
|
-
// Reset the module registry before running each individual test
|
|
106
|
-
// resetModules: false,
|
|
107
|
-
|
|
108
|
-
// A path to a custom resolver
|
|
109
|
-
// resolver: undefined,
|
|
110
|
-
|
|
111
|
-
// Automatically restore mock state between every test
|
|
112
|
-
// restoreMocks: false,
|
|
113
|
-
|
|
114
|
-
// The root directory that Jest should scan for tests and modules within
|
|
115
|
-
// rootDir: undefined,
|
|
116
|
-
|
|
117
|
-
// A list of paths to directories that Jest should use to search for files in
|
|
118
|
-
roots: ['<rootDir>/src'],
|
|
119
|
-
|
|
120
|
-
// Allows you to use a custom runner instead of Jest's default test runner
|
|
121
|
-
// runner: "jest-runner",
|
|
122
|
-
|
|
123
|
-
// The paths to modules that run some code to configure or set up the testing environment before each test
|
|
124
|
-
// setupFiles: ['<rootDir>/src/test/setup.ts', 'jest-localstorage-mock'],
|
|
125
|
-
|
|
126
|
-
// A list of paths to modules that run some code to configure or set up the testing framework before each test
|
|
127
|
-
// setupFilesAfterEnv: ['@testing-library/jest-dom/extend-expect'],
|
|
128
|
-
|
|
129
|
-
// The number of seconds after which a test is considered as slow and reported as such in the results.
|
|
130
|
-
// slowTestThreshold: 5,
|
|
131
|
-
|
|
132
|
-
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
|
|
133
|
-
// snapshotSerializers: [],
|
|
134
|
-
|
|
135
|
-
// The test environment that will be used for testing
|
|
136
|
-
testEnvironment: 'jest-environment-jsdom',
|
|
137
|
-
|
|
138
|
-
// Options that will be passed to the testEnvironment
|
|
139
|
-
// testEnvironmentOptions: {},
|
|
140
|
-
|
|
141
|
-
// Adds a location field to test results
|
|
142
|
-
// testLocationInResults: false,
|
|
143
|
-
|
|
144
|
-
// The glob patterns Jest uses to detect test files
|
|
145
|
-
// testMatch: [
|
|
146
|
-
// "**/__tests__/**/*.[jt]s?(x)",
|
|
147
|
-
// "**/?(*.)+(spec|test).[tj]s?(x)"
|
|
148
|
-
// ],
|
|
149
|
-
|
|
150
|
-
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
|
|
151
|
-
// testPathIgnorePatterns: [
|
|
152
|
-
// "/node_modules/"
|
|
153
|
-
// ],
|
|
154
|
-
|
|
155
|
-
// The regexp pattern or array of patterns that Jest uses to detect test files
|
|
156
|
-
testRegex: '(\\.|/)(test|spec)\\.tsx?$',
|
|
157
|
-
|
|
158
|
-
// This option allows the use of a custom results processor
|
|
159
|
-
// testResultsProcessor: undefined,
|
|
160
|
-
|
|
161
|
-
// This option allows use of a custom test runner
|
|
162
|
-
// testRunner: "jasmine2",
|
|
163
|
-
|
|
164
|
-
// This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
|
|
165
|
-
// testURL: "http://localhost",
|
|
166
|
-
|
|
167
|
-
// Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
|
|
168
|
-
// timers: "real",
|
|
169
|
-
|
|
170
|
-
// A map from regular expressions to paths to transformers
|
|
171
|
-
transform: {
|
|
172
|
-
'^.+\\.tsx?$': 'ts-jest',
|
|
173
|
-
'^.+\\.jsx?$': 'ts-jest'
|
|
174
|
-
// '^.+\\.svg$': '<rootDir>/src/test/svgTransformer.js'
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
|
|
178
|
-
// transformIgnorePatterns: [
|
|
179
|
-
// "/node_modules/",
|
|
180
|
-
// "\\.pnp\\.[^\\/]+$"
|
|
181
|
-
// ],
|
|
182
|
-
|
|
183
|
-
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
|
|
184
|
-
// unmockedModulePathPatterns: undefined,
|
|
185
|
-
|
|
186
|
-
// Indicates whether each individual test should be reported during the run
|
|
187
|
-
// verbose: undefined,
|
|
188
|
-
|
|
189
|
-
// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
|
|
190
|
-
// watchPathIgnorePatterns: [],
|
|
191
|
-
|
|
192
|
-
// Whether to use watchman for file crawling
|
|
193
|
-
// watchman: true,
|
|
194
|
-
};
|
package/src/pacman/index.ts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import queryString from "./queryString";
|
|
2
|
-
//@ts-ignore
|
|
3
|
-
import uuid from "uuid/v1";
|
|
4
|
-
import { ITrackerFlowEvents } from "pacman-client/.build-lib/Pacman/types";
|
|
5
|
-
import mkPacmanClient from "pacman-client";
|
|
6
|
-
|
|
7
|
-
export { queryString };
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export type { ITrackerFlowEvents as ITracker};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export default (window: Window, country?: string, page?: string): ITrackerFlowEvents => {
|
|
15
|
-
if (!window) {
|
|
16
|
-
return {
|
|
17
|
-
advancedInFlow: () => void 6,
|
|
18
|
-
advancedInPreFlow: () => void 6,
|
|
19
|
-
recedeInFlow: () => void 6,
|
|
20
|
-
customEvent: () => void 6,
|
|
21
|
-
sendOptInFlowEvent: () => void 6
|
|
22
|
-
};
|
|
23
|
-
} else {
|
|
24
|
-
|
|
25
|
-
const url = !!window.pac_analytics
|
|
26
|
-
? window.pac_analytics.url
|
|
27
|
-
: queryString(window.location.search, "pacman-server") || "/analytics";
|
|
28
|
-
|
|
29
|
-
if (!window.pac_analytics) {
|
|
30
|
-
|
|
31
|
-
const rockmanId = uuid().replace(/-/g, "");
|
|
32
|
-
|
|
33
|
-
const campaignId =
|
|
34
|
-
parseInt(queryString(window.location.search, "cid")) || 2;
|
|
35
|
-
|
|
36
|
-
window.pac_analytics = {
|
|
37
|
-
visitor: {
|
|
38
|
-
rockmanId,
|
|
39
|
-
impressionNumber: 1, //TODO: get impressionNumber from localStorage
|
|
40
|
-
country,
|
|
41
|
-
page,
|
|
42
|
-
xaid: queryString(window.location.search, "xaid"),
|
|
43
|
-
cid: campaignId,
|
|
44
|
-
offer: parseInt(queryString(window.location.search, "offer")) || 1 // default to 1 offer id
|
|
45
|
-
},
|
|
46
|
-
startTime: new Date().valueOf(),
|
|
47
|
-
queryString: (key:string) => queryString(window.location.search, key),
|
|
48
|
-
url,
|
|
49
|
-
userId: rockmanId,
|
|
50
|
-
encCampaignId: queryString(window.location.search, "xcid"),
|
|
51
|
-
originalUrl: document.location.href,
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const pacmanClient = mkPacmanClient({
|
|
58
|
-
rockmanId: window.pac_analytics.visitor.rockmanId,
|
|
59
|
-
serverUrl: process.env.pacman_server,
|
|
60
|
-
impressionNumber: 1,
|
|
61
|
-
signalInterval: 1000 // in milliseconds
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
return {
|
|
65
|
-
sendOptInFlowEvent:pacmanClient.sendOptInFlowEvent,
|
|
66
|
-
...pacmanClient.trackerFlowEvents
|
|
67
|
-
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export default (url: string, paramName: string) => {
|
|
2
|
-
var name = paramName.replace(/[\[\]]/g, "\\$&");
|
|
3
|
-
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)", "i"),
|
|
4
|
-
results = regex.exec(url);
|
|
5
|
-
if (!results) return null;
|
|
6
|
-
if (!results[2]) return "";
|
|
7
|
-
return decodeURIComponent(results[2].replace(/\+/g, " "));
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export function updateUrlParameter(uri: string, key: string, value: string) {
|
|
11
|
-
// remove the hash part before operating on the uri
|
|
12
|
-
var i = uri.indexOf('#');
|
|
13
|
-
var hash = i === -1 ? '' : uri.substr(i);
|
|
14
|
-
uri = i === -1 ? uri : uri.substr(0, i);
|
|
15
|
-
|
|
16
|
-
var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
|
|
17
|
-
var separator = uri.indexOf('?') !== -1 ? "&" : "?";
|
|
18
|
-
if (uri.match(re)) {
|
|
19
|
-
uri = uri.replace(re, '$1' + key + "=" + value + '$2');
|
|
20
|
-
} else {
|
|
21
|
-
uri = uri + separator + key + "=" + value;
|
|
22
|
-
}
|
|
23
|
-
return uri + hash; // finally append the hash as well
|
|
24
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import * as RDS from "../../common-types/RemoteDataState";
|
|
2
|
-
import { AppThunk } from "../../common-types/AppThunk";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export type IWithMultiKeywordShortcode = IKeywordShortcode & {
|
|
6
|
-
type?:string,
|
|
7
|
-
data?:Array<IKeywordShortcode>
|
|
8
|
-
}
|
|
9
|
-
export type IClick2smsFlowCurrentState = {
|
|
10
|
-
type:"LOAD_OC2SMS";
|
|
11
|
-
result:RDS.RemoteDataState<string, IWithMultiKeywordShortcode>
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export type MSISDNEntryErrorTypes =
|
|
16
|
-
| "AlreadySubscribed"
|
|
17
|
-
| "UnknownError"
|
|
18
|
-
| "InvalidMSISDN"
|
|
19
|
-
| "UnexpectedState";
|
|
20
|
-
export type ILOADOC2SMSFailure = {
|
|
21
|
-
errorType: MSISDNEntryErrorTypes;
|
|
22
|
-
error: any;
|
|
23
|
-
productUrl?:string;
|
|
24
|
-
};
|
|
25
|
-
export type ILOADOC2SMSSuccess = IKeywordShortcode
|
|
26
|
-
|
|
27
|
-
export type ILoadOc2click2smsPayload = {
|
|
28
|
-
type:"LOAD_OC2SMS";
|
|
29
|
-
payload: RDS.RemoteDataState<string, IWithMultiKeywordShortcode>;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
export interface IClick2smsFlowReducerState {
|
|
35
|
-
currentState:IClick2smsFlowCurrentState
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
export type IKeywordShortcode = {
|
|
40
|
-
keyword : string,
|
|
41
|
-
shortcode : string,
|
|
42
|
-
operator?: string,
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
type Config = {
|
|
46
|
-
host?: string;
|
|
47
|
-
country?: string;
|
|
48
|
-
slug?: string;
|
|
49
|
-
automaticallySubmitAllOperators?: boolean;
|
|
50
|
-
operators?: string[];
|
|
51
|
-
}
|
|
52
|
-
export type IConfig =
|
|
53
|
-
| { tag: "tallyman"} & Config
|
|
54
|
-
| { tag: "keywordAndShortCode" } & IKeywordShortcode & Config
|
|
55
|
-
| { tag: "keyword" } & Config
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
export type SingleSubmissionResult = IKeywordShortcode & {
|
|
60
|
-
type: "SingleSubmissionResult"
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export type MultiOperatorSubmissionResult = {
|
|
64
|
-
type: "MultiOperatorSubmissionResult",
|
|
65
|
-
data: Array<IKeywordShortcode>
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
export type ICheckSubscriptionResult = {
|
|
70
|
-
success: false;
|
|
71
|
-
rockman_id: string;
|
|
72
|
-
message: string;
|
|
73
|
-
} | {
|
|
74
|
-
success: true;
|
|
75
|
-
msisdn: string;
|
|
76
|
-
product_url?: string;
|
|
77
|
-
rockman_id: string;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export type IClick2SmsActions =
|
|
81
|
-
{
|
|
82
|
-
type: "LOAD_OC2SMS";
|
|
83
|
-
payload:ILoadOc2click2smsPayload;
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
export type IFetchResult = { "success": boolean, "uid": string, "shortcode": string, "keyword": string, displayKeyword:string, message?: string }
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
export type IClick2SmsFlowActionMaps = {
|
|
92
|
-
loadOc2sms:()=>AppThunk;
|
|
93
|
-
}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
// LIBRARIES
|
|
2
|
-
import * as RDS from "../../common-types/RemoteDataState";
|
|
3
|
-
|
|
4
|
-
import { ILOADOC2SMSFailure, ILOADOC2SMSSuccess, IClick2smsFlowReducerState, IClick2SmsFlowActionMaps, IWithMultiKeywordShortcode, IClick2SmsActions, ILoadOc2click2smsPayload, SingleSubmissionResult, MultiOperatorSubmissionResult } from "./Click2smsTypes";
|
|
5
|
-
import { AppThunk } from "../../common-types/AppThunk";
|
|
6
|
-
import { genericHandler } from "../strategy";
|
|
7
|
-
import load from "./utils";
|
|
8
|
-
|
|
9
|
-
//ACTION CREATORS
|
|
10
|
-
export function loadOc2sms():AppThunk{
|
|
11
|
-
return async (dispatch, store)=>{
|
|
12
|
-
const {currentState} = store().strategy
|
|
13
|
-
|
|
14
|
-
if(currentState.type === "CLICK2SMS"){
|
|
15
|
-
|
|
16
|
-
const maybeConfig = currentState.result.config;
|
|
17
|
-
|
|
18
|
-
try {
|
|
19
|
-
|
|
20
|
-
dispatch({
|
|
21
|
-
type: "LOAD_OC2SMS",
|
|
22
|
-
payload:{
|
|
23
|
-
type:"LOAD_OC2SMS",
|
|
24
|
-
result: RDS.Loading()
|
|
25
|
-
}
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
//@ts-ignore
|
|
29
|
-
if(!!maybeConfig && maybeConfig.tag == "keywordAndShortCode") {
|
|
30
|
-
dispatch({
|
|
31
|
-
type: "LOAD_OC2SMS",
|
|
32
|
-
payload:{
|
|
33
|
-
type:"LOAD_OC2SMS",
|
|
34
|
-
result:RDS.Success({
|
|
35
|
-
type:"SingleSubmissionResult",
|
|
36
|
-
...maybeConfig
|
|
37
|
-
})
|
|
38
|
-
}
|
|
39
|
-
})
|
|
40
|
-
//@ts-ignore
|
|
41
|
-
}else if((!!maybeConfig && maybeConfig.tag != "keyword") || !maybeConfig){
|
|
42
|
-
//@ts-ignore
|
|
43
|
-
load(window, maybeConfig).then(
|
|
44
|
-
(x:SingleSubmissionResult | MultiOperatorSubmissionResult) => dispatch({
|
|
45
|
-
type: "LOAD_OC2SMS",
|
|
46
|
-
payload:{
|
|
47
|
-
type: "LOAD_OC2SMS",
|
|
48
|
-
result:RDS.Success(x)
|
|
49
|
-
}
|
|
50
|
-
})
|
|
51
|
-
).catch(
|
|
52
|
-
(e:Error) => dispatch({
|
|
53
|
-
type: "LOAD_OC2SMS",
|
|
54
|
-
payload:{
|
|
55
|
-
type: "LOAD_OC2SMS",
|
|
56
|
-
result:RDS.Failure(e.toString())
|
|
57
|
-
}
|
|
58
|
-
})
|
|
59
|
-
)
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
} catch (ex) {
|
|
64
|
-
console.warn(ex)
|
|
65
|
-
dispatch({
|
|
66
|
-
type: "LOAD_OC2SMS",
|
|
67
|
-
payload:{
|
|
68
|
-
type: "LOAD_OC2SMS",
|
|
69
|
-
result:RDS.Failure(ex.toString())
|
|
70
|
-
}
|
|
71
|
-
})
|
|
72
|
-
}
|
|
73
|
-
}else{
|
|
74
|
-
dispatch({
|
|
75
|
-
type: "LOAD_OC2SMS",
|
|
76
|
-
payload:{
|
|
77
|
-
type: "LOAD_OC2SMS",
|
|
78
|
-
result:RDS.Failure("Unexpected state")
|
|
79
|
-
}
|
|
80
|
-
})
|
|
81
|
-
throw "Unexpected state"
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const initialState:IClick2smsFlowReducerState = {
|
|
88
|
-
currentState:{
|
|
89
|
-
type: "LOAD_OC2SMS",
|
|
90
|
-
result: RDS.NothingYet<string, IWithMultiKeywordShortcode>()
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
export const Click2smsFlowActionMaps:IClick2SmsFlowActionMaps = {
|
|
95
|
-
loadOc2sms:loadOc2sms
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export default function Click2smsFlowReducer(state = initialState, action:IClick2SmsActions) {
|
|
99
|
-
switch (action.type) {
|
|
100
|
-
case "LOAD_OC2SMS":
|
|
101
|
-
return genericHandler<IClick2smsFlowReducerState, ILoadOc2click2smsPayload>(state, action.payload)
|
|
102
|
-
default:
|
|
103
|
-
return state;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { IConfig, SingleSubmissionResult, IKeywordShortcode, IFetchResult, ICheckSubscriptionResult, MultiOperatorSubmissionResult } from "./Click2smsTypes"
|
|
2
|
-
import IError from "../../common-types/IError"
|
|
3
|
-
import { loop } from "../strategy/utils"
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
async function loadOnce(window: Window, maybeConfig: IConfig, operator?:string, keyword?: string, shortcode?: string): Promise<SingleSubmissionResult> {
|
|
7
|
-
|
|
8
|
-
if(!!maybeConfig && maybeConfig.tag == "keywordAndShortCode") {
|
|
9
|
-
const {keyword, shortcode} = maybeConfig
|
|
10
|
-
return {
|
|
11
|
-
type: "SingleSubmissionResult",
|
|
12
|
-
...{keyword, shortcode} as IKeywordShortcode
|
|
13
|
-
}
|
|
14
|
-
} else {
|
|
15
|
-
const offer = window.pac_analytics.visitor.offer
|
|
16
|
-
const config = {offer:window.pac_analytics.visitor.offer, ...maybeConfig}
|
|
17
|
-
|
|
18
|
-
const { host, country, slug } = config
|
|
19
|
-
const rockmanId = window.pac_analytics.visitor.rockmanId
|
|
20
|
-
const search = window.location.search.substr(1) || ''
|
|
21
|
-
const result: IFetchResult = await window.tallymanApi.oc2sms(host, country, slug, offer, rockmanId, keyword, operator, search)
|
|
22
|
-
if(!result.success) {
|
|
23
|
-
throw result.message;
|
|
24
|
-
} else {
|
|
25
|
-
return {
|
|
26
|
-
type:"SingleSubmissionResult",
|
|
27
|
-
...{keyword: `${keyword || result.displayKeyword}${!!result.uid ? ' ' + result.uid : ''}`, shortcode: result.shortcode}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
type Either<L, R> = { type: 'left', value: L } | {type: 'right', value: R}
|
|
35
|
-
function right<L, R>(r: R) {
|
|
36
|
-
return {type: 'right', value: r} as Either<L, R>
|
|
37
|
-
}
|
|
38
|
-
function left<L, R>(l: L) {
|
|
39
|
-
return { type: 'left', value: l } as Either<L, R>
|
|
40
|
-
}
|
|
41
|
-
function foldEither<L, R, T>(left: (l:L) => T, right: (r:R) => T, either: Either<L, R>) : T {
|
|
42
|
-
return either.type == 'left'
|
|
43
|
-
? left(either.value)
|
|
44
|
-
: right(either.value)
|
|
45
|
-
}
|
|
46
|
-
async function loadForMultipleOperators(window: Window, maybeConfig: IConfig, operators: string[], keyword?: string, shortcode?:string): Promise<MultiOperatorSubmissionResult> {
|
|
47
|
-
|
|
48
|
-
const results = Promise.all(operators.map(async o => {
|
|
49
|
-
try {
|
|
50
|
-
const singleResult = await loadOnce(window, maybeConfig, o, keyword, shortcode)
|
|
51
|
-
return right({...singleResult, operator: o})
|
|
52
|
-
} catch (error) {
|
|
53
|
-
return left(error)
|
|
54
|
-
}
|
|
55
|
-
}))
|
|
56
|
-
|
|
57
|
-
const finalResults = await Promise.resolve(results);
|
|
58
|
-
if (finalResults.every(r => r.type == 'left')) {
|
|
59
|
-
// no submission worked
|
|
60
|
-
throw finalResults[0].value;
|
|
61
|
-
}
|
|
62
|
-
else{
|
|
63
|
-
const arrResult:Array<IKeywordShortcode> = [];
|
|
64
|
-
finalResults.map((obj)=>{
|
|
65
|
-
if(obj.type == 'right'){
|
|
66
|
-
const { keyword, shortcode, operator } = obj.value as IKeywordShortcode
|
|
67
|
-
arrResult.push({keyword, shortcode, operator })
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
return {
|
|
72
|
-
type:"MultiOperatorSubmissionResult",
|
|
73
|
-
data: arrResult
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
export default async function load(window: Window, maybeConfig: IConfig, keyword?: string, shortcode?: string): Promise<SingleSubmissionResult | MultiOperatorSubmissionResult> {
|
|
80
|
-
if (!!maybeConfig && maybeConfig.tag == "keywordAndShortCode") {
|
|
81
|
-
return {
|
|
82
|
-
type: "SingleSubmissionResult",
|
|
83
|
-
...{ keyword:maybeConfig.keyword, shortcode:maybeConfig.shortcode } as IKeywordShortcode
|
|
84
|
-
}
|
|
85
|
-
} else if (!!maybeConfig && maybeConfig.tag == "keyword") {
|
|
86
|
-
return load1(window, maybeConfig, keyword, shortcode)
|
|
87
|
-
} else {
|
|
88
|
-
return load1(window, maybeConfig, null, null)
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export async function load1(window: Window, maybeConfig: IConfig, keyword?: string, shortcode?: string): Promise<SingleSubmissionResult | MultiOperatorSubmissionResult> {
|
|
93
|
-
const config = {offer:window.pac_analytics.visitor.offer, ...maybeConfig}
|
|
94
|
-
|
|
95
|
-
if(true == config.automaticallySubmitAllOperators && !!config.operators && config.operators.length > 0) {
|
|
96
|
-
return loadForMultipleOperators(window, maybeConfig, config.operators, keyword, shortcode)
|
|
97
|
-
} else {
|
|
98
|
-
|
|
99
|
-
const singleOperator = (maybeConfig.operators && maybeConfig.operators.length > 0) ? maybeConfig.operators[0] : null;
|
|
100
|
-
return loadOnce(window, maybeConfig, singleOperator, keyword, shortcode)
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export async function checkSubscription(window: Window, maybeConfig: IConfig): Promise<string> {
|
|
105
|
-
const config = {offer:window.pac_analytics.visitor.offer, ...maybeConfig}
|
|
106
|
-
|
|
107
|
-
const { host } = config
|
|
108
|
-
|
|
109
|
-
const rockmanId = window.pac_analytics.visitor.rockmanId
|
|
110
|
-
const check : () => Promise<ICheckSubscriptionResult> = () => window.tallymanApi.checkSubscriptionByRockmanIdOnly(host, rockmanId)
|
|
111
|
-
const checkResult: ICheckSubscriptionResult = await loop(
|
|
112
|
-
check,
|
|
113
|
-
60,
|
|
114
|
-
r => r.success,
|
|
115
|
-
0
|
|
116
|
-
)
|
|
117
|
-
|
|
118
|
-
if(true === checkResult.success) {
|
|
119
|
-
window.location.href = checkResult.product_url;
|
|
120
|
-
return checkResult.product_url || null
|
|
121
|
-
} else {
|
|
122
|
-
const error = new Error(`${"SubscriptionFailed"}:\n${checkResult.message}`) as IError & {type:string}
|
|
123
|
-
error['type'] = "SubscriptionFailed";
|
|
124
|
-
throw error
|
|
125
|
-
}
|
|
126
|
-
}
|