@convertcom/js-sdk-rules 2.0.0 → 2.1.2
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/README.md +2 -2
- package/lib/enums/index.d.ts +26 -0
- package/lib/enums/src/bucketing-error.d.ts +9 -0
- package/lib/enums/src/conversion-setting-key.d.ts +9 -0
- package/lib/enums/src/data-enitites.d.ts +16 -0
- package/lib/enums/src/dictionary.d.ts +68 -0
- package/lib/enums/src/do-not-track.d.ts +12 -0
- package/lib/enums/src/entity-type.d.ts +15 -0
- package/lib/enums/src/feature-status.d.ts +10 -0
- package/lib/enums/src/goal-data-key.d.ts +11 -0
- package/lib/enums/src/log-level.d.ts +14 -0
- package/lib/enums/src/log-method.d.ts +14 -0
- package/lib/enums/src/project-type.d.ts +10 -0
- package/lib/enums/src/rule-error.d.ts +10 -0
- package/lib/enums/src/segments/browser-type.d.ts +17 -0
- package/lib/enums/src/segments/device-type.d.ts +16 -0
- package/lib/enums/src/segments/segments-keys.d.ts +15 -0
- package/lib/enums/src/segments/source-type.d.ts +12 -0
- package/lib/enums/src/segments/visitor-type.d.ts +10 -0
- package/lib/enums/src/system-events.d.ts +22 -0
- package/lib/enums/src/variable-types.d.ts +7 -0
- package/lib/enums/src/variation-change-type.d.ts +14 -0
- package/lib/index.d.ts +5 -4
- package/lib/index.js +767 -30
- package/lib/index.js.map +1 -1
- package/lib/index.min.js +1 -1
- package/lib/index.min.js.map +1 -1
- package/lib/index.min.mjs +1 -1
- package/lib/index.min.mjs.map +1 -1
- package/lib/index.mjs +743 -6
- package/lib/index.mjs.map +1 -1
- package/lib/legacy/index.js +798 -140
- package/lib/legacy/index.js.map +1 -1
- package/lib/legacy/index.min.js +1 -1
- package/lib/legacy/index.min.js.map +1 -1
- package/lib/logger/index.d.ts +8 -0
- package/lib/logger/src/interfaces/log-client.d.ts +13 -0
- package/lib/logger/src/interfaces/log-manager.d.ts +18 -0
- package/lib/logger/src/interfaces/log-method-map.d.ts +15 -0
- package/lib/logger/src/log-manager.d.ts +64 -0
- package/lib/package.json +6 -6
- package/lib/rules/index.d.ts +8 -0
- package/lib/rules/src/interfaces/rule-manager.d.ts +15 -0
- package/lib/rules/src/rule-manager.d.ts +82 -0
- package/lib/types/index.d.ts +28 -0
- package/lib/types/src/BucketedFeature.d.ts +29 -0
- package/lib/types/src/BucketedVariation.d.ts +13 -0
- package/lib/types/src/BucketingAllocation.d.ts +10 -0
- package/lib/types/src/BucketingAttributes.d.ts +17 -0
- package/lib/types/src/BucketingHash.d.ts +11 -0
- package/lib/types/src/Config.d.ts +60 -0
- package/lib/types/src/ConversionAttributes.d.ts +13 -0
- package/lib/types/src/Entity.d.ts +8 -0
- package/lib/types/src/GoalData.d.ts +11 -0
- package/lib/types/src/IndentityField.d.ts +7 -0
- package/lib/types/src/Integration.d.ts +8 -0
- package/lib/types/src/LocationAttributes.d.ts +12 -0
- package/lib/types/src/Path.d.ts +10 -0
- package/lib/types/src/RequireAtLeastOne.d.ts +3 -0
- package/lib/types/src/Rule.d.ts +13 -0
- package/lib/types/src/SegmentsAttributes.d.ts +9 -0
- package/lib/types/src/StoreData.d.ts +13 -0
- package/lib/types/src/TrackingEvent.d.ts +14 -0
- package/lib/types/src/VariableType.d.ts +8 -0
- package/lib/types/src/Visitor.d.ts +12 -0
- package/lib/types/src/VisitorsQueue.d.ts +14 -0
- package/lib/types/src/config/index.d.ts +1 -0
- package/lib/types/src/config/types.gen.d.ts +2387 -0
- package/lib/utils/index.d.ts +14 -0
- package/lib/utils/src/array-utils.d.ts +11 -0
- package/lib/utils/src/comparisons.d.ts +22 -0
- package/lib/utils/src/data-store.d.ts +39 -0
- package/lib/utils/src/file-logger.d.ts +40 -0
- package/lib/utils/src/http-client.d.ts +115 -0
- package/lib/utils/src/object-utils.d.ts +35 -0
- package/lib/utils/src/string-utils.d.ts +32 -0
- package/lib/utils/src/types-utils.d.ts +12 -0
- package/package.json +35 -31
package/lib/index.js
CHANGED
|
@@ -1,7 +1,738 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
/*!
|
|
4
|
+
* Convert JS SDK
|
|
5
|
+
* Version 1.0.0
|
|
6
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
7
|
+
* License Apache-2.0
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Validates variable is array and not empty
|
|
11
|
+
* @param array
|
|
12
|
+
*/
|
|
13
|
+
function arrayNotEmpty(array) {
|
|
14
|
+
return Array.isArray(array) && array.length > 0;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/*!
|
|
18
|
+
* Convert JS SDK
|
|
19
|
+
* Version 1.0.0
|
|
20
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
21
|
+
* License Apache-2.0
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Returns the value at path of object
|
|
25
|
+
* TODO: get this utility to work with the optional mapper() helper from config
|
|
26
|
+
* @param {Record<string, any>} object
|
|
27
|
+
* @param {string} path
|
|
28
|
+
* @param {any=} defaultValue
|
|
29
|
+
* @param {boolean=} truthy Should Number 0 number and Boolean false be considered as normal value
|
|
30
|
+
* @return {any}
|
|
31
|
+
*/
|
|
32
|
+
/**
|
|
33
|
+
* Validates variable is object and not empty
|
|
34
|
+
* @param object
|
|
35
|
+
*/
|
|
36
|
+
function objectNotEmpty(object) {
|
|
37
|
+
return (typeof object === 'object' &&
|
|
38
|
+
object !== null &&
|
|
39
|
+
Object.keys(object).length > 0);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
var murmurhash = {exports: {}};
|
|
43
|
+
|
|
44
|
+
(function (module) {
|
|
45
|
+
(function(){
|
|
46
|
+
|
|
47
|
+
const createBuffer = (val) => new TextEncoder().encode(val);
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* JS Implementation of MurmurHash2
|
|
51
|
+
*
|
|
52
|
+
* @author <a href="mailto:gary.court@gmail.com">Gary Court</a>
|
|
53
|
+
* @see http://github.com/garycourt/murmurhash-js
|
|
54
|
+
* @author <a href="mailto:aappleby@gmail.com">Austin Appleby</a>
|
|
55
|
+
* @see http://sites.google.com/site/murmurhash/
|
|
56
|
+
*
|
|
57
|
+
* @param {Uint8Array | string} str ASCII only
|
|
58
|
+
* @param {number} seed Positive integer only
|
|
59
|
+
* @return {number} 32-bit positive integer hash
|
|
60
|
+
*/
|
|
61
|
+
function MurmurHashV2(str, seed) {
|
|
62
|
+
if (typeof str === 'string') str = createBuffer(str);
|
|
63
|
+
let
|
|
64
|
+
l = str.length,
|
|
65
|
+
h = seed ^ l,
|
|
66
|
+
i = 0,
|
|
67
|
+
k;
|
|
68
|
+
|
|
69
|
+
while (l >= 4) {
|
|
70
|
+
k =
|
|
71
|
+
((str[i] & 0xff)) |
|
|
72
|
+
((str[++i] & 0xff) << 8) |
|
|
73
|
+
((str[++i] & 0xff) << 16) |
|
|
74
|
+
((str[++i] & 0xff) << 24);
|
|
75
|
+
|
|
76
|
+
k = (((k & 0xffff) * 0x5bd1e995) + ((((k >>> 16) * 0x5bd1e995) & 0xffff) << 16));
|
|
77
|
+
k ^= k >>> 24;
|
|
78
|
+
k = (((k & 0xffff) * 0x5bd1e995) + ((((k >>> 16) * 0x5bd1e995) & 0xffff) << 16));
|
|
79
|
+
|
|
80
|
+
h = (((h & 0xffff) * 0x5bd1e995) + ((((h >>> 16) * 0x5bd1e995) & 0xffff) << 16)) ^ k;
|
|
81
|
+
|
|
82
|
+
l -= 4;
|
|
83
|
+
++i;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
switch (l) {
|
|
87
|
+
case 3: h ^= (str[i + 2] & 0xff) << 16;
|
|
88
|
+
case 2: h ^= (str[i + 1] & 0xff) << 8;
|
|
89
|
+
case 1: h ^= (str[i] & 0xff);
|
|
90
|
+
h = (((h & 0xffff) * 0x5bd1e995) + ((((h >>> 16) * 0x5bd1e995) & 0xffff) << 16));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
h ^= h >>> 13;
|
|
94
|
+
h = (((h & 0xffff) * 0x5bd1e995) + ((((h >>> 16) * 0x5bd1e995) & 0xffff) << 16));
|
|
95
|
+
h ^= h >>> 15;
|
|
96
|
+
|
|
97
|
+
return h >>> 0;
|
|
98
|
+
}
|
|
99
|
+
/*
|
|
100
|
+
* JS Implementation of MurmurHash3 (r136) (as of May 20, 2011)
|
|
101
|
+
*
|
|
102
|
+
* @author <a href="mailto:gary.court@gmail.com">Gary Court</a>
|
|
103
|
+
* @see http://github.com/garycourt/murmurhash-js
|
|
104
|
+
* @author <a href="mailto:aappleby@gmail.com">Austin Appleby</a>
|
|
105
|
+
* @see http://sites.google.com/site/murmurhash/
|
|
106
|
+
*
|
|
107
|
+
* @param {Uint8Array | string} key ASCII only
|
|
108
|
+
* @param {number} seed Positive integer only
|
|
109
|
+
* @return {number} 32-bit positive integer hash
|
|
110
|
+
*/
|
|
111
|
+
function MurmurHashV3(key, seed) {
|
|
112
|
+
if (typeof key === 'string') key = createBuffer(key);
|
|
113
|
+
|
|
114
|
+
let remainder, bytes, h1, h1b, c1, c2, k1, i;
|
|
115
|
+
|
|
116
|
+
remainder = key.length & 3; // key.length % 4
|
|
117
|
+
bytes = key.length - remainder;
|
|
118
|
+
h1 = seed;
|
|
119
|
+
c1 = 0xcc9e2d51;
|
|
120
|
+
c2 = 0x1b873593;
|
|
121
|
+
i = 0;
|
|
122
|
+
|
|
123
|
+
while (i < bytes) {
|
|
124
|
+
k1 =
|
|
125
|
+
((key[i] & 0xff)) |
|
|
126
|
+
((key[++i] & 0xff) << 8) |
|
|
127
|
+
((key[++i] & 0xff) << 16) |
|
|
128
|
+
((key[++i] & 0xff) << 24);
|
|
129
|
+
++i;
|
|
130
|
+
|
|
131
|
+
k1 = ((((k1 & 0xffff) * c1) + ((((k1 >>> 16) * c1) & 0xffff) << 16))) & 0xffffffff;
|
|
132
|
+
k1 = (k1 << 15) | (k1 >>> 17);
|
|
133
|
+
k1 = ((((k1 & 0xffff) * c2) + ((((k1 >>> 16) * c2) & 0xffff) << 16))) & 0xffffffff;
|
|
134
|
+
|
|
135
|
+
h1 ^= k1;
|
|
136
|
+
h1 = (h1 << 13) | (h1 >>> 19);
|
|
137
|
+
h1b = ((((h1 & 0xffff) * 5) + ((((h1 >>> 16) * 5) & 0xffff) << 16))) & 0xffffffff;
|
|
138
|
+
h1 = (((h1b & 0xffff) + 0x6b64) + ((((h1b >>> 16) + 0xe654) & 0xffff) << 16));
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
k1 = 0;
|
|
142
|
+
|
|
143
|
+
switch (remainder) {
|
|
144
|
+
case 3: k1 ^= (key[i + 2] & 0xff) << 16;
|
|
145
|
+
case 2: k1 ^= (key[i + 1] & 0xff) << 8;
|
|
146
|
+
case 1: k1 ^= (key[i] & 0xff);
|
|
147
|
+
|
|
148
|
+
k1 = (((k1 & 0xffff) * c1) + ((((k1 >>> 16) * c1) & 0xffff) << 16)) & 0xffffffff;
|
|
149
|
+
k1 = (k1 << 15) | (k1 >>> 17);
|
|
150
|
+
k1 = (((k1 & 0xffff) * c2) + ((((k1 >>> 16) * c2) & 0xffff) << 16)) & 0xffffffff;
|
|
151
|
+
h1 ^= k1;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
h1 ^= key.length;
|
|
155
|
+
|
|
156
|
+
h1 ^= h1 >>> 16;
|
|
157
|
+
h1 = (((h1 & 0xffff) * 0x85ebca6b) + ((((h1 >>> 16) * 0x85ebca6b) & 0xffff) << 16)) & 0xffffffff;
|
|
158
|
+
h1 ^= h1 >>> 13;
|
|
159
|
+
h1 = ((((h1 & 0xffff) * 0xc2b2ae35) + ((((h1 >>> 16) * 0xc2b2ae35) & 0xffff) << 16))) & 0xffffffff;
|
|
160
|
+
h1 ^= h1 >>> 16;
|
|
161
|
+
|
|
162
|
+
return h1 >>> 0;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const murmur = MurmurHashV3;
|
|
166
|
+
murmur.v2 = MurmurHashV2;
|
|
167
|
+
murmur.v3 = MurmurHashV3;
|
|
168
|
+
|
|
169
|
+
{
|
|
170
|
+
module.exports = murmur;
|
|
171
|
+
}
|
|
172
|
+
}());
|
|
173
|
+
} (murmurhash));
|
|
174
|
+
|
|
175
|
+
/*!
|
|
176
|
+
* Convert JS SDK
|
|
177
|
+
* Version 1.0.0
|
|
178
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
179
|
+
* License Apache-2.0
|
|
180
|
+
*/
|
|
181
|
+
/**
|
|
182
|
+
* String formatter tool. Transforms a space-separated string into camelCase
|
|
183
|
+
* @param {string} input
|
|
184
|
+
* @return {string}
|
|
185
|
+
*/
|
|
186
|
+
function camelCase(input) {
|
|
187
|
+
return input
|
|
188
|
+
.replace(/(?:^\w|[A-Z]|\b\w)/g, function (word, index) {
|
|
189
|
+
return index === 0 ? word.toLowerCase() : word.toUpperCase();
|
|
190
|
+
})
|
|
191
|
+
.replace(/\s+/g, '');
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Check if a value is numeric
|
|
195
|
+
* @param {string | number} value
|
|
196
|
+
* @returns {boolean}
|
|
197
|
+
*/
|
|
198
|
+
function isNumeric(value) {
|
|
199
|
+
if (typeof value === 'number') {
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
const number = parseFloat(String(value));
|
|
203
|
+
return Number.isFinite(number) && !isNaN(number);
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Convert a string to a number
|
|
207
|
+
* @param {string | number} value
|
|
208
|
+
* @returns {number}
|
|
209
|
+
*/
|
|
210
|
+
function toNumber(value) {
|
|
211
|
+
if (typeof value === 'number') {
|
|
212
|
+
return value;
|
|
213
|
+
}
|
|
214
|
+
const parts = String(value).split(',');
|
|
215
|
+
return parseFloat(parts[0] == '0'
|
|
216
|
+
? String(value).replace(/,/g, '.')
|
|
217
|
+
: String(value).replace(/,/g, ''));
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/*!
|
|
221
|
+
* Convert JS SDK
|
|
222
|
+
* Version 1.0.0
|
|
223
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
224
|
+
* License Apache-2.0
|
|
225
|
+
*/
|
|
226
|
+
var _a;
|
|
227
|
+
/**
|
|
228
|
+
* Comparison Processor. Provides comparison methods for rules validation
|
|
229
|
+
*/
|
|
230
|
+
class Comparisons {
|
|
231
|
+
static equals(value, testAgainst, negation) {
|
|
232
|
+
if (Array.isArray(value))
|
|
233
|
+
return this._returnNegationCheck(value.indexOf(testAgainst) !== -1, negation);
|
|
234
|
+
if (objectNotEmpty(value))
|
|
235
|
+
return this._returnNegationCheck(Object.keys(value).indexOf(String(testAgainst)) !== -1, negation);
|
|
236
|
+
value = String(value);
|
|
237
|
+
testAgainst = String(testAgainst);
|
|
238
|
+
value = value.valueOf().toLowerCase();
|
|
239
|
+
testAgainst = testAgainst.valueOf().toLowerCase();
|
|
240
|
+
return this._returnNegationCheck(value === testAgainst, negation);
|
|
241
|
+
}
|
|
242
|
+
static less(value, testAgainst, negation) {
|
|
243
|
+
value = isNumeric(value) ? toNumber(value) : value;
|
|
244
|
+
testAgainst = isNumeric(testAgainst) ? toNumber(testAgainst) : testAgainst;
|
|
245
|
+
if (typeof value !== typeof testAgainst) {
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
return this._returnNegationCheck(value < testAgainst, negation);
|
|
249
|
+
}
|
|
250
|
+
static lessEqual(value, testAgainst, negation) {
|
|
251
|
+
value = isNumeric(value) ? toNumber(value) : value;
|
|
252
|
+
testAgainst = isNumeric(testAgainst) ? toNumber(testAgainst) : testAgainst;
|
|
253
|
+
if (typeof value !== typeof testAgainst) {
|
|
254
|
+
return false;
|
|
255
|
+
}
|
|
256
|
+
return this._returnNegationCheck(value <= testAgainst, negation);
|
|
257
|
+
}
|
|
258
|
+
static contains(value, testAgainst, negation) {
|
|
259
|
+
value = String(value);
|
|
260
|
+
testAgainst = String(testAgainst);
|
|
261
|
+
value = value.valueOf().toLowerCase();
|
|
262
|
+
testAgainst = testAgainst.valueOf().toLowerCase();
|
|
263
|
+
if (testAgainst.replace(/^([\s]*)|([\s]*)$/g, '').length === 0) {
|
|
264
|
+
return this._returnNegationCheck(true, negation);
|
|
265
|
+
}
|
|
266
|
+
return this._returnNegationCheck(value.indexOf(testAgainst) !== -1, negation);
|
|
267
|
+
}
|
|
268
|
+
static isIn(values, testAgainst, negation = false, splitter = '|') {
|
|
269
|
+
const matchedValuesArray = String(values)
|
|
270
|
+
.split(splitter)
|
|
271
|
+
.map((item) => {
|
|
272
|
+
return String(item);
|
|
273
|
+
});
|
|
274
|
+
if (typeof testAgainst === 'string') {
|
|
275
|
+
testAgainst = testAgainst.split(splitter);
|
|
276
|
+
}
|
|
277
|
+
if (!Array.isArray(testAgainst)) {
|
|
278
|
+
testAgainst = [];
|
|
279
|
+
}
|
|
280
|
+
testAgainst = testAgainst.map((item) => {
|
|
281
|
+
return String(item).valueOf().toLowerCase();
|
|
282
|
+
});
|
|
283
|
+
for (let i = 0; i < matchedValuesArray.length; i++) {
|
|
284
|
+
if (testAgainst.indexOf(matchedValuesArray[i]) !== -1) {
|
|
285
|
+
return this._returnNegationCheck(true, negation);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
return this._returnNegationCheck(false, negation);
|
|
289
|
+
}
|
|
290
|
+
static startsWith(value, testAgainst, negation) {
|
|
291
|
+
value = String(value).valueOf().toLowerCase();
|
|
292
|
+
testAgainst = String(testAgainst).valueOf().toLowerCase();
|
|
293
|
+
return this._returnNegationCheck(value.indexOf(testAgainst) === 0, negation);
|
|
294
|
+
}
|
|
295
|
+
static endsWith(value, testAgainst, negation) {
|
|
296
|
+
value = String(value).valueOf().toLowerCase();
|
|
297
|
+
testAgainst = String(testAgainst).valueOf().toLowerCase();
|
|
298
|
+
return this._returnNegationCheck(value.indexOf(testAgainst, value.length - testAgainst.length) !== -1, negation);
|
|
299
|
+
}
|
|
300
|
+
static regexMatches(value, testAgainst, negation) {
|
|
301
|
+
value = String(value).valueOf().toLowerCase();
|
|
302
|
+
testAgainst = String(testAgainst).valueOf();
|
|
303
|
+
const regExp = new RegExp(testAgainst, 'i');
|
|
304
|
+
return this._returnNegationCheck(regExp.test(value), negation);
|
|
305
|
+
}
|
|
306
|
+
static _returnNegationCheck(value, negation = false) {
|
|
307
|
+
if (negation) {
|
|
308
|
+
return !value;
|
|
309
|
+
}
|
|
310
|
+
else {
|
|
311
|
+
return value;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
_a = Comparisons;
|
|
316
|
+
Comparisons.equalsNumber = _a.equals;
|
|
317
|
+
Comparisons.matches = _a.equals;
|
|
318
|
+
|
|
319
|
+
/******************************************************************************
|
|
320
|
+
Copyright (c) Microsoft Corporation.
|
|
321
|
+
|
|
322
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
323
|
+
purpose with or without fee is hereby granted.
|
|
324
|
+
|
|
325
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
326
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
327
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
328
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
329
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
330
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
331
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
332
|
+
***************************************************************************** */
|
|
333
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
337
|
+
var e = new Error(message);
|
|
338
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
/*!
|
|
342
|
+
* Convert JS SDK
|
|
343
|
+
* Version 1.0.0
|
|
344
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
345
|
+
* License Apache-2.0
|
|
346
|
+
*/
|
|
347
|
+
var BucketingError;
|
|
348
|
+
(function (BucketingError) {
|
|
349
|
+
BucketingError["VARIAION_NOT_DECIDED"] = "convert.com_variation_not_decided";
|
|
350
|
+
})(BucketingError || (BucketingError = {}));
|
|
351
|
+
|
|
352
|
+
/*!
|
|
353
|
+
* Convert JS SDK
|
|
354
|
+
* Version 1.0.0
|
|
355
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
356
|
+
* License Apache-2.0
|
|
357
|
+
*/
|
|
358
|
+
var ConversionSettingKey;
|
|
359
|
+
(function (ConversionSettingKey) {
|
|
360
|
+
ConversionSettingKey["FORCE_MULTIPLE_TRANSACTIONS"] = "forceMultipleTransactions";
|
|
361
|
+
})(ConversionSettingKey || (ConversionSettingKey = {}));
|
|
362
|
+
|
|
363
|
+
/*!
|
|
364
|
+
* Convert JS SDK
|
|
365
|
+
* Version 1.0.0
|
|
366
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
367
|
+
* License Apache-2.0
|
|
368
|
+
*/
|
|
369
|
+
const ERROR_MESSAGES = {
|
|
370
|
+
SDK_KEY_MISSING: 'SDK key is missing',
|
|
371
|
+
DATA_OBJECT_MISSING: 'Data object is missing',
|
|
372
|
+
CONFIG_DATA_NOT_VALID: 'Config Data is not valid',
|
|
373
|
+
SDK_OR_DATA_OBJECT_REQUIRED: 'SDK key or Data object should be provided',
|
|
374
|
+
RULE_NOT_VALID: 'Provided rule is not valid',
|
|
375
|
+
RULE_DATA_NOT_VALID: 'Provided rule data is not valid',
|
|
376
|
+
RULE_MATCH_TYPE_NOT_SUPPORTED: 'Provided rule matching type "#" is not supported',
|
|
377
|
+
RULE_ERROR: 'Rule error',
|
|
378
|
+
DATA_STORE_NOT_VALID: 'DataStore object is not valid. It should contain get and set methods',
|
|
379
|
+
VISITOR_ID_REQUIRED: 'Visitor string string is not present',
|
|
380
|
+
GOAL_DATA_NOT_VALID: 'GoalData object is not valid',
|
|
381
|
+
UNABLE_TO_SELECT_BUCKET_FOR_VISITOR: 'Unable to bucket visitor',
|
|
382
|
+
UNABLE_TO_PERFORM_NETWORK_REQUEST: 'Unable to perform network request',
|
|
383
|
+
UNSUPPORTED_RESPONSE_TYPE: 'Unsupported response type'
|
|
384
|
+
};
|
|
385
|
+
const MESSAGES = {
|
|
386
|
+
CONFIG_DATA_UPDATED: 'Config Data updated',
|
|
387
|
+
CORE_CONSTRUCTOR: 'Core Manager constructor has been called',
|
|
388
|
+
CORE_INITIALIZED: 'Core Manager has been initialized',
|
|
389
|
+
EXPERIENCE_CONSTRUCTOR: 'Experience Manager constructor has been called',
|
|
390
|
+
EXPERIENCE_NOT_FOUND: 'Experience not found',
|
|
391
|
+
EXPERIENCE_ARCHIVED: 'Experience archived',
|
|
392
|
+
EXPERIENCE_ENVIRONMENT_NOT_MATCH: 'Experience environment does not match',
|
|
393
|
+
EXPERIENCE_RULES_MATCHED: 'Experience rules matched',
|
|
394
|
+
VARIATIONS_NOT_FOUND: 'Variations not found',
|
|
395
|
+
VARIATION_CHANGE_NOT_SUPPORTED: 'Variation change not supported',
|
|
396
|
+
FEATURE_CONSTRUCTOR: 'Feature Manager constructor has been called',
|
|
397
|
+
FEATURE_NOT_FOUND: 'Fullstack Feature not found',
|
|
398
|
+
FEATURE_VARIABLES_NOT_FOUND: 'Fullstack Feature Variables not found',
|
|
399
|
+
FEATURE_VARIABLES_TYPE_NOT_FOUND: 'Fullstack Feature Variables Type not found',
|
|
400
|
+
BUCKETING_CONSTRUCTOR: 'Bucketing Manager constructor has been called',
|
|
401
|
+
DATA_CONSTRUCTOR: 'Data Manager constructor has been called',
|
|
402
|
+
RULE_CONSTRUCTOR: 'Rule Manager constructor has been called',
|
|
403
|
+
PROCESSING_ENTITY: 'Processing #',
|
|
404
|
+
LOCATION_MATCH: 'Location # rule matched',
|
|
405
|
+
LOCATION_NOT_MATCH: 'Location does not match',
|
|
406
|
+
LOCATION_NOT_RESTRICTED: 'Location not restricted',
|
|
407
|
+
AUDIENCE_MATCH: 'Audience # rule matched',
|
|
408
|
+
AUDIENCE_NOT_MATCH: 'Audience does not match',
|
|
409
|
+
NON_PERMANENT_AUDIENCE_NOT_RESTRICTED: 'Non-Permanent Audience not restricted',
|
|
410
|
+
AUDIENCE_NOT_RESTRICTED: 'Audience not restricted',
|
|
411
|
+
SEGMENTATION_MATCH: 'Segmentation # rule matched',
|
|
412
|
+
SEGMENTATION_NOT_RESTRICTED: 'Segmentation not restricted',
|
|
413
|
+
RULE_NOT_MATCH: 'Rule does not match',
|
|
414
|
+
RULE_MATCH: 'Found matched rule at OR block #',
|
|
415
|
+
RULE_MATCH_AND: 'AND block rule macthed',
|
|
416
|
+
RULE_MATCH_START: 'About to evaluate rule #',
|
|
417
|
+
LOCATION_ACTIVATED: 'Location # activated',
|
|
418
|
+
LOCATION_DEACTIVATED: 'Location # deactivated',
|
|
419
|
+
BUCKETED_VISITOR_FOUND: 'Visitor is already bucketed for variation #',
|
|
420
|
+
BUCKETED_VISITOR_FORCED: 'Forcing variation #',
|
|
421
|
+
BUCKETED_VISITOR: 'Visitor is bucketed for variation #',
|
|
422
|
+
GOAL_NOT_FOUND: 'Goal not found',
|
|
423
|
+
GOAL_RULE_NOT_MATCH: 'Goal rule do not match',
|
|
424
|
+
GOAL_FOUND: 'Goal # already triggered',
|
|
425
|
+
SEGMENTS_NOT_FOUND: 'Segments not found',
|
|
426
|
+
SEGMENTS_RULE_NOT_MATCH: 'Segments rule do not match',
|
|
427
|
+
CUSTOM_SEGMENTS_KEY_FOUND: 'Custom segments key already set',
|
|
428
|
+
SEND_BEACON_SUCCESS: 'The user agent successfully queued the data for transfer',
|
|
429
|
+
RELEASING_QUEUE: 'Releasing event queue...'
|
|
430
|
+
};
|
|
431
|
+
|
|
432
|
+
/*!
|
|
433
|
+
* Convert JS SDK
|
|
434
|
+
* Version 1.0.0
|
|
435
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
436
|
+
* License Apache-2.0
|
|
437
|
+
*/
|
|
438
|
+
var DoNotTrack;
|
|
439
|
+
(function (DoNotTrack) {
|
|
440
|
+
DoNotTrack["OFF"] = "OFF";
|
|
441
|
+
DoNotTrack["EU_ONLY"] = "EU ONLY";
|
|
442
|
+
DoNotTrack["EEA_ONLY"] = "EEA ONLY";
|
|
443
|
+
DoNotTrack["WORLDWIDE"] = "Worldwide";
|
|
444
|
+
})(DoNotTrack || (DoNotTrack = {}));
|
|
445
|
+
|
|
446
|
+
/*!
|
|
447
|
+
* Convert JS SDK
|
|
448
|
+
* Version 1.0.0
|
|
449
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
450
|
+
* License Apache-2.0
|
|
451
|
+
*/
|
|
452
|
+
var EntityType;
|
|
453
|
+
(function (EntityType) {
|
|
454
|
+
EntityType["AUDIENCE"] = "audience";
|
|
455
|
+
EntityType["LOCATION"] = "location";
|
|
456
|
+
EntityType["SEGMENT"] = "segment";
|
|
457
|
+
EntityType["FEATURE"] = "feature";
|
|
458
|
+
EntityType["GOAL"] = "goal";
|
|
459
|
+
EntityType["EXPERIENCE"] = "experience";
|
|
460
|
+
EntityType["VARIATION"] = "variation";
|
|
461
|
+
})(EntityType || (EntityType = {}));
|
|
462
|
+
|
|
463
|
+
/*!
|
|
464
|
+
* Convert JS SDK
|
|
465
|
+
* Version 1.0.0
|
|
466
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
467
|
+
* License Apache-2.0
|
|
468
|
+
*/
|
|
469
|
+
var FeatureStatus;
|
|
470
|
+
(function (FeatureStatus) {
|
|
471
|
+
FeatureStatus["ENABLED"] = "enabled";
|
|
472
|
+
FeatureStatus["DISABLED"] = "disabled";
|
|
473
|
+
})(FeatureStatus || (FeatureStatus = {}));
|
|
474
|
+
|
|
475
|
+
/*!
|
|
476
|
+
* Convert JS SDK
|
|
477
|
+
* Version 1.0.0
|
|
478
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
479
|
+
* License Apache-2.0
|
|
480
|
+
*/
|
|
481
|
+
var GoalDataKey;
|
|
482
|
+
(function (GoalDataKey) {
|
|
483
|
+
GoalDataKey["AMOUNT"] = "amount";
|
|
484
|
+
GoalDataKey["PRODUCTS_COUNT"] = "productsCount";
|
|
485
|
+
GoalDataKey["TRANSACTION_ID"] = "transactionId";
|
|
486
|
+
})(GoalDataKey || (GoalDataKey = {}));
|
|
487
|
+
|
|
488
|
+
/*!
|
|
489
|
+
* Convert JS SDK
|
|
490
|
+
* Version 1.0.0
|
|
491
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
492
|
+
* License Apache-2.0
|
|
493
|
+
*/
|
|
494
|
+
var LogLevel;
|
|
495
|
+
(function (LogLevel) {
|
|
496
|
+
LogLevel[LogLevel["TRACE"] = 0] = "TRACE";
|
|
497
|
+
LogLevel[LogLevel["DEBUG"] = 1] = "DEBUG";
|
|
498
|
+
LogLevel[LogLevel["INFO"] = 2] = "INFO";
|
|
499
|
+
LogLevel[LogLevel["WARN"] = 3] = "WARN";
|
|
500
|
+
LogLevel[LogLevel["ERROR"] = 4] = "ERROR";
|
|
501
|
+
LogLevel[LogLevel["SILENT"] = 5] = "SILENT";
|
|
502
|
+
})(LogLevel || (LogLevel = {}));
|
|
503
|
+
|
|
504
|
+
/*!
|
|
505
|
+
* Convert JS SDK
|
|
506
|
+
* Version 1.0.0
|
|
507
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
508
|
+
* License Apache-2.0
|
|
509
|
+
*/
|
|
510
|
+
var LogMethod;
|
|
511
|
+
(function (LogMethod) {
|
|
512
|
+
LogMethod["LOG"] = "log";
|
|
513
|
+
LogMethod["TRACE"] = "trace";
|
|
514
|
+
LogMethod["DEBUG"] = "debug";
|
|
515
|
+
LogMethod["INFO"] = "info";
|
|
516
|
+
LogMethod["WARN"] = "warn";
|
|
517
|
+
LogMethod["ERROR"] = "error";
|
|
518
|
+
})(LogMethod || (LogMethod = {}));
|
|
519
|
+
|
|
520
|
+
/*!
|
|
521
|
+
* Convert JS SDK
|
|
522
|
+
* Version 1.0.0
|
|
523
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
524
|
+
* License Apache-2.0
|
|
525
|
+
*/
|
|
526
|
+
var ProjectType;
|
|
527
|
+
(function (ProjectType) {
|
|
528
|
+
ProjectType["WEB"] = "web";
|
|
529
|
+
ProjectType["FULLSTACK"] = "fullstack";
|
|
530
|
+
})(ProjectType || (ProjectType = {}));
|
|
531
|
+
|
|
532
|
+
/*!
|
|
533
|
+
* Convert JS SDK
|
|
534
|
+
* Version 1.0.0
|
|
535
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
536
|
+
* License Apache-2.0
|
|
537
|
+
*/
|
|
538
|
+
var RuleError;
|
|
539
|
+
(function (RuleError) {
|
|
540
|
+
RuleError["NO_DATA_FOUND"] = "convert.com_no_data_found";
|
|
541
|
+
RuleError["NEED_MORE_DATA"] = "convert.com_need_more_data";
|
|
542
|
+
})(RuleError || (RuleError = {}));
|
|
543
|
+
|
|
544
|
+
/*!
|
|
545
|
+
* Convert JS SDK
|
|
546
|
+
* Version 1.0.0
|
|
547
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
548
|
+
* License Apache-2.0
|
|
549
|
+
*/
|
|
550
|
+
/**
|
|
551
|
+
* SDK system events. Possible values: 'ready' | 'queue-released'
|
|
552
|
+
* or custom visitor's event
|
|
553
|
+
*/
|
|
554
|
+
var SystemEvents;
|
|
555
|
+
(function (SystemEvents) {
|
|
556
|
+
SystemEvents["READY"] = "ready";
|
|
557
|
+
SystemEvents["CONFIG_UPDATED"] = "config.updated";
|
|
558
|
+
SystemEvents["API_QUEUE_RELEASED"] = "api.queue.released";
|
|
559
|
+
SystemEvents["BUCKETING"] = "bucketing";
|
|
560
|
+
SystemEvents["CONVERSION"] = "conversion";
|
|
561
|
+
SystemEvents["SEGMENTS"] = "segments";
|
|
562
|
+
SystemEvents["LOCATION_ACTIVATED"] = "location.activated";
|
|
563
|
+
SystemEvents["LOCATION_DEACTIVATED"] = "location.deactivated";
|
|
564
|
+
SystemEvents["AUDIENCES"] = "audiences";
|
|
565
|
+
SystemEvents["DATA_STORE_QUEUE_RELEASED"] = "datastore.queue.released";
|
|
566
|
+
})(SystemEvents || (SystemEvents = {}));
|
|
567
|
+
|
|
568
|
+
/*!
|
|
569
|
+
* Convert JS SDK
|
|
570
|
+
* Version 1.0.0
|
|
571
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
572
|
+
* License Apache-2.0
|
|
573
|
+
*/
|
|
574
|
+
var VariationChangeType;
|
|
575
|
+
(function (VariationChangeType) {
|
|
576
|
+
VariationChangeType["RICH_STRUCTURE"] = "richStructure";
|
|
577
|
+
VariationChangeType["CUSTOM_CODE"] = "customCode";
|
|
578
|
+
VariationChangeType["DEFAULT_CODE"] = "defaultCode";
|
|
579
|
+
VariationChangeType["DEFAULT_CODE_MULTIPAGE"] = "defaultCodeMultipage";
|
|
580
|
+
VariationChangeType["DEFAULT_REDIRECT"] = "defaultRedirect";
|
|
581
|
+
VariationChangeType["FULLSTACK_FEATURE"] = "fullStackFeature";
|
|
582
|
+
})(VariationChangeType || (VariationChangeType = {}));
|
|
583
|
+
|
|
584
|
+
/*!
|
|
585
|
+
* Convert JS SDK
|
|
586
|
+
* Version 1.0.0
|
|
587
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
588
|
+
* License Apache-2.0
|
|
589
|
+
*/
|
|
590
|
+
var BrowserType;
|
|
591
|
+
(function (BrowserType) {
|
|
592
|
+
BrowserType["IE"] = "IE";
|
|
593
|
+
BrowserType["CH"] = "CH";
|
|
594
|
+
BrowserType["FF"] = "FF";
|
|
595
|
+
BrowserType["OP"] = "OP";
|
|
596
|
+
BrowserType["SF"] = "SF";
|
|
597
|
+
BrowserType["EDG"] = "EDG";
|
|
598
|
+
BrowserType["MO"] = "MO";
|
|
599
|
+
BrowserType["NS"] = "NS";
|
|
600
|
+
BrowserType["OTH"] = "OTH";
|
|
601
|
+
})(BrowserType || (BrowserType = {}));
|
|
602
|
+
|
|
603
|
+
/*!
|
|
604
|
+
* Convert JS SDK
|
|
605
|
+
* Version 1.0.0
|
|
606
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
607
|
+
* License Apache-2.0
|
|
608
|
+
*/
|
|
609
|
+
var DeviceType;
|
|
610
|
+
(function (DeviceType) {
|
|
611
|
+
DeviceType["ALLPH"] = "ALLPH";
|
|
612
|
+
DeviceType["IPH"] = "IPH";
|
|
613
|
+
DeviceType["OTHPH"] = "OTHPH";
|
|
614
|
+
DeviceType["ALLTAB"] = "ALLTAB";
|
|
615
|
+
DeviceType["IPAD"] = "IPAD";
|
|
616
|
+
DeviceType["OTHTAB"] = "OTHTAB";
|
|
617
|
+
DeviceType["DESK"] = "DESK";
|
|
618
|
+
DeviceType["OTHDEV"] = "OTHDEV";
|
|
619
|
+
})(DeviceType || (DeviceType = {}));
|
|
620
|
+
|
|
621
|
+
/*!
|
|
622
|
+
* Convert JS SDK
|
|
623
|
+
* Version 1.0.0
|
|
624
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
625
|
+
* License Apache-2.0
|
|
626
|
+
*/
|
|
627
|
+
var SegmentsKeys;
|
|
628
|
+
(function (SegmentsKeys) {
|
|
629
|
+
SegmentsKeys["COUNTRY"] = "country";
|
|
630
|
+
SegmentsKeys["BROWSER"] = "browser";
|
|
631
|
+
SegmentsKeys["DEVICES"] = "devices";
|
|
632
|
+
SegmentsKeys["SOURCE"] = "source";
|
|
633
|
+
SegmentsKeys["CAMPAIGN"] = "campaign";
|
|
634
|
+
SegmentsKeys["VISITOR_TYPE"] = "visitorType";
|
|
635
|
+
SegmentsKeys["CUSTOM_SEGMENTS"] = "customSegments";
|
|
636
|
+
})(SegmentsKeys || (SegmentsKeys = {}));
|
|
637
|
+
|
|
638
|
+
/*!
|
|
639
|
+
* Convert JS SDK
|
|
640
|
+
* Version 1.0.0
|
|
641
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
642
|
+
* License Apache-2.0
|
|
643
|
+
*/
|
|
644
|
+
var SourceType;
|
|
645
|
+
(function (SourceType) {
|
|
646
|
+
SourceType["CAMPAIGN"] = "campaign";
|
|
647
|
+
SourceType["SEARCH"] = "search";
|
|
648
|
+
SourceType["REFERRAL"] = "referral";
|
|
649
|
+
SourceType["DIRECT"] = "direct";
|
|
650
|
+
})(SourceType || (SourceType = {}));
|
|
651
|
+
|
|
652
|
+
/*!
|
|
653
|
+
* Convert JS SDK
|
|
654
|
+
* Version 1.0.0
|
|
655
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
656
|
+
* License Apache-2.0
|
|
657
|
+
*/
|
|
658
|
+
var VisitorType;
|
|
659
|
+
(function (VisitorType) {
|
|
660
|
+
VisitorType["NEW"] = "new";
|
|
661
|
+
VisitorType["RETURNING"] = "returning";
|
|
662
|
+
})(VisitorType || (VisitorType = {}));
|
|
663
|
+
|
|
664
|
+
/*!
|
|
665
|
+
* Convert JS SDK
|
|
666
|
+
* Version 1.0.0
|
|
667
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
668
|
+
* License Apache-2.0
|
|
669
|
+
*/
|
|
670
|
+
var HttpStatusCode;
|
|
671
|
+
(function (HttpStatusCode) {
|
|
672
|
+
HttpStatusCode[HttpStatusCode["Continue"] = 100] = "Continue";
|
|
673
|
+
HttpStatusCode[HttpStatusCode["SwitchingProtocols"] = 101] = "SwitchingProtocols";
|
|
674
|
+
HttpStatusCode[HttpStatusCode["Processing"] = 102] = "Processing";
|
|
675
|
+
HttpStatusCode[HttpStatusCode["EarlyHints"] = 103] = "EarlyHints";
|
|
676
|
+
HttpStatusCode[HttpStatusCode["Ok"] = 200] = "Ok";
|
|
677
|
+
HttpStatusCode[HttpStatusCode["Created"] = 201] = "Created";
|
|
678
|
+
HttpStatusCode[HttpStatusCode["Accepted"] = 202] = "Accepted";
|
|
679
|
+
HttpStatusCode[HttpStatusCode["NonAuthoritativeInformation"] = 203] = "NonAuthoritativeInformation";
|
|
680
|
+
HttpStatusCode[HttpStatusCode["NoContent"] = 204] = "NoContent";
|
|
681
|
+
HttpStatusCode[HttpStatusCode["ResetContent"] = 205] = "ResetContent";
|
|
682
|
+
HttpStatusCode[HttpStatusCode["PartialContent"] = 206] = "PartialContent";
|
|
683
|
+
HttpStatusCode[HttpStatusCode["MultiStatus"] = 207] = "MultiStatus";
|
|
684
|
+
HttpStatusCode[HttpStatusCode["AlreadyReported"] = 208] = "AlreadyReported";
|
|
685
|
+
HttpStatusCode[HttpStatusCode["ImUsed"] = 226] = "ImUsed";
|
|
686
|
+
HttpStatusCode[HttpStatusCode["MultipleChoices"] = 300] = "MultipleChoices";
|
|
687
|
+
HttpStatusCode[HttpStatusCode["MovedPermanently"] = 301] = "MovedPermanently";
|
|
688
|
+
HttpStatusCode[HttpStatusCode["Found"] = 302] = "Found";
|
|
689
|
+
HttpStatusCode[HttpStatusCode["SeeOther"] = 303] = "SeeOther";
|
|
690
|
+
HttpStatusCode[HttpStatusCode["NotModified"] = 304] = "NotModified";
|
|
691
|
+
HttpStatusCode[HttpStatusCode["UseProxy"] = 305] = "UseProxy";
|
|
692
|
+
HttpStatusCode[HttpStatusCode["Unused"] = 306] = "Unused";
|
|
693
|
+
HttpStatusCode[HttpStatusCode["TemporaryRedirect"] = 307] = "TemporaryRedirect";
|
|
694
|
+
HttpStatusCode[HttpStatusCode["PermanentRedirect"] = 308] = "PermanentRedirect";
|
|
695
|
+
HttpStatusCode[HttpStatusCode["BadRequest"] = 400] = "BadRequest";
|
|
696
|
+
HttpStatusCode[HttpStatusCode["Unauthorized"] = 401] = "Unauthorized";
|
|
697
|
+
HttpStatusCode[HttpStatusCode["PaymentRequired"] = 402] = "PaymentRequired";
|
|
698
|
+
HttpStatusCode[HttpStatusCode["Forbidden"] = 403] = "Forbidden";
|
|
699
|
+
HttpStatusCode[HttpStatusCode["NotFound"] = 404] = "NotFound";
|
|
700
|
+
HttpStatusCode[HttpStatusCode["MethodNotAllowed"] = 405] = "MethodNotAllowed";
|
|
701
|
+
HttpStatusCode[HttpStatusCode["NotAcceptable"] = 406] = "NotAcceptable";
|
|
702
|
+
HttpStatusCode[HttpStatusCode["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired";
|
|
703
|
+
HttpStatusCode[HttpStatusCode["RequestTimeout"] = 408] = "RequestTimeout";
|
|
704
|
+
HttpStatusCode[HttpStatusCode["Conflict"] = 409] = "Conflict";
|
|
705
|
+
HttpStatusCode[HttpStatusCode["Gone"] = 410] = "Gone";
|
|
706
|
+
HttpStatusCode[HttpStatusCode["LengthRequired"] = 411] = "LengthRequired";
|
|
707
|
+
HttpStatusCode[HttpStatusCode["PreconditionFailed"] = 412] = "PreconditionFailed";
|
|
708
|
+
HttpStatusCode[HttpStatusCode["PayloadTooLarge"] = 413] = "PayloadTooLarge";
|
|
709
|
+
HttpStatusCode[HttpStatusCode["UriTooLong"] = 414] = "UriTooLong";
|
|
710
|
+
HttpStatusCode[HttpStatusCode["UnsupportedMediaType"] = 415] = "UnsupportedMediaType";
|
|
711
|
+
HttpStatusCode[HttpStatusCode["RangeNotSatisfiable"] = 416] = "RangeNotSatisfiable";
|
|
712
|
+
HttpStatusCode[HttpStatusCode["ExpectationFailed"] = 417] = "ExpectationFailed";
|
|
713
|
+
HttpStatusCode[HttpStatusCode["ImATeapot"] = 418] = "ImATeapot";
|
|
714
|
+
HttpStatusCode[HttpStatusCode["MisdirectedRequest"] = 421] = "MisdirectedRequest";
|
|
715
|
+
HttpStatusCode[HttpStatusCode["UnprocessableEntity"] = 422] = "UnprocessableEntity";
|
|
716
|
+
HttpStatusCode[HttpStatusCode["Locked"] = 423] = "Locked";
|
|
717
|
+
HttpStatusCode[HttpStatusCode["FailedDependency"] = 424] = "FailedDependency";
|
|
718
|
+
HttpStatusCode[HttpStatusCode["TooEarly"] = 425] = "TooEarly";
|
|
719
|
+
HttpStatusCode[HttpStatusCode["UpgradeRequired"] = 426] = "UpgradeRequired";
|
|
720
|
+
HttpStatusCode[HttpStatusCode["PreconditionRequired"] = 428] = "PreconditionRequired";
|
|
721
|
+
HttpStatusCode[HttpStatusCode["TooManyRequests"] = 429] = "TooManyRequests";
|
|
722
|
+
HttpStatusCode[HttpStatusCode["RequestHeaderFieldsTooLarge"] = 431] = "RequestHeaderFieldsTooLarge";
|
|
723
|
+
HttpStatusCode[HttpStatusCode["UnavailableForLegalReasons"] = 451] = "UnavailableForLegalReasons";
|
|
724
|
+
HttpStatusCode[HttpStatusCode["InternalServerError"] = 500] = "InternalServerError";
|
|
725
|
+
HttpStatusCode[HttpStatusCode["NotImplemented"] = 501] = "NotImplemented";
|
|
726
|
+
HttpStatusCode[HttpStatusCode["BadGateway"] = 502] = "BadGateway";
|
|
727
|
+
HttpStatusCode[HttpStatusCode["ServiceUnavailable"] = 503] = "ServiceUnavailable";
|
|
728
|
+
HttpStatusCode[HttpStatusCode["GatewayTimeout"] = 504] = "GatewayTimeout";
|
|
729
|
+
HttpStatusCode[HttpStatusCode["HttpVersionNotSupported"] = 505] = "HttpVersionNotSupported";
|
|
730
|
+
HttpStatusCode[HttpStatusCode["VariantAlsoNegotiates"] = 506] = "VariantAlsoNegotiates";
|
|
731
|
+
HttpStatusCode[HttpStatusCode["InsufficientStorage"] = 507] = "InsufficientStorage";
|
|
732
|
+
HttpStatusCode[HttpStatusCode["LoopDetected"] = 508] = "LoopDetected";
|
|
733
|
+
HttpStatusCode[HttpStatusCode["NotExtended"] = 510] = "NotExtended";
|
|
734
|
+
HttpStatusCode[HttpStatusCode["NetworkAuthenticationRequired"] = 511] = "NetworkAuthenticationRequired";
|
|
735
|
+
})(HttpStatusCode || (HttpStatusCode = {}));
|
|
5
736
|
|
|
6
737
|
/*!
|
|
7
738
|
* Convert JS SDK
|
|
@@ -25,17 +756,17 @@ class RuleManager {
|
|
|
25
756
|
*/
|
|
26
757
|
constructor(config, { loggerManager } = {}) {
|
|
27
758
|
var _a, _b, _c, _d, _e;
|
|
28
|
-
this._comparisonProcessor =
|
|
759
|
+
this._comparisonProcessor = Comparisons;
|
|
29
760
|
this._negation = DEFAULT_NEGATION;
|
|
30
761
|
this._keys_case_sensitive = DEFAULT_KEYS_CASE_SENSITIVE;
|
|
31
762
|
this._loggerManager = loggerManager;
|
|
32
763
|
this._comparisonProcessor =
|
|
33
|
-
((_a = config === null || config === void 0 ? void 0 : config.rules) === null || _a === void 0 ? void 0 : _a.comparisonProcessor) ||
|
|
764
|
+
((_a = config === null || config === void 0 ? void 0 : config.rules) === null || _a === void 0 ? void 0 : _a.comparisonProcessor) || Comparisons;
|
|
34
765
|
this._negation = String(((_b = config === null || config === void 0 ? void 0 : config.rules) === null || _b === void 0 ? void 0 : _b.negation) || DEFAULT_NEGATION);
|
|
35
766
|
this._keys_case_sensitive =
|
|
36
767
|
((_c = config === null || config === void 0 ? void 0 : config.rules) === null || _c === void 0 ? void 0 : _c.keys_case_sensitive) || DEFAULT_KEYS_CASE_SENSITIVE;
|
|
37
768
|
this._mapper = (config === null || config === void 0 ? void 0 : config.mapper) || ((value) => value);
|
|
38
|
-
(_e = (_d = this._loggerManager) === null || _d === void 0 ? void 0 : _d.trace) === null || _e === void 0 ? void 0 : _e.call(_d, 'RuleManager()',
|
|
769
|
+
(_e = (_d = this._loggerManager) === null || _d === void 0 ? void 0 : _d.trace) === null || _e === void 0 ? void 0 : _e.call(_d, 'RuleManager()', MESSAGES.RULE_CONSTRUCTOR, this);
|
|
39
770
|
}
|
|
40
771
|
/**
|
|
41
772
|
* Setter for comparison processor
|
|
@@ -70,29 +801,32 @@ class RuleManager {
|
|
|
70
801
|
ruleSet: ruleSet
|
|
71
802
|
}));
|
|
72
803
|
if (logEntry) {
|
|
73
|
-
(_d = (_c = this._loggerManager) === null || _c === void 0 ? void 0 : _c.info) === null || _d === void 0 ? void 0 : _d.call(_c, 'RuleManager.isRuleMatched()',
|
|
804
|
+
(_d = (_c = this._loggerManager) === null || _c === void 0 ? void 0 : _c.info) === null || _d === void 0 ? void 0 : _d.call(_c, 'RuleManager.isRuleMatched()', MESSAGES.PROCESSING_ENTITY.replace('#', logEntry));
|
|
74
805
|
}
|
|
75
806
|
// Top OR level
|
|
76
807
|
let match;
|
|
77
808
|
if (Object.prototype.hasOwnProperty.call(ruleSet, 'OR') &&
|
|
78
|
-
|
|
809
|
+
arrayNotEmpty(ruleSet === null || ruleSet === void 0 ? void 0 : ruleSet.OR)) {
|
|
79
810
|
for (let i = 0, l = ruleSet.OR.length; i < l; i++) {
|
|
80
811
|
match = this._processAND(data, ruleSet.OR[i]);
|
|
81
|
-
if (
|
|
82
|
-
|
|
812
|
+
if (match === true) {
|
|
813
|
+
return match;
|
|
814
|
+
}
|
|
815
|
+
if (Object.values(RuleError).includes(match)) {
|
|
816
|
+
(_f = (_e = this._loggerManager) === null || _e === void 0 ? void 0 : _e.info) === null || _f === void 0 ? void 0 : _f.call(_e, 'RuleManager.isRuleMatched()', logEntry || '', ERROR_MESSAGES.RULE_ERROR);
|
|
83
817
|
}
|
|
84
818
|
else {
|
|
85
819
|
(_h = (_g = this._loggerManager) === null || _g === void 0 ? void 0 : _g.info) === null || _h === void 0 ? void 0 : _h.call(_g, 'RuleManager.isRuleMatched()', logEntry || '', match === false
|
|
86
|
-
?
|
|
87
|
-
:
|
|
88
|
-
}
|
|
89
|
-
if (match !== false) {
|
|
90
|
-
return match;
|
|
820
|
+
? MESSAGES.RULE_NOT_MATCH
|
|
821
|
+
: MESSAGES.RULE_MATCH.replace('#', String(i)));
|
|
91
822
|
}
|
|
92
823
|
}
|
|
824
|
+
if (match !== false) {
|
|
825
|
+
return match;
|
|
826
|
+
}
|
|
93
827
|
}
|
|
94
828
|
else {
|
|
95
|
-
(_k = (_j = this._loggerManager) === null || _j === void 0 ? void 0 : _j.warn) === null || _k === void 0 ? void 0 : _k.call(_j, 'RuleManager.isRuleMatched()', logEntry || '',
|
|
829
|
+
(_k = (_j = this._loggerManager) === null || _j === void 0 ? void 0 : _j.warn) === null || _k === void 0 ? void 0 : _k.call(_j, 'RuleManager.isRuleMatched()', logEntry || '', ERROR_MESSAGES.RULE_NOT_VALID);
|
|
96
830
|
}
|
|
97
831
|
return false;
|
|
98
832
|
}
|
|
@@ -126,7 +860,7 @@ class RuleManager {
|
|
|
126
860
|
// Second AND level
|
|
127
861
|
let match;
|
|
128
862
|
if (Object.prototype.hasOwnProperty.call(rulesSubset, 'AND') &&
|
|
129
|
-
|
|
863
|
+
arrayNotEmpty(rulesSubset === null || rulesSubset === void 0 ? void 0 : rulesSubset.AND)) {
|
|
130
864
|
for (let i = 0, l = rulesSubset.AND.length; i < l; i++) {
|
|
131
865
|
match = this._processORWHEN(data, rulesSubset.AND[i]);
|
|
132
866
|
if (match === false) {
|
|
@@ -134,12 +868,12 @@ class RuleManager {
|
|
|
134
868
|
}
|
|
135
869
|
}
|
|
136
870
|
if (match !== false) {
|
|
137
|
-
(_b = (_a = this._loggerManager) === null || _a === void 0 ? void 0 : _a.info) === null || _b === void 0 ? void 0 : _b.call(_a, 'RuleManager._processAND()',
|
|
871
|
+
(_b = (_a = this._loggerManager) === null || _a === void 0 ? void 0 : _a.info) === null || _b === void 0 ? void 0 : _b.call(_a, 'RuleManager._processAND()', MESSAGES.RULE_MATCH_AND);
|
|
138
872
|
}
|
|
139
873
|
return match;
|
|
140
874
|
}
|
|
141
875
|
else {
|
|
142
|
-
(_d = (_c = this._loggerManager) === null || _c === void 0 ? void 0 : _c.warn) === null || _d === void 0 ? void 0 : _d.call(_c, 'RuleManager._processAND()',
|
|
876
|
+
(_d = (_c = this._loggerManager) === null || _c === void 0 ? void 0 : _c.warn) === null || _d === void 0 ? void 0 : _d.call(_c, 'RuleManager._processAND()', ERROR_MESSAGES.RULE_NOT_VALID);
|
|
143
877
|
}
|
|
144
878
|
return false;
|
|
145
879
|
}
|
|
@@ -155,16 +889,19 @@ class RuleManager {
|
|
|
155
889
|
// Third OR level. Called OR_WHEN.
|
|
156
890
|
let match;
|
|
157
891
|
if (Object.prototype.hasOwnProperty.call(rulesSubset, 'OR_WHEN') &&
|
|
158
|
-
|
|
892
|
+
arrayNotEmpty(rulesSubset === null || rulesSubset === void 0 ? void 0 : rulesSubset.OR_WHEN)) {
|
|
159
893
|
for (let i = 0, l = rulesSubset.OR_WHEN.length; i < l; i++) {
|
|
160
894
|
match = this._processRuleItem(data, rulesSubset.OR_WHEN[i]);
|
|
161
|
-
if (match
|
|
895
|
+
if (match === true) {
|
|
162
896
|
return match;
|
|
163
897
|
}
|
|
164
898
|
}
|
|
899
|
+
if (match !== false) {
|
|
900
|
+
return match;
|
|
901
|
+
}
|
|
165
902
|
}
|
|
166
903
|
else {
|
|
167
|
-
(_b = (_a = this._loggerManager) === null || _a === void 0 ? void 0 : _a.warn) === null || _b === void 0 ? void 0 : _b.call(_a, 'RuleManager._processORWHEN()',
|
|
904
|
+
(_b = (_a = this._loggerManager) === null || _a === void 0 ? void 0 : _a.warn) === null || _b === void 0 ? void 0 : _b.call(_a, 'RuleManager._processORWHEN()', ERROR_MESSAGES.RULE_NOT_VALID);
|
|
168
905
|
}
|
|
169
906
|
return false;
|
|
170
907
|
}
|
|
@@ -187,15 +924,15 @@ class RuleManager {
|
|
|
187
924
|
if (this.isUsingCustomInterface(data)) {
|
|
188
925
|
// RuleElement object has to have `rule_type` field
|
|
189
926
|
if (rule === null || rule === void 0 ? void 0 : rule.rule_type) {
|
|
190
|
-
(_b = (_a = this._loggerManager) === null || _a === void 0 ? void 0 : _a.info) === null || _b === void 0 ? void 0 : _b.call(_a, 'RuleManager._processRuleItem()',
|
|
927
|
+
(_b = (_a = this._loggerManager) === null || _a === void 0 ? void 0 : _a.info) === null || _b === void 0 ? void 0 : _b.call(_a, 'RuleManager._processRuleItem()', MESSAGES.RULE_MATCH_START.replace('#', rule.rule_type));
|
|
191
928
|
for (const method of Object.getOwnPropertyNames(data.constructor.prototype)) {
|
|
192
929
|
if (method === 'constructor')
|
|
193
930
|
continue;
|
|
194
|
-
const rule_method =
|
|
931
|
+
const rule_method = camelCase(`get ${rule.rule_type.replace(/_/g, ' ')}`);
|
|
195
932
|
if (method === rule_method ||
|
|
196
933
|
((_c = data === null || data === void 0 ? void 0 : data.mapper) === null || _c === void 0 ? void 0 : _c.call(data, method)) === rule_method) {
|
|
197
934
|
const dataValue = data[method](rule);
|
|
198
|
-
if (Object.values(
|
|
935
|
+
if (Object.values(RuleError).includes(dataValue))
|
|
199
936
|
return dataValue;
|
|
200
937
|
if (rule.rule_type === 'js_condition')
|
|
201
938
|
return dataValue;
|
|
@@ -204,7 +941,7 @@ class RuleManager {
|
|
|
204
941
|
}
|
|
205
942
|
}
|
|
206
943
|
}
|
|
207
|
-
else if (
|
|
944
|
+
else if (objectNotEmpty(data)) {
|
|
208
945
|
// only handle RuleElement with a `key` field
|
|
209
946
|
for (const key of Object.keys(data)) {
|
|
210
947
|
const k = this._keys_case_sensitive ? key : key.toLowerCase();
|
|
@@ -218,21 +955,21 @@ class RuleManager {
|
|
|
218
955
|
}
|
|
219
956
|
else {
|
|
220
957
|
(_e = (_d = this._loggerManager) === null || _d === void 0 ? void 0 : _d.trace) === null || _e === void 0 ? void 0 : _e.call(_d, 'RuleManager._processRuleItem()', {
|
|
221
|
-
warn:
|
|
958
|
+
warn: ERROR_MESSAGES.RULE_DATA_NOT_VALID,
|
|
222
959
|
data
|
|
223
960
|
});
|
|
224
961
|
}
|
|
225
962
|
}
|
|
226
963
|
else {
|
|
227
964
|
(_g = (_f = this._loggerManager) === null || _f === void 0 ? void 0 : _f.trace) === null || _g === void 0 ? void 0 : _g.call(_f, 'RuleManager._processRuleItem()', {
|
|
228
|
-
warn:
|
|
965
|
+
warn: ERROR_MESSAGES.RULE_NOT_VALID,
|
|
229
966
|
data,
|
|
230
967
|
rule
|
|
231
968
|
});
|
|
232
969
|
}
|
|
233
970
|
}
|
|
234
971
|
else {
|
|
235
|
-
(_j = (_h = this._loggerManager) === null || _h === void 0 ? void 0 : _h.warn) === null || _j === void 0 ? void 0 : _j.call(_h, 'RuleManager._processRuleItem()',
|
|
972
|
+
(_j = (_h = this._loggerManager) === null || _h === void 0 ? void 0 : _h.warn) === null || _j === void 0 ? void 0 : _j.call(_h, 'RuleManager._processRuleItem()', ERROR_MESSAGES.RULE_MATCH_TYPE_NOT_SUPPORTED.replace('#', matching));
|
|
236
973
|
}
|
|
237
974
|
}
|
|
238
975
|
catch (error) {
|
|
@@ -242,7 +979,7 @@ class RuleManager {
|
|
|
242
979
|
}
|
|
243
980
|
}
|
|
244
981
|
else {
|
|
245
|
-
(_o = (_m = this._loggerManager) === null || _m === void 0 ? void 0 : _m.warn) === null || _o === void 0 ? void 0 : _o.call(_m, 'RuleManager._processRuleItem()',
|
|
982
|
+
(_o = (_m = this._loggerManager) === null || _m === void 0 ? void 0 : _m.warn) === null || _o === void 0 ? void 0 : _o.call(_m, 'RuleManager._processRuleItem()', ERROR_MESSAGES.RULE_NOT_VALID);
|
|
246
983
|
}
|
|
247
984
|
return false;
|
|
248
985
|
}
|
|
@@ -252,7 +989,7 @@ class RuleManager {
|
|
|
252
989
|
* @return {boolean}
|
|
253
990
|
*/
|
|
254
991
|
isUsingCustomInterface(data) {
|
|
255
|
-
return (
|
|
992
|
+
return (objectNotEmpty(data) &&
|
|
256
993
|
Object.prototype.hasOwnProperty.call(data, 'name') &&
|
|
257
994
|
data.name === 'RuleData');
|
|
258
995
|
}
|