superposition-provider 0.93.1 → 0.93.2
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/experimentation-client.d.ts +5 -1
- package/dist/index.esm.js +73 -32
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +73 -32
- 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/dist/superposition-provider.d.ts +3 -3
- package/dist/types.d.ts +13 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9903,6 +9903,7 @@ function requireAws_restJson1 () {
|
|
|
9903
9903
|
[_v]: [, input[_v]],
|
|
9904
9904
|
[_sr]: [() => input.show_reasoning !== void 0, () => (input[_sr].toString())],
|
|
9905
9905
|
[_ci]: [, input[_ci]],
|
|
9906
|
+
[_rr]: [() => input.resolve_remote !== void 0, () => (input[_rr].toString())],
|
|
9906
9907
|
});
|
|
9907
9908
|
let body;
|
|
9908
9909
|
body = JSON.stringify((0, smithy_client_1.take)(input, {
|
|
@@ -12620,6 +12621,7 @@ function requireAws_restJson1 () {
|
|
|
12620
12621
|
};
|
|
12621
12622
|
const de_DimensionInfo = (output, context) => {
|
|
12622
12623
|
return (0, smithy_client_1.take)(output, {
|
|
12624
|
+
'autocomplete_function_name': smithy_client_1.expectString,
|
|
12623
12625
|
'dependency_graph': smithy_client_1._json,
|
|
12624
12626
|
'dimension_type': (_) => (0, smithy_client_1._json)((0, core_1.awsExpectUnion)(_)),
|
|
12625
12627
|
'position': smithy_client_1.expectInt32,
|
|
@@ -12936,6 +12938,7 @@ function requireAws_restJson1 () {
|
|
|
12936
12938
|
const _p = "prefix";
|
|
12937
12939
|
const _pa = "page";
|
|
12938
12940
|
const _pl = "plaintext";
|
|
12941
|
+
const _rr = "resolve_remote";
|
|
12939
12942
|
const _s = "status";
|
|
12940
12943
|
const _sb = "sort_by";
|
|
12941
12944
|
const _so = "sort_on";
|
|
@@ -15599,7 +15602,10 @@ class ExperimentationClient {
|
|
|
15599
15602
|
member_experiment_ids: exp_group.member_experiment_ids || [],
|
|
15600
15603
|
group_type: exp_group.group_type ||
|
|
15601
15604
|
superpositionSdk.GroupType.USER_CREATED,
|
|
15602
|
-
buckets: exp_group.buckets
|
|
15605
|
+
buckets: exp_group.buckets?.map((bucket) => ({
|
|
15606
|
+
variant_id: bucket.variant_id || "",
|
|
15607
|
+
experiment_id: bucket.experiment_id || "",
|
|
15608
|
+
})) || [],
|
|
15603
15609
|
});
|
|
15604
15610
|
}
|
|
15605
15611
|
return experimentGroups;
|
|
@@ -15744,10 +15750,10 @@ class ConfigurationClient {
|
|
|
15744
15750
|
console.error("Failed to refresh configuration. Will continue to use the last known good configuration.", error);
|
|
15745
15751
|
}
|
|
15746
15752
|
}, strategy.interval);
|
|
15747
|
-
|
|
15748
|
-
|
|
15749
|
-
|
|
15750
|
-
|
|
15753
|
+
}
|
|
15754
|
+
if (experimentationOptions) {
|
|
15755
|
+
this.experimentationOptions = experimentationOptions;
|
|
15756
|
+
this.experimentationClient = new ExperimentationClient(config, experimentationOptions);
|
|
15751
15757
|
}
|
|
15752
15758
|
this.smithyClient = new superpositionSdk.SuperpositionClient({
|
|
15753
15759
|
endpoint: this.config.endpoint,
|
|
@@ -15766,8 +15772,10 @@ class ConfigurationClient {
|
|
|
15766
15772
|
let experimentationArgs;
|
|
15767
15773
|
if (this.experimentationClient && targetingKey) {
|
|
15768
15774
|
const experiments = await this.experimentationClient.getExperiments();
|
|
15775
|
+
const experiment_groups = await this.experimentationClient.getExperimentGroups();
|
|
15769
15776
|
experimentationArgs = {
|
|
15770
15777
|
experiments,
|
|
15778
|
+
experiment_groups,
|
|
15771
15779
|
targeting_key: targetingKey,
|
|
15772
15780
|
};
|
|
15773
15781
|
}
|
|
@@ -15809,6 +15817,7 @@ class ConfigurationClient {
|
|
|
15809
15817
|
}
|
|
15810
15818
|
}
|
|
15811
15819
|
// TODO: defaultValue is taken but not used. Should it be used as a fallback?
|
|
15820
|
+
// TODO: Remove this function all together and use eval for getAllConfigValue as well
|
|
15812
15821
|
async getAllConfigValue(defaultValue, context, targetingKey) {
|
|
15813
15822
|
try {
|
|
15814
15823
|
const configData = await this.fetchConfigData();
|
|
@@ -15956,7 +15965,9 @@ class NativeResolver {
|
|
|
15956
15965
|
console.log(" queryData :", queryDataJson);
|
|
15957
15966
|
console.log(" mergeStrategy:", mergeStrategy);
|
|
15958
15967
|
console.log(" filterPrefixes:", filterPrefixes);
|
|
15959
|
-
console.log("
|
|
15968
|
+
console.log(" experiment:", experimentation?.experiments?.length);
|
|
15969
|
+
console.log(" experiment groups:", experimentation?.experiment_groups?.length);
|
|
15970
|
+
console.log(" targetingKey:", experimentation?.targetingKey);
|
|
15960
15971
|
if (!defaultConfigsJson ||
|
|
15961
15972
|
defaultConfigsJson === "null" ||
|
|
15962
15973
|
defaultConfigsJson === "undefined") {
|
|
@@ -16168,13 +16179,14 @@ class SuperpositionProvider {
|
|
|
16168
16179
|
constructor(config) {
|
|
16169
16180
|
this.config = config;
|
|
16170
16181
|
this.metadata = {
|
|
16171
|
-
name:
|
|
16172
|
-
slug:
|
|
16182
|
+
name: "SuperpositionProvider",
|
|
16183
|
+
slug: "superposition-provider",
|
|
16173
16184
|
};
|
|
16174
16185
|
this.events = new serverSdk.OpenFeatureEventEmitter();
|
|
16175
16186
|
this.hooks = [];
|
|
16176
16187
|
this.status = serverSdk.ProviderStatus.NOT_READY;
|
|
16177
16188
|
// Cache for processed contexts
|
|
16189
|
+
// TODO: verify if this is at all needed
|
|
16178
16190
|
this.processedContextCache = new WeakMap();
|
|
16179
16191
|
this.client = new ConfigurationClient({
|
|
16180
16192
|
endpoint: config.endpoint,
|
|
@@ -16191,14 +16203,22 @@ class SuperpositionProvider {
|
|
|
16191
16203
|
this.status = serverSdk.ProviderStatus.NOT_READY;
|
|
16192
16204
|
try {
|
|
16193
16205
|
await this.client.initialize();
|
|
16206
|
+
// TODO: find why is this needed?
|
|
16194
16207
|
await this.client.eval(context || {});
|
|
16195
16208
|
this.status = serverSdk.ProviderStatus.READY;
|
|
16196
|
-
this.events.emit(serverSdk.ProviderEvents.Ready, {
|
|
16209
|
+
this.events.emit(serverSdk.ProviderEvents.Ready, {
|
|
16210
|
+
message: "Provider ready",
|
|
16211
|
+
});
|
|
16197
16212
|
}
|
|
16198
16213
|
catch (error) {
|
|
16199
16214
|
this.status = serverSdk.ProviderStatus.ERROR;
|
|
16200
|
-
const message = error instanceof Error
|
|
16201
|
-
|
|
16215
|
+
const message = error instanceof Error
|
|
16216
|
+
? error.message
|
|
16217
|
+
: "Initialization failed";
|
|
16218
|
+
this.events.emit(serverSdk.ProviderEvents.Error, {
|
|
16219
|
+
message,
|
|
16220
|
+
errorCode: serverSdk.ErrorCode.PROVIDER_NOT_READY,
|
|
16221
|
+
});
|
|
16202
16222
|
throw error;
|
|
16203
16223
|
}
|
|
16204
16224
|
}
|
|
@@ -16213,7 +16233,7 @@ class SuperpositionProvider {
|
|
|
16213
16233
|
processedContext = this.filterContext(context);
|
|
16214
16234
|
this.processedContextCache.set(context, processedContext);
|
|
16215
16235
|
}
|
|
16216
|
-
const config = await this.client.eval(processedContext);
|
|
16236
|
+
const config = await this.client.eval(processedContext, undefined, context.targetingKey);
|
|
16217
16237
|
const value = getNestedValue(config, flagKey);
|
|
16218
16238
|
const converter = TYPE_CONVERTERS[type];
|
|
16219
16239
|
return converter(value, defaultValue);
|
|
@@ -16221,17 +16241,24 @@ class SuperpositionProvider {
|
|
|
16221
16241
|
filterContext(context) {
|
|
16222
16242
|
const filtered = {};
|
|
16223
16243
|
for (const [key, value] of Object.entries(context)) {
|
|
16224
|
-
if (key.startsWith(
|
|
16244
|
+
if (key.startsWith("__") ||
|
|
16245
|
+
key === "targetingKey" ||
|
|
16246
|
+
key === "timestamp") {
|
|
16225
16247
|
continue;
|
|
16226
16248
|
}
|
|
16227
16249
|
// Only include simple, serializable types
|
|
16228
|
-
if (typeof value ===
|
|
16250
|
+
if (typeof value === "string" ||
|
|
16251
|
+
typeof value === "number" ||
|
|
16252
|
+
typeof value === "boolean") {
|
|
16229
16253
|
filtered[key] = value;
|
|
16230
16254
|
}
|
|
16231
|
-
else if (typeof value ===
|
|
16255
|
+
else if (typeof value === "object" &&
|
|
16256
|
+
value !== null &&
|
|
16257
|
+
!Array.isArray(value)) {
|
|
16232
16258
|
try {
|
|
16233
16259
|
const serialized = JSON.stringify(value);
|
|
16234
|
-
if (serialized.length < 1000 &&
|
|
16260
|
+
if (serialized.length < 1000 &&
|
|
16261
|
+
Object.keys(value).length < 10) {
|
|
16235
16262
|
filtered[key] = value;
|
|
16236
16263
|
}
|
|
16237
16264
|
}
|
|
@@ -16244,62 +16271,76 @@ class SuperpositionProvider {
|
|
|
16244
16271
|
}
|
|
16245
16272
|
createResolver(type) {
|
|
16246
16273
|
return async (flagKey, defaultValue, context) => {
|
|
16247
|
-
if (this.status !== serverSdk.ProviderStatus.READY &&
|
|
16274
|
+
if (this.status !== serverSdk.ProviderStatus.READY &&
|
|
16275
|
+
this.status !== serverSdk.ProviderStatus.STALE) {
|
|
16248
16276
|
return {
|
|
16249
16277
|
value: defaultValue,
|
|
16250
|
-
reason:
|
|
16251
|
-
errorCode: this.status === serverSdk.ProviderStatus.FATAL
|
|
16252
|
-
|
|
16278
|
+
reason: "ERROR",
|
|
16279
|
+
errorCode: this.status === serverSdk.ProviderStatus.FATAL
|
|
16280
|
+
? serverSdk.ErrorCode.PROVIDER_FATAL
|
|
16281
|
+
: serverSdk.ErrorCode.PROVIDER_NOT_READY,
|
|
16282
|
+
errorMessage: `Provider status: ${this.status}`,
|
|
16253
16283
|
};
|
|
16254
16284
|
}
|
|
16255
16285
|
try {
|
|
16256
16286
|
const value = await this.evaluateFlag(flagKey, defaultValue, context, type);
|
|
16257
16287
|
return {
|
|
16258
16288
|
value,
|
|
16259
|
-
reason: this.status === serverSdk.ProviderStatus.STALE
|
|
16289
|
+
reason: this.status === serverSdk.ProviderStatus.STALE
|
|
16290
|
+
? "STALE"
|
|
16291
|
+
: "TARGETING_MATCH",
|
|
16260
16292
|
};
|
|
16261
16293
|
}
|
|
16262
16294
|
catch (error) {
|
|
16263
16295
|
return {
|
|
16264
16296
|
value: defaultValue,
|
|
16265
|
-
reason:
|
|
16297
|
+
reason: "ERROR",
|
|
16266
16298
|
errorCode: serverSdk.ErrorCode.GENERAL,
|
|
16267
|
-
errorMessage: error instanceof Error
|
|
16299
|
+
errorMessage: error instanceof Error
|
|
16300
|
+
? error.message
|
|
16301
|
+
: "Evaluation failed",
|
|
16268
16302
|
};
|
|
16269
16303
|
}
|
|
16270
16304
|
};
|
|
16271
16305
|
}
|
|
16272
16306
|
async resolveBooleanEvaluation(flagKey, defaultValue, context) {
|
|
16273
|
-
return this.createResolver(
|
|
16307
|
+
return this.createResolver("boolean")(flagKey, defaultValue, context);
|
|
16274
16308
|
}
|
|
16275
16309
|
async resolveStringEvaluation(flagKey, defaultValue, context) {
|
|
16276
|
-
return this.createResolver(
|
|
16310
|
+
return this.createResolver("string")(flagKey, defaultValue, context);
|
|
16277
16311
|
}
|
|
16278
16312
|
async resolveNumberEvaluation(flagKey, defaultValue, context) {
|
|
16279
|
-
return this.createResolver(
|
|
16313
|
+
return this.createResolver("number")(flagKey, defaultValue, context);
|
|
16280
16314
|
}
|
|
16281
16315
|
async resolveObjectEvaluation(flagKey, defaultValue, context, logger) {
|
|
16282
|
-
return this.createResolver(
|
|
16316
|
+
return this.createResolver("object")(flagKey, defaultValue, context);
|
|
16283
16317
|
}
|
|
16284
16318
|
async resolveAllConfigDetails(defaultValue, context) {
|
|
16285
|
-
if (this.status !== serverSdk.ProviderStatus.READY &&
|
|
16319
|
+
if (this.status !== serverSdk.ProviderStatus.READY &&
|
|
16320
|
+
this.status !== serverSdk.ProviderStatus.STALE) {
|
|
16286
16321
|
return defaultValue;
|
|
16287
16322
|
}
|
|
16288
16323
|
try {
|
|
16289
|
-
const processedContext = this.processedContextCache.get(context) ||
|
|
16324
|
+
const processedContext = this.processedContextCache.get(context) ||
|
|
16325
|
+
this.filterContext(context);
|
|
16290
16326
|
if (!this.processedContextCache.has(context)) {
|
|
16291
16327
|
this.processedContextCache.set(context, processedContext);
|
|
16292
16328
|
}
|
|
16293
16329
|
const targetingKey = context.targetingKey;
|
|
16330
|
+
// TODO: remove this function and use eval for getAllConfigValue as well
|
|
16294
16331
|
return await this.client.getAllConfigValue(defaultValue, processedContext, targetingKey);
|
|
16295
16332
|
}
|
|
16296
16333
|
catch (error) {
|
|
16297
|
-
console.error(
|
|
16334
|
+
console.error("Error resolving all config details:", error);
|
|
16298
16335
|
return defaultValue;
|
|
16299
16336
|
}
|
|
16300
16337
|
}
|
|
16301
|
-
getStatus() {
|
|
16302
|
-
|
|
16338
|
+
getStatus() {
|
|
16339
|
+
return this.status;
|
|
16340
|
+
}
|
|
16341
|
+
getConfigurationClient() {
|
|
16342
|
+
return this.client;
|
|
16343
|
+
}
|
|
16303
16344
|
}
|
|
16304
16345
|
|
|
16305
16346
|
function httpRequest(options) {
|