superposition-provider 0.105.0 → 0.106.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/dist/configuration-client.d.ts +0 -1
- package/dist/experimentation-client.d.ts +2 -2
- package/dist/index.esm.js +22 -27
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +22 -27
- package/dist/index.js.map +1 -1
- package/dist/native-lib/libsuperposition_core-aarch64-apple-darwin.dylib +0 -0
- package/dist/native-lib/libsuperposition_core-x86_64-apple-darwin.dylib +0 -0
- package/dist/native-lib/libsuperposition_core-x86_64-pc-windows-msvc.dll +0 -0
- package/dist/native-lib/libsuperposition_core-x86_64-unknown-linux-gnu.so +0 -0
- package/package.json +1 -1
|
@@ -20,6 +20,5 @@ export declare class ConfigurationClient {
|
|
|
20
20
|
setDefault(defaults: ConfigData): void;
|
|
21
21
|
private fetchConfigData;
|
|
22
22
|
getAllConfigValue(defaultValue: Record<string, any>, context: Record<string, any>, targetingKey?: string): Promise<Record<string, any>>;
|
|
23
|
-
private getApplicableVariants;
|
|
24
23
|
close(): Promise<void>;
|
|
25
24
|
}
|
|
@@ -35,8 +35,8 @@ export declare class ExperimentationClient {
|
|
|
35
35
|
private lastUpdated;
|
|
36
36
|
private evaluationCache;
|
|
37
37
|
private pollingInterval?;
|
|
38
|
-
private onExperimentsChange
|
|
39
|
-
constructor(superpositionOptions: SuperpositionOptions, experimentOptions: ExperimentationOptions, onExperimentsChange
|
|
38
|
+
private onExperimentsChange?;
|
|
39
|
+
constructor(superpositionOptions: SuperpositionOptions, experimentOptions: ExperimentationOptions, onExperimentsChange?: () => void);
|
|
40
40
|
initialize(): Promise<void>;
|
|
41
41
|
private startPolling;
|
|
42
42
|
private fetchExperiments;
|
package/dist/index.esm.js
CHANGED
|
@@ -3180,7 +3180,7 @@ var runtimeConfig = {};
|
|
|
3180
3180
|
|
|
3181
3181
|
var name = "superposition-sdk";
|
|
3182
3182
|
var description = "superposition-sdk client";
|
|
3183
|
-
var version = "0.
|
|
3183
|
+
var version = "0.106.0";
|
|
3184
3184
|
var repository = {
|
|
3185
3185
|
type: "git",
|
|
3186
3186
|
url: "git+https://github.com/juspay/superposition.git"
|
|
@@ -16410,7 +16410,7 @@ class ExperimentationClient {
|
|
|
16410
16410
|
if (experiments && experimentgroups) {
|
|
16411
16411
|
this.cachedExperiments = experiments;
|
|
16412
16412
|
this.cachedExperimentGroups = experimentgroups;
|
|
16413
|
-
this.onExperimentsChange(
|
|
16413
|
+
this.onExperimentsChange?.();
|
|
16414
16414
|
this.lastUpdated = new Date();
|
|
16415
16415
|
console.log("Experiments and Experiment Groups fetched successfully.");
|
|
16416
16416
|
}
|
|
@@ -16424,7 +16424,7 @@ class ExperimentationClient {
|
|
|
16424
16424
|
startPolling(interval) {
|
|
16425
16425
|
const weakSelf = new WeakRef(this);
|
|
16426
16426
|
const poll = async () => {
|
|
16427
|
-
|
|
16427
|
+
const self = weakSelf.deref();
|
|
16428
16428
|
if (!self)
|
|
16429
16429
|
return;
|
|
16430
16430
|
try {
|
|
@@ -16435,16 +16435,13 @@ class ExperimentationClient {
|
|
|
16435
16435
|
self.cachedExperimentGroups = experimentGroups;
|
|
16436
16436
|
self.lastUpdated = new Date();
|
|
16437
16437
|
console.log("Experiments and Experiment Groups refreshed successfully.");
|
|
16438
|
-
self.onExperimentsChange(
|
|
16438
|
+
self.onExperimentsChange?.();
|
|
16439
16439
|
}
|
|
16440
16440
|
}
|
|
16441
16441
|
catch (error) {
|
|
16442
16442
|
console.error("Polling error:", error);
|
|
16443
16443
|
}
|
|
16444
|
-
|
|
16445
|
-
self.pollingInterval = setTimeout(poll, interval);
|
|
16446
|
-
}
|
|
16447
|
-
self = undefined;
|
|
16444
|
+
self.pollingInterval = setTimeout(poll, interval);
|
|
16448
16445
|
};
|
|
16449
16446
|
this.pollingInterval = setTimeout(poll, interval);
|
|
16450
16447
|
}
|
|
@@ -16592,7 +16589,7 @@ class ExperimentationClient {
|
|
|
16592
16589
|
if (experiments) {
|
|
16593
16590
|
this.cachedExperiments = experiments;
|
|
16594
16591
|
this.lastUpdated = new Date();
|
|
16595
|
-
this.onExperimentsChange(
|
|
16592
|
+
this.onExperimentsChange?.();
|
|
16596
16593
|
}
|
|
16597
16594
|
}
|
|
16598
16595
|
catch (error) {
|
|
@@ -16610,7 +16607,7 @@ class ExperimentationClient {
|
|
|
16610
16607
|
const experiments = await this.fetchExperiments();
|
|
16611
16608
|
if (experiments) {
|
|
16612
16609
|
this.cachedExperiments = experiments;
|
|
16613
|
-
this.onExperimentsChange(
|
|
16610
|
+
this.onExperimentsChange?.();
|
|
16614
16611
|
this.lastUpdated = new Date();
|
|
16615
16612
|
}
|
|
16616
16613
|
}
|
|
@@ -16631,7 +16628,7 @@ class ExperimentationClient {
|
|
|
16631
16628
|
if (experimentGroups) {
|
|
16632
16629
|
this.cachedExperimentGroups = experimentGroups;
|
|
16633
16630
|
this.lastUpdated = new Date();
|
|
16634
|
-
this.onExperimentsChange(
|
|
16631
|
+
this.onExperimentsChange?.();
|
|
16635
16632
|
}
|
|
16636
16633
|
}
|
|
16637
16634
|
catch (error) {
|
|
@@ -16649,7 +16646,7 @@ class ExperimentationClient {
|
|
|
16649
16646
|
const experimentGroups = await this.fetchExperimentGroups();
|
|
16650
16647
|
if (experimentGroups) {
|
|
16651
16648
|
this.cachedExperimentGroups = experimentGroups;
|
|
16652
|
-
this.onExperimentsChange(
|
|
16649
|
+
this.onExperimentsChange?.();
|
|
16653
16650
|
this.lastUpdated = new Date();
|
|
16654
16651
|
}
|
|
16655
16652
|
}
|
|
@@ -16681,6 +16678,7 @@ class ExperimentationClient {
|
|
|
16681
16678
|
}
|
|
16682
16679
|
this.clearEvalCache();
|
|
16683
16680
|
this.cachedExperiments = null;
|
|
16681
|
+
this.cachedExperimentGroups = null;
|
|
16684
16682
|
this.lastUpdated = null;
|
|
16685
16683
|
console.log("ExperimentationClient closed successfully");
|
|
16686
16684
|
}
|
|
@@ -16713,7 +16711,7 @@ class ConfigurationClient {
|
|
|
16713
16711
|
const strategy = this.options.refreshStrategy;
|
|
16714
16712
|
const weakSelf = new WeakRef(this);
|
|
16715
16713
|
const poll = async () => {
|
|
16716
|
-
|
|
16714
|
+
const self = weakSelf.deref();
|
|
16717
16715
|
if (!self)
|
|
16718
16716
|
return;
|
|
16719
16717
|
try {
|
|
@@ -16725,10 +16723,7 @@ class ConfigurationClient {
|
|
|
16725
16723
|
catch (error) {
|
|
16726
16724
|
console.error("Failed to refresh configuration. Will continue to use the last known good configuration.", error);
|
|
16727
16725
|
}
|
|
16728
|
-
|
|
16729
|
-
self.refreshInterval = setTimeout(poll, strategy.interval);
|
|
16730
|
-
}
|
|
16731
|
-
self = undefined;
|
|
16726
|
+
self.refreshInterval = setTimeout(poll, strategy.interval);
|
|
16732
16727
|
};
|
|
16733
16728
|
this.refreshInterval = setTimeout(poll, strategy.interval);
|
|
16734
16729
|
}
|
|
@@ -16747,9 +16742,14 @@ class ConfigurationClient {
|
|
|
16747
16742
|
this.providerCache.initConfig(configData.default_configs, configData.contexts, configData.overrides, configData.dimensions);
|
|
16748
16743
|
if (this.experimentationClient) {
|
|
16749
16744
|
await this.experimentationClient.initialize();
|
|
16745
|
+
this.reinitExperimentsCache();
|
|
16750
16746
|
}
|
|
16751
16747
|
}
|
|
16752
|
-
reinitExperimentsCache(
|
|
16748
|
+
reinitExperimentsCache() {
|
|
16749
|
+
if (!this.experimentationClient || !this.providerCache)
|
|
16750
|
+
return;
|
|
16751
|
+
const experiments = this.experimentationClient.getCachedExperiments();
|
|
16752
|
+
const experimentGroups = this.experimentationClient.getCachedExperimentGroups();
|
|
16753
16753
|
if (experiments && experimentGroups) {
|
|
16754
16754
|
this.providerCache.initExperiments(experiments, experimentGroups);
|
|
16755
16755
|
}
|
|
@@ -16760,11 +16760,11 @@ class ConfigurationClient {
|
|
|
16760
16760
|
const configData = await this.fetchConfigData();
|
|
16761
16761
|
this.providerCache.initConfig(configData.default_configs, configData.contexts, configData.overrides, configData.dimensions);
|
|
16762
16762
|
}
|
|
16763
|
-
if (this.experimentationClient &&
|
|
16764
|
-
targetingKey &&
|
|
16763
|
+
if (this.experimentationClient && targetingKey &&
|
|
16765
16764
|
!this.experimentationClient.getCachedExperiments()) {
|
|
16766
16765
|
await this.experimentationClient.getExperiments();
|
|
16767
16766
|
await this.experimentationClient.getExperimentGroups();
|
|
16767
|
+
this.reinitExperimentsCache();
|
|
16768
16768
|
}
|
|
16769
16769
|
return this.providerCache.evalConfig(queryData, "merge", filterPrefixes, targetingKey);
|
|
16770
16770
|
}
|
|
@@ -16810,11 +16810,11 @@ class ConfigurationClient {
|
|
|
16810
16810
|
const configData = await this.fetchConfigData();
|
|
16811
16811
|
this.providerCache.initConfig(configData.default_configs, configData.contexts, configData.overrides, configData.dimensions);
|
|
16812
16812
|
}
|
|
16813
|
-
if (this.experimentationClient &&
|
|
16814
|
-
targetingKey &&
|
|
16813
|
+
if (this.experimentationClient && targetingKey &&
|
|
16815
16814
|
!this.experimentationClient.getCachedExperiments()) {
|
|
16816
16815
|
await this.experimentationClient.getExperiments();
|
|
16817
16816
|
await this.experimentationClient.getExperimentGroups();
|
|
16817
|
+
this.reinitExperimentsCache();
|
|
16818
16818
|
}
|
|
16819
16819
|
return this.providerCache.evalConfig(context, "merge", undefined, targetingKey);
|
|
16820
16820
|
}
|
|
@@ -16825,11 +16825,6 @@ class ConfigurationClient {
|
|
|
16825
16825
|
throw error;
|
|
16826
16826
|
}
|
|
16827
16827
|
}
|
|
16828
|
-
// Add method to get applicable variants
|
|
16829
|
-
async getApplicableVariants(experiments, experiment_groups, dimensions, queryData, identifier, filterPrefixes) {
|
|
16830
|
-
// This would use the native resolver's getApplicableVariants method
|
|
16831
|
-
return this.resolver.getApplicableVariants(experiments, experiment_groups, dimensions, queryData, identifier, filterPrefixes || []);
|
|
16832
|
-
}
|
|
16833
16828
|
// Add method to close and cleanup
|
|
16834
16829
|
async close() {
|
|
16835
16830
|
_cacheRegistry.unregister(this);
|