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