dsl updates

This commit is contained in:
lohit-bruno
2025-08-20 16:30:08 +05:30
parent 8d1f292b83
commit cd00c21781
5 changed files with 76 additions and 76 deletions

View File

@@ -29,17 +29,17 @@ const { safeParseJson, outdentString } = require('./utils');
*
*/
const grammar = ohm.grammar(`Bru {
BruFile = (meta | http | query | params | headers | auths | bodies | varsandassert | script | tests | settings | docs | authOAuth2Configs)*
auths = authawsv4 | authbasic | authbearer | authdigest | authNTLM | authOAuth2 | authwsse | authapikey
BruFile = (meta | http | query | params | headers | auths | bodies | varsandassert | script | tests | settings | docs)*
auths = authawsv4 | authbasic | authbearer | authdigest | authNTLM | authOAuth2 | authwsse | authapikey | authOauth2Configs
bodies = bodyjson | bodytext | bodyxml | bodysparql | bodygraphql | bodygraphqlvars | bodyforms | body
bodyforms = bodyformurlencoded | bodymultipart | bodyfile
params = paramspath | paramsquery
// Oauth2 additional parameters
authOAuth2Configs = oAuth2AuthorizationConfig | oAuth2TokenConfig | oAuth2RefreshConfig
oAuth2AuthorizationConfig = oAuth2AuthorizationHeaders | oAuth2AuthorizationQueryParams
oAuth2TokenConfig = oAuth2TokenHeaders | oAuth2TokenQueryParams | oAuth2TokenBodyValues
oAuth2RefreshConfig = oAuth2RefreshHeaders | oAuth2RefreshQueryParams | oAuth2RefreshBodyValues
authOauth2Configs = oauth2AuthReqConfig | oauth2AccessTokenReqConfig | oauth2RefreshTokenReqConfig
oauth2AuthReqConfig = oauth2AuthReqHeaders | oauth2AuthReqQueryParams
oauth2AccessTokenReqConfig = oauth2AccessTokenReqHeaders | oauth2AccessTokenReqQueryParams | oauth2AccessTokenReqBody
oauth2RefreshTokenReqConfig = oauth2RefreshTokenReqHeaders | oauth2RefreshTokenReqQueryParams | oauth2RefreshTokenReqBody
nl = "\\r"? "\\n"
st = " " | "\\t"
@@ -111,14 +111,14 @@ const grammar = ohm.grammar(`Bru {
authwsse = "auth:wsse" dictionary
authapikey = "auth:apikey" dictionary
oAuth2AuthorizationHeaders = "auth:oauth2:authorization_headers" dictionary
oAuth2AuthorizationQueryParams = "auth:oauth2:authorization_queryparams" dictionary
oAuth2TokenHeaders = "auth:oauth2:token_headers" dictionary
oAuth2TokenQueryParams = "auth:oauth2:token_queryparams" dictionary
oAuth2TokenBodyValues = "auth:oauth2:token_bodyvalues" dictionary
oAuth2RefreshHeaders = "auth:oauth2:refresh_headers" dictionary
oAuth2RefreshQueryParams = "auth:oauth2:refresh_queryparams" dictionary
oAuth2RefreshBodyValues = "auth:oauth2:refresh_bodyvalues" dictionary
oauth2AuthReqHeaders = "auth:oauth2:additional_params:auth_req:headers" dictionary
oauth2AuthReqQueryParams = "auth:oauth2:additional_params:auth_req:queryparams" dictionary
oauth2AccessTokenReqHeaders = "auth:oauth2:additional_params:access_token_req:headers" dictionary
oauth2AccessTokenReqQueryParams = "auth:oauth2:additional_params:access_token_req:queryparams" dictionary
oauth2AccessTokenReqBody = "auth:oauth2:additional_params:access_token_req:body" dictionary
oauth2RefreshTokenReqHeaders = "auth:oauth2:additional_params:refresh_token_req:headers" dictionary
oauth2RefreshTokenReqQueryParams = "auth:oauth2:additional_params:refresh_token_req:queryparams" dictionary
oauth2RefreshTokenReqBody = "auth:oauth2:additional_params:refresh_token_req:body" dictionary
body = "body" st* "{" nl* textblock tagend
bodyjson = "body:json" st* "{" nl* textblock tagend
@@ -655,42 +655,42 @@ const sem = grammar.createSemantics().addAttribute('ast', {
}
};
},
oAuth2AuthorizationHeaders(_1, dictionary) {
oauth2AuthReqHeaders(_1, dictionary) {
return {
oauth2_additional_parameters_authorization_headers: mapPairListToKeyValPairs(dictionary.ast)
};
},
oAuth2AuthorizationQueryParams(_1, dictionary) {
oauth2AuthReqQueryParams(_1, dictionary) {
return {
oauth2_additional_parameters_authorization_queryparams: mapPairListToKeyValPairs(dictionary.ast)
};
},
oAuth2TokenHeaders(_1, dictionary) {
oauth2AccessTokenReqHeaders(_1, dictionary) {
return {
oauth2_additional_parameters_token_headers: mapPairListToKeyValPairs(dictionary.ast)
};
},
oAuth2TokenQueryParams(_1, dictionary) {
oauth2AccessTokenReqQueryParams(_1, dictionary) {
return {
oauth2_additional_parameters_token_queryparams: mapPairListToKeyValPairs(dictionary.ast)
};
},
oAuth2TokenBodyValues(_1, dictionary) {
oauth2AccessTokenReqBody(_1, dictionary) {
return {
oauth2_additional_parameters_token_bodyvalues: mapPairListToKeyValPairs(dictionary.ast)
};
},
oAuth2RefreshHeaders(_1, dictionary) {
oauth2RefreshTokenReqHeaders(_1, dictionary) {
return {
oauth2_additional_parameters_refresh_headers: mapPairListToKeyValPairs(dictionary.ast)
};
},
oAuth2RefreshQueryParams(_1, dictionary) {
oauth2RefreshTokenReqQueryParams(_1, dictionary) {
return {
oauth2_additional_parameters_refresh_queryparams: mapPairListToKeyValPairs(dictionary.ast)
};
},
oAuth2RefreshBodyValues(_1, dictionary) {
oauth2RefreshTokenReqBody(_1, dictionary) {
return {
oauth2_additional_parameters_refresh_bodyvalues: mapPairListToKeyValPairs(dictionary.ast)
};

View File

@@ -3,14 +3,14 @@ const _ = require('lodash');
const { safeParseJson, outdentString } = require('./utils');
const grammar = ohm.grammar(`Bru {
BruFile = (meta | query | headers | auth | auths | vars | script | tests | docs | authOAuth2Configs)*
auths = authawsv4 | authbasic | authbearer | authdigest | authNTLM |authOAuth2 | authwsse | authapikey
BruFile = (meta | query | headers | auth | auths | vars | script | tests | docs)*
auths = authawsv4 | authbasic | authbearer | authdigest | authNTLM |authOAuth2 | authwsse | authapikey | authOauth2Configs
// Oauth2 additional parameters
authOAuth2Configs = oAuth2AuthorizationConfig | oAuth2TokenConfig | oAuth2RefreshConfig
oAuth2AuthorizationConfig = oAuth2AuthorizationHeaders | oAuth2AuthorizationQueryParams
oAuth2TokenConfig = oAuth2TokenHeaders | oAuth2TokenQueryParams | oAuth2TokenBodyValues
oAuth2RefreshConfig = oAuth2RefreshHeaders | oAuth2RefreshQueryParams | oAuth2RefreshBodyValues
authOauth2Configs = oauth2AuthReqConfig | oauth2AccessTokenReqConfig | oauth2RefreshTokenReqConfig
oauth2AuthReqConfig = oauth2AuthReqHeaders | oauth2AuthReqQueryParams
oauth2AccessTokenReqConfig = oauth2AccessTokenReqHeaders | oauth2AccessTokenReqQueryParams | oauth2AccessTokenReqBody
oauth2RefreshTokenReqConfig = oauth2RefreshTokenReqHeaders | oauth2RefreshTokenReqQueryParams | oauth2RefreshTokenReqBody
nl = "\\r"? "\\n"
st = " " | "\\t"
@@ -36,14 +36,14 @@ const grammar = ohm.grammar(`Bru {
auth = "auth" dictionary
oAuth2AuthorizationHeaders = "auth:oauth2:authorization_headers" dictionary
oAuth2AuthorizationQueryParams = "auth:oauth2:authorization_queryparams" dictionary
oAuth2TokenHeaders = "auth:oauth2:token_headers" dictionary
oAuth2TokenQueryParams = "auth:oauth2:token_queryparams" dictionary
oAuth2TokenBodyValues = "auth:oauth2:token_bodyvalues" dictionary
oAuth2RefreshHeaders = "auth:oauth2:refresh_headers" dictionary
oAuth2RefreshQueryParams = "auth:oauth2:refresh_queryparams" dictionary
oAuth2RefreshBodyValues = "auth:oauth2:refresh_bodyvalues" dictionary
oauth2AuthReqHeaders = "auth:oauth2:additional_params:auth_req:headers" dictionary
oauth2AuthReqQueryParams = "auth:oauth2:additional_params:auth_req:queryparams" dictionary
oauth2AccessTokenReqHeaders = "auth:oauth2:additional_params:access_token_req:headers" dictionary
oauth2AccessTokenReqQueryParams = "auth:oauth2:additional_params:access_token_req:queryparams" dictionary
oauth2AccessTokenReqBody = "auth:oauth2:additional_params:access_token_req:body" dictionary
oauth2RefreshTokenReqHeaders = "auth:oauth2:additional_params:refresh_token_req:headers" dictionary
oauth2RefreshTokenReqQueryParams = "auth:oauth2:additional_params:refresh_token_req:queryparams" dictionary
oauth2RefreshTokenReqBody = "auth:oauth2:additional_params:refresh_token_req:body" dictionary
headers = "headers" dictionary
@@ -377,42 +377,42 @@ const sem = grammar.createSemantics().addAttribute('ast', {
}
};
},
oAuth2AuthorizationHeaders(_1, dictionary) {
oauth2AuthReqHeaders(_1, dictionary) {
return {
oauth2_additional_parameters_authorization_headers: mapPairListToKeyValPairs(dictionary.ast)
};
},
oAuth2AuthorizationQueryParams(_1, dictionary) {
oauth2AuthReqQueryParams(_1, dictionary) {
return {
oauth2_additional_parameters_authorization_queryparams: mapPairListToKeyValPairs(dictionary.ast)
};
},
oAuth2TokenHeaders(_1, dictionary) {
oauth2AccessTokenReqHeaders(_1, dictionary) {
return {
oauth2_additional_parameters_token_headers: mapPairListToKeyValPairs(dictionary.ast)
};
},
oAuth2TokenQueryParams(_1, dictionary) {
oauth2AccessTokenReqQueryParams(_1, dictionary) {
return {
oauth2_additional_parameters_token_queryparams: mapPairListToKeyValPairs(dictionary.ast)
};
},
oAuth2TokenBodyValues(_1, dictionary) {
oauth2AccessTokenReqBody(_1, dictionary) {
return {
oauth2_additional_parameters_token_bodyvalues: mapPairListToKeyValPairs(dictionary.ast)
};
},
oAuth2RefreshHeaders(_1, dictionary) {
oauth2RefreshTokenReqHeaders(_1, dictionary) {
return {
oauth2_additional_parameters_refresh_headers: mapPairListToKeyValPairs(dictionary.ast)
};
},
oAuth2RefreshQueryParams(_1, dictionary) {
oauth2RefreshTokenReqQueryParams(_1, dictionary) {
return {
oauth2_additional_parameters_refresh_queryparams: mapPairListToKeyValPairs(dictionary.ast)
};
},
oAuth2RefreshBodyValues(_1, dictionary) {
oauth2RefreshTokenReqBody(_1, dictionary) {
return {
oauth2_additional_parameters_refresh_bodyvalues: mapPairListToKeyValPairs(dictionary.ast)
};

View File

@@ -286,7 +286,7 @@ ${indentString(`auto_fetch_token: ${(auth?.oauth2?.autoFetchToken ?? true).toStr
const { authorization: authorizationParams, token: tokenParams, refresh: refreshParams } = auth?.oauth2?.additionalParameters;
const authorizationHeaders = authorizationParams?.filter(p => p?.sendIn == 'headers');
if (authorizationHeaders?.length) {
bru += `auth:oauth2:authorization_headers {
bru += `auth:oauth2:additional_params:auth_req:headers {
${indentString(
authorizationHeaders
.filter(item => item?.name?.length)
@@ -299,7 +299,7 @@ ${indentString(
}
const authorizationQueryParams = authorizationParams?.filter(p => p?.sendIn == 'queryparams');
if (authorizationQueryParams?.length) {
bru += `auth:oauth2:authorization_queryparams {
bru += `auth:oauth2:additional_params:auth_req:queryparams {
${indentString(
authorizationQueryParams
.filter(item => item?.name?.length)
@@ -312,7 +312,7 @@ ${indentString(
}
const tokenHeaders = tokenParams?.filter(p => p?.sendIn == 'headers');
if (tokenHeaders?.length) {
bru += `auth:oauth2:token_headers {
bru += `auth:oauth2:additional_params:access_token_req:headers {
${indentString(
tokenHeaders
.filter(item => item?.name?.length)
@@ -325,7 +325,7 @@ ${indentString(
}
const tokenQueryParams = tokenParams?.filter(p => p?.sendIn == 'queryparams');
if (tokenQueryParams?.length) {
bru += `auth:oauth2:token_queryparams {
bru += `auth:oauth2:additional_params:access_token_req:queryparams {
${indentString(
tokenQueryParams
.filter(item => item?.name?.length)
@@ -338,7 +338,7 @@ ${indentString(
}
const tokenBodyValues = tokenParams?.filter(p => p?.sendIn == 'body');
if (tokenBodyValues?.length) {
bru += `auth:oauth2:token_bodyvalues {
bru += `auth:oauth2:additional_params:access_token_req:body {
${indentString(
tokenBodyValues
.filter(item => item?.name?.length)
@@ -351,7 +351,7 @@ ${indentString(
}
const refreshHeaders = refreshParams?.filter(p => p?.sendIn == 'headers');
if (refreshHeaders?.length) {
bru += `auth:oauth2:refresh_headers {
bru += `auth:oauth2:additional_params:refresh_token_req:headers {
${indentString(
refreshHeaders
.filter(item => item?.name?.length)
@@ -364,7 +364,7 @@ ${indentString(
}
const refreshQueryParams = refreshParams?.filter(p => p?.sendIn == 'queryparams');
if (refreshQueryParams?.length) {
bru += `auth:oauth2:refresh_queryparams {
bru += `auth:oauth2:additional_params:refresh_token_req:queryparams {
${indentString(
refreshQueryParams
.filter(item => item?.name?.length)
@@ -377,7 +377,7 @@ ${indentString(
}
const refreshBodyValues = refreshParams?.filter(p => p?.sendIn == 'body');
if (refreshBodyValues?.length) {
bru += `auth:oauth2:refresh_bodyvalues {
bru += `auth:oauth2:additional_params:refresh_token_req:body {
${indentString(
refreshBodyValues
.filter(item => item?.name?.length)

View File

@@ -239,7 +239,7 @@ ${indentString(`auto_refresh_token: ${(auth?.oauth2?.autoRefreshToken ?? false).
const { authorization: authorizationParams, token: tokenParams, refresh: refreshParams } = auth?.oauth2?.additionalParameters;
const authorizationHeaders = authorizationParams?.filter(p => p?.sendIn == 'headers');
if (authorizationHeaders?.length) {
bru += `auth:oauth2:authorization_headers {
bru += `auth:oauth2:additional_params:auth_req:headers {
${indentString(
authorizationHeaders
.filter(item => item?.name?.length)
@@ -252,7 +252,7 @@ ${indentString(
}
const authorizationQueryParams = authorizationParams?.filter(p => p?.sendIn == 'queryparams');
if (authorizationQueryParams?.length) {
bru += `auth:oauth2:authorization_queryparams {
bru += `auth:oauth2:additional_params:auth_req:queryparams {
${indentString(
authorizationQueryParams
.filter(item => item?.name?.length)
@@ -265,7 +265,7 @@ ${indentString(
}
const tokenHeaders = tokenParams?.filter(p => p?.sendIn == 'headers');
if (tokenHeaders?.length) {
bru += `auth:oauth2:token_headers {
bru += `auth:oauth2:additional_params:access_token_req:headers {
${indentString(
tokenHeaders
.filter(item => item?.name?.length)
@@ -278,7 +278,7 @@ ${indentString(
}
const tokenQueryParams = tokenParams?.filter(p => p?.sendIn == 'queryparams');
if (tokenQueryParams?.length) {
bru += `auth:oauth2:token_queryparams {
bru += `auth:oauth2:additional_params:access_token_req:queryparams {
${indentString(
tokenQueryParams
.filter(item => item?.name?.length)
@@ -291,7 +291,7 @@ ${indentString(
}
const tokenBodyValues = tokenParams?.filter(p => p?.sendIn == 'body');
if (tokenBodyValues?.length) {
bru += `auth:oauth2:token_bodyvalues {
bru += `auth:oauth2:additional_params:access_token_req:body {
${indentString(
tokenBodyValues
.filter(item => item?.name?.length)
@@ -304,7 +304,7 @@ ${indentString(
}
const refreshHeaders = refreshParams?.filter(p => p?.sendIn == 'headers');
if (refreshHeaders?.length) {
bru += `auth:oauth2:refresh_headers {
bru += `auth:oauth2:additional_params:refresh_token_req:headers {
${indentString(
refreshHeaders
.filter(item => item?.name?.length)
@@ -317,7 +317,7 @@ ${indentString(
}
const refreshQueryParams = refreshParams?.filter(p => p?.sendIn == 'queryparams');
if (refreshQueryParams?.length) {
bru += `auth:oauth2:refresh_queryparams {
bru += `auth:oauth2:additional_params:refresh_token_req:queryparams {
${indentString(
refreshQueryParams
.filter(item => item?.name?.length)
@@ -330,7 +330,7 @@ ${indentString(
}
const refreshBodyValues = refreshParams?.filter(p => p?.sendIn == 'body');
if (refreshBodyValues?.length) {
bru += `auth:oauth2:refresh_bodyvalues {
bru += `auth:oauth2:additional_params:refresh_token_req:body {
${indentString(
refreshBodyValues
.filter(item => item?.name?.length)

View File

@@ -21,42 +21,42 @@ auth:oauth2 {
access_token_url: https://auth.usebruno.com/oauth/token
}
auth:oauth2:authorization_headers {
auth:oauth2:additional_params:auth_req:headers {
auth-header: auth-header-value
~disabled-auth-header: disabled-auth-header-value
}
auth:oauth2:authorization_queryparams {
auth:oauth2:additional_params:auth_req:queryparams {
auth-query-param: auth-query-param-value
~disabled-auth-query-param: disabled-auth-query-param-value
}
auth:oauth2:token_headers {
auth:oauth2:additional_params:access_token_req:headers {
token-header: token-header-value
~disabled-token-header: disabled-token-header-value
}
auth:oauth2:token_queryparams {
auth:oauth2:additional_params:access_token_req:queryparams {
token-query-param: token-query-param-value
~disabled-token-query-param: disabled-token-query-param-value
}
auth:oauth2:token_bodyvalues {
auth:oauth2:additional_params:access_token_req:body {
token-body: token-body-value
~disabled-token-body: disabled-token-body-value
}
auth:oauth2:refresh_headers {
auth:oauth2:additional_params:refresh_token_req:headers {
refresh-header: refresh-header-value
~disabled-refresh-header: disabled-refresh-header-value
}
auth:oauth2:refresh_queryparams {
auth:oauth2:additional_params:refresh_token_req:queryparams {
refresh-query-param: refresh-query-param-value
~disabled-refresh-query-param: disabled-refresh-query-param-value
}
auth:oauth2:refresh_bodyvalues {
auth:oauth2:additional_params:refresh_token_req:body {
refresh-body: refresh-body-value
~disabled-refresh-body: disabled-refresh-body-value
}
@@ -182,42 +182,42 @@ auth:oauth2 {
access_token_url: https://auth.usebruno.com/oauth/token
}
auth:oauth2:authorization_headers {
auth:oauth2:additional_params:auth_req:headers {
auth-header: auth-header-value
~disabled-auth-header: disabled-auth-header-value
}
auth:oauth2:authorization_queryparams {
auth:oauth2:additional_params:auth_req:queryparams {
auth-query-param: auth-query-param-value
~disabled-auth-query-param: disabled-auth-query-param-value
}
auth:oauth2:token_headers {
auth:oauth2:additional_params:access_token_req:headers {
token-header: token-header-value
~disabled-token-header: disabled-token-header-value
}
auth:oauth2:token_queryparams {
auth:oauth2:additional_params:access_token_req:queryparams {
token-query-param: token-query-param-value
~disabled-token-query-param: disabled-token-query-param-value
}
auth:oauth2:token_bodyvalues {
auth:oauth2:additional_params:access_token_req:body {
token-body: token-body-value
~disabled-token-body: disabled-token-body-value
}
auth:oauth2:refresh_headers {
auth:oauth2:additional_params:refresh_token_req:headers {
refresh-header: refresh-header-value
~disabled-refresh-header: disabled-refresh-header-value
}
auth:oauth2:refresh_queryparams {
auth:oauth2:additional_params:refresh_token_req:queryparams {
refresh-query-param: refresh-query-param-value
~disabled-refresh-query-param: disabled-refresh-query-param-value
}
auth:oauth2:refresh_bodyvalues {
auth:oauth2:additional_params:refresh_token_req:body {
refresh-body: refresh-body-value
~disabled-refresh-body: disabled-refresh-body-value
}