superposition-provider 0.93.0 → 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 +127 -88
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +127 -88
- 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
|
@@ -9337,13 +9337,9 @@ function requireAws_restJson1 () {
|
|
|
9337
9337
|
});
|
|
9338
9338
|
b.bp("/context/bulk-operations");
|
|
9339
9339
|
let body;
|
|
9340
|
-
|
|
9341
|
-
|
|
9342
|
-
}
|
|
9343
|
-
if (body === undefined) {
|
|
9344
|
-
body = {};
|
|
9345
|
-
}
|
|
9346
|
-
body = JSON.stringify(body);
|
|
9340
|
+
body = JSON.stringify((0, smithy_client_1.take)(input, {
|
|
9341
|
+
'operations': _ => se_BulkOperationList(_),
|
|
9342
|
+
}));
|
|
9347
9343
|
b.m("PUT")
|
|
9348
9344
|
.h(headers)
|
|
9349
9345
|
.b(body);
|
|
@@ -9381,12 +9377,13 @@ function requireAws_restJson1 () {
|
|
|
9381
9377
|
});
|
|
9382
9378
|
b.bp("/context");
|
|
9383
9379
|
let body;
|
|
9384
|
-
|
|
9385
|
-
|
|
9386
|
-
|
|
9387
|
-
|
|
9388
|
-
|
|
9389
|
-
}
|
|
9380
|
+
if (input.request !== undefined) {
|
|
9381
|
+
body = se_ContextPut(input.request);
|
|
9382
|
+
}
|
|
9383
|
+
if (body === undefined) {
|
|
9384
|
+
body = {};
|
|
9385
|
+
}
|
|
9386
|
+
body = JSON.stringify(body);
|
|
9390
9387
|
b.m("PUT")
|
|
9391
9388
|
.h(headers)
|
|
9392
9389
|
.b(body);
|
|
@@ -9906,6 +9903,7 @@ function requireAws_restJson1 () {
|
|
|
9906
9903
|
[_v]: [, input[_v]],
|
|
9907
9904
|
[_sr]: [() => input.show_reasoning !== void 0, () => (input[_sr].toString())],
|
|
9908
9905
|
[_ci]: [, input[_ci]],
|
|
9906
|
+
[_rr]: [() => input.resolve_remote !== void 0, () => (input[_rr].toString())],
|
|
9909
9907
|
});
|
|
9910
9908
|
let body;
|
|
9911
9909
|
body = JSON.stringify((0, smithy_client_1.take)(input, {
|
|
@@ -10283,11 +10281,13 @@ function requireAws_restJson1 () {
|
|
|
10283
10281
|
b.bp("/context/move/{id}");
|
|
10284
10282
|
b.p('id', () => input.id, '{id}', false);
|
|
10285
10283
|
let body;
|
|
10286
|
-
|
|
10287
|
-
|
|
10288
|
-
|
|
10289
|
-
|
|
10290
|
-
|
|
10284
|
+
if (input.request !== undefined) {
|
|
10285
|
+
body = se_ContextMove(input.request);
|
|
10286
|
+
}
|
|
10287
|
+
if (body === undefined) {
|
|
10288
|
+
body = {};
|
|
10289
|
+
}
|
|
10290
|
+
body = JSON.stringify(body);
|
|
10291
10291
|
b.m("PUT")
|
|
10292
10292
|
.h(headers)
|
|
10293
10293
|
.b(body);
|
|
@@ -10545,7 +10545,7 @@ function requireAws_restJson1 () {
|
|
|
10545
10545
|
body = {};
|
|
10546
10546
|
}
|
|
10547
10547
|
body = JSON.stringify(body);
|
|
10548
|
-
b.m("
|
|
10548
|
+
b.m("PATCH")
|
|
10549
10549
|
.h(headers)
|
|
10550
10550
|
.b(body);
|
|
10551
10551
|
return b.build();
|
|
@@ -10728,8 +10728,11 @@ function requireAws_restJson1 () {
|
|
|
10728
10728
|
const contents = (0, smithy_client_1.map)({
|
|
10729
10729
|
$metadata: deserializeMetadata(output),
|
|
10730
10730
|
});
|
|
10731
|
-
const data = (0, smithy_client_1.expectObject)(await (0, core_1.parseJsonBody)(output.body, context));
|
|
10732
|
-
|
|
10731
|
+
const data = (0, smithy_client_1.expectNonNull)(((0, smithy_client_1.expectObject)(await (0, core_1.parseJsonBody)(output.body, context))), "body");
|
|
10732
|
+
const doc = (0, smithy_client_1.take)(data, {
|
|
10733
|
+
'output': _ => de_BulkOperationOutList(_),
|
|
10734
|
+
});
|
|
10735
|
+
Object.assign(contents, doc);
|
|
10733
10736
|
return contents;
|
|
10734
10737
|
};
|
|
10735
10738
|
Aws_restJson1.de_BulkOperationCommand = de_BulkOperationCommand;
|
|
@@ -11043,7 +11046,7 @@ function requireAws_restJson1 () {
|
|
|
11043
11046
|
};
|
|
11044
11047
|
Aws_restJson1.de_CreateWorkspaceCommand = de_CreateWorkspaceCommand;
|
|
11045
11048
|
const de_DeleteContextCommand = async (output, context) => {
|
|
11046
|
-
if (output.statusCode !==
|
|
11049
|
+
if (output.statusCode !== 204 && output.statusCode >= 300) {
|
|
11047
11050
|
return de_CommandError(output, context);
|
|
11048
11051
|
}
|
|
11049
11052
|
const contents = (0, smithy_client_1.map)({
|
|
@@ -11054,7 +11057,7 @@ function requireAws_restJson1 () {
|
|
|
11054
11057
|
};
|
|
11055
11058
|
Aws_restJson1.de_DeleteContextCommand = de_DeleteContextCommand;
|
|
11056
11059
|
const de_DeleteDefaultConfigCommand = async (output, context) => {
|
|
11057
|
-
if (output.statusCode !==
|
|
11060
|
+
if (output.statusCode !== 204 && output.statusCode >= 300) {
|
|
11058
11061
|
return de_CommandError(output, context);
|
|
11059
11062
|
}
|
|
11060
11063
|
const contents = (0, smithy_client_1.map)({
|
|
@@ -11065,7 +11068,7 @@ function requireAws_restJson1 () {
|
|
|
11065
11068
|
};
|
|
11066
11069
|
Aws_restJson1.de_DeleteDefaultConfigCommand = de_DeleteDefaultConfigCommand;
|
|
11067
11070
|
const de_DeleteDimensionCommand = async (output, context) => {
|
|
11068
|
-
if (output.statusCode !==
|
|
11071
|
+
if (output.statusCode !== 204 && output.statusCode >= 300) {
|
|
11069
11072
|
return de_CommandError(output, context);
|
|
11070
11073
|
}
|
|
11071
11074
|
const contents = (0, smithy_client_1.map)({
|
|
@@ -11104,7 +11107,7 @@ function requireAws_restJson1 () {
|
|
|
11104
11107
|
};
|
|
11105
11108
|
Aws_restJson1.de_DeleteExperimentGroupCommand = de_DeleteExperimentGroupCommand;
|
|
11106
11109
|
const de_DeleteFunctionCommand = async (output, context) => {
|
|
11107
|
-
if (output.statusCode !==
|
|
11110
|
+
if (output.statusCode !== 204 && output.statusCode >= 300) {
|
|
11108
11111
|
return de_CommandError(output, context);
|
|
11109
11112
|
}
|
|
11110
11113
|
const contents = (0, smithy_client_1.map)({
|
|
@@ -11137,7 +11140,7 @@ function requireAws_restJson1 () {
|
|
|
11137
11140
|
};
|
|
11138
11141
|
Aws_restJson1.de_DeleteTypeTemplatesCommand = de_DeleteTypeTemplatesCommand;
|
|
11139
11142
|
const de_DeleteWebhookCommand = async (output, context) => {
|
|
11140
|
-
if (output.statusCode !==
|
|
11143
|
+
if (output.statusCode !== 204 && output.statusCode >= 300) {
|
|
11141
11144
|
return de_CommandError(output, context);
|
|
11142
11145
|
}
|
|
11143
11146
|
const contents = (0, smithy_client_1.map)({
|
|
@@ -11660,7 +11663,7 @@ function requireAws_restJson1 () {
|
|
|
11660
11663
|
});
|
|
11661
11664
|
const data = (0, smithy_client_1.expectNonNull)(((0, smithy_client_1.expectObject)(await (0, core_1.parseJsonBody)(output.body, context))), "body");
|
|
11662
11665
|
const doc = (0, smithy_client_1.take)(data, {
|
|
11663
|
-
'data': _ =>
|
|
11666
|
+
'data': _ => de_DimensionList(_),
|
|
11664
11667
|
'total_items': smithy_client_1.expectInt32,
|
|
11665
11668
|
'total_pages': smithy_client_1.expectInt32,
|
|
11666
11669
|
});
|
|
@@ -12377,11 +12380,6 @@ function requireAws_restJson1 () {
|
|
|
12377
12380
|
return se_ContextAction(entry);
|
|
12378
12381
|
});
|
|
12379
12382
|
};
|
|
12380
|
-
const se_BulkOperationReq = (input, context) => {
|
|
12381
|
-
return (0, smithy_client_1.take)(input, {
|
|
12382
|
-
'operations': _ => se_BulkOperationList(_),
|
|
12383
|
-
});
|
|
12384
|
-
};
|
|
12385
12383
|
const se_Condition = (input, context) => {
|
|
12386
12384
|
return Object.entries(input).reduce((acc, [key, value]) => {
|
|
12387
12385
|
if (value === null) {
|
|
@@ -12394,7 +12392,7 @@ function requireAws_restJson1 () {
|
|
|
12394
12392
|
const se_ContextAction = (input, context) => {
|
|
12395
12393
|
return models_0_1.ContextAction.visit(input, {
|
|
12396
12394
|
DELETE: value => ({ "DELETE": value }),
|
|
12397
|
-
MOVE: value => ({ "MOVE":
|
|
12395
|
+
MOVE: value => ({ "MOVE": se_ContextMoveBulkRequest(value) }),
|
|
12398
12396
|
PUT: value => ({ "PUT": se_ContextPut(value) }),
|
|
12399
12397
|
REPLACE: value => ({ "REPLACE": se_UpdateContextOverrideRequest(value) }),
|
|
12400
12398
|
_: (name, value) => ({ name: value })
|
|
@@ -12421,7 +12419,12 @@ function requireAws_restJson1 () {
|
|
|
12421
12419
|
'change_reason': [],
|
|
12422
12420
|
'context': _ => se_Condition(_),
|
|
12423
12421
|
'description': [],
|
|
12422
|
+
});
|
|
12423
|
+
};
|
|
12424
|
+
const se_ContextMoveBulkRequest = (input, context) => {
|
|
12425
|
+
return (0, smithy_client_1.take)(input, {
|
|
12424
12426
|
'id': [],
|
|
12427
|
+
'request': _ => se_ContextMove(_),
|
|
12425
12428
|
});
|
|
12426
12429
|
};
|
|
12427
12430
|
const se_ContextPut = (input, context) => {
|
|
@@ -12486,14 +12489,14 @@ function requireAws_restJson1 () {
|
|
|
12486
12489
|
'context_id': [],
|
|
12487
12490
|
'id': [],
|
|
12488
12491
|
'override_id': [],
|
|
12489
|
-
'overrides': _ =>
|
|
12492
|
+
'overrides': _ => se_Overrides(_),
|
|
12490
12493
|
'variant_type': [],
|
|
12491
12494
|
});
|
|
12492
12495
|
};
|
|
12493
12496
|
const se_VariantUpdateRequest = (input, context) => {
|
|
12494
12497
|
return (0, smithy_client_1.take)(input, {
|
|
12495
12498
|
'id': [],
|
|
12496
|
-
'overrides': _ =>
|
|
12499
|
+
'overrides': _ => se_Overrides(_),
|
|
12497
12500
|
});
|
|
12498
12501
|
};
|
|
12499
12502
|
const se_Document = (input, context) => {
|
|
@@ -12502,6 +12505,7 @@ function requireAws_restJson1 () {
|
|
|
12502
12505
|
const de_AuditLogFull = (output, context) => {
|
|
12503
12506
|
return (0, smithy_client_1.take)(output, {
|
|
12504
12507
|
'action': smithy_client_1.expectString,
|
|
12508
|
+
'id': smithy_client_1.expectString,
|
|
12505
12509
|
'new_data': (_) => de_Document(_),
|
|
12506
12510
|
'original_data': (_) => de_Document(_),
|
|
12507
12511
|
'query': smithy_client_1.expectString,
|
|
@@ -12525,11 +12529,6 @@ function requireAws_restJson1 () {
|
|
|
12525
12529
|
});
|
|
12526
12530
|
return retVal;
|
|
12527
12531
|
};
|
|
12528
|
-
const de_BulkOperationOut = (output, context) => {
|
|
12529
|
-
return (0, smithy_client_1.take)(output, {
|
|
12530
|
-
'output': (_) => de_BulkOperationOutList(_),
|
|
12531
|
-
});
|
|
12532
|
-
};
|
|
12533
12532
|
const de_BulkOperationOutList = (output, context) => {
|
|
12534
12533
|
const retVal = (output || []).filter((e) => e != null).map((entry) => {
|
|
12535
12534
|
return de_ContextActionOut((0, core_1.awsExpectUnion)(entry));
|
|
@@ -12596,7 +12595,7 @@ function requireAws_restJson1 () {
|
|
|
12596
12595
|
'weight': smithy_client_1.expectString,
|
|
12597
12596
|
});
|
|
12598
12597
|
};
|
|
12599
|
-
const
|
|
12598
|
+
const de_DefaultConfigResponse = (output, context) => {
|
|
12600
12599
|
return (0, smithy_client_1.take)(output, {
|
|
12601
12600
|
'autocomplete_function_name': smithy_client_1.expectString,
|
|
12602
12601
|
'change_reason': smithy_client_1.expectString,
|
|
@@ -12620,34 +12619,35 @@ function requireAws_restJson1 () {
|
|
|
12620
12619
|
return acc;
|
|
12621
12620
|
}, {});
|
|
12622
12621
|
};
|
|
12623
|
-
const
|
|
12622
|
+
const de_DimensionInfo = (output, context) => {
|
|
12624
12623
|
return (0, smithy_client_1.take)(output, {
|
|
12625
12624
|
'autocomplete_function_name': smithy_client_1.expectString,
|
|
12626
|
-
'change_reason': smithy_client_1.expectString,
|
|
12627
|
-
'created_at': (_) => (0, smithy_client_1.expectNonNull)((0, smithy_client_1.parseRfc3339DateTimeWithOffset)(_)),
|
|
12628
|
-
'created_by': smithy_client_1.expectString,
|
|
12629
12625
|
'dependency_graph': smithy_client_1._json,
|
|
12630
|
-
'description': smithy_client_1.expectString,
|
|
12631
|
-
'dimension': smithy_client_1.expectString,
|
|
12632
12626
|
'dimension_type': (_) => (0, smithy_client_1._json)((0, core_1.awsExpectUnion)(_)),
|
|
12633
|
-
'function_name': smithy_client_1.expectString,
|
|
12634
|
-
'last_modified_at': (_) => (0, smithy_client_1.expectNonNull)((0, smithy_client_1.parseRfc3339DateTimeWithOffset)(_)),
|
|
12635
|
-
'last_modified_by': smithy_client_1.expectString,
|
|
12636
|
-
'mandatory': smithy_client_1.expectBoolean,
|
|
12637
12627
|
'position': smithy_client_1.expectInt32,
|
|
12638
12628
|
'schema': (_) => de_Object(_),
|
|
12639
12629
|
});
|
|
12640
12630
|
};
|
|
12641
|
-
const
|
|
12631
|
+
const de_DimensionList = (output, context) => {
|
|
12642
12632
|
const retVal = (output || []).filter((e) => e != null).map((entry) => {
|
|
12643
|
-
return
|
|
12633
|
+
return de_DimensionResponse(entry);
|
|
12644
12634
|
});
|
|
12645
12635
|
return retVal;
|
|
12646
12636
|
};
|
|
12647
|
-
const
|
|
12637
|
+
const de_DimensionResponse = (output, context) => {
|
|
12648
12638
|
return (0, smithy_client_1.take)(output, {
|
|
12639
|
+
'autocomplete_function_name': smithy_client_1.expectString,
|
|
12640
|
+
'change_reason': smithy_client_1.expectString,
|
|
12641
|
+
'created_at': (_) => (0, smithy_client_1.expectNonNull)((0, smithy_client_1.parseRfc3339DateTimeWithOffset)(_)),
|
|
12642
|
+
'created_by': smithy_client_1.expectString,
|
|
12649
12643
|
'dependency_graph': smithy_client_1._json,
|
|
12644
|
+
'description': smithy_client_1.expectString,
|
|
12645
|
+
'dimension': smithy_client_1.expectString,
|
|
12650
12646
|
'dimension_type': (_) => (0, smithy_client_1._json)((0, core_1.awsExpectUnion)(_)),
|
|
12647
|
+
'function_name': smithy_client_1.expectString,
|
|
12648
|
+
'last_modified_at': (_) => (0, smithy_client_1.expectNonNull)((0, smithy_client_1.parseRfc3339DateTimeWithOffset)(_)),
|
|
12649
|
+
'last_modified_by': smithy_client_1.expectString,
|
|
12650
|
+
'mandatory': smithy_client_1.expectBoolean,
|
|
12651
12651
|
'position': smithy_client_1.expectInt32,
|
|
12652
12652
|
'schema': (_) => de_Object(_),
|
|
12653
12653
|
});
|
|
@@ -12738,7 +12738,7 @@ function requireAws_restJson1 () {
|
|
|
12738
12738
|
};
|
|
12739
12739
|
const de_ListDefaultConfigOut = (output, context) => {
|
|
12740
12740
|
const retVal = (output || []).filter((e) => e != null).map((entry) => {
|
|
12741
|
-
return
|
|
12741
|
+
return de_DefaultConfigResponse(entry);
|
|
12742
12742
|
});
|
|
12743
12743
|
return retVal;
|
|
12744
12744
|
};
|
|
@@ -12835,7 +12835,7 @@ function requireAws_restJson1 () {
|
|
|
12835
12835
|
'context_id': smithy_client_1.expectString,
|
|
12836
12836
|
'id': smithy_client_1.expectString,
|
|
12837
12837
|
'override_id': smithy_client_1.expectString,
|
|
12838
|
-
'overrides': (_) =>
|
|
12838
|
+
'overrides': (_) => de_Overrides(_),
|
|
12839
12839
|
'variant_type': smithy_client_1.expectString,
|
|
12840
12840
|
});
|
|
12841
12841
|
};
|
|
@@ -12938,6 +12938,7 @@ function requireAws_restJson1 () {
|
|
|
12938
12938
|
const _p = "prefix";
|
|
12939
12939
|
const _pa = "page";
|
|
12940
12940
|
const _pl = "plaintext";
|
|
12941
|
+
const _rr = "resolve_remote";
|
|
12941
12942
|
const _s = "status";
|
|
12942
12943
|
const _sb = "sort_by";
|
|
12943
12944
|
const _so = "sort_on";
|
|
@@ -15601,7 +15602,10 @@ class ExperimentationClient {
|
|
|
15601
15602
|
member_experiment_ids: exp_group.member_experiment_ids || [],
|
|
15602
15603
|
group_type: exp_group.group_type ||
|
|
15603
15604
|
superpositionSdk.GroupType.USER_CREATED,
|
|
15604
|
-
buckets: exp_group.buckets
|
|
15605
|
+
buckets: exp_group.buckets?.map((bucket) => ({
|
|
15606
|
+
variant_id: bucket.variant_id || "",
|
|
15607
|
+
experiment_id: bucket.experiment_id || "",
|
|
15608
|
+
})) || [],
|
|
15605
15609
|
});
|
|
15606
15610
|
}
|
|
15607
15611
|
return experimentGroups;
|
|
@@ -15746,10 +15750,10 @@ class ConfigurationClient {
|
|
|
15746
15750
|
console.error("Failed to refresh configuration. Will continue to use the last known good configuration.", error);
|
|
15747
15751
|
}
|
|
15748
15752
|
}, strategy.interval);
|
|
15749
|
-
|
|
15750
|
-
|
|
15751
|
-
|
|
15752
|
-
|
|
15753
|
+
}
|
|
15754
|
+
if (experimentationOptions) {
|
|
15755
|
+
this.experimentationOptions = experimentationOptions;
|
|
15756
|
+
this.experimentationClient = new ExperimentationClient(config, experimentationOptions);
|
|
15753
15757
|
}
|
|
15754
15758
|
this.smithyClient = new superpositionSdk.SuperpositionClient({
|
|
15755
15759
|
endpoint: this.config.endpoint,
|
|
@@ -15768,8 +15772,10 @@ class ConfigurationClient {
|
|
|
15768
15772
|
let experimentationArgs;
|
|
15769
15773
|
if (this.experimentationClient && targetingKey) {
|
|
15770
15774
|
const experiments = await this.experimentationClient.getExperiments();
|
|
15775
|
+
const experiment_groups = await this.experimentationClient.getExperimentGroups();
|
|
15771
15776
|
experimentationArgs = {
|
|
15772
15777
|
experiments,
|
|
15778
|
+
experiment_groups,
|
|
15773
15779
|
targeting_key: targetingKey,
|
|
15774
15780
|
};
|
|
15775
15781
|
}
|
|
@@ -15811,6 +15817,7 @@ class ConfigurationClient {
|
|
|
15811
15817
|
}
|
|
15812
15818
|
}
|
|
15813
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
|
|
15814
15821
|
async getAllConfigValue(defaultValue, context, targetingKey) {
|
|
15815
15822
|
try {
|
|
15816
15823
|
const configData = await this.fetchConfigData();
|
|
@@ -15958,7 +15965,9 @@ class NativeResolver {
|
|
|
15958
15965
|
console.log(" queryData :", queryDataJson);
|
|
15959
15966
|
console.log(" mergeStrategy:", mergeStrategy);
|
|
15960
15967
|
console.log(" filterPrefixes:", filterPrefixes);
|
|
15961
|
-
console.log("
|
|
15968
|
+
console.log(" experiment:", experimentation?.experiments?.length);
|
|
15969
|
+
console.log(" experiment groups:", experimentation?.experiment_groups?.length);
|
|
15970
|
+
console.log(" targetingKey:", experimentation?.targetingKey);
|
|
15962
15971
|
if (!defaultConfigsJson ||
|
|
15963
15972
|
defaultConfigsJson === "null" ||
|
|
15964
15973
|
defaultConfigsJson === "undefined") {
|
|
@@ -16170,13 +16179,14 @@ class SuperpositionProvider {
|
|
|
16170
16179
|
constructor(config) {
|
|
16171
16180
|
this.config = config;
|
|
16172
16181
|
this.metadata = {
|
|
16173
|
-
name:
|
|
16174
|
-
slug:
|
|
16182
|
+
name: "SuperpositionProvider",
|
|
16183
|
+
slug: "superposition-provider",
|
|
16175
16184
|
};
|
|
16176
16185
|
this.events = new serverSdk.OpenFeatureEventEmitter();
|
|
16177
16186
|
this.hooks = [];
|
|
16178
16187
|
this.status = serverSdk.ProviderStatus.NOT_READY;
|
|
16179
16188
|
// Cache for processed contexts
|
|
16189
|
+
// TODO: verify if this is at all needed
|
|
16180
16190
|
this.processedContextCache = new WeakMap();
|
|
16181
16191
|
this.client = new ConfigurationClient({
|
|
16182
16192
|
endpoint: config.endpoint,
|
|
@@ -16193,14 +16203,22 @@ class SuperpositionProvider {
|
|
|
16193
16203
|
this.status = serverSdk.ProviderStatus.NOT_READY;
|
|
16194
16204
|
try {
|
|
16195
16205
|
await this.client.initialize();
|
|
16206
|
+
// TODO: find why is this needed?
|
|
16196
16207
|
await this.client.eval(context || {});
|
|
16197
16208
|
this.status = serverSdk.ProviderStatus.READY;
|
|
16198
|
-
this.events.emit(serverSdk.ProviderEvents.Ready, {
|
|
16209
|
+
this.events.emit(serverSdk.ProviderEvents.Ready, {
|
|
16210
|
+
message: "Provider ready",
|
|
16211
|
+
});
|
|
16199
16212
|
}
|
|
16200
16213
|
catch (error) {
|
|
16201
16214
|
this.status = serverSdk.ProviderStatus.ERROR;
|
|
16202
|
-
const message = error instanceof Error
|
|
16203
|
-
|
|
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
|
+
});
|
|
16204
16222
|
throw error;
|
|
16205
16223
|
}
|
|
16206
16224
|
}
|
|
@@ -16215,7 +16233,7 @@ class SuperpositionProvider {
|
|
|
16215
16233
|
processedContext = this.filterContext(context);
|
|
16216
16234
|
this.processedContextCache.set(context, processedContext);
|
|
16217
16235
|
}
|
|
16218
|
-
const config = await this.client.eval(processedContext);
|
|
16236
|
+
const config = await this.client.eval(processedContext, undefined, context.targetingKey);
|
|
16219
16237
|
const value = getNestedValue(config, flagKey);
|
|
16220
16238
|
const converter = TYPE_CONVERTERS[type];
|
|
16221
16239
|
return converter(value, defaultValue);
|
|
@@ -16223,17 +16241,24 @@ class SuperpositionProvider {
|
|
|
16223
16241
|
filterContext(context) {
|
|
16224
16242
|
const filtered = {};
|
|
16225
16243
|
for (const [key, value] of Object.entries(context)) {
|
|
16226
|
-
if (key.startsWith(
|
|
16244
|
+
if (key.startsWith("__") ||
|
|
16245
|
+
key === "targetingKey" ||
|
|
16246
|
+
key === "timestamp") {
|
|
16227
16247
|
continue;
|
|
16228
16248
|
}
|
|
16229
16249
|
// Only include simple, serializable types
|
|
16230
|
-
if (typeof value ===
|
|
16250
|
+
if (typeof value === "string" ||
|
|
16251
|
+
typeof value === "number" ||
|
|
16252
|
+
typeof value === "boolean") {
|
|
16231
16253
|
filtered[key] = value;
|
|
16232
16254
|
}
|
|
16233
|
-
else if (typeof value ===
|
|
16255
|
+
else if (typeof value === "object" &&
|
|
16256
|
+
value !== null &&
|
|
16257
|
+
!Array.isArray(value)) {
|
|
16234
16258
|
try {
|
|
16235
16259
|
const serialized = JSON.stringify(value);
|
|
16236
|
-
if (serialized.length < 1000 &&
|
|
16260
|
+
if (serialized.length < 1000 &&
|
|
16261
|
+
Object.keys(value).length < 10) {
|
|
16237
16262
|
filtered[key] = value;
|
|
16238
16263
|
}
|
|
16239
16264
|
}
|
|
@@ -16246,62 +16271,76 @@ class SuperpositionProvider {
|
|
|
16246
16271
|
}
|
|
16247
16272
|
createResolver(type) {
|
|
16248
16273
|
return async (flagKey, defaultValue, context) => {
|
|
16249
|
-
if (this.status !== serverSdk.ProviderStatus.READY &&
|
|
16274
|
+
if (this.status !== serverSdk.ProviderStatus.READY &&
|
|
16275
|
+
this.status !== serverSdk.ProviderStatus.STALE) {
|
|
16250
16276
|
return {
|
|
16251
16277
|
value: defaultValue,
|
|
16252
|
-
reason:
|
|
16253
|
-
errorCode: this.status === serverSdk.ProviderStatus.FATAL
|
|
16254
|
-
|
|
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}`,
|
|
16255
16283
|
};
|
|
16256
16284
|
}
|
|
16257
16285
|
try {
|
|
16258
16286
|
const value = await this.evaluateFlag(flagKey, defaultValue, context, type);
|
|
16259
16287
|
return {
|
|
16260
16288
|
value,
|
|
16261
|
-
reason: this.status === serverSdk.ProviderStatus.STALE
|
|
16289
|
+
reason: this.status === serverSdk.ProviderStatus.STALE
|
|
16290
|
+
? "STALE"
|
|
16291
|
+
: "TARGETING_MATCH",
|
|
16262
16292
|
};
|
|
16263
16293
|
}
|
|
16264
16294
|
catch (error) {
|
|
16265
16295
|
return {
|
|
16266
16296
|
value: defaultValue,
|
|
16267
|
-
reason:
|
|
16297
|
+
reason: "ERROR",
|
|
16268
16298
|
errorCode: serverSdk.ErrorCode.GENERAL,
|
|
16269
|
-
errorMessage: error instanceof Error
|
|
16299
|
+
errorMessage: error instanceof Error
|
|
16300
|
+
? error.message
|
|
16301
|
+
: "Evaluation failed",
|
|
16270
16302
|
};
|
|
16271
16303
|
}
|
|
16272
16304
|
};
|
|
16273
16305
|
}
|
|
16274
16306
|
async resolveBooleanEvaluation(flagKey, defaultValue, context) {
|
|
16275
|
-
return this.createResolver(
|
|
16307
|
+
return this.createResolver("boolean")(flagKey, defaultValue, context);
|
|
16276
16308
|
}
|
|
16277
16309
|
async resolveStringEvaluation(flagKey, defaultValue, context) {
|
|
16278
|
-
return this.createResolver(
|
|
16310
|
+
return this.createResolver("string")(flagKey, defaultValue, context);
|
|
16279
16311
|
}
|
|
16280
16312
|
async resolveNumberEvaluation(flagKey, defaultValue, context) {
|
|
16281
|
-
return this.createResolver(
|
|
16313
|
+
return this.createResolver("number")(flagKey, defaultValue, context);
|
|
16282
16314
|
}
|
|
16283
16315
|
async resolveObjectEvaluation(flagKey, defaultValue, context, logger) {
|
|
16284
|
-
return this.createResolver(
|
|
16316
|
+
return this.createResolver("object")(flagKey, defaultValue, context);
|
|
16285
16317
|
}
|
|
16286
16318
|
async resolveAllConfigDetails(defaultValue, context) {
|
|
16287
|
-
if (this.status !== serverSdk.ProviderStatus.READY &&
|
|
16319
|
+
if (this.status !== serverSdk.ProviderStatus.READY &&
|
|
16320
|
+
this.status !== serverSdk.ProviderStatus.STALE) {
|
|
16288
16321
|
return defaultValue;
|
|
16289
16322
|
}
|
|
16290
16323
|
try {
|
|
16291
|
-
const processedContext = this.processedContextCache.get(context) ||
|
|
16324
|
+
const processedContext = this.processedContextCache.get(context) ||
|
|
16325
|
+
this.filterContext(context);
|
|
16292
16326
|
if (!this.processedContextCache.has(context)) {
|
|
16293
16327
|
this.processedContextCache.set(context, processedContext);
|
|
16294
16328
|
}
|
|
16295
16329
|
const targetingKey = context.targetingKey;
|
|
16330
|
+
// TODO: remove this function and use eval for getAllConfigValue as well
|
|
16296
16331
|
return await this.client.getAllConfigValue(defaultValue, processedContext, targetingKey);
|
|
16297
16332
|
}
|
|
16298
16333
|
catch (error) {
|
|
16299
|
-
console.error(
|
|
16334
|
+
console.error("Error resolving all config details:", error);
|
|
16300
16335
|
return defaultValue;
|
|
16301
16336
|
}
|
|
16302
16337
|
}
|
|
16303
|
-
getStatus() {
|
|
16304
|
-
|
|
16338
|
+
getStatus() {
|
|
16339
|
+
return this.status;
|
|
16340
|
+
}
|
|
16341
|
+
getConfigurationClient() {
|
|
16342
|
+
return this.client;
|
|
16343
|
+
}
|
|
16305
16344
|
}
|
|
16306
16345
|
|
|
16307
16346
|
function httpRequest(options) {
|