@spotify-confidence/openfeature-server-provider-local 0.9.1 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/dist/confidence_resolver.wasm +0 -0
- package/dist/index.fetch.d.ts +73 -71
- package/dist/index.fetch.js +439 -172
- package/dist/index.inlined.d.ts +73 -71
- package/dist/index.inlined.js +440 -173
- package/dist/index.node.d.ts +73 -71
- package/dist/index.node.js +439 -172
- package/package.json +1 -1
package/dist/index.node.js
CHANGED
|
@@ -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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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.
|
|
1416
|
+
const VERSION = "0.10.0";
|
|
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
|
}
|
|
@@ -2421,13 +2427,13 @@ const SetResolverStateRequest = {
|
|
|
2421
2427
|
},
|
|
2422
2428
|
fromJSON(object) {
|
|
2423
2429
|
return {
|
|
2424
|
-
state: isSet$1(object.state) ? bytesFromBase64$
|
|
2430
|
+
state: isSet$1(object.state) ? bytesFromBase64$2(object.state) : new Uint8Array(0),
|
|
2425
2431
|
accountId: isSet$1(object.accountId) ? globalThis.String(object.accountId) : ""
|
|
2426
2432
|
};
|
|
2427
2433
|
},
|
|
2428
2434
|
toJSON(message) {
|
|
2429
2435
|
const obj = {};
|
|
2430
|
-
if (message.state.length !== 0) obj.state = base64FromBytes$
|
|
2436
|
+
if (message.state.length !== 0) obj.state = base64FromBytes$2(message.state);
|
|
2431
2437
|
if (message.accountId !== "") obj.accountId = message.accountId;
|
|
2432
2438
|
return obj;
|
|
2433
2439
|
},
|
|
@@ -2467,11 +2473,11 @@ const Request = {
|
|
|
2467
2473
|
return message;
|
|
2468
2474
|
},
|
|
2469
2475
|
fromJSON(object) {
|
|
2470
|
-
return { data: isSet$1(object.data) ? bytesFromBase64$
|
|
2476
|
+
return { data: isSet$1(object.data) ? bytesFromBase64$2(object.data) : new Uint8Array(0) };
|
|
2471
2477
|
},
|
|
2472
2478
|
toJSON(message) {
|
|
2473
2479
|
const obj = {};
|
|
2474
|
-
if (message.data.length !== 0) obj.data = base64FromBytes$
|
|
2480
|
+
if (message.data.length !== 0) obj.data = base64FromBytes$2(message.data);
|
|
2475
2481
|
return obj;
|
|
2476
2482
|
},
|
|
2477
2483
|
create(base) {
|
|
@@ -2518,13 +2524,13 @@ const Response$1 = {
|
|
|
2518
2524
|
},
|
|
2519
2525
|
fromJSON(object) {
|
|
2520
2526
|
return {
|
|
2521
|
-
data: isSet$1(object.data) ? bytesFromBase64$
|
|
2527
|
+
data: isSet$1(object.data) ? bytesFromBase64$2(object.data) : void 0,
|
|
2522
2528
|
error: isSet$1(object.error) ? globalThis.String(object.error) : void 0
|
|
2523
2529
|
};
|
|
2524
2530
|
},
|
|
2525
2531
|
toJSON(message) {
|
|
2526
2532
|
const obj = {};
|
|
2527
|
-
if (message.data !== void 0) obj.data = base64FromBytes$
|
|
2533
|
+
if (message.data !== void 0) obj.data = base64FromBytes$2(message.data);
|
|
2528
2534
|
if (message.error !== void 0) obj.error = message.error;
|
|
2529
2535
|
return obj;
|
|
2530
2536
|
},
|
|
@@ -2538,7 +2544,7 @@ const Response$1 = {
|
|
|
2538
2544
|
return message;
|
|
2539
2545
|
}
|
|
2540
2546
|
};
|
|
2541
|
-
function bytesFromBase64$
|
|
2547
|
+
function bytesFromBase64$2(b64) {
|
|
2542
2548
|
if (globalThis.Buffer) return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
|
|
2543
2549
|
else {
|
|
2544
2550
|
const bin = globalThis.atob(b64);
|
|
@@ -2547,7 +2553,7 @@ function bytesFromBase64$1(b64) {
|
|
|
2547
2553
|
return arr;
|
|
2548
2554
|
}
|
|
2549
2555
|
}
|
|
2550
|
-
function base64FromBytes$
|
|
2556
|
+
function base64FromBytes$2(arr) {
|
|
2551
2557
|
if (globalThis.Buffer) return globalThis.Buffer.from(arr).toString("base64");
|
|
2552
2558
|
else {
|
|
2553
2559
|
const bin = [];
|
|
@@ -2568,8 +2574,8 @@ let ErrorCode = /* @__PURE__ */ function(ErrorCode$1) {
|
|
|
2568
2574
|
ErrorCode$1["GENERAL"] = "GENERAL";
|
|
2569
2575
|
return ErrorCode$1;
|
|
2570
2576
|
}({});
|
|
2571
|
-
const encodeToken = base64FromBytes;
|
|
2572
|
-
const decodeToken = bytesFromBase64;
|
|
2577
|
+
const encodeToken = base64FromBytes$1;
|
|
2578
|
+
const decodeToken = bytesFromBase64$1;
|
|
2573
2579
|
function create({ resolveId, resolveToken, resolvedFlags }) {
|
|
2574
2580
|
return {
|
|
2575
2581
|
flags: Object.fromEntries(resolvedFlags.map(({ flag, reason, variant, value, shouldApply }) => {
|
|
@@ -2676,7 +2682,7 @@ function convertReason(reason) {
|
|
|
2676
2682
|
const logger$1 = getLogger("provider");
|
|
2677
2683
|
const DEFAULT_INITIALIZE_TIMEOUT = 3e4;
|
|
2678
2684
|
const DEFAULT_STATE_INTERVAL = 3e4;
|
|
2679
|
-
const DEFAULT_FLUSH_INTERVAL =
|
|
2685
|
+
const DEFAULT_FLUSH_INTERVAL = 15e3;
|
|
2680
2686
|
var ConfidenceServerProviderLocal = class ConfidenceServerProviderLocal {
|
|
2681
2687
|
metadata = { name: "ConfidenceServerProviderLocal" };
|
|
2682
2688
|
status = castStringToEnum("NOT_READY");
|
|
@@ -2702,7 +2708,7 @@ var ConfidenceServerProviderLocal = class ConfidenceServerProviderLocal {
|
|
|
2702
2708
|
maxAttempts: Infinity,
|
|
2703
2709
|
baseInterval: 500,
|
|
2704
2710
|
maxInterval: this.stateUpdateInterval
|
|
2705
|
-
}), withStallTimeout(
|
|
2711
|
+
}), withStallTimeout(1 * TimeUnit.SECOND)],
|
|
2706
2712
|
"https://resolver.confidence.dev/*": [withRouter({
|
|
2707
2713
|
"*/v1/materialization:readMaterializedOperations": [withRetry({
|
|
2708
2714
|
maxAttempts: 3,
|
|
@@ -2747,23 +2753,19 @@ var ConfidenceServerProviderLocal = class ConfidenceServerProviderLocal {
|
|
|
2747
2753
|
this.main.abort();
|
|
2748
2754
|
}
|
|
2749
2755
|
async resolve(context, flagNames, apply = false) {
|
|
2750
|
-
const
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
}
|
|
2760
|
-
},
|
|
2761
|
-
materializations: [],
|
|
2762
|
-
failFastOnSticky: false,
|
|
2763
|
-
notProcessSticky: false
|
|
2756
|
+
const resolveRequest = {
|
|
2757
|
+
flags: flagNames.map((name) => `flags/${name}`),
|
|
2758
|
+
evaluationContext: ConfidenceServerProviderLocal.convertEvaluationContext(context),
|
|
2759
|
+
apply,
|
|
2760
|
+
clientSecret: this.options.flagClientSecret,
|
|
2761
|
+
sdk: {
|
|
2762
|
+
id: SdkId.SDK_ID_JS_LOCAL_SERVER_PROVIDER,
|
|
2763
|
+
version: VERSION
|
|
2764
|
+
}
|
|
2764
2765
|
};
|
|
2765
2766
|
try {
|
|
2766
|
-
|
|
2767
|
+
const processRequest = this.materializationStore ? { deferredMaterializations: resolveRequest } : { withoutMaterializations: resolveRequest };
|
|
2768
|
+
return create(await this.resolveProcess(processRequest));
|
|
2767
2769
|
} catch (err) {
|
|
2768
2770
|
return error(ErrorCode.GENERAL, String(err));
|
|
2769
2771
|
}
|
|
@@ -2777,19 +2779,30 @@ var ConfidenceServerProviderLocal = class ConfidenceServerProviderLocal {
|
|
|
2777
2779
|
this.flushAssigned();
|
|
2778
2780
|
}
|
|
2779
2781
|
}
|
|
2780
|
-
async
|
|
2781
|
-
|
|
2782
|
-
if (
|
|
2783
|
-
const {
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2782
|
+
async resolveProcess(request) {
|
|
2783
|
+
const response = this.resolver.resolveProcess(request);
|
|
2784
|
+
if (response.suspended) {
|
|
2785
|
+
const { materializationsToRead, state } = response.suspended;
|
|
2786
|
+
const readOps = materializationRecordsToReadOps(materializationsToRead);
|
|
2787
|
+
const readResults = await this.readMaterializations(readOps);
|
|
2788
|
+
const materializations = readResultsToMaterializationRecords(readResults);
|
|
2789
|
+
const resumeResponse = this.resolver.resolveProcess({ resume: {
|
|
2790
|
+
materializations,
|
|
2791
|
+
state
|
|
2792
|
+
} });
|
|
2793
|
+
if (!resumeResponse.resolved) throw new Error("Resolve still suspended after providing materializations");
|
|
2794
|
+
this.handleMaterializationWrites(resumeResponse.resolved.materializationsToWrite);
|
|
2795
|
+
return ResolveFlagsResponse.create(resumeResponse.resolved.response);
|
|
2796
|
+
}
|
|
2797
|
+
if (!response.resolved) throw new Error("Unexpected empty resolve response");
|
|
2798
|
+
this.handleMaterializationWrites(response.resolved.materializationsToWrite);
|
|
2799
|
+
return ResolveFlagsResponse.create(response.resolved.response);
|
|
2800
|
+
}
|
|
2801
|
+
handleMaterializationWrites(records) {
|
|
2802
|
+
if (records.length > 0) {
|
|
2803
|
+
const writeOps = materializationRecordsToWriteOps(records);
|
|
2804
|
+
this.writeMaterializations(writeOps);
|
|
2788
2805
|
}
|
|
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
2806
|
}
|
|
2794
2807
|
async updateState(signal) {
|
|
2795
2808
|
const cdnUrl = `https://confidence-resolver-state-cdn.spotifycdn.com/${await sha256Hex(this.options.flagClientSecret)}`;
|
|
@@ -2830,18 +2843,15 @@ var ConfidenceServerProviderLocal = class ConfidenceServerProviderLocal {
|
|
|
2830
2843
|
throw err;
|
|
2831
2844
|
}
|
|
2832
2845
|
}
|
|
2833
|
-
async readMaterializations(
|
|
2846
|
+
async readMaterializations(readOps) {
|
|
2834
2847
|
const materializationStore = this.materializationStore;
|
|
2835
|
-
if (materializationStore && typeof materializationStore.readMaterializations === "function")
|
|
2836
|
-
const result = await materializationStore.readMaterializations(readOpsFromProto(readOpsReq));
|
|
2837
|
-
return readResultToProto(result);
|
|
2838
|
-
}
|
|
2848
|
+
if (materializationStore && typeof materializationStore.readMaterializations === "function") return materializationStore.readMaterializations(readOps);
|
|
2839
2849
|
throw new Error("Read materialization not supported");
|
|
2840
2850
|
}
|
|
2841
|
-
writeMaterializations(
|
|
2851
|
+
writeMaterializations(writeOps) {
|
|
2842
2852
|
const materializationStore = this.materializationStore;
|
|
2843
2853
|
if (materializationStore && typeof materializationStore.writeMaterializations === "function") {
|
|
2844
|
-
materializationStore.writeMaterializations(
|
|
2854
|
+
materializationStore.writeMaterializations(writeOps).catch((e) => {
|
|
2845
2855
|
logger$1.warn("Failed to write materialization", e);
|
|
2846
2856
|
});
|
|
2847
2857
|
return;
|
|
@@ -2883,44 +2893,105 @@ var ConfidenceServerProviderLocal = class ConfidenceServerProviderLocal {
|
|
|
2883
2893
|
this.resolver.applyFlags(request);
|
|
2884
2894
|
}
|
|
2885
2895
|
};
|
|
2886
|
-
function
|
|
2896
|
+
function createBaseResolveProcessRequest() {
|
|
2887
2897
|
return {
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2898
|
+
deferredMaterializations: void 0,
|
|
2899
|
+
staticMaterializations: void 0,
|
|
2900
|
+
withoutMaterializations: void 0,
|
|
2901
|
+
resume: void 0
|
|
2892
2902
|
};
|
|
2893
2903
|
}
|
|
2894
|
-
const
|
|
2904
|
+
const ResolveProcessRequest = {
|
|
2895
2905
|
encode(message, writer = new BinaryWriter()) {
|
|
2896
|
-
if (message.
|
|
2897
|
-
if (message.
|
|
2898
|
-
if (message.
|
|
2899
|
-
|
|
2906
|
+
if (message.deferredMaterializations !== void 0) ResolveFlagsRequest.encode(message.deferredMaterializations, writer.uint32(10).fork()).join();
|
|
2907
|
+
if (message.staticMaterializations !== void 0) ResolveProcessRequest_StaticMaterializations.encode(message.staticMaterializations, writer.uint32(18).fork()).join();
|
|
2908
|
+
if (message.withoutMaterializations !== void 0) ResolveFlagsRequest.encode(message.withoutMaterializations, writer.uint32(26).fork()).join();
|
|
2909
|
+
if (message.resume !== void 0) ResolveProcessRequest_Resume.encode(message.resume, writer.uint32(34).fork()).join();
|
|
2900
2910
|
return writer;
|
|
2901
2911
|
},
|
|
2902
2912
|
decode(input, length) {
|
|
2903
2913
|
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
2904
2914
|
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
2905
|
-
const message =
|
|
2915
|
+
const message = createBaseResolveProcessRequest();
|
|
2906
2916
|
while (reader.pos < end) {
|
|
2907
2917
|
const tag = reader.uint32();
|
|
2908
2918
|
switch (tag >>> 3) {
|
|
2909
2919
|
case 1:
|
|
2910
2920
|
if (tag !== 10) break;
|
|
2911
|
-
message.
|
|
2921
|
+
message.deferredMaterializations = ResolveFlagsRequest.decode(reader, reader.uint32());
|
|
2922
|
+
continue;
|
|
2923
|
+
case 2:
|
|
2924
|
+
if (tag !== 18) break;
|
|
2925
|
+
message.staticMaterializations = ResolveProcessRequest_StaticMaterializations.decode(reader, reader.uint32());
|
|
2912
2926
|
continue;
|
|
2913
2927
|
case 3:
|
|
2914
|
-
if (tag !==
|
|
2915
|
-
message.
|
|
2928
|
+
if (tag !== 26) break;
|
|
2929
|
+
message.withoutMaterializations = ResolveFlagsRequest.decode(reader, reader.uint32());
|
|
2916
2930
|
continue;
|
|
2917
2931
|
case 4:
|
|
2918
|
-
if (tag !==
|
|
2919
|
-
message.
|
|
2932
|
+
if (tag !== 34) break;
|
|
2933
|
+
message.resume = ResolveProcessRequest_Resume.decode(reader, reader.uint32());
|
|
2920
2934
|
continue;
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2935
|
+
}
|
|
2936
|
+
if ((tag & 7) === 4 || tag === 0) break;
|
|
2937
|
+
reader.skip(tag & 7);
|
|
2938
|
+
}
|
|
2939
|
+
return message;
|
|
2940
|
+
},
|
|
2941
|
+
fromJSON(object) {
|
|
2942
|
+
return {
|
|
2943
|
+
deferredMaterializations: isSet(object.deferredMaterializations) ? ResolveFlagsRequest.fromJSON(object.deferredMaterializations) : void 0,
|
|
2944
|
+
staticMaterializations: isSet(object.staticMaterializations) ? ResolveProcessRequest_StaticMaterializations.fromJSON(object.staticMaterializations) : void 0,
|
|
2945
|
+
withoutMaterializations: isSet(object.withoutMaterializations) ? ResolveFlagsRequest.fromJSON(object.withoutMaterializations) : void 0,
|
|
2946
|
+
resume: isSet(object.resume) ? ResolveProcessRequest_Resume.fromJSON(object.resume) : void 0
|
|
2947
|
+
};
|
|
2948
|
+
},
|
|
2949
|
+
toJSON(message) {
|
|
2950
|
+
const obj = {};
|
|
2951
|
+
if (message.deferredMaterializations !== void 0) obj.deferredMaterializations = ResolveFlagsRequest.toJSON(message.deferredMaterializations);
|
|
2952
|
+
if (message.staticMaterializations !== void 0) obj.staticMaterializations = ResolveProcessRequest_StaticMaterializations.toJSON(message.staticMaterializations);
|
|
2953
|
+
if (message.withoutMaterializations !== void 0) obj.withoutMaterializations = ResolveFlagsRequest.toJSON(message.withoutMaterializations);
|
|
2954
|
+
if (message.resume !== void 0) obj.resume = ResolveProcessRequest_Resume.toJSON(message.resume);
|
|
2955
|
+
return obj;
|
|
2956
|
+
},
|
|
2957
|
+
create(base) {
|
|
2958
|
+
return ResolveProcessRequest.fromPartial(base ?? {});
|
|
2959
|
+
},
|
|
2960
|
+
fromPartial(object) {
|
|
2961
|
+
const message = createBaseResolveProcessRequest();
|
|
2962
|
+
message.deferredMaterializations = object.deferredMaterializations !== void 0 && object.deferredMaterializations !== null ? ResolveFlagsRequest.fromPartial(object.deferredMaterializations) : void 0;
|
|
2963
|
+
message.staticMaterializations = object.staticMaterializations !== void 0 && object.staticMaterializations !== null ? ResolveProcessRequest_StaticMaterializations.fromPartial(object.staticMaterializations) : void 0;
|
|
2964
|
+
message.withoutMaterializations = object.withoutMaterializations !== void 0 && object.withoutMaterializations !== null ? ResolveFlagsRequest.fromPartial(object.withoutMaterializations) : void 0;
|
|
2965
|
+
message.resume = object.resume !== void 0 && object.resume !== null ? ResolveProcessRequest_Resume.fromPartial(object.resume) : void 0;
|
|
2966
|
+
return message;
|
|
2967
|
+
}
|
|
2968
|
+
};
|
|
2969
|
+
function createBaseResolveProcessRequest_StaticMaterializations() {
|
|
2970
|
+
return {
|
|
2971
|
+
resolveRequest: void 0,
|
|
2972
|
+
materializations: []
|
|
2973
|
+
};
|
|
2974
|
+
}
|
|
2975
|
+
const ResolveProcessRequest_StaticMaterializations = {
|
|
2976
|
+
encode(message, writer = new BinaryWriter()) {
|
|
2977
|
+
if (message.resolveRequest !== void 0) ResolveFlagsRequest.encode(message.resolveRequest, writer.uint32(10).fork()).join();
|
|
2978
|
+
for (const v of message.materializations) MaterializationRecord.encode(v, writer.uint32(18).fork()).join();
|
|
2979
|
+
return writer;
|
|
2980
|
+
},
|
|
2981
|
+
decode(input, length) {
|
|
2982
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
2983
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
2984
|
+
const message = createBaseResolveProcessRequest_StaticMaterializations();
|
|
2985
|
+
while (reader.pos < end) {
|
|
2986
|
+
const tag = reader.uint32();
|
|
2987
|
+
switch (tag >>> 3) {
|
|
2988
|
+
case 1:
|
|
2989
|
+
if (tag !== 10) break;
|
|
2990
|
+
message.resolveRequest = ResolveFlagsRequest.decode(reader, reader.uint32());
|
|
2991
|
+
continue;
|
|
2992
|
+
case 2:
|
|
2993
|
+
if (tag !== 18) break;
|
|
2994
|
+
message.materializations.push(MaterializationRecord.decode(reader, reader.uint32()));
|
|
2924
2995
|
continue;
|
|
2925
2996
|
}
|
|
2926
2997
|
if ((tag & 7) === 4 || tag === 0) break;
|
|
@@ -2931,57 +3002,51 @@ const ResolveWithStickyRequest = {
|
|
|
2931
3002
|
fromJSON(object) {
|
|
2932
3003
|
return {
|
|
2933
3004
|
resolveRequest: isSet(object.resolveRequest) ? ResolveFlagsRequest.fromJSON(object.resolveRequest) : void 0,
|
|
2934
|
-
|
|
2935
|
-
notProcessSticky: isSet(object.notProcessSticky) ? globalThis.Boolean(object.notProcessSticky) : false,
|
|
2936
|
-
materializations: globalThis.Array.isArray(object?.materializations) ? object.materializations.map((e) => ReadResult.fromJSON(e)) : []
|
|
3005
|
+
materializations: globalThis.Array.isArray(object?.materializations) ? object.materializations.map((e) => MaterializationRecord.fromJSON(e)) : []
|
|
2937
3006
|
};
|
|
2938
3007
|
},
|
|
2939
3008
|
toJSON(message) {
|
|
2940
3009
|
const obj = {};
|
|
2941
3010
|
if (message.resolveRequest !== void 0) obj.resolveRequest = ResolveFlagsRequest.toJSON(message.resolveRequest);
|
|
2942
|
-
if (message.
|
|
2943
|
-
if (message.notProcessSticky !== false) obj.notProcessSticky = message.notProcessSticky;
|
|
2944
|
-
if (message.materializations?.length) obj.materializations = message.materializations.map((e) => ReadResult.toJSON(e));
|
|
3011
|
+
if (message.materializations?.length) obj.materializations = message.materializations.map((e) => MaterializationRecord.toJSON(e));
|
|
2945
3012
|
return obj;
|
|
2946
3013
|
},
|
|
2947
3014
|
create(base) {
|
|
2948
|
-
return
|
|
3015
|
+
return ResolveProcessRequest_StaticMaterializations.fromPartial(base ?? {});
|
|
2949
3016
|
},
|
|
2950
3017
|
fromPartial(object) {
|
|
2951
|
-
const message =
|
|
3018
|
+
const message = createBaseResolveProcessRequest_StaticMaterializations();
|
|
2952
3019
|
message.resolveRequest = object.resolveRequest !== void 0 && object.resolveRequest !== null ? ResolveFlagsRequest.fromPartial(object.resolveRequest) : void 0;
|
|
2953
|
-
message.
|
|
2954
|
-
message.notProcessSticky = object.notProcessSticky ?? false;
|
|
2955
|
-
message.materializations = object.materializations?.map((e) => ReadResult.fromPartial(e)) || [];
|
|
3020
|
+
message.materializations = object.materializations?.map((e) => MaterializationRecord.fromPartial(e)) || [];
|
|
2956
3021
|
return message;
|
|
2957
3022
|
}
|
|
2958
3023
|
};
|
|
2959
|
-
function
|
|
3024
|
+
function createBaseResolveProcessRequest_Resume() {
|
|
2960
3025
|
return {
|
|
2961
|
-
|
|
2962
|
-
|
|
3026
|
+
materializations: [],
|
|
3027
|
+
state: new Uint8Array(0)
|
|
2963
3028
|
};
|
|
2964
3029
|
}
|
|
2965
|
-
const
|
|
3030
|
+
const ResolveProcessRequest_Resume = {
|
|
2966
3031
|
encode(message, writer = new BinaryWriter()) {
|
|
2967
|
-
|
|
2968
|
-
if (message.
|
|
3032
|
+
for (const v of message.materializations) MaterializationRecord.encode(v, writer.uint32(10).fork()).join();
|
|
3033
|
+
if (message.state.length !== 0) writer.uint32(18).bytes(message.state);
|
|
2969
3034
|
return writer;
|
|
2970
3035
|
},
|
|
2971
3036
|
decode(input, length) {
|
|
2972
3037
|
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
2973
3038
|
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
2974
|
-
const message =
|
|
3039
|
+
const message = createBaseResolveProcessRequest_Resume();
|
|
2975
3040
|
while (reader.pos < end) {
|
|
2976
3041
|
const tag = reader.uint32();
|
|
2977
3042
|
switch (tag >>> 3) {
|
|
2978
3043
|
case 1:
|
|
2979
3044
|
if (tag !== 10) break;
|
|
2980
|
-
message.
|
|
3045
|
+
message.materializations.push(MaterializationRecord.decode(reader, reader.uint32()));
|
|
2981
3046
|
continue;
|
|
2982
|
-
case
|
|
2983
|
-
if (tag !==
|
|
2984
|
-
message.
|
|
3047
|
+
case 2:
|
|
3048
|
+
if (tag !== 18) break;
|
|
3049
|
+
message.state = reader.bytes();
|
|
2985
3050
|
continue;
|
|
2986
3051
|
}
|
|
2987
3052
|
if ((tag & 7) === 4 || tag === 0) break;
|
|
@@ -2991,42 +3056,97 @@ const ResolveWithStickyResponse = {
|
|
|
2991
3056
|
},
|
|
2992
3057
|
fromJSON(object) {
|
|
2993
3058
|
return {
|
|
2994
|
-
|
|
2995
|
-
|
|
3059
|
+
materializations: globalThis.Array.isArray(object?.materializations) ? object.materializations.map((e) => MaterializationRecord.fromJSON(e)) : [],
|
|
3060
|
+
state: isSet(object.state) ? bytesFromBase64(object.state) : new Uint8Array(0)
|
|
2996
3061
|
};
|
|
2997
3062
|
},
|
|
2998
3063
|
toJSON(message) {
|
|
2999
3064
|
const obj = {};
|
|
3000
|
-
if (message.
|
|
3001
|
-
if (message.
|
|
3065
|
+
if (message.materializations?.length) obj.materializations = message.materializations.map((e) => MaterializationRecord.toJSON(e));
|
|
3066
|
+
if (message.state.length !== 0) obj.state = base64FromBytes(message.state);
|
|
3002
3067
|
return obj;
|
|
3003
3068
|
},
|
|
3004
3069
|
create(base) {
|
|
3005
|
-
return
|
|
3070
|
+
return ResolveProcessRequest_Resume.fromPartial(base ?? {});
|
|
3006
3071
|
},
|
|
3007
3072
|
fromPartial(object) {
|
|
3008
|
-
const message =
|
|
3009
|
-
message.
|
|
3010
|
-
message.
|
|
3073
|
+
const message = createBaseResolveProcessRequest_Resume();
|
|
3074
|
+
message.materializations = object.materializations?.map((e) => MaterializationRecord.fromPartial(e)) || [];
|
|
3075
|
+
message.state = object.state ?? new Uint8Array(0);
|
|
3011
3076
|
return message;
|
|
3012
3077
|
}
|
|
3013
3078
|
};
|
|
3014
|
-
function
|
|
3079
|
+
function createBaseResolveProcessResponse() {
|
|
3080
|
+
return {
|
|
3081
|
+
resolved: void 0,
|
|
3082
|
+
suspended: void 0
|
|
3083
|
+
};
|
|
3084
|
+
}
|
|
3085
|
+
const ResolveProcessResponse = {
|
|
3086
|
+
encode(message, writer = new BinaryWriter()) {
|
|
3087
|
+
if (message.resolved !== void 0) ResolveProcessResponse_Resolved.encode(message.resolved, writer.uint32(10).fork()).join();
|
|
3088
|
+
if (message.suspended !== void 0) ResolveProcessResponse_Suspended.encode(message.suspended, writer.uint32(18).fork()).join();
|
|
3089
|
+
return writer;
|
|
3090
|
+
},
|
|
3091
|
+
decode(input, length) {
|
|
3092
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
3093
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
3094
|
+
const message = createBaseResolveProcessResponse();
|
|
3095
|
+
while (reader.pos < end) {
|
|
3096
|
+
const tag = reader.uint32();
|
|
3097
|
+
switch (tag >>> 3) {
|
|
3098
|
+
case 1:
|
|
3099
|
+
if (tag !== 10) break;
|
|
3100
|
+
message.resolved = ResolveProcessResponse_Resolved.decode(reader, reader.uint32());
|
|
3101
|
+
continue;
|
|
3102
|
+
case 2:
|
|
3103
|
+
if (tag !== 18) break;
|
|
3104
|
+
message.suspended = ResolveProcessResponse_Suspended.decode(reader, reader.uint32());
|
|
3105
|
+
continue;
|
|
3106
|
+
}
|
|
3107
|
+
if ((tag & 7) === 4 || tag === 0) break;
|
|
3108
|
+
reader.skip(tag & 7);
|
|
3109
|
+
}
|
|
3110
|
+
return message;
|
|
3111
|
+
},
|
|
3112
|
+
fromJSON(object) {
|
|
3113
|
+
return {
|
|
3114
|
+
resolved: isSet(object.resolved) ? ResolveProcessResponse_Resolved.fromJSON(object.resolved) : void 0,
|
|
3115
|
+
suspended: isSet(object.suspended) ? ResolveProcessResponse_Suspended.fromJSON(object.suspended) : void 0
|
|
3116
|
+
};
|
|
3117
|
+
},
|
|
3118
|
+
toJSON(message) {
|
|
3119
|
+
const obj = {};
|
|
3120
|
+
if (message.resolved !== void 0) obj.resolved = ResolveProcessResponse_Resolved.toJSON(message.resolved);
|
|
3121
|
+
if (message.suspended !== void 0) obj.suspended = ResolveProcessResponse_Suspended.toJSON(message.suspended);
|
|
3122
|
+
return obj;
|
|
3123
|
+
},
|
|
3124
|
+
create(base) {
|
|
3125
|
+
return ResolveProcessResponse.fromPartial(base ?? {});
|
|
3126
|
+
},
|
|
3127
|
+
fromPartial(object) {
|
|
3128
|
+
const message = createBaseResolveProcessResponse();
|
|
3129
|
+
message.resolved = object.resolved !== void 0 && object.resolved !== null ? ResolveProcessResponse_Resolved.fromPartial(object.resolved) : void 0;
|
|
3130
|
+
message.suspended = object.suspended !== void 0 && object.suspended !== null ? ResolveProcessResponse_Suspended.fromPartial(object.suspended) : void 0;
|
|
3131
|
+
return message;
|
|
3132
|
+
}
|
|
3133
|
+
};
|
|
3134
|
+
function createBaseResolveProcessResponse_Resolved() {
|
|
3015
3135
|
return {
|
|
3016
3136
|
response: void 0,
|
|
3017
|
-
|
|
3137
|
+
materializationsToWrite: []
|
|
3018
3138
|
};
|
|
3019
3139
|
}
|
|
3020
|
-
const
|
|
3140
|
+
const ResolveProcessResponse_Resolved = {
|
|
3021
3141
|
encode(message, writer = new BinaryWriter()) {
|
|
3022
3142
|
if (message.response !== void 0) ResolveFlagsResponse.encode(message.response, writer.uint32(10).fork()).join();
|
|
3023
|
-
for (const v of message.
|
|
3143
|
+
for (const v of message.materializationsToWrite) MaterializationRecord.encode(v, writer.uint32(18).fork()).join();
|
|
3024
3144
|
return writer;
|
|
3025
3145
|
},
|
|
3026
3146
|
decode(input, length) {
|
|
3027
3147
|
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
3028
3148
|
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
3029
|
-
const message =
|
|
3149
|
+
const message = createBaseResolveProcessResponse_Resolved();
|
|
3030
3150
|
while (reader.pos < end) {
|
|
3031
3151
|
const tag = reader.uint32();
|
|
3032
3152
|
switch (tag >>> 3) {
|
|
@@ -3034,9 +3154,9 @@ const ResolveWithStickyResponse_Success = {
|
|
|
3034
3154
|
if (tag !== 10) break;
|
|
3035
3155
|
message.response = ResolveFlagsResponse.decode(reader, reader.uint32());
|
|
3036
3156
|
continue;
|
|
3037
|
-
case
|
|
3038
|
-
if (tag !==
|
|
3039
|
-
message.
|
|
3157
|
+
case 2:
|
|
3158
|
+
if (tag !== 18) break;
|
|
3159
|
+
message.materializationsToWrite.push(MaterializationRecord.decode(reader, reader.uint32()));
|
|
3040
3160
|
continue;
|
|
3041
3161
|
}
|
|
3042
3162
|
if ((tag & 7) === 4 || tag === 0) break;
|
|
@@ -3047,25 +3167,172 @@ const ResolveWithStickyResponse_Success = {
|
|
|
3047
3167
|
fromJSON(object) {
|
|
3048
3168
|
return {
|
|
3049
3169
|
response: isSet(object.response) ? ResolveFlagsResponse.fromJSON(object.response) : void 0,
|
|
3050
|
-
|
|
3170
|
+
materializationsToWrite: globalThis.Array.isArray(object?.materializationsToWrite) ? object.materializationsToWrite.map((e) => MaterializationRecord.fromJSON(e)) : []
|
|
3051
3171
|
};
|
|
3052
3172
|
},
|
|
3053
3173
|
toJSON(message) {
|
|
3054
3174
|
const obj = {};
|
|
3055
3175
|
if (message.response !== void 0) obj.response = ResolveFlagsResponse.toJSON(message.response);
|
|
3056
|
-
if (message.
|
|
3176
|
+
if (message.materializationsToWrite?.length) obj.materializationsToWrite = message.materializationsToWrite.map((e) => MaterializationRecord.toJSON(e));
|
|
3057
3177
|
return obj;
|
|
3058
3178
|
},
|
|
3059
3179
|
create(base) {
|
|
3060
|
-
return
|
|
3180
|
+
return ResolveProcessResponse_Resolved.fromPartial(base ?? {});
|
|
3061
3181
|
},
|
|
3062
3182
|
fromPartial(object) {
|
|
3063
|
-
const message =
|
|
3183
|
+
const message = createBaseResolveProcessResponse_Resolved();
|
|
3064
3184
|
message.response = object.response !== void 0 && object.response !== null ? ResolveFlagsResponse.fromPartial(object.response) : void 0;
|
|
3065
|
-
message.
|
|
3185
|
+
message.materializationsToWrite = object.materializationsToWrite?.map((e) => MaterializationRecord.fromPartial(e)) || [];
|
|
3066
3186
|
return message;
|
|
3067
3187
|
}
|
|
3068
3188
|
};
|
|
3189
|
+
function createBaseResolveProcessResponse_Suspended() {
|
|
3190
|
+
return {
|
|
3191
|
+
materializationsToRead: [],
|
|
3192
|
+
state: new Uint8Array(0)
|
|
3193
|
+
};
|
|
3194
|
+
}
|
|
3195
|
+
const ResolveProcessResponse_Suspended = {
|
|
3196
|
+
encode(message, writer = new BinaryWriter()) {
|
|
3197
|
+
for (const v of message.materializationsToRead) MaterializationRecord.encode(v, writer.uint32(10).fork()).join();
|
|
3198
|
+
if (message.state.length !== 0) writer.uint32(18).bytes(message.state);
|
|
3199
|
+
return writer;
|
|
3200
|
+
},
|
|
3201
|
+
decode(input, length) {
|
|
3202
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
3203
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
3204
|
+
const message = createBaseResolveProcessResponse_Suspended();
|
|
3205
|
+
while (reader.pos < end) {
|
|
3206
|
+
const tag = reader.uint32();
|
|
3207
|
+
switch (tag >>> 3) {
|
|
3208
|
+
case 1:
|
|
3209
|
+
if (tag !== 10) break;
|
|
3210
|
+
message.materializationsToRead.push(MaterializationRecord.decode(reader, reader.uint32()));
|
|
3211
|
+
continue;
|
|
3212
|
+
case 2:
|
|
3213
|
+
if (tag !== 18) break;
|
|
3214
|
+
message.state = reader.bytes();
|
|
3215
|
+
continue;
|
|
3216
|
+
}
|
|
3217
|
+
if ((tag & 7) === 4 || tag === 0) break;
|
|
3218
|
+
reader.skip(tag & 7);
|
|
3219
|
+
}
|
|
3220
|
+
return message;
|
|
3221
|
+
},
|
|
3222
|
+
fromJSON(object) {
|
|
3223
|
+
return {
|
|
3224
|
+
materializationsToRead: globalThis.Array.isArray(object?.materializationsToRead) ? object.materializationsToRead.map((e) => MaterializationRecord.fromJSON(e)) : [],
|
|
3225
|
+
state: isSet(object.state) ? bytesFromBase64(object.state) : new Uint8Array(0)
|
|
3226
|
+
};
|
|
3227
|
+
},
|
|
3228
|
+
toJSON(message) {
|
|
3229
|
+
const obj = {};
|
|
3230
|
+
if (message.materializationsToRead?.length) obj.materializationsToRead = message.materializationsToRead.map((e) => MaterializationRecord.toJSON(e));
|
|
3231
|
+
if (message.state.length !== 0) obj.state = base64FromBytes(message.state);
|
|
3232
|
+
return obj;
|
|
3233
|
+
},
|
|
3234
|
+
create(base) {
|
|
3235
|
+
return ResolveProcessResponse_Suspended.fromPartial(base ?? {});
|
|
3236
|
+
},
|
|
3237
|
+
fromPartial(object) {
|
|
3238
|
+
const message = createBaseResolveProcessResponse_Suspended();
|
|
3239
|
+
message.materializationsToRead = object.materializationsToRead?.map((e) => MaterializationRecord.fromPartial(e)) || [];
|
|
3240
|
+
message.state = object.state ?? new Uint8Array(0);
|
|
3241
|
+
return message;
|
|
3242
|
+
}
|
|
3243
|
+
};
|
|
3244
|
+
function createBaseMaterializationRecord() {
|
|
3245
|
+
return {
|
|
3246
|
+
unit: "",
|
|
3247
|
+
materialization: "",
|
|
3248
|
+
rule: "",
|
|
3249
|
+
variant: ""
|
|
3250
|
+
};
|
|
3251
|
+
}
|
|
3252
|
+
const MaterializationRecord = {
|
|
3253
|
+
encode(message, writer = new BinaryWriter()) {
|
|
3254
|
+
if (message.unit !== "") writer.uint32(10).string(message.unit);
|
|
3255
|
+
if (message.materialization !== "") writer.uint32(18).string(message.materialization);
|
|
3256
|
+
if (message.rule !== "") writer.uint32(26).string(message.rule);
|
|
3257
|
+
if (message.variant !== "") writer.uint32(34).string(message.variant);
|
|
3258
|
+
return writer;
|
|
3259
|
+
},
|
|
3260
|
+
decode(input, length) {
|
|
3261
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
3262
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
3263
|
+
const message = createBaseMaterializationRecord();
|
|
3264
|
+
while (reader.pos < end) {
|
|
3265
|
+
const tag = reader.uint32();
|
|
3266
|
+
switch (tag >>> 3) {
|
|
3267
|
+
case 1:
|
|
3268
|
+
if (tag !== 10) break;
|
|
3269
|
+
message.unit = reader.string();
|
|
3270
|
+
continue;
|
|
3271
|
+
case 2:
|
|
3272
|
+
if (tag !== 18) break;
|
|
3273
|
+
message.materialization = reader.string();
|
|
3274
|
+
continue;
|
|
3275
|
+
case 3:
|
|
3276
|
+
if (tag !== 26) break;
|
|
3277
|
+
message.rule = reader.string();
|
|
3278
|
+
continue;
|
|
3279
|
+
case 4:
|
|
3280
|
+
if (tag !== 34) break;
|
|
3281
|
+
message.variant = reader.string();
|
|
3282
|
+
continue;
|
|
3283
|
+
}
|
|
3284
|
+
if ((tag & 7) === 4 || tag === 0) break;
|
|
3285
|
+
reader.skip(tag & 7);
|
|
3286
|
+
}
|
|
3287
|
+
return message;
|
|
3288
|
+
},
|
|
3289
|
+
fromJSON(object) {
|
|
3290
|
+
return {
|
|
3291
|
+
unit: isSet(object.unit) ? globalThis.String(object.unit) : "",
|
|
3292
|
+
materialization: isSet(object.materialization) ? globalThis.String(object.materialization) : "",
|
|
3293
|
+
rule: isSet(object.rule) ? globalThis.String(object.rule) : "",
|
|
3294
|
+
variant: isSet(object.variant) ? globalThis.String(object.variant) : ""
|
|
3295
|
+
};
|
|
3296
|
+
},
|
|
3297
|
+
toJSON(message) {
|
|
3298
|
+
const obj = {};
|
|
3299
|
+
if (message.unit !== "") obj.unit = message.unit;
|
|
3300
|
+
if (message.materialization !== "") obj.materialization = message.materialization;
|
|
3301
|
+
if (message.rule !== "") obj.rule = message.rule;
|
|
3302
|
+
if (message.variant !== "") obj.variant = message.variant;
|
|
3303
|
+
return obj;
|
|
3304
|
+
},
|
|
3305
|
+
create(base) {
|
|
3306
|
+
return MaterializationRecord.fromPartial(base ?? {});
|
|
3307
|
+
},
|
|
3308
|
+
fromPartial(object) {
|
|
3309
|
+
const message = createBaseMaterializationRecord();
|
|
3310
|
+
message.unit = object.unit ?? "";
|
|
3311
|
+
message.materialization = object.materialization ?? "";
|
|
3312
|
+
message.rule = object.rule ?? "";
|
|
3313
|
+
message.variant = object.variant ?? "";
|
|
3314
|
+
return message;
|
|
3315
|
+
}
|
|
3316
|
+
};
|
|
3317
|
+
function bytesFromBase64(b64) {
|
|
3318
|
+
if (globalThis.Buffer) return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
|
|
3319
|
+
else {
|
|
3320
|
+
const bin = globalThis.atob(b64);
|
|
3321
|
+
const arr = new Uint8Array(bin.length);
|
|
3322
|
+
for (let i = 0; i < bin.length; ++i) arr[i] = bin.charCodeAt(i);
|
|
3323
|
+
return arr;
|
|
3324
|
+
}
|
|
3325
|
+
}
|
|
3326
|
+
function base64FromBytes(arr) {
|
|
3327
|
+
if (globalThis.Buffer) return globalThis.Buffer.from(arr).toString("base64");
|
|
3328
|
+
else {
|
|
3329
|
+
const bin = [];
|
|
3330
|
+
arr.forEach((byte) => {
|
|
3331
|
+
bin.push(globalThis.String.fromCharCode(byte));
|
|
3332
|
+
});
|
|
3333
|
+
return globalThis.btoa(bin.join(""));
|
|
3334
|
+
}
|
|
3335
|
+
}
|
|
3069
3336
|
function isSet(value) {
|
|
3070
3337
|
return value !== null && value !== void 0;
|
|
3071
3338
|
}
|
|
@@ -3073,7 +3340,7 @@ const logger = getLogger("wasm-resolver");
|
|
|
3073
3340
|
const EXPORT_FN_NAMES = [
|
|
3074
3341
|
"wasm_msg_alloc",
|
|
3075
3342
|
"wasm_msg_free",
|
|
3076
|
-
"
|
|
3343
|
+
"wasm_msg_guest_resolve_flags",
|
|
3077
3344
|
"wasm_msg_guest_set_resolver_state",
|
|
3078
3345
|
"wasm_msg_guest_bounded_flush_logs",
|
|
3079
3346
|
"wasm_msg_guest_bounded_flush_assign",
|
|
@@ -3088,9 +3355,9 @@ var UnsafeWasmResolver = class {
|
|
|
3088
3355
|
flushCount = 0;
|
|
3089
3356
|
constructor(module) {
|
|
3090
3357
|
const { exports } = new WebAssembly.Instance(module, { wasm_msg: { wasm_msg_host_current_time: () => {
|
|
3091
|
-
const
|
|
3092
|
-
const seconds = Math.floor(
|
|
3093
|
-
const nanos = (
|
|
3358
|
+
const epochMs = performance.timeOrigin + performance.now();
|
|
3359
|
+
const seconds = Math.floor(epochMs / 1e3);
|
|
3360
|
+
const nanos = Math.round((epochMs - seconds * 1e3) * 1e6);
|
|
3094
3361
|
return this.transferRequest({
|
|
3095
3362
|
seconds,
|
|
3096
3363
|
nanos
|
|
@@ -3099,10 +3366,10 @@ var UnsafeWasmResolver = class {
|
|
|
3099
3366
|
verifyExports(exports);
|
|
3100
3367
|
this.exports = exports;
|
|
3101
3368
|
}
|
|
3102
|
-
|
|
3103
|
-
const reqPtr = this.transferRequest(request,
|
|
3104
|
-
const resPtr = this.exports.
|
|
3105
|
-
return this.consumeResponse(resPtr,
|
|
3369
|
+
resolveProcess(request) {
|
|
3370
|
+
const reqPtr = this.transferRequest(request, ResolveProcessRequest);
|
|
3371
|
+
const resPtr = this.exports.wasm_msg_guest_resolve_flags(reqPtr);
|
|
3372
|
+
return this.consumeResponse(resPtr, ResolveProcessResponse);
|
|
3106
3373
|
}
|
|
3107
3374
|
setResolverState(request) {
|
|
3108
3375
|
const reqPtr = this.transferRequest(request, SetResolverStateRequest);
|
|
@@ -3175,9 +3442,9 @@ var WasmResolver = class {
|
|
|
3175
3442
|
this.delegate = this.delegateFactory(this.module);
|
|
3176
3443
|
if (this.currentState) this.delegate.setResolverState(this.currentState);
|
|
3177
3444
|
}
|
|
3178
|
-
|
|
3445
|
+
resolveProcess(request) {
|
|
3179
3446
|
try {
|
|
3180
|
-
return this.delegate.
|
|
3447
|
+
return this.delegate.resolveProcess(request);
|
|
3181
3448
|
} catch (error$1) {
|
|
3182
3449
|
if (error$1 instanceof WebAssembly.RuntimeError) this.reloadInstance(error$1);
|
|
3183
3450
|
throw error$1;
|