@spotify-confidence/openfeature-server-provider-local 0.2.0 → 0.4.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 +26 -0
- package/README.md +80 -58
- package/dist/confidence_resolver.wasm +0 -0
- package/dist/index.browser.d.ts +63 -26
- package/dist/index.browser.js +210 -775
- package/dist/index.node.d.ts +63 -26
- package/dist/index.node.js +210 -775
- package/dist/messages-Bw39oRlC.js +524 -0
- package/dist/messages-CvypvyG4.js +2 -0
- package/package.json +2 -2
package/dist/index.browser.js
CHANGED
|
@@ -1,320 +1,5 @@
|
|
|
1
|
+
import { Request, Response as Response$1, SetResolverStateRequest, Struct, Void } from "./messages-Bw39oRlC.js";
|
|
1
2
|
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
|
2
|
-
let NullValue = /* @__PURE__ */ function(NullValue$1) {
|
|
3
|
-
NullValue$1[NullValue$1["NULL_VALUE"] = 0] = "NULL_VALUE";
|
|
4
|
-
NullValue$1[NullValue$1["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
|
|
5
|
-
return NullValue$1;
|
|
6
|
-
}({});
|
|
7
|
-
function nullValueFromJSON(object) {
|
|
8
|
-
switch (object) {
|
|
9
|
-
case 0:
|
|
10
|
-
case "NULL_VALUE": return NullValue.NULL_VALUE;
|
|
11
|
-
case -1:
|
|
12
|
-
case "UNRECOGNIZED":
|
|
13
|
-
default: return NullValue.UNRECOGNIZED;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
function nullValueToJSON(object) {
|
|
17
|
-
switch (object) {
|
|
18
|
-
case NullValue.NULL_VALUE: return "NULL_VALUE";
|
|
19
|
-
case NullValue.UNRECOGNIZED:
|
|
20
|
-
default: return "UNRECOGNIZED";
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
function createBaseStruct() {
|
|
24
|
-
return { fields: {} };
|
|
25
|
-
}
|
|
26
|
-
const Struct = {
|
|
27
|
-
encode(message, writer = new BinaryWriter()) {
|
|
28
|
-
Object.entries(message.fields).forEach(([key, value]) => {
|
|
29
|
-
if (value !== void 0) Struct_FieldsEntry.encode({
|
|
30
|
-
key,
|
|
31
|
-
value
|
|
32
|
-
}, writer.uint32(10).fork()).join();
|
|
33
|
-
});
|
|
34
|
-
return writer;
|
|
35
|
-
},
|
|
36
|
-
decode(input, length) {
|
|
37
|
-
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
38
|
-
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
39
|
-
const message = createBaseStruct();
|
|
40
|
-
while (reader.pos < end) {
|
|
41
|
-
const tag = reader.uint32();
|
|
42
|
-
switch (tag >>> 3) {
|
|
43
|
-
case 1: {
|
|
44
|
-
if (tag !== 10) break;
|
|
45
|
-
const entry1 = Struct_FieldsEntry.decode(reader, reader.uint32());
|
|
46
|
-
if (entry1.value !== void 0) message.fields[entry1.key] = entry1.value;
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
if ((tag & 7) === 4 || tag === 0) break;
|
|
51
|
-
reader.skip(tag & 7);
|
|
52
|
-
}
|
|
53
|
-
return message;
|
|
54
|
-
},
|
|
55
|
-
fromJSON(object) {
|
|
56
|
-
return { fields: isObject$1(object.fields) ? Object.entries(object.fields).reduce((acc, [key, value]) => {
|
|
57
|
-
acc[key] = value;
|
|
58
|
-
return acc;
|
|
59
|
-
}, {}) : {} };
|
|
60
|
-
},
|
|
61
|
-
toJSON(message) {
|
|
62
|
-
const obj = {};
|
|
63
|
-
if (message.fields) {
|
|
64
|
-
const entries = Object.entries(message.fields);
|
|
65
|
-
if (entries.length > 0) {
|
|
66
|
-
obj.fields = {};
|
|
67
|
-
entries.forEach(([k, v]) => {
|
|
68
|
-
obj.fields[k] = v;
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return obj;
|
|
73
|
-
},
|
|
74
|
-
create(base) {
|
|
75
|
-
return Struct.fromPartial(base ?? {});
|
|
76
|
-
},
|
|
77
|
-
fromPartial(object) {
|
|
78
|
-
const message = createBaseStruct();
|
|
79
|
-
message.fields = Object.entries(object.fields ?? {}).reduce((acc, [key, value]) => {
|
|
80
|
-
if (value !== void 0) acc[key] = value;
|
|
81
|
-
return acc;
|
|
82
|
-
}, {});
|
|
83
|
-
return message;
|
|
84
|
-
},
|
|
85
|
-
wrap(object) {
|
|
86
|
-
const struct = createBaseStruct();
|
|
87
|
-
if (object !== void 0) for (const key of Object.keys(object)) struct.fields[key] = object[key];
|
|
88
|
-
return struct;
|
|
89
|
-
},
|
|
90
|
-
unwrap(message) {
|
|
91
|
-
const object = {};
|
|
92
|
-
if (message.fields) for (const key of Object.keys(message.fields)) object[key] = message.fields[key];
|
|
93
|
-
return object;
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
function createBaseStruct_FieldsEntry() {
|
|
97
|
-
return {
|
|
98
|
-
key: "",
|
|
99
|
-
value: void 0
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
const Struct_FieldsEntry = {
|
|
103
|
-
encode(message, writer = new BinaryWriter()) {
|
|
104
|
-
if (message.key !== "") writer.uint32(10).string(message.key);
|
|
105
|
-
if (message.value !== void 0) Value.encode(Value.wrap(message.value), writer.uint32(18).fork()).join();
|
|
106
|
-
return writer;
|
|
107
|
-
},
|
|
108
|
-
decode(input, length) {
|
|
109
|
-
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
110
|
-
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
111
|
-
const message = createBaseStruct_FieldsEntry();
|
|
112
|
-
while (reader.pos < end) {
|
|
113
|
-
const tag = reader.uint32();
|
|
114
|
-
switch (tag >>> 3) {
|
|
115
|
-
case 1:
|
|
116
|
-
if (tag !== 10) break;
|
|
117
|
-
message.key = reader.string();
|
|
118
|
-
continue;
|
|
119
|
-
case 2:
|
|
120
|
-
if (tag !== 18) break;
|
|
121
|
-
message.value = Value.unwrap(Value.decode(reader, reader.uint32()));
|
|
122
|
-
continue;
|
|
123
|
-
}
|
|
124
|
-
if ((tag & 7) === 4 || tag === 0) break;
|
|
125
|
-
reader.skip(tag & 7);
|
|
126
|
-
}
|
|
127
|
-
return message;
|
|
128
|
-
},
|
|
129
|
-
fromJSON(object) {
|
|
130
|
-
return {
|
|
131
|
-
key: isSet$3(object.key) ? globalThis.String(object.key) : "",
|
|
132
|
-
value: isSet$3(object?.value) ? object.value : void 0
|
|
133
|
-
};
|
|
134
|
-
},
|
|
135
|
-
toJSON(message) {
|
|
136
|
-
const obj = {};
|
|
137
|
-
if (message.key !== "") obj.key = message.key;
|
|
138
|
-
if (message.value !== void 0) obj.value = message.value;
|
|
139
|
-
return obj;
|
|
140
|
-
},
|
|
141
|
-
create(base) {
|
|
142
|
-
return Struct_FieldsEntry.fromPartial(base ?? {});
|
|
143
|
-
},
|
|
144
|
-
fromPartial(object) {
|
|
145
|
-
const message = createBaseStruct_FieldsEntry();
|
|
146
|
-
message.key = object.key ?? "";
|
|
147
|
-
message.value = object.value ?? void 0;
|
|
148
|
-
return message;
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
function createBaseValue() {
|
|
152
|
-
return {
|
|
153
|
-
nullValue: void 0,
|
|
154
|
-
numberValue: void 0,
|
|
155
|
-
stringValue: void 0,
|
|
156
|
-
boolValue: void 0,
|
|
157
|
-
structValue: void 0,
|
|
158
|
-
listValue: void 0
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
const Value = {
|
|
162
|
-
encode(message, writer = new BinaryWriter()) {
|
|
163
|
-
if (message.nullValue !== void 0) writer.uint32(8).int32(message.nullValue);
|
|
164
|
-
if (message.numberValue !== void 0) writer.uint32(17).double(message.numberValue);
|
|
165
|
-
if (message.stringValue !== void 0) writer.uint32(26).string(message.stringValue);
|
|
166
|
-
if (message.boolValue !== void 0) writer.uint32(32).bool(message.boolValue);
|
|
167
|
-
if (message.structValue !== void 0) Struct.encode(Struct.wrap(message.structValue), writer.uint32(42).fork()).join();
|
|
168
|
-
if (message.listValue !== void 0) ListValue.encode(ListValue.wrap(message.listValue), writer.uint32(50).fork()).join();
|
|
169
|
-
return writer;
|
|
170
|
-
},
|
|
171
|
-
decode(input, length) {
|
|
172
|
-
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
173
|
-
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
174
|
-
const message = createBaseValue();
|
|
175
|
-
while (reader.pos < end) {
|
|
176
|
-
const tag = reader.uint32();
|
|
177
|
-
switch (tag >>> 3) {
|
|
178
|
-
case 1:
|
|
179
|
-
if (tag !== 8) break;
|
|
180
|
-
message.nullValue = reader.int32();
|
|
181
|
-
continue;
|
|
182
|
-
case 2:
|
|
183
|
-
if (tag !== 17) break;
|
|
184
|
-
message.numberValue = reader.double();
|
|
185
|
-
continue;
|
|
186
|
-
case 3:
|
|
187
|
-
if (tag !== 26) break;
|
|
188
|
-
message.stringValue = reader.string();
|
|
189
|
-
continue;
|
|
190
|
-
case 4:
|
|
191
|
-
if (tag !== 32) break;
|
|
192
|
-
message.boolValue = reader.bool();
|
|
193
|
-
continue;
|
|
194
|
-
case 5:
|
|
195
|
-
if (tag !== 42) break;
|
|
196
|
-
message.structValue = Struct.unwrap(Struct.decode(reader, reader.uint32()));
|
|
197
|
-
continue;
|
|
198
|
-
case 6:
|
|
199
|
-
if (tag !== 50) break;
|
|
200
|
-
message.listValue = ListValue.unwrap(ListValue.decode(reader, reader.uint32()));
|
|
201
|
-
continue;
|
|
202
|
-
}
|
|
203
|
-
if ((tag & 7) === 4 || tag === 0) break;
|
|
204
|
-
reader.skip(tag & 7);
|
|
205
|
-
}
|
|
206
|
-
return message;
|
|
207
|
-
},
|
|
208
|
-
fromJSON(object) {
|
|
209
|
-
return {
|
|
210
|
-
nullValue: isSet$3(object.nullValue) ? nullValueFromJSON(object.nullValue) : void 0,
|
|
211
|
-
numberValue: isSet$3(object.numberValue) ? globalThis.Number(object.numberValue) : void 0,
|
|
212
|
-
stringValue: isSet$3(object.stringValue) ? globalThis.String(object.stringValue) : void 0,
|
|
213
|
-
boolValue: isSet$3(object.boolValue) ? globalThis.Boolean(object.boolValue) : void 0,
|
|
214
|
-
structValue: isObject$1(object.structValue) ? object.structValue : void 0,
|
|
215
|
-
listValue: globalThis.Array.isArray(object.listValue) ? [...object.listValue] : void 0
|
|
216
|
-
};
|
|
217
|
-
},
|
|
218
|
-
toJSON(message) {
|
|
219
|
-
const obj = {};
|
|
220
|
-
if (message.nullValue !== void 0) obj.nullValue = nullValueToJSON(message.nullValue);
|
|
221
|
-
if (message.numberValue !== void 0) obj.numberValue = message.numberValue;
|
|
222
|
-
if (message.stringValue !== void 0) obj.stringValue = message.stringValue;
|
|
223
|
-
if (message.boolValue !== void 0) obj.boolValue = message.boolValue;
|
|
224
|
-
if (message.structValue !== void 0) obj.structValue = message.structValue;
|
|
225
|
-
if (message.listValue !== void 0) obj.listValue = message.listValue;
|
|
226
|
-
return obj;
|
|
227
|
-
},
|
|
228
|
-
create(base) {
|
|
229
|
-
return Value.fromPartial(base ?? {});
|
|
230
|
-
},
|
|
231
|
-
fromPartial(object) {
|
|
232
|
-
const message = createBaseValue();
|
|
233
|
-
message.nullValue = object.nullValue ?? void 0;
|
|
234
|
-
message.numberValue = object.numberValue ?? void 0;
|
|
235
|
-
message.stringValue = object.stringValue ?? void 0;
|
|
236
|
-
message.boolValue = object.boolValue ?? void 0;
|
|
237
|
-
message.structValue = object.structValue ?? void 0;
|
|
238
|
-
message.listValue = object.listValue ?? void 0;
|
|
239
|
-
return message;
|
|
240
|
-
},
|
|
241
|
-
wrap(value) {
|
|
242
|
-
const result = createBaseValue();
|
|
243
|
-
if (value === null) result.nullValue = NullValue.NULL_VALUE;
|
|
244
|
-
else if (typeof value === "boolean") result.boolValue = value;
|
|
245
|
-
else if (typeof value === "number") result.numberValue = value;
|
|
246
|
-
else if (typeof value === "string") result.stringValue = value;
|
|
247
|
-
else if (globalThis.Array.isArray(value)) result.listValue = value;
|
|
248
|
-
else if (typeof value === "object") result.structValue = value;
|
|
249
|
-
else if (typeof value !== "undefined") throw new globalThis.Error("Unsupported any value type: " + typeof value);
|
|
250
|
-
return result;
|
|
251
|
-
},
|
|
252
|
-
unwrap(message) {
|
|
253
|
-
if (message.stringValue !== void 0) return message.stringValue;
|
|
254
|
-
else if (message?.numberValue !== void 0) return message.numberValue;
|
|
255
|
-
else if (message?.boolValue !== void 0) return message.boolValue;
|
|
256
|
-
else if (message?.structValue !== void 0) return message.structValue;
|
|
257
|
-
else if (message?.listValue !== void 0) return message.listValue;
|
|
258
|
-
else if (message?.nullValue !== void 0) return null;
|
|
259
|
-
}
|
|
260
|
-
};
|
|
261
|
-
function createBaseListValue() {
|
|
262
|
-
return { values: [] };
|
|
263
|
-
}
|
|
264
|
-
const ListValue = {
|
|
265
|
-
encode(message, writer = new BinaryWriter()) {
|
|
266
|
-
for (const v of message.values) Value.encode(Value.wrap(v), writer.uint32(10).fork()).join();
|
|
267
|
-
return writer;
|
|
268
|
-
},
|
|
269
|
-
decode(input, length) {
|
|
270
|
-
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
271
|
-
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
272
|
-
const message = createBaseListValue();
|
|
273
|
-
while (reader.pos < end) {
|
|
274
|
-
const tag = reader.uint32();
|
|
275
|
-
switch (tag >>> 3) {
|
|
276
|
-
case 1:
|
|
277
|
-
if (tag !== 10) break;
|
|
278
|
-
message.values.push(Value.unwrap(Value.decode(reader, reader.uint32())));
|
|
279
|
-
continue;
|
|
280
|
-
}
|
|
281
|
-
if ((tag & 7) === 4 || tag === 0) break;
|
|
282
|
-
reader.skip(tag & 7);
|
|
283
|
-
}
|
|
284
|
-
return message;
|
|
285
|
-
},
|
|
286
|
-
fromJSON(object) {
|
|
287
|
-
return { values: globalThis.Array.isArray(object?.values) ? [...object.values] : [] };
|
|
288
|
-
},
|
|
289
|
-
toJSON(message) {
|
|
290
|
-
const obj = {};
|
|
291
|
-
if (message.values?.length) obj.values = message.values;
|
|
292
|
-
return obj;
|
|
293
|
-
},
|
|
294
|
-
create(base) {
|
|
295
|
-
return ListValue.fromPartial(base ?? {});
|
|
296
|
-
},
|
|
297
|
-
fromPartial(object) {
|
|
298
|
-
const message = createBaseListValue();
|
|
299
|
-
message.values = object.values?.map((e) => e) || [];
|
|
300
|
-
return message;
|
|
301
|
-
},
|
|
302
|
-
wrap(array) {
|
|
303
|
-
const result = createBaseListValue();
|
|
304
|
-
result.values = array ?? [];
|
|
305
|
-
return result;
|
|
306
|
-
},
|
|
307
|
-
unwrap(message) {
|
|
308
|
-
if (message?.hasOwnProperty("values") && globalThis.Array.isArray(message.values)) return message.values;
|
|
309
|
-
else return message;
|
|
310
|
-
}
|
|
311
|
-
};
|
|
312
|
-
function isObject$1(value) {
|
|
313
|
-
return typeof value === "object" && value !== null;
|
|
314
|
-
}
|
|
315
|
-
function isSet$3(value) {
|
|
316
|
-
return value !== null && value !== void 0;
|
|
317
|
-
}
|
|
318
3
|
let SdkId = /* @__PURE__ */ function(SdkId$1) {
|
|
319
4
|
SdkId$1[SdkId$1["SDK_ID_UNSPECIFIED"] = 0] = "SDK_ID_UNSPECIFIED";
|
|
320
5
|
SdkId$1[SdkId$1["SDK_ID_JAVA_PROVIDER"] = 1] = "SDK_ID_JAVA_PROVIDER";
|
|
@@ -424,51 +109,6 @@ function sdkIdToJSON(object) {
|
|
|
424
109
|
default: return "UNRECOGNIZED";
|
|
425
110
|
}
|
|
426
111
|
}
|
|
427
|
-
let ResolveReason = /* @__PURE__ */ function(ResolveReason$1) {
|
|
428
|
-
ResolveReason$1[ResolveReason$1["RESOLVE_REASON_UNSPECIFIED"] = 0] = "RESOLVE_REASON_UNSPECIFIED";
|
|
429
|
-
ResolveReason$1[ResolveReason$1["RESOLVE_REASON_MATCH"] = 1] = "RESOLVE_REASON_MATCH";
|
|
430
|
-
ResolveReason$1[ResolveReason$1["RESOLVE_REASON_NO_SEGMENT_MATCH"] = 2] = "RESOLVE_REASON_NO_SEGMENT_MATCH";
|
|
431
|
-
ResolveReason$1[ResolveReason$1["RESOLVE_REASON_NO_TREATMENT_MATCH"] = 3] = "RESOLVE_REASON_NO_TREATMENT_MATCH";
|
|
432
|
-
ResolveReason$1[ResolveReason$1["RESOLVE_REASON_FLAG_ARCHIVED"] = 4] = "RESOLVE_REASON_FLAG_ARCHIVED";
|
|
433
|
-
ResolveReason$1[ResolveReason$1["RESOLVE_REASON_TARGETING_KEY_ERROR"] = 5] = "RESOLVE_REASON_TARGETING_KEY_ERROR";
|
|
434
|
-
ResolveReason$1[ResolveReason$1["RESOLVE_REASON_ERROR"] = 6] = "RESOLVE_REASON_ERROR";
|
|
435
|
-
ResolveReason$1[ResolveReason$1["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
|
|
436
|
-
return ResolveReason$1;
|
|
437
|
-
}({});
|
|
438
|
-
function resolveReasonFromJSON(object) {
|
|
439
|
-
switch (object) {
|
|
440
|
-
case 0:
|
|
441
|
-
case "RESOLVE_REASON_UNSPECIFIED": return ResolveReason.RESOLVE_REASON_UNSPECIFIED;
|
|
442
|
-
case 1:
|
|
443
|
-
case "RESOLVE_REASON_MATCH": return ResolveReason.RESOLVE_REASON_MATCH;
|
|
444
|
-
case 2:
|
|
445
|
-
case "RESOLVE_REASON_NO_SEGMENT_MATCH": return ResolveReason.RESOLVE_REASON_NO_SEGMENT_MATCH;
|
|
446
|
-
case 3:
|
|
447
|
-
case "RESOLVE_REASON_NO_TREATMENT_MATCH": return ResolveReason.RESOLVE_REASON_NO_TREATMENT_MATCH;
|
|
448
|
-
case 4:
|
|
449
|
-
case "RESOLVE_REASON_FLAG_ARCHIVED": return ResolveReason.RESOLVE_REASON_FLAG_ARCHIVED;
|
|
450
|
-
case 5:
|
|
451
|
-
case "RESOLVE_REASON_TARGETING_KEY_ERROR": return ResolveReason.RESOLVE_REASON_TARGETING_KEY_ERROR;
|
|
452
|
-
case 6:
|
|
453
|
-
case "RESOLVE_REASON_ERROR": return ResolveReason.RESOLVE_REASON_ERROR;
|
|
454
|
-
case -1:
|
|
455
|
-
case "UNRECOGNIZED":
|
|
456
|
-
default: return ResolveReason.UNRECOGNIZED;
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
function resolveReasonToJSON(object) {
|
|
460
|
-
switch (object) {
|
|
461
|
-
case ResolveReason.RESOLVE_REASON_UNSPECIFIED: return "RESOLVE_REASON_UNSPECIFIED";
|
|
462
|
-
case ResolveReason.RESOLVE_REASON_MATCH: return "RESOLVE_REASON_MATCH";
|
|
463
|
-
case ResolveReason.RESOLVE_REASON_NO_SEGMENT_MATCH: return "RESOLVE_REASON_NO_SEGMENT_MATCH";
|
|
464
|
-
case ResolveReason.RESOLVE_REASON_NO_TREATMENT_MATCH: return "RESOLVE_REASON_NO_TREATMENT_MATCH";
|
|
465
|
-
case ResolveReason.RESOLVE_REASON_FLAG_ARCHIVED: return "RESOLVE_REASON_FLAG_ARCHIVED";
|
|
466
|
-
case ResolveReason.RESOLVE_REASON_TARGETING_KEY_ERROR: return "RESOLVE_REASON_TARGETING_KEY_ERROR";
|
|
467
|
-
case ResolveReason.RESOLVE_REASON_ERROR: return "RESOLVE_REASON_ERROR";
|
|
468
|
-
case ResolveReason.UNRECOGNIZED:
|
|
469
|
-
default: return "UNRECOGNIZED";
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
112
|
function createBaseSdk() {
|
|
473
113
|
return {
|
|
474
114
|
id: void 0,
|
|
@@ -532,7 +172,119 @@ const Sdk = {
|
|
|
532
172
|
message.version = object.version ?? "";
|
|
533
173
|
return message;
|
|
534
174
|
}
|
|
535
|
-
};
|
|
175
|
+
};
|
|
176
|
+
function isSet$2(value) {
|
|
177
|
+
return value !== null && value !== void 0;
|
|
178
|
+
}
|
|
179
|
+
function createBaseTimestamp() {
|
|
180
|
+
return {
|
|
181
|
+
seconds: 0,
|
|
182
|
+
nanos: 0
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
const Timestamp = {
|
|
186
|
+
encode(message, writer = new BinaryWriter()) {
|
|
187
|
+
if (message.seconds !== 0) writer.uint32(8).int64(message.seconds);
|
|
188
|
+
if (message.nanos !== 0) writer.uint32(16).int32(message.nanos);
|
|
189
|
+
return writer;
|
|
190
|
+
},
|
|
191
|
+
decode(input, length) {
|
|
192
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
193
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
194
|
+
const message = createBaseTimestamp();
|
|
195
|
+
while (reader.pos < end) {
|
|
196
|
+
const tag = reader.uint32();
|
|
197
|
+
switch (tag >>> 3) {
|
|
198
|
+
case 1:
|
|
199
|
+
if (tag !== 8) break;
|
|
200
|
+
message.seconds = longToNumber(reader.int64());
|
|
201
|
+
continue;
|
|
202
|
+
case 2:
|
|
203
|
+
if (tag !== 16) break;
|
|
204
|
+
message.nanos = reader.int32();
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
if ((tag & 7) === 4 || tag === 0) break;
|
|
208
|
+
reader.skip(tag & 7);
|
|
209
|
+
}
|
|
210
|
+
return message;
|
|
211
|
+
},
|
|
212
|
+
fromJSON(object) {
|
|
213
|
+
return {
|
|
214
|
+
seconds: isSet$1(object.seconds) ? globalThis.Number(object.seconds) : 0,
|
|
215
|
+
nanos: isSet$1(object.nanos) ? globalThis.Number(object.nanos) : 0
|
|
216
|
+
};
|
|
217
|
+
},
|
|
218
|
+
toJSON(message) {
|
|
219
|
+
const obj = {};
|
|
220
|
+
if (message.seconds !== 0) obj.seconds = Math.round(message.seconds);
|
|
221
|
+
if (message.nanos !== 0) obj.nanos = Math.round(message.nanos);
|
|
222
|
+
return obj;
|
|
223
|
+
},
|
|
224
|
+
create(base) {
|
|
225
|
+
return Timestamp.fromPartial(base ?? {});
|
|
226
|
+
},
|
|
227
|
+
fromPartial(object) {
|
|
228
|
+
const message = createBaseTimestamp();
|
|
229
|
+
message.seconds = object.seconds ?? 0;
|
|
230
|
+
message.nanos = object.nanos ?? 0;
|
|
231
|
+
return message;
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
function longToNumber(int64) {
|
|
235
|
+
const num = globalThis.Number(int64.toString());
|
|
236
|
+
if (num > globalThis.Number.MAX_SAFE_INTEGER) throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
|
|
237
|
+
if (num < globalThis.Number.MIN_SAFE_INTEGER) throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");
|
|
238
|
+
return num;
|
|
239
|
+
}
|
|
240
|
+
function isSet$1(value) {
|
|
241
|
+
return value !== null && value !== void 0;
|
|
242
|
+
}
|
|
243
|
+
let ResolveReason = /* @__PURE__ */ function(ResolveReason$1) {
|
|
244
|
+
ResolveReason$1[ResolveReason$1["RESOLVE_REASON_UNSPECIFIED"] = 0] = "RESOLVE_REASON_UNSPECIFIED";
|
|
245
|
+
ResolveReason$1[ResolveReason$1["RESOLVE_REASON_MATCH"] = 1] = "RESOLVE_REASON_MATCH";
|
|
246
|
+
ResolveReason$1[ResolveReason$1["RESOLVE_REASON_NO_SEGMENT_MATCH"] = 2] = "RESOLVE_REASON_NO_SEGMENT_MATCH";
|
|
247
|
+
ResolveReason$1[ResolveReason$1["RESOLVE_REASON_NO_TREATMENT_MATCH"] = 3] = "RESOLVE_REASON_NO_TREATMENT_MATCH";
|
|
248
|
+
ResolveReason$1[ResolveReason$1["RESOLVE_REASON_FLAG_ARCHIVED"] = 4] = "RESOLVE_REASON_FLAG_ARCHIVED";
|
|
249
|
+
ResolveReason$1[ResolveReason$1["RESOLVE_REASON_TARGETING_KEY_ERROR"] = 5] = "RESOLVE_REASON_TARGETING_KEY_ERROR";
|
|
250
|
+
ResolveReason$1[ResolveReason$1["RESOLVE_REASON_ERROR"] = 6] = "RESOLVE_REASON_ERROR";
|
|
251
|
+
ResolveReason$1[ResolveReason$1["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
|
|
252
|
+
return ResolveReason$1;
|
|
253
|
+
}({});
|
|
254
|
+
function resolveReasonFromJSON(object) {
|
|
255
|
+
switch (object) {
|
|
256
|
+
case 0:
|
|
257
|
+
case "RESOLVE_REASON_UNSPECIFIED": return ResolveReason.RESOLVE_REASON_UNSPECIFIED;
|
|
258
|
+
case 1:
|
|
259
|
+
case "RESOLVE_REASON_MATCH": return ResolveReason.RESOLVE_REASON_MATCH;
|
|
260
|
+
case 2:
|
|
261
|
+
case "RESOLVE_REASON_NO_SEGMENT_MATCH": return ResolveReason.RESOLVE_REASON_NO_SEGMENT_MATCH;
|
|
262
|
+
case 3:
|
|
263
|
+
case "RESOLVE_REASON_NO_TREATMENT_MATCH": return ResolveReason.RESOLVE_REASON_NO_TREATMENT_MATCH;
|
|
264
|
+
case 4:
|
|
265
|
+
case "RESOLVE_REASON_FLAG_ARCHIVED": return ResolveReason.RESOLVE_REASON_FLAG_ARCHIVED;
|
|
266
|
+
case 5:
|
|
267
|
+
case "RESOLVE_REASON_TARGETING_KEY_ERROR": return ResolveReason.RESOLVE_REASON_TARGETING_KEY_ERROR;
|
|
268
|
+
case 6:
|
|
269
|
+
case "RESOLVE_REASON_ERROR": return ResolveReason.RESOLVE_REASON_ERROR;
|
|
270
|
+
case -1:
|
|
271
|
+
case "UNRECOGNIZED":
|
|
272
|
+
default: return ResolveReason.UNRECOGNIZED;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
function resolveReasonToJSON(object) {
|
|
276
|
+
switch (object) {
|
|
277
|
+
case ResolveReason.RESOLVE_REASON_UNSPECIFIED: return "RESOLVE_REASON_UNSPECIFIED";
|
|
278
|
+
case ResolveReason.RESOLVE_REASON_MATCH: return "RESOLVE_REASON_MATCH";
|
|
279
|
+
case ResolveReason.RESOLVE_REASON_NO_SEGMENT_MATCH: return "RESOLVE_REASON_NO_SEGMENT_MATCH";
|
|
280
|
+
case ResolveReason.RESOLVE_REASON_NO_TREATMENT_MATCH: return "RESOLVE_REASON_NO_TREATMENT_MATCH";
|
|
281
|
+
case ResolveReason.RESOLVE_REASON_FLAG_ARCHIVED: return "RESOLVE_REASON_FLAG_ARCHIVED";
|
|
282
|
+
case ResolveReason.RESOLVE_REASON_TARGETING_KEY_ERROR: return "RESOLVE_REASON_TARGETING_KEY_ERROR";
|
|
283
|
+
case ResolveReason.RESOLVE_REASON_ERROR: return "RESOLVE_REASON_ERROR";
|
|
284
|
+
case ResolveReason.UNRECOGNIZED:
|
|
285
|
+
default: return "UNRECOGNIZED";
|
|
286
|
+
}
|
|
287
|
+
}
|
|
536
288
|
function createBaseResolveFlagsRequest() {
|
|
537
289
|
return {
|
|
538
290
|
flags: [],
|
|
@@ -588,9 +340,9 @@ const ResolveFlagsRequest = {
|
|
|
588
340
|
return {
|
|
589
341
|
flags: globalThis.Array.isArray(object?.flags) ? object.flags.map((e) => globalThis.String(e)) : [],
|
|
590
342
|
evaluationContext: isObject(object.evaluationContext) ? object.evaluationContext : void 0,
|
|
591
|
-
clientSecret: isSet
|
|
592
|
-
apply: isSet
|
|
593
|
-
sdk: isSet
|
|
343
|
+
clientSecret: isSet(object.clientSecret) ? globalThis.String(object.clientSecret) : "",
|
|
344
|
+
apply: isSet(object.apply) ? globalThis.Boolean(object.apply) : false,
|
|
345
|
+
sdk: isSet(object.sdk) ? Sdk.fromJSON(object.sdk) : void 0
|
|
594
346
|
};
|
|
595
347
|
},
|
|
596
348
|
toJSON(message) {
|
|
@@ -657,14 +409,14 @@ const ResolveFlagsResponse = {
|
|
|
657
409
|
fromJSON(object) {
|
|
658
410
|
return {
|
|
659
411
|
resolvedFlags: globalThis.Array.isArray(object?.resolvedFlags) ? object.resolvedFlags.map((e) => ResolvedFlag.fromJSON(e)) : [],
|
|
660
|
-
resolveToken: isSet
|
|
661
|
-
resolveId: isSet
|
|
412
|
+
resolveToken: isSet(object.resolveToken) ? bytesFromBase64(object.resolveToken) : new Uint8Array(0),
|
|
413
|
+
resolveId: isSet(object.resolveId) ? globalThis.String(object.resolveId) : ""
|
|
662
414
|
};
|
|
663
415
|
},
|
|
664
416
|
toJSON(message) {
|
|
665
417
|
const obj = {};
|
|
666
418
|
if (message.resolvedFlags?.length) obj.resolvedFlags = message.resolvedFlags.map((e) => ResolvedFlag.toJSON(e));
|
|
667
|
-
if (message.resolveToken.length !== 0) obj.resolveToken = base64FromBytes
|
|
419
|
+
if (message.resolveToken.length !== 0) obj.resolveToken = base64FromBytes(message.resolveToken);
|
|
668
420
|
if (message.resolveId !== "") obj.resolveId = message.resolveId;
|
|
669
421
|
return obj;
|
|
670
422
|
},
|
|
@@ -726,10 +478,10 @@ const ResolvedFlag = {
|
|
|
726
478
|
},
|
|
727
479
|
fromJSON(object) {
|
|
728
480
|
return {
|
|
729
|
-
flag: isSet
|
|
730
|
-
variant: isSet
|
|
481
|
+
flag: isSet(object.flag) ? globalThis.String(object.flag) : "",
|
|
482
|
+
variant: isSet(object.variant) ? globalThis.String(object.variant) : "",
|
|
731
483
|
value: isObject(object.value) ? object.value : void 0,
|
|
732
|
-
reason: isSet
|
|
484
|
+
reason: isSet(object.reason) ? resolveReasonFromJSON(object.reason) : 0
|
|
733
485
|
};
|
|
734
486
|
},
|
|
735
487
|
toJSON(message) {
|
|
@@ -752,61 +504,6 @@ const ResolvedFlag = {
|
|
|
752
504
|
return message;
|
|
753
505
|
}
|
|
754
506
|
};
|
|
755
|
-
function createBaseSetResolverStateRequest() {
|
|
756
|
-
return {
|
|
757
|
-
state: new Uint8Array(0),
|
|
758
|
-
accountId: ""
|
|
759
|
-
};
|
|
760
|
-
}
|
|
761
|
-
const SetResolverStateRequest = {
|
|
762
|
-
encode(message, writer = new BinaryWriter()) {
|
|
763
|
-
if (message.state.length !== 0) writer.uint32(10).bytes(message.state);
|
|
764
|
-
if (message.accountId !== "") writer.uint32(18).string(message.accountId);
|
|
765
|
-
return writer;
|
|
766
|
-
},
|
|
767
|
-
decode(input, length) {
|
|
768
|
-
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
769
|
-
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
770
|
-
const message = createBaseSetResolverStateRequest();
|
|
771
|
-
while (reader.pos < end) {
|
|
772
|
-
const tag = reader.uint32();
|
|
773
|
-
switch (tag >>> 3) {
|
|
774
|
-
case 1:
|
|
775
|
-
if (tag !== 10) break;
|
|
776
|
-
message.state = reader.bytes();
|
|
777
|
-
continue;
|
|
778
|
-
case 2:
|
|
779
|
-
if (tag !== 18) break;
|
|
780
|
-
message.accountId = reader.string();
|
|
781
|
-
continue;
|
|
782
|
-
}
|
|
783
|
-
if ((tag & 7) === 4 || tag === 0) break;
|
|
784
|
-
reader.skip(tag & 7);
|
|
785
|
-
}
|
|
786
|
-
return message;
|
|
787
|
-
},
|
|
788
|
-
fromJSON(object) {
|
|
789
|
-
return {
|
|
790
|
-
state: isSet$2(object.state) ? bytesFromBase64$1(object.state) : new Uint8Array(0),
|
|
791
|
-
accountId: isSet$2(object.accountId) ? globalThis.String(object.accountId) : ""
|
|
792
|
-
};
|
|
793
|
-
},
|
|
794
|
-
toJSON(message) {
|
|
795
|
-
const obj = {};
|
|
796
|
-
if (message.state.length !== 0) obj.state = base64FromBytes$1(message.state);
|
|
797
|
-
if (message.accountId !== "") obj.accountId = message.accountId;
|
|
798
|
-
return obj;
|
|
799
|
-
},
|
|
800
|
-
create(base) {
|
|
801
|
-
return SetResolverStateRequest.fromPartial(base ?? {});
|
|
802
|
-
},
|
|
803
|
-
fromPartial(object) {
|
|
804
|
-
const message = createBaseSetResolverStateRequest();
|
|
805
|
-
message.state = object.state ?? new Uint8Array(0);
|
|
806
|
-
message.accountId = object.accountId ?? "";
|
|
807
|
-
return message;
|
|
808
|
-
}
|
|
809
|
-
};
|
|
810
507
|
function createBaseResolveWithStickyRequest() {
|
|
811
508
|
return {
|
|
812
509
|
resolveRequest: void 0,
|
|
@@ -855,12 +552,12 @@ const ResolveWithStickyRequest = {
|
|
|
855
552
|
},
|
|
856
553
|
fromJSON(object) {
|
|
857
554
|
return {
|
|
858
|
-
resolveRequest: isSet
|
|
555
|
+
resolveRequest: isSet(object.resolveRequest) ? ResolveFlagsRequest.fromJSON(object.resolveRequest) : void 0,
|
|
859
556
|
materializationsPerUnit: isObject(object.materializationsPerUnit) ? Object.entries(object.materializationsPerUnit).reduce((acc, [key, value]) => {
|
|
860
557
|
acc[key] = MaterializationMap.fromJSON(value);
|
|
861
558
|
return acc;
|
|
862
559
|
}, {}) : {},
|
|
863
|
-
failFastOnSticky: isSet
|
|
560
|
+
failFastOnSticky: isSet(object.failFastOnSticky) ? globalThis.Boolean(object.failFastOnSticky) : false
|
|
864
561
|
};
|
|
865
562
|
},
|
|
866
563
|
toJSON(message) {
|
|
@@ -927,8 +624,8 @@ const ResolveWithStickyRequest_MaterializationsPerUnitEntry = {
|
|
|
927
624
|
},
|
|
928
625
|
fromJSON(object) {
|
|
929
626
|
return {
|
|
930
|
-
key: isSet
|
|
931
|
-
value: isSet
|
|
627
|
+
key: isSet(object.key) ? globalThis.String(object.key) : "",
|
|
628
|
+
value: isSet(object.value) ? MaterializationMap.fromJSON(object.value) : void 0
|
|
932
629
|
};
|
|
933
630
|
},
|
|
934
631
|
toJSON(message) {
|
|
@@ -1045,8 +742,8 @@ const MaterializationMap_InfoMapEntry = {
|
|
|
1045
742
|
},
|
|
1046
743
|
fromJSON(object) {
|
|
1047
744
|
return {
|
|
1048
|
-
key: isSet
|
|
1049
|
-
value: isSet
|
|
745
|
+
key: isSet(object.key) ? globalThis.String(object.key) : "",
|
|
746
|
+
value: isSet(object.value) ? MaterializationInfo.fromJSON(object.value) : void 0
|
|
1050
747
|
};
|
|
1051
748
|
},
|
|
1052
749
|
toJSON(message) {
|
|
@@ -1107,7 +804,7 @@ const MaterializationInfo = {
|
|
|
1107
804
|
},
|
|
1108
805
|
fromJSON(object) {
|
|
1109
806
|
return {
|
|
1110
|
-
unitInInfo: isSet
|
|
807
|
+
unitInInfo: isSet(object.unitInInfo) ? globalThis.Boolean(object.unitInInfo) : false,
|
|
1111
808
|
ruleToVariant: isObject(object.ruleToVariant) ? Object.entries(object.ruleToVariant).reduce((acc, [key, value]) => {
|
|
1112
809
|
acc[key] = String(value);
|
|
1113
810
|
return acc;
|
|
@@ -1176,8 +873,8 @@ const MaterializationInfo_RuleToVariantEntry = {
|
|
|
1176
873
|
},
|
|
1177
874
|
fromJSON(object) {
|
|
1178
875
|
return {
|
|
1179
|
-
key: isSet
|
|
1180
|
-
value: isSet
|
|
876
|
+
key: isSet(object.key) ? globalThis.String(object.key) : "",
|
|
877
|
+
value: isSet(object.value) ? globalThis.String(object.value) : ""
|
|
1181
878
|
};
|
|
1182
879
|
},
|
|
1183
880
|
toJSON(message) {
|
|
@@ -1231,8 +928,8 @@ const ResolveWithStickyResponse = {
|
|
|
1231
928
|
},
|
|
1232
929
|
fromJSON(object) {
|
|
1233
930
|
return {
|
|
1234
|
-
success: isSet
|
|
1235
|
-
missingMaterializations: isSet
|
|
931
|
+
success: isSet(object.success) ? ResolveWithStickyResponse_Success.fromJSON(object.success) : void 0,
|
|
932
|
+
missingMaterializations: isSet(object.missingMaterializations) ? ResolveWithStickyResponse_MissingMaterializations.fromJSON(object.missingMaterializations) : void 0
|
|
1236
933
|
};
|
|
1237
934
|
},
|
|
1238
935
|
toJSON(message) {
|
|
@@ -1286,7 +983,7 @@ const ResolveWithStickyResponse_Success = {
|
|
|
1286
983
|
},
|
|
1287
984
|
fromJSON(object) {
|
|
1288
985
|
return {
|
|
1289
|
-
response: isSet
|
|
986
|
+
response: isSet(object.response) ? ResolveFlagsResponse.fromJSON(object.response) : void 0,
|
|
1290
987
|
updates: globalThis.Array.isArray(object?.updates) ? object.updates.map((e) => ResolveWithStickyResponse_MaterializationUpdate.fromJSON(e)) : []
|
|
1291
988
|
};
|
|
1292
989
|
},
|
|
@@ -1389,9 +1086,9 @@ const ResolveWithStickyResponse_MissingMaterializationItem = {
|
|
|
1389
1086
|
},
|
|
1390
1087
|
fromJSON(object) {
|
|
1391
1088
|
return {
|
|
1392
|
-
unit: isSet
|
|
1393
|
-
rule: isSet
|
|
1394
|
-
readMaterialization: isSet
|
|
1089
|
+
unit: isSet(object.unit) ? globalThis.String(object.unit) : "",
|
|
1090
|
+
rule: isSet(object.rule) ? globalThis.String(object.rule) : "",
|
|
1091
|
+
readMaterialization: isSet(object.readMaterialization) ? globalThis.String(object.readMaterialization) : ""
|
|
1395
1092
|
};
|
|
1396
1093
|
},
|
|
1397
1094
|
toJSON(message) {
|
|
@@ -1459,10 +1156,10 @@ const ResolveWithStickyResponse_MaterializationUpdate = {
|
|
|
1459
1156
|
},
|
|
1460
1157
|
fromJSON(object) {
|
|
1461
1158
|
return {
|
|
1462
|
-
unit: isSet
|
|
1463
|
-
writeMaterialization: isSet
|
|
1464
|
-
rule: isSet
|
|
1465
|
-
variant: isSet
|
|
1159
|
+
unit: isSet(object.unit) ? globalThis.String(object.unit) : "",
|
|
1160
|
+
writeMaterialization: isSet(object.writeMaterialization) ? globalThis.String(object.writeMaterialization) : "",
|
|
1161
|
+
rule: isSet(object.rule) ? globalThis.String(object.rule) : "",
|
|
1162
|
+
variant: isSet(object.variant) ? globalThis.String(object.variant) : ""
|
|
1466
1163
|
};
|
|
1467
1164
|
},
|
|
1468
1165
|
toJSON(message) {
|
|
@@ -1485,7 +1182,7 @@ const ResolveWithStickyResponse_MaterializationUpdate = {
|
|
|
1485
1182
|
return message;
|
|
1486
1183
|
}
|
|
1487
1184
|
};
|
|
1488
|
-
function bytesFromBase64
|
|
1185
|
+
function bytesFromBase64(b64) {
|
|
1489
1186
|
if (globalThis.Buffer) return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
|
|
1490
1187
|
else {
|
|
1491
1188
|
const bin = globalThis.atob(b64);
|
|
@@ -1494,7 +1191,7 @@ function bytesFromBase64$1(b64) {
|
|
|
1494
1191
|
return arr;
|
|
1495
1192
|
}
|
|
1496
1193
|
}
|
|
1497
|
-
function base64FromBytes
|
|
1194
|
+
function base64FromBytes(arr) {
|
|
1498
1195
|
if (globalThis.Buffer) return globalThis.Buffer.from(arr).toString("base64");
|
|
1499
1196
|
else {
|
|
1500
1197
|
const bin = [];
|
|
@@ -1507,13 +1204,13 @@ function base64FromBytes$1(arr) {
|
|
|
1507
1204
|
function isObject(value) {
|
|
1508
1205
|
return typeof value === "object" && value !== null;
|
|
1509
1206
|
}
|
|
1510
|
-
function isSet
|
|
1207
|
+
function isSet(value) {
|
|
1511
1208
|
return value !== null && value !== void 0;
|
|
1512
1209
|
}
|
|
1513
|
-
const VERSION = "0.
|
|
1514
|
-
const NOOP_LOG_FN = () => {};
|
|
1210
|
+
const VERSION = "0.4.0";
|
|
1211
|
+
const NOOP_LOG_FN = Object.assign(() => {}, { enabled: false });
|
|
1515
1212
|
const debugBackend = loadDebug();
|
|
1516
|
-
const logger$
|
|
1213
|
+
const logger$2 = new class LoggerImpl {
|
|
1517
1214
|
childLoggers = /* @__PURE__ */ new Map();
|
|
1518
1215
|
debug = NOOP_LOG_FN;
|
|
1519
1216
|
info = NOOP_LOG_FN;
|
|
@@ -1523,8 +1220,8 @@ const logger$1 = new class LoggerImpl {
|
|
|
1523
1220
|
this.name = name;
|
|
1524
1221
|
this.configure();
|
|
1525
1222
|
}
|
|
1526
|
-
async configure() {
|
|
1527
|
-
const debug = await
|
|
1223
|
+
async configure(backend = debugBackend) {
|
|
1224
|
+
const debug = await backend;
|
|
1528
1225
|
if (!debug) return;
|
|
1529
1226
|
const debugFn = this.debug = (debug(this.name + ":debug"));
|
|
1530
1227
|
const infoFn = this.info = (debug(this.name + ":info"));
|
|
@@ -1545,7 +1242,7 @@ const logger$1 = new class LoggerImpl {
|
|
|
1545
1242
|
return child;
|
|
1546
1243
|
}
|
|
1547
1244
|
}("cnfd");
|
|
1548
|
-
const getLogger = logger$
|
|
1245
|
+
const getLogger = logger$2.getLogger.bind(logger$2);
|
|
1549
1246
|
async function loadDebug() {
|
|
1550
1247
|
try {
|
|
1551
1248
|
const { default: debug } = await import("debug");
|
|
@@ -1575,7 +1272,7 @@ function scheduleWithFixedInterval(operation, intervalMs, opt = {}) {
|
|
|
1575
1272
|
try {
|
|
1576
1273
|
await operation(ac.signal);
|
|
1577
1274
|
} catch (e) {
|
|
1578
|
-
logger$
|
|
1275
|
+
logger$2.warn("scheduleWithFixedInterval failure:", e);
|
|
1579
1276
|
}
|
|
1580
1277
|
concurrent--;
|
|
1581
1278
|
if (Date.now() - lastRunTime > intervalMs && nextRunTimeoutId != 0) {
|
|
@@ -1634,10 +1331,7 @@ function promiseSignal(signal) {
|
|
|
1634
1331
|
}, { once: true });
|
|
1635
1332
|
});
|
|
1636
1333
|
}
|
|
1637
|
-
|
|
1638
|
-
return signal ? Promise.race([promise, promiseSignal(signal)]) : promise;
|
|
1639
|
-
}
|
|
1640
|
-
const logger$2 = logger$1.getLogger("fetch");
|
|
1334
|
+
const logger$3 = logger$2.getLogger("fetch");
|
|
1641
1335
|
let Fetch;
|
|
1642
1336
|
(function(_Fetch) {
|
|
1643
1337
|
function create(middleware, sink = fetch) {
|
|
@@ -1708,13 +1402,13 @@ function withRetry(opts) {
|
|
|
1708
1402
|
const onSuccess = async (resp) => {
|
|
1709
1403
|
const { status, statusText } = resp;
|
|
1710
1404
|
if (status !== 408 && status !== 429 && status < 500 || attempts >= maxAttempts) return resp;
|
|
1711
|
-
logger$
|
|
1405
|
+
logger$3.debug("withRetry %s failed attempt %d with %d %s", url, attempts - 1, status, statusText);
|
|
1712
1406
|
const serverDelay = parseRetryAfter(resp.headers.get("Retry-After"), baseInterval, maxInterval);
|
|
1713
1407
|
await abortableSleep(serverDelay ?? deadline - Date.now(), signal);
|
|
1714
1408
|
return doTry();
|
|
1715
1409
|
};
|
|
1716
1410
|
const onError = async (error) => {
|
|
1717
|
-
logger$
|
|
1411
|
+
logger$3.debug("withRetry %s failed attempt %d with %s", url, attempts - 1, error);
|
|
1718
1412
|
if (signal?.aborted || attempts >= maxAttempts) throw error;
|
|
1719
1413
|
await abortableSleep(deadline - Date.now(), signal);
|
|
1720
1414
|
return doTry();
|
|
@@ -1733,54 +1427,6 @@ function withRetry(opts) {
|
|
|
1733
1427
|
return doTry();
|
|
1734
1428
|
};
|
|
1735
1429
|
}
|
|
1736
|
-
function withAuth(tokenProvider, signal) {
|
|
1737
|
-
let renewTimeout = 0;
|
|
1738
|
-
let current = null;
|
|
1739
|
-
signal?.addEventListener("abort", () => {
|
|
1740
|
-
clearTimeout(renewTimeout);
|
|
1741
|
-
});
|
|
1742
|
-
const renewToken = () => {
|
|
1743
|
-
logger$2.debug("withAuth renewing token");
|
|
1744
|
-
clearTimeout(renewTimeout);
|
|
1745
|
-
current = tokenProvider().then(([token, expiry]) => {
|
|
1746
|
-
logger$2.debug("withAuth renew success %s", expiry && expiry.valueOf() - Date.now());
|
|
1747
|
-
if (expiry) {
|
|
1748
|
-
const ttl = expiry.valueOf() - Date.now();
|
|
1749
|
-
renewTimeout = portableSetTimeout(renewToken, .8 * ttl);
|
|
1750
|
-
}
|
|
1751
|
-
return token;
|
|
1752
|
-
}).catch((e) => {
|
|
1753
|
-
current = null;
|
|
1754
|
-
throw e;
|
|
1755
|
-
});
|
|
1756
|
-
};
|
|
1757
|
-
const fetchWithToken = async (fetch$1, url, init) => {
|
|
1758
|
-
const token = await abortablePromise(current, init.signal);
|
|
1759
|
-
const headers = new Headers(init.headers);
|
|
1760
|
-
headers.set("Authorization", `Bearer ${token}`);
|
|
1761
|
-
return fetch$1(url, {
|
|
1762
|
-
...init,
|
|
1763
|
-
headers
|
|
1764
|
-
});
|
|
1765
|
-
};
|
|
1766
|
-
return (next) => async (url, init = {}) => {
|
|
1767
|
-
const bodyClone = await bodyRepeater(init.body);
|
|
1768
|
-
if (!current) renewToken();
|
|
1769
|
-
const currentBeforeFetch = current;
|
|
1770
|
-
let resp = await fetchWithToken(next, url, {
|
|
1771
|
-
...init,
|
|
1772
|
-
body: bodyClone()
|
|
1773
|
-
});
|
|
1774
|
-
if (resp.status === 401) {
|
|
1775
|
-
if (current === currentBeforeFetch) renewToken();
|
|
1776
|
-
resp = await fetchWithToken(next, url, {
|
|
1777
|
-
...init,
|
|
1778
|
-
body: bodyClone()
|
|
1779
|
-
});
|
|
1780
|
-
}
|
|
1781
|
-
return resp;
|
|
1782
|
-
};
|
|
1783
|
-
}
|
|
1784
1430
|
function withRouter(routes) {
|
|
1785
1431
|
const hasOnlyOneStar = (s) => s.split("*").length - 1 === 1;
|
|
1786
1432
|
const compile = (pattern) => {
|
|
@@ -1815,7 +1461,7 @@ function withRouter(routes) {
|
|
|
1815
1461
|
return async (url, init = {}) => {
|
|
1816
1462
|
const match = table.find(([pred]) => pred(url));
|
|
1817
1463
|
if (!match) {
|
|
1818
|
-
logger$
|
|
1464
|
+
logger$3.info("withRouter no route matched %s, falling through", url);
|
|
1819
1465
|
return next(url, init);
|
|
1820
1466
|
}
|
|
1821
1467
|
return match[1](url, init);
|
|
@@ -1825,13 +1471,13 @@ function withRouter(routes) {
|
|
|
1825
1471
|
function withResponse(factory) {
|
|
1826
1472
|
return (_next) => factory;
|
|
1827
1473
|
}
|
|
1828
|
-
const fetchLogger = logger$
|
|
1829
|
-
function withLogging(logger$
|
|
1474
|
+
const fetchLogger = logger$3;
|
|
1475
|
+
function withLogging(logger$4 = fetchLogger) {
|
|
1830
1476
|
return (next) => async (url, init) => {
|
|
1831
1477
|
const start = Date.now();
|
|
1832
1478
|
const resp = await next(url, init);
|
|
1833
1479
|
const duration = Date.now() - start;
|
|
1834
|
-
logger$
|
|
1480
|
+
logger$4.info("%s %s (%i) %dms", (init?.method ?? "get").toUpperCase(), url.split("?", 1)[0], resp.status, duration);
|
|
1835
1481
|
return resp;
|
|
1836
1482
|
};
|
|
1837
1483
|
}
|
|
@@ -1854,6 +1500,12 @@ function timeoutSignal$1(delay, signal) {
|
|
|
1854
1500
|
portableSetTimeout(() => ac.abort(/* @__PURE__ */ new Error(`Operation timed out after ${delay}ms`)), delay);
|
|
1855
1501
|
return signal ? AbortSignal.any([signal, ac.signal]) : ac.signal;
|
|
1856
1502
|
}
|
|
1503
|
+
async function sha256Hex(input) {
|
|
1504
|
+
const data = new TextEncoder().encode(input);
|
|
1505
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", data);
|
|
1506
|
+
return Array.from(new Uint8Array(hashBuffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
1507
|
+
}
|
|
1508
|
+
const logger$1 = getLogger("provider");
|
|
1857
1509
|
const DEFAULT_STATE_INTERVAL = 3e4;
|
|
1858
1510
|
const DEFAULT_FLUSH_INTERVAL = 1e4;
|
|
1859
1511
|
var ConfidenceServerProviderLocal = class ConfidenceServerProviderLocal {
|
|
@@ -1867,29 +1519,18 @@ var ConfidenceServerProviderLocal = class ConfidenceServerProviderLocal {
|
|
|
1867
1519
|
this.resolver = resolver$1;
|
|
1868
1520
|
this.options = options;
|
|
1869
1521
|
this.flushInterval = options.flushInterval ?? DEFAULT_FLUSH_INTERVAL;
|
|
1870
|
-
const withConfidenceAuth = withAuth(async () => {
|
|
1871
|
-
const { accessToken, expiresIn } = await this.fetchToken();
|
|
1872
|
-
return [accessToken, new Date(Date.now() + 1e3 * expiresIn)];
|
|
1873
|
-
}, this.main.signal);
|
|
1874
|
-
const withFastRetry = FetchMiddleware.compose(withRetry({
|
|
1875
|
-
maxAttempts: Infinity,
|
|
1876
|
-
baseInterval: 300,
|
|
1877
|
-
maxInterval: 5 * TimeUnit.SECOND
|
|
1878
|
-
}), withTimeout(5 * TimeUnit.SECOND));
|
|
1879
1522
|
this.fetch = Fetch.create([withRouter({
|
|
1880
|
-
"https://
|
|
1881
|
-
"https://storage.googleapis.com/*": [withRetry({
|
|
1523
|
+
"https://confidence-resolver-state-cdn.spotifycdn.com/*": [withRetry({
|
|
1882
1524
|
maxAttempts: Infinity,
|
|
1883
1525
|
baseInterval: 500,
|
|
1884
1526
|
maxInterval: DEFAULT_STATE_INTERVAL
|
|
1885
1527
|
}), withStallTimeout(500)],
|
|
1886
|
-
"https://resolver.confidence.dev/*": [
|
|
1887
|
-
"*/v1/resolverState:resolverStateUri": [withFastRetry],
|
|
1528
|
+
"https://resolver.confidence.dev/*": [withRouter({
|
|
1888
1529
|
"*/v1/flags:resolve": [withRetry({
|
|
1889
1530
|
maxAttempts: 3,
|
|
1890
1531
|
baseInterval: 100
|
|
1891
1532
|
}), withTimeout(3 * TimeUnit.SECOND)],
|
|
1892
|
-
"*/v1/
|
|
1533
|
+
"*/v1/clientFlagLogs:write": [withRetry({
|
|
1893
1534
|
maxAttempts: 3,
|
|
1894
1535
|
baseInterval: 500
|
|
1895
1536
|
}), withTimeout(5 * TimeUnit.SECOND)]
|
|
@@ -1936,11 +1577,14 @@ var ConfidenceServerProviderLocal = class ConfidenceServerProviderLocal {
|
|
|
1936
1577
|
failFastOnSticky: true
|
|
1937
1578
|
};
|
|
1938
1579
|
const response = await this.resolveWithStickyInternal(stickyRequest);
|
|
1939
|
-
|
|
1580
|
+
const result = this.extractValue(response.resolvedFlags[0], flagName, path, defaultValue);
|
|
1581
|
+
if (result.errorCode) logger$1.warn(`Flag evaluation for '${flagKey}' returned error code: ${result.errorCode}`);
|
|
1582
|
+
return result;
|
|
1940
1583
|
}
|
|
1941
1584
|
async resolveWithStickyInternal(request) {
|
|
1942
1585
|
const response = this.resolver.resolveWithSticky(request);
|
|
1943
1586
|
if (response.success && response.success.response) {
|
|
1587
|
+
this.flushAssigned();
|
|
1944
1588
|
const { response: flagsResponse } = response.success;
|
|
1945
1589
|
return flagsResponse;
|
|
1946
1590
|
}
|
|
@@ -1988,49 +1632,44 @@ var ConfidenceServerProviderLocal = class ConfidenceServerProviderLocal {
|
|
|
1988
1632
|
};
|
|
1989
1633
|
}
|
|
1990
1634
|
async updateState(signal) {
|
|
1991
|
-
const
|
|
1635
|
+
const cdnUrl = `https://confidence-resolver-state-cdn.spotifycdn.com/${await sha256Hex(this.options.flagClientSecret)}`;
|
|
1992
1636
|
const headers = new Headers();
|
|
1993
1637
|
if (this.stateEtag) headers.set("If-None-Match", this.stateEtag);
|
|
1994
|
-
const resp = await this.fetch(
|
|
1638
|
+
const resp = await this.fetch(cdnUrl, {
|
|
1995
1639
|
headers,
|
|
1996
1640
|
signal
|
|
1997
1641
|
});
|
|
1998
1642
|
if (resp.status === 304) return;
|
|
1999
1643
|
if (!resp.ok) throw new Error(`Failed to fetch state: ${resp.status} ${resp.statusText}`);
|
|
2000
1644
|
this.stateEtag = resp.headers.get("etag");
|
|
2001
|
-
const
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
state
|
|
2005
|
-
});
|
|
1645
|
+
const bytes = new Uint8Array(await resp.arrayBuffer());
|
|
1646
|
+
const { SetResolverStateRequest: SetResolverStateRequest$1 } = await import("./messages-CvypvyG4.js");
|
|
1647
|
+
this.resolver.setResolverState(SetResolverStateRequest$1.decode(bytes));
|
|
2006
1648
|
}
|
|
2007
1649
|
async flush(signal) {
|
|
2008
1650
|
const writeFlagLogRequest = this.resolver.flushLogs();
|
|
2009
|
-
if (writeFlagLogRequest.length
|
|
2010
|
-
await this.fetch("https://resolver.confidence.dev/v1/flagLogs:write", {
|
|
2011
|
-
method: "post",
|
|
2012
|
-
signal,
|
|
2013
|
-
headers: { "Content-Type": "application/x-protobuf" },
|
|
2014
|
-
body: writeFlagLogRequest
|
|
2015
|
-
});
|
|
1651
|
+
if (writeFlagLogRequest.length > 0) await this.sendFlagLogs(writeFlagLogRequest, signal);
|
|
2016
1652
|
}
|
|
2017
|
-
async
|
|
2018
|
-
const
|
|
2019
|
-
if (
|
|
2020
|
-
return resp.json();
|
|
1653
|
+
async flushAssigned() {
|
|
1654
|
+
const writeFlagLogRequest = this.resolver.flushAssigned();
|
|
1655
|
+
if (writeFlagLogRequest.length > 0) await this.sendFlagLogs(writeFlagLogRequest);
|
|
2021
1656
|
}
|
|
2022
|
-
async
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
1657
|
+
async sendFlagLogs(encodedWriteFlagLogRequest, signal = this.main.signal) {
|
|
1658
|
+
try {
|
|
1659
|
+
const response = await this.fetch("https://resolver.confidence.dev/v1/clientFlagLogs:write", {
|
|
1660
|
+
method: "post",
|
|
1661
|
+
signal,
|
|
1662
|
+
headers: {
|
|
1663
|
+
"Content-Type": "application/x-protobuf",
|
|
1664
|
+
Authorization: `ClientSecret ${this.options.flagClientSecret}`
|
|
1665
|
+
},
|
|
1666
|
+
body: encodedWriteFlagLogRequest
|
|
1667
|
+
});
|
|
1668
|
+
if (!response.ok) logger$1.error(`Failed to write flag logs: ${response.status} ${response.statusText} - ${await response.text()}`);
|
|
1669
|
+
} catch (err) {
|
|
1670
|
+
logger$1.warn("Failed to send flag logs", err);
|
|
1671
|
+
throw err;
|
|
1672
|
+
}
|
|
2034
1673
|
}
|
|
2035
1674
|
static convertReason(reason) {
|
|
2036
1675
|
switch (reason) {
|
|
@@ -2081,228 +1720,14 @@ function isAssignableTo(value, schema) {
|
|
|
2081
1720
|
}
|
|
2082
1721
|
return true;
|
|
2083
1722
|
}
|
|
2084
|
-
function createBaseVoid() {
|
|
2085
|
-
return {};
|
|
2086
|
-
}
|
|
2087
|
-
const Void = {
|
|
2088
|
-
encode(_, writer = new BinaryWriter()) {
|
|
2089
|
-
return writer;
|
|
2090
|
-
},
|
|
2091
|
-
decode(input, length) {
|
|
2092
|
-
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
2093
|
-
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
2094
|
-
const message = createBaseVoid();
|
|
2095
|
-
while (reader.pos < end) {
|
|
2096
|
-
const tag = reader.uint32();
|
|
2097
|
-
switch (tag >>> 3) {}
|
|
2098
|
-
if ((tag & 7) === 4 || tag === 0) break;
|
|
2099
|
-
reader.skip(tag & 7);
|
|
2100
|
-
}
|
|
2101
|
-
return message;
|
|
2102
|
-
},
|
|
2103
|
-
fromJSON(_) {
|
|
2104
|
-
return {};
|
|
2105
|
-
},
|
|
2106
|
-
toJSON(_) {
|
|
2107
|
-
return {};
|
|
2108
|
-
},
|
|
2109
|
-
create(base) {
|
|
2110
|
-
return Void.fromPartial(base ?? {});
|
|
2111
|
-
},
|
|
2112
|
-
fromPartial(_) {
|
|
2113
|
-
return createBaseVoid();
|
|
2114
|
-
}
|
|
2115
|
-
};
|
|
2116
|
-
function createBaseRequest() {
|
|
2117
|
-
return { data: new Uint8Array(0) };
|
|
2118
|
-
}
|
|
2119
|
-
const Request = {
|
|
2120
|
-
encode(message, writer = new BinaryWriter()) {
|
|
2121
|
-
if (message.data.length !== 0) writer.uint32(10).bytes(message.data);
|
|
2122
|
-
return writer;
|
|
2123
|
-
},
|
|
2124
|
-
decode(input, length) {
|
|
2125
|
-
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
2126
|
-
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
2127
|
-
const message = createBaseRequest();
|
|
2128
|
-
while (reader.pos < end) {
|
|
2129
|
-
const tag = reader.uint32();
|
|
2130
|
-
switch (tag >>> 3) {
|
|
2131
|
-
case 1:
|
|
2132
|
-
if (tag !== 10) break;
|
|
2133
|
-
message.data = reader.bytes();
|
|
2134
|
-
continue;
|
|
2135
|
-
}
|
|
2136
|
-
if ((tag & 7) === 4 || tag === 0) break;
|
|
2137
|
-
reader.skip(tag & 7);
|
|
2138
|
-
}
|
|
2139
|
-
return message;
|
|
2140
|
-
},
|
|
2141
|
-
fromJSON(object) {
|
|
2142
|
-
return { data: isSet$1(object.data) ? bytesFromBase64(object.data) : new Uint8Array(0) };
|
|
2143
|
-
},
|
|
2144
|
-
toJSON(message) {
|
|
2145
|
-
const obj = {};
|
|
2146
|
-
if (message.data.length !== 0) obj.data = base64FromBytes(message.data);
|
|
2147
|
-
return obj;
|
|
2148
|
-
},
|
|
2149
|
-
create(base) {
|
|
2150
|
-
return Request.fromPartial(base ?? {});
|
|
2151
|
-
},
|
|
2152
|
-
fromPartial(object) {
|
|
2153
|
-
const message = createBaseRequest();
|
|
2154
|
-
message.data = object.data ?? new Uint8Array(0);
|
|
2155
|
-
return message;
|
|
2156
|
-
}
|
|
2157
|
-
};
|
|
2158
|
-
function createBaseResponse() {
|
|
2159
|
-
return {
|
|
2160
|
-
data: void 0,
|
|
2161
|
-
error: void 0
|
|
2162
|
-
};
|
|
2163
|
-
}
|
|
2164
|
-
const Response$1 = {
|
|
2165
|
-
encode(message, writer = new BinaryWriter()) {
|
|
2166
|
-
if (message.data !== void 0) writer.uint32(10).bytes(message.data);
|
|
2167
|
-
if (message.error !== void 0) writer.uint32(18).string(message.error);
|
|
2168
|
-
return writer;
|
|
2169
|
-
},
|
|
2170
|
-
decode(input, length) {
|
|
2171
|
-
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
2172
|
-
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
2173
|
-
const message = createBaseResponse();
|
|
2174
|
-
while (reader.pos < end) {
|
|
2175
|
-
const tag = reader.uint32();
|
|
2176
|
-
switch (tag >>> 3) {
|
|
2177
|
-
case 1:
|
|
2178
|
-
if (tag !== 10) break;
|
|
2179
|
-
message.data = reader.bytes();
|
|
2180
|
-
continue;
|
|
2181
|
-
case 2:
|
|
2182
|
-
if (tag !== 18) break;
|
|
2183
|
-
message.error = reader.string();
|
|
2184
|
-
continue;
|
|
2185
|
-
}
|
|
2186
|
-
if ((tag & 7) === 4 || tag === 0) break;
|
|
2187
|
-
reader.skip(tag & 7);
|
|
2188
|
-
}
|
|
2189
|
-
return message;
|
|
2190
|
-
},
|
|
2191
|
-
fromJSON(object) {
|
|
2192
|
-
return {
|
|
2193
|
-
data: isSet$1(object.data) ? bytesFromBase64(object.data) : void 0,
|
|
2194
|
-
error: isSet$1(object.error) ? globalThis.String(object.error) : void 0
|
|
2195
|
-
};
|
|
2196
|
-
},
|
|
2197
|
-
toJSON(message) {
|
|
2198
|
-
const obj = {};
|
|
2199
|
-
if (message.data !== void 0) obj.data = base64FromBytes(message.data);
|
|
2200
|
-
if (message.error !== void 0) obj.error = message.error;
|
|
2201
|
-
return obj;
|
|
2202
|
-
},
|
|
2203
|
-
create(base) {
|
|
2204
|
-
return Response$1.fromPartial(base ?? {});
|
|
2205
|
-
},
|
|
2206
|
-
fromPartial(object) {
|
|
2207
|
-
const message = createBaseResponse();
|
|
2208
|
-
message.data = object.data ?? void 0;
|
|
2209
|
-
message.error = object.error ?? void 0;
|
|
2210
|
-
return message;
|
|
2211
|
-
}
|
|
2212
|
-
};
|
|
2213
|
-
function bytesFromBase64(b64) {
|
|
2214
|
-
if (globalThis.Buffer) return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
|
|
2215
|
-
else {
|
|
2216
|
-
const bin = globalThis.atob(b64);
|
|
2217
|
-
const arr = new Uint8Array(bin.length);
|
|
2218
|
-
for (let i = 0; i < bin.length; ++i) arr[i] = bin.charCodeAt(i);
|
|
2219
|
-
return arr;
|
|
2220
|
-
}
|
|
2221
|
-
}
|
|
2222
|
-
function base64FromBytes(arr) {
|
|
2223
|
-
if (globalThis.Buffer) return globalThis.Buffer.from(arr).toString("base64");
|
|
2224
|
-
else {
|
|
2225
|
-
const bin = [];
|
|
2226
|
-
arr.forEach((byte) => {
|
|
2227
|
-
bin.push(globalThis.String.fromCharCode(byte));
|
|
2228
|
-
});
|
|
2229
|
-
return globalThis.btoa(bin.join(""));
|
|
2230
|
-
}
|
|
2231
|
-
}
|
|
2232
|
-
function isSet$1(value) {
|
|
2233
|
-
return value !== null && value !== void 0;
|
|
2234
|
-
}
|
|
2235
|
-
function createBaseTimestamp() {
|
|
2236
|
-
return {
|
|
2237
|
-
seconds: 0,
|
|
2238
|
-
nanos: 0
|
|
2239
|
-
};
|
|
2240
|
-
}
|
|
2241
|
-
const Timestamp = {
|
|
2242
|
-
encode(message, writer = new BinaryWriter()) {
|
|
2243
|
-
if (message.seconds !== 0) writer.uint32(8).int64(message.seconds);
|
|
2244
|
-
if (message.nanos !== 0) writer.uint32(16).int32(message.nanos);
|
|
2245
|
-
return writer;
|
|
2246
|
-
},
|
|
2247
|
-
decode(input, length) {
|
|
2248
|
-
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
2249
|
-
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
2250
|
-
const message = createBaseTimestamp();
|
|
2251
|
-
while (reader.pos < end) {
|
|
2252
|
-
const tag = reader.uint32();
|
|
2253
|
-
switch (tag >>> 3) {
|
|
2254
|
-
case 1:
|
|
2255
|
-
if (tag !== 8) break;
|
|
2256
|
-
message.seconds = longToNumber(reader.int64());
|
|
2257
|
-
continue;
|
|
2258
|
-
case 2:
|
|
2259
|
-
if (tag !== 16) break;
|
|
2260
|
-
message.nanos = reader.int32();
|
|
2261
|
-
continue;
|
|
2262
|
-
}
|
|
2263
|
-
if ((tag & 7) === 4 || tag === 0) break;
|
|
2264
|
-
reader.skip(tag & 7);
|
|
2265
|
-
}
|
|
2266
|
-
return message;
|
|
2267
|
-
},
|
|
2268
|
-
fromJSON(object) {
|
|
2269
|
-
return {
|
|
2270
|
-
seconds: isSet(object.seconds) ? globalThis.Number(object.seconds) : 0,
|
|
2271
|
-
nanos: isSet(object.nanos) ? globalThis.Number(object.nanos) : 0
|
|
2272
|
-
};
|
|
2273
|
-
},
|
|
2274
|
-
toJSON(message) {
|
|
2275
|
-
const obj = {};
|
|
2276
|
-
if (message.seconds !== 0) obj.seconds = Math.round(message.seconds);
|
|
2277
|
-
if (message.nanos !== 0) obj.nanos = Math.round(message.nanos);
|
|
2278
|
-
return obj;
|
|
2279
|
-
},
|
|
2280
|
-
create(base) {
|
|
2281
|
-
return Timestamp.fromPartial(base ?? {});
|
|
2282
|
-
},
|
|
2283
|
-
fromPartial(object) {
|
|
2284
|
-
const message = createBaseTimestamp();
|
|
2285
|
-
message.seconds = object.seconds ?? 0;
|
|
2286
|
-
message.nanos = object.nanos ?? 0;
|
|
2287
|
-
return message;
|
|
2288
|
-
}
|
|
2289
|
-
};
|
|
2290
|
-
function longToNumber(int64) {
|
|
2291
|
-
const num = globalThis.Number(int64.toString());
|
|
2292
|
-
if (num > globalThis.Number.MAX_SAFE_INTEGER) throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
|
|
2293
|
-
if (num < globalThis.Number.MIN_SAFE_INTEGER) throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");
|
|
2294
|
-
return num;
|
|
2295
|
-
}
|
|
2296
|
-
function isSet(value) {
|
|
2297
|
-
return value !== null && value !== void 0;
|
|
2298
|
-
}
|
|
2299
1723
|
const logger = getLogger("wasm-resolver");
|
|
2300
1724
|
const EXPORT_FN_NAMES = [
|
|
2301
1725
|
"wasm_msg_alloc",
|
|
2302
1726
|
"wasm_msg_free",
|
|
2303
1727
|
"wasm_msg_guest_resolve_with_sticky",
|
|
2304
1728
|
"wasm_msg_guest_set_resolver_state",
|
|
2305
|
-
"
|
|
1729
|
+
"wasm_msg_guest_bounded_flush_logs",
|
|
1730
|
+
"wasm_msg_guest_bounded_flush_assign"
|
|
2306
1731
|
];
|
|
2307
1732
|
function verifyExports(exports) {
|
|
2308
1733
|
for (const fnName of EXPORT_FN_NAMES) if (typeof exports[fnName] !== "function") throw new Error(`Expected Function export "${fnName}" found ${exports[fnName]}`);
|
|
@@ -2310,6 +1735,7 @@ function verifyExports(exports) {
|
|
|
2310
1735
|
}
|
|
2311
1736
|
var UnsafeWasmResolver = class {
|
|
2312
1737
|
exports;
|
|
1738
|
+
flushCount = 0;
|
|
2313
1739
|
constructor(module$1) {
|
|
2314
1740
|
const { exports } = new WebAssembly.Instance(module$1, { wasm_msg: { wasm_msg_host_current_time: () => {
|
|
2315
1741
|
const epochMillisecond = Date.now();
|
|
@@ -2334,7 +1760,13 @@ var UnsafeWasmResolver = class {
|
|
|
2334
1760
|
this.consumeResponse(resPtr, Void);
|
|
2335
1761
|
}
|
|
2336
1762
|
flushLogs() {
|
|
2337
|
-
const resPtr = this.exports.
|
|
1763
|
+
const resPtr = this.exports.wasm_msg_guest_bounded_flush_logs(0);
|
|
1764
|
+
const { data, error } = this.consume(resPtr, Response$1);
|
|
1765
|
+
if (error) throw new Error(error);
|
|
1766
|
+
return data;
|
|
1767
|
+
}
|
|
1768
|
+
flushAssigned() {
|
|
1769
|
+
const resPtr = this.exports.wasm_msg_guest_bounded_flush_assign(0);
|
|
2338
1770
|
const { data, error } = this.consume(resPtr, Response$1);
|
|
2339
1771
|
if (error) throw new Error(error);
|
|
2340
1772
|
return data;
|
|
@@ -2422,6 +1854,9 @@ var WasmResolver = class {
|
|
|
2422
1854
|
throw error;
|
|
2423
1855
|
}
|
|
2424
1856
|
}
|
|
1857
|
+
flushAssigned() {
|
|
1858
|
+
return this.delegate.flushAssigned();
|
|
1859
|
+
}
|
|
2425
1860
|
};
|
|
2426
1861
|
const wasmUrl = new URL("confidence_resolver.wasm", import.meta.url);
|
|
2427
1862
|
const module = await WebAssembly.compileStreaming(fetch(wasmUrl));
|