@kameleoon/javascript-sdk-core 4.2.0 → 4.3.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 (41) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/clientConfiguration/clientConfiguration.d.ts +2 -4
  3. package/dist/clientConfiguration/clientConfiguration.js +1 -1
  4. package/dist/clientConfiguration/clientConfiguration.js.map +1 -1
  5. package/dist/clientConfiguration/types.d.ts +2 -0
  6. package/dist/clientConfiguration/types.js.map +1 -1
  7. package/dist/eventManager/eventManager.d.ts +11 -0
  8. package/dist/eventManager/eventManager.js +2 -0
  9. package/dist/eventManager/eventManager.js.map +1 -0
  10. package/dist/eventManager/index.d.ts +2 -0
  11. package/dist/eventManager/index.js +2 -0
  12. package/dist/eventManager/index.js.map +1 -0
  13. package/dist/eventManager/types.d.ts +36 -0
  14. package/dist/eventManager/types.js +2 -0
  15. package/dist/eventManager/types.js.map +1 -0
  16. package/dist/index.d.ts +1 -0
  17. package/dist/index.js +1 -1
  18. package/dist/index.js.map +1 -1
  19. package/dist/kameleoonClient.d.ts +10 -2
  20. package/dist/kameleoonClient.js +1 -1
  21. package/dist/kameleoonClient.js.map +1 -1
  22. package/dist/kameleoonClientInterface.d.ts +26 -0
  23. package/dist/kameleoonClientInterface.js.map +1 -1
  24. package/dist/kameleoonError/constants.d.ts +1 -0
  25. package/dist/kameleoonError/constants.js +1 -1
  26. package/dist/kameleoonError/constants.js.map +1 -1
  27. package/dist/kameleoonError/kameleoonError.d.ts +1 -0
  28. package/dist/kameleoonError/kameleoonError.js +1 -1
  29. package/dist/kameleoonError/kameleoonError.js.map +1 -1
  30. package/dist/kameleoonError/types.d.ts +1 -0
  31. package/dist/kameleoonError/types.js +1 -1
  32. package/dist/kameleoonError/types.js.map +1 -1
  33. package/dist/targeting/conditions/customData.d.ts +4 -2
  34. package/dist/targeting/conditions/customData.js +1 -1
  35. package/dist/targeting/conditions/customData.js.map +1 -1
  36. package/dist/targeting/conditions/types.d.ts +1 -0
  37. package/dist/targeting/conditions/types.js.map +1 -1
  38. package/dist/targeting/types.d.ts +2 -1
  39. package/dist/targeting/types.js +1 -1
  40. package/dist/targeting/types.js.map +1 -1
  41. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"kameleoonClient.js","names":["KameleoonClient","constructor","a","siteCode","configuration","internalConfiguration","_defineProperty","settings","clientSettings","ClientSettings","environment","externalStorage","externalEventSource","externalPackageInfo","externalVisitorCodeManager","externalRequestDispatcher","externalClientConfiguration","trackingCache","CacheManager","CACHE_CLEANUP_TIMEOUT","clientDataStorage","DataStorage","KameleoonStorageKey","ClientData","targetingDataStorage","TargetingData","variationDataStorage","VariationData","offlineTrackingStorage","OfflineTracking","consentDataStorage","ConsentData","dataManager","DataManager","storage","targetingCleanupInterval","targetingDataCleanupInterval","eventSource","KameleoonEventSource","requester","Requester","packageInfo","requestDispatcher","clientConfiguration","ClientConfiguration","variationConfiguration","VariationConfiguration","visitorCodeManager","initialize","useCache","result","throw","isOfflineModeOn","initialized","ok","addData","visitorCode","Utilities","validateVisitorCode","KameleoonError","KameleoonException","Initialization","b","arguments","length","data","Array","d","getRemoteVisitorData","shouldAddData","filters","DEFAULT_VISITOR_DATA_FILTERS","isUniqueIdentifier","previousVisitAmount","VisitAmount","getVisitorData","isMappingIdentifier","visitorData","storageVisitorData","visitsData","parseVisitorData","dataItem","isPersistentCustomData","trackConversion","goalId","revenue","Conversion","flush","linkedVisitor","getLinkedVisitor","index","identifierCustomDataIndex","CustomData","trackData","isConsentProvided","_isConsentProvided","unsentDataVisitors","sendOfflineTracking","visitorCodeKey","getFeatureFlags","featureFlags","resultFeatureFlags","forEach","id","featureKey","push","key","getVisitorFeatureFlags","activeVariations","_getActiveFeatureVariations","featureFlagId","getActiveFeatureFlags","resultFeatureList","Map","variation","variationKey","variationId","experimentId","variables","_getFeatureVariables","resultVariables","map","variable","parseFeatureVariable","set","getFeatureFlagVariationKey","_getFeatureVariation","getFeatureFlagVariable","variableKey","find","item","FeatureFlagVariableNotFound","type","value","getFeatureFlagVariables","parsedVariable","isFeatureFlagActive","OFF_VARIATION_KEY","err","FeatureFlagEnvironmentDisabled","getRemoteData","remoteData","getVisitorWarehouseAudience","customDataIndex","warehouseKey","RemoteData","WAREHOUSE_AUDIENCE_KEY","Object","keys","customData","onConfigurationUpdate","callback","getEngineTrackingCode","getTrackingCode","isInitialized","setUserConsent","consent","setData","update","VisitorCode","maxAge","DEFAULT_MAX_AGE","path","PATH","consentRequired","ZERO_MAX_AGE","isConsentRequired","consentDataResult","read","featureFlag","get","FeatureFlagConfigurationNotFound","variations","FeatureFlagVariationNotFound","targetingData","getTargetingData","visitorIdentifier","getVisitorIdentifier","values","environmentEnabled","variationData","getVariation","Err","Environment","Production","withAssignment","updateCache","cacheManager","trackFeatureExperiment","featureFlagVariation","Ok","exports"],"sources":["../src/kameleoonClient.ts"],"sourcesContent":["import { Err, Ok, Result } from 'ts-res';\nimport { CacheManager } from './cacheManager';\nimport {\n ClientConfiguration,\n FeatureVariableType,\n JSONType,\n} from './clientConfiguration';\nimport { ClientSettings } from './clientSettings';\nimport {\n CACHE_CLEANUP_TIMEOUT,\n DEFAULT_VISITOR_DATA_FILTERS,\n OFF_VARIATION_KEY,\n} from './constants';\nimport {\n Conversion,\n CustomData,\n DataManager,\n KameleoonDataType,\n} from './kameleoonData';\nimport { WAREHOUSE_AUDIENCE_KEY } from './constants';\nimport { KameleoonError, KameleoonException } from './kameleoonError';\nimport { Requester } from './requester';\nimport {\n ClientDataType,\n KameleoonStorageKey,\n VariationDataType,\n DataStorage,\n ConsentDataType,\n IStorage,\n OfflineTracking,\n} from './storage';\nimport {\n TrackConversionParamsType,\n FeatureFlagType,\n GetFeatureFlagVariableParamsType,\n FeatureVariableResultType,\n SDKCoreParameters,\n TrackingCacheItemType,\n ExternalPackageInfoType,\n RemoteVisitorDataParamsType,\n GetVisitorWarehouseAudienceParamsType,\n Environment,\n SetUserConsentParametersType,\n FeatureFlagVariableType,\n KameleoonVariationType,\n GetFeatureVariablesParamsType,\n} from './types';\nimport { IVisitorCodeManager } from './visitorCodeManager';\nimport { Utilities } from './utilities';\nimport {\n FeatureFlagVariationType,\n VariationConfiguration,\n} from './variationConfiguration';\nimport { TargetingDataType } from './targeting';\nimport { KameleoonEventSource } from './eventSource';\nimport { IKameleoonClient } from './kameleoonClientInterface';\nimport { DEFAULT_MAX_AGE, PATH, ZERO_MAX_AGE } from './visitorCodeManager';\n\n/**\n * @class\n * KameleoonClient - a class for creating kameleoon client instance\n * for communicating with Kameleoon JavaScript SDK Core, when new instance is created\n */\nexport class KameleoonClient implements IKameleoonClient {\n private variationConfiguration: VariationConfiguration;\n private clientConfiguration: ClientConfiguration;\n private dataManager: DataManager;\n private offlineTrackingStorage: IStorage<OfflineTracking>;\n private consentDataStorage: IStorage<ConsentDataType>;\n private trackingCache: CacheManager<TrackingCacheItemType>;\n private requester: Requester;\n private externalPackageInfo: ExternalPackageInfoType;\n private isOfflineModeOn?: boolean;\n private initialized: boolean = false;\n private environment?: Environment;\n private visitorCodeManager: IVisitorCodeManager;\n\n /**\n * @param {SDKCoreParameters} sdkCoreParameters - parameters for initializing sdk core\n */\n constructor({\n siteCode,\n configuration,\n internalConfiguration,\n }: SDKCoreParameters) {\n const { settings: clientSettings } = new ClientSettings(\n siteCode,\n configuration,\n );\n this.environment = clientSettings.environment;\n const {\n externalStorage,\n externalEventSource,\n externalPackageInfo,\n externalVisitorCodeManager,\n externalRequestDispatcher,\n externalClientConfiguration,\n } = internalConfiguration;\n const trackingCache = new CacheManager<TrackingCacheItemType>(\n CACHE_CLEANUP_TIMEOUT,\n );\n\n const clientDataStorage = new DataStorage<ClientDataType>(\n externalStorage,\n KameleoonStorageKey.ClientData,\n );\n const targetingDataStorage = new DataStorage<TargetingDataType>(\n externalStorage,\n KameleoonStorageKey.TargetingData,\n );\n const variationDataStorage = new DataStorage<VariationDataType>(\n externalStorage,\n KameleoonStorageKey.VariationData,\n );\n const offlineTrackingStorage = new DataStorage<OfflineTracking>(\n externalStorage,\n KameleoonStorageKey.OfflineTracking,\n );\n const consentDataStorage = new DataStorage<ConsentDataType>(\n externalStorage,\n KameleoonStorageKey.ConsentData,\n );\n\n const dataManager = new DataManager({\n storage: targetingDataStorage,\n targetingCleanupInterval: configuration?.targetingDataCleanupInterval,\n });\n\n const eventSource = new KameleoonEventSource(\n clientSettings.siteCode,\n externalEventSource,\n );\n\n const requester = new Requester({\n siteCode,\n environment: clientSettings.environment,\n packageInfo: externalPackageInfo,\n requestDispatcher: externalRequestDispatcher,\n });\n\n const clientConfiguration = new ClientConfiguration({\n settings: clientSettings,\n storage: clientDataStorage,\n dataManager,\n requester,\n externalClientConfiguration,\n offlineTrackingStorage,\n eventSource,\n externalVisitorCodeManager,\n });\n\n const variationConfiguration = new VariationConfiguration(\n variationDataStorage,\n );\n\n this.variationConfiguration = variationConfiguration;\n this.requester = requester;\n this.trackingCache = trackingCache;\n this.dataManager = dataManager;\n this.clientConfiguration = clientConfiguration;\n this.externalPackageInfo = externalPackageInfo;\n this.offlineTrackingStorage = offlineTrackingStorage;\n this.consentDataStorage = consentDataStorage;\n this.visitorCodeManager = externalVisitorCodeManager;\n }\n\n public async initialize(useCache?: boolean): Promise<boolean> {\n const result = await this.clientConfiguration.initialize();\n result.throw();\n\n this.isOfflineModeOn = useCache;\n this.initialized = true;\n\n return result.ok;\n }\n\n public addData(visitorCode: string, ...data: KameleoonDataType[]): void {\n Utilities.validateVisitorCode(visitorCode).throw();\n\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n this.dataManager.addData(visitorCode, ...data).throw();\n }\n\n public async getRemoteVisitorData({\n visitorCode,\n shouldAddData = true,\n filters = DEFAULT_VISITOR_DATA_FILTERS,\n isUniqueIdentifier = false,\n }: RemoteVisitorDataParamsType): Promise<KameleoonDataType[]> {\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n Utilities.validateVisitorCode(visitorCode).throw();\n\n const { previousVisitAmount } = filters;\n\n if (\n typeof previousVisitAmount === 'number' &&\n (previousVisitAmount < 1 || previousVisitAmount > 25)\n ) {\n throw new KameleoonError(KameleoonException.VisitAmount);\n }\n\n const result = await this.requester.getVisitorData({\n visitorCode,\n filters,\n isMappingIdentifier: isUniqueIdentifier,\n });\n const data = result.throw();\n\n const { visitorData, storageVisitorData, visitsData } =\n Utilities.parseVisitorData({\n data,\n filters,\n visitorCode,\n dataManager: this.dataManager,\n variationConfiguration: this.variationConfiguration,\n });\n\n for (const dataItem of storageVisitorData) {\n if (shouldAddData || this.dataManager.isPersistentCustomData(dataItem)) {\n this.addData(visitorCode, dataItem);\n }\n }\n\n // --- Note ---\n // Data on visits amount and time stamps is not returned to a user\n if (visitsData && shouldAddData) {\n this.addData(visitorCode, visitsData);\n }\n\n return visitorData;\n }\n\n public trackConversion({\n visitorCode,\n goalId,\n revenue,\n isUniqueIdentifier,\n }: TrackConversionParamsType): void {\n this.addData(visitorCode, new Conversion({ goalId, revenue }));\n this.flush(visitorCode, isUniqueIdentifier);\n }\n\n public flush(visitorCode?: string, isUniqueIdentifier?: boolean): void {\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n if (typeof visitorCode === 'string') {\n Utilities.validateVisitorCode(visitorCode).throw();\n }\n\n if (visitorCode) {\n let isMappingIdentifier = false;\n\n // --- Note ---\n // This part is a workaround for Data API\n // If there's is no unique identifier for the visitor\n // We do reconciliation for visitor with himself\n if (isUniqueIdentifier) {\n const linkedVisitor = this.dataManager.getLinkedVisitor(visitorCode);\n const index = this.dataManager.identifierCustomDataIndex;\n\n if (!linkedVisitor && typeof index === 'number') {\n this.dataManager.addData(\n visitorCode,\n new CustomData(index, visitorCode),\n );\n } else {\n isMappingIdentifier = true;\n }\n }\n\n Utilities.trackData({\n visitorCode,\n isMappingIdentifier,\n dataManager: this.dataManager,\n requester: this.requester,\n isOfflineModeOn: this.isOfflineModeOn,\n isConsentProvided: this._isConsentProvided(visitorCode),\n offlineTrackingStorage: this.offlineTrackingStorage,\n });\n\n return;\n }\n\n // --- Note ---\n // `Utilities.trackData` executes `Utilities.sendOfflineTracking` asynchronously at first, but\n // we need to execute `Utilities.sendOfflineTracking` even if calling `Utilities.trackData` is skipped\n // due to lack of unsent data\n if (!this.dataManager.unsentDataVisitors.length) {\n Utilities.sendOfflineTracking({\n requester: this.requester,\n storage: this.offlineTrackingStorage,\n });\n return;\n }\n\n for (const visitorCodeKey of this.dataManager.unsentDataVisitors) {\n Utilities.trackData({\n visitorCode: visitorCodeKey,\n dataManager: this.dataManager,\n requester: this.requester,\n isOfflineModeOn: this.isOfflineModeOn,\n isConsentProvided: this._isConsentProvided(visitorCodeKey),\n offlineTrackingStorage: this.offlineTrackingStorage,\n });\n }\n }\n\n public getFeatureFlags(): FeatureFlagType[] {\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n const featureFlags = this.clientConfiguration.featureFlags;\n const resultFeatureFlags: FeatureFlagType[] = [];\n\n featureFlags.forEach(({ id, featureKey }) => {\n resultFeatureFlags.push({\n id,\n key: featureKey,\n });\n });\n\n return resultFeatureFlags;\n }\n\n public getVisitorFeatureFlags(visitorCode: string): FeatureFlagType[] {\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n const activeVariations = this._getActiveFeatureVariations(visitorCode);\n const resultFeatureFlags: FeatureFlagType[] = [];\n\n activeVariations.forEach(({ featureFlagId, featureKey }) => {\n resultFeatureFlags.push({\n id: featureFlagId,\n key: featureKey,\n });\n });\n\n return resultFeatureFlags;\n }\n\n public getActiveFeatureFlags(\n visitorCode: string,\n ): Map<string, KameleoonVariationType> {\n const activeVariations = this._getActiveFeatureVariations(visitorCode);\n const resultFeatureList: Map<string, KameleoonVariationType> = new Map();\n\n activeVariations.forEach((variation) => {\n const { variationKey, featureKey, variationId, experimentId } = variation;\n\n let variables: FeatureVariableType[] = [];\n\n if (variationId !== null && experimentId !== null) {\n variables = this._getFeatureVariables({\n visitorCode,\n featureKey,\n variationKey,\n });\n }\n\n const resultVariables = variables.map((variable) =>\n Utilities.parseFeatureVariable(variable).throw(),\n );\n\n resultFeatureList.set(variation.featureKey, {\n key: variationKey,\n id: variationId,\n experimentId,\n variables: resultVariables,\n });\n });\n\n return resultFeatureList;\n }\n\n public getFeatureFlagVariationKey(\n visitorCode: string,\n featureKey: string,\n ): string {\n Utilities.validateVisitorCode(visitorCode).throw();\n\n const { variationKey } = this._getFeatureVariation(\n visitorCode,\n featureKey,\n ).throw();\n\n return variationKey;\n }\n\n public getFeatureFlagVariable({\n visitorCode,\n featureKey,\n variableKey,\n }: GetFeatureFlagVariableParamsType): FeatureFlagVariableType {\n Utilities.validateVisitorCode(visitorCode).throw();\n\n const { variationKey } = this._getFeatureVariation(\n visitorCode,\n featureKey,\n ).throw();\n\n const variables = this._getFeatureVariables({\n visitorCode,\n featureKey,\n variationKey,\n });\n const variable = variables.find((item) => item.key === variableKey);\n\n if (!variable) {\n throw new KameleoonError(\n KameleoonException.FeatureFlagVariableNotFound,\n variableKey,\n visitorCode,\n );\n }\n\n const { type, value } = Utilities.parseFeatureVariable(variable).throw();\n\n return { type, value } as FeatureFlagVariableType;\n }\n\n public getFeatureFlagVariables(\n visitorCode: string,\n featureKey: string,\n ): FeatureVariableResultType[] {\n Utilities.validateVisitorCode(visitorCode).throw();\n\n const { variationKey } = this._getFeatureVariation(\n visitorCode,\n featureKey,\n ).throw();\n\n const variables = this._getFeatureVariables({\n visitorCode,\n featureKey,\n variationKey,\n });\n const resultVariables: FeatureVariableResultType[] = [];\n\n for (const variable of variables) {\n const parsedVariable = Utilities.parseFeatureVariable(variable).throw();\n resultVariables.push(parsedVariable);\n }\n\n return resultVariables;\n }\n\n public isFeatureFlagActive(visitorCode: string, featureKey: string): boolean {\n try {\n const variationKey = this.getFeatureFlagVariationKey(\n visitorCode,\n featureKey,\n );\n\n return variationKey !== OFF_VARIATION_KEY;\n } catch (err) {\n if (\n err instanceof KameleoonError &&\n err.type === KameleoonException.FeatureFlagEnvironmentDisabled\n ) {\n return false;\n }\n\n throw err;\n }\n }\n\n public async getRemoteData(key: string): Promise<JSONType> {\n const remoteData = await this.requester.getRemoteData(key);\n\n return remoteData.throw();\n }\n\n public async getVisitorWarehouseAudience({\n visitorCode,\n customDataIndex,\n warehouseKey,\n }: GetVisitorWarehouseAudienceParamsType): Promise<CustomData | null> {\n Utilities.validateVisitorCode(visitorCode).throw();\n\n const data = await this.getRemoteData(warehouseKey || visitorCode);\n\n if (!data) {\n throw new KameleoonError(KameleoonException.RemoteData);\n }\n\n if (\n !data[WAREHOUSE_AUDIENCE_KEY] ||\n Object.keys(data[WAREHOUSE_AUDIENCE_KEY]).length === 0\n ) {\n return null;\n }\n\n const customData = new CustomData(\n customDataIndex,\n ...Object.keys(data[WAREHOUSE_AUDIENCE_KEY]),\n );\n\n this.dataManager.addData(visitorCode, customData);\n\n return customData;\n }\n\n public onConfigurationUpdate(callback: () => void): void {\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n this.clientConfiguration.onConfigurationUpdate(callback);\n }\n\n public getEngineTrackingCode(visitorCode: string): string {\n Utilities.validateVisitorCode(visitorCode).throw();\n\n return Utilities.getTrackingCode(this.trackingCache, visitorCode);\n }\n\n public isInitialized(): boolean {\n return this.initialized;\n }\n\n protected setUserConsent({\n visitorCode,\n consent,\n setData,\n }: SetUserConsentParametersType): void {\n Utilities.validateVisitorCode(visitorCode).throw();\n\n this.consentDataStorage.update({ [visitorCode]: consent });\n\n if (consent) {\n setData({\n visitorCode,\n key: KameleoonStorageKey.VisitorCode,\n maxAge: DEFAULT_MAX_AGE,\n path: PATH,\n });\n } else {\n if (this.visitorCodeManager.consentRequired) {\n setData({\n visitorCode: '',\n key: KameleoonStorageKey.VisitorCode,\n maxAge: ZERO_MAX_AGE,\n path: PATH,\n });\n }\n }\n }\n\n private _isConsentProvided(visitorCode: string): boolean {\n const { isConsentRequired } = this.clientConfiguration;\n const consentDataResult = this.consentDataStorage.read();\n\n return (\n !isConsentRequired ||\n (consentDataResult.ok && consentDataResult.data[visitorCode])\n );\n }\n\n private _getFeatureVariables({\n visitorCode,\n featureKey,\n variationKey,\n }: GetFeatureVariablesParamsType): FeatureVariableType[] {\n const featureFlags = this.clientConfiguration.featureFlags;\n const featureFlag = featureFlags.get(featureKey);\n\n if (!featureFlag) {\n throw new KameleoonError(\n KameleoonException.FeatureFlagConfigurationNotFound,\n featureKey,\n );\n }\n const variation = featureFlag.variations.find(\n (item) => item.key === variationKey,\n );\n\n if (!variation) {\n throw new KameleoonError(\n KameleoonException.FeatureFlagVariationNotFound,\n variationKey,\n visitorCode,\n );\n }\n\n return variation.variables;\n }\n\n private _getActiveFeatureVariations(\n visitorCode: string,\n ): FeatureFlagVariationType[] {\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n const featureFlags = this.clientConfiguration.featureFlags;\n const activeVariations: FeatureFlagVariationType[] = [];\n\n const targetingData = this.dataManager.getTargetingData(visitorCode);\n const visitorIdentifier =\n this.dataManager.getVisitorIdentifier(visitorCode);\n\n for (const featureFlag of featureFlags.values()) {\n if (!featureFlag.environmentEnabled) {\n continue;\n }\n\n const variationData = this.variationConfiguration\n .getVariation({\n visitorCode,\n visitorIdentifier,\n targetingData,\n featureFlag,\n clientConfiguration: this.clientConfiguration,\n dataManager: this.dataManager,\n packageInfo: this.externalPackageInfo,\n })\n .throw();\n\n if (variationData.variationKey !== OFF_VARIATION_KEY) {\n activeVariations.push(variationData);\n }\n }\n\n return activeVariations;\n }\n\n private _getFeatureVariation(\n visitorCode: string,\n featureKey: string,\n ): Result<FeatureFlagVariationType, KameleoonError> {\n if (!this.initialized) {\n return Err(new KameleoonError(KameleoonException.Initialization));\n }\n\n const featureFlags = this.clientConfiguration.featureFlags;\n const featureFlag = featureFlags.get(featureKey);\n\n if (!featureFlag) {\n return Err(\n new KameleoonError(\n KameleoonException.FeatureFlagConfigurationNotFound,\n featureKey,\n ),\n );\n }\n\n if (!featureFlag.environmentEnabled) {\n return Err(\n new KameleoonError(\n KameleoonException.FeatureFlagEnvironmentDisabled,\n featureFlag.featureKey,\n this.environment || Environment.Production,\n ),\n );\n }\n\n const targetingData = this.dataManager.getTargetingData(visitorCode);\n const visitorIdentifier =\n this.dataManager.getVisitorIdentifier(visitorCode);\n\n const variationData = this.variationConfiguration\n .getVariation({\n visitorCode,\n visitorIdentifier,\n featureFlag,\n targetingData,\n withAssignment: true,\n clientConfiguration: this.clientConfiguration,\n dataManager: this.dataManager,\n packageInfo: this.externalPackageInfo,\n })\n .throw();\n\n const { experimentId, variationId } = variationData;\n\n if (typeof variationId === 'number' && typeof experimentId === 'number') {\n Utilities.updateCache({\n cacheManager: this.trackingCache,\n visitorCode,\n experimentId,\n variationId,\n });\n }\n\n Utilities.trackFeatureExperiment({\n visitorCode,\n requester: this.requester,\n featureFlagVariation: variationData,\n dataManager: this.dataManager,\n isOfflineModeOn: this.isOfflineModeOn,\n isConsentProvided: this._isConsentProvided(visitorCode),\n offlineTrackingStorage: this.offlineTrackingStorage,\n variationConfiguration: this.variationConfiguration,\n });\n\n return Ok(variationData);\n }\n}\n"],"mappings":"upCA+DO,KAAM,CAAAA,eAA4C,CAiBvDC,WAAWA,CAAAC,CAAA,CAIW,IAJV,CACVC,QAAQ,CAARA,CAAQ,CACRC,aAAa,CAAbA,CAAa,CACbC,qBAAqB,CAArBA,CACiB,CAAC,CAAAH,CAAA,CAAAI,eAAA,uCAAAA,eAAA,oCAAAA,eAAA,4BAAAA,eAAA,uCAAAA,eAAA,mCAAAA,eAAA,8BAAAA,eAAA,0BAAAA,eAAA,oCAAAA,eAAA,gCAAAA,eAAA,wBAAAA,eAAA,4BAAAA,eAAA,mCAClB,KAAM,CAAEC,QAAQ,CAAEC,CAAe,CAAC,CAAG,GAAI,CAAAC,8BAAc,CACrDN,CAAQ,CACRC,CACF,CAAC,CACD,IAAI,CAACM,WAAW,C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BoB,eAAe,CAAE,IAAI,CAACA,eAAe,CACrC0C,iBAAiB,CAAE,IAAI,CAACC,kBAAkB,CAACvC,CAAW,CAAC,CACvD5B,sBAAsB,CAAE,IAAI,CAACA,sBAAsB,CACnDiB,sBAAsB,CAAE,IAAI,CAACA,sBAC/B,CAAC,CAAC,CAEK,GAAAiJ,SAAE,EAACV,CAAa,CACzB,CACF,CAACW,OAAA,CAAA/L,eAAA,CAAAA,eAAA"}
1
+ {"version":3,"file":"kameleoonClient.js","names":["KameleoonClient","constructor","a","siteCode","configuration","internalConfiguration","_defineProperty","settings","clientSettings","ClientSettings","environment","externalStorage","externalEventSource","externalPackageInfo","externalVisitorCodeManager","externalRequestDispatcher","externalClientConfiguration","trackingCache","CacheManager","CACHE_CLEANUP_TIMEOUT","clientDataStorage","DataStorage","KameleoonStorageKey","ClientData","targetingDataStorage","TargetingData","variationDataStorage","VariationData","offlineTrackingStorage","OfflineTracking","consentDataStorage","ConsentData","dataManager","DataManager","storage","targetingCleanupInterval","targetingDataCleanupInterval","eventSource","KameleoonEventSource","requester","Requester","packageInfo","requestDispatcher","eventManager","EventManager","clientConfiguration","ClientConfiguration","variationConfiguration","VariationConfiguration","visitorCodeManager","initialize","useCache","result","throw","isOfflineModeOn","initialized","ok","addData","visitorCode","Utilities","validateVisitorCode","KameleoonError","KameleoonException","Initialization","b","arguments","length","data","Array","d","getRemoteVisitorData","shouldAddData","filters","DEFAULT_VISITOR_DATA_FILTERS","isUniqueIdentifier","previousVisitAmount","VisitAmount","getVisitorData","isMappingIdentifier","visitorData","storageVisitorData","visitsData","parseVisitorData","dataItem","isPersistentCustomData","trackConversion","goalId","revenue","Conversion","flush","linkedVisitor","getLinkedVisitor","index","identifierCustomDataIndex","CustomData","trackData","isConsentProvided","_isConsentProvided","unsentDataVisitors","sendOfflineTracking","visitorCodeKey","getFeatureFlags","featureFlags","resultFeatureFlags","forEach","id","featureKey","push","key","getVisitorFeatureFlags","activeVariations","_getActiveFeatureVariations","featureFlagId","getActiveFeatureFlags","resultFeatureList","Map","variation","variationKey","variationId","experimentId","variables","_getFeatureVariables","resultVariables","map","variable","parseFeatureVariable","set","getFeatureFlagVariationKey","_getFeatureVariation","getFeatureFlagVariable","variableKey","find","item","FeatureFlagVariableNotFound","type","value","getFeatureFlagVariables","parsedVariable","isFeatureFlagActive","OFF_VARIATION_KEY","err","FeatureFlagEnvironmentDisabled","getRemoteData","remoteData","getVisitorWarehouseAudience","customDataIndex","warehouseKey","RemoteData","WAREHOUSE_AUDIENCE_KEY","Object","keys","customData","onConfigurationUpdate","callback","addEventHandler","EventType","ConfigurationUpdate","onEvent","event","getEngineTrackingCode","getTrackingCode","isInitialized","setUserConsent","consent","setData","update","VisitorCode","maxAge","DEFAULT_MAX_AGE","path","PATH","consentRequired","ZERO_MAX_AGE","isConsentRequired","consentDataResult","read","featureFlag","get","FeatureFlagConfigurationNotFound","variations","FeatureFlagVariationNotFound","targetingData","getTargetingData","visitorIdentifier","getVisitorIdentifier","values","environmentEnabled","variationData","getVariation","fireEvent","Evaluation","Err","Environment","Production","withAssignment","updateCache","cacheManager","trackFeatureExperiment","featureFlagVariation","Ok","exports"],"sources":["../src/kameleoonClient.ts"],"sourcesContent":["import { Err, Ok, Result } from 'ts-res';\nimport { CacheManager } from './cacheManager';\nimport {\n ClientConfiguration,\n FeatureVariableType,\n JSONType,\n} from './clientConfiguration';\nimport { ClientSettings } from './clientSettings';\nimport {\n CACHE_CLEANUP_TIMEOUT,\n DEFAULT_VISITOR_DATA_FILTERS,\n OFF_VARIATION_KEY,\n} from './constants';\nimport {\n Conversion,\n CustomData,\n DataManager,\n KameleoonDataType,\n} from './kameleoonData';\nimport { WAREHOUSE_AUDIENCE_KEY } from './constants';\nimport { KameleoonError, KameleoonException } from './kameleoonError';\nimport { Requester } from './requester';\nimport {\n ClientDataType,\n KameleoonStorageKey,\n VariationDataType,\n DataStorage,\n ConsentDataType,\n IStorage,\n OfflineTracking,\n} from './storage';\nimport {\n TrackConversionParamsType,\n FeatureFlagType,\n GetFeatureFlagVariableParamsType,\n FeatureVariableResultType,\n SDKCoreParameters,\n TrackingCacheItemType,\n ExternalPackageInfoType,\n RemoteVisitorDataParamsType,\n GetVisitorWarehouseAudienceParamsType,\n Environment,\n SetUserConsentParametersType,\n FeatureFlagVariableType,\n KameleoonVariationType,\n GetFeatureVariablesParamsType,\n} from './types';\nimport { IVisitorCodeManager } from './visitorCodeManager';\nimport { Utilities } from './utilities';\nimport {\n FeatureFlagVariationType,\n VariationConfiguration,\n} from './variationConfiguration';\nimport { TargetingDataType } from './targeting';\nimport { EventCallbackType, EventManager, EventType } from './eventManager';\nimport { KameleoonEventSource } from './eventSource';\nimport { IKameleoonClient } from './kameleoonClientInterface';\nimport { DEFAULT_MAX_AGE, PATH, ZERO_MAX_AGE } from './visitorCodeManager';\n\n/**\n * @class\n * KameleoonClient - a class for creating kameleoon client instance\n * for communicating with Kameleoon JavaScript SDK Core, when new instance is created\n */\nexport class KameleoonClient implements IKameleoonClient {\n private variationConfiguration: VariationConfiguration;\n private clientConfiguration: ClientConfiguration;\n private dataManager: DataManager;\n private offlineTrackingStorage: IStorage<OfflineTracking>;\n private consentDataStorage: IStorage<ConsentDataType>;\n private trackingCache: CacheManager<TrackingCacheItemType>;\n private requester: Requester;\n private externalPackageInfo: ExternalPackageInfoType;\n private initialized: boolean = false;\n private visitorCodeManager: IVisitorCodeManager;\n private eventManager: EventManager;\n private environment?: Environment;\n private isOfflineModeOn?: boolean;\n\n /**\n * @param {SDKCoreParameters} sdkCoreParameters - parameters for initializing sdk core\n */\n constructor({\n siteCode,\n configuration,\n internalConfiguration,\n }: SDKCoreParameters) {\n const { settings: clientSettings } = new ClientSettings(\n siteCode,\n configuration,\n );\n this.environment = clientSettings.environment;\n const {\n externalStorage,\n externalEventSource,\n externalPackageInfo,\n externalVisitorCodeManager,\n externalRequestDispatcher,\n externalClientConfiguration,\n } = internalConfiguration;\n const trackingCache = new CacheManager<TrackingCacheItemType>(\n CACHE_CLEANUP_TIMEOUT,\n );\n\n const clientDataStorage = new DataStorage<ClientDataType>(\n externalStorage,\n KameleoonStorageKey.ClientData,\n );\n const targetingDataStorage = new DataStorage<TargetingDataType>(\n externalStorage,\n KameleoonStorageKey.TargetingData,\n );\n const variationDataStorage = new DataStorage<VariationDataType>(\n externalStorage,\n KameleoonStorageKey.VariationData,\n );\n const offlineTrackingStorage = new DataStorage<OfflineTracking>(\n externalStorage,\n KameleoonStorageKey.OfflineTracking,\n );\n const consentDataStorage = new DataStorage<ConsentDataType>(\n externalStorage,\n KameleoonStorageKey.ConsentData,\n );\n\n const dataManager = new DataManager({\n storage: targetingDataStorage,\n targetingCleanupInterval: configuration?.targetingDataCleanupInterval,\n });\n\n const eventSource = new KameleoonEventSource(\n clientSettings.siteCode,\n externalEventSource,\n );\n\n const requester = new Requester({\n siteCode,\n environment: clientSettings.environment,\n packageInfo: externalPackageInfo,\n requestDispatcher: externalRequestDispatcher,\n });\n\n const eventManager = new EventManager();\n\n const clientConfiguration = new ClientConfiguration({\n settings: clientSettings,\n storage: clientDataStorage,\n dataManager,\n eventManager,\n requester,\n externalClientConfiguration,\n offlineTrackingStorage,\n eventSource,\n externalVisitorCodeManager,\n });\n\n const variationConfiguration = new VariationConfiguration(\n variationDataStorage,\n );\n\n this.variationConfiguration = variationConfiguration;\n this.requester = requester;\n this.trackingCache = trackingCache;\n this.dataManager = dataManager;\n this.clientConfiguration = clientConfiguration;\n this.externalPackageInfo = externalPackageInfo;\n this.offlineTrackingStorage = offlineTrackingStorage;\n this.consentDataStorage = consentDataStorage;\n this.visitorCodeManager = externalVisitorCodeManager;\n this.eventManager = eventManager;\n }\n\n public async initialize(useCache?: boolean): Promise<boolean> {\n const result = await this.clientConfiguration.initialize();\n result.throw();\n\n this.isOfflineModeOn = useCache;\n this.initialized = true;\n\n return result.ok;\n }\n\n public addData(visitorCode: string, ...data: KameleoonDataType[]): void {\n Utilities.validateVisitorCode(visitorCode).throw();\n\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n this.dataManager.addData(visitorCode, ...data).throw();\n }\n\n public async getRemoteVisitorData({\n visitorCode,\n shouldAddData = true,\n filters = DEFAULT_VISITOR_DATA_FILTERS,\n isUniqueIdentifier = false,\n }: RemoteVisitorDataParamsType): Promise<KameleoonDataType[]> {\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n Utilities.validateVisitorCode(visitorCode).throw();\n\n const { previousVisitAmount } = filters;\n\n if (\n typeof previousVisitAmount === 'number' &&\n (previousVisitAmount < 1 || previousVisitAmount > 25)\n ) {\n throw new KameleoonError(KameleoonException.VisitAmount);\n }\n\n const result = await this.requester.getVisitorData({\n visitorCode,\n filters,\n isMappingIdentifier: isUniqueIdentifier,\n });\n const data = result.throw();\n\n const { visitorData, storageVisitorData, visitsData } =\n Utilities.parseVisitorData({\n data,\n filters,\n visitorCode,\n dataManager: this.dataManager,\n variationConfiguration: this.variationConfiguration,\n });\n\n for (const dataItem of storageVisitorData) {\n if (shouldAddData || this.dataManager.isPersistentCustomData(dataItem)) {\n this.addData(visitorCode, dataItem);\n }\n }\n\n // --- Note ---\n // Data on visits amount and time stamps is not returned to a user\n if (visitsData && shouldAddData) {\n this.addData(visitorCode, visitsData);\n }\n\n return visitorData;\n }\n\n public trackConversion({\n visitorCode,\n goalId,\n revenue,\n isUniqueIdentifier,\n }: TrackConversionParamsType): void {\n this.addData(visitorCode, new Conversion({ goalId, revenue }));\n this.flush(visitorCode, isUniqueIdentifier);\n }\n\n public flush(visitorCode?: string, isUniqueIdentifier?: boolean): void {\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n if (typeof visitorCode === 'string') {\n Utilities.validateVisitorCode(visitorCode).throw();\n }\n\n if (visitorCode) {\n let isMappingIdentifier = false;\n\n // --- Note ---\n // This part is a workaround for Data API\n // If there's is no unique identifier for the visitor\n // We do reconciliation for visitor with himself\n if (isUniqueIdentifier) {\n const linkedVisitor = this.dataManager.getLinkedVisitor(visitorCode);\n const index = this.dataManager.identifierCustomDataIndex;\n\n if (!linkedVisitor && typeof index === 'number') {\n this.dataManager.addData(\n visitorCode,\n new CustomData(index, visitorCode),\n );\n } else {\n isMappingIdentifier = true;\n }\n }\n\n Utilities.trackData({\n visitorCode,\n isMappingIdentifier,\n dataManager: this.dataManager,\n requester: this.requester,\n isOfflineModeOn: this.isOfflineModeOn,\n isConsentProvided: this._isConsentProvided(visitorCode),\n offlineTrackingStorage: this.offlineTrackingStorage,\n });\n\n return;\n }\n\n // --- Note ---\n // `Utilities.trackData` executes `Utilities.sendOfflineTracking` asynchronously at first, but\n // we need to execute `Utilities.sendOfflineTracking` even if calling `Utilities.trackData` is skipped\n // due to lack of unsent data\n if (!this.dataManager.unsentDataVisitors.length) {\n Utilities.sendOfflineTracking({\n requester: this.requester,\n storage: this.offlineTrackingStorage,\n });\n return;\n }\n\n for (const visitorCodeKey of this.dataManager.unsentDataVisitors) {\n Utilities.trackData({\n visitorCode: visitorCodeKey,\n dataManager: this.dataManager,\n requester: this.requester,\n isOfflineModeOn: this.isOfflineModeOn,\n isConsentProvided: this._isConsentProvided(visitorCodeKey),\n offlineTrackingStorage: this.offlineTrackingStorage,\n });\n }\n }\n\n public getFeatureFlags(): FeatureFlagType[] {\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n const featureFlags = this.clientConfiguration.featureFlags;\n const resultFeatureFlags: FeatureFlagType[] = [];\n\n featureFlags.forEach(({ id, featureKey }) => {\n resultFeatureFlags.push({\n id,\n key: featureKey,\n });\n });\n\n return resultFeatureFlags;\n }\n\n public getVisitorFeatureFlags(visitorCode: string): FeatureFlagType[] {\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n const activeVariations = this._getActiveFeatureVariations(visitorCode);\n const resultFeatureFlags: FeatureFlagType[] = [];\n\n activeVariations.forEach(({ featureFlagId, featureKey }) => {\n resultFeatureFlags.push({\n id: featureFlagId,\n key: featureKey,\n });\n });\n\n return resultFeatureFlags;\n }\n\n public getActiveFeatureFlags(\n visitorCode: string,\n ): Map<string, KameleoonVariationType> {\n const activeVariations = this._getActiveFeatureVariations(visitorCode);\n const resultFeatureList: Map<string, KameleoonVariationType> = new Map();\n\n activeVariations.forEach((variation) => {\n const { variationKey, featureKey, variationId, experimentId } = variation;\n\n let variables: FeatureVariableType[] = [];\n\n if (variationId !== null && experimentId !== null) {\n variables = this._getFeatureVariables({\n visitorCode,\n featureKey,\n variationKey,\n });\n }\n\n const resultVariables = variables.map((variable) =>\n Utilities.parseFeatureVariable(variable).throw(),\n );\n\n resultFeatureList.set(variation.featureKey, {\n key: variationKey,\n id: variationId,\n experimentId,\n variables: resultVariables,\n });\n });\n\n return resultFeatureList;\n }\n\n public getFeatureFlagVariationKey(\n visitorCode: string,\n featureKey: string,\n ): string {\n Utilities.validateVisitorCode(visitorCode).throw();\n\n const { variationKey } = this._getFeatureVariation(\n visitorCode,\n featureKey,\n ).throw();\n\n return variationKey;\n }\n\n public getFeatureFlagVariable({\n visitorCode,\n featureKey,\n variableKey,\n }: GetFeatureFlagVariableParamsType): FeatureFlagVariableType {\n Utilities.validateVisitorCode(visitorCode).throw();\n\n const { variationKey } = this._getFeatureVariation(\n visitorCode,\n featureKey,\n ).throw();\n\n const variables = this._getFeatureVariables({\n visitorCode,\n featureKey,\n variationKey,\n });\n const variable = variables.find((item) => item.key === variableKey);\n\n if (!variable) {\n throw new KameleoonError(\n KameleoonException.FeatureFlagVariableNotFound,\n variableKey,\n visitorCode,\n );\n }\n\n const { type, value } = Utilities.parseFeatureVariable(variable).throw();\n\n return { type, value } as FeatureFlagVariableType;\n }\n\n public getFeatureFlagVariables(\n visitorCode: string,\n featureKey: string,\n ): FeatureVariableResultType[] {\n Utilities.validateVisitorCode(visitorCode).throw();\n\n const { variationKey } = this._getFeatureVariation(\n visitorCode,\n featureKey,\n ).throw();\n\n const variables = this._getFeatureVariables({\n visitorCode,\n featureKey,\n variationKey,\n });\n const resultVariables: FeatureVariableResultType[] = [];\n\n for (const variable of variables) {\n const parsedVariable = Utilities.parseFeatureVariable(variable).throw();\n resultVariables.push(parsedVariable);\n }\n\n return resultVariables;\n }\n\n public isFeatureFlagActive(visitorCode: string, featureKey: string): boolean {\n try {\n const variationKey = this.getFeatureFlagVariationKey(\n visitorCode,\n featureKey,\n );\n\n return variationKey !== OFF_VARIATION_KEY;\n } catch (err) {\n if (\n err instanceof KameleoonError &&\n err.type === KameleoonException.FeatureFlagEnvironmentDisabled\n ) {\n return false;\n }\n\n throw err;\n }\n }\n\n public async getRemoteData(key: string): Promise<JSONType> {\n const remoteData = await this.requester.getRemoteData(key);\n\n return remoteData.throw();\n }\n\n public async getVisitorWarehouseAudience({\n visitorCode,\n customDataIndex,\n warehouseKey,\n }: GetVisitorWarehouseAudienceParamsType): Promise<CustomData | null> {\n Utilities.validateVisitorCode(visitorCode).throw();\n\n const data = await this.getRemoteData(warehouseKey || visitorCode);\n\n if (!data) {\n throw new KameleoonError(KameleoonException.RemoteData);\n }\n\n if (\n !data[WAREHOUSE_AUDIENCE_KEY] ||\n Object.keys(data[WAREHOUSE_AUDIENCE_KEY]).length === 0\n ) {\n return null;\n }\n\n const customData = new CustomData(\n customDataIndex,\n ...Object.keys(data[WAREHOUSE_AUDIENCE_KEY]),\n );\n\n this.dataManager.addData(visitorCode, customData);\n\n return customData;\n }\n\n /**\n * @deprecated\n * use `onEvent(EventType.ConfigurationUpdate, callback)` instead\n * Will be removed in the next major release\n * */\n public onConfigurationUpdate(callback: () => void): void {\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n this.eventManager.addEventHandler(EventType.ConfigurationUpdate, callback);\n }\n\n public onEvent<E extends EventType>(\n event: E,\n callback: EventCallbackType<E>,\n ): void {\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n this.eventManager.addEventHandler(event, callback);\n }\n\n public getEngineTrackingCode(visitorCode: string): string {\n Utilities.validateVisitorCode(visitorCode).throw();\n\n return Utilities.getTrackingCode(this.trackingCache, visitorCode);\n }\n\n public isInitialized(): boolean {\n return this.initialized;\n }\n\n protected setUserConsent({\n visitorCode,\n consent,\n setData,\n }: SetUserConsentParametersType): void {\n Utilities.validateVisitorCode(visitorCode).throw();\n\n this.consentDataStorage.update({ [visitorCode]: consent });\n\n if (consent) {\n setData({\n visitorCode,\n key: KameleoonStorageKey.VisitorCode,\n maxAge: DEFAULT_MAX_AGE,\n path: PATH,\n });\n } else {\n if (this.visitorCodeManager.consentRequired) {\n setData({\n visitorCode: '',\n key: KameleoonStorageKey.VisitorCode,\n maxAge: ZERO_MAX_AGE,\n path: PATH,\n });\n }\n }\n }\n\n private _isConsentProvided(visitorCode: string): boolean {\n const { isConsentRequired } = this.clientConfiguration;\n const consentDataResult = this.consentDataStorage.read();\n\n return (\n !isConsentRequired ||\n (consentDataResult.ok && consentDataResult.data[visitorCode])\n );\n }\n\n private _getFeatureVariables({\n visitorCode,\n featureKey,\n variationKey,\n }: GetFeatureVariablesParamsType): FeatureVariableType[] {\n const featureFlags = this.clientConfiguration.featureFlags;\n const featureFlag = featureFlags.get(featureKey);\n\n if (!featureFlag) {\n throw new KameleoonError(\n KameleoonException.FeatureFlagConfigurationNotFound,\n featureKey,\n );\n }\n const variation = featureFlag.variations.find(\n (item) => item.key === variationKey,\n );\n\n if (!variation) {\n throw new KameleoonError(\n KameleoonException.FeatureFlagVariationNotFound,\n variationKey,\n visitorCode,\n );\n }\n\n return variation.variables;\n }\n\n private _getActiveFeatureVariations(\n visitorCode: string,\n ): FeatureFlagVariationType[] {\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n const featureFlags = this.clientConfiguration.featureFlags;\n const activeVariations: FeatureFlagVariationType[] = [];\n\n const targetingData = this.dataManager.getTargetingData(visitorCode);\n const visitorIdentifier =\n this.dataManager.getVisitorIdentifier(visitorCode);\n\n for (const featureFlag of featureFlags.values()) {\n if (!featureFlag.environmentEnabled) {\n continue;\n }\n\n const variationData = this.variationConfiguration\n .getVariation({\n visitorCode,\n visitorIdentifier,\n targetingData,\n featureFlag,\n clientConfiguration: this.clientConfiguration,\n dataManager: this.dataManager,\n packageInfo: this.externalPackageInfo,\n })\n .throw();\n\n this.eventManager.fireEvent(EventType.Evaluation, {\n featureKey: featureFlag.featureKey,\n variation: {\n key: variationData.variationKey,\n experimentId: variationData.experimentId,\n id: variationData.variationId,\n },\n });\n\n if (variationData.variationKey !== OFF_VARIATION_KEY) {\n activeVariations.push(variationData);\n }\n }\n\n return activeVariations;\n }\n\n private _getFeatureVariation(\n visitorCode: string,\n featureKey: string,\n ): Result<FeatureFlagVariationType, KameleoonError> {\n if (!this.initialized) {\n return Err(new KameleoonError(KameleoonException.Initialization));\n }\n\n const featureFlags = this.clientConfiguration.featureFlags;\n const featureFlag = featureFlags.get(featureKey);\n\n if (!featureFlag) {\n return Err(\n new KameleoonError(\n KameleoonException.FeatureFlagConfigurationNotFound,\n featureKey,\n ),\n );\n }\n\n if (!featureFlag.environmentEnabled) {\n return Err(\n new KameleoonError(\n KameleoonException.FeatureFlagEnvironmentDisabled,\n featureFlag.featureKey,\n this.environment || Environment.Production,\n ),\n );\n }\n\n const targetingData = this.dataManager.getTargetingData(visitorCode);\n const visitorIdentifier =\n this.dataManager.getVisitorIdentifier(visitorCode);\n\n const variationData = this.variationConfiguration\n .getVariation({\n visitorCode,\n visitorIdentifier,\n featureFlag,\n targetingData,\n withAssignment: true,\n clientConfiguration: this.clientConfiguration,\n dataManager: this.dataManager,\n packageInfo: this.externalPackageInfo,\n })\n .throw();\n\n this.eventManager.fireEvent(EventType.Evaluation, {\n featureKey,\n variation: {\n key: variationData.variationKey,\n experimentId: variationData.experimentId,\n id: variationData.variationId,\n },\n });\n\n const { experimentId, variationId } = variationData;\n\n if (typeof variationId === 'number' && typeof experimentId === 'number') {\n Utilities.updateCache({\n cacheManager: this.trackingCache,\n visitorCode,\n experimentId,\n variationId,\n });\n }\n\n Utilities.trackFeatureExperiment({\n visitorCode,\n requester: this.requester,\n featureFlagVariation: variationData,\n dataManager: this.dataManager,\n isOfflineModeOn: this.isOfflineModeOn,\n isConsentProvided: this._isConsentProvided(visitorCode),\n offlineTrackingStorage: this.offlineTrackingStorage,\n variationConfiguration: this.variationConfiguration,\n });\n\n return Ok(variationData);\n }\n}\n"],"mappings":"+rCAgEO,KAAM,CAAAA,eAA4C,CAkBvDC,WAAWA,CAAAC,CAAA,CAIW,IAJV,CACVC,QAAQ,CAARA,CAAQ,CACRC,aAAa,CAAbA,CAAa,CACbC,qBAAqB,CAArBA,CACiB,CAAC,CAAAH,CAAA,CAAAI,eAAA,uCAAAA,eAAA,oCAAAA,eAAA,4BAAAA,eAAA,uCAAAA,eAAA,mCAAAA,eAAA,8BAAAA,eAAA,0BAAAA,eAAA,oCAAAA,eAAA,wBAAAA,eAAA,mCAAAA,eAAA,6BAAAA,eAAA,4BAAAA,eAAA,gCAClB,KAAM,CAAEC,QAAQ,CAAEC,CAAe,CAAC,CAAG,GAAI,CAAAC,8BAAc,CACrDN,CAAQ,CACRC,CACF,CAAC,CACD,IAAI,CAACM,WAAW,CAAGF,CAAc,CAACE,WAAW,MACvC,CACJC,eAAe,CAAfA,CAAe,CACfC,mBAAmB,CAAnBA,CAAmB,CACnBC,mBAAmB,CAAnBA,CAAmB,CACnBC,0BAA0B,CAA1BA,CAA0B,CAC1BC,yBAAyB,CAAzBA,CAAyB,CACzBC,2BAA2B,CAA3BA,CACF,CAAC,CAAGX,CAAqB,CACnBY,CAAa,CAAG,GAAI,CAAAC,0BAAY,CACpCC,gCACF,CAAC,CAEKC,CAAiB,CAAG,GAAI,CAAAC,oBAAW,CACvCV,CAAe,CACfW,4BAAmB,CAACC,UACtB,CAAC,CACKC,CAAoB,CAAG,GAAI,CAAAH,oBAAW,CAC1CV,CAAe,CACfW,4BAAmB,CAACG,aACtB,CAAC,CACKC,CAAoB,CAAG,GAAI,CAAAL,oBAAW,CAC1CV,CAAe,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A4B,QAAQ,EAAhC,MAAO,CAAAC,CAAyB,EACrE5D,oBAAS,CAACwI,WAAW,CAAC,CACpBC,YAAY,CAAE,IAAI,CAACnL,aAAa,CAChCyC,WAAW,CAAXA,CAAW,CACX6D,YAAY,CAAZA,CAAY,CACZD,WAAW,CAAXA,CACF,CAAC,CAAC,CAGJ3D,oBAAS,CAAC0I,sBAAsB,CAAC,CAC/B3I,WAAW,CAAXA,CAAW,CACXnB,SAAS,CAAE,IAAI,CAACA,SAAS,CACzB+J,oBAAoB,CAAEX,CAAa,CACnC3J,WAAW,CAAE,IAAI,CAACA,WAAW,CAC7BsB,eAAe,CAAE,IAAI,CAACA,eAAe,CACrC0C,iBAAiB,CAAE,IAAI,CAACC,kBAAkB,CAACvC,CAAW,CAAC,CACvD9B,sBAAsB,CAAE,IAAI,CAACA,sBAAsB,CACnDmB,sBAAsB,CAAE,IAAI,CAACA,sBAC/B,CAAC,CAAC,CAEK,GAAAwJ,SAAE,EAACZ,CAAa,CACzB,CACF,CAACa,OAAA,CAAAxM,eAAA,CAAAA,eAAA"}
@@ -1,4 +1,5 @@
1
1
  import { JSONType } from './clientConfiguration';
2
+ import { EventCallbackType, EventType } from './eventManager';
2
3
  import { CustomData, KameleoonDataType } from './kameleoonData';
3
4
  import { FeatureFlagType, FeatureFlagVariableType, FeatureVariableResultType, GetFeatureFlagVariableParamsType, GetVisitorWarehouseAudienceParamsType, KameleoonVariationType, RemoteVisitorDataParamsType, TrackConversionParamsType } from './types';
4
5
  /**
@@ -7,6 +8,9 @@ import { FeatureFlagType, FeatureFlagVariableType, FeatureVariableResultType, Ge
7
8
  export interface IKameleoonClient {
8
9
  /**
9
10
  * @method initialize - an asynchronous method for KameleoonClient initialization by fetching Kameleoon SDK related data from server or by retrieving data from local source if data is up-to-date or update interval has not been reached
11
+ *
12
+ * Triggered Events: `EventType.ConfigurationUpdate` (On each successful configuration update while using Real Time Update)
13
+ *
10
14
  * @param {boolean | undefined} useCache - optional parameter for activating SDK offline mode, if `true` is passed failed polls will not return error and will use cached data if such data is available, default value is `false`. Note: if offline mode is on, SDK will still try to retrieve the latest data.
11
15
  * @returns {Promise<boolean>} Promise resolved into boolean field indicating success or fail
12
16
  * @throws `KameleoonError` with one of the following `type` s:
@@ -84,6 +88,7 @@ export interface IKameleoonClient {
84
88
  * @method getVisitorFeatureFlags - returns a list of feature flags that the visitor with `visitorCode` that is targeted by and that are *active* for the visitor (visitor will have one of the variations allocated).
85
89
  *
86
90
  * Note: This method **doesn't send** tracking data
91
+ * Triggered Events: `EventType.Evaluation` (For each feature flag evaluated)
87
92
  *
88
93
  * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length
89
94
  * @returns {FeatureFlagType[]} a list of all feature flags items with `id` and `key` fields
@@ -100,6 +105,7 @@ export interface IKameleoonClient {
100
105
  * @method getActiveFeatureFlags - method collecting all active feature flags information including it's variation and variables for the visitor
101
106
  *
102
107
  * Note: This method **doesn't send** tracking data
108
+ * Triggered Events: `EventType.Evaluation` (For each feature flag evaluated)
103
109
  *
104
110
  * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length
105
111
  * @returns {Map<string, KameleoonVariationType>} a map of feature flags with `featureKey` as a key and `KameleoonVariationType` as a value
@@ -117,6 +123,7 @@ export interface IKameleoonClient {
117
123
  * @method isFeatureFlagActive - returns a boolean indicating whether the visitor with `visitorCode` has `featureKey` active for him, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request
118
124
  *
119
125
  * Note: This method **sends** tracking data
126
+ * Triggered Events: `EventType.Evaluation`
120
127
  *
121
128
  * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length
122
129
  * @param {string} featureKey - a unique key for feature flag
@@ -135,6 +142,7 @@ export interface IKameleoonClient {
135
142
  * @method getFeatureFlagVariationKey - returns variation key for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request
136
143
  *
137
144
  * Note: This method **sends** tracking data
145
+ * Triggered Events: `EventType.Evaluation`
138
146
  *
139
147
  * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length
140
148
  * @param {string} featureKey - a unique key for feature flag
@@ -153,6 +161,7 @@ export interface IKameleoonClient {
153
161
  * @method getFeatureFlagVariable - returns a variable for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request
154
162
  *
155
163
  * Note: This method **sends** tracking data
164
+ * Triggered Events: `EventType.Evaluation`
156
165
  *
157
166
  * @param {GetFeatureFlagVariableParamsType} parameters - an object with parameters of a type `GetFeatureFlagVariableParamsType`, see the type for details.
158
167
  * @returns {FeatureFlagVariableType} a variable object containing `type` and `value` fields. You can check the `type` field against `VariableType` enum. For example, if the `type` is `VariableType.BOOLEAN` then `value` will be a `boolean` type.
@@ -173,6 +182,7 @@ export interface IKameleoonClient {
173
182
  * @method getFeatureFlagVariables - returns a list of variables for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request
174
183
  *
175
184
  * Note: This method **sends** tracking data
185
+ * Triggered Events: `EventType.Evaluation`
176
186
  *
177
187
  * @param {string} visitorCode - a unique visitor identifier, shouldn't exceed 255 characters
178
188
  * @param {string} featureKey - a unique key for feature flag
@@ -231,4 +241,20 @@ export interface IKameleoonClient {
231
241
  * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call
232
242
  */
233
243
  onConfigurationUpdate: (callback: () => void) => void;
244
+ /**
245
+ * @method onEvent - fires a callback on a specified Kameleoon `EventType`. Each event can only have one according callback.
246
+ *
247
+ * Note: SDK methods are marked with the `EventType` they trigger if any.
248
+ *
249
+ * @param {EventCallbackType<EventType>} callback - callback function with parameters that will be called upon event
250
+ *
251
+ * Parameter type depends on the `EventType` passed:
252
+ * - `EventType.Evaluation` - `EvaluationEventDataType`
253
+ * - `EventType.ConfigurationUpdate` - `ConfigurationUpdateEventDataType`
254
+ * @returns {void}
255
+ * @throws `KameleoonError` with one of the following `type` s:
256
+ *
257
+ * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call
258
+ */
259
+ onEvent: (event: EventType, callback: EventCallbackType<EventType>) => void;
234
260
  }
@@ -1 +1 @@
1
- {"version":3,"file":"kameleoonClientInterface.js","names":[],"sources":["../src/kameleoonClientInterface.ts"],"sourcesContent":["import { JSONType } from './clientConfiguration';\nimport { CustomData, KameleoonDataType } from './kameleoonData';\nimport {\n FeatureFlagType,\n FeatureFlagVariableType,\n FeatureVariableResultType,\n GetFeatureFlagVariableParamsType,\n GetVisitorWarehouseAudienceParamsType,\n KameleoonVariationType,\n RemoteVisitorDataParamsType,\n TrackConversionParamsType,\n} from './types';\n\n/**\n * @interface an interface of KameleoonClient instance\n */\nexport interface IKameleoonClient {\n /**\n * @method initialize - an asynchronous method for KameleoonClient initialization by fetching Kameleoon SDK related data from server or by retrieving data from local source if data is up-to-date or update interval has not been reached\n * @param {boolean | undefined} useCache - optional parameter for activating SDK offline mode, if `true` is passed failed polls will not return error and will use cached data if such data is available, default value is `false`. Note: if offline mode is on, SDK will still try to retrieve the latest data.\n * @returns {Promise<boolean>} Promise resolved into boolean field indicating success or fail\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.StorageWrite` Couldn't update storage data\n * - `KameleoonException.ClientConfiguration` Couldn't retrieve client configuration from Kameleoon Api\n * - `KameleoonException.MaximumRetriesReached` Maximum retries reached, request failed\n */\n initialize(useCache?: boolean): Promise<boolean>;\n initialize(): Promise<boolean>;\n /**\n * @method addData - method for adding targeting data to the storage so that other methods could decide whether the current visitor is targeted or not. Note: userAgent data will not be stored in storage like other data, and it will be sent with every tracking request for bot filtration.\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @param {KameleoonDataType[]} kameleoonData - number of instances of any type of `KameleoonData`, can be added solely in array or as a sequential arguments\n * @returns {void}\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.StorageWrite` Couldn't update storage data\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n */\n addData: (visitorCode: string, ...data: KameleoonDataType[]) => void;\n /**\n * @method getRemoteVisitorData - an asynchronous method for retrieving KameleoonData from Data API and optionally adding it to the storage so that other methods could decide whether the current visitor is targeted or not.\n * @param {RemoteVisitorDataParamsType} remoteVisitorDataParameters - `visitorCode`, `shouldAddData`, `filters` and `isUniqueIdentifier` parameters\n * @returns {KameleoonDataType[]} promise resolved to an array of `KameleoonData` instances, only includes custom data\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.RemoteData` - Couldn't retrieve data from Kameleoon server\n * - `KameleoonException.VisitAmount` - Visit amount must be a number between 1 and 25\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n */\n getRemoteVisitorData: ({\n visitorCode,\n shouldAddData,\n filters,\n isUniqueIdentifier,\n }: RemoteVisitorDataParamsType) => Promise<KameleoonDataType[]>;\n /**\n * @method trackConversion - creates and adds `Conversion` data to the visitor with specified parameters and executes `flush`. Note: it's a helper method for the quick and convenient conversion tracking, however creating and adding `Conversion` manually allows more flexible `Conversion` with `negative` parameter\n * @param {TrackConversionParamsType} conversionParameters - `visitorCode`, `goalId` and `revenue` parameters for data tracking\n * @returns {void}\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.StorageWrite` Couldn't update storage data\n */\n trackConversion: ({\n visitorCode,\n goalId,\n revenue,\n isUniqueIdentifier,\n }: TrackConversionParamsType) => void;\n /**\n * @method flush - takes visitor associated kameleoon data and sends the data tracking request with collected data,\n * sent data is removed from `KameleoonClient` instance but not from the storage for correct targeting checks. If no visitor is passed,\n * then data for all visitors is sent and removed from `KameleoonClient` instance. Moreover, regardless of visitor code input\n * the method first attempts to send all previously failed tracking requests which were stored locally during the offline mode.\n * @param {string | undefined} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @param {boolean | undefined} isUniqueIdentifier - an optional parameter for specifying if the visitorCode is a unique identifier, default value is `false`\n * @returns {void}\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n */\n flush: (visitorCode?: string, isUniqueIdentifier?: boolean) => void;\n /**\n * @method getFeatureFlags - returns a list of feature flags stored in the client configuration\n *\n * Note: This method **doesn't send** tracking data\n *\n * @returns {FeatureFlagType[]} a list of all feature flags items with `id` and `key` fields\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n */\n getFeatureFlags: () => FeatureFlagType[];\n /**\n * @method getVisitorFeatureFlags - returns a list of feature flags that the visitor with `visitorCode` that is targeted by and that are *active* for the visitor (visitor will have one of the variations allocated).\n *\n * Note: This method **doesn't send** tracking data\n *\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @returns {FeatureFlagType[]} a list of all feature flags items with `id` and `key` fields\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`\n * - `KameleoonException.StorageRead` - Couldn't read storage data\n * - `KameleoonException.NotTargeted` - Current visitor is not targeted\n */\n getVisitorFeatureFlags: (visitorCode: string) => FeatureFlagType[];\n /**\n * @method getActiveFeatureFlags - method collecting all active feature flags information including it's variation and variables for the visitor\n *\n * Note: This method **doesn't send** tracking data\n *\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @returns {Map<string, KameleoonVariationType>} a map of feature flags with `featureKey` as a key and `KameleoonVariationType` as a value\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`\n * - `KameleoonException.StorageRead` - Couldn't read storage data\n * - `KameleoonException.JSONParse` - Couldn't parse JSON value\n * - `KameleoonException.NumberParse` - Couldn't parse Number value\n */\n getActiveFeatureFlags: (\n visitorCode: string,\n ) => Map<string, KameleoonVariationType>;\n /**\n * @method isFeatureFlagActive - returns a boolean indicating whether the visitor with `visitorCode` has `featureKey` active for him, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request\n *\n * Note: This method **sends** tracking data\n *\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @param {string} featureKey - a unique key for feature flag\n * @returns {boolean} a boolean indicator of whether the feature flag with `featureKey` is active for visitor with `visitorCode`\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`\n * - `KameleoonException.DataInconsistency` - Allocated variation was found but there is no feature flag with according `featureKey`.\n * - `KameleoonException.NotTargeted` - Current visitor is not targeted\n */\n isFeatureFlagActive: (visitorCode: string, featureKey: string) => boolean;\n /**\n * @method getFeatureFlagVariationKey - returns variation key for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request\n *\n * Note: This method **sends** tracking data\n *\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @param {string} featureKey - a unique key for feature flag\n * @returns {string} a string containing variable key for the allocated feature flag variation for the provided visitor\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`\n * - `KameleoonException.FeatureFlagEnvironmentDisabled` - The feature flag is disabled for the current environment\n * - `KameleoonException.NotTargeted` - Current visitor is not targeted\n */\n getFeatureFlagVariationKey: (\n visitorCode: string,\n featureKey: string,\n ) => string;\n /**\n * @method getFeatureFlagVariable - returns a variable for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request\n *\n * Note: This method **sends** tracking data\n *\n * @param {GetFeatureFlagVariableParamsType} parameters - an object with parameters of a type `GetFeatureFlagVariableParamsType`, see the type for details.\n * @returns {FeatureFlagVariableType} a variable object containing `type` and `value` fields. You can check the `type` field against `VariableType` enum. For example, if the `type` is `VariableType.BOOLEAN` then `value` will be a `boolean` type.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`\n * - `KameleoonException.FeatureFlagVariableNotFound` - No feature variable was found for provided `visitorCode` and `variableKey`\n * - `KameleoonException.FeatureFlagEnvironmentDisabled` - The feature flag is disabled for the current environment\n * - `KameleoonException.NotTargeted` - Current visitor is not targeted\n * - `KameleoonException.JSONParse` - Couldn't parse JSON value\n * - `KameleoonException.NumberParse` - Couldn't parse Number value\n */\n getFeatureFlagVariable: ({\n visitorCode,\n featureKey,\n variableKey,\n }: GetFeatureFlagVariableParamsType) => FeatureFlagVariableType;\n /**\n * @method getFeatureFlagVariables - returns a list of variables for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request\n *\n * Note: This method **sends** tracking data\n *\n * @param {string} visitorCode - a unique visitor identifier, shouldn't exceed 255 characters\n * @param {string} featureKey - a unique key for feature flag\n * @returns {FeatureVariableResultType[]} a list of variable objects containing `key`, `type` and `value` fields. You can check the `type` field against `VariableType` enum. For example, if the `type` is `VariableType.BOOLEAN` then `value` will be a `boolean` type.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`\n * - `KameleoonException.FeatureFlagVariationNotFound` - No feature variation was found for provided `visitorCode` and `variationKey`\n * - `KameleoonException.FeatureFlagEnvironmentDisabled` - The feature flag is disabled for the current environment\n * - `KameleoonException.JSONParse` - Couldn't parse JSON value\n * - `KameleoonException.NumberParse` - Couldn't parse Number value\n */\n getFeatureFlagVariables: (\n visitorCode: string,\n featureKey: string,\n ) => FeatureVariableResultType[];\n /**\n * @method getRemoteData - returns a data which is stored for specified siteCode on a remote Kameleoon server.\n * @param {string} key - unique key that the data you try to get is associated with.\n * @returns {JSONType} - promise with retrieving data for specific key.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.RemoteData` - Couldn't retrieve data from Kameleoon server\n */\n getRemoteData: (key: string) => Promise<JSONType>;\n /**\n * @method getVisitorWarehouseAudience - an async method that returns a `CustomData` instance, containing data associated with a visitor's warehouse audiences\n * which is stored for specified visitorCode on a remote Kameleoon server.\n * Retrieved data will be added to storage under the specified `customDataIndex`\n * @param {GetVisitorWarehouseAudienceParamsType} parameters - an object with parameters of a type `GetVisitorWarehouseAudienceParamsType`, see the type for details.\n * @returns {Promise<CustomData | null>} `Promise` containing an instance of `CustomData` containing data associated with a visitor's warehouse audiences or `null` if the data was retrieved successfully but nothing was found under the specified `warehouseKey`\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` - The visitor code is empty\n * - `KameleoonException.RemoteData` - Couldn't retrieve data from Kameleoon server\n */\n getVisitorWarehouseAudience: ({\n visitorCode,\n customDataIndex,\n warehouseKey,\n }: GetVisitorWarehouseAudienceParamsType) => Promise<CustomData | null>;\n /**\n * @method getEngineTrackingCode - returns Kameleoon tracking code for the current visitor. Tracking code is built of the experiments that were triggered and feature flag variations that were assigned during the last 5 seconds\n * See [Kameleoon Automation API](https://developers.kameleoon.com/apis/activation-api-js/api-reference#trigger-1) for the details\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @returns {string} Kameleoon tracking code\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n */\n getEngineTrackingCode: (visitorCode: string) => string;\n /**\n * @method onConfigurationUpdate - fires a callback on client configuration update. Note: this method only works for server sent events of real time update.\n * @param {() => void} callback - callback function with no parameters that will be called upon configuration update\n * @returns {void}\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n */\n onConfigurationUpdate: (callback: () => void) => void;\n}\n"],"mappings":""}
1
+ {"version":3,"file":"kameleoonClientInterface.js","names":[],"sources":["../src/kameleoonClientInterface.ts"],"sourcesContent":["import { JSONType } from './clientConfiguration';\nimport { EventCallbackType, EventType } from './eventManager';\nimport { CustomData, KameleoonDataType } from './kameleoonData';\nimport {\n FeatureFlagType,\n FeatureFlagVariableType,\n FeatureVariableResultType,\n GetFeatureFlagVariableParamsType,\n GetVisitorWarehouseAudienceParamsType,\n KameleoonVariationType,\n RemoteVisitorDataParamsType,\n TrackConversionParamsType,\n} from './types';\n\n/**\n * @interface an interface of KameleoonClient instance\n */\nexport interface IKameleoonClient {\n /**\n * @method initialize - an asynchronous method for KameleoonClient initialization by fetching Kameleoon SDK related data from server or by retrieving data from local source if data is up-to-date or update interval has not been reached\n *\n * Triggered Events: `EventType.ConfigurationUpdate` (On each successful configuration update while using Real Time Update)\n *\n * @param {boolean | undefined} useCache - optional parameter for activating SDK offline mode, if `true` is passed failed polls will not return error and will use cached data if such data is available, default value is `false`. Note: if offline mode is on, SDK will still try to retrieve the latest data.\n * @returns {Promise<boolean>} Promise resolved into boolean field indicating success or fail\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.StorageWrite` Couldn't update storage data\n * - `KameleoonException.ClientConfiguration` Couldn't retrieve client configuration from Kameleoon Api\n * - `KameleoonException.MaximumRetriesReached` Maximum retries reached, request failed\n */\n initialize(useCache?: boolean): Promise<boolean>;\n initialize(): Promise<boolean>;\n /**\n * @method addData - method for adding targeting data to the storage so that other methods could decide whether the current visitor is targeted or not. Note: userAgent data will not be stored in storage like other data, and it will be sent with every tracking request for bot filtration.\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @param {KameleoonDataType[]} kameleoonData - number of instances of any type of `KameleoonData`, can be added solely in array or as a sequential arguments\n * @returns {void}\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.StorageWrite` Couldn't update storage data\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n */\n addData: (visitorCode: string, ...data: KameleoonDataType[]) => void;\n /**\n * @method getRemoteVisitorData - an asynchronous method for retrieving KameleoonData from Data API and optionally adding it to the storage so that other methods could decide whether the current visitor is targeted or not.\n * @param {RemoteVisitorDataParamsType} remoteVisitorDataParameters - `visitorCode`, `shouldAddData`, `filters` and `isUniqueIdentifier` parameters\n * @returns {KameleoonDataType[]} promise resolved to an array of `KameleoonData` instances, only includes custom data\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.RemoteData` - Couldn't retrieve data from Kameleoon server\n * - `KameleoonException.VisitAmount` - Visit amount must be a number between 1 and 25\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n */\n getRemoteVisitorData: ({\n visitorCode,\n shouldAddData,\n filters,\n isUniqueIdentifier,\n }: RemoteVisitorDataParamsType) => Promise<KameleoonDataType[]>;\n /**\n * @method trackConversion - creates and adds `Conversion` data to the visitor with specified parameters and executes `flush`. Note: it's a helper method for the quick and convenient conversion tracking, however creating and adding `Conversion` manually allows more flexible `Conversion` with `negative` parameter\n * @param {TrackConversionParamsType} conversionParameters - `visitorCode`, `goalId` and `revenue` parameters for data tracking\n * @returns {void}\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.StorageWrite` Couldn't update storage data\n */\n trackConversion: ({\n visitorCode,\n goalId,\n revenue,\n isUniqueIdentifier,\n }: TrackConversionParamsType) => void;\n /**\n * @method flush - takes visitor associated kameleoon data and sends the data tracking request with collected data,\n * sent data is removed from `KameleoonClient` instance but not from the storage for correct targeting checks. If no visitor is passed,\n * then data for all visitors is sent and removed from `KameleoonClient` instance. Moreover, regardless of visitor code input\n * the method first attempts to send all previously failed tracking requests which were stored locally during the offline mode.\n * @param {string | undefined} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @param {boolean | undefined} isUniqueIdentifier - an optional parameter for specifying if the visitorCode is a unique identifier, default value is `false`\n * @returns {void}\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n */\n flush: (visitorCode?: string, isUniqueIdentifier?: boolean) => void;\n /**\n * @method getFeatureFlags - returns a list of feature flags stored in the client configuration\n *\n * Note: This method **doesn't send** tracking data\n *\n * @returns {FeatureFlagType[]} a list of all feature flags items with `id` and `key` fields\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n */\n getFeatureFlags: () => FeatureFlagType[];\n /**\n * @method getVisitorFeatureFlags - returns a list of feature flags that the visitor with `visitorCode` that is targeted by and that are *active* for the visitor (visitor will have one of the variations allocated).\n *\n * Note: This method **doesn't send** tracking data\n * Triggered Events: `EventType.Evaluation` (For each feature flag evaluated)\n *\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @returns {FeatureFlagType[]} a list of all feature flags items with `id` and `key` fields\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`\n * - `KameleoonException.StorageRead` - Couldn't read storage data\n * - `KameleoonException.NotTargeted` - Current visitor is not targeted\n */\n getVisitorFeatureFlags: (visitorCode: string) => FeatureFlagType[];\n /**\n * @method getActiveFeatureFlags - method collecting all active feature flags information including it's variation and variables for the visitor\n *\n * Note: This method **doesn't send** tracking data\n * Triggered Events: `EventType.Evaluation` (For each feature flag evaluated)\n *\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @returns {Map<string, KameleoonVariationType>} a map of feature flags with `featureKey` as a key and `KameleoonVariationType` as a value\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`\n * - `KameleoonException.StorageRead` - Couldn't read storage data\n * - `KameleoonException.JSONParse` - Couldn't parse JSON value\n * - `KameleoonException.NumberParse` - Couldn't parse Number value\n */\n getActiveFeatureFlags: (\n visitorCode: string,\n ) => Map<string, KameleoonVariationType>;\n /**\n * @method isFeatureFlagActive - returns a boolean indicating whether the visitor with `visitorCode` has `featureKey` active for him, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request\n *\n * Note: This method **sends** tracking data\n * Triggered Events: `EventType.Evaluation`\n *\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @param {string} featureKey - a unique key for feature flag\n * @returns {boolean} a boolean indicator of whether the feature flag with `featureKey` is active for visitor with `visitorCode`\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`\n * - `KameleoonException.DataInconsistency` - Allocated variation was found but there is no feature flag with according `featureKey`.\n * - `KameleoonException.NotTargeted` - Current visitor is not targeted\n */\n isFeatureFlagActive: (visitorCode: string, featureKey: string) => boolean;\n /**\n * @method getFeatureFlagVariationKey - returns variation key for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request\n *\n * Note: This method **sends** tracking data\n * Triggered Events: `EventType.Evaluation`\n *\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @param {string} featureKey - a unique key for feature flag\n * @returns {string} a string containing variable key for the allocated feature flag variation for the provided visitor\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`\n * - `KameleoonException.FeatureFlagEnvironmentDisabled` - The feature flag is disabled for the current environment\n * - `KameleoonException.NotTargeted` - Current visitor is not targeted\n */\n getFeatureFlagVariationKey: (\n visitorCode: string,\n featureKey: string,\n ) => string;\n /**\n * @method getFeatureFlagVariable - returns a variable for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request\n *\n * Note: This method **sends** tracking data\n * Triggered Events: `EventType.Evaluation`\n *\n * @param {GetFeatureFlagVariableParamsType} parameters - an object with parameters of a type `GetFeatureFlagVariableParamsType`, see the type for details.\n * @returns {FeatureFlagVariableType} a variable object containing `type` and `value` fields. You can check the `type` field against `VariableType` enum. For example, if the `type` is `VariableType.BOOLEAN` then `value` will be a `boolean` type.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`\n * - `KameleoonException.FeatureFlagVariableNotFound` - No feature variable was found for provided `visitorCode` and `variableKey`\n * - `KameleoonException.FeatureFlagEnvironmentDisabled` - The feature flag is disabled for the current environment\n * - `KameleoonException.NotTargeted` - Current visitor is not targeted\n * - `KameleoonException.JSONParse` - Couldn't parse JSON value\n * - `KameleoonException.NumberParse` - Couldn't parse Number value\n */\n getFeatureFlagVariable: ({\n visitorCode,\n featureKey,\n variableKey,\n }: GetFeatureFlagVariableParamsType) => FeatureFlagVariableType;\n /**\n * @method getFeatureFlagVariables - returns a list of variables for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request\n *\n * Note: This method **sends** tracking data\n * Triggered Events: `EventType.Evaluation`\n *\n * @param {string} visitorCode - a unique visitor identifier, shouldn't exceed 255 characters\n * @param {string} featureKey - a unique key for feature flag\n * @returns {FeatureVariableResultType[]} a list of variable objects containing `key`, `type` and `value` fields. You can check the `type` field against `VariableType` enum. For example, if the `type` is `VariableType.BOOLEAN` then `value` will be a `boolean` type.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`\n * - `KameleoonException.FeatureFlagVariationNotFound` - No feature variation was found for provided `visitorCode` and `variationKey`\n * - `KameleoonException.FeatureFlagEnvironmentDisabled` - The feature flag is disabled for the current environment\n * - `KameleoonException.JSONParse` - Couldn't parse JSON value\n * - `KameleoonException.NumberParse` - Couldn't parse Number value\n */\n getFeatureFlagVariables: (\n visitorCode: string,\n featureKey: string,\n ) => FeatureVariableResultType[];\n /**\n * @method getRemoteData - returns a data which is stored for specified siteCode on a remote Kameleoon server.\n * @param {string} key - unique key that the data you try to get is associated with.\n * @returns {JSONType} - promise with retrieving data for specific key.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.RemoteData` - Couldn't retrieve data from Kameleoon server\n */\n getRemoteData: (key: string) => Promise<JSONType>;\n /**\n * @method getVisitorWarehouseAudience - an async method that returns a `CustomData` instance, containing data associated with a visitor's warehouse audiences\n * which is stored for specified visitorCode on a remote Kameleoon server.\n * Retrieved data will be added to storage under the specified `customDataIndex`\n * @param {GetVisitorWarehouseAudienceParamsType} parameters - an object with parameters of a type `GetVisitorWarehouseAudienceParamsType`, see the type for details.\n * @returns {Promise<CustomData | null>} `Promise` containing an instance of `CustomData` containing data associated with a visitor's warehouse audiences or `null` if the data was retrieved successfully but nothing was found under the specified `warehouseKey`\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` - The visitor code is empty\n * - `KameleoonException.RemoteData` - Couldn't retrieve data from Kameleoon server\n */\n getVisitorWarehouseAudience: ({\n visitorCode,\n customDataIndex,\n warehouseKey,\n }: GetVisitorWarehouseAudienceParamsType) => Promise<CustomData | null>;\n /**\n * @method getEngineTrackingCode - returns Kameleoon tracking code for the current visitor. Tracking code is built of the experiments that were triggered and feature flag variations that were assigned during the last 5 seconds\n * See [Kameleoon Automation API](https://developers.kameleoon.com/apis/activation-api-js/api-reference#trigger-1) for the details\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @returns {string} Kameleoon tracking code\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n */\n getEngineTrackingCode: (visitorCode: string) => string;\n /**\n * @method onConfigurationUpdate - fires a callback on client configuration update. Note: this method only works for server sent events of real time update.\n * @param {() => void} callback - callback function with no parameters that will be called upon configuration update\n * @returns {void}\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n */\n onConfigurationUpdate: (callback: () => void) => void;\n /**\n * @method onEvent - fires a callback on a specified Kameleoon `EventType`. Each event can only have one according callback.\n *\n * Note: SDK methods are marked with the `EventType` they trigger if any.\n *\n * @param {EventCallbackType<EventType>} callback - callback function with parameters that will be called upon event\n *\n * Parameter type depends on the `EventType` passed:\n * - `EventType.Evaluation` - `EvaluationEventDataType`\n * - `EventType.ConfigurationUpdate` - `ConfigurationUpdateEventDataType`\n * @returns {void}\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n */\n onEvent: (event: EventType, callback: EventCallbackType<EventType>) => void;\n}\n"],"mappings":""}
@@ -25,6 +25,7 @@ export declare const ERROR_MESSAGES: {
25
25
  ClientConfiguration: () => string;
26
26
  TargetingCondition: (targetingType: TargetingType) => string;
27
27
  AmongValuesCheck: (err: unknown, value: string) => string;
28
+ RangeCheck: (value?: number[] | null) => string;
28
29
  RemoteData: () => string;
29
30
  MaximumRetriesReached: () => string;
30
31
  };
@@ -1,2 +1,2 @@
1
- "use strict";var _types=require("./types");Object.defineProperty(exports,"__esModule",{value:!0}),exports.ERROR_MESSAGES=void 0;const ERROR_MESSAGES=exports.ERROR_MESSAGES={[_types.KameleoonException.CookieParse]:a=>"Couldn't parse cookie string: ".concat(a),[_types.KameleoonException.JSONParse]:a=>"Couldn't parse JSON variable: ".concat(a),[_types.KameleoonException.NumberParse]:a=>"It's not possible to parse value ".concat(a," to Number"),[_types.KameleoonException.VersionParse]:a=>"It's not possible to parse a version value ".concat(a," to Number, version should be in format x.x"),[_types.KameleoonException.SemanticVersionParse]:a=>"It's not possible to parse a version value ".concat(a," to Number, version should be in format x.x.x"),[_types.KameleoonException.Initialization]:()=>"It seems that the client wasn't properly initialized, make sure to run `initialize` method before invoking other methods",[_types.KameleoonException.Credentials]:()=>"KameleoonClient can not be created without credentials",[_types.KameleoonException.StorageInitialization]:()=>"There was an error while initializing React Native SDK storage, it seems that the storage library dependency wasn't installed",[_types.KameleoonException.EventSourceInitialization]:()=>"There was an error while initializing Real Time Update service, it seems that the event source library dependency wasn't installed",[_types.KameleoonException.FeatureFlagConfigurationNotFound]:a=>"No feature flag with key ".concat(a," was found."),[_types.KameleoonException.FeatureFlagEnvironmentDisabled]:(a,b)=>"Feature flag with key ".concat(a," is disabled in ").concat(b," environment."),[_types.KameleoonException.FeatureFlagVariableNotFound]:(a,b)=>"No feature flag variable with key ".concat(a," was found for ").concat(b," visitorCode."),[_types.KameleoonException.FeatureFlagVariationNotFound]:(a,b)=>"No feature flag variation with key ".concat(a," was found for ").concat(b," visitorCode."),[_types.KameleoonException.NotTargeted]:a=>"Visitor code ".concat(a," is not targeted"),[_types.KameleoonException.VisitAmount]:()=>"Visit amount must be a number between 1 and 25",[_types.KameleoonException.VisitorCodeMaxLength]:()=>"Visitor code can not be more than 255 characters long",[_types.KameleoonException.VisitorCodeEmpty]:()=>"Visitor code can not be empty",[_types.KameleoonException.StorageWrite]:a=>"Couldn't update storage for kameleoonClient: ".concat(a),[_types.KameleoonException.StorageRead]:a=>"No data found in storage under ".concat(a," key"),[_types.KameleoonException.StorageEmpty]:()=>"No data found in storage",[_types.KameleoonException.StorageParse]:(a,b)=>"Couldn't parse ".concat(b," storage data, the data may be corrupted. Error: ").concat(a),[_types.KameleoonException.ClientConfiguration]:()=>"Couldn't retrieve client configuration from Kameleoon Api",[_types.KameleoonException.TargetingCondition]:a=>"".concat(a," targeting condition is not yet supported."),[_types.KameleoonException.AmongValuesCheck]:(a,b)=>"Couldn't parse value \"".concat(b,"\": ").concat(a),[_types.KameleoonException.RemoteData]:()=>"Couldn't retrieve data from Kameleoon server",[_types.KameleoonException.MaximumRetriesReached]:()=>"Maximum retries reached, request failed"};
1
+ "use strict";var _types=require("./types");Object.defineProperty(exports,"__esModule",{value:!0}),exports.ERROR_MESSAGES=void 0;const ERROR_MESSAGES=exports.ERROR_MESSAGES={[_types.KameleoonException.CookieParse]:a=>"Couldn't parse cookie string: ".concat(a),[_types.KameleoonException.JSONParse]:a=>"Couldn't parse JSON variable: ".concat(a),[_types.KameleoonException.NumberParse]:a=>"It's not possible to parse value ".concat(a," to Number"),[_types.KameleoonException.VersionParse]:a=>"It's not possible to parse a version value ".concat(a," to Number, version should be in format x.x"),[_types.KameleoonException.SemanticVersionParse]:a=>"It's not possible to parse a version value ".concat(a," to Number, version should be in format x.x.x"),[_types.KameleoonException.Initialization]:()=>"It seems that the client wasn't properly initialized, make sure to run `initialize` method before invoking other methods",[_types.KameleoonException.Credentials]:()=>"KameleoonClient can not be created without credentials",[_types.KameleoonException.StorageInitialization]:()=>"There was an error while initializing React Native SDK storage, it seems that the storage library dependency wasn't installed",[_types.KameleoonException.EventSourceInitialization]:()=>"There was an error while initializing Real Time Update service, it seems that the event source library dependency wasn't installed",[_types.KameleoonException.FeatureFlagConfigurationNotFound]:a=>"No feature flag with key ".concat(a," was found."),[_types.KameleoonException.FeatureFlagEnvironmentDisabled]:(a,b)=>"Feature flag with key ".concat(a," is disabled in ").concat(b," environment."),[_types.KameleoonException.FeatureFlagVariableNotFound]:(a,b)=>"No feature flag variable with key ".concat(a," was found for ").concat(b," visitorCode."),[_types.KameleoonException.FeatureFlagVariationNotFound]:(a,b)=>"No feature flag variation with key ".concat(a," was found for ").concat(b," visitorCode."),[_types.KameleoonException.NotTargeted]:a=>"Visitor code ".concat(a," is not targeted"),[_types.KameleoonException.VisitAmount]:()=>"Visit amount must be a number between 1 and 25",[_types.KameleoonException.VisitorCodeMaxLength]:()=>"Visitor code can not be more than 255 characters long",[_types.KameleoonException.VisitorCodeEmpty]:()=>"Visitor code can not be empty",[_types.KameleoonException.StorageWrite]:a=>"Couldn't update storage for kameleoonClient: ".concat(a),[_types.KameleoonException.StorageRead]:a=>"No data found in storage under ".concat(a," key"),[_types.KameleoonException.StorageEmpty]:()=>"No data found in storage",[_types.KameleoonException.StorageParse]:(a,b)=>"Couldn't parse ".concat(b," storage data, the data may be corrupted. Error: ").concat(a),[_types.KameleoonException.ClientConfiguration]:()=>"Couldn't retrieve client configuration from Kameleoon Api",[_types.KameleoonException.TargetingCondition]:a=>"".concat(a," targeting condition is not yet supported."),[_types.KameleoonException.AmongValuesCheck]:(a,b)=>"Couldn't parse value \"".concat(b,"\": ").concat(a),[_types.KameleoonException.RangeCheck]:a=>"Couldn't parse value \"".concat(a,"\" as a range, value should be in format [x: number, y: number]"),[_types.KameleoonException.RemoteData]:()=>"Couldn't retrieve data from Kameleoon server",[_types.KameleoonException.MaximumRetriesReached]:()=>"Maximum retries reached, request failed"};
2
2
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","names":["_types","require","Object","defineProperty","exports","value","ERROR_MESSAGES","KameleoonException","CookieParse","reason","concat","JSONParse","err","NumberParse","VersionParse","SemanticVersionParse","Initialization","Credentials","StorageInitialization","EventSourceInitialization","FeatureFlagConfigurationNotFound","featureKey","FeatureFlagEnvironmentDisabled","environment","FeatureFlagVariableNotFound","variableKey","visitorCode","FeatureFlagVariationNotFound","variationKey","NotTargeted","VisitAmount","VisitorCodeMaxLength","VisitorCodeEmpty","StorageWrite","StorageRead","key","StorageEmpty","StorageParse","ClientConfiguration","TargetingCondition","targetingType","AmongValuesCheck","RemoteData","MaximumRetriesReached"],"sources":["../../src/kameleoonError/constants.ts"],"sourcesContent":["import { KameleoonStorageKey } from 'src/storage';\nimport { TargetingType } from 'src/targeting';\nimport { KameleoonException } from './types';\n\nexport const ERROR_MESSAGES = {\n [KameleoonException.CookieParse]: (reason: string) =>\n `Couldn't parse cookie string: ${reason}`,\n [KameleoonException.JSONParse]: (err: unknown) =>\n `Couldn't parse JSON variable: ${err}`,\n [KameleoonException.NumberParse]: (value: string) =>\n `It's not possible to parse value ${value} to Number`,\n [KameleoonException.VersionParse]: (value: string) =>\n `It's not possible to parse a version value ${value} to Number, version should be in format x.x`,\n [KameleoonException.SemanticVersionParse]: (value: string) =>\n `It's not possible to parse a version value ${value} to Number, version should be in format x.x.x`,\n [KameleoonException.Initialization]: () =>\n \"It seems that the client wasn't properly initialized, make sure to run `initialize` method before invoking other methods\",\n [KameleoonException.Credentials]: () =>\n 'KameleoonClient can not be created without credentials',\n [KameleoonException.StorageInitialization]: () =>\n \"There was an error while initializing React Native SDK storage, it seems that the storage library dependency wasn't installed\",\n [KameleoonException.EventSourceInitialization]: () =>\n \"There was an error while initializing Real Time Update service, it seems that the event source library dependency wasn't installed\",\n [KameleoonException.FeatureFlagConfigurationNotFound]: (featureKey: string) =>\n `No feature flag with key ${featureKey} was found.`,\n [KameleoonException.FeatureFlagEnvironmentDisabled]: (\n featureKey: string,\n environment: string,\n ) =>\n `Feature flag with key ${featureKey} is disabled in ${environment} environment.`,\n [KameleoonException.FeatureFlagVariableNotFound]: (\n variableKey: string,\n visitorCode: string,\n ) =>\n `No feature flag variable with key ${variableKey} was found for ${visitorCode} visitorCode.`,\n [KameleoonException.FeatureFlagVariationNotFound]: (\n variationKey: string,\n visitorCode: string,\n ) =>\n `No feature flag variation with key ${variationKey} was found for ${visitorCode} visitorCode.`,\n [KameleoonException.NotTargeted]: (visitorCode: string) =>\n `Visitor code ${visitorCode} is not targeted`,\n [KameleoonException.VisitAmount]: () =>\n 'Visit amount must be a number between 1 and 25',\n [KameleoonException.VisitorCodeMaxLength]: () =>\n 'Visitor code can not be more than 255 characters long',\n [KameleoonException.VisitorCodeEmpty]: () => 'Visitor code can not be empty',\n [KameleoonException.StorageWrite]: (err: unknown) =>\n `Couldn't update storage for kameleoonClient: ${err}`,\n [KameleoonException.StorageRead]: (key: KameleoonStorageKey) =>\n `No data found in storage under ${key} key`,\n [KameleoonException.StorageEmpty]: () => 'No data found in storage',\n [KameleoonException.StorageParse]: (err: unknown, key: KameleoonStorageKey) =>\n `Couldn't parse ${key} storage data, the data may be corrupted. Error: ${err}`,\n [KameleoonException.ClientConfiguration]: () =>\n \"Couldn't retrieve client configuration from Kameleoon Api\",\n [KameleoonException.TargetingCondition]: (targetingType: TargetingType) =>\n `${targetingType} targeting condition is not yet supported.`,\n [KameleoonException.AmongValuesCheck]: (err: unknown, value: string) =>\n `Couldn't parse value \"${value}\": ${err}`,\n [KameleoonException.RemoteData]: () =>\n `Couldn't retrieve data from Kameleoon server`,\n [KameleoonException.MaximumRetriesReached]: () =>\n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CACjDC,CAAoB,CACpBF,CAAmB,yCAAAhB,MAAA,CAEmBkB,CAAY,oBAAAlB,MAAA,CAAkBgB,CAAW,iBAAe,CAChG,CAACnB,yBAAkB,CAACsB,WAAW,EAAIH,CAAmB,kBAAAhB,MAAA,CACpCgB,CAAW,oBAAkB,CAC/C,CAACnB,yBAAkB,CAACuB,WAAW,EAAG,IAChC,gDAAgD,CAClD,CAACvB,yBAAkB,CAACwB,oBAAoB,EAAG,IACzC,uDAAuD,CACzD,CAACxB,yBAAkB,CAACyB,gBAAgB,EAAG,IAAM,+BAA+B,CAC5E,CAACzB,yBAAkB,CAAC0B,YAAY,EAAIrB,CAAY,kDAAAF,MAAA,CACEE,CAAG,CAAE,CACvD,CAACL,yBAAkB,CAAC2B,WAAW,EAAIC,CAAwB,oCAAAzB,MAAA,CACvByB,CAAG,QAAM,CAC7C,CAAC5B,yBAAkB,CAAC6B,YAAY,EAAG,IAAM,0BAA0B,CACnE,CAAC7B,yBAAkB,CAAC8B,YAAY,EAAG,CAACzB,CAAY,CAAEuB,CAAwB,qBAAAzB,MAAA,CACtDyB,CAAG,sDAAAzB,MAAA,CAAoDE,CAAG,CAAE,CAChF,CAACL,yBAAkB,CAAC+B,mBAAmB,EAAG,IACxC,2DAA2D,CAC7D,CAAC/B,yBAAkB,CAACgC,kBAAkB,EAAIC,CAA4B,KAAA9B,MAAA,CACjE8B,CAAa,8CAA4C,CAC9D,CAACjC,yBAAkB,CAACkC,gBAAgB,EAAG,CAAC7B,CAAY,CAAEP,CAAa,6BAAAK,MAAA,CACxCL,CAAK,SAAAK,MAAA,CAAME,CAAG,CAAE,CAC3C,CAACL,yBAAkB,CAACmC,UAAU,EAAG,kDACe,CAChD,CAACnC,yBAAkB,CAACoC,qBAAqB,EAAG,6CAE9C,CAAC"}
1
+ {"version":3,"file":"constants.js","names":["_types","require","Object","defineProperty","exports","value","ERROR_MESSAGES","KameleoonException","CookieParse","reason","concat","JSONParse","err","NumberParse","VersionParse","SemanticVersionParse","Initialization","Credentials","StorageInitialization","EventSourceInitialization","FeatureFlagConfigurationNotFound","featureKey","FeatureFlagEnvironmentDisabled","environment","FeatureFlagVariableNotFound","variableKey","visitorCode","FeatureFlagVariationNotFound","variationKey","NotTargeted","VisitAmount","VisitorCodeMaxLength","VisitorCodeEmpty","StorageWrite","StorageRead","key","StorageEmpty","StorageParse","ClientConfiguration","TargetingCondition","targetingType","AmongValuesCheck","RangeCheck","RemoteData","MaximumRetriesReached"],"sources":["../../src/kameleoonError/constants.ts"],"sourcesContent":["import { KameleoonStorageKey } from 'src/storage';\nimport { TargetingType } from 'src/targeting';\nimport { KameleoonException } from './types';\n\nexport const ERROR_MESSAGES = {\n [KameleoonException.CookieParse]: (reason: string) =>\n `Couldn't parse cookie string: ${reason}`,\n [KameleoonException.JSONParse]: (err: unknown) =>\n `Couldn't parse JSON variable: ${err}`,\n [KameleoonException.NumberParse]: (value: string) =>\n `It's not possible to parse value ${value} to Number`,\n [KameleoonException.VersionParse]: (value: string) =>\n `It's not possible to parse a version value ${value} to Number, version should be in format x.x`,\n [KameleoonException.SemanticVersionParse]: (value: string) =>\n `It's not possible to parse a version value ${value} to Number, version should be in format x.x.x`,\n [KameleoonException.Initialization]: () =>\n \"It seems that the client wasn't properly initialized, make sure to run `initialize` method before invoking other methods\",\n [KameleoonException.Credentials]: () =>\n 'KameleoonClient can not be created without credentials',\n [KameleoonException.StorageInitialization]: () =>\n \"There was an error while initializing React Native SDK storage, it seems that the storage library dependency wasn't installed\",\n [KameleoonException.EventSourceInitialization]: () =>\n \"There was an error while initializing Real Time Update service, it seems that the event source library dependency wasn't installed\",\n [KameleoonException.FeatureFlagConfigurationNotFound]: (featureKey: string) =>\n `No feature flag with key ${featureKey} was found.`,\n [KameleoonException.FeatureFlagEnvironmentDisabled]: (\n featureKey: string,\n environment: string,\n ) =>\n `Feature flag with key ${featureKey} is disabled in ${environment} environment.`,\n [KameleoonException.FeatureFlagVariableNotFound]: (\n variableKey: string,\n visitorCode: string,\n ) =>\n `No feature flag variable with key ${variableKey} was found for ${visitorCode} visitorCode.`,\n [KameleoonException.FeatureFlagVariationNotFound]: (\n variationKey: string,\n visitorCode: string,\n ) =>\n `No feature flag variation with key ${variationKey} was found for ${visitorCode} visitorCode.`,\n [KameleoonException.NotTargeted]: (visitorCode: string) =>\n `Visitor code ${visitorCode} is not targeted`,\n [KameleoonException.VisitAmount]: () =>\n 'Visit amount must be a number between 1 and 25',\n [KameleoonException.VisitorCodeMaxLength]: () =>\n 'Visitor code can not be more than 255 characters long',\n [KameleoonException.VisitorCodeEmpty]: () => 'Visitor code can not be empty',\n [KameleoonException.StorageWrite]: (err: unknown) =>\n `Couldn't update storage for kameleoonClient: ${err}`,\n [KameleoonException.StorageRead]: (key: KameleoonStorageKey) =>\n `No data found in storage under ${key} key`,\n [KameleoonException.StorageEmpty]: () => 'No data found in storage',\n [KameleoonException.StorageParse]: (err: unknown, key: KameleoonStorageKey) =>\n `Couldn't parse ${key} storage data, the data may be corrupted. Error: ${err}`,\n [KameleoonException.ClientConfiguration]: () =>\n \"Couldn't retrieve client configuration from Kameleoon Api\",\n [KameleoonException.TargetingCondition]: (targetingType: TargetingType) =>\n `${targetingType} targeting condition is not yet supported.`,\n [KameleoonException.AmongValuesCheck]: (err: unknown, value: string) =>\n `Couldn't parse value \"${value}\": ${err}`,\n [KameleoonException.RangeCheck]: (value?: number[] | null) =>\n `Couldn't parse value \"${value}\" as a range, value should be in format [x: number, y: number]`,\n [KameleoonException.RemoteData]: () =>\n `Couldn't retrieve data from Kameleoon server`,\n [KameleoonException.MaximumRetriesReached]: () =>\n `Maximum retries reached, request failed`,\n};\n"],"mappings":"aAEA,IAAAA,MAAA,CAAAC,OAAA,YAA6CC,MAAA,CAAAC,cAAA,CAAAC,OAAA,eAAAC,KAAA,MAAAD,OAAA,CAAAE,cAAA,QAEtC,KAAM,CAAAA,cAAc,CAAAF,OAAA,CAAAE,cAAA,CAAG,CAC5B,CAACC,yBAAkB,CAACC,WAAW,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gD,CAClD,CAACvB,yBAAkB,CAACwB,oBAAoB,EAAG,IACzC,uDAAuD,CACzD,CAACxB,yBAAkB,CAACyB,gBAAgB,EAAG,IAAM,+BAA+B,CAC5E,CAACzB,yBAAkB,CAAC0B,YAAY,EAAIrB,CAAY,kDAAAF,MAAA,CACEE,CAAG,CAAE,CACvD,CAACL,yBAAkB,CAAC2B,WAAW,EAAIC,CAAwB,oCAAAzB,MAAA,CACvByB,CAAG,QAAM,CAC7C,CAAC5B,yBAAkB,CAAC6B,YAAY,EAAG,IAAM,0BAA0B,CACnE,CAAC7B,yBAAkB,CAAC8B,YAAY,EAAG,CAACzB,CAAY,CAAEuB,CAAwB,qBAAAzB,MAAA,CACtDyB,CAAG,sDAAAzB,MAAA,CAAoDE,CAAG,CAAE,CAChF,CAACL,yBAAkB,CAAC+B,mBAAmB,EAAG,IACxC,2DAA2D,CAC7D,CAAC/B,yBAAkB,CAACgC,kBAAkB,EAAIC,CAA4B,KAAA9B,MAAA,CACjE8B,CAAa,8CAA4C,CAC9D,CAACjC,yBAAkB,CAACkC,gBAAgB,EAAG,CAAC7B,CAAY,CAAEP,CAAa,6BAAAK,MAAA,CACxCL,CAAK,SAAAK,MAAA,CAAME,CAAG,CAAE,CAC3C,CAACL,yBAAkB,CAACmC,UAAU,EAAIrC,CAAuB,4BAAAK,MAAA,CAC9BL,CAAK,mEAAgE,CAChG,CAACE,yBAAkB,CAACoC,UAAU,EAAG,kDACe,CAChD,CAACpC,yBAAkB,CAACqC,qBAAqB,EAAG,6CAE9C,CAAC"}
@@ -22,6 +22,7 @@ export declare class KameleoonError extends Error {
22
22
  constructor(type: KameleoonException.StorageParse, err: unknown, key: KameleoonStorageKey);
23
23
  constructor(type: KameleoonException.TargetingCondition, targetingType: TargetingType);
24
24
  constructor(type: KameleoonException.AmongValuesCheck, err: unknown, value: string);
25
+ constructor(type: KameleoonException.RangeCheck, value?: number[] | null);
25
26
  constructor(type: KameleoonException.NumberParse | KameleoonException.VersionParse | KameleoonException.SemanticVersionParse, value: string);
26
27
  get type(): KameleoonException;
27
28
  }
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.KameleoonError=void 0;var _constants=require("./constants"),_helpers=require("./helpers"),_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 KameleoonError extends Error{constructor(a,b,c){super("Error: ".concat(a)),_defineProperty(this,"errorType",void 0),this.name="KameleoonError",this.errorType=a;a===_types.KameleoonException.Initialization||a===_types.KameleoonException.Credentials||a===_types.KameleoonException.ClientConfiguration||a===_types.KameleoonException.VisitorCodeMaxLength||a===_types.KameleoonException.VisitorCodeEmpty||a===_types.KameleoonException.StorageInitialization||a===_types.KameleoonException.VisitAmount||a===_types.KameleoonException.EventSourceInitialization||a===_types.KameleoonException.RemoteData||a===_types.KameleoonException.MaximumRetriesReached||a===_types.KameleoonException.StorageEmpty?this.message=_constants.ERROR_MESSAGES[a]():a===_types.KameleoonException.CookieParse||a===_types.KameleoonException.NotTargeted||a===_types.KameleoonException.FeatureFlagConfigurationNotFound||a===_types.KameleoonException.NumberParse||a===_types.KameleoonException.VersionParse||a===_types.KameleoonException.SemanticVersionParse?this.message=_constants.ERROR_MESSAGES[a](b):a===_types.KameleoonException.FeatureFlagVariationNotFound||a===_types.KameleoonException.FeatureFlagEnvironmentDisabled||a===_types.KameleoonException.FeatureFlagVariableNotFound?this.message=_constants.ERROR_MESSAGES[a](b,c):a===_types.KameleoonException.StorageWrite||a===_types.KameleoonException.JSONParse?this.message=_constants.ERROR_MESSAGES[a](b):a===_types.KameleoonException.StorageRead?this.message=_constants.ERROR_MESSAGES[a](b):a===_types.KameleoonException.StorageParse?this.message=_constants.ERROR_MESSAGES[a](b,c):a===_types.KameleoonException.TargetingCondition?this.message=_constants.ERROR_MESSAGES[a](b):a===_types.KameleoonException.AmongValuesCheck?this.message=_constants.ERROR_MESSAGES[a](b,c):(0,_helpers.exhaustCheck)(a)}get type(){return this.errorType}}exports.KameleoonError=KameleoonError;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.KameleoonError=void 0;var _constants=require("./constants"),_helpers=require("./helpers"),_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 KameleoonError extends Error{constructor(a,b,c){super("Error: ".concat(a)),_defineProperty(this,"errorType",void 0),this.name="KameleoonError",this.errorType=a;a===_types.KameleoonException.Initialization||a===_types.KameleoonException.Credentials||a===_types.KameleoonException.ClientConfiguration||a===_types.KameleoonException.VisitorCodeMaxLength||a===_types.KameleoonException.VisitorCodeEmpty||a===_types.KameleoonException.StorageInitialization||a===_types.KameleoonException.VisitAmount||a===_types.KameleoonException.EventSourceInitialization||a===_types.KameleoonException.RemoteData||a===_types.KameleoonException.MaximumRetriesReached||a===_types.KameleoonException.StorageEmpty?this.message=_constants.ERROR_MESSAGES[a]():a===_types.KameleoonException.CookieParse||a===_types.KameleoonException.NotTargeted||a===_types.KameleoonException.FeatureFlagConfigurationNotFound||a===_types.KameleoonException.NumberParse||a===_types.KameleoonException.VersionParse||a===_types.KameleoonException.SemanticVersionParse?this.message=_constants.ERROR_MESSAGES[a](b):a===_types.KameleoonException.FeatureFlagVariationNotFound||a===_types.KameleoonException.FeatureFlagEnvironmentDisabled||a===_types.KameleoonException.FeatureFlagVariableNotFound?this.message=_constants.ERROR_MESSAGES[a](b,c):a===_types.KameleoonException.StorageWrite||a===_types.KameleoonException.JSONParse?this.message=_constants.ERROR_MESSAGES[a](b):a===_types.KameleoonException.StorageRead?this.message=_constants.ERROR_MESSAGES[a](b):a===_types.KameleoonException.StorageParse?this.message=_constants.ERROR_MESSAGES[a](b,c):a===_types.KameleoonException.TargetingCondition?this.message=_constants.ERROR_MESSAGES[a](b):a===_types.KameleoonException.AmongValuesCheck?this.message=_constants.ERROR_MESSAGES[a](b,c):a===_types.KameleoonException.RangeCheck?this.message=_constants.ERROR_MESSAGES[a](b):(0,_helpers.exhaustCheck)(a)}get type(){return this.errorType}}exports.KameleoonError=KameleoonError;
2
2
  //# sourceMappingURL=kameleoonError.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"kameleoonError.js","names":["KameleoonError","Error","constructor","type","secondParam","thirdParam","concat","_defineProperty","name","errorType","KameleoonException","Initialization","Credentials","ClientConfiguration","VisitorCodeMaxLength","VisitorCodeEmpty","StorageInitialization","VisitAmount","EventSourceInitialization","RemoteData","MaximumRetriesReached","StorageEmpty","message","ERROR_MESSAGES","CookieParse","NotTargeted","FeatureFlagConfigurationNotFound","NumberParse","VersionParse","SemanticVersionParse","FeatureFlagVariationNotFound","FeatureFlagEnvironmentDisabled","FeatureFlagVariableNotFound","StorageWrite","JSONParse","StorageRead","StorageParse","TargetingCondition","AmongValuesCheck","exhaustCheck","exports"],"sources":["../../src/kameleoonError/kameleoonError.ts"],"sourcesContent":["import { KameleoonStorageKey } from 'src/storage';\nimport { TargetingType } from 'src/targeting';\nimport { ERROR_MESSAGES } from './constants';\nimport { exhaustCheck } from './helpers';\nimport { KameleoonException } from './types';\n\n/**\n * @class\n * KameleoonError - extends standard `Error` by adding custom `type` property with the type of `KameleoonException`\n * */\nexport class KameleoonError extends Error {\n private errorType: KameleoonException;\n\n /**\n * @param {KameleoonException} type - type of KameleoonError represented by `KameleoonException` enum\n * */\n constructor(\n type:\n | KameleoonException.Initialization\n | KameleoonException.Credentials\n | KameleoonException.ClientConfiguration\n | KameleoonException.VisitorCodeMaxLength\n | KameleoonException.VisitorCodeEmpty\n | KameleoonException.VisitAmount\n | KameleoonException.StorageInitialization\n | KameleoonException.EventSourceInitialization\n | KameleoonException.RemoteData\n | KameleoonException.MaximumRetriesReached\n | KameleoonException.StorageEmpty,\n );\n constructor(\n type:\n | KameleoonException.FeatureFlagConfigurationNotFound\n | KameleoonException.FeatureFlagEnvironmentDisabled,\n featureKey: string,\n );\n constructor(\n type:\n | KameleoonException.FeatureFlagConfigurationNotFound\n | KameleoonException.FeatureFlagEnvironmentDisabled,\n featureKey: string,\n environment: string,\n );\n constructor(\n type: KameleoonException.FeatureFlagVariableNotFound,\n variableKey: string,\n visitorCode: string,\n );\n constructor(\n type: KameleoonException.FeatureFlagVariationNotFound,\n variationKey: string,\n visitorCode: string,\n );\n constructor(type: KameleoonException.NotTargeted, visitorCode: string);\n constructor(type: KameleoonException.CookieParse, message: string);\n constructor(\n type: KameleoonException.StorageWrite | KameleoonException.JSONParse,\n err: unknown,\n );\n constructor(type: KameleoonException.StorageRead, storageKey: string);\n constructor(\n type: KameleoonException.StorageParse,\n err: unknown,\n key: KameleoonStorageKey,\n );\n constructor(\n type: KameleoonException.TargetingCondition,\n targetingType: TargetingType,\n );\n constructor(\n type: KameleoonException.AmongValuesCheck,\n err: unknown,\n value: string,\n );\n constructor(\n type:\n | KameleoonException.NumberParse\n | KameleoonException.VersionParse\n | KameleoonException.SemanticVersionParse,\n value: string,\n );\n constructor(\n type: KameleoonException,\n secondParam?:\n | number\n | string\n | unknown\n | KameleoonStorageKey\n | TargetingType,\n thirdParam?: string | KameleoonStorageKey,\n ) {\n super(`Error: ${type}`);\n\n this.name = 'KameleoonError';\n this.errorType = type;\n\n switch (type) {\n case KameleoonException.Initialization:\n case KameleoonException.Credentials:\n case KameleoonException.ClientConfiguration:\n case KameleoonException.VisitorCodeMaxLength:\n case KameleoonException.VisitorCodeEmpty:\n case KameleoonException.StorageInitialization:\n case KameleoonException.VisitAmount:\n case KameleoonException.EventSourceInitialization:\n case KameleoonException.RemoteData:\n case KameleoonException.MaximumRetriesReached:\n case KameleoonException.StorageEmpty:\n this.message = ERROR_MESSAGES[type]();\n break;\n case KameleoonException.CookieParse:\n case KameleoonException.NotTargeted:\n case KameleoonException.FeatureFlagConfigurationNotFound:\n case KameleoonException.NumberParse:\n case KameleoonException.VersionParse:\n case KameleoonException.SemanticVersionParse:\n this.message = ERROR_MESSAGES[type](secondParam as string);\n break;\n case KameleoonException.FeatureFlagVariationNotFound:\n case KameleoonException.FeatureFlagEnvironmentDisabled:\n case KameleoonException.FeatureFlagVariableNotFound:\n this.message = ERROR_MESSAGES[type](\n secondParam as string,\n thirdParam as string,\n );\n break;\n case KameleoonException.StorageWrite:\n case KameleoonException.JSONParse:\n this.message = ERROR_MESSAGES[type](secondParam);\n break;\n case KameleoonException.StorageRead:\n this.message = ERROR_MESSAGES[type](secondParam as KameleoonStorageKey);\n break;\n case KameleoonException.StorageParse:\n this.message = ERROR_MESSAGES[type](\n secondParam,\n thirdParam as KameleoonStorageKey,\n );\n break;\n case KameleoonException.TargetingCondition:\n this.message = ERROR_MESSAGES[type](secondParam as TargetingType);\n break;\n case KameleoonException.AmongValuesCheck:\n this.message = ERROR_MESSAGES[type](secondParam, thirdParam as string);\n break;\n default:\n exhaustCheck(type);\n }\n }\n\n get type(): KameleoonException {\n return this.errorType;\n }\n}\n"],"mappings":"msBAUO,KAAM,CAAAA,cAAc,QAAS,CAAAC,KAAM,CAuExCC,WAAWA,CACTC,CAAwB,CACxBC,CAKiB,CACjBC,CAAyC,CACzC,CACA,KAAK,WAAAC,MAAA,CAAWH,CAAI,CAAE,CAAC,CAAAI,eAAA,0BAEvB,IAAI,CAACC,IAAI,CAAG,gB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CAAI,GA+BLO,yBAAkB,CAACwB,SAAS,CAC/B,IAAI,CAACZ,OAAO,CAAGC,yBAAc,CAACpB,CAAI,CAAC,CAACC,CAAW,CAAC,CAhC5CD,CAAI,GAkCLO,yBAAkB,CAACyB,WAAW,CACjC,IAAI,CAACb,OAAO,CAAGC,yBAAc,CAACpB,CAAI,CAAC,CAACC,CAAkC,CAAC,CAnCnED,CAAI,GAqCLO,yBAAkB,CAAC0B,YAAY,CAClC,IAAI,CAACd,OAAO,CAAGC,yBAAc,CAACpB,CAAI,CAAC,CACjCC,CAAW,CACXC,CACF,CAAC,CAzCGF,CAAI,GA2CLO,yBAAkB,CAAC2B,kBAAkB,CACxC,IAAI,CAACf,OAAO,CAAGC,yBAAc,CAACpB,CAAI,CAAC,CAACC,CAA4B,CAAC,CA5C7DD,CAAI,GA8CLO,yBAAkB,CAAC4B,gBAAgB,CACtC,IAAI,CAAChB,OAAO,CAAGC,yBAAc,CAACpB,CAAI,CAAC,CAACC,CAAW,CAAEC,CAAoB,CAAC,CAGtE,GAAAkC,qBAAY,EAACpC,CAAI,CAEvB,CAEA,GAAI,CAAAA,IAAIA,CAAA,CAAuB,CAC7B,MAAO,KAAI,CAACM,SACd,CACF,CAAC+B,OAAA,CAAAxC,cAAA,CAAAA,cAAA"}
1
+ {"version":3,"file":"kameleoonError.js","names":["KameleoonError","Error","constructor","type","secondParam","thirdParam","concat","_defineProperty","name","errorType","KameleoonException","Initialization","Credentials","ClientConfiguration","VisitorCodeMaxLength","VisitorCodeEmpty","StorageInitialization","VisitAmount","EventSourceInitialization","RemoteData","MaximumRetriesReached","StorageEmpty","message","ERROR_MESSAGES","CookieParse","NotTargeted","FeatureFlagConfigurationNotFound","NumberParse","VersionParse","SemanticVersionParse","FeatureFlagVariationNotFound","FeatureFlagEnvironmentDisabled","FeatureFlagVariableNotFound","StorageWrite","JSONParse","StorageRead","StorageParse","TargetingCondition","AmongValuesCheck","RangeCheck","exhaustCheck","exports"],"sources":["../../src/kameleoonError/kameleoonError.ts"],"sourcesContent":["import { KameleoonStorageKey } from 'src/storage';\nimport { TargetingType } from 'src/targeting';\nimport { ERROR_MESSAGES } from './constants';\nimport { exhaustCheck } from './helpers';\nimport { KameleoonException } from './types';\n\n/**\n * @class\n * KameleoonError - extends standard `Error` by adding custom `type` property with the type of `KameleoonException`\n * */\nexport class KameleoonError extends Error {\n private errorType: KameleoonException;\n\n /**\n * @param {KameleoonException} type - type of KameleoonError represented by `KameleoonException` enum\n * */\n constructor(\n type:\n | KameleoonException.Initialization\n | KameleoonException.Credentials\n | KameleoonException.ClientConfiguration\n | KameleoonException.VisitorCodeMaxLength\n | KameleoonException.VisitorCodeEmpty\n | KameleoonException.VisitAmount\n | KameleoonException.StorageInitialization\n | KameleoonException.EventSourceInitialization\n | KameleoonException.RemoteData\n | KameleoonException.MaximumRetriesReached\n | KameleoonException.StorageEmpty,\n );\n constructor(\n type:\n | KameleoonException.FeatureFlagConfigurationNotFound\n | KameleoonException.FeatureFlagEnvironmentDisabled,\n featureKey: string,\n );\n constructor(\n type:\n | KameleoonException.FeatureFlagConfigurationNotFound\n | KameleoonException.FeatureFlagEnvironmentDisabled,\n featureKey: string,\n environment: string,\n );\n constructor(\n type: KameleoonException.FeatureFlagVariableNotFound,\n variableKey: string,\n visitorCode: string,\n );\n constructor(\n type: KameleoonException.FeatureFlagVariationNotFound,\n variationKey: string,\n visitorCode: string,\n );\n constructor(type: KameleoonException.NotTargeted, visitorCode: string);\n constructor(type: KameleoonException.CookieParse, message: string);\n constructor(\n type: KameleoonException.StorageWrite | KameleoonException.JSONParse,\n err: unknown,\n );\n constructor(type: KameleoonException.StorageRead, storageKey: string);\n constructor(\n type: KameleoonException.StorageParse,\n err: unknown,\n key: KameleoonStorageKey,\n );\n constructor(\n type: KameleoonException.TargetingCondition,\n targetingType: TargetingType,\n );\n constructor(\n type: KameleoonException.AmongValuesCheck,\n err: unknown,\n value: string,\n );\n constructor(type: KameleoonException.RangeCheck, value?: number[] | null);\n constructor(\n type:\n | KameleoonException.NumberParse\n | KameleoonException.VersionParse\n | KameleoonException.SemanticVersionParse,\n value: string,\n );\n constructor(\n type: KameleoonException,\n secondParam?:\n | number\n | string\n | unknown\n | KameleoonStorageKey\n | TargetingType,\n thirdParam?: string | KameleoonStorageKey,\n ) {\n super(`Error: ${type}`);\n\n this.name = 'KameleoonError';\n this.errorType = type;\n\n switch (type) {\n case KameleoonException.Initialization:\n case KameleoonException.Credentials:\n case KameleoonException.ClientConfiguration:\n case KameleoonException.VisitorCodeMaxLength:\n case KameleoonException.VisitorCodeEmpty:\n case KameleoonException.StorageInitialization:\n case KameleoonException.VisitAmount:\n case KameleoonException.EventSourceInitialization:\n case KameleoonException.RemoteData:\n case KameleoonException.MaximumRetriesReached:\n case KameleoonException.StorageEmpty:\n this.message = ERROR_MESSAGES[type]();\n break;\n case KameleoonException.CookieParse:\n case KameleoonException.NotTargeted:\n case KameleoonException.FeatureFlagConfigurationNotFound:\n case KameleoonException.NumberParse:\n case KameleoonException.VersionParse:\n case KameleoonException.SemanticVersionParse:\n this.message = ERROR_MESSAGES[type](secondParam as string);\n break;\n case KameleoonException.FeatureFlagVariationNotFound:\n case KameleoonException.FeatureFlagEnvironmentDisabled:\n case KameleoonException.FeatureFlagVariableNotFound:\n this.message = ERROR_MESSAGES[type](\n secondParam as string,\n thirdParam as string,\n );\n break;\n case KameleoonException.StorageWrite:\n case KameleoonException.JSONParse:\n this.message = ERROR_MESSAGES[type](secondParam);\n break;\n case KameleoonException.StorageRead:\n this.message = ERROR_MESSAGES[type](secondParam as KameleoonStorageKey);\n break;\n case KameleoonException.StorageParse:\n this.message = ERROR_MESSAGES[type](\n secondParam,\n thirdParam as KameleoonStorageKey,\n );\n break;\n case KameleoonException.TargetingCondition:\n this.message = ERROR_MESSAGES[type](secondParam as TargetingType);\n break;\n case KameleoonException.AmongValuesCheck:\n this.message = ERROR_MESSAGES[type](secondParam, thirdParam as string);\n break;\n case KameleoonException.RangeCheck:\n this.message = ERROR_MESSAGES[type](\n secondParam as number[] | null | undefined,\n );\n break;\n default:\n exhaustCheck(type);\n }\n }\n\n get type(): KameleoonException {\n return this.errorType;\n }\n}\n"],"mappings":"msBAUO,KAAM,CAAAA,cAAc,QAAS,CAAAC,KAAM,CAwExCC,WAAWA,CACTC,CAAwB,CACxBC,CAKiB,CACjBC,CAAyC,CACzC,CACA,KAAK,WAAAC,MAAA,CAAWH,CAAI,CAAE,CAAC,CAAAI,eAAA,0BAEvB,IAAI,CAACC,IAAI,CAAG,gBAAgB,CAC5B,IAAI,CAACC,SAAS,CAAGN,CAAI,CAEbA,CAAI,GACLO,yBAAkB,CAACC,cAAc,EADhCR,CAAI,GAELO,yBAAkB,CAACE,WAAW,EAF7BT,CAAI,GAGLO,yBAAkB,CAACG,mBAAmB,EAHrCV,CAAI,GAILO,yBAAkB,CAACI,oBAAoB,EAJtCX,CAAI,GAKLO,yBAAkB,CAACK,gBAAgB,EALlCZ,CAAI,GAMLO,yBAAkB,CAACM,qBAAqB,EANvCb,CAAI,GAOLO,yBAAkB,CAACO,WAAW,EAP7Bd,CAAI,GAQLO,yBAAkB,CAACQ,yBAAyB,EAR3Cf,CAAI,GASLO,yBAAkB,CAACS,UAAU,EAT5BhB,CAAI,GAULO,yBAAkB,CAACU,qBAAqB,EAVvCjB,CAAI,GAWLO,yBAAkB,CAACW,YAAY,CAClC,IAAI,CAACC,OAAO,CAAGC,yBAAc,CAACpB,CAAI,CAAC,CAAC,CAAC,CAZjCA,CAAI,GAcLO,yBAAkB,CAACc,WAAW,EAd7BrB,CAAI,GAeLO,yBAAkB,CAACe,WAAW,EAf7BtB,CAAI,GAgBLO,yBAAkB,CAACgB,gCAAgC,EAhBlDvB,CAAI,GAiBLO,yBAAkB,CAACiB,WAAW,EAjB7BxB,CAAI,GAkBLO,yBAAkB,CAACkB,YAAY,EAlB9BzB,CAAI,GAmBLO,yBAAkB,CAACmB,oBAAoB,CAC1C,IAAI,CAACP,OAAO,CAAGC,yBAAc,CAACp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A,cAAA"}
@@ -21,6 +21,7 @@ export declare enum KameleoonException {
21
21
  ClientConfiguration = "ClientConfiguration",
22
22
  TargetingCondition = "TargetingCondition",
23
23
  AmongValuesCheck = "AmongValuesCheck",
24
+ RangeCheck = "RangeCheck",
24
25
  Initialization = "Initialization",
25
26
  JSONParse = "JSONParse",
26
27
  NumberParse = "NumberParse",
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.KameleoonException=void 0;let KameleoonException=exports.KameleoonException=function(a){return a.Credentials="Credentials",a.EventSourceInitialization="EventSourceInitialization",a.FeatureFlagConfigurationNotFound="FeatureFlagConfigurationNotFound",a.FeatureFlagVariableNotFound="FeatureFlagVariableNotFound",a.FeatureFlagVariationNotFound="FeatureFlagVariationNotFound",a.FeatureFlagEnvironmentDisabled="FeatureFlagEnvironmentDisabled",a.NotTargeted="NotTargeted",a.VisitAmount="VisitAmount",a.VisitorCodeMaxLength="VisitorCodeMaxLength",a.VisitorCodeEmpty="VisitorCodeEmpty",a.StorageInitialization="StorageInitialization",a.StorageWrite="StorageWrite",a.StorageRead="StorageRead",a.StorageParse="StorageParse",a.StorageEmpty="StorageEmpty",a.ClientConfiguration="ClientConfiguration",a.TargetingCondition="TargetingCondition",a.AmongValuesCheck="AmongValuesCheck",a.Initialization="Initialization",a.JSONParse="JSONParse",a.NumberParse="NumberParse",a.VersionParse="VersionParse",a.CookieParse="CookieParse",a.SemanticVersionParse="SemanticVersionParse",a.RemoteData="RemoteData",a.MaximumRetriesReached="MaximumRetriesReached",a}({});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.KameleoonException=void 0;let KameleoonException=exports.KameleoonException=function(a){return a.Credentials="Credentials",a.EventSourceInitialization="EventSourceInitialization",a.FeatureFlagConfigurationNotFound="FeatureFlagConfigurationNotFound",a.FeatureFlagVariableNotFound="FeatureFlagVariableNotFound",a.FeatureFlagVariationNotFound="FeatureFlagVariationNotFound",a.FeatureFlagEnvironmentDisabled="FeatureFlagEnvironmentDisabled",a.NotTargeted="NotTargeted",a.VisitAmount="VisitAmount",a.VisitorCodeMaxLength="VisitorCodeMaxLength",a.VisitorCodeEmpty="VisitorCodeEmpty",a.StorageInitialization="StorageInitialization",a.StorageWrite="StorageWrite",a.StorageRead="StorageRead",a.StorageParse="StorageParse",a.StorageEmpty="StorageEmpty",a.ClientConfiguration="ClientConfiguration",a.TargetingCondition="TargetingCondition",a.AmongValuesCheck="AmongValuesCheck",a.RangeCheck="RangeCheck",a.Initialization="Initialization",a.JSONParse="JSONParse",a.NumberParse="NumberParse",a.VersionParse="VersionParse",a.CookieParse="CookieParse",a.SemanticVersionParse="SemanticVersionParse",a.RemoteData="RemoteData",a.MaximumRetriesReached="MaximumRetriesReached",a}({});
2
2
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":["KameleoonException","exports","Credentials","EventSourceInitialization","FeatureFlagConfigurationNotFound","FeatureFlagVariableNotFound","FeatureFlagVariationNotFound","FeatureFlagEnvironmentDisabled","NotTargeted","VisitAmount","VisitorCodeMaxLength","VisitorCodeEmpty","StorageInitialization","StorageWrite","StorageRead","StorageParse","StorageEmpty","ClientConfiguration","TargetingCondition","AmongValuesCheck","Initialization","JSONParse","NumberParse","VersionParse","CookieParse","SemanticVersionParse","RemoteData","MaximumRetriesReached"],"sources":["../../src/kameleoonError/types.ts"],"sourcesContent":["/**\n * @readonly\n * @enum {string} an Enum containing all possible variants of exception types `KameleoonError`\n * */\nexport enum KameleoonException {\n Credentials = 'Credentials',\n EventSourceInitialization = 'EventSourceInitialization',\n FeatureFlagConfigurationNotFound = 'FeatureFlagConfigurationNotFound',\n FeatureFlagVariableNotFound = 'FeatureFlagVariableNotFound',\n FeatureFlagVariationNotFound = 'FeatureFlagVariationNotFound',\n FeatureFlagEnvironmentDisabled = 'FeatureFlagEnvironmentDisabled',\n NotTargeted = 'NotTargeted',\n VisitAmount = 'VisitAmount',\n VisitorCodeMaxLength = 'VisitorCodeMaxLength',\n VisitorCodeEmpty = 'VisitorCodeEmpty',\n StorageInitialization = 'StorageInitialization',\n StorageWrite = 'StorageWrite',\n StorageRead = 'StorageRead',\n StorageParse = 'StorageParse',\n StorageEmpty = 'StorageEmpty',\n ClientConfiguration = 'ClientConfiguration',\n TargetingCondition = 'TargetingCondition',\n AmongValuesCheck = 'AmongValuesCheck',\n Initialization = 'Initialization',\n JSONParse = 'JSONParse',\n NumberParse = 'NumberParse',\n VersionParse = 'VersionParse',\n CookieParse = 'CookieParse',\n SemanticVersionParse = 'SemanticVersionParse',\n RemoteData = 'RemoteData',\n MaximumRetriesReached = 'MaximumRetriesReached',\n}\n"],"mappings":"yGAIY,CAAAA,kBAAkB,CAAAC,OAAA,CAAAD,kBAAA,UAAlBA,CAAkB,QAAlB,CAAAA,CAAkB,CAAAE,WAAA,eAAlBF,CAAkB,CAAAG,yBAAA,6BAAlBH,CAAkB,CAAAI,gCAAA,oCAAlBJ,CAAkB,CAAAK,2BAAA,+BAAlBL,CAAkB,CAAAM,4BAAA,gCAAlBN,CAAkB,CAAAO,8BAAA,kCAAlBP,CAAkB,CAAAQ,WAAA,eAAlBR,CAAkB,CAAAS,WAAA,eAAlBT,CAAkB,CAAAU,oBAAA,wBAAlBV,CAAkB,CAAAW,gBAAA,oBAAlBX,CAAkB,CAAAY,qBAAA,yBAAlBZ,CAAkB,CAAAa,YAAA,gBAAlBb,CAAkB,CAAAc,WAAA,eAAlBd,CAAkB,CAAAe,YAAA,gBAAlBf,CAAkB,CAAAgB,YAAA,gBAAlBhB,CAAkB,CAAAiB,mBAAA,uBAAlBjB,CAAkB,CAAAkB,kBAAA,sBAAlBlB,CAAkB,CAAAmB,gBAAA,oBAAlBnB,CAAkB,CAAAoB,cAAA,kBAAlBpB,CAAkB,CAAAqB,SAAA,aAAlBrB,CAAkB,CAAAsB,WAAA,eAAlBtB,CAAkB,CAAAuB,YAAA,gBAAlBvB,CAAkB,CAAAwB,WAAA,eAAlBxB,CAAkB,CAAAyB,oBAAA,wBAAlBzB,CAAkB,CAAA0B,UAAA,cAAlB1B,CAAkB,CAAA2B,qBAAA,yBAAlB3B,CAAkB"}
1
+ {"version":3,"file":"types.js","names":["KameleoonException","exports","Credentials","EventSourceInitialization","FeatureFlagConfigurationNotFound","FeatureFlagVariableNotFound","FeatureFlagVariationNotFound","FeatureFlagEnvironmentDisabled","NotTargeted","VisitAmount","VisitorCodeMaxLength","VisitorCodeEmpty","StorageInitialization","StorageWrite","StorageRead","StorageParse","StorageEmpty","ClientConfiguration","TargetingCondition","AmongValuesCheck","RangeCheck","Initialization","JSONParse","NumberParse","VersionParse","CookieParse","SemanticVersionParse","RemoteData","MaximumRetriesReached"],"sources":["../../src/kameleoonError/types.ts"],"sourcesContent":["/**\n * @readonly\n * @enum {string} an Enum containing all possible variants of exception types `KameleoonError`\n * */\nexport enum KameleoonException {\n Credentials = 'Credentials',\n EventSourceInitialization = 'EventSourceInitialization',\n FeatureFlagConfigurationNotFound = 'FeatureFlagConfigurationNotFound',\n FeatureFlagVariableNotFound = 'FeatureFlagVariableNotFound',\n FeatureFlagVariationNotFound = 'FeatureFlagVariationNotFound',\n FeatureFlagEnvironmentDisabled = 'FeatureFlagEnvironmentDisabled',\n NotTargeted = 'NotTargeted',\n VisitAmount = 'VisitAmount',\n VisitorCodeMaxLength = 'VisitorCodeMaxLength',\n VisitorCodeEmpty = 'VisitorCodeEmpty',\n StorageInitialization = 'StorageInitialization',\n StorageWrite = 'StorageWrite',\n StorageRead = 'StorageRead',\n StorageParse = 'StorageParse',\n StorageEmpty = 'StorageEmpty',\n ClientConfiguration = 'ClientConfiguration',\n TargetingCondition = 'TargetingCondition',\n AmongValuesCheck = 'AmongValuesCheck',\n RangeCheck = 'RangeCheck',\n Initialization = 'Initialization',\n JSONParse = 'JSONParse',\n NumberParse = 'NumberParse',\n VersionParse = 'VersionParse',\n CookieParse = 'CookieParse',\n SemanticVersionParse = 'SemanticVersionParse',\n RemoteData = 'RemoteData',\n MaximumRetriesReached = 'MaximumRetriesReached',\n}\n"],"mappings":"yGAIY,CAAAA,kBAAkB,CAAAC,OAAA,CAAAD,kBAAA,UAAlBA,CAAkB,QAAlB,CAAAA,CAAkB,CAAAE,WAAA,eAAlBF,CAAkB,CAAAG,yBAAA,6BAAlBH,CAAkB,CAAAI,gCAAA,oCAAlBJ,CAAkB,CAAAK,2BAAA,+BAAlBL,CAAkB,CAAAM,4BAAA,gCAAlBN,CAAkB,CAAAO,8BAAA,kCAAlBP,CAAkB,CAAAQ,WAAA,eAAlBR,CAAkB,CAAAS,WAAA,eAAlBT,CAAkB,CAAAU,oBAAA,wBAAlBV,CAAkB,CAAAW,gBAAA,oBAAlBX,CAAkB,CAAAY,qBAAA,yBAAlBZ,CAAkB,CAAAa,YAAA,gBAAlBb,CAAkB,CAAAc,WAAA,eAAlBd,CAAkB,CAAAe,YAAA,gBAAlBf,CAAkB,CAAAgB,YAAA,gBAAlBhB,CAAkB,CAAAiB,mBAAA,uBAAlBjB,CAAkB,CAAAkB,kBAAA,sBAAlBlB,CAAkB,CAAAmB,gBAAA,oBAAlBnB,CAAkB,CAAAoB,UAAA,cAAlBpB,CAAkB,CAAAqB,cAAA,kBAAlBrB,CAAkB,CAAAsB,SAAA,aAAlBtB,CAAkB,CAAAuB,WAAA,eAAlBvB,CAAkB,CAAAwB,YAAA,gBAAlBxB,CAAkB,CAAAyB,WAAA,eAAlBzB,CAAkB,CAAA0B,oBAAA,wBAAlB1B,CAAkB,CAAA2B,UAAA,cAAlB3B,CAAkB,CAAA4B,qBAAA,yBAAlB5B,CAAkB"}
@@ -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