@@ -26,7 +26,7 @@ import {
2626 isFeatureFlag ,
2727 parseFeatureFlag
2828} from "@azure/app-configuration" ;
29- import { inject , ref } from "vue" ;
29+ import { inject , reactive , ref } from "vue" ;
3030var FeatureFlagsManagerKey = Symbol (
3131 "FeatureFlagsManager"
3232) ;
@@ -45,14 +45,18 @@ var featureFlagsManager = (connectionString, cacheEnabled = true, flagsToPrefetc
4545 key : `${ featureFlagPrefix } ${ name } ` ,
4646 label
4747 } ) . then ( ( response ) => {
48+ var _a ;
4849 if ( isFeatureFlag ( response ) ) {
4950 const {
50- value : { enabled, description = "" }
51+ value : { enabled, description = "" , conditions }
5152 } = parseFeatureFlag ( response ) ;
5253 const cacheKey = `cache-${ name } -${ label != null ? label : "empty-label" } ` ;
5354 cache [ cacheKey ] = {
5455 isFeatureEnabled : ref ( enabled ) ,
55- featureDescription : ref ( description )
56+ featureDescription : ref ( description ) ,
57+ featureConditions : reactive ( {
58+ clientFilters : ( _a = conditions . clientFilters ) != null ? _a : [ ]
59+ } )
5660 } ;
5761 }
5862 } ) . catch ( ( error ) => {
@@ -73,24 +77,26 @@ var featureFlagsManager = (connectionString, cacheEnabled = true, flagsToPrefetc
7377 }
7478 const isFeatureEnabled = ref ( false ) ;
7579 const featureDescription = ref ( "" ) ;
80+ const featureConditions = reactive ( { } ) ;
7681 if ( ! appConfigurationClient ) {
7782 if ( cacheEnabled ) {
78- cache [ cacheKey ] = { isFeatureEnabled, featureDescription } ;
83+ cache [ cacheKey ] = { isFeatureEnabled, featureDescription, featureConditions } ;
7984 }
80- return { isFeatureEnabled, featureDescription } ;
85+ return { isFeatureEnabled, featureDescription, featureConditions } ;
8186 }
8287 appConfigurationClient . getConfigurationSetting ( {
8388 key : `${ featureFlagPrefix } ${ name } ` ,
8489 label
8590 } ) . then ( ( response ) => {
8691 if ( isFeatureFlag ( response ) ) {
8792 const {
88- value : { enabled, description = "" }
93+ value : { enabled, description = "" , conditions }
8994 } = parseFeatureFlag ( response ) ;
9095 isFeatureEnabled . value = enabled ;
9196 featureDescription . value = description ;
97+ Object . assign ( conditions , featureConditions ) ;
9298 if ( cacheEnabled ) {
93- cache [ cacheKey ] = { isFeatureEnabled, featureDescription } ;
99+ cache [ cacheKey ] = { isFeatureEnabled, featureDescription, featureConditions } ;
94100 }
95101 }
96102 } ) . catch ( ( error ) => {
@@ -99,7 +105,7 @@ var featureFlagsManager = (connectionString, cacheEnabled = true, flagsToPrefetc
99105 error
100106 ) ;
101107 } ) ;
102- return { isFeatureEnabled, featureDescription } ;
108+ return { isFeatureEnabled, featureDescription, featureConditions } ;
103109 } ;
104110 return { getFeatureFlag, appConfigurationClient } ;
105111} ;
@@ -116,19 +122,23 @@ var featureFlagsManagerAsync = (_0, ..._1) => __async(void 0, [_0, ..._1], funct
116122 }
117123 yield Promise . all (
118124 flags . map ( ( _02 ) => __async ( this , [ _02 ] , function * ( { name, label } ) {
125+ var _a ;
119126 try {
120127 const response = yield appConfigurationClient . getConfigurationSetting ( {
121128 key : `${ featureFlagPrefix } ${ name } ` ,
122129 label
123130 } ) ;
124131 if ( isFeatureFlag ( response ) ) {
125132 const {
126- value : { enabled, description = "" }
133+ value : { enabled, description = "" , conditions }
127134 } = parseFeatureFlag ( response ) ;
128135 const cacheKey = `cache-${ name } -${ label != null ? label : "empty-label" } ` ;
129136 cache [ cacheKey ] = {
130137 isFeatureEnabled : ref ( enabled ) ,
131- featureDescription : ref ( description )
138+ featureDescription : ref ( description ) ,
139+ featureConditions : reactive ( {
140+ clientFilters : ( _a = conditions . clientFilters ) != null ? _a : [ ]
141+ } )
132142 } ;
133143 }
134144 } catch ( error ) {
@@ -149,7 +159,10 @@ var featureFlagsManagerAsync = (_0, ..._1) => __async(void 0, [_0, ..._1], funct
149159 }
150160 cache [ cacheKey ] = {
151161 isFeatureEnabled : ref ( false ) ,
152- featureDescription : ref ( "" )
162+ featureDescription : ref ( "" ) ,
163+ featureConditions : reactive ( {
164+ clientFilters : [ ]
165+ } )
153166 } ;
154167 return cache [ cacheKey ] ;
155168 } ;
0 commit comments