File tree Expand file tree Collapse file tree 2 files changed +72
-0
lines changed
Expand file tree Collapse file tree 2 files changed +72
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import { newRateLimiter } from "./rate-limiter";
1919import type {
2020 EvaluatedFeaturesAPIResponse ,
2121 FeatureAPIResponse ,
22+ FeatureDefinition ,
2223 FeatureOverridesFn ,
2324 IdType ,
2425 RawFeature ,
@@ -482,6 +483,22 @@ export class BucketClient {
482483 await this . _config . batchBuffer . flush ( ) ;
483484 }
484485
486+ /**
487+ * Gets the feature definitions, including all config values.
488+ * To evaluate which features are enabled for a given user/company, use `getFeatures`.
489+ *
490+ * @returns The features definitions.
491+ */
492+ public async getFeatureDefinitions ( ) : Promise < FeatureDefinition [ ] > {
493+ const features = this . getFeaturesCache ( ) . get ( ) ?. features || [ ] ;
494+ return features . map ( ( f ) => ( {
495+ key : f . key ,
496+ description : f . description ,
497+ isEnabled : f . targeting ,
498+ config : f . config ,
499+ } ) ) ;
500+ }
501+
485502 /**
486503 * Gets the evaluated features for the current context which includes the user, company, and custom context.
487504 *
Original file line number Diff line number Diff line change @@ -190,6 +190,56 @@ export type FeatureOverride =
190190 } )
191191 | boolean ;
192192
193+ /**
194+ * Describes a feature definition.
195+ */
196+ export type FeatureDefinition = {
197+ /**
198+ * The key of the feature.
199+ */
200+ key : string ;
201+
202+ /**
203+ * Description of the feature.
204+ */
205+ description : string | null ;
206+
207+ /**
208+ * The targeting rules for the feature.
209+ */
210+ isEnabled : {
211+ /**
212+ * The version of the targeting rules.
213+ */
214+ version : number ;
215+
216+ /**
217+ * The targeting rules.
218+ */
219+ rules : {
220+ /**
221+ * The filter for the rule.
222+ */
223+ filter : RuleFilter ;
224+ } [ ] ;
225+ } ;
226+
227+ /**
228+ * The remote configuration for the feature.
229+ */
230+ config ?: {
231+ /**
232+ * The version of the remote configuration.
233+ */
234+ version : number ;
235+
236+ /**
237+ * The variants of the remote configuration.
238+ */
239+ variants : FeatureConfigVariant [ ] ;
240+ } ;
241+ } ;
242+
193243/**
194244 * Describes a collection of evaluated features.
195245 *
@@ -264,6 +314,11 @@ export type FeatureAPIResponse = {
264314 */
265315 key : string ;
266316
317+ /**
318+ * Description of the feature.
319+ */
320+ description : string | null ;
321+
267322 /**
268323 * The targeting rules for the feature.
269324 */
You can’t perform that action at this time.
0 commit comments