@spotify-confidence/openfeature-server-provider-local 0.14.2 → 0.15.1

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.
@@ -86,6 +86,8 @@ declare enum ResolveReason {
86
86
  RESOLVE_REASON_TYPE_MISMATCH = 9,
87
87
  /** RESOLVE_REASON_FLAG_NOT_FOUND - The flag was not found in the resolve response */
88
88
  RESOLVE_REASON_FLAG_NOT_FOUND = 10,
89
+ /** RESOLVE_REASON_BUNDLE - A bundle resolve was performed (multiple flags resolved at once) */
90
+ RESOLVE_REASON_BUNDLE = 11,
89
91
  UNRECOGNIZED = -1,
90
92
  }
91
93
  declare enum SdkId {
@@ -514,6 +516,7 @@ declare class ConfidenceServerProviderLocal implements Provider {
514
516
  initialize(context?: EvaluationContext): Promise<void>;
515
517
  onClose(): Promise<void>;
516
518
  resolve(context: EvaluationContext, flagNames: string[], apply?: boolean): Promise<FlagBundle$1>;
519
+ private resolveFlags;
517
520
  evaluate<T extends JsonValue>(flagKey: string, defaultValue: T, context: EvaluationContext): Promise<ResolutionDetails<T>>;
518
521
  private resolveProcess;
519
522
  private handleMaterializationWrites;
@@ -779,6 +779,7 @@ let ResolveReason = /* @__PURE__ */ function(ResolveReason$1) {
779
779
  ResolveReason$1[ResolveReason$1["RESOLVE_REASON_MATERIALIZATION_NOT_SUPPORTED"] = 8] = "RESOLVE_REASON_MATERIALIZATION_NOT_SUPPORTED";
780
780
  ResolveReason$1[ResolveReason$1["RESOLVE_REASON_TYPE_MISMATCH"] = 9] = "RESOLVE_REASON_TYPE_MISMATCH";
781
781
  ResolveReason$1[ResolveReason$1["RESOLVE_REASON_FLAG_NOT_FOUND"] = 10] = "RESOLVE_REASON_FLAG_NOT_FOUND";
782
+ ResolveReason$1[ResolveReason$1["RESOLVE_REASON_BUNDLE"] = 11] = "RESOLVE_REASON_BUNDLE";
782
783
  ResolveReason$1[ResolveReason$1["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
783
784
  return ResolveReason$1;
784
785
  }({});
@@ -806,6 +807,8 @@ function resolveReasonFromJSON(object) {
806
807
  case "RESOLVE_REASON_TYPE_MISMATCH": return ResolveReason.RESOLVE_REASON_TYPE_MISMATCH;
807
808
  case 10:
808
809
  case "RESOLVE_REASON_FLAG_NOT_FOUND": return ResolveReason.RESOLVE_REASON_FLAG_NOT_FOUND;
810
+ case 11:
811
+ case "RESOLVE_REASON_BUNDLE": return ResolveReason.RESOLVE_REASON_BUNDLE;
809
812
  case -1:
810
813
  case "UNRECOGNIZED":
811
814
  default: return ResolveReason.UNRECOGNIZED;
@@ -824,6 +827,7 @@ function resolveReasonToJSON(object) {
824
827
  case ResolveReason.RESOLVE_REASON_MATERIALIZATION_NOT_SUPPORTED: return "RESOLVE_REASON_MATERIALIZATION_NOT_SUPPORTED";
825
828
  case ResolveReason.RESOLVE_REASON_TYPE_MISMATCH: return "RESOLVE_REASON_TYPE_MISMATCH";
826
829
  case ResolveReason.RESOLVE_REASON_FLAG_NOT_FOUND: return "RESOLVE_REASON_FLAG_NOT_FOUND";
830
+ case ResolveReason.RESOLVE_REASON_BUNDLE: return "RESOLVE_REASON_BUNDLE";
827
831
  case ResolveReason.UNRECOGNIZED:
828
832
  default: return "UNRECOGNIZED";
829
833
  }
@@ -1433,7 +1437,7 @@ function isObject(value) {
1433
1437
  function isSet$3(value) {
1434
1438
  return value !== null && value !== void 0;
1435
1439
  }
1436
- const VERSION = "0.14.2";
1440
+ const VERSION = "0.15.1";
1437
1441
  const NOOP_LOG_FN = Object.assign(() => {}, { enabled: false });
1438
1442
  const debugBackend = loadDebug();
1439
1443
  const logger$2 = new class LoggerImpl {
@@ -2899,6 +2903,24 @@ var ConfidenceServerProviderLocal = class ConfidenceServerProviderLocal {
2899
2903
  this.main.abort();
2900
2904
  }
2901
2905
  async resolve(context, flagNames, apply = false) {
2906
+ const startMs = performance.now();
2907
+ let reason = ResolveReason.RESOLVE_REASON_BUNDLE;
2908
+ try {
2909
+ return await this.resolveFlags(context, flagNames, apply);
2910
+ } catch (err) {
2911
+ reason = ResolveReason.RESOLVE_REASON_ERROR;
2912
+ return error(ErrorCode.GENERAL, String(err));
2913
+ } finally {
2914
+ const latencyUs = Math.round((performance.now() - startMs) * 1e3);
2915
+ try {
2916
+ this.resolver.registerResolve({
2917
+ reason,
2918
+ latencyUs
2919
+ });
2920
+ } catch {}
2921
+ }
2922
+ }
2923
+ async resolveFlags(context, flagNames, apply) {
2902
2924
  const resolveRequest = {
2903
2925
  flags: flagNames.map((name) => `flags/${name}`),
2904
2926
  evaluationContext: ConfidenceServerProviderLocal.convertEvaluationContext(context),
@@ -2909,18 +2931,21 @@ var ConfidenceServerProviderLocal = class ConfidenceServerProviderLocal {
2909
2931
  version: VERSION
2910
2932
  }
2911
2933
  };
2912
- try {
2913
- const processRequest = this.materializationStore ? { deferredMaterializations: resolveRequest } : { withoutMaterializations: resolveRequest };
2914
- return create(await this.resolveProcess(processRequest));
2915
- } catch (err) {
2916
- return error(ErrorCode.GENERAL, String(err));
2917
- }
2934
+ const processRequest = this.materializationStore ? { deferredMaterializations: resolveRequest } : { withoutMaterializations: resolveRequest };
2935
+ return create(await this.resolveProcess(processRequest));
2918
2936
  }
2919
2937
  async evaluate(flagKey, defaultValue, context) {
2920
2938
  const startMs = performance.now();
2921
2939
  try {
2922
2940
  const [flagName] = flagKey.split(".", 1);
2923
- const resolution = await this.resolve(context, [flagName], true);
2941
+ const { _confidence_skip_apply,...cleanContext } = context;
2942
+ const skipApply = _confidence_skip_apply === true;
2943
+ let resolution;
2944
+ try {
2945
+ resolution = await this.resolveFlags(cleanContext, [flagName], !skipApply);
2946
+ } catch (err) {
2947
+ resolution = error(ErrorCode.GENERAL, String(err));
2948
+ }
2924
2949
  const result = resolve(resolution, flagKey, defaultValue, logger$1);
2925
2950
  const latencyUs = Math.round((performance.now() - startMs) * 1e3);
2926
2951
  let reason;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spotify-confidence/openfeature-server-provider-local",
3
- "version": "0.14.2",
3
+ "version": "0.15.1",
4
4
  "description": "Spotify Confidence Open Feature provider",
5
5
  "type": "module",
6
6
  "files": [