@convertcom/js-sdk-rules 1.0.2 → 2.1.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.
- package/README.md +2 -2
- package/lib/enums/index.d.ts +26 -0
- package/lib/enums/src/bucketing-error.d.ts +9 -0
- package/lib/enums/src/conversion-setting-key.d.ts +9 -0
- package/lib/enums/src/data-enitites.d.ts +16 -0
- package/lib/enums/src/dictionary.d.ts +65 -0
- package/lib/enums/src/do-not-track.d.ts +12 -0
- package/lib/enums/src/entity-type.d.ts +15 -0
- package/lib/enums/src/feature-status.d.ts +10 -0
- package/lib/enums/src/goal-data-key.d.ts +11 -0
- package/lib/enums/src/log-level.d.ts +14 -0
- package/lib/enums/src/log-method.d.ts +14 -0
- package/lib/enums/src/project-type.d.ts +10 -0
- package/lib/enums/src/rule-error.d.ts +10 -0
- package/lib/enums/src/segments/browser-type.d.ts +17 -0
- package/lib/enums/src/segments/device-type.d.ts +16 -0
- package/lib/enums/src/segments/segments-keys.d.ts +15 -0
- package/lib/enums/src/segments/source-type.d.ts +12 -0
- package/lib/enums/src/segments/visitor-type.d.ts +10 -0
- package/lib/enums/src/system-events.d.ts +22 -0
- package/lib/enums/src/variable-types.d.ts +7 -0
- package/lib/enums/src/variation-change-type.d.ts +14 -0
- package/lib/index.d.ts +10 -10
- package/lib/index.js +731 -33
- package/lib/index.js.map +1 -1
- package/lib/index.min.js +1 -1
- package/lib/index.min.js.map +1 -1
- package/lib/index.min.mjs +1 -1
- package/lib/index.min.mjs.map +1 -1
- package/lib/index.mjs +707 -9
- package/lib/index.mjs.map +1 -1
- package/lib/legacy/index.js +759 -140
- package/lib/legacy/index.js.map +1 -1
- package/lib/legacy/index.min.js +1 -1
- package/lib/legacy/index.min.js.map +1 -1
- package/lib/logger/index.d.ts +8 -0
- package/lib/logger/src/interfaces/log-client.d.ts +13 -0
- package/lib/logger/src/interfaces/log-manager.d.ts +18 -0
- package/lib/logger/src/interfaces/log-method-map.d.ts +15 -0
- package/lib/logger/src/log-manager.d.ts +64 -0
- package/lib/package.json +6 -6
- package/lib/rules/index.d.ts +8 -0
- package/lib/rules/src/interfaces/rule-manager.d.ts +14 -0
- package/lib/rules/src/rule-manager.d.ts +82 -0
- package/lib/types/index.d.ts +27 -0
- package/lib/types/src/BucketedFeature.d.ts +29 -0
- package/lib/types/src/BucketedVariation.d.ts +13 -0
- package/lib/types/src/BucketingAllocation.d.ts +10 -0
- package/lib/types/src/BucketingAttributes.d.ts +17 -0
- package/lib/types/src/BucketingHash.d.ts +11 -0
- package/lib/types/src/Config.d.ts +60 -0
- package/lib/types/src/ConversionAttributes.d.ts +13 -0
- package/lib/types/src/Entity.d.ts +8 -0
- package/lib/types/src/GoalData.d.ts +11 -0
- package/lib/types/src/IndentityField.d.ts +7 -0
- package/lib/types/src/Integration.d.ts +8 -0
- package/lib/types/src/LocationAttributes.d.ts +12 -0
- package/lib/types/src/Path.d.ts +10 -0
- package/lib/types/src/RequireAtLeastOne.d.ts +3 -0
- package/lib/types/src/Rule.d.ts +13 -0
- package/lib/types/src/SegmentsAttributes.d.ts +9 -0
- package/lib/types/src/StoreData.d.ts +13 -0
- package/lib/types/src/TrackingEvent.d.ts +14 -0
- package/lib/types/src/VariableType.d.ts +8 -0
- package/lib/types/src/Visitor.d.ts +12 -0
- package/lib/types/src/VisitorsQueue.d.ts +14 -0
- package/lib/types/src/config/index.d.ts +192 -0
- package/lib/types/src/config/models/Base64Image.d.ts +6 -0
- package/lib/types/src/config/models/BaseMatch.d.ts +8 -0
- package/lib/types/src/config/models/BaseRule.d.ts +6 -0
- package/lib/types/src/config/models/BaseRuleWithBooleanValue.d.ts +7 -0
- package/lib/types/src/config/models/BaseRuleWithBrowserNameValue.d.ts +21 -0
- package/lib/types/src/config/models/BaseRuleWithCountryCodeValue.d.ts +7 -0
- package/lib/types/src/config/models/BaseRuleWithDayOfWeekValue.d.ts +7 -0
- package/lib/types/src/config/models/BaseRuleWithExperienceBucketedValue.d.ts +7 -0
- package/lib/types/src/config/models/BaseRuleWithGoalTriggeredValue.d.ts +7 -0
- package/lib/types/src/config/models/BaseRuleWithHourOfDayValue.d.ts +7 -0
- package/lib/types/src/config/models/BaseRuleWithJsCodeValue.d.ts +9 -0
- package/lib/types/src/config/models/BaseRuleWithLanguageCodeValue.d.ts +7 -0
- package/lib/types/src/config/models/BaseRuleWithMinuteOfHourValue.d.ts +7 -0
- package/lib/types/src/config/models/BaseRuleWithNumericValue.d.ts +7 -0
- package/lib/types/src/config/models/BaseRuleWithOsValue.d.ts +21 -0
- package/lib/types/src/config/models/BaseRuleWithSegmentBucketedValue.d.ts +7 -0
- package/lib/types/src/config/models/BaseRuleWithStringValue.d.ts +7 -0
- package/lib/types/src/config/models/BaseRuleWithVisitorTypeValue.d.ts +16 -0
- package/lib/types/src/config/models/BaseRuleWithWeatherConditionValue.d.ts +34 -0
- package/lib/types/src/config/models/BoolMatchRulesTypes.d.ts +6 -0
- package/lib/types/src/config/models/BrowserNameMatchRule.d.ts +10 -0
- package/lib/types/src/config/models/BrowserNameMatchRulesTypes.d.ts +3 -0
- package/lib/types/src/config/models/BucketingEvent.d.ts +15 -0
- package/lib/types/src/config/models/ChoiceContainsOptions.d.ts +3 -0
- package/lib/types/src/config/models/ChoiceMatchingOptions.d.ts +3 -0
- package/lib/types/src/config/models/ClicksElementGoal.d.ts +11 -0
- package/lib/types/src/config/models/ClicksElementGoalSettings.d.ts +6 -0
- package/lib/types/src/config/models/ClicksLinkGoal.d.ts +11 -0
- package/lib/types/src/config/models/ClicksLinkGoalSettings.d.ts +6 -0
- package/lib/types/src/config/models/ConfigAudience.d.ts +21 -0
- package/lib/types/src/config/models/ConfigAudienceTypes.d.ts +10 -0
- package/lib/types/src/config/models/ConfigExperience.d.ts +98 -0
- package/lib/types/src/config/models/ConfigFeature.d.ts +22 -0
- package/lib/types/src/config/models/ConfigGoal.d.ts +9 -0
- package/lib/types/src/config/models/ConfigGoalBase.d.ts +24 -0
- package/lib/types/src/config/models/ConfigLocation.d.ts +21 -0
- package/lib/types/src/config/models/ConfigProject.d.ts +151 -0
- package/lib/types/src/config/models/ConfigResponseData.d.ts +45 -0
- package/lib/types/src/config/models/ConfigSegment.d.ts +19 -0
- package/lib/types/src/config/models/ConversionEvent.d.ts +30 -0
- package/lib/types/src/config/models/CookieMatchRule.d.ts +14 -0
- package/lib/types/src/config/models/CookieMatchRulesTypes.d.ts +3 -0
- package/lib/types/src/config/models/CountryMatchRule.d.ts +10 -0
- package/lib/types/src/config/models/CountryMatchRulesTypes.d.ts +3 -0
- package/lib/types/src/config/models/DayOfWeekMatchRule.d.ts +10 -0
- package/lib/types/src/config/models/DayOfWeekMatchRulesTypes.d.ts +4 -0
- package/lib/types/src/config/models/DomInteractionGoal.d.ts +11 -0
- package/lib/types/src/config/models/DomInteractionGoalSettings.d.ts +15 -0
- package/lib/types/src/config/models/ErrorData.d.ts +5 -0
- package/lib/types/src/config/models/ExperienceBucketedMatchRule.d.ts +9 -0
- package/lib/types/src/config/models/ExperienceChange.d.ts +10 -0
- package/lib/types/src/config/models/ExperienceChangeAdd.d.ts +10 -0
- package/lib/types/src/config/models/ExperienceChangeBase.d.ts +27 -0
- package/lib/types/src/config/models/ExperienceChangeCustomCodeData.d.ts +6 -0
- package/lib/types/src/config/models/ExperienceChangeCustomCodeDataAdd.d.ts +6 -0
- package/lib/types/src/config/models/ExperienceChangeCustomCodeDataBase.d.ts +29 -0
- package/lib/types/src/config/models/ExperienceChangeCustomCodeDataUpdate.d.ts +6 -0
- package/lib/types/src/config/models/ExperienceChangeCustomCodeDataUpdateNoId.d.ts +5 -0
- package/lib/types/src/config/models/ExperienceChangeDefaultCodeData.d.ts +6 -0
- package/lib/types/src/config/models/ExperienceChangeDefaultCodeDataAdd.d.ts +6 -0
- package/lib/types/src/config/models/ExperienceChangeDefaultCodeDataBase.d.ts +29 -0
- package/lib/types/src/config/models/ExperienceChangeDefaultCodeDataUpdate.d.ts +6 -0
- package/lib/types/src/config/models/ExperienceChangeDefaultCodeDataUpdateNoId.d.ts +5 -0
- package/lib/types/src/config/models/ExperienceChangeDefaultCodeMultipageData.d.ts +6 -0
- package/lib/types/src/config/models/ExperienceChangeDefaultCodeMultipageDataAdd.d.ts +6 -0
- package/lib/types/src/config/models/ExperienceChangeDefaultCodeMultipageDataBase.d.ts +33 -0
- package/lib/types/src/config/models/ExperienceChangeDefaultCodeMultipageDataUpdate.d.ts +6 -0
- package/lib/types/src/config/models/ExperienceChangeDefaultCodeMultipageDataUpdateNoId.d.ts +5 -0
- package/lib/types/src/config/models/ExperienceChangeDefaultRedirectData.d.ts +6 -0
- package/lib/types/src/config/models/ExperienceChangeDefaultRedirectDataAdd.d.ts +6 -0
- package/lib/types/src/config/models/ExperienceChangeDefaultRedirectDataBase.d.ts +29 -0
- package/lib/types/src/config/models/ExperienceChangeDefaultRedirectDataUpdate.d.ts +6 -0
- package/lib/types/src/config/models/ExperienceChangeDefaultRedirectDataUpdateNoId.d.ts +5 -0
- package/lib/types/src/config/models/ExperienceChangeFullStackFeature.d.ts +6 -0
- package/lib/types/src/config/models/ExperienceChangeFullStackFeatureAdd.d.ts +6 -0
- package/lib/types/src/config/models/ExperienceChangeFullStackFeatureBase.d.ts +25 -0
- package/lib/types/src/config/models/ExperienceChangeFullStackFeatureUpdate.d.ts +6 -0
- package/lib/types/src/config/models/ExperienceChangeFullStackFeatureUpdateNoId.d.ts +5 -0
- package/lib/types/src/config/models/ExperienceChangeId.d.ts +9 -0
- package/lib/types/src/config/models/ExperienceChangeIdReadOnly.d.ts +9 -0
- package/lib/types/src/config/models/ExperienceChangeRichStructureData.d.ts +6 -0
- package/lib/types/src/config/models/ExperienceChangeRichStructureDataAdd.d.ts +6 -0
- package/lib/types/src/config/models/ExperienceChangeRichStructureDataBase.d.ts +16 -0
- package/lib/types/src/config/models/ExperienceChangeRichStructureDataUpdate.d.ts +6 -0
- package/lib/types/src/config/models/ExperienceChangeRichStructureDataUpdateNoId.d.ts +5 -0
- package/lib/types/src/config/models/ExperienceChangeUpdate.d.ts +10 -0
- package/lib/types/src/config/models/ExperienceChangeUpdateNoId.d.ts +10 -0
- package/lib/types/src/config/models/ExperienceIntegrationBaidu.d.ts +7 -0
- package/lib/types/src/config/models/ExperienceIntegrationBase.d.ts +10 -0
- package/lib/types/src/config/models/ExperienceIntegrationClicktale.d.ts +2 -0
- package/lib/types/src/config/models/ExperienceIntegrationClicky.d.ts +2 -0
- package/lib/types/src/config/models/ExperienceIntegrationCnzz.d.ts +7 -0
- package/lib/types/src/config/models/ExperienceIntegrationCrazyegg.d.ts +9 -0
- package/lib/types/src/config/models/ExperienceIntegrationEconda.d.ts +2 -0
- package/lib/types/src/config/models/ExperienceIntegrationEulerian.d.ts +2 -0
- package/lib/types/src/config/models/ExperienceIntegrationGA3.d.ts +9 -0
- package/lib/types/src/config/models/ExperienceIntegrationGA4.d.ts +8 -0
- package/lib/types/src/config/models/ExperienceIntegrationGA4Base.d.ts +4 -0
- package/lib/types/src/config/models/ExperienceIntegrationGAServing.d.ts +3 -0
- package/lib/types/src/config/models/ExperienceIntegrationGoogleAnalytics.d.ts +3 -0
- package/lib/types/src/config/models/ExperienceIntegrationGosquared.d.ts +2 -0
- package/lib/types/src/config/models/ExperienceIntegrationHeapanalytics.d.ts +2 -0
- package/lib/types/src/config/models/ExperienceIntegrationHotjar.d.ts +2 -0
- package/lib/types/src/config/models/ExperienceIntegrationMixpanel.d.ts +2 -0
- package/lib/types/src/config/models/ExperienceIntegrationMouseflow.d.ts +2 -0
- package/lib/types/src/config/models/ExperienceIntegrationPiwik.d.ts +7 -0
- package/lib/types/src/config/models/ExperienceIntegrationSegmentio.d.ts +2 -0
- package/lib/types/src/config/models/ExperienceIntegrationSitecatalyst.d.ts +7 -0
- package/lib/types/src/config/models/ExperienceIntegrationWoopra.d.ts +2 -0
- package/lib/types/src/config/models/ExperienceIntegrationYsance.d.ts +7 -0
- package/lib/types/src/config/models/ExperienceTypes.d.ts +8 -0
- package/lib/types/src/config/models/ExperienceVariationConfig.d.ts +30 -0
- package/lib/types/src/config/models/Extra.d.ts +4 -0
- package/lib/types/src/config/models/FeatureVariableItemData.d.ts +25 -0
- package/lib/types/src/config/models/GA_Settings.d.ts +3 -0
- package/lib/types/src/config/models/GA_SettingsBase.d.ts +6 -0
- package/lib/types/src/config/models/GaGoal.d.ts +11 -0
- package/lib/types/src/config/models/GaGoalSettings.d.ts +6 -0
- package/lib/types/src/config/models/GenericBoolKeyValueMatchRule.d.ts +11 -0
- package/lib/types/src/config/models/GenericBoolKeyValueMatchRulesTypes.d.ts +3 -0
- package/lib/types/src/config/models/GenericBoolMatchRule.d.ts +10 -0
- package/lib/types/src/config/models/GenericKey.d.ts +6 -0
- package/lib/types/src/config/models/GenericNumericKeyValueMatchRule.d.ts +11 -0
- package/lib/types/src/config/models/GenericNumericKeyValueMatchRulesTypes.d.ts +3 -0
- package/lib/types/src/config/models/GenericNumericMatchRule.d.ts +10 -0
- package/lib/types/src/config/models/GenericSetMatchRule.d.ts +9 -0
- package/lib/types/src/config/models/GenericTextKeyValueMatchRule.d.ts +11 -0
- package/lib/types/src/config/models/GenericTextKeyValueMatchRulesTypes.d.ts +3 -0
- package/lib/types/src/config/models/GenericTextMatchRule.d.ts +10 -0
- package/lib/types/src/config/models/GoalTriggeredMatchRule.d.ts +10 -0
- package/lib/types/src/config/models/GoalTriggeredMatchRulesTypes.d.ts +3 -0
- package/lib/types/src/config/models/GoalTypes.d.ts +10 -0
- package/lib/types/src/config/models/HourOfDayMatchRule.d.ts +10 -0
- package/lib/types/src/config/models/HourOfDayMatchRulesTypes.d.ts +4 -0
- package/lib/types/src/config/models/IntegrationGA3.d.ts +12 -0
- package/lib/types/src/config/models/IntegrationGA4.d.ts +7 -0
- package/lib/types/src/config/models/IntegrationGA4Base.d.ts +12 -0
- package/lib/types/src/config/models/IntegrationProvider.d.ts +23 -0
- package/lib/types/src/config/models/JsConditionMatchRule.d.ts +10 -0
- package/lib/types/src/config/models/JsConditionMatchRulesTypes.d.ts +3 -0
- package/lib/types/src/config/models/KeyValueMatchRulesTypes.d.ts +4 -0
- package/lib/types/src/config/models/LanguageMatchRule.d.ts +10 -0
- package/lib/types/src/config/models/LanguageMatchRulesTypes.d.ts +3 -0
- package/lib/types/src/config/models/LocationTrigger.d.ts +5 -0
- package/lib/types/src/config/models/LocationTriggerBase.d.ts +14 -0
- package/lib/types/src/config/models/LocationTriggerCallback.d.ts +13 -0
- package/lib/types/src/config/models/LocationTriggerDomChange.d.ts +17 -0
- package/lib/types/src/config/models/LocationTriggerManual.d.ts +9 -0
- package/lib/types/src/config/models/LocationTriggerUrlChange.d.ts +9 -0
- package/lib/types/src/config/models/MinuteOfHourMatchRule.d.ts +10 -0
- package/lib/types/src/config/models/MinuteOfHourMatchRulesTypes.d.ts +4 -0
- package/lib/types/src/config/models/NoSettingsGoal.d.ts +11 -0
- package/lib/types/src/config/models/NumericMatchRulesTypes.d.ts +8 -0
- package/lib/types/src/config/models/NumericMatchingOptions.d.ts +5 -0
- package/lib/types/src/config/models/OnlyCount.d.ts +7 -0
- package/lib/types/src/config/models/OsMatchRule.d.ts +10 -0
- package/lib/types/src/config/models/OsMatchRulesTypes.d.ts +3 -0
- package/lib/types/src/config/models/PageNumber.d.ts +9 -0
- package/lib/types/src/config/models/Pagination.d.ts +18 -0
- package/lib/types/src/config/models/ProjectGASettingsBase.d.ts +7 -0
- package/lib/types/src/config/models/ProjectIntegrationGA3.d.ts +3 -0
- package/lib/types/src/config/models/ProjectIntegrationGA4.d.ts +8 -0
- package/lib/types/src/config/models/ResultsPerPage.d.ts +10 -0
- package/lib/types/src/config/models/RevenueGoal.d.ts +11 -0
- package/lib/types/src/config/models/RevenueGoalSettings.d.ts +25 -0
- package/lib/types/src/config/models/RuleElement.d.ts +20 -0
- package/lib/types/src/config/models/RuleElementNoUrl.d.ts +20 -0
- package/lib/types/src/config/models/RuleObject.d.ts +20 -0
- package/lib/types/src/config/models/RuleObjectNoUrl.d.ts +20 -0
- package/lib/types/src/config/models/RulesTypes.d.ts +17 -0
- package/lib/types/src/config/models/ScrollPercentageGoal.d.ts +11 -0
- package/lib/types/src/config/models/ScrollPercentageGoalSettings.d.ts +6 -0
- package/lib/types/src/config/models/SegmentBucketedMatchRule.d.ts +10 -0
- package/lib/types/src/config/models/SegmentBucketedMatchRulesTypes.d.ts +3 -0
- package/lib/types/src/config/models/SendTrackingEventsRequestData.d.ts +39 -0
- package/lib/types/src/config/models/SetMatchingOptions.d.ts +3 -0
- package/lib/types/src/config/models/SortDirection.d.ts +21 -0
- package/lib/types/src/config/models/SubmitsFormGoal.d.ts +11 -0
- package/lib/types/src/config/models/SubmitsFormGoalSettings.d.ts +6 -0
- package/lib/types/src/config/models/SuccessData.d.ts +4 -0
- package/lib/types/src/config/models/TextMatchRulesTypes.d.ts +23 -0
- package/lib/types/src/config/models/TextMatchingOptions.d.ts +7 -0
- package/lib/types/src/config/models/UTC_Offset.d.ts +4 -0
- package/lib/types/src/config/models/UpdateExperienceChangeRequestData.d.ts +2 -0
- package/lib/types/src/config/models/VariationStatuses.d.ts +7 -0
- package/lib/types/src/config/models/VisitorSegments.d.ts +78 -0
- package/lib/types/src/config/models/VisitorTrackingEvents.d.ts +21 -0
- package/lib/types/src/config/models/VisitorTypeMatchRule.d.ts +10 -0
- package/lib/types/src/config/models/VisitorTypeMatchRulesTypes.d.ts +3 -0
- package/lib/types/src/config/models/WeatherConditionMatchRule.d.ts +10 -0
- package/lib/types/src/config/models/WeatherConditionMatchRulesTypes.d.ts +3 -0
- package/lib/types/src/config/models/WeatherConditions.d.ts +30 -0
- package/lib/utils/index.d.ts +14 -0
- package/lib/utils/src/array-utils.d.ts +11 -0
- package/lib/utils/src/comparisons.d.ts +22 -0
- package/lib/utils/src/data-store.d.ts +39 -0
- package/lib/utils/src/file-logger.d.ts +40 -0
- package/lib/utils/src/http-client.d.ts +115 -0
- package/lib/utils/src/object-utils.d.ts +35 -0
- package/lib/utils/src/string-utils.d.ts +20 -0
- package/lib/utils/src/types-utils.d.ts +12 -0
- package/package.json +35 -31
package/lib/index.js
CHANGED
|
@@ -1,7 +1,705 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
/*!
|
|
4
|
+
* Convert JS SDK
|
|
5
|
+
* Version 1.0.0
|
|
6
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
7
|
+
* License Apache-2.0
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Validates variable is array and not empty
|
|
11
|
+
* @param array
|
|
12
|
+
*/
|
|
13
|
+
function arrayNotEmpty(array) {
|
|
14
|
+
return Array.isArray(array) && array.length > 0;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/*!
|
|
18
|
+
* Convert JS SDK
|
|
19
|
+
* Version 1.0.0
|
|
20
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
21
|
+
* License Apache-2.0
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Returns the value at path of object
|
|
25
|
+
* TODO: get this utility to work with the optional mapper() helper from config
|
|
26
|
+
* @param {Record<string, any>} object
|
|
27
|
+
* @param {string} path
|
|
28
|
+
* @param {any=} defaultValue
|
|
29
|
+
* @param {boolean=} truthy Should Number 0 number and Boolean false be considered as normal value
|
|
30
|
+
* @return {any}
|
|
31
|
+
*/
|
|
32
|
+
/**
|
|
33
|
+
* Validates variable is object and not empty
|
|
34
|
+
* @param object
|
|
35
|
+
*/
|
|
36
|
+
function objectNotEmpty(object) {
|
|
37
|
+
return (typeof object === 'object' &&
|
|
38
|
+
object !== null &&
|
|
39
|
+
Object.keys(object).length > 0);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/*!
|
|
43
|
+
* Convert JS SDK
|
|
44
|
+
* Version 1.0.0
|
|
45
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
46
|
+
* License Apache-2.0
|
|
47
|
+
*/
|
|
48
|
+
var _a;
|
|
49
|
+
/**
|
|
50
|
+
* Comparison Processor. Provides comparison methods for rules validation
|
|
51
|
+
*/
|
|
52
|
+
class Comparisons {
|
|
53
|
+
static equals(value, testAgainst, negation) {
|
|
54
|
+
if (Array.isArray(value))
|
|
55
|
+
return this._returnNegationCheck(value.indexOf(testAgainst) !== -1, negation);
|
|
56
|
+
if (objectNotEmpty(value))
|
|
57
|
+
return this._returnNegationCheck(Object.keys(value).indexOf(String(testAgainst)) !== -1, negation);
|
|
58
|
+
value = String(value);
|
|
59
|
+
testAgainst = String(testAgainst);
|
|
60
|
+
value = value.valueOf().toLowerCase();
|
|
61
|
+
testAgainst = testAgainst.valueOf().toLowerCase();
|
|
62
|
+
return this._returnNegationCheck(value === testAgainst, negation);
|
|
63
|
+
}
|
|
64
|
+
static less(value, testAgainst, negation) {
|
|
65
|
+
if (typeof value !== typeof testAgainst) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
return this._returnNegationCheck(value < testAgainst, negation);
|
|
69
|
+
}
|
|
70
|
+
static lessEqual(value, testAgainst, negation) {
|
|
71
|
+
if (typeof value !== typeof testAgainst) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
return this._returnNegationCheck(value <= testAgainst, negation);
|
|
75
|
+
}
|
|
76
|
+
static contains(value, testAgainst, negation) {
|
|
77
|
+
value = String(value);
|
|
78
|
+
testAgainst = String(testAgainst);
|
|
79
|
+
value = value.valueOf().toLowerCase();
|
|
80
|
+
testAgainst = testAgainst.valueOf().toLowerCase();
|
|
81
|
+
if (testAgainst.replace(/^([\s]*)|([\s]*)$/g, '').length === 0) {
|
|
82
|
+
return this._returnNegationCheck(true, negation);
|
|
83
|
+
}
|
|
84
|
+
return this._returnNegationCheck(value.indexOf(testAgainst) !== -1, negation);
|
|
85
|
+
}
|
|
86
|
+
static isIn(values, testAgainst, negation = false, splitter = '|') {
|
|
87
|
+
const matchedValuesArray = String(values)
|
|
88
|
+
.split(splitter)
|
|
89
|
+
.map((item) => {
|
|
90
|
+
return String(item);
|
|
91
|
+
});
|
|
92
|
+
if (typeof testAgainst === 'string') {
|
|
93
|
+
testAgainst = testAgainst.split(splitter);
|
|
94
|
+
}
|
|
95
|
+
if (!Array.isArray(testAgainst)) {
|
|
96
|
+
testAgainst = [];
|
|
97
|
+
}
|
|
98
|
+
testAgainst = testAgainst.map((item) => {
|
|
99
|
+
return String(item).valueOf().toLowerCase();
|
|
100
|
+
});
|
|
101
|
+
for (let i = 0; i < matchedValuesArray.length; i++) {
|
|
102
|
+
if (testAgainst.indexOf(matchedValuesArray[i]) !== -1) {
|
|
103
|
+
return this._returnNegationCheck(true, negation);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return this._returnNegationCheck(false, negation);
|
|
107
|
+
}
|
|
108
|
+
static startsWith(value, testAgainst, negation) {
|
|
109
|
+
value = String(value).valueOf().toLowerCase();
|
|
110
|
+
testAgainst = String(testAgainst).valueOf().toLowerCase();
|
|
111
|
+
return this._returnNegationCheck(value.indexOf(testAgainst) === 0, negation);
|
|
112
|
+
}
|
|
113
|
+
static endsWith(value, testAgainst, negation) {
|
|
114
|
+
value = String(value).valueOf().toLowerCase();
|
|
115
|
+
testAgainst = String(testAgainst).valueOf().toLowerCase();
|
|
116
|
+
return this._returnNegationCheck(value.indexOf(testAgainst, value.length - testAgainst.length) !== -1, negation);
|
|
117
|
+
}
|
|
118
|
+
static regexMatches(value, testAgainst, negation) {
|
|
119
|
+
value = String(value).valueOf().toLowerCase();
|
|
120
|
+
testAgainst = String(testAgainst).valueOf();
|
|
121
|
+
const regExp = new RegExp(testAgainst, 'i');
|
|
122
|
+
return this._returnNegationCheck(regExp.test(value), negation);
|
|
123
|
+
}
|
|
124
|
+
static _returnNegationCheck(value, negation = false) {
|
|
125
|
+
if (negation) {
|
|
126
|
+
return !value;
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
return value;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
_a = Comparisons;
|
|
134
|
+
Comparisons.equalsNumber = _a.equals;
|
|
135
|
+
Comparisons.matches = _a.equals;
|
|
136
|
+
|
|
137
|
+
/******************************************************************************
|
|
138
|
+
Copyright (c) Microsoft Corporation.
|
|
139
|
+
|
|
140
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
141
|
+
purpose with or without fee is hereby granted.
|
|
142
|
+
|
|
143
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
144
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
145
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
146
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
147
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
148
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
149
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
150
|
+
***************************************************************************** */
|
|
151
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
155
|
+
var e = new Error(message);
|
|
156
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
/*!
|
|
160
|
+
* Convert JS SDK
|
|
161
|
+
* Version 1.0.0
|
|
162
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
163
|
+
* License Apache-2.0
|
|
164
|
+
*/
|
|
165
|
+
var BucketingError;
|
|
166
|
+
(function (BucketingError) {
|
|
167
|
+
BucketingError["VARIAION_NOT_DECIDED"] = "convert.com_variation_not_decided";
|
|
168
|
+
})(BucketingError || (BucketingError = {}));
|
|
169
|
+
|
|
170
|
+
/*!
|
|
171
|
+
* Convert JS SDK
|
|
172
|
+
* Version 1.0.0
|
|
173
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
174
|
+
* License Apache-2.0
|
|
175
|
+
*/
|
|
176
|
+
var ConversionSettingKey;
|
|
177
|
+
(function (ConversionSettingKey) {
|
|
178
|
+
ConversionSettingKey["FORCE_MULTIPLE_TRANSACTIONS"] = "forceMultipleTransactions";
|
|
179
|
+
})(ConversionSettingKey || (ConversionSettingKey = {}));
|
|
180
|
+
|
|
181
|
+
/*!
|
|
182
|
+
* Convert JS SDK
|
|
183
|
+
* Version 1.0.0
|
|
184
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
185
|
+
* License Apache-2.0
|
|
186
|
+
*/
|
|
187
|
+
const ERROR_MESSAGES = {
|
|
188
|
+
SDK_KEY_MISSING: 'SDK key is missing',
|
|
189
|
+
DATA_OBJECT_MISSING: 'Data object is missing',
|
|
190
|
+
CONFIG_DATA_NOT_VALID: 'Config Data is not valid',
|
|
191
|
+
SDK_OR_DATA_OBJECT_REQUIRED: 'SDK key or Data object should be provided',
|
|
192
|
+
RULE_NOT_VALID: 'Provided rule is not valid',
|
|
193
|
+
RULE_DATA_NOT_VALID: 'Provided rule data is not valid',
|
|
194
|
+
RULE_MATCH_TYPE_NOT_SUPPORTED: 'Provided rule matching type "#" is not supported',
|
|
195
|
+
RULE_ERROR: 'Rule error',
|
|
196
|
+
DATA_STORE_NOT_VALID: 'DataStore object is not valid. It should contain get and set methods',
|
|
197
|
+
VISITOR_ID_REQUIRED: 'Visitor string string is not present',
|
|
198
|
+
GOAL_DATA_NOT_VALID: 'GoalData object is not valid',
|
|
199
|
+
UNABLE_TO_SELECT_BUCKET_FOR_VISITOR: 'Unable to bucket visitor',
|
|
200
|
+
UNABLE_TO_PERFORM_NETWORK_REQUEST: 'Unable to perform network request',
|
|
201
|
+
UNSUPPORTED_RESPONSE_TYPE: 'Unsupported response type'
|
|
202
|
+
};
|
|
203
|
+
const MESSAGES = {
|
|
204
|
+
CONFIG_DATA_UPDATED: 'Config Data updated',
|
|
205
|
+
CORE_CONSTRUCTOR: 'Core Manager constructor has been called',
|
|
206
|
+
CORE_INITIALIZED: 'Core Manager has been initialized',
|
|
207
|
+
EXPERIENCE_CONSTRUCTOR: 'Experience Manager constructor has been called',
|
|
208
|
+
EXPERIENCE_NOT_FOUND: 'Experience not found',
|
|
209
|
+
EXPERIENCE_RULES_MATCHED: 'Experience rules matched',
|
|
210
|
+
VARIATIONS_NOT_FOUND: 'Variations not found',
|
|
211
|
+
VARIATION_CHANGE_NOT_SUPPORTED: 'Variation change not supported',
|
|
212
|
+
FEATURE_CONSTRUCTOR: 'Feature Manager constructor has been called',
|
|
213
|
+
FEATURE_NOT_FOUND: 'Fullstack Feature not found',
|
|
214
|
+
FEATURE_VARIABLES_NOT_FOUND: 'Fullstack Feature Variables not found',
|
|
215
|
+
FEATURE_VARIABLES_TYPE_NOT_FOUND: 'Fullstack Feature Variables Type not found',
|
|
216
|
+
BUCKETING_CONSTRUCTOR: 'Bucketing Manager constructor has been called',
|
|
217
|
+
DATA_CONSTRUCTOR: 'Data Manager constructor has been called',
|
|
218
|
+
RULE_CONSTRUCTOR: 'Rule Manager constructor has been called',
|
|
219
|
+
PROCESSING_ENTITY: 'Processing #',
|
|
220
|
+
LOCATION_MATCH: 'Location # rule matched',
|
|
221
|
+
LOCATION_NOT_MATCH: 'Location does not match',
|
|
222
|
+
LOCATION_NOT_RESTRICTED: 'Location not restricted',
|
|
223
|
+
AUDIENCE_MATCH: 'Audience # rule matched',
|
|
224
|
+
AUDIENCE_NOT_MATCH: 'Audience does not match',
|
|
225
|
+
NON_PERMANENT_AUDIENCE_NOT_RESTRICTED: 'Non-Permanent Audience not restricted',
|
|
226
|
+
AUDIENCE_NOT_RESTRICTED: 'Audience not restricted',
|
|
227
|
+
SEGMENTATION_MATCH: 'Segmentation # rule matched',
|
|
228
|
+
SEGMENTATION_NOT_RESTRICTED: 'Segmentation not restricted',
|
|
229
|
+
RULE_NOT_MATCH: 'Rule does not match',
|
|
230
|
+
RULE_MATCH: 'Found matched rule at OR block #',
|
|
231
|
+
RULE_MATCH_AND: 'AND block rule macthed',
|
|
232
|
+
RULE_MATCH_START: 'About to evaluate rule #',
|
|
233
|
+
LOCATION_ACTIVATED: 'Location # activated',
|
|
234
|
+
LOCATION_DEACTIVATED: 'Location # deactivated',
|
|
235
|
+
BUCKETED_VISITOR_FOUND: 'Visitor is already bucketed for variation #',
|
|
236
|
+
BUCKETED_VISITOR_FORCED: 'Forcing variation #',
|
|
237
|
+
BUCKETED_VISITOR: 'Visitor is bucketed for variation #',
|
|
238
|
+
GOAL_NOT_FOUND: 'Goal not found',
|
|
239
|
+
GOAL_RULE_NOT_MATCH: 'Goal rule do not match',
|
|
240
|
+
GOAL_FOUND: 'Goal # already triggered',
|
|
241
|
+
SEGMENTS_NOT_FOUND: 'Segments not found',
|
|
242
|
+
SEGMENTS_RULE_NOT_MATCH: 'Segments rule do not match',
|
|
243
|
+
CUSTOM_SEGMENTS_KEY_FOUND: 'Custom segments key already set',
|
|
244
|
+
SEND_BEACON_SUCCESS: 'The user agent successfully queued the data for transfer'
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
/*!
|
|
248
|
+
* Convert JS SDK
|
|
249
|
+
* Version 1.0.0
|
|
250
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
251
|
+
* License Apache-2.0
|
|
252
|
+
*/
|
|
253
|
+
var DoNotTrack;
|
|
254
|
+
(function (DoNotTrack) {
|
|
255
|
+
DoNotTrack["OFF"] = "OFF";
|
|
256
|
+
DoNotTrack["EU_ONLY"] = "EU ONLY";
|
|
257
|
+
DoNotTrack["EEA_ONLY"] = "EEA ONLY";
|
|
258
|
+
DoNotTrack["WORLDWIDE"] = "Worldwide";
|
|
259
|
+
})(DoNotTrack || (DoNotTrack = {}));
|
|
260
|
+
|
|
261
|
+
/*!
|
|
262
|
+
* Convert JS SDK
|
|
263
|
+
* Version 1.0.0
|
|
264
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
265
|
+
* License Apache-2.0
|
|
266
|
+
*/
|
|
267
|
+
var EntityType;
|
|
268
|
+
(function (EntityType) {
|
|
269
|
+
EntityType["AUDIENCE"] = "audience";
|
|
270
|
+
EntityType["LOCATION"] = "location";
|
|
271
|
+
EntityType["SEGMENT"] = "segment";
|
|
272
|
+
EntityType["FEATURE"] = "feature";
|
|
273
|
+
EntityType["GOAL"] = "goal";
|
|
274
|
+
EntityType["EXPERIENCE"] = "experience";
|
|
275
|
+
EntityType["VARIATION"] = "variation";
|
|
276
|
+
})(EntityType || (EntityType = {}));
|
|
277
|
+
|
|
278
|
+
/*!
|
|
279
|
+
* Convert JS SDK
|
|
280
|
+
* Version 1.0.0
|
|
281
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
282
|
+
* License Apache-2.0
|
|
283
|
+
*/
|
|
284
|
+
var FeatureStatus;
|
|
285
|
+
(function (FeatureStatus) {
|
|
286
|
+
FeatureStatus["ENABLED"] = "enabled";
|
|
287
|
+
FeatureStatus["DISABLED"] = "disabled";
|
|
288
|
+
})(FeatureStatus || (FeatureStatus = {}));
|
|
289
|
+
|
|
290
|
+
/*!
|
|
291
|
+
* Convert JS SDK
|
|
292
|
+
* Version 1.0.0
|
|
293
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
294
|
+
* License Apache-2.0
|
|
295
|
+
*/
|
|
296
|
+
var GoalDataKey;
|
|
297
|
+
(function (GoalDataKey) {
|
|
298
|
+
GoalDataKey["AMOUNT"] = "amount";
|
|
299
|
+
GoalDataKey["PRODUCTS_COUNT"] = "productsCount";
|
|
300
|
+
GoalDataKey["TRANSACTION_ID"] = "transactionId";
|
|
301
|
+
})(GoalDataKey || (GoalDataKey = {}));
|
|
302
|
+
|
|
303
|
+
/*!
|
|
304
|
+
* Convert JS SDK
|
|
305
|
+
* Version 1.0.0
|
|
306
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
307
|
+
* License Apache-2.0
|
|
308
|
+
*/
|
|
309
|
+
var LogLevel;
|
|
310
|
+
(function (LogLevel) {
|
|
311
|
+
LogLevel[LogLevel["TRACE"] = 0] = "TRACE";
|
|
312
|
+
LogLevel[LogLevel["DEBUG"] = 1] = "DEBUG";
|
|
313
|
+
LogLevel[LogLevel["INFO"] = 2] = "INFO";
|
|
314
|
+
LogLevel[LogLevel["WARN"] = 3] = "WARN";
|
|
315
|
+
LogLevel[LogLevel["ERROR"] = 4] = "ERROR";
|
|
316
|
+
LogLevel[LogLevel["SILENT"] = 5] = "SILENT";
|
|
317
|
+
})(LogLevel || (LogLevel = {}));
|
|
318
|
+
|
|
319
|
+
/*!
|
|
320
|
+
* Convert JS SDK
|
|
321
|
+
* Version 1.0.0
|
|
322
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
323
|
+
* License Apache-2.0
|
|
324
|
+
*/
|
|
325
|
+
var LogMethod;
|
|
326
|
+
(function (LogMethod) {
|
|
327
|
+
LogMethod["LOG"] = "log";
|
|
328
|
+
LogMethod["TRACE"] = "trace";
|
|
329
|
+
LogMethod["DEBUG"] = "debug";
|
|
330
|
+
LogMethod["INFO"] = "info";
|
|
331
|
+
LogMethod["WARN"] = "warn";
|
|
332
|
+
LogMethod["ERROR"] = "error";
|
|
333
|
+
})(LogMethod || (LogMethod = {}));
|
|
334
|
+
|
|
335
|
+
/*!
|
|
336
|
+
* Convert JS SDK
|
|
337
|
+
* Version 1.0.0
|
|
338
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
339
|
+
* License Apache-2.0
|
|
340
|
+
*/
|
|
341
|
+
var ProjectType;
|
|
342
|
+
(function (ProjectType) {
|
|
343
|
+
ProjectType["WEB"] = "web";
|
|
344
|
+
ProjectType["FULLSTACK"] = "fullstack";
|
|
345
|
+
})(ProjectType || (ProjectType = {}));
|
|
346
|
+
|
|
347
|
+
/*!
|
|
348
|
+
* Convert JS SDK
|
|
349
|
+
* Version 1.0.0
|
|
350
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
351
|
+
* License Apache-2.0
|
|
352
|
+
*/
|
|
353
|
+
var RuleError;
|
|
354
|
+
(function (RuleError) {
|
|
355
|
+
RuleError["NO_DATA_FOUND"] = "convert.com_no_data_found";
|
|
356
|
+
RuleError["NEED_MORE_DATA"] = "convert.com_need_more_data";
|
|
357
|
+
})(RuleError || (RuleError = {}));
|
|
358
|
+
|
|
359
|
+
/*!
|
|
360
|
+
* Convert JS SDK
|
|
361
|
+
* Version 1.0.0
|
|
362
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
363
|
+
* License Apache-2.0
|
|
364
|
+
*/
|
|
365
|
+
/**
|
|
366
|
+
* SDK system events. Possible values: 'ready' | 'queue-released'
|
|
367
|
+
* or custom visitor's event
|
|
368
|
+
*/
|
|
369
|
+
var SystemEvents;
|
|
370
|
+
(function (SystemEvents) {
|
|
371
|
+
SystemEvents["READY"] = "ready";
|
|
372
|
+
SystemEvents["CONFIG_UPDATED"] = "config.updated";
|
|
373
|
+
SystemEvents["API_QUEUE_RELEASED"] = "api.queue.released";
|
|
374
|
+
SystemEvents["BUCKETING"] = "bucketing";
|
|
375
|
+
SystemEvents["CONVERSION"] = "conversion";
|
|
376
|
+
SystemEvents["SEGMENTS"] = "segments";
|
|
377
|
+
SystemEvents["LOCATION_ACTIVATED"] = "location.activated";
|
|
378
|
+
SystemEvents["LOCATION_DEACTIVATED"] = "location.deactivated";
|
|
379
|
+
SystemEvents["AUDIENCES"] = "audiences";
|
|
380
|
+
SystemEvents["DATA_STORE_QUEUE_RELEASED"] = "datastore.queue.released";
|
|
381
|
+
})(SystemEvents || (SystemEvents = {}));
|
|
382
|
+
|
|
383
|
+
/*!
|
|
384
|
+
* Convert JS SDK
|
|
385
|
+
* Version 1.0.0
|
|
386
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
387
|
+
* License Apache-2.0
|
|
388
|
+
*/
|
|
389
|
+
var VariationChangeType;
|
|
390
|
+
(function (VariationChangeType) {
|
|
391
|
+
VariationChangeType["RICH_STRUCTURE"] = "richStructure";
|
|
392
|
+
VariationChangeType["CUSTOM_CODE"] = "customCode";
|
|
393
|
+
VariationChangeType["DEFAULT_CODE"] = "defaultCode";
|
|
394
|
+
VariationChangeType["DEFAULT_CODE_MULTIPAGE"] = "defaultCodeMultipage";
|
|
395
|
+
VariationChangeType["DEFAULT_REDIRECT"] = "defaultRedirect";
|
|
396
|
+
VariationChangeType["FULLSTACK_FEATURE"] = "fullStackFeature";
|
|
397
|
+
})(VariationChangeType || (VariationChangeType = {}));
|
|
398
|
+
|
|
399
|
+
/*!
|
|
400
|
+
* Convert JS SDK
|
|
401
|
+
* Version 1.0.0
|
|
402
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
403
|
+
* License Apache-2.0
|
|
404
|
+
*/
|
|
405
|
+
var BrowserType;
|
|
406
|
+
(function (BrowserType) {
|
|
407
|
+
BrowserType["IE"] = "IE";
|
|
408
|
+
BrowserType["CH"] = "CH";
|
|
409
|
+
BrowserType["FF"] = "FF";
|
|
410
|
+
BrowserType["OP"] = "OP";
|
|
411
|
+
BrowserType["SF"] = "SF";
|
|
412
|
+
BrowserType["EDG"] = "EDG";
|
|
413
|
+
BrowserType["MO"] = "MO";
|
|
414
|
+
BrowserType["NS"] = "NS";
|
|
415
|
+
BrowserType["OTH"] = "OTH";
|
|
416
|
+
})(BrowserType || (BrowserType = {}));
|
|
417
|
+
|
|
418
|
+
/*!
|
|
419
|
+
* Convert JS SDK
|
|
420
|
+
* Version 1.0.0
|
|
421
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
422
|
+
* License Apache-2.0
|
|
423
|
+
*/
|
|
424
|
+
var DeviceType;
|
|
425
|
+
(function (DeviceType) {
|
|
426
|
+
DeviceType["ALLPH"] = "ALLPH";
|
|
427
|
+
DeviceType["IPH"] = "IPH";
|
|
428
|
+
DeviceType["OTHPH"] = "OTHPH";
|
|
429
|
+
DeviceType["ALLTAB"] = "ALLTAB";
|
|
430
|
+
DeviceType["IPAD"] = "IPAD";
|
|
431
|
+
DeviceType["OTHTAB"] = "OTHTAB";
|
|
432
|
+
DeviceType["DESK"] = "DESK";
|
|
433
|
+
DeviceType["OTHDEV"] = "OTHDEV";
|
|
434
|
+
})(DeviceType || (DeviceType = {}));
|
|
435
|
+
|
|
436
|
+
/*!
|
|
437
|
+
* Convert JS SDK
|
|
438
|
+
* Version 1.0.0
|
|
439
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
440
|
+
* License Apache-2.0
|
|
441
|
+
*/
|
|
442
|
+
var SegmentsKeys;
|
|
443
|
+
(function (SegmentsKeys) {
|
|
444
|
+
SegmentsKeys["COUNTRY"] = "country";
|
|
445
|
+
SegmentsKeys["BROWSER"] = "browser";
|
|
446
|
+
SegmentsKeys["DEVICES"] = "devices";
|
|
447
|
+
SegmentsKeys["SOURCE"] = "source";
|
|
448
|
+
SegmentsKeys["CAMPAIGN"] = "campaign";
|
|
449
|
+
SegmentsKeys["VISITOR_TYPE"] = "visitorType";
|
|
450
|
+
SegmentsKeys["CUSTOM_SEGMENTS"] = "customSegments";
|
|
451
|
+
})(SegmentsKeys || (SegmentsKeys = {}));
|
|
452
|
+
|
|
453
|
+
/*!
|
|
454
|
+
* Convert JS SDK
|
|
455
|
+
* Version 1.0.0
|
|
456
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
457
|
+
* License Apache-2.0
|
|
458
|
+
*/
|
|
459
|
+
var SourceType;
|
|
460
|
+
(function (SourceType) {
|
|
461
|
+
SourceType["CAMPAIGN"] = "campaign";
|
|
462
|
+
SourceType["SEARCH"] = "search";
|
|
463
|
+
SourceType["REFERRAL"] = "referral";
|
|
464
|
+
SourceType["DIRECT"] = "direct";
|
|
465
|
+
})(SourceType || (SourceType = {}));
|
|
466
|
+
|
|
467
|
+
/*!
|
|
468
|
+
* Convert JS SDK
|
|
469
|
+
* Version 1.0.0
|
|
470
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
471
|
+
* License Apache-2.0
|
|
472
|
+
*/
|
|
473
|
+
var VisitorType;
|
|
474
|
+
(function (VisitorType) {
|
|
475
|
+
VisitorType["NEW"] = "new";
|
|
476
|
+
VisitorType["RETURNING"] = "returning";
|
|
477
|
+
})(VisitorType || (VisitorType = {}));
|
|
478
|
+
|
|
479
|
+
/*!
|
|
480
|
+
* Convert JS SDK
|
|
481
|
+
* Version 1.0.0
|
|
482
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
483
|
+
* License Apache-2.0
|
|
484
|
+
*/
|
|
485
|
+
var HttpStatusCode;
|
|
486
|
+
(function (HttpStatusCode) {
|
|
487
|
+
HttpStatusCode[HttpStatusCode["Continue"] = 100] = "Continue";
|
|
488
|
+
HttpStatusCode[HttpStatusCode["SwitchingProtocols"] = 101] = "SwitchingProtocols";
|
|
489
|
+
HttpStatusCode[HttpStatusCode["Processing"] = 102] = "Processing";
|
|
490
|
+
HttpStatusCode[HttpStatusCode["EarlyHints"] = 103] = "EarlyHints";
|
|
491
|
+
HttpStatusCode[HttpStatusCode["Ok"] = 200] = "Ok";
|
|
492
|
+
HttpStatusCode[HttpStatusCode["Created"] = 201] = "Created";
|
|
493
|
+
HttpStatusCode[HttpStatusCode["Accepted"] = 202] = "Accepted";
|
|
494
|
+
HttpStatusCode[HttpStatusCode["NonAuthoritativeInformation"] = 203] = "NonAuthoritativeInformation";
|
|
495
|
+
HttpStatusCode[HttpStatusCode["NoContent"] = 204] = "NoContent";
|
|
496
|
+
HttpStatusCode[HttpStatusCode["ResetContent"] = 205] = "ResetContent";
|
|
497
|
+
HttpStatusCode[HttpStatusCode["PartialContent"] = 206] = "PartialContent";
|
|
498
|
+
HttpStatusCode[HttpStatusCode["MultiStatus"] = 207] = "MultiStatus";
|
|
499
|
+
HttpStatusCode[HttpStatusCode["AlreadyReported"] = 208] = "AlreadyReported";
|
|
500
|
+
HttpStatusCode[HttpStatusCode["ImUsed"] = 226] = "ImUsed";
|
|
501
|
+
HttpStatusCode[HttpStatusCode["MultipleChoices"] = 300] = "MultipleChoices";
|
|
502
|
+
HttpStatusCode[HttpStatusCode["MovedPermanently"] = 301] = "MovedPermanently";
|
|
503
|
+
HttpStatusCode[HttpStatusCode["Found"] = 302] = "Found";
|
|
504
|
+
HttpStatusCode[HttpStatusCode["SeeOther"] = 303] = "SeeOther";
|
|
505
|
+
HttpStatusCode[HttpStatusCode["NotModified"] = 304] = "NotModified";
|
|
506
|
+
HttpStatusCode[HttpStatusCode["UseProxy"] = 305] = "UseProxy";
|
|
507
|
+
HttpStatusCode[HttpStatusCode["Unused"] = 306] = "Unused";
|
|
508
|
+
HttpStatusCode[HttpStatusCode["TemporaryRedirect"] = 307] = "TemporaryRedirect";
|
|
509
|
+
HttpStatusCode[HttpStatusCode["PermanentRedirect"] = 308] = "PermanentRedirect";
|
|
510
|
+
HttpStatusCode[HttpStatusCode["BadRequest"] = 400] = "BadRequest";
|
|
511
|
+
HttpStatusCode[HttpStatusCode["Unauthorized"] = 401] = "Unauthorized";
|
|
512
|
+
HttpStatusCode[HttpStatusCode["PaymentRequired"] = 402] = "PaymentRequired";
|
|
513
|
+
HttpStatusCode[HttpStatusCode["Forbidden"] = 403] = "Forbidden";
|
|
514
|
+
HttpStatusCode[HttpStatusCode["NotFound"] = 404] = "NotFound";
|
|
515
|
+
HttpStatusCode[HttpStatusCode["MethodNotAllowed"] = 405] = "MethodNotAllowed";
|
|
516
|
+
HttpStatusCode[HttpStatusCode["NotAcceptable"] = 406] = "NotAcceptable";
|
|
517
|
+
HttpStatusCode[HttpStatusCode["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired";
|
|
518
|
+
HttpStatusCode[HttpStatusCode["RequestTimeout"] = 408] = "RequestTimeout";
|
|
519
|
+
HttpStatusCode[HttpStatusCode["Conflict"] = 409] = "Conflict";
|
|
520
|
+
HttpStatusCode[HttpStatusCode["Gone"] = 410] = "Gone";
|
|
521
|
+
HttpStatusCode[HttpStatusCode["LengthRequired"] = 411] = "LengthRequired";
|
|
522
|
+
HttpStatusCode[HttpStatusCode["PreconditionFailed"] = 412] = "PreconditionFailed";
|
|
523
|
+
HttpStatusCode[HttpStatusCode["PayloadTooLarge"] = 413] = "PayloadTooLarge";
|
|
524
|
+
HttpStatusCode[HttpStatusCode["UriTooLong"] = 414] = "UriTooLong";
|
|
525
|
+
HttpStatusCode[HttpStatusCode["UnsupportedMediaType"] = 415] = "UnsupportedMediaType";
|
|
526
|
+
HttpStatusCode[HttpStatusCode["RangeNotSatisfiable"] = 416] = "RangeNotSatisfiable";
|
|
527
|
+
HttpStatusCode[HttpStatusCode["ExpectationFailed"] = 417] = "ExpectationFailed";
|
|
528
|
+
HttpStatusCode[HttpStatusCode["ImATeapot"] = 418] = "ImATeapot";
|
|
529
|
+
HttpStatusCode[HttpStatusCode["MisdirectedRequest"] = 421] = "MisdirectedRequest";
|
|
530
|
+
HttpStatusCode[HttpStatusCode["UnprocessableEntity"] = 422] = "UnprocessableEntity";
|
|
531
|
+
HttpStatusCode[HttpStatusCode["Locked"] = 423] = "Locked";
|
|
532
|
+
HttpStatusCode[HttpStatusCode["FailedDependency"] = 424] = "FailedDependency";
|
|
533
|
+
HttpStatusCode[HttpStatusCode["TooEarly"] = 425] = "TooEarly";
|
|
534
|
+
HttpStatusCode[HttpStatusCode["UpgradeRequired"] = 426] = "UpgradeRequired";
|
|
535
|
+
HttpStatusCode[HttpStatusCode["PreconditionRequired"] = 428] = "PreconditionRequired";
|
|
536
|
+
HttpStatusCode[HttpStatusCode["TooManyRequests"] = 429] = "TooManyRequests";
|
|
537
|
+
HttpStatusCode[HttpStatusCode["RequestHeaderFieldsTooLarge"] = 431] = "RequestHeaderFieldsTooLarge";
|
|
538
|
+
HttpStatusCode[HttpStatusCode["UnavailableForLegalReasons"] = 451] = "UnavailableForLegalReasons";
|
|
539
|
+
HttpStatusCode[HttpStatusCode["InternalServerError"] = 500] = "InternalServerError";
|
|
540
|
+
HttpStatusCode[HttpStatusCode["NotImplemented"] = 501] = "NotImplemented";
|
|
541
|
+
HttpStatusCode[HttpStatusCode["BadGateway"] = 502] = "BadGateway";
|
|
542
|
+
HttpStatusCode[HttpStatusCode["ServiceUnavailable"] = 503] = "ServiceUnavailable";
|
|
543
|
+
HttpStatusCode[HttpStatusCode["GatewayTimeout"] = 504] = "GatewayTimeout";
|
|
544
|
+
HttpStatusCode[HttpStatusCode["HttpVersionNotSupported"] = 505] = "HttpVersionNotSupported";
|
|
545
|
+
HttpStatusCode[HttpStatusCode["VariantAlsoNegotiates"] = 506] = "VariantAlsoNegotiates";
|
|
546
|
+
HttpStatusCode[HttpStatusCode["InsufficientStorage"] = 507] = "InsufficientStorage";
|
|
547
|
+
HttpStatusCode[HttpStatusCode["LoopDetected"] = 508] = "LoopDetected";
|
|
548
|
+
HttpStatusCode[HttpStatusCode["NotExtended"] = 510] = "NotExtended";
|
|
549
|
+
HttpStatusCode[HttpStatusCode["NetworkAuthenticationRequired"] = 511] = "NetworkAuthenticationRequired";
|
|
550
|
+
})(HttpStatusCode || (HttpStatusCode = {}));
|
|
551
|
+
|
|
552
|
+
var murmurhash = {exports: {}};
|
|
553
|
+
|
|
554
|
+
(function (module) {
|
|
555
|
+
(function(){
|
|
556
|
+
|
|
557
|
+
const createBuffer = (val) => new TextEncoder().encode(val);
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* JS Implementation of MurmurHash2
|
|
561
|
+
*
|
|
562
|
+
* @author <a href="mailto:gary.court@gmail.com">Gary Court</a>
|
|
563
|
+
* @see http://github.com/garycourt/murmurhash-js
|
|
564
|
+
* @author <a href="mailto:aappleby@gmail.com">Austin Appleby</a>
|
|
565
|
+
* @see http://sites.google.com/site/murmurhash/
|
|
566
|
+
*
|
|
567
|
+
* @param {Uint8Array | string} str ASCII only
|
|
568
|
+
* @param {number} seed Positive integer only
|
|
569
|
+
* @return {number} 32-bit positive integer hash
|
|
570
|
+
*/
|
|
571
|
+
function MurmurHashV2(str, seed) {
|
|
572
|
+
if (typeof str === 'string') str = createBuffer(str);
|
|
573
|
+
let
|
|
574
|
+
l = str.length,
|
|
575
|
+
h = seed ^ l,
|
|
576
|
+
i = 0,
|
|
577
|
+
k;
|
|
578
|
+
|
|
579
|
+
while (l >= 4) {
|
|
580
|
+
k =
|
|
581
|
+
((str[i] & 0xff)) |
|
|
582
|
+
((str[++i] & 0xff) << 8) |
|
|
583
|
+
((str[++i] & 0xff) << 16) |
|
|
584
|
+
((str[++i] & 0xff) << 24);
|
|
585
|
+
|
|
586
|
+
k = (((k & 0xffff) * 0x5bd1e995) + ((((k >>> 16) * 0x5bd1e995) & 0xffff) << 16));
|
|
587
|
+
k ^= k >>> 24;
|
|
588
|
+
k = (((k & 0xffff) * 0x5bd1e995) + ((((k >>> 16) * 0x5bd1e995) & 0xffff) << 16));
|
|
589
|
+
|
|
590
|
+
h = (((h & 0xffff) * 0x5bd1e995) + ((((h >>> 16) * 0x5bd1e995) & 0xffff) << 16)) ^ k;
|
|
591
|
+
|
|
592
|
+
l -= 4;
|
|
593
|
+
++i;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
switch (l) {
|
|
597
|
+
case 3: h ^= (str[i + 2] & 0xff) << 16;
|
|
598
|
+
case 2: h ^= (str[i + 1] & 0xff) << 8;
|
|
599
|
+
case 1: h ^= (str[i] & 0xff);
|
|
600
|
+
h = (((h & 0xffff) * 0x5bd1e995) + ((((h >>> 16) * 0x5bd1e995) & 0xffff) << 16));
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
h ^= h >>> 13;
|
|
604
|
+
h = (((h & 0xffff) * 0x5bd1e995) + ((((h >>> 16) * 0x5bd1e995) & 0xffff) << 16));
|
|
605
|
+
h ^= h >>> 15;
|
|
606
|
+
|
|
607
|
+
return h >>> 0;
|
|
608
|
+
}
|
|
609
|
+
/*
|
|
610
|
+
* JS Implementation of MurmurHash3 (r136) (as of May 20, 2011)
|
|
611
|
+
*
|
|
612
|
+
* @author <a href="mailto:gary.court@gmail.com">Gary Court</a>
|
|
613
|
+
* @see http://github.com/garycourt/murmurhash-js
|
|
614
|
+
* @author <a href="mailto:aappleby@gmail.com">Austin Appleby</a>
|
|
615
|
+
* @see http://sites.google.com/site/murmurhash/
|
|
616
|
+
*
|
|
617
|
+
* @param {Uint8Array | string} key ASCII only
|
|
618
|
+
* @param {number} seed Positive integer only
|
|
619
|
+
* @return {number} 32-bit positive integer hash
|
|
620
|
+
*/
|
|
621
|
+
function MurmurHashV3(key, seed) {
|
|
622
|
+
if (typeof key === 'string') key = createBuffer(key);
|
|
623
|
+
|
|
624
|
+
let remainder, bytes, h1, h1b, c1, c2, k1, i;
|
|
625
|
+
|
|
626
|
+
remainder = key.length & 3; // key.length % 4
|
|
627
|
+
bytes = key.length - remainder;
|
|
628
|
+
h1 = seed;
|
|
629
|
+
c1 = 0xcc9e2d51;
|
|
630
|
+
c2 = 0x1b873593;
|
|
631
|
+
i = 0;
|
|
632
|
+
|
|
633
|
+
while (i < bytes) {
|
|
634
|
+
k1 =
|
|
635
|
+
((key[i] & 0xff)) |
|
|
636
|
+
((key[++i] & 0xff) << 8) |
|
|
637
|
+
((key[++i] & 0xff) << 16) |
|
|
638
|
+
((key[++i] & 0xff) << 24);
|
|
639
|
+
++i;
|
|
640
|
+
|
|
641
|
+
k1 = ((((k1 & 0xffff) * c1) + ((((k1 >>> 16) * c1) & 0xffff) << 16))) & 0xffffffff;
|
|
642
|
+
k1 = (k1 << 15) | (k1 >>> 17);
|
|
643
|
+
k1 = ((((k1 & 0xffff) * c2) + ((((k1 >>> 16) * c2) & 0xffff) << 16))) & 0xffffffff;
|
|
644
|
+
|
|
645
|
+
h1 ^= k1;
|
|
646
|
+
h1 = (h1 << 13) | (h1 >>> 19);
|
|
647
|
+
h1b = ((((h1 & 0xffff) * 5) + ((((h1 >>> 16) * 5) & 0xffff) << 16))) & 0xffffffff;
|
|
648
|
+
h1 = (((h1b & 0xffff) + 0x6b64) + ((((h1b >>> 16) + 0xe654) & 0xffff) << 16));
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
k1 = 0;
|
|
652
|
+
|
|
653
|
+
switch (remainder) {
|
|
654
|
+
case 3: k1 ^= (key[i + 2] & 0xff) << 16;
|
|
655
|
+
case 2: k1 ^= (key[i + 1] & 0xff) << 8;
|
|
656
|
+
case 1: k1 ^= (key[i] & 0xff);
|
|
657
|
+
|
|
658
|
+
k1 = (((k1 & 0xffff) * c1) + ((((k1 >>> 16) * c1) & 0xffff) << 16)) & 0xffffffff;
|
|
659
|
+
k1 = (k1 << 15) | (k1 >>> 17);
|
|
660
|
+
k1 = (((k1 & 0xffff) * c2) + ((((k1 >>> 16) * c2) & 0xffff) << 16)) & 0xffffffff;
|
|
661
|
+
h1 ^= k1;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
h1 ^= key.length;
|
|
665
|
+
|
|
666
|
+
h1 ^= h1 >>> 16;
|
|
667
|
+
h1 = (((h1 & 0xffff) * 0x85ebca6b) + ((((h1 >>> 16) * 0x85ebca6b) & 0xffff) << 16)) & 0xffffffff;
|
|
668
|
+
h1 ^= h1 >>> 13;
|
|
669
|
+
h1 = ((((h1 & 0xffff) * 0xc2b2ae35) + ((((h1 >>> 16) * 0xc2b2ae35) & 0xffff) << 16))) & 0xffffffff;
|
|
670
|
+
h1 ^= h1 >>> 16;
|
|
671
|
+
|
|
672
|
+
return h1 >>> 0;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
const murmur = MurmurHashV3;
|
|
676
|
+
murmur.v2 = MurmurHashV2;
|
|
677
|
+
murmur.v3 = MurmurHashV3;
|
|
678
|
+
|
|
679
|
+
{
|
|
680
|
+
module.exports = murmur;
|
|
681
|
+
}
|
|
682
|
+
}());
|
|
683
|
+
} (murmurhash));
|
|
684
|
+
|
|
685
|
+
/*!
|
|
686
|
+
* Convert JS SDK
|
|
687
|
+
* Version 1.0.0
|
|
688
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
689
|
+
* License Apache-2.0
|
|
690
|
+
*/
|
|
691
|
+
/**
|
|
692
|
+
* String formatter tool. Transforms a space-separated string into camelCase
|
|
693
|
+
* @param {string} input
|
|
694
|
+
* @return {string}
|
|
695
|
+
*/
|
|
696
|
+
function camelCase(input) {
|
|
697
|
+
return input
|
|
698
|
+
.replace(/(?:^\w|[A-Z]|\b\w)/g, function (word, index) {
|
|
699
|
+
return index === 0 ? word.toLowerCase() : word.toUpperCase();
|
|
700
|
+
})
|
|
701
|
+
.replace(/\s+/g, '');
|
|
702
|
+
}
|
|
5
703
|
|
|
6
704
|
/*!
|
|
7
705
|
* Convert JS SDK
|
|
@@ -25,17 +723,17 @@ class RuleManager {
|
|
|
25
723
|
*/
|
|
26
724
|
constructor(config, { loggerManager } = {}) {
|
|
27
725
|
var _a, _b, _c, _d, _e;
|
|
28
|
-
this._comparisonProcessor =
|
|
726
|
+
this._comparisonProcessor = Comparisons;
|
|
29
727
|
this._negation = DEFAULT_NEGATION;
|
|
30
728
|
this._keys_case_sensitive = DEFAULT_KEYS_CASE_SENSITIVE;
|
|
31
729
|
this._loggerManager = loggerManager;
|
|
32
730
|
this._comparisonProcessor =
|
|
33
|
-
((_a = config === null || config === void 0 ? void 0 : config.rules) === null || _a === void 0 ? void 0 : _a.comparisonProcessor) ||
|
|
731
|
+
((_a = config === null || config === void 0 ? void 0 : config.rules) === null || _a === void 0 ? void 0 : _a.comparisonProcessor) || Comparisons;
|
|
34
732
|
this._negation = String(((_b = config === null || config === void 0 ? void 0 : config.rules) === null || _b === void 0 ? void 0 : _b.negation) || DEFAULT_NEGATION);
|
|
35
733
|
this._keys_case_sensitive =
|
|
36
734
|
((_c = config === null || config === void 0 ? void 0 : config.rules) === null || _c === void 0 ? void 0 : _c.keys_case_sensitive) || DEFAULT_KEYS_CASE_SENSITIVE;
|
|
37
735
|
this._mapper = (config === null || config === void 0 ? void 0 : config.mapper) || ((value) => value);
|
|
38
|
-
(_e = (_d = this._loggerManager) === null || _d === void 0 ? void 0 : _d.trace) === null || _e === void 0 ? void 0 : _e.call(_d, 'RuleManager()',
|
|
736
|
+
(_e = (_d = this._loggerManager) === null || _d === void 0 ? void 0 : _d.trace) === null || _e === void 0 ? void 0 : _e.call(_d, 'RuleManager()', MESSAGES.RULE_CONSTRUCTOR, this);
|
|
39
737
|
}
|
|
40
738
|
/**
|
|
41
739
|
* Setter for comparison processor
|
|
@@ -60,7 +758,7 @@ class RuleManager {
|
|
|
60
758
|
/**
|
|
61
759
|
* Check input data matching to rule set
|
|
62
760
|
* @param {Record<string, any>} data Single value or key-value data set to compare
|
|
63
|
-
* @param {
|
|
761
|
+
* @param {RuleObject} ruleSet
|
|
64
762
|
* @return {boolean | RuleError}
|
|
65
763
|
*/
|
|
66
764
|
isRuleMatched(data, ruleSet, logEntry) {
|
|
@@ -70,21 +768,21 @@ class RuleManager {
|
|
|
70
768
|
ruleSet: ruleSet
|
|
71
769
|
}));
|
|
72
770
|
if (logEntry) {
|
|
73
|
-
(_d = (_c = this._loggerManager) === null || _c === void 0 ? void 0 : _c.info) === null || _d === void 0 ? void 0 : _d.call(_c, 'RuleManager.isRuleMatched()',
|
|
771
|
+
(_d = (_c = this._loggerManager) === null || _c === void 0 ? void 0 : _c.info) === null || _d === void 0 ? void 0 : _d.call(_c, 'RuleManager.isRuleMatched()', MESSAGES.PROCESSING_ENTITY.replace('#', logEntry));
|
|
74
772
|
}
|
|
75
773
|
// Top OR level
|
|
76
774
|
let match;
|
|
77
775
|
if (Object.prototype.hasOwnProperty.call(ruleSet, 'OR') &&
|
|
78
|
-
|
|
776
|
+
arrayNotEmpty(ruleSet === null || ruleSet === void 0 ? void 0 : ruleSet.OR)) {
|
|
79
777
|
for (let i = 0, l = ruleSet.OR.length; i < l; i++) {
|
|
80
778
|
match = this._processAND(data, ruleSet.OR[i]);
|
|
81
|
-
if (Object.values(
|
|
82
|
-
(_f = (_e = this._loggerManager) === null || _e === void 0 ? void 0 : _e.info) === null || _f === void 0 ? void 0 : _f.call(_e, 'RuleManager.isRuleMatched()', logEntry || '',
|
|
779
|
+
if (Object.values(RuleError).includes(match)) {
|
|
780
|
+
(_f = (_e = this._loggerManager) === null || _e === void 0 ? void 0 : _e.info) === null || _f === void 0 ? void 0 : _f.call(_e, 'RuleManager.isRuleMatched()', logEntry || '', ERROR_MESSAGES.RULE_ERROR);
|
|
83
781
|
}
|
|
84
782
|
else {
|
|
85
783
|
(_h = (_g = this._loggerManager) === null || _g === void 0 ? void 0 : _g.info) === null || _h === void 0 ? void 0 : _h.call(_g, 'RuleManager.isRuleMatched()', logEntry || '', match === false
|
|
86
|
-
?
|
|
87
|
-
:
|
|
784
|
+
? MESSAGES.RULE_NOT_MATCH
|
|
785
|
+
: MESSAGES.RULE_MATCH.replace('#', String(i)));
|
|
88
786
|
}
|
|
89
787
|
if (match !== false) {
|
|
90
788
|
return match;
|
|
@@ -92,13 +790,13 @@ class RuleManager {
|
|
|
92
790
|
}
|
|
93
791
|
}
|
|
94
792
|
else {
|
|
95
|
-
(_k = (_j = this._loggerManager) === null || _j === void 0 ? void 0 : _j.warn) === null || _k === void 0 ? void 0 : _k.call(_j, 'RuleManager.isRuleMatched()', logEntry || '',
|
|
793
|
+
(_k = (_j = this._loggerManager) === null || _j === void 0 ? void 0 : _j.warn) === null || _k === void 0 ? void 0 : _k.call(_j, 'RuleManager.isRuleMatched()', logEntry || '', ERROR_MESSAGES.RULE_NOT_VALID);
|
|
96
794
|
}
|
|
97
795
|
return false;
|
|
98
796
|
}
|
|
99
797
|
/**
|
|
100
798
|
* Check is rule object valid
|
|
101
|
-
* @param {
|
|
799
|
+
* @param {RuleElement} rule
|
|
102
800
|
* @return {boolean}
|
|
103
801
|
*/
|
|
104
802
|
isValidRule(rule) {
|
|
@@ -126,7 +824,7 @@ class RuleManager {
|
|
|
126
824
|
// Second AND level
|
|
127
825
|
let match;
|
|
128
826
|
if (Object.prototype.hasOwnProperty.call(rulesSubset, 'AND') &&
|
|
129
|
-
|
|
827
|
+
arrayNotEmpty(rulesSubset === null || rulesSubset === void 0 ? void 0 : rulesSubset.AND)) {
|
|
130
828
|
for (let i = 0, l = rulesSubset.AND.length; i < l; i++) {
|
|
131
829
|
match = this._processORWHEN(data, rulesSubset.AND[i]);
|
|
132
830
|
if (match === false) {
|
|
@@ -134,12 +832,12 @@ class RuleManager {
|
|
|
134
832
|
}
|
|
135
833
|
}
|
|
136
834
|
if (match !== false) {
|
|
137
|
-
(_b = (_a = this._loggerManager) === null || _a === void 0 ? void 0 : _a.info) === null || _b === void 0 ? void 0 : _b.call(_a, 'RuleManager._processAND()',
|
|
835
|
+
(_b = (_a = this._loggerManager) === null || _a === void 0 ? void 0 : _a.info) === null || _b === void 0 ? void 0 : _b.call(_a, 'RuleManager._processAND()', MESSAGES.RULE_MATCH_AND);
|
|
138
836
|
}
|
|
139
837
|
return match;
|
|
140
838
|
}
|
|
141
839
|
else {
|
|
142
|
-
(_d = (_c = this._loggerManager) === null || _c === void 0 ? void 0 : _c.warn) === null || _d === void 0 ? void 0 : _d.call(_c, 'RuleManager._processAND()',
|
|
840
|
+
(_d = (_c = this._loggerManager) === null || _c === void 0 ? void 0 : _c.warn) === null || _d === void 0 ? void 0 : _d.call(_c, 'RuleManager._processAND()', ERROR_MESSAGES.RULE_NOT_VALID);
|
|
143
841
|
}
|
|
144
842
|
return false;
|
|
145
843
|
}
|
|
@@ -155,7 +853,7 @@ class RuleManager {
|
|
|
155
853
|
// Third OR level. Called OR_WHEN.
|
|
156
854
|
let match;
|
|
157
855
|
if (Object.prototype.hasOwnProperty.call(rulesSubset, 'OR_WHEN') &&
|
|
158
|
-
|
|
856
|
+
arrayNotEmpty(rulesSubset === null || rulesSubset === void 0 ? void 0 : rulesSubset.OR_WHEN)) {
|
|
159
857
|
for (let i = 0, l = rulesSubset.OR_WHEN.length; i < l; i++) {
|
|
160
858
|
match = this._processRuleItem(data, rulesSubset.OR_WHEN[i]);
|
|
161
859
|
if (match !== false) {
|
|
@@ -164,14 +862,14 @@ class RuleManager {
|
|
|
164
862
|
}
|
|
165
863
|
}
|
|
166
864
|
else {
|
|
167
|
-
(_b = (_a = this._loggerManager) === null || _a === void 0 ? void 0 : _a.warn) === null || _b === void 0 ? void 0 : _b.call(_a, 'RuleManager._processORWHEN()',
|
|
865
|
+
(_b = (_a = this._loggerManager) === null || _a === void 0 ? void 0 : _a.warn) === null || _b === void 0 ? void 0 : _b.call(_a, 'RuleManager._processORWHEN()', ERROR_MESSAGES.RULE_NOT_VALID);
|
|
168
866
|
}
|
|
169
867
|
return false;
|
|
170
868
|
}
|
|
171
869
|
/**
|
|
172
870
|
* Process single rule item
|
|
173
871
|
* @param {Record<string, any>} data Single value or key-value data set to compare
|
|
174
|
-
* @param {
|
|
872
|
+
* @param {RuleElement} rule A single rule to compare
|
|
175
873
|
* @return {boolean | RuleError} Comparison result
|
|
176
874
|
* @private
|
|
177
875
|
*/
|
|
@@ -185,17 +883,17 @@ class RuleManager {
|
|
|
185
883
|
if (data && typeof data === 'object') {
|
|
186
884
|
// Validate data key-value set.
|
|
187
885
|
if (this.isUsingCustomInterface(data)) {
|
|
188
|
-
//
|
|
886
|
+
// RuleElement object has to have `rule_type` field
|
|
189
887
|
if (rule === null || rule === void 0 ? void 0 : rule.rule_type) {
|
|
190
|
-
(_b = (_a = this._loggerManager) === null || _a === void 0 ? void 0 : _a.info) === null || _b === void 0 ? void 0 : _b.call(_a, 'RuleManager._processRuleItem()',
|
|
888
|
+
(_b = (_a = this._loggerManager) === null || _a === void 0 ? void 0 : _a.info) === null || _b === void 0 ? void 0 : _b.call(_a, 'RuleManager._processRuleItem()', MESSAGES.RULE_MATCH_START.replace('#', rule.rule_type));
|
|
191
889
|
for (const method of Object.getOwnPropertyNames(data.constructor.prototype)) {
|
|
192
890
|
if (method === 'constructor')
|
|
193
891
|
continue;
|
|
194
|
-
const rule_method =
|
|
892
|
+
const rule_method = camelCase(`get ${rule.rule_type.replace(/_/g, ' ')}`);
|
|
195
893
|
if (method === rule_method ||
|
|
196
894
|
((_c = data === null || data === void 0 ? void 0 : data.mapper) === null || _c === void 0 ? void 0 : _c.call(data, method)) === rule_method) {
|
|
197
895
|
const dataValue = data[method](rule);
|
|
198
|
-
if (Object.values(
|
|
896
|
+
if (Object.values(RuleError).includes(dataValue))
|
|
199
897
|
return dataValue;
|
|
200
898
|
if (rule.rule_type === 'js_condition')
|
|
201
899
|
return dataValue;
|
|
@@ -204,13 +902,13 @@ class RuleManager {
|
|
|
204
902
|
}
|
|
205
903
|
}
|
|
206
904
|
}
|
|
207
|
-
else if (
|
|
208
|
-
//
|
|
905
|
+
else if (objectNotEmpty(data)) {
|
|
906
|
+
// only handle RuleElement with a `key` field
|
|
209
907
|
for (const key of Object.keys(data)) {
|
|
210
908
|
const k = this._keys_case_sensitive ? key : key.toLowerCase();
|
|
211
909
|
const rule_k = this._keys_case_sensitive
|
|
212
|
-
? rule
|
|
213
|
-
: rule
|
|
910
|
+
? rule['key']
|
|
911
|
+
: String(rule['key']).toLowerCase();
|
|
214
912
|
if (k === rule_k) {
|
|
215
913
|
return this._comparisonProcessor[matching](data[key], rule.value, negation);
|
|
216
914
|
}
|
|
@@ -218,21 +916,21 @@ class RuleManager {
|
|
|
218
916
|
}
|
|
219
917
|
else {
|
|
220
918
|
(_e = (_d = this._loggerManager) === null || _d === void 0 ? void 0 : _d.trace) === null || _e === void 0 ? void 0 : _e.call(_d, 'RuleManager._processRuleItem()', {
|
|
221
|
-
warn:
|
|
919
|
+
warn: ERROR_MESSAGES.RULE_DATA_NOT_VALID,
|
|
222
920
|
data
|
|
223
921
|
});
|
|
224
922
|
}
|
|
225
923
|
}
|
|
226
924
|
else {
|
|
227
925
|
(_g = (_f = this._loggerManager) === null || _f === void 0 ? void 0 : _f.trace) === null || _g === void 0 ? void 0 : _g.call(_f, 'RuleManager._processRuleItem()', {
|
|
228
|
-
warn:
|
|
926
|
+
warn: ERROR_MESSAGES.RULE_NOT_VALID,
|
|
229
927
|
data,
|
|
230
928
|
rule
|
|
231
929
|
});
|
|
232
930
|
}
|
|
233
931
|
}
|
|
234
932
|
else {
|
|
235
|
-
(_j = (_h = this._loggerManager) === null || _h === void 0 ? void 0 : _h.warn) === null || _j === void 0 ? void 0 : _j.call(_h, 'RuleManager._processRuleItem()',
|
|
933
|
+
(_j = (_h = this._loggerManager) === null || _h === void 0 ? void 0 : _h.warn) === null || _j === void 0 ? void 0 : _j.call(_h, 'RuleManager._processRuleItem()', ERROR_MESSAGES.RULE_MATCH_TYPE_NOT_SUPPORTED.replace('#', matching));
|
|
236
934
|
}
|
|
237
935
|
}
|
|
238
936
|
catch (error) {
|
|
@@ -242,7 +940,7 @@ class RuleManager {
|
|
|
242
940
|
}
|
|
243
941
|
}
|
|
244
942
|
else {
|
|
245
|
-
(_o = (_m = this._loggerManager) === null || _m === void 0 ? void 0 : _m.warn) === null || _o === void 0 ? void 0 : _o.call(_m, 'RuleManager._processRuleItem()',
|
|
943
|
+
(_o = (_m = this._loggerManager) === null || _m === void 0 ? void 0 : _m.warn) === null || _o === void 0 ? void 0 : _o.call(_m, 'RuleManager._processRuleItem()', ERROR_MESSAGES.RULE_NOT_VALID);
|
|
246
944
|
}
|
|
247
945
|
return false;
|
|
248
946
|
}
|
|
@@ -252,7 +950,7 @@ class RuleManager {
|
|
|
252
950
|
* @return {boolean}
|
|
253
951
|
*/
|
|
254
952
|
isUsingCustomInterface(data) {
|
|
255
|
-
return (
|
|
953
|
+
return (objectNotEmpty(data) &&
|
|
256
954
|
Object.prototype.hasOwnProperty.call(data, 'name') &&
|
|
257
955
|
data.name === 'RuleData');
|
|
258
956
|
}
|