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.
@@ -1,4 +1,4 @@
1
- import { GroupType, Bucket, VariantType } from "superposition-sdk";
1
+ import { GroupType, VariantType } from "superposition-sdk";
2
2
  import { SuperpositionOptions, ExperimentationOptions } from "./types";
3
3
  export interface Variant {
4
4
  id: string;
@@ -13,6 +13,10 @@ export interface Experiment {
13
13
  variants: Variant[];
14
14
  traffic_percentage: number;
15
15
  }
16
+ export interface Bucket {
17
+ variant_id: string;
18
+ experiment_id: string;
19
+ }
16
20
  export interface ExperimentGroup {
17
21
  id: string;
18
22
  context: Record<string, string>;
package/dist/index.esm.js CHANGED
@@ -9334,13 +9334,9 @@ function requireAws_restJson1 () {
9334
9334
  });
9335
9335
  b.bp("/context/bulk-operations");
9336
9336
  let body;
9337
- if (input.bulk_operation !== undefined) {
9338
- body = se_BulkOperationReq(input.bulk_operation);
9339
- }
9340
- if (body === undefined) {
9341
- body = {};
9342
- }
9343
- body = JSON.stringify(body);
9337
+ body = JSON.stringify((0, smithy_client_1.take)(input, {
9338
+ 'operations': _ => se_BulkOperationList(_),
9339
+ }));
9344
9340
  b.m("PUT")
9345
9341
  .h(headers)
9346
9342
  .b(body);
@@ -9378,12 +9374,13 @@ function requireAws_restJson1 () {
9378
9374
  });
9379
9375
  b.bp("/context");
9380
9376
  let body;
9381
- body = JSON.stringify((0, smithy_client_1.take)(input, {
9382
- 'change_reason': [],
9383
- 'context': _ => se_Condition(_),
9384
- 'description': [],
9385
- 'override': _ => se_Overrides(_),
9386
- }));
9377
+ if (input.request !== undefined) {
9378
+ body = se_ContextPut(input.request);
9379
+ }
9380
+ if (body === undefined) {
9381
+ body = {};
9382
+ }
9383
+ body = JSON.stringify(body);
9387
9384
  b.m("PUT")
9388
9385
  .h(headers)
9389
9386
  .b(body);
@@ -9903,6 +9900,7 @@ function requireAws_restJson1 () {
9903
9900
  [_v]: [, input[_v]],
9904
9901
  [_sr]: [() => input.show_reasoning !== void 0, () => (input[_sr].toString())],
9905
9902
  [_ci]: [, input[_ci]],
9903
+ [_rr]: [() => input.resolve_remote !== void 0, () => (input[_rr].toString())],
9906
9904
  });
9907
9905
  let body;
9908
9906
  body = JSON.stringify((0, smithy_client_1.take)(input, {
@@ -10280,11 +10278,13 @@ function requireAws_restJson1 () {
10280
10278
  b.bp("/context/move/{id}");
10281
10279
  b.p('id', () => input.id, '{id}', false);
10282
10280
  let body;
10283
- body = JSON.stringify((0, smithy_client_1.take)(input, {
10284
- 'change_reason': [],
10285
- 'context': _ => se_Condition(_),
10286
- 'description': [],
10287
- }));
10281
+ if (input.request !== undefined) {
10282
+ body = se_ContextMove(input.request);
10283
+ }
10284
+ if (body === undefined) {
10285
+ body = {};
10286
+ }
10287
+ body = JSON.stringify(body);
10288
10288
  b.m("PUT")
10289
10289
  .h(headers)
10290
10290
  .b(body);
@@ -10542,7 +10542,7 @@ function requireAws_restJson1 () {
10542
10542
  body = {};
10543
10543
  }
10544
10544
  body = JSON.stringify(body);
10545
- b.m("PUT")
10545
+ b.m("PATCH")
10546
10546
  .h(headers)
10547
10547
  .b(body);
10548
10548
  return b.build();
@@ -10725,8 +10725,11 @@ function requireAws_restJson1 () {
10725
10725
  const contents = (0, smithy_client_1.map)({
10726
10726
  $metadata: deserializeMetadata(output),
10727
10727
  });
10728
- const data = (0, smithy_client_1.expectObject)(await (0, core_1.parseJsonBody)(output.body, context));
10729
- contents.bulk_operation_output = de_BulkOperationOut(data);
10728
+ const data = (0, smithy_client_1.expectNonNull)(((0, smithy_client_1.expectObject)(await (0, core_1.parseJsonBody)(output.body, context))), "body");
10729
+ const doc = (0, smithy_client_1.take)(data, {
10730
+ 'output': _ => de_BulkOperationOutList(_),
10731
+ });
10732
+ Object.assign(contents, doc);
10730
10733
  return contents;
10731
10734
  };
10732
10735
  Aws_restJson1.de_BulkOperationCommand = de_BulkOperationCommand;
@@ -11040,7 +11043,7 @@ function requireAws_restJson1 () {
11040
11043
  };
11041
11044
  Aws_restJson1.de_CreateWorkspaceCommand = de_CreateWorkspaceCommand;
11042
11045
  const de_DeleteContextCommand = async (output, context) => {
11043
- if (output.statusCode !== 201 && output.statusCode >= 300) {
11046
+ if (output.statusCode !== 204 && output.statusCode >= 300) {
11044
11047
  return de_CommandError(output, context);
11045
11048
  }
11046
11049
  const contents = (0, smithy_client_1.map)({
@@ -11051,7 +11054,7 @@ function requireAws_restJson1 () {
11051
11054
  };
11052
11055
  Aws_restJson1.de_DeleteContextCommand = de_DeleteContextCommand;
11053
11056
  const de_DeleteDefaultConfigCommand = async (output, context) => {
11054
- if (output.statusCode !== 201 && output.statusCode >= 300) {
11057
+ if (output.statusCode !== 204 && output.statusCode >= 300) {
11055
11058
  return de_CommandError(output, context);
11056
11059
  }
11057
11060
  const contents = (0, smithy_client_1.map)({
@@ -11062,7 +11065,7 @@ function requireAws_restJson1 () {
11062
11065
  };
11063
11066
  Aws_restJson1.de_DeleteDefaultConfigCommand = de_DeleteDefaultConfigCommand;
11064
11067
  const de_DeleteDimensionCommand = async (output, context) => {
11065
- if (output.statusCode !== 201 && output.statusCode >= 300) {
11068
+ if (output.statusCode !== 204 && output.statusCode >= 300) {
11066
11069
  return de_CommandError(output, context);
11067
11070
  }
11068
11071
  const contents = (0, smithy_client_1.map)({
@@ -11101,7 +11104,7 @@ function requireAws_restJson1 () {
11101
11104
  };
11102
11105
  Aws_restJson1.de_DeleteExperimentGroupCommand = de_DeleteExperimentGroupCommand;
11103
11106
  const de_DeleteFunctionCommand = async (output, context) => {
11104
- if (output.statusCode !== 200 && output.statusCode >= 300) {
11107
+ if (output.statusCode !== 204 && output.statusCode >= 300) {
11105
11108
  return de_CommandError(output, context);
11106
11109
  }
11107
11110
  const contents = (0, smithy_client_1.map)({
@@ -11134,7 +11137,7 @@ function requireAws_restJson1 () {
11134
11137
  };
11135
11138
  Aws_restJson1.de_DeleteTypeTemplatesCommand = de_DeleteTypeTemplatesCommand;
11136
11139
  const de_DeleteWebhookCommand = async (output, context) => {
11137
- if (output.statusCode !== 201 && output.statusCode >= 300) {
11140
+ if (output.statusCode !== 204 && output.statusCode >= 300) {
11138
11141
  return de_CommandError(output, context);
11139
11142
  }
11140
11143
  const contents = (0, smithy_client_1.map)({
@@ -11657,7 +11660,7 @@ function requireAws_restJson1 () {
11657
11660
  });
11658
11661
  const data = (0, smithy_client_1.expectNonNull)(((0, smithy_client_1.expectObject)(await (0, core_1.parseJsonBody)(output.body, context))), "body");
11659
11662
  const doc = (0, smithy_client_1.take)(data, {
11660
- 'data': _ => de_DimensionExtList(_),
11663
+ 'data': _ => de_DimensionList(_),
11661
11664
  'total_items': smithy_client_1.expectInt32,
11662
11665
  'total_pages': smithy_client_1.expectInt32,
11663
11666
  });
@@ -12374,11 +12377,6 @@ function requireAws_restJson1 () {
12374
12377
  return se_ContextAction(entry);
12375
12378
  });
12376
12379
  };
12377
- const se_BulkOperationReq = (input, context) => {
12378
- return (0, smithy_client_1.take)(input, {
12379
- 'operations': _ => se_BulkOperationList(_),
12380
- });
12381
- };
12382
12380
  const se_Condition = (input, context) => {
12383
12381
  return Object.entries(input).reduce((acc, [key, value]) => {
12384
12382
  if (value === null) {
@@ -12391,7 +12389,7 @@ function requireAws_restJson1 () {
12391
12389
  const se_ContextAction = (input, context) => {
12392
12390
  return models_0_1.ContextAction.visit(input, {
12393
12391
  DELETE: value => ({ "DELETE": value }),
12394
- MOVE: value => ({ "MOVE": se_ContextMove(value) }),
12392
+ MOVE: value => ({ "MOVE": se_ContextMoveBulkRequest(value) }),
12395
12393
  PUT: value => ({ "PUT": se_ContextPut(value) }),
12396
12394
  REPLACE: value => ({ "REPLACE": se_UpdateContextOverrideRequest(value) }),
12397
12395
  _: (name, value) => ({ name: value })
@@ -12418,7 +12416,12 @@ function requireAws_restJson1 () {
12418
12416
  'change_reason': [],
12419
12417
  'context': _ => se_Condition(_),
12420
12418
  'description': [],
12419
+ });
12420
+ };
12421
+ const se_ContextMoveBulkRequest = (input, context) => {
12422
+ return (0, smithy_client_1.take)(input, {
12421
12423
  'id': [],
12424
+ 'request': _ => se_ContextMove(_),
12422
12425
  });
12423
12426
  };
12424
12427
  const se_ContextPut = (input, context) => {
@@ -12483,14 +12486,14 @@ function requireAws_restJson1 () {
12483
12486
  'context_id': [],
12484
12487
  'id': [],
12485
12488
  'override_id': [],
12486
- 'overrides': _ => se_Document(_),
12489
+ 'overrides': _ => se_Overrides(_),
12487
12490
  'variant_type': [],
12488
12491
  });
12489
12492
  };
12490
12493
  const se_VariantUpdateRequest = (input, context) => {
12491
12494
  return (0, smithy_client_1.take)(input, {
12492
12495
  'id': [],
12493
- 'overrides': _ => se_Document(_),
12496
+ 'overrides': _ => se_Overrides(_),
12494
12497
  });
12495
12498
  };
12496
12499
  const se_Document = (input, context) => {
@@ -12499,6 +12502,7 @@ function requireAws_restJson1 () {
12499
12502
  const de_AuditLogFull = (output, context) => {
12500
12503
  return (0, smithy_client_1.take)(output, {
12501
12504
  'action': smithy_client_1.expectString,
12505
+ 'id': smithy_client_1.expectString,
12502
12506
  'new_data': (_) => de_Document(_),
12503
12507
  'original_data': (_) => de_Document(_),
12504
12508
  'query': smithy_client_1.expectString,
@@ -12522,11 +12526,6 @@ function requireAws_restJson1 () {
12522
12526
  });
12523
12527
  return retVal;
12524
12528
  };
12525
- const de_BulkOperationOut = (output, context) => {
12526
- return (0, smithy_client_1.take)(output, {
12527
- 'output': (_) => de_BulkOperationOutList(_),
12528
- });
12529
- };
12530
12529
  const de_BulkOperationOutList = (output, context) => {
12531
12530
  const retVal = (output || []).filter((e) => e != null).map((entry) => {
12532
12531
  return de_ContextActionOut((0, core_1.awsExpectUnion)(entry));
@@ -12593,7 +12592,7 @@ function requireAws_restJson1 () {
12593
12592
  'weight': smithy_client_1.expectString,
12594
12593
  });
12595
12594
  };
12596
- const de_DefaultConfigFull = (output, context) => {
12595
+ const de_DefaultConfigResponse = (output, context) => {
12597
12596
  return (0, smithy_client_1.take)(output, {
12598
12597
  'autocomplete_function_name': smithy_client_1.expectString,
12599
12598
  'change_reason': smithy_client_1.expectString,
@@ -12617,34 +12616,35 @@ function requireAws_restJson1 () {
12617
12616
  return acc;
12618
12617
  }, {});
12619
12618
  };
12620
- const de_DimensionExt = (output, context) => {
12619
+ const de_DimensionInfo = (output, context) => {
12621
12620
  return (0, smithy_client_1.take)(output, {
12622
12621
  'autocomplete_function_name': smithy_client_1.expectString,
12623
- 'change_reason': smithy_client_1.expectString,
12624
- 'created_at': (_) => (0, smithy_client_1.expectNonNull)((0, smithy_client_1.parseRfc3339DateTimeWithOffset)(_)),
12625
- 'created_by': smithy_client_1.expectString,
12626
12622
  'dependency_graph': smithy_client_1._json,
12627
- 'description': smithy_client_1.expectString,
12628
- 'dimension': smithy_client_1.expectString,
12629
12623
  'dimension_type': (_) => (0, smithy_client_1._json)((0, core_1.awsExpectUnion)(_)),
12630
- 'function_name': smithy_client_1.expectString,
12631
- 'last_modified_at': (_) => (0, smithy_client_1.expectNonNull)((0, smithy_client_1.parseRfc3339DateTimeWithOffset)(_)),
12632
- 'last_modified_by': smithy_client_1.expectString,
12633
- 'mandatory': smithy_client_1.expectBoolean,
12634
12624
  'position': smithy_client_1.expectInt32,
12635
12625
  'schema': (_) => de_Object(_),
12636
12626
  });
12637
12627
  };
12638
- const de_DimensionExtList = (output, context) => {
12628
+ const de_DimensionList = (output, context) => {
12639
12629
  const retVal = (output || []).filter((e) => e != null).map((entry) => {
12640
- return de_DimensionExt(entry);
12630
+ return de_DimensionResponse(entry);
12641
12631
  });
12642
12632
  return retVal;
12643
12633
  };
12644
- const de_DimensionInfo = (output, context) => {
12634
+ const de_DimensionResponse = (output, context) => {
12645
12635
  return (0, smithy_client_1.take)(output, {
12636
+ 'autocomplete_function_name': smithy_client_1.expectString,
12637
+ 'change_reason': smithy_client_1.expectString,
12638
+ 'created_at': (_) => (0, smithy_client_1.expectNonNull)((0, smithy_client_1.parseRfc3339DateTimeWithOffset)(_)),
12639
+ 'created_by': smithy_client_1.expectString,
12646
12640
  'dependency_graph': smithy_client_1._json,
12641
+ 'description': smithy_client_1.expectString,
12642
+ 'dimension': smithy_client_1.expectString,
12647
12643
  'dimension_type': (_) => (0, smithy_client_1._json)((0, core_1.awsExpectUnion)(_)),
12644
+ 'function_name': smithy_client_1.expectString,
12645
+ 'last_modified_at': (_) => (0, smithy_client_1.expectNonNull)((0, smithy_client_1.parseRfc3339DateTimeWithOffset)(_)),
12646
+ 'last_modified_by': smithy_client_1.expectString,
12647
+ 'mandatory': smithy_client_1.expectBoolean,
12648
12648
  'position': smithy_client_1.expectInt32,
12649
12649
  'schema': (_) => de_Object(_),
12650
12650
  });
@@ -12735,7 +12735,7 @@ function requireAws_restJson1 () {
12735
12735
  };
12736
12736
  const de_ListDefaultConfigOut = (output, context) => {
12737
12737
  const retVal = (output || []).filter((e) => e != null).map((entry) => {
12738
- return de_DefaultConfigFull(entry);
12738
+ return de_DefaultConfigResponse(entry);
12739
12739
  });
12740
12740
  return retVal;
12741
12741
  };
@@ -12832,7 +12832,7 @@ function requireAws_restJson1 () {
12832
12832
  'context_id': smithy_client_1.expectString,
12833
12833
  'id': smithy_client_1.expectString,
12834
12834
  'override_id': smithy_client_1.expectString,
12835
- 'overrides': (_) => de_Document(_),
12835
+ 'overrides': (_) => de_Overrides(_),
12836
12836
  'variant_type': smithy_client_1.expectString,
12837
12837
  });
12838
12838
  };
@@ -12935,6 +12935,7 @@ function requireAws_restJson1 () {
12935
12935
  const _p = "prefix";
12936
12936
  const _pa = "page";
12937
12937
  const _pl = "plaintext";
12938
+ const _rr = "resolve_remote";
12938
12939
  const _s = "status";
12939
12940
  const _sb = "sort_by";
12940
12941
  const _so = "sort_on";
@@ -15598,7 +15599,10 @@ class ExperimentationClient {
15598
15599
  member_experiment_ids: exp_group.member_experiment_ids || [],
15599
15600
  group_type: exp_group.group_type ||
15600
15601
  superpositionSdk.GroupType.USER_CREATED,
15601
- buckets: exp_group.buckets || [],
15602
+ buckets: exp_group.buckets?.map((bucket) => ({
15603
+ variant_id: bucket.variant_id || "",
15604
+ experiment_id: bucket.experiment_id || "",
15605
+ })) || [],
15602
15606
  });
15603
15607
  }
15604
15608
  return experimentGroups;
@@ -15743,10 +15747,10 @@ class ConfigurationClient {
15743
15747
  console.error("Failed to refresh configuration. Will continue to use the last known good configuration.", error);
15744
15748
  }
15745
15749
  }, strategy.interval);
15746
- if (experimentationOptions) {
15747
- this.experimentationOptions = experimentationOptions;
15748
- this.experimentationClient = new ExperimentationClient(config, experimentationOptions);
15749
- }
15750
+ }
15751
+ if (experimentationOptions) {
15752
+ this.experimentationOptions = experimentationOptions;
15753
+ this.experimentationClient = new ExperimentationClient(config, experimentationOptions);
15750
15754
  }
15751
15755
  this.smithyClient = new superpositionSdk.SuperpositionClient({
15752
15756
  endpoint: this.config.endpoint,
@@ -15765,8 +15769,10 @@ class ConfigurationClient {
15765
15769
  let experimentationArgs;
15766
15770
  if (this.experimentationClient && targetingKey) {
15767
15771
  const experiments = await this.experimentationClient.getExperiments();
15772
+ const experiment_groups = await this.experimentationClient.getExperimentGroups();
15768
15773
  experimentationArgs = {
15769
15774
  experiments,
15775
+ experiment_groups,
15770
15776
  targeting_key: targetingKey,
15771
15777
  };
15772
15778
  }
@@ -15808,6 +15814,7 @@ class ConfigurationClient {
15808
15814
  }
15809
15815
  }
15810
15816
  // TODO: defaultValue is taken but not used. Should it be used as a fallback?
15817
+ // TODO: Remove this function all together and use eval for getAllConfigValue as well
15811
15818
  async getAllConfigValue(defaultValue, context, targetingKey) {
15812
15819
  try {
15813
15820
  const configData = await this.fetchConfigData();
@@ -15955,7 +15962,9 @@ class NativeResolver {
15955
15962
  console.log(" queryData :", queryDataJson);
15956
15963
  console.log(" mergeStrategy:", mergeStrategy);
15957
15964
  console.log(" filterPrefixes:", filterPrefixes);
15958
- console.log(" experimentation:", experimentationJson);
15965
+ console.log(" experiment:", experimentation?.experiments?.length);
15966
+ console.log(" experiment groups:", experimentation?.experiment_groups?.length);
15967
+ console.log(" targetingKey:", experimentation?.targetingKey);
15959
15968
  if (!defaultConfigsJson ||
15960
15969
  defaultConfigsJson === "null" ||
15961
15970
  defaultConfigsJson === "undefined") {
@@ -16167,13 +16176,14 @@ class SuperpositionProvider {
16167
16176
  constructor(config) {
16168
16177
  this.config = config;
16169
16178
  this.metadata = {
16170
- name: 'SuperpositionProvider',
16171
- slug: 'superposition-provider'
16179
+ name: "SuperpositionProvider",
16180
+ slug: "superposition-provider",
16172
16181
  };
16173
16182
  this.events = new OpenFeatureEventEmitter();
16174
16183
  this.hooks = [];
16175
16184
  this.status = ProviderStatus.NOT_READY;
16176
16185
  // Cache for processed contexts
16186
+ // TODO: verify if this is at all needed
16177
16187
  this.processedContextCache = new WeakMap();
16178
16188
  this.client = new ConfigurationClient({
16179
16189
  endpoint: config.endpoint,
@@ -16190,14 +16200,22 @@ class SuperpositionProvider {
16190
16200
  this.status = ProviderStatus.NOT_READY;
16191
16201
  try {
16192
16202
  await this.client.initialize();
16203
+ // TODO: find why is this needed?
16193
16204
  await this.client.eval(context || {});
16194
16205
  this.status = ProviderStatus.READY;
16195
- this.events.emit(ProviderEvents.Ready, { message: 'Provider ready' });
16206
+ this.events.emit(ProviderEvents.Ready, {
16207
+ message: "Provider ready",
16208
+ });
16196
16209
  }
16197
16210
  catch (error) {
16198
16211
  this.status = ProviderStatus.ERROR;
16199
- const message = error instanceof Error ? error.message : 'Initialization failed';
16200
- this.events.emit(ProviderEvents.Error, { message, errorCode: ErrorCode.PROVIDER_NOT_READY });
16212
+ const message = error instanceof Error
16213
+ ? error.message
16214
+ : "Initialization failed";
16215
+ this.events.emit(ProviderEvents.Error, {
16216
+ message,
16217
+ errorCode: ErrorCode.PROVIDER_NOT_READY,
16218
+ });
16201
16219
  throw error;
16202
16220
  }
16203
16221
  }
@@ -16212,7 +16230,7 @@ class SuperpositionProvider {
16212
16230
  processedContext = this.filterContext(context);
16213
16231
  this.processedContextCache.set(context, processedContext);
16214
16232
  }
16215
- const config = await this.client.eval(processedContext);
16233
+ const config = await this.client.eval(processedContext, undefined, context.targetingKey);
16216
16234
  const value = getNestedValue(config, flagKey);
16217
16235
  const converter = TYPE_CONVERTERS[type];
16218
16236
  return converter(value, defaultValue);
@@ -16220,17 +16238,24 @@ class SuperpositionProvider {
16220
16238
  filterContext(context) {
16221
16239
  const filtered = {};
16222
16240
  for (const [key, value] of Object.entries(context)) {
16223
- if (key.startsWith('__') || key === 'targetingKey' || key === 'timestamp') {
16241
+ if (key.startsWith("__") ||
16242
+ key === "targetingKey" ||
16243
+ key === "timestamp") {
16224
16244
  continue;
16225
16245
  }
16226
16246
  // Only include simple, serializable types
16227
- if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
16247
+ if (typeof value === "string" ||
16248
+ typeof value === "number" ||
16249
+ typeof value === "boolean") {
16228
16250
  filtered[key] = value;
16229
16251
  }
16230
- else if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
16252
+ else if (typeof value === "object" &&
16253
+ value !== null &&
16254
+ !Array.isArray(value)) {
16231
16255
  try {
16232
16256
  const serialized = JSON.stringify(value);
16233
- if (serialized.length < 1000 && Object.keys(value).length < 10) {
16257
+ if (serialized.length < 1000 &&
16258
+ Object.keys(value).length < 10) {
16234
16259
  filtered[key] = value;
16235
16260
  }
16236
16261
  }
@@ -16243,62 +16268,76 @@ class SuperpositionProvider {
16243
16268
  }
16244
16269
  createResolver(type) {
16245
16270
  return async (flagKey, defaultValue, context) => {
16246
- if (this.status !== ProviderStatus.READY && this.status !== ProviderStatus.STALE) {
16271
+ if (this.status !== ProviderStatus.READY &&
16272
+ this.status !== ProviderStatus.STALE) {
16247
16273
  return {
16248
16274
  value: defaultValue,
16249
- reason: 'ERROR',
16250
- errorCode: this.status === ProviderStatus.FATAL ? ErrorCode.PROVIDER_FATAL : ErrorCode.PROVIDER_NOT_READY,
16251
- errorMessage: `Provider status: ${this.status}`
16275
+ reason: "ERROR",
16276
+ errorCode: this.status === ProviderStatus.FATAL
16277
+ ? ErrorCode.PROVIDER_FATAL
16278
+ : ErrorCode.PROVIDER_NOT_READY,
16279
+ errorMessage: `Provider status: ${this.status}`,
16252
16280
  };
16253
16281
  }
16254
16282
  try {
16255
16283
  const value = await this.evaluateFlag(flagKey, defaultValue, context, type);
16256
16284
  return {
16257
16285
  value,
16258
- reason: this.status === ProviderStatus.STALE ? 'STALE' : 'TARGETING_MATCH',
16286
+ reason: this.status === ProviderStatus.STALE
16287
+ ? "STALE"
16288
+ : "TARGETING_MATCH",
16259
16289
  };
16260
16290
  }
16261
16291
  catch (error) {
16262
16292
  return {
16263
16293
  value: defaultValue,
16264
- reason: 'ERROR',
16294
+ reason: "ERROR",
16265
16295
  errorCode: ErrorCode.GENERAL,
16266
- errorMessage: error instanceof Error ? error.message : 'Evaluation failed'
16296
+ errorMessage: error instanceof Error
16297
+ ? error.message
16298
+ : "Evaluation failed",
16267
16299
  };
16268
16300
  }
16269
16301
  };
16270
16302
  }
16271
16303
  async resolveBooleanEvaluation(flagKey, defaultValue, context) {
16272
- return this.createResolver('boolean')(flagKey, defaultValue, context);
16304
+ return this.createResolver("boolean")(flagKey, defaultValue, context);
16273
16305
  }
16274
16306
  async resolveStringEvaluation(flagKey, defaultValue, context) {
16275
- return this.createResolver('string')(flagKey, defaultValue, context);
16307
+ return this.createResolver("string")(flagKey, defaultValue, context);
16276
16308
  }
16277
16309
  async resolveNumberEvaluation(flagKey, defaultValue, context) {
16278
- return this.createResolver('number')(flagKey, defaultValue, context);
16310
+ return this.createResolver("number")(flagKey, defaultValue, context);
16279
16311
  }
16280
16312
  async resolveObjectEvaluation(flagKey, defaultValue, context, logger) {
16281
- return this.createResolver('object')(flagKey, defaultValue, context);
16313
+ return this.createResolver("object")(flagKey, defaultValue, context);
16282
16314
  }
16283
16315
  async resolveAllConfigDetails(defaultValue, context) {
16284
- if (this.status !== ProviderStatus.READY && this.status !== ProviderStatus.STALE) {
16316
+ if (this.status !== ProviderStatus.READY &&
16317
+ this.status !== ProviderStatus.STALE) {
16285
16318
  return defaultValue;
16286
16319
  }
16287
16320
  try {
16288
- const processedContext = this.processedContextCache.get(context) || this.filterContext(context);
16321
+ const processedContext = this.processedContextCache.get(context) ||
16322
+ this.filterContext(context);
16289
16323
  if (!this.processedContextCache.has(context)) {
16290
16324
  this.processedContextCache.set(context, processedContext);
16291
16325
  }
16292
16326
  const targetingKey = context.targetingKey;
16327
+ // TODO: remove this function and use eval for getAllConfigValue as well
16293
16328
  return await this.client.getAllConfigValue(defaultValue, processedContext, targetingKey);
16294
16329
  }
16295
16330
  catch (error) {
16296
- console.error('Error resolving all config details:', error);
16331
+ console.error("Error resolving all config details:", error);
16297
16332
  return defaultValue;
16298
16333
  }
16299
16334
  }
16300
- getStatus() { return this.status; }
16301
- getConfigurationClient() { return this.client; }
16335
+ getStatus() {
16336
+ return this.status;
16337
+ }
16338
+ getConfigurationClient() {
16339
+ return this.client;
16340
+ }
16302
16341
  }
16303
16342
 
16304
16343
  function httpRequest(options) {