@kameleoon/javascript-sdk-core 5.5.0 → 5.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/clientConfiguration/clientConfiguration.d.ts +6 -0
- package/dist/clientConfiguration/clientConfiguration.js +1 -1
- package/dist/clientConfiguration/meGroup.d.ts +7 -0
- package/dist/clientConfiguration/meGroup.js +1 -0
- package/dist/clientConfiguration/types.d.ts +1 -0
- package/dist/clientSettings/clientSettings.js +1 -1
- package/dist/eventSource/eventSource.js +1 -1
- package/dist/hasher/hasher.d.ts +1 -0
- package/dist/hasher/hasher.js +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/dist/kameleoonClient.d.ts +3 -1
- package/dist/kameleoonClient.js +1 -1
- package/dist/kameleoonData/dataProcessor.d.ts +1 -1
- package/dist/kameleoonData/dataProcessor.js +1 -1
- package/dist/kameleoonData/types.d.ts +2 -1
- package/dist/kameleoonData/visitsData.js +1 -1
- package/dist/requester/types.d.ts +1 -1
- package/dist/requester/urlProvider.js +1 -1
- package/dist/sdkInfoTypes.d.ts +20 -0
- package/dist/sdkInfoTypes.js +1 -0
- package/dist/storage/integrityChecker.js +1 -1
- package/dist/targeting/conditions/applicationVersion.js +1 -1
- package/dist/targeting/conditions/browser.js +1 -1
- package/dist/targeting/conditions/conditionFactory.d.ts +3 -2
- package/dist/targeting/conditions/conditionFactory.js +1 -1
- package/dist/targeting/conditions/conditionFactoryInstance.d.ts +11 -0
- package/dist/targeting/conditions/conditionFactoryInstance.js +1 -0
- package/dist/targeting/conditions/conversion.js +1 -1
- package/dist/targeting/conditions/conversionLikelihood.js +1 -1
- package/dist/targeting/conditions/cookie.js +1 -1
- package/dist/targeting/conditions/customData.d.ts +1 -1
- package/dist/targeting/conditions/customData.js +1 -1
- package/dist/targeting/conditions/device.js +1 -1
- package/dist/targeting/conditions/firstVisit.js +1 -1
- package/dist/targeting/conditions/geolocation.js +1 -1
- package/dist/targeting/conditions/lastVisit.js +1 -1
- package/dist/targeting/conditions/newVisitor.js +1 -1
- package/dist/targeting/conditions/operatingSystem.js +1 -1
- package/dist/targeting/conditions/pageTitle.js +1 -1
- package/dist/targeting/conditions/pageUrl.js +1 -1
- package/dist/targeting/conditions/previousPage.js +1 -1
- package/dist/targeting/conditions/sameDayVisits.js +1 -1
- package/dist/targeting/conditions/targetPersonalization.js +1 -1
- package/dist/targeting/conditions/visitedPages.js +1 -1
- package/dist/targeting/conditions/visits.js +1 -1
- package/dist/targeting/node.d.ts +1 -1
- package/dist/targeting/node.js +1 -1
- package/dist/targeting/types.d.ts +1 -1
- package/dist/types.d.ts +3 -20
- package/dist/types.js +1 -1
- package/dist/utilities/index.d.ts +1 -0
- package/dist/utilities/index.js +1 -1
- package/dist/utilities/listUtilities.d.ts +10 -0
- package/dist/utilities/listUtilities.js +1 -0
- package/dist/utilities/types.d.ts +2 -1
- package/dist/utilities/utilities.d.ts +4 -10
- package/dist/utilities/utilities.js +1 -1
- package/dist/utilities/validator.d.ts +2 -0
- package/dist/utilities/validator.js +1 -1
- package/dist/variationConfiguration/types.d.ts +2 -1
- package/package.json +3 -2
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Result } from 'ts-res';
|
|
2
2
|
import { KameleoonError } from '../../kameleoonError';
|
|
3
3
|
import { ConditionDataType, ConditionType } from './types';
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
import { IConditionFactory } from '../../targeting/conditions/conditionFactoryInstance';
|
|
5
|
+
export declare class ConditionFactory implements IConditionFactory {
|
|
6
|
+
createCondition(data: ConditionDataType): Result<ConditionType, KameleoonError>;
|
|
6
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ConditionFactory=void 0;var _tsRes=require("ts-res"),_kameleoonError=require("../../kameleoonError"),_types=require("../types"),_browser=require("./browser"),_conversion=require("./conversion"),_customData=require("./customData"),_device=require("./device"),_exclusiveCampaign=require("./exclusiveCampaign"),_pageTitle=require("./pageTitle"),_pageUrl=require("./pageUrl"),_sdkLanguage=require("./sdkLanguage"),_visitorCode=require("./visitorCode"),_cookie=require("./cookie"),_operatingSystem=require("./operatingSystem"),_geolocation=require("./geolocation"),_segment=require("./segment"),_targetFeatureFlag=require("./targetFeatureFlag"),_previousPage=require("./previousPage"),_visitedPages=require("./visitedPages"),_firstVisit=require("./firstVisit"),_lastVisit=require("./lastVisit"),_sameDayVisits=require("./sameDayVisits"),_visits=require("./visits"),_newVisitor=require("./newVisitor"),_applicationVersion=require("./applicationVersion"),_conversionLikelihood=require("./conversionLikelihood"),_logging=require("../../logging"),_exclusiveExperiment=require("./exclusiveExperiment"),_targetExperiment=require("./targetExperiment"),_targetPersonalization=require("./targetPersonalization");class ConditionFactory{
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ConditionFactory=void 0;var _tsRes=require("ts-res"),_kameleoonError=require("../../kameleoonError"),_types=require("../types"),_browser=require("./browser"),_conversion=require("./conversion"),_customData=require("./customData"),_device=require("./device"),_exclusiveCampaign=require("./exclusiveCampaign"),_pageTitle=require("./pageTitle"),_pageUrl=require("./pageUrl"),_sdkLanguage=require("./sdkLanguage"),_visitorCode=require("./visitorCode"),_cookie=require("./cookie"),_operatingSystem=require("./operatingSystem"),_geolocation=require("./geolocation"),_segment=require("./segment"),_targetFeatureFlag=require("./targetFeatureFlag"),_previousPage=require("./previousPage"),_visitedPages=require("./visitedPages"),_firstVisit=require("./firstVisit"),_lastVisit=require("./lastVisit"),_sameDayVisits=require("./sameDayVisits"),_visits=require("./visits"),_newVisitor=require("./newVisitor"),_applicationVersion=require("./applicationVersion"),_conversionLikelihood=require("./conversionLikelihood"),_logging=require("../../logging"),_exclusiveExperiment=require("./exclusiveExperiment"),_targetExperiment=require("./targetExperiment"),_targetPersonalization=require("./targetPersonalization"),_conditionFactoryInstance=require("./conditionFactoryInstance");class ConditionFactory{createCondition(a){const{targetingType:b}=a;return b===_types.TargetingType.CUSTOM_DATUM?(0,_tsRes.Ok)(new _customData.CustomData(a)):b===_types.TargetingType.EXCLUSIVE_EXPERIMENT?(0,_tsRes.Ok)(new _exclusiveExperiment.ExclusiveExperimentCondition(a)):b===_types.TargetingType.EXCLUSIVE_FEATURE_FLAG?(0,_tsRes.Ok)(new _exclusiveCampaign.ExclusiveCampaign):b===_types.TargetingType.TARGET_EXPERIMENT?(0,_tsRes.Ok)(new _targetExperiment.TargetExperimentCondition(a)):b===_types.TargetingType.TARGET_FEATURE_FLAG?(0,_tsRes.Ok)(new _targetFeatureFlag.TargetFeatureFlag(a)):b===_types.TargetingType.TARGET_PERSONALIZATION?(0,_tsRes.Ok)(new _targetPersonalization.TargetPersonalizationCondition(a)):b===_types.TargetingType.DEVICE_TYPE?(0,_tsRes.Ok)(new _device.Device(a)):b===_types.TargetingType.BROWSER?(0,_tsRes.Ok)(new _browser.Browser(a)):b===_types.TargetingType.PAGE_URL?(0,_tsRes.Ok)(new _pageUrl.PageUrl(a)):b===_types.TargetingType.PAGE_TITLE?(0,_tsRes.Ok)(new _pageTitle.PageTitle(a)):b===_types.TargetingType.CONVERSIONS?(0,_tsRes.Ok)(new _conversion.Conversion(a)):b===_types.TargetingType.VISITOR_CODE?(0,_tsRes.Ok)(new _visitorCode.VisitorCode(a)):b===_types.TargetingType.SDK_LANGUAGE?(0,_tsRes.Ok)(new _sdkLanguage.SdkLanguage(a)):b===_types.TargetingType.COOKIE?(0,_tsRes.Ok)(new _cookie.Cookie(a)):b===_types.TargetingType.OPERATING_SYSTEM?(0,_tsRes.Ok)(new _operatingSystem.OperatingSystem(a)):b===_types.TargetingType.GEOLOCATION?(0,_tsRes.Ok)(new _geolocation.GeolocationCondition(a)):b===_types.TargetingType.SEGMENT?(0,_tsRes.Ok)(new _segment.Segment(a)):b===_types.TargetingType.APPLICATION_VERSION?(0,_tsRes.Ok)(new _applicationVersion.ApplicationVersion(a)):b===_types.TargetingType.PREVIOUS_PAGE?(0,_tsRes.Ok)(new _previousPage.PreviousPage(a)):b===_types.TargetingType.NUMBER_OF_VISITED_PAGES?(0,_tsRes.Ok)(new _visitedPages.VisitedPages(a)):b===_types.TargetingType.LAST_VISIT?(0,_tsRes.Ok)(new _lastVisit.LastVisit(a)):b===_types.TargetingType.FIRST_VISIT?(0,_tsRes.Ok)(new _firstVisit.FirstVisit(a)):b===_types.TargetingType.SAME_DAY_VISITS?(0,_tsRes.Ok)(new _sameDayVisits.SameDayVisits(a)):b===_types.TargetingType.VISITS?(0,_tsRes.Ok)(new _visits.Visits(a)):b===_types.TargetingType.NEW_VISITORS?(0,_tsRes.Ok)(new _newVisitor.NewVisitor(a)):b===_types.TargetingType.HEAT_SLICE?(0,_tsRes.Ok)(new _conversionLikelihood.ConversionLikelihood(a)):(_logging.KameleoonLogger.error`Unsupported targeted condition type found: ${b}`,(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.TargetingCondition,b)))}}exports.ConditionFactory=ConditionFactory,_conditionFactoryInstance.ConditionFactoryInstance.setConditionFactoryInstance(new ConditionFactory);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ConditionDataType, ConditionType } from '../../targeting/conditions/types';
|
|
2
|
+
import { Result } from 'ts-res';
|
|
3
|
+
import { KameleoonError } from '../../kameleoonError';
|
|
4
|
+
export interface IConditionFactory {
|
|
5
|
+
createCondition(data: ConditionDataType): Result<ConditionType, KameleoonError>;
|
|
6
|
+
}
|
|
7
|
+
export declare class ConditionFactoryInstance {
|
|
8
|
+
static conditionFactoryInstance: IConditionFactory;
|
|
9
|
+
static setConditionFactoryInstance(value: IConditionFactory): void;
|
|
10
|
+
static createCondition(data: ConditionDataType): Result<ConditionType, KameleoonError>;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ConditionFactoryInstance=void 0;function _defineProperty(a,b,c){return(b=_toPropertyKey(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||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){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)}class ConditionFactoryInstance{static setConditionFactoryInstance(a){this.conditionFactoryInstance=a}static createCondition(a){return this.conditionFactoryInstance.createCondition(a)}}exports.ConditionFactoryInstance=ConditionFactoryInstance,_defineProperty(ConditionFactoryInstance,"conditionFactoryInstance",void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Conversion=void 0;var _tsRes=require("ts-res"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Conversion=void 0;var _tsRes=require("ts-res"),_types=require("../../kameleoonData/types");function _defineProperty(a,b,c){return(b=_toPropertyKey(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||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){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)}class Conversion{constructor(a){let{goalId:b}=a;_defineProperty(this,"conditionValue",void 0),this.conditionValue=b}evaluate(a){let{targetingData:b}=a;const c=null===b||void 0===b?void 0:b[_types.KameleoonData.Conversion];if(!this.conditionValue)return(0,_tsRes.Ok)(!1);if(c){if(Object.keys(c).length&&-1===this.conditionValue)return(0,_tsRes.Ok)(!0);const a=Object.values(c);return(0,_tsRes.Ok)(a.some(a=>!!a&&a.goalId===this.conditionValue))}return(0,_tsRes.Ok)(!1)}}exports.Conversion=Conversion;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ConversionLikelihood=void 0;var _tsRes=require("ts-res"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ConversionLikelihood=void 0;var _tsRes=require("ts-res"),_types=require("../../kameleoonData/types");function _defineProperty(a,b,c){return(b=_toPropertyKey(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||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){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)}class ConversionLikelihood{constructor(a){let{lowerBound:b,upperBound:c,keyMomentId:d,goalId:e}=a;_defineProperty(this,"lowerBound",void 0),_defineProperty(this,"upperBound",void 0),_defineProperty(this,"keyMomentId",void 0),_defineProperty(this,"goalId",void 0),this.lowerBound=b,this.upperBound=c,this.keyMomentId=d,this.goalId=e}evaluate(a){var b;let{targetingData:c}=a;const d=null===c||void 0===c?void 0:c[_types.KameleoonData.KameleoonConversionScore];if("number"!=typeof this.keyMomentId||"number"!=typeof this.goalId||"number"!=typeof this.lowerBound||"number"!=typeof this.upperBound||!d)return(0,_tsRes.Ok)(!1);const e=null===(b=d.kcs[this.keyMomentId.toString()])||void 0===b?void 0:b[this.goalId.toString()];return"number"==typeof e?(0,_tsRes.Ok)(e>=this.lowerBound&&e<=this.upperBound):(0,_tsRes.Ok)(!1)}}exports.ConversionLikelihood=ConversionLikelihood;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Cookie=void 0;var _tsRes=require("ts-res"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Cookie=void 0;var _tsRes=require("ts-res"),_cookie=require("../../kameleoonData/cookie"),_types=require("../../kameleoonData/types"),_kameleoonError=require("../../kameleoonError"),_types2=require("../types"),_utilities=require("../../utilities"),_logging=require("../../logging");function _defineProperty(a,b,c){return(b=_toPropertyKey(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||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){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)}class Cookie{constructor(a){let{name:b,value:c,nameMatchType:d,valueMatchType:e}=a;_defineProperty(this,"cookie",void 0),_defineProperty(this,"keyMatchType",void 0),_defineProperty(this,"valueMatchType",void 0),this.cookie={key:null!==b&&void 0!==b?b:void 0,value:null!==c&&void 0!==c?c:void 0},this.keyMatchType=d,this.valueMatchType=e}evaluate(a){var b;let{targetingData:c}=a;const d=!this.cookie.key&&!this.cookie.value,e=!!this.valueMatchType&&!!this.keyMatchType;if(d||!e)return(0,_tsRes.Ok)(!1);const f=this.extractCookie(),g=(null===c||void 0===c||null===(b=c[_types.KameleoonData.Cookie])||void 0===b?void 0:b.cookie)||[];return(0,_tsRes.Ok)(f.some(a=>this.checkCondition(a))||g.some(a=>this.checkCondition(a)))}extractCookie(){return"undefined"!=typeof document&&document.cookie?_cookie.Cookie.fromString(document.cookie).data.cookie:[]}checkCondition(a){const b=this.keyMatchType,{key:c,value:d}=a;if(b===_types2.NameMatchType.OPTIONAL){const a=this.cookie;return!!this.isOptionalCookie(a)&&this.compareCookieValue(d,a.value)}const{key:e,value:f}=this.cookie;let g;return b===_types2.NameMatchType.EXACT?g=c===e:b===_types2.NameMatchType.CONTAINS?g=c.includes(e):b===_types2.NameMatchType.REGULAR_EXPRESSION?g=_utilities.Parser.parseRegExp(e).test(c):(_logging.KameleoonLogger.error`Unexpected comparing operation for Cookie condition: ${b}`,(0,_kameleoonError.exhaustCheck)(b)),g&&this.compareCookieValue(d,f)}compareCookieValue(a,b){const c=this.valueMatchType;return c===_types2.ValueMatchType.EXACT?a===b:c===_types2.ValueMatchType.CONTAINS?a.includes(b):c===_types2.ValueMatchType.REGULAR_EXPRESSION?_utilities.Parser.parseRegExp(b).test(a):(_logging.KameleoonLogger.error`Unexpected comparing operation for Cookie condition: ${c}`,!1)}isOptionalCookie(a){const{value:b}=a;return"undefined"!=typeof b}}exports.Cookie=Cookie;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Result } from 'ts-res';
|
|
2
2
|
import { KameleoonError } from '../../kameleoonError';
|
|
3
|
-
import { EvaluationDataType } from '../../targeting';
|
|
3
|
+
import { EvaluationDataType } from '../../targeting/types';
|
|
4
4
|
import { ConditionDataType, ICondition } from './types';
|
|
5
5
|
export declare class CustomData implements ICondition {
|
|
6
6
|
private customDataIndex;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CustomData=void 0;var _tsRes=require("ts-res"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CustomData=void 0;var _tsRes=require("ts-res"),_types=require("../../kameleoonData/types"),_kameleoonError=require("../../kameleoonError"),_types2=require("../types"),_utilities=require("../../utilities"),_kameleoonLogger=require("../../logging/kameleoonLogger");function _defineProperty(a,b,c){return(b=_toPropertyKey(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||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){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)}class CustomData{constructor(a){let{customDataIndex:b,valueMatchType:c,value:d,range:e}=a;_defineProperty(this,"customDataIndex",void 0),_defineProperty(this,"matchType",void 0),_defineProperty(this,"conditionValue",void 0),_defineProperty(this,"error",void 0),_defineProperty(this,"range",void 0),this.customDataIndex=b?+b:null,this.matchType=c,this.conditionValue=d,this.range=e}evaluate(a){let{targetingData:b}=a;if("number"==typeof this.customDataIndex){var c;const a=null===b||void 0===b||null===(c=b[_types.KameleoonData.CustomData])||void 0===c?void 0:c[this.customDataIndex];if(a){const{value:b}=a,c=this.checkCondition(b);return this.error?(0,_tsRes.Err)(this.error):(0,_tsRes.Ok)(c)}}return(0,_tsRes.Ok)(this.matchType===_types2.ValueMatchType.UNDEFINED)}checkCondition(a){if("string"!=typeof this.conditionValue&&this.matchType!==_types2.ValueMatchType.TRUE&&this.matchType!==_types2.ValueMatchType.FALSE&&this.matchType!==_types2.ValueMatchType.RANGE)return _kameleoonLogger.KameleoonLogger.error`Unexpected condition value for CustomData condition: ${this.conditionValue}`,!1;const b=this.conditionValue;if(this.matchType===_types2.ValueMatchType.AMONG_VALUES){const c=this.parseArray(b);if(!c.ok)return this.error=c.error,!1;const d=new Set(c.data);return Array.isArray(a)?a.some(a=>d.has(a)):c.data.includes(a)}if(this.matchType===_types2.ValueMatchType.RANGE){const b=this.parseRange(this.range);if(!b.ok)return this.error=b.error,!1;const[c,d]=b.data,e=a=>a>=c&&a<=d;return Array.isArray(a)?a.some(a=>e(+a)):e(+a)}if(Array.isArray(a))return a.some(a=>this.checkCondition(a));switch(this.matchType){case _types2.ValueMatchType.CONTAINS:return a.includes(b);case _types2.ValueMatchType.EXACT:return a===this.conditionValue;case _types2.ValueMatchType.REGULAR_EXPRESSION:return _utilities.Parser.parseRegExp(b).test(a);case _types2.ValueMatchType.LOWER:return+a<+this.conditionValue;case _types2.ValueMatchType.EQUAL:return+a===+this.conditionValue;case _types2.ValueMatchType.GREATER:return+a>+this.conditionValue;case _types2.ValueMatchType.TRUE:return"true"===a.toLowerCase();case _types2.ValueMatchType.FALSE:return"false"===a.toLowerCase();default:return _kameleoonLogger.KameleoonLogger.error`Unexpected comparing operation for CustomData condition: ${this.matchType}`,!1}}parseArray(a){try{const b=JSON.parse(a);if(Array.isArray(b))return(0,_tsRes.Ok)(b)}catch(b){return _kameleoonLogger.KameleoonLogger.error`Failed to parse array: ${a} in CustomData condition`,(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.AmongValuesCheck,b,a))}return(0,_tsRes.Ok)([])}parseRange(a){return a&&2===a.length?(0,_tsRes.Ok)(a):(_kameleoonLogger.KameleoonLogger.error`Failed to parse range: ${a} in CustomData condition`,(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.RangeCheck,a)))}}exports.CustomData=CustomData;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Device=void 0;var _tsRes=require("ts-res"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Device=void 0;var _tsRes=require("ts-res"),_types=require("../../kameleoonData/types");function _defineProperty(a,b,c){return(b=_toPropertyKey(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||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){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)}class Device{constructor(a){let{device:b}=a;_defineProperty(this,"device",void 0),this.device=b}evaluate(a){let{targetingData:b}=a;const c=null===b||void 0===b?void 0:b[_types.KameleoonData.Device];if(c){const{device:a}=c;return(0,_tsRes.Ok)(a===this.device)}return(0,_tsRes.Ok)(!1)}}exports.Device=Device;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.FirstVisit=void 0;var _tsRes=require("ts-res"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.FirstVisit=void 0;var _tsRes=require("ts-res"),_types=require("../../kameleoonData/types"),_utilities=require("../../utilities"),_types2=require("../types"),_logging=require("../../logging");function _defineProperty(a,b,c){return(b=_toPropertyKey(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||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){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)}class FirstVisit{constructor(a){let{matchType:b,count:c,unitOfTime:d}=a;_defineProperty(this,"matchType",void 0),_defineProperty(this,"conditionValue",void 0),_defineProperty(this,"timeUnit",void 0),this.matchType=b,this.conditionValue=c,this.timeUnit=d}evaluate(a){let{targetingData:b}=a;const c=null===b||void 0===b?void 0:b[_types.KameleoonData.VisitsData];if(!(null!==c&&void 0!==c&&c.visits.length))return(0,_tsRes.Ok)(!1);const d=c.visits[0];return(0,_tsRes.Ok)(this.checkCondition(d))}checkCondition(a){if(!this.matchType||"number"!=typeof this.conditionValue||!this.timeUnit)return!1;const b=Date.now()-a,c=_utilities.Utilities.convertTimeUnit(b,this.timeUnit);switch(this.matchType){case _types2.MatchType.GREATER:return c>this.conditionValue;case _types2.MatchType.LOWER:return c<this.conditionValue;default:return _logging.KameleoonLogger.error`Unexpected comparing operation for FirstVisit condition: ${this.matchType}`,!1}}}exports.FirstVisit=FirstVisit;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GeolocationCondition=void 0;var _tsRes=require("ts-res"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GeolocationCondition=void 0;var _tsRes=require("ts-res"),_types=require("../../kameleoonData/types");function _defineProperty(a,b,c){return(b=_toPropertyKey(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||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){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)}class GeolocationCondition{constructor(a){let{country:b,region:c,city:d}=a;_defineProperty(this,"country",void 0),_defineProperty(this,"region",void 0),_defineProperty(this,"city",void 0),this.country=b,this.region=c,this.city=d}evaluate(a){let{targetingData:b}=a;const c=null===b||void 0===b?void 0:b[_types.KameleoonData.GeolocationData];if(c){const{country:a,region:b,city:d}=c,[e,f,g]=[this.country,this.region,this.city];if(!e||!a)return(0,_tsRes.Ok)(!1);const h=a.toLowerCase()===e.toLowerCase()&&(!f||(null===b||void 0===b?void 0:b.toLowerCase())===f.toLowerCase())&&(!g||(null===d||void 0===d?void 0:d.toLowerCase())===g.toLowerCase());return(0,_tsRes.Ok)(h)}return(0,_tsRes.Ok)(!1)}}exports.GeolocationCondition=GeolocationCondition;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LastVisit=void 0;var _tsRes=require("ts-res"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LastVisit=void 0;var _tsRes=require("ts-res"),_types=require("../../kameleoonData/types"),_utilities=require("../../utilities"),_types2=require("../types"),_logging=require("../../logging");function _defineProperty(a,b,c){return(b=_toPropertyKey(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||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){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)}class LastVisit{constructor(a){let{matchType:b,count:c,unitOfTime:d}=a;_defineProperty(this,"matchType",void 0),_defineProperty(this,"conditionValue",void 0),_defineProperty(this,"timeUnit",void 0),this.matchType=b,this.conditionValue=c,this.timeUnit=d}evaluate(a){let{targetingData:b}=a;const c=null===b||void 0===b?void 0:b[_types.KameleoonData.VisitsData];if(!(null!==c&&void 0!==c&&c.visits.length))return(0,_tsRes.Ok)(!1);const{visits:d}=c,e=d[d.length-1];return(0,_tsRes.Ok)(this.checkCondition(e))}checkCondition(a){if(!this.matchType||"number"!=typeof this.conditionValue||!this.timeUnit)return!1;const b=Date.now()-a,c=_utilities.Utilities.convertTimeUnit(b,this.timeUnit);switch(this.matchType){case _types2.MatchType.GREATER:return c>this.conditionValue;case _types2.MatchType.LOWER:return c<this.conditionValue;default:return _logging.KameleoonLogger.error`Unexpected comparing operation for LastVisit condition: ${this.matchType}`,!1}}}exports.LastVisit=LastVisit;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.NewVisitor=void 0;var _tsRes=require("ts-res"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.NewVisitor=void 0;var _tsRes=require("ts-res"),_types=require("../../kameleoonData/types"),_kameleoonError=require("../../kameleoonError"),_types2=require("../types"),_logging=require("../../logging");function _defineProperty(a,b,c){return(b=_toPropertyKey(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||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){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)}class NewVisitor{constructor(a){let{visitorType:b}=a;_defineProperty(this,"visitorType",void 0),this.visitorType=b}evaluate(a){let{targetingData:b}=a;const c=null===b||void 0===b?void 0:b[_types.KameleoonData.VisitsData];if(!c||!this.visitorType)return(0,_tsRes.Ok)(!1);const{visits:d}=c,e=!d.length;switch(this.visitorType){case _types2.VisitorType.NEW:return(0,_tsRes.Ok)(e);case _types2.VisitorType.RETURNING:return(0,_tsRes.Ok)(!e);default:_logging.KameleoonLogger.error`Unexpected visitor type for NewVisitor condition: ${this.visitorType}`,(0,_kameleoonError.exhaustCheck)(this.visitorType)}}}exports.NewVisitor=NewVisitor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.OperatingSystem=void 0;var _tsRes=require("ts-res"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.OperatingSystem=void 0;var _tsRes=require("ts-res"),_types=require("../../kameleoonData/types");function _defineProperty(a,b,c){return(b=_toPropertyKey(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||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){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)}class OperatingSystem{constructor(a){let{os:b}=a;_defineProperty(this,"operatingSystem",void 0),this.operatingSystem=b}evaluate(a){let{targetingData:b}=a;const c=null===b||void 0===b?void 0:b[_types.KameleoonData.OperatingSystem];if(c){const{operatingSystem:a}=c;return(0,_tsRes.Ok)(a===this.operatingSystem)}return(0,_tsRes.Ok)(!1)}}exports.OperatingSystem=OperatingSystem;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PageTitle=void 0;var _tsRes=require("ts-res"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PageTitle=void 0;var _tsRes=require("ts-res"),_types=require("../../kameleoonData/types"),_utilities=require("../../utilities"),_types2=require("../types"),_logging=require("../../logging"),_utilities2=require("./utilities");function _defineProperty(a,b,c){return(b=_toPropertyKey(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||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){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)}class PageTitle{constructor(a){let{matchType:b,title:c}=a;_defineProperty(this,"matchType",void 0),_defineProperty(this,"conditionValue",void 0),this.matchType=b,this.conditionValue=c}evaluate(a){let{targetingData:b}=a;const c=null===b||void 0===b?void 0:b[_types.KameleoonData.PageView];if(!c)return(0,_tsRes.Ok)(!1);const d=_utilities2.PageUtils.getLatest(c);return(0,_tsRes.Ok)(this.checkCondition(d.title))}checkCondition(a){if(!this.matchType||!this.conditionValue)return!1;switch(this.matchType){case _types2.MatchType.CONTAINS:return a.includes(this.conditionValue);case _types2.MatchType.EXACT:return a===this.conditionValue;case _types2.MatchType.REGULAR_EXPRESSION:return _utilities.Parser.parseRegExp(this.conditionValue).test(a);default:return _logging.KameleoonLogger.error`Unexpected comparing operation for PageTitle condition: ${this.matchType}`,!1}}}exports.PageTitle=PageTitle;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PageUrl=void 0;var _tsRes=require("ts-res"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PageUrl=void 0;var _tsRes=require("ts-res"),_types=require("../../kameleoonData/types"),_utilities=require("../../utilities"),_types2=require("../types"),_logging=require("../../logging"),_utilities2=require("./utilities");function _defineProperty(a,b,c){return(b=_toPropertyKey(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||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){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)}class PageUrl{constructor(a){let{matchType:b,url:c}=a;_defineProperty(this,"matchType",void 0),_defineProperty(this,"conditionValue",void 0),this.matchType=b,this.conditionValue=c}evaluate(a){let{targetingData:b}=a;const c=null===b||void 0===b?void 0:b[_types.KameleoonData.PageView];if(!c)return(0,_tsRes.Ok)(!1);const d=_utilities2.PageUtils.getLatest(c);return(0,_tsRes.Ok)(this.checkCondition(d.urlAddress))}checkCondition(a){if(!this.matchType||!this.conditionValue)return!1;switch(this.matchType){case _types2.MatchType.CONTAINS:return a.includes(this.conditionValue);case _types2.MatchType.EXACT:return a===this.conditionValue;case _types2.MatchType.REGULAR_EXPRESSION:return _utilities.Parser.parseRegExp(this.conditionValue).test(a);default:return _logging.KameleoonLogger.error`Unexpected comparing operation for PageUrl condition: ${this.matchType}`,!1}}}exports.PageUrl=PageUrl;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PreviousPage=void 0;var _tsRes=require("ts-res"),_utilities=require("../../utilities"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PreviousPage=void 0;var _tsRes=require("ts-res"),_utilities=require("../../utilities"),_types=require("../../kameleoonData/types"),_types2=require("../types"),_logging=require("../../logging");function _defineProperty(a,b,c){return(b=_toPropertyKey(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||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){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)}class PreviousPage{constructor(a){let{matchType:b,url:c}=a;_defineProperty(this,"conditionValue",void 0),_defineProperty(this,"matchType",void 0),this.conditionValue=c,this.matchType=b}evaluate(a){let{targetingData:b}=a;const c=null===b||void 0===b?void 0:b[_types.KameleoonData.PageView];if(!c)return(0,_tsRes.Ok)(!1);const d=this.getSecondLatestPageView(Object.values(c));if(!d)return(0,_tsRes.Ok)(!1);const e=d.urlAddress;return(0,_tsRes.Ok)(this.checkCondition(e))}checkCondition(a){if(!this.matchType||!this.conditionValue)return!1;switch(this.matchType){case _types2.MatchType.CONTAINS:return a.includes(this.conditionValue);case _types2.MatchType.EXACT:return a===this.conditionValue;case _types2.MatchType.REGULAR_EXPRESSION:return _utilities.Parser.parseRegExp(this.conditionValue).test(a);default:return _logging.KameleoonLogger.error`Unexpected comparing operation for PreviousPage condition: ${this.matchType}`,!1}}getSecondLatestPageView(a){if(2>a.length)return;let b,c;return a.forEach(a=>{const d=a.timestamps[a.timestamps.length-1].time;if(!b)return void(b=a);const e=b.timestamps[b.timestamps.length-1].time;if(d>e)return c=b,void(b=a);const f=c?c.timestamps[c.timestamps.length-1].time:0;d>f&&(c=a)}),c}}exports.PreviousPage=PreviousPage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SameDayVisits=void 0;var _tsRes=require("ts-res"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SameDayVisits=void 0;var _tsRes=require("ts-res"),_types=require("../../kameleoonData/types"),_types2=require("../types"),_logging=require("../../logging");function _defineProperty(a,b,c){return(b=_toPropertyKey(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||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){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)}class SameDayVisits{constructor(a){let{matchType:b,visitCount:c}=a;_defineProperty(this,"matchType",void 0),_defineProperty(this,"conditionValue",void 0),this.matchType=b,this.conditionValue=c}evaluate(a){let{targetingData:b}=a;const c=null===b||void 0===b?void 0:b[_types.KameleoonData.VisitsData];if(!c)return(0,_tsRes.Ok)(!1);let d=0;const e=new Date().setHours(0,0,0,0),{visits:f}=c;return f.forEach(a=>{a>e&&d++}),d+=1,(0,_tsRes.Ok)(this.checkCondition(d))}checkCondition(a){if(!this.matchType||"number"!=typeof this.conditionValue)return!1;switch(this.matchType){case _types2.MatchType.EQUAL:return a===this.conditionValue;case _types2.MatchType.GREATER:return a>this.conditionValue;case _types2.MatchType.LOWER:return a<this.conditionValue;default:return _logging.KameleoonLogger.error`Unexpected comparing operation for SameDayVisits condition: ${this.matchType}`,!1}}}exports.SameDayVisits=SameDayVisits;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.TargetPersonalizationCondition=void 0;var _tsRes=require("ts-res"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.TargetPersonalizationCondition=void 0;var _tsRes=require("ts-res"),_types=require("../../kameleoonData/types");function _defineProperty(a,b,c){return(b=_toPropertyKey(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||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){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)}class TargetPersonalizationCondition{constructor(a){let{personalizationId:b}=a;_defineProperty(this,"personalizationId",void 0),this.personalizationId=b}evaluate(a){return a.targetingData?(0,_tsRes.Ok)(this.checkCondition(a)):(0,_tsRes.Ok)(!1)}checkCondition(a){var b;if(!this.personalizationId)return!1;const c=null===(b=a.targetingData)||void 0===b?void 0:b[_types.KameleoonData.Personalization];return(null===c||void 0===c?void 0:c[this.personalizationId])!==void 0}}exports.TargetPersonalizationCondition=TargetPersonalizationCondition;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.VisitedPages=void 0;var _tsRes=require("ts-res"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.VisitedPages=void 0;var _tsRes=require("ts-res"),_types=require("../../kameleoonData/types"),_types2=require("../types"),_logging=require("../../logging");function _defineProperty(a,b,c){return(b=_toPropertyKey(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||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){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)}class VisitedPages{constructor(a){let{matchType:b,pageCount:c}=a;_defineProperty(this,"conditionValue",void 0),_defineProperty(this,"matchType",void 0),this.matchType=b,this.conditionValue=c}evaluate(a){let{targetingData:b}=a;const c=null===b||void 0===b?void 0:b[_types.KameleoonData.PageView];if(!c)return(0,_tsRes.Ok)(!1);let d=0;return Object.values(c).forEach(a=>{d+=a.timestamps.length}),(0,_tsRes.Ok)(this.checkCondition(d))}checkCondition(a){if(!this.matchType||"number"!=typeof this.conditionValue)return!1;switch(this.matchType){case _types2.MatchType.EQUAL:return a===this.conditionValue;case _types2.MatchType.GREATER:return a>this.conditionValue;case _types2.MatchType.LOWER:return a<this.conditionValue;default:return _logging.KameleoonLogger.error`Unexpected comparing operation for VisitedPages condition: ${this.matchType}`,!1}}}exports.VisitedPages=VisitedPages;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Visits=void 0;var _tsRes=require("ts-res"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Visits=void 0;var _tsRes=require("ts-res"),_types=require("../../kameleoonData/types"),_types2=require("../types"),_logging=require("../../logging");function _defineProperty(a,b,c){return(b=_toPropertyKey(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||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){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)}class Visits{constructor(a){let{matchType:b,visitCount:c}=a;_defineProperty(this,"matchType",void 0),_defineProperty(this,"conditionValue",void 0),this.matchType=b,this.conditionValue=c}evaluate(a){let{targetingData:b}=a;const c=null===b||void 0===b?void 0:b[_types.KameleoonData.VisitsData];if(!c)return(0,_tsRes.Ok)(!1);const d=c.visits.length+1;return(0,_tsRes.Ok)(this.checkCondition(d))}checkCondition(a){if(!this.matchType||"number"!=typeof this.conditionValue)return!1;switch(this.matchType){case _types2.MatchType.EQUAL:return a===this.conditionValue;case _types2.MatchType.GREATER:return a>this.conditionValue;case _types2.MatchType.LOWER:return a<this.conditionValue;default:return _logging.KameleoonLogger.error`Unexpected comparing operation for Visits condition: ${this.matchType}`,!1}}}exports.Visits=Visits;
|
package/dist/targeting/node.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { KameleoonError } from '../kameleoonError';
|
|
2
|
-
import { ConditionDataType } from './conditions';
|
|
2
|
+
import { ConditionDataType } from './conditions/types';
|
|
3
3
|
import { NodeValueType, Operator } from './types';
|
|
4
4
|
export interface INode {
|
|
5
5
|
readonly value?: NodeValueType;
|
package/dist/targeting/node.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Node=void 0;var
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Node=void 0;var _types=require("./types"),_conditionFactoryInstance=require("./conditions/conditionFactoryInstance");function _defineProperty(a,b,c){return(b=_toPropertyKey(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||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){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)}class Node{constructor(a,b,c){if(_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(a))this.nodeValue=a;else{var d;const b=_conditionFactoryInstance.ConditionFactoryInstance.createCondition(a);this.inverseResult=null!==(d=a.isInclude)&&void 0!==d&&!d,b.ok?this.nodeValue=b.data:this.nodeError=b.error}this.leftChild=b,this.rightChild=c}get value(){return this.nodeValue}get error(){return this.nodeError}get left(){return this.leftChild}get right(){return this.rightChild}get inverse(){return this.inverseResult}isOperator(a){return a===_types.Operator.And||a===_types.Operator.Or}}exports.Node=Node;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MappedRuleType } from '../clientConfiguration/types';
|
|
2
2
|
import { KameleoonVisitorDataType } from '../kameleoonData/types';
|
|
3
3
|
import { FeatureFlagVariationsType } from '../storage/types';
|
|
4
|
-
import { ExternalPackageInfoType } from '../
|
|
4
|
+
import { ExternalPackageInfoType } from '../sdkInfoTypes';
|
|
5
5
|
import { ConditionDataType, ConditionType } from './conditions';
|
|
6
6
|
import { Node } from './node';
|
|
7
7
|
import { Tree } from './tree';
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ClientConfigurationDataType, JSONType, RuleType } from './clientConfiguration/types';
|
|
2
|
-
import { SdkLanguageType } from './constants';
|
|
3
2
|
import { IExternalEventSource } from './eventSource';
|
|
4
3
|
import { IExternalRequester, IUrlProvider, RequestType } from './requester';
|
|
5
4
|
import { IExternalStorage } from './storage';
|
|
@@ -7,6 +6,7 @@ import { IExternalPRNG, VisitorDataFiltersType } from './utilities';
|
|
|
7
6
|
import { IVisitorCodeManager } from './visitorCodeManager';
|
|
8
7
|
import { IExternalLogger } from './logging';
|
|
9
8
|
import { FeatureFlagType as ConfigFeatureFlagType } from './clientConfiguration/types';
|
|
9
|
+
import { Environment, ExternalPackageInfoType } from './sdkInfoTypes';
|
|
10
10
|
/**
|
|
11
11
|
* @param {number} updateInterval - update interval in _minutes_ for sdk configuration, minimum value is 1 minute
|
|
12
12
|
* @defaultvalue 60
|
|
@@ -48,22 +48,14 @@ export type DependenciesType = {
|
|
|
48
48
|
* @param {Partial<SDKConfigurationType>} configuration - client's configuration
|
|
49
49
|
* @param {InternalSDKConfigurationType} internalConfiguration - internal configuration for sdk core to be initialized with certain parameters to certain type of JavaScript SDK
|
|
50
50
|
* @param {DependenciesType | undefined} dependencies - internal dependencies meant primarily for testing purposes
|
|
51
|
+
* @param {boolean | undefined} stubMode - When set to true, the client will operate in stub mode and perform no operations. In this mode, all method calls become no-ops, ensuring that no external actions or side effects occur.
|
|
51
52
|
* */
|
|
52
53
|
export type SDKCoreParameters = {
|
|
53
54
|
siteCode: string;
|
|
54
55
|
internalConfiguration: InternalSDKConfigurationType;
|
|
55
56
|
configuration?: Partial<SDKConfigurationType>;
|
|
56
57
|
dependencies?: DependenciesType;
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* @param {SdkLanguageType} type - type of the SDK
|
|
60
|
-
* @param {string} version - version of the package
|
|
61
|
-
* @param {boolean} isServer - flag to indicate if the SDK is running on the server
|
|
62
|
-
* */
|
|
63
|
-
export type ExternalPackageInfoType = {
|
|
64
|
-
type: SdkLanguageType;
|
|
65
|
-
version: string;
|
|
66
|
-
isServer: boolean;
|
|
58
|
+
stubMode?: boolean;
|
|
67
59
|
};
|
|
68
60
|
/**
|
|
69
61
|
* @param {ExternalPackageInfoType} packageInfo - external package info, used to get package version and name
|
|
@@ -104,15 +96,6 @@ export type InternalSDKConfigurationType = {
|
|
|
104
96
|
externals: ExternalsType;
|
|
105
97
|
settings: InternalSettingsType;
|
|
106
98
|
};
|
|
107
|
-
/**
|
|
108
|
-
* @readonly
|
|
109
|
-
* @enum {string} an Enum containing all possible variants of environment, passed as an argument to KameleoonClient `configuration`s `environment` field
|
|
110
|
-
* */
|
|
111
|
-
export declare enum Environment {
|
|
112
|
-
Production = "production",
|
|
113
|
-
Staging = "staging",
|
|
114
|
-
Development = "development"
|
|
115
|
-
}
|
|
116
99
|
/**
|
|
117
100
|
* @readonly
|
|
118
101
|
* @enum {string} an Enum containing all possible variants of feature variable types
|
package/dist/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var _requester=require("./requester");Object.defineProperty(exports,"__esModule",{value:!0}),exports.VariableType=exports.TrackingStatus=exports.Milliseconds=
|
|
1
|
+
"use strict";var _requester=require("./requester");Object.defineProperty(exports,"__esModule",{value:!0}),exports.VariableType=exports.TrackingStatus=exports.Milliseconds=void 0;let VariableType=exports.VariableType=function(a){return a.BOOLEAN="BOOLEAN",a.NUMBER="NUMBER",a.STRING="STRING",a.JSON="JSON",a.JS="JS",a.CSS="CSS",a}({}),TrackingStatus=exports.TrackingStatus=function(a){return a.Sent="sent",a.Unsent="unsent",a.Pending="pending",a}({}),Milliseconds=exports.Milliseconds=function(a){return a[a.Second=1000]="Second",a[a.Minute=60*a.Second]="Minute",a[a.Hour=60*a.Minute]="Hour",a[a.Day=24*a.Hour]="Day",a[a.Week=7*a.Day]="Week",a[a.Month=30*a.Day]="Month",a}({});
|
package/dist/utilities/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"IExternalPRNG",{enumerable:!0,get:function(){return _types.IExternalPRNG}}),Object.defineProperty(exports,"Order",{enumerable:!0,get:function(){return _types.Order}}),Object.defineProperty(exports,"Parser",{enumerable:!0,get:function(){return _parser.Parser}}),Object.defineProperty(exports,"TimeUnit",{enumerable:!0,get:function(){return _types.TimeUnit}}),Object.defineProperty(exports,"Utilities",{enumerable:!0,get:function(){return _utilities.Utilities}}),Object.defineProperty(exports,"Validator",{enumerable:!0,get:function(){return _validator.Validator}}),Object.defineProperty(exports,"VisitorDataFiltersType",{enumerable:!0,get:function(){return _types.VisitorDataFiltersType}});var _utilities=require("./utilities"),_parser=require("./parser"),_validator=require("./validator"),_types=require("./types");
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"IExternalPRNG",{enumerable:!0,get:function(){return _types.IExternalPRNG}}),Object.defineProperty(exports,"ListUtilities",{enumerable:!0,get:function(){return _listUtilities.ListUtilities}}),Object.defineProperty(exports,"Order",{enumerable:!0,get:function(){return _types.Order}}),Object.defineProperty(exports,"Parser",{enumerable:!0,get:function(){return _parser.Parser}}),Object.defineProperty(exports,"TimeUnit",{enumerable:!0,get:function(){return _types.TimeUnit}}),Object.defineProperty(exports,"Utilities",{enumerable:!0,get:function(){return _utilities.Utilities}}),Object.defineProperty(exports,"Validator",{enumerable:!0,get:function(){return _validator.Validator}}),Object.defineProperty(exports,"VisitorDataFiltersType",{enumerable:!0,get:function(){return _types.VisitorDataFiltersType}});var _utilities=require("./utilities"),_listUtilities=require("./listUtilities"),_parser=require("./parser"),_validator=require("./validator"),_types=require("./types");
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { InsertInOrderedListParametersType } from '../utilities/types';
|
|
2
|
+
export declare class ListUtilities {
|
|
3
|
+
/**
|
|
4
|
+
* Insert element in ordered list, if element already exists in list, does nothing
|
|
5
|
+
* @param list - list to insert element
|
|
6
|
+
* @param element - element to insert
|
|
7
|
+
* @param order - order of list
|
|
8
|
+
*/
|
|
9
|
+
static insertInOrderedListMutably({ list, element, order, }: InsertInOrderedListParametersType): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var _types=require("./types");Object.defineProperty(exports,"__esModule",{value:!0}),exports.ListUtilities=void 0;class ListUtilities{static insertInOrderedListMutably(a){let{list:b,element:c,order:d}=a;if(!b.includes(c)){const a=b.findIndex(a=>d===_types.Order.Ascending?a>=c:a<=c);-1===a?b.push(c):b.splice(a,0,c)}}}exports.ListUtilities=ListUtilities;
|
|
@@ -5,7 +5,8 @@ import { KameleoonDataType, KameleoonVisitorDataType } from '../kameleoonData/ty
|
|
|
5
5
|
import { Requester } from '../requester';
|
|
6
6
|
import { GetVisitorDataResultType } from '../requester/types';
|
|
7
7
|
import { SegmentType } from '../targeting';
|
|
8
|
-
import {
|
|
8
|
+
import { TrackingCacheItemType } from '../types';
|
|
9
|
+
import { ExternalPackageInfoType } from '../sdkInfoTypes';
|
|
9
10
|
import { VariationConfiguration } from '../variationConfiguration';
|
|
10
11
|
import { MappingIdentifierType } from "../storage/types";
|
|
11
12
|
export type CheckTargetingParametersType = {
|
|
@@ -1,23 +1,17 @@
|
|
|
1
1
|
import { Result } from 'ts-res';
|
|
2
2
|
import { KameleoonError } from '../kameleoonError';
|
|
3
3
|
import { TrackingCacheItemType } from '../types';
|
|
4
|
-
import { CustomData
|
|
4
|
+
import { CustomData } from '../kameleoonData/customData';
|
|
5
|
+
import { KameleoonDataType } from '../kameleoonData/types';
|
|
5
6
|
import { CacheManager } from '../cacheManager';
|
|
6
|
-
import { VersionMatchType } from '../targeting';
|
|
7
|
-
import { CheckTargetingParametersType, ManageCacheParametersType,
|
|
7
|
+
import { VersionMatchType } from '../targeting/types';
|
|
8
|
+
import { CheckTargetingParametersType, ManageCacheParametersType, TimeUnit, IExternalPRNG } from './types';
|
|
8
9
|
import { VariationByExpositionType } from '../clientConfiguration/types';
|
|
9
10
|
export declare class Utilities {
|
|
10
11
|
static getNonce(prng: IExternalPRNG): string;
|
|
11
12
|
static checkTargeting({ segment, visitorCode, targetingData, experimentId, variationConfiguration, clientConfiguration, packageInfo, dataManager, }: CheckTargetingParametersType): Result<boolean, KameleoonError>;
|
|
12
13
|
static convertTimeUnit(time: number, timeUnit: TimeUnit): number;
|
|
13
14
|
static isCustomData(dataItem: KameleoonDataType): dataItem is CustomData;
|
|
14
|
-
/**
|
|
15
|
-
* Insert element in ordered list, if element already exists in list, does nothing
|
|
16
|
-
* @param list - list to insert element
|
|
17
|
-
* @param element - element to insert
|
|
18
|
-
* @param order - order of list
|
|
19
|
-
*/
|
|
20
|
-
static insertInOrderedListMutably({ list, element, order, }: InsertInOrderedListParametersType): void;
|
|
21
15
|
static updateCache({ hasJsCssVariables, cacheManager, visitorCode, experimentId, variationId, }: ManageCacheParametersType): void;
|
|
22
16
|
static getTrackingCode(trackingCache: CacheManager<TrackingCacheItemType>, visitorCode: string): string;
|
|
23
17
|
static compareSemVer({ version, compareVersion, operator, }: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Utilities=void 0;var _tsRes=require("ts-res"),_kameleoonError=require("../kameleoonError"),_types=require("../types"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Utilities=void 0;var _tsRes=require("ts-res"),_kameleoonError=require("../kameleoonError"),_types=require("../types"),_types2=require("../kameleoonData/types"),_constants=require("../constants"),_types3=require("../targeting/types"),_types4=require("./types"),_constants2=require("./constants"),_validator=require("./validator"),_logging=require("../logging");function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _defineProperty(a,b,c){return(b=_toPropertyKey(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||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){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)}class Utilities{static getNonce(a){let b="";for(let c=0;c<_constants2.NONCE_LENGTH;c++){const c=a.getRandomNumber(),d=Math.floor(c*_constants2.NONCE_LENGTH);b+=_constants2.HEX_CHARACTERS.charAt(d)}return b}static checkTargeting(a){let{segment:b,visitorCode:c,targetingData:d,experimentId:e,variationConfiguration:f,clientConfiguration:g,packageInfo:h,dataManager:i}=a;if(_logging.KameleoonLogger.debug`CALL: checkTargeting(segment, visitorCode: ${c}, targetingData: ${d}, experimentId: ${e}, variationConfiguration, clientConfiguration, packageInfo, dataManager)`,!b||!b.conditionsData.firstLevel.length){const a=(0,_tsRes.Ok)(!0);return _logging.KameleoonLogger.debug`RETURN checkTargeting(segment, visitorCode: ${c}, targetingData: ${d}, experimentId: ${e}, variationConfiguration, clientConfiguration, packageInfo, dataManager) -> (result: ${a})`,a}if(!f){const a=(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization));return _logging.KameleoonLogger.debug`RETURN checkTargeting(segment, visitorCode: ${c}, targetingData: ${d}, experimentId: ${e}, variationConfiguration, clientConfiguration, packageInfo, dataManager) -> (result: ${a})`,a}let j={};const k=f.getStoredVariations(c);k.ok&&(j=k.data);const l=i.getTree(b);let m,n,o;l.hasTargetingType(_types3.TargetingType.SEGMENT)&&(m=i.trees,o=g.segments),l.hasTargetingType(_types3.TargetingType.TARGET_FEATURE_FLAG)&&(n=g.ruleMap);const p=l.evaluate({variationData:j,sdkInfo:h,segments:o,ruleMap:n,trees:m,targetingData:d,experimentId:e,visitorCode:c});return _logging.KameleoonLogger.debug`RETURN checkTargeting(segment, visitorCode: ${c}, targetingData: ${d}, experimentId: ${e}, variationConfiguration, clientConfiguration, packageInfo, dataManager) -> (result: ${p})`,p}static convertTimeUnit(a,b){const c={[_types4.TimeUnit.Minute]:_types.Milliseconds.Minute,[_types4.TimeUnit.Hour]:_types.Milliseconds.Hour,[_types4.TimeUnit.Day]:_types.Milliseconds.Day,[_types4.TimeUnit.Week]:_types.Milliseconds.Week,[_types4.TimeUnit.Month]:_types.Milliseconds.Month};return a/c[b]}static isCustomData(a){return a.data.type===_types2.KameleoonData.CustomData}static updateCache(a){let{hasJsCssVariables:b,cacheManager:c,visitorCode:d,experimentId:e,variationId:f}=a;const g=c.getAliveItem(d),h=g?_objectSpread({},g):{};h[e]={variationId:f,hasJsCssVariables:b,expirationTime:Date.now()+_constants.CACHE_ITEM_LIFETIME*_types.Milliseconds.Second},c.add({key:d,data:h,lifetime:_constants.CACHE_ITEM_LIFETIME})}static getTrackingCode(a,b){let c="window.kameleoonQueue=window.kameleoonQueue||[];";const d=a.getAliveItem(b);if(!d)return c;const e={};return Object.entries(d).forEach(a=>{let[b,{variationId:d,expirationTime:f,hasJsCssVariables:g}]=a;f>Date.now()&&(c+=`window.kameleoonQueue.push(['Experiments.assignVariation',${b},${d},true]);`,c+=`window.kameleoonQueue.push(['Experiments.trigger',${b},${!g}]);`,e[+b]={variationId:d,expirationTime:f,hasJsCssVariables:g})}),a.add({key:b,data:e,lifetime:_constants.CACHE_ITEM_LIFETIME}),c}static compareSemVer(a){let{version:b,compareVersion:c,operator:d}=a;const e=_validator.Validator.validateVersion(b),f=_validator.Validator.validateVersion(c);if(!e.ok)return(0,_tsRes.Err)(e.error);if(!f.ok)return(0,_tsRes.Err)(f.error);const[g,h,i]=e.data,[j,k,l]=f.data,[m,n,o]=[g===j,h===k,i===l];switch(d){case _types3.VersionMatchType.EQUAL:return(0,_tsRes.Ok)(m&&n&&o);case _types3.VersionMatchType.GREATER:return(0,_tsRes.Ok)(g>j||m&&h>k||m&&n&&i>l);case _types3.VersionMatchType.LOWER:return(0,_tsRes.Ok)(g<j||m&&h<k||m&&n&&i<l);default:_logging.KameleoonLogger.error`Unknown version match type: ${d}`,(0,_kameleoonError.exhaustCheck)(d)}}static getVariationByHash(a,b){let c=0;for(const d of a)if(c+=d.exposition,c>=b)return d;return null}}exports.Utilities=Utilities;
|
|
@@ -3,4 +3,6 @@ import { KameleoonError } from '../kameleoonError';
|
|
|
3
3
|
export declare class Validator {
|
|
4
4
|
static validateVersion(version: string): Result<[number, number, number], KameleoonError>;
|
|
5
5
|
static validateDomain(domain: string | undefined): Result<string, void>;
|
|
6
|
+
static validateNetworkDomain(networkDomain: string | undefined): Result<string, void>;
|
|
7
|
+
private static checkAndTrimProtocol;
|
|
6
8
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Validator=void 0;var _tsRes=require("ts-res"),_kameleoonError=require("../kameleoonError"),_constants=require("./constants"),_logging=require("../logging");class Validator{static validateVersion(a){const b=a.split(".").map(a=>parseInt(a,10));for(;3>b.length;)b.push(0);return b.some(a=>isNaN(a))?(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.SemanticVersionParse,a)):(0,_tsRes.Ok)(b.slice(0,3))}static validateDomain(a){
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Validator=void 0;var _tsRes=require("ts-res"),_kameleoonError=require("../kameleoonError"),_constants=require("./constants"),_logging=require("../logging");class Validator{static validateVersion(a){const b=a.split(".").map(a=>parseInt(a,10));for(;3>b.length;)b.push(0);return b.some(a=>isNaN(a))?(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.SemanticVersionParse,a)):(0,_tsRes.Ok)(b.slice(0,3))}static validateDomain(a){return a?(a=Validator.checkAndTrimProtocol(a.toLowerCase()),_constants.REGEX_DOMAIN.test(a)||a===_constants.LOCALHOST?(0,_tsRes.Ok)(a):(_logging.KameleoonLogger.error`The top-level domain ${a} is invalid. The value has been set as provided, but it does not meet the required format for proper SDK functionality. Please check the domain for correctness.`,(0,_tsRes.Ok)(a))):(0,_tsRes.Err)()}static validateNetworkDomain(a){return a?(a=Validator.checkAndTrimProtocol(a.toLowerCase()),a=a.replace(/^\.+|\.+$/g,""),_constants.REGEX_DOMAIN.test(a)||a===_constants.LOCALHOST?(0,_tsRes.Ok)(a):(_logging.KameleoonLogger.error`The network domain ${a} is invalid.`,(0,_tsRes.Err)())):(0,_tsRes.Err)()}static checkAndTrimProtocol(a){const b=[_constants.HTTP,_constants.HTTPS];for(const c of b)if(a.startsWith(c)){a=a.substring(c.length),_logging.KameleoonLogger.warning`The domain contains ${c}. Domain after protocol trimming: ${a}`;break}return a}}exports.Validator=Validator;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ClientConfiguration, FeatureFlagType, RuleItemType } from '../clientConfiguration';
|
|
2
2
|
import { DataManager } from '../kameleoonData';
|
|
3
3
|
import { KameleoonVisitorDataType } from '../kameleoonData/types';
|
|
4
|
-
import {
|
|
4
|
+
import { TrackingStatus } from '../types';
|
|
5
|
+
import { ExternalPackageInfoType } from '../sdkInfoTypes';
|
|
5
6
|
export type UpdateDataStatusParametersType = {
|
|
6
7
|
visitorCode: string;
|
|
7
8
|
experimentIdList: string[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kameleoon/javascript-sdk-core",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.6.1",
|
|
4
4
|
"description": "Kameleoon JS SDK Core",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"test": "jest",
|
|
23
23
|
"test:watch": "jest --watch",
|
|
24
24
|
"test:coverage": "jest --coverage",
|
|
25
|
-
"lint": "eslint -c ../../eslint.config.js 'dist/**/*.js'"
|
|
25
|
+
"lint": "eslint -c ../../eslint.config.js 'dist/**/*.js'",
|
|
26
|
+
"madge": "madge -c ./dist"
|
|
26
27
|
},
|
|
27
28
|
"homepage": "https://developers.kameleoon.com/react-js-sdk.html",
|
|
28
29
|
"publishConfig": {
|