@kameleoon/javascript-sdk-core 0.0.3 → 1.0.0

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 (261) hide show
  1. package/README.md +7 -3
  2. package/dist/campaignConfiguration/campaignConfiguration.d.ts +46 -0
  3. package/dist/campaignConfiguration/campaignConfiguration.js +217 -0
  4. package/dist/campaignConfiguration/campaignConfiguration.js.map +1 -0
  5. package/dist/campaignConfiguration/constants.d.ts +18 -0
  6. package/dist/campaignConfiguration/constants.js +23 -0
  7. package/dist/campaignConfiguration/constants.js.map +1 -0
  8. package/dist/campaignConfiguration/index.d.ts +2 -0
  9. package/dist/campaignConfiguration/index.js +8 -0
  10. package/dist/campaignConfiguration/index.js.map +1 -0
  11. package/dist/campaignConfiguration/types.d.ts +126 -0
  12. package/dist/campaignConfiguration/types.js +47 -0
  13. package/dist/campaignConfiguration/types.js.map +1 -0
  14. package/dist/clientSettings/clientSettings.d.ts +12 -0
  15. package/dist/clientSettings/clientSettings.js +29 -0
  16. package/dist/clientSettings/clientSettings.js.map +1 -0
  17. package/dist/clientSettings/index.d.ts +2 -0
  18. package/dist/clientSettings/index.js +6 -0
  19. package/dist/clientSettings/index.js.map +1 -0
  20. package/dist/clientSettings/types.d.ts +6 -0
  21. package/dist/{interfaces/interfaces.js → clientSettings/types.js} +1 -1
  22. package/dist/clientSettings/types.js.map +1 -0
  23. package/dist/constants.d.ts +10 -16
  24. package/dist/constants.js +13 -20
  25. package/dist/constants.js.map +1 -1
  26. package/dist/eventSource/constants.d.ts +1 -0
  27. package/dist/eventSource/constants.js +5 -0
  28. package/dist/eventSource/constants.js.map +1 -0
  29. package/dist/eventSource/externalEventSource.d.ts +12 -0
  30. package/dist/eventSource/externalEventSource.js +26 -0
  31. package/dist/eventSource/externalEventSource.js.map +1 -0
  32. package/dist/eventSource/index.d.ts +3 -0
  33. package/dist/eventSource/index.js +8 -0
  34. package/dist/eventSource/index.js.map +1 -0
  35. package/dist/eventSource/types.d.ts +47 -0
  36. package/dist/eventSource/types.js +3 -0
  37. package/dist/eventSource/types.js.map +1 -0
  38. package/dist/hasher/constants.d.ts +1 -0
  39. package/dist/hasher/constants.js +5 -0
  40. package/dist/hasher/constants.js.map +1 -0
  41. package/dist/hasher/hasher.d.ts +6 -0
  42. package/dist/hasher/hasher.js +34 -0
  43. package/dist/hasher/hasher.js.map +1 -0
  44. package/dist/hasher/index.d.ts +1 -0
  45. package/dist/hasher/index.js +6 -0
  46. package/dist/hasher/index.js.map +1 -0
  47. package/dist/hasher/types.d.ts +12 -0
  48. package/dist/hasher/types.js +3 -0
  49. package/dist/hasher/types.js.map +1 -0
  50. package/dist/index.d.ts +10 -3
  51. package/dist/index.js +25 -7
  52. package/dist/index.js.map +1 -1
  53. package/dist/kameleoonClient.d.ts +189 -100
  54. package/dist/kameleoonClient.js +238 -701
  55. package/dist/kameleoonClient.js.map +1 -1
  56. package/dist/kameleoonData/browser.d.ts +21 -0
  57. package/dist/kameleoonData/browser.js +41 -0
  58. package/dist/kameleoonData/browser.js.map +1 -0
  59. package/dist/kameleoonData/constants.d.ts +1 -0
  60. package/dist/kameleoonData/constants.js +5 -0
  61. package/dist/kameleoonData/constants.js.map +1 -0
  62. package/dist/kameleoonData/conversion.d.ts +23 -0
  63. package/dist/kameleoonData/conversion.js +49 -0
  64. package/dist/kameleoonData/conversion.js.map +1 -0
  65. package/dist/kameleoonData/customData.d.ts +33 -0
  66. package/dist/kameleoonData/customData.js +68 -0
  67. package/dist/kameleoonData/customData.js.map +1 -0
  68. package/dist/kameleoonData/device.d.ts +21 -0
  69. package/dist/kameleoonData/device.js +41 -0
  70. package/dist/kameleoonData/device.js.map +1 -0
  71. package/dist/kameleoonData/index.d.ts +7 -0
  72. package/dist/kameleoonData/index.js +20 -0
  73. package/dist/kameleoonData/index.js.map +1 -0
  74. package/dist/kameleoonData/nonce.d.ts +5 -0
  75. package/dist/kameleoonData/nonce.js +20 -0
  76. package/dist/kameleoonData/nonce.js.map +1 -0
  77. package/dist/kameleoonData/pageView.d.ts +24 -0
  78. package/dist/kameleoonData/pageView.js +54 -0
  79. package/dist/kameleoonData/pageView.js.map +1 -0
  80. package/dist/kameleoonData/types.d.ts +100 -0
  81. package/dist/kameleoonData/types.js +36 -0
  82. package/dist/kameleoonData/types.js.map +1 -0
  83. package/dist/kameleoonData/userAgent.d.ts +18 -0
  84. package/dist/kameleoonData/userAgent.js +33 -0
  85. package/dist/kameleoonData/userAgent.js.map +1 -0
  86. package/dist/kameleoonError/constants.d.ts +22 -0
  87. package/dist/kameleoonError/constants.js +25 -0
  88. package/dist/kameleoonError/constants.js.map +1 -0
  89. package/dist/kameleoonError/helpers.d.ts +1 -0
  90. package/dist/kameleoonError/helpers.js +8 -0
  91. package/dist/kameleoonError/helpers.js.map +1 -0
  92. package/dist/kameleoonError/index.d.ts +3 -0
  93. package/dist/kameleoonError/index.js +10 -0
  94. package/dist/kameleoonError/index.js.map +1 -0
  95. package/dist/kameleoonError/kameleoonError.d.ts +24 -0
  96. package/dist/kameleoonError/kameleoonError.js +64 -0
  97. package/dist/kameleoonError/kameleoonError.js.map +1 -0
  98. package/dist/kameleoonError/types.d.ts +20 -0
  99. package/dist/kameleoonError/types.js +25 -0
  100. package/dist/kameleoonError/types.js.map +1 -0
  101. package/dist/kameleoonUtils.d.ts +11 -10
  102. package/dist/kameleoonUtils.js +42 -128
  103. package/dist/kameleoonUtils.js.map +1 -1
  104. package/dist/requester/constants.d.ts +15 -0
  105. package/dist/requester/constants.js +53 -0
  106. package/dist/requester/constants.js.map +1 -0
  107. package/dist/requester/index.d.ts +3 -0
  108. package/dist/requester/index.js +10 -0
  109. package/dist/requester/index.js.map +1 -0
  110. package/dist/requester/requester.d.ts +23 -0
  111. package/dist/requester/requester.js +121 -0
  112. package/dist/requester/requester.js.map +1 -0
  113. package/dist/requester/types.d.ts +43 -0
  114. package/dist/requester/types.js +39 -0
  115. package/dist/requester/types.js.map +1 -0
  116. package/dist/storage/constants.d.ts +9 -0
  117. package/dist/storage/constants.js +14 -0
  118. package/dist/storage/constants.js.map +1 -0
  119. package/dist/storage/externalStorage.d.ts +11 -0
  120. package/dist/storage/externalStorage.js +34 -0
  121. package/dist/storage/externalStorage.js.map +1 -0
  122. package/dist/storage/index.d.ts +3 -0
  123. package/dist/storage/index.js +8 -0
  124. package/dist/storage/index.js.map +1 -0
  125. package/dist/storage/types.d.ts +52 -11
  126. package/dist/targeting/conditions/conditionFactory.d.ts +6 -0
  127. package/dist/targeting/conditions/conditionFactory.js +26 -0
  128. package/dist/targeting/conditions/conditionFactory.js.map +1 -0
  129. package/dist/targeting/conditions/customDataCondition.d.ts +16 -0
  130. package/dist/targeting/conditions/customDataCondition.js +99 -0
  131. package/dist/targeting/conditions/customDataCondition.js.map +1 -0
  132. package/dist/targeting/conditions/exclusiveExperimentCondition.d.ts +9 -0
  133. package/dist/targeting/conditions/exclusiveExperimentCondition.js +21 -0
  134. package/dist/targeting/conditions/exclusiveExperimentCondition.js.map +1 -0
  135. package/dist/targeting/conditions/index.d.ts +5 -0
  136. package/dist/targeting/conditions/index.js +12 -0
  137. package/dist/targeting/conditions/index.js.map +1 -0
  138. package/dist/targeting/conditions/targetExperimentCondition.d.ts +13 -0
  139. package/dist/targeting/conditions/targetExperimentCondition.js +42 -0
  140. package/dist/targeting/conditions/targetExperimentCondition.js.map +1 -0
  141. package/dist/targeting/conditions/types.d.ts +22 -11
  142. package/dist/targeting/index.d.ts +3 -0
  143. package/dist/targeting/index.js +15 -0
  144. package/dist/targeting/index.js.map +1 -0
  145. package/dist/targeting/targetingNode.d.ts +21 -0
  146. package/dist/targeting/targetingNode.js +40 -0
  147. package/dist/targeting/targetingNode.js.map +1 -0
  148. package/dist/targeting/targetingTree.d.ts +16 -8
  149. package/dist/targeting/targetingTree.js +112 -10
  150. package/dist/targeting/targetingTree.js.map +1 -1
  151. package/dist/targeting/types.d.ts +127 -0
  152. package/dist/targeting/types.js +93 -0
  153. package/dist/targeting/types.js.map +1 -0
  154. package/dist/types.d.ts +135 -5
  155. package/dist/types.js +28 -0
  156. package/dist/types.js.map +1 -1
  157. package/dist/utilities/constants.d.ts +1 -0
  158. package/dist/utilities/constants.js +5 -0
  159. package/dist/utilities/constants.js.map +1 -0
  160. package/dist/utilities/index.d.ts +1 -0
  161. package/dist/utilities/index.js +6 -0
  162. package/dist/utilities/index.js.map +1 -0
  163. package/dist/utilities/types.d.ts +18 -0
  164. package/dist/utilities/types.js +3 -0
  165. package/dist/utilities/types.js.map +1 -0
  166. package/dist/utilities/utilities.d.ts +13 -0
  167. package/dist/utilities/utilities.js +119 -0
  168. package/dist/utilities/utilities.js.map +1 -0
  169. package/dist/variationConfiguration/index.d.ts +2 -0
  170. package/dist/variationConfiguration/index.js +6 -0
  171. package/dist/variationConfiguration/index.js.map +1 -0
  172. package/dist/variationConfiguration/types.d.ts +25 -0
  173. package/dist/variationConfiguration/types.js +3 -0
  174. package/dist/variationConfiguration/types.js.map +1 -0
  175. package/dist/variationConfiguration/variation.d.ts +13 -0
  176. package/dist/variationConfiguration/variation.js +38 -0
  177. package/dist/variationConfiguration/variation.js.map +1 -0
  178. package/dist/variationConfiguration/variationConfiguration.d.ts +36 -0
  179. package/dist/variationConfiguration/variationConfiguration.js +248 -0
  180. package/dist/variationConfiguration/variationConfiguration.js.map +1 -0
  181. package/package.json +19 -9
  182. package/dist/configurations/configuration.d.ts +0 -15
  183. package/dist/configurations/configuration.js +0 -31
  184. package/dist/configurations/configuration.js.map +0 -1
  185. package/dist/configurations/experiment.d.ts +0 -13
  186. package/dist/configurations/experiment.js +0 -54
  187. package/dist/configurations/experiment.js.map +0 -1
  188. package/dist/configurations/featureFlag.d.ts +0 -23
  189. package/dist/configurations/featureFlag.js +0 -105
  190. package/dist/configurations/featureFlag.js.map +0 -1
  191. package/dist/configurations/variation.d.ts +0 -15
  192. package/dist/configurations/variation.js +0 -14
  193. package/dist/configurations/variation.js.map +0 -1
  194. package/dist/data.d.ts +0 -67
  195. package/dist/data.js +0 -127
  196. package/dist/data.js.map +0 -1
  197. package/dist/exceptions/credentialsNotFound.d.ts +0 -6
  198. package/dist/exceptions/credentialsNotFound.js +0 -29
  199. package/dist/exceptions/credentialsNotFound.js.map +0 -1
  200. package/dist/exceptions/experimentConfigurationNotFound.d.ts +0 -6
  201. package/dist/exceptions/experimentConfigurationNotFound.js +0 -29
  202. package/dist/exceptions/experimentConfigurationNotFound.js.map +0 -1
  203. package/dist/exceptions/featureConfigurationNotFound.d.ts +0 -6
  204. package/dist/exceptions/featureConfigurationNotFound.js +0 -29
  205. package/dist/exceptions/featureConfigurationNotFound.js.map +0 -1
  206. package/dist/exceptions/notActivated.d.ts +0 -6
  207. package/dist/exceptions/notActivated.js +0 -29
  208. package/dist/exceptions/notActivated.js.map +0 -1
  209. package/dist/exceptions/notTargeted.d.ts +0 -6
  210. package/dist/exceptions/notTargeted.js +0 -29
  211. package/dist/exceptions/notTargeted.js.map +0 -1
  212. package/dist/exceptions/siteCodeDisabled.d.ts +0 -5
  213. package/dist/exceptions/siteCodeDisabled.js +0 -30
  214. package/dist/exceptions/siteCodeDisabled.js.map +0 -1
  215. package/dist/exceptions/variationConfigurationNotFound.d.ts +0 -6
  216. package/dist/exceptions/variationConfigurationNotFound.js +0 -29
  217. package/dist/exceptions/variationConfigurationNotFound.js.map +0 -1
  218. package/dist/exceptions/visitorCodeNotValid.d.ts +0 -5
  219. package/dist/exceptions/visitorCodeNotValid.js +0 -30
  220. package/dist/exceptions/visitorCodeNotValid.js.map +0 -1
  221. package/dist/interfaces/interfaces.d.ts +0 -81
  222. package/dist/interfaces/interfaces.js.map +0 -1
  223. package/dist/nonce.d.ts +0 -1
  224. package/dist/nonce.js +0 -16
  225. package/dist/nonce.js.map +0 -1
  226. package/dist/realTimeConfigurationService.d.ts +0 -12
  227. package/dist/realTimeConfigurationService.js +0 -24
  228. package/dist/realTimeConfigurationService.js.map +0 -1
  229. package/dist/storage/variationStorage.d.ts +0 -11
  230. package/dist/storage/variationStorage.js +0 -159
  231. package/dist/storage/variationStorage.js.map +0 -1
  232. package/dist/storage/visitorVariation.d.ts +0 -9
  233. package/dist/storage/visitorVariation.js +0 -22
  234. package/dist/storage/visitorVariation.js.map +0 -1
  235. package/dist/targeting/conditions/customDatum.d.ts +0 -12
  236. package/dist/targeting/conditions/customDatum.js +0 -129
  237. package/dist/targeting/conditions/customDatum.js.map +0 -1
  238. package/dist/targeting/conditions/exclusiveExperiment.d.ts +0 -9
  239. package/dist/targeting/conditions/exclusiveExperiment.js +0 -45
  240. package/dist/targeting/conditions/exclusiveExperiment.js.map +0 -1
  241. package/dist/targeting/conditions/targetExperiment.d.ts +0 -14
  242. package/dist/targeting/conditions/targetExperiment.js +0 -57
  243. package/dist/targeting/conditions/targetExperiment.js.map +0 -1
  244. package/dist/targeting/targetingCondition.d.ts +0 -7
  245. package/dist/targeting/targetingCondition.js +0 -9
  246. package/dist/targeting/targetingCondition.js.map +0 -1
  247. package/dist/targeting/targetingConditionsFactory.d.ts +0 -7
  248. package/dist/targeting/targetingConditionsFactory.js +0 -30
  249. package/dist/targeting/targetingConditionsFactory.js.map +0 -1
  250. package/dist/targeting/targetingData.d.ts +0 -7
  251. package/dist/targeting/targetingData.js +0 -11
  252. package/dist/targeting/targetingData.js.map +0 -1
  253. package/dist/targeting/targetingEngine.d.ts +0 -6
  254. package/dist/targeting/targetingEngine.js +0 -130
  255. package/dist/targeting/targetingEngine.js.map +0 -1
  256. package/dist/targeting/targetingSegment.d.ts +0 -5
  257. package/dist/targeting/targetingSegment.js +0 -9
  258. package/dist/targeting/targetingSegment.js.map +0 -1
  259. package/dist/targeting/targetingTreeBuilder.d.ts +0 -8
  260. package/dist/targeting/targetingTreeBuilder.js +0 -127
  261. package/dist/targeting/targetingTreeBuilder.js.map +0 -1
@@ -1,12 +0,0 @@
1
- export interface RealTimeEvent {
2
- ts: number;
3
- }
4
- export interface RealTimeConfigurationServiceInterface {
5
- disconnect: () => void;
6
- }
7
- export declare class RealTimeConfigurationService {
8
- private static readonly EVENT_NAME;
9
- private eventSource;
10
- constructor(eventUrl: string, handler?: (event: RealTimeEvent) => void);
11
- disconnect: () => void;
12
- }
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RealTimeConfigurationService = void 0;
4
- var RealTimeConfigurationService = /** @class */ (function () {
5
- function RealTimeConfigurationService(eventUrl, handler) {
6
- var _this = this;
7
- this.disconnect = function () {
8
- _this.eventSource.close();
9
- };
10
- this.eventSource = new EventSource(eventUrl);
11
- this.eventSource.onerror = function (error) {
12
- console.log("SSE Client error called: ".concat(error));
13
- };
14
- this.eventSource.addEventListener(RealTimeConfigurationService.EVENT_NAME, function (message) {
15
- var messageEvent = message;
16
- var event = JSON.parse(messageEvent.data);
17
- handler && handler(event);
18
- });
19
- }
20
- RealTimeConfigurationService.EVENT_NAME = 'configuration-update-event';
21
- return RealTimeConfigurationService;
22
- }());
23
- exports.RealTimeConfigurationService = RealTimeConfigurationService;
24
- //# sourceMappingURL=realTimeConfigurationService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"realTimeConfigurationService.js","sourceRoot":"","sources":["../src/realTimeConfigurationService.ts"],"names":[],"mappings":";;;AAQA;IAIE,sCAAY,QAAgB,EAAE,OAAwC;QAAtE,iBAeC;QAED,eAAU,GAAG;YACX,KAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;QAC3B,CAAC,CAAC;QAlBA,IAAI,CAAC,WAAW,GAAG,IAAI,WAAW,CAAC,QAAQ,CAAC,CAAC;QAE7C,IAAI,CAAC,WAAW,CAAC,OAAO,GAAG,UAAC,KAAK;YAC/B,OAAO,CAAC,GAAG,CAAC,mCAA4B,KAAK,CAAE,CAAC,CAAC;QACnD,CAAC,CAAC;QAEF,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAC/B,4BAA4B,CAAC,UAAU,EACvC,UAAC,OAAO;YACN,IAAM,YAAY,GAAG,OAAuB,CAAC;YAC7C,IAAM,KAAK,GAAkB,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;YAC3D,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC;QAC5B,CAAC,CACF,CAAC;IACJ,CAAC;IAlBuB,uCAAU,GAAG,4BAA4B,CAAC;IAuBpE,mCAAC;CAAA,AAxBD,IAwBC;AAxBY,oEAA4B"}
@@ -1,11 +0,0 @@
1
- import Variation from '../configurations/variation';
2
- import { VariationStorageInterface } from './types';
3
- export declare class VariationStorage implements VariationStorageInterface {
4
- private variations;
5
- constructor();
6
- updateVariation: (visitorCode: string, experimentId: number, variation: Variation) => void;
7
- getVariationId: (visitorCode: string, experimentId: number) => number | null;
8
- getMapVariationId: (visitorCode: string) => Record<number, number> | null;
9
- private loadFromLocalStorage;
10
- private saveToLocalStorage;
11
- }
@@ -1,159 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- var __read = (this && this.__read) || function (o, n) {
39
- var m = typeof Symbol === "function" && o[Symbol.iterator];
40
- if (!m) return o;
41
- var i = m.call(o), r, ar = [], e;
42
- try {
43
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
44
- }
45
- catch (error) { e = { error: error }; }
46
- finally {
47
- try {
48
- if (r && !r.done && (m = i["return"])) m.call(i);
49
- }
50
- finally { if (e) throw e.error; }
51
- }
52
- return ar;
53
- };
54
- var __importDefault = (this && this.__importDefault) || function (mod) {
55
- return (mod && mod.__esModule) ? mod : { "default": mod };
56
- };
57
- Object.defineProperty(exports, "__esModule", { value: true });
58
- exports.VariationStorage = void 0;
59
- var async_storage_1 = __importDefault(require("@react-native-async-storage/async-storage"));
60
- var visitorVariation_1 = require("./visitorVariation");
61
- var VariationStorage = /** @class */ (function () {
62
- function VariationStorage() {
63
- var _this = this;
64
- this.variations = {};
65
- this.updateVariation = function (visitorCode, experimentId, variation) {
66
- if (!_this.variations[visitorCode]) {
67
- _this.variations[visitorCode] = {};
68
- }
69
- _this.variations[visitorCode][experimentId] = new visitorVariation_1.VisitorVariation(variation.id, variation.respoolTime);
70
- _this.saveToLocalStorage();
71
- };
72
- this.getVariationId = function (visitorCode, experimentId) {
73
- var savedVisitorVariation = _this.variations[visitorCode] &&
74
- _this.variations[visitorCode][experimentId];
75
- if (savedVisitorVariation && savedVisitorVariation.isValid()) {
76
- return savedVisitorVariation.variationId;
77
- }
78
- return null;
79
- };
80
- this.getMapVariationId = function (visitorCode) {
81
- var visitorExperiments = _this.variations[visitorCode];
82
- if (visitorExperiments) {
83
- var variationIds_1 = {};
84
- Object.keys(visitorExperiments).map(function (key) {
85
- var variationKey = Number(key);
86
- variationIds_1[variationKey] =
87
- visitorExperiments[variationKey].variationId;
88
- });
89
- return variationIds_1;
90
- }
91
- return null;
92
- };
93
- this.loadFromLocalStorage = function () { return __awaiter(_this, void 0, void 0, function () {
94
- var data, dataJSON, newSavedVariations_1;
95
- return __generator(this, function (_a) {
96
- switch (_a.label) {
97
- case 0:
98
- if (!(typeof document !== 'undefined')) return [3 /*break*/, 1];
99
- data = localStorage.getItem('kameleoonVariationStorage');
100
- return [3 /*break*/, 3];
101
- case 1:
102
- if (!(typeof navigator !== 'undefined' &&
103
- navigator.product === 'ReactNative')) return [3 /*break*/, 3];
104
- return [4 /*yield*/, async_storage_1.default.getItem('kameleoonVariationStorage')];
105
- case 2:
106
- data = _a.sent();
107
- _a.label = 3;
108
- case 3:
109
- if (data) {
110
- try {
111
- dataJSON = JSON.parse(data);
112
- newSavedVariations_1 = {};
113
- Object.entries(dataJSON).forEach(function (_a) {
114
- var _b = __read(_a, 2), visitorCode = _b[0], experiment = _b[1];
115
- var savedExperiments = experiment;
116
- Object.entries(savedExperiments).forEach(function (_a) {
117
- var _b = __read(_a, 2), experimentId = _b[0], visitorVariation = _b[1];
118
- var experimentIdNumber = parseInt(experimentId);
119
- if (!newSavedVariations_1[visitorCode]) {
120
- newSavedVariations_1[visitorCode] = {};
121
- }
122
- newSavedVariations_1[visitorCode][experimentIdNumber] =
123
- visitorVariation_1.VisitorVariation.createFromJSON(visitorVariation);
124
- });
125
- });
126
- this.variations = newSavedVariations_1;
127
- }
128
- catch (e) {
129
- console.log(e);
130
- }
131
- }
132
- return [2 /*return*/];
133
- }
134
- });
135
- }); };
136
- this.saveToLocalStorage = function () { return __awaiter(_this, void 0, void 0, function () {
137
- return __generator(this, function (_a) {
138
- switch (_a.label) {
139
- case 0:
140
- if (!(typeof document !== 'undefined')) return [3 /*break*/, 1];
141
- localStorage.setItem('kameleoonJavaScriptClientData', JSON.stringify(this.variations));
142
- return [3 /*break*/, 3];
143
- case 1:
144
- if (!(typeof navigator !== 'undefined' &&
145
- navigator.product === 'ReactNative')) return [3 /*break*/, 3];
146
- return [4 /*yield*/, async_storage_1.default.setItem('kameleoonJavaScriptClientData', JSON.stringify(this.variations))];
147
- case 2:
148
- _a.sent();
149
- _a.label = 3;
150
- case 3: return [2 /*return*/];
151
- }
152
- });
153
- }); };
154
- this.loadFromLocalStorage();
155
- }
156
- return VariationStorage;
157
- }());
158
- exports.VariationStorage = VariationStorage;
159
- //# sourceMappingURL=variationStorage.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"variationStorage.js","sourceRoot":"","sources":["../../src/storage/variationStorage.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4FAAqE;AAOrE,uDAAsD;AAEtD;IAGE;QAAA,iBAEC;QAJO,eAAU,GAA+B,EAAE,CAAC;QAMpD,oBAAe,GAAG,UAChB,WAAmB,EACnB,YAAoB,EACpB,SAAoB;YAEpB,IAAI,CAAC,KAAI,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE;gBACjC,KAAI,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC;aACnC;YACD,KAAI,CAAC,UAAU,CAA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K,WAAW;4BAChC,SAAS,CAAC,OAAO,KAAK,aAAa,CAAA,EADnC,wBACmC;wBAEnC,qBAAM,uBAAY,CAAC,OAAO,CACxB,+BAA+B,EAC/B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAChC,EAAA;;wBAHD,SAGC,CAAC;;;;;aAEL,CAAC;QAnGA,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAC9B,CAAC;IAmGH,uBAAC;AAAD,CAAC,AAxGD,IAwGC;AAxGY,4CAAgB"}
@@ -1,9 +0,0 @@
1
- import { VisitorVariationInterface } from './types';
2
- export declare class VisitorVariation implements VisitorVariationInterface {
3
- variationId: number;
4
- respoolTime?: number;
5
- assignmentDate: Date;
6
- static createFromJSON(json: VisitorVariationInterface): VisitorVariation;
7
- constructor(variationId: number | string, respoolTime?: number, assignmentDate?: Date);
8
- isValid: () => boolean;
9
- }
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VisitorVariation = void 0;
4
- var VisitorVariation = /** @class */ (function () {
5
- function VisitorVariation(variationId, respoolTime, assignmentDate) {
6
- var _this = this;
7
- this.isValid = function () {
8
- return (!_this.respoolTime ||
9
- _this.assignmentDate.getTime() / 1000 > _this.respoolTime);
10
- };
11
- this.variationId = Number(variationId);
12
- this.respoolTime = respoolTime;
13
- this.assignmentDate = assignmentDate !== null && assignmentDate !== void 0 ? assignmentDate : new Date();
14
- }
15
- VisitorVariation.createFromJSON = function (json) {
16
- var variationId = json.variationId, respoolTime = json.respoolTime, assignmentDate = json.assignmentDate;
17
- return new VisitorVariation(variationId, respoolTime, assignmentDate);
18
- };
19
- return VisitorVariation;
20
- }());
21
- exports.VisitorVariation = VisitorVariation;
22
- //# sourceMappingURL=visitorVariation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"visitorVariation.js","sourceRoot":"","sources":["../../src/storage/visitorVariation.ts"],"names":[],"mappings":";;;AAEA;IAUE,0BACE,WAA4B,EAC5B,WAAoB,EACpB,cAAqB;QAHvB,iBAQC;QAED,YAAO,GAAG;YACR,OAAO,CACL,CAAC,KAAI,CAAC,WAAW;gBACjB,KAAI,CAAC,cAAc,CAAC,OAAO,EAAE,GAAG,IAAI,GAAG,KAAI,CAAC,WAAW,CACxD,CAAC;QACJ,CAAC,CAAC;QAVA,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;QACvC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,cAAc,GAAG,cAAc,aAAd,cAAc,cAAd,cAAc,GAAI,IAAI,IAAI,EAAE,CAAC;IACrD,CAAC;IAbM,+BAAc,GAArB,UAAsB,IAA+B;QAC3C,IAAA,WAAW,GAAkC,IAAI,YAAtC,EAAE,WAAW,GAAqB,IAAI,YAAzB,EAAE,cAAc,GAAK,IAAI,eAAT,CAAU;QAC1D,OAAO,IAAI,gBAAgB,CAAC,WAAW,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC;IACxE,CAAC;IAkBH,uBAAC;AAAD,CAAC,AA1BD,IA0BC;AA1BY,4CAAgB"}
@@ -1,12 +0,0 @@
1
- import TargetingCondition from '../targetingCondition';
2
- import { TargetingConditionType } from './types';
3
- export declare class CustomDatum extends TargetingCondition {
4
- index: number;
5
- operator: string;
6
- value: string;
7
- include: boolean;
8
- conditionType: string;
9
- constructor(index: number, value: string, isInclude: boolean, matchType: string);
10
- check: (data: TargetingConditionType) => boolean;
11
- }
12
- export default CustomDatum;
@@ -1,129 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __importDefault = (this && this.__importDefault) || function (mod) {
18
- return (mod && mod.__esModule) ? mod : { "default": mod };
19
- };
20
- Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.CustomDatum = void 0;
22
- var targetingCondition_1 = __importDefault(require("../targetingCondition"));
23
- var data_1 = require("../../data");
24
- var constants_1 = require("../../constants");
25
- var CustomDatum = /** @class */ (function (_super) {
26
- __extends(CustomDatum, _super);
27
- function CustomDatum(index, value, isInclude, matchType) {
28
- var _this = _super.call(this) || this;
29
- _this.check = function (data) {
30
- var targetingData = data.targetingData;
31
- var targeting = true;
32
- var customData = targetingData
33
- .filter(function (item) {
34
- return item.data instanceof data_1.CustomData && item.data.id == _this.index;
35
- })
36
- .map(function (d) {
37
- return d.data;
38
- });
39
- if (customData.length == 0) {
40
- targeting = _this.operator == 'UNDEFINED';
41
- }
42
- else {
43
- targeting = false;
44
- var customDatum = customData.slice(-1)[0];
45
- switch (_this.operator) {
46
- case 'CONTAINS':
47
- if (customDatum.value.indexOf(_this.value) >= 0) {
48
- targeting = true;
49
- }
50
- break;
51
- case 'EXACT':
52
- if (customDatum.value == _this.value) {
53
- targeting = true;
54
- }
55
- break;
56
- case 'REGULAR_EXPRESSION':
57
- if (customDatum.value.match(_this.value)) {
58
- targeting = true;
59
- }
60
- break;
61
- case 'LOWER':
62
- case 'EQUAL':
63
- case 'GREATER': {
64
- var number = parseFloat(_this.value);
65
- if (!isNaN(number)) {
66
- var valueNumber = parseFloat(customDatum.value);
67
- if (!isNaN(valueNumber)) {
68
- switch (_this.operator) {
69
- case 'LOWER':
70
- if (valueNumber < number) {
71
- targeting = true;
72
- }
73
- break;
74
- case 'EQUAL':
75
- if (valueNumber == number) {
76
- targeting = true;
77
- }
78
- break;
79
- case 'GREATER':
80
- if (valueNumber > number) {
81
- targeting = true;
82
- }
83
- break;
84
- }
85
- }
86
- }
87
- break;
88
- }
89
- case 'TRUE':
90
- if (customDatum.value == 'true') {
91
- targeting = true;
92
- }
93
- break;
94
- case 'FALSE':
95
- if (customDatum.value == 'false') {
96
- targeting = true;
97
- }
98
- break;
99
- case 'AMONG_VALUES': {
100
- var regexp = new RegExp('"([^"]*)"', 'g');
101
- var match = void 0;
102
- /* this.value has a format "["id1", "id2", "id3", "id3"]"
103
- need to find all matches (id1, id2, id3, id4 for current sample)
104
- in a string `this.value`and to compare them all
105
- with `customDatum.value` for a match */
106
- while ((match = regexp.exec(_this.value)) !== null) {
107
- if (match[1] === customDatum.value) {
108
- targeting = true;
109
- break;
110
- }
111
- }
112
- break;
113
- }
114
- }
115
- }
116
- return targeting;
117
- };
118
- _this.include = isInclude;
119
- _this.conditionType = constants_1.ConditionTypes.CUSTOM_DATUM;
120
- _this.index = index;
121
- _this.value = value;
122
- _this.operator = matchType;
123
- return _this;
124
- }
125
- return CustomDatum;
126
- }(targetingCondition_1.default));
127
- exports.CustomDatum = CustomDatum;
128
- exports.default = CustomDatum;
129
- //# sourceMappingURL=customDatum.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"customDatum.js","sourceRoot":"","sources":["../../../src/targeting/conditions/customDatum.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,6EAAuD;AACvD,mCAAwC;AAExC,6CAAiD;AAEjD;IAAiC,+BAAkB;IAOjD,qBACE,KAAa,EACb,KAAa,EACb,SAAkB,EAClB,SAAiB;QAJnB,YAME,iBAAO,SAOR;QAED,WAAK,GAAG,UAAC,IAA4B;YACnC,IAAM,aAAa,GAAI,IAAiC,CAAC,aAAa,CAAC;YACvE,IAAI,SAAS,GAAG,IAAI,CAAC;YACrB,IAAM,UAAU,GAAG,aAAa;iBAC7B,MAAM,CAAC,UAAC,IAAI;gBACX,OAAO,IAAI,CAAC,IAAI,YAAY,iBAAU,IAAI,IA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,KAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;;IAC5B,CAAC;IA2FH,kBAAC;AAAD,CAAC,AA/GD,CAAiC,4BAAkB,GA+GlD;AA/GY,kCAAW;AAiHxB,kBAAe,WAAW,CAAC"}
@@ -1,9 +0,0 @@
1
- import TargetingCondition from '../targetingCondition';
2
- import { TargetingConditionType } from './types';
3
- export declare class ExclusiveExperiment extends TargetingCondition {
4
- static readonly CONDITION_TYPE = "exclusiveExperiment";
5
- include: boolean;
6
- conditionType: string;
7
- constructor();
8
- check: (data: TargetingConditionType) => boolean;
9
- }
@@ -1,45 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __importDefault = (this && this.__importDefault) || function (mod) {
18
- return (mod && mod.__esModule) ? mod : { "default": mod };
19
- };
20
- Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.ExclusiveExperiment = void 0;
22
- var constants_1 = require("../../constants");
23
- var targetingCondition_1 = __importDefault(require("../targetingCondition"));
24
- var ExclusiveExperiment = /** @class */ (function (_super) {
25
- __extends(ExclusiveExperiment, _super);
26
- function ExclusiveExperiment() {
27
- var _this = _super.call(this) || this;
28
- _this.check = function (data) {
29
- //need to return true if variation storage is empty or it has only single current experiment in the storage
30
- var _a = data, currentExperimentId = _a.currentExperimentId, variationStorage = _a.variationStorage;
31
- var isVariationStorageEmpty = !variationStorage || Object.keys(variationStorage).length === 0;
32
- var isCurrentExperimentSingle = !isVariationStorageEmpty &&
33
- Object.keys(variationStorage).length === 1 &&
34
- (variationStorage === null || variationStorage === void 0 ? void 0 : variationStorage[currentExperimentId]) != null;
35
- return isVariationStorageEmpty || isCurrentExperimentSingle;
36
- };
37
- _this.include = true;
38
- _this.conditionType = constants_1.ConditionTypes.EXCLUSIVE_EXPERIMENT;
39
- return _this;
40
- }
41
- ExclusiveExperiment.CONDITION_TYPE = 'exclusiveExperiment';
42
- return ExclusiveExperiment;
43
- }(targetingCondition_1.default));
44
- exports.ExclusiveExperiment = ExclusiveExperiment;
45
- //# sourceMappingURL=exclusiveExperiment.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"exclusiveExperiment.js","sourceRoot":"","sources":["../../../src/targeting/conditions/exclusiveExperiment.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,6CAAiD;AACjD,6EAAuD;AAMvD;IAAyC,uCAAkB;IAMzD;QAAA,YACE,iBAAO,SAIR;QAED,WAAK,GAAG,UAAC,IAA4B;YACnC,2GAA2G;YACrG,IAAA,KACJ,IAAwC,EADlC,mBAAmB,yBAAA,EAAE,gBAAgB,sBACH,CAAC;YAC3C,IAAM,uBAAuB,GAC3B,CAAC,gBAAgB,IAAI,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;YAClE,IAAM,yBAAyB,GAC7B,CAAC,uBAAuB;gBACxB,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,MAAM,KAAK,CAAC;gBAC1C,CAAA,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAG,mBAAmB,CAAC,KAAI,IAAI,CAAC;YAClD,OAAO,uBAAuB,IAAI,yBAAyB,CAAC;QAC9D,CAAC,CAAC;QAfA,KAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,KAAI,CAAC,aAAa,GAAG,0BAAc,CAAC,oBAAoB,CAAC;;IAC3D,CAAC;IAVe,kCAAc,GAAG,qBAAqB,CAAC;IAwBzD,0BAAC;CAAA,AAzBD,CAAyC,4BAAkB,GAyB1D;AAzBY,kDAAmB"}
@@ -1,14 +0,0 @@
1
- import TargetingCondition from '../targetingCondition';
2
- import { TargetingConditionType } from './types';
3
- export interface TargetExperimentConditionData {
4
- variationStorage: Record<number, number> | null;
5
- }
6
- export declare class TargetExperiment extends TargetingCondition {
7
- include: boolean;
8
- conditionType: string;
9
- experiment: number;
10
- variation: number | undefined;
11
- variationMatchType: string;
12
- constructor(isInclude: boolean, experiment: number, variation: number | undefined, variationMatchType: string);
13
- check: (data: TargetingConditionType) => boolean;
14
- }
@@ -1,57 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __importDefault = (this && this.__importDefault) || function (mod) {
18
- return (mod && mod.__esModule) ? mod : { "default": mod };
19
- };
20
- Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.TargetExperiment = void 0;
22
- var constants_1 = require("../../constants");
23
- var targetingCondition_1 = __importDefault(require("../targetingCondition"));
24
- var TargetExperiment = /** @class */ (function (_super) {
25
- __extends(TargetExperiment, _super);
26
- function TargetExperiment(isInclude, experiment, variation, variationMatchType) {
27
- var _this = _super.call(this) || this;
28
- _this.check = function (data) {
29
- var targeting = false;
30
- var variationStorage = data
31
- .variationStorage;
32
- var currentExperimentIdExist = variationStorage != null && variationStorage[_this.experiment] != null;
33
- switch (_this.variationMatchType) {
34
- case 'EXACT':
35
- targeting =
36
- currentExperimentIdExist &&
37
- variationStorage[_this.experiment] === _this.variation;
38
- break;
39
- case 'ANY':
40
- targeting = currentExperimentIdExist;
41
- break;
42
- default:
43
- break;
44
- }
45
- return targeting;
46
- };
47
- _this.include = isInclude;
48
- _this.conditionType = constants_1.ConditionTypes.TARGET_EXPERIMENT;
49
- _this.experiment = experiment;
50
- _this.variation = variation;
51
- _this.variationMatchType = variationMatchType;
52
- return _this;
53
- }
54
- return TargetExperiment;
55
- }(targetingCondition_1.default));
56
- exports.TargetExperiment = TargetExperiment;
57
- //# sourceMappingURL=targetExperiment.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"targetExperiment.js","sourceRoot":"","sources":["../../../src/targeting/conditions/targetExperiment.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,6CAAiD;AACjD,6EAAuD;AAOvD;IAAsC,oCAAkB;IAOtD,0BACE,SAAkB,EAClB,UAAkB,EAClB,SAA6B,EAC7B,kBAA0B;QAJ5B,YAME,iBAAO,SAOR;QAED,WAAK,GAAG,UAAC,IAA4B;YACnC,IAAI,SAAS,GAAG,KAAK,CAAC;YACtB,IAAM,gBAAgB,GAAI,IAAsC;iBAC7D,gBAAgB,CAAC;YACpB,IAAM,wBAAwB,GAC5B,gBAAgB,IAAI,IAAI,IAAI,gBAAgB,CAAC,KAAI,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC;YACxE,QAAQ,KAAI,CAAC,kBAAkB,EAAE;gBAC/B,KAAK,OAAO;oBACV,SAAS;wBACP,wBAAwB;4BACxB,gBAAgB,CAAC,KAAI,CAAC,UAAU,CAAC,KAAK,KAAI,CAAC,SAAS,CAAC;oBACvD,MAAM;gBACR,KAAK,KAAK;oBACR,SAAS,GAAG,wBAAwB,CAAC;oBACrC,MAAM;gBACR;oBACE,MAAM;aACT;YACD,OAAO,SAAS,CAAC;QACnB,CAAC,CAAC;QA1BA,KAAI,CAAC,OAAO,GAAG,SAAS,CAAC;QACzB,KAAI,CAAC,aAAa,GAAG,0BAAc,CAAC,iBAAiB,CAAC;QACtD,KAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,KAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,KAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;;IAC/C,CAAC;IAsBH,uBAAC;AAAD,CAAC,AA1CD,CAAsC,4BAAkB,GA0CvD;AA1CY,4CAAgB"}
@@ -1,7 +0,0 @@
1
- import { TargetingConditionType } from './conditions/types';
2
- declare abstract class TargetingCondition {
3
- abstract conditionType: string;
4
- abstract include: boolean;
5
- abstract check: (data: TargetingConditionType) => boolean;
6
- }
7
- export default TargetingCondition;
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var TargetingCondition = /** @class */ (function () {
4
- function TargetingCondition() {
5
- }
6
- return TargetingCondition;
7
- }());
8
- exports.default = TargetingCondition;
9
- //# sourceMappingURL=targetingCondition.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"targetingCondition.js","sourceRoot":"","sources":["../../src/targeting/targetingCondition.ts"],"names":[],"mappings":";;AAEA;IAAA;IAIA,CAAC;IAAD,yBAAC;AAAD,CAAC,AAJD,IAIC;AAED,kBAAe,kBAAkB,CAAC"}
@@ -1,7 +0,0 @@
1
- import CustomDatum from './conditions/customDatum';
2
- import { ExclusiveExperiment } from './conditions/exclusiveExperiment';
3
- import { TargetExperiment } from './conditions/targetExperiment';
4
- export declare class TargetingConditionsFactory {
5
- getCondition(targetingConditionType: string, conditionData: any): CustomDatum | ExclusiveExperiment | TargetExperiment | null;
6
- }
7
- export default TargetingConditionsFactory;
@@ -1,30 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.TargetingConditionsFactory = void 0;
7
- var constants_1 = require("../constants");
8
- var customDatum_1 = __importDefault(require("./conditions/customDatum"));
9
- var exclusiveExperiment_1 = require("./conditions/exclusiveExperiment");
10
- var targetExperiment_1 = require("./conditions/targetExperiment");
11
- var TargetingConditionsFactory = /** @class */ (function () {
12
- function TargetingConditionsFactory() {
13
- }
14
- TargetingConditionsFactory.prototype.getCondition = function (targetingConditionType, conditionData) {
15
- switch (targetingConditionType) {
16
- case constants_1.ConditionTypes.CUSTOM_DATUM:
17
- return new customDatum_1.default(parseInt(conditionData.customDataIndex), conditionData.value, conditionData.isInclude, conditionData.valueMatchType);
18
- case constants_1.ConditionTypes.EXCLUSIVE_EXPERIMENT:
19
- return new exclusiveExperiment_1.ExclusiveExperiment();
20
- case constants_1.ConditionTypes.TARGET_EXPERIMENT:
21
- return new targetExperiment_1.TargetExperiment(conditionData.isInclude, conditionData.experiment, conditionData.variation, conditionData.variationMatchType);
22
- default:
23
- return null;
24
- }
25
- };
26
- return TargetingConditionsFactory;
27
- }());
28
- exports.TargetingConditionsFactory = TargetingConditionsFactory;
29
- exports.default = TargetingConditionsFactory;
30
- //# sourceMappingURL=targetingConditionsFactory.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"targetingConditionsFactory.js","sourceRoot":"","sources":["../../src/targeting/targetingConditionsFactory.ts"],"names":[],"mappings":";;;;;;AAAA,0CAA8C;AAC9C,yEAAmD;AACnD,wEAAuE;AACvE,kEAAiE;AAEjE;IAAA;IAuBA,CAAC;IAtBC,iDAAY,GAAZ,UAAa,sBAA8B,EAAE,aAAkB;QAC7D,QAAQ,sBAAsB,EAAE;YAC9B,KAAK,0BAAc,CAAC,YAAY;gBAC9B,OAAO,IAAI,qBAAW,CACpB,QAAQ,CAAC,aAAa,CAAC,eAAe,CAAC,EACvC,aAAa,CAAC,KAAK,EACnB,aAAa,CAAC,SAAS,EACvB,aAAa,CAAC,cAAc,CAC7B,CAAC;YACJ,KAAK,0BAAc,CAAC,oBAAoB;gBACtC,OAAO,IAAI,yCAAmB,EAAE,CAAC;YACnC,KAAK,0BAAc,CAAC,iBAAiB;gBACnC,OAAO,IAAI,mCAAgB,CACzB,aAAa,CAAC,SAAS,EACvB,aAAa,CAAC,UAAU,EACxB,aAAa,CAAC,SAAS,EACvB,aAAa,CAAC,kBAAkB,CACjC,CAAC;YACJ;gBACE,OAAO,IAAI,CAAC;SACf;IACH,CAAC;IACH,iCAAC;AAAD,CAAC,AAvBD,IAuBC;AAvBY,gEAA0B;AAyBvC,kBAAe,0BAA0B,CAAC"}
@@ -1,7 +0,0 @@
1
- import { DataInterface } from '../interfaces/interfaces';
2
- declare class TargetingData {
3
- lastActivityTime: number;
4
- data: DataInterface;
5
- constructor(lastActivityTime: number, data: DataInterface);
6
- }
7
- export default TargetingData;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var TargetingData = /** @class */ (function () {
4
- function TargetingData(lastActivityTime, data) {
5
- this.lastActivityTime = lastActivityTime;
6
- this.data = data;
7
- }
8
- return TargetingData;
9
- }());
10
- exports.default = TargetingData;
11
- //# sourceMappingURL=targetingData.js.map