@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
package/dist/constants.js CHANGED
@@ -1,23 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ConditionTypes = exports.CONFIGURATION_URL = exports.API_DATA_URL = exports.API_SSX_URL = exports.EVENTS_URL = exports.TARGETING_DATA_MAXIMUM_SIZE_BYTES = exports.MINUTES_SESSION_DURATION = exports.DEFAULT_MILLISECONDS_BETWEEN_TARGETING_DATA_UPDATE = exports.Milliseconds = void 0;
4
- var Milliseconds;
5
- (function (Milliseconds) {
6
- Milliseconds[Milliseconds["Second"] = 1000] = "Second";
7
- Milliseconds[Milliseconds["Minute"] = 60000] = "Minute";
8
- Milliseconds[Milliseconds["Hour"] = 3600000] = "Hour";
9
- })(Milliseconds = exports.Milliseconds || (exports.Milliseconds = {}));
10
- exports.DEFAULT_MILLISECONDS_BETWEEN_TARGETING_DATA_UPDATE = 30 * Milliseconds.Minute;
11
- exports.MINUTES_SESSION_DURATION = 30 * Milliseconds.Minute;
12
- exports.TARGETING_DATA_MAXIMUM_SIZE_BYTES = 500;
13
- exports.EVENTS_URL = 'https://events.kameleoon.com:8110/';
14
- exports.API_SSX_URL = 'https://api-ssx.kameleoon.com/';
15
- exports.API_DATA_URL = 'https://api-data.kameleoon.com/';
16
- exports.CONFIGURATION_URL = 'https://client-config.kameleoon.com/';
17
- var ConditionTypes;
18
- (function (ConditionTypes) {
19
- ConditionTypes["CUSTOM_DATUM"] = "CUSTOM_DATUM";
20
- ConditionTypes["EXCLUSIVE_EXPERIMENT"] = "EXCLUSIVE_EXPERIMENT";
21
- ConditionTypes["TARGET_EXPERIMENT"] = "TARGET_EXPERIMENT";
22
- })(ConditionTypes = exports.ConditionTypes || (exports.ConditionTypes = {}));
3
+ exports.Cookie = exports.VISITOR_CODE_LENGTH = exports.KAMELEOON_COOKIE_KEY = exports.OFF_VARIATION_KEY = exports.UNALLOCATED_VARIATION_ID = void 0;
4
+ exports.UNALLOCATED_VARIATION_ID = 0;
5
+ exports.OFF_VARIATION_KEY = 'off';
6
+ exports.KAMELEOON_COOKIE_KEY = 'kameleoonVisitorCode';
7
+ exports.VISITOR_CODE_LENGTH = 16;
8
+ var Cookie;
9
+ (function (Cookie) {
10
+ Cookie["PairsDelimiter"] = "; ";
11
+ Cookie["KeyValueDelimiter"] = "=";
12
+ Cookie["MaxAge"] = "MaxAge";
13
+ Cookie["Path"] = "Path";
14
+ Cookie["Domain"] = "Domain";
15
+ })(Cookie = exports.Cookie || (exports.Cookie = {}));
23
16
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAA,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,sDAAa,CAAA;IACb,uDAAiC,CAAA;IACjC,qDAA+B,CAAA;AACjC,CAAC,EAJW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAIvB;AAEY,QAAA,kDAAkD,GAC7D,EAAE,GAAG,YAAY,CAAC,MAAM,CAAC;AACd,QAAA,wBAAwB,GAAG,EAAE,GAAG,YAAY,CAAC,MAAM,CAAC;AACpD,QAAA,iCAAiC,GAAG,GAAG,CAAC;AACxC,QAAA,UAAU,GAAG,oCAAoC,CAAC;AAClD,QAAA,WAAW,GAAG,gCAAgC,CAAC;AAC/C,QAAA,YAAY,GAAG,iCAAiC,CAAC;AACjD,QAAA,iBAAiB,GAAG,sCAAsC,CAAC;AAExE,IAAY,cAIX;AAJD,WAAY,cAAc;IACxB,+CAA6B,CAAA;IAC7B,+DAA6C,CAAA;IAC7C,yDAAuC,CAAA;AACzC,CAAC,EAJW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAIzB"}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,wBAAwB,GAAG,CAAC,CAAC;AAC7B,QAAA,iBAAiB,GAAG,KAAK,CAAC;AAC1B,QAAA,oBAAoB,GAAG,sBAAsB,CAAC;AAC9C,QAAA,mBAAmB,GAAG,EAAE,CAAC;AAEtC,IAAY,MAMX;AAND,WAAY,MAAM;IAChB,+BAAqB,CAAA;IACrB,iCAAuB,CAAA;IACvB,2BAAiB,CAAA;IACjB,uBAAa,CAAA;IACb,2BAAiB,CAAA;AACnB,CAAC,EANW,MAAM,GAAN,cAAM,KAAN,cAAM,QAMjB"}
@@ -0,0 +1 @@
1
+ export declare const REAL_TIME_EVENT = "configuration-update-event";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.REAL_TIME_EVENT = void 0;
4
+ exports.REAL_TIME_EVENT = 'configuration-update-event';
5
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/eventSource/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,4BAA4B,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { IExternalEventSourceConstructor } from './types';
2
+ export interface IEventSource {
3
+ open: (onEvent: (timestamp: number) => void) => void;
4
+ close: () => void;
5
+ }
6
+ export declare class ExternalEventSource implements IEventSource {
7
+ private eventSource;
8
+ private siteCode;
9
+ constructor(siteCode: string, externalEventSource: IExternalEventSourceConstructor);
10
+ open(onEvent: (timestamp: number) => void): void;
11
+ close(): void;
12
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExternalEventSource = void 0;
4
+ const requester_1 = require("../requester");
5
+ const constants_1 = require("../requester/constants");
6
+ const constants_2 = require("./constants");
7
+ class ExternalEventSource {
8
+ constructor(siteCode, externalEventSource) {
9
+ const url = requester_1.URL.EVENTS + constants_1.UrlQuery.Sse + siteCode;
10
+ const eventSource = externalEventSource.initialize(url);
11
+ this.eventSource = eventSource;
12
+ this.siteCode = siteCode;
13
+ }
14
+ open(onEvent) {
15
+ this.eventSource.open({
16
+ onEvent,
17
+ siteCode: this.siteCode,
18
+ eventType: constants_2.REAL_TIME_EVENT,
19
+ });
20
+ }
21
+ close() {
22
+ this.eventSource.close();
23
+ }
24
+ }
25
+ exports.ExternalEventSource = ExternalEventSource;
26
+ //# sourceMappingURL=externalEventSource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"externalEventSource.js","sourceRoot":"","sources":["../../src/eventSource/externalEventSource.ts"],"names":[],"mappings":";;;AAAA,4CAAmC;AACnC,sDAAkD;AAClD,2CAA8C;AAQ9C,MAAa,mBAAmB;IAI9B,YACE,QAAgB,EAChB,mBAAoD;QAEpD,MAAM,GAAG,GAAG,eAAG,CAAC,MAAM,GAAG,oBAAQ,CAAC,GAAG,GAAG,QAAQ,CAAC;QACjD,MAAM,WAAW,GAAG,mBAAmB,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QAExD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAEM,IAAI,CAAC,OAAoC;QAC9C,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;YACpB,OAAO;YACP,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,SAAS,EAAE,2BAAe;SAC3B,CAAC,CAAC;IACL,CAAC;IAEM,KAAK;QACV,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC;CACF;AA1BD,kDA0BC"}
@@ -0,0 +1,3 @@
1
+ export { IExternalEventSourceConstructor, EventSourceOpenParametersType, IExternalEventSource, RealTimeEventType, } from './types';
2
+ export { ExternalEventSource, IEventSource } from './externalEventSource';
3
+ export { REAL_TIME_EVENT } from './constants';
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.REAL_TIME_EVENT = exports.ExternalEventSource = void 0;
4
+ var externalEventSource_1 = require("./externalEventSource");
5
+ Object.defineProperty(exports, "ExternalEventSource", { enumerable: true, get: function () { return externalEventSource_1.ExternalEventSource; } });
6
+ var constants_1 = require("./constants");
7
+ Object.defineProperty(exports, "REAL_TIME_EVENT", { enumerable: true, get: function () { return constants_1.REAL_TIME_EVENT; } });
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/eventSource/index.ts"],"names":[],"mappings":";;;AAMA,6DAA0E;AAAjE,0HAAA,mBAAmB,OAAA;AAC5B,yCAA8C;AAArC,4GAAA,eAAe,OAAA"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * @interface an interface of External Constructor for Extrnal Event Source which must be implemented by the wrapper constructor to initialize new `IExternalEventSource` in order to pass the necessary `url` parameter
3
+ * */
4
+ export interface IExternalEventSourceConstructor {
5
+ /**
6
+ * @method initialize - creates and instance of `IExternalEventSource` and returns it
7
+ * @param {string} url - url of server sent event server which will be pasted by consumer
8
+ * @returns {IExternalEventSource} an initialized instance of `IExternalEventSource`
9
+ * */
10
+ initialize: (url: string) => IExternalEventSource;
11
+ }
12
+ /**
13
+ * @param {string} siteCode - site code from the event
14
+ * @param {string} eventType - type of event to be listened for
15
+ * @param {(timestamp: number) => void} onEvent - callback to be executed upon event if the site code from event matches the site code of EvenetSource
16
+ * */
17
+ export type EventSourceOpenParametersType = {
18
+ siteCode: string;
19
+ eventType: string;
20
+ onEvent: (timestamp: number) => void;
21
+ };
22
+ /**
23
+ * @interface an interface of External Event Source which will be used in server sent events operations
24
+ * */
25
+ export interface IExternalEventSource {
26
+ /**
27
+ * @method open - opens event source live connection
28
+ * @param {(timestamp: number) => void} callback - callback function that will be executed on each obtainment of server event
29
+ * */
30
+ open: ({ siteCode, eventType, onEvent, }: EventSourceOpenParametersType) => void;
31
+ /**
32
+ * @method close - closes event source live connection
33
+ * */
34
+ close: () => void;
35
+ }
36
+ /**
37
+ * @param {string} siteCode - site code from the event
38
+ * @param {number} ts - timestamp of when the event has happened
39
+ * */
40
+ export type RealTimeEventType = {
41
+ siteCode: string;
42
+ ts: number;
43
+ };
44
+ export type CreateEventSourceParamsType = {
45
+ siteCode: string;
46
+ externalEventSource?: IExternalEventSourceConstructor;
47
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/eventSource/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ export declare const RESHUFFLE_SUFFIX = "variation";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RESHUFFLE_SUFFIX = void 0;
4
+ exports.RESHUFFLE_SUFFIX = 'variation';
5
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/hasher/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,gBAAgB,GAAG,WAAW,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { ObtainExperimentHashDoubleParamsType, ObtainFeatureFlagHashDoubleParamsType } from './types';
2
+ export declare class Hasher {
3
+ static obtainExperimentHashDouble({ visitorCode, campaignId, respoolTime, }: ObtainExperimentHashDoubleParamsType): number;
4
+ static obtainFeatureFlagHashDouble({ visitorCode, campaignId, reShuffle, }: ObtainFeatureFlagHashDoubleParamsType): number;
5
+ static calculateHash(seed: string): number;
6
+ }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Hasher = void 0;
4
+ const crypto_js_1 = require("crypto-js");
5
+ const constants_1 = require("./constants");
6
+ class Hasher {
7
+ static obtainExperimentHashDouble({ visitorCode, campaignId, respoolTime, }) {
8
+ let respoolTimeString = '';
9
+ if (respoolTime.length) {
10
+ respoolTime.forEach((respoolObject) => {
11
+ respoolTimeString += String(respoolObject.value);
12
+ });
13
+ }
14
+ return this.calculateHash(visitorCode + campaignId + respoolTimeString);
15
+ }
16
+ static obtainFeatureFlagHashDouble({ visitorCode, campaignId,
17
+ // --- Note ---
18
+ // For some cases of feature flag rules we need to obtain `hashDouble` twice
19
+ // in a row, but the second `hashDouble` should be different (yet still predictable)
20
+ reShuffle = false, }) {
21
+ return this.calculateHash(visitorCode + campaignId + (reShuffle ? constants_1.RESHUFFLE_SUFFIX : ''));
22
+ }
23
+ // --- Note ---
24
+ // `hashDouble` is a seeded pseudo-random number between 0 and 1
25
+ // used for deciding what variation to assign
26
+ // `calculateHash` algorythm is consistent between every SDK
27
+ // and will always provide same pseudo-random value for the same input parameters
28
+ static calculateHash(seed) {
29
+ const hashDigest = (0, crypto_js_1.SHA256)(seed).toString();
30
+ return parseInt(hashDigest, 16) / Math.pow(2, 256);
31
+ }
32
+ }
33
+ exports.Hasher = Hasher;
34
+ //# sourceMappingURL=hasher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hasher.js","sourceRoot":"","sources":["../../src/hasher/hasher.ts"],"names":[],"mappings":";;;AAAA,yCAAmC;AACnC,2CAA+C;AAM/C,MAAa,MAAM;IACjB,MAAM,CAAC,0BAA0B,CAAC,EAChC,WAAW,EACX,UAAU,EACV,WAAW,GAC0B;QACrC,IAAI,iBAAiB,GAAG,EAAE,CAAC;QAE3B,IAAI,WAAW,CAAC,MAAM,EAAE;YACtB,WAAW,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,EAAE;gBACpC,iBAAiB,IAAI,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YACnD,CAAC,CAAC,CAAC;SACJ;QAED,OAAO,IAAI,CAAC,aAAa,CAAC,WAAW,GAAG,UAAU,GAAG,iBAAiB,CAAC,CAAC;IAC1E,CAAC;IAED,MAAM,CAAC,2BAA2B,CAAC,EACjC,WAAW,EACX,UAAU;IACV,eAAe;IACf,4EAA4E;IAC5E,oFAAoF;IACpF,SAAS,GAAG,KAAK,GACqB;QACtC,OAAO,IAAI,CAAC,aAAa,CACvB,WAAW,GAAG,UAAU,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,4BAAgB,CAAC,CAAC,CAAC,EAAE,CAAC,CAC/D,CAAC;IACJ,CAAC;IAED,eAAe;IACf,gEAAgE;IAChE,6CAA6C;IAC7C,4DAA4D;IAC5D,iFAAiF;IACjF,MAAM,CAAC,aAAa,CAAC,IAAY;QAC/B,MAAM,UAAU,GAAG,IAAA,kBAAM,EAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;QAE3C,OAAO,QAAQ,CAAC,UAAU,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACrD,CAAC;CACF;AAxCD,wBAwCC"}
@@ -0,0 +1 @@
1
+ export { Hasher } from './hasher';
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Hasher = void 0;
4
+ var hasher_1 = require("./hasher");
5
+ Object.defineProperty(exports, "Hasher", { enumerable: true, get: function () { return hasher_1.Hasher; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hasher/index.ts"],"names":[],"mappings":";;;AAAA,mCAAkC;AAAzB,gGAAA,MAAM,OAAA"}
@@ -0,0 +1,12 @@
1
+ import { RespoolTimeType } from '../campaignConfiguration/types';
2
+ type ObtainHashDoubleParamsType = {
3
+ visitorCode: string;
4
+ campaignId: string;
5
+ };
6
+ export type ObtainExperimentHashDoubleParamsType = ObtainHashDoubleParamsType & {
7
+ respoolTime: RespoolTimeType[];
8
+ };
9
+ export type ObtainFeatureFlagHashDoubleParamsType = ObtainHashDoubleParamsType & {
10
+ reShuffle?: boolean;
11
+ };
12
+ export {};
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/hasher/types.ts"],"names":[],"mappings":""}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,10 @@
1
- import Data from './data';
2
- export { KameleoonClient } from './kameleoonClient';
3
- export { Data as KameleoonData };
1
+ export { KameleoonClient as KameleoonCore, IKameleoonClient as IKameleoonCore, } from './kameleoonClient';
2
+ export { KameleoonUtils as KameleoonCoreUtils } from './kameleoonUtils';
3
+ export { KameleoonException, KameleoonError } from './kameleoonError';
4
+ export { KameleoonStorageKey, IExternalStorage, IExternalStorageConstructor, } from './storage';
5
+ export { Cookie, VISITOR_CODE_LENGTH } from './constants';
6
+ export { JSONType } from './campaignConfiguration';
7
+ export { Ok, Result, Err } from 'ts-res';
8
+ export { Environment, ExperimentType, FeatureFlagType, SDKCoreParameters, SDKConfigurationType, TrackConversionParamsType, FeatureVariableResultType, InternalSDKConfigurationType, GetFeatureFlagVariableParamsType, ServerGetVisitorCodeParametersType, ClientGetVisitorCodeParametersType, MobileGetVisitorCodeParametersType, } from './types';
9
+ export { CustomData, Conversion, Device, Browser, DeviceType, BrowserType, PageView, KameleoonDataType, PageViewParametersType, ConversionParametersType, } from './kameleoonData';
10
+ export { RealTimeEventType, IExternalEventSource, EventSourceOpenParametersType, IExternalEventSourceConstructor, } from './eventSource';
package/dist/index.js CHANGED
@@ -1,11 +1,29 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.KameleoonData = exports.KameleoonClient = void 0;
7
- var data_1 = __importDefault(require("./data"));
8
- exports.KameleoonData = data_1.default;
3
+ exports.PageView = exports.BrowserType = exports.DeviceType = exports.Browser = exports.Device = exports.Conversion = exports.CustomData = exports.Environment = exports.Err = exports.Ok = exports.VISITOR_CODE_LENGTH = exports.Cookie = exports.KameleoonStorageKey = exports.KameleoonError = exports.KameleoonException = exports.KameleoonCoreUtils = exports.KameleoonCore = void 0;
9
4
  var kameleoonClient_1 = require("./kameleoonClient");
10
- Object.defineProperty(exports, "KameleoonClient", { enumerable: true, get: function () { return kameleoonClient_1.KameleoonClient; } });
5
+ Object.defineProperty(exports, "KameleoonCore", { enumerable: true, get: function () { return kameleoonClient_1.KameleoonClient; } });
6
+ var kameleoonUtils_1 = require("./kameleoonUtils");
7
+ Object.defineProperty(exports, "KameleoonCoreUtils", { enumerable: true, get: function () { return kameleoonUtils_1.KameleoonUtils; } });
8
+ var kameleoonError_1 = require("./kameleoonError");
9
+ Object.defineProperty(exports, "KameleoonException", { enumerable: true, get: function () { return kameleoonError_1.KameleoonException; } });
10
+ Object.defineProperty(exports, "KameleoonError", { enumerable: true, get: function () { return kameleoonError_1.KameleoonError; } });
11
+ var storage_1 = require("./storage");
12
+ Object.defineProperty(exports, "KameleoonStorageKey", { enumerable: true, get: function () { return storage_1.KameleoonStorageKey; } });
13
+ var constants_1 = require("./constants");
14
+ Object.defineProperty(exports, "Cookie", { enumerable: true, get: function () { return constants_1.Cookie; } });
15
+ Object.defineProperty(exports, "VISITOR_CODE_LENGTH", { enumerable: true, get: function () { return constants_1.VISITOR_CODE_LENGTH; } });
16
+ var ts_res_1 = require("ts-res");
17
+ Object.defineProperty(exports, "Ok", { enumerable: true, get: function () { return ts_res_1.Ok; } });
18
+ Object.defineProperty(exports, "Err", { enumerable: true, get: function () { return ts_res_1.Err; } });
19
+ var types_1 = require("./types");
20
+ Object.defineProperty(exports, "Environment", { enumerable: true, get: function () { return types_1.Environment; } });
21
+ var kameleoonData_1 = require("./kameleoonData");
22
+ Object.defineProperty(exports, "CustomData", { enumerable: true, get: function () { return kameleoonData_1.CustomData; } });
23
+ Object.defineProperty(exports, "Conversion", { enumerable: true, get: function () { return kameleoonData_1.Conversion; } });
24
+ Object.defineProperty(exports, "Device", { enumerable: true, get: function () { return kameleoonData_1.Device; } });
25
+ Object.defineProperty(exports, "Browser", { enumerable: true, get: function () { return kameleoonData_1.Browser; } });
26
+ Object.defineProperty(exports, "DeviceType", { enumerable: true, get: function () { return kameleoonData_1.DeviceType; } });
27
+ Object.defineProperty(exports, "BrowserType", { enumerable: true, get: function () { return kameleoonData_1.BrowserType; } });
28
+ Object.defineProperty(exports, "PageView", { enumerable: true, get: function () { return kameleoonData_1.PageView; } });
11
29
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,gDAA0B;AAGT,wBAHV,cAAI,CAGmB;AAD9B,qDAAoD;AAA3C,kHAAA,eAAe,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,qDAG2B;AAFzB,gHAAA,eAAe,OAAiB;AAGlC,mDAAwE;AAA/D,oHAAA,cAAc,OAAsB;AAC7C,mDAAsE;AAA7D,oHAAA,kBAAkB,OAAA;AAAE,gHAAA,cAAc,OAAA;AAC3C,qCAImB;AAHjB,8GAAA,mBAAmB,OAAA;AAIrB,yCAA0D;AAAjD,mGAAA,MAAM,OAAA;AAAE,gHAAA,mBAAmB,OAAA;AAEpC,iCAAyC;AAAhC,4FAAA,EAAE,OAAA;AAAU,6FAAA,GAAG,OAAA;AACxB,iCAaiB;AAZf,oGAAA,WAAW,OAAA;AAab,iDAWyB;AAVvB,2GAAA,UAAU,OAAA;AACV,2GAAA,UAAU,OAAA;AACV,uGAAA,MAAM,OAAA;AACN,wGAAA,OAAO,OAAA;AACP,2GAAA,UAAU,OAAA;AACV,4GAAA,WAAW,OAAA;AACX,yGAAA,QAAQ,OAAA"}