@@ -26,7 +26,7 @@ import {
26
26
isFeatureFlag ,
27
27
parseFeatureFlag
28
28
} from "@azure/app-configuration" ;
29
- import { inject , ref } from "vue" ;
29
+ import { inject , reactive , ref } from "vue" ;
30
30
var FeatureFlagsManagerKey = Symbol (
31
31
"FeatureFlagsManager"
32
32
) ;
@@ -45,14 +45,18 @@ var featureFlagsManager = (connectionString, cacheEnabled = true, flagsToPrefetc
45
45
key : `${ featureFlagPrefix } ${ name } ` ,
46
46
label
47
47
} ) . then ( ( response ) => {
48
+ var _a ;
48
49
if ( isFeatureFlag ( response ) ) {
49
50
const {
50
- value : { enabled, description = "" }
51
+ value : { enabled, description = "" , conditions }
51
52
} = parseFeatureFlag ( response ) ;
52
53
const cacheKey = `cache-${ name } -${ label != null ? label : "empty-label" } ` ;
53
54
cache [ cacheKey ] = {
54
55
isFeatureEnabled : ref ( enabled ) ,
55
- featureDescription : ref ( description )
56
+ featureDescription : ref ( description ) ,
57
+ featureConditions : reactive ( {
58
+ clientFilters : ( _a = conditions . clientFilters ) != null ? _a : [ ]
59
+ } )
56
60
} ;
57
61
}
58
62
} ) . catch ( ( error ) => {
@@ -73,24 +77,26 @@ var featureFlagsManager = (connectionString, cacheEnabled = true, flagsToPrefetc
73
77
}
74
78
const isFeatureEnabled = ref ( false ) ;
75
79
const featureDescription = ref ( "" ) ;
80
+ const featureConditions = reactive ( { } ) ;
76
81
if ( ! appConfigurationClient ) {
77
82
if ( cacheEnabled ) {
78
- cache [ cacheKey ] = { isFeatureEnabled, featureDescription } ;
83
+ cache [ cacheKey ] = { isFeatureEnabled, featureDescription, featureConditions } ;
79
84
}
80
- return { isFeatureEnabled, featureDescription } ;
85
+ return { isFeatureEnabled, featureDescription, featureConditions } ;
81
86
}
82
87
appConfigurationClient . getConfigurationSetting ( {
83
88
key : `${ featureFlagPrefix } ${ name } ` ,
84
89
label
85
90
} ) . then ( ( response ) => {
86
91
if ( isFeatureFlag ( response ) ) {
87
92
const {
88
- value : { enabled, description = "" }
93
+ value : { enabled, description = "" , conditions }
89
94
} = parseFeatureFlag ( response ) ;
90
95
isFeatureEnabled . value = enabled ;
91
96
featureDescription . value = description ;
97
+ Object . assign ( conditions , featureConditions ) ;
92
98
if ( cacheEnabled ) {
93
- cache [ cacheKey ] = { isFeatureEnabled, featureDescription } ;
99
+ cache [ cacheKey ] = { isFeatureEnabled, featureDescription, featureConditions } ;
94
100
}
95
101
}
96
102
} ) . catch ( ( error ) => {
@@ -99,7 +105,7 @@ var featureFlagsManager = (connectionString, cacheEnabled = true, flagsToPrefetc
99
105
error
100
106
) ;
101
107
} ) ;
102
- return { isFeatureEnabled, featureDescription } ;
108
+ return { isFeatureEnabled, featureDescription, featureConditions } ;
103
109
} ;
104
110
return { getFeatureFlag, appConfigurationClient } ;
105
111
} ;
@@ -116,19 +122,23 @@ var featureFlagsManagerAsync = (_0, ..._1) => __async(void 0, [_0, ..._1], funct
116
122
}
117
123
yield Promise . all (
118
124
flags . map ( ( _02 ) => __async ( this , [ _02 ] , function * ( { name, label } ) {
125
+ var _a ;
119
126
try {
120
127
const response = yield appConfigurationClient . getConfigurationSetting ( {
121
128
key : `${ featureFlagPrefix } ${ name } ` ,
122
129
label
123
130
} ) ;
124
131
if ( isFeatureFlag ( response ) ) {
125
132
const {
126
- value : { enabled, description = "" }
133
+ value : { enabled, description = "" , conditions }
127
134
} = parseFeatureFlag ( response ) ;
128
135
const cacheKey = `cache-${ name } -${ label != null ? label : "empty-label" } ` ;
129
136
cache [ cacheKey ] = {
130
137
isFeatureEnabled : ref ( enabled ) ,
131
- featureDescription : ref ( description )
138
+ featureDescription : ref ( description ) ,
139
+ featureConditions : reactive ( {
140
+ clientFilters : ( _a = conditions . clientFilters ) != null ? _a : [ ]
141
+ } )
132
142
} ;
133
143
}
134
144
} catch ( error ) {
@@ -149,7 +159,10 @@ var featureFlagsManagerAsync = (_0, ..._1) => __async(void 0, [_0, ..._1], funct
149
159
}
150
160
cache [ cacheKey ] = {
151
161
isFeatureEnabled : ref ( false ) ,
152
- featureDescription : ref ( "" )
162
+ featureDescription : ref ( "" ) ,
163
+ featureConditions : reactive ( {
164
+ clientFilters : [ ]
165
+ } )
153
166
} ;
154
167
return cache [ cacheKey ] ;
155
168
} ;
0 commit comments