@spotify-confidence/openfeature-server-provider-local 0.5.1 → 0.6.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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.6.0](https://github.com/spotify/confidence-resolver/compare/openfeature-provider-js-v0.5.1...openfeature-provider-js-v0.6.0) (2026-01-15)
4
+
5
+
6
+ ### Features
7
+
8
+ * **js:** add stateUpdateInterval option for configurable state polling ([#224](https://github.com/spotify/confidence-resolver/issues/224)) ([5687847](https://github.com/spotify/confidence-resolver/commit/56878478d3d508870ac0f3172f897c8728e8a85d))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * prevent split bundle ([#212](https://github.com/spotify/confidence-resolver/issues/212)) ([80cfd0d](https://github.com/spotify/confidence-resolver/commit/80cfd0d0128af4c65b1ae50539f2b1d0d959c02e))
14
+
3
15
  ## [0.5.1](https://github.com/spotify/confidence-resolver/compare/openfeature-provider-js-v0.5.0...openfeature-provider-js-v0.5.1) (2026-01-12)
4
16
 
5
17
 
package/README.md CHANGED
@@ -50,6 +50,7 @@ import { createConfidenceServerProvider } from '@spotify-confidence/openfeature-
50
50
  const provider = createConfidenceServerProvider({
51
51
  flagClientSecret: process.env.CONFIDENCE_FLAG_CLIENT_SECRET!,
52
52
  // initializeTimeout?: number
53
+ // stateUpdateInterval?: number
53
54
  // flushInterval?: number
54
55
  // fetch?: typeof fetch (Node <18 or custom transport)
55
56
  });
@@ -129,12 +130,13 @@ if (details.errorCode) {
129
130
 
130
131
  - `flagClientSecret` (string, required): The flag client secret used during evaluation and authentication.
131
132
  - `initializeTimeout` (number, optional): Max ms to wait for initial state fetch. Defaults to 30_000.
133
+ - `stateUpdateInterval` (number, optional): Interval in ms between state polling updates. Defaults to 30_000.
132
134
  - `flushInterval` (number, optional): Interval in ms for sending evaluation logs. Defaults to 10_000.
133
135
  - `fetch` (optional): Custom `fetch` implementation. Required for Node < 18; for Node 18+ you can omit.
134
136
 
135
137
  The provider periodically:
136
- - Refreshes resolver state (default every 30s)
137
- - Flushes flag evaluation logs to the backend
138
+ - Refreshes resolver state (configurable via `stateUpdateInterval`, default every 30s)
139
+ - Flushes flag evaluation logs to the backend (configurable via `flushInterval`, default every 10s)
138
140
 
139
141
  ---
140
142
 
@@ -402,6 +402,9 @@ interface MaterializationStore {
402
402
  interface ProviderOptions {
403
403
  flagClientSecret: string;
404
404
  initializeTimeout?: number;
405
+ /** Interval in milliseconds between state polling updates. Defaults to 30000ms. */
406
+ stateUpdateInterval?: number;
407
+ /** Interval in milliseconds between log flushes. Defaults to 10000ms. */
405
408
  flushInterval?: number;
406
409
  fetch?: typeof fetch;
407
410
  materializationStore?: MaterializationStore | "CONFIDENCE_REMOTE_STORE";
@@ -419,6 +422,7 @@ declare class ConfidenceServerProviderLocal implements Provider {
419
422
  status: ProviderStatus;
420
423
  private readonly main;
421
424
  private readonly fetch;
425
+ private readonly stateUpdateInterval;
422
426
  private readonly flushInterval;
423
427
  private readonly materializationStore;
424
428
  private stateEtag;
@@ -1,4 +1,3 @@
1
- import { Request, Response as Response$1, SetResolverStateRequest, Void } from "./messages-ZL-6wQib.js";
2
1
  import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
3
2
  let NullValue = /* @__PURE__ */ function(NullValue$1) {
4
3
  NullValue$1[NullValue$1["NULL_VALUE"] = 0] = "NULL_VALUE";
@@ -129,8 +128,8 @@ const Struct_FieldsEntry = {
129
128
  },
130
129
  fromJSON(object) {
131
130
  return {
132
- key: isSet$6(object.key) ? globalThis.String(object.key) : "",
133
- value: isSet$6(object?.value) ? object.value : void 0
131
+ key: isSet$7(object.key) ? globalThis.String(object.key) : "",
132
+ value: isSet$7(object?.value) ? object.value : void 0
134
133
  };
135
134
  },
136
135
  toJSON(message) {
@@ -208,10 +207,10 @@ const Value = {
208
207
  },
209
208
  fromJSON(object) {
210
209
  return {
211
- nullValue: isSet$6(object.nullValue) ? nullValueFromJSON(object.nullValue) : void 0,
212
- numberValue: isSet$6(object.numberValue) ? globalThis.Number(object.numberValue) : void 0,
213
- stringValue: isSet$6(object.stringValue) ? globalThis.String(object.stringValue) : void 0,
214
- boolValue: isSet$6(object.boolValue) ? globalThis.Boolean(object.boolValue) : void 0,
210
+ nullValue: isSet$7(object.nullValue) ? nullValueFromJSON(object.nullValue) : void 0,
211
+ numberValue: isSet$7(object.numberValue) ? globalThis.Number(object.numberValue) : void 0,
212
+ stringValue: isSet$7(object.stringValue) ? globalThis.String(object.stringValue) : void 0,
213
+ boolValue: isSet$7(object.boolValue) ? globalThis.Boolean(object.boolValue) : void 0,
215
214
  structValue: isObject$2(object.structValue) ? object.structValue : void 0,
216
215
  listValue: globalThis.Array.isArray(object.listValue) ? [...object.listValue] : void 0
217
216
  };
@@ -313,7 +312,7 @@ const ListValue = {
313
312
  function isObject$2(value) {
314
313
  return typeof value === "object" && value !== null;
315
314
  }
316
- function isSet$6(value) {
315
+ function isSet$7(value) {
317
316
  return value !== null && value !== void 0;
318
317
  }
319
318
  function createBaseTimestamp() {
@@ -351,8 +350,8 @@ const Timestamp = {
351
350
  },
352
351
  fromJSON(object) {
353
352
  return {
354
- seconds: isSet$5(object.seconds) ? globalThis.Number(object.seconds) : 0,
355
- nanos: isSet$5(object.nanos) ? globalThis.Number(object.nanos) : 0
353
+ seconds: isSet$6(object.seconds) ? globalThis.Number(object.seconds) : 0,
354
+ nanos: isSet$6(object.nanos) ? globalThis.Number(object.nanos) : 0
356
355
  };
357
356
  },
358
357
  toJSON(message) {
@@ -377,7 +376,7 @@ function longToNumber(int64) {
377
376
  if (num < globalThis.Number.MIN_SAFE_INTEGER) throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");
378
377
  return num;
379
378
  }
380
- function isSet$5(value) {
379
+ function isSet$6(value) {
381
380
  return value !== null && value !== void 0;
382
381
  }
383
382
  function createBaseFlagSchema() {
@@ -439,12 +438,12 @@ const FlagSchema = {
439
438
  },
440
439
  fromJSON(object) {
441
440
  return {
442
- structSchema: isSet$4(object.structSchema) ? FlagSchema_StructFlagSchema.fromJSON(object.structSchema) : void 0,
443
- listSchema: isSet$4(object.listSchema) ? FlagSchema_ListFlagSchema.fromJSON(object.listSchema) : void 0,
444
- intSchema: isSet$4(object.intSchema) ? FlagSchema_IntFlagSchema.fromJSON(object.intSchema) : void 0,
445
- doubleSchema: isSet$4(object.doubleSchema) ? FlagSchema_DoubleFlagSchema.fromJSON(object.doubleSchema) : void 0,
446
- stringSchema: isSet$4(object.stringSchema) ? FlagSchema_StringFlagSchema.fromJSON(object.stringSchema) : void 0,
447
- boolSchema: isSet$4(object.boolSchema) ? FlagSchema_BoolFlagSchema.fromJSON(object.boolSchema) : void 0
441
+ structSchema: isSet$5(object.structSchema) ? FlagSchema_StructFlagSchema.fromJSON(object.structSchema) : void 0,
442
+ listSchema: isSet$5(object.listSchema) ? FlagSchema_ListFlagSchema.fromJSON(object.listSchema) : void 0,
443
+ intSchema: isSet$5(object.intSchema) ? FlagSchema_IntFlagSchema.fromJSON(object.intSchema) : void 0,
444
+ doubleSchema: isSet$5(object.doubleSchema) ? FlagSchema_DoubleFlagSchema.fromJSON(object.doubleSchema) : void 0,
445
+ stringSchema: isSet$5(object.stringSchema) ? FlagSchema_StringFlagSchema.fromJSON(object.stringSchema) : void 0,
446
+ boolSchema: isSet$5(object.boolSchema) ? FlagSchema_BoolFlagSchema.fromJSON(object.boolSchema) : void 0
448
447
  };
449
448
  },
450
449
  toJSON(message) {
@@ -569,8 +568,8 @@ const FlagSchema_StructFlagSchema_SchemaEntry = {
569
568
  },
570
569
  fromJSON(object) {
571
570
  return {
572
- key: isSet$4(object.key) ? globalThis.String(object.key) : "",
573
- value: isSet$4(object.value) ? FlagSchema.fromJSON(object.value) : void 0
571
+ key: isSet$5(object.key) ? globalThis.String(object.key) : "",
572
+ value: isSet$5(object.value) ? FlagSchema.fromJSON(object.value) : void 0
574
573
  };
575
574
  },
576
575
  toJSON(message) {
@@ -743,7 +742,7 @@ const FlagSchema_ListFlagSchema = {
743
742
  return message;
744
743
  },
745
744
  fromJSON(object) {
746
- return { elementSchema: isSet$4(object.elementSchema) ? FlagSchema.fromJSON(object.elementSchema) : void 0 };
745
+ return { elementSchema: isSet$5(object.elementSchema) ? FlagSchema.fromJSON(object.elementSchema) : void 0 };
747
746
  },
748
747
  toJSON(message) {
749
748
  const obj = {};
@@ -762,7 +761,7 @@ const FlagSchema_ListFlagSchema = {
762
761
  function isObject$1(value) {
763
762
  return typeof value === "object" && value !== null;
764
763
  }
765
- function isSet$4(value) {
764
+ function isSet$5(value) {
766
765
  return value !== null && value !== void 0;
767
766
  }
768
767
  let ResolveReason = /* @__PURE__ */ function(ResolveReason$1) {
@@ -960,9 +959,9 @@ const Sdk = {
960
959
  },
961
960
  fromJSON(object) {
962
961
  return {
963
- id: isSet$3(object.id) ? sdkIdFromJSON(object.id) : void 0,
964
- customId: isSet$3(object.customId) ? globalThis.String(object.customId) : void 0,
965
- version: isSet$3(object.version) ? globalThis.String(object.version) : ""
962
+ id: isSet$4(object.id) ? sdkIdFromJSON(object.id) : void 0,
963
+ customId: isSet$4(object.customId) ? globalThis.String(object.customId) : void 0,
964
+ version: isSet$4(object.version) ? globalThis.String(object.version) : ""
966
965
  };
967
966
  },
968
967
  toJSON(message) {
@@ -983,7 +982,7 @@ const Sdk = {
983
982
  return message;
984
983
  }
985
984
  };
986
- function isSet$3(value) {
985
+ function isSet$4(value) {
987
986
  return value !== null && value !== void 0;
988
987
  }
989
988
  function createBaseResolveFlagsRequest() {
@@ -1041,9 +1040,9 @@ const ResolveFlagsRequest = {
1041
1040
  return {
1042
1041
  flags: globalThis.Array.isArray(object?.flags) ? object.flags.map((e) => globalThis.String(e)) : [],
1043
1042
  evaluationContext: isObject(object.evaluationContext) ? object.evaluationContext : void 0,
1044
- clientSecret: isSet$2(object.clientSecret) ? globalThis.String(object.clientSecret) : "",
1045
- apply: isSet$2(object.apply) ? globalThis.Boolean(object.apply) : false,
1046
- sdk: isSet$2(object.sdk) ? Sdk.fromJSON(object.sdk) : void 0
1043
+ clientSecret: isSet$3(object.clientSecret) ? globalThis.String(object.clientSecret) : "",
1044
+ apply: isSet$3(object.apply) ? globalThis.Boolean(object.apply) : false,
1045
+ sdk: isSet$3(object.sdk) ? Sdk.fromJSON(object.sdk) : void 0
1047
1046
  };
1048
1047
  },
1049
1048
  toJSON(message) {
@@ -1110,14 +1109,14 @@ const ResolveFlagsResponse = {
1110
1109
  fromJSON(object) {
1111
1110
  return {
1112
1111
  resolvedFlags: globalThis.Array.isArray(object?.resolvedFlags) ? object.resolvedFlags.map((e) => ResolvedFlag.fromJSON(e)) : [],
1113
- resolveToken: isSet$2(object.resolveToken) ? bytesFromBase64(object.resolveToken) : new Uint8Array(0),
1114
- resolveId: isSet$2(object.resolveId) ? globalThis.String(object.resolveId) : ""
1112
+ resolveToken: isSet$3(object.resolveToken) ? bytesFromBase64$1(object.resolveToken) : new Uint8Array(0),
1113
+ resolveId: isSet$3(object.resolveId) ? globalThis.String(object.resolveId) : ""
1115
1114
  };
1116
1115
  },
1117
1116
  toJSON(message) {
1118
1117
  const obj = {};
1119
1118
  if (message.resolvedFlags?.length) obj.resolvedFlags = message.resolvedFlags.map((e) => ResolvedFlag.toJSON(e));
1120
- if (message.resolveToken.length !== 0) obj.resolveToken = base64FromBytes(message.resolveToken);
1119
+ if (message.resolveToken.length !== 0) obj.resolveToken = base64FromBytes$1(message.resolveToken);
1121
1120
  if (message.resolveId !== "") obj.resolveId = message.resolveId;
1122
1121
  return obj;
1123
1122
  },
@@ -1185,11 +1184,11 @@ const ResolvedFlag = {
1185
1184
  },
1186
1185
  fromJSON(object) {
1187
1186
  return {
1188
- flag: isSet$2(object.flag) ? globalThis.String(object.flag) : "",
1189
- variant: isSet$2(object.variant) ? globalThis.String(object.variant) : "",
1187
+ flag: isSet$3(object.flag) ? globalThis.String(object.flag) : "",
1188
+ variant: isSet$3(object.variant) ? globalThis.String(object.variant) : "",
1190
1189
  value: isObject(object.value) ? object.value : void 0,
1191
- flagSchema: isSet$2(object.flagSchema) ? FlagSchema_StructFlagSchema.fromJSON(object.flagSchema) : void 0,
1192
- reason: isSet$2(object.reason) ? resolveReasonFromJSON(object.reason) : 0
1190
+ flagSchema: isSet$3(object.flagSchema) ? FlagSchema_StructFlagSchema.fromJSON(object.flagSchema) : void 0,
1191
+ reason: isSet$3(object.reason) ? resolveReasonFromJSON(object.reason) : 0
1193
1192
  };
1194
1193
  },
1195
1194
  toJSON(message) {
@@ -1214,7 +1213,7 @@ const ResolvedFlag = {
1214
1213
  return message;
1215
1214
  }
1216
1215
  };
1217
- function bytesFromBase64(b64) {
1216
+ function bytesFromBase64$1(b64) {
1218
1217
  if (globalThis.Buffer) return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
1219
1218
  else {
1220
1219
  const bin = globalThis.atob(b64);
@@ -1223,7 +1222,7 @@ function bytesFromBase64(b64) {
1223
1222
  return arr;
1224
1223
  }
1225
1224
  }
1226
- function base64FromBytes(arr) {
1225
+ function base64FromBytes$1(arr) {
1227
1226
  if (globalThis.Buffer) return globalThis.Buffer.from(arr).toString("base64");
1228
1227
  else {
1229
1228
  const bin = [];
@@ -1236,10 +1235,10 @@ function base64FromBytes(arr) {
1236
1235
  function isObject(value) {
1237
1236
  return typeof value === "object" && value !== null;
1238
1237
  }
1239
- function isSet$2(value) {
1238
+ function isSet$3(value) {
1240
1239
  return value !== null && value !== void 0;
1241
1240
  }
1242
- const VERSION = "0.5.1";
1241
+ const VERSION = "0.6.0";
1243
1242
  const NOOP_LOG_FN = Object.assign(() => {}, { enabled: false });
1244
1243
  const debugBackend = loadDebug();
1245
1244
  const logger$2 = new class LoggerImpl {
@@ -1628,9 +1627,9 @@ const VariantReadOp = {
1628
1627
  },
1629
1628
  fromJSON(object) {
1630
1629
  return {
1631
- unit: isSet$1(object.unit) ? globalThis.String(object.unit) : "",
1632
- materialization: isSet$1(object.materialization) ? globalThis.String(object.materialization) : "",
1633
- rule: isSet$1(object.rule) ? globalThis.String(object.rule) : ""
1630
+ unit: isSet$2(object.unit) ? globalThis.String(object.unit) : "",
1631
+ materialization: isSet$2(object.materialization) ? globalThis.String(object.materialization) : "",
1632
+ rule: isSet$2(object.rule) ? globalThis.String(object.rule) : ""
1634
1633
  };
1635
1634
  },
1636
1635
  toJSON(message) {
@@ -1686,8 +1685,8 @@ const InclusionReadOp = {
1686
1685
  },
1687
1686
  fromJSON(object) {
1688
1687
  return {
1689
- unit: isSet$1(object.unit) ? globalThis.String(object.unit) : "",
1690
- materialization: isSet$1(object.materialization) ? globalThis.String(object.materialization) : ""
1688
+ unit: isSet$2(object.unit) ? globalThis.String(object.unit) : "",
1689
+ materialization: isSet$2(object.materialization) ? globalThis.String(object.materialization) : ""
1691
1690
  };
1692
1691
  },
1693
1692
  toJSON(message) {
@@ -1741,8 +1740,8 @@ const ReadOp = {
1741
1740
  },
1742
1741
  fromJSON(object) {
1743
1742
  return {
1744
- variantReadOp: isSet$1(object.variantReadOp) ? VariantReadOp.fromJSON(object.variantReadOp) : void 0,
1745
- inclusionReadOp: isSet$1(object.inclusionReadOp) ? InclusionReadOp.fromJSON(object.inclusionReadOp) : void 0
1743
+ variantReadOp: isSet$2(object.variantReadOp) ? VariantReadOp.fromJSON(object.variantReadOp) : void 0,
1744
+ inclusionReadOp: isSet$2(object.inclusionReadOp) ? InclusionReadOp.fromJSON(object.inclusionReadOp) : void 0
1746
1745
  };
1747
1746
  },
1748
1747
  toJSON(message) {
@@ -1850,10 +1849,10 @@ const VariantData = {
1850
1849
  },
1851
1850
  fromJSON(object) {
1852
1851
  return {
1853
- unit: isSet$1(object.unit) ? globalThis.String(object.unit) : "",
1854
- materialization: isSet$1(object.materialization) ? globalThis.String(object.materialization) : "",
1855
- rule: isSet$1(object.rule) ? globalThis.String(object.rule) : "",
1856
- variant: isSet$1(object.variant) ? globalThis.String(object.variant) : ""
1852
+ unit: isSet$2(object.unit) ? globalThis.String(object.unit) : "",
1853
+ materialization: isSet$2(object.materialization) ? globalThis.String(object.materialization) : "",
1854
+ rule: isSet$2(object.rule) ? globalThis.String(object.rule) : "",
1855
+ variant: isSet$2(object.variant) ? globalThis.String(object.variant) : ""
1857
1856
  };
1858
1857
  },
1859
1858
  toJSON(message) {
@@ -1917,9 +1916,9 @@ const InclusionData = {
1917
1916
  },
1918
1917
  fromJSON(object) {
1919
1918
  return {
1920
- unit: isSet$1(object.unit) ? globalThis.String(object.unit) : "",
1921
- materialization: isSet$1(object.materialization) ? globalThis.String(object.materialization) : "",
1922
- isIncluded: isSet$1(object.isIncluded) ? globalThis.Boolean(object.isIncluded) : false
1919
+ unit: isSet$2(object.unit) ? globalThis.String(object.unit) : "",
1920
+ materialization: isSet$2(object.materialization) ? globalThis.String(object.materialization) : "",
1921
+ isIncluded: isSet$2(object.isIncluded) ? globalThis.Boolean(object.isIncluded) : false
1923
1922
  };
1924
1923
  },
1925
1924
  toJSON(message) {
@@ -1975,8 +1974,8 @@ const ReadResult = {
1975
1974
  },
1976
1975
  fromJSON(object) {
1977
1976
  return {
1978
- variantResult: isSet$1(object.variantResult) ? VariantData.fromJSON(object.variantResult) : void 0,
1979
- inclusionResult: isSet$1(object.inclusionResult) ? InclusionData.fromJSON(object.inclusionResult) : void 0
1977
+ variantResult: isSet$2(object.variantResult) ? VariantData.fromJSON(object.variantResult) : void 0,
1978
+ inclusionResult: isSet$2(object.inclusionResult) ? InclusionData.fromJSON(object.inclusionResult) : void 0
1980
1979
  };
1981
1980
  },
1982
1981
  toJSON(message) {
@@ -2037,7 +2036,7 @@ const ReadOperationsResult = {
2037
2036
  return message;
2038
2037
  }
2039
2038
  };
2040
- function isSet$1(value) {
2039
+ function isSet$2(value) {
2041
2040
  return value !== null && value !== void 0;
2042
2041
  }
2043
2042
  var ConfidenceRemoteMaterializationStore = class {
@@ -2164,7 +2163,214 @@ function writeOpsFromProto(writeOpsReq) {
2164
2163
  };
2165
2164
  });
2166
2165
  }
2166
+ function createBaseVoid() {
2167
+ return {};
2168
+ }
2169
+ const Void = {
2170
+ encode(_, writer = new BinaryWriter()) {
2171
+ return writer;
2172
+ },
2173
+ decode(input, length) {
2174
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2175
+ const end = length === void 0 ? reader.len : reader.pos + length;
2176
+ const message = createBaseVoid();
2177
+ while (reader.pos < end) {
2178
+ const tag = reader.uint32();
2179
+ switch (tag >>> 3) {}
2180
+ if ((tag & 7) === 4 || tag === 0) break;
2181
+ reader.skip(tag & 7);
2182
+ }
2183
+ return message;
2184
+ },
2185
+ fromJSON(_) {
2186
+ return {};
2187
+ },
2188
+ toJSON(_) {
2189
+ return {};
2190
+ },
2191
+ create(base) {
2192
+ return Void.fromPartial(base ?? {});
2193
+ },
2194
+ fromPartial(_) {
2195
+ return createBaseVoid();
2196
+ }
2197
+ };
2198
+ function createBaseSetResolverStateRequest() {
2199
+ return {
2200
+ state: new Uint8Array(0),
2201
+ accountId: ""
2202
+ };
2203
+ }
2204
+ const SetResolverStateRequest = {
2205
+ encode(message, writer = new BinaryWriter()) {
2206
+ if (message.state.length !== 0) writer.uint32(10).bytes(message.state);
2207
+ if (message.accountId !== "") writer.uint32(18).string(message.accountId);
2208
+ return writer;
2209
+ },
2210
+ decode(input, length) {
2211
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2212
+ const end = length === void 0 ? reader.len : reader.pos + length;
2213
+ const message = createBaseSetResolverStateRequest();
2214
+ while (reader.pos < end) {
2215
+ const tag = reader.uint32();
2216
+ switch (tag >>> 3) {
2217
+ case 1:
2218
+ if (tag !== 10) break;
2219
+ message.state = reader.bytes();
2220
+ continue;
2221
+ case 2:
2222
+ if (tag !== 18) break;
2223
+ message.accountId = reader.string();
2224
+ continue;
2225
+ }
2226
+ if ((tag & 7) === 4 || tag === 0) break;
2227
+ reader.skip(tag & 7);
2228
+ }
2229
+ return message;
2230
+ },
2231
+ fromJSON(object) {
2232
+ return {
2233
+ state: isSet$1(object.state) ? bytesFromBase64(object.state) : new Uint8Array(0),
2234
+ accountId: isSet$1(object.accountId) ? globalThis.String(object.accountId) : ""
2235
+ };
2236
+ },
2237
+ toJSON(message) {
2238
+ const obj = {};
2239
+ if (message.state.length !== 0) obj.state = base64FromBytes(message.state);
2240
+ if (message.accountId !== "") obj.accountId = message.accountId;
2241
+ return obj;
2242
+ },
2243
+ create(base) {
2244
+ return SetResolverStateRequest.fromPartial(base ?? {});
2245
+ },
2246
+ fromPartial(object) {
2247
+ const message = createBaseSetResolverStateRequest();
2248
+ message.state = object.state ?? new Uint8Array(0);
2249
+ message.accountId = object.accountId ?? "";
2250
+ return message;
2251
+ }
2252
+ };
2253
+ function createBaseRequest() {
2254
+ return { data: new Uint8Array(0) };
2255
+ }
2256
+ const Request = {
2257
+ encode(message, writer = new BinaryWriter()) {
2258
+ if (message.data.length !== 0) writer.uint32(10).bytes(message.data);
2259
+ return writer;
2260
+ },
2261
+ decode(input, length) {
2262
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2263
+ const end = length === void 0 ? reader.len : reader.pos + length;
2264
+ const message = createBaseRequest();
2265
+ while (reader.pos < end) {
2266
+ const tag = reader.uint32();
2267
+ switch (tag >>> 3) {
2268
+ case 1:
2269
+ if (tag !== 10) break;
2270
+ message.data = reader.bytes();
2271
+ continue;
2272
+ }
2273
+ if ((tag & 7) === 4 || tag === 0) break;
2274
+ reader.skip(tag & 7);
2275
+ }
2276
+ return message;
2277
+ },
2278
+ fromJSON(object) {
2279
+ return { data: isSet$1(object.data) ? bytesFromBase64(object.data) : new Uint8Array(0) };
2280
+ },
2281
+ toJSON(message) {
2282
+ const obj = {};
2283
+ if (message.data.length !== 0) obj.data = base64FromBytes(message.data);
2284
+ return obj;
2285
+ },
2286
+ create(base) {
2287
+ return Request.fromPartial(base ?? {});
2288
+ },
2289
+ fromPartial(object) {
2290
+ const message = createBaseRequest();
2291
+ message.data = object.data ?? new Uint8Array(0);
2292
+ return message;
2293
+ }
2294
+ };
2295
+ function createBaseResponse() {
2296
+ return {
2297
+ data: void 0,
2298
+ error: void 0
2299
+ };
2300
+ }
2301
+ const Response$1 = {
2302
+ encode(message, writer = new BinaryWriter()) {
2303
+ if (message.data !== void 0) writer.uint32(10).bytes(message.data);
2304
+ if (message.error !== void 0) writer.uint32(18).string(message.error);
2305
+ return writer;
2306
+ },
2307
+ decode(input, length) {
2308
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2309
+ const end = length === void 0 ? reader.len : reader.pos + length;
2310
+ const message = createBaseResponse();
2311
+ while (reader.pos < end) {
2312
+ const tag = reader.uint32();
2313
+ switch (tag >>> 3) {
2314
+ case 1:
2315
+ if (tag !== 10) break;
2316
+ message.data = reader.bytes();
2317
+ continue;
2318
+ case 2:
2319
+ if (tag !== 18) break;
2320
+ message.error = reader.string();
2321
+ continue;
2322
+ }
2323
+ if ((tag & 7) === 4 || tag === 0) break;
2324
+ reader.skip(tag & 7);
2325
+ }
2326
+ return message;
2327
+ },
2328
+ fromJSON(object) {
2329
+ return {
2330
+ data: isSet$1(object.data) ? bytesFromBase64(object.data) : void 0,
2331
+ error: isSet$1(object.error) ? globalThis.String(object.error) : void 0
2332
+ };
2333
+ },
2334
+ toJSON(message) {
2335
+ const obj = {};
2336
+ if (message.data !== void 0) obj.data = base64FromBytes(message.data);
2337
+ if (message.error !== void 0) obj.error = message.error;
2338
+ return obj;
2339
+ },
2340
+ create(base) {
2341
+ return Response$1.fromPartial(base ?? {});
2342
+ },
2343
+ fromPartial(object) {
2344
+ const message = createBaseResponse();
2345
+ message.data = object.data ?? void 0;
2346
+ message.error = object.error ?? void 0;
2347
+ return message;
2348
+ }
2349
+ };
2350
+ function bytesFromBase64(b64) {
2351
+ if (globalThis.Buffer) return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
2352
+ else {
2353
+ const bin = globalThis.atob(b64);
2354
+ const arr = new Uint8Array(bin.length);
2355
+ for (let i = 0; i < bin.length; ++i) arr[i] = bin.charCodeAt(i);
2356
+ return arr;
2357
+ }
2358
+ }
2359
+ function base64FromBytes(arr) {
2360
+ if (globalThis.Buffer) return globalThis.Buffer.from(arr).toString("base64");
2361
+ else {
2362
+ const bin = [];
2363
+ arr.forEach((byte) => {
2364
+ bin.push(globalThis.String.fromCharCode(byte));
2365
+ });
2366
+ return globalThis.btoa(bin.join(""));
2367
+ }
2368
+ }
2369
+ function isSet$1(value) {
2370
+ return value !== null && value !== void 0;
2371
+ }
2167
2372
  const logger$1 = getLogger("provider");
2373
+ const DEFAULT_INITIALIZE_TIMEOUT = 3e4;
2168
2374
  const DEFAULT_STATE_INTERVAL = 3e4;
2169
2375
  const DEFAULT_FLUSH_INTERVAL = 1e4;
2170
2376
  var ConfidenceServerProviderLocal = class ConfidenceServerProviderLocal {
@@ -2172,18 +2378,22 @@ var ConfidenceServerProviderLocal = class ConfidenceServerProviderLocal {
2172
2378
  status = "NOT_READY";
2173
2379
  main = new AbortController();
2174
2380
  fetch;
2381
+ stateUpdateInterval;
2175
2382
  flushInterval;
2176
2383
  materializationStore;
2177
2384
  stateEtag = null;
2178
2385
  constructor(resolver$1, options) {
2179
2386
  this.resolver = resolver$1;
2180
2387
  this.options = options;
2388
+ this.stateUpdateInterval = options.stateUpdateInterval ?? DEFAULT_STATE_INTERVAL;
2389
+ if (!Number.isInteger(this.stateUpdateInterval) || this.stateUpdateInterval < 1e3) throw new Error(`stateUpdateInterval must be an integer >= 1000 (1s), currently: ${this.stateUpdateInterval}`);
2181
2390
  this.flushInterval = options.flushInterval ?? DEFAULT_FLUSH_INTERVAL;
2391
+ if (!Number.isInteger(this.flushInterval) || this.flushInterval < 1e3) throw new Error(`flushInterval must be an integer >= 1000 (1s), currently: ${this.flushInterval}`);
2182
2392
  this.fetch = Fetch.create([withRouter({
2183
2393
  "https://confidence-resolver-state-cdn.spotifycdn.com/*": [withRetry({
2184
2394
  maxAttempts: Infinity,
2185
2395
  baseInterval: 500,
2186
- maxInterval: DEFAULT_STATE_INTERVAL
2396
+ maxInterval: this.stateUpdateInterval
2187
2397
  }), withStallTimeout(500)],
2188
2398
  "https://resolver.confidence.dev/*": [withRouter({
2189
2399
  "*/v1/materialization:readMaterializedOperations": [withRetry({
@@ -2209,14 +2419,14 @@ var ConfidenceServerProviderLocal = class ConfidenceServerProviderLocal {
2209
2419
  }
2210
2420
  async initialize(context) {
2211
2421
  const signal = this.main.signal;
2212
- const initialUpdateSignal = AbortSignal.any([signal, timeoutSignal(this.options.initializeTimeout ?? DEFAULT_STATE_INTERVAL)]);
2422
+ const initialUpdateSignal = AbortSignal.any([signal, timeoutSignal(this.options.initializeTimeout ?? DEFAULT_INITIALIZE_TIMEOUT)]);
2213
2423
  try {
2214
2424
  await this.updateState(initialUpdateSignal);
2215
2425
  scheduleWithFixedInterval((signal$1) => this.flush(signal$1), this.flushInterval, {
2216
2426
  maxConcurrent: 3,
2217
2427
  signal
2218
2428
  });
2219
- scheduleWithFixedInterval((signal$1) => this.updateState(signal$1), DEFAULT_STATE_INTERVAL, { signal });
2429
+ scheduleWithFixedInterval((signal$1) => this.updateState(signal$1), this.stateUpdateInterval, { signal });
2220
2430
  this.status = "READY";
2221
2431
  } catch (e) {
2222
2432
  this.status = "ERROR";
@@ -2315,8 +2525,7 @@ var ConfidenceServerProviderLocal = class ConfidenceServerProviderLocal {
2315
2525
  if (!resp.ok) throw new Error(`Failed to fetch state: ${resp.status} ${resp.statusText}`);
2316
2526
  this.stateEtag = resp.headers.get("etag");
2317
2527
  const bytes = new Uint8Array(await resp.arrayBuffer());
2318
- const { SetResolverStateRequest: SetResolverStateRequest$1 } = await import("./messages-BjOGSPNo.js");
2319
- this.resolver.setResolverState(SetResolverStateRequest$1.decode(bytes));
2528
+ this.resolver.setResolverState(SetResolverStateRequest.decode(bytes));
2320
2529
  }
2321
2530
  async flush(signal) {
2322
2531
  const writeFlagLogRequest = this.resolver.flushLogs();
@@ -402,6 +402,9 @@ interface MaterializationStore {
402
402
  interface ProviderOptions {
403
403
  flagClientSecret: string;
404
404
  initializeTimeout?: number;
405
+ /** Interval in milliseconds between state polling updates. Defaults to 30000ms. */
406
+ stateUpdateInterval?: number;
407
+ /** Interval in milliseconds between log flushes. Defaults to 10000ms. */
405
408
  flushInterval?: number;
406
409
  fetch?: typeof fetch;
407
410
  materializationStore?: MaterializationStore | "CONFIDENCE_REMOTE_STORE";
@@ -419,6 +422,7 @@ declare class ConfidenceServerProviderLocal implements Provider {
419
422
  status: ProviderStatus;
420
423
  private readonly main;
421
424
  private readonly fetch;
425
+ private readonly stateUpdateInterval;
422
426
  private readonly flushInterval;
423
427
  private readonly materializationStore;
424
428
  private stateEtag;