@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/legacy/index.js
CHANGED
|
@@ -1,7 +1,138 @@
|
|
|
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;
|
|
5
136
|
|
|
6
137
|
/******************************************************************************
|
|
7
138
|
Copyright (c) Microsoft Corporation.
|
|
@@ -20,105 +151,615 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
20
151
|
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
21
152
|
|
|
22
153
|
|
|
23
|
-
function __values(o) {
|
|
24
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
25
|
-
if (m) return m.call(o);
|
|
26
|
-
if (o && typeof o.length === "number") return {
|
|
27
|
-
next: function () {
|
|
28
|
-
if (o && i >= o.length) o = void 0;
|
|
29
|
-
return { value: o && o[i++], done: !o };
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
33
|
-
}
|
|
34
|
-
|
|
35
154
|
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
36
155
|
var e = new Error(message);
|
|
37
156
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
38
157
|
};
|
|
39
158
|
|
|
40
|
-
|
|
41
|
-
|
|
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
|
+
const createBuffer = val => new TextEncoder().encode(val);
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* JS Implementation of MurmurHash2
|
|
560
|
+
*
|
|
561
|
+
* @author <a href="mailto:gary.court@gmail.com">Gary Court</a>
|
|
562
|
+
* @see http://github.com/garycourt/murmurhash-js
|
|
563
|
+
* @author <a href="mailto:aappleby@gmail.com">Austin Appleby</a>
|
|
564
|
+
* @see http://sites.google.com/site/murmurhash/
|
|
565
|
+
*
|
|
566
|
+
* @param {Uint8Array | string} str ASCII only
|
|
567
|
+
* @param {number} seed Positive integer only
|
|
568
|
+
* @return {number} 32-bit positive integer hash
|
|
569
|
+
*/
|
|
570
|
+
function MurmurHashV2(str, seed) {
|
|
571
|
+
if (typeof str === 'string') str = createBuffer(str);
|
|
572
|
+
let l = str.length,
|
|
573
|
+
h = seed ^ l,
|
|
574
|
+
i = 0,
|
|
575
|
+
k;
|
|
576
|
+
while (l >= 4) {
|
|
577
|
+
k = str[i] & 0xff | (str[++i] & 0xff) << 8 | (str[++i] & 0xff) << 16 | (str[++i] & 0xff) << 24;
|
|
578
|
+
k = (k & 0xffff) * 0x5bd1e995 + (((k >>> 16) * 0x5bd1e995 & 0xffff) << 16);
|
|
579
|
+
k ^= k >>> 24;
|
|
580
|
+
k = (k & 0xffff) * 0x5bd1e995 + (((k >>> 16) * 0x5bd1e995 & 0xffff) << 16);
|
|
581
|
+
h = (h & 0xffff) * 0x5bd1e995 + (((h >>> 16) * 0x5bd1e995 & 0xffff) << 16) ^ k;
|
|
582
|
+
l -= 4;
|
|
583
|
+
++i;
|
|
584
|
+
}
|
|
585
|
+
switch (l) {
|
|
586
|
+
case 3:
|
|
587
|
+
h ^= (str[i + 2] & 0xff) << 16;
|
|
588
|
+
case 2:
|
|
589
|
+
h ^= (str[i + 1] & 0xff) << 8;
|
|
590
|
+
case 1:
|
|
591
|
+
h ^= str[i] & 0xff;
|
|
592
|
+
h = (h & 0xffff) * 0x5bd1e995 + (((h >>> 16) * 0x5bd1e995 & 0xffff) << 16);
|
|
593
|
+
}
|
|
594
|
+
h ^= h >>> 13;
|
|
595
|
+
h = (h & 0xffff) * 0x5bd1e995 + (((h >>> 16) * 0x5bd1e995 & 0xffff) << 16);
|
|
596
|
+
h ^= h >>> 15;
|
|
597
|
+
return h >>> 0;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
/*
|
|
601
|
+
* JS Implementation of MurmurHash3 (r136) (as of May 20, 2011)
|
|
602
|
+
*
|
|
603
|
+
* @author <a href="mailto:gary.court@gmail.com">Gary Court</a>
|
|
604
|
+
* @see http://github.com/garycourt/murmurhash-js
|
|
605
|
+
* @author <a href="mailto:aappleby@gmail.com">Austin Appleby</a>
|
|
606
|
+
* @see http://sites.google.com/site/murmurhash/
|
|
607
|
+
*
|
|
608
|
+
* @param {Uint8Array | string} key ASCII only
|
|
609
|
+
* @param {number} seed Positive integer only
|
|
610
|
+
* @return {number} 32-bit positive integer hash
|
|
611
|
+
*/
|
|
612
|
+
function MurmurHashV3(key, seed) {
|
|
613
|
+
if (typeof key === 'string') key = createBuffer(key);
|
|
614
|
+
let remainder, bytes, h1, h1b, c1, c2, k1, i;
|
|
615
|
+
remainder = key.length & 3; // key.length % 4
|
|
616
|
+
bytes = key.length - remainder;
|
|
617
|
+
h1 = seed;
|
|
618
|
+
c1 = 0xcc9e2d51;
|
|
619
|
+
c2 = 0x1b873593;
|
|
620
|
+
i = 0;
|
|
621
|
+
while (i < bytes) {
|
|
622
|
+
k1 = key[i] & 0xff | (key[++i] & 0xff) << 8 | (key[++i] & 0xff) << 16 | (key[++i] & 0xff) << 24;
|
|
623
|
+
++i;
|
|
624
|
+
k1 = (k1 & 0xffff) * c1 + (((k1 >>> 16) * c1 & 0xffff) << 16) & 0xffffffff;
|
|
625
|
+
k1 = k1 << 15 | k1 >>> 17;
|
|
626
|
+
k1 = (k1 & 0xffff) * c2 + (((k1 >>> 16) * c2 & 0xffff) << 16) & 0xffffffff;
|
|
627
|
+
h1 ^= k1;
|
|
628
|
+
h1 = h1 << 13 | h1 >>> 19;
|
|
629
|
+
h1b = (h1 & 0xffff) * 5 + (((h1 >>> 16) * 5 & 0xffff) << 16) & 0xffffffff;
|
|
630
|
+
h1 = (h1b & 0xffff) + 0x6b64 + (((h1b >>> 16) + 0xe654 & 0xffff) << 16);
|
|
631
|
+
}
|
|
632
|
+
k1 = 0;
|
|
633
|
+
switch (remainder) {
|
|
634
|
+
case 3:
|
|
635
|
+
k1 ^= (key[i + 2] & 0xff) << 16;
|
|
636
|
+
case 2:
|
|
637
|
+
k1 ^= (key[i + 1] & 0xff) << 8;
|
|
638
|
+
case 1:
|
|
639
|
+
k1 ^= key[i] & 0xff;
|
|
640
|
+
k1 = (k1 & 0xffff) * c1 + (((k1 >>> 16) * c1 & 0xffff) << 16) & 0xffffffff;
|
|
641
|
+
k1 = k1 << 15 | k1 >>> 17;
|
|
642
|
+
k1 = (k1 & 0xffff) * c2 + (((k1 >>> 16) * c2 & 0xffff) << 16) & 0xffffffff;
|
|
643
|
+
h1 ^= k1;
|
|
644
|
+
}
|
|
645
|
+
h1 ^= key.length;
|
|
646
|
+
h1 ^= h1 >>> 16;
|
|
647
|
+
h1 = (h1 & 0xffff) * 0x85ebca6b + (((h1 >>> 16) * 0x85ebca6b & 0xffff) << 16) & 0xffffffff;
|
|
648
|
+
h1 ^= h1 >>> 13;
|
|
649
|
+
h1 = (h1 & 0xffff) * 0xc2b2ae35 + (((h1 >>> 16) * 0xc2b2ae35 & 0xffff) << 16) & 0xffffffff;
|
|
650
|
+
h1 ^= h1 >>> 16;
|
|
651
|
+
return h1 >>> 0;
|
|
652
|
+
}
|
|
653
|
+
const murmur = MurmurHashV3;
|
|
654
|
+
murmur.v2 = MurmurHashV2;
|
|
655
|
+
murmur.v3 = MurmurHashV3;
|
|
656
|
+
{
|
|
657
|
+
module.exports = murmur;
|
|
658
|
+
}
|
|
659
|
+
})();
|
|
660
|
+
})(murmurhash);
|
|
661
|
+
|
|
662
|
+
/*!
|
|
663
|
+
* Convert JS SDK
|
|
664
|
+
* Version 1.0.0
|
|
665
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
666
|
+
* License Apache-2.0
|
|
667
|
+
*/
|
|
668
|
+
/**
|
|
669
|
+
* String formatter tool. Transforms a space-separated string into camelCase
|
|
670
|
+
* @param {string} input
|
|
671
|
+
* @return {string}
|
|
672
|
+
*/
|
|
673
|
+
function camelCase(input) {
|
|
674
|
+
return input
|
|
675
|
+
.replace(/(?:^\w|[A-Z]|\b\w)/g, function (word, index) {
|
|
676
|
+
return index === 0 ? word.toLowerCase() : word.toUpperCase();
|
|
677
|
+
})
|
|
678
|
+
.replace(/\s+/g, '');
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
/*!
|
|
682
|
+
* Convert JS SDK
|
|
683
|
+
* Version 1.0.0
|
|
684
|
+
* Copyright(c) 2020 Convert Insights, Inc
|
|
685
|
+
* License Apache-2.0
|
|
686
|
+
*/
|
|
687
|
+
const DEFAULT_KEYS_CASE_SENSITIVE = true;
|
|
688
|
+
const DEFAULT_NEGATION = '!';
|
|
42
689
|
/**
|
|
43
690
|
* Provides rule processing calculations with corresponding comparisons methods
|
|
44
691
|
* @category Modules
|
|
45
692
|
* @constructor
|
|
46
693
|
* @implements {RuleManagerInterface}
|
|
47
694
|
*/
|
|
48
|
-
|
|
695
|
+
class RuleManager {
|
|
49
696
|
/**
|
|
50
697
|
* @param {Config=} config
|
|
51
698
|
* @param {Object=} dependencies
|
|
52
699
|
* @param {LogManagerInterface=} dependencies.loggerManager
|
|
53
700
|
*/
|
|
54
|
-
|
|
55
|
-
var
|
|
56
|
-
|
|
57
|
-
this._comparisonProcessor = jsSdkUtils.Comparisons;
|
|
701
|
+
constructor(config, { loggerManager } = {}) {
|
|
702
|
+
var _a, _b, _c, _d, _e;
|
|
703
|
+
this._comparisonProcessor = Comparisons;
|
|
58
704
|
this._negation = DEFAULT_NEGATION;
|
|
59
705
|
this._keys_case_sensitive = DEFAULT_KEYS_CASE_SENSITIVE;
|
|
60
706
|
this._loggerManager = loggerManager;
|
|
61
707
|
this._comparisonProcessor =
|
|
62
|
-
((
|
|
63
|
-
this._negation = String(((
|
|
708
|
+
((_a = config === null || config === void 0 ? void 0 : config.rules) === null || _a === void 0 ? void 0 : _a.comparisonProcessor) || Comparisons;
|
|
709
|
+
this._negation = String(((_b = config === null || config === void 0 ? void 0 : config.rules) === null || _b === void 0 ? void 0 : _b.negation) || DEFAULT_NEGATION);
|
|
64
710
|
this._keys_case_sensitive =
|
|
65
|
-
((
|
|
66
|
-
this._mapper = (config === null || config === void 0 ? void 0 : config.mapper) || (
|
|
67
|
-
(
|
|
711
|
+
((_c = config === null || config === void 0 ? void 0 : config.rules) === null || _c === void 0 ? void 0 : _c.keys_case_sensitive) || DEFAULT_KEYS_CASE_SENSITIVE;
|
|
712
|
+
this._mapper = (config === null || config === void 0 ? void 0 : config.mapper) || ((value) => value);
|
|
713
|
+
(_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);
|
|
714
|
+
}
|
|
715
|
+
/**
|
|
716
|
+
* Setter for comparison processor
|
|
717
|
+
* @param {Record<string, any>} comparisonProcessor
|
|
718
|
+
*/
|
|
719
|
+
set comparisonProcessor(comparisonProcessor) {
|
|
720
|
+
this._comparisonProcessor = comparisonProcessor;
|
|
721
|
+
}
|
|
722
|
+
/**
|
|
723
|
+
* Getter for comparison processor
|
|
724
|
+
*/
|
|
725
|
+
get comparisonProcessor() {
|
|
726
|
+
return this._comparisonProcessor;
|
|
68
727
|
}
|
|
69
|
-
Object.defineProperty(RuleManager.prototype, "comparisonProcessor", {
|
|
70
|
-
/**
|
|
71
|
-
* Getter for comparison processor
|
|
72
|
-
*/
|
|
73
|
-
get: function () {
|
|
74
|
-
return this._comparisonProcessor;
|
|
75
|
-
},
|
|
76
|
-
/**
|
|
77
|
-
* Setter for comparison processor
|
|
78
|
-
* @param {Record<string, any>} comparisonProcessor
|
|
79
|
-
*/
|
|
80
|
-
set: function (comparisonProcessor) {
|
|
81
|
-
this._comparisonProcessor = comparisonProcessor;
|
|
82
|
-
},
|
|
83
|
-
enumerable: false,
|
|
84
|
-
configurable: true
|
|
85
|
-
});
|
|
86
728
|
/**
|
|
87
729
|
* Retrieve comparison methods from comparison processor
|
|
88
730
|
* @return {Array<string>} List of methods of comparison processor
|
|
89
731
|
*/
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
};
|
|
732
|
+
getComparisonProcessorMethods() {
|
|
733
|
+
return Object.getOwnPropertyNames(this._comparisonProcessor).filter((name) => typeof this._comparisonProcessor[name] === 'function');
|
|
734
|
+
}
|
|
94
735
|
/**
|
|
95
736
|
* Check input data matching to rule set
|
|
96
737
|
* @param {Record<string, any>} data Single value or key-value data set to compare
|
|
97
|
-
* @param {
|
|
738
|
+
* @param {RuleObject} ruleSet
|
|
98
739
|
* @return {boolean | RuleError}
|
|
99
740
|
*/
|
|
100
|
-
|
|
741
|
+
isRuleMatched(data, ruleSet, logEntry) {
|
|
101
742
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
102
743
|
(_b = (_a = this._loggerManager) === null || _a === void 0 ? void 0 : _a.trace) === null || _b === void 0 ? void 0 : _b.call(_a, 'RuleManager.isRuleMatched()', this._mapper({
|
|
103
744
|
data: data,
|
|
104
745
|
ruleSet: ruleSet
|
|
105
746
|
}));
|
|
106
747
|
if (logEntry) {
|
|
107
|
-
(_d = (_c = this._loggerManager) === null || _c === void 0 ? void 0 : _c.info) === null || _d === void 0 ? void 0 : _d.call(_c, 'RuleManager.isRuleMatched()',
|
|
748
|
+
(_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));
|
|
108
749
|
}
|
|
109
750
|
// Top OR level
|
|
110
|
-
|
|
751
|
+
let match;
|
|
111
752
|
if (Object.prototype.hasOwnProperty.call(ruleSet, 'OR') &&
|
|
112
|
-
|
|
113
|
-
for (
|
|
753
|
+
arrayNotEmpty(ruleSet === null || ruleSet === void 0 ? void 0 : ruleSet.OR)) {
|
|
754
|
+
for (let i = 0, l = ruleSet.OR.length; i < l; i++) {
|
|
114
755
|
match = this._processAND(data, ruleSet.OR[i]);
|
|
115
|
-
if (Object.values(
|
|
116
|
-
(_f = (_e = this._loggerManager) === null || _e === void 0 ? void 0 : _e.info) === null || _f === void 0 ? void 0 : _f.call(_e, 'RuleManager.isRuleMatched()', logEntry || '',
|
|
756
|
+
if (Object.values(RuleError).includes(match)) {
|
|
757
|
+
(_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);
|
|
117
758
|
}
|
|
118
759
|
else {
|
|
119
760
|
(_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
|
|
120
|
-
?
|
|
121
|
-
:
|
|
761
|
+
? MESSAGES.RULE_NOT_MATCH
|
|
762
|
+
: MESSAGES.RULE_MATCH.replace('#', String(i)));
|
|
122
763
|
}
|
|
123
764
|
if (match !== false) {
|
|
124
765
|
return match;
|
|
@@ -126,16 +767,16 @@ var RuleManager = /** @class */ (function () {
|
|
|
126
767
|
}
|
|
127
768
|
}
|
|
128
769
|
else {
|
|
129
|
-
(_k = (_j = this._loggerManager) === null || _j === void 0 ? void 0 : _j.warn) === null || _k === void 0 ? void 0 : _k.call(_j, 'RuleManager.isRuleMatched()', logEntry || '',
|
|
770
|
+
(_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);
|
|
130
771
|
}
|
|
131
772
|
return false;
|
|
132
|
-
}
|
|
773
|
+
}
|
|
133
774
|
/**
|
|
134
775
|
* Check is rule object valid
|
|
135
|
-
* @param {
|
|
776
|
+
* @param {RuleElement} rule
|
|
136
777
|
* @return {boolean}
|
|
137
778
|
*/
|
|
138
|
-
|
|
779
|
+
isValidRule(rule) {
|
|
139
780
|
var _a, _b;
|
|
140
781
|
(_b = (_a = this._loggerManager) === null || _a === void 0 ? void 0 : _a.trace) === null || _b === void 0 ? void 0 : _b.call(_a, 'RuleManager.isValidRule()', this._mapper({
|
|
141
782
|
rule: rule
|
|
@@ -147,7 +788,7 @@ var RuleManager = /** @class */ (function () {
|
|
|
147
788
|
Object.prototype.hasOwnProperty.call(rule.matching, 'negated') &&
|
|
148
789
|
typeof rule.matching.negated === 'boolean' &&
|
|
149
790
|
Object.prototype.hasOwnProperty.call(rule, 'value'));
|
|
150
|
-
}
|
|
791
|
+
}
|
|
151
792
|
/**
|
|
152
793
|
* Process AND block of rule set. Return first false if found
|
|
153
794
|
* @param {Record<string, any>} data Single value or key-value data set to compare
|
|
@@ -155,28 +796,28 @@ var RuleManager = /** @class */ (function () {
|
|
|
155
796
|
* @return {boolean | RuleError}
|
|
156
797
|
* @private
|
|
157
798
|
*/
|
|
158
|
-
|
|
799
|
+
_processAND(data, rulesSubset) {
|
|
159
800
|
var _a, _b, _c, _d;
|
|
160
801
|
// Second AND level
|
|
161
|
-
|
|
802
|
+
let match;
|
|
162
803
|
if (Object.prototype.hasOwnProperty.call(rulesSubset, 'AND') &&
|
|
163
|
-
|
|
164
|
-
for (
|
|
804
|
+
arrayNotEmpty(rulesSubset === null || rulesSubset === void 0 ? void 0 : rulesSubset.AND)) {
|
|
805
|
+
for (let i = 0, l = rulesSubset.AND.length; i < l; i++) {
|
|
165
806
|
match = this._processORWHEN(data, rulesSubset.AND[i]);
|
|
166
807
|
if (match === false) {
|
|
167
808
|
return false;
|
|
168
809
|
}
|
|
169
810
|
}
|
|
170
811
|
if (match !== false) {
|
|
171
|
-
(_b = (_a = this._loggerManager) === null || _a === void 0 ? void 0 : _a.info) === null || _b === void 0 ? void 0 : _b.call(_a, 'RuleManager._processAND()',
|
|
812
|
+
(_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);
|
|
172
813
|
}
|
|
173
814
|
return match;
|
|
174
815
|
}
|
|
175
816
|
else {
|
|
176
|
-
(_d = (_c = this._loggerManager) === null || _c === void 0 ? void 0 : _c.warn) === null || _d === void 0 ? void 0 : _d.call(_c, 'RuleManager._processAND()',
|
|
817
|
+
(_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);
|
|
177
818
|
}
|
|
178
819
|
return false;
|
|
179
|
-
}
|
|
820
|
+
}
|
|
180
821
|
/**
|
|
181
822
|
* Process OR block of rule set. Return first true if found
|
|
182
823
|
* @param {Record<string, any>} data Single value or key-value data set to compare
|
|
@@ -184,13 +825,13 @@ var RuleManager = /** @class */ (function () {
|
|
|
184
825
|
* @return {boolean | RuleError}
|
|
185
826
|
* @private
|
|
186
827
|
*/
|
|
187
|
-
|
|
828
|
+
_processORWHEN(data, rulesSubset) {
|
|
188
829
|
var _a, _b;
|
|
189
830
|
// Third OR level. Called OR_WHEN.
|
|
190
|
-
|
|
831
|
+
let match;
|
|
191
832
|
if (Object.prototype.hasOwnProperty.call(rulesSubset, 'OR_WHEN') &&
|
|
192
|
-
|
|
193
|
-
for (
|
|
833
|
+
arrayNotEmpty(rulesSubset === null || rulesSubset === void 0 ? void 0 : rulesSubset.OR_WHEN)) {
|
|
834
|
+
for (let i = 0, l = rulesSubset.OR_WHEN.length; i < l; i++) {
|
|
194
835
|
match = this._processRuleItem(data, rulesSubset.OR_WHEN[i]);
|
|
195
836
|
if (match !== false) {
|
|
196
837
|
return match;
|
|
@@ -198,121 +839,99 @@ var RuleManager = /** @class */ (function () {
|
|
|
198
839
|
}
|
|
199
840
|
}
|
|
200
841
|
else {
|
|
201
|
-
(_b = (_a = this._loggerManager) === null || _a === void 0 ? void 0 : _a.warn) === null || _b === void 0 ? void 0 : _b.call(_a, 'RuleManager._processORWHEN()',
|
|
842
|
+
(_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);
|
|
202
843
|
}
|
|
203
844
|
return false;
|
|
204
|
-
}
|
|
845
|
+
}
|
|
205
846
|
/**
|
|
206
847
|
* Process single rule item
|
|
207
848
|
* @param {Record<string, any>} data Single value or key-value data set to compare
|
|
208
|
-
* @param {
|
|
849
|
+
* @param {RuleElement} rule A single rule to compare
|
|
209
850
|
* @return {boolean | RuleError} Comparison result
|
|
210
851
|
* @private
|
|
211
852
|
*/
|
|
212
|
-
|
|
213
|
-
var
|
|
214
|
-
var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
853
|
+
_processRuleItem(data, rule) {
|
|
854
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
215
855
|
if (this.isValidRule(rule)) {
|
|
216
856
|
try {
|
|
217
|
-
|
|
218
|
-
|
|
857
|
+
const negation = rule.matching.negated || false;
|
|
858
|
+
const matching = rule.matching.match_type;
|
|
219
859
|
if (this.getComparisonProcessorMethods().indexOf(matching) !== -1) {
|
|
220
860
|
if (data && typeof data === 'object') {
|
|
221
861
|
// Validate data key-value set.
|
|
222
862
|
if (this.isUsingCustomInterface(data)) {
|
|
223
|
-
//
|
|
863
|
+
// RuleElement object has to have `rule_type` field
|
|
224
864
|
if (rule === null || rule === void 0 ? void 0 : rule.rule_type) {
|
|
225
|
-
(
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
return dataValue;
|
|
239
|
-
return this._comparisonProcessor[matching](dataValue, rule.value, negation);
|
|
240
|
-
}
|
|
865
|
+
(_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));
|
|
866
|
+
for (const method of Object.getOwnPropertyNames(data.constructor.prototype)) {
|
|
867
|
+
if (method === 'constructor')
|
|
868
|
+
continue;
|
|
869
|
+
const rule_method = camelCase(`get ${rule.rule_type.replace(/_/g, ' ')}`);
|
|
870
|
+
if (method === rule_method ||
|
|
871
|
+
((_c = data === null || data === void 0 ? void 0 : data.mapper) === null || _c === void 0 ? void 0 : _c.call(data, method)) === rule_method) {
|
|
872
|
+
const dataValue = data[method](rule);
|
|
873
|
+
if (Object.values(RuleError).includes(dataValue))
|
|
874
|
+
return dataValue;
|
|
875
|
+
if (rule.rule_type === 'js_condition')
|
|
876
|
+
return dataValue;
|
|
877
|
+
return this._comparisonProcessor[matching](dataValue, rule.value, negation);
|
|
241
878
|
}
|
|
242
879
|
}
|
|
243
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
244
|
-
finally {
|
|
245
|
-
try {
|
|
246
|
-
if (_s && !_s.done && (_a = _r.return)) _a.call(_r);
|
|
247
|
-
}
|
|
248
|
-
finally { if (e_1) throw e_1.error; }
|
|
249
|
-
}
|
|
250
880
|
}
|
|
251
881
|
}
|
|
252
|
-
else if (
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
if (k === rule_k) {
|
|
262
|
-
return this._comparisonProcessor[matching](data[key], rule.value, negation);
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
267
|
-
finally {
|
|
268
|
-
try {
|
|
269
|
-
if (_u && !_u.done && (_b = _t.return)) _b.call(_t);
|
|
882
|
+
else if (objectNotEmpty(data)) {
|
|
883
|
+
// only handle RuleElement with a `key` field
|
|
884
|
+
for (const key of Object.keys(data)) {
|
|
885
|
+
const k = this._keys_case_sensitive ? key : key.toLowerCase();
|
|
886
|
+
const rule_k = this._keys_case_sensitive
|
|
887
|
+
? rule['key']
|
|
888
|
+
: String(rule['key']).toLowerCase();
|
|
889
|
+
if (k === rule_k) {
|
|
890
|
+
return this._comparisonProcessor[matching](data[key], rule.value, negation);
|
|
270
891
|
}
|
|
271
|
-
finally { if (e_2) throw e_2.error; }
|
|
272
892
|
}
|
|
273
893
|
}
|
|
274
894
|
else {
|
|
275
|
-
(
|
|
276
|
-
warn:
|
|
277
|
-
data
|
|
895
|
+
(_e = (_d = this._loggerManager) === null || _d === void 0 ? void 0 : _d.trace) === null || _e === void 0 ? void 0 : _e.call(_d, 'RuleManager._processRuleItem()', {
|
|
896
|
+
warn: ERROR_MESSAGES.RULE_DATA_NOT_VALID,
|
|
897
|
+
data
|
|
278
898
|
});
|
|
279
899
|
}
|
|
280
900
|
}
|
|
281
901
|
else {
|
|
282
|
-
(
|
|
283
|
-
warn:
|
|
284
|
-
data
|
|
285
|
-
rule
|
|
902
|
+
(_g = (_f = this._loggerManager) === null || _f === void 0 ? void 0 : _f.trace) === null || _g === void 0 ? void 0 : _g.call(_f, 'RuleManager._processRuleItem()', {
|
|
903
|
+
warn: ERROR_MESSAGES.RULE_NOT_VALID,
|
|
904
|
+
data,
|
|
905
|
+
rule
|
|
286
906
|
});
|
|
287
907
|
}
|
|
288
908
|
}
|
|
289
909
|
else {
|
|
290
|
-
(
|
|
910
|
+
(_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));
|
|
291
911
|
}
|
|
292
912
|
}
|
|
293
913
|
catch (error) {
|
|
294
|
-
(
|
|
914
|
+
(_l = (_k = this._loggerManager) === null || _k === void 0 ? void 0 : _k.error) === null || _l === void 0 ? void 0 : _l.call(_k, 'RuleManager._processRuleItem()', {
|
|
295
915
|
error: error.message
|
|
296
916
|
});
|
|
297
917
|
}
|
|
298
918
|
}
|
|
299
919
|
else {
|
|
300
|
-
(
|
|
920
|
+
(_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);
|
|
301
921
|
}
|
|
302
922
|
return false;
|
|
303
|
-
}
|
|
923
|
+
}
|
|
304
924
|
/**
|
|
305
925
|
* Check is rule data object is a custom interface instead of a literal object
|
|
306
926
|
* @param {Record<string, any>} data Single value or key-value data set to compare
|
|
307
927
|
* @return {boolean}
|
|
308
928
|
*/
|
|
309
|
-
|
|
310
|
-
return (
|
|
929
|
+
isUsingCustomInterface(data) {
|
|
930
|
+
return (objectNotEmpty(data) &&
|
|
311
931
|
Object.prototype.hasOwnProperty.call(data, 'name') &&
|
|
312
932
|
data.name === 'RuleData');
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
}());
|
|
933
|
+
}
|
|
934
|
+
}
|
|
316
935
|
|
|
317
936
|
exports.RuleManager = RuleManager;
|
|
318
937
|
//# sourceMappingURL=index.js.map
|