@flipfeatureflag/core 0.1.11 → 0.1.12
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/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +19 -2
- package/dist/index.mjs +19 -2
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -98,6 +98,7 @@ declare class FlipFlagClient {
|
|
|
98
98
|
private emitter;
|
|
99
99
|
private status;
|
|
100
100
|
private evaluations;
|
|
101
|
+
private knownFlagKeys;
|
|
101
102
|
private refreshTimer?;
|
|
102
103
|
private metricsTimer?;
|
|
103
104
|
private metricsBuffer;
|
|
@@ -115,6 +116,7 @@ declare class FlipFlagClient {
|
|
|
115
116
|
getContext(): SdkContext;
|
|
116
117
|
updateContext(partial: SdkContext): void;
|
|
117
118
|
getAllFlags(): Record<string, SdkFlagEvaluation>;
|
|
119
|
+
hasFlag(flagKey: string): boolean;
|
|
118
120
|
isEnabled(flagKey: string, defaultValue?: boolean): boolean;
|
|
119
121
|
getVariant(flagKey: string, defaultValue?: FlagValue): SdkFlagEvaluation;
|
|
120
122
|
private evaluate;
|
package/dist/index.d.ts
CHANGED
|
@@ -98,6 +98,7 @@ declare class FlipFlagClient {
|
|
|
98
98
|
private emitter;
|
|
99
99
|
private status;
|
|
100
100
|
private evaluations;
|
|
101
|
+
private knownFlagKeys;
|
|
101
102
|
private refreshTimer?;
|
|
102
103
|
private metricsTimer?;
|
|
103
104
|
private metricsBuffer;
|
|
@@ -115,6 +116,7 @@ declare class FlipFlagClient {
|
|
|
115
116
|
getContext(): SdkContext;
|
|
116
117
|
updateContext(partial: SdkContext): void;
|
|
117
118
|
getAllFlags(): Record<string, SdkFlagEvaluation>;
|
|
119
|
+
hasFlag(flagKey: string): boolean;
|
|
118
120
|
isEnabled(flagKey: string, defaultValue?: boolean): boolean;
|
|
119
121
|
getVariant(flagKey: string, defaultValue?: FlagValue): SdkFlagEvaluation;
|
|
120
122
|
private evaluate;
|
package/dist/index.js
CHANGED
|
@@ -138,6 +138,7 @@ var FlipFlagClient = class {
|
|
|
138
138
|
this.emitter = new Emitter();
|
|
139
139
|
this.status = { ready: false };
|
|
140
140
|
this.evaluations = /* @__PURE__ */ new Map();
|
|
141
|
+
this.knownFlagKeys = /* @__PURE__ */ new Set();
|
|
141
142
|
this.metricsBuffer = new MetricsBuffer();
|
|
142
143
|
this.started = false;
|
|
143
144
|
this.pendingFlagKeys = /* @__PURE__ */ new Set();
|
|
@@ -219,6 +220,9 @@ var FlipFlagClient = class {
|
|
|
219
220
|
}
|
|
220
221
|
return result;
|
|
221
222
|
}
|
|
223
|
+
hasFlag(flagKey) {
|
|
224
|
+
return this.knownFlagKeys.has(flagKey);
|
|
225
|
+
}
|
|
222
226
|
isEnabled(flagKey, defaultValue = false) {
|
|
223
227
|
const evaluation = this.evaluate(flagKey, defaultValue);
|
|
224
228
|
return Boolean(evaluation.value);
|
|
@@ -269,7 +273,7 @@ var FlipFlagClient = class {
|
|
|
269
273
|
context: this.context,
|
|
270
274
|
flagKeys: keys
|
|
271
275
|
});
|
|
272
|
-
this.applyEvaluate(response);
|
|
276
|
+
this.applyEvaluate(response, keys);
|
|
273
277
|
if (!this.status.ready) {
|
|
274
278
|
this.status.ready = true;
|
|
275
279
|
this.emitter.emit("ready");
|
|
@@ -287,9 +291,22 @@ var FlipFlagClient = class {
|
|
|
287
291
|
})();
|
|
288
292
|
return this.refreshInFlight;
|
|
289
293
|
}
|
|
290
|
-
applyEvaluate(response) {
|
|
294
|
+
applyEvaluate(response, requestedKeys) {
|
|
295
|
+
if (!requestedKeys) {
|
|
296
|
+
this.knownFlagKeys.clear();
|
|
297
|
+
}
|
|
298
|
+
const returnedKeys = /* @__PURE__ */ new Set();
|
|
291
299
|
for (const [key, evaluation] of Object.entries(response.flags)) {
|
|
292
300
|
this.evaluations.set(key, evaluation);
|
|
301
|
+
this.knownFlagKeys.add(key);
|
|
302
|
+
returnedKeys.add(key);
|
|
303
|
+
}
|
|
304
|
+
if (requestedKeys) {
|
|
305
|
+
for (const key of requestedKeys) {
|
|
306
|
+
if (!returnedKeys.has(key)) {
|
|
307
|
+
this.knownFlagKeys.delete(key);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
293
310
|
}
|
|
294
311
|
this.status.updatedAt = response.updatedAt;
|
|
295
312
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -112,6 +112,7 @@ var FlipFlagClient = class {
|
|
|
112
112
|
this.emitter = new Emitter();
|
|
113
113
|
this.status = { ready: false };
|
|
114
114
|
this.evaluations = /* @__PURE__ */ new Map();
|
|
115
|
+
this.knownFlagKeys = /* @__PURE__ */ new Set();
|
|
115
116
|
this.metricsBuffer = new MetricsBuffer();
|
|
116
117
|
this.started = false;
|
|
117
118
|
this.pendingFlagKeys = /* @__PURE__ */ new Set();
|
|
@@ -193,6 +194,9 @@ var FlipFlagClient = class {
|
|
|
193
194
|
}
|
|
194
195
|
return result;
|
|
195
196
|
}
|
|
197
|
+
hasFlag(flagKey) {
|
|
198
|
+
return this.knownFlagKeys.has(flagKey);
|
|
199
|
+
}
|
|
196
200
|
isEnabled(flagKey, defaultValue = false) {
|
|
197
201
|
const evaluation = this.evaluate(flagKey, defaultValue);
|
|
198
202
|
return Boolean(evaluation.value);
|
|
@@ -243,7 +247,7 @@ var FlipFlagClient = class {
|
|
|
243
247
|
context: this.context,
|
|
244
248
|
flagKeys: keys
|
|
245
249
|
});
|
|
246
|
-
this.applyEvaluate(response);
|
|
250
|
+
this.applyEvaluate(response, keys);
|
|
247
251
|
if (!this.status.ready) {
|
|
248
252
|
this.status.ready = true;
|
|
249
253
|
this.emitter.emit("ready");
|
|
@@ -261,9 +265,22 @@ var FlipFlagClient = class {
|
|
|
261
265
|
})();
|
|
262
266
|
return this.refreshInFlight;
|
|
263
267
|
}
|
|
264
|
-
applyEvaluate(response) {
|
|
268
|
+
applyEvaluate(response, requestedKeys) {
|
|
269
|
+
if (!requestedKeys) {
|
|
270
|
+
this.knownFlagKeys.clear();
|
|
271
|
+
}
|
|
272
|
+
const returnedKeys = /* @__PURE__ */ new Set();
|
|
265
273
|
for (const [key, evaluation] of Object.entries(response.flags)) {
|
|
266
274
|
this.evaluations.set(key, evaluation);
|
|
275
|
+
this.knownFlagKeys.add(key);
|
|
276
|
+
returnedKeys.add(key);
|
|
277
|
+
}
|
|
278
|
+
if (requestedKeys) {
|
|
279
|
+
for (const key of requestedKeys) {
|
|
280
|
+
if (!returnedKeys.has(key)) {
|
|
281
|
+
this.knownFlagKeys.delete(key);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
267
284
|
}
|
|
268
285
|
this.status.updatedAt = response.updatedAt;
|
|
269
286
|
}
|