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