@spotify-confidence/openfeature-server-provider-local 0.9.1 → 0.10.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.
@@ -773,6 +773,7 @@ let ResolveReason = /* @__PURE__ */ function(ResolveReason$1) {
773
773
  ResolveReason$1[ResolveReason$1["RESOLVE_REASON_TARGETING_KEY_ERROR"] = 5] = "RESOLVE_REASON_TARGETING_KEY_ERROR";
774
774
  ResolveReason$1[ResolveReason$1["RESOLVE_REASON_ERROR"] = 6] = "RESOLVE_REASON_ERROR";
775
775
  ResolveReason$1[ResolveReason$1["RESOLVE_REASON_UNRECOGNIZED_TARGETING_RULE"] = 7] = "RESOLVE_REASON_UNRECOGNIZED_TARGETING_RULE";
776
+ ResolveReason$1[ResolveReason$1["RESOLVE_REASON_MATERIALIZATION_NOT_SUPPORTED"] = 8] = "RESOLVE_REASON_MATERIALIZATION_NOT_SUPPORTED";
776
777
  ResolveReason$1[ResolveReason$1["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
777
778
  return ResolveReason$1;
778
779
  }({});
@@ -794,6 +795,8 @@ function resolveReasonFromJSON(object) {
794
795
  case "RESOLVE_REASON_ERROR": return ResolveReason.RESOLVE_REASON_ERROR;
795
796
  case 7:
796
797
  case "RESOLVE_REASON_UNRECOGNIZED_TARGETING_RULE": return ResolveReason.RESOLVE_REASON_UNRECOGNIZED_TARGETING_RULE;
798
+ case 8:
799
+ case "RESOLVE_REASON_MATERIALIZATION_NOT_SUPPORTED": return ResolveReason.RESOLVE_REASON_MATERIALIZATION_NOT_SUPPORTED;
797
800
  case -1:
798
801
  case "UNRECOGNIZED":
799
802
  default: return ResolveReason.UNRECOGNIZED;
@@ -809,6 +812,7 @@ function resolveReasonToJSON(object) {
809
812
  case ResolveReason.RESOLVE_REASON_TARGETING_KEY_ERROR: return "RESOLVE_REASON_TARGETING_KEY_ERROR";
810
813
  case ResolveReason.RESOLVE_REASON_ERROR: return "RESOLVE_REASON_ERROR";
811
814
  case ResolveReason.RESOLVE_REASON_UNRECOGNIZED_TARGETING_RULE: return "RESOLVE_REASON_UNRECOGNIZED_TARGETING_RULE";
815
+ case ResolveReason.RESOLVE_REASON_MATERIALIZATION_NOT_SUPPORTED: return "RESOLVE_REASON_MATERIALIZATION_NOT_SUPPORTED";
812
816
  case ResolveReason.UNRECOGNIZED:
813
817
  default: return "UNRECOGNIZED";
814
818
  }
@@ -1113,14 +1117,14 @@ const ResolveFlagsResponse = {
1113
1117
  fromJSON(object) {
1114
1118
  return {
1115
1119
  resolvedFlags: globalThis.Array.isArray(object?.resolvedFlags) ? object.resolvedFlags.map((e) => ResolvedFlag.fromJSON(e)) : [],
1116
- resolveToken: isSet$3(object.resolveToken) ? bytesFromBase64$2(object.resolveToken) : new Uint8Array(0),
1120
+ resolveToken: isSet$3(object.resolveToken) ? bytesFromBase64$3(object.resolveToken) : new Uint8Array(0),
1117
1121
  resolveId: isSet$3(object.resolveId) ? globalThis.String(object.resolveId) : ""
1118
1122
  };
1119
1123
  },
1120
1124
  toJSON(message) {
1121
1125
  const obj = {};
1122
1126
  if (message.resolvedFlags?.length) obj.resolvedFlags = message.resolvedFlags.map((e) => ResolvedFlag.toJSON(e));
1123
- if (message.resolveToken.length !== 0) obj.resolveToken = base64FromBytes$2(message.resolveToken);
1127
+ if (message.resolveToken.length !== 0) obj.resolveToken = base64FromBytes$3(message.resolveToken);
1124
1128
  if (message.resolveId !== "") obj.resolveId = message.resolveId;
1125
1129
  return obj;
1126
1130
  },
@@ -1190,7 +1194,7 @@ const ApplyFlagsRequest = {
1190
1194
  return {
1191
1195
  flags: globalThis.Array.isArray(object?.flags) ? object.flags.map((e) => AppliedFlag.fromJSON(e)) : [],
1192
1196
  clientSecret: isSet$3(object.clientSecret) ? globalThis.String(object.clientSecret) : "",
1193
- resolveToken: isSet$3(object.resolveToken) ? bytesFromBase64$2(object.resolveToken) : new Uint8Array(0),
1197
+ resolveToken: isSet$3(object.resolveToken) ? bytesFromBase64$3(object.resolveToken) : new Uint8Array(0),
1194
1198
  sendTime: isSet$3(object.sendTime) ? fromJsonTimestamp(object.sendTime) : void 0,
1195
1199
  sdk: isSet$3(object.sdk) ? Sdk.fromJSON(object.sdk) : void 0
1196
1200
  };
@@ -1199,7 +1203,7 @@ const ApplyFlagsRequest = {
1199
1203
  const obj = {};
1200
1204
  if (message.flags?.length) obj.flags = message.flags.map((e) => AppliedFlag.toJSON(e));
1201
1205
  if (message.clientSecret !== "") obj.clientSecret = message.clientSecret;
1202
- if (message.resolveToken.length !== 0) obj.resolveToken = base64FromBytes$2(message.resolveToken);
1206
+ if (message.resolveToken.length !== 0) obj.resolveToken = base64FromBytes$3(message.resolveToken);
1203
1207
  if (message.sendTime !== void 0) obj.sendTime = message.sendTime.toISOString();
1204
1208
  if (message.sdk !== void 0) obj.sdk = Sdk.toJSON(message.sdk);
1205
1209
  return obj;
@@ -1363,7 +1367,7 @@ const ResolvedFlag = {
1363
1367
  return message;
1364
1368
  }
1365
1369
  };
1366
- function bytesFromBase64$2(b64) {
1370
+ function bytesFromBase64$3(b64) {
1367
1371
  if (globalThis.Buffer) return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
1368
1372
  else {
1369
1373
  const bin = globalThis.atob(b64);
@@ -1372,7 +1376,7 @@ function bytesFromBase64$2(b64) {
1372
1376
  return arr;
1373
1377
  }
1374
1378
  }
1375
- function base64FromBytes$2(arr) {
1379
+ function base64FromBytes$3(arr) {
1376
1380
  if (globalThis.Buffer) return globalThis.Buffer.from(arr).toString("base64");
1377
1381
  else {
1378
1382
  const bin = [];
@@ -1406,7 +1410,7 @@ function isObject(value) {
1406
1410
  function isSet$3(value) {
1407
1411
  return value !== null && value !== void 0;
1408
1412
  }
1409
- const VERSION = "0.9.1";
1413
+ const VERSION = "0.10.1";
1410
1414
  const NOOP_LOG_FN = Object.assign(() => {}, { enabled: false });
1411
1415
  const debugBackend = loadDebug();
1412
1416
  const logger$2 = new class LoggerImpl {
@@ -1539,7 +1543,7 @@ function hasKey(obj, key) {
1539
1543
  function castStringToEnum(value) {
1540
1544
  return value;
1541
1545
  }
1542
- function bytesFromBase64(b64) {
1546
+ function bytesFromBase64$1(b64) {
1543
1547
  if (globalThis.Buffer) return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
1544
1548
  else {
1545
1549
  const bin = globalThis.atob(b64);
@@ -1548,7 +1552,7 @@ function bytesFromBase64(b64) {
1548
1552
  return arr;
1549
1553
  }
1550
1554
  }
1551
- function base64FromBytes(arr) {
1555
+ function base64FromBytes$1(arr) {
1552
1556
  if (globalThis.Buffer) return globalThis.Buffer.from(arr).toString("base64");
1553
1557
  else {
1554
1558
  const bin = [];
@@ -2259,6 +2263,53 @@ var ConfidenceRemoteMaterializationStore = class {
2259
2263
  if (!response.ok) throw new Error(`Failed to write materializations: ${response.status} ${response.statusText}`);
2260
2264
  }
2261
2265
  };
2266
+ function materializationRecordsToReadOps(records) {
2267
+ return records.map((record) => {
2268
+ if (record.rule) return {
2269
+ op: "variant",
2270
+ unit: record.unit,
2271
+ materialization: record.materialization,
2272
+ rule: record.rule
2273
+ };
2274
+ return {
2275
+ op: "inclusion",
2276
+ unit: record.unit,
2277
+ materialization: record.materialization
2278
+ };
2279
+ });
2280
+ }
2281
+ function readResultsToMaterializationRecords(results) {
2282
+ return results.flatMap((result) => {
2283
+ switch (result.op) {
2284
+ case "variant":
2285
+ if (result.variant) return [{
2286
+ unit: result.unit,
2287
+ materialization: result.materialization,
2288
+ rule: result.rule,
2289
+ variant: result.variant
2290
+ }];
2291
+ return [];
2292
+ case "inclusion":
2293
+ if (result.included) return [{
2294
+ unit: result.unit,
2295
+ materialization: result.materialization,
2296
+ rule: "",
2297
+ variant: ""
2298
+ }];
2299
+ return [];
2300
+ }
2301
+ return [];
2302
+ });
2303
+ }
2304
+ function materializationRecordsToWriteOps(records) {
2305
+ return records.map((record) => ({
2306
+ op: "variant",
2307
+ unit: record.unit,
2308
+ materialization: record.materialization,
2309
+ rule: record.rule,
2310
+ variant: record.variant
2311
+ }));
2312
+ }
2262
2313
  function readOpsToProto(readOps) {
2263
2314
  return { ops: readOps.flatMap((readOp) => {
2264
2315
  switch (readOp.op) {
@@ -2275,22 +2326,6 @@ function readOpsToProto(readOps) {
2275
2326
  return [];
2276
2327
  }) };
2277
2328
  }
2278
- function readOpsFromProto(readOpReq) {
2279
- return readOpReq.ops.flatMap(({ variantReadOp, inclusionReadOp }) => {
2280
- if (variantReadOp) return [{
2281
- op: "variant",
2282
- unit: variantReadOp.unit,
2283
- materialization: variantReadOp.materialization,
2284
- rule: variantReadOp.rule
2285
- }];
2286
- if (inclusionReadOp) return [{
2287
- op: "inclusion",
2288
- unit: inclusionReadOp.unit,
2289
- materialization: inclusionReadOp.materialization
2290
- }];
2291
- return [];
2292
- });
2293
- }
2294
2329
  function readResultFromProto(result) {
2295
2330
  return result.results.flatMap(({ inclusionResult, variantResult }) => {
2296
2331
  if (inclusionResult) return [{
@@ -2309,24 +2344,6 @@ function readResultFromProto(result) {
2309
2344
  return [];
2310
2345
  });
2311
2346
  }
2312
- function readResultToProto(readResults) {
2313
- return { results: readResults.flatMap((readResult) => {
2314
- switch (readResult.op) {
2315
- case "inclusion": return [{ inclusionResult: {
2316
- unit: readResult.unit,
2317
- materialization: readResult.materialization,
2318
- isIncluded: readResult.included
2319
- } }];
2320
- case "variant": return [{ variantResult: {
2321
- unit: readResult.unit,
2322
- materialization: readResult.materialization,
2323
- rule: readResult.rule,
2324
- variant: readResult.variant ?? ""
2325
- } }];
2326
- }
2327
- return [];
2328
- }) };
2329
- }
2330
2347
  function writeOpsToProto(writeOps) {
2331
2348
  return { storeVariantOp: writeOps.flatMap((writeOp) => {
2332
2349
  switch (writeOp.op) {
@@ -2340,17 +2357,6 @@ function writeOpsToProto(writeOps) {
2340
2357
  return [];
2341
2358
  }) };
2342
2359
  }
2343
- function writeOpsFromProto(writeOpsReq) {
2344
- return writeOpsReq.storeVariantOp.map((variantData) => {
2345
- return {
2346
- op: "variant",
2347
- unit: variantData.unit,
2348
- materialization: variantData.materialization,
2349
- rule: variantData.rule,
2350
- variant: variantData.variant
2351
- };
2352
- });
2353
- }
2354
2360
  function createBaseVoid() {
2355
2361
  return {};
2356
2362
  }
@@ -2386,13 +2392,15 @@ const Void = {
2386
2392
  function createBaseSetResolverStateRequest() {
2387
2393
  return {
2388
2394
  state: new Uint8Array(0),
2389
- accountId: ""
2395
+ accountId: "",
2396
+ sdk: void 0
2390
2397
  };
2391
2398
  }
2392
2399
  const SetResolverStateRequest = {
2393
2400
  encode(message, writer = new BinaryWriter()) {
2394
2401
  if (message.state.length !== 0) writer.uint32(10).bytes(message.state);
2395
2402
  if (message.accountId !== "") writer.uint32(18).string(message.accountId);
2403
+ if (message.sdk !== void 0) Sdk.encode(message.sdk, writer.uint32(26).fork()).join();
2396
2404
  return writer;
2397
2405
  },
2398
2406
  decode(input, length) {
@@ -2410,6 +2418,10 @@ const SetResolverStateRequest = {
2410
2418
  if (tag !== 18) break;
2411
2419
  message.accountId = reader.string();
2412
2420
  continue;
2421
+ case 3:
2422
+ if (tag !== 26) break;
2423
+ message.sdk = Sdk.decode(reader, reader.uint32());
2424
+ continue;
2413
2425
  }
2414
2426
  if ((tag & 7) === 4 || tag === 0) break;
2415
2427
  reader.skip(tag & 7);
@@ -2418,14 +2430,16 @@ const SetResolverStateRequest = {
2418
2430
  },
2419
2431
  fromJSON(object) {
2420
2432
  return {
2421
- state: isSet$1(object.state) ? bytesFromBase64$1(object.state) : new Uint8Array(0),
2422
- accountId: isSet$1(object.accountId) ? globalThis.String(object.accountId) : ""
2433
+ state: isSet$1(object.state) ? bytesFromBase64$2(object.state) : new Uint8Array(0),
2434
+ accountId: isSet$1(object.accountId) ? globalThis.String(object.accountId) : "",
2435
+ sdk: isSet$1(object.sdk) ? Sdk.fromJSON(object.sdk) : void 0
2423
2436
  };
2424
2437
  },
2425
2438
  toJSON(message) {
2426
2439
  const obj = {};
2427
- if (message.state.length !== 0) obj.state = base64FromBytes$1(message.state);
2440
+ if (message.state.length !== 0) obj.state = base64FromBytes$2(message.state);
2428
2441
  if (message.accountId !== "") obj.accountId = message.accountId;
2442
+ if (message.sdk !== void 0) obj.sdk = Sdk.toJSON(message.sdk);
2429
2443
  return obj;
2430
2444
  },
2431
2445
  create(base) {
@@ -2435,6 +2449,7 @@ const SetResolverStateRequest = {
2435
2449
  const message = createBaseSetResolverStateRequest();
2436
2450
  message.state = object.state ?? new Uint8Array(0);
2437
2451
  message.accountId = object.accountId ?? "";
2452
+ message.sdk = object.sdk !== void 0 && object.sdk !== null ? Sdk.fromPartial(object.sdk) : void 0;
2438
2453
  return message;
2439
2454
  }
2440
2455
  };
@@ -2464,11 +2479,11 @@ const Request = {
2464
2479
  return message;
2465
2480
  },
2466
2481
  fromJSON(object) {
2467
- return { data: isSet$1(object.data) ? bytesFromBase64$1(object.data) : new Uint8Array(0) };
2482
+ return { data: isSet$1(object.data) ? bytesFromBase64$2(object.data) : new Uint8Array(0) };
2468
2483
  },
2469
2484
  toJSON(message) {
2470
2485
  const obj = {};
2471
- if (message.data.length !== 0) obj.data = base64FromBytes$1(message.data);
2486
+ if (message.data.length !== 0) obj.data = base64FromBytes$2(message.data);
2472
2487
  return obj;
2473
2488
  },
2474
2489
  create(base) {
@@ -2515,13 +2530,13 @@ const Response$1 = {
2515
2530
  },
2516
2531
  fromJSON(object) {
2517
2532
  return {
2518
- data: isSet$1(object.data) ? bytesFromBase64$1(object.data) : void 0,
2533
+ data: isSet$1(object.data) ? bytesFromBase64$2(object.data) : void 0,
2519
2534
  error: isSet$1(object.error) ? globalThis.String(object.error) : void 0
2520
2535
  };
2521
2536
  },
2522
2537
  toJSON(message) {
2523
2538
  const obj = {};
2524
- if (message.data !== void 0) obj.data = base64FromBytes$1(message.data);
2539
+ if (message.data !== void 0) obj.data = base64FromBytes$2(message.data);
2525
2540
  if (message.error !== void 0) obj.error = message.error;
2526
2541
  return obj;
2527
2542
  },
@@ -2535,7 +2550,7 @@ const Response$1 = {
2535
2550
  return message;
2536
2551
  }
2537
2552
  };
2538
- function bytesFromBase64$1(b64) {
2553
+ function bytesFromBase64$2(b64) {
2539
2554
  if (globalThis.Buffer) return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
2540
2555
  else {
2541
2556
  const bin = globalThis.atob(b64);
@@ -2544,7 +2559,7 @@ function bytesFromBase64$1(b64) {
2544
2559
  return arr;
2545
2560
  }
2546
2561
  }
2547
- function base64FromBytes$1(arr) {
2562
+ function base64FromBytes$2(arr) {
2548
2563
  if (globalThis.Buffer) return globalThis.Buffer.from(arr).toString("base64");
2549
2564
  else {
2550
2565
  const bin = [];
@@ -2565,8 +2580,8 @@ let ErrorCode = /* @__PURE__ */ function(ErrorCode$1) {
2565
2580
  ErrorCode$1["GENERAL"] = "GENERAL";
2566
2581
  return ErrorCode$1;
2567
2582
  }({});
2568
- const encodeToken = base64FromBytes;
2569
- const decodeToken = bytesFromBase64;
2583
+ const encodeToken = base64FromBytes$1;
2584
+ const decodeToken = bytesFromBase64$1;
2570
2585
  function create({ resolveId, resolveToken, resolvedFlags }) {
2571
2586
  return {
2572
2587
  flags: Object.fromEntries(resolvedFlags.map(({ flag, reason, variant, value, shouldApply }) => {
@@ -2673,7 +2688,7 @@ function convertReason(reason) {
2673
2688
  const logger$1 = getLogger("provider");
2674
2689
  const DEFAULT_INITIALIZE_TIMEOUT = 3e4;
2675
2690
  const DEFAULT_STATE_INTERVAL = 3e4;
2676
- const DEFAULT_FLUSH_INTERVAL = 1e4;
2691
+ const DEFAULT_FLUSH_INTERVAL = 15e3;
2677
2692
  var ConfidenceServerProviderLocal = class ConfidenceServerProviderLocal {
2678
2693
  metadata = { name: "ConfidenceServerProviderLocal" };
2679
2694
  status = castStringToEnum("NOT_READY");
@@ -2699,7 +2714,7 @@ var ConfidenceServerProviderLocal = class ConfidenceServerProviderLocal {
2699
2714
  maxAttempts: Infinity,
2700
2715
  baseInterval: 500,
2701
2716
  maxInterval: this.stateUpdateInterval
2702
- }), withStallTimeout(500)],
2717
+ }), withStallTimeout(1 * TimeUnit.SECOND)],
2703
2718
  "https://resolver.confidence.dev/*": [withRouter({
2704
2719
  "*/v1/materialization:readMaterializedOperations": [withRetry({
2705
2720
  maxAttempts: 3,
@@ -2744,23 +2759,19 @@ var ConfidenceServerProviderLocal = class ConfidenceServerProviderLocal {
2744
2759
  this.main.abort();
2745
2760
  }
2746
2761
  async resolve(context, flagNames, apply = false) {
2747
- const stickyRequest = {
2748
- resolveRequest: {
2749
- flags: flagNames.map((name) => `flags/${name}`),
2750
- evaluationContext: ConfidenceServerProviderLocal.convertEvaluationContext(context),
2751
- apply,
2752
- clientSecret: this.options.flagClientSecret,
2753
- sdk: {
2754
- id: SdkId.SDK_ID_JS_LOCAL_SERVER_PROVIDER,
2755
- version: VERSION
2756
- }
2757
- },
2758
- materializations: [],
2759
- failFastOnSticky: false,
2760
- notProcessSticky: false
2762
+ const resolveRequest = {
2763
+ flags: flagNames.map((name) => `flags/${name}`),
2764
+ evaluationContext: ConfidenceServerProviderLocal.convertEvaluationContext(context),
2765
+ apply,
2766
+ clientSecret: this.options.flagClientSecret,
2767
+ sdk: {
2768
+ id: SdkId.SDK_ID_JS_LOCAL_SERVER_PROVIDER,
2769
+ version: VERSION
2770
+ }
2761
2771
  };
2762
2772
  try {
2763
- return create(await this.resolveWithSticky(stickyRequest));
2773
+ const processRequest = this.materializationStore ? { deferredMaterializations: resolveRequest } : { withoutMaterializations: resolveRequest };
2774
+ return create(await this.resolveProcess(processRequest));
2764
2775
  } catch (err) {
2765
2776
  return error(ErrorCode.GENERAL, String(err));
2766
2777
  }
@@ -2774,19 +2785,30 @@ var ConfidenceServerProviderLocal = class ConfidenceServerProviderLocal {
2774
2785
  this.flushAssigned();
2775
2786
  }
2776
2787
  }
2777
- async resolveWithSticky(stickyRequest) {
2778
- let stickyResponse = this.resolver.resolveWithSticky(stickyRequest);
2779
- if (stickyResponse.readOpsRequest) {
2780
- const { results: materializations } = await this.readMaterializations(stickyResponse.readOpsRequest);
2781
- stickyResponse = this.resolver.resolveWithSticky({
2782
- ...stickyRequest,
2783
- materializations
2784
- });
2788
+ async resolveProcess(request) {
2789
+ const response = this.resolver.resolveProcess(request);
2790
+ if (response.suspended) {
2791
+ const { materializationsToRead, state } = response.suspended;
2792
+ const readOps = materializationRecordsToReadOps(materializationsToRead);
2793
+ const readResults = await this.readMaterializations(readOps);
2794
+ const materializations = readResultsToMaterializationRecords(readResults);
2795
+ const resumeResponse = this.resolver.resolveProcess({ resume: {
2796
+ materializations,
2797
+ state
2798
+ } });
2799
+ if (!resumeResponse.resolved) throw new Error("Resolve still suspended after providing materializations");
2800
+ this.handleMaterializationWrites(resumeResponse.resolved.materializationsToWrite);
2801
+ return ResolveFlagsResponse.create(resumeResponse.resolved.response);
2802
+ }
2803
+ if (!response.resolved) throw new Error("Unexpected empty resolve response");
2804
+ this.handleMaterializationWrites(response.resolved.materializationsToWrite);
2805
+ return ResolveFlagsResponse.create(response.resolved.response);
2806
+ }
2807
+ handleMaterializationWrites(records) {
2808
+ if (records.length > 0) {
2809
+ const writeOps = materializationRecordsToWriteOps(records);
2810
+ this.writeMaterializations(writeOps);
2785
2811
  }
2786
- if (!stickyResponse.success) throw new Error("Missing materializations");
2787
- const { materializationUpdates: storeVariantOp, response: resolveResponse } = stickyResponse.success;
2788
- if (storeVariantOp.length) this.writeMaterializations({ storeVariantOp });
2789
- return ResolveFlagsResponse.create(resolveResponse);
2790
2812
  }
2791
2813
  async updateState(signal) {
2792
2814
  const cdnUrl = `https://confidence-resolver-state-cdn.spotifycdn.com/${await sha256Hex(this.options.flagClientSecret)}`;
@@ -2800,7 +2822,12 @@ var ConfidenceServerProviderLocal = class ConfidenceServerProviderLocal {
2800
2822
  if (!resp.ok) throw new Error(`Failed to fetch state: ${resp.status} ${resp.statusText}`);
2801
2823
  this.stateEtag = resp.headers.get("etag");
2802
2824
  const bytes = new Uint8Array(await resp.arrayBuffer());
2803
- this.resolver.setResolverState(SetResolverStateRequest.decode(bytes));
2825
+ const stateRequest = SetResolverStateRequest.decode(bytes);
2826
+ stateRequest.sdk = {
2827
+ id: SdkId.SDK_ID_JS_LOCAL_SERVER_PROVIDER,
2828
+ version: VERSION
2829
+ };
2830
+ this.resolver.setResolverState(stateRequest);
2804
2831
  }
2805
2832
  async flush(signal) {
2806
2833
  const writeFlagLogRequest = this.resolver.flushLogs();
@@ -2827,18 +2854,15 @@ var ConfidenceServerProviderLocal = class ConfidenceServerProviderLocal {
2827
2854
  throw err;
2828
2855
  }
2829
2856
  }
2830
- async readMaterializations(readOpsReq) {
2857
+ async readMaterializations(readOps) {
2831
2858
  const materializationStore = this.materializationStore;
2832
- if (materializationStore && typeof materializationStore.readMaterializations === "function") {
2833
- const result = await materializationStore.readMaterializations(readOpsFromProto(readOpsReq));
2834
- return readResultToProto(result);
2835
- }
2859
+ if (materializationStore && typeof materializationStore.readMaterializations === "function") return materializationStore.readMaterializations(readOps);
2836
2860
  throw new Error("Read materialization not supported");
2837
2861
  }
2838
- writeMaterializations(writeOpsRequest) {
2862
+ writeMaterializations(writeOps) {
2839
2863
  const materializationStore = this.materializationStore;
2840
2864
  if (materializationStore && typeof materializationStore.writeMaterializations === "function") {
2841
- materializationStore.writeMaterializations(writeOpsFromProto(writeOpsRequest)).catch((e) => {
2865
+ materializationStore.writeMaterializations(writeOps).catch((e) => {
2842
2866
  logger$1.warn("Failed to write materialization", e);
2843
2867
  });
2844
2868
  return;
@@ -2880,44 +2904,105 @@ var ConfidenceServerProviderLocal = class ConfidenceServerProviderLocal {
2880
2904
  this.resolver.applyFlags(request);
2881
2905
  }
2882
2906
  };
2883
- function createBaseResolveWithStickyRequest() {
2907
+ function createBaseResolveProcessRequest() {
2884
2908
  return {
2885
- resolveRequest: void 0,
2886
- failFastOnSticky: false,
2887
- notProcessSticky: false,
2888
- materializations: []
2909
+ deferredMaterializations: void 0,
2910
+ staticMaterializations: void 0,
2911
+ withoutMaterializations: void 0,
2912
+ resume: void 0
2889
2913
  };
2890
2914
  }
2891
- const ResolveWithStickyRequest = {
2915
+ const ResolveProcessRequest = {
2892
2916
  encode(message, writer = new BinaryWriter()) {
2893
- if (message.resolveRequest !== void 0) ResolveFlagsRequest.encode(message.resolveRequest, writer.uint32(10).fork()).join();
2894
- if (message.failFastOnSticky !== false) writer.uint32(24).bool(message.failFastOnSticky);
2895
- if (message.notProcessSticky !== false) writer.uint32(32).bool(message.notProcessSticky);
2896
- for (const v of message.materializations) ReadResult.encode(v, writer.uint32(42).fork()).join();
2917
+ if (message.deferredMaterializations !== void 0) ResolveFlagsRequest.encode(message.deferredMaterializations, writer.uint32(10).fork()).join();
2918
+ if (message.staticMaterializations !== void 0) ResolveProcessRequest_StaticMaterializations.encode(message.staticMaterializations, writer.uint32(18).fork()).join();
2919
+ if (message.withoutMaterializations !== void 0) ResolveFlagsRequest.encode(message.withoutMaterializations, writer.uint32(26).fork()).join();
2920
+ if (message.resume !== void 0) ResolveProcessRequest_Resume.encode(message.resume, writer.uint32(34).fork()).join();
2897
2921
  return writer;
2898
2922
  },
2899
2923
  decode(input, length) {
2900
2924
  const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2901
2925
  const end = length === void 0 ? reader.len : reader.pos + length;
2902
- const message = createBaseResolveWithStickyRequest();
2926
+ const message = createBaseResolveProcessRequest();
2903
2927
  while (reader.pos < end) {
2904
2928
  const tag = reader.uint32();
2905
2929
  switch (tag >>> 3) {
2906
2930
  case 1:
2907
2931
  if (tag !== 10) break;
2908
- message.resolveRequest = ResolveFlagsRequest.decode(reader, reader.uint32());
2932
+ message.deferredMaterializations = ResolveFlagsRequest.decode(reader, reader.uint32());
2933
+ continue;
2934
+ case 2:
2935
+ if (tag !== 18) break;
2936
+ message.staticMaterializations = ResolveProcessRequest_StaticMaterializations.decode(reader, reader.uint32());
2909
2937
  continue;
2910
2938
  case 3:
2911
- if (tag !== 24) break;
2912
- message.failFastOnSticky = reader.bool();
2939
+ if (tag !== 26) break;
2940
+ message.withoutMaterializations = ResolveFlagsRequest.decode(reader, reader.uint32());
2913
2941
  continue;
2914
2942
  case 4:
2915
- if (tag !== 32) break;
2916
- message.notProcessSticky = reader.bool();
2943
+ if (tag !== 34) break;
2944
+ message.resume = ResolveProcessRequest_Resume.decode(reader, reader.uint32());
2917
2945
  continue;
2918
- case 5:
2919
- if (tag !== 42) break;
2920
- message.materializations.push(ReadResult.decode(reader, reader.uint32()));
2946
+ }
2947
+ if ((tag & 7) === 4 || tag === 0) break;
2948
+ reader.skip(tag & 7);
2949
+ }
2950
+ return message;
2951
+ },
2952
+ fromJSON(object) {
2953
+ return {
2954
+ deferredMaterializations: isSet(object.deferredMaterializations) ? ResolveFlagsRequest.fromJSON(object.deferredMaterializations) : void 0,
2955
+ staticMaterializations: isSet(object.staticMaterializations) ? ResolveProcessRequest_StaticMaterializations.fromJSON(object.staticMaterializations) : void 0,
2956
+ withoutMaterializations: isSet(object.withoutMaterializations) ? ResolveFlagsRequest.fromJSON(object.withoutMaterializations) : void 0,
2957
+ resume: isSet(object.resume) ? ResolveProcessRequest_Resume.fromJSON(object.resume) : void 0
2958
+ };
2959
+ },
2960
+ toJSON(message) {
2961
+ const obj = {};
2962
+ if (message.deferredMaterializations !== void 0) obj.deferredMaterializations = ResolveFlagsRequest.toJSON(message.deferredMaterializations);
2963
+ if (message.staticMaterializations !== void 0) obj.staticMaterializations = ResolveProcessRequest_StaticMaterializations.toJSON(message.staticMaterializations);
2964
+ if (message.withoutMaterializations !== void 0) obj.withoutMaterializations = ResolveFlagsRequest.toJSON(message.withoutMaterializations);
2965
+ if (message.resume !== void 0) obj.resume = ResolveProcessRequest_Resume.toJSON(message.resume);
2966
+ return obj;
2967
+ },
2968
+ create(base) {
2969
+ return ResolveProcessRequest.fromPartial(base ?? {});
2970
+ },
2971
+ fromPartial(object) {
2972
+ const message = createBaseResolveProcessRequest();
2973
+ message.deferredMaterializations = object.deferredMaterializations !== void 0 && object.deferredMaterializations !== null ? ResolveFlagsRequest.fromPartial(object.deferredMaterializations) : void 0;
2974
+ message.staticMaterializations = object.staticMaterializations !== void 0 && object.staticMaterializations !== null ? ResolveProcessRequest_StaticMaterializations.fromPartial(object.staticMaterializations) : void 0;
2975
+ message.withoutMaterializations = object.withoutMaterializations !== void 0 && object.withoutMaterializations !== null ? ResolveFlagsRequest.fromPartial(object.withoutMaterializations) : void 0;
2976
+ message.resume = object.resume !== void 0 && object.resume !== null ? ResolveProcessRequest_Resume.fromPartial(object.resume) : void 0;
2977
+ return message;
2978
+ }
2979
+ };
2980
+ function createBaseResolveProcessRequest_StaticMaterializations() {
2981
+ return {
2982
+ resolveRequest: void 0,
2983
+ materializations: []
2984
+ };
2985
+ }
2986
+ const ResolveProcessRequest_StaticMaterializations = {
2987
+ encode(message, writer = new BinaryWriter()) {
2988
+ if (message.resolveRequest !== void 0) ResolveFlagsRequest.encode(message.resolveRequest, writer.uint32(10).fork()).join();
2989
+ for (const v of message.materializations) MaterializationRecord.encode(v, writer.uint32(18).fork()).join();
2990
+ return writer;
2991
+ },
2992
+ decode(input, length) {
2993
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2994
+ const end = length === void 0 ? reader.len : reader.pos + length;
2995
+ const message = createBaseResolveProcessRequest_StaticMaterializations();
2996
+ while (reader.pos < end) {
2997
+ const tag = reader.uint32();
2998
+ switch (tag >>> 3) {
2999
+ case 1:
3000
+ if (tag !== 10) break;
3001
+ message.resolveRequest = ResolveFlagsRequest.decode(reader, reader.uint32());
3002
+ continue;
3003
+ case 2:
3004
+ if (tag !== 18) break;
3005
+ message.materializations.push(MaterializationRecord.decode(reader, reader.uint32()));
2921
3006
  continue;
2922
3007
  }
2923
3008
  if ((tag & 7) === 4 || tag === 0) break;
@@ -2928,57 +3013,51 @@ const ResolveWithStickyRequest = {
2928
3013
  fromJSON(object) {
2929
3014
  return {
2930
3015
  resolveRequest: isSet(object.resolveRequest) ? ResolveFlagsRequest.fromJSON(object.resolveRequest) : void 0,
2931
- failFastOnSticky: isSet(object.failFastOnSticky) ? globalThis.Boolean(object.failFastOnSticky) : false,
2932
- notProcessSticky: isSet(object.notProcessSticky) ? globalThis.Boolean(object.notProcessSticky) : false,
2933
- materializations: globalThis.Array.isArray(object?.materializations) ? object.materializations.map((e) => ReadResult.fromJSON(e)) : []
3016
+ materializations: globalThis.Array.isArray(object?.materializations) ? object.materializations.map((e) => MaterializationRecord.fromJSON(e)) : []
2934
3017
  };
2935
3018
  },
2936
3019
  toJSON(message) {
2937
3020
  const obj = {};
2938
3021
  if (message.resolveRequest !== void 0) obj.resolveRequest = ResolveFlagsRequest.toJSON(message.resolveRequest);
2939
- if (message.failFastOnSticky !== false) obj.failFastOnSticky = message.failFastOnSticky;
2940
- if (message.notProcessSticky !== false) obj.notProcessSticky = message.notProcessSticky;
2941
- if (message.materializations?.length) obj.materializations = message.materializations.map((e) => ReadResult.toJSON(e));
3022
+ if (message.materializations?.length) obj.materializations = message.materializations.map((e) => MaterializationRecord.toJSON(e));
2942
3023
  return obj;
2943
3024
  },
2944
3025
  create(base) {
2945
- return ResolveWithStickyRequest.fromPartial(base ?? {});
3026
+ return ResolveProcessRequest_StaticMaterializations.fromPartial(base ?? {});
2946
3027
  },
2947
3028
  fromPartial(object) {
2948
- const message = createBaseResolveWithStickyRequest();
3029
+ const message = createBaseResolveProcessRequest_StaticMaterializations();
2949
3030
  message.resolveRequest = object.resolveRequest !== void 0 && object.resolveRequest !== null ? ResolveFlagsRequest.fromPartial(object.resolveRequest) : void 0;
2950
- message.failFastOnSticky = object.failFastOnSticky ?? false;
2951
- message.notProcessSticky = object.notProcessSticky ?? false;
2952
- message.materializations = object.materializations?.map((e) => ReadResult.fromPartial(e)) || [];
3031
+ message.materializations = object.materializations?.map((e) => MaterializationRecord.fromPartial(e)) || [];
2953
3032
  return message;
2954
3033
  }
2955
3034
  };
2956
- function createBaseResolveWithStickyResponse() {
3035
+ function createBaseResolveProcessRequest_Resume() {
2957
3036
  return {
2958
- success: void 0,
2959
- readOpsRequest: void 0
3037
+ materializations: [],
3038
+ state: new Uint8Array(0)
2960
3039
  };
2961
3040
  }
2962
- const ResolveWithStickyResponse = {
3041
+ const ResolveProcessRequest_Resume = {
2963
3042
  encode(message, writer = new BinaryWriter()) {
2964
- if (message.success !== void 0) ResolveWithStickyResponse_Success.encode(message.success, writer.uint32(10).fork()).join();
2965
- if (message.readOpsRequest !== void 0) ReadOperationsRequest.encode(message.readOpsRequest, writer.uint32(26).fork()).join();
3043
+ for (const v of message.materializations) MaterializationRecord.encode(v, writer.uint32(10).fork()).join();
3044
+ if (message.state.length !== 0) writer.uint32(18).bytes(message.state);
2966
3045
  return writer;
2967
3046
  },
2968
3047
  decode(input, length) {
2969
3048
  const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2970
3049
  const end = length === void 0 ? reader.len : reader.pos + length;
2971
- const message = createBaseResolveWithStickyResponse();
3050
+ const message = createBaseResolveProcessRequest_Resume();
2972
3051
  while (reader.pos < end) {
2973
3052
  const tag = reader.uint32();
2974
3053
  switch (tag >>> 3) {
2975
3054
  case 1:
2976
3055
  if (tag !== 10) break;
2977
- message.success = ResolveWithStickyResponse_Success.decode(reader, reader.uint32());
3056
+ message.materializations.push(MaterializationRecord.decode(reader, reader.uint32()));
2978
3057
  continue;
2979
- case 3:
2980
- if (tag !== 26) break;
2981
- message.readOpsRequest = ReadOperationsRequest.decode(reader, reader.uint32());
3058
+ case 2:
3059
+ if (tag !== 18) break;
3060
+ message.state = reader.bytes();
2982
3061
  continue;
2983
3062
  }
2984
3063
  if ((tag & 7) === 4 || tag === 0) break;
@@ -2988,42 +3067,97 @@ const ResolveWithStickyResponse = {
2988
3067
  },
2989
3068
  fromJSON(object) {
2990
3069
  return {
2991
- success: isSet(object.success) ? ResolveWithStickyResponse_Success.fromJSON(object.success) : void 0,
2992
- readOpsRequest: isSet(object.readOpsRequest) ? ReadOperationsRequest.fromJSON(object.readOpsRequest) : void 0
3070
+ materializations: globalThis.Array.isArray(object?.materializations) ? object.materializations.map((e) => MaterializationRecord.fromJSON(e)) : [],
3071
+ state: isSet(object.state) ? bytesFromBase64(object.state) : new Uint8Array(0)
2993
3072
  };
2994
3073
  },
2995
3074
  toJSON(message) {
2996
3075
  const obj = {};
2997
- if (message.success !== void 0) obj.success = ResolveWithStickyResponse_Success.toJSON(message.success);
2998
- if (message.readOpsRequest !== void 0) obj.readOpsRequest = ReadOperationsRequest.toJSON(message.readOpsRequest);
3076
+ if (message.materializations?.length) obj.materializations = message.materializations.map((e) => MaterializationRecord.toJSON(e));
3077
+ if (message.state.length !== 0) obj.state = base64FromBytes(message.state);
2999
3078
  return obj;
3000
3079
  },
3001
3080
  create(base) {
3002
- return ResolveWithStickyResponse.fromPartial(base ?? {});
3081
+ return ResolveProcessRequest_Resume.fromPartial(base ?? {});
3003
3082
  },
3004
3083
  fromPartial(object) {
3005
- const message = createBaseResolveWithStickyResponse();
3006
- message.success = object.success !== void 0 && object.success !== null ? ResolveWithStickyResponse_Success.fromPartial(object.success) : void 0;
3007
- message.readOpsRequest = object.readOpsRequest !== void 0 && object.readOpsRequest !== null ? ReadOperationsRequest.fromPartial(object.readOpsRequest) : void 0;
3084
+ const message = createBaseResolveProcessRequest_Resume();
3085
+ message.materializations = object.materializations?.map((e) => MaterializationRecord.fromPartial(e)) || [];
3086
+ message.state = object.state ?? new Uint8Array(0);
3008
3087
  return message;
3009
3088
  }
3010
3089
  };
3011
- function createBaseResolveWithStickyResponse_Success() {
3090
+ function createBaseResolveProcessResponse() {
3091
+ return {
3092
+ resolved: void 0,
3093
+ suspended: void 0
3094
+ };
3095
+ }
3096
+ const ResolveProcessResponse = {
3097
+ encode(message, writer = new BinaryWriter()) {
3098
+ if (message.resolved !== void 0) ResolveProcessResponse_Resolved.encode(message.resolved, writer.uint32(10).fork()).join();
3099
+ if (message.suspended !== void 0) ResolveProcessResponse_Suspended.encode(message.suspended, writer.uint32(18).fork()).join();
3100
+ return writer;
3101
+ },
3102
+ decode(input, length) {
3103
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
3104
+ const end = length === void 0 ? reader.len : reader.pos + length;
3105
+ const message = createBaseResolveProcessResponse();
3106
+ while (reader.pos < end) {
3107
+ const tag = reader.uint32();
3108
+ switch (tag >>> 3) {
3109
+ case 1:
3110
+ if (tag !== 10) break;
3111
+ message.resolved = ResolveProcessResponse_Resolved.decode(reader, reader.uint32());
3112
+ continue;
3113
+ case 2:
3114
+ if (tag !== 18) break;
3115
+ message.suspended = ResolveProcessResponse_Suspended.decode(reader, reader.uint32());
3116
+ continue;
3117
+ }
3118
+ if ((tag & 7) === 4 || tag === 0) break;
3119
+ reader.skip(tag & 7);
3120
+ }
3121
+ return message;
3122
+ },
3123
+ fromJSON(object) {
3124
+ return {
3125
+ resolved: isSet(object.resolved) ? ResolveProcessResponse_Resolved.fromJSON(object.resolved) : void 0,
3126
+ suspended: isSet(object.suspended) ? ResolveProcessResponse_Suspended.fromJSON(object.suspended) : void 0
3127
+ };
3128
+ },
3129
+ toJSON(message) {
3130
+ const obj = {};
3131
+ if (message.resolved !== void 0) obj.resolved = ResolveProcessResponse_Resolved.toJSON(message.resolved);
3132
+ if (message.suspended !== void 0) obj.suspended = ResolveProcessResponse_Suspended.toJSON(message.suspended);
3133
+ return obj;
3134
+ },
3135
+ create(base) {
3136
+ return ResolveProcessResponse.fromPartial(base ?? {});
3137
+ },
3138
+ fromPartial(object) {
3139
+ const message = createBaseResolveProcessResponse();
3140
+ message.resolved = object.resolved !== void 0 && object.resolved !== null ? ResolveProcessResponse_Resolved.fromPartial(object.resolved) : void 0;
3141
+ message.suspended = object.suspended !== void 0 && object.suspended !== null ? ResolveProcessResponse_Suspended.fromPartial(object.suspended) : void 0;
3142
+ return message;
3143
+ }
3144
+ };
3145
+ function createBaseResolveProcessResponse_Resolved() {
3012
3146
  return {
3013
3147
  response: void 0,
3014
- materializationUpdates: []
3148
+ materializationsToWrite: []
3015
3149
  };
3016
3150
  }
3017
- const ResolveWithStickyResponse_Success = {
3151
+ const ResolveProcessResponse_Resolved = {
3018
3152
  encode(message, writer = new BinaryWriter()) {
3019
3153
  if (message.response !== void 0) ResolveFlagsResponse.encode(message.response, writer.uint32(10).fork()).join();
3020
- for (const v of message.materializationUpdates) VariantData.encode(v, writer.uint32(26).fork()).join();
3154
+ for (const v of message.materializationsToWrite) MaterializationRecord.encode(v, writer.uint32(18).fork()).join();
3021
3155
  return writer;
3022
3156
  },
3023
3157
  decode(input, length) {
3024
3158
  const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
3025
3159
  const end = length === void 0 ? reader.len : reader.pos + length;
3026
- const message = createBaseResolveWithStickyResponse_Success();
3160
+ const message = createBaseResolveProcessResponse_Resolved();
3027
3161
  while (reader.pos < end) {
3028
3162
  const tag = reader.uint32();
3029
3163
  switch (tag >>> 3) {
@@ -3031,9 +3165,9 @@ const ResolveWithStickyResponse_Success = {
3031
3165
  if (tag !== 10) break;
3032
3166
  message.response = ResolveFlagsResponse.decode(reader, reader.uint32());
3033
3167
  continue;
3034
- case 3:
3035
- if (tag !== 26) break;
3036
- message.materializationUpdates.push(VariantData.decode(reader, reader.uint32()));
3168
+ case 2:
3169
+ if (tag !== 18) break;
3170
+ message.materializationsToWrite.push(MaterializationRecord.decode(reader, reader.uint32()));
3037
3171
  continue;
3038
3172
  }
3039
3173
  if ((tag & 7) === 4 || tag === 0) break;
@@ -3044,25 +3178,172 @@ const ResolveWithStickyResponse_Success = {
3044
3178
  fromJSON(object) {
3045
3179
  return {
3046
3180
  response: isSet(object.response) ? ResolveFlagsResponse.fromJSON(object.response) : void 0,
3047
- materializationUpdates: globalThis.Array.isArray(object?.materializationUpdates) ? object.materializationUpdates.map((e) => VariantData.fromJSON(e)) : []
3181
+ materializationsToWrite: globalThis.Array.isArray(object?.materializationsToWrite) ? object.materializationsToWrite.map((e) => MaterializationRecord.fromJSON(e)) : []
3048
3182
  };
3049
3183
  },
3050
3184
  toJSON(message) {
3051
3185
  const obj = {};
3052
3186
  if (message.response !== void 0) obj.response = ResolveFlagsResponse.toJSON(message.response);
3053
- if (message.materializationUpdates?.length) obj.materializationUpdates = message.materializationUpdates.map((e) => VariantData.toJSON(e));
3187
+ if (message.materializationsToWrite?.length) obj.materializationsToWrite = message.materializationsToWrite.map((e) => MaterializationRecord.toJSON(e));
3054
3188
  return obj;
3055
3189
  },
3056
3190
  create(base) {
3057
- return ResolveWithStickyResponse_Success.fromPartial(base ?? {});
3191
+ return ResolveProcessResponse_Resolved.fromPartial(base ?? {});
3058
3192
  },
3059
3193
  fromPartial(object) {
3060
- const message = createBaseResolveWithStickyResponse_Success();
3194
+ const message = createBaseResolveProcessResponse_Resolved();
3061
3195
  message.response = object.response !== void 0 && object.response !== null ? ResolveFlagsResponse.fromPartial(object.response) : void 0;
3062
- message.materializationUpdates = object.materializationUpdates?.map((e) => VariantData.fromPartial(e)) || [];
3196
+ message.materializationsToWrite = object.materializationsToWrite?.map((e) => MaterializationRecord.fromPartial(e)) || [];
3063
3197
  return message;
3064
3198
  }
3065
3199
  };
3200
+ function createBaseResolveProcessResponse_Suspended() {
3201
+ return {
3202
+ materializationsToRead: [],
3203
+ state: new Uint8Array(0)
3204
+ };
3205
+ }
3206
+ const ResolveProcessResponse_Suspended = {
3207
+ encode(message, writer = new BinaryWriter()) {
3208
+ for (const v of message.materializationsToRead) MaterializationRecord.encode(v, writer.uint32(10).fork()).join();
3209
+ if (message.state.length !== 0) writer.uint32(18).bytes(message.state);
3210
+ return writer;
3211
+ },
3212
+ decode(input, length) {
3213
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
3214
+ const end = length === void 0 ? reader.len : reader.pos + length;
3215
+ const message = createBaseResolveProcessResponse_Suspended();
3216
+ while (reader.pos < end) {
3217
+ const tag = reader.uint32();
3218
+ switch (tag >>> 3) {
3219
+ case 1:
3220
+ if (tag !== 10) break;
3221
+ message.materializationsToRead.push(MaterializationRecord.decode(reader, reader.uint32()));
3222
+ continue;
3223
+ case 2:
3224
+ if (tag !== 18) break;
3225
+ message.state = reader.bytes();
3226
+ continue;
3227
+ }
3228
+ if ((tag & 7) === 4 || tag === 0) break;
3229
+ reader.skip(tag & 7);
3230
+ }
3231
+ return message;
3232
+ },
3233
+ fromJSON(object) {
3234
+ return {
3235
+ materializationsToRead: globalThis.Array.isArray(object?.materializationsToRead) ? object.materializationsToRead.map((e) => MaterializationRecord.fromJSON(e)) : [],
3236
+ state: isSet(object.state) ? bytesFromBase64(object.state) : new Uint8Array(0)
3237
+ };
3238
+ },
3239
+ toJSON(message) {
3240
+ const obj = {};
3241
+ if (message.materializationsToRead?.length) obj.materializationsToRead = message.materializationsToRead.map((e) => MaterializationRecord.toJSON(e));
3242
+ if (message.state.length !== 0) obj.state = base64FromBytes(message.state);
3243
+ return obj;
3244
+ },
3245
+ create(base) {
3246
+ return ResolveProcessResponse_Suspended.fromPartial(base ?? {});
3247
+ },
3248
+ fromPartial(object) {
3249
+ const message = createBaseResolveProcessResponse_Suspended();
3250
+ message.materializationsToRead = object.materializationsToRead?.map((e) => MaterializationRecord.fromPartial(e)) || [];
3251
+ message.state = object.state ?? new Uint8Array(0);
3252
+ return message;
3253
+ }
3254
+ };
3255
+ function createBaseMaterializationRecord() {
3256
+ return {
3257
+ unit: "",
3258
+ materialization: "",
3259
+ rule: "",
3260
+ variant: ""
3261
+ };
3262
+ }
3263
+ const MaterializationRecord = {
3264
+ encode(message, writer = new BinaryWriter()) {
3265
+ if (message.unit !== "") writer.uint32(10).string(message.unit);
3266
+ if (message.materialization !== "") writer.uint32(18).string(message.materialization);
3267
+ if (message.rule !== "") writer.uint32(26).string(message.rule);
3268
+ if (message.variant !== "") writer.uint32(34).string(message.variant);
3269
+ return writer;
3270
+ },
3271
+ decode(input, length) {
3272
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
3273
+ const end = length === void 0 ? reader.len : reader.pos + length;
3274
+ const message = createBaseMaterializationRecord();
3275
+ while (reader.pos < end) {
3276
+ const tag = reader.uint32();
3277
+ switch (tag >>> 3) {
3278
+ case 1:
3279
+ if (tag !== 10) break;
3280
+ message.unit = reader.string();
3281
+ continue;
3282
+ case 2:
3283
+ if (tag !== 18) break;
3284
+ message.materialization = reader.string();
3285
+ continue;
3286
+ case 3:
3287
+ if (tag !== 26) break;
3288
+ message.rule = reader.string();
3289
+ continue;
3290
+ case 4:
3291
+ if (tag !== 34) break;
3292
+ message.variant = reader.string();
3293
+ continue;
3294
+ }
3295
+ if ((tag & 7) === 4 || tag === 0) break;
3296
+ reader.skip(tag & 7);
3297
+ }
3298
+ return message;
3299
+ },
3300
+ fromJSON(object) {
3301
+ return {
3302
+ unit: isSet(object.unit) ? globalThis.String(object.unit) : "",
3303
+ materialization: isSet(object.materialization) ? globalThis.String(object.materialization) : "",
3304
+ rule: isSet(object.rule) ? globalThis.String(object.rule) : "",
3305
+ variant: isSet(object.variant) ? globalThis.String(object.variant) : ""
3306
+ };
3307
+ },
3308
+ toJSON(message) {
3309
+ const obj = {};
3310
+ if (message.unit !== "") obj.unit = message.unit;
3311
+ if (message.materialization !== "") obj.materialization = message.materialization;
3312
+ if (message.rule !== "") obj.rule = message.rule;
3313
+ if (message.variant !== "") obj.variant = message.variant;
3314
+ return obj;
3315
+ },
3316
+ create(base) {
3317
+ return MaterializationRecord.fromPartial(base ?? {});
3318
+ },
3319
+ fromPartial(object) {
3320
+ const message = createBaseMaterializationRecord();
3321
+ message.unit = object.unit ?? "";
3322
+ message.materialization = object.materialization ?? "";
3323
+ message.rule = object.rule ?? "";
3324
+ message.variant = object.variant ?? "";
3325
+ return message;
3326
+ }
3327
+ };
3328
+ function bytesFromBase64(b64) {
3329
+ if (globalThis.Buffer) return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
3330
+ else {
3331
+ const bin = globalThis.atob(b64);
3332
+ const arr = new Uint8Array(bin.length);
3333
+ for (let i = 0; i < bin.length; ++i) arr[i] = bin.charCodeAt(i);
3334
+ return arr;
3335
+ }
3336
+ }
3337
+ function base64FromBytes(arr) {
3338
+ if (globalThis.Buffer) return globalThis.Buffer.from(arr).toString("base64");
3339
+ else {
3340
+ const bin = [];
3341
+ arr.forEach((byte) => {
3342
+ bin.push(globalThis.String.fromCharCode(byte));
3343
+ });
3344
+ return globalThis.btoa(bin.join(""));
3345
+ }
3346
+ }
3066
3347
  function isSet(value) {
3067
3348
  return value !== null && value !== void 0;
3068
3349
  }
@@ -3070,7 +3351,7 @@ const logger = getLogger("wasm-resolver");
3070
3351
  const EXPORT_FN_NAMES = [
3071
3352
  "wasm_msg_alloc",
3072
3353
  "wasm_msg_free",
3073
- "wasm_msg_guest_resolve_with_sticky",
3354
+ "wasm_msg_guest_resolve_flags",
3074
3355
  "wasm_msg_guest_set_resolver_state",
3075
3356
  "wasm_msg_guest_bounded_flush_logs",
3076
3357
  "wasm_msg_guest_bounded_flush_assign",
@@ -3085,9 +3366,9 @@ var UnsafeWasmResolver = class {
3085
3366
  flushCount = 0;
3086
3367
  constructor(module) {
3087
3368
  const { exports } = new WebAssembly.Instance(module, { wasm_msg: { wasm_msg_host_current_time: () => {
3088
- const epochMillisecond = Date.now();
3089
- const seconds = Math.floor(epochMillisecond / 1e3);
3090
- const nanos = (epochMillisecond - 1e3 * seconds) * 1e6;
3369
+ const epochMs = performance.timeOrigin + performance.now();
3370
+ const seconds = Math.floor(epochMs / 1e3);
3371
+ const nanos = Math.round((epochMs - seconds * 1e3) * 1e6);
3091
3372
  return this.transferRequest({
3092
3373
  seconds,
3093
3374
  nanos
@@ -3096,10 +3377,10 @@ var UnsafeWasmResolver = class {
3096
3377
  verifyExports(exports);
3097
3378
  this.exports = exports;
3098
3379
  }
3099
- resolveWithSticky(request) {
3100
- const reqPtr = this.transferRequest(request, ResolveWithStickyRequest);
3101
- const resPtr = this.exports.wasm_msg_guest_resolve_with_sticky(reqPtr);
3102
- return this.consumeResponse(resPtr, ResolveWithStickyResponse);
3380
+ resolveProcess(request) {
3381
+ const reqPtr = this.transferRequest(request, ResolveProcessRequest);
3382
+ const resPtr = this.exports.wasm_msg_guest_resolve_flags(reqPtr);
3383
+ return this.consumeResponse(resPtr, ResolveProcessResponse);
3103
3384
  }
3104
3385
  setResolverState(request) {
3105
3386
  const reqPtr = this.transferRequest(request, SetResolverStateRequest);
@@ -3172,9 +3453,9 @@ var WasmResolver = class {
3172
3453
  this.delegate = this.delegateFactory(this.module);
3173
3454
  if (this.currentState) this.delegate.setResolverState(this.currentState);
3174
3455
  }
3175
- resolveWithSticky(request) {
3456
+ resolveProcess(request) {
3176
3457
  try {
3177
- return this.delegate.resolveWithSticky(request);
3458
+ return this.delegate.resolveProcess(request);
3178
3459
  } catch (error$1) {
3179
3460
  if (error$1 instanceof WebAssembly.RuntimeError) this.reloadInstance(error$1);
3180
3461
  throw error$1;