@kameleoon/javascript-sdk-core 4.2.0 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +0 -2
  3. package/dist/clientConfiguration/clientConfiguration.d.ts +3 -5
  4. package/dist/clientConfiguration/clientConfiguration.js +1 -1
  5. package/dist/clientConfiguration/clientConfiguration.js.map +1 -1
  6. package/dist/clientConfiguration/constants.js +1 -1
  7. package/dist/clientConfiguration/constants.js.map +1 -1
  8. package/dist/clientConfiguration/types.d.ts +3 -2
  9. package/dist/clientConfiguration/types.js.map +1 -1
  10. package/dist/clientSettings/clientSettings.d.ts +11 -1
  11. package/dist/clientSettings/clientSettings.js +1 -1
  12. package/dist/clientSettings/clientSettings.js.map +1 -1
  13. package/dist/clientSettings/types.d.ts +5 -1
  14. package/dist/clientSettings/types.js.map +1 -1
  15. package/dist/eventManager/eventManager.d.ts +11 -0
  16. package/dist/eventManager/eventManager.js +2 -0
  17. package/dist/eventManager/eventManager.js.map +1 -0
  18. package/dist/eventManager/index.d.ts +2 -0
  19. package/dist/eventManager/index.js +2 -0
  20. package/dist/eventManager/index.js.map +1 -0
  21. package/dist/eventManager/types.d.ts +36 -0
  22. package/dist/eventManager/types.js +2 -0
  23. package/dist/eventManager/types.js.map +1 -0
  24. package/dist/eventSource/eventSource.js +1 -1
  25. package/dist/eventSource/eventSource.js.map +1 -1
  26. package/dist/index.d.ts +4 -4
  27. package/dist/index.js +1 -1
  28. package/dist/index.js.map +1 -1
  29. package/dist/kameleoonClient.d.ts +10 -2
  30. package/dist/kameleoonClient.js +1 -1
  31. package/dist/kameleoonClient.js.map +1 -1
  32. package/dist/kameleoonClientInterface.d.ts +26 -0
  33. package/dist/kameleoonClientInterface.js.map +1 -1
  34. package/dist/kameleoonData/dataManager.d.ts +2 -2
  35. package/dist/kameleoonData/dataManager.js +1 -1
  36. package/dist/kameleoonData/dataManager.js.map +1 -1
  37. package/dist/kameleoonData/dataProcessor.d.ts +2 -2
  38. package/dist/kameleoonData/dataProcessor.js +1 -1
  39. package/dist/kameleoonData/dataProcessor.js.map +1 -1
  40. package/dist/kameleoonData/index.d.ts +0 -1
  41. package/dist/kameleoonData/index.js +1 -1
  42. package/dist/kameleoonData/index.js.map +1 -1
  43. package/dist/kameleoonData/types.d.ts +1 -1
  44. package/dist/kameleoonData/types.js.map +1 -1
  45. package/dist/kameleoonError/constants.d.ts +1 -0
  46. package/dist/kameleoonError/constants.js +1 -1
  47. package/dist/kameleoonError/constants.js.map +1 -1
  48. package/dist/kameleoonError/kameleoonError.d.ts +1 -0
  49. package/dist/kameleoonError/kameleoonError.js +1 -1
  50. package/dist/kameleoonError/kameleoonError.js.map +1 -1
  51. package/dist/kameleoonError/types.d.ts +1 -0
  52. package/dist/kameleoonError/types.js +1 -1
  53. package/dist/kameleoonError/types.js.map +1 -1
  54. package/dist/kameleoonUtils.d.ts +29 -5
  55. package/dist/kameleoonUtils.js +1 -1
  56. package/dist/kameleoonUtils.js.map +1 -1
  57. package/dist/requester/constants.d.ts +1 -8
  58. package/dist/requester/constants.js +1 -1
  59. package/dist/requester/constants.js.map +1 -1
  60. package/dist/requester/index.d.ts +2 -2
  61. package/dist/requester/index.js +1 -1
  62. package/dist/requester/index.js.map +1 -1
  63. package/dist/requester/requester.d.ts +6 -2
  64. package/dist/requester/requester.js +1 -1
  65. package/dist/requester/requester.js.map +1 -1
  66. package/dist/requester/types.d.ts +96 -19
  67. package/dist/requester/types.js +1 -1
  68. package/dist/requester/types.js.map +1 -1
  69. package/dist/requester/urlProvider.d.ts +8 -5
  70. package/dist/requester/urlProvider.js +1 -1
  71. package/dist/requester/urlProvider.js.map +1 -1
  72. package/dist/targeting/conditions/customData.d.ts +4 -2
  73. package/dist/targeting/conditions/customData.js +1 -1
  74. package/dist/targeting/conditions/customData.js.map +1 -1
  75. package/dist/targeting/conditions/types.d.ts +1 -0
  76. package/dist/targeting/conditions/types.js.map +1 -1
  77. package/dist/targeting/types.d.ts +2 -1
  78. package/dist/targeting/types.js +1 -1
  79. package/dist/targeting/types.js.map +1 -1
  80. package/dist/types.d.ts +17 -5
  81. package/dist/types.js +1 -1
  82. package/dist/types.js.map +1 -1
  83. package/dist/utilities/constants.d.ts +1 -0
  84. package/dist/utilities/constants.js +1 -1
  85. package/dist/utilities/constants.js.map +1 -1
  86. package/dist/utilities/utilities.js +1 -1
  87. package/dist/utilities/utilities.js.map +1 -1
  88. package/dist/visitorCodeManager/visitorCodeManager.js +1 -1
  89. package/dist/visitorCodeManager/visitorCodeManager.js.map +1 -1
  90. package/package.json +2 -2
  91. package/dist/kameleoonData/constants.d.ts +0 -4
  92. package/dist/kameleoonData/constants.js +0 -2
  93. package/dist/kameleoonData/constants.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"urlProvider.js","names":["UrlProvider","initialize","a","siteCode","packageInfo","environment","ready","setDataApiDomain","domain","dataApiDomain","split","slice","join","getClientConfigurationUrl","timeStamp","isInitialized","environmentParam","UrlFirstParameter","Environment","timeStampParam","UrlParameter","Ts","URL","CLIENT_CONFIGURATION","getRemoteDataUrl","key","getDataApiUrl","DataApiQuery","DataMap","Key","encodeURI","getVisitorDataUrl","visitorCode","filters","isMappingIdentifier","customData","previousVisitAmount","currentVisit","conversions","geolocation","experiments","pageViews","device","browser","operatingSystem","kcs","identifierParameter","MappingValue","VisitorCode","customDataParameter","CustomData","conversionsParameter","Conversion","geolocationParameter","Geolocation","experimentsParameter","Experiment","pageViewsParameter","Page","staticDataParameter","StaticData","currentVisitParameter","CurrentVisit","kcsParameter","Kcs","previousVisitAmountParam","MaxNumberPreviousVisits","VisitData","getTrackingUrl","type","version","VisitEvent","SdkName","toLowerCase","SdkVersion","Error","query","concat","dataApiTopLevelDomain","UrlTracking","Visit","UrlQuery","Events","Visitor","Map","exports","_defineProperty"],"sources":["../../src/requester/urlProvider.ts"],"sourcesContent":["import { Environment, ExternalPackageInfoType } from 'src/types';\nimport {\n UrlFirstParameter,\n UrlParameter,\n URL,\n UrlTracking,\n UrlQuery,\n} from './constants';\nimport {\n DataApiQuery,\n GetVisitorDataUrlParamsType,\n UrlProviderInitializeParamsType,\n} from './types';\n\n// TODO: To be removed in favour of `DependencyManager`\n// which will use protected `KameleoonClient` method to be able to mock every dependency\n// for tests\nexport class UrlProvider {\n private static siteCode: string;\n private static environment?: Environment;\n private static ready = false;\n private static packageInfo: ExternalPackageInfoType;\n private static dataApiDomain = 'data.kameleoon';\n\n public static dataApiTopLevelDomain = '.io';\n\n public static initialize({\n siteCode,\n packageInfo,\n environment,\n }: UrlProviderInitializeParamsType): void {\n this.siteCode = siteCode;\n this.environment = environment;\n this.packageInfo = packageInfo;\n this.ready = true;\n }\n\n public static setDataApiDomain(domain: string): void {\n this.dataApiDomain = domain.split('.').slice(0, -1).join('.');\n }\n\n public static getClientConfigurationUrl(timeStamp?: number): string {\n this.isInitialized();\n\n const environmentParam = this.environment\n ? UrlFirstParameter.Environment + this.environment\n : '';\n let timeStampParam = '';\n\n if (timeStamp) {\n if (environmentParam) {\n timeStampParam = UrlParameter.Ts + timeStamp;\n } else {\n timeStampParam = UrlFirstParameter.Ts + timeStamp;\n }\n }\n\n return (\n URL.CLIENT_CONFIGURATION +\n this.siteCode +\n environmentParam +\n timeStampParam\n );\n }\n\n public static getRemoteDataUrl(key: string): string {\n this.isInitialized();\n\n return (\n this.getDataApiUrl(DataApiQuery.DataMap) +\n this.siteCode +\n UrlParameter.Key +\n encodeURI(key)\n );\n }\n\n public static getVisitorDataUrl({\n visitorCode,\n filters,\n isMappingIdentifier,\n }: GetVisitorDataUrlParamsType): string {\n const {\n customData,\n previousVisitAmount,\n currentVisit,\n conversions,\n geolocation,\n experiments,\n pageViews,\n device,\n browser,\n operatingSystem,\n kcs,\n } = filters;\n\n const identifierParameter = isMappingIdentifier\n ? UrlParameter.MappingValue\n : UrlParameter.VisitorCode;\n\n const customDataParameter = customData\n ? UrlParameter.CustomData + true\n : '';\n const conversionsParameter = conversions\n ? UrlParameter.Conversion + true\n : '';\n const geolocationParameter = geolocation\n ? UrlParameter.Geolocation + true\n : '';\n const experimentsParameter = experiments\n ? UrlParameter.Experiment + true\n : '';\n const pageViewsParameter = pageViews ? UrlParameter.Page + true : '';\n const staticDataParameter = Boolean(device || browser || operatingSystem)\n ? UrlParameter.StaticData + true\n : '';\n const currentVisitParameter = currentVisit\n ? UrlParameter.CurrentVisit + true\n : '';\n\n // --- Note ---\n // `kcs` parameter requires `currentVisit=true`\n let kcsParameter = '';\n\n if (kcs) {\n kcsParameter = UrlParameter.Kcs + true;\n\n if (!currentVisitParameter) {\n kcsParameter += UrlParameter.CurrentVisit + true;\n }\n }\n\n const previousVisitAmountParam =\n typeof previousVisitAmount !== 'number'\n ? UrlParameter.MaxNumberPreviousVisits + 1\n : UrlParameter.MaxNumberPreviousVisits + previousVisitAmount;\n\n return (\n this.getDataApiUrl(DataApiQuery.VisitData) +\n this.siteCode +\n identifierParameter +\n visitorCode +\n previousVisitAmountParam +\n customDataParameter +\n conversionsParameter +\n geolocationParameter +\n experimentsParameter +\n pageViewsParameter +\n staticDataParameter +\n currentVisitParameter +\n kcsParameter\n );\n }\n\n public static getTrackingUrl(\n visitorCode: string,\n isMappingIdentifier?: boolean,\n ): string {\n this.isInitialized();\n\n const { type, version } = this.packageInfo;\n\n const identifierParameter = isMappingIdentifier\n ? UrlParameter.MappingValue\n : UrlParameter.VisitorCode;\n\n return (\n this.getDataApiUrl(DataApiQuery.VisitEvent) +\n this.siteCode +\n identifierParameter +\n visitorCode +\n UrlParameter.SdkName +\n type.toLowerCase() +\n UrlParameter.SdkVersion +\n version\n );\n }\n\n private static isInitialized(): void {\n if (!this.ready) {\n throw new Error('UrlProvider is not initialized');\n }\n }\n\n private static getDataApiUrl(query: DataApiQuery): string {\n const domain = `https://${this.dataApiDomain}${this.dataApiTopLevelDomain}`;\n\n switch (query) {\n case DataApiQuery.VisitEvent:\n return `${domain}/${UrlTracking.Visit + UrlQuery.Events}`;\n case DataApiQuery.VisitData:\n return `${domain}/${UrlTracking.Visit + UrlQuery.Visitor}`;\n case DataApiQuery.DataMap:\n return `${domain}/${UrlTracking.Map + UrlQuery.Map}`;\n }\n }\n}\n"],"mappings":"kqBAiBO,KAAM,CAAAA,WAAY,CASvB,MAAc,CAAAC,UAAUA,CAAAC,CAAA,CAIkB,IAJjB,CACvBC,QAAQ,CAARA,CAAQ,CACRC,WAAW,CAAXA,CAAW,CACXC,WAAW,CAAXA,CAC+B,CAAC,CAAAH,CAAA,CAChC,IAAI,CAACC,QAAQ,CAAGA,CAAQ,CACxB,IAAI,CAACE,WAAW,CAAGA,CAAW,CAC9B,IAAI,CAACD,WAAW,CAAGA,CAAW,CAC9B,IAAI,CAACE,KAAK,GACZ,CAEA,MAAc,CAAAC,gBAAgBA,CAACC,CAAc,CAAQ,CACnD,IAAI,CAACC,aAAa,CAAGD,CAAM,CAACE,KAAK,CAAC,GAAG,CAAC,CAACC,KAAK,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC,CAACC,IAAI,CAAC,GAAG,CAC9D,CAEA,MAAc,CAAAC,yBAAyBA,CAACC,CAAkB,CAAU,CAClE,IAAI,CAACC,aAAa,CAAC,CAAC,CAEpB,KAAM,CAAAC,CAAgB,CAAG,IAAI,CAACX,WAAW,CACrCY,4BAAiB,CAACC,WAAW,CAAG,IAAI,CAACb,WAAW,CAChD,EAAE,CACN,GAAI,CAAAc,CAAc,CAAG,EAAE,CAUvB,MARI,CAAAL,CAAS,GACPE,CAAgB,CAClBG,CAAc,CAAGC,uBAAY,CAACC,EAAE,CAAGP,CAAS,CAE5CK,CAAc,CAAGF,4BAAiB,CAACI,EAAE,CAAGP,CAAS,EAKnDQ,cAAG,CAACC,oBAAoB,CACxB,IAAI,CAACpB,QAAQ,CACba,CAAgB,CAChBG,CAEJ,CAEA,MAAc,CAAAK,gBAAgBA,CAACC,CAAW,CAAU,CAGlD,MAFA,KAAI,CAACV,aAA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I,CAAAqE,KAAK,CAAC,gCAAgC,CAEpD,CAEA,MAAe,CAAAjD,aAAaA,CAACkD,CAAmB,CAAU,CACxD,KAAM,CAAApE,CAAM,YAAAqE,MAAA,CAAc,IAAI,CAACpE,aAAa,EAAAoE,MAAA,CAAG,IAAI,CAACC,qBAAqB,CAAE,CAAC,MAEpE,CAAAF,CAAK,GACNjD,mBAAY,CAAC4C,UAAU,IAAAM,MAAA,CAChBrE,CAAM,MAAAqE,MAAA,CAAIE,sBAAW,CAACC,KAAK,CAAGC,mBAAQ,CAACC,MAAM,EAFnDN,CAAK,GAGNjD,mBAAY,CAACwC,SAAS,IAAAU,MAAA,CACfrE,CAAM,MAAAqE,MAAA,CAAIE,sBAAW,CAACC,KAAK,CAAGC,mBAAQ,CAACE,OAAO,EAJpDP,CAAK,GAKNjD,mBAAY,CAACC,OAAO,IAAAiD,MAAA,CACbrE,CAAM,MAAAqE,MAAA,CAAIE,sBAAW,CAACK,GAAG,CAAGH,mBAAQ,CAACG,GAAG,QAExD,CACF,CAACC,OAAA,CAAArF,WAAA,CAAAA,WAAA,CAAAsF,eAAA,CAlLYtF,WAAW,oBAAAsF,eAAA,CAAXtF,WAAW,uBAAAsF,eAAA,CAAXtF,WAAW,aAAAsF,eAAA,CAAXtF,WAAW,uBAAAsF,eAAA,CAAXtF,WAAW,iBAKS,gBAAgB,EAAAsF,eAAA,CALpCtF,WAAW,yBAOgB,KAAK"}
1
+ {"version":3,"file":"urlProvider.js","names":["UrlProvider","initialize","a","siteCode","domain","packageInfo","environment","ready","setDomains","setDataApiDomain","b","isCustomDomain","parts","split","length","subdomain","secondLevelDomain","topLevelDomain","domains","UrlType","DataApi","dataApiTopLevelDomain","getClientConfigurationUrl","timeStamp","isInitialized","ClientConfiguration","baseUrl","concat","environmentParam","Environment","Production","UrlFirstParameter","timeStampParam","UrlParameter","Ts","getEventSourceUrl","Events","UrlQuery","Sse","getRemoteDataUrl","key","getDataApiUrl","DataApiQuery","DataMap","Key","encodeURI","getVisitorDataUrl","visitorCode","filters","isMappingIdentifier","customData","previousVisitAmount","currentVisit","conversions","geolocation","experiments","pageViews","device","browser","operatingSystem","kcs","identifierParameter","MappingValue","VisitorCode","customDataParameter","CustomData","conversionsParameter","Conversion","geolocationParameter","Geolocation","experimentsParameter","Experiment","pageViewsParameter","Page","staticDataParameter","StaticData","currentVisitParameter","CurrentVisit","kcsParameter","Kcs","previousVisitAmountParam","MaxNumberPreviousVisits","VisitData","getTrackingUrl","type","version","VisitEvent","SdkName","toLowerCase","SdkVersion","Error","query","UrlTracking","Visit","Visitor","Map","domainData","_objectSpread","exports","_defineProperty"],"sources":["../../src/requester/urlProvider.ts"],"sourcesContent":["import { Environment, ExternalPackageInfoType } from 'src/types';\nimport {\n UrlFirstParameter,\n UrlParameter,\n UrlTracking,\n UrlQuery,\n} from './constants';\nimport {\n DataApiQuery,\n DomainsType,\n GetVisitorDataUrlParamsType,\n UrlProviderInitializeParamsType,\n UrlType,\n} from './types';\n\n// TODO: To be removed in favour of `DependencyManager`\n// which will use protected `KameleoonClient` method to be able to mock every dependency\n// for tests\nexport class UrlProvider {\n private static ready = false;\n private static siteCode: string;\n private static isCustomDomain = false;\n private static environment: Environment;\n private static packageInfo: ExternalPackageInfoType;\n private static domains: DomainsType = {\n [UrlType.DataApi]: {\n subdomain: 'data',\n topLevelDomain: 'io',\n secondLevelDomain: 'kameleoon',\n },\n [UrlType.Events]: {\n subdomain: 'events',\n topLevelDomain: 'com',\n secondLevelDomain: 'kameleoon',\n },\n [UrlType.ClientConfiguration]: {\n subdomain: 'sdk-config',\n topLevelDomain: 'eu',\n secondLevelDomain: 'kameleoon',\n },\n };\n\n // --- Note ---\n // Dirty workaround before the `DependencyManager` implementation\n // see a note above\n public static dataApiTopLevelDomain?: string;\n\n public static initialize({\n siteCode,\n domain,\n packageInfo,\n environment,\n }: UrlProviderInitializeParamsType) {\n this.siteCode = siteCode;\n this.environment = environment;\n this.packageInfo = packageInfo;\n this.ready = true;\n\n this.setDomains(domain);\n }\n\n public static setDataApiDomain(domain: string): void {\n if (this.isCustomDomain) {\n return;\n }\n\n const parts = domain.split('.');\n\n if (parts.length !== 3) {\n return;\n }\n\n const [subdomain, secondLevelDomain, topLevelDomain] = parts;\n\n this.domains[UrlType.DataApi] = {\n subdomain,\n secondLevelDomain,\n topLevelDomain: this.dataApiTopLevelDomain ?? topLevelDomain,\n };\n }\n\n public static getClientConfigurationUrl(timeStamp?: number): string {\n this.isInitialized();\n\n const { subdomain, topLevelDomain, secondLevelDomain } =\n this.domains[UrlType.ClientConfiguration];\n\n const baseUrl = `https://${subdomain}.${secondLevelDomain}.${topLevelDomain}/`;\n const environmentParam =\n this.environment === Environment.Production\n ? ''\n : UrlFirstParameter.Environment + this.environment;\n let timeStampParam = '';\n\n if (timeStamp) {\n if (environmentParam) {\n timeStampParam = UrlParameter.Ts + timeStamp;\n } else {\n timeStampParam = UrlFirstParameter.Ts + timeStamp;\n }\n }\n\n return baseUrl + this.siteCode + environmentParam + timeStampParam;\n }\n\n public static getEventSourceUrl(): string {\n this.isInitialized();\n\n const { subdomain, topLevelDomain, secondLevelDomain } =\n this.domains[UrlType.Events];\n\n return `https://${subdomain}.${secondLevelDomain}.${topLevelDomain}:8110/${UrlQuery.Sse}${this.siteCode}`;\n }\n\n public static getRemoteDataUrl(key: string): string {\n this.isInitialized();\n\n return (\n this.getDataApiUrl(DataApiQuery.DataMap) +\n this.siteCode +\n UrlParameter.Key +\n encodeURI(key)\n );\n }\n\n public static getVisitorDataUrl({\n visitorCode,\n filters,\n isMappingIdentifier,\n }: GetVisitorDataUrlParamsType): string {\n this.isInitialized();\n\n const {\n customData,\n previousVisitAmount,\n currentVisit,\n conversions,\n geolocation,\n experiments,\n pageViews,\n device,\n browser,\n operatingSystem,\n kcs,\n } = filters;\n\n const identifierParameter = isMappingIdentifier\n ? UrlParameter.MappingValue\n : UrlParameter.VisitorCode;\n const customDataParameter = customData\n ? UrlParameter.CustomData + true\n : '';\n const conversionsParameter = conversions\n ? UrlParameter.Conversion + true\n : '';\n const geolocationParameter = geolocation\n ? UrlParameter.Geolocation + true\n : '';\n const experimentsParameter = experiments\n ? UrlParameter.Experiment + true\n : '';\n const pageViewsParameter = pageViews ? UrlParameter.Page + true : '';\n const staticDataParameter = Boolean(device || browser || operatingSystem)\n ? UrlParameter.StaticData + true\n : '';\n const currentVisitParameter = currentVisit\n ? UrlParameter.CurrentVisit + true\n : '';\n const kcsParameter = kcs ? UrlParameter.Kcs + true : '';\n const previousVisitAmountParam =\n typeof previousVisitAmount !== 'number'\n ? UrlParameter.MaxNumberPreviousVisits + 1\n : UrlParameter.MaxNumberPreviousVisits + previousVisitAmount;\n\n return (\n this.getDataApiUrl(DataApiQuery.VisitData) +\n this.siteCode +\n identifierParameter +\n visitorCode +\n previousVisitAmountParam +\n customDataParameter +\n conversionsParameter +\n geolocationParameter +\n experimentsParameter +\n pageViewsParameter +\n staticDataParameter +\n currentVisitParameter +\n kcsParameter\n );\n }\n\n public static getTrackingUrl(\n visitorCode: string,\n isMappingIdentifier?: boolean,\n ): string {\n this.isInitialized();\n\n const { type, version } = this.packageInfo;\n\n const identifierParameter = isMappingIdentifier\n ? UrlParameter.MappingValue\n : UrlParameter.VisitorCode;\n\n return (\n this.getDataApiUrl(DataApiQuery.VisitEvent) +\n this.siteCode +\n identifierParameter +\n visitorCode +\n UrlParameter.SdkName +\n type.toLowerCase() +\n UrlParameter.SdkVersion +\n version\n );\n }\n\n private static isInitialized(): void {\n if (!this.ready) {\n throw new Error('UrlProvider is not initialized');\n }\n }\n\n private static getDataApiUrl(query: DataApiQuery): string {\n const { subdomain, topLevelDomain, secondLevelDomain } =\n this.domains[UrlType.DataApi];\n\n if (!subdomain || !topLevelDomain || !secondLevelDomain) {\n throw new Error('Data API domain is not set');\n }\n\n const domain = `https://${subdomain}.${secondLevelDomain}.${topLevelDomain}`;\n\n switch (query) {\n case DataApiQuery.VisitEvent:\n return `${domain}/${UrlTracking.Visit + UrlQuery.Events}`;\n case DataApiQuery.VisitData:\n return `${domain}/${UrlTracking.Visit + UrlQuery.Visitor}`;\n case DataApiQuery.DataMap:\n return `${domain}/${UrlTracking.Map + UrlQuery.Map}`;\n }\n }\n\n private static setDomains(domain: string | null): void {\n if (!domain) {\n return;\n }\n\n this.isCustomDomain = true;\n\n const parts = domain.split('.');\n\n const [secondLevelDomain, topLevelDomain] = parts;\n\n const domainData = {\n secondLevelDomain,\n topLevelDomain,\n };\n\n this.domains = {\n [UrlType.DataApi]: {\n ...this.domains[UrlType.DataApi],\n ...domainData,\n },\n [UrlType.Events]: {\n ...this.domains[UrlType.Events],\n ...domainData,\n },\n [UrlType.ClientConfiguration]: {\n ...this.domains[UrlType.ClientConfiguration],\n ...domainData,\n },\n };\n }\n}\n"],"mappings":"gyCAkBO,KAAM,CAAAA,WAAY,CA6BvB,MAAc,CAAAC,UAAUA,CAAAC,CAAA,CAKY,IALX,CACvBC,QAAQ,CAARA,CAAQ,CACRC,MAAM,CAANA,CAAM,CACNC,WAAW,CAAXA,CAAW,CACXC,WAAW,CAAXA,CAC+B,CAAC,CAAAJ,CAAA,CAChC,IAAI,CAACC,QAAQ,CAAGA,CAAQ,CACxB,IAAI,CAACG,WAAW,CAAGA,CAAW,CAC9B,IAAI,CAACD,WAAW,CAAGA,CAAW,CAC9B,IAAI,CAACE,KAAK,GAAO,CAEjB,IAAI,CAACC,UAAU,CAACJ,CAAM,CACxB,CAEA,MAAc,CAAAK,gBAAgBA,CAACL,CAAc,CAAQ,KAAAM,CAAA,CACnD,IAAI,IAAI,CAACC,cAAc,EAIvB,KAAM,CAAAC,CAAK,CAAGR,CAAM,CAACS,KAAK,CAAC,GAAG,CAAC,CAE/B,GAAqB,CAAC,GAAlBD,CAAK,CAACE,MAAY,EAItB,KAAM,CAACC,CAAS,CAAEC,CAAiB,CAAEC,CAAc,CAAC,CAAGL,CAAK,CAE5D,IAAI,CAACM,OAAO,CAACC,eAAO,CAACC,OAAO,CAAC,CAAG,CAC9BL,SAAS,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BhF,iBAAiB,CAAjBA,CAAiB,CACjBC,cAAc,CAAdA,CACF,CAAC,CAED,IAAI,CAACC,OAAO,CAAG,CACb,CAACC,eAAO,CAACC,OAAO,EAAA6E,aAAA,CAAAA,aAAA,IACX,IAAI,CAAC/E,OAAO,CAACC,eAAO,CAACC,OAAO,CAAC,EAC7B4E,CAAU,CACd,CACD,CAAC7E,eAAO,CAACiB,MAAM,EAAA6D,aAAA,CAAAA,aAAA,IACV,IAAI,CAAC/E,OAAO,CAACC,eAAO,CAACiB,MAAM,CAAC,EAC5B4D,CAAU,CACd,CACD,CAAC7E,eAAO,CAACM,mBAAmB,EAAAwE,aAAA,CAAAA,aAAA,IACvB,IAAI,CAAC/E,OAAO,CAACC,eAAO,CAACM,mBAAmB,CAAC,EACzCuE,CAAU,CAEjB,CACF,CACF,CAACE,OAAA,CAAAlG,WAAA,CAAAA,WAAA,CAAAmG,eAAA,CA9PYnG,WAAW,aAAAmG,eAAA,CAAXnG,WAAW,oBAAAmG,eAAA,CAAXnG,WAAW,sBAAAmG,eAAA,CAAXnG,WAAW,uBAAAmG,eAAA,CAAXnG,WAAW,uBAAAmG,eAAA,CAAXnG,WAAW,WAMgB,CACpC,CAACmB,eAAO,CAACC,OAAO,EAAG,CACjBL,SAAS,CAAE,MAAM,CACjBE,cAAc,CAAE,IAAI,CACpBD,iBAAiB,CAAE,WACrB,CAAC,CACD,CAACG,eAAO,CAACiB,MAAM,EAAG,CAChBrB,SAAS,CAAE,QAAQ,CACnBE,cAAc,CAAE,KAAK,CACrBD,iBAAiB,CAAE,WACrB,CAAC,CACD,CAACG,eAAO,CAACM,mBAAmB,EAAG,CAC7BV,SAAS,CAAE,YAAY,CACvBE,cAAc,CAAE,IAAI,CACpBD,iBAAiB,CAAE,WACrB,CACF,CAAC,EAAAmF,eAAA,CAtBUnG,WAAW"}
@@ -1,14 +1,16 @@
1
1
  import { Result } from 'ts-res';
2
2
  import { KameleoonError } from '../../kameleoonError';
3
- import { EvaluationDataType } from '../../targeting/types';
3
+ import { EvaluationDataType } from '../../targeting';
4
4
  import { ConditionDataType, ICondition } from './types';
5
5
  export declare class CustomData implements ICondition {
6
6
  private customDataIndex;
7
7
  private matchType?;
8
8
  private conditionValue?;
9
9
  private error?;
10
- constructor({ customDataIndex, valueMatchType, value }: ConditionDataType);
10
+ private range?;
11
+ constructor({ customDataIndex, valueMatchType, value, range, }: ConditionDataType);
11
12
  evaluate({ targetingData, }: EvaluationDataType): Result<boolean, KameleoonError>;
12
13
  private checkCondition;
13
14
  private parseArray;
15
+ private parseRange;
14
16
  }
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CustomData=void 0;var _tsRes=require("ts-res"),_kameleoonData=require("../../kameleoonData"),_kameleoonError=require("../../kameleoonError"),_utilities=require("../../utilities"),_types=require("../types");function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==typeof b?b:b+""}function _toPrimitive(a,b){if("object"!=typeof a||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=typeof d)return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}class CustomData{constructor(a){let{customDataIndex:b,valueMatchType:c,value:d}=a;_defineProperty(this,"customDataIndex",void 0),_defineProperty(this,"matchType",void 0),_defineProperty(this,"conditionValue",void 0),_defineProperty(this,"error",void 0),this.customDataIndex=b?+b:null,this.matchType=c,this.conditionValue=d}evaluate(a){let{targetingData:b}=a;if("number"==typeof this.customDataIndex){var c;const a=null===b||void 0===b||null===(c=b[_kameleoonData.KameleoonData.CustomData])||void 0===c?void 0:c[this.customDataIndex];if(a){const{value:b}=a,c=this.checkCondition(b);return this.error?(0,_tsRes.Err)(this.error):(0,_tsRes.Ok)(c)}}return(0,_tsRes.Ok)(this.matchType===_types.ValueMatchType.UNDEFINED)}checkCondition(a){if("string"!=typeof this.conditionValue&&this.matchType!==_types.ValueMatchType.TRUE&&this.matchType!==_types.ValueMatchType.FALSE)return!1;const b=this.conditionValue;if(this.matchType===_types.ValueMatchType.AMONG_VALUES){const c=this.parseArray(b);if(!c.ok)return this.error=c.error,!1;const d=new Set(c.data);return Array.isArray(a)?a.some(a=>d.has(a)):c.data.includes(a)}if(Array.isArray(a))return a.some(a=>this.checkCondition(a));switch(this.matchType){case _types.ValueMatchType.CONTAINS:return a.includes(b);case _types.ValueMatchType.EXACT:return a===this.conditionValue;case _types.ValueMatchType.REGULAR_EXPRESSION:return _utilities.Utilities.parseRegExp(b).test(a);case _types.ValueMatchType.LOWER:return+a<+this.conditionValue;case _types.ValueMatchType.EQUAL:return+a===+this.conditionValue;case _types.ValueMatchType.GREATER:return+a>+this.conditionValue;case _types.ValueMatchType.TRUE:return"true"===a.toLowerCase();case _types.ValueMatchType.FALSE:return"false"===a.toLowerCase();default:return!1}}parseArray(a){try{const b=JSON.parse(a);if(Array.isArray(b))return(0,_tsRes.Ok)(b)}catch(b){return(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.AmongValuesCheck,b,a))}return(0,_tsRes.Ok)([])}}exports.CustomData=CustomData;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CustomData=void 0;var _tsRes=require("ts-res"),_kameleoonData=require("../../kameleoonData"),_kameleoonError=require("../../kameleoonError"),_=require("./.."),_utilities=require("../../utilities");function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==typeof b?b:b+""}function _toPrimitive(a,b){if("object"!=typeof a||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=typeof d)return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}class CustomData{constructor(a){let{customDataIndex:b,valueMatchType:c,value:d,range:e}=a;_defineProperty(this,"customDataIndex",void 0),_defineProperty(this,"matchType",void 0),_defineProperty(this,"conditionValue",void 0),_defineProperty(this,"error",void 0),_defineProperty(this,"range",void 0),this.customDataIndex=b?+b:null,this.matchType=c,this.conditionValue=d,this.range=e}evaluate(a){let{targetingData:b}=a;if("number"==typeof this.customDataIndex){var c;const a=null===b||void 0===b||null===(c=b[_kameleoonData.KameleoonData.CustomData])||void 0===c?void 0:c[this.customDataIndex];if(a){const{value:b}=a,c=this.checkCondition(b);return this.error?(0,_tsRes.Err)(this.error):(0,_tsRes.Ok)(c)}}return(0,_tsRes.Ok)(this.matchType===_.ValueMatchType.UNDEFINED)}checkCondition(a){if("string"!=typeof this.conditionValue&&this.matchType!==_.ValueMatchType.TRUE&&this.matchType!==_.ValueMatchType.FALSE&&this.matchType!==_.ValueMatchType.RANGE)return!1;const b=this.conditionValue;if(this.matchType===_.ValueMatchType.AMONG_VALUES){const c=this.parseArray(b);if(!c.ok)return this.error=c.error,!1;const d=new Set(c.data);return Array.isArray(a)?a.some(a=>d.has(a)):c.data.includes(a)}if(this.matchType===_.ValueMatchType.RANGE){const b=this.parseRange(this.range);if(!b.ok)return this.error=b.error,!1;const[c,d]=b.data,e=a=>a>=c&&a<=d;return Array.isArray(a)?a.some(a=>e(+a)):e(+a)}if(Array.isArray(a))return a.some(a=>this.checkCondition(a));switch(this.matchType){case _.ValueMatchType.CONTAINS:return a.includes(b);case _.ValueMatchType.EXACT:return a===this.conditionValue;case _.ValueMatchType.REGULAR_EXPRESSION:return _utilities.Utilities.parseRegExp(b).test(a);case _.ValueMatchType.LOWER:return+a<+this.conditionValue;case _.ValueMatchType.EQUAL:return+a===+this.conditionValue;case _.ValueMatchType.GREATER:return+a>+this.conditionValue;case _.ValueMatchType.TRUE:return"true"===a.toLowerCase();case _.ValueMatchType.FALSE:return"false"===a.toLowerCase();default:return!1}}parseArray(a){try{const b=JSON.parse(a);if(Array.isArray(b))return(0,_tsRes.Ok)(b)}catch(b){return(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.AmongValuesCheck,b,a))}return(0,_tsRes.Ok)([])}parseRange(a){return a&&2===a.length?(0,_tsRes.Ok)(a):(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.RangeCheck,a))}}exports.CustomData=CustomData;
2
2
  //# sourceMappingURL=customData.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"customData.js","names":["CustomData","constructor","a","customDataIndex","valueMatchType","value","_defineProperty","matchType","conditionValue","evaluate","targetingData","c","customData","KameleoonData","customDataValue","result","checkCondition","error","Err","Ok","ValueMatchType","UNDEFINED","TRUE","FALSE","AMONG_VALUES","parseArray","ok","resultData","Set","data","Array","isArray","some","has","includes","CONTAINS","EXACT","REGULAR_EXPRESSION","Utilities","parseRegExp","test","LOWER","EQUAL","GREATER","toLowerCase","JSON","parse","err","KameleoonError","KameleoonException","AmongValuesCheck","exports"],"sources":["../../../src/targeting/conditions/customData.ts"],"sourcesContent":["import { Err, Ok, Result } from 'ts-res';\nimport { CustomDataType, KameleoonData } from 'src/kameleoonData';\nimport { KameleoonError, KameleoonException } from 'src/kameleoonError';\nimport { Utilities } from 'src/utilities';\nimport { EvaluationDataType, ValueMatchType } from 'src/targeting/types';\nimport { ConditionDataType, ICondition } from './types';\n\nexport class CustomData implements ICondition {\n private customDataIndex: number | null;\n private matchType?: ValueMatchType | null;\n private conditionValue?: string | null;\n private error?: KameleoonError;\n\n constructor({ customDataIndex, valueMatchType, value }: ConditionDataType) {\n this.customDataIndex = customDataIndex ? Number(customDataIndex) : null;\n this.matchType = valueMatchType;\n this.conditionValue = value;\n }\n\n public evaluate({\n targetingData,\n }: EvaluationDataType): Result<boolean, KameleoonError> {\n if (typeof this.customDataIndex === 'number') {\n const customData =\n targetingData?.[KameleoonData.CustomData]?.[this.customDataIndex];\n\n if (customData) {\n const { value: customDataValue } = customData;\n const result = this.checkCondition(customDataValue);\n\n if (this.error) {\n return Err(this.error);\n }\n\n return Ok(result);\n }\n }\n\n return Ok(this.matchType === ValueMatchType.UNDEFINED);\n }\n\n private checkCondition(\n customDataValue: CustomDataType['value'] | string,\n ): boolean {\n if (\n typeof this.conditionValue !== 'string' &&\n this.matchType !== ValueMatchType.TRUE &&\n this.matchType !== ValueMatchType.FALSE\n ) {\n return false;\n }\n\n // --- Note ---\n // `ValueMatchType.TRUE` and `ValueMatchType.FALSE` do not use condition value\n // so we can safely assume that `this.conditionValue` is a string at this point\n const conditionValue = this.conditionValue as string;\n\n // --- Note ---\n // `AMONG_VALUES` is checked separately to avoid recursion overhead\n // for `JSON.parse` inside `this.parseArray`\n if (this.matchType === ValueMatchType.AMONG_VALUES) {\n const result = this.parseArray(conditionValue);\n\n if (!result.ok) {\n this.error = result.error;\n\n return false;\n }\n\n const resultData = new Set(result.data);\n\n return Array.isArray(customDataValue)\n ? customDataValue.some((value) => resultData.has(value))\n : result.data.includes(customDataValue);\n }\n\n if (Array.isArray(customDataValue)) {\n return customDataValue.some((value) => this.checkCondition(value));\n }\n\n switch (this.matchType) {\n case ValueMatchType.CONTAINS:\n return customDataValue.includes(conditionValue);\n case ValueMatchType.EXACT:\n return customDataValue === this.conditionValue;\n case ValueMatchType.REGULAR_EXPRESSION:\n return Utilities.parseRegExp(conditionValue).test(customDataValue);\n case ValueMatchType.LOWER:\n return Number(customDataValue) < Number(this.conditionValue);\n case ValueMatchType.EQUAL:\n return Number(customDataValue) === Number(this.conditionValue);\n case ValueMatchType.GREATER:\n return Number(customDataValue) > Number(this.conditionValue);\n case ValueMatchType.TRUE:\n return customDataValue.toLowerCase() === 'true';\n case ValueMatchType.FALSE:\n return customDataValue.toLowerCase() === 'false';\n default:\n return false;\n }\n }\n\n private parseArray(value: string): Result<string[], KameleoonError> {\n try {\n const result = JSON.parse(value);\n\n if (Array.isArray(result)) {\n return Ok(result);\n }\n } catch (err) {\n return Err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ACN,cAAe,CAC9D,IAAK,CAAAY,qBAAc,CAACsB,KAAK,CACvB,MAAO,CAAO5B,CAAe,IAAa,IAAI,CAACN,cAAe,CAChE,IAAK,CAAAY,qBAAc,CAACuB,OAAO,CACzB,MAAO,CAAO7B,CAAe,EAAW,IAAI,CAACN,cAAe,CAC9D,IAAK,CAAAY,qBAAc,CAACE,IAAI,CACtB,MAAyC,MAAM,GAAxCR,CAAe,CAAC8B,WAAW,CAAC,CAAY,CACjD,IAAK,CAAAxB,qBAAc,CAACG,KAAK,CACvB,MAAyC,OAAO,GAAzCT,CAAe,CAAC8B,WAAW,CAAC,CAAa,CAClD,QACE,QACJ,CACF,CAEQnB,UAAUA,CAACpB,CAAa,CAAoC,CAClE,GAAI,CACF,KAAM,CAAAU,CAAM,CAAG8B,IAAI,CAACC,KAAK,CAACzC,CAAK,CAAC,CAEhC,GAAIyB,KAAK,CAACC,OAAO,CAAChB,CAAM,CAAC,CACvB,MAAO,GAAAI,SAAE,EAACJ,CAAM,CAEpB,CAAE,MAAOgC,CAAG,CAAE,CACZ,MAAO,GAAA7B,UAAG,EACR,GAAI,CAAA8B,8BAAc,CAACC,kCAAkB,CAACC,gBAAgB,CAAEH,CAAG,CAAE1C,CAAK,CACpE,CACF,CAEA,MAAO,GAAAc,SAAE,EAAC,EAAE,CACd,CACF,CAACgC,OAAA,CAAAnD,UAAA,CAAAA,UAAA"}
1
+ {"version":3,"file":"customData.js","names":["CustomData","constructor","a","customDataIndex","valueMatchType","value","range","_defineProperty","matchType","conditionValue","evaluate","targetingData","c","customData","KameleoonData","customDataValue","result","checkCondition","error","Err","Ok","ValueMatchType","UNDEFINED","TRUE","FALSE","RANGE","AMONG_VALUES","parseArray","ok","resultData","Set","data","Array","isArray","some","has","includes","parseRange","lowerBound","upperBound","isInRange","CONTAINS","EXACT","REGULAR_EXPRESSION","Utilities","parseRegExp","test","LOWER","EQUAL","GREATER","toLowerCase","JSON","parse","err","KameleoonError","KameleoonException","AmongValuesCheck","array","length","RangeCheck","exports"],"sources":["../../../src/targeting/conditions/customData.ts"],"sourcesContent":["import { Err, Ok, Result } from 'ts-res';\nimport { CustomDataType, KameleoonData } from 'src/kameleoonData';\nimport { KameleoonError, KameleoonException } from 'src/kameleoonError';\nimport { EvaluationDataType, ValueMatchType } from 'src/targeting';\nimport { Utilities } from 'src/utilities';\nimport { ConditionDataType, ICondition } from './types';\n\nexport class CustomData implements ICondition {\n private customDataIndex: number | null;\n private matchType?: ValueMatchType | null;\n private conditionValue?: string | null;\n private error?: KameleoonError;\n private range?: number[] | null;\n\n constructor({\n customDataIndex,\n valueMatchType,\n value,\n range,\n }: ConditionDataType) {\n this.customDataIndex = customDataIndex ? Number(customDataIndex) : null;\n this.matchType = valueMatchType;\n this.conditionValue = value;\n this.range = range;\n }\n\n public evaluate({\n targetingData,\n }: EvaluationDataType): Result<boolean, KameleoonError> {\n if (typeof this.customDataIndex === 'number') {\n const customData =\n targetingData?.[KameleoonData.CustomData]?.[this.customDataIndex];\n\n if (customData) {\n const { value: customDataValue } = customData;\n const result = this.checkCondition(customDataValue);\n\n if (this.error) {\n return Err(this.error);\n }\n\n return Ok(result);\n }\n }\n\n return Ok(this.matchType === ValueMatchType.UNDEFINED);\n }\n\n private checkCondition(\n customDataValue: CustomDataType['value'] | string,\n ): boolean {\n if (\n typeof this.conditionValue !== 'string' &&\n this.matchType !== ValueMatchType.TRUE &&\n this.matchType !== ValueMatchType.FALSE &&\n this.matchType !== ValueMatchType.RANGE\n ) {\n return false;\n }\n\n // --- Note ---\n // `TRUE`/`FALSE`/`RANGE` do not use condition value\n // so we can safely assume that `this.conditionValue` is a string at this point\n // for other match types\n const conditionValue = this.conditionValue as string;\n\n // --- Note ---\n // `AMONG_VALUES` and `RANGE` are checked separately to avoid recursion overhead\n // for `JSON.parse` inside `this.parseArray`\n if (this.matchType === ValueMatchType.AMONG_VALUES) {\n const result = this.parseArray(conditionValue);\n\n if (!result.ok) {\n this.error = result.error;\n\n return false;\n }\n\n const resultData = new Set(result.data);\n\n return Array.isArray(customDataValue)\n ? customDataValue.some((value) => resultData.has(value))\n : result.data.includes(customDataValue);\n }\n\n if (this.matchType === ValueMatchType.RANGE) {\n const result = this.parseRange(this.range);\n\n if (!result.ok) {\n this.error = result.error;\n\n return false;\n }\n\n const [lowerBound, upperBound] = result.data;\n\n const isInRange = (value: number) =>\n value >= lowerBound && value <= upperBound;\n\n return Array.isArray(customDataValue)\n ? customDataValue.some((value) => isInRange(Number(value)))\n : isInRange(Number(customDataValue));\n }\n\n if (Array.isArray(customDataValue)) {\n return customDataValue.some((value) => this.checkCondition(value));\n }\n\n switch (this.matchType) {\n case ValueMatchType.CONTAINS:\n return customDataValue.includes(conditionValue);\n case ValueMatchType.EXACT:\n return customDataValue === this.conditionValue;\n case ValueMatchType.REGULAR_EXPRESSION:\n return Utilities.parseRegExp(conditionValue).test(customDataValue);\n case ValueMatchType.LOWER:\n return Number(customDataValue) < Number(this.conditionValue);\n case ValueMatchType.EQUAL:\n return Number(customDataValue) === Number(this.conditionValue);\n case ValueMatchType.GREATER:\n return Number(customDataValue) > Number(this.conditionValue);\n case ValueMatchType.TRUE:\n return customDataValue.toLowerCase() === 'true';\n case ValueMatchType.FALSE:\n return customDataValue.toLowerCase() === 'false';\n default:\n return false;\n }\n }\n\n private parseArray(value: string): Result<string[], KameleoonError> {\n try {\n const result = JSON.parse(value);\n\n if (Array.isArray(result)) {\n return Ok(result);\n }\n } catch (err) {\n return Err(\n new KameleoonError(KameleoonException.AmongValuesCheck, err, value),\n );\n }\n\n return Ok([]);\n }\n\n private parseRange(\n array?: number[] | null,\n ): Result<[number, number], KameleoonError> {\n if (!array || array.length !== 2) {\n return Err(new KameleoonError(KameleoonException.RangeCheck, array));\n }\n\n return Ok(array as [number, number]);\n }\n}\n"],"mappings":"oxBAOO,KAAM,CAAAA,UAAiC,CAO5CC,WAAWA,CAAAC,CAAA,CAKW,IALV,CACVC,eAAe,CAAfA,CAAe,CACfC,cAAc,CAAdA,CAAc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C,gBAAgB,CAAEH,CAAG,CAAEhD,CAAK,CACpE,CACF,CAEA,MAAO,GAAAe,SAAE,EAAC,EAAE,CACd,CAEQiB,UAAUA,CAChBoB,CAAuB,CACmB,OACrC,CAAAA,CAAK,EAAqB,CAAC,GAAlBA,CAAK,CAACC,MAAY,CAIzB,GAAAtC,SAAE,EAACqC,CAAyB,CAAC,CAH3B,GAAAtC,UAAG,EAAC,GAAI,CAAAmC,8BAAc,CAACC,kCAAkB,CAACI,UAAU,CAAEF,CAAK,CAAC,CAIvE,CACF,CAACG,OAAA,CAAA5D,UAAA,CAAAA,UAAA"}
@@ -46,6 +46,7 @@ export type ConditionDataType = {
46
46
  goalId?: number | null;
47
47
  sdkLanguage?: SdkLanguageType | null;
48
48
  visitorCode?: string | null;
49
+ range?: number[] | null;
49
50
  lowerBound?: number;
50
51
  upperBound?: number;
51
52
  keyMomentId?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../src/targeting/conditions/types.ts"],"sourcesContent":["import { Result } from 'ts-res';\nimport { SdkLanguageType } from 'src/constants';\nimport { BrowserType, DeviceType } from 'src/kameleoonData';\nimport { KameleoonError } from 'src/kameleoonError';\nimport {\n EvaluationDataType,\n MatchType,\n MatchTypeTest,\n MatchTypeVariation,\n NameMatchType,\n TargetingType,\n ValueMatchType,\n VersionMatchType,\n VisitorType,\n} from 'src/targeting/types';\nimport { OperatingSystemType } from 'src/kameleoonData/types';\nimport { TimeUnit } from 'src/utilities';\n\nexport interface ICondition {\n evaluate: (data: EvaluationDataType) => Result<boolean, KameleoonError>;\n}\n\nexport type ConditionType = ICondition;\n\nexport type ConditionDataType = {\n id: number;\n targetingType: TargetingType;\n isInclude: boolean | null;\n weight: number;\n customDataIndex?: string | null;\n pageCount?: number | null;\n value?: string | null;\n valueMatchType?: ValueMatchType | null;\n experiment?: number | null;\n variation?: number | null;\n visitCount?: number | null;\n variationKey?: string | null;\n featureFlagId?: number | null;\n ruleId?: number | null;\n variationMatchType?: MatchTypeVariation | null;\n testMatchType?: MatchTypeTest | null;\n matchType?: MatchType | null;\n device?: DeviceType | null;\n browser?: BrowserType | null;\n os?: OperatingSystemType | null;\n name?: string | null;\n nameMatchType?: NameMatchType | null;\n country?: string | null;\n region?: string | null;\n city?: string | null;\n segmentId?: number | null;\n version?: string | null;\n versionMatchType?: VersionMatchType | null;\n visitorType?: VisitorType | null;\n count?: number | null;\n unitOfTime?: TimeUnit | null;\n title?: string | null;\n url?: string | null;\n goalId?: number | null;\n sdkLanguage?: SdkLanguageType | null;\n visitorCode?: string | null;\n lowerBound?: number;\n upperBound?: number;\n keyMomentId?: number;\n};\n"],"mappings":""}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../src/targeting/conditions/types.ts"],"sourcesContent":["import { Result } from 'ts-res';\nimport { SdkLanguageType } from 'src/constants';\nimport { BrowserType, DeviceType } from 'src/kameleoonData';\nimport { KameleoonError } from 'src/kameleoonError';\nimport {\n EvaluationDataType,\n MatchType,\n MatchTypeTest,\n MatchTypeVariation,\n NameMatchType,\n TargetingType,\n ValueMatchType,\n VersionMatchType,\n VisitorType,\n} from 'src/targeting/types';\nimport { OperatingSystemType } from 'src/kameleoonData/types';\nimport { TimeUnit } from 'src/utilities';\n\nexport interface ICondition {\n evaluate: (data: EvaluationDataType) => Result<boolean, KameleoonError>;\n}\n\nexport type ConditionType = ICondition;\n\nexport type ConditionDataType = {\n id: number;\n targetingType: TargetingType;\n isInclude: boolean | null;\n weight: number;\n customDataIndex?: string | null;\n pageCount?: number | null;\n value?: string | null;\n valueMatchType?: ValueMatchType | null;\n experiment?: number | null;\n variation?: number | null;\n visitCount?: number | null;\n variationKey?: string | null;\n featureFlagId?: number | null;\n ruleId?: number | null;\n variationMatchType?: MatchTypeVariation | null;\n testMatchType?: MatchTypeTest | null;\n matchType?: MatchType | null;\n device?: DeviceType | null;\n browser?: BrowserType | null;\n os?: OperatingSystemType | null;\n name?: string | null;\n nameMatchType?: NameMatchType | null;\n country?: string | null;\n region?: string | null;\n city?: string | null;\n segmentId?: number | null;\n version?: string | null;\n versionMatchType?: VersionMatchType | null;\n visitorType?: VisitorType | null;\n count?: number | null;\n unitOfTime?: TimeUnit | null;\n title?: string | null;\n url?: string | null;\n goalId?: number | null;\n sdkLanguage?: SdkLanguageType | null;\n visitorCode?: string | null;\n range?: number[] | null;\n lowerBound?: number;\n upperBound?: number;\n keyMomentId?: number;\n};\n"],"mappings":""}
@@ -67,7 +67,8 @@ export declare enum ValueMatchType {
67
67
  LOWER = "LOWER",
68
68
  GREATER = "GREATER",
69
69
  UNDEFINED = "UNDEFINED",
70
- AMONG_VALUES = "AMONG_VALUES"
70
+ AMONG_VALUES = "AMONG_VALUES",
71
+ RANGE = "RANGE"
71
72
  }
72
73
  export declare enum VisitorType {
73
74
  NEW = "NEW",
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.VisitorType=exports.VersionMatchType=exports.ValueMatchType=exports.TargetingType=exports.Operator=exports.NameMatchType=exports.MatchTypeVariation=exports.MatchTypeTest=exports.MatchType=void 0;let Operator=exports.Operator=function(a){return a.And="AND",a.Or="OR",a}({}),ValueMatchType=exports.ValueMatchType=function(a){return a.TRUE="TRUE",a.FALSE="FALSE",a.EXACT="EXACT",a.CONTAINS="CONTAINS",a.REGULAR_EXPRESSION="REGULAR_EXPRESSION",a.EQUAL="EQUAL",a.LOWER="LOWER",a.GREATER="GREATER",a.UNDEFINED="UNDEFINED",a.AMONG_VALUES="AMONG_VALUES",a}({}),VisitorType=exports.VisitorType=function(a){return a.NEW="NEW",a.RETURNING="RETURNING",a}({}),MatchTypeVariation=exports.MatchTypeVariation=function(a){return a.ANY="ANY",a.EXACT="EXACT",a}({}),MatchTypeTest=exports.MatchTypeTest=function(a){return a.ALL="ALL",a.TEST="TEST",a.PERSO="PERSO",a}({}),MatchType=exports.MatchType=function(a){return a.EXACT="EXACT",a.CONTAINS="CONTAINS",a.REGULAR_EXPRESSION="REGULAR_EXPRESSION",a.GREATER="GREATER",a.EQUAL="EQUAL",a.LOWER="LOWER",a}({}),VersionMatchType=exports.VersionMatchType=function(a){return a.GREATER="GREATER",a.EQUAL="EQUAL",a.LOWER="LOWER",a}({}),NameMatchType=exports.NameMatchType=function(a){return a.EXACT="EXACT",a.CONTAINS="CONTAINS",a.REGULAR_EXPRESSION="REGULAR_EXPRESSION",a.OPTIONAL="OPTIONAL",a}({}),TargetingType=exports.TargetingType=function(a){return a.PAGE_URL="PAGE_URL",a.PAGE_TITLE="PAGE_TITLE",a.LANDING_PAGE="LANDING_PAGE",a.ORIGIN="ORIGIN",a.ORIGIN_TYPE="ORIGIN_TYPE",a.REFERRERS="REFERRERS",a.NEW_VISITORS="NEW_VISITORS",a.INTERESTS="INTERESTS",a.BROWSER_LANGUAGE="BROWSER_LANGUAGE",a.GEOLOCATION="GEOLOCATION",a.DEVICE_TYPE="DEVICE_TYPE",a.SCREEN_DIMENSION="SCREEN_DIMENSION",a.VISITOR_IP="VISITOR_IP",a.AD_BLOCKER="AD_BLOCKER",a.PREVIOUS_PAGE="PREVIOUS_PAGE",a.KEY_PAGES="KEY_PAGES",a.PAGE_VIEWS="PAGE_VIEWS",a.FIRST_VISIT="FIRST_VISIT",a.LAST_VISIT="LAST_VISIT",a.ACTIVE_SESSION="ACTIVE_SESSION",a.TIME_SINCE_PAGE_LOAD="TIME_SINCE_PAGE_LOAD",a.SAME_DAY_VISITS="SAME_DAY_VISITS",a.VISITS="VISITS",a.VISITS_BY_PAGE="VISITS_BY_PAGE",a.VISITOR_CODE="VISITOR_CODE",a.SDK_LANGUAGE="SDK_LANGUAGE",a.INTERNAL_SEARCH_KEYWORDS="INTERNAL_SEARCH_KEYWORDS",a.TABS_ON_SITE="TABS_ON_SITE",a.CONVERSION_PROBABILITY="CONVERSION_PROBABILITY",a.HEAT_SLICE="HEAT_SLICE",a.SKY_STATUS="SKY_STATUS",a.TEMPERATURE="TEMPERATURE",a.DAY_NIGHT="DAY_NIGHT",a.FORECAST_SKY_STATUS="FORECAST_SKY_STATUS",a.FORECAST_TEMPERATURE="FORECAST_TEMPERATURE",a.DAY_OF_WEEK="DAY_OF_WEEK",a.TIME_RANGE="TIME_RANGE",a.HOUR_MINUTE_RANGE="HOUR_MINUTE_RANGE",a.JS_CODE="JS_CODE",a.COOKIE="COOKIE",a.EVENT="EVENT",a.BROWSER="BROWSER",a.OPERATING_SYSTEM="OPERATING_SYSTEM",a.DOM_ELEMENT="DOM_ELEMENT",a.MOUSE_OUT="MOUSE_OUT",a.TARGET_EXPERIMENT="TARGET_EXPERIMENT",a.TARGET_FEATURE_FLAG="TARGET_FEATURE_FLAG",a.TARGET_PERSONALIZATION="TARGET_PERSONALIZATION",a.EXCLUSIVE_EXPERIMENT="EXCLUSIVE_EXPERIMENT",a.EXCLUSIVE_FEATURE_FLAG="EXCLUSIVE_FEATURE_FLAG",a.CONVERSIONS="CONVERSIONS",a.CUSTOM_DATUM="CUSTOM_DATUM",a.YSANCE_SEGMENT="YSANCE_SEGMENT",a.SEGMENT="SEGMENT",a.YSANCE_ATTRIBUT="YSANCE_ATTRIBUT",a.TEALIUM_BADGE="TEALIUM_BADGE",a.TEALIUM_AUDIENCE="TEALIUM_AUDIENCE",a.PRICE_OF_DISPLAYED_PAGE="PRICE_OF_DISPLAYED_PAGE",a.NUMBER_OF_VISITED_PAGES="NUMBER_OF_VISITED_PAGES",a.VISITED_PAGES="VISITED_PAGES",a.CUSTOM="CUSTOM",a.EXPLICIT_TRIGGER="EXPLICIT_TRIGGER",a.APPLICATION_VERSION="APPLICATION_VERSION",a}({});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.VisitorType=exports.VersionMatchType=exports.ValueMatchType=exports.TargetingType=exports.Operator=exports.NameMatchType=exports.MatchTypeVariation=exports.MatchTypeTest=exports.MatchType=void 0;let Operator=exports.Operator=function(a){return a.And="AND",a.Or="OR",a}({}),ValueMatchType=exports.ValueMatchType=function(a){return a.TRUE="TRUE",a.FALSE="FALSE",a.EXACT="EXACT",a.CONTAINS="CONTAINS",a.REGULAR_EXPRESSION="REGULAR_EXPRESSION",a.EQUAL="EQUAL",a.LOWER="LOWER",a.GREATER="GREATER",a.UNDEFINED="UNDEFINED",a.AMONG_VALUES="AMONG_VALUES",a.RANGE="RANGE",a}({}),VisitorType=exports.VisitorType=function(a){return a.NEW="NEW",a.RETURNING="RETURNING",a}({}),MatchTypeVariation=exports.MatchTypeVariation=function(a){return a.ANY="ANY",a.EXACT="EXACT",a}({}),MatchTypeTest=exports.MatchTypeTest=function(a){return a.ALL="ALL",a.TEST="TEST",a.PERSO="PERSO",a}({}),MatchType=exports.MatchType=function(a){return a.EXACT="EXACT",a.CONTAINS="CONTAINS",a.REGULAR_EXPRESSION="REGULAR_EXPRESSION",a.GREATER="GREATER",a.EQUAL="EQUAL",a.LOWER="LOWER",a}({}),VersionMatchType=exports.VersionMatchType=function(a){return a.GREATER="GREATER",a.EQUAL="EQUAL",a.LOWER="LOWER",a}({}),NameMatchType=exports.NameMatchType=function(a){return a.EXACT="EXACT",a.CONTAINS="CONTAINS",a.REGULAR_EXPRESSION="REGULAR_EXPRESSION",a.OPTIONAL="OPTIONAL",a}({}),TargetingType=exports.TargetingType=function(a){return a.PAGE_URL="PAGE_URL",a.PAGE_TITLE="PAGE_TITLE",a.LANDING_PAGE="LANDING_PAGE",a.ORIGIN="ORIGIN",a.ORIGIN_TYPE="ORIGIN_TYPE",a.REFERRERS="REFERRERS",a.NEW_VISITORS="NEW_VISITORS",a.INTERESTS="INTERESTS",a.BROWSER_LANGUAGE="BROWSER_LANGUAGE",a.GEOLOCATION="GEOLOCATION",a.DEVICE_TYPE="DEVICE_TYPE",a.SCREEN_DIMENSION="SCREEN_DIMENSION",a.VISITOR_IP="VISITOR_IP",a.AD_BLOCKER="AD_BLOCKER",a.PREVIOUS_PAGE="PREVIOUS_PAGE",a.KEY_PAGES="KEY_PAGES",a.PAGE_VIEWS="PAGE_VIEWS",a.FIRST_VISIT="FIRST_VISIT",a.LAST_VISIT="LAST_VISIT",a.ACTIVE_SESSION="ACTIVE_SESSION",a.TIME_SINCE_PAGE_LOAD="TIME_SINCE_PAGE_LOAD",a.SAME_DAY_VISITS="SAME_DAY_VISITS",a.VISITS="VISITS",a.VISITS_BY_PAGE="VISITS_BY_PAGE",a.VISITOR_CODE="VISITOR_CODE",a.SDK_LANGUAGE="SDK_LANGUAGE",a.INTERNAL_SEARCH_KEYWORDS="INTERNAL_SEARCH_KEYWORDS",a.TABS_ON_SITE="TABS_ON_SITE",a.CONVERSION_PROBABILITY="CONVERSION_PROBABILITY",a.HEAT_SLICE="HEAT_SLICE",a.SKY_STATUS="SKY_STATUS",a.TEMPERATURE="TEMPERATURE",a.DAY_NIGHT="DAY_NIGHT",a.FORECAST_SKY_STATUS="FORECAST_SKY_STATUS",a.FORECAST_TEMPERATURE="FORECAST_TEMPERATURE",a.DAY_OF_WEEK="DAY_OF_WEEK",a.TIME_RANGE="TIME_RANGE",a.HOUR_MINUTE_RANGE="HOUR_MINUTE_RANGE",a.JS_CODE="JS_CODE",a.COOKIE="COOKIE",a.EVENT="EVENT",a.BROWSER="BROWSER",a.OPERATING_SYSTEM="OPERATING_SYSTEM",a.DOM_ELEMENT="DOM_ELEMENT",a.MOUSE_OUT="MOUSE_OUT",a.TARGET_EXPERIMENT="TARGET_EXPERIMENT",a.TARGET_FEATURE_FLAG="TARGET_FEATURE_FLAG",a.TARGET_PERSONALIZATION="TARGET_PERSONALIZATION",a.EXCLUSIVE_EXPERIMENT="EXCLUSIVE_EXPERIMENT",a.EXCLUSIVE_FEATURE_FLAG="EXCLUSIVE_FEATURE_FLAG",a.CONVERSIONS="CONVERSIONS",a.CUSTOM_DATUM="CUSTOM_DATUM",a.YSANCE_SEGMENT="YSANCE_SEGMENT",a.SEGMENT="SEGMENT",a.YSANCE_ATTRIBUT="YSANCE_ATTRIBUT",a.TEALIUM_BADGE="TEALIUM_BADGE",a.TEALIUM_AUDIENCE="TEALIUM_AUDIENCE",a.PRICE_OF_DISPLAYED_PAGE="PRICE_OF_DISPLAYED_PAGE",a.NUMBER_OF_VISITED_PAGES="NUMBER_OF_VISITED_PAGES",a.VISITED_PAGES="VISITED_PAGES",a.CUSTOM="CUSTOM",a.EXPLICIT_TRIGGER="EXPLICIT_TRIGGER",a.APPLICATION_VERSION="APPLICATION_VERSION",a}({});
2
2
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":["Operator","exports","And","Or","ValueMatchType","TRUE","FALSE","EXACT","CONTAINS","REGULAR_EXPRESSION","EQUAL","LOWER","GREATER","UNDEFINED","AMONG_VALUES","VisitorType","NEW","RETURNING","MatchTypeVariation","ANY","MatchTypeTest","ALL","TEST","PERSO","MatchType","VersionMatchType","NameMatchType","OPTIONAL","TargetingType","PAGE_URL","PAGE_TITLE","LANDING_PAGE","ORIGIN","ORIGIN_TYPE","REFERRERS","NEW_VISITORS","INTERESTS","BROWSER_LANGUAGE","GEOLOCATION","DEVICE_TYPE","SCREEN_DIMENSION","VISITOR_IP","AD_BLOCKER","PREVIOUS_PAGE","KEY_PAGES","PAGE_VIEWS","FIRST_VISIT","LAST_VISIT","ACTIVE_SESSION","TIME_SINCE_PAGE_LOAD","SAME_DAY_VISITS","VISITS","VISITS_BY_PAGE","VISITOR_CODE","SDK_LANGUAGE","INTERNAL_SEARCH_KEYWORDS","TABS_ON_SITE","CONVERSION_PROBABILITY","HEAT_SLICE","SKY_STATUS","TEMPERATURE","DAY_NIGHT","FORECAST_SKY_STATUS","FORECAST_TEMPERATURE","DAY_OF_WEEK","TIME_RANGE","HOUR_MINUTE_RANGE","JS_CODE","COOKIE","EVENT","BROWSER","OPERATING_SYSTEM","DOM_ELEMENT","MOUSE_OUT","TARGET_EXPERIMENT","TARGET_FEATURE_FLAG","TARGET_PERSONALIZATION","EXCLUSIVE_EXPERIMENT","EXCLUSIVE_FEATURE_FLAG","CONVERSIONS","CUSTOM_DATUM","YSANCE_SEGMENT","SEGMENT","YSANCE_ATTRIBUT","TEALIUM_BADGE","TEALIUM_AUDIENCE","PRICE_OF_DISPLAYED_PAGE","NUMBER_OF_VISITED_PAGES","VISITED_PAGES","CUSTOM","EXPLICIT_TRIGGER","APPLICATION_VERSION"],"sources":["../../src/targeting/types.ts"],"sourcesContent":["import { MappedRuleType } from 'src/clientConfiguration/types';\nimport { KameleoonVisitorDataType } from 'src/kameleoonData/types';\nimport { FeatureFlagVariationsType } from 'src/storage/types';\nimport { ExternalPackageInfoType } from 'src/types';\nimport { ConditionDataType, ConditionType } from './conditions';\nimport { Node } from './node';\nimport { Tree } from './tree';\n\nexport enum Operator {\n And = 'AND',\n Or = 'OR',\n}\n\nexport type NonLeafNodeType = {\n left: Node;\n right: Node;\n value: Operator;\n};\n\nexport type LeafNodeType = {\n left: undefined;\n right: undefined;\n value: ConditionType;\n};\n\nexport type NodeValueType = ConditionType | Operator;\n\nexport type ConditionLevelType = {\n orOperators: boolean[];\n conditions: ConditionDataType[];\n};\n\nexport type SegmentType = {\n id: string;\n name: string;\n conditionsData: {\n firstLevelOrOperators: boolean[];\n firstLevel: ConditionLevelType[];\n };\n};\n\nexport type NestedConditionGroupType = {\n operators: Operator[];\n conditions: ConditionDataType[];\n};\n\nexport type GroupedSegmentsType = {\n topLevelOperators: Operator[];\n nestedConditions: NestedConditionGroupType[];\n};\n\nexport type VisitorReference = string;\n\nexport type TargetingDataType = {\n [visitorCode: string]: KameleoonVisitorDataType | VisitorReference;\n};\n\nexport type DereferencedTargetingDataType = {\n [visitorCode: string]: KameleoonVisitorDataType;\n};\n\nexport type EvaluationDataType = {\n targetingData?: KameleoonVisitorDataType;\n variationData: FeatureFlagVariationsType;\n ruleMap?: Map<number, MappedRuleType>;\n sdkInfo: ExternalPackageInfoType;\n experimentId: number | null;\n visitorCode: string;\n segments?: Map<string, SegmentType>;\n trees?: Map<string, Tree>;\n};\n\nexport enum ValueMatchType {\n TRUE = 'TRUE',\n FALSE = 'FALSE',\n EXACT = 'EXACT',\n CONTAINS = 'CONTAINS',\n REGULAR_EXPRESSION = 'REGULAR_EXPRESSION',\n EQUAL = 'EQUAL',\n LOWER = 'LOWER',\n GREATER = 'GREATER',\n UNDEFINED = 'UNDEFINED',\n AMONG_VALUES = 'AMONG_VALUES',\n}\n\nexport enum VisitorType {\n NEW = 'NEW',\n RETURNING = 'RETURNING',\n}\n\nexport enum MatchTypeVariation {\n ANY = 'ANY',\n EXACT = 'EXACT',\n}\n\nexport enum MatchTypeTest {\n ALL = 'ALL',\n TEST = 'TEST',\n PERSO = 'PERSO',\n}\n\n// --- Note ---\n// Starting the merge of `matchType` with the release of new conditions\n// Now it contains a couple of sub types, in future API version all match types\n// will be accumulated in this enum\nexport enum MatchType {\n // -- Sub Type One\n EXACT = 'EXACT',\n CONTAINS = 'CONTAINS',\n REGULAR_EXPRESSION = 'REGULAR_EXPRESSION',\n // -- Sub Type Two\n GREATER = 'GREATER',\n EQUAL = 'EQUAL',\n LOWER = 'LOWER',\n}\n\nexport enum VersionMatchType {\n GREATER = 'GREATER',\n EQUAL = 'EQUAL',\n LOWER = 'LOWER',\n}\n\nexport enum NameMatchType {\n EXACT = 'EXACT',\n CONTAINS = 'CONTAINS',\n REGULAR_EXPRESSION = 'REGULAR_EXPRESSION',\n OPTIONAL = 'OPTIONAL',\n}\n\nexport enum TargetingType {\n PAGE_URL = 'PAGE_URL',\n PAGE_TITLE = 'PAGE_TITLE',\n LANDING_PAGE = 'LANDING_PAGE',\n ORIGIN = 'ORIGIN',\n ORIGIN_TYPE = 'ORIGIN_TYPE',\n REFERRERS = 'REFERRERS',\n NEW_VISITORS = 'NEW_VISITORS',\n INTERESTS = 'INTERESTS',\n BROWSER_LANGUAGE = 'BROWSER_LANGUAGE',\n GEOLOCATION = 'GEOLOCATION',\n DEVICE_TYPE = 'DEVICE_TYPE',\n SCREEN_DIMENSION = 'SCREEN_DIMENSION',\n VISITOR_IP = 'VISITOR_IP',\n AD_BLOCKER = 'AD_BLOCKER',\n PREVIOUS_PAGE = 'PREVIOUS_PAGE',\n KEY_PAGES = 'KEY_PAGES',\n PAGE_VIEWS = 'PAGE_VIEWS',\n FIRST_VISIT = 'FIRST_VISIT',\n LAST_VISIT = 'LAST_VISIT',\n ACTIVE_SESSION = 'ACTIVE_SESSION',\n TIME_SINCE_PAGE_LOAD = 'TIME_SINCE_PAGE_LOAD',\n SAME_DAY_VISITS = 'SAME_DAY_VISITS',\n VISITS = 'VISITS',\n VISITS_BY_PAGE = 'VISITS_BY_PAGE',\n VISITOR_CODE = 'VISITOR_CODE',\n SDK_LANGUAGE = 'SDK_LANGUAGE',\n INTERNAL_SEARCH_KEYWORDS = 'INTERNAL_SEARCH_KEYWORDS',\n TABS_ON_SITE = 'TABS_ON_SITE',\n CONVERSION_PROBABILITY = 'CONVERSION_PROBABILITY',\n HEAT_SLICE = 'HEAT_SLICE',\n SKY_STATUS = 'SKY_STATUS',\n TEMPERATURE = 'TEMPERATURE',\n DAY_NIGHT = 'DAY_NIGHT',\n FORECAST_SKY_STATUS = 'FORECAST_SKY_STATUS',\n FORECAST_TEMPERATURE = 'FORECAST_TEMPERATURE',\n DAY_OF_WEEK = 'DAY_OF_WEEK',\n TIME_RANGE = 'TIME_RANGE',\n HOUR_MINUTE_RANGE = 'HOUR_MINUTE_RANGE',\n JS_CODE = 'JS_CODE',\n COOKIE = 'COOKIE',\n EVENT = 'EVENT',\n BROWSER = 'BROWSER',\n OPERATING_SYSTEM = 'OPERATING_SYSTEM',\n DOM_ELEMENT = 'DOM_ELEMENT',\n MOUSE_OUT = 'MOUSE_OUT',\n TARGET_EXPERIMENT = 'TARGET_EXPERIMENT',\n TARGET_FEATURE_FLAG = 'TARGET_FEATURE_FLAG',\n TARGET_PERSONALIZATION = 'TARGET_PERSONALIZATION',\n EXCLUSIVE_EXPERIMENT = 'EXCLUSIVE_EXPERIMENT',\n EXCLUSIVE_FEATURE_FLAG = 'EXCLUSIVE_FEATURE_FLAG',\n CONVERSIONS = 'CONVERSIONS',\n CUSTOM_DATUM = 'CUSTOM_DATUM',\n YSANCE_SEGMENT = 'YSANCE_SEGMENT',\n SEGMENT = 'SEGMENT',\n YSANCE_ATTRIBUT = 'YSANCE_ATTRIBUT',\n TEALIUM_BADGE = 'TEALIUM_BADGE',\n TEALIUM_AUDIENCE = 'TEALIUM_AUDIENCE',\n PRICE_OF_DISPLAYED_PAGE = 'PRICE_OF_DISPLAYED_PAGE',\n NUMBER_OF_VISITED_PAGES = 'NUMBER_OF_VISITED_PAGES',\n VISITED_PAGES = 'VISITED_PAGES',\n CUSTOM = 'CUSTOM',\n EXPLICIT_TRIGGER = 'EXPLICIT_TRIGGER',\n APPLICATION_VERSION = 'APPLICATION_VERSION',\n}\n"],"mappings":"kRAQY,CAAAA,QAAQ,CAAAC,OAAA,CAAAD,QAAA,UAARA,CAAQ,QAAR,CAAAA,CAAQ,CAAAE,GAAA,OAARF,CAAQ,CAAAG,EAAA,MAARH,CAAQ,MAgERI,cAAc,CAAAH,OAAA,CAAAG,cAAA,UAAdA,CAAc,QAAd,CAAAA,CAAc,CAAAC,IAAA,QAAdD,CAAc,CAAAE,KAAA,SAAdF,CAAc,CAAAG,KAAA,SAAdH,CAAc,CAAAI,QAAA,YAAdJ,CAAc,CAAAK,kBAAA,sBAAdL,CAAc,CAAAM,KAAA,SAAdN,CAAc,CAAAO,KAAA,SAAdP,CAAc,CAAAQ,OAAA,WAAdR,CAAc,CAAAS,SAAA,aAAdT,CAAc,CAAAU,YAAA,gBAAdV,CAAc,MAadW,WAAW,CAAAd,OAAA,CAAAc,WAAA,UAAXA,CAAW,QAAX,CAAAA,CAAW,CAAAC,GAAA,OAAXD,CAAW,CAAAE,SAAA,aAAXF,CAAW,MAKXG,kBAAkB,CAAAjB,OAAA,CAAAiB,kBAAA,UAAlBA,CAAkB,QAAlB,CAAAA,CAAkB,CAAAC,GAAA,OAAlBD,CAAkB,CAAAX,KAAA,SAAlBW,CAAkB,MAKlBE,aAAa,CAAAnB,OAAA,CAAAm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,2BAAb1D,CAAa,CAAA2D,uBAAA,2BAAb3D,CAAa,CAAA4D,aAAA,iBAAb5D,CAAa,CAAA6D,MAAA,UAAb7D,CAAa,CAAA8D,gBAAA,oBAAb9D,CAAa,CAAA+D,mBAAA,uBAAb/D,CAAa"}
1
+ {"version":3,"file":"types.js","names":["Operator","exports","And","Or","ValueMatchType","TRUE","FALSE","EXACT","CONTAINS","REGULAR_EXPRESSION","EQUAL","LOWER","GREATER","UNDEFINED","AMONG_VALUES","RANGE","VisitorType","NEW","RETURNING","MatchTypeVariation","ANY","MatchTypeTest","ALL","TEST","PERSO","MatchType","VersionMatchType","NameMatchType","OPTIONAL","TargetingType","PAGE_URL","PAGE_TITLE","LANDING_PAGE","ORIGIN","ORIGIN_TYPE","REFERRERS","NEW_VISITORS","INTERESTS","BROWSER_LANGUAGE","GEOLOCATION","DEVICE_TYPE","SCREEN_DIMENSION","VISITOR_IP","AD_BLOCKER","PREVIOUS_PAGE","KEY_PAGES","PAGE_VIEWS","FIRST_VISIT","LAST_VISIT","ACTIVE_SESSION","TIME_SINCE_PAGE_LOAD","SAME_DAY_VISITS","VISITS","VISITS_BY_PAGE","VISITOR_CODE","SDK_LANGUAGE","INTERNAL_SEARCH_KEYWORDS","TABS_ON_SITE","CONVERSION_PROBABILITY","HEAT_SLICE","SKY_STATUS","TEMPERATURE","DAY_NIGHT","FORECAST_SKY_STATUS","FORECAST_TEMPERATURE","DAY_OF_WEEK","TIME_RANGE","HOUR_MINUTE_RANGE","JS_CODE","COOKIE","EVENT","BROWSER","OPERATING_SYSTEM","DOM_ELEMENT","MOUSE_OUT","TARGET_EXPERIMENT","TARGET_FEATURE_FLAG","TARGET_PERSONALIZATION","EXCLUSIVE_EXPERIMENT","EXCLUSIVE_FEATURE_FLAG","CONVERSIONS","CUSTOM_DATUM","YSANCE_SEGMENT","SEGMENT","YSANCE_ATTRIBUT","TEALIUM_BADGE","TEALIUM_AUDIENCE","PRICE_OF_DISPLAYED_PAGE","NUMBER_OF_VISITED_PAGES","VISITED_PAGES","CUSTOM","EXPLICIT_TRIGGER","APPLICATION_VERSION"],"sources":["../../src/targeting/types.ts"],"sourcesContent":["import { MappedRuleType } from 'src/clientConfiguration/types';\nimport { KameleoonVisitorDataType } from 'src/kameleoonData/types';\nimport { FeatureFlagVariationsType } from 'src/storage/types';\nimport { ExternalPackageInfoType } from 'src/types';\nimport { ConditionDataType, ConditionType } from './conditions';\nimport { Node } from './node';\nimport { Tree } from './tree';\n\nexport enum Operator {\n And = 'AND',\n Or = 'OR',\n}\n\nexport type NonLeafNodeType = {\n left: Node;\n right: Node;\n value: Operator;\n};\n\nexport type LeafNodeType = {\n left: undefined;\n right: undefined;\n value: ConditionType;\n};\n\nexport type NodeValueType = ConditionType | Operator;\n\nexport type ConditionLevelType = {\n orOperators: boolean[];\n conditions: ConditionDataType[];\n};\n\nexport type SegmentType = {\n id: string;\n name: string;\n conditionsData: {\n firstLevelOrOperators: boolean[];\n firstLevel: ConditionLevelType[];\n };\n};\n\nexport type NestedConditionGroupType = {\n operators: Operator[];\n conditions: ConditionDataType[];\n};\n\nexport type GroupedSegmentsType = {\n topLevelOperators: Operator[];\n nestedConditions: NestedConditionGroupType[];\n};\n\nexport type VisitorReference = string;\n\nexport type TargetingDataType = {\n [visitorCode: string]: KameleoonVisitorDataType | VisitorReference;\n};\n\nexport type DereferencedTargetingDataType = {\n [visitorCode: string]: KameleoonVisitorDataType;\n};\n\nexport type EvaluationDataType = {\n targetingData?: KameleoonVisitorDataType;\n variationData: FeatureFlagVariationsType;\n ruleMap?: Map<number, MappedRuleType>;\n sdkInfo: ExternalPackageInfoType;\n experimentId: number | null;\n visitorCode: string;\n segments?: Map<string, SegmentType>;\n trees?: Map<string, Tree>;\n};\n\nexport enum ValueMatchType {\n TRUE = 'TRUE',\n FALSE = 'FALSE',\n EXACT = 'EXACT',\n CONTAINS = 'CONTAINS',\n REGULAR_EXPRESSION = 'REGULAR_EXPRESSION',\n EQUAL = 'EQUAL',\n LOWER = 'LOWER',\n GREATER = 'GREATER',\n UNDEFINED = 'UNDEFINED',\n AMONG_VALUES = 'AMONG_VALUES',\n RANGE = 'RANGE',\n}\n\nexport enum VisitorType {\n NEW = 'NEW',\n RETURNING = 'RETURNING',\n}\n\nexport enum MatchTypeVariation {\n ANY = 'ANY',\n EXACT = 'EXACT',\n}\n\nexport enum MatchTypeTest {\n ALL = 'ALL',\n TEST = 'TEST',\n PERSO = 'PERSO',\n}\n\n// --- Note ---\n// Starting the merge of `matchType` with the release of new conditions\n// Now it contains a couple of sub types, in future API version all match types\n// will be accumulated in this enum\nexport enum MatchType {\n // -- Sub Type One\n EXACT = 'EXACT',\n CONTAINS = 'CONTAINS',\n REGULAR_EXPRESSION = 'REGULAR_EXPRESSION',\n // -- Sub Type Two\n GREATER = 'GREATER',\n EQUAL = 'EQUAL',\n LOWER = 'LOWER',\n}\n\nexport enum VersionMatchType {\n GREATER = 'GREATER',\n EQUAL = 'EQUAL',\n LOWER = 'LOWER',\n}\n\nexport enum NameMatchType {\n EXACT = 'EXACT',\n CONTAINS = 'CONTAINS',\n REGULAR_EXPRESSION = 'REGULAR_EXPRESSION',\n OPTIONAL = 'OPTIONAL',\n}\n\nexport enum TargetingType {\n PAGE_URL = 'PAGE_URL',\n PAGE_TITLE = 'PAGE_TITLE',\n LANDING_PAGE = 'LANDING_PAGE',\n ORIGIN = 'ORIGIN',\n ORIGIN_TYPE = 'ORIGIN_TYPE',\n REFERRERS = 'REFERRERS',\n NEW_VISITORS = 'NEW_VISITORS',\n INTERESTS = 'INTERESTS',\n BROWSER_LANGUAGE = 'BROWSER_LANGUAGE',\n GEOLOCATION = 'GEOLOCATION',\n DEVICE_TYPE = 'DEVICE_TYPE',\n SCREEN_DIMENSION = 'SCREEN_DIMENSION',\n VISITOR_IP = 'VISITOR_IP',\n AD_BLOCKER = 'AD_BLOCKER',\n PREVIOUS_PAGE = 'PREVIOUS_PAGE',\n KEY_PAGES = 'KEY_PAGES',\n PAGE_VIEWS = 'PAGE_VIEWS',\n FIRST_VISIT = 'FIRST_VISIT',\n LAST_VISIT = 'LAST_VISIT',\n ACTIVE_SESSION = 'ACTIVE_SESSION',\n TIME_SINCE_PAGE_LOAD = 'TIME_SINCE_PAGE_LOAD',\n SAME_DAY_VISITS = 'SAME_DAY_VISITS',\n VISITS = 'VISITS',\n VISITS_BY_PAGE = 'VISITS_BY_PAGE',\n VISITOR_CODE = 'VISITOR_CODE',\n SDK_LANGUAGE = 'SDK_LANGUAGE',\n INTERNAL_SEARCH_KEYWORDS = 'INTERNAL_SEARCH_KEYWORDS',\n TABS_ON_SITE = 'TABS_ON_SITE',\n CONVERSION_PROBABILITY = 'CONVERSION_PROBABILITY',\n HEAT_SLICE = 'HEAT_SLICE',\n SKY_STATUS = 'SKY_STATUS',\n TEMPERATURE = 'TEMPERATURE',\n DAY_NIGHT = 'DAY_NIGHT',\n FORECAST_SKY_STATUS = 'FORECAST_SKY_STATUS',\n FORECAST_TEMPERATURE = 'FORECAST_TEMPERATURE',\n DAY_OF_WEEK = 'DAY_OF_WEEK',\n TIME_RANGE = 'TIME_RANGE',\n HOUR_MINUTE_RANGE = 'HOUR_MINUTE_RANGE',\n JS_CODE = 'JS_CODE',\n COOKIE = 'COOKIE',\n EVENT = 'EVENT',\n BROWSER = 'BROWSER',\n OPERATING_SYSTEM = 'OPERATING_SYSTEM',\n DOM_ELEMENT = 'DOM_ELEMENT',\n MOUSE_OUT = 'MOUSE_OUT',\n TARGET_EXPERIMENT = 'TARGET_EXPERIMENT',\n TARGET_FEATURE_FLAG = 'TARGET_FEATURE_FLAG',\n TARGET_PERSONALIZATION = 'TARGET_PERSONALIZATION',\n EXCLUSIVE_EXPERIMENT = 'EXCLUSIVE_EXPERIMENT',\n EXCLUSIVE_FEATURE_FLAG = 'EXCLUSIVE_FEATURE_FLAG',\n CONVERSIONS = 'CONVERSIONS',\n CUSTOM_DATUM = 'CUSTOM_DATUM',\n YSANCE_SEGMENT = 'YSANCE_SEGMENT',\n SE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,CAAA4D,aAAA,iBAAb5D,CAAa,CAAA6D,MAAA,UAAb7D,CAAa,CAAA8D,gBAAA,oBAAb9D,CAAa,CAAA+D,mBAAA,uBAAb/D,CAAa"}
package/dist/types.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { ConfigurationDataType, JSONType } from './clientConfiguration/types';
1
+ import { ClientConfigurationDataType, ConfigurationDataType, JSONType } from './clientConfiguration/types';
2
2
  import { SdkLanguageType } from './constants';
3
3
  import { IExternalEventSource } from './eventSource';
4
- import { IExternalRequestDispatcher } from './requester';
4
+ import { IExternalRequester, RequestType } from './requester';
5
5
  import { IExternalStorage } from './storage';
6
6
  import { VisitorDataFiltersType } from './utilities';
7
7
  import { IVisitorCodeManager } from './visitorCodeManager';
@@ -19,7 +19,9 @@ import { IVisitorCodeManager } from './visitorCodeManager';
19
19
  * - React/React Native SDK: `undefined` (no cleanup)
20
20
  * - NodeJS SDK: `30`
21
21
  *
22
- * @param {string | undefined} domain - domain which cookie belongs to
22
+ * @param {string | undefined} domain - domain which cookie which Kameleoon visitor code belongs to. Note: parameter `domain` is deprecated and will be removed in the next major update, use `cookieDomain` instead
23
+ * @param {string | undefined} cookieDomain - domain which cookie which Kameleoon visitor code belongs to
24
+ * @param {string | undefined} networkDomain - custom domain to be used in place of all requests URL, domain format is `example.com`, if the format is incorrect, default Kameleoon domain will be used
23
25
  * @param {number | undefined} requestTimeout - timeout in _milliseconds_ for requests
24
26
  * @defaultvalue `10_000` (10 seconds)
25
27
  * */
@@ -29,6 +31,8 @@ export type SDKConfigurationType = {
29
31
  targetingDataCleanupInterval?: number;
30
32
  requestTimeout?: number;
31
33
  domain?: string;
34
+ networkDomain?: string;
35
+ cookieDomain?: string;
32
36
  };
33
37
  /**
34
38
  * @param {string} siteCode - client's siteCode defined on Kameleoon platform
@@ -53,7 +57,7 @@ export type ExternalPackageInfoType = {
53
57
  * @param {IExternalEventSourceConstructor | undefined} externalEventSource - constructor for building external event source implementation
54
58
  * @param {ExternalPackageInfoType} externalPackageInfo - external package info, used to get package version and name
55
59
  * @param {ConfigurationDataType} externalClientConfiguration - external fetched client configuration
56
- * @param {IExternalRequestDispatcher} externalRequestDispatcher - external request dispatcher, used to track data or get data
60
+ * @param {IExternalRequester} externalRequester - external requester , used to track or get data
57
61
  * @param {IVisitorCodeManager} externalVisitorCodeManager - external visitor code manager, used to get or generate visitor code
58
62
  * @param {number} targetingDataCleanupInterval - interval in *minutes* for cleaning up targeting data, minimum value is 1 minute
59
63
  * */
@@ -62,7 +66,7 @@ export type InternalSDKConfigurationType = {
62
66
  externalEventSource: IExternalEventSource;
63
67
  externalVisitorCodeManager: IVisitorCodeManager;
64
68
  externalPackageInfo: ExternalPackageInfoType;
65
- externalRequestDispatcher: IExternalRequestDispatcher;
69
+ externalRequester: IExternalRequester;
66
70
  externalClientConfiguration?: ConfigurationDataType;
67
71
  };
68
72
  /**
@@ -223,3 +227,11 @@ export type SetUserConsentParametersType = {
223
227
  consent: boolean;
224
228
  setData: ({ visitorCode, maxAge, path, }: SetDataCallbackParametersType) => void;
225
229
  };
230
+ /**
231
+ * @type `SimulateRequestDataType` a type of data provided to `simulateSuccessRequest` method depending on `RequestType`
232
+ * */
233
+ export type SimulateRequestDataType = {
234
+ [RequestType.Configuration]: ClientConfigurationDataType;
235
+ [RequestType.RemoteData]: JSONType;
236
+ [RequestType.Tracking]: null;
237
+ };
package/dist/types.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.VariableType=exports.Milliseconds=exports.Environment=void 0;let Environment=exports.Environment=function(a){return a.Production="production",a.Staging="staging",a.Development="development",a}({}),VariableType=exports.VariableType=function(a){return a.BOOLEAN="BOOLEAN",a.NUMBER="NUMBER",a.STRING="STRING",a.JSON="JSON",a}({}),Milliseconds=exports.Milliseconds=function(a){return a[a.Second=1000]="Second",a[a.Minute=60*a.Second]="Minute",a[a.Hour=60*a.Minute]="Hour",a[a.Day=24*a.Hour]="Day",a[a.Week=7*a.Day]="Week",a[a.Month=30*a.Day]="Month",a}({});
1
+ "use strict";var _requester=require("./requester");Object.defineProperty(exports,"__esModule",{value:!0}),exports.VariableType=exports.Milliseconds=exports.Environment=void 0;let Environment=exports.Environment=function(a){return a.Production="production",a.Staging="staging",a.Development="development",a}({}),VariableType=exports.VariableType=function(a){return a.BOOLEAN="BOOLEAN",a.NUMBER="NUMBER",a.STRING="STRING",a.JSON="JSON",a}({}),Milliseconds=exports.Milliseconds=function(a){return a[a.Second=1000]="Second",a[a.Minute=60*a.Second]="Minute",a[a.Hour=60*a.Minute]="Hour",a[a.Day=24*a.Hour]="Day",a[a.Week=7*a.Day]="Week",a[a.Month=30*a.Day]="Month",a}({});
2
2
  //# sourceMappingURL=types.js.map
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":["Environment","exports","Production","Staging","Development","VariableType","BOOLEAN","NUMBER","STRING","JSON","Milliseconds","Second","Minute","Hour","Day","Week","Month"],"sources":["../src/types.ts"],"sourcesContent":["import { ConfigurationDataType, JSONType } from './clientConfiguration/types';\nimport { SdkLanguageType } from './constants';\nimport { IExternalEventSource } from './eventSource';\nimport { IExternalRequestDispatcher } from './requester';\nimport { IExternalStorage } from './storage';\nimport { VisitorDataFiltersType } from './utilities';\nimport { IVisitorCodeManager } from './visitorCodeManager';\n\n/**\n * @param {number} updateInterval - update interval in _minutes_ for sdk configuration, minimum value is 1 minute\n * @defaultvalue 60\n *\n * @param {Environment} environment - feature flag environment\n * @defaultvalue Environment.Production\n *\n * @param {number | undefined} targetingDataCleanupInterval - interval in _minutes_ for cleaning up targeting data, minimum value is 1 minute\n * Note: if not specified, default value will be used\n * @defaultvalue\n * - JavaScript SDK: `undefined` (no cleanup)\n * - React/React Native SDK: `undefined` (no cleanup)\n * - NodeJS SDK: `30`\n *\n * @param {string | undefined} domain - domain which cookie belongs to\n * @param {number | undefined} requestTimeout - timeout in _milliseconds_ for requests\n * @defaultvalue `10_000` (10 seconds)\n * */\nexport type SDKConfigurationType = {\n updateInterval?: number;\n environment?: Environment;\n targetingDataCleanupInterval?: number;\n requestTimeout?: number;\n domain?: string;\n};\n\n/**\n * @param {string} siteCode - client's siteCode defined on Kameleoon platform\n * @param {Partial<SDKConfigurationType>} configuration - client's configuration\n * @param {InternalSDKConfigurationType} internalConfiguration - internal configuration for sdk core to be initialized with certain parameters to certain type of JavaScript SDK\n * */\nexport type SDKCoreParameters = {\n siteCode: string;\n configuration?: Partial<SDKConfigurationType>;\n internalConfiguration: InternalSDKConfigurationType;\n};\n\n/**\n * @param {SdkLanguageType} type - type of the SDK\n * @param {string} version - version of the package\n * */\nexport type ExternalPackageInfoType = {\n type: SdkLanguageType;\n version: string;\n};\n\n/**\n * @param {IExternalStorage | undefined} externalStorage - external file system storage implemented outside client initialization\n * @param {IExternalEventSourceConstructor | undefined} externalEventSource - constructor for building external event source implementation\n * @param {ExternalPackageInfoType} externalPackageInfo - external package info, used to get package version and name\n * @param {ConfigurationDataType} externalClientConfiguration - external fetched client configuration\n * @param {IExternalRequestDispatcher} externalRequestDispatcher - external request dispatcher, used to track data or get data\n * @param {IVisitorCodeManager} externalVisitorCodeManager - external visitor code manager, used to get or generate visitor code\n * @param {number} targetingDataCleanupInterval - interval in *minutes* for cleaning up targeting data, minimum value is 1 minute\n * */\nexport type InternalSDKConfigurationType = {\n externalStorage: IExternalStorage;\n externalEventSource: IExternalEventSource;\n externalVisitorCodeManager: IVisitorCodeManager;\n externalPackageInfo: ExternalPackageInfoType;\n externalRequestDispatcher: IExternalRequestDispatcher;\n externalClientConfiguration?: ConfigurationDataType;\n};\n\n/**\n * @readonly\n * @enum {string} an Enum containing all possible variants of environment, passed as an argument to KameleoonClient `configuration`s `environment` field\n * */\nexport enum Environment {\n Production = 'production',\n Staging = 'staging',\n Development = 'development',\n}\n\n/**\n * @readonly\n * @enum {string} an Enum containing all possible variants of feature variable types\n * */\nexport enum VariableType {\n BOOLEAN = 'BOOLEAN',\n NUMBER = 'NUMBER',\n STRING = 'STRING',\n JSON = 'JSON',\n}\n\nexport type BooleanVariableType = {\n key: string;\n type: VariableType.BOOLEAN;\n value: boolean;\n};\n\nexport type NumberVariableType = {\n key: string;\n type: VariableType.NUMBER;\n value: number;\n};\n\nexport type StringVariableType = {\n key: string;\n type: VariableType.STRING;\n value: string;\n};\n\nexport type JSONVariableType = {\n key: string;\n type: VariableType.JSON;\n value: JSONType;\n};\n\n/**\n * @type `FeatureVariableResultType` - tuple of possible feature variable result types, each possible variation is an object containing `key`, `type` and `value` fields, `type` can be checked against `VariableType` enum, if the `type` is `VariableType.BOOLEAN` then the `value` type will be `boolean` and so on.\n * */\nexport type FeatureVariableResultType =\n | BooleanVariableType\n | NumberVariableType\n | StringVariableType\n | JSONVariableType;\n\n/**\n * @type `FeatureFlagVariableType` - tuple of possible feature variable result types, each possible variation is an object containing `type` and `value` fields, `type` can be checked against `VariableType` enum, if the `type` is `VariableType.BOOLEAN` then the `value` type will be `boolean` and so on.\n * */\nexport type FeatureFlagVariableType = Omit<FeatureVariableResultType, 'key'>;\n\n/**\n * @readonly\n * @enum {number} a helper Enum for getting milliseconds for a second/minute/hour/day/week/month.\n * Month is considered in average of 30 days\n * */\nexport enum Milliseconds {\n Second = 1000,\n Minute = 60 * Milliseconds.Second,\n Hour = 60 * Milliseconds.Minute,\n Day = 24 * Milliseconds.Hour,\n Week = 7 * Milliseconds.Day,\n Month = 30 * Milliseconds.Day,\n}\n\n/**\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * @param {number} goalId - an id of a goal to track\n * @param {number | undefined} revenue - an optional parameter for revenue, default value is `0`\n * @param {boolean | undefined} isUniqueIdentifier - an optional parameter for specifying if the visitorCode is a unique identifier, default value is `false`\n * */\nexport type TrackConversionParamsType = {\n visitorCode: string;\n goalId: number;\n revenue?: number;\n isUniqueIdentifier?: boolean;\n};\n\n/**\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * @param {boolean | undefined} shouldAddData - optional parameter for adding retrieved data to the storage like `addData` method does, default value is `true`\n * @param {VisitorDataFiltersType | undefined} filters - optional parameter for specifying the filters for which data should be retrieved from what visit, by default only current and latest previous visits' `customData` is retrieved\n * @param {boolean | undefined} isUniqueIdentifier - an optional parameter for specifying if the visitorCode is a unique identifier, default value is `false`\n * */\nexport type RemoteVisitorDataParamsType = {\n visitorCode: string;\n shouldAddData?: boolean;\n filters?: VisitorDataFiltersType;\n isUniqueIdentifier?: boolean;\n};\n\nexport type GetFeatureVariablesParamsType = {\n visitorCode: string;\n featureKey: string;\n variationKey: string;\n};\n\nexport type FeatureFlagType = {\n id: number;\n key: string;\n};\n\n/**\n * @type `KameleoonVariableType` - tuple of possible feature variable result types, each possible variation is an object containing `key`, `type` and `value` fields, `type` can be checked against `VariableType` enum, if the `type` is `VariableType.BOOLEAN` then the `value` type will be `boolean` and so on.\n * */\nexport type KameleoonVariableType = FeatureVariableResultType;\n\n/**\n * @type `KameleoonVariationType` - object containing information about the variation and its variables\n * @param {string} key - key of the variation\n * @param {number | null} id - id of the variation or `null` if the visitor hit default variation\n * @param {number | null} experimentId - id of the experiment or `null` if the visitor hit default variation\n * @param {KameleoonVariableType[]} variables - array of variables for the variation\n * */\nexport type KameleoonVariationType = {\n key: string;\n id: number | null;\n experimentId: number | null;\n variables: KameleoonVariableType[];\n};\n\n/**\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * @param {string} featureKey - key of the feature flag to look for, can be found on Kameleoon Platform\n * @param {string} variableKey - key of the variable to be found for a feature flag with provided `featureKey`, can be found on Kameleoon Platform\n * */\nexport type GetFeatureFlagVariableParamsType = {\n visitorCode: string;\n featureKey: string;\n variableKey: string;\n};\n\n/**\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @param {number} customDataIndex - index of the custom data in the warehouse audience\n * @param {string | undefined} warehouseKey - unique key to identify the warehouse data (usually internal user ID)\n * If not specified, the `visitorCode` will be used as a `warehouseKey`\n * */\nexport type GetVisitorWarehouseAudienceParamsType = {\n visitorCode: string;\n customDataIndex: number;\n warehouseKey?: string;\n};\n\nexport type WarehouseAudienceType = {\n // --- Note ---\n // Using `unknown` type here because we don't care about the type of the value\n warehouseAudiences: Record<string, unknown>;\n};\n\nexport type TrackingCacheItemType = {\n [experimentId: number]: { variationId: number; expirationTime: number };\n};\n\nexport type SetDataCallbackParametersType = {\n visitorCode: string;\n maxAge: number;\n path: string;\n key: string;\n};\n\n/**\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * @param {boolean} consent - a value representing the legal consent status. - 'true' indicates the\n * visitor has given legal consent. - 'false' indicates the visitor has withdrawn or not\n * provided legal consent.\n * @param {(visitorCode: string) => void} setData - a callback to set a visitor code in cookie\n * */\nexport type SetUserConsentParametersType = {\n visitorCode: string;\n consent: boolean;\n setData: ({\n visitorCode,\n maxAge,\n path,\n }: SetDataCallbackParametersType) => void;\n};\n"],"mappings":"4IA4EY,CAAAA,WAAW,CAAAC,OAAA,CAAAD,WAAA,UAAXA,CAAW,QAAX,CAAAA,CAAW,CAAAE,UAAA,cAAXF,CAAW,CAAAG,OAAA,WAAXH,CAAW,CAAAI,WAAA,eAAXJ,CAAW,MAUXK,YAAY,CAAAJ,OAAA,CAAAI,YAAA,UAAZA,CAAY,QAAZ,CAAAA,CAAY,CAAAC,OAAA,WAAZD,CAAY,CAAAE,MAAA,UAAZF,CAAY,CAAAG,MAAA,UAAZH,CAAY,CAAAI,IAAA,QAAZJ,CAAY,MAkDZK,YAAY,CAAAT,OAAA,CAAAS,YAAA,UAAZA,CAAY,QAAZ,CAAAA,CAAY,CAAZA,CAAY,CAAAC,MAAA,gBAAZD,CAAY,CAAZA,CAAY,CAAAE,MAAA,CAEb,EAAE,CAAGF,CAAY,CAACC,MAAM,WAFvBD,CAAY,CAAZA,CAAY,CAAAG,IAAA,CAGf,EAAE,CAAGH,CAAY,CAACE,MAAM,SAHrBF,CAAY,CAAZA,CAAY,CAAAI,GAAA,CAIhB,EAAE,CAAGJ,CAAY,CAACG,IAAI,QAJlBH,CAAY,CAAZA,CAAY,CAAAK,IAAA,CAKf,CAAC,CAAGL,CAAY,CAACI,GAAG,SALjBJ,CAAY,CAAZA,CAAY,CAAAM,KAAA,CAMd,EAAE,CAAGN,CAAY,CAACI,GAAG,UANnBJ,CAAY"}
1
+ {"version":3,"file":"types.js","names":["_requester","require","Object","defineProperty","exports","value","VariableType","Milliseconds","Environment","Production","Staging","Development","BOOLEAN","NUMBER","STRING","JSON","Second","Minute","Hour","Day","Week","Month"],"sources":["../src/types.ts"],"sourcesContent":["import {\n ClientConfigurationDataType,\n ConfigurationDataType,\n JSONType,\n} from './clientConfiguration/types';\nimport { SdkLanguageType } from './constants';\nimport { IExternalEventSource } from './eventSource';\nimport { IExternalRequester, RequestType } from './requester';\nimport { IExternalStorage } from './storage';\nimport { VisitorDataFiltersType } from './utilities';\nimport { IVisitorCodeManager } from './visitorCodeManager';\n\n/**\n * @param {number} updateInterval - update interval in _minutes_ for sdk configuration, minimum value is 1 minute\n * @defaultvalue 60\n *\n * @param {Environment} environment - feature flag environment\n * @defaultvalue Environment.Production\n *\n * @param {number | undefined} targetingDataCleanupInterval - interval in _minutes_ for cleaning up targeting data, minimum value is 1 minute\n * Note: if not specified, default value will be used\n * @defaultvalue\n * - JavaScript SDK: `undefined` (no cleanup)\n * - React/React Native SDK: `undefined` (no cleanup)\n * - NodeJS SDK: `30`\n *\n * @param {string | undefined} domain - domain which cookie which Kameleoon visitor code belongs to. Note: parameter `domain` is deprecated and will be removed in the next major update, use `cookieDomain` instead\n * @param {string | undefined} cookieDomain - domain which cookie which Kameleoon visitor code belongs to\n * @param {string | undefined} networkDomain - custom domain to be used in place of all requests URL, domain format is `example.com`, if the format is incorrect, default Kameleoon domain will be used\n * @param {number | undefined} requestTimeout - timeout in _milliseconds_ for requests\n * @defaultvalue `10_000` (10 seconds)\n * */\nexport type SDKConfigurationType = {\n updateInterval?: number;\n environment?: Environment;\n targetingDataCleanupInterval?: number;\n requestTimeout?: number;\n domain?: string;\n networkDomain?: string;\n cookieDomain?: string;\n};\n\n/**\n * @param {string} siteCode - client's siteCode defined on Kameleoon platform\n * @param {Partial<SDKConfigurationType>} configuration - client's configuration\n * @param {InternalSDKConfigurationType} internalConfiguration - internal configuration for sdk core to be initialized with certain parameters to certain type of JavaScript SDK\n * */\nexport type SDKCoreParameters = {\n siteCode: string;\n configuration?: Partial<SDKConfigurationType>;\n internalConfiguration: InternalSDKConfigurationType;\n};\n\n/**\n * @param {SdkLanguageType} type - type of the SDK\n * @param {string} version - version of the package\n * */\nexport type ExternalPackageInfoType = {\n type: SdkLanguageType;\n version: string;\n};\n\n/**\n * @param {IExternalStorage | undefined} externalStorage - external file system storage implemented outside client initialization\n * @param {IExternalEventSourceConstructor | undefined} externalEventSource - constructor for building external event source implementation\n * @param {ExternalPackageInfoType} externalPackageInfo - external package info, used to get package version and name\n * @param {ConfigurationDataType} externalClientConfiguration - external fetched client configuration\n * @param {IExternalRequester} externalRequester - external requester , used to track or get data\n * @param {IVisitorCodeManager} externalVisitorCodeManager - external visitor code manager, used to get or generate visitor code\n * @param {number} targetingDataCleanupInterval - interval in *minutes* for cleaning up targeting data, minimum value is 1 minute\n * */\nexport type InternalSDKConfigurationType = {\n externalStorage: IExternalStorage;\n externalEventSource: IExternalEventSource;\n externalVisitorCodeManager: IVisitorCodeManager;\n externalPackageInfo: ExternalPackageInfoType;\n externalRequester: IExternalRequester;\n externalClientConfiguration?: ConfigurationDataType;\n};\n\n/**\n * @readonly\n * @enum {string} an Enum containing all possible variants of environment, passed as an argument to KameleoonClient `configuration`s `environment` field\n * */\nexport enum Environment {\n Production = 'production',\n Staging = 'staging',\n Development = 'development',\n}\n\n/**\n * @readonly\n * @enum {string} an Enum containing all possible variants of feature variable types\n * */\nexport enum VariableType {\n BOOLEAN = 'BOOLEAN',\n NUMBER = 'NUMBER',\n STRING = 'STRING',\n JSON = 'JSON',\n}\n\nexport type BooleanVariableType = {\n key: string;\n type: VariableType.BOOLEAN;\n value: boolean;\n};\n\nexport type NumberVariableType = {\n key: string;\n type: VariableType.NUMBER;\n value: number;\n};\n\nexport type StringVariableType = {\n key: string;\n type: VariableType.STRING;\n value: string;\n};\n\nexport type JSONVariableType = {\n key: string;\n type: VariableType.JSON;\n value: JSONType;\n};\n\n/**\n * @type `FeatureVariableResultType` - tuple of possible feature variable result types, each possible variation is an object containing `key`, `type` and `value` fields, `type` can be checked against `VariableType` enum, if the `type` is `VariableType.BOOLEAN` then the `value` type will be `boolean` and so on.\n * */\nexport type FeatureVariableResultType =\n | BooleanVariableType\n | NumberVariableType\n | StringVariableType\n | JSONVariableType;\n\n/**\n * @type `FeatureFlagVariableType` - tuple of possible feature variable result types, each possible variation is an object containing `type` and `value` fields, `type` can be checked against `VariableType` enum, if the `type` is `VariableType.BOOLEAN` then the `value` type will be `boolean` and so on.\n * */\nexport type FeatureFlagVariableType = Omit<FeatureVariableResultType, 'key'>;\n\n/**\n * @readonly\n * @enum {number} a helper Enum for getting milliseconds for a second/minute/hour/day/week/month.\n * Month is considered in average of 30 days\n * */\nexport enum Milliseconds {\n Second = 1000,\n Minute = 60 * Milliseconds.Second,\n Hour = 60 * Milliseconds.Minute,\n Day = 24 * Milliseconds.Hour,\n Week = 7 * Milliseconds.Day,\n Month = 30 * Milliseconds.Day,\n}\n\n/**\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * @param {number} goalId - an id of a goal to track\n * @param {number | undefined} revenue - an optional parameter for revenue, default value is `0`\n * @param {boolean | undefined} isUniqueIdentifier - an optional parameter for specifying if the visitorCode is a unique identifier, default value is `false`\n * */\nexport type TrackConversionParamsType = {\n visitorCode: string;\n goalId: number;\n revenue?: number;\n isUniqueIdentifier?: boolean;\n};\n\n/**\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * @param {boolean | undefined} shouldAddData - optional parameter for adding retrieved data to the storage like `addData` method does, default value is `true`\n * @param {VisitorDataFiltersType | undefined} filters - optional parameter for specifying the filters for which data should be retrieved from what visit, by default only current and latest previous visits' `customData` is retrieved\n * @param {boolean | undefined} isUniqueIdentifier - an optional parameter for specifying if the visitorCode is a unique identifier, default value is `false`\n * */\nexport type RemoteVisitorDataParamsType = {\n visitorCode: string;\n shouldAddData?: boolean;\n filters?: VisitorDataFiltersType;\n isUniqueIdentifier?: boolean;\n};\n\nexport type GetFeatureVariablesParamsType = {\n visitorCode: string;\n featureKey: string;\n variationKey: string;\n};\n\nexport type FeatureFlagType = {\n id: number;\n key: string;\n};\n\n/**\n * @type `KameleoonVariableType` - tuple of possible feature variable result types, each possible variation is an object containing `key`, `type` and `value` fields, `type` can be checked against `VariableType` enum, if the `type` is `VariableType.BOOLEAN` then the `value` type will be `boolean` and so on.\n * */\nexport type KameleoonVariableType = FeatureVariableResultType;\n\n/**\n * @type `KameleoonVariationType` - object containing information about the variation and its variables\n * @param {string} key - key of the variation\n * @param {number | null} id - id of the variation or `null` if the visitor hit default variation\n * @param {number | null} experimentId - id of the experiment or `null` if the visitor hit default variation\n * @param {KameleoonVariableType[]} variables - array of variables for the variation\n * */\nexport type KameleoonVariationType = {\n key: string;\n id: number | null;\n experimentId: number | null;\n variables: KameleoonVariableType[];\n};\n\n/**\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * @param {string} featureKey - key of the feature flag to look for, can be found on Kameleoon Platform\n * @param {string} variableKey - key of the variable to be found for a feature flag with provided `featureKey`, can be found on Kameleoon Platform\n * */\nexport type GetFeatureFlagVariableParamsType = {\n visitorCode: string;\n featureKey: string;\n variableKey: string;\n};\n\n/**\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @param {number} customDataIndex - index of the custom data in the warehouse audience\n * @param {string | undefined} warehouseKey - unique key to identify the warehouse data (usually internal user ID)\n * If not specified, the `visitorCode` will be used as a `warehouseKey`\n * */\nexport type GetVisitorWarehouseAudienceParamsType = {\n visitorCode: string;\n customDataIndex: number;\n warehouseKey?: string;\n};\n\nexport type WarehouseAudienceType = {\n // --- Note ---\n // Using `unknown` type here because we don't care about the type of the value\n warehouseAudiences: Record<string, unknown>;\n};\n\nexport type TrackingCacheItemType = {\n [experimentId: number]: { variationId: number; expirationTime: number };\n};\n\nexport type SetDataCallbackParametersType = {\n visitorCode: string;\n maxAge: number;\n path: string;\n key: string;\n};\n\n/**\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * @param {boolean} consent - a value representing the legal consent status. - 'true' indicates the\n * visitor has given legal consent. - 'false' indicates the visitor has withdrawn or not\n * provided legal consent.\n * @param {(visitorCode: string) => void} setData - a callback to set a visitor code in cookie\n * */\nexport type SetUserConsentParametersType = {\n visitorCode: string;\n consent: boolean;\n setData: ({\n visitorCode,\n maxAge,\n path,\n }: SetDataCallbackParametersType) => void;\n};\n\n/**\n * @type `SimulateRequestDataType` a type of data provided to `simulateSuccessRequest` method depending on `RequestType`\n * */\nexport type SimulateRequestDataType = {\n [RequestType.Configuration]: ClientConfigurationDataType;\n [RequestType.RemoteData]: JSONType;\n [RequestType.Tracking]: null;\n};\n"],"mappings":"aAOA,IAAAA,UAAA,CAAAC,OAAA,gBAA8DC,MAAA,CAAAC,cAAA,CAAAC,OAAA,eAAAC,KAAA,MAAAD,OAAA,CAAAE,YAAA,CAAAF,OAAA,CAAAG,YAAA,CAAAH,OAAA,CAAAI,WAAA,WA6ElD,CAAAA,WAAW,CAAAJ,OAAA,CAAAI,WAAA,UAAXA,CAAW,QAAX,CAAAA,CAAW,CAAAC,UAAA,cAAXD,CAAW,CAAAE,OAAA,WAAXF,CAAW,CAAAG,WAAA,eAAXH,CAAW,MAUXF,YAAY,CAAAF,OAAA,CAAAE,YAAA,UAAZA,CAAY,QAAZ,CAAAA,CAAY,CAAAM,OAAA,WAAZN,CAAY,CAAAO,MAAA,UAAZP,CAAY,CAAAQ,MAAA,UAAZR,CAAY,CAAAS,IAAA,QAAZT,CAAY,MAkDZC,YAAY,CAAAH,OAAA,CAAAG,YAAA,UAAZA,CAAY,QAAZ,CAAAA,CAAY,CAAZA,CAAY,CAAAS,MAAA,gBAAZT,CAAY,CAAZA,CAAY,CAAAU,MAAA,CAEb,EAAE,CAAGV,CAAY,CAACS,MAAM,WAFvBT,CAAY,CAAZA,CAAY,CAAAW,IAAA,CAGf,EAAE,CAAGX,CAAY,CAACU,MAAM,SAHrBV,CAAY,CAAZA,CAAY,CAAAY,GAAA,CAIhB,EAAE,CAAGZ,CAAY,CAACW,IAAI,QAJlBX,CAAY,CAAZA,CAAY,CAAAa,IAAA,CAKf,CAAC,CAAGb,CAAY,CAACY,GAAG,SALjBZ,CAAY,CAAZA,CAAY,CAAAc,KAAA,CAMd,EAAE,CAAGd,CAAY,CAACY,GAAG,UANnBZ,CAAY"}
@@ -1,2 +1,3 @@
1
1
  export declare const VISITOR_CODE_MAX_LENGTH = 255;
2
2
  export declare const HEX_CHARACTERS = "0123456789ABCDEF";
3
+ export declare const NONCE_LENGTH = 16;
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.VISITOR_CODE_MAX_LENGTH=exports.HEX_CHARACTERS=void 0;const VISITOR_CODE_MAX_LENGTH=exports.VISITOR_CODE_MAX_LENGTH=255,HEX_CHARACTERS=exports.HEX_CHARACTERS="0123456789ABCDEF";
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.VISITOR_CODE_MAX_LENGTH=exports.NONCE_LENGTH=exports.HEX_CHARACTERS=void 0;const VISITOR_CODE_MAX_LENGTH=exports.VISITOR_CODE_MAX_LENGTH=255,HEX_CHARACTERS=exports.HEX_CHARACTERS="0123456789ABCDEF",NONCE_LENGTH=exports.NONCE_LENGTH=16;
2
2
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","names":["VISITOR_CODE_MAX_LENGTH","exports","HEX_CHARACTERS"],"sources":["../../src/utilities/constants.ts"],"sourcesContent":["export const VISITOR_CODE_MAX_LENGTH = 255;\nexport const HEX_CHARACTERS = '0123456789ABCDEF';\n"],"mappings":"uIAAa,CAAAA,uBAAuB,CAAAC,OAAA,CAAAD,uBAAA,CAAG,GAAG,CAC7BE,cAAc,CAAAD,OAAA,CAAAC,cAAA,CAAG,kBAAkB"}
1
+ {"version":3,"file":"constants.js","names":["VISITOR_CODE_MAX_LENGTH","exports","HEX_CHARACTERS","NONCE_LENGTH"],"sources":["../../src/utilities/constants.ts"],"sourcesContent":["export const VISITOR_CODE_MAX_LENGTH = 255;\nexport const HEX_CHARACTERS = '0123456789ABCDEF';\nexport const NONCE_LENGTH = 16;\n"],"mappings":"4JAAa,CAAAA,uBAAuB,CAAAC,OAAA,CAAAD,uBAAA,CAAG,GAAG,CAC7BE,cAAc,CAAAD,OAAA,CAAAC,cAAA,CAAG,kBAAkB,CACnCC,YAAY,CAAAF,OAAA,CAAAE,YAAA,CAAG,EAAE"}
@@ -1,2 +1,2 @@
1
- "use strict";const _excluded=["timestamp","isExperiment"];Object.defineProperty(exports,"__esModule",{value:!0}),exports.Utilities=void 0;var _tsRes=require("ts-res"),_kameleoonError=require("../kameleoonError"),_types=require("../types"),_kameleoonData=require("../kameleoonData"),_constants=require("../constants"),_requester=require("../requester"),_targeting=require("../targeting"),_visitProcessor=require("../kameleoonData/visitProcessor"),_constants2=require("./constants"),_types2=require("./types");function _objectWithoutProperties(a,b){if(null==a)return{};var c,d,e=_objectWithoutPropertiesLoose(a,b);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(a);for(d=0;d<f.length;d++)c=f[d],0<=b.indexOf(c)||Object.prototype.propertyIsEnumerable.call(a,c)&&(e[c]=a[c])}return e}function _objectWithoutPropertiesLoose(a,b){if(null==a)return{};var c,d,e={},f=Object.keys(a);for(d=0;d<f.length;d++)c=f[d],0<=b.indexOf(c)||(e[c]=a[c]);return e}function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==typeof b?b:b+""}function _toPrimitive(a,b){if("object"!=typeof a||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=typeof d)return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}class Utilities{static checkTargeting(a){let{segment:b,visitorCode:c,targetingData:d,experimentId:e,variationConfiguration:f,clientConfiguration:g,packageInfo:h,dataManager:i}=a;if(!b||!b.conditionsData.firstLevel.length)return(0,_tsRes.Ok)(!0);if(!f)return(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization));let j={};const k=f.getStoredVariations(c);k.ok&&(j=k.data);const l=i.getTree(b);let m,n,o;l.hasTargetingType(_targeting.TargetingType.SEGMENT)&&(m=i.trees,n=g.segments),l.hasTargetingType(_targeting.TargetingType.TARGET_FEATURE_FLAG)&&(o=g.ruleMap);const p=l.evaluate({variationData:j,sdkInfo:h,segments:n,ruleMap:o,trees:m,targetingData:d,experimentId:e,visitorCode:c});return p}static validateVisitorCode(a){return 0===a.length?(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.VisitorCodeEmpty)):a.length>_constants2.VISITOR_CODE_MAX_LENGTH?(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.VisitorCodeMaxLength)):(0,_tsRes.Ok)()}static getDataUrl(a){function b(a){if(!a.url)return;const b=a.data.type===_kameleoonData.KameleoonData.Conversion;if(e||b){const c=b?"":_requester.UrlParameter.Nonce+Utilities.getNonce();g.push(a.url+c+"\n")}}let{visitorCode:c,dataManager:d,isConsentProvided:e}=a;const f=d.getUnsentData(c),g=[];if(!f||!f.size)return"";for(const c of f.values())Array.isArray(c)?c.forEach(a=>b(a)):b(c);return g.join("")}static getVariationDataUrlAndSentExperimentIds(a){let{visitorCode:b,isConsentProvided:c,variationConfiguration:d}=a;const e=[],f=new Set,g=d.getUnsentData(b);g.ok&&g.data.length&&g.data.forEach(a=>{(a.isTargetedRule||c)&&(e.push(_requester.UrlEventType.Experiment+_requester.UrlParameter.Id+a.experimentId+_requester.UrlParameter.VariationId+a.variationId+_requester.UrlParameter.Nonce+Utilities.getNonce()+"\n"),f.add(a.experimentId+""))});const h=e.join(""),i=Array.from(f);return[h,i]}static async trackFeatureExperiment(a){let{featureFlagVariation:b,dataManager:c,visitorCode:d,requester:e,isOfflineModeOn:f,isConsentProvided:g,offlineTrackingStorage:h,variationConfiguration:i}=a;const{variationId:j,rule:k}=b,l=this.getUserAgent(d,c),m=this.getDataUrl({visitorCode:d,dataManager:c,isConsentProvided:g}),n=k?k.experimentId:0,[o,p]=this.getVariationDataUrlAndSentExperimentIds({visitorCode:d,isConsentProvided:g,variationConfiguration:i});if(!g&&!m&&!k)return;const q={visitorCode:d,dataUrl:m,variationDataUrl:o,experimentId:n,variationId:j||0,userAgent:l,isUnallocated:null===j},r=await e.trackExperiment(q);r.ok&&(g?c.clearUnsentData(d):c.clearUnsentDataByKey(d,_kameleoonData.KameleoonData.Conversion),p.forEach(a=>{i.markUnsentDataAsSent(d,a)})),!r.ok&&f&&this.addItemToOfflineTracking({item:q,storage:h,isExperiment:!0})}static convertTimeUnit(a,b){const c={[_types2.TimeUnit.Minute]:_types.Milliseconds.Minute,[_types2.TimeUnit.Hour]:_types.Milliseconds.Hour,[_types2.TimeUnit.Day]:_types.Milliseconds.Day,[_types2.TimeUnit.Week]:_types.Milliseconds.Week,[_types2.TimeUnit.Month]:_types.Milliseconds.Month};return a/c[b]}static parseFeatureVariable(a){const{key:b,type:c,value:d}=a;switch(c){case _types.VariableType.BOOLEAN:return(0,_tsRes.Ok)({key:b,type:c,value:!!d});case _types.VariableType.STRING:return(0,_tsRes.Ok)({key:b,type:c,value:d+""});case _types.VariableType.NUMBER:const e=+d;return Number.isNaN(e)?(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.NumberParse,d+"")):(0,_tsRes.Ok)({key:b,type:c,value:e});case _types.VariableType.JSON:try{const d=JSON.parse(a.value+"");return(0,_tsRes.Ok)({key:b,type:c,value:d})}catch(a){return(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.JSONParse,a))}default:(0,_kameleoonError.exhaustCheck)(c)}}static parseVisitorData(a){let{data:b,filters:c,visitorCode:d,dataManager:e,variationConfiguration:f}=a;const g=new _visitProcessor.VisitProcessor(c,e),{currentVisit:h,previousVisits:i,kcs:j}=b;let k=[];const l=c.kcs&&!c.currentVisit;if(h&&!l&&k.push(h),i&&k.push(...i),!k.length&&!l)return{visitorData:[],storageVisitorData:[]};k.forEach(a=>{g.processVisit(a)}),g.processKcs(j),g.processMultipleDataTypes();const{visitorData:m,storageVisitorData:n,visitsData:o,experimentData:p}=g.data;return f.updateStoredVariations(d,p),{visitorData:m,storageVisitorData:n,visitsData:o}}static parseRegExp(a){if("/"===a[0]){const[_,b,c]=a.split("/");return new RegExp(b,c)}return new RegExp(a)}static getUserAgent(a,b){const c=b.getTargetingData(a);if(c){const a=c[_kameleoonData.KameleoonData.UserAgent];if(a)return a.value}}static isCustomData(a){return a.data.type===_kameleoonData.KameleoonData.CustomData}static insertInOrderedListMutably(a){let{list:b,element:c,order:d}=a;if(!b.includes(c)){const a=b.findIndex(a=>d===_types2.Order.Ascending?a>=c:a<=c);-1===a?b.push(c):b.splice(a,0,c)}}static updateCache(a){let{cacheManager:b,visitorCode:c,experimentId:d,variationId:e}=a;const f=b.getAliveItem(c),g=f?_objectSpread({},f):{};g[d]={variationId:e,expirationTime:Date.now()+_constants.CACHE_ITEM_LIFETIME*_types.Milliseconds.Second},b.add({key:c,data:g,lifetime:_constants.CACHE_ITEM_LIFETIME})}static getTrackingCode(a,b){let c="window.kameleoonQueue=window.kameleoonQueue||[];";const d=a.getAliveItem(b);if(!d)return c;const e={};return Object.entries(d).forEach(a=>{let[b,{variationId:d,expirationTime:f}]=a;f>Date.now()&&(c+="window.kameleoonQueue.push(['Experiments.assignVariation',".concat(b,",").concat(d,"]);"),c+="window.kameleoonQueue.push(['Experiments.trigger',".concat(b,",true]);"),e[+b]={variationId:d,expirationTime:f})}),a.add({key:b,data:e,lifetime:_constants.CACHE_ITEM_LIFETIME}),c}static async trackData(a){let{visitorCode:b,dataManager:c,requester:d,isOfflineModeOn:e,offlineTrackingStorage:f,isConsentProvided:g,isMappingIdentifier:h}=a;await this.sendOfflineTracking({requester:d,storage:f});const i=this.getDataUrl({visitorCode:b,dataManager:c,isConsentProvided:g});if(!g&&!i)return;const j=this.getUserAgent(b,c),k={visitorCode:b,body:i,userAgent:j,isMappingIdentifier:h},l=await d.trackData(k),m=()=>g?c.clearUnsentData(b):c.clearUnsentDataByKey(b,_kameleoonData.KameleoonData.Conversion);l.ok&&m(),!l.ok&&e&&this.addItemToOfflineTracking({item:k,storage:f,isExperiment:!1,onSuccess:m})}static getNonce(){const a=_constants2.HEX_CHARACTERS.length;let b="";for(let c=0;c<a;c++){const c=Math.floor(Math.random()*a);b+=_constants2.HEX_CHARACTERS.substring(c,c+1)}return b}static compareSemVer(a){let{version:b,compareVersion:c,operator:d}=a;const e=this.validateVersion(b),f=this.validateVersion(c);if(!e.ok)return(0,_tsRes.Err)(e.error);if(!f.ok)return(0,_tsRes.Err)(f.error);const[g,h,i]=e.data,[j,k,l]=f.data,[m,n,o]=[g===j,h===k,i===l];switch(d){case _targeting.VersionMatchType.EQUAL:return(0,_tsRes.Ok)(m&&n&&o);case _targeting.VersionMatchType.GREATER:return(0,_tsRes.Ok)(g>j||m&&h>k||m&&n&&i>l);case _targeting.VersionMatchType.LOWER:return(0,_tsRes.Ok)(g<j||m&&h<k||m&&n&&i<l);default:(0,_kameleoonError.exhaustCheck)(d)}}static generateRandomString(a){const b="abcdefghijklmnopqrstuvwxyz0123456789",c=[];if(0>a)return"";for(let d=0;d<a;d++)c.push(b[Math.floor(Math.random()*b.length)]);return c.join("")}static async sendOfflineTracking(a){let{requester:b,storage:c}=a;const d=c.read();if(d.ok&&d.data.requestParameters){const{requestParameters:a}=d.data,e=[];for(const c of a){const{timestamp:a,isExperiment:d}=c,f=_objectWithoutProperties(c,_excluded);let g;g=d?await b.trackExperiment(f):await b.trackData(f),g.ok&&g.data&&e.push(a)}this.deleteFromOfflineTracking({storage:c,timestamps:e})}}static addItemToOfflineTracking(a){let{item:b,isExperiment:c,storage:d,onSuccess:e}=a;const f=d.read(),g=f.ok?f.data:{},{requestParameters:h}=g,i=_objectSpread(_objectSpread({},b),{},{timestamp:new Date().getTime(),isExperiment:c}),j=h?[...h,i]:[i],k=d.write({requestParameters:j});k.ok&&e&&e()}static deleteFromOfflineTracking(a){let{timestamps:b,storage:c}=a;const d=c.read();if(d.ok){const{requestParameters:a}=d.data,e=null===a||void 0===a?void 0:a.filter(a=>!b.includes(a.timestamp));c.write({requestParameters:e})}}static validateVersion(a){const b=a.split(".").map(a=>parseInt(a,10));for(;3>b.length;)b.push(0);return b.some(a=>isNaN(a))?(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.SemanticVersionParse,a)):(0,_tsRes.Ok)(b.slice(0,3))}}exports.Utilities=Utilities;
1
+ "use strict";const _excluded=["timestamp","isExperiment"];Object.defineProperty(exports,"__esModule",{value:!0}),exports.Utilities=void 0;var _tsRes=require("ts-res"),_kameleoonError=require("../kameleoonError"),_types=require("../types"),_kameleoonData=require("../kameleoonData"),_constants=require("../constants"),_requester=require("../requester"),_targeting=require("../targeting"),_visitProcessor=require("../kameleoonData/visitProcessor"),_constants2=require("./constants"),_types2=require("./types");function _objectWithoutProperties(a,b){if(null==a)return{};var c,d,e=_objectWithoutPropertiesLoose(a,b);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(a);for(d=0;d<f.length;d++)c=f[d],0<=b.indexOf(c)||Object.prototype.propertyIsEnumerable.call(a,c)&&(e[c]=a[c])}return e}function _objectWithoutPropertiesLoose(a,b){if(null==a)return{};var c,d,e={},f=Object.keys(a);for(d=0;d<f.length;d++)c=f[d],0<=b.indexOf(c)||(e[c]=a[c]);return e}function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==typeof b?b:b+""}function _toPrimitive(a,b){if("object"!=typeof a||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=typeof d)return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}class Utilities{static checkTargeting(a){let{segment:b,visitorCode:c,targetingData:d,experimentId:e,variationConfiguration:f,clientConfiguration:g,packageInfo:h,dataManager:i}=a;if(!b||!b.conditionsData.firstLevel.length)return(0,_tsRes.Ok)(!0);if(!f)return(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization));let j={};const k=f.getStoredVariations(c);k.ok&&(j=k.data);const l=i.getTree(b);let m,n,o;l.hasTargetingType(_targeting.TargetingType.SEGMENT)&&(m=i.trees,n=g.segments),l.hasTargetingType(_targeting.TargetingType.TARGET_FEATURE_FLAG)&&(o=g.ruleMap);const p=l.evaluate({variationData:j,sdkInfo:h,segments:n,ruleMap:o,trees:m,targetingData:d,experimentId:e,visitorCode:c});return p}static validateVisitorCode(a){return 0===a.length?(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.VisitorCodeEmpty)):a.length>_constants2.VISITOR_CODE_MAX_LENGTH?(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.VisitorCodeMaxLength)):(0,_tsRes.Ok)()}static getDataUrl(a){function b(a){if(!a.url)return;const b=a.data.type===_kameleoonData.KameleoonData.Conversion;if(e||b){const c=b?"":_requester.UrlParameter.Nonce+Utilities.getNonce();g.push(a.url+c+"\n")}}let{visitorCode:c,dataManager:d,isConsentProvided:e}=a;const f=d.getUnsentData(c),g=[];if(!f||!f.size)return"";for(const c of f.values())Array.isArray(c)?c.forEach(a=>b(a)):b(c);return g.join("")}static getVariationDataUrlAndSentExperimentIds(a){let{visitorCode:b,isConsentProvided:c,variationConfiguration:d}=a;const e=[],f=new Set,g=d.getUnsentData(b);g.ok&&g.data.length&&g.data.forEach(a=>{(a.isTargetedRule||c)&&(e.push(_requester.UrlEventType.Experiment+_requester.UrlParameter.Id+a.experimentId+_requester.UrlParameter.VariationId+a.variationId+_requester.UrlParameter.Nonce+Utilities.getNonce()+"\n"),f.add(a.experimentId+""))});const h=e.join(""),i=Array.from(f);return[h,i]}static async trackFeatureExperiment(a){let{featureFlagVariation:b,dataManager:c,visitorCode:d,requester:e,isOfflineModeOn:f,isConsentProvided:g,offlineTrackingStorage:h,variationConfiguration:i}=a;const{variationId:j,rule:k}=b,l=this.getUserAgent(d,c),m=this.getDataUrl({visitorCode:d,dataManager:c,isConsentProvided:g}),n=k?k.experimentId:0,[o,p]=this.getVariationDataUrlAndSentExperimentIds({visitorCode:d,isConsentProvided:g,variationConfiguration:i});if(!g&&!m&&!k)return;const q={visitorCode:d,dataUrl:m,variationDataUrl:o,experimentId:n,variationId:j||0,userAgent:l,isUnallocated:null===j},r=await e.trackExperiment(q);r.ok&&(g?c.clearUnsentData(d):c.clearUnsentDataByKey(d,_kameleoonData.KameleoonData.Conversion),p.forEach(a=>{i.markUnsentDataAsSent(d,a)})),!r.ok&&f&&this.addItemToOfflineTracking({item:q,storage:h,isExperiment:!0})}static convertTimeUnit(a,b){const c={[_types2.TimeUnit.Minute]:_types.Milliseconds.Minute,[_types2.TimeUnit.Hour]:_types.Milliseconds.Hour,[_types2.TimeUnit.Day]:_types.Milliseconds.Day,[_types2.TimeUnit.Week]:_types.Milliseconds.Week,[_types2.TimeUnit.Month]:_types.Milliseconds.Month};return a/c[b]}static parseFeatureVariable(a){const{key:b,type:c,value:d}=a;switch(c){case _types.VariableType.BOOLEAN:return(0,_tsRes.Ok)({key:b,type:c,value:!!d});case _types.VariableType.STRING:return(0,_tsRes.Ok)({key:b,type:c,value:d+""});case _types.VariableType.NUMBER:const e=+d;return Number.isNaN(e)?(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.NumberParse,d+"")):(0,_tsRes.Ok)({key:b,type:c,value:e});case _types.VariableType.JSON:try{const d=JSON.parse(a.value+"");return(0,_tsRes.Ok)({key:b,type:c,value:d})}catch(a){return(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.JSONParse,a))}default:(0,_kameleoonError.exhaustCheck)(c)}}static parseVisitorData(a){let{data:b,filters:c,visitorCode:d,dataManager:e,variationConfiguration:f}=a;const g=new _visitProcessor.VisitProcessor(c,e),{currentVisit:h,previousVisits:i,kcs:j}=b;let k=[];if(h&&k.push(h),i&&k.push(...i),!k.length)return{visitorData:[],storageVisitorData:[]};k.forEach(a=>{g.processVisit(a)}),g.processKcs(j),g.processMultipleDataTypes();const{visitorData:l,storageVisitorData:m,visitsData:n,experimentData:o}=g.data;return f.updateStoredVariations(d,o),{visitorData:l,storageVisitorData:m,visitsData:n}}static parseRegExp(a){if("/"===a[0]){const[_,b,c]=a.split("/");return new RegExp(b,c)}return new RegExp(a)}static getUserAgent(a,b){const c=b.getTargetingData(a);if(c){const a=c[_kameleoonData.KameleoonData.UserAgent];if(a)return a.value}}static isCustomData(a){return a.data.type===_kameleoonData.KameleoonData.CustomData}static insertInOrderedListMutably(a){let{list:b,element:c,order:d}=a;if(!b.includes(c)){const a=b.findIndex(a=>d===_types2.Order.Ascending?a>=c:a<=c);-1===a?b.push(c):b.splice(a,0,c)}}static updateCache(a){let{cacheManager:b,visitorCode:c,experimentId:d,variationId:e}=a;const f=b.getAliveItem(c),g=f?_objectSpread({},f):{};g[d]={variationId:e,expirationTime:Date.now()+_constants.CACHE_ITEM_LIFETIME*_types.Milliseconds.Second},b.add({key:c,data:g,lifetime:_constants.CACHE_ITEM_LIFETIME})}static getTrackingCode(a,b){let c="window.kameleoonQueue=window.kameleoonQueue||[];";const d=a.getAliveItem(b);if(!d)return c;const e={};return Object.entries(d).forEach(a=>{let[b,{variationId:d,expirationTime:f}]=a;f>Date.now()&&(c+="window.kameleoonQueue.push(['Experiments.assignVariation',".concat(b,",").concat(d,"]);"),c+="window.kameleoonQueue.push(['Experiments.trigger',".concat(b,",true]);"),e[+b]={variationId:d,expirationTime:f})}),a.add({key:b,data:e,lifetime:_constants.CACHE_ITEM_LIFETIME}),c}static async trackData(a){let{visitorCode:b,dataManager:c,requester:d,isOfflineModeOn:e,offlineTrackingStorage:f,isConsentProvided:g,isMappingIdentifier:h}=a;const i=this.getDataUrl({visitorCode:b,dataManager:c,isConsentProvided:g});if(!g&&!i)return;const j=this.getUserAgent(b,c),k={visitorCode:b,body:i,userAgent:j,isMappingIdentifier:h},l=await d.trackData(k),m=()=>g?c.clearUnsentData(b):c.clearUnsentDataByKey(b,_kameleoonData.KameleoonData.Conversion);l.ok&&m(),!l.ok&&e&&this.addItemToOfflineTracking({item:k,storage:f,isExperiment:!1,onSuccess:m}),await this.sendOfflineTracking({requester:d,storage:f})}static getNonce(){let a="";for(let b=0;b<_constants2.NONCE_LENGTH;b++){const b=Math.floor(Math.random()*_constants2.NONCE_LENGTH);a+=_constants2.HEX_CHARACTERS.charAt(b)}return a}static compareSemVer(a){let{version:b,compareVersion:c,operator:d}=a;const e=this.validateVersion(b),f=this.validateVersion(c);if(!e.ok)return(0,_tsRes.Err)(e.error);if(!f.ok)return(0,_tsRes.Err)(f.error);const[g,h,i]=e.data,[j,k,l]=f.data,[m,n,o]=[g===j,h===k,i===l];switch(d){case _targeting.VersionMatchType.EQUAL:return(0,_tsRes.Ok)(m&&n&&o);case _targeting.VersionMatchType.GREATER:return(0,_tsRes.Ok)(g>j||m&&h>k||m&&n&&i>l);case _targeting.VersionMatchType.LOWER:return(0,_tsRes.Ok)(g<j||m&&h<k||m&&n&&i<l);default:(0,_kameleoonError.exhaustCheck)(d)}}static generateRandomString(a){const b="abcdefghijklmnopqrstuvwxyz0123456789",c=[];if(0>a)return"";for(let d=0;d<a;d++)c.push(b[Math.floor(Math.random()*b.length)]);return c.join("")}static async sendOfflineTracking(a){let{requester:b,storage:c}=a;const d=c.read();if(d.ok&&d.data.requestParameters){const{requestParameters:a}=d.data,e=[];for(const c of a){const{timestamp:a,isExperiment:d}=c,f=_objectWithoutProperties(c,_excluded);let g;g=d?await b.trackExperiment(f):await b.trackData(f),g.ok&&g.data&&e.push(a)}this.deleteFromOfflineTracking({storage:c,timestamps:e})}}static addItemToOfflineTracking(a){let{item:b,isExperiment:c,storage:d,onSuccess:e}=a;const f=d.read(),g=f.ok?f.data:{},{requestParameters:h}=g,i=_objectSpread(_objectSpread({},b),{},{timestamp:new Date().getTime(),isExperiment:c}),j=h?[...h,i]:[i],k=d.write({requestParameters:j});k.ok&&e&&e()}static deleteFromOfflineTracking(a){let{timestamps:b,storage:c}=a;const d=c.read();if(d.ok){const{requestParameters:a}=d.data,e=null===a||void 0===a?void 0:a.filter(a=>!b.includes(a.timestamp));c.write({requestParameters:e})}}static validateVersion(a){const b=a.split(".").map(a=>parseInt(a,10));for(;3>b.length;)b.push(0);return b.some(a=>isNaN(a))?(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.SemanticVersionParse,a)):(0,_tsRes.Ok)(b.slice(0,3))}}exports.Utilities=Utilities;
2
2
  //# sourceMappingURL=utilities.js.map