@kameleoon/javascript-sdk-core 2.10.0 → 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 (262) hide show
  1. package/dist/cacheManager/cacheManager.d.ts +38 -0
  2. package/dist/cacheManager/cacheManager.js +2 -0
  3. package/dist/cacheManager/cacheManager.js.map +1 -0
  4. package/dist/cacheManager/index.d.ts +2 -0
  5. package/dist/cacheManager/index.js +2 -0
  6. package/dist/cacheManager/index.js.map +1 -0
  7. package/dist/cacheManager/types.d.ts +14 -0
  8. package/dist/cacheManager/types.js +2 -0
  9. package/dist/cacheManager/types.js.map +1 -0
  10. package/dist/clientConfiguration/clientConfiguration.d.ts +52 -0
  11. package/dist/clientConfiguration/clientConfiguration.js +2 -0
  12. package/dist/clientConfiguration/clientConfiguration.js.map +1 -0
  13. package/dist/clientConfiguration/constants.d.ts +2 -0
  14. package/dist/clientConfiguration/constants.js +2 -0
  15. package/dist/clientConfiguration/constants.js.map +1 -0
  16. package/dist/clientConfiguration/index.d.ts +2 -0
  17. package/dist/clientConfiguration/index.js +2 -0
  18. package/dist/clientConfiguration/index.js.map +1 -0
  19. package/dist/clientConfiguration/types.d.ts +114 -0
  20. package/dist/clientConfiguration/types.js +2 -0
  21. package/dist/clientConfiguration/types.js.map +1 -0
  22. package/dist/clientSettings/clientSettings.d.ts +12 -0
  23. package/dist/clientSettings/clientSettings.js +2 -0
  24. package/dist/clientSettings/clientSettings.js.map +1 -0
  25. package/dist/clientSettings/index.d.ts +2 -0
  26. package/dist/clientSettings/index.js +2 -0
  27. package/dist/clientSettings/index.js.map +1 -0
  28. package/dist/clientSettings/types.d.ts +6 -0
  29. package/dist/clientSettings/types.js +2 -0
  30. package/dist/clientSettings/types.js.map +1 -0
  31. package/dist/constants.d.ts +34 -0
  32. package/dist/constants.js +2 -0
  33. package/dist/constants.js.map +1 -0
  34. package/dist/eventSource/constants.d.ts +1 -0
  35. package/dist/eventSource/constants.js +2 -0
  36. package/dist/eventSource/constants.js.map +1 -0
  37. package/dist/eventSource/externalEventSource.d.ts +12 -0
  38. package/dist/eventSource/externalEventSource.js +2 -0
  39. package/dist/eventSource/externalEventSource.js.map +1 -0
  40. package/dist/eventSource/index.d.ts +3 -0
  41. package/dist/eventSource/index.js +2 -0
  42. package/dist/eventSource/index.js.map +1 -0
  43. package/dist/eventSource/types.d.ts +47 -0
  44. package/dist/eventSource/types.js +2 -0
  45. package/dist/eventSource/types.js.map +1 -0
  46. package/dist/hasher/hasher.d.ts +5 -0
  47. package/dist/hasher/hasher.js +2 -0
  48. package/dist/hasher/hasher.js.map +1 -0
  49. package/dist/hasher/index.d.ts +1 -0
  50. package/dist/hasher/index.js +2 -0
  51. package/dist/hasher/index.js.map +1 -0
  52. package/dist/hasher/types.d.ts +5 -0
  53. package/dist/hasher/types.js +2 -0
  54. package/dist/hasher/types.js.map +1 -0
  55. package/dist/index.d.ts +13 -0
  56. package/dist/index.js +2 -0
  57. package/dist/index.js.map +1 -0
  58. package/dist/kameleoonClient.d.ts +231 -0
  59. package/dist/kameleoonClient.js +2 -0
  60. package/dist/kameleoonClient.js.map +1 -0
  61. package/dist/kameleoonData/applicationVersion.d.ts +26 -0
  62. package/dist/kameleoonData/applicationVersion.js +2 -0
  63. package/dist/kameleoonData/applicationVersion.js.map +1 -0
  64. package/dist/kameleoonData/browser.d.ts +41 -0
  65. package/dist/kameleoonData/browser.js +2 -0
  66. package/dist/kameleoonData/browser.js.map +1 -0
  67. package/dist/kameleoonData/constants.d.ts +4 -0
  68. package/dist/kameleoonData/constants.js +2 -0
  69. package/dist/kameleoonData/constants.js.map +1 -0
  70. package/dist/kameleoonData/conversion.d.ts +36 -0
  71. package/dist/kameleoonData/conversion.js +2 -0
  72. package/dist/kameleoonData/conversion.js.map +1 -0
  73. package/dist/kameleoonData/cookie.d.ts +33 -0
  74. package/dist/kameleoonData/cookie.js +2 -0
  75. package/dist/kameleoonData/cookie.js.map +1 -0
  76. package/dist/kameleoonData/customData.d.ts +46 -0
  77. package/dist/kameleoonData/customData.js +2 -0
  78. package/dist/kameleoonData/customData.js.map +1 -0
  79. package/dist/kameleoonData/dataManager.d.ts +38 -0
  80. package/dist/kameleoonData/dataManager.js +2 -0
  81. package/dist/kameleoonData/dataManager.js.map +1 -0
  82. package/dist/kameleoonData/dataProcessor.d.ts +26 -0
  83. package/dist/kameleoonData/dataProcessor.js +2 -0
  84. package/dist/kameleoonData/dataProcessor.js.map +1 -0
  85. package/dist/kameleoonData/device.d.ts +34 -0
  86. package/dist/kameleoonData/device.js +2 -0
  87. package/dist/kameleoonData/device.js.map +1 -0
  88. package/dist/kameleoonData/geolocation.d.ts +52 -0
  89. package/dist/kameleoonData/geolocation.js +2 -0
  90. package/dist/kameleoonData/geolocation.js.map +1 -0
  91. package/dist/kameleoonData/helpers.d.ts +1 -0
  92. package/dist/kameleoonData/helpers.js +2 -0
  93. package/dist/kameleoonData/helpers.js.map +1 -0
  94. package/dist/kameleoonData/index.d.ts +14 -0
  95. package/dist/kameleoonData/index.js +2 -0
  96. package/dist/kameleoonData/index.js.map +1 -0
  97. package/dist/kameleoonData/operatingSystem.d.ts +34 -0
  98. package/dist/kameleoonData/operatingSystem.js +2 -0
  99. package/dist/kameleoonData/operatingSystem.js.map +1 -0
  100. package/dist/kameleoonData/pageView.d.ts +42 -0
  101. package/dist/kameleoonData/pageView.js +2 -0
  102. package/dist/kameleoonData/pageView.js.map +1 -0
  103. package/dist/kameleoonData/types.d.ts +226 -0
  104. package/dist/kameleoonData/types.js +2 -0
  105. package/dist/kameleoonData/types.js.map +1 -0
  106. package/dist/kameleoonData/userAgent.d.ts +23 -0
  107. package/dist/kameleoonData/userAgent.js +2 -0
  108. package/dist/kameleoonData/userAgent.js.map +1 -0
  109. package/dist/kameleoonData/visitsData.d.ts +34 -0
  110. package/dist/kameleoonData/visitsData.js +2 -0
  111. package/dist/kameleoonData/visitsData.js.map +1 -0
  112. package/dist/kameleoonError/constants.d.ts +28 -0
  113. package/dist/kameleoonError/constants.js +2 -0
  114. package/dist/kameleoonError/constants.js.map +1 -0
  115. package/dist/kameleoonError/helpers.d.ts +1 -0
  116. package/dist/kameleoonError/helpers.js +2 -0
  117. package/dist/kameleoonError/helpers.js.map +1 -0
  118. package/dist/kameleoonError/index.d.ts +3 -0
  119. package/dist/kameleoonError/index.js +2 -0
  120. package/dist/kameleoonError/index.js.map +1 -0
  121. package/dist/kameleoonError/kameleoonError.d.ts +26 -0
  122. package/dist/kameleoonError/kameleoonError.js +2 -0
  123. package/dist/kameleoonError/kameleoonError.js.map +1 -0
  124. package/dist/kameleoonError/types.d.ts +30 -0
  125. package/dist/kameleoonError/types.js +2 -0
  126. package/dist/kameleoonError/types.js.map +1 -0
  127. package/dist/kameleoonUtils.d.ts +13 -0
  128. package/dist/kameleoonUtils.js +2 -0
  129. package/dist/kameleoonUtils.js.map +1 -0
  130. package/dist/requester/constants.d.ts +18 -0
  131. package/dist/requester/constants.js +2 -0
  132. package/dist/requester/constants.js.map +1 -0
  133. package/dist/requester/index.d.ts +3 -0
  134. package/dist/requester/index.js +2 -0
  135. package/dist/requester/index.js.map +1 -0
  136. package/dist/requester/requester.d.ts +24 -0
  137. package/dist/requester/requester.js +2 -0
  138. package/dist/requester/requester.js.map +1 -0
  139. package/dist/requester/types.d.ts +165 -0
  140. package/dist/requester/types.js +2 -0
  141. package/dist/requester/types.js.map +1 -0
  142. package/dist/storage/constants.d.ts +11 -0
  143. package/dist/storage/constants.js +2 -0
  144. package/dist/storage/constants.js.map +1 -0
  145. package/dist/storage/index.d.ts +2 -0
  146. package/dist/storage/index.js +2 -0
  147. package/dist/storage/index.js.map +1 -0
  148. package/dist/storage/types.d.ts +65 -0
  149. package/dist/storage/types.js +2 -0
  150. package/dist/storage/types.js.map +1 -0
  151. package/dist/targeting/conditions/applicationVersion.d.ts +10 -0
  152. package/dist/targeting/conditions/applicationVersion.js +2 -0
  153. package/dist/targeting/conditions/applicationVersion.js.map +1 -0
  154. package/dist/targeting/conditions/browser.d.ts +13 -0
  155. package/dist/targeting/conditions/browser.js +2 -0
  156. package/dist/targeting/conditions/browser.js.map +1 -0
  157. package/dist/targeting/conditions/conditionFactory.d.ts +6 -0
  158. package/dist/targeting/conditions/conditionFactory.js +2 -0
  159. package/dist/targeting/conditions/conditionFactory.js.map +1 -0
  160. package/dist/targeting/conditions/conversion.d.ts +9 -0
  161. package/dist/targeting/conditions/conversion.js +2 -0
  162. package/dist/targeting/conditions/conversion.js.map +1 -0
  163. package/dist/targeting/conditions/cookie.d.ts +15 -0
  164. package/dist/targeting/conditions/cookie.js +2 -0
  165. package/dist/targeting/conditions/cookie.js.map +1 -0
  166. package/dist/targeting/conditions/customData.d.ts +14 -0
  167. package/dist/targeting/conditions/customData.js +2 -0
  168. package/dist/targeting/conditions/customData.js.map +1 -0
  169. package/dist/targeting/conditions/device.d.ts +9 -0
  170. package/dist/targeting/conditions/device.js +2 -0
  171. package/dist/targeting/conditions/device.js.map +1 -0
  172. package/dist/targeting/conditions/exclusiveCampaign.d.ts +7 -0
  173. package/dist/targeting/conditions/exclusiveCampaign.js +2 -0
  174. package/dist/targeting/conditions/exclusiveCampaign.js.map +1 -0
  175. package/dist/targeting/conditions/firstVisit.d.ts +12 -0
  176. package/dist/targeting/conditions/firstVisit.js +2 -0
  177. package/dist/targeting/conditions/firstVisit.js.map +1 -0
  178. package/dist/targeting/conditions/geolocation.d.ts +11 -0
  179. package/dist/targeting/conditions/geolocation.js +2 -0
  180. package/dist/targeting/conditions/geolocation.js.map +1 -0
  181. package/dist/targeting/conditions/index.d.ts +24 -0
  182. package/dist/targeting/conditions/index.js +2 -0
  183. package/dist/targeting/conditions/index.js.map +1 -0
  184. package/dist/targeting/conditions/lastVisit.d.ts +12 -0
  185. package/dist/targeting/conditions/lastVisit.js +2 -0
  186. package/dist/targeting/conditions/lastVisit.js.map +1 -0
  187. package/dist/targeting/conditions/newVisitor.d.ts +9 -0
  188. package/dist/targeting/conditions/newVisitor.js +2 -0
  189. package/dist/targeting/conditions/newVisitor.js.map +1 -0
  190. package/dist/targeting/conditions/operatingSystem.d.ts +9 -0
  191. package/dist/targeting/conditions/operatingSystem.js +2 -0
  192. package/dist/targeting/conditions/operatingSystem.js.map +1 -0
  193. package/dist/targeting/conditions/pageTitle.d.ts +11 -0
  194. package/dist/targeting/conditions/pageTitle.js +2 -0
  195. package/dist/targeting/conditions/pageTitle.js.map +1 -0
  196. package/dist/targeting/conditions/pageUrl.d.ts +11 -0
  197. package/dist/targeting/conditions/pageUrl.js +2 -0
  198. package/dist/targeting/conditions/pageUrl.js.map +1 -0
  199. package/dist/targeting/conditions/previousPage.d.ts +12 -0
  200. package/dist/targeting/conditions/previousPage.js +2 -0
  201. package/dist/targeting/conditions/previousPage.js.map +1 -0
  202. package/dist/targeting/conditions/sameDayVisits.d.ts +11 -0
  203. package/dist/targeting/conditions/sameDayVisits.js +2 -0
  204. package/dist/targeting/conditions/sameDayVisits.js.map +1 -0
  205. package/dist/targeting/conditions/sdkLanguage.d.ts +12 -0
  206. package/dist/targeting/conditions/sdkLanguage.js +2 -0
  207. package/dist/targeting/conditions/sdkLanguage.js.map +1 -0
  208. package/dist/targeting/conditions/segment.d.ts +9 -0
  209. package/dist/targeting/conditions/segment.js +2 -0
  210. package/dist/targeting/conditions/segment.js.map +1 -0
  211. package/dist/targeting/conditions/targetFeatureFlag.d.ts +11 -0
  212. package/dist/targeting/conditions/targetFeatureFlag.js +2 -0
  213. package/dist/targeting/conditions/targetFeatureFlag.js.map +1 -0
  214. package/dist/targeting/conditions/types.d.ts +49 -0
  215. package/dist/targeting/conditions/types.js +2 -0
  216. package/dist/targeting/conditions/types.js.map +1 -0
  217. package/dist/targeting/conditions/visitedPages.d.ts +11 -0
  218. package/dist/targeting/conditions/visitedPages.js +2 -0
  219. package/dist/targeting/conditions/visitedPages.js.map +1 -0
  220. package/dist/targeting/conditions/visitorCode.d.ts +11 -0
  221. package/dist/targeting/conditions/visitorCode.js +2 -0
  222. package/dist/targeting/conditions/visitorCode.js.map +1 -0
  223. package/dist/targeting/conditions/visits.d.ts +11 -0
  224. package/dist/targeting/conditions/visits.js +2 -0
  225. package/dist/targeting/conditions/visits.js.map +1 -0
  226. package/dist/targeting/index.d.ts +3 -0
  227. package/dist/targeting/index.js +2 -0
  228. package/dist/targeting/index.js.map +1 -0
  229. package/dist/targeting/node.d.ts +23 -0
  230. package/dist/targeting/node.js +2 -0
  231. package/dist/targeting/node.js.map +1 -0
  232. package/dist/targeting/tree.d.ts +22 -0
  233. package/dist/targeting/tree.js +2 -0
  234. package/dist/targeting/tree.js.map +1 -0
  235. package/dist/targeting/types.d.ts +164 -0
  236. package/dist/targeting/types.js +2 -0
  237. package/dist/targeting/types.js.map +1 -0
  238. package/dist/types.d.ts +200 -0
  239. package/dist/types.js +2 -0
  240. package/dist/types.js.map +1 -0
  241. package/dist/utilities/constants.d.ts +2 -0
  242. package/dist/utilities/constants.js +2 -0
  243. package/dist/utilities/constants.js.map +1 -0
  244. package/dist/utilities/index.d.ts +3 -0
  245. package/dist/utilities/index.js +2 -0
  246. package/dist/utilities/index.js.map +1 -0
  247. package/dist/utilities/types.d.ts +119 -0
  248. package/dist/utilities/types.js +2 -0
  249. package/dist/utilities/types.js.map +1 -0
  250. package/dist/utilities/utilities.d.ts +40 -0
  251. package/dist/utilities/utilities.js +2 -0
  252. package/dist/utilities/utilities.js.map +1 -0
  253. package/dist/variationConfiguration/index.d.ts +2 -0
  254. package/dist/variationConfiguration/index.js +2 -0
  255. package/dist/variationConfiguration/index.js.map +1 -0
  256. package/dist/variationConfiguration/types.d.ts +21 -0
  257. package/dist/variationConfiguration/types.js +2 -0
  258. package/dist/variationConfiguration/types.js.map +1 -0
  259. package/dist/variationConfiguration/variationConfiguration.d.ts +27 -0
  260. package/dist/variationConfiguration/variationConfiguration.js +2 -0
  261. package/dist/variationConfiguration/variationConfiguration.js.map +1 -0
  262. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lastVisit.js","names":["LastVisit","a","b","matchType","count","unitOfTime","_classCallCheck","_defineProperty","conditionValue","timeUnit","_createClass","key","value","evaluate","targetingData","visitsData","KameleoonData","VisitsData","Ok","currentVisit","previousVisits","lastVisitTimestamp","length","checkCondition","elapsedTimeMilliseconds","Date","now","elapsedTimeUnit","Utilities","convertTimeUnit","MatchType","GREATER","LOWER","exports"],"sources":["../../../src/targeting/conditions/lastVisit.ts"],"sourcesContent":["import { Ok, Result } from 'ts-res';\nimport { KameleoonData } from 'src/kameleoonData';\nimport { KameleoonError } from 'src/kameleoonError';\nimport { Utilities, TimeUnit } from 'src/utilities';\nimport { EvaluationDataType, MatchType } from 'src/targeting/types';\nimport { ConditionDataType, ICondition } from './types';\n\nexport class LastVisit implements ICondition {\n private matchType?: MatchType | null;\n private conditionValue?: number | null;\n private timeUnit?: TimeUnit | null;\n\n constructor({ matchType, count, unitOfTime }: ConditionDataType) {\n this.matchType = matchType;\n this.conditionValue = count;\n this.timeUnit = unitOfTime;\n }\n\n public evaluate({\n targetingData,\n }: EvaluationDataType): Result<boolean, KameleoonError> {\n const visitsData = targetingData?.[KameleoonData.VisitsData];\n\n if (!visitsData) {\n return Ok(false);\n }\n\n const { currentVisit, previousVisits } = visitsData;\n\n const lastVisitTimestamp = currentVisit\n ? currentVisit\n : previousVisits[previousVisits.length - 1];\n\n if (typeof lastVisitTimestamp !== 'number') {\n return Ok(false);\n }\n\n return Ok(this.checkCondition(lastVisitTimestamp));\n }\n\n private checkCondition(lastVisitTimestamp: number): boolean {\n if (\n !this.matchType ||\n typeof this.conditionValue !== 'number' ||\n !this.timeUnit\n ) {\n return false;\n }\n\n const elapsedTimeMilliseconds = Date.now() - lastVisitTimestamp;\n const elapsedTimeUnit = Utilities.convertTimeUnit(\n elapsedTimeMilliseconds,\n this.timeUnit,\n );\n\n switch (this.matchType) {\n case MatchType.GREATER:\n return elapsedTimeUnit > this.conditionValue;\n case MatchType.LOWER:\n return elapsedTimeUnit < this.conditionValue;\n default:\n return false;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AAG,EAAE,CAAGL,CAAkB,CACzDM,CAAe,CAAGC,oBAAS,CAACC,eAAe,CAC/CL,CAAuB,CACvB,IAAI,CAACf,QAAQ,CACd,CAED,OAAQ,IAAI,CAACN,SAAS,EACpB,IAAK,CAAA2B,gBAAS,CAACC,OAAO,CACpB,MAAO,CAAAJ,CAAe,CAAG,IAAI,CAACnB,cAAc,CAC9C,IAAK,CAAAsB,gBAAS,CAACE,KAAK,CAClB,MAAO,CAAAL,CAAe,CAAG,IAAI,CAACnB,cAAc,CAC9C,QACE,SAAa,CAEnB,CAAC,IAAAP,CAAA,IAAAgC,OAAA,CAAAjC,SAAA,CAAAA,SAAA"}
@@ -0,0 +1,9 @@
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 NewVisitor implements ICondition {
6
+ private visitorType?;
7
+ constructor({ visitorType }: ConditionDataType);
8
+ evaluate({ targetingData, }: EvaluationDataType): Result<boolean, KameleoonError>;
9
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.NewVisitor=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 NewVisitor=function(){function a(b){var c=b.visitorType;_classCallCheck(this,a),_defineProperty(this,"visitorType",void 0),this.visitorType=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.VisitsData];if(!c||!this.visitorType)return(0,_tsRes.Ok)(!1);var d=c.currentVisit,e=c.previousVisits,f=d&&!e.length||!d&&!e.length;switch(this.visitorType){case _types.VisitorType.NEW:return(0,_tsRes.Ok)(f);case _types.VisitorType.RETURNING:return(0,_tsRes.Ok)(!f);default:(0,_kameleoonError.exhaustCheck)(this.visitorType);}}}]),a}();exports.NewVisitor=NewVisitor;
2
+ //# sourceMappingURL=newVisitor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"newVisitor.js","names":["NewVisitor","a","b","visitorType","_classCallCheck","_defineProperty","_createClass","key","value","evaluate","targetingData","visitsData","KameleoonData","VisitsData","Ok","currentVisit","previousVisits","isNewVisitor","length","VisitorType","NEW","RETURNING","exhaustCheck","exports"],"sources":["../../../src/targeting/conditions/newVisitor.ts"],"sourcesContent":["import { Ok, Result } from 'ts-res';\nimport { KameleoonData } from 'src/kameleoonData';\nimport { exhaustCheck, KameleoonError } from 'src/kameleoonError';\nimport { EvaluationDataType, VisitorType } from 'src/targeting/types';\nimport { ConditionDataType, ICondition } from './types';\n\nexport class NewVisitor implements ICondition {\n private visitorType?: VisitorType | null;\n\n constructor({ visitorType }: ConditionDataType) {\n this.visitorType = visitorType;\n }\n\n public evaluate({\n targetingData,\n }: EvaluationDataType): Result<boolean, KameleoonError> {\n const visitsData = targetingData?.[KameleoonData.VisitsData];\n\n if (!visitsData || !this.visitorType) {\n return Ok(false);\n }\n\n const { currentVisit, previousVisits } = visitsData;\n\n // --- Note ---\n // Second case handles situation when user didn't use `addData` that\n // creates new current visit\n const isNewVisitor =\n (currentVisit && !previousVisits.length) ||\n (!currentVisit && !previousVisits.length);\n\n switch (this.visitorType) {\n case VisitorType.NEW:\n return Ok(isNewVisitor);\n case VisitorType.RETURNING:\n return Ok(!isNewVisitor);\n default:\n exhaustCheck(this.visitorType);\n }\n }\n}\n"],"mappings":"g+CAMa,CAAAA,UAAU,YAGrB,SAAAC,EAAAC,CAAA,CAAgD,IAAlC,CAAAC,CAAW,CAAAD,CAAA,CAAXC,WAAW,CAAAC,eAAA,MAAAH,CAAA,EAAAI,eAAA,4BACvB,IAAI,CAACF,WAAW,CAAGA,CACrB,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,CAACC,UAAU,CAAC,CAE5D,GAAI,CAACF,CAAU,EAAI,CAAC,IAAI,CAACR,WAAW,CAClC,MAAO,GAAAW,SAAE,KAAO,CACjB,GAEO,CAAAC,CAAY,CAAqBJ,CAAU,CAA3CI,YAAY,CAAEC,CAAc,CAAKL,CAAU,CAA7BK,cAAc,CAK9BC,CAAY,CACfF,CAAY,EAAI,CAACC,CAAc,CAACE,MAAM,EACtC,CAACH,CAAY,EAAI,CAACC,CAAc,CAACE,MAAO,CAE3C,OAAQ,IAAI,CAACf,WAAW,EACtB,IAAK,CAAAgB,kBAAW,CAACC,GAAG,CAClB,MAAO,GAAAN,SAAE,EAACG,CAAY,CAAC,CACzB,IAAK,CAAAE,kBAAW,CAACE,SAAS,CACxB,MAAO,GAAAP,SAAE,EAAC,CAACG,CAAY,CAAC,CAC1B,QACE,GAAAK,4BAAY,EAAC,IAAI,CAACnB,WAAW,CAAC,CAAC,CAErC,CAAC,IAAAF,CAAA,IAAAsB,OAAA,CAAAvB,UAAA,CAAAA,UAAA"}
@@ -0,0 +1,9 @@
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 OperatingSystem implements ICondition {
6
+ private operatingSystem?;
7
+ constructor({ os }: ConditionDataType);
8
+ evaluate({ targetingData, }: EvaluationDataType): Result<boolean, KameleoonError>;
9
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.OperatingSystem=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 OperatingSystem=function(){function a(b){var c=b.os;_classCallCheck(this,a),_defineProperty(this,"operatingSystem",void 0),this.operatingSystem=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.OperatingSystem];if(c){var d=c.operatingSystem;return(0,_tsRes.Ok)(d===this.operatingSystem)}return(0,_tsRes.Ok)(!1)}}]),a}();exports.OperatingSystem=OperatingSystem;
2
+ //# sourceMappingURL=operatingSystem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operatingSystem.js","names":["OperatingSystem","a","b","os","_classCallCheck","_defineProperty","operatingSystem","_createClass","key","value","evaluate","targetingData","operatingSystemData","KameleoonData","Ok","exports"],"sources":["../../../src/targeting/conditions/operatingSystem.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 { OperatingSystemType } from 'src/kameleoonData/types';\nimport { ConditionDataType, ICondition } from './types';\n\nexport class OperatingSystem implements ICondition {\n private operatingSystem?: OperatingSystemType | null;\n\n constructor({ os }: ConditionDataType) {\n this.operatingSystem = os;\n }\n\n public evaluate({\n targetingData,\n }: EvaluationDataType): Result<boolean, KameleoonError> {\n const operatingSystemData = targetingData?.[KameleoonData.OperatingSystem];\n\n if (operatingSystemData) {\n const { operatingSystem } = operatingSystemData;\n\n return Ok(operatingSystem === this.operatingSystem);\n }\n\n return Ok(false);\n }\n}\n"],"mappings":"05CAOa,CAAAA,eAAe,YAG1B,SAAAC,EAAAC,CAAA,CAAuC,IAAzB,CAAAC,CAAE,CAAAD,CAAA,CAAFC,EAAE,CAAAC,eAAA,MAAAH,CAAA,EAAAI,eAAA,gCACd,IAAI,CAACC,eAAe,CAAGH,CACzB,CAAC,OAAAI,YAAA,CAAAN,CAAA,GAAAO,GAAA,YAAAC,KAAA,CAED,SAAAC,SAAAT,CAAA,CAEwD,IADtD,CAAAU,CAAa,CAAAV,CAAA,CAAbU,aAAa,CAEPC,CAAmB,QAAGD,CAAa,WAAbA,CAAa,QAAbA,CAAa,CAAGE,4BAAa,CAACb,eAAe,CAAC,CAE1E,GAAIY,CAAmB,CAAE,CACvB,GAAQ,CAAAN,CAAe,CAAKM,CAAmB,CAAvCN,eAAe,CAEvB,MAAO,GAAAQ,SAAE,EAACR,CAAe,GAAK,IAAI,CAACA,eAAe,CACpD,CAEA,MAAO,GAAAQ,SAAE,KACX,CAAC,IAAAb,CAAA,IAAAc,OAAA,CAAAf,eAAA,CAAAA,eAAA"}
@@ -0,0 +1,11 @@
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 PageTitle implements ICondition {
6
+ private matchType?;
7
+ private conditionValue?;
8
+ constructor({ matchType, title }: ConditionDataType);
9
+ evaluate({ targetingData, }: EvaluationDataType): Result<boolean, KameleoonError>;
10
+ private checkCondition;
11
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PageTitle=void 0;var _tsRes=require("ts-res"),_kameleoonData=require("../../kameleoonData"),_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 PageTitle=function(){function a(b){var c=b.matchType,d=b.title;_classCallCheck(this,a),_defineProperty(this,"matchType",void 0),_defineProperty(this,"conditionValue",void 0),this.matchType=c,this.conditionValue=d}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.PageView];return d?(0,_tsRes.Ok)(Object.values(d).some(function(a){return b.checkCondition(a.title)})):(0,_tsRes.Ok)(!1)}},{key:"checkCondition",value:function checkCondition(a){if(!this.matchType||!this.conditionValue)return!1;switch(this.matchType){case _types.MatchType.CONTAINS:return a.includes(this.conditionValue);case _types.MatchType.EXACT:return a===this.conditionValue;case _types.MatchType.REGULAR_EXPRESSION:return _utilities.Utilities.parseRegExp(this.conditionValue).test(a);default:return!1;}}}]),a}();exports.PageTitle=PageTitle;
2
+ //# sourceMappingURL=pageTitle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pageTitle.js","names":["PageTitle","a","b","matchType","title","_classCallCheck","_defineProperty","conditionValue","_createClass","key","value","evaluate","targetingData","pageViewData","KameleoonData","PageView","Ok","Object","values","some","data","checkCondition","MatchType","CONTAINS","includes","EXACT","REGULAR_EXPRESSION","Utilities","parseRegExp","test","exports"],"sources":["../../../src/targeting/conditions/pageTitle.ts"],"sourcesContent":["import { Ok, Result } from 'ts-res';\nimport { KameleoonData } from 'src/kameleoonData';\nimport { KameleoonError } from 'src/kameleoonError';\nimport { Utilities } from 'src/utilities';\nimport { EvaluationDataType, MatchType } from 'src/targeting/types';\nimport { ConditionDataType, ICondition } from './types';\n\nexport class PageTitle implements ICondition {\n private matchType?: MatchType | null;\n private conditionValue?: string | null;\n\n constructor({ matchType, title }: ConditionDataType) {\n this.matchType = matchType;\n this.conditionValue = title;\n }\n\n public evaluate({\n targetingData,\n }: EvaluationDataType): Result<boolean, KameleoonError> {\n const pageViewData = targetingData?.[KameleoonData.PageView];\n\n if (pageViewData) {\n return Ok(\n Object.values(pageViewData).some((data) => {\n return this.checkCondition(data.title);\n }),\n );\n }\n\n return Ok(false);\n }\n\n private checkCondition(title: string): boolean {\n if (!this.matchType || !this.conditionValue) {\n return false;\n }\n\n switch (this.matchType) {\n case MatchType.CONTAINS:\n return title.includes(this.conditionValue);\n case MatchType.EXACT:\n return title === this.conditionValue;\n case MatchType.REGULAR_EXPRESSION:\n return Utilities.parseRegExp(this.conditionValue).test(title);\n default:\n return false;\n }\n }\n}\n"],"mappings":"q9CAOa,CAAAA,SAAS,YAIpB,SAAAC,EAAAC,CAAA,CAAqD,IAAvC,CAAAC,CAAS,CAAAD,CAAA,CAATC,SAAS,CAAEC,CAAK,CAAAF,CAAA,CAALE,KAAK,CAAAC,eAAA,MAAAJ,CAAA,EAAAK,eAAA,0BAAAA,eAAA,+BAC5B,IAAI,CAACH,SAAS,CAAGA,CAAS,CAC1B,IAAI,CAACI,cAAc,CAAGH,CACxB,CAAC,OAAAI,YAAA,CAAAP,CAAA,GAAAQ,GAAA,YAAAC,KAAA,CAED,SAAAC,SAAAV,CAAA,CAEwD,KAAAC,CAAA,MADtDU,CAAa,CAAAX,CAAA,CAAbW,aAAa,CAEPC,CAAY,QAAGD,CAAa,WAAbA,CAAa,QAAbA,CAAa,CAAGE,4BAAa,CAACC,QAAQ,CAAC,OAExD,CAAAF,CAAY,CACP,GAAAG,SAAE,EACPC,MAAM,CAACC,MAAM,CAACL,CAAY,CAAC,CAACM,IAAI,CAAC,SAACC,CAAI,CAAK,CACzC,MAAO,CAAAlB,CAAI,CAACmB,cAAc,CAACD,CAAI,CAAChB,KAAK,CACvC,CAAC,CAAC,CACH,CAGI,GAAAY,SAAE,KACX,CAAC,GAAAP,GAAA,kBAAAC,KAAA,CAED,SAAAW,eAAuBjB,CAAa,CAAW,CAC7C,GAAI,CAAC,IAAI,CAACD,SAAS,EAAI,CAAC,IAAI,CAACI,cAAc,CACzC,SAGF,OAAQ,IAAI,CAACJ,SAAS,EACpB,IAAK,CAAAmB,gBAAS,CAACC,QAAQ,CACrB,MAAO,CAAAnB,CAAK,CAACoB,QAAQ,CAAC,IAAI,CAACjB,cAAc,CAAC,CAC5C,IAAK,CAAAe,gBAAS,CAACG,KAAK,CAClB,MAAO,CAAArB,CAAK,GAAK,IAAI,CAACG,cAAc,CACtC,IAAK,CAAAe,gBAAS,CAACI,kBAAkB,CAC/B,MAAO,CAAAC,oBAAS,CAACC,WAAW,CAAC,IAAI,CAACrB,cAAc,CAAC,CAACsB,IAAI,CAACzB,CAAK,CAAC,CAC/D,QACE,SAAa,CAEnB,CAAC,IAAAH,CAAA,IAAA6B,OAAA,CAAA9B,SAAA,CAAAA,SAAA"}
@@ -0,0 +1,11 @@
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 PageUrl implements ICondition {
6
+ private matchType?;
7
+ private conditionValue?;
8
+ constructor({ matchType, url }: ConditionDataType);
9
+ evaluate({ targetingData, }: EvaluationDataType): Result<boolean, KameleoonError>;
10
+ private checkCondition;
11
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PageUrl=void 0;var _tsRes=require("ts-res"),_kameleoonData=require("../../kameleoonData"),_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 PageUrl=function(){function a(b){var c=b.matchType,d=b.url;_classCallCheck(this,a),_defineProperty(this,"matchType",void 0),_defineProperty(this,"conditionValue",void 0),this.matchType=c,this.conditionValue=d}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.PageView];return d?(0,_tsRes.Ok)(Object.keys(d).some(function(a){return b.checkCondition(a)})):(0,_tsRes.Ok)(!1)}},{key:"checkCondition",value:function checkCondition(a){if(!this.matchType||!this.conditionValue)return!1;switch(this.matchType){case _types.MatchType.CONTAINS:return a.includes(this.conditionValue);case _types.MatchType.EXACT:return a===this.conditionValue;case _types.MatchType.REGULAR_EXPRESSION:return _utilities.Utilities.parseRegExp(this.conditionValue).test(a);default:return!1;}}}]),a}();exports.PageUrl=PageUrl;
2
+ //# sourceMappingURL=pageUrl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pageUrl.js","names":["PageUrl","a","b","matchType","url","_classCallCheck","_defineProperty","conditionValue","_createClass","key","value","evaluate","targetingData","pageViewData","KameleoonData","PageView","Ok","Object","keys","some","checkCondition","MatchType","CONTAINS","includes","EXACT","REGULAR_EXPRESSION","Utilities","parseRegExp","test","exports"],"sources":["../../../src/targeting/conditions/pageUrl.ts"],"sourcesContent":["import { Ok, Result } from 'ts-res';\nimport { KameleoonData } from 'src/kameleoonData';\nimport { exhaustCheck, KameleoonError } from 'src/kameleoonError';\nimport { Utilities } from 'src/utilities';\nimport { EvaluationDataType, MatchType } from 'src/targeting/types';\nimport { ConditionDataType, ICondition } from './types';\n\nexport class PageUrl implements ICondition {\n private matchType?: MatchType | null;\n private conditionValue?: string | null;\n\n constructor({ matchType, url }: ConditionDataType) {\n this.matchType = matchType;\n this.conditionValue = url;\n }\n\n public evaluate({\n targetingData,\n }: EvaluationDataType): Result<boolean, KameleoonError> {\n const pageViewData = targetingData?.[KameleoonData.PageView];\n\n if (pageViewData) {\n return Ok(\n Object.keys(pageViewData).some((url) => this.checkCondition(url)),\n );\n }\n\n return Ok(false);\n }\n\n private checkCondition(url: string): boolean {\n if (!this.matchType || !this.conditionValue) {\n return false;\n }\n\n switch (this.matchType) {\n case MatchType.CONTAINS:\n return url.includes(this.conditionValue);\n case MatchType.EXACT:\n return url === this.conditionValue;\n case MatchType.REGULAR_EXPRESSION:\n return Utilities.parseRegExp(this.conditionValue).test(url);\n default:\n return false;\n }\n }\n}\n"],"mappings":"m9CAOa,CAAAA,OAAO,YAIlB,SAAAC,EAAAC,CAAA,CAAmD,IAArC,CAAAC,CAAS,CAAAD,CAAA,CAATC,SAAS,CAAEC,CAAG,CAAAF,CAAA,CAAHE,GAAG,CAAAC,eAAA,MAAAJ,CAAA,EAAAK,eAAA,0BAAAA,eAAA,+BAC1B,IAAI,CAACH,SAAS,CAAGA,CAAS,CAC1B,IAAI,CAACI,cAAc,CAAGH,CACxB,CAAC,OAAAI,YAAA,CAAAP,CAAA,GAAAQ,GAAA,YAAAC,KAAA,CAED,SAAAC,SAAAV,CAAA,CAEwD,KAAAC,CAAA,MADtDU,CAAa,CAAAX,CAAA,CAAbW,aAAa,CAEPC,CAAY,QAAGD,CAAa,WAAbA,CAAa,QAAbA,CAAa,CAAGE,4BAAa,CAACC,QAAQ,CAAC,OAExD,CAAAF,CAAY,CACP,GAAAG,SAAE,EACPC,MAAM,CAACC,IAAI,CAACL,CAAY,CAAC,CAACM,IAAI,CAAC,SAACf,CAAG,QAAK,CAAAF,CAAI,CAACkB,cAAc,CAAChB,CAAG,CAAC,EAAC,CAClE,CAGI,GAAAY,SAAE,KACX,CAAC,GAAAP,GAAA,kBAAAC,KAAA,CAED,SAAAU,eAAuBhB,CAAW,CAAW,CAC3C,GAAI,CAAC,IAAI,CAACD,SAAS,EAAI,CAAC,IAAI,CAACI,cAAc,CACzC,SAGF,OAAQ,IAAI,CAACJ,SAAS,EACpB,IAAK,CAAAkB,gBAAS,CAACC,QAAQ,CACrB,MAAO,CAAAlB,CAAG,CAACmB,QAAQ,CAAC,IAAI,CAAChB,cAAc,CAAC,CAC1C,IAAK,CAAAc,gBAAS,CAACG,KAAK,CAClB,MAAO,CAAApB,CAAG,GAAK,IAAI,CAACG,cAAc,CACpC,IAAK,CAAAc,gBAAS,CAACI,kBAAkB,CAC/B,MAAO,CAAAC,oBAAS,CAACC,WAAW,CAAC,IAAI,CAACpB,cAAc,CAAC,CAACqB,IAAI,CAACxB,CAAG,CAAC,CAC7D,QACE,SAAa,CAEnB,CAAC,IAAAH,CAAA,IAAA4B,OAAA,CAAA7B,OAAA,CAAAA,OAAA"}
@@ -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 PreviousPage implements ICondition {
6
+ private conditionValue?;
7
+ private matchType?;
8
+ constructor({ matchType, url }: ConditionDataType);
9
+ evaluate({ targetingData, }: EvaluationDataType): Result<boolean, KameleoonError>;
10
+ private checkCondition;
11
+ private getSecondLatestPageView;
12
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PreviousPage=void 0;var _tsRes=require("ts-res"),_utilities=require("../../utilities"),_kameleoonData=require("../../kameleoonData"),_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 PreviousPage=function(){function a(b){var c=b.matchType,d=b.url;_classCallCheck(this,a),_defineProperty(this,"conditionValue",void 0),_defineProperty(this,"matchType",void 0),this.conditionValue=d,this.matchType=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.PageView];if(!c)return(0,_tsRes.Ok)(!1);var d=this.getSecondLatestPageView(Object.values(c));if(!d)return(0,_tsRes.Ok)(!1);var e=d.urlAddress;return(0,_tsRes.Ok)(this.checkCondition(e))}},{key:"checkCondition",value:function checkCondition(a){if(!this.matchType||!this.conditionValue)return!1;switch(this.matchType){case _types.MatchType.CONTAINS:return a.includes(this.conditionValue);case _types.MatchType.EXACT:return a===this.conditionValue;case _types.MatchType.REGULAR_EXPRESSION:return _utilities.Utilities.parseRegExp(this.conditionValue).test(a);default:return!1;}}},{key:"getSecondLatestPageView",value:function getSecondLatestPageView(a){if(!(2>a.length)){var b,c;return a.forEach(function(a){var d,e,f=a.timestamps[a.timestamps.length-1],g=a.timestamps[a.timestamps.length-2];if(!b&&!c)return b=a,void(g&&(c=a));var h=null!==(d=b.timestamps[b.timestamps.length-1])&&void 0!==d?d:0;if(f>h){var i,j;c=b,b=a;var k=null===(i=c)||void 0===i?void 0:i.timestamps[(null===(j=c)||void 0===j?void 0:j.timestamps.length)-1];return void(g&&g>k&&(c=a))}var l;if(b.urlAddress===(null===(e=c)||void 0===e?void 0:e.urlAddress))l=c.timestamps[c.timestamps.length-2];else{var m,n,o;l=null!==(m=null===(n=c)||void 0===n?void 0:n.timestamps[(null===(o=c)||void 0===o?void 0:o.timestamps.length)-1])&&void 0!==m?m:0}f&&f>l&&(c=a)}),c}}}]),a}();exports.PreviousPage=PreviousPage;
2
+ //# sourceMappingURL=previousPage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"previousPage.js","names":["PreviousPage","a","b","matchType","url","_classCallCheck","_defineProperty","conditionValue","_createClass","key","value","evaluate","targetingData","pageViewsData","KameleoonData","PageView","Ok","secondLatestPageView","getSecondLatestPageView","Object","values","urlAddress","checkCondition","MatchType","CONTAINS","includes","EXACT","REGULAR_EXPRESSION","Utilities","parseRegExp","test","length","latestPV","secondPV","forEach","currentPV","d","e","currentLatestTs","timestamps","currentSecondTs","latestTs","i","j","secondTs","m","n","o","exports"],"sources":["../../../src/targeting/conditions/previousPage.ts"],"sourcesContent":["import { Ok, Result } from 'ts-res';\nimport { Utilities } from 'src/utilities';\nimport { KameleoonData, PageViewDataType } from 'src/kameleoonData';\nimport { KameleoonError } from 'src/kameleoonError';\nimport { EvaluationDataType, MatchType } from 'src/targeting/types';\nimport { ConditionDataType, ICondition } from './types';\n\nexport class PreviousPage implements ICondition {\n private conditionValue?: string | null;\n private matchType?: MatchType | null;\n\n constructor({ matchType, url }: ConditionDataType) {\n this.conditionValue = url;\n this.matchType = matchType;\n }\n\n public evaluate({\n targetingData,\n }: EvaluationDataType): Result<boolean, KameleoonError> {\n const pageViewsData = targetingData?.[KameleoonData.PageView];\n\n if (!pageViewsData) {\n return Ok(false);\n }\n\n // --- Note ---\n // There is more concise way to find previous latest page, but it's less performant,\n // here we only ever check two latest timestamps of page and use one loop\n const secondLatestPageView = this.getSecondLatestPageView(\n Object.values(pageViewsData),\n );\n\n if (!secondLatestPageView) {\n return Ok(false);\n }\n\n const url = secondLatestPageView.urlAddress;\n\n return Ok(this.checkCondition(url));\n }\n\n private checkCondition(url: string): boolean {\n if (!this.matchType || !this.conditionValue) {\n return false;\n }\n\n switch (this.matchType) {\n case MatchType.CONTAINS:\n return url.includes(this.conditionValue);\n case MatchType.EXACT:\n return url === this.conditionValue;\n case MatchType.REGULAR_EXPRESSION:\n return Utilities.parseRegExp(this.conditionValue).test(url);\n default:\n return false;\n }\n }\n\n private getSecondLatestPageView(\n pageViewsData: PageViewDataType[],\n ): PageViewDataType | undefined {\n if (pageViewsData.length < 2) {\n return undefined;\n }\n\n // --- Note ---\n // Arguments and variables named with abbreviations for better readability\n // `second` in this context is `second to latest`\n let latestPV: PageViewDataType | undefined;\n let secondPV: PageViewDataType | undefined;\n\n pageViewsData.forEach((currentPV) => {\n const currentLatestTs =\n currentPV.timestamps[currentPV.timestamps.length - 1];\n const currentSecondTs =\n currentPV.timestamps[currentPV.timestamps.length - 2];\n\n // -- Initial check\n if (!latestPV && !secondPV) {\n latestPV = currentPV;\n\n if (currentSecondTs) {\n secondPV = currentPV;\n }\n\n return;\n }\n\n const latestTs =\n latestPV!.timestamps[latestPV!.timestamps.length - 1] ?? 0;\n\n // -- Covering a case where latest needs to be updated\n if (currentLatestTs > latestTs) {\n secondPV = latestPV;\n latestPV = currentPV;\n\n const secondTs = secondPV?.timestamps[secondPV?.timestamps.length - 1];\n\n // -- Second may need to be updated after latest\n if (currentSecondTs && currentSecondTs > secondTs!) {\n secondPV = currentPV;\n }\n\n return;\n }\n\n // -- Covering a case where only second needs to be updated\n let secondTs: number;\n\n // -- Second and latest can be the same page\n if (latestPV!.urlAddress === secondPV?.urlAddress) {\n // --- Note ---\n // If latest is equal to second, there are at least two timestamps in array\n secondTs = secondPV.timestamps[secondPV.timestamps.length - 2];\n } else {\n secondTs = secondPV?.timestamps[secondPV?.timestamps.length - 1] ?? 0;\n }\n\n // -- Second may need to be updated\n if (currentLatestTs && currentLatestTs > secondTs!) {\n secondPV = currentPV;\n }\n });\n\n return secondPV;\n }\n}\n"],"mappings":"w9CAOa,CAAAA,YAAY,YAIvB,SAAAC,EAAAC,CAAA,CAAmD,IAArC,CAAAC,CAAS,CAAAD,CAAA,CAATC,SAAS,CAAEC,CAAG,CAAAF,CAAA,CAAHE,GAAG,CAAAC,eAAA,MAAAJ,CAAA,EAAAK,eAAA,+BAAAA,eAAA,0BAC1B,IAAI,CAACC,cAAc,CAAGH,CAAG,CACzB,IAAI,CAACD,SAAS,CAAGA,CACnB,CAAC,OAAAK,YAAA,CAAAP,CAAA,GAAAQ,GAAA,YAAAC,KAAA,CAED,SAAAC,SAAAV,CAAA,CAEwD,IADtD,CAAAW,CAAa,CAAAX,CAAA,CAAbW,aAAa,CAEPC,CAAa,QAAGD,CAAa,WAAbA,CAAa,QAAbA,CAAa,CAAGE,4BAAa,CAACC,QAAQ,CAAC,CAE7D,GAAI,CAACF,CAAa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CAAC,YAAAc,CAAA,CAAAA,CAAA,CAAI,CACtE,CAGIP,CAAe,EAAIA,CAAe,CAAGM,CAAS,GAChDX,CAAQ,CAAGE,CAAS,CAExB,CAAC,CAAC,CAEKF,CAAS,CAClB,CAAC,IAAAhC,CAAA,IAAA+C,OAAA,CAAAhD,YAAA,CAAAA,YAAA"}
@@ -0,0 +1,11 @@
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 SameDayVisits implements ICondition {
6
+ private matchType?;
7
+ private conditionValue?;
8
+ constructor({ matchType, visitCount }: ConditionDataType);
9
+ evaluate({ targetingData, }: EvaluationDataType): Result<boolean, KameleoonError>;
10
+ private checkCondition;
11
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SameDayVisits=void 0;var _tsRes=require("ts-res"),_kameleoonData=require("../../kameleoonData"),_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 SameDayVisits=function(){function a(b){var c=b.matchType,d=b.visitCount;_classCallCheck(this,a),_defineProperty(this,"matchType",void 0),_defineProperty(this,"conditionValue",void 0),this.matchType=c,this.conditionValue=d}return _createClass(a,[{key:"evaluate",value:function evaluate(a){var b=a.targetingData,c=null===b||void 0===b?void 0:b[_kameleoonData.KameleoonData.VisitsData];if(!c)return(0,_tsRes.Ok)(!1);var d=0,e=new Date().setHours(0,0,0,0),f=c.previousVisits,g=c.currentVisit;return f.forEach(function(a){a>e&&d++}),g&&g>e&&d++,(0,_tsRes.Ok)(this.checkCondition(d))}},{key:"checkCondition",value:function checkCondition(a){if(!this.matchType||"number"!=typeof this.conditionValue)return!1;switch(this.matchType){case _types.MatchType.EQUAL:return a===this.conditionValue;case _types.MatchType.GREATER:return a>this.conditionValue;case _types.MatchType.LOWER:return a<this.conditionValue;default:return!1;}}}]),a}();exports.SameDayVisits=SameDayVisits;
2
+ //# sourceMappingURL=sameDayVisits.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sameDayVisits.js","names":["SameDayVisits","a","b","matchType","visitCount","_classCallCheck","_defineProperty","conditionValue","_createClass","key","value","evaluate","targetingData","visitsData","KameleoonData","VisitsData","Ok","todayVisits","todayTimestamp","Date","setHours","previousVisits","currentVisit","forEach","timestamp","checkCondition","todayVisitsAmount","MatchType","EQUAL","GREATER","LOWER","exports"],"sources":["../../../src/targeting/conditions/sameDayVisits.ts"],"sourcesContent":["import { Ok, Result } from 'ts-res';\nimport { KameleoonData } from 'src/kameleoonData';\nimport { KameleoonError } from 'src/kameleoonError';\nimport { EvaluationDataType, MatchType } from 'src/targeting/types';\nimport { ConditionDataType, ICondition } from './types';\n\nexport class SameDayVisits implements ICondition {\n private matchType?: MatchType | null;\n private conditionValue?: number | null;\n\n constructor({ matchType, visitCount }: ConditionDataType) {\n this.matchType = matchType;\n this.conditionValue = visitCount;\n }\n\n public evaluate({\n targetingData,\n }: EvaluationDataType): Result<boolean, KameleoonError> {\n const visitsData = targetingData?.[KameleoonData.VisitsData];\n\n if (!visitsData) {\n return Ok(false);\n }\n\n let todayVisits = 0;\n\n const todayTimestamp = new Date().setHours(0, 0, 0, 0);\n const { previousVisits, currentVisit } = visitsData;\n\n previousVisits.forEach((timestamp) => {\n if (timestamp > todayTimestamp) {\n todayVisits++;\n }\n });\n\n if (currentVisit && currentVisit > todayTimestamp) {\n todayVisits++;\n }\n\n return Ok(this.checkCondition(todayVisits));\n }\n\n private checkCondition(todayVisitsAmount: number): boolean {\n if (!this.matchType || typeof this.conditionValue !== 'number') {\n return false;\n }\n\n switch (this.matchType) {\n case MatchType.EQUAL:\n return todayVisitsAmount === this.conditionValue;\n case MatchType.GREATER:\n return todayVisitsAmount > this.conditionValue;\n case MatchType.LOWER:\n return todayVisitsAmount < this.conditionValue;\n default:\n return false;\n }\n }\n}\n"],"mappings":"m7CAMa,CAAAA,aAAa,YAIxB,SAAAC,EAAAC,CAAA,CAA0D,IAA5C,CAAAC,CAAS,CAAAD,CAAA,CAATC,SAAS,CAAEC,CAAU,CAAAF,CAAA,CAAVE,UAAU,CAAAC,eAAA,MAAAJ,CAAA,EAAAK,eAAA,0BAAAA,eAAA,+BACjC,IAAI,CAACH,SAAS,CAAGA,CAAS,CAC1B,IAAI,CAACI,cAAc,CAAGH,CACxB,CAAC,OAAAI,YAAA,CAAAP,CAAA,GAAAQ,GAAA,YAAAC,KAAA,CAED,SAAAC,SAAAV,CAAA,CAEwD,IADtD,CAAAW,CAAa,CAAAX,CAAA,CAAbW,aAAa,CAEPC,CAAU,QAAGD,CAAa,WAAbA,CAAa,QAAbA,CAAa,CAAGE,4BAAa,CAACC,UAAU,CAAC,CAE5D,GAAI,CAACF,CAAU,CACb,MAAO,GAAAG,SAAE,KAAO,CACjB,GAEG,CAAAC,CAAW,CAAG,CAAC,CAEbC,CAAc,CAAG,GAAI,CAAAC,IAAI,EAAE,CAACC,QAAQ,CAAC,CAAC,CAAE,CAAC,CAAE,CAAC,CAAE,CAAC,CAAC,CAC9CC,CAAc,CAAmBR,CAAU,CAA3CQ,cAAc,CAAEC,CAAY,CAAKT,CAAU,CAA3BS,YAAY,CAYpC,MAVA,CAAAD,CAAc,CAACE,OAAO,CAAC,SAACC,CAAS,CAAK,CAChCA,CAAS,CAAGN,CAAc,EAC5BD,CAAW,EAEf,CAAC,CAAC,CAEEK,CAAY,EAAIA,CAAY,CAAGJ,CAAc,EAC/CD,CAAW,EAAE,CAGR,GAAAD,SAAE,EAAC,IAAI,CAACS,cAAc,CAACR,CAAW,CAAC,CAC5C,CAAC,GAAAR,GAAA,kBAAAC,KAAA,CAED,SAAAe,eAAuBC,CAAyB,CAAW,CACzD,GAAI,CAAC,IAAI,CAACvB,SAAS,EAAmC,QAAQ,EAAvC,MAAO,KAAI,CAACI,cAA2B,CAC5D,SAGF,OAAQ,IAAI,CAACJ,SAAS,EACpB,IAAK,CAAAwB,gBAAS,CAACC,KAAK,CAClB,MAAO,CAAAF,CAAiB,GAAK,IAAI,CAACnB,cAAc,CAClD,IAAK,CAAAoB,gBAAS,CAACE,OAAO,CACpB,MAAO,CAAAH,CAAiB,CAAG,IAAI,CAACnB,cAAc,CAChD,IAAK,CAAAoB,gBAAS,CAACG,KAAK,CAClB,MAAO,CAAAJ,CAAiB,CAAG,IAAI,CAACnB,cAAc,CAChD,QACE,SAAa,CAEnB,CAAC,IAAAN,CAAA,IAAA8B,OAAA,CAAA/B,aAAA,CAAAA,aAAA"}
@@ -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 SdkLanguage implements ICondition {
6
+ private sdkLanguage?;
7
+ private conditionValue?;
8
+ private versionMatchType?;
9
+ constructor({ sdkLanguage, version, versionMatchType }: ConditionDataType);
10
+ evaluate({ sdkInfo, }: EvaluationDataType): Result<boolean, KameleoonError>;
11
+ private checkCondition;
12
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SdkLanguage=void 0;var _tsRes=require("ts-res"),_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 SdkLanguage=function(){function a(b){var c=b.sdkLanguage,d=b.version,e=b.versionMatchType;_classCallCheck(this,a),_defineProperty(this,"sdkLanguage",void 0),_defineProperty(this,"conditionValue",void 0),_defineProperty(this,"versionMatchType",void 0),this.sdkLanguage=c,this.conditionValue=d,this.versionMatchType=e}return _createClass(a,[{key:"evaluate",value:function evaluate(a){var b=a.sdkInfo;return this.checkCondition(b)}},{key:"checkCondition",value:function checkCondition(a){var b=a.type,c=a.version;if(!this.sdkLanguage)return(0,_tsRes.Ok)(!1);if("string"!=typeof this.conditionValue)return(0,_tsRes.Ok)(b===this.sdkLanguage);if(!this.versionMatchType)return(0,_tsRes.Ok)(!1);var d=_utilities.Utilities.compareSemVer({version:c,compareVersion:this.conditionValue,operator:this.versionMatchType});return d.ok?(0,_tsRes.Ok)(b===this.sdkLanguage&&d.data):(0,_tsRes.Err)(d.error)}}]),a}();exports.SdkLanguage=SdkLanguage;
2
+ //# sourceMappingURL=sdkLanguage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdkLanguage.js","names":["SdkLanguage","a","b","sdkLanguage","version","versionMatchType","_classCallCheck","_defineProperty","conditionValue","_createClass","key","value","evaluate","sdkInfo","checkCondition","sdkType","type","Ok","result","Utilities","compareSemVer","compareVersion","operator","ok","data","Err","error","exports"],"sources":["../../../src/targeting/conditions/sdkLanguage.ts"],"sourcesContent":["import { Err, Ok, Result } from 'ts-res';\nimport { SdkLanguageType } from 'src/constants';\nimport { KameleoonError } from 'src/kameleoonError';\nimport { Utilities } from 'src/utilities';\nimport { ExternalPackageInfoType } from 'src/types';\nimport { EvaluationDataType, VersionMatchType } from 'src/targeting/types';\nimport { ConditionDataType, ICondition } from './types';\n\nexport class SdkLanguage implements ICondition {\n private sdkLanguage?: SdkLanguageType | null;\n private conditionValue?: string | null;\n private versionMatchType?: VersionMatchType | null;\n\n constructor({ sdkLanguage, version, versionMatchType }: ConditionDataType) {\n this.sdkLanguage = sdkLanguage;\n this.conditionValue = version;\n this.versionMatchType = versionMatchType;\n }\n\n public evaluate({\n sdkInfo,\n }: EvaluationDataType): Result<boolean, KameleoonError> {\n return this.checkCondition(sdkInfo);\n }\n\n private checkCondition(\n sdkInfo: ExternalPackageInfoType,\n ): Result<boolean, KameleoonError> {\n const { type: sdkType, version } = sdkInfo;\n\n if (!this.sdkLanguage) {\n return Ok(false);\n }\n\n if (typeof this.conditionValue !== 'string') {\n return Ok(sdkType === this.sdkLanguage);\n }\n\n if (!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(sdkType === this.sdkLanguage && result.data);\n }\n}\n"],"mappings":"84CAQa,CAAAA,WAAW,YAKtB,SAAAC,EAAAC,CAAA,CAA2E,IAA7D,CAAAC,CAAW,CAAAD,CAAA,CAAXC,WAAW,CAAEC,CAAO,CAAAF,CAAA,CAAPE,OAAO,CAAEC,CAAgB,CAAAH,CAAA,CAAhBG,gBAAgB,CAAAC,eAAA,MAAAL,CAAA,EAAAM,eAAA,4BAAAA,eAAA,+BAAAA,eAAA,iCAClD,IAAI,CAACJ,WAAW,CAAGA,CAAW,CAC9B,IAAI,CAACK,cAAc,CAAGJ,CAAO,CAC7B,IAAI,CAACC,gBAAgB,CAAGA,CAC1B,CAAC,OAAAI,YAAA,CAAAR,CAAA,GAAAS,GAAA,YAAAC,KAAA,CAED,SAAAC,SAAAX,CAAA,CAEwD,IADtD,CAAAY,CAAO,CAAAZ,CAAA,CAAPY,OAAO,CAEP,MAAO,KAAI,CAACC,cAAc,CAACD,CAAO,CACpC,CAAC,GAAAH,GAAA,kBAAAC,KAAA,CAED,SAAAG,eACED,CAAgC,CACC,CACjC,GAAc,CAAAE,CAAO,CAAcF,CAAO,CAAlCG,IAAI,CAAWZ,CAAO,CAAKS,CAAO,CAAnBT,OAAO,CAE9B,GAAI,CAAC,IAAI,CAACD,WAAW,CACnB,MAAO,GAAAc,SAAE,KAAO,CAGlB,GAAmC,QAAQ,EAAvC,MAAO,KAAI,CAACT,cAA2B,CACzC,MAAO,GAAAS,SAAE,EAACF,CAAO,GAAK,IAAI,CAACZ,WAAW,CAAC,CAGzC,GAAI,CAAC,IAAI,CAACE,gBAAgB,CACxB,MAAO,GAAAY,SAAE,KAAO,CAGlB,GAAM,CAAAC,CAAM,CAAGC,oBAAS,CAACC,aAAa,CAAC,CACrChB,OAAO,CAAPA,CAAO,CACPiB,cAAc,CAAE,IAAI,CAACb,cAAc,CACnCc,QAAQ,CAAE,IAAI,CAACjB,gBACjB,CAAC,CAAC,CAAC,MAEE,CAAAa,CAAM,CAACK,EAAE,CAIP,GAAAN,SAAE,EAACF,CAAO,GAAK,IAAI,CAACZ,WAAW,EAAIe,CAAM,CAACM,IAAI,CAAC,CAH7C,GAAAC,UAAG,EAACP,CAAM,CAACQ,KAAK,CAI3B,CAAC,IAAAzB,CAAA,IAAA0B,OAAA,CAAA3B,WAAA,CAAAA,WAAA"}
@@ -0,0 +1,9 @@
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 Segment implements ICondition {
6
+ segmentId?: number | null;
7
+ constructor({ segmentId }: ConditionDataType);
8
+ evaluate(evaluationData: EvaluationDataType): Result<boolean, KameleoonError>;
9
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Segment=void 0;var _tsRes=require("ts-res"),_tree=require("../tree");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 Segment=function(){function a(b){var c=b.segmentId;_classCallCheck(this,a),_defineProperty(this,"segmentId",void 0),this.segmentId=c}return _createClass(a,[{key:"evaluate",value:function evaluate(a){var b=a.segments,c=a.trees;if(!this.segmentId)return(0,_tsRes.Ok)(!1);var d=null===b||void 0===b?void 0:b.get(this.segmentId.toString());if(!d)return(0,_tsRes.Ok)(!1);var e=null===c||void 0===c?void 0:c.get(this.segmentId.toString());return e?e.evaluate(a):new _tree.Tree(d).evaluate(a)}}]),a}();exports.Segment=Segment;
2
+ //# sourceMappingURL=segment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"segment.js","names":["Segment","a","b","segmentId","_classCallCheck","_defineProperty","_createClass","key","value","evaluate","evaluationData","segments","trees","Ok","segment","get","toString","tree","Tree","exports"],"sources":["../../../src/targeting/conditions/segment.ts"],"sourcesContent":["import { Ok, Result } from 'ts-res';\nimport { KameleoonError } from 'src/kameleoonError';\nimport { EvaluationDataType } from 'src/targeting/types';\nimport { ConditionDataType, ICondition } from './types';\nimport { Tree } from 'src/targeting/tree';\n\nexport class Segment implements ICondition {\n segmentId?: number | null;\n\n constructor({ segmentId }: ConditionDataType) {\n this.segmentId = segmentId;\n }\n\n public evaluate(\n evaluationData: EvaluationDataType,\n ): Result<boolean, KameleoonError> {\n const { segments, trees } = evaluationData;\n\n if (!this.segmentId) {\n return Ok(false);\n }\n\n const segment = segments?.get(this.segmentId.toString());\n\n if (!segment) {\n return Ok(false);\n }\n\n const tree = trees?.get(this.segmentId.toString());\n\n if (tree) {\n return tree.evaluate(evaluationData);\n }\n\n return new Tree(segment).evaluate(evaluationData);\n }\n}\n"],"mappings":"63CAMa,CAAAA,OAAO,YAGlB,SAAAC,EAAAC,CAAA,CAA8C,IAAhC,CAAAC,CAAS,CAAAD,CAAA,CAATC,SAAS,CAAAC,eAAA,MAAAH,CAAA,EAAAI,eAAA,0BACrB,IAAI,CAACF,SAAS,CAAGA,CACnB,CAAC,OAAAG,YAAA,CAAAL,CAAA,GAAAM,GAAA,YAAAC,KAAA,CAED,SAAAC,SACEC,CAAkC,CACD,CACjC,GAAQ,CAAAC,CAAQ,CAAYD,CAAc,CAAlCC,QAAQ,CAAEC,CAAK,CAAKF,CAAc,CAAxBE,KAAK,CAEvB,GAAI,CAAC,IAAI,CAACT,SAAS,CACjB,MAAO,GAAAU,SAAE,KAAO,CAGlB,GAAM,CAAAC,CAAO,QAAGH,CAAQ,WAARA,CAAQ,QAARA,CAAQ,CAAEI,GAAG,CAAC,IAAI,CAACZ,SAAS,CAACa,QAAQ,EAAE,CAAC,CAExD,GAAI,CAACF,CAAO,CACV,MAAO,GAAAD,SAAE,KAAO,CAGlB,GAAM,CAAAI,CAAI,QAAGL,CAAK,WAALA,CAAK,QAALA,CAAK,CAAEG,GAAG,CAAC,IAAI,CAACZ,SAAS,CAACa,QAAQ,EAAE,CAAC,CAAC,MAE/C,CAAAC,CAAI,CACCA,CAAI,CAACR,QAAQ,CAACC,CAAc,CAAC,CAG/B,GAAI,CAAAQ,UAAI,CAACJ,CAAO,CAAC,CAACL,QAAQ,CAACC,CAAc,CAClD,CAAC,IAAAT,CAAA,IAAAkB,OAAA,CAAAnB,OAAA,CAAAA,OAAA"}
@@ -0,0 +1,11 @@
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 TargetFeatureFlag implements ICondition {
6
+ private featureId?;
7
+ private ruleId?;
8
+ private variationKey?;
9
+ constructor({ featureFlagId, variationKey, ruleId }: ConditionDataType);
10
+ evaluate({ variationData, ruleMap, }: EvaluationDataType): Result<boolean, KameleoonError>;
11
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var _tsRes=require("ts-res");Object.defineProperty(exports,"__esModule",{value:!0}),exports.TargetFeatureFlag=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 _slicedToArray(a,b){return _arrayWithHoles(a)||_iterableToArrayLimit(a,b)||_unsupportedIterableToArray(a,b)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(a,b){var c=null==a?null:"undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(null!=c){var d,e,f,g,h=[],i=!0,j=!1;try{if(f=(c=c.call(a)).next,0===b){if(Object(c)!==c)return;i=!1}else for(;!(i=(d=f.call(c)).done)&&(h.push(d.value),h.length!==b);i=!0);}catch(a){j=!0,e=a}finally{try{if(!i&&null!=c.return&&(g=c.return(),Object(g)!==g))return}finally{if(j)throw e}}return h}}function _arrayWithHoles(a){if(Array.isArray(a))return a}function _createForOfIteratorHelper(a,b){var c="undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(!c){if(Array.isArray(a)||(c=_unsupportedIterableToArray(a))||b&&a&&"number"==typeof a.length){c&&(a=c);var d=0,e=function(){};return{s:e,n:function n(){return d>=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function e(a){throw a},f:e}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var f,g=!0,h=!1;return{s:function s(){c=c.call(a)},n:function n(){var a=c.next();return g=a.done,a},e:function e(a){h=!0,f=a},f:function f(){try{g||null==c.return||c.return()}finally{if(h)throw f}}}}function _unsupportedIterableToArray(a,b){if(a){if("string"==typeof a)return _arrayLikeToArray(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray(a,b):void 0}}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}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 TargetFeatureFlag=function(){function a(b){var c=b.featureFlagId,d=b.variationKey,e=b.ruleId;_classCallCheck(this,a),_defineProperty(this,"featureId",void 0),_defineProperty(this,"ruleId",void 0),_defineProperty(this,"variationKey",void 0),this.featureId=c,this.ruleId=e,this.variationKey=d}return _createClass(a,[{key:"evaluate",value:function evaluate(a){var b=a.variationData,c=a.ruleMap;if(!this.featureId||!c)return(0,_tsRes.Ok)(!1);if(this.featureId&&!this.ruleId&&!this.variationKey){var d,e=_createForOfIteratorHelper(c);try{for(e.s();!(d=e.n()).done;){var f=_slicedToArray(d.value,2),g=f[0],h=f[1],i=h.featureId,j=h.experimentId;if(i===this.featureId&&"number"==typeof b[j])return(0,_tsRes.Ok)(!0)}}catch(a){e.e(a)}finally{e.f()}return(0,_tsRes.Ok)(!1)}if(this.featureId&&this.ruleId){var k=c.get(this.ruleId);if(!k)return(0,_tsRes.Ok)(!1);var l=k.experimentId,m=k.variations;if(this.variationKey){var n=m.get(this.variationKey);return(0,_tsRes.Ok)(!!n&&b[l]===n)}return(0,_tsRes.Ok)(!!b[k.experimentId])}if(this.featureId&&!this.ruleId&&this.variationKey){var o,p=_createForOfIteratorHelper(c);try{for(p.s();!(o=p.n()).done;){var q=_slicedToArray(o.value,2),r=q[0],s=q[1],t=s.featureId,u=s.experimentId,v=s.variations;if(t===this.featureId&&v.has(this.variationKey)){var w=v.get(this.variationKey);return(0,_tsRes.Ok)(!!w&&b[u]===w)}}}catch(a){p.e(a)}finally{p.f()}}return(0,_tsRes.Ok)(!1)}}]),a}();exports.TargetFeatureFlag=TargetFeatureFlag;
2
+ //# sourceMappingURL=targetFeatureFlag.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"targetFeatureFlag.js","names":["_tsRes","require","Object","defineProperty","exports","value","TargetFeatureFlag","_typeof","a","Symbol","iterator","constructor","prototype","_slicedToArray","b","_arrayWithHoles","_iterableToArrayLimit","_unsupportedIterableToArray","_nonIterableRest","TypeError","c","d","e","f","g","h","i","j","call","next","done","push","length","return","Array","isArray","_createForOfIteratorHelper","s","n","_arrayLikeToArray","toString","slice","name","from","test","_classCallCheck","_defineProperties","enumerable","configurable","writable","_toPropertyKey","key","_createClass","_defineProperty","_toPrimitive","toPrimitive","String","Number","featureFlagId","variationKey","ruleId","featureId","evaluate","variationData","ruleMap","Ok","_","rule","experimentId","get","variations","variationId","o","p","q","has"],"sources":["../../../src/targeting/conditions/targetFeatureFlag.ts"],"sourcesContent":["import { Ok, Result } from 'ts-res';\nimport { KameleoonError } from 'src/kameleoonError';\nimport { EvaluationDataType } from 'src/targeting/types';\nimport { ConditionDataType, ICondition } from './types';\n\nexport class TargetFeatureFlag implements ICondition {\n private featureId?: number | null;\n private ruleId?: number | null;\n private variationKey?: string | null;\n\n constructor({ featureFlagId, variationKey, ruleId }: ConditionDataType) {\n this.featureId = featureFlagId;\n this.ruleId = ruleId;\n this.variationKey = variationKey;\n }\n\n public evaluate({\n variationData,\n ruleMap,\n }: EvaluationDataType): Result<boolean, KameleoonError> {\n if (!this.featureId || !ruleMap) {\n return Ok(false);\n }\n\n // -- Visitor took part in any experiment of the feature flag\n // with any variation\n if (this.featureId && !this.ruleId && !this.variationKey) {\n for (const [_, rule] of ruleMap) {\n const { featureId, experimentId } = rule;\n\n if (\n featureId === this.featureId &&\n typeof variationData[experimentId] === 'number'\n ) {\n return Ok(true);\n }\n }\n\n return Ok(false);\n }\n\n // -- Visitor took part in certain experiment of the feature flag\n // with any/exact variation\n if (this.featureId && this.ruleId) {\n const rule = ruleMap.get(this.ruleId);\n\n if (!rule) {\n return Ok(false);\n }\n\n const { experimentId, variations } = rule;\n\n if (this.variationKey) {\n const variationId = variations.get(this.variationKey);\n\n return Ok(\n Boolean(variationId) && variationData[experimentId] === variationId,\n );\n }\n\n return Ok(Boolean(variationData[rule.experimentId]));\n }\n\n // -- Visitor took part in any experiment of the feature flag\n // with certain variation\n if (this.featureId && !this.ruleId && this.variationKey) {\n for (const [_, rule] of ruleMap) {\n const { featureId, experimentId, variations } = rule;\n\n if (featureId === this.featureId && variations.has(this.variationKey)) {\n const variationId = variations.get(this.variationKey);\n\n return Ok(\n Boolean(variationId) && variationData[experimentId] === variationId,\n );\n }\n }\n }\n\n return Ok(false);\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,oBAA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,IAAAJ,OAAA,CAAAE,iBAAA,CAAAA,iBAAA"}
@@ -0,0 +1,49 @@
1
+ import { Result } from 'ts-res';
2
+ import { SdkLanguageType } from '../../constants';
3
+ import { BrowserType, DeviceType } from '../../kameleoonData';
4
+ import { KameleoonError } from '../../kameleoonError';
5
+ import { EvaluationDataType, MatchType, MatchTypeTest, MatchTypeVariation, NameMatchType, TargetingType, ValueMatchType, VersionMatchType, VisitorType } from '../../targeting/types';
6
+ import { OperatingSystemType } from '../../kameleoonData/types';
7
+ import { TimeUnit } from '../../utilities';
8
+ export interface ICondition {
9
+ evaluate: (data: EvaluationDataType) => Result<boolean, KameleoonError>;
10
+ }
11
+ export type ConditionType = ICondition;
12
+ export type ConditionDataType = {
13
+ id: number;
14
+ targetingType: TargetingType;
15
+ isInclude: boolean | null;
16
+ weight: number;
17
+ customDataIndex?: string | null;
18
+ pageCount?: number | null;
19
+ value?: string | null;
20
+ valueMatchType?: ValueMatchType | null;
21
+ experiment?: number | null;
22
+ variation?: number | null;
23
+ visitCount?: number | null;
24
+ variationKey?: string | null;
25
+ featureFlagId?: number | null;
26
+ ruleId?: number | null;
27
+ variationMatchType?: MatchTypeVariation | null;
28
+ testMatchType?: MatchTypeTest | null;
29
+ matchType?: MatchType | null;
30
+ device?: DeviceType | null;
31
+ browser?: BrowserType | null;
32
+ os?: OperatingSystemType | null;
33
+ name?: string | null;
34
+ nameMatchType?: NameMatchType | null;
35
+ country?: string | null;
36
+ region?: string | null;
37
+ city?: string | null;
38
+ segmentId?: number | null;
39
+ version?: string | null;
40
+ versionMatchType?: VersionMatchType | null;
41
+ visitorType?: VisitorType | null;
42
+ count?: number | null;
43
+ unitOfTime?: TimeUnit | null;
44
+ title?: string | null;
45
+ url?: string | null;
46
+ goalId?: number | null;
47
+ sdkLanguage?: SdkLanguageType | null;
48
+ visitorCode?: string | null;
49
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../src/targeting/conditions/types.ts"],"sourcesContent":["import { Result } from 'ts-res';\nimport { SdkLanguageType } from 'src/constants';\nimport { BrowserType, DeviceType } from 'src/kameleoonData';\nimport { KameleoonError } from 'src/kameleoonError';\nimport {\n EvaluationDataType,\n MatchType,\n MatchTypeTest,\n MatchTypeVariation,\n NameMatchType,\n TargetingType,\n ValueMatchType,\n VersionMatchType,\n VisitorType,\n} from 'src/targeting/types';\nimport { OperatingSystemType } from 'src/kameleoonData/types';\nimport { TimeUnit } from 'src/utilities';\n\nexport interface ICondition {\n evaluate: (data: EvaluationDataType) => Result<boolean, KameleoonError>;\n}\n\nexport type ConditionType = ICondition;\n\nexport type ConditionDataType = {\n id: number;\n targetingType: TargetingType;\n isInclude: boolean | null;\n weight: number;\n customDataIndex?: string | null;\n pageCount?: number | null;\n value?: string | null;\n valueMatchType?: ValueMatchType | null;\n experiment?: number | null;\n variation?: number | null;\n visitCount?: number | null;\n variationKey?: string | null;\n featureFlagId?: number | null;\n ruleId?: number | null;\n variationMatchType?: MatchTypeVariation | null;\n testMatchType?: MatchTypeTest | null;\n matchType?: MatchType | null;\n device?: DeviceType | null;\n browser?: BrowserType | null;\n os?: OperatingSystemType | null;\n name?: string | null;\n nameMatchType?: NameMatchType | null;\n country?: string | null;\n region?: string | null;\n city?: string | null;\n segmentId?: number | null;\n version?: string | null;\n versionMatchType?: VersionMatchType | null;\n visitorType?: VisitorType | null;\n count?: number | null;\n unitOfTime?: TimeUnit | null;\n title?: string | null;\n url?: string | null;\n goalId?: number | null;\n sdkLanguage?: SdkLanguageType | null;\n visitorCode?: string | null;\n};\n"],"mappings":""}
@@ -0,0 +1,11 @@
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 VisitedPages implements ICondition {
6
+ private conditionValue?;
7
+ private matchType?;
8
+ constructor({ matchType, pageCount }: ConditionDataType);
9
+ evaluate({ targetingData, }: EvaluationDataType): Result<boolean, KameleoonError>;
10
+ private checkCondition;
11
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.VisitedPages=void 0;var _tsRes=require("ts-res"),_kameleoonData=require("../../kameleoonData"),_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 VisitedPages=function(){function a(b){var c=b.matchType,d=b.pageCount;_classCallCheck(this,a),_defineProperty(this,"conditionValue",void 0),_defineProperty(this,"matchType",void 0),this.matchType=c,this.conditionValue=d}return _createClass(a,[{key:"evaluate",value:function evaluate(a){var b=a.targetingData,c=null===b||void 0===b?void 0:b[_kameleoonData.KameleoonData.PageView];if(!c)return(0,_tsRes.Ok)(!1);var d=0;return Object.values(c).forEach(function(a){d+=a.timestamps.length}),(0,_tsRes.Ok)(this.checkCondition(d))}},{key:"checkCondition",value:function checkCondition(a){if(!this.matchType||"number"!=typeof this.conditionValue)return!1;switch(this.matchType){case _types.MatchType.EQUAL:return a===this.conditionValue;case _types.MatchType.GREATER:return a>this.conditionValue;case _types.MatchType.LOWER:return a<this.conditionValue;default:return!1;}}}]),a}();exports.VisitedPages=VisitedPages;
2
+ //# sourceMappingURL=visitedPages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"visitedPages.js","names":["VisitedPages","a","b","matchType","pageCount","_classCallCheck","_defineProperty","conditionValue","_createClass","key","value","evaluate","targetingData","pageViewsData","KameleoonData","PageView","Ok","pagesAmount","Object","values","forEach","pageView","timestamps","length","checkCondition","MatchType","EQUAL","GREATER","LOWER","exports"],"sources":["../../../src/targeting/conditions/visitedPages.ts"],"sourcesContent":["import { Ok, Result } from 'ts-res';\nimport { KameleoonData, PageViewDataType } from 'src/kameleoonData';\nimport { KameleoonError } from 'src/kameleoonError';\nimport { EvaluationDataType, MatchType } from 'src/targeting/types';\nimport { ConditionDataType, ICondition } from './types';\n\nexport class VisitedPages implements ICondition {\n private conditionValue?: number | null;\n private matchType?: MatchType | null;\n\n constructor({ matchType, pageCount }: ConditionDataType) {\n this.matchType = matchType;\n this.conditionValue = pageCount;\n }\n\n public evaluate({\n targetingData,\n }: EvaluationDataType): Result<boolean, KameleoonError> {\n const pageViewsData = targetingData?.[KameleoonData.PageView];\n\n if (!pageViewsData) {\n return Ok(false);\n }\n\n let pagesAmount = 0;\n\n Object.values(pageViewsData).forEach((pageView: PageViewDataType) => {\n pagesAmount += pageView.timestamps.length;\n });\n\n return Ok(this.checkCondition(pagesAmount));\n }\n\n private checkCondition(pagesAmount: number): boolean {\n if (!this.matchType || typeof this.conditionValue !== 'number') {\n return false;\n }\n\n switch (this.matchType) {\n case MatchType.EQUAL:\n return pagesAmount === this.conditionValue;\n case MatchType.GREATER:\n return pagesAmount > this.conditionValue;\n case MatchType.LOWER:\n return pagesAmount < this.conditionValue;\n default:\n return false;\n }\n }\n}\n"],"mappings":"k7CAMa,CAAAA,YAAY,YAIvB,SAAAC,EAAAC,CAAA,CAAyD,IAA3C,CAAAC,CAAS,CAAAD,CAAA,CAATC,SAAS,CAAEC,CAAS,CAAAF,CAAA,CAATE,SAAS,CAAAC,eAAA,MAAAJ,CAAA,EAAAK,eAAA,+BAAAA,eAAA,0BAChC,IAAI,CAACH,SAAS,CAAGA,CAAS,CAC1B,IAAI,CAACI,cAAc,CAAGH,CACxB,CAAC,OAAAI,YAAA,CAAAP,CAAA,GAAAQ,GAAA,YAAAC,KAAA,CAED,SAAAC,SAAAV,CAAA,CAEwD,IADtD,CAAAW,CAAa,CAAAX,CAAA,CAAbW,aAAa,CAEPC,CAAa,QAAGD,CAAa,WAAbA,CAAa,QAAbA,CAAa,CAAGE,4BAAa,CAACC,QAAQ,CAAC,CAE7D,GAAI,CAACF,CAAa,CAChB,MAAO,GAAAG,SAAE,KAAO,CAGlB,GAAI,CAAAC,CAAW,CAAG,CAAC,CAMnB,MAJA,CAAAC,MAAM,CAACC,MAAM,CAACN,CAAa,CAAC,CAACO,OAAO,CAAC,SAACC,CAA0B,CAAK,CACnEJ,CAAW,EAAII,CAAQ,CAACC,UAAU,CAACC,MACrC,CAAC,CAAC,CAEK,GAAAP,SAAE,EAAC,IAAI,CAACQ,cAAc,CAACP,CAAW,CAAC,CAC5C,CAAC,GAAAR,GAAA,kBAAAC,KAAA,CAED,SAAAc,eAAuBP,CAAmB,CAAW,CACnD,GAAI,CAAC,IAAI,CAACd,SAAS,EAAmC,QAAQ,EAAvC,MAAO,KAAI,CAACI,cAA2B,CAC5D,SAGF,OAAQ,IAAI,CAACJ,SAAS,EACpB,IAAK,CAAAsB,gBAAS,CAACC,KAAK,CAClB,MAAO,CAAAT,CAAW,GAAK,IAAI,CAACV,cAAc,CAC5C,IAAK,CAAAkB,gBAAS,CAACE,OAAO,CACpB,MAAO,CAAAV,CAAW,CAAG,IAAI,CAACV,cAAc,CAC1C,IAAK,CAAAkB,gBAAS,CAACG,KAAK,CAClB,MAAO,CAAAX,CAAW,CAAG,IAAI,CAACV,cAAc,CAC1C,QACE,SAAa,CAEnB,CAAC,IAAAN,CAAA,IAAA4B,OAAA,CAAA7B,YAAA,CAAAA,YAAA"}
@@ -0,0 +1,11 @@
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 VisitorCode implements ICondition {
6
+ private matchType?;
7
+ private conditionValue?;
8
+ constructor({ visitorCode, matchType }: ConditionDataType);
9
+ evaluate({ visitorCode, }: EvaluationDataType): Result<boolean, KameleoonError>;
10
+ private checkCondition;
11
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.VisitorCode=void 0;var _tsRes=require("ts-res"),_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 VisitorCode=function(){function a(b){var c=b.visitorCode,d=b.matchType;_classCallCheck(this,a),_defineProperty(this,"matchType",void 0),_defineProperty(this,"conditionValue",void 0),this.matchType=d,this.conditionValue=c}return _createClass(a,[{key:"evaluate",value:function evaluate(a){var b=a.visitorCode;return(0,_tsRes.Ok)(this.checkCondition(b))}},{key:"checkCondition",value:function checkCondition(a){if(!this.matchType||!this.conditionValue)return!1;switch(this.matchType){case _types.MatchType.CONTAINS:return a.includes(this.conditionValue);case _types.MatchType.EXACT:return a===this.conditionValue;case _types.MatchType.REGULAR_EXPRESSION:return _utilities.Utilities.parseRegExp(this.conditionValue).test(a);default:return!1;}}}]),a}();exports.VisitorCode=VisitorCode;
2
+ //# sourceMappingURL=visitorCode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"visitorCode.js","names":["VisitorCode","a","b","visitorCode","matchType","_classCallCheck","_defineProperty","conditionValue","_createClass","key","value","evaluate","Ok","checkCondition","MatchType","CONTAINS","includes","EXACT","REGULAR_EXPRESSION","Utilities","parseRegExp","test","exports"],"sources":["../../../src/targeting/conditions/visitorCode.ts"],"sourcesContent":["import { Ok, Result } from 'ts-res';\nimport { KameleoonError } from 'src/kameleoonError';\nimport { Utilities } from 'src/utilities';\nimport { EvaluationDataType, MatchType } from 'src/targeting/types';\nimport { ConditionDataType, ICondition } from './types';\n\nexport class VisitorCode implements ICondition {\n private matchType?: MatchType | null;\n private conditionValue?: string | null;\n\n constructor({ visitorCode, matchType }: ConditionDataType) {\n this.matchType = matchType;\n this.conditionValue = visitorCode;\n }\n\n public evaluate({\n visitorCode,\n }: EvaluationDataType): Result<boolean, KameleoonError> {\n return Ok(this.checkCondition(visitorCode));\n }\n\n private checkCondition(visitorCode: string): boolean {\n if (!this.matchType || !this.conditionValue) {\n return false;\n }\n\n switch (this.matchType) {\n case MatchType.CONTAINS:\n return visitorCode.includes(this.conditionValue);\n case MatchType.EXACT:\n return visitorCode === this.conditionValue;\n case MatchType.REGULAR_EXPRESSION:\n return Utilities.parseRegExp(this.conditionValue).test(visitorCode);\n default:\n return false;\n }\n }\n}\n"],"mappings":"y6CAMa,CAAAA,WAAW,YAItB,SAAAC,EAAAC,CAAA,CAA2D,IAA7C,CAAAC,CAAW,CAAAD,CAAA,CAAXC,WAAW,CAAEC,CAAS,CAAAF,CAAA,CAATE,SAAS,CAAAC,eAAA,MAAAJ,CAAA,EAAAK,eAAA,0BAAAA,eAAA,+BAClC,IAAI,CAACF,SAAS,CAAGA,CAAS,CAC1B,IAAI,CAACG,cAAc,CAAGJ,CACxB,CAAC,OAAAK,YAAA,CAAAP,CAAA,GAAAQ,GAAA,YAAAC,KAAA,CAED,SAAAC,SAAAV,CAAA,CAEwD,IADtD,CAAAE,CAAW,CAAAF,CAAA,CAAXE,WAAW,CAEX,MAAO,GAAAS,SAAE,EAAC,IAAI,CAACC,cAAc,CAACV,CAAW,CAAC,CAC5C,CAAC,GAAAM,GAAA,kBAAAC,KAAA,CAED,SAAAG,eAAuBV,CAAmB,CAAW,CACnD,GAAI,CAAC,IAAI,CAACC,SAAS,EAAI,CAAC,IAAI,CAACG,cAAc,CACzC,SAGF,OAAQ,IAAI,CAACH,SAAS,EACpB,IAAK,CAAAU,gBAAS,CAACC,QAAQ,CACrB,MAAO,CAAAZ,CAAW,CAACa,QAAQ,CAAC,IAAI,CAACT,cAAc,CAAC,CAClD,IAAK,CAAAO,gBAAS,CAACG,KAAK,CAClB,MAAO,CAAAd,CAAW,GAAK,IAAI,CAACI,cAAc,CAC5C,IAAK,CAAAO,gBAAS,CAACI,kBAAkB,CAC/B,MAAO,CAAAC,oBAAS,CAACC,WAAW,CAAC,IAAI,CAACb,cAAc,CAAC,CAACc,IAAI,CAAClB,CAAW,CAAC,CACrE,QACE,SAAa,CAEnB,CAAC,IAAAF,CAAA,IAAAqB,OAAA,CAAAtB,WAAA,CAAAA,WAAA"}
@@ -0,0 +1,11 @@
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 Visits implements ICondition {
6
+ private matchType?;
7
+ private conditionValue?;
8
+ constructor({ matchType, visitCount }: ConditionDataType);
9
+ evaluate({ targetingData, }: EvaluationDataType): Result<boolean, KameleoonError>;
10
+ private checkCondition;
11
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Visits=void 0;var _tsRes=require("ts-res"),_kameleoonData=require("../../kameleoonData"),_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 Visits=function(){function a(b){var c=b.matchType,d=b.visitCount;_classCallCheck(this,a),_defineProperty(this,"matchType",void 0),_defineProperty(this,"conditionValue",void 0),this.matchType=c,this.conditionValue=d}return _createClass(a,[{key:"evaluate",value:function evaluate(a){var b=a.targetingData,c=null===b||void 0===b?void 0:b[_kameleoonData.KameleoonData.VisitsData];if(!c)return(0,_tsRes.Ok)(!1);var d=0,e=c.previousVisits,f=c.currentVisit;return d+=e.length,f&&d++,(0,_tsRes.Ok)(this.checkCondition(d))}},{key:"checkCondition",value:function checkCondition(a){if(!this.matchType||"number"!=typeof this.conditionValue)return!1;switch(this.matchType){case _types.MatchType.EQUAL:return a===this.conditionValue;case _types.MatchType.GREATER:return a>this.conditionValue;case _types.MatchType.LOWER:return a<this.conditionValue;default:return!1;}}}]),a}();exports.Visits=Visits;
2
+ //# sourceMappingURL=visits.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"visits.js","names":["Visits","a","b","matchType","visitCount","_classCallCheck","_defineProperty","conditionValue","_createClass","key","value","evaluate","targetingData","visitsData","KameleoonData","VisitsData","Ok","visits","previousVisits","currentVisit","length","checkCondition","visitsAmount","MatchType","EQUAL","GREATER","LOWER","exports"],"sources":["../../../src/targeting/conditions/visits.ts"],"sourcesContent":["import { Ok, Result } from 'ts-res';\nimport { KameleoonData } from 'src/kameleoonData';\nimport { KameleoonError } from 'src/kameleoonError';\nimport { EvaluationDataType, MatchType } from 'src/targeting/types';\nimport { ConditionDataType, ICondition } from './types';\n\nexport class Visits implements ICondition {\n private matchType?: MatchType | null;\n private conditionValue?: number | null;\n\n constructor({ matchType, visitCount }: ConditionDataType) {\n this.matchType = matchType;\n this.conditionValue = visitCount;\n }\n\n public evaluate({\n targetingData,\n }: EvaluationDataType): Result<boolean, KameleoonError> {\n const visitsData = targetingData?.[KameleoonData.VisitsData];\n\n if (!visitsData) {\n return Ok(false);\n }\n\n let visits = 0;\n\n const { previousVisits, currentVisit } = visitsData;\n\n visits += previousVisits.length;\n\n if (currentVisit) {\n visits++;\n }\n\n return Ok(this.checkCondition(visits));\n }\n\n private checkCondition(visitsAmount: number): boolean {\n if (!this.matchType || typeof this.conditionValue !== 'number') {\n return false;\n }\n\n switch (this.matchType) {\n case MatchType.EQUAL:\n return visitsAmount === this.conditionValue;\n case MatchType.GREATER:\n return visitsAmount > this.conditionValue;\n case MatchType.LOWER:\n return visitsAmount < this.conditionValue;\n default:\n return false;\n }\n }\n}\n"],"mappings":"46CAMa,CAAAA,MAAM,YAIjB,SAAAC,EAAAC,CAAA,CAA0D,IAA5C,CAAAC,CAAS,CAAAD,CAAA,CAATC,SAAS,CAAEC,CAAU,CAAAF,CAAA,CAAVE,UAAU,CAAAC,eAAA,MAAAJ,CAAA,EAAAK,eAAA,0BAAAA,eAAA,+BACjC,IAAI,CAACH,SAAS,CAAGA,CAAS,CAC1B,IAAI,CAACI,cAAc,CAAGH,CACxB,CAAC,OAAAI,YAAA,CAAAP,CAAA,GAAAQ,GAAA,YAAAC,KAAA,CAED,SAAAC,SAAAV,CAAA,CAEwD,IADtD,CAAAW,CAAa,CAAAX,CAAA,CAAbW,aAAa,CAEPC,CAAU,QAAGD,CAAa,WAAbA,CAAa,QAAbA,CAAa,CAAGE,4BAAa,CAACC,UAAU,CAAC,CAE5D,GAAI,CAACF,CAAU,CACb,MAAO,GAAAG,SAAE,KAAO,CACjB,GAEG,CAAAC,CAAM,CAAG,CAAC,CAENC,CAAc,CAAmBL,CAAU,CAA3CK,cAAc,CAAEC,CAAY,CAAKN,CAAU,CAA3BM,YAAY,CAQpC,MANA,CAAAF,CAAM,EAAIC,CAAc,CAACE,MAAM,CAE3BD,CAAY,EACdF,CAAM,EAAE,CAGH,GAAAD,SAAE,EAAC,IAAI,CAACK,cAAc,CAACJ,CAAM,CAAC,CACvC,CAAC,GAAAR,GAAA,kBAAAC,KAAA,CAED,SAAAW,eAAuBC,CAAoB,CAAW,CACpD,GAAI,CAAC,IAAI,CAACnB,SAAS,EAAmC,QAAQ,EAAvC,MAAO,KAAI,CAACI,cAA2B,CAC5D,SAGF,OAAQ,IAAI,CAACJ,SAAS,EACpB,IAAK,CAAAoB,gBAAS,CAACC,KAAK,CAClB,MAAO,CAAAF,CAAY,GAAK,IAAI,CAACf,cAAc,CAC7C,IAAK,CAAAgB,gBAAS,CAACE,OAAO,CACpB,MAAO,CAAAH,CAAY,CAAG,IAAI,CAACf,cAAc,CAC3C,IAAK,CAAAgB,gBAAS,CAACG,KAAK,CAClB,MAAO,CAAAJ,CAAY,CAAG,IAAI,CAACf,cAAc,CAC3C,QACE,SAAa,CAEnB,CAAC,IAAAN,CAAA,IAAA0B,OAAA,CAAA3B,MAAA,CAAAA,MAAA"}
@@ -0,0 +1,3 @@
1
+ export { Tree } from './tree';
2
+ export { Operator, TargetingType, SegmentType, TargetingDataType, EvaluationDataType, ValueMatchType, MatchTypeVariation, MatchType, VersionMatchType, } from './types';
3
+ export { CustomData, ExclusiveCampaign, Browser, PageUrl, PageTitle, Conversion, VisitorCode, SdkLanguage, Device, PreviousPage, VisitedPages, ConditionFactory, TargetFeatureFlag, Cookie, GeolocationCondition, OperatingSystem, Segment, FirstVisit, LastVisit, SameDayVisits, Visits, NewVisitor, } from './conditions';
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"Browser",{enumerable:!0,get:function get(){return _conditions.Browser}}),Object.defineProperty(exports,"ConditionFactory",{enumerable:!0,get:function get(){return _conditions.ConditionFactory}}),Object.defineProperty(exports,"Conversion",{enumerable:!0,get:function get(){return _conditions.Conversion}}),Object.defineProperty(exports,"Cookie",{enumerable:!0,get:function get(){return _conditions.Cookie}}),Object.defineProperty(exports,"CustomData",{enumerable:!0,get:function get(){return _conditions.CustomData}}),Object.defineProperty(exports,"Device",{enumerable:!0,get:function get(){return _conditions.Device}}),Object.defineProperty(exports,"EvaluationDataType",{enumerable:!0,get:function get(){return _types.EvaluationDataType}}),Object.defineProperty(exports,"ExclusiveCampaign",{enumerable:!0,get:function get(){return _conditions.ExclusiveCampaign}}),Object.defineProperty(exports,"FirstVisit",{enumerable:!0,get:function get(){return _conditions.FirstVisit}}),Object.defineProperty(exports,"GeolocationCondition",{enumerable:!0,get:function get(){return _conditions.GeolocationCondition}}),Object.defineProperty(exports,"LastVisit",{enumerable:!0,get:function get(){return _conditions.LastVisit}}),Object.defineProperty(exports,"MatchType",{enumerable:!0,get:function get(){return _types.MatchType}}),Object.defineProperty(exports,"MatchTypeVariation",{enumerable:!0,get:function get(){return _types.MatchTypeVariation}}),Object.defineProperty(exports,"NewVisitor",{enumerable:!0,get:function get(){return _conditions.NewVisitor}}),Object.defineProperty(exports,"OperatingSystem",{enumerable:!0,get:function get(){return _conditions.OperatingSystem}}),Object.defineProperty(exports,"Operator",{enumerable:!0,get:function get(){return _types.Operator}}),Object.defineProperty(exports,"PageTitle",{enumerable:!0,get:function get(){return _conditions.PageTitle}}),Object.defineProperty(exports,"PageUrl",{enumerable:!0,get:function get(){return _conditions.PageUrl}}),Object.defineProperty(exports,"PreviousPage",{enumerable:!0,get:function get(){return _conditions.PreviousPage}}),Object.defineProperty(exports,"SameDayVisits",{enumerable:!0,get:function get(){return _conditions.SameDayVisits}}),Object.defineProperty(exports,"SdkLanguage",{enumerable:!0,get:function get(){return _conditions.SdkLanguage}}),Object.defineProperty(exports,"Segment",{enumerable:!0,get:function get(){return _conditions.Segment}}),Object.defineProperty(exports,"SegmentType",{enumerable:!0,get:function get(){return _types.SegmentType}}),Object.defineProperty(exports,"TargetFeatureFlag",{enumerable:!0,get:function get(){return _conditions.TargetFeatureFlag}}),Object.defineProperty(exports,"TargetingDataType",{enumerable:!0,get:function get(){return _types.TargetingDataType}}),Object.defineProperty(exports,"TargetingType",{enumerable:!0,get:function get(){return _types.TargetingType}}),Object.defineProperty(exports,"Tree",{enumerable:!0,get:function get(){return _tree.Tree}}),Object.defineProperty(exports,"ValueMatchType",{enumerable:!0,get:function get(){return _types.ValueMatchType}}),Object.defineProperty(exports,"VersionMatchType",{enumerable:!0,get:function get(){return _types.VersionMatchType}}),Object.defineProperty(exports,"VisitedPages",{enumerable:!0,get:function get(){return _conditions.VisitedPages}}),Object.defineProperty(exports,"VisitorCode",{enumerable:!0,get:function get(){return _conditions.VisitorCode}}),Object.defineProperty(exports,"Visits",{enumerable:!0,get:function get(){return _conditions.Visits}});var _tree=require("./tree"),_types=require("./types"),_conditions=require("./conditions");
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/targeting/index.ts"],"sourcesContent":["export { Tree } from './tree';\nexport {\n Operator,\n TargetingType,\n SegmentType,\n TargetingDataType,\n EvaluationDataType,\n ValueMatchType,\n MatchTypeVariation,\n MatchType,\n VersionMatchType,\n} from './types';\nexport {\n CustomData,\n ExclusiveCampaign,\n Browser,\n PageUrl,\n PageTitle,\n Conversion,\n VisitorCode,\n SdkLanguage,\n Device,\n PreviousPage,\n VisitedPages,\n ConditionFactory,\n TargetFeatureFlag,\n Cookie,\n GeolocationCondition,\n OperatingSystem,\n Segment,\n FirstVisit,\n LastVisit,\n SameDayVisits,\n Visits,\n NewVisitor,\n} from './conditions';\n"],"mappings":""}
@@ -0,0 +1,23 @@
1
+ import { KameleoonError } from '../kameleoonError';
2
+ import { ConditionDataType } from './conditions';
3
+ import { NodeValueType, Operator } from './types';
4
+ export interface INode {
5
+ readonly value?: NodeValueType;
6
+ readonly left?: INode;
7
+ readonly right?: INode;
8
+ readonly error?: KameleoonError;
9
+ }
10
+ export declare class Node implements INode {
11
+ private nodeValue?;
12
+ private nodeError?;
13
+ private leftChild?;
14
+ private rightChild?;
15
+ private inverseResult;
16
+ constructor(value: ConditionDataType | Operator, left?: INode, right?: INode);
17
+ get value(): NodeValueType | undefined;
18
+ get error(): KameleoonError | undefined;
19
+ get left(): INode | undefined;
20
+ get right(): INode | undefined;
21
+ get inverse(): boolean;
22
+ private isOperator;
23
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Node=void 0;var _conditions=require("./conditions"),_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 Node=function(){function a(b,c,d){if(_classCallCheck(this,a),_defineProperty(this,"nodeValue",void 0),_defineProperty(this,"nodeError",void 0),_defineProperty(this,"leftChild",void 0),_defineProperty(this,"rightChild",void 0),_defineProperty(this,"inverseResult",!1),this.isOperator(b))this.nodeValue=b;else{var e,f=_conditions.ConditionFactory.createCondition(b);this.inverseResult=null!==(e=b.isInclude)&&void 0!==e&&!e,f.ok?this.nodeValue=f.data:this.nodeError=f.error}this.leftChild=c,this.rightChild=d}return _createClass(a,[{key:"value",get:function get(){return this.nodeValue}},{key:"error",get:function get(){return this.nodeError}},{key:"left",get:function get(){return this.leftChild}},{key:"right",get:function get(){return this.rightChild}},{key:"inverse",get:function get(){return this.inverseResult}},{key:"isOperator",value:function isOperator(a){return a===_types.Operator.And||a===_types.Operator.Or}}]),a}();exports.Node=Node;
2
+ //# sourceMappingURL=node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.js","names":["Node","a","value","left","right","_classCallCheck","_defineProperty","isOperator","nodeValue","e","result","ConditionFactory","createCondition","inverseResult","isInclude","ok","data","nodeError","error","leftChild","rightChild","_createClass","key","get","Operator","And","Or","exports"],"sources":["../../src/targeting/node.ts"],"sourcesContent":["import { KameleoonError } from 'src/kameleoonError';\nimport { ConditionFactory, ConditionDataType } from './conditions';\nimport { NodeValueType, Operator } from './types';\n\nexport interface INode {\n readonly value?: NodeValueType;\n readonly left?: INode;\n readonly right?: INode;\n readonly error?: KameleoonError;\n}\n\nexport class Node implements INode {\n private nodeValue?: NodeValueType;\n private nodeError?: KameleoonError;\n private leftChild?: INode;\n private rightChild?: INode;\n private inverseResult: boolean = false;\n\n constructor(\n value: ConditionDataType | Operator,\n left?: INode,\n right?: INode,\n ) {\n if (this.isOperator(value)) {\n this.nodeValue = value;\n } else {\n const result = ConditionFactory.createCondition(value);\n this.inverseResult = !(value.isInclude ?? true);\n\n if (result.ok) {\n this.nodeValue = result.data;\n } else {\n this.nodeError = result.error;\n }\n }\n\n this.leftChild = left;\n this.rightChild = right;\n }\n\n get value(): NodeValueType | undefined {\n return this.nodeValue;\n }\n\n get error(): KameleoonError | undefined {\n return this.nodeError;\n }\n\n get left(): INode | undefined {\n return this.leftChild;\n }\n\n get right(): INode | undefined {\n return this.rightChild;\n }\n\n get inverse(): boolean {\n return this.inverseResult;\n }\n\n private isOperator(value: ConditionDataType | Operator): value is Operator {\n return value === Operator.And || value === Operator.Or;\n }\n}\n"],"mappings":"s4CAWa,CAAAA,IAAI,YAOf,SAAAC,EACEC,CAAmC,CACnCC,CAAY,CACZC,CAAa,CACb,CACA,GAAAC,eAAA,MAAAJ,CAAA,EAAAK,eAAA,0BAAAA,eAAA,0BAAAA,eAAA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} from '../kameleoonError';
3
+ import { EvaluationDataType, SegmentType, TargetingType } from './types';
4
+ interface ITree {
5
+ evaluate: (data: EvaluationDataType) => Result<boolean, KameleoonError>;
6
+ hasTargetingType: (targetingType: TargetingType) => boolean;
7
+ }
8
+ export declare class Tree implements ITree {
9
+ private tree;
10
+ private error;
11
+ private targetingTypes;
12
+ constructor(segment: SegmentType);
13
+ evaluate(data: EvaluationDataType): Result<boolean, KameleoonError>;
14
+ hasTargetingType(targetingType: TargetingType): boolean;
15
+ private evaluateNode;
16
+ private isLeafNode;
17
+ private isNonLeafNode;
18
+ private buildTree;
19
+ private flattenSegment;
20
+ private convertOperators;
21
+ }
22
+ export {};