@kameleoon/javascript-sdk-core 0.0.3 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -3
- package/dist/campaignConfiguration/campaignConfiguration.d.ts +46 -0
- package/dist/campaignConfiguration/campaignConfiguration.js +217 -0
- package/dist/campaignConfiguration/campaignConfiguration.js.map +1 -0
- package/dist/campaignConfiguration/constants.d.ts +18 -0
- package/dist/campaignConfiguration/constants.js +23 -0
- package/dist/campaignConfiguration/constants.js.map +1 -0
- package/dist/campaignConfiguration/index.d.ts +2 -0
- package/dist/campaignConfiguration/index.js +8 -0
- package/dist/campaignConfiguration/index.js.map +1 -0
- package/dist/campaignConfiguration/types.d.ts +126 -0
- package/dist/campaignConfiguration/types.js +47 -0
- package/dist/campaignConfiguration/types.js.map +1 -0
- package/dist/clientSettings/clientSettings.d.ts +12 -0
- package/dist/clientSettings/clientSettings.js +29 -0
- package/dist/clientSettings/clientSettings.js.map +1 -0
- package/dist/clientSettings/index.d.ts +2 -0
- package/dist/clientSettings/index.js +6 -0
- package/dist/clientSettings/index.js.map +1 -0
- package/dist/clientSettings/types.d.ts +6 -0
- package/dist/{interfaces/interfaces.js → clientSettings/types.js} +1 -1
- package/dist/clientSettings/types.js.map +1 -0
- package/dist/constants.d.ts +10 -16
- package/dist/constants.js +13 -20
- package/dist/constants.js.map +1 -1
- package/dist/eventSource/constants.d.ts +1 -0
- package/dist/eventSource/constants.js +5 -0
- package/dist/eventSource/constants.js.map +1 -0
- package/dist/eventSource/externalEventSource.d.ts +12 -0
- package/dist/eventSource/externalEventSource.js +26 -0
- package/dist/eventSource/externalEventSource.js.map +1 -0
- package/dist/eventSource/index.d.ts +3 -0
- package/dist/eventSource/index.js +8 -0
- package/dist/eventSource/index.js.map +1 -0
- package/dist/eventSource/types.d.ts +47 -0
- package/dist/eventSource/types.js +3 -0
- package/dist/eventSource/types.js.map +1 -0
- package/dist/hasher/constants.d.ts +1 -0
- package/dist/hasher/constants.js +5 -0
- package/dist/hasher/constants.js.map +1 -0
- package/dist/hasher/hasher.d.ts +6 -0
- package/dist/hasher/hasher.js +34 -0
- package/dist/hasher/hasher.js.map +1 -0
- package/dist/hasher/index.d.ts +1 -0
- package/dist/hasher/index.js +6 -0
- package/dist/hasher/index.js.map +1 -0
- package/dist/hasher/types.d.ts +12 -0
- package/dist/hasher/types.js +3 -0
- package/dist/hasher/types.js.map +1 -0
- package/dist/index.d.ts +10 -3
- package/dist/index.js +25 -7
- package/dist/index.js.map +1 -1
- package/dist/kameleoonClient.d.ts +189 -100
- package/dist/kameleoonClient.js +238 -701
- package/dist/kameleoonClient.js.map +1 -1
- package/dist/kameleoonData/browser.d.ts +21 -0
- package/dist/kameleoonData/browser.js +41 -0
- package/dist/kameleoonData/browser.js.map +1 -0
- package/dist/kameleoonData/constants.d.ts +1 -0
- package/dist/kameleoonData/constants.js +5 -0
- package/dist/kameleoonData/constants.js.map +1 -0
- package/dist/kameleoonData/conversion.d.ts +23 -0
- package/dist/kameleoonData/conversion.js +49 -0
- package/dist/kameleoonData/conversion.js.map +1 -0
- package/dist/kameleoonData/customData.d.ts +33 -0
- package/dist/kameleoonData/customData.js +68 -0
- package/dist/kameleoonData/customData.js.map +1 -0
- package/dist/kameleoonData/device.d.ts +21 -0
- package/dist/kameleoonData/device.js +41 -0
- package/dist/kameleoonData/device.js.map +1 -0
- package/dist/kameleoonData/index.d.ts +7 -0
- package/dist/kameleoonData/index.js +20 -0
- package/dist/kameleoonData/index.js.map +1 -0
- package/dist/kameleoonData/nonce.d.ts +5 -0
- package/dist/kameleoonData/nonce.js +20 -0
- package/dist/kameleoonData/nonce.js.map +1 -0
- package/dist/kameleoonData/pageView.d.ts +24 -0
- package/dist/kameleoonData/pageView.js +54 -0
- package/dist/kameleoonData/pageView.js.map +1 -0
- package/dist/kameleoonData/types.d.ts +100 -0
- package/dist/kameleoonData/types.js +36 -0
- package/dist/kameleoonData/types.js.map +1 -0
- package/dist/kameleoonData/userAgent.d.ts +18 -0
- package/dist/kameleoonData/userAgent.js +33 -0
- package/dist/kameleoonData/userAgent.js.map +1 -0
- package/dist/kameleoonError/constants.d.ts +22 -0
- package/dist/kameleoonError/constants.js +25 -0
- package/dist/kameleoonError/constants.js.map +1 -0
- package/dist/kameleoonError/helpers.d.ts +1 -0
- package/dist/kameleoonError/helpers.js +8 -0
- package/dist/kameleoonError/helpers.js.map +1 -0
- package/dist/kameleoonError/index.d.ts +3 -0
- package/dist/kameleoonError/index.js +10 -0
- package/dist/kameleoonError/index.js.map +1 -0
- package/dist/kameleoonError/kameleoonError.d.ts +24 -0
- package/dist/kameleoonError/kameleoonError.js +64 -0
- package/dist/kameleoonError/kameleoonError.js.map +1 -0
- package/dist/kameleoonError/types.d.ts +20 -0
- package/dist/kameleoonError/types.js +25 -0
- package/dist/kameleoonError/types.js.map +1 -0
- package/dist/kameleoonUtils.d.ts +11 -10
- package/dist/kameleoonUtils.js +42 -128
- package/dist/kameleoonUtils.js.map +1 -1
- package/dist/requester/constants.d.ts +15 -0
- package/dist/requester/constants.js +53 -0
- package/dist/requester/constants.js.map +1 -0
- package/dist/requester/index.d.ts +3 -0
- package/dist/requester/index.js +10 -0
- package/dist/requester/index.js.map +1 -0
- package/dist/requester/requester.d.ts +23 -0
- package/dist/requester/requester.js +121 -0
- package/dist/requester/requester.js.map +1 -0
- package/dist/requester/types.d.ts +43 -0
- package/dist/requester/types.js +39 -0
- package/dist/requester/types.js.map +1 -0
- package/dist/storage/constants.d.ts +9 -0
- package/dist/storage/constants.js +14 -0
- package/dist/storage/constants.js.map +1 -0
- package/dist/storage/externalStorage.d.ts +11 -0
- package/dist/storage/externalStorage.js +34 -0
- package/dist/storage/externalStorage.js.map +1 -0
- package/dist/storage/index.d.ts +3 -0
- package/dist/storage/index.js +8 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/types.d.ts +52 -11
- package/dist/targeting/conditions/conditionFactory.d.ts +6 -0
- package/dist/targeting/conditions/conditionFactory.js +26 -0
- package/dist/targeting/conditions/conditionFactory.js.map +1 -0
- package/dist/targeting/conditions/customDataCondition.d.ts +16 -0
- package/dist/targeting/conditions/customDataCondition.js +99 -0
- package/dist/targeting/conditions/customDataCondition.js.map +1 -0
- package/dist/targeting/conditions/exclusiveExperimentCondition.d.ts +9 -0
- package/dist/targeting/conditions/exclusiveExperimentCondition.js +21 -0
- package/dist/targeting/conditions/exclusiveExperimentCondition.js.map +1 -0
- package/dist/targeting/conditions/index.d.ts +5 -0
- package/dist/targeting/conditions/index.js +12 -0
- package/dist/targeting/conditions/index.js.map +1 -0
- package/dist/targeting/conditions/targetExperimentCondition.d.ts +13 -0
- package/dist/targeting/conditions/targetExperimentCondition.js +42 -0
- package/dist/targeting/conditions/targetExperimentCondition.js.map +1 -0
- package/dist/targeting/conditions/types.d.ts +22 -11
- package/dist/targeting/index.d.ts +3 -0
- package/dist/targeting/index.js +15 -0
- package/dist/targeting/index.js.map +1 -0
- package/dist/targeting/targetingNode.d.ts +21 -0
- package/dist/targeting/targetingNode.js +40 -0
- package/dist/targeting/targetingNode.js.map +1 -0
- package/dist/targeting/targetingTree.d.ts +16 -8
- package/dist/targeting/targetingTree.js +112 -10
- package/dist/targeting/targetingTree.js.map +1 -1
- package/dist/targeting/types.d.ts +127 -0
- package/dist/targeting/types.js +93 -0
- package/dist/targeting/types.js.map +1 -0
- package/dist/types.d.ts +135 -5
- package/dist/types.js +28 -0
- package/dist/types.js.map +1 -1
- package/dist/utilities/constants.d.ts +1 -0
- package/dist/utilities/constants.js +5 -0
- package/dist/utilities/constants.js.map +1 -0
- package/dist/utilities/index.d.ts +1 -0
- package/dist/utilities/index.js +6 -0
- package/dist/utilities/index.js.map +1 -0
- package/dist/utilities/types.d.ts +18 -0
- package/dist/utilities/types.js +3 -0
- package/dist/utilities/types.js.map +1 -0
- package/dist/utilities/utilities.d.ts +13 -0
- package/dist/utilities/utilities.js +119 -0
- package/dist/utilities/utilities.js.map +1 -0
- package/dist/variationConfiguration/index.d.ts +2 -0
- package/dist/variationConfiguration/index.js +6 -0
- package/dist/variationConfiguration/index.js.map +1 -0
- package/dist/variationConfiguration/types.d.ts +25 -0
- package/dist/variationConfiguration/types.js +3 -0
- package/dist/variationConfiguration/types.js.map +1 -0
- package/dist/variationConfiguration/variation.d.ts +13 -0
- package/dist/variationConfiguration/variation.js +38 -0
- package/dist/variationConfiguration/variation.js.map +1 -0
- package/dist/variationConfiguration/variationConfiguration.d.ts +36 -0
- package/dist/variationConfiguration/variationConfiguration.js +248 -0
- package/dist/variationConfiguration/variationConfiguration.js.map +1 -0
- package/package.json +19 -9
- package/dist/configurations/configuration.d.ts +0 -15
- package/dist/configurations/configuration.js +0 -31
- package/dist/configurations/configuration.js.map +0 -1
- package/dist/configurations/experiment.d.ts +0 -13
- package/dist/configurations/experiment.js +0 -54
- package/dist/configurations/experiment.js.map +0 -1
- package/dist/configurations/featureFlag.d.ts +0 -23
- package/dist/configurations/featureFlag.js +0 -105
- package/dist/configurations/featureFlag.js.map +0 -1
- package/dist/configurations/variation.d.ts +0 -15
- package/dist/configurations/variation.js +0 -14
- package/dist/configurations/variation.js.map +0 -1
- package/dist/data.d.ts +0 -67
- package/dist/data.js +0 -127
- package/dist/data.js.map +0 -1
- package/dist/exceptions/credentialsNotFound.d.ts +0 -6
- package/dist/exceptions/credentialsNotFound.js +0 -29
- package/dist/exceptions/credentialsNotFound.js.map +0 -1
- package/dist/exceptions/experimentConfigurationNotFound.d.ts +0 -6
- package/dist/exceptions/experimentConfigurationNotFound.js +0 -29
- package/dist/exceptions/experimentConfigurationNotFound.js.map +0 -1
- package/dist/exceptions/featureConfigurationNotFound.d.ts +0 -6
- package/dist/exceptions/featureConfigurationNotFound.js +0 -29
- package/dist/exceptions/featureConfigurationNotFound.js.map +0 -1
- package/dist/exceptions/notActivated.d.ts +0 -6
- package/dist/exceptions/notActivated.js +0 -29
- package/dist/exceptions/notActivated.js.map +0 -1
- package/dist/exceptions/notTargeted.d.ts +0 -6
- package/dist/exceptions/notTargeted.js +0 -29
- package/dist/exceptions/notTargeted.js.map +0 -1
- package/dist/exceptions/siteCodeDisabled.d.ts +0 -5
- package/dist/exceptions/siteCodeDisabled.js +0 -30
- package/dist/exceptions/siteCodeDisabled.js.map +0 -1
- package/dist/exceptions/variationConfigurationNotFound.d.ts +0 -6
- package/dist/exceptions/variationConfigurationNotFound.js +0 -29
- package/dist/exceptions/variationConfigurationNotFound.js.map +0 -1
- package/dist/exceptions/visitorCodeNotValid.d.ts +0 -5
- package/dist/exceptions/visitorCodeNotValid.js +0 -30
- package/dist/exceptions/visitorCodeNotValid.js.map +0 -1
- package/dist/interfaces/interfaces.d.ts +0 -81
- package/dist/interfaces/interfaces.js.map +0 -1
- package/dist/nonce.d.ts +0 -1
- package/dist/nonce.js +0 -16
- package/dist/nonce.js.map +0 -1
- package/dist/realTimeConfigurationService.d.ts +0 -12
- package/dist/realTimeConfigurationService.js +0 -24
- package/dist/realTimeConfigurationService.js.map +0 -1
- package/dist/storage/variationStorage.d.ts +0 -11
- package/dist/storage/variationStorage.js +0 -159
- package/dist/storage/variationStorage.js.map +0 -1
- package/dist/storage/visitorVariation.d.ts +0 -9
- package/dist/storage/visitorVariation.js +0 -22
- package/dist/storage/visitorVariation.js.map +0 -1
- package/dist/targeting/conditions/customDatum.d.ts +0 -12
- package/dist/targeting/conditions/customDatum.js +0 -129
- package/dist/targeting/conditions/customDatum.js.map +0 -1
- package/dist/targeting/conditions/exclusiveExperiment.d.ts +0 -9
- package/dist/targeting/conditions/exclusiveExperiment.js +0 -45
- package/dist/targeting/conditions/exclusiveExperiment.js.map +0 -1
- package/dist/targeting/conditions/targetExperiment.d.ts +0 -14
- package/dist/targeting/conditions/targetExperiment.js +0 -57
- package/dist/targeting/conditions/targetExperiment.js.map +0 -1
- package/dist/targeting/targetingCondition.d.ts +0 -7
- package/dist/targeting/targetingCondition.js +0 -9
- package/dist/targeting/targetingCondition.js.map +0 -1
- package/dist/targeting/targetingConditionsFactory.d.ts +0 -7
- package/dist/targeting/targetingConditionsFactory.js +0 -30
- package/dist/targeting/targetingConditionsFactory.js.map +0 -1
- package/dist/targeting/targetingData.d.ts +0 -7
- package/dist/targeting/targetingData.js +0 -11
- package/dist/targeting/targetingData.js.map +0 -1
- package/dist/targeting/targetingEngine.d.ts +0 -6
- package/dist/targeting/targetingEngine.js +0 -130
- package/dist/targeting/targetingEngine.js.map +0 -1
- package/dist/targeting/targetingSegment.d.ts +0 -5
- package/dist/targeting/targetingSegment.js +0 -9
- package/dist/targeting/targetingSegment.js.map +0 -1
- package/dist/targeting/targetingTreeBuilder.d.ts +0 -8
- package/dist/targeting/targetingTreeBuilder.js +0 -127
- package/dist/targeting/targetingTreeBuilder.js.map +0 -1
package/dist/constants.js
CHANGED
|
@@ -1,23 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
exports.
|
|
16
|
-
exports.CONFIGURATION_URL = 'https://client-config.kameleoon.com/';
|
|
17
|
-
var ConditionTypes;
|
|
18
|
-
(function (ConditionTypes) {
|
|
19
|
-
ConditionTypes["CUSTOM_DATUM"] = "CUSTOM_DATUM";
|
|
20
|
-
ConditionTypes["EXCLUSIVE_EXPERIMENT"] = "EXCLUSIVE_EXPERIMENT";
|
|
21
|
-
ConditionTypes["TARGET_EXPERIMENT"] = "TARGET_EXPERIMENT";
|
|
22
|
-
})(ConditionTypes = exports.ConditionTypes || (exports.ConditionTypes = {}));
|
|
3
|
+
exports.Cookie = exports.VISITOR_CODE_LENGTH = exports.KAMELEOON_COOKIE_KEY = exports.OFF_VARIATION_KEY = exports.UNALLOCATED_VARIATION_ID = void 0;
|
|
4
|
+
exports.UNALLOCATED_VARIATION_ID = 0;
|
|
5
|
+
exports.OFF_VARIATION_KEY = 'off';
|
|
6
|
+
exports.KAMELEOON_COOKIE_KEY = 'kameleoonVisitorCode';
|
|
7
|
+
exports.VISITOR_CODE_LENGTH = 16;
|
|
8
|
+
var Cookie;
|
|
9
|
+
(function (Cookie) {
|
|
10
|
+
Cookie["PairsDelimiter"] = "; ";
|
|
11
|
+
Cookie["KeyValueDelimiter"] = "=";
|
|
12
|
+
Cookie["MaxAge"] = "MaxAge";
|
|
13
|
+
Cookie["Path"] = "Path";
|
|
14
|
+
Cookie["Domain"] = "Domain";
|
|
15
|
+
})(Cookie = exports.Cookie || (exports.Cookie = {}));
|
|
23
16
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,wBAAwB,GAAG,CAAC,CAAC;AAC7B,QAAA,iBAAiB,GAAG,KAAK,CAAC;AAC1B,QAAA,oBAAoB,GAAG,sBAAsB,CAAC;AAC9C,QAAA,mBAAmB,GAAG,EAAE,CAAC;AAEtC,IAAY,MAMX;AAND,WAAY,MAAM;IAChB,+BAAqB,CAAA;IACrB,iCAAuB,CAAA;IACvB,2BAAiB,CAAA;IACjB,uBAAa,CAAA;IACb,2BAAiB,CAAA;AACnB,CAAC,EANW,MAAM,GAAN,cAAM,KAAN,cAAM,QAMjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const REAL_TIME_EVENT = "configuration-update-event";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/eventSource/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IExternalEventSourceConstructor } from './types';
|
|
2
|
+
export interface IEventSource {
|
|
3
|
+
open: (onEvent: (timestamp: number) => void) => void;
|
|
4
|
+
close: () => void;
|
|
5
|
+
}
|
|
6
|
+
export declare class ExternalEventSource implements IEventSource {
|
|
7
|
+
private eventSource;
|
|
8
|
+
private siteCode;
|
|
9
|
+
constructor(siteCode: string, externalEventSource: IExternalEventSourceConstructor);
|
|
10
|
+
open(onEvent: (timestamp: number) => void): void;
|
|
11
|
+
close(): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExternalEventSource = void 0;
|
|
4
|
+
const requester_1 = require("../requester");
|
|
5
|
+
const constants_1 = require("../requester/constants");
|
|
6
|
+
const constants_2 = require("./constants");
|
|
7
|
+
class ExternalEventSource {
|
|
8
|
+
constructor(siteCode, externalEventSource) {
|
|
9
|
+
const url = requester_1.URL.EVENTS + constants_1.UrlQuery.Sse + siteCode;
|
|
10
|
+
const eventSource = externalEventSource.initialize(url);
|
|
11
|
+
this.eventSource = eventSource;
|
|
12
|
+
this.siteCode = siteCode;
|
|
13
|
+
}
|
|
14
|
+
open(onEvent) {
|
|
15
|
+
this.eventSource.open({
|
|
16
|
+
onEvent,
|
|
17
|
+
siteCode: this.siteCode,
|
|
18
|
+
eventType: constants_2.REAL_TIME_EVENT,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
close() {
|
|
22
|
+
this.eventSource.close();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.ExternalEventSource = ExternalEventSource;
|
|
26
|
+
//# sourceMappingURL=externalEventSource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"externalEventSource.js","sourceRoot":"","sources":["../../src/eventSource/externalEventSource.ts"],"names":[],"mappings":";;;AAAA,4CAAmC;AACnC,sDAAkD;AAClD,2CAA8C;AAQ9C,MAAa,mBAAmB;IAI9B,YACE,QAAgB,EAChB,mBAAoD;QAEpD,MAAM,GAAG,GAAG,eAAG,CAAC,MAAM,GAAG,oBAAQ,CAAC,GAAG,GAAG,QAAQ,CAAC;QACjD,MAAM,WAAW,GAAG,mBAAmB,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QAExD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAEM,IAAI,CAAC,OAAoC;QAC9C,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;YACpB,OAAO;YACP,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,SAAS,EAAE,2BAAe;SAC3B,CAAC,CAAC;IACL,CAAC;IAEM,KAAK;QACV,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC;CACF;AA1BD,kDA0BC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.REAL_TIME_EVENT = exports.ExternalEventSource = void 0;
|
|
4
|
+
var externalEventSource_1 = require("./externalEventSource");
|
|
5
|
+
Object.defineProperty(exports, "ExternalEventSource", { enumerable: true, get: function () { return externalEventSource_1.ExternalEventSource; } });
|
|
6
|
+
var constants_1 = require("./constants");
|
|
7
|
+
Object.defineProperty(exports, "REAL_TIME_EVENT", { enumerable: true, get: function () { return constants_1.REAL_TIME_EVENT; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/eventSource/index.ts"],"names":[],"mappings":";;;AAMA,6DAA0E;AAAjE,0HAAA,mBAAmB,OAAA;AAC5B,yCAA8C;AAArC,4GAAA,eAAe,OAAA"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @interface an interface of External Constructor for Extrnal Event Source which must be implemented by the wrapper constructor to initialize new `IExternalEventSource` in order to pass the necessary `url` parameter
|
|
3
|
+
* */
|
|
4
|
+
export interface IExternalEventSourceConstructor {
|
|
5
|
+
/**
|
|
6
|
+
* @method initialize - creates and instance of `IExternalEventSource` and returns it
|
|
7
|
+
* @param {string} url - url of server sent event server which will be pasted by consumer
|
|
8
|
+
* @returns {IExternalEventSource} an initialized instance of `IExternalEventSource`
|
|
9
|
+
* */
|
|
10
|
+
initialize: (url: string) => IExternalEventSource;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* @param {string} siteCode - site code from the event
|
|
14
|
+
* @param {string} eventType - type of event to be listened for
|
|
15
|
+
* @param {(timestamp: number) => void} onEvent - callback to be executed upon event if the site code from event matches the site code of EvenetSource
|
|
16
|
+
* */
|
|
17
|
+
export type EventSourceOpenParametersType = {
|
|
18
|
+
siteCode: string;
|
|
19
|
+
eventType: string;
|
|
20
|
+
onEvent: (timestamp: number) => void;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* @interface an interface of External Event Source which will be used in server sent events operations
|
|
24
|
+
* */
|
|
25
|
+
export interface IExternalEventSource {
|
|
26
|
+
/**
|
|
27
|
+
* @method open - opens event source live connection
|
|
28
|
+
* @param {(timestamp: number) => void} callback - callback function that will be executed on each obtainment of server event
|
|
29
|
+
* */
|
|
30
|
+
open: ({ siteCode, eventType, onEvent, }: EventSourceOpenParametersType) => void;
|
|
31
|
+
/**
|
|
32
|
+
* @method close - closes event source live connection
|
|
33
|
+
* */
|
|
34
|
+
close: () => void;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* @param {string} siteCode - site code from the event
|
|
38
|
+
* @param {number} ts - timestamp of when the event has happened
|
|
39
|
+
* */
|
|
40
|
+
export type RealTimeEventType = {
|
|
41
|
+
siteCode: string;
|
|
42
|
+
ts: number;
|
|
43
|
+
};
|
|
44
|
+
export type CreateEventSourceParamsType = {
|
|
45
|
+
siteCode: string;
|
|
46
|
+
externalEventSource?: IExternalEventSourceConstructor;
|
|
47
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/eventSource/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const RESHUFFLE_SUFFIX = "variation";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/hasher/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,gBAAgB,GAAG,WAAW,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ObtainExperimentHashDoubleParamsType, ObtainFeatureFlagHashDoubleParamsType } from './types';
|
|
2
|
+
export declare class Hasher {
|
|
3
|
+
static obtainExperimentHashDouble({ visitorCode, campaignId, respoolTime, }: ObtainExperimentHashDoubleParamsType): number;
|
|
4
|
+
static obtainFeatureFlagHashDouble({ visitorCode, campaignId, reShuffle, }: ObtainFeatureFlagHashDoubleParamsType): number;
|
|
5
|
+
static calculateHash(seed: string): number;
|
|
6
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Hasher = void 0;
|
|
4
|
+
const crypto_js_1 = require("crypto-js");
|
|
5
|
+
const constants_1 = require("./constants");
|
|
6
|
+
class Hasher {
|
|
7
|
+
static obtainExperimentHashDouble({ visitorCode, campaignId, respoolTime, }) {
|
|
8
|
+
let respoolTimeString = '';
|
|
9
|
+
if (respoolTime.length) {
|
|
10
|
+
respoolTime.forEach((respoolObject) => {
|
|
11
|
+
respoolTimeString += String(respoolObject.value);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
return this.calculateHash(visitorCode + campaignId + respoolTimeString);
|
|
15
|
+
}
|
|
16
|
+
static obtainFeatureFlagHashDouble({ visitorCode, campaignId,
|
|
17
|
+
// --- Note ---
|
|
18
|
+
// For some cases of feature flag rules we need to obtain `hashDouble` twice
|
|
19
|
+
// in a row, but the second `hashDouble` should be different (yet still predictable)
|
|
20
|
+
reShuffle = false, }) {
|
|
21
|
+
return this.calculateHash(visitorCode + campaignId + (reShuffle ? constants_1.RESHUFFLE_SUFFIX : ''));
|
|
22
|
+
}
|
|
23
|
+
// --- Note ---
|
|
24
|
+
// `hashDouble` is a seeded pseudo-random number between 0 and 1
|
|
25
|
+
// used for deciding what variation to assign
|
|
26
|
+
// `calculateHash` algorythm is consistent between every SDK
|
|
27
|
+
// and will always provide same pseudo-random value for the same input parameters
|
|
28
|
+
static calculateHash(seed) {
|
|
29
|
+
const hashDigest = (0, crypto_js_1.SHA256)(seed).toString();
|
|
30
|
+
return parseInt(hashDigest, 16) / Math.pow(2, 256);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.Hasher = Hasher;
|
|
34
|
+
//# sourceMappingURL=hasher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hasher.js","sourceRoot":"","sources":["../../src/hasher/hasher.ts"],"names":[],"mappings":";;;AAAA,yCAAmC;AACnC,2CAA+C;AAM/C,MAAa,MAAM;IACjB,MAAM,CAAC,0BAA0B,CAAC,EAChC,WAAW,EACX,UAAU,EACV,WAAW,GAC0B;QACrC,IAAI,iBAAiB,GAAG,EAAE,CAAC;QAE3B,IAAI,WAAW,CAAC,MAAM,EAAE;YACtB,WAAW,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,EAAE;gBACpC,iBAAiB,IAAI,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YACnD,CAAC,CAAC,CAAC;SACJ;QAED,OAAO,IAAI,CAAC,aAAa,CAAC,WAAW,GAAG,UAAU,GAAG,iBAAiB,CAAC,CAAC;IAC1E,CAAC;IAED,MAAM,CAAC,2BAA2B,CAAC,EACjC,WAAW,EACX,UAAU;IACV,eAAe;IACf,4EAA4E;IAC5E,oFAAoF;IACpF,SAAS,GAAG,KAAK,GACqB;QACtC,OAAO,IAAI,CAAC,aAAa,CACvB,WAAW,GAAG,UAAU,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,4BAAgB,CAAC,CAAC,CAAC,EAAE,CAAC,CAC/D,CAAC;IACJ,CAAC;IAED,eAAe;IACf,gEAAgE;IAChE,6CAA6C;IAC7C,4DAA4D;IAC5D,iFAAiF;IACjF,MAAM,CAAC,aAAa,CAAC,IAAY;QAC/B,MAAM,UAAU,GAAG,IAAA,kBAAM,EAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;QAE3C,OAAO,QAAQ,CAAC,UAAU,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACrD,CAAC;CACF;AAxCD,wBAwCC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Hasher } from './hasher';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Hasher = void 0;
|
|
4
|
+
var hasher_1 = require("./hasher");
|
|
5
|
+
Object.defineProperty(exports, "Hasher", { enumerable: true, get: function () { return hasher_1.Hasher; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hasher/index.ts"],"names":[],"mappings":";;;AAAA,mCAAkC;AAAzB,gGAAA,MAAM,OAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { RespoolTimeType } from '../campaignConfiguration/types';
|
|
2
|
+
type ObtainHashDoubleParamsType = {
|
|
3
|
+
visitorCode: string;
|
|
4
|
+
campaignId: string;
|
|
5
|
+
};
|
|
6
|
+
export type ObtainExperimentHashDoubleParamsType = ObtainHashDoubleParamsType & {
|
|
7
|
+
respoolTime: RespoolTimeType[];
|
|
8
|
+
};
|
|
9
|
+
export type ObtainFeatureFlagHashDoubleParamsType = ObtainHashDoubleParamsType & {
|
|
10
|
+
reShuffle?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/hasher/types.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
1
|
+
export { KameleoonClient as KameleoonCore, IKameleoonClient as IKameleoonCore, } from './kameleoonClient';
|
|
2
|
+
export { KameleoonUtils as KameleoonCoreUtils } from './kameleoonUtils';
|
|
3
|
+
export { KameleoonException, KameleoonError } from './kameleoonError';
|
|
4
|
+
export { KameleoonStorageKey, IExternalStorage, IExternalStorageConstructor, } from './storage';
|
|
5
|
+
export { Cookie, VISITOR_CODE_LENGTH } from './constants';
|
|
6
|
+
export { JSONType } from './campaignConfiguration';
|
|
7
|
+
export { Ok, Result, Err } from 'ts-res';
|
|
8
|
+
export { Environment, ExperimentType, FeatureFlagType, SDKCoreParameters, SDKConfigurationType, TrackConversionParamsType, FeatureVariableResultType, InternalSDKConfigurationType, GetFeatureFlagVariableParamsType, ServerGetVisitorCodeParametersType, ClientGetVisitorCodeParametersType, MobileGetVisitorCodeParametersType, } from './types';
|
|
9
|
+
export { CustomData, Conversion, Device, Browser, DeviceType, BrowserType, PageView, KameleoonDataType, PageViewParametersType, ConversionParametersType, } from './kameleoonData';
|
|
10
|
+
export { RealTimeEventType, IExternalEventSource, EventSourceOpenParametersType, IExternalEventSourceConstructor, } from './eventSource';
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
var data_1 = __importDefault(require("./data"));
|
|
8
|
-
exports.KameleoonData = data_1.default;
|
|
3
|
+
exports.PageView = exports.BrowserType = exports.DeviceType = exports.Browser = exports.Device = exports.Conversion = exports.CustomData = exports.Environment = exports.Err = exports.Ok = exports.VISITOR_CODE_LENGTH = exports.Cookie = exports.KameleoonStorageKey = exports.KameleoonError = exports.KameleoonException = exports.KameleoonCoreUtils = exports.KameleoonCore = void 0;
|
|
9
4
|
var kameleoonClient_1 = require("./kameleoonClient");
|
|
10
|
-
Object.defineProperty(exports, "
|
|
5
|
+
Object.defineProperty(exports, "KameleoonCore", { enumerable: true, get: function () { return kameleoonClient_1.KameleoonClient; } });
|
|
6
|
+
var kameleoonUtils_1 = require("./kameleoonUtils");
|
|
7
|
+
Object.defineProperty(exports, "KameleoonCoreUtils", { enumerable: true, get: function () { return kameleoonUtils_1.KameleoonUtils; } });
|
|
8
|
+
var kameleoonError_1 = require("./kameleoonError");
|
|
9
|
+
Object.defineProperty(exports, "KameleoonException", { enumerable: true, get: function () { return kameleoonError_1.KameleoonException; } });
|
|
10
|
+
Object.defineProperty(exports, "KameleoonError", { enumerable: true, get: function () { return kameleoonError_1.KameleoonError; } });
|
|
11
|
+
var storage_1 = require("./storage");
|
|
12
|
+
Object.defineProperty(exports, "KameleoonStorageKey", { enumerable: true, get: function () { return storage_1.KameleoonStorageKey; } });
|
|
13
|
+
var constants_1 = require("./constants");
|
|
14
|
+
Object.defineProperty(exports, "Cookie", { enumerable: true, get: function () { return constants_1.Cookie; } });
|
|
15
|
+
Object.defineProperty(exports, "VISITOR_CODE_LENGTH", { enumerable: true, get: function () { return constants_1.VISITOR_CODE_LENGTH; } });
|
|
16
|
+
var ts_res_1 = require("ts-res");
|
|
17
|
+
Object.defineProperty(exports, "Ok", { enumerable: true, get: function () { return ts_res_1.Ok; } });
|
|
18
|
+
Object.defineProperty(exports, "Err", { enumerable: true, get: function () { return ts_res_1.Err; } });
|
|
19
|
+
var types_1 = require("./types");
|
|
20
|
+
Object.defineProperty(exports, "Environment", { enumerable: true, get: function () { return types_1.Environment; } });
|
|
21
|
+
var kameleoonData_1 = require("./kameleoonData");
|
|
22
|
+
Object.defineProperty(exports, "CustomData", { enumerable: true, get: function () { return kameleoonData_1.CustomData; } });
|
|
23
|
+
Object.defineProperty(exports, "Conversion", { enumerable: true, get: function () { return kameleoonData_1.Conversion; } });
|
|
24
|
+
Object.defineProperty(exports, "Device", { enumerable: true, get: function () { return kameleoonData_1.Device; } });
|
|
25
|
+
Object.defineProperty(exports, "Browser", { enumerable: true, get: function () { return kameleoonData_1.Browser; } });
|
|
26
|
+
Object.defineProperty(exports, "DeviceType", { enumerable: true, get: function () { return kameleoonData_1.DeviceType; } });
|
|
27
|
+
Object.defineProperty(exports, "BrowserType", { enumerable: true, get: function () { return kameleoonData_1.BrowserType; } });
|
|
28
|
+
Object.defineProperty(exports, "PageView", { enumerable: true, get: function () { return kameleoonData_1.PageView; } });
|
|
11
29
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,qDAG2B;AAFzB,gHAAA,eAAe,OAAiB;AAGlC,mDAAwE;AAA/D,oHAAA,cAAc,OAAsB;AAC7C,mDAAsE;AAA7D,oHAAA,kBAAkB,OAAA;AAAE,gHAAA,cAAc,OAAA;AAC3C,qCAImB;AAHjB,8GAAA,mBAAmB,OAAA;AAIrB,yCAA0D;AAAjD,mGAAA,MAAM,OAAA;AAAE,gHAAA,mBAAmB,OAAA;AAEpC,iCAAyC;AAAhC,4FAAA,EAAE,OAAA;AAAU,6FAAA,GAAG,OAAA;AACxB,iCAaiB;AAZf,oGAAA,WAAW,OAAA;AAab,iDAWyB;AAVvB,2GAAA,UAAU,OAAA;AACV,2GAAA,UAAU,OAAA;AACV,uGAAA,MAAM,OAAA;AACN,wGAAA,OAAO,OAAA;AACP,2GAAA,UAAU,OAAA;AACV,4GAAA,WAAW,OAAA;AACX,yGAAA,QAAQ,OAAA"}
|