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