@kameleoon/javascript-sdk-core 2.10.1 → 3.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 (256) hide show
  1. package/dist/cacheManager/cacheManager.js +1 -11
  2. package/dist/cacheManager/cacheManager.js.map +1 -1
  3. package/dist/clientConfiguration/clientConfiguration.d.ts +52 -0
  4. package/dist/clientConfiguration/clientConfiguration.js +2 -0
  5. package/dist/clientConfiguration/clientConfiguration.js.map +1 -0
  6. package/dist/clientConfiguration/constants.d.ts +2 -0
  7. package/dist/clientConfiguration/constants.js +2 -0
  8. package/dist/clientConfiguration/constants.js.map +1 -0
  9. package/dist/clientConfiguration/index.d.ts +2 -0
  10. package/dist/clientConfiguration/index.js +2 -0
  11. package/dist/clientConfiguration/index.js.map +1 -0
  12. package/dist/{campaignConfiguration → clientConfiguration}/types.d.ts +12 -53
  13. package/dist/clientConfiguration/types.js +2 -0
  14. package/dist/clientConfiguration/types.js.map +1 -0
  15. package/dist/clientSettings/clientSettings.js +1 -1
  16. package/dist/clientSettings/clientSettings.js.map +1 -1
  17. package/dist/constants.d.ts +3 -2
  18. package/dist/constants.js +1 -4
  19. package/dist/constants.js.map +1 -1
  20. package/dist/eventSource/externalEventSource.js +1 -1
  21. package/dist/eventSource/externalEventSource.js.map +1 -1
  22. package/dist/hasher/hasher.d.ts +2 -3
  23. package/dist/hasher/hasher.js +1 -6
  24. package/dist/hasher/hasher.js.map +1 -1
  25. package/dist/hasher/types.d.ts +3 -10
  26. package/dist/hasher/types.js.map +1 -1
  27. package/dist/index.d.ts +7 -6
  28. package/dist/index.js +1 -1
  29. package/dist/index.js.map +1 -1
  30. package/dist/kameleoonClient.d.ts +44 -80
  31. package/dist/kameleoonClient.js +1 -18
  32. package/dist/kameleoonClient.js.map +1 -1
  33. package/dist/kameleoonData/applicationVersion.d.ts +26 -0
  34. package/dist/kameleoonData/applicationVersion.js +2 -0
  35. package/dist/kameleoonData/applicationVersion.js.map +1 -0
  36. package/dist/kameleoonData/browser.d.ts +16 -1
  37. package/dist/kameleoonData/browser.js +1 -17
  38. package/dist/kameleoonData/browser.js.map +1 -1
  39. package/dist/kameleoonData/constants.d.ts +4 -0
  40. package/dist/kameleoonData/constants.js +2 -0
  41. package/dist/kameleoonData/constants.js.map +1 -0
  42. package/dist/kameleoonData/conversion.d.ts +14 -1
  43. package/dist/kameleoonData/conversion.js +1 -13
  44. package/dist/kameleoonData/conversion.js.map +1 -1
  45. package/dist/kameleoonData/cookie.d.ts +33 -0
  46. package/dist/kameleoonData/cookie.js +2 -0
  47. package/dist/kameleoonData/cookie.js.map +1 -0
  48. package/dist/kameleoonData/customData.d.ts +14 -1
  49. package/dist/kameleoonData/customData.js +1 -24
  50. package/dist/kameleoonData/customData.js.map +1 -1
  51. package/dist/kameleoonData/dataManager.d.ts +38 -0
  52. package/dist/kameleoonData/dataManager.js +2 -0
  53. package/dist/kameleoonData/dataManager.js.map +1 -0
  54. package/dist/kameleoonData/dataProcessor.d.ts +26 -0
  55. package/dist/kameleoonData/dataProcessor.js +2 -0
  56. package/dist/kameleoonData/dataProcessor.js.map +1 -0
  57. package/dist/kameleoonData/device.d.ts +14 -1
  58. package/dist/kameleoonData/device.js +1 -13
  59. package/dist/kameleoonData/device.js.map +1 -1
  60. package/dist/kameleoonData/geolocation.d.ts +52 -0
  61. package/dist/kameleoonData/geolocation.js +2 -0
  62. package/dist/kameleoonData/geolocation.js.map +1 -0
  63. package/dist/kameleoonData/helpers.d.ts +1 -0
  64. package/dist/kameleoonData/helpers.js +2 -0
  65. package/dist/kameleoonData/helpers.js.map +1 -0
  66. package/dist/kameleoonData/index.d.ts +10 -3
  67. package/dist/kameleoonData/index.js +1 -1
  68. package/dist/kameleoonData/index.js.map +1 -1
  69. package/dist/kameleoonData/operatingSystem.d.ts +34 -0
  70. package/dist/kameleoonData/operatingSystem.js +2 -0
  71. package/dist/kameleoonData/operatingSystem.js.map +1 -0
  72. package/dist/kameleoonData/pageView.d.ts +20 -1
  73. package/dist/kameleoonData/pageView.js +1 -13
  74. package/dist/kameleoonData/pageView.js.map +1 -1
  75. package/dist/kameleoonData/types.d.ts +118 -9
  76. package/dist/kameleoonData/types.js +1 -14
  77. package/dist/kameleoonData/types.js.map +1 -1
  78. package/dist/kameleoonData/userAgent.d.ts +6 -1
  79. package/dist/kameleoonData/userAgent.js +1 -8
  80. package/dist/kameleoonData/userAgent.js.map +1 -1
  81. package/dist/kameleoonData/visitsData.d.ts +34 -0
  82. package/dist/{variationConfiguration/variation.js → kameleoonData/visitsData.js} +2 -7
  83. package/dist/kameleoonData/visitsData.js.map +1 -0
  84. package/dist/kameleoonError/constants.d.ts +5 -4
  85. package/dist/kameleoonError/constants.js +1 -1
  86. package/dist/kameleoonError/constants.js.map +1 -1
  87. package/dist/kameleoonError/kameleoonError.d.ts +5 -4
  88. package/dist/kameleoonError/kameleoonError.js +1 -4
  89. package/dist/kameleoonError/kameleoonError.js.map +1 -1
  90. package/dist/kameleoonError/types.d.ts +8 -3
  91. package/dist/kameleoonError/types.js +1 -1
  92. package/dist/kameleoonError/types.js.map +1 -1
  93. package/dist/kameleoonUtils.js +1 -4
  94. package/dist/kameleoonUtils.js.map +1 -1
  95. package/dist/requester/constants.d.ts +2 -1
  96. package/dist/requester/constants.js +1 -1
  97. package/dist/requester/constants.js.map +1 -1
  98. package/dist/requester/index.d.ts +1 -1
  99. package/dist/requester/index.js +1 -1
  100. package/dist/requester/index.js.map +1 -1
  101. package/dist/requester/requester.d.ts +5 -4
  102. package/dist/requester/requester.js +1 -1
  103. package/dist/requester/requester.js.map +1 -1
  104. package/dist/requester/types.d.ts +73 -8
  105. package/dist/requester/types.js +1 -1
  106. package/dist/requester/types.js.map +1 -1
  107. package/dist/storage/constants.d.ts +1 -0
  108. package/dist/storage/constants.js +1 -4
  109. package/dist/storage/constants.js.map +1 -1
  110. package/dist/storage/index.d.ts +1 -1
  111. package/dist/storage/index.js +1 -1
  112. package/dist/storage/index.js.map +1 -1
  113. package/dist/storage/types.d.ts +5 -8
  114. package/dist/storage/types.js.map +1 -1
  115. package/dist/targeting/conditions/applicationVersion.d.ts +10 -0
  116. package/dist/targeting/conditions/applicationVersion.js +2 -0
  117. package/dist/targeting/conditions/applicationVersion.js.map +1 -0
  118. package/dist/targeting/conditions/{browserCondition.d.ts → browser.d.ts} +1 -1
  119. package/dist/targeting/conditions/browser.js +2 -0
  120. package/dist/targeting/conditions/browser.js.map +1 -0
  121. package/dist/targeting/conditions/conditionFactory.js +1 -1
  122. package/dist/targeting/conditions/conditionFactory.js.map +1 -1
  123. package/dist/targeting/conditions/{conversionCondition.d.ts → conversion.d.ts} +1 -2
  124. package/dist/targeting/conditions/conversion.js +2 -0
  125. package/dist/targeting/conditions/conversion.js.map +1 -0
  126. package/dist/targeting/conditions/cookie.d.ts +15 -0
  127. package/dist/targeting/conditions/cookie.js +2 -0
  128. package/dist/targeting/conditions/cookie.js.map +1 -0
  129. package/dist/targeting/conditions/{customDataCondition.d.ts → customData.d.ts} +1 -1
  130. package/dist/targeting/conditions/customData.js +2 -0
  131. package/dist/targeting/conditions/customData.js.map +1 -0
  132. package/dist/targeting/conditions/{deviceCondition.d.ts → device.d.ts} +1 -1
  133. package/dist/targeting/conditions/{targetExperimentCondition.js → device.js} +2 -2
  134. package/dist/targeting/conditions/device.js.map +1 -0
  135. package/dist/targeting/conditions/{exclusiveExperimentCondition.d.ts → exclusiveCampaign.d.ts} +2 -2
  136. package/dist/targeting/conditions/exclusiveCampaign.js +2 -0
  137. package/dist/targeting/conditions/exclusiveCampaign.js.map +1 -0
  138. package/dist/targeting/conditions/firstVisit.d.ts +12 -0
  139. package/dist/targeting/conditions/firstVisit.js +2 -0
  140. package/dist/targeting/conditions/firstVisit.js.map +1 -0
  141. package/dist/targeting/conditions/geolocation.d.ts +11 -0
  142. package/dist/targeting/conditions/geolocation.js +2 -0
  143. package/dist/targeting/conditions/geolocation.js.map +1 -0
  144. package/dist/targeting/conditions/index.d.ts +22 -10
  145. package/dist/targeting/conditions/index.js +1 -1
  146. package/dist/targeting/conditions/index.js.map +1 -1
  147. package/dist/targeting/conditions/lastVisit.d.ts +12 -0
  148. package/dist/targeting/conditions/lastVisit.js +2 -0
  149. package/dist/targeting/conditions/lastVisit.js.map +1 -0
  150. package/dist/targeting/conditions/newVisitor.d.ts +9 -0
  151. package/dist/targeting/conditions/newVisitor.js +2 -0
  152. package/dist/targeting/conditions/newVisitor.js.map +1 -0
  153. package/dist/targeting/conditions/operatingSystem.d.ts +9 -0
  154. package/dist/targeting/conditions/{deviceCondition.js → operatingSystem.js} +2 -2
  155. package/dist/targeting/conditions/operatingSystem.js.map +1 -0
  156. package/dist/targeting/conditions/{pageTitleCondition.d.ts → pageTitle.d.ts} +1 -1
  157. package/dist/targeting/conditions/pageTitle.js +2 -0
  158. package/dist/targeting/conditions/pageTitle.js.map +1 -0
  159. package/dist/targeting/conditions/{pageUrlCondition.d.ts → pageUrl.d.ts} +1 -1
  160. package/dist/targeting/conditions/pageUrl.js +2 -0
  161. package/dist/targeting/conditions/pageUrl.js.map +1 -0
  162. package/dist/targeting/conditions/previousPage.d.ts +12 -0
  163. package/dist/targeting/conditions/previousPage.js +2 -0
  164. package/dist/targeting/conditions/previousPage.js.map +1 -0
  165. package/dist/targeting/conditions/sameDayVisits.d.ts +11 -0
  166. package/dist/targeting/conditions/sameDayVisits.js +2 -0
  167. package/dist/targeting/conditions/sameDayVisits.js.map +1 -0
  168. package/dist/targeting/conditions/{sdkLanguageCondition.d.ts → sdkLanguage.d.ts} +1 -4
  169. package/dist/targeting/conditions/sdkLanguage.js +2 -0
  170. package/dist/targeting/conditions/sdkLanguage.js.map +1 -0
  171. package/dist/targeting/conditions/segment.d.ts +9 -0
  172. package/dist/targeting/conditions/segment.js +2 -0
  173. package/dist/targeting/conditions/segment.js.map +1 -0
  174. package/dist/targeting/conditions/targetFeatureFlag.d.ts +11 -0
  175. package/dist/targeting/conditions/targetFeatureFlag.js +2 -0
  176. package/dist/targeting/conditions/targetFeatureFlag.js.map +1 -0
  177. package/dist/targeting/conditions/types.d.ts +20 -13
  178. package/dist/targeting/conditions/types.js.map +1 -1
  179. package/dist/targeting/conditions/visitedPages.d.ts +11 -0
  180. package/dist/targeting/conditions/visitedPages.js +2 -0
  181. package/dist/targeting/conditions/visitedPages.js.map +1 -0
  182. package/dist/targeting/conditions/{visitorCodeCondition.d.ts → visitorCode.d.ts} +1 -1
  183. package/dist/targeting/conditions/visitorCode.js +2 -0
  184. package/dist/targeting/conditions/visitorCode.js.map +1 -0
  185. package/dist/targeting/conditions/visits.d.ts +11 -0
  186. package/dist/targeting/conditions/visits.js +2 -0
  187. package/dist/targeting/conditions/visits.js.map +1 -0
  188. package/dist/targeting/index.d.ts +3 -3
  189. package/dist/targeting/index.js +1 -1
  190. package/dist/targeting/index.js.map +1 -1
  191. package/dist/targeting/{targetingNode.d.ts → node.d.ts} +7 -7
  192. package/dist/targeting/node.js +2 -0
  193. package/dist/targeting/node.js.map +1 -0
  194. package/dist/targeting/{targetingTree.d.ts → tree.d.ts} +6 -3
  195. package/dist/targeting/tree.js +2 -0
  196. package/dist/targeting/tree.js.map +1 -0
  197. package/dist/targeting/types.d.ts +30 -8
  198. package/dist/targeting/types.js +1 -1
  199. package/dist/targeting/types.js.map +1 -1
  200. package/dist/types.d.ts +17 -6
  201. package/dist/types.js +1 -41
  202. package/dist/types.js.map +1 -1
  203. package/dist/utilities/index.d.ts +1 -0
  204. package/dist/utilities/index.js +1 -1
  205. package/dist/utilities/index.js.map +1 -1
  206. package/dist/utilities/types.d.ts +61 -6
  207. package/dist/utilities/types.js +1 -1
  208. package/dist/utilities/types.js.map +1 -1
  209. package/dist/utilities/utilities.d.ts +24 -11
  210. package/dist/utilities/utilities.js +1 -1
  211. package/dist/utilities/utilities.js.map +1 -1
  212. package/dist/variationConfiguration/index.d.ts +1 -1
  213. package/dist/variationConfiguration/index.js +1 -1
  214. package/dist/variationConfiguration/index.js.map +1 -1
  215. package/dist/variationConfiguration/types.d.ts +5 -12
  216. package/dist/variationConfiguration/types.js.map +1 -1
  217. package/dist/variationConfiguration/variationConfiguration.d.ts +13 -21
  218. package/dist/variationConfiguration/variationConfiguration.js +1 -65
  219. package/dist/variationConfiguration/variationConfiguration.js.map +1 -1
  220. package/package.json +1 -1
  221. package/dist/campaignConfiguration/campaignConfiguration.d.ts +0 -71
  222. package/dist/campaignConfiguration/campaignConfiguration.js +0 -24
  223. package/dist/campaignConfiguration/campaignConfiguration.js.map +0 -1
  224. package/dist/campaignConfiguration/constants.d.ts +0 -6
  225. package/dist/campaignConfiguration/constants.js +0 -4
  226. package/dist/campaignConfiguration/constants.js.map +0 -1
  227. package/dist/campaignConfiguration/index.d.ts +0 -3
  228. package/dist/campaignConfiguration/index.js +0 -2
  229. package/dist/campaignConfiguration/index.js.map +0 -1
  230. package/dist/campaignConfiguration/types.js +0 -2
  231. package/dist/campaignConfiguration/types.js.map +0 -1
  232. package/dist/targeting/conditions/browserCondition.js +0 -2
  233. package/dist/targeting/conditions/browserCondition.js.map +0 -1
  234. package/dist/targeting/conditions/conversionCondition.js +0 -4
  235. package/dist/targeting/conditions/conversionCondition.js.map +0 -1
  236. package/dist/targeting/conditions/customDataCondition.js +0 -8
  237. package/dist/targeting/conditions/customDataCondition.js.map +0 -1
  238. package/dist/targeting/conditions/deviceCondition.js.map +0 -1
  239. package/dist/targeting/conditions/exclusiveExperimentCondition.js +0 -2
  240. package/dist/targeting/conditions/exclusiveExperimentCondition.js.map +0 -1
  241. package/dist/targeting/conditions/pageTitleCondition.js +0 -2
  242. package/dist/targeting/conditions/pageTitleCondition.js.map +0 -1
  243. package/dist/targeting/conditions/pageUrlCondition.js +0 -2
  244. package/dist/targeting/conditions/pageUrlCondition.js.map +0 -1
  245. package/dist/targeting/conditions/sdkLanguageCondition.js +0 -2
  246. package/dist/targeting/conditions/sdkLanguageCondition.js.map +0 -1
  247. package/dist/targeting/conditions/targetExperimentCondition.d.ts +0 -12
  248. package/dist/targeting/conditions/targetExperimentCondition.js.map +0 -1
  249. package/dist/targeting/conditions/visitorCodeCondition.js +0 -2
  250. package/dist/targeting/conditions/visitorCodeCondition.js.map +0 -1
  251. package/dist/targeting/targetingNode.js +0 -2
  252. package/dist/targeting/targetingNode.js.map +0 -1
  253. package/dist/targeting/targetingTree.js +0 -35
  254. package/dist/targeting/targetingTree.js.map +0 -1
  255. package/dist/variationConfiguration/variation.d.ts +0 -13
  256. package/dist/variationConfiguration/variation.js.map +0 -1
@@ -1,6 +1,8 @@
1
- import { JSONType, FeatureFlagType, ConfigurationDataType } from '../campaignConfiguration';
1
+ import { JSONType, FeatureFlagType, ConfigurationDataType } from '../clientConfiguration';
2
2
  import { Environment, ExternalPackageInfoType } from '../types';
3
+ import { BrowserIndexMap, BrowserType, OperatingSystemType } from '../kameleoonData';
3
4
  import { Header } from './constants';
5
+ import { DeviceType, OperatingSystemIndexMap } from '../kameleoonData/types';
4
6
  export type RequesterParamsType = {
5
7
  siteCode: string;
6
8
  environment?: Environment;
@@ -20,13 +22,15 @@ export type TrackDataParamsType = {
20
22
  body: string;
21
23
  userAgent?: string;
22
24
  };
23
- type CustomDataEventType = {
24
- sdk: {
25
+ type EventDataType = {
26
+ sdk?: {
25
27
  name: string;
26
28
  version: string;
27
29
  };
28
30
  itp: boolean;
29
31
  time: number;
32
+ };
33
+ type CustomDataEventType = {
30
34
  data: {
31
35
  index: number;
32
36
  valuesCountMap: {
@@ -35,14 +39,75 @@ type CustomDataEventType = {
35
39
  overwrite: boolean;
36
40
  mappingIdentifier: boolean;
37
41
  };
38
- };
42
+ } & EventDataType;
43
+ type ExperimentEventType = {
44
+ data: {
45
+ id: number;
46
+ variationId: number;
47
+ };
48
+ } & EventDataType;
49
+ type ConversionEventType = {
50
+ data: {
51
+ goalId: number;
52
+ revenue: number;
53
+ negative: boolean;
54
+ };
55
+ } & EventDataType;
56
+ type BrowserIndexType = (typeof BrowserIndexMap)[BrowserType];
57
+ type OperatingSystemIndexType = (typeof OperatingSystemIndexMap)[OperatingSystemType];
58
+ export type PageEventType = {
59
+ data: {
60
+ href: string;
61
+ canonicalHref: string | null;
62
+ title: string;
63
+ keyPagesIndices: number[] | [null];
64
+ referrerHref: string | null;
65
+ referrersIndices: number[] | [null];
66
+ };
67
+ } & EventDataType;
68
+ export type GeolocationEventType = {
69
+ data: {
70
+ country: string;
71
+ region: string | null;
72
+ city: string | null;
73
+ postalCode: string | null;
74
+ latitude: number | null;
75
+ longitude: number | null;
76
+ };
77
+ } & EventDataType;
78
+ export type StaticDataEventType = {
79
+ data: {
80
+ visitNumber: number;
81
+ timeSincePreviousVisit: number;
82
+ firstReferrerHref: string | null;
83
+ browser: BrowserType | null;
84
+ browserIndex: BrowserIndexType | null;
85
+ browserVersion: number | null;
86
+ os: OperatingSystemType | null;
87
+ osIndex: OperatingSystemIndexType | null;
88
+ windowWidth: number | null;
89
+ windowHeight: number | null;
90
+ screenWidth: number | null;
91
+ screenHeight: number | null;
92
+ timeZoneId: string | null;
93
+ localeLanguageTag: string | null;
94
+ deviceType: DeviceType | null;
95
+ mappingIdentifier: string | null;
96
+ };
97
+ } & EventDataType;
39
98
  export type VisitType = {
40
99
  siteCode: string;
41
100
  visitorCode: string;
42
- customDataEvents: CustomDataEventType[];
101
+ timeStarted: number;
102
+ customDataEvents?: CustomDataEventType[];
103
+ experimentEvents?: ExperimentEventType[];
104
+ conversionEvents?: ConversionEventType[];
105
+ geolocationEvents?: GeolocationEventType[];
106
+ staticDataEvent?: StaticDataEventType;
107
+ pageEvents?: PageEventType[];
43
108
  };
44
109
  export type GetVisitorDataResultType = {
45
- previousVisits?: [VisitType];
110
+ previousVisits?: VisitType[];
46
111
  currentVisit?: VisitType;
47
112
  };
48
113
  export type GetClientConfigurationResultType = Omit<ConfigurationDataType, 'featureFlags'> & {
@@ -52,8 +117,8 @@ export declare enum HttpMethod {
52
117
  Get = "GET",
53
118
  Post = "POST"
54
119
  }
55
- declare const EVENT_TYPE_KEYS: readonly ["customData", "staticData", "page", "conversion", "activity", "experiment"];
56
- declare const PARAMETER_KEYS: readonly ["valuesCountMap", "id", "nonce", "sdkName", "sdkVersion", "browserIndex", "browserVersion", "siteCode", "environment", "visitorCode", "currentVisit", "maxNumberPreviousVisits", "customData", "negative", "revenue", "title", "referrersIndices", "overwrite", "index", "href", "variationId", "deviceType", "goalId", "ts", "key"];
120
+ declare const EVENT_TYPE_KEYS: readonly ["customData", "staticData", "page", "conversion", "geolocation", "activity", "experiment"];
121
+ declare const PARAMETER_KEYS: readonly ["valuesCountMap", "id", "nonce", "country", "city", "region", "latitude", "geolocation", "longitude", "postalCode", "sdkName", "sdkVersion", "browserIndex", "browserVersion", "siteCode", "environment", "visitorCode", "currentVisit", "maxNumberPreviousVisits", "customData", "negative", "revenue", "title", "os", "conversion", "staticData", "osIndex", "browser", "referrersIndices", "overwrite", "index", "href", "experiment", "page", "variationId", "deviceType", "goalId", "ts", "key"];
57
122
  declare const TRACKING_KEYS: readonly ["visit", "map"];
58
123
  declare const QUERY_KEYS: readonly ["sse", "visitor", "mobile", "map", "events"];
59
124
  export type TrackingType = Record<Capitalize<(typeof TRACKING_KEYS)[number]>, string>;
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.HttpMethod=void 0;var HttpMethod=/*#__PURE__*/function(a){return a.Get="GET",a.Post="POST",a}({});exports.HttpMethod=HttpMethod;var EVENT_TYPE_KEYS=["customData","staticData","page","conversion","activity","experiment"],PARAMETER_KEYS=["valuesCountMap","id","nonce","sdkName","sdkVersion","browserIndex","browserVersion","siteCode","environment","visitorCode","currentVisit","maxNumberPreviousVisits","customData","negative","revenue","title","referrersIndices","overwrite","index","href","variationId","deviceType","goalId","ts","key"],TRACKING_KEYS=["visit","map"],QUERY_KEYS=["sse","visitor","mobile","map","events"];
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.HttpMethod=void 0;var HttpMethod=function(a){return a.Get="GET",a.Post="POST",a}({});exports.HttpMethod=HttpMethod;var EVENT_TYPE_KEYS=["customData","staticData","page","conversion","geolocation","activity","experiment"],PARAMETER_KEYS=["valuesCountMap","id","nonce","country","city","region","latitude","geolocation","longitude","postalCode","sdkName","sdkVersion","browserIndex","browserVersion","siteCode","environment","visitorCode","currentVisit","maxNumberPreviousVisits","customData","negative","revenue","title","os","conversion","staticData","osIndex","browser","referrersIndices","overwrite","index","href","experiment","page","variationId","deviceType","goalId","ts","key"],TRACKING_KEYS=["visit","map"],QUERY_KEYS=["sse","visitor","mobile","map","events"];
2
2
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":["HttpMethod","Get","Post","exports","EVENT_TYPE_KEYS","PARAMETER_KEYS","TRACKING_KEYS","QUERY_KEYS"],"sources":["../../src/requester/types.ts"],"sourcesContent":["import {\n JSONType,\n FeatureFlagType,\n ConfigurationDataType,\n} from 'src/campaignConfiguration';\nimport { Environment, ExternalPackageInfoType } from 'src/types';\nimport { Header } from './constants';\n\nexport type RequesterParamsType = {\n siteCode: string;\n environment?: Environment;\n packageInfo: ExternalPackageInfoType;\n requestDispatcher: IExternalRequestDispatcher;\n};\n\nexport type TrackExperimentParamsType = {\n body: string;\n variationId: number;\n visitorCode: string;\n experimentId: number;\n isUnallocated: boolean;\n userAgent?: string;\n};\n\nexport type TrackDataParamsType = {\n visitorCode: string;\n body: string;\n userAgent?: string;\n};\n\ntype CustomDataEventType = {\n sdk: {\n name: string;\n version: string;\n };\n itp: boolean;\n time: number;\n data: {\n index: number;\n valuesCountMap: {\n [value: string]: number;\n };\n overwrite: boolean;\n mappingIdentifier: boolean;\n };\n};\n\nexport type VisitType = {\n siteCode: string;\n visitorCode: string;\n customDataEvents: CustomDataEventType[];\n};\n\nexport type GetVisitorDataResultType = {\n previousVisits?: [VisitType];\n currentVisit?: VisitType;\n};\n\nexport type GetClientConfigurationResultType = Omit<\n ConfigurationDataType,\n 'featureFlags'\n> & { featureFlagConfigurations: FeatureFlagType[] };\n\nexport enum HttpMethod {\n Get = 'GET',\n Post = 'POST',\n}\n\nconst EVENT_TYPE_KEYS = [\n 'customData',\n 'staticData',\n 'page',\n 'conversion',\n 'activity',\n 'experiment',\n] as const;\nconst PARAMETER_KEYS = [\n 'valuesCountMap',\n 'id',\n 'nonce',\n 'sdkName',\n 'sdkVersion',\n 'browserIndex',\n 'browserVersion',\n 'siteCode',\n 'environment',\n 'visitorCode',\n 'currentVisit',\n 'maxNumberPreviousVisits',\n 'customData',\n 'negative',\n 'revenue',\n 'title',\n 'referrersIndices',\n 'overwrite',\n 'index',\n 'href',\n 'variationId',\n 'deviceType',\n 'goalId',\n 'ts',\n 'key',\n] as const;\nconst TRACKING_KEYS = ['visit', 'map'] as const;\nconst QUERY_KEYS = ['sse', 'visitor', 'mobile', 'map', 'events'] as const;\n\nexport type TrackingType = Record<\n Capitalize<(typeof TRACKING_KEYS)[number]>,\n string\n>;\nexport type QueryType = Record<Capitalize<(typeof QUERY_KEYS)[number]>, string>;\nexport type ParameterType = Record<\n Capitalize<(typeof PARAMETER_KEYS)[number]>,\n string\n>;\nexport type EventType = Record<\n Capitalize<(typeof EVENT_TYPE_KEYS)[number]>,\n string\n>;\n\nexport type StrictTrackingRecord<T> = {\n [K in keyof T]: `${Uncapitalize<K & string>}/`;\n};\nexport type StrictQueryRecord<T> = {\n [K in keyof T]: `${Uncapitalize<K & string>}?siteCode=`;\n};\nexport type StrictEventTypeRecord<T> = {\n [K in keyof T]: `eventType=${Uncapitalize<K & string>}`;\n};\nexport type StrictParameterRecord<T> = {\n [K in keyof T]: `&${Uncapitalize<K & string>}=`;\n};\n\nexport type TrackParametersType = {\n url: string;\n headers?: Partial<Record<Header, string>>;\n body: string;\n};\n\n/**\n * @interface an interface of External Request Dispatcher which will be used to perform requests.\n * */\nexport interface IExternalRequestDispatcher {\n /**\n * @method track - send a track request\n * @param {TrackParametersType} parameters - track parameters\n * */\n track: (params: TrackParametersType) => Promise<boolean>;\n /**\n * @method getClientConfiguration - get client configuration\n * @param {string} url - url address\n * */\n getClientConfiguration: (url: string) => Promise<JSONType>;\n /**\n * @method getRemoteData - get data from remote server of Kameleoon\n * @param {string} url - url address\n * */\n getRemoteData: (url: string) => Promise<JSONType>;\n}\n"],"mappings":"iGA+DY,CAAAA,UAAU,uBAAVA,CAAU,QAAV,CAAAA,CAAU,CAAAC,GAAA,OAAVD,CAAU,CAAAE,IAAA,QAAVF,CAAU,MAAAG,OAAA,CAAAH,UAAA,CAAAA,UAAA,IAKhB,CAAAI,eAAe,CAAG,CACtB,YAAY,CACZ,YAAY,CACZ,MAAM,CACN,YAAY,CACZ,UAAU,CACV,YAAY,CACJ,CACJC,cAAc,CAAG,CACrB,gBAAgB,CAChB,IAAI,CACJ,OAAO,CACP,SAAS,CACT,YAAY,CACZ,cAAc,CACd,gBAAgB,CAChB,UAAU,CACV,aAAa,CACb,aAAa,CACb,cAAc,CACd,yBAAyB,CACzB,YAAY,CACZ,UAAU,CACV,SAAS,CACT,OAAO,CACP,kBAAkB,CAClB,WAAW,CACX,OAAO,CACP,MAAM,CACN,aAAa,CACb,YAAY,CACZ,QAAQ,CACR,IAAI,CACJ,KAAK,CACG,CACJC,aAAa,CAAG,CAAC,OAAO,CAAE,KAAK,CAAU,CACzCC,UAAU,CAAG,CAAC,KAAK,CAAE,SAAS,CAAE,QAAQ,CAAE,KAAK,CAAE,QAAQ,CAAU"}
1
+ {"version":3,"file":"types.js","names":["HttpMethod","Get","Post","exports","EVENT_TYPE_KEYS","PARAMETER_KEYS","TRACKING_KEYS","QUERY_KEYS"],"sources":["../../src/requester/types.ts"],"sourcesContent":["import {\n JSONType,\n FeatureFlagType,\n ConfigurationDataType,\n} from 'src/clientConfiguration';\nimport { Environment, ExternalPackageInfoType } from 'src/types';\nimport {\n BrowserIndexMap,\n BrowserType,\n OperatingSystemType,\n} from 'src/kameleoonData';\nimport { Header } from './constants';\nimport { DeviceType, OperatingSystemIndexMap } from 'src/kameleoonData/types';\n\nexport type RequesterParamsType = {\n siteCode: string;\n environment?: Environment;\n packageInfo: ExternalPackageInfoType;\n requestDispatcher: IExternalRequestDispatcher;\n};\n\nexport type TrackExperimentParamsType = {\n body: string;\n variationId: number;\n visitorCode: string;\n experimentId: number;\n isUnallocated: boolean;\n userAgent?: string;\n};\n\nexport type TrackDataParamsType = {\n visitorCode: string;\n body: string;\n userAgent?: string;\n};\n\ntype EventDataType = {\n sdk?: {\n name: string;\n version: string;\n };\n itp: boolean;\n time: number;\n};\n\ntype CustomDataEventType = {\n data: {\n index: number;\n valuesCountMap: {\n [value: string]: number;\n };\n overwrite: boolean;\n mappingIdentifier: boolean;\n };\n} & EventDataType;\n\ntype ExperimentEventType = {\n data: {\n id: number;\n variationId: number;\n };\n} & EventDataType;\n\ntype ConversionEventType = {\n data: {\n goalId: number;\n revenue: number;\n negative: boolean;\n };\n} & EventDataType;\n\ntype BrowserIndexType = (typeof BrowserIndexMap)[BrowserType];\ntype OperatingSystemIndexType =\n (typeof OperatingSystemIndexMap)[OperatingSystemType];\n\nexport type PageEventType = {\n data: {\n href: string;\n canonicalHref: string | null;\n title: string;\n keyPagesIndices: number[] | [null];\n referrerHref: string | null;\n referrersIndices: number[] | [null];\n };\n} & EventDataType;\n\nexport type GeolocationEventType = {\n data: {\n country: string;\n region: string | null;\n city: string | null;\n postalCode: string | null;\n latitude: number | null;\n longitude: number | null;\n };\n} & EventDataType;\n\nexport type StaticDataEventType = {\n data: {\n visitNumber: number;\n timeSincePreviousVisit: number;\n firstReferrerHref: string | null;\n browser: BrowserType | null;\n browserIndex: BrowserIndexType | null;\n browserVersion: number | null;\n os: OperatingSystemType | null;\n osIndex: OperatingSystemIndexType | null;\n windowWidth: number | null;\n windowHeight: number | null;\n screenWidth: number | null;\n screenHeight: number | null;\n timeZoneId: string | null;\n localeLanguageTag: string | null;\n deviceType: DeviceType | null;\n mappingIdentifier: string | null;\n };\n} & EventDataType;\n\nexport type VisitType = {\n siteCode: string;\n visitorCode: string;\n timeStarted: number;\n customDataEvents?: CustomDataEventType[];\n experimentEvents?: ExperimentEventType[];\n conversionEvents?: ConversionEventType[];\n geolocationEvents?: GeolocationEventType[];\n staticDataEvent?: StaticDataEventType;\n pageEvents?: PageEventType[];\n};\n\nexport type GetVisitorDataResultType = {\n previousVisits?: VisitType[];\n currentVisit?: VisitType;\n};\n\nexport type GetClientConfigurationResultType = Omit<\n ConfigurationDataType,\n 'featureFlags'\n> & { featureFlagConfigurations: FeatureFlagType[] };\n\nexport enum HttpMethod {\n Get = 'GET',\n Post = 'POST',\n}\n\nconst EVENT_TYPE_KEYS = [\n 'customData',\n 'staticData',\n 'page',\n 'conversion',\n 'geolocation',\n 'activity',\n 'experiment',\n] as const;\nconst PARAMETER_KEYS = [\n 'valuesCountMap',\n 'id',\n 'nonce',\n 'country',\n 'city',\n 'region',\n 'latitude',\n 'geolocation',\n 'longitude',\n 'postalCode',\n 'sdkName',\n 'sdkVersion',\n 'browserIndex',\n 'browserVersion',\n 'siteCode',\n 'environment',\n 'visitorCode',\n 'currentVisit',\n 'maxNumberPreviousVisits',\n 'customData',\n 'negative',\n 'revenue',\n 'title',\n 'os',\n 'conversion',\n 'staticData',\n 'osIndex',\n 'browser',\n 'referrersIndices',\n 'overwrite',\n 'index',\n 'href',\n 'experiment',\n 'page',\n 'variationId',\n 'deviceType',\n 'goalId',\n 'ts',\n 'key',\n] as const;\nconst TRACKING_KEYS = ['visit', 'map'] as const;\nconst QUERY_KEYS = ['sse', 'visitor', 'mobile', 'map', 'events'] as const;\n\nexport type TrackingType = Record<\n Capitalize<(typeof TRACKING_KEYS)[number]>,\n string\n>;\nexport type QueryType = Record<Capitalize<(typeof QUERY_KEYS)[number]>, string>;\nexport type ParameterType = Record<\n Capitalize<(typeof PARAMETER_KEYS)[number]>,\n string\n>;\nexport type EventType = Record<\n Capitalize<(typeof EVENT_TYPE_KEYS)[number]>,\n string\n>;\n\nexport type StrictTrackingRecord<T> = {\n [K in keyof T]: `${Uncapitalize<K & string>}/`;\n};\nexport type StrictQueryRecord<T> = {\n [K in keyof T]: `${Uncapitalize<K & string>}?siteCode=`;\n};\nexport type StrictEventTypeRecord<T> = {\n [K in keyof T]: `eventType=${Uncapitalize<K & string>}`;\n};\nexport type StrictParameterRecord<T> = {\n [K in keyof T]: `&${Uncapitalize<K & string>}=`;\n};\n\nexport type TrackParametersType = {\n url: string;\n headers?: Partial<Record<Header, string>>;\n body: string;\n};\n\n/**\n * @interface an interface of External Request Dispatcher which will be used to perform requests.\n * */\nexport interface IExternalRequestDispatcher {\n /**\n * @method track - send a track request\n * @param {TrackParametersType} parameters - track parameters\n * */\n track: (params: TrackParametersType) => Promise<boolean>;\n /**\n * @method getClientConfiguration - get client configuration\n * @param {string} url - url address\n * */\n getClientConfiguration: (url: string) => Promise<JSONType>;\n /**\n * @method getRemoteData - get data from remote server of Kameleoon\n * @param {string} url - url address\n * */\n getRemoteData: (url: string) => Promise<JSONType>;\n}\n"],"mappings":"iGA4IY,CAAAA,UAAU,UAAVA,CAAU,QAAV,CAAAA,CAAU,CAAAC,GAAA,OAAVD,CAAU,CAAAE,IAAA,QAAVF,CAAU,MAAAG,OAAA,CAAAH,UAAA,CAAAA,UAAA,IAKhB,CAAAI,eAAe,CAAG,CACtB,YAAY,CACZ,YAAY,CACZ,MAAM,CACN,YAAY,CACZ,aAAa,CACb,UAAU,CACV,YAAY,CACJ,CACJC,cAAc,CAAG,CACrB,gBAAgB,CAChB,IAAI,CACJ,OAAO,CACP,SAAS,CACT,MAAM,CACN,QAAQ,CACR,UAAU,CACV,aAAa,CACb,WAAW,CACX,YAAY,CACZ,SAAS,CACT,YAAY,CACZ,cAAc,CACd,gBAAgB,CAChB,UAAU,CACV,aAAa,CACb,aAAa,CACb,cAAc,CACd,yBAAyB,CACzB,YAAY,CACZ,UAAU,CACV,SAAS,CACT,OAAO,CACP,IAAI,CACJ,YAAY,CACZ,YAAY,CACZ,SAAS,CACT,SAAS,CACT,kBAAkB,CAClB,WAAW,CACX,OAAO,CACP,MAAM,CACN,YAAY,CACZ,MAAM,CACN,aAAa,CACb,YAAY,CACZ,QAAQ,CACR,IAAI,CACJ,KAAK,CACG,CACJC,aAAa,CAAG,CAAC,OAAO,CAAE,KAAK,CAAU,CACzCC,UAAU,CAAG,CAAC,KAAK,CAAE,SAAS,CAAE,QAAQ,CAAE,KAAK,CAAE,QAAQ,CAAU"}
@@ -4,6 +4,7 @@
4
4
  * */
5
5
  export declare enum KameleoonStorageKey {
6
6
  ClientData = "kameleoonClientData",
7
+ TargetingData = "kameleoonTargetingData",
7
8
  VariationData = "kameleoonVariationData",
8
9
  VisitorCode = "kameleoonVisitorCode",
9
10
  OfflineTracking = "kameleoonOfflineTracking"
@@ -1,5 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.KameleoonStorageKey=void 0;/**
2
- * @readonly
3
- * @enum {string} an Enum containing keys for Kameleoon SDK related data stored on storage
4
- * */var KameleoonStorageKey=/*#__PURE__*/function(a){return a.ClientData="kameleoonClientData",a.VariationData="kameleoonVariationData",a.VisitorCode="kameleoonVisitorCode",a.OfflineTracking="kameleoonOfflineTracking",a}({});exports.KameleoonStorageKey=KameleoonStorageKey;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.KameleoonStorageKey=void 0;var KameleoonStorageKey=function(a){return a.ClientData="kameleoonClientData",a.TargetingData="kameleoonTargetingData",a.VariationData="kameleoonVariationData",a.VisitorCode="kameleoonVisitorCode",a.OfflineTracking="kameleoonOfflineTracking",a}({});exports.KameleoonStorageKey=KameleoonStorageKey;
5
2
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","names":["KameleoonStorageKey","ClientData","VariationData","VisitorCode","OfflineTracking","exports"],"sources":["../../src/storage/constants.ts"],"sourcesContent":["/**\n * @readonly\n * @enum {string} an Enum containing keys for Kameleoon SDK related data stored on storage\n * */\nexport enum KameleoonStorageKey {\n ClientData = 'kameleoonClientData',\n VariationData = 'kameleoonVariationData',\n VisitorCode = 'kameleoonVisitorCode',\n OfflineTracking = 'kameleoonOfflineTracking',\n}\n"],"mappings":"uGAAA;AACA;AACA;AACA,KAHA,GAIY,CAAAA,mBAAmB,uBAAnBA,CAAmB,QAAnB,CAAAA,CAAmB,CAAAC,UAAA,uBAAnBD,CAAmB,CAAAE,aAAA,0BAAnBF,CAAmB,CAAAG,WAAA,wBAAnBH,CAAmB,CAAAI,eAAA,4BAAnBJ,CAAmB,MAAAK,OAAA,CAAAL,mBAAA,CAAAA,mBAAA"}
1
+ {"version":3,"file":"constants.js","names":["KameleoonStorageKey","ClientData","TargetingData","VariationData","VisitorCode","OfflineTracking","exports"],"sources":["../../src/storage/constants.ts"],"sourcesContent":["/**\n * @readonly\n * @enum {string} an Enum containing keys for Kameleoon SDK related data stored on storage\n * */\nexport enum KameleoonStorageKey {\n ClientData = 'kameleoonClientData',\n TargetingData = 'kameleoonTargetingData',\n VariationData = 'kameleoonVariationData',\n VisitorCode = 'kameleoonVisitorCode',\n OfflineTracking = 'kameleoonOfflineTracking',\n}\n"],"mappings":"0GAIY,CAAAA,mBAAmB,UAAnBA,CAAmB,QAAnB,CAAAA,CAAmB,CAAAC,UAAA,uBAAnBD,CAAmB,CAAAE,aAAA,0BAAnBF,CAAmB,CAAAG,aAAA,0BAAnBH,CAAmB,CAAAI,WAAA,wBAAnBJ,CAAmB,CAAAK,eAAA,4BAAnBL,CAAmB,MAAAM,OAAA,CAAAN,mBAAA,CAAAA,mBAAA"}
@@ -1,2 +1,2 @@
1
1
  export { KameleoonStorageKey } from './constants';
2
- export { ClientDataType, IExternalStorage, VariationDataType, StorageDataType, ExperimentVariationsType, IExternalStorageConstructor, } from './types';
2
+ export { ClientDataType, IExternalStorage, VariationDataType, StorageDataType, FeatureFlagVariationsType, IExternalStorageConstructor, } from './types';
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"ClientDataType",{enumerable:!0,get:function get(){return _types.ClientDataType}}),Object.defineProperty(exports,"ExperimentVariationsType",{enumerable:!0,get:function get(){return _types.ExperimentVariationsType}}),Object.defineProperty(exports,"IExternalStorage",{enumerable:!0,get:function get(){return _types.IExternalStorage}}),Object.defineProperty(exports,"IExternalStorageConstructor",{enumerable:!0,get:function get(){return _types.IExternalStorageConstructor}}),Object.defineProperty(exports,"KameleoonStorageKey",{enumerable:!0,get:function get(){return _constants.KameleoonStorageKey}}),Object.defineProperty(exports,"StorageDataType",{enumerable:!0,get:function get(){return _types.StorageDataType}}),Object.defineProperty(exports,"VariationDataType",{enumerable:!0,get:function get(){return _types.VariationDataType}});var _constants=require("./constants"),_types=require("./types");
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"ClientDataType",{enumerable:!0,get:function get(){return _types.ClientDataType}}),Object.defineProperty(exports,"FeatureFlagVariationsType",{enumerable:!0,get:function get(){return _types.FeatureFlagVariationsType}}),Object.defineProperty(exports,"IExternalStorage",{enumerable:!0,get:function get(){return _types.IExternalStorage}}),Object.defineProperty(exports,"IExternalStorageConstructor",{enumerable:!0,get:function get(){return _types.IExternalStorageConstructor}}),Object.defineProperty(exports,"KameleoonStorageKey",{enumerable:!0,get:function get(){return _constants.KameleoonStorageKey}}),Object.defineProperty(exports,"StorageDataType",{enumerable:!0,get:function get(){return _types.StorageDataType}}),Object.defineProperty(exports,"VariationDataType",{enumerable:!0,get:function get(){return _types.VariationDataType}});var _constants=require("./constants"),_types=require("./types");
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/storage/index.ts"],"sourcesContent":["export { KameleoonStorageKey } from './constants';\nexport {\n ClientDataType,\n IExternalStorage,\n VariationDataType,\n StorageDataType,\n ExperimentVariationsType,\n IExternalStorageConstructor,\n} from './types';\n"],"mappings":""}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/storage/index.ts"],"sourcesContent":["export { KameleoonStorageKey } from './constants';\nexport {\n ClientDataType,\n IExternalStorage,\n VariationDataType,\n StorageDataType,\n FeatureFlagVariationsType,\n IExternalStorageConstructor,\n} from './types';\n"],"mappings":""}
@@ -1,20 +1,17 @@
1
1
  import { Result } from 'ts-res';
2
- import { ConfigurationDataType } from '../campaignConfiguration';
2
+ import { ConfigurationDataType } from '../clientConfiguration';
3
3
  import { KameleoonError } from '../kameleoonError';
4
- import { VariationType } from '../variationConfiguration';
5
4
  import { KameleoonStorageKey } from './constants';
6
- import { TargetingDataType } from '../targeting';
7
5
  import { TrackDataParamsType, TrackExperimentParamsType } from '../requester/types';
8
6
  export type ClientDataType = {
9
- kameleoonTargetingData: TargetingDataType;
10
- kameleoonConfiguration: ConfigurationDataType;
7
+ data: ConfigurationDataType;
11
8
  lastUpdate: string;
12
9
  };
13
- export type ExperimentVariationsType = {
14
- [experimentId: string]: VariationType;
10
+ export type FeatureFlagVariationsType = {
11
+ [experimentId: string]: number;
15
12
  };
16
13
  export type VariationDataType = {
17
- [visitorCode: string]: ExperimentVariationsType;
14
+ [visitorCode: string]: FeatureFlagVariationsType;
18
15
  };
19
16
  type OfflineTrackingParameters = TrackDataParamsType | TrackExperimentParamsType;
20
17
  export type OfflineTracking = {
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../src/storage/types.ts"],"sourcesContent":["import { Result } from 'ts-res';\nimport { ConfigurationDataType } from 'src/campaignConfiguration';\nimport { KameleoonError } from 'src/kameleoonError';\nimport { VariationType } from 'src/variationConfiguration';\nimport { KameleoonStorageKey } from './constants';\nimport { TargetingDataType } from 'src/targeting';\nimport {\n TrackDataParamsType,\n TrackExperimentParamsType,\n} from 'src/requester/types';\n\nexport type ClientDataType = {\n kameleoonTargetingData: TargetingDataType;\n kameleoonConfiguration: ConfigurationDataType;\n lastUpdate: string;\n};\n\nexport type ExperimentVariationsType = {\n [experimentId: string]: VariationType;\n};\n\nexport type VariationDataType = {\n [visitorCode: string]: ExperimentVariationsType;\n};\n\ntype OfflineTrackingParameters =\n | TrackDataParamsType\n | TrackExperimentParamsType;\n\nexport type OfflineTracking = {\n requestParameters?: Array<\n OfflineTrackingParameters & { timestamp: number; isExperiment: boolean }\n >;\n};\n\n/**\n * @type StorageDataType - an enumeration type which represents a data stored on SDK storage\n *\n * `string` represents visitor code storage with only one string value\n * */\nexport type StorageDataType =\n | ClientDataType\n | VariationDataType\n | OfflineTracking\n | string;\n\n/**\n * @interface an interface of External Constructor for Storage which must be implemented by the wrapper constructor to initialize new `IExternalStorage` in order to be able to pass necessary initialization parameters\n * */\nexport interface IExternalStorageConstructor {\n /**\n * @method initialize - creates and instance of `IExternalStorage<StorageDataType>` and returns it\n *\n * Generic needs to be specified with a type for TypeScript to be able to infer concrete type based on enum variant\n * @param {KameleoonStorageKey} key - an enum variant containing keys for Kameleoon SDK related data stored on storage\n * @returns {IExternalStorage<StorageDataType>} an initialized instance of `IExternalStorage<StorageDataType>`\n * */\n initialize: <T extends StorageDataType>(\n key: KameleoonStorageKey,\n ) => IExternalStorage<T>;\n}\n\n/**\n * @interface an interface of External Storage which must be implemented to be used as external storage for initialized JS SDK Core.\n *\n * Generic `StorageDataType` needs to be specified with a type for TypeScript to be able to infer concrete type based on enum variant\n * However it's not constrained strictly by `StorageDataType` to let implementer use storage as a generic for other types\n * */\nexport interface IExternalStorage<T> {\n /**\n * @property key - an Enum `KameleoonStorageKey` variant containing a key for Kameleoon SDK related data stored on storage\n * */\n readonly key: KameleoonStorageKey;\n /**\n * @method read - reads data from the storage\n * @returns {Result<T, KameleoonError>} result with an `ok` boolean field indicated success or error. If result is ok contains `data` field with a type `T`, if not contains `error` field with a type of `KameleoonError`\n * */\n read: () => Result<T, KameleoonError>;\n /**\n * @method write - writes data to storage\n * @param {T} data - representation of any generic data type\n * @returns {Result<void, KameleoonError>} result with an `ok` boolean field indicated success or error. If result is ok contains an empty `data`, if not contains `error` field with a type of `KameleoonError`\n * */\n write: (data: T) => Result<void, KameleoonError>;\n}\n"],"mappings":""}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../src/storage/types.ts"],"sourcesContent":["import { Result } from 'ts-res';\nimport { ConfigurationDataType } from 'src/clientConfiguration';\nimport { KameleoonError } from 'src/kameleoonError';\nimport { KameleoonStorageKey } from './constants';\nimport {\n TrackDataParamsType,\n TrackExperimentParamsType,\n} from 'src/requester/types';\n\nexport type ClientDataType = {\n data: ConfigurationDataType;\n lastUpdate: string;\n};\n\nexport type FeatureFlagVariationsType = {\n [experimentId: string]: number;\n};\n\nexport type VariationDataType = {\n [visitorCode: string]: FeatureFlagVariationsType;\n};\n\ntype OfflineTrackingParameters =\n | TrackDataParamsType\n | TrackExperimentParamsType;\n\nexport type OfflineTracking = {\n requestParameters?: Array<\n OfflineTrackingParameters & { timestamp: number; isExperiment: boolean }\n >;\n};\n\n/**\n * @type StorageDataType - an enumeration type which represents a data stored on SDK storage\n *\n * `string` represents visitor code storage with only one string value\n * */\nexport type StorageDataType =\n | ClientDataType\n | VariationDataType\n | OfflineTracking\n | string;\n\n/**\n * @interface an interface of External Constructor for Storage which must be implemented by the wrapper constructor to initialize new `IExternalStorage` in order to be able to pass necessary initialization parameters\n * */\nexport interface IExternalStorageConstructor {\n /**\n * @method initialize - creates and instance of `IExternalStorage<StorageDataType>` and returns it\n *\n * Generic needs to be specified with a type for TypeScript to be able to infer concrete type based on enum variant\n * @param {KameleoonStorageKey} key - an enum variant containing keys for Kameleoon SDK related data stored on storage\n * @returns {IExternalStorage<StorageDataType>} an initialized instance of `IExternalStorage<StorageDataType>`\n * */\n initialize: <T extends StorageDataType>(\n key: KameleoonStorageKey,\n ) => IExternalStorage<T>;\n}\n\n/**\n * @interface an interface of External Storage which must be implemented to be used as external storage for initialized JS SDK Core.\n *\n * Generic `StorageDataType` needs to be specified with a type for TypeScript to be able to infer concrete type based on enum variant\n * However it's not constrained strictly by `StorageDataType` to let implementer use storage as a generic for other types\n * */\nexport interface IExternalStorage<T> {\n /**\n * @property key - an Enum `KameleoonStorageKey` variant containing a key for Kameleoon SDK related data stored on storage\n * */\n readonly key: KameleoonStorageKey;\n /**\n * @method read - reads data from the storage\n * @returns {Result<T, KameleoonError>} result with an `ok` boolean field indicated success or error. If result is ok contains `data` field with a type `T`, if not contains `error` field with a type of `KameleoonError`\n * */\n read: () => Result<T, KameleoonError>;\n /**\n * @method write - writes data to storage\n * @param {T} data - representation of any generic data type\n * @returns {Result<void, KameleoonError>} result with an `ok` boolean field indicated success or error. If result is ok contains an empty `data`, if not contains `error` field with a type of `KameleoonError`\n * */\n write: (data: T) => Result<void, KameleoonError>;\n}\n"],"mappings":""}
@@ -0,0 +1,10 @@
1
+ import { Result } from 'ts-res';
2
+ import { KameleoonError } from '../../kameleoonError';
3
+ import { EvaluationDataType } from '../../targeting/types';
4
+ import { ConditionDataType, ICondition } from './types';
5
+ export declare class ApplicationVersion implements ICondition {
6
+ private conditionValue?;
7
+ private versionMatchType?;
8
+ constructor({ version, versionMatchType }: ConditionDataType);
9
+ evaluate({ targetingData, }: EvaluationDataType): Result<boolean, KameleoonError>;
10
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ApplicationVersion=void 0;var _tsRes=require("ts-res"),_utilities=require("../../utilities"),_kameleoonData=require("../../kameleoonData");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var ApplicationVersion=function(){function a(b){var c=b.version,d=b.versionMatchType;_classCallCheck(this,a),_defineProperty(this,"conditionValue",void 0),_defineProperty(this,"versionMatchType",void 0),this.conditionValue=c,this.versionMatchType=d}return _createClass(a,[{key:"evaluate",value:function evaluate(a){var b,c=a.targetingData,d=null===c||void 0===c||null===(b=c[_kameleoonData.KameleoonData.ApplicationVersion])||void 0===b?void 0:b.version;if(!d||!this.conditionValue||!this.versionMatchType)return(0,_tsRes.Ok)(!1);var e=_utilities.Utilities.compareSemVer({version:d,compareVersion:this.conditionValue,operator:this.versionMatchType});return e.ok?(0,_tsRes.Ok)(e.data):(0,_tsRes.Err)(e.error)}}]),a}();exports.ApplicationVersion=ApplicationVersion;
2
+ //# sourceMappingURL=applicationVersion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applicationVersion.js","names":["ApplicationVersion","a","b","version","versionMatchType","_classCallCheck","_defineProperty","conditionValue","_createClass","key","value","evaluate","targetingData","KameleoonData","Ok","result","Utilities","compareSemVer","compareVersion","operator","ok","data","Err","error","exports"],"sources":["../../../src/targeting/conditions/applicationVersion.ts"],"sourcesContent":["import { Err, Ok, Result } from 'ts-res';\nimport { KameleoonError } from 'src/kameleoonError';\nimport { Utilities } from 'src/utilities';\nimport { KameleoonData } from 'src/kameleoonData';\nimport { EvaluationDataType, VersionMatchType } from 'src/targeting/types';\nimport { ConditionDataType, ICondition } from './types';\n\nexport class ApplicationVersion implements ICondition {\n private conditionValue?: string | null;\n private versionMatchType?: VersionMatchType | null;\n\n constructor({ version, versionMatchType }: ConditionDataType) {\n this.conditionValue = version;\n this.versionMatchType = versionMatchType;\n }\n\n public evaluate({\n targetingData,\n }: EvaluationDataType): Result<boolean, KameleoonError> {\n const version = targetingData?.[KameleoonData.ApplicationVersion]?.version;\n\n if (!version || !this.conditionValue || !this.versionMatchType) {\n return Ok(false);\n }\n\n const result = Utilities.compareSemVer({\n version,\n compareVersion: this.conditionValue,\n operator: this.versionMatchType,\n });\n\n if (!result.ok) {\n return Err(result.error);\n }\n\n return Ok(result.data);\n }\n}\n"],"mappings":"m8CAOa,CAAAA,kBAAkB,YAI7B,SAAAC,EAAAC,CAAA,CAA8D,IAAhD,CAAAC,CAAO,CAAAD,CAAA,CAAPC,OAAO,CAAEC,CAAgB,CAAAF,CAAA,CAAhBE,gBAAgB,CAAAC,eAAA,MAAAJ,CAAA,EAAAK,eAAA,+BAAAA,eAAA,iCACrC,IAAI,CAACC,cAAc,CAAGJ,CAAO,CAC7B,IAAI,CAACC,gBAAgB,CAAGA,CAC1B,CAAC,OAAAI,YAAA,CAAAP,CAAA,GAAAQ,GAAA,YAAAC,KAAA,CAED,SAAAC,SAAAV,CAAA,CAEwD,KAAAC,CAAA,CADtDU,CAAa,CAAAX,CAAA,CAAbW,aAAa,CAEPT,CAAO,QAAGS,CAAa,WAAbA,CAAa,UAAAV,CAAA,CAAbU,CAAa,CAAGC,4BAAa,CAACb,kBAAkB,CAAC,YAAAE,CAAA,QAAjDA,CAAA,CAAmDC,OAAO,CAE1E,GAAI,CAACA,CAAO,EAAI,CAAC,IAAI,CAACI,cAAc,EAAI,CAAC,IAAI,CAACH,gBAAgB,CAC5D,MAAO,GAAAU,SAAE,KAAO,CAGlB,GAAM,CAAAC,CAAM,CAAGC,oBAAS,CAACC,aAAa,CAAC,CACrCd,OAAO,CAAPA,CAAO,CACPe,cAAc,CAAE,IAAI,CAACX,cAAc,CACnCY,QAAQ,CAAE,IAAI,CAACf,gBACjB,CAAC,CAAC,CAAC,MAEE,CAAAW,CAAM,CAACK,EAAE,CAIP,GAAAN,SAAE,EAACC,CAAM,CAACM,IAAI,CAAC,CAHb,GAAAC,UAAG,EAACP,CAAM,CAACQ,KAAK,CAI3B,CAAC,IAAAtB,CAAA,IAAAuB,OAAA,CAAAxB,kBAAA,CAAAA,kBAAA"}
@@ -2,7 +2,7 @@ import { Result } from 'ts-res';
2
2
  import { KameleoonError } from '../../kameleoonError';
3
3
  import { EvaluationDataType } from '../../targeting/types';
4
4
  import { ConditionDataType, ICondition } from './types';
5
- export declare class BrowserCondition implements ICondition {
5
+ export declare class Browser implements ICondition {
6
6
  private browser?;
7
7
  private version?;
8
8
  private versionMatchType?;
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Browser=void 0;var _tsRes=require("ts-res"),_kameleoonData=require("../../kameleoonData"),_kameleoonError=require("../../kameleoonError"),_types=require("../types");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var Browser=function(){function a(b){var c=b.browser,d=b.version,e=b.versionMatchType;_classCallCheck(this,a),_defineProperty(this,"browser",void 0),_defineProperty(this,"version",void 0),_defineProperty(this,"versionMatchType",void 0),_defineProperty(this,"error",void 0),this.browser=c,this.version=d,this.versionMatchType=e}return _createClass(a,[{key:"evaluate",value:function evaluate(a){var b=a.targetingData,c=null===b||void 0===b?void 0:b[_kameleoonData.KameleoonData.Browser];if(c){var d=this.checkCondition(c);return this.error?(0,_tsRes.Err)(this.error):(0,_tsRes.Ok)(d)}return(0,_tsRes.Ok)(!1)}},{key:"checkCondition",value:function checkCondition(a){var b=a.browser,c=a.version;if("string"!=typeof this.browser)return!1;if("string"!=typeof this.version)return b===this.browser;if(!this.versionMatchType||"number"!=typeof c)return!1;var d=parseFloat(this.version);switch(isNaN(d)&&(this.error=new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.VersionParse,this.version)),this.versionMatchType){case _types.VersionMatchType.EQUAL:return b===this.browser&&c===d;case _types.VersionMatchType.GREATER:return b===this.browser&&c>d;case _types.VersionMatchType.LOWER:return b===this.browser&&c<d;default:(0,_kameleoonError.exhaustCheck)(this.versionMatchType);}}}]),a}();exports.Browser=Browser;
2
+ //# sourceMappingURL=browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.js","names":["Browser","a","b","browser","version","versionMatchType","_classCallCheck","_defineProperty","_createClass","key","value","evaluate","targetingData","browserData","KameleoonData","result","checkCondition","error","Err","Ok","parsedVersion","parseFloat","isNaN","KameleoonError","KameleoonException","VersionParse","VersionMatchType","EQUAL","GREATER","LOWER","exhaustCheck","exports"],"sources":["../../../src/targeting/conditions/browser.ts"],"sourcesContent":["import { Err, Ok, Result } from 'ts-res';\nimport { KameleoonData, BrowserType, BrowserDataType } from 'src/kameleoonData';\nimport {\n exhaustCheck,\n KameleoonError,\n KameleoonException,\n} from 'src/kameleoonError';\nimport { EvaluationDataType, VersionMatchType } from 'src/targeting/types';\nimport { ConditionDataType, ICondition } from './types';\n\nexport class Browser implements ICondition {\n private browser?: BrowserType | null;\n private version?: string | null;\n private versionMatchType?: VersionMatchType | null;\n private error?: KameleoonError;\n\n constructor({ browser, version, versionMatchType }: ConditionDataType) {\n this.browser = browser;\n this.version = version;\n this.versionMatchType = versionMatchType;\n }\n\n public evaluate({\n targetingData,\n }: EvaluationDataType): Result<boolean, KameleoonError> {\n const browserData = targetingData?.[KameleoonData.Browser];\n\n if (browserData) {\n const result = this.checkCondition(browserData);\n\n if (this.error) {\n return Err(this.error);\n }\n\n return Ok(result);\n }\n\n return Ok(false);\n }\n\n private checkCondition(browserData: BrowserDataType): boolean {\n const { browser, version } = browserData;\n\n if (typeof this.browser !== 'string') {\n return false;\n }\n\n if (typeof this.version !== 'string') {\n return browser === this.browser;\n }\n\n if (!this.versionMatchType || typeof version !== 'number') {\n return false;\n }\n\n const parsedVersion = parseFloat(this.version);\n\n if (isNaN(parsedVersion)) {\n this.error = new KameleoonError(\n KameleoonException.VersionParse,\n this.version,\n );\n }\n\n switch (this.versionMatchType) {\n case VersionMatchType.EQUAL:\n return browser === this.browser && version === parsedVersion;\n case VersionMatchType.GREATER:\n return browser === this.browser && version > parsedVersion;\n case VersionMatchType.LOWER:\n return browser === this.browser && version < parsedVersion;\n default:\n exhaustCheck(this.versionMatchType);\n }\n }\n}\n"],"mappings":"69CAUa,CAAAA,OAAO,YAMlB,SAAAC,EAAAC,CAAA,CAAuE,IAAzD,CAAAC,CAAO,CAAAD,CAAA,CAAPC,OAAO,CAAEC,CAAO,CAAAF,CAAA,CAAPE,OAAO,CAAEC,CAAgB,CAAAH,CAAA,CAAhBG,gBAAgB,CAAAC,eAAA,MAAAL,CAAA,EAAAM,eAAA,wBAAAA,eAAA,wBAAAA,eAAA,iCAAAA,eAAA,sBAC9C,IAAI,CAACJ,OAAO,CAAGA,CAAO,CACtB,IAAI,CAACC,OAAO,CAAGA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AxB,CAAO,GAAK,IAAI,CAACA,OAAO,EAAIC,CAAO,GAAKgB,CAAa,CAC9D,IAAK,CAAAM,uBAAgB,CAACE,OAAO,CAC3B,MAAO,CAAAzB,CAAO,GAAK,IAAI,CAACA,OAAO,EAAIC,CAAO,CAAGgB,CAAa,CAC5D,IAAK,CAAAM,uBAAgB,CAACG,KAAK,CACzB,MAAO,CAAA1B,CAAO,GAAK,IAAI,CAACA,OAAO,EAAIC,CAAO,CAAGgB,CAAa,CAC5D,QACE,GAAAU,4BAAY,EAAC,IAAI,CAACzB,gBAAgB,CAAC,CAAC,CAE1C,CAAC,IAAAJ,CAAA,IAAA8B,OAAA,CAAA/B,OAAA,CAAAA,OAAA"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ConditionFactory=void 0;var _tsRes=require("ts-res"),_kameleoonError=require("../../kameleoonError"),_types=require("../types"),_browserCondition=require("./browserCondition"),_conversionCondition=require("./conversionCondition"),_customDataCondition=require("./customDataCondition"),_deviceCondition=require("./deviceCondition"),_exclusiveExperimentCondition=require("./exclusiveExperimentCondition"),_pageTitleCondition=require("./pageTitleCondition"),_pageUrlCondition=require("./pageUrlCondition"),_sdkLanguageCondition=require("./sdkLanguageCondition"),_targetExperimentCondition=require("./targetExperimentCondition"),_visitorCodeCondition=require("./visitorCodeCondition");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var ConditionFactory=/*#__PURE__*/function(){function a(){_classCallCheck(this,a)}return _createClass(a,null,[{key:"createCondition",value:function createCondition(a){var b=a.targetingType;return b===_types.TargetingType.CUSTOM_DATUM?(0,_tsRes.Ok)(new _customDataCondition.CustomDataCondition(a)):b===_types.TargetingType.EXCLUSIVE_EXPERIMENT?(0,_tsRes.Ok)(new _exclusiveExperimentCondition.ExclusiveExperimentCondition):b===_types.TargetingType.TARGET_EXPERIMENT?(0,_tsRes.Ok)(new _targetExperimentCondition.TargetExperimentCondition(a)):b===_types.TargetingType.DEVICE_TYPE?(0,_tsRes.Ok)(new _deviceCondition.DeviceCondition(a)):b===_types.TargetingType.BROWSER?(0,_tsRes.Ok)(new _browserCondition.BrowserCondition(a)):b===_types.TargetingType.PAGE_URL?(0,_tsRes.Ok)(new _pageUrlCondition.PageUrlCondition(a)):b===_types.TargetingType.PAGE_TITLE?(0,_tsRes.Ok)(new _pageTitleCondition.PageTitleCondition(a)):b===_types.TargetingType.CONVERSIONS?(0,_tsRes.Ok)(new _conversionCondition.ConversionCondition(a)):b===_types.TargetingType.VISITOR_CODE?(0,_tsRes.Ok)(new _visitorCodeCondition.VisitorCodeCondition(a)):b===_types.TargetingType.SDK_LANGUAGE?(0,_tsRes.Ok)(new _sdkLanguageCondition.SdkLanguageCondition(a)):(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.TargetingCondition,b))}}]),a}();exports.ConditionFactory=ConditionFactory;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ConditionFactory=void 0;var _tsRes=require("ts-res"),_kameleoonError=require("../../kameleoonError"),_types=require("../types"),_browser=require("./browser"),_conversion=require("./conversion"),_customData=require("./customData"),_device=require("./device"),_exclusiveCampaign=require("./exclusiveCampaign"),_pageTitle=require("./pageTitle"),_pageUrl=require("./pageUrl"),_sdkLanguage=require("./sdkLanguage"),_visitorCode=require("./visitorCode"),_cookie=require("./cookie"),_operatingSystem=require("./operatingSystem"),_geolocation=require("./geolocation"),_segment=require("./segment"),_targetFeatureFlag=require("./targetFeatureFlag"),_previousPage=require("./previousPage"),_visitedPages=require("./visitedPages"),_firstVisit=require("./firstVisit"),_lastVisit=require("./lastVisit"),_sameDayVisits=require("./sameDayVisits"),_visits=require("./visits"),_newVisitor=require("./newVisitor"),_applicationVersion=require("./applicationVersion");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var ConditionFactory=function(){function a(){_classCallCheck(this,a)}return _createClass(a,null,[{key:"createCondition",value:function createCondition(a){var b=a.targetingType;return b===_types.TargetingType.CUSTOM_DATUM?(0,_tsRes.Ok)(new _customData.CustomData(a)):b===_types.TargetingType.EXCLUSIVE_EXPERIMENT||b===_types.TargetingType.EXCLUSIVE_FEATURE_FLAG?(0,_tsRes.Ok)(new _exclusiveCampaign.ExclusiveCampaign):b===_types.TargetingType.TARGET_FEATURE_FLAG?(0,_tsRes.Ok)(new _targetFeatureFlag.TargetFeatureFlag(a)):b===_types.TargetingType.DEVICE_TYPE?(0,_tsRes.Ok)(new _device.Device(a)):b===_types.TargetingType.BROWSER?(0,_tsRes.Ok)(new _browser.Browser(a)):b===_types.TargetingType.PAGE_URL?(0,_tsRes.Ok)(new _pageUrl.PageUrl(a)):b===_types.TargetingType.PAGE_TITLE?(0,_tsRes.Ok)(new _pageTitle.PageTitle(a)):b===_types.TargetingType.CONVERSIONS?(0,_tsRes.Ok)(new _conversion.Conversion(a)):b===_types.TargetingType.VISITOR_CODE?(0,_tsRes.Ok)(new _visitorCode.VisitorCode(a)):b===_types.TargetingType.SDK_LANGUAGE?(0,_tsRes.Ok)(new _sdkLanguage.SdkLanguage(a)):b===_types.TargetingType.COOKIE?(0,_tsRes.Ok)(new _cookie.Cookie(a)):b===_types.TargetingType.OPERATING_SYSTEM?(0,_tsRes.Ok)(new _operatingSystem.OperatingSystem(a)):b===_types.TargetingType.GEOLOCATION?(0,_tsRes.Ok)(new _geolocation.GeolocationCondition(a)):b===_types.TargetingType.SEGMENT?(0,_tsRes.Ok)(new _segment.Segment(a)):b===_types.TargetingType.APPLICATION_VERSION?(0,_tsRes.Ok)(new _applicationVersion.ApplicationVersion(a)):b===_types.TargetingType.PREVIOUS_PAGE?(0,_tsRes.Ok)(new _previousPage.PreviousPage(a)):b===_types.TargetingType.NUMBER_OF_VISITED_PAGES?(0,_tsRes.Ok)(new _visitedPages.VisitedPages(a)):b===_types.TargetingType.LAST_VISIT?(0,_tsRes.Ok)(new _lastVisit.LastVisit(a)):b===_types.TargetingType.FIRST_VISIT?(0,_tsRes.Ok)(new _firstVisit.FirstVisit(a)):b===_types.TargetingType.SAME_DAY_VISITS?(0,_tsRes.Ok)(new _sameDayVisits.SameDayVisits(a)):b===_types.TargetingType.VISITS?(0,_tsRes.Ok)(new _visits.Visits(a)):b===_types.TargetingType.NEW_VISITORS?(0,_tsRes.Ok)(new _newVisitor.NewVisitor(a)):(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.TargetingCondition,b))}}]),a}();exports.ConditionFactory=ConditionFactory;
2
2
  //# sourceMappingURL=conditionFactory.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"conditionFactory.js","names":["ConditionFactory","a","_classCallCheck","_createClass","key","value","createCondition","data","targetingType","TargetingType","CUSTOM_DATUM","Ok","CustomDataCondition","EXCLUSIVE_EXPERIMENT","ExclusiveExperimentCondition","TARGET_EXPERIMENT","TargetExperimentCondition","DEVICE_TYPE","DeviceCondition","BROWSER","BrowserCondition","PAGE_URL","PageUrlCondition","PAGE_TITLE","PageTitleCondition","CONVERSIONS","ConversionCondition","VISITOR_CODE","VisitorCodeCondition","SDK_LANGUAGE","SdkLanguageCondition","Err","KameleoonError","KameleoonException","TargetingCondition","exports"],"sources":["../../../src/targeting/conditions/conditionFactory.ts"],"sourcesContent":["import { Err, Ok, Result } from 'ts-res';\nimport { KameleoonError, KameleoonException } from 'src/kameleoonError';\nimport { TargetingType } from 'src/targeting/types';\nimport { BrowserCondition } from './browserCondition';\nimport { ConversionCondition } from './conversionCondition';\nimport { CustomDataCondition } from './customDataCondition';\nimport { DeviceCondition } from './deviceCondition';\nimport { ExclusiveExperimentCondition } from './exclusiveExperimentCondition';\nimport { PageTitleCondition } from './pageTitleCondition';\nimport { PageUrlCondition } from './pageUrlCondition';\nimport { SdkLanguageCondition } from './sdkLanguageCondition';\nimport { TargetExperimentCondition } from './targetExperimentCondition';\nimport { ConditionDataType, ConditionType } from './types';\nimport { VisitorCodeCondition } from './visitorCodeCondition';\n\nexport class ConditionFactory {\n static createCondition(\n data: ConditionDataType,\n ): Result<ConditionType, KameleoonError> {\n const { targetingType } = data;\n\n switch (targetingType) {\n case TargetingType.CUSTOM_DATUM:\n return Ok(new CustomDataCondition(data));\n case TargetingType.EXCLUSIVE_EXPERIMENT:\n return Ok(new ExclusiveExperimentCondition());\n case TargetingType.TARGET_EXPERIMENT:\n return Ok(new TargetExperimentCondition(data));\n case TargetingType.DEVICE_TYPE:\n return Ok(new DeviceCondition(data));\n case TargetingType.BROWSER:\n return Ok(new BrowserCondition(data));\n case TargetingType.PAGE_URL:\n return Ok(new PageUrlCondition(data));\n case TargetingType.PAGE_TITLE:\n return Ok(new PageTitleCondition(data));\n case TargetingType.CONVERSIONS:\n return Ok(new ConversionCondition(data));\n case TargetingType.VISITOR_CODE:\n return Ok(new VisitorCodeCondition(data));\n case TargetingType.SDK_LANGUAGE:\n return Ok(new SdkLanguageCondition(data));\n default:\n return Err(\n new KameleoonError(\n KameleoonException.TargetingCondition,\n targetingType,\n ),\n );\n }\n }\n}\n"],"mappings":"s0DAea,CAAAA,gBAAgB,kCAAAC,EAAA,EAAAC,eAAA,MAAAD,CAAA,SAAAE,YAAA,CAAAF,CAAA,QAAAG,GAAA,mBAAAC,KAAA,CAC3B,SAAAC,gBACEC,CAAuB,CACgB,CACvC,GAAQ,CAAAC,CAAa,CAAKD,CAAI,CAAtBC,aAAa,CAAU,MAEvB,CAAAA,CAAa,GACdC,oBAAa,CAACC,YAAY,CACtB,GAAAC,SAAE,EAAC,GAAI,CAAAC,wCAAmB,CAACL,CAAI,CAAC,CAAC,CAFpCC,CAAa,GAGdC,oBAAa,CAACI,oBAAoB,CAC9B,GAAAF,SAAE,EAAC,GAAI,CAAAG,0DAA8B,CAAC,CAJzCN,CAAa,GAKdC,oBAAa,CAACM,iBAAiB,CAC3B,GAAAJ,SAAE,EAAC,GAAI,CAAAK,oDAAyB,CAACT,CAAI,CAAC,CAAC,CAN1CC,CAAa,GAOdC,oBAAa,CAACQ,WAAW,CACrB,GAAAN,SAAE,EAAC,GAAI,CAAAO,gCAAe,CAACX,CAAI,CAAC,CAAC,CARhCC,CAAa,GASdC,oBAAa,CAACU,OAAO,CACjB,GAAAR,SAAE,EAAC,GAAI,CAAAS,kCAAgB,CAACb,CAAI,CAAC,CAAC,CAVjCC,CAAa,GAWdC,oBAAa,CAACY,QAAQ,CAClB,GAAAV,SAAE,EAAC,GAAI,CAAAW,kCAAgB,CAACf,CAAI,CAAC,CAAC,CAZjCC,CAAa,GAadC,oBAAa,CAACc,UAAU,CACpB,GAAAZ,SAAE,EAAC,GAAI,CAAAa,sCAAkB,CAACjB,CAAI,CAAC,CAAC,CAdnCC,CAAa,GAedC,oBAAa,CAACgB,WAAW,CACrB,GAAAd,SAAE,EAAC,GAAI,CAAAe,wCAAmB,CAACnB,CAAI,CAAC,CAAC,CAhBpCC,CAAa,GAiBdC,oBAAa,CAACkB,YAAY,CACtB,GAAAhB,SAAE,EAAC,GAAI,CAAAiB,0CAAoB,CAACrB,CAAI,CAAC,CAAC,CAlBrCC,CAAa,GAmBdC,oBAAa,CAACoB,YAAY,CACtB,GAAAlB,SAAE,EAAC,GAAI,CAAAmB,0CAAoB,CAACvB,CAAI,CAAC,CAAC,CAElC,GAAAwB,UAAG,EACR,GAAI,CAAAC,8BAAc,CAChBC,kCAAkB,CAACC,kBAAkB,CACrC1B,CAAa,CACd,CAGT,CAAC,IAAAP,CAAA,IAAAkC,OAAA,CAAAnC,gBAAA,CAAAA,gBAAA"}
1
+ {"version":3,"file":"conditionFactory.js","names":["ConditionFactory","a","_classCallCheck","_createClass","key","value","createCondition","data","targetingType","TargetingType","CUSTOM_DATUM","Ok","CustomData","EXCLUSIVE_EXPERIMENT","EXCLUSIVE_FEATURE_FLAG","ExclusiveCampaign","TARGET_FEATURE_FLAG","TargetFeatureFlag","DEVICE_TYPE","Device","BROWSER","Browser","PAGE_URL","PageUrl","PAGE_TITLE","PageTitle","CONVERSIONS","Conversion","VISITOR_CODE","VisitorCode","SDK_LANGUAGE","SdkLanguage","COOKIE","Cookie","OPERATING_SYSTEM","OperatingSystem","GEOLOCATION","GeolocationCondition","SEGMENT","Segment","APPLICATION_VERSION","ApplicationVersion","PREVIOUS_PAGE","PreviousPage","NUMBER_OF_VISITED_PAGES","VisitedPages","LAST_VISIT","LastVisit","FIRST_VISIT","FirstVisit","SAME_DAY_VISITS","SameDayVisits","VISITS","Visits","NEW_VISITORS","NewVisitor","Err","KameleoonError","KameleoonException","TargetingCondition","exports"],"sources":["../../../src/targeting/conditions/conditionFactory.ts"],"sourcesContent":["import { Err, Ok, Result } from 'ts-res';\nimport { KameleoonError, KameleoonException } from 'src/kameleoonError';\nimport { TargetingType } from 'src/targeting/types';\nimport { Browser } from './browser';\nimport { Conversion } from './conversion';\nimport { CustomData } from './customData';\nimport { Device } from './device';\nimport { ExclusiveCampaign } from './exclusiveCampaign';\nimport { PageTitle } from './pageTitle';\nimport { PageUrl } from './pageUrl';\nimport { SdkLanguage } from './sdkLanguage';\nimport { ConditionDataType, ConditionType } from './types';\nimport { VisitorCode } from './visitorCode';\nimport { Cookie } from './cookie';\nimport { OperatingSystem } from './operatingSystem';\nimport { GeolocationCondition } from './geolocation';\nimport { Segment } from './segment';\nimport { TargetFeatureFlag } from './targetFeatureFlag';\nimport { PreviousPage } from './previousPage';\nimport { VisitedPages } from './visitedPages';\nimport { FirstVisit } from './firstVisit';\nimport { LastVisit } from './lastVisit';\nimport { SameDayVisits } from './sameDayVisits';\nimport { Visits } from './visits';\nimport { NewVisitor } from './newVisitor';\nimport { ApplicationVersion } from './applicationVersion';\n\nexport class ConditionFactory {\n static createCondition(\n data: ConditionDataType,\n ): Result<ConditionType, KameleoonError> {\n const { targetingType } = data;\n\n switch (targetingType) {\n case TargetingType.CUSTOM_DATUM:\n return Ok(new CustomData(data));\n case TargetingType.EXCLUSIVE_EXPERIMENT:\n case TargetingType.EXCLUSIVE_FEATURE_FLAG:\n return Ok(new ExclusiveCampaign());\n case TargetingType.TARGET_FEATURE_FLAG:\n return Ok(new TargetFeatureFlag(data));\n case TargetingType.DEVICE_TYPE:\n return Ok(new Device(data));\n case TargetingType.BROWSER:\n return Ok(new Browser(data));\n case TargetingType.PAGE_URL:\n return Ok(new PageUrl(data));\n case TargetingType.PAGE_TITLE:\n return Ok(new PageTitle(data));\n case TargetingType.CONVERSIONS:\n return Ok(new Conversion(data));\n case TargetingType.VISITOR_CODE:\n return Ok(new VisitorCode(data));\n case TargetingType.SDK_LANGUAGE:\n return Ok(new SdkLanguage(data));\n case TargetingType.COOKIE:\n return Ok(new Cookie(data));\n case TargetingType.OPERATING_SYSTEM:\n return Ok(new OperatingSystem(data));\n case TargetingType.GEOLOCATION:\n return Ok(new GeolocationCondition(data));\n case TargetingType.SEGMENT:\n return Ok(new Segment(data));\n case TargetingType.APPLICATION_VERSION:\n return Ok(new ApplicationVersion(data));\n case TargetingType.PREVIOUS_PAGE:\n return Ok(new PreviousPage(data));\n case TargetingType.NUMBER_OF_VISITED_PAGES:\n return Ok(new VisitedPages(data));\n case TargetingType.LAST_VISIT:\n return Ok(new LastVisit(data));\n case TargetingType.FIRST_VISIT:\n return Ok(new FirstVisit(data));\n case TargetingType.SAME_DAY_VISITS:\n return Ok(new SameDayVisits(data));\n case TargetingType.VISITS:\n return Ok(new Visits(data));\n case TargetingType.NEW_VISITORS:\n return Ok(new NewVisitor(data));\n default:\n return Err(\n new KameleoonError(\n KameleoonException.TargetingCondition,\n targetingType,\n ),\n );\n }\n }\n}\n"],"mappings":"klEA2Ba,CAAAA,gBAAgB,qBAAAC,EAAA,EAAAC,eAAA,MAAAD,CAAA,SAAAE,YAAA,CAAAF,CAAA,QAAAG,GAAA,mBAAAC,KAAA,CAC3B,SAAAC,gBACEC,CAAuB,CACgB,CACvC,GAAQ,CAAAC,CAAa,CAAKD,CAAI,CAAtBC,aAAa,CAAU,MAEvB,CAAAA,CAAa,GACdC,oBAAa,CAACC,YAAY,CACtB,GAAAC,SAAE,EAAC,GAAI,CAAAC,sBAAU,CAACL,CAAI,CAAC,CAAC,CAF3BC,CAAa,GAGdC,oBAA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,GAAAiD,UAAG,EACR,GAAI,CAAAC,8BAAc,CAChBC,kCAAkB,CAACC,kBAAkB,CACrCnD,CAAa,CACd,CAGT,CAAC,IAAAP,CAAA,IAAA2D,OAAA,CAAA5D,gBAAA,CAAAA,gBAAA"}
@@ -2,9 +2,8 @@ import { Result } from 'ts-res';
2
2
  import { KameleoonError } from '../../kameleoonError';
3
3
  import { EvaluationDataType } from '../../targeting/types';
4
4
  import { ConditionDataType, ICondition } from './types';
5
- export declare class ConversionCondition implements ICondition {
5
+ export declare class Conversion implements ICondition {
6
6
  private conditionValue?;
7
7
  constructor({ goalId }: ConditionDataType);
8
8
  evaluate({ targetingData, }: EvaluationDataType): Result<boolean, KameleoonError>;
9
- private checkCondition;
10
9
  }
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Conversion=void 0;var _tsRes=require("ts-res"),_kameleoonData=require("../../kameleoonData");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var Conversion=function(){function a(b){var c=b.goalId;_classCallCheck(this,a),_defineProperty(this,"conditionValue",void 0),this.conditionValue=c}return _createClass(a,[{key:"evaluate",value:function evaluate(a){var b=this,c=a.targetingData,d=null===c||void 0===c?void 0:c[_kameleoonData.KameleoonData.Conversion];return this.conditionValue?d?d.length&&-1===this.conditionValue?(0,_tsRes.Ok)(!0):(0,_tsRes.Ok)(d.some(function(a){var c=a.goalId;return c===b.conditionValue})):(0,_tsRes.Ok)(!1):(0,_tsRes.Ok)(!1)}}]),a}();exports.Conversion=Conversion;
2
+ //# sourceMappingURL=conversion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversion.js","names":["Conversion","a","b","goalId","_classCallCheck","_defineProperty","conditionValue","_createClass","key","value","evaluate","targetingData","conversionData","KameleoonData","length","Ok","some","exports"],"sources":["../../../src/targeting/conditions/conversion.ts"],"sourcesContent":["import { Ok, Result } from 'ts-res';\nimport { KameleoonData } from 'src/kameleoonData';\nimport { KameleoonError } from 'src/kameleoonError';\nimport { EvaluationDataType } from 'src/targeting/types';\nimport { ConditionDataType, ICondition } from './types';\n\nexport class Conversion implements ICondition {\n private conditionValue?: number | null;\n\n constructor({ goalId }: ConditionDataType) {\n this.conditionValue = goalId;\n }\n\n public evaluate({\n targetingData,\n }: EvaluationDataType): Result<boolean, KameleoonError> {\n const conversionData = targetingData?.[KameleoonData.Conversion];\n\n if (!this.conditionValue) {\n return Ok(false);\n }\n\n if (conversionData) {\n if (conversionData.length && this.conditionValue === -1) {\n return Ok(true);\n }\n\n return Ok(\n conversionData.some(({ goalId }) => goalId === this.conditionValue),\n );\n }\n\n return Ok(false);\n }\n}\n"],"mappings":"q5CAMa,CAAAA,UAAU,YAGrB,SAAAC,EAAAC,CAAA,CAA2C,IAA7B,CAAAC,CAAM,CAAAD,CAAA,CAANC,MAAM,CAAAC,eAAA,MAAAH,CAAA,EAAAI,eAAA,+BAClB,IAAI,CAACC,cAAc,CAAGH,CACxB,CAAC,OAAAI,YAAA,CAAAN,CAAA,GAAAO,GAAA,YAAAC,KAAA,CAED,SAAAC,SAAAT,CAAA,CAEwD,KAAAC,CAAA,MADtDS,CAAa,CAAAV,CAAA,CAAbU,aAAa,CAEPC,CAAc,QAAGD,CAAa,WAAbA,CAAa,QAAbA,CAAa,CAAGE,4BAAa,CAACb,UAAU,CAAC,OAE3D,KAAI,CAACM,cAAc,CAIpBM,CAAc,CACZA,CAAc,CAACE,MAAM,EAA4B,CAAC,CAAC,GAA1B,IAAI,CAACR,cAAqB,CAC9C,GAAAS,SAAE,KAAM,CAGV,GAAAA,SAAE,EACPH,CAAc,CAACI,IAAI,CAAC,SAAAf,CAAA,KAAG,CAAAE,CAAM,CAAAF,CAAA,CAANE,MAAM,OAAO,CAAAA,CAAM,GAAKD,CAAI,CAACI,cAAc,EAAC,CACpE,CAGI,GAAAS,SAAE,KAAO,CAbP,GAAAA,SAAE,KAcb,CAAC,IAAAd,CAAA,IAAAgB,OAAA,CAAAjB,UAAA,CAAAA,UAAA"}
@@ -0,0 +1,15 @@
1
+ import { Result } from 'ts-res';
2
+ import { KameleoonError } from '../../kameleoonError';
3
+ import { EvaluationDataType } from '../../targeting/types';
4
+ import { ConditionDataType, ICondition } from './types';
5
+ export declare class Cookie implements ICondition {
6
+ private cookie;
7
+ private keyMatchType?;
8
+ private valueMatchType?;
9
+ constructor({ name, value, nameMatchType, valueMatchType, }: ConditionDataType);
10
+ evaluate({ targetingData, }: EvaluationDataType): Result<boolean, KameleoonError>;
11
+ private extractCookie;
12
+ private checkCondition;
13
+ private compareCookieValue;
14
+ private isOptionalCookie;
15
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Cookie=void 0;var _tsRes=require("ts-res"),_kameleoonData=require("../../kameleoonData"),_kameleoonError=require("../../kameleoonError"),_types=require("../types"),_utilities=require("../../utilities");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var Cookie=function(){function a(b){var c=b.name,d=b.value,e=b.nameMatchType,f=b.valueMatchType;_classCallCheck(this,a),_defineProperty(this,"cookie",void 0),_defineProperty(this,"keyMatchType",void 0),_defineProperty(this,"valueMatchType",void 0),this.cookie={key:null!==c&&void 0!==c?c:void 0,value:null!==d&&void 0!==d?d:void 0},this.keyMatchType=e,this.valueMatchType=f}return _createClass(a,[{key:"evaluate",value:function evaluate(a){var b,c=this,d=a.targetingData,e=!this.cookie.key&&!this.cookie.value,f=!!this.valueMatchType&&!!this.keyMatchType;if(e||!f)return(0,_tsRes.Ok)(!1);var g=this.extractCookie(),h=(null===d||void 0===d||null===(b=d[_kameleoonData.KameleoonData.Cookie])||void 0===b?void 0:b.cookie)||[];return(0,_tsRes.Ok)(g.some(function(a){return c.checkCondition(a)})||h.some(function(a){return c.checkCondition(a)}))}},{key:"extractCookie",value:function extractCookie(){return"undefined"!=typeof document&&document.cookie?_kameleoonData.Cookie.fromString(document.cookie).data.cookie:[]}},{key:"checkCondition",value:function checkCondition(a){var b=this.keyMatchType,c=a.key,d=a.value;if(b===_types.NameMatchType.OPTIONAL){var e=this.cookie;return!!this.isOptionalCookie(e)&&this.compareCookieValue(d,e.value)}var f,g=this.cookie,h=g.key,i=g.value;return b===_types.NameMatchType.EXACT?f=c===h:b===_types.NameMatchType.CONTAINS?f=c.includes(h):b===_types.NameMatchType.REGULAR_EXPRESSION?f=_utilities.Utilities.parseRegExp(h).test(c):(0,_kameleoonError.exhaustCheck)(b),f&&this.compareCookieValue(d,i)}},{key:"compareCookieValue",value:function compareCookieValue(a,b){var c=this.valueMatchType;return c===_types.ValueMatchType.EXACT?a===b:c===_types.ValueMatchType.CONTAINS?a.includes(b):c===_types.ValueMatchType.REGULAR_EXPRESSION&&_utilities.Utilities.parseRegExp(b).test(a)}},{key:"isOptionalCookie",value:function isOptionalCookie(a){var b=a.value;return"undefined"!=typeof b}}]),a}();exports.Cookie=Cookie;
2
+ //# sourceMappingURL=cookie.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cookie.js","names":["Cookie","a","b","name","value","nameMatchType","valueMatchType","_classCallCheck","_defineProperty","cookie","key","keyMatchType","_createClass","evaluate","c","targetingData","isEmptyCookie","isValidMatchType","Ok","extractedCookie","extractCookie","cookieData","KameleoonData","some","pair","checkCondition","document","CookieData","fromString","data","dataCookie","cookieMatchType","NameMatchType","OPTIONAL","conditionCookie","isOptionalCookie","compareCookieValue","keyMatch","g","compareKey","compareValue","EXACT","CONTAINS","includes","REGULAR_EXPRESSION","Utilities","parseRegExp","test","exhaustCheck","ValueMatchType","exports"],"sources":["../../../src/targeting/conditions/cookie.ts"],"sourcesContent":["import { Ok, Result } from 'ts-res';\nimport { Cookie as CookieData, KameleoonData } from 'src/kameleoonData';\nimport { exhaustCheck, KameleoonError } from 'src/kameleoonError';\nimport {\n EvaluationDataType,\n NameMatchType,\n ValueMatchType,\n} from 'src/targeting/types';\nimport { CookieType, OptionalCookieType } from 'src/kameleoonData/types';\nimport { Utilities } from 'src/utilities';\nimport { ConditionDataType, ICondition } from './types';\n\nexport class Cookie implements ICondition {\n private cookie: Partial<CookieType>;\n private keyMatchType?: NameMatchType | null;\n private valueMatchType?: ValueMatchType | null;\n\n constructor({\n name,\n value,\n nameMatchType,\n valueMatchType,\n }: ConditionDataType) {\n this.cookie = {\n key: name ?? undefined,\n value: value ?? undefined,\n };\n this.keyMatchType = nameMatchType;\n this.valueMatchType = valueMatchType;\n }\n\n public evaluate({\n targetingData,\n }: EvaluationDataType): Result<boolean, KameleoonError> {\n const isEmptyCookie = !this.cookie.key && !this.cookie.value;\n const isValidMatchType =\n Boolean(this.valueMatchType) && Boolean(this.keyMatchType);\n\n if (isEmptyCookie || !isValidMatchType) {\n return Ok(false);\n }\n\n const extractedCookie = this.extractCookie();\n const cookieData = targetingData?.[KameleoonData.Cookie]?.cookie || [];\n\n return Ok(\n extractedCookie.some((pair) => this.checkCondition(pair)) ||\n cookieData.some((pair) => this.checkCondition(pair)),\n );\n }\n\n private extractCookie(): CookieType[] {\n if (typeof document !== 'undefined' && document.cookie) {\n return CookieData.fromString(document.cookie).data.cookie;\n }\n\n return [];\n }\n\n private checkCondition(dataCookie: CookieType): boolean {\n const cookieMatchType = this.keyMatchType!;\n const { key, value } = dataCookie;\n\n if (cookieMatchType === NameMatchType.OPTIONAL) {\n const conditionCookie = this.cookie;\n\n return this.isOptionalCookie(conditionCookie)\n ? this.compareCookieValue(value, conditionCookie.value)\n : false;\n }\n\n const { key: compareKey, value: compareValue } = this.cookie as CookieType;\n\n let keyMatch: boolean;\n\n switch (cookieMatchType) {\n case NameMatchType.EXACT:\n keyMatch = key === compareKey;\n break;\n case NameMatchType.CONTAINS:\n keyMatch = key.includes(compareKey);\n break;\n case NameMatchType.REGULAR_EXPRESSION:\n keyMatch = Utilities.parseRegExp(compareKey).test(key);\n break;\n default:\n exhaustCheck(cookieMatchType);\n }\n\n return keyMatch && this.compareCookieValue(value, compareValue);\n }\n\n private compareCookieValue(value: string, compareValue: string): boolean {\n const valueMatchType = this.valueMatchType!;\n\n switch (valueMatchType) {\n case ValueMatchType.EXACT:\n return value === compareValue;\n case ValueMatchType.CONTAINS:\n return value.includes(compareValue);\n case ValueMatchType.REGULAR_EXPRESSION:\n return Utilities.parseRegExp(compareValue).test(value);\n default:\n return false;\n }\n }\n\n private isOptionalCookie(\n cookie: Partial<CookieType>,\n ): cookie is OptionalCookieType {\n const { value } = cookie;\n\n return typeof value !== 'undefined';\n }\n}\n"],"mappings":"kgDAYa,CAAAA,MAAM,YAKjB,SAAAC,EAAAC,CAAA,CAKsB,IAJpB,CAAAC,CAAI,CAAAD,CAAA,CAAJC,IAAI,CACJC,CAAK,CAAAF,CAAA,CAALE,KAAK,CACLC,CAAa,CAAAH,CAAA,CAAbG,aAAa,CACbC,CAAc,CAAAJ,CAAA,CAAdI,cAAc,CAAAC,eAAA,MAAAN,CAAA,EAAAO,eAAA,uBAAAA,eAAA,6BAAAA,eAAA,+BAEd,IAAI,CAACC,MAAM,CAAG,CACZC,GAAG,QAAEP,CAAI,WAAJA,CAAI,CAAJA,CAAI,OAAa,CACtBC,KAAK,QAAEA,CAAK,WAALA,CAAK,CAALA,CAAK,OACd,CAAC,CACD,IAAI,CAACO,YAAY,CAAGN,CAAa,CACjC,IAAI,CAACC,cAAc,CAAGA,CACxB,CAAC,OAAAM,YAAA,CAAAX,CAAA,GAAAS,GAAA,YAAAN,KAAA,CAED,SAAAS,SAAAZ,CAAA,CAEwD,KAAAC,CAAA,CAAAY,CAAA,MADtDC,CAAa,CAAAd,CAAA,CAAbc,aAAa,CAEPC,CAAa,CAAG,CAAC,IAAI,CAACP,MAAM,CAACC,GAAG,EAAI,CAAC,IAAI,CAACD,MAAM,CAACL,KAAK,CACtDa,CAAgB,CACp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CAAA,IAAAiD,OAAA,CAAAlD,MAAA,CAAAA,MAAA"}
@@ -2,7 +2,7 @@ import { Result } from 'ts-res';
2
2
  import { KameleoonError } from '../../kameleoonError';
3
3
  import { EvaluationDataType } from '../../targeting/types';
4
4
  import { ConditionDataType, ICondition } from './types';
5
- export declare class CustomDataCondition implements ICondition {
5
+ export declare class CustomData implements ICondition {
6
6
  private customDataIndex;
7
7
  private matchType?;
8
8
  private conditionValue?;
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CustomData=void 0;var _tsRes=require("ts-res"),_kameleoonData=require("../../kameleoonData"),_kameleoonError=require("../../kameleoonError"),_utilities=require("../../utilities"),_types=require("../types");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var CustomData=function(){function a(b){var c=b.customDataIndex,d=b.valueMatchType,e=b.value;_classCallCheck(this,a),_defineProperty(this,"customDataIndex",void 0),_defineProperty(this,"matchType",void 0),_defineProperty(this,"conditionValue",void 0),_defineProperty(this,"error",void 0),this.customDataIndex=c?+c:null,this.matchType=d,this.conditionValue=e}return _createClass(a,[{key:"evaluate",value:function evaluate(a){var b=a.targetingData;if("number"==typeof this.customDataIndex){var c,d=null===b||void 0===b||null===(c=b[_kameleoonData.KameleoonData.CustomData])||void 0===c?void 0:c[this.customDataIndex];if(d){var e=d.value,f=this.checkCondition(e);return this.error?(0,_tsRes.Err)(this.error):(0,_tsRes.Ok)(f)}}return(0,_tsRes.Ok)(this.matchType===_types.ValueMatchType.UNDEFINED)}},{key:"checkCondition",value:function checkCondition(a){var b=this;if("string"!=typeof this.conditionValue&&this.matchType!==_types.ValueMatchType.TRUE&&this.matchType!==_types.ValueMatchType.FALSE)return!1;var c=this.conditionValue;if(this.matchType===_types.ValueMatchType.AMONG_VALUES){var d=this.parseArray(c);if(!d.ok)return this.error=d.error,!1;var e=new Set(d.data);return Array.isArray(a)?a.some(function(a){return e.has(a)}):d.data.includes(a)}if(Array.isArray(a))return a.some(function(a){return b.checkCondition(a)});switch(this.matchType){case _types.ValueMatchType.CONTAINS:return a.includes(c);case _types.ValueMatchType.EXACT:return a===this.conditionValue;case _types.ValueMatchType.REGULAR_EXPRESSION:return _utilities.Utilities.parseRegExp(c).test(a);case _types.ValueMatchType.LOWER:return+a<+this.conditionValue;case _types.ValueMatchType.EQUAL:return+a===+this.conditionValue;case _types.ValueMatchType.GREATER:return+a>+this.conditionValue;case _types.ValueMatchType.TRUE:return"true"===a.toLowerCase();case _types.ValueMatchType.FALSE:return"false"===a.toLowerCase();default:return!1;}}},{key:"parseArray",value:function parseArray(a){try{var b=JSON.parse(a);if(Array.isArray(b))return(0,_tsRes.Ok)(b)}catch(b){return(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.AmongValuesCheck,b,a))}return(0,_tsRes.Ok)([])}}]),a}();exports.CustomData=CustomData;
2
+ //# sourceMappingURL=customData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customData.js","names":["CustomData","a","b","customDataIndex","valueMatchType","value","_classCallCheck","_defineProperty","matchType","conditionValue","_createClass","key","evaluate","targetingData","c","customData","KameleoonData","customDataValue","result","checkCondition","error","Err","Ok","ValueMatchType","UNDEFINED","TRUE","FALSE","AMONG_VALUES","parseArray","ok","resultData","Set","data","Array","isArray","some","has","includes","CONTAINS","EXACT","REGULAR_EXPRESSION","Utilities","parseRegExp","test","LOWER","EQUAL","GREATER","toLowerCase","JSON","parse","err","KameleoonError","KameleoonException","AmongValuesCheck","exports"],"sources":["../../../src/targeting/conditions/customData.ts"],"sourcesContent":["import { Err, Ok, Result } from 'ts-res';\nimport { CustomDataType, KameleoonData } from 'src/kameleoonData';\nimport { KameleoonError, KameleoonException } from 'src/kameleoonError';\nimport { Utilities } from 'src/utilities';\nimport { EvaluationDataType, ValueMatchType } from 'src/targeting/types';\nimport { ConditionDataType, ICondition } from './types';\n\nexport class CustomData implements ICondition {\n private customDataIndex: number | null;\n private matchType?: ValueMatchType | null;\n private conditionValue?: string | null;\n private error?: KameleoonError;\n\n constructor({ customDataIndex, valueMatchType, value }: ConditionDataType) {\n this.customDataIndex = customDataIndex ? Number(customDataIndex) : null;\n this.matchType = valueMatchType;\n this.conditionValue = value;\n }\n\n public evaluate({\n targetingData,\n }: EvaluationDataType): Result<boolean, KameleoonError> {\n if (typeof this.customDataIndex === 'number') {\n const customData =\n targetingData?.[KameleoonData.CustomData]?.[this.customDataIndex];\n\n if (customData) {\n const { value: customDataValue } = customData;\n const result = this.checkCondition(customDataValue);\n\n if (this.error) {\n return Err(this.error);\n }\n\n return Ok(result);\n }\n }\n\n return Ok(this.matchType === ValueMatchType.UNDEFINED);\n }\n\n private checkCondition(\n customDataValue: CustomDataType['value'] | string,\n ): boolean {\n if (\n typeof this.conditionValue !== 'string' &&\n this.matchType !== ValueMatchType.TRUE &&\n this.matchType !== ValueMatchType.FALSE\n ) {\n return false;\n }\n\n // --- Note ---\n // `ValueMatchType.TRUE` and `ValueMatchType.FALSE` do not use condition value\n // so we can safely assume that `this.conditionValue` is a string at this point\n const conditionValue = this.conditionValue as string;\n\n // --- Note ---\n // `AMONG_VALUES` is checked separately to avoid recursion overhead\n // for `JSON.parse` inside `this.parseArray`\n if (this.matchType === ValueMatchType.AMONG_VALUES) {\n const result = this.parseArray(conditionValue);\n\n if (!result.ok) {\n this.error = result.error;\n\n return false;\n }\n\n const resultData = new Set(result.data);\n\n return Array.isArray(customDataValue)\n ? customDataValue.some((value) => resultData.has(value))\n : result.data.includes(customDataValue);\n }\n\n if (Array.isArray(customDataValue)) {\n return customDataValue.some((value) => this.checkCondition(value));\n }\n\n switch (this.matchType) {\n case ValueMatchType.CONTAINS:\n return customDataValue.includes(conditionValue);\n case ValueMatchType.EXACT:\n return customDataValue === this.conditionValue;\n case ValueMatchType.REGULAR_EXPRESSION:\n return Utilities.parseRegExp(conditionValue).test(customDataValue);\n case ValueMatchType.LOWER:\n return Number(customDataValue) < Number(this.conditionValue);\n case ValueMatchType.EQUAL:\n return Number(customDataValue) === Number(this.conditionValue);\n case ValueMatchType.GREATER:\n return Number(customDataValue) > Number(this.conditionValue);\n case ValueMatchType.TRUE:\n return customDataValue.toLowerCase() === 'true';\n case ValueMatchType.FALSE:\n return customDataValue.toLowerCase() === 'false';\n default:\n return false;\n }\n }\n\n private parseArray(value: string): Result<string[], KameleoonError> {\n try {\n const result = JSON.parse(value);\n\n if (Array.isArray(result)) {\n return Ok(result);\n }\n } catch (err) {\n return Err(\n new KameleoonError(KameleoonException.AmongValuesCheck, err, value),\n );\n }\n\n return Ok([]);\n }\n}\n"],"mappings":"sgDAOa,CAAAA,UAAU,YAMrB,SAAAC,EAAAC,CAAA,CAA2E,IAA7D,CAAAC,CAAe,CAAAD,CAAA,CAAfC,eAAe,CAAEC,CAAc,CAAAF,CAAA,CAAdE,cAAc,CAAEC,CAAK,CAAAH,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CAChE,IAAK,CAAAc,qBAAc,CAACuB,OAAO,CACzB,MAAO,CAAO7B,CAAe,EAAW,IAAI,CAACR,cAAe,CAC9D,IAAK,CAAAc,qBAAc,CAACE,IAAI,CACtB,MAAyC,MAAM,GAAxCR,CAAe,CAAC8B,WAAW,EAAa,CACjD,IAAK,CAAAxB,qBAAc,CAACG,KAAK,CACvB,MAAyC,OAAO,GAAzCT,CAAe,CAAC8B,WAAW,EAAc,CAClD,QACE,SAAa,CAEnB,CAAC,GAAApC,GAAA,cAAAN,KAAA,CAED,SAAAuB,WAAmBvB,CAAa,CAAoC,CAClE,GAAI,CACF,GAAM,CAAAa,CAAM,CAAG8B,IAAI,CAACC,KAAK,CAAC5C,CAAK,CAAC,CAEhC,GAAI4B,KAAK,CAACC,OAAO,CAAChB,CAAM,CAAC,CACvB,MAAO,GAAAI,SAAE,EAACJ,CAAM,CAEpB,CAAE,MAAOgC,CAAG,CAAE,CACZ,MAAO,GAAA7B,UAAG,EACR,GAAI,CAAA8B,8BAAc,CAACC,kCAAkB,CAACC,gBAAgB,CAAEH,CAAG,CAAE7C,CAAK,CAAC,CAEvE,CAEA,MAAO,GAAAiB,SAAE,EAAC,EAAE,CACd,CAAC,IAAArB,CAAA,IAAAqD,OAAA,CAAAtD,UAAA,CAAAA,UAAA"}
@@ -2,7 +2,7 @@ import { Result } from 'ts-res';
2
2
  import { KameleoonError } from '../../kameleoonError';
3
3
  import { EvaluationDataType } from '../../targeting/types';
4
4
  import { ConditionDataType, ICondition } from './types';
5
- export declare class DeviceCondition implements ICondition {
5
+ export declare class Device implements ICondition {
6
6
  private device?;
7
7
  constructor({ device }: ConditionDataType);
8
8
  evaluate({ targetingData, }: EvaluationDataType): Result<boolean, KameleoonError>;
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.TargetExperimentCondition=void 0;var _tsRes=require("ts-res"),_types=require("../types");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var TargetExperimentCondition=/*#__PURE__*/function(){function a(b){var c=b.variation,d=b.experiment,e=b.variationMatchType;_classCallCheck(this,a),_defineProperty(this,"experimentId",void 0),_defineProperty(this,"variationId",void 0),_defineProperty(this,"matchType",void 0),this.experimentId=d,this.variationId=c,this.matchType=e}return _createClass(a,[{key:"evaluate",value:function evaluate(a){var b=a.variationData;if(!this.experimentId)return(0,_tsRes.Ok)(!1);this.matchType!==_types.MatchTypeVariation.EXACT||this.variationId||(0,_tsRes.Ok)(!1);var c=this.checkCondition({variationId:this.variationId,experimentId:this.experimentId,variationData:b});return(0,_tsRes.Ok)(c)}},{key:"checkCondition",value:function checkCondition(a){var b=a.variationId,c=a.experimentId,d=a.variationData,e=d[c+""];switch(this.matchType){case _types.MatchTypeVariation.EXACT:return(null===e||void 0===e?void 0:e.variationId)===b;case _types.MatchTypeVariation.ANY:return!!e;default:return!1;}}}]),a}();exports.TargetExperimentCondition=TargetExperimentCondition;
2
- //# sourceMappingURL=targetExperimentCondition.js.map
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Device=void 0;var _tsRes=require("ts-res"),_kameleoonData=require("../../kameleoonData");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var Device=function(){function a(b){var c=b.device;_classCallCheck(this,a),_defineProperty(this,"device",void 0),this.device=c}return _createClass(a,[{key:"evaluate",value:function evaluate(a){var b=a.targetingData,c=null===b||void 0===b?void 0:b[_kameleoonData.KameleoonData.Device];if(c){var d=c.device;return(0,_tsRes.Ok)(d===this.device)}return(0,_tsRes.Ok)(!1)}}]),a}();exports.Device=Device;
2
+ //# sourceMappingURL=device.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"device.js","names":["Device","a","b","device","_classCallCheck","_defineProperty","_createClass","key","value","evaluate","targetingData","deviceData","KameleoonData","Ok","exports"],"sources":["../../../src/targeting/conditions/device.ts"],"sourcesContent":["import { Ok, Result } from 'ts-res';\nimport { DeviceType, KameleoonData } from 'src/kameleoonData';\nimport { KameleoonError } from 'src/kameleoonError';\nimport { EvaluationDataType } from 'src/targeting/types';\nimport { ConditionDataType, ICondition } from './types';\n\nexport class Device implements ICondition {\n private device?: DeviceType | null;\n\n constructor({ device }: ConditionDataType) {\n this.device = device;\n }\n\n public evaluate({\n targetingData,\n }: EvaluationDataType): Result<boolean, KameleoonError> {\n const deviceData = targetingData?.[KameleoonData.Device];\n\n if (deviceData) {\n const { device } = deviceData;\n\n return Ok(device === this.device);\n }\n\n return Ok(false);\n }\n}\n"],"mappings":"i5CAMa,CAAAA,MAAM,YAGjB,SAAAC,EAAAC,CAAA,CAA2C,IAA7B,CAAAC,CAAM,CAAAD,CAAA,CAANC,MAAM,CAAAC,eAAA,MAAAH,CAAA,EAAAI,eAAA,uBAClB,IAAI,CAACF,MAAM,CAAGA,CAChB,CAAC,OAAAG,YAAA,CAAAL,CAAA,GAAAM,GAAA,YAAAC,KAAA,CAED,SAAAC,SAAAR,CAAA,CAEwD,IADtD,CAAAS,CAAa,CAAAT,CAAA,CAAbS,aAAa,CAEPC,CAAU,QAAGD,CAAa,WAAbA,CAAa,QAAbA,CAAa,CAAGE,4BAAa,CAACZ,MAAM,CAAC,CAExD,GAAIW,CAAU,CAAE,CACd,GAAQ,CAAAR,CAAM,CAAKQ,CAAU,CAArBR,MAAM,CAEd,MAAO,GAAAU,SAAE,EAACV,CAAM,GAAK,IAAI,CAACA,MAAM,CAClC,CAEA,MAAO,GAAAU,SAAE,KACX,CAAC,IAAAZ,CAAA,IAAAa,OAAA,CAAAd,MAAA,CAAAA,MAAA"}
@@ -2,6 +2,6 @@ import { Result } from 'ts-res';
2
2
  import { KameleoonError } from '../../kameleoonError';
3
3
  import { EvaluationDataType } from '../../targeting/types';
4
4
  import { ICondition } from './types';
5
- export declare class ExclusiveExperimentCondition implements ICondition {
6
- evaluate({ experimentId, variationData, }: EvaluationDataType): Result<boolean, KameleoonError>;
5
+ export declare class ExclusiveCampaign implements ICondition {
6
+ evaluate({ variationData, experimentId, }: EvaluationDataType): Result<boolean, KameleoonError>;
7
7
  }
@@ -0,0 +1,2 @@
1
+ "use strict";var _tsRes=require("ts-res");Object.defineProperty(exports,"__esModule",{value:!0}),exports.ExclusiveCampaign=void 0;function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var ExclusiveCampaign=function(){function a(){_classCallCheck(this,a)}return _createClass(a,[{key:"evaluate",value:function evaluate(a){var b=a.variationData,c=a.experimentId,d=Object.keys(b),e=!d.length,f=1===d.length&&d[0]===c+"";return(0,_tsRes.Ok)(e||f)}}]),a}();exports.ExclusiveCampaign=ExclusiveCampaign;
2
+ //# sourceMappingURL=exclusiveCampaign.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exclusiveCampaign.js","names":["_tsRes","require","Object","defineProperty","exports","value","ExclusiveCampaign","_typeof","a","Symbol","iterator","constructor","prototype","_classCallCheck","b","TypeError","_defineProperties","c","d","length","enumerable","configurable","writable","_toPropertyKey","key","_createClass","_toPrimitive","toPrimitive","call","String","Number","evaluate","variationData","experimentId","keys","isEmpty","isExclusive","Ok"],"sources":["../../../src/targeting/conditions/exclusiveCampaign.ts"],"sourcesContent":["import { Ok, Result } from 'ts-res';\nimport { KameleoonError } from 'src/kameleoonError';\nimport { EvaluationDataType } from 'src/targeting/types';\nimport { ICondition } from './types';\n\nexport class ExclusiveCampaign implements ICondition {\n evaluate({\n variationData,\n experimentId,\n }: EvaluationDataType): Result<boolean, KameleoonError> {\n const keys = Object.keys(variationData);\n const isEmpty = !keys.length;\n // --- Note ---\n // Checking exclusiveness is done by checking if there is only one experiment id with variation\n // and the next assigned experiment id will overwrite the previous one\n // (thus, still leaving one exclusive experiment)\n const isExclusive = keys.length === 1 && keys[0] === String(experimentId);\n const isSatisfied = isEmpty || isExclusive;\n\n return Ok(isSatisfied);\n }\n}\n"],"mappings":"aAAA,IAAAA,MAAA,CAAAC,OAAA,WAAoCC,MAAA,CAAAC,cAAA,CAAAC,OAAA,eAAAC,KAAA,MAAAD,OAAA,CAAAE,iBAAA,iBAAAC,QAAAC,CAAA,mCAAAD,OAAA,oBAAAE,MAAA,mBAAAA,MAAA,CAAAC,QAAA,UAAAF,CAAA,gBAAAA,CAAA,WAAAA,CAAA,SAAAA,CAAA,qBAAAC,MAAA,EAAAD,CAAA,CAAAG,WAAA,GAAAF,MAAA,EAAAD,CAAA,GAAAC,MAAA,CAAAG,SAAA,iBAAAJ,CAAA,EAAAD,OAAA,CAAAC,CAAA,WAAAK,gBAAAL,CAAA,CAAAM,CAAA,OAAAN,CAAA,YAAAM,CAAA,YAAAC,SAAA,+CAAAC,kBAAAR,CAAA,CAAAM,CAAA,UAAAG,CAAA,CAAAC,CAAA,GAAAA,CAAA,CAAAJ,CAAA,CAAAK,MAAA,CAAAD,CAA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ACF,CAAa,CAAC,CACjCG,CAAO,CAAG,CAACD,CAAI,CAACf,MAAM,CAKtBiB,CAAW,CAAmB,CAAC,GAAjBF,CAAI,CAACf,MAAY,EAAIe,CAAI,CAAC,CAAC,CAAC,GAAYD,CAAY,GAAC,CAGzE,MAAO,GAAAI,SAAE,EAFWF,CAAO,EAAIC,CAAW,CAG5C,CAAC,IAAA5B,CAAA,IAAAJ,OAAA,CAAAE,iBAAA,CAAAA,iBAAA"}
@@ -0,0 +1,12 @@
1
+ import { Result } from 'ts-res';
2
+ import { KameleoonError } from '../../kameleoonError';
3
+ import { EvaluationDataType } from '../../targeting/types';
4
+ import { ConditionDataType, ICondition } from './types';
5
+ export declare class FirstVisit implements ICondition {
6
+ private matchType?;
7
+ private conditionValue?;
8
+ private timeUnit?;
9
+ constructor({ matchType, count, unitOfTime }: ConditionDataType);
10
+ evaluate({ targetingData, }: EvaluationDataType): Result<boolean, KameleoonError>;
11
+ private checkCondition;
12
+ }