@scalemule/sdk 0.0.14 → 0.0.15
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/dist/flags/server.js +10 -22
- package/dist/flags/server.mjs +10 -22
- package/package.json +1 -1
package/dist/flags/server.js
CHANGED
|
@@ -306,25 +306,16 @@ var FlagClient = class {
|
|
|
306
306
|
}
|
|
307
307
|
}
|
|
308
308
|
async doInit() {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
this.lastETag = resp.headers.get("etag") || "";
|
|
320
|
-
this.connectStream();
|
|
321
|
-
this.startTelemetryFlush();
|
|
322
|
-
return;
|
|
323
|
-
} catch (e) {
|
|
324
|
-
if (attempt < 2) await sleep(1e3 * 2 ** attempt);
|
|
325
|
-
else throw e;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
309
|
+
const resp = await fetch(`${this.gatewayUrl}/v1/flags/config?environment=${encodeURIComponent(this.environment)}`, {
|
|
310
|
+
headers: { "x-api-key": this.apiKey }
|
|
311
|
+
});
|
|
312
|
+
if (resp.status === 403) throw new Error("Secret API key required for /config");
|
|
313
|
+
if (!resp.ok) throw new Error(`Config fetch failed: ${resp.status}`);
|
|
314
|
+
const json = await resp.json();
|
|
315
|
+
this.config = json.data;
|
|
316
|
+
this.lastETag = resp.headers.get("etag") || "";
|
|
317
|
+
this.connectStream();
|
|
318
|
+
this.startTelemetryFlush();
|
|
328
319
|
}
|
|
329
320
|
evaluate(flagKey, context) {
|
|
330
321
|
if (!this.config) throw new Error("FlagClient not initialized \u2014 call init() first");
|
|
@@ -523,9 +514,6 @@ var FlagClient = class {
|
|
|
523
514
|
}
|
|
524
515
|
}
|
|
525
516
|
};
|
|
526
|
-
function sleep(ms) {
|
|
527
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
528
|
-
}
|
|
529
517
|
// Annotate the CommonJS export names for ESM import in node:
|
|
530
518
|
0 && (module.exports = {
|
|
531
519
|
FlagClient,
|
package/dist/flags/server.mjs
CHANGED
|
@@ -277,25 +277,16 @@ var FlagClient = class {
|
|
|
277
277
|
}
|
|
278
278
|
}
|
|
279
279
|
async doInit() {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
this.lastETag = resp.headers.get("etag") || "";
|
|
291
|
-
this.connectStream();
|
|
292
|
-
this.startTelemetryFlush();
|
|
293
|
-
return;
|
|
294
|
-
} catch (e) {
|
|
295
|
-
if (attempt < 2) await sleep(1e3 * 2 ** attempt);
|
|
296
|
-
else throw e;
|
|
297
|
-
}
|
|
298
|
-
}
|
|
280
|
+
const resp = await fetch(`${this.gatewayUrl}/v1/flags/config?environment=${encodeURIComponent(this.environment)}`, {
|
|
281
|
+
headers: { "x-api-key": this.apiKey }
|
|
282
|
+
});
|
|
283
|
+
if (resp.status === 403) throw new Error("Secret API key required for /config");
|
|
284
|
+
if (!resp.ok) throw new Error(`Config fetch failed: ${resp.status}`);
|
|
285
|
+
const json = await resp.json();
|
|
286
|
+
this.config = json.data;
|
|
287
|
+
this.lastETag = resp.headers.get("etag") || "";
|
|
288
|
+
this.connectStream();
|
|
289
|
+
this.startTelemetryFlush();
|
|
299
290
|
}
|
|
300
291
|
evaluate(flagKey, context) {
|
|
301
292
|
if (!this.config) throw new Error("FlagClient not initialized \u2014 call init() first");
|
|
@@ -494,9 +485,6 @@ var FlagClient = class {
|
|
|
494
485
|
}
|
|
495
486
|
}
|
|
496
487
|
};
|
|
497
|
-
function sleep(ms) {
|
|
498
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
499
|
-
}
|
|
500
488
|
export {
|
|
501
489
|
FlagClient,
|
|
502
490
|
allConditionsMatch,
|