@@ -117,7 +117,6 @@ import {
117
117
isBodySegment ,
118
118
canStringBeConverted ,
119
119
splitAtIndex ,
120
- unescapeString ,
121
120
} from '@microsoft/logic-apps-shared' ;
122
121
import type {
123
122
AuthProps ,
@@ -788,8 +787,8 @@ function toAuthenticationViewModel(value: any): { type: AuthenticationType; auth
788
787
type : value . type ,
789
788
authenticationValue : {
790
789
basic : {
791
- basicUsername : loadParameterValueFromString ( value . username , { parameterType : constants . SWAGGER . TYPE . STRING } ) ,
792
- basicPassword : loadParameterValueFromString ( value . password , { parameterType : constants . SWAGGER . TYPE . STRING } ) ,
790
+ basicUsername : loadParameterValueFromString ( value . username ) ,
791
+ basicPassword : loadParameterValueFromString ( value . password ) ,
793
792
} ,
794
793
} ,
795
794
} ;
@@ -798,8 +797,8 @@ function toAuthenticationViewModel(value: any): { type: AuthenticationType; auth
798
797
type : value . type ,
799
798
authenticationValue : {
800
799
clientCertificate : {
801
- clientCertificatePfx : loadParameterValueFromString ( value . pfx , { parameterType : constants . SWAGGER . TYPE . STRING } ) ,
802
- clientCertificatePassword : loadParameterValueFromString ( value . password , { parameterType : constants . SWAGGER . TYPE . STRING } ) ,
800
+ clientCertificatePfx : loadParameterValueFromString ( value . pfx ) ,
801
+ clientCertificatePassword : loadParameterValueFromString ( value . password ) ,
803
802
} ,
804
803
} ,
805
804
} ;
@@ -809,14 +808,14 @@ function toAuthenticationViewModel(value: any): { type: AuthenticationType; auth
809
808
type : value . type ,
810
809
authenticationValue : {
811
810
aadOAuth : {
812
- oauthTenant : loadParameterValueFromString ( value . tenant , { parameterType : constants . SWAGGER . TYPE . STRING } ) ,
813
- oauthAudience : loadParameterValueFromString ( value . audience , { parameterType : constants . SWAGGER . TYPE . STRING } ) ,
814
- oauthAuthority : loadParameterValueFromString ( value . authority , { parameterType : constants . SWAGGER . TYPE . STRING } ) ,
815
- oauthClientId : loadParameterValueFromString ( value . clientId , { parameterType : constants . SWAGGER . TYPE . STRING } ) ,
811
+ oauthTenant : loadParameterValueFromString ( value . tenant ) ,
812
+ oauthAudience : loadParameterValueFromString ( value . audience ) ,
813
+ oauthAuthority : loadParameterValueFromString ( value . authority ) ,
814
+ oauthClientId : loadParameterValueFromString ( value . clientId ) ,
816
815
oauthType : loadOauthType ( value ) ,
817
- oauthTypeSecret : loadParameterValueFromString ( value . secret , { parameterType : constants . SWAGGER . TYPE . STRING } ) ,
818
- oauthTypeCertificatePfx : loadParameterValueFromString ( value . pfx , { parameterType : constants . SWAGGER . TYPE . STRING } ) ,
819
- oauthTypeCertificatePassword : loadParameterValueFromString ( value . password , { parameterType : constants . SWAGGER . TYPE . STRING } ) ,
816
+ oauthTypeSecret : loadParameterValueFromString ( value . secret ) ,
817
+ oauthTypeCertificatePfx : loadParameterValueFromString ( value . pfx ) ,
818
+ oauthTypeCertificatePassword : loadParameterValueFromString ( value . password ) ,
820
819
} ,
821
820
} ,
822
821
} ;
@@ -836,7 +835,7 @@ function toAuthenticationViewModel(value: any): { type: AuthenticationType; auth
836
835
type : value . type ,
837
836
authenticationValue : {
838
837
msi : {
839
- msiAudience : loadParameterValueFromString ( value . audience , { parameterType : constants . SWAGGER . TYPE . STRING } ) ,
838
+ msiAudience : loadParameterValueFromString ( value . audience ) ,
840
839
msiIdentity : value . identity ,
841
840
} ,
842
841
} ,
@@ -955,7 +954,7 @@ export function convertToTokenExpression(value: any): string {
955
954
return value . toString ( ) ;
956
955
}
957
956
958
- export function convertToValueSegments ( value : any , shouldUncast : boolean , parameterType ? : string ) : ValueSegment [ ] {
957
+ export function convertToValueSegments ( value : any , shouldUncast : boolean , parameterType : string ) : ValueSegment [ ] {
959
958
try {
960
959
const convertor = new ValueSegmentConvertor ( {
961
960
shouldUncast,
@@ -3618,7 +3617,6 @@ export function parameterValueToJSONString(parameterValue: ValueSegment[], apply
3618
3617
let tokenExpression : string = expression . value ;
3619
3618
3620
3619
if ( isTokenValueSegment ( expression ) ) {
3621
- const stringifiedTokenExpression = tokenExpression ;
3622
3620
// Note: Stringify the token expression to escape double quotes and other characters which must be escaped in JSON.
3623
3621
if ( shouldInterpolate ) {
3624
3622
if ( applyCasting ) {
@@ -3631,15 +3629,20 @@ export function parameterValueToJSONString(parameterValue: ValueSegment[], apply
3631
3629
) ;
3632
3630
}
3633
3631
3632
+ const stringifiedTokenExpression = JSON . stringify ( tokenExpression ) . slice ( 1 , - 1 ) ;
3634
3633
tokenExpression = `@{${ stringifiedTokenExpression } }` ;
3635
3634
} else {
3636
3635
// Add quotes around tokens. Tokens directly after a literal need a leading quote, and those before another literal need an ending quote.
3637
3636
const lastExpressionWasLiteral = i > 0 && updatedParameterValue [ i - 1 ] . type !== ValueSegmentType . TOKEN ;
3638
3637
const nextExpressionIsLiteral =
3639
3638
i < updatedParameterValue . length - 1 && updatedParameterValue [ i + 1 ] . type !== ValueSegmentType . TOKEN ;
3639
+
3640
+ const stringifiedTokenExpression = JSON . stringify ( tokenExpression ) . slice ( 1 , - 1 ) ;
3640
3641
tokenExpression = `@${ stringifiedTokenExpression } ` ;
3641
- tokenExpression = lastExpressionWasLiteral ? `"${ tokenExpression } ` : tokenExpression ;
3642
- tokenExpression = nextExpressionIsLiteral ? `${ tokenExpression } "` : `${ tokenExpression } ` ;
3642
+ // eslint-disable-next-line no-useless-escape
3643
+ tokenExpression = lastExpressionWasLiteral ? `\"${ tokenExpression } ` : tokenExpression ;
3644
+ // eslint-disable-next-line no-useless-escape
3645
+ tokenExpression = nextExpressionIsLiteral ? `${ tokenExpression } \"` : `${ tokenExpression } ` ;
3643
3646
}
3644
3647
3645
3648
parameterValueString += tokenExpression ;
@@ -3767,14 +3770,13 @@ function parameterValueToStringWithoutCasting(value: ValueSegment[], forValidati
3767
3770
const shouldInterpolateTokens = ( value . length > 1 || shouldInterpolateSingleToken ) && value . some ( isTokenValueSegment ) ;
3768
3771
3769
3772
return value
3770
- . map ( ( segment ) => {
3771
- const { value : segmentValue } = segment ;
3772
- if ( isTokenValueSegment ( segment ) ) {
3773
- const token = forValidation ? segmentValue || null : unescapeString ( segmentValue ) ;
3774
- return shouldInterpolateTokens ? `@{${ token } }` : `@${ token } ` ;
3773
+ . map ( ( expression ) => {
3774
+ let expressionValue = forValidation ? expression . value || null : expression . value ;
3775
+ if ( isTokenValueSegment ( expression ) ) {
3776
+ expressionValue = shouldInterpolateTokens ? `@{${ expressionValue } }` : `@${ expressionValue } ` ;
3775
3777
}
3776
3778
3777
- return forValidation ? segmentValue || null : segmentValue ;
3779
+ return expressionValue ;
3778
3780
} )
3779
3781
. join ( '' ) ;
3780
3782
}
0 commit comments