@@ -49,7 +49,7 @@ export class LaunchDarklyUtilsFlags {
4949 throw {
5050 api : 'getFeatureFlags' ,
5151 message : e . message ,
52- docs : 'https://apidocs.launchdarkly.com/docs/list-feature- flags'
52+ docs : 'https://apidocs.launchdarkly.com/tag/Feature- flags#operation/getFeatureFlags '
5353 } ;
5454 }
5555 }
@@ -79,7 +79,7 @@ export class LaunchDarklyUtilsFlags {
7979 throw {
8080 api : 'getFeatureFlag' ,
8181 message : e . message ,
82- docs : 'https://apidocs.launchdarkly.com/docs/get-feature-flag '
82+ docs : 'https://apidocs.launchdarkly.com/tag/Feature-flags#operation/getFeatureFlag '
8383 } ;
8484 }
8585 }
@@ -104,28 +104,32 @@ export class LaunchDarklyUtilsFlags {
104104 * patch a feature flag by key
105105 * @param {string } projectKey - project identifier
106106 * @param {string } featureFlagKey - feature flag identifier
107- * @param {Array<Object> } patchComment - array of valid json patch descriptors
107+ * @param {Array<Object> } patch - array of valid json patch descriptors
108108 * @returns {Promise }
109109 * @fulfil {Object} updated feature flag json
110110 * @reject {Error} object with message
111111 * @example ldutils updateFeatureFlag my-project my-flag {jsonPatch}
112112 */
113- async updateFeatureFlag ( projectKey , featureFlagKey , patchComment ) {
113+ async updateFeatureFlag ( projectKey , featureFlagKey , patch ) {
114114 try {
115115 return this . apiClient . apis [ this . API_GROUP ]
116- . patchFeatureFlag ( {
117- projectKey : projectKey ,
118- featureFlagKey : featureFlagKey ,
119- patchComment : patchComment
120- } )
116+ . patchFeatureFlag (
117+ {
118+ projectKey : projectKey ,
119+ featureFlagKey : featureFlagKey
120+ } ,
121+ {
122+ requestBody : patch
123+ }
124+ )
121125 . then ( response => {
122126 return response . body ;
123127 } ) ;
124128 } catch ( e ) {
125129 throw {
126130 api : 'patchFeatureFlag' ,
127131 message : e . message ,
128- docs : 'https://apidocs.launchdarkly.com/docs/update-feature-flag '
132+ docs : 'https://apidocs.launchdarkly.com/tag/Feature-flags#operation/patchFeatureFlag '
129133 } ;
130134 }
131135 }
@@ -170,15 +174,15 @@ export class LaunchDarklyUtilsFlags {
170174 return patchDelta ;
171175 } )
172176 . then ( patchDelta => {
173- let patchComment = this . assembleFlagPatch ( patchDelta , toEnv , includeState ) ;
177+ let patch = this . assembleFlagPatch ( patchDelta , toEnv , includeState ) ;
174178
175- that . log . debug ( `patchComment for '${ featureFlagKey } ' in ${ toEnv } : ${ json . plain ( patchComment ) } ` ) ;
176- return this . updateFeatureFlag ( projectKey , featureFlagKey , patchComment ) ;
179+ that . log . debug ( `patch for '${ featureFlagKey } ' in ${ toEnv } : ${ json . plain ( patch ) } ` ) ;
180+ return this . updateFeatureFlag ( projectKey , featureFlagKey , patch ) ;
177181 } ) ;
178182 }
179183
180184 assembleFlagPatch ( patchDelta , targetEnv , includeState ) {
181- let patchComment = [ ] ;
185+ let patches = [ ] ;
182186 patchDelta . forEach ( patch => {
183187 if (
184188 patch . path . startsWith ( '/targets' ) ||
@@ -190,10 +194,10 @@ export class LaunchDarklyUtilsFlags {
190194 ) {
191195 // add target env obj path and push
192196 patch . path = `/environments/${ targetEnv } ${ patch . path } ` ;
193- patchComment . push ( patch ) ;
197+ patches . push ( patch ) ;
194198 }
195199 } ) ;
196- return patchComment ;
200+ return patches ;
197201 }
198202
199203 /**
@@ -256,10 +260,10 @@ export class LaunchDarklyUtilsFlags {
256260 return patchDelta ;
257261 } )
258262 . then ( patchDelta => {
259- let patchComment = this . assembleFlagPatch ( patchDelta , targetEnv , includeState ) ;
263+ let patch = this . assembleFlagPatch ( patchDelta , targetEnv , includeState ) ;
260264
261- that . log . debug ( `patchComment for '${ key } ' in ${ targetEnv } : ${ json . plain ( patchComment ) } ` ) ;
262- return this . updateFeatureFlag ( projectKey , key , patchComment ) ;
265+ that . log . debug ( `patch for '${ key } ' in ${ targetEnv } : ${ json . plain ( patch ) } ` ) ;
266+ return this . updateFeatureFlag ( projectKey , key , patch ) ;
263267 } )
264268 ) ;
265269 } ) ;
0 commit comments