Merge branch 'main' into feature/proxy-global-and-collection

# Conflicts:
#	packages/bruno-app/src/components/ResponsePane/Placeholder/index.js
This commit is contained in:
Mirko Golze 2023-10-11 08:30:51 +02:00
commit 608d606f64
32 changed files with 269 additions and 194 deletions

126
package-lock.json generated
View File

@ -5605,6 +5605,14 @@
"node": ">=4" "node": ">=4"
} }
}, },
"node_modules/chai-string": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/chai-string/-/chai-string-1.5.0.tgz",
"integrity": "sha512-sydDC3S3pNAQMYwJrs6dQX0oBQ6KfIPuOZ78n7rocW0eJJlsHPh2t3kwW7xfwYA/1Bf6/arGtSUo16rxR2JFlw==",
"peerDependencies": {
"chai": "^4.1.2"
}
},
"node_modules/chalk": { "node_modules/chalk": {
"version": "4.1.2", "version": "4.1.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
@ -13517,8 +13525,7 @@
"node_modules/react-is": { "node_modules/react-is": {
"version": "18.2.0", "version": "18.2.0",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz", "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz",
"integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==", "integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w=="
"dev": true
}, },
"node_modules/react-redux": { "node_modules/react-redux": {
"version": "7.2.9", "version": "7.2.9",
@ -16705,7 +16712,7 @@
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@usebruno/js": "0.8.0", "@usebruno/js": "0.8.0",
"@usebruno/lang": "0.6.0", "@usebruno/lang": "0.8.0",
"axios": "^1.5.1", "axios": "^1.5.1",
"chai": "^4.3.7", "chai": "^4.3.7",
"chalk": "^3.0.0", "chalk": "^3.0.0",
@ -16785,14 +16792,15 @@
}, },
"packages/bruno-electron": { "packages/bruno-electron": {
"name": "bruno", "name": "bruno",
"version": "v0.22.0", "version": "v0.22.1",
"dependencies": { "dependencies": {
"@usebruno/js": "0.8.0", "@usebruno/js": "0.8.0",
"@usebruno/lang": "0.6.0", "@usebruno/lang": "0.8.0",
"@usebruno/schema": "0.5.0", "@usebruno/schema": "0.5.0",
"about-window": "^1.15.2", "about-window": "^1.15.2",
"axios": "^1.5.1", "axios": "^1.5.1",
"chai": "^4.3.7", "chai": "^4.3.7",
"chai-string": "^1.5.0",
"chokidar": "^3.5.3", "chokidar": "^3.5.3",
"decomment": "^0.9.5", "decomment": "^0.9.5",
"dotenv": "^16.0.3", "dotenv": "^16.0.3",
@ -17036,14 +17044,26 @@
}, },
"packages/bruno-lang": { "packages/bruno-lang": {
"name": "@usebruno/lang", "name": "@usebruno/lang",
"version": "0.6.0", "version": "0.8.0",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"arcsecond": "^5.0.0", "arcsecond": "^5.0.0",
"dotenv": "^16.3.1",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"ohm-js": "^16.6.0" "ohm-js": "^16.6.0"
} }
}, },
"packages/bruno-lang/node_modules/dotenv": {
"version": "16.3.1",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz",
"integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/motdotla/dotenv?sponsor=1"
}
},
"packages/bruno-query": { "packages/bruno-query": {
"name": "@usebruno/query", "name": "@usebruno/query",
"version": "0.1.0", "version": "0.1.0",
@ -19558,7 +19578,8 @@
"@tabler/icons": { "@tabler/icons": {
"version": "1.119.0", "version": "1.119.0",
"resolved": "https://registry.npmjs.org/@tabler/icons/-/icons-1.119.0.tgz", "resolved": "https://registry.npmjs.org/@tabler/icons/-/icons-1.119.0.tgz",
"integrity": "sha512-Fk3Qq4w2SXcTjc/n1cuL5bccPkylrOMo7cYpQIf/yw6zP76LQV9dtLcHQUjFiUnaYuswR645CnURIhlafyAh9g==" "integrity": "sha512-Fk3Qq4w2SXcTjc/n1cuL5bccPkylrOMo7cYpQIf/yw6zP76LQV9dtLcHQUjFiUnaYuswR645CnURIhlafyAh9g==",
"requires": {}
}, },
"@tauri-apps/cli": { "@tauri-apps/cli": {
"version": "1.2.2", "version": "1.2.2",
@ -20030,7 +20051,7 @@
"version": "file:packages/bruno-cli", "version": "file:packages/bruno-cli",
"requires": { "requires": {
"@usebruno/js": "0.8.0", "@usebruno/js": "0.8.0",
"@usebruno/lang": "0.6.0", "@usebruno/lang": "0.8.0",
"axios": "^1.5.1", "axios": "^1.5.1",
"chai": "^4.3.7", "chai": "^4.3.7",
"chalk": "^3.0.0", "chalk": "^3.0.0",
@ -20162,8 +20183,16 @@
"version": "file:packages/bruno-lang", "version": "file:packages/bruno-lang",
"requires": { "requires": {
"arcsecond": "^5.0.0", "arcsecond": "^5.0.0",
"dotenv": "^16.3.1",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"ohm-js": "^16.6.0" "ohm-js": "^16.6.0"
},
"dependencies": {
"dotenv": {
"version": "16.3.1",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz",
"integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ=="
}
} }
}, },
"@usebruno/query": { "@usebruno/query": {
@ -20180,7 +20209,8 @@
} }
}, },
"@usebruno/schema": { "@usebruno/schema": {
"version": "file:packages/bruno-schema" "version": "file:packages/bruno-schema",
"requires": {}
}, },
"@usebruno/testbench": { "@usebruno/testbench": {
"version": "file:packages/bruno-testbench", "version": "file:packages/bruno-testbench",
@ -20356,7 +20386,8 @@
"version": "1.2.0", "version": "1.2.0",
"resolved": "https://registry.npmjs.org/@webpack-cli/configtest/-/configtest-1.2.0.tgz", "resolved": "https://registry.npmjs.org/@webpack-cli/configtest/-/configtest-1.2.0.tgz",
"integrity": "sha512-4FB8Tj6xyVkyqjj1OaTqCjXYULB9FMkqQ8yGrZjRDrYh0nOE+7Lhs45WioWQQMV+ceFlE368Ukhe6xdvJM9Egg==", "integrity": "sha512-4FB8Tj6xyVkyqjj1OaTqCjXYULB9FMkqQ8yGrZjRDrYh0nOE+7Lhs45WioWQQMV+ceFlE368Ukhe6xdvJM9Egg==",
"dev": true "dev": true,
"requires": {}
}, },
"@webpack-cli/info": { "@webpack-cli/info": {
"version": "1.5.0", "version": "1.5.0",
@ -20371,7 +20402,8 @@
"version": "1.7.0", "version": "1.7.0",
"resolved": "https://registry.npmjs.org/@webpack-cli/serve/-/serve-1.7.0.tgz", "resolved": "https://registry.npmjs.org/@webpack-cli/serve/-/serve-1.7.0.tgz",
"integrity": "sha512-oxnCNGj88fL+xzV+dacXs44HcDwf1ovs3AuEzvP7mqXw7fQntqIhQ1BRmynh4qEKQSSSRSWVyXRjmTbZIX9V2Q==", "integrity": "sha512-oxnCNGj88fL+xzV+dacXs44HcDwf1ovs3AuEzvP7mqXw7fQntqIhQ1BRmynh4qEKQSSSRSWVyXRjmTbZIX9V2Q==",
"dev": true "dev": true,
"requires": {}
}, },
"@xtuc/ieee754": { "@xtuc/ieee754": {
"version": "1.2.0", "version": "1.2.0",
@ -20476,7 +20508,8 @@
"version": "3.5.2", "version": "3.5.2",
"resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz", "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz",
"integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==", "integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==",
"dev": true "dev": true,
"requires": {}
}, },
"amdefine": { "amdefine": {
"version": "0.0.8", "version": "0.0.8",
@ -21150,11 +21183,12 @@
"version": "file:packages/bruno-electron", "version": "file:packages/bruno-electron",
"requires": { "requires": {
"@usebruno/js": "0.8.0", "@usebruno/js": "0.8.0",
"@usebruno/lang": "0.6.0", "@usebruno/lang": "0.8.0",
"@usebruno/schema": "0.5.0", "@usebruno/schema": "0.5.0",
"about-window": "^1.15.2", "about-window": "^1.15.2",
"axios": "^1.5.1", "axios": "^1.5.1",
"chai": "^4.3.7", "chai": "^4.3.7",
"chai-string": "^1.5.0",
"chokidar": "^3.5.3", "chokidar": "^3.5.3",
"decomment": "^0.9.5", "decomment": "^0.9.5",
"dmg-license": "^1.0.11", "dmg-license": "^1.0.11",
@ -21543,6 +21577,12 @@
"type-detect": "^4.0.5" "type-detect": "^4.0.5"
} }
}, },
"chai-string": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/chai-string/-/chai-string-1.5.0.tgz",
"integrity": "sha512-sydDC3S3pNAQMYwJrs6dQX0oBQ6KfIPuOZ78n7rocW0eJJlsHPh2t3kwW7xfwYA/1Bf6/arGtSUo16rxR2JFlw==",
"requires": {}
},
"chalk": { "chalk": {
"version": "4.1.2", "version": "4.1.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
@ -22076,7 +22116,8 @@
"version": "6.3.1", "version": "6.3.1",
"resolved": "https://registry.npmjs.org/css-declaration-sorter/-/css-declaration-sorter-6.3.1.tgz", "resolved": "https://registry.npmjs.org/css-declaration-sorter/-/css-declaration-sorter-6.3.1.tgz",
"integrity": "sha512-fBffmak0bPAnyqc/HO8C3n2sHrp9wcqQz6ES9koRF2/mLOVAx9zIQ3Y7R29sYCteTPqMCwns4WYQoCX91Xl3+w==", "integrity": "sha512-fBffmak0bPAnyqc/HO8C3n2sHrp9wcqQz6ES9koRF2/mLOVAx9zIQ3Y7R29sYCteTPqMCwns4WYQoCX91Xl3+w==",
"dev": true "dev": true,
"requires": {}
}, },
"css-loader": { "css-loader": {
"version": "6.7.3", "version": "6.7.3",
@ -22221,7 +22262,8 @@
"version": "3.1.0", "version": "3.1.0",
"resolved": "https://registry.npmjs.org/cssnano-utils/-/cssnano-utils-3.1.0.tgz", "resolved": "https://registry.npmjs.org/cssnano-utils/-/cssnano-utils-3.1.0.tgz",
"integrity": "sha512-JQNR19/YZhz4psLX/rQ9M83e3z2Wf/HdJbryzte4a3NSuafyp9w/I4U+hx5C2S9g41qlstH7DEWnZaaj83OuEA==", "integrity": "sha512-JQNR19/YZhz4psLX/rQ9M83e3z2Wf/HdJbryzte4a3NSuafyp9w/I4U+hx5C2S9g41qlstH7DEWnZaaj83OuEA==",
"dev": true "dev": true,
"requires": {}
}, },
"csso": { "csso": {
"version": "4.2.0", "version": "4.2.0",
@ -23682,7 +23724,8 @@
"goober": { "goober": {
"version": "2.1.11", "version": "2.1.11",
"resolved": "https://registry.npmjs.org/goober/-/goober-2.1.11.tgz", "resolved": "https://registry.npmjs.org/goober/-/goober-2.1.11.tgz",
"integrity": "sha512-5SS2lmxbhqH0u9ABEWq7WPU69a4i2pYcHeCxqaNq6Cw3mnrF0ghWNM4tEGid4dKy8XNIAUbuThuozDHHKJVh3A==" "integrity": "sha512-5SS2lmxbhqH0u9ABEWq7WPU69a4i2pYcHeCxqaNq6Cw3mnrF0ghWNM4tEGid4dKy8XNIAUbuThuozDHHKJVh3A==",
"requires": {}
}, },
"got": { "got": {
"version": "9.6.0", "version": "9.6.0",
@ -24155,7 +24198,8 @@
"version": "5.1.0", "version": "5.1.0",
"resolved": "https://registry.npmjs.org/icss-utils/-/icss-utils-5.1.0.tgz", "resolved": "https://registry.npmjs.org/icss-utils/-/icss-utils-5.1.0.tgz",
"integrity": "sha512-soFhflCVWLfRNOPU3iv5Z9VUdT44xFRbzjLsEzSr5AQmgqPMTHdU3PMT1Cf1ssx8fLNJDA1juftYl+PUcv3MqA==", "integrity": "sha512-soFhflCVWLfRNOPU3iv5Z9VUdT44xFRbzjLsEzSr5AQmgqPMTHdU3PMT1Cf1ssx8fLNJDA1juftYl+PUcv3MqA==",
"dev": true "dev": true,
"requires": {}
}, },
"idb": { "idb": {
"version": "7.1.1", "version": "7.1.1",
@ -24939,7 +24983,8 @@
"version": "1.2.3", "version": "1.2.3",
"resolved": "https://registry.npmjs.org/jest-pnp-resolver/-/jest-pnp-resolver-1.2.3.tgz", "resolved": "https://registry.npmjs.org/jest-pnp-resolver/-/jest-pnp-resolver-1.2.3.tgz",
"integrity": "sha512-+3NpwQEnRoIBtx4fyhblQDPgJI0H1IEIkX7ShLUjPGA7TtUTvI1oiKi3SR4oBR0hQhQR80l4WAe5RrXBwWMA8w==", "integrity": "sha512-+3NpwQEnRoIBtx4fyhblQDPgJI0H1IEIkX7ShLUjPGA7TtUTvI1oiKi3SR4oBR0hQhQR80l4WAe5RrXBwWMA8w==",
"dev": true "dev": true,
"requires": {}
}, },
"jest-regex-util": { "jest-regex-util": {
"version": "29.2.0", "version": "29.2.0",
@ -25701,7 +25746,8 @@
"meros": { "meros": {
"version": "1.2.1", "version": "1.2.1",
"resolved": "https://registry.npmjs.org/meros/-/meros-1.2.1.tgz", "resolved": "https://registry.npmjs.org/meros/-/meros-1.2.1.tgz",
"integrity": "sha512-R2f/jxYqCAGI19KhAvaxSOxALBMkaXWH2a7rOyqQw+ZmizX5bKkEYWLzdhC+U82ZVVPVp6MCXe3EkVligh+12g==" "integrity": "sha512-R2f/jxYqCAGI19KhAvaxSOxALBMkaXWH2a7rOyqQw+ZmizX5bKkEYWLzdhC+U82ZVVPVp6MCXe3EkVligh+12g==",
"requires": {}
}, },
"methods": { "methods": {
"version": "1.1.2", "version": "1.1.2",
@ -26731,25 +26777,29 @@
"version": "5.1.2", "version": "5.1.2",
"resolved": "https://registry.npmjs.org/postcss-discard-comments/-/postcss-discard-comments-5.1.2.tgz", "resolved": "https://registry.npmjs.org/postcss-discard-comments/-/postcss-discard-comments-5.1.2.tgz",
"integrity": "sha512-+L8208OVbHVF2UQf1iDmRcbdjJkuBF6IS29yBDSiWUIzpYaAhtNl6JYnYm12FnkeCwQqF5LeklOu6rAqgfBZqQ==", "integrity": "sha512-+L8208OVbHVF2UQf1iDmRcbdjJkuBF6IS29yBDSiWUIzpYaAhtNl6JYnYm12FnkeCwQqF5LeklOu6rAqgfBZqQ==",
"dev": true "dev": true,
"requires": {}
}, },
"postcss-discard-duplicates": { "postcss-discard-duplicates": {
"version": "5.1.0", "version": "5.1.0",
"resolved": "https://registry.npmjs.org/postcss-discard-duplicates/-/postcss-discard-duplicates-5.1.0.tgz", "resolved": "https://registry.npmjs.org/postcss-discard-duplicates/-/postcss-discard-duplicates-5.1.0.tgz",
"integrity": "sha512-zmX3IoSI2aoenxHV6C7plngHWWhUOV3sP1T8y2ifzxzbtnuhk1EdPwm0S1bIUNaJ2eNbWeGLEwzw8huPD67aQw==", "integrity": "sha512-zmX3IoSI2aoenxHV6C7plngHWWhUOV3sP1T8y2ifzxzbtnuhk1EdPwm0S1bIUNaJ2eNbWeGLEwzw8huPD67aQw==",
"dev": true "dev": true,
"requires": {}
}, },
"postcss-discard-empty": { "postcss-discard-empty": {
"version": "5.1.1", "version": "5.1.1",
"resolved": "https://registry.npmjs.org/postcss-discard-empty/-/postcss-discard-empty-5.1.1.tgz", "resolved": "https://registry.npmjs.org/postcss-discard-empty/-/postcss-discard-empty-5.1.1.tgz",
"integrity": "sha512-zPz4WljiSuLWsI0ir4Mcnr4qQQ5e1Ukc3i7UfE2XcrwKK2LIPIqE5jxMRxO6GbI3cv//ztXDsXwEWT3BHOGh3A==", "integrity": "sha512-zPz4WljiSuLWsI0ir4Mcnr4qQQ5e1Ukc3i7UfE2XcrwKK2LIPIqE5jxMRxO6GbI3cv//ztXDsXwEWT3BHOGh3A==",
"dev": true "dev": true,
"requires": {}
}, },
"postcss-discard-overridden": { "postcss-discard-overridden": {
"version": "5.1.0", "version": "5.1.0",
"resolved": "https://registry.npmjs.org/postcss-discard-overridden/-/postcss-discard-overridden-5.1.0.tgz", "resolved": "https://registry.npmjs.org/postcss-discard-overridden/-/postcss-discard-overridden-5.1.0.tgz",
"integrity": "sha512-21nOL7RqWR1kasIVdKs8HNqQJhFxLsyRfAnUDm4Fe4t4mCWL9OJiHvlHPjcd8zc5Myu89b/7wZDnOSjFgeWRtw==", "integrity": "sha512-21nOL7RqWR1kasIVdKs8HNqQJhFxLsyRfAnUDm4Fe4t4mCWL9OJiHvlHPjcd8zc5Myu89b/7wZDnOSjFgeWRtw==",
"dev": true "dev": true,
"requires": {}
}, },
"postcss-js": { "postcss-js": {
"version": "3.0.3", "version": "3.0.3",
@ -26851,7 +26901,8 @@
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/postcss-modules-extract-imports/-/postcss-modules-extract-imports-3.0.0.tgz", "resolved": "https://registry.npmjs.org/postcss-modules-extract-imports/-/postcss-modules-extract-imports-3.0.0.tgz",
"integrity": "sha512-bdHleFnP3kZ4NYDhuGlVK+CMrQ/pqUm8bx/oGL93K6gVwiclvX5x0n76fYMKuIGKzlABOy13zsvqjb0f92TEXw==", "integrity": "sha512-bdHleFnP3kZ4NYDhuGlVK+CMrQ/pqUm8bx/oGL93K6gVwiclvX5x0n76fYMKuIGKzlABOy13zsvqjb0f92TEXw==",
"dev": true "dev": true,
"requires": {}
}, },
"postcss-modules-local-by-default": { "postcss-modules-local-by-default": {
"version": "4.0.0", "version": "4.0.0",
@ -26894,7 +26945,8 @@
"version": "5.1.0", "version": "5.1.0",
"resolved": "https://registry.npmjs.org/postcss-normalize-charset/-/postcss-normalize-charset-5.1.0.tgz", "resolved": "https://registry.npmjs.org/postcss-normalize-charset/-/postcss-normalize-charset-5.1.0.tgz",
"integrity": "sha512-mSgUJ+pd/ldRGVx26p2wz9dNZ7ji6Pn8VWBajMXFf8jk7vUoSrZ2lt/wZR7DtlZYKesmZI680qjr2CeFF2fbUg==", "integrity": "sha512-mSgUJ+pd/ldRGVx26p2wz9dNZ7ji6Pn8VWBajMXFf8jk7vUoSrZ2lt/wZR7DtlZYKesmZI680qjr2CeFF2fbUg==",
"dev": true "dev": true,
"requires": {}
}, },
"postcss-normalize-display-values": { "postcss-normalize-display-values": {
"version": "5.1.0", "version": "5.1.0",
@ -27415,13 +27467,13 @@
"react-inspector": { "react-inspector": {
"version": "6.0.2", "version": "6.0.2",
"resolved": "https://registry.npmjs.org/react-inspector/-/react-inspector-6.0.2.tgz", "resolved": "https://registry.npmjs.org/react-inspector/-/react-inspector-6.0.2.tgz",
"integrity": "sha512-x+b7LxhmHXjHoU/VrFAzw5iutsILRoYyDq97EDYdFpPLcvqtEzk4ZSZSQjnFPbr5T57tLXnHcqFYoN1pI6u8uQ==" "integrity": "sha512-x+b7LxhmHXjHoU/VrFAzw5iutsILRoYyDq97EDYdFpPLcvqtEzk4ZSZSQjnFPbr5T57tLXnHcqFYoN1pI6u8uQ==",
"requires": {}
}, },
"react-is": { "react-is": {
"version": "18.2.0", "version": "18.2.0",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz", "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz",
"integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==", "integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w=="
"dev": true
}, },
"react-redux": { "react-redux": {
"version": "7.2.9", "version": "7.2.9",
@ -27608,7 +27660,8 @@
"redux-thunk": { "redux-thunk": {
"version": "2.4.2", "version": "2.4.2",
"resolved": "https://registry.npmjs.org/redux-thunk/-/redux-thunk-2.4.2.tgz", "resolved": "https://registry.npmjs.org/redux-thunk/-/redux-thunk-2.4.2.tgz",
"integrity": "sha512-+P3TjtnP0k/FEjcBL5FZpoovtvrTNT/UXd4/sluaSyrURlSlhLSzEdfsTBW7WsKB6yPvgd7q/iZPICFjW4o57Q==" "integrity": "sha512-+P3TjtnP0k/FEjcBL5FZpoovtvrTNT/UXd4/sluaSyrURlSlhLSzEdfsTBW7WsKB6yPvgd7q/iZPICFjW4o57Q==",
"requires": {}
}, },
"regenerate": { "regenerate": {
"version": "1.4.2", "version": "1.4.2",
@ -27910,7 +27963,8 @@
"version": "2.2.4", "version": "2.2.4",
"resolved": "https://registry.npmjs.org/rollup-plugin-peer-deps-external/-/rollup-plugin-peer-deps-external-2.2.4.tgz", "resolved": "https://registry.npmjs.org/rollup-plugin-peer-deps-external/-/rollup-plugin-peer-deps-external-2.2.4.tgz",
"integrity": "sha512-AWdukIM1+k5JDdAqV/Cxd+nejvno2FVLVeZ74NKggm3Q5s9cbbcOgUPGdbxPi4BXu7xGaZ8HG12F+thImYu/0g==", "integrity": "sha512-AWdukIM1+k5JDdAqV/Cxd+nejvno2FVLVeZ74NKggm3Q5s9cbbcOgUPGdbxPi4BXu7xGaZ8HG12F+thImYu/0g==",
"dev": true "dev": true,
"requires": {}
}, },
"rollup-plugin-postcss": { "rollup-plugin-postcss": {
"version": "4.0.2", "version": "4.0.2",
@ -28559,7 +28613,8 @@
"version": "3.3.1", "version": "3.3.1",
"resolved": "https://registry.npmjs.org/style-loader/-/style-loader-3.3.1.tgz", "resolved": "https://registry.npmjs.org/style-loader/-/style-loader-3.3.1.tgz",
"integrity": "sha512-GPcQ+LDJbrcxHORTRes6Jy2sfvK2kS6hpSfI/fXhPt+spVzxF6LJ1dHLN9zIGmVaaP044YKaIatFaufENRiDoQ==", "integrity": "sha512-GPcQ+LDJbrcxHORTRes6Jy2sfvK2kS6hpSfI/fXhPt+spVzxF6LJ1dHLN9zIGmVaaP044YKaIatFaufENRiDoQ==",
"dev": true "dev": true,
"requires": {}
}, },
"styled-components": { "styled-components": {
"version": "5.3.6", "version": "5.3.6",
@ -28596,7 +28651,8 @@
"styled-jsx": { "styled-jsx": {
"version": "5.0.7", "version": "5.0.7",
"resolved": "https://registry.npmjs.org/styled-jsx/-/styled-jsx-5.0.7.tgz", "resolved": "https://registry.npmjs.org/styled-jsx/-/styled-jsx-5.0.7.tgz",
"integrity": "sha512-b3sUzamS086YLRuvnaDigdAewz1/EFYlHpYBP5mZovKEdQQOIIYq8lApylub3HHZ6xFjV051kkGU7cudJmrXEA==" "integrity": "sha512-b3sUzamS086YLRuvnaDigdAewz1/EFYlHpYBP5mZovKEdQQOIIYq8lApylub3HHZ6xFjV051kkGU7cudJmrXEA==",
"requires": {}
}, },
"stylehacks": { "stylehacks": {
"version": "5.1.1", "version": "5.1.1",
@ -29334,7 +29390,8 @@
"use-sync-external-store": { "use-sync-external-store": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.2.0.tgz", "resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.2.0.tgz",
"integrity": "sha512-eEgnFxGQ1Ife9bzYs6VLi8/4X6CObHMw9Qr9tPY43iKwsPw8xE8+EFsf/2cFZ5S3esXgpWgtSCtLNS41F+sKPA==" "integrity": "sha512-eEgnFxGQ1Ife9bzYs6VLi8/4X6CObHMw9Qr9tPY43iKwsPw8xE8+EFsf/2cFZ5S3esXgpWgtSCtLNS41F+sKPA==",
"requires": {}
}, },
"utf8-byte-length": { "utf8-byte-length": {
"version": "1.0.4", "version": "1.0.4",
@ -29547,7 +29604,8 @@
"version": "1.8.0", "version": "1.8.0",
"resolved": "https://registry.npmjs.org/acorn-import-assertions/-/acorn-import-assertions-1.8.0.tgz", "resolved": "https://registry.npmjs.org/acorn-import-assertions/-/acorn-import-assertions-1.8.0.tgz",
"integrity": "sha512-m7VZ3jwz4eK6A4Vtt8Ew1/mNbP24u0FhdyfA7fSvnJR6LMdfOYnmuIrrJAgrYfYJ10F/otaHTtrtrtmHdMNzEw==", "integrity": "sha512-m7VZ3jwz4eK6A4Vtt8Ew1/mNbP24u0FhdyfA7fSvnJR6LMdfOYnmuIrrJAgrYfYJ10F/otaHTtrtrtmHdMNzEw==",
"dev": true "dev": true,
"requires": {}
}, },
"schema-utils": { "schema-utils": {
"version": "3.1.1", "version": "3.1.1",

View File

@ -82,6 +82,15 @@ const RequestBodyMode = ({ item, collection }) => {
> >
TEXT TEXT
</div> </div>
<div
className="dropdown-item"
onClick={() => {
dropdownTippyRef.current.hide();
onModeChange('sparql');
}}
>
SPARQL
</div>
<div className="label-item font-medium">Other</div> <div className="label-item font-medium">Other</div>
<div <div
className="dropdown-item" className="dropdown-item"

View File

@ -28,17 +28,19 @@ const RequestBody = ({ item, collection }) => {
const onRun = () => dispatch(sendRequest(item, collection.uid)); const onRun = () => dispatch(sendRequest(item, collection.uid));
const onSave = () => dispatch(saveRequest(item.uid, collection.uid)); const onSave = () => dispatch(saveRequest(item.uid, collection.uid));
if (['json', 'xml', 'text'].includes(bodyMode)) { if (['json', 'xml', 'text', 'sparql'].includes(bodyMode)) {
let codeMirrorMode = { let codeMirrorMode = {
json: 'application/ld+json', json: 'application/ld+json',
text: 'application/text', text: 'application/text',
xml: 'application/xml' xml: 'application/xml',
sparql: 'application/sparql-query'
}; };
let bodyContent = { let bodyContent = {
json: body.json, json: body.json,
text: body.text, text: body.text,
xml: body.xml xml: body.xml,
sparql: body.sparql
}; };
return ( return (

View File

@ -2,16 +2,12 @@ import styled from 'styled-components';
const StyledWrapper = styled.div` const StyledWrapper = styled.div`
position: absolute; position: absolute;
height: 100%;
z-index: 1; z-index: 1;
height: 100vh;
background-color: ${(props) => props.theme.requestTabPanel.responseOverlayBg}; background-color: ${(props) => props.theme.requestTabPanel.responseOverlayBg};
div.overlay { div.overlay {
position: absolute; height: 100%;
top: 0;
right: 0;
left: 0;
bottom: 0;
z-index: 9; z-index: 9;
display: flex; display: flex;
flex-direction: column; flex-direction: column;

View File

@ -3,12 +3,12 @@ import { IconSend } from '@tabler/icons';
import StyledWrapper from './StyledWrapper'; import StyledWrapper from './StyledWrapper';
import { isMacOS } from 'utils/common/platform'; import { isMacOS } from 'utils/common/platform';
const isMac = isMacOS();
const sendShortcut = isMac ? 'Cmd + Enter' : 'Ctrl + Enter';
const newShortcut = isMac ? 'Cmd + B' : 'Ctrl + B';
const editEnvShortcut = isMac ? 'Cmd + E' : 'Ctrl + E';
const Placeholder = () => { const Placeholder = () => {
const isMac = isMacOS();
const sendRequestShortcut = isMac ? 'Cmd + Enter' : 'Ctrl + Enter';
const newRequestShortcut = isMac ? 'Cmd + B' : 'Ctrl + B';
const editEnvironmentShortcut = isMac ? 'Cmd + E' : 'Ctrl + E';
return ( return (
<StyledWrapper> <StyledWrapper>
<div className="send-icon flex justify-center" style={{ fontSize: 200 }}> <div className="send-icon flex justify-center" style={{ fontSize: 200 }}>
@ -21,9 +21,9 @@ const Placeholder = () => {
<div className="px-1 py-2">Edit Environments</div> <div className="px-1 py-2">Edit Environments</div>
</div> </div>
<div className="flex flex-1 flex-col px-1"> <div className="flex flex-1 flex-col px-1">
<div className="px-1 py-2">{sendShortcut}</div> <div className="px-1 py-2">{sendRequestShortcut}</div>
<div className="px-1 py-2">{newShortcut}</div> <div className="px-1 py-2">{newRequestShortcut}</div>
<div className="px-1 py-2">{editEnvShortcut}</div> <div className="px-1 py-2">{editEnvironmentShortcut}</div>
</div> </div>
</div> </div>
</StyledWrapper> </StyledWrapper>

View File

@ -45,6 +45,10 @@ const QueryResult = ({ item, collection, data, width, disableRunEventListener, h
return safeStringifyJSON(data); return safeStringifyJSON(data);
} }
if (mode.includes('image')) {
return item.requestSent.url;
}
// final fallback // final fallback
if (typeof data === 'string') { if (typeof data === 'string') {
return data; return data;
@ -103,6 +107,8 @@ const QueryResult = ({ item, collection, data, width, disableRunEventListener, h
className="h-full bg-white" className="h-full bg-white"
/> />
); );
} else if (mode.includes('image')) {
return <img src={item.requestSent.url} alt="image" />;
} }
return <CodeEditor collection={collection} theme={storedTheme} onRun={onRun} value={value} mode={mode} readOnly />; return <CodeEditor collection={collection} theme={storedTheme} onRun={onRun} value={value} mode={mode} readOnly />;

View File

@ -115,7 +115,7 @@ const ResponsePane = ({ rightPaneWidth, item, collection }) => {
</div> </div>
) : null} ) : null}
</div> </div>
<section className={`flex flex-grow ${focusedTab.responsePaneTab === 'response' ? '' : 'mt-4'}`}> <section className={`flex flex-grow relative ${focusedTab.responsePaneTab === 'response' ? '' : 'mt-4'}`}>
{isLoading ? <Overlay item={item} collection={collection} /> : null} {isLoading ? <Overlay item={item} collection={collection} /> : null}
{getTabPanel(focusedTab.responsePaneTab)} {getTabPanel(focusedTab.responsePaneTab)}
</section> </section>

View File

@ -16,6 +16,7 @@ const NewFolder = ({ collection, item, onClose }) => {
}, },
validationSchema: Yup.object({ validationSchema: Yup.object({
folderName: Yup.string() folderName: Yup.string()
.trim()
.min(1, 'must be at least 1 character') .min(1, 'must be at least 1 character')
.required('name is required') .required('name is required')
.test({ .test({
@ -32,7 +33,7 @@ const NewFolder = ({ collection, item, onClose }) => {
onSubmit: (values) => { onSubmit: (values) => {
dispatch(newFolder(values.folderName, collection.uid, item ? item.uid : null)) dispatch(newFolder(values.folderName, collection.uid, item ? item.uid : null))
.then(() => onClose()) .then(() => onClose())
.catch((err) => toast.error(err ? err.message : 'An error occurred while adding the request')); .catch((err) => toast.error(err ? err.message : 'An error occurred while adding the folder'));
} }
}); });

View File

@ -25,13 +25,14 @@ const NewRequest = ({ collection, item, isEphemeral, onClose }) => {
}, },
validationSchema: Yup.object({ validationSchema: Yup.object({
requestName: Yup.string() requestName: Yup.string()
.trim()
.min(1, 'must be at least 1 character') .min(1, 'must be at least 1 character')
.required('name is required') .required('name is required')
.test({ .test({
name: 'requestName', name: 'requestName',
message: `The request names - collection and folder is reserved in bruno`, message: `The request names - collection and folder is reserved in bruno`,
test: (value) => { test: (value) => {
const trimmedValue = value.trim().toLowerCase(); const trimmedValue = value ? value.trim().toLowerCase() : '';
return !['collection', 'folder'].includes(trimmedValue); return !['collection', 'folder'].includes(trimmedValue);
} }
}) })

View File

@ -105,7 +105,7 @@ const Sidebar = () => {
Star Star
</GitHubButton> </GitHubButton>
</div> </div>
<div className="flex flex-grow items-center justify-end text-xs mr-2">v0.22.0</div> <div className="flex flex-grow items-center justify-end text-xs mr-2">v0.23.0</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -14,6 +14,7 @@ const SERVER_RENDERED = typeof navigator === 'undefined' || global['PREVENT_CODE
if (!SERVER_RENDERED) { if (!SERVER_RENDERED) {
require('codemirror/mode/javascript/javascript'); require('codemirror/mode/javascript/javascript');
require('codemirror/mode/xml/xml'); require('codemirror/mode/xml/xml');
require('codemirror/mode/sparql/sparql');
require('codemirror/addon/comment/comment'); require('codemirror/addon/comment/comment');
require('codemirror/addon/dialog/dialog'); require('codemirror/addon/dialog/dialog');
require('codemirror/addon/edit/closebrackets'); require('codemirror/addon/edit/closebrackets');

View File

@ -45,6 +45,8 @@ import {
import { closeAllCollectionTabs } from 'providers/ReduxStore/slices/tabs'; import { closeAllCollectionTabs } from 'providers/ReduxStore/slices/tabs';
import { resolveRequestFilename } from 'utils/common/platform'; import { resolveRequestFilename } from 'utils/common/platform';
import { parseQueryParams, splitOnFirst } from 'utils/url/index';
import { each } from 'lodash';
const PATH_SEPARATOR = path.sep; const PATH_SEPARATOR = path.sep;
@ -588,6 +590,12 @@ export const newHttpRequest = (params) => (dispatch, getState) => {
return reject(new Error('Collection not found')); return reject(new Error('Collection not found'));
} }
const parts = splitOnFirst(requestUrl, '?');
const params = parseQueryParams(parts[1]);
each(params, (urlParam) => {
urlParam.enabled = true;
});
const collectionCopy = cloneDeep(collection); const collectionCopy = cloneDeep(collection);
const item = { const item = {
uid: uuid(), uid: uuid(),
@ -597,11 +605,13 @@ export const newHttpRequest = (params) => (dispatch, getState) => {
method: requestMethod, method: requestMethod,
url: requestUrl, url: requestUrl,
headers: [], headers: [],
params,
body: { body: {
mode: 'none', mode: 'none',
json: null, json: null,
text: null, text: null,
xml: null, xml: null,
sparql: null,
multipartForm: null, multipartForm: null,
formUrlEncoded: null formUrlEncoded: null
} }

View File

@ -286,6 +286,12 @@ export const collectionsSlice = createSlice({
const collection = findCollectionByUid(state.collections, action.payload.collectionUid); const collection = findCollectionByUid(state.collections, action.payload.collectionUid);
if (collection && collection.items && collection.items.length) { if (collection && collection.items && collection.items.length) {
const parts = splitOnFirst(action.payload.requestUrl, '?');
const params = parseQueryParams(parts[1]);
each(params, (urlParam) => {
urlParam.enabled = true;
});
const item = { const item = {
uid: action.payload.uid, uid: action.payload.uid,
name: action.payload.requestName, name: action.payload.requestName,
@ -293,7 +299,7 @@ export const collectionsSlice = createSlice({
request: { request: {
url: action.payload.requestUrl, url: action.payload.requestUrl,
method: action.payload.requestMethod, method: action.payload.requestMethod,
params: [], params,
headers: [], headers: [],
body: { body: {
mode: null, mode: null,
@ -692,6 +698,10 @@ export const collectionsSlice = createSlice({
item.draft.request.body.xml = action.payload.content; item.draft.request.body.xml = action.payload.content;
break; break;
} }
case 'sparql': {
item.draft.request.body.sparql = action.payload.content;
break;
}
case 'formUrlEncoded': { case 'formUrlEncoded': {
item.draft.request.body.formUrlEncoded = action.payload.content; item.draft.request.body.formUrlEncoded = action.payload.content;
break; break;

View File

@ -284,6 +284,7 @@ export const transformCollectionToSaveToExportAsFile = (collection, options = {}
text: si.draft.request.body.text, text: si.draft.request.body.text,
xml: si.draft.request.body.xml, xml: si.draft.request.body.xml,
graphql: si.draft.request.body.graphql, graphql: si.draft.request.body.graphql,
sparql: si.draft.request.body.sparql,
formUrlEncoded: copyFormUrlEncodedParams(si.draft.request.body.formUrlEncoded), formUrlEncoded: copyFormUrlEncodedParams(si.draft.request.body.formUrlEncoded),
multipartForm: copyMultipartFormParams(si.draft.request.body.multipartForm) multipartForm: copyMultipartFormParams(si.draft.request.body.multipartForm)
}, },
@ -316,6 +317,7 @@ export const transformCollectionToSaveToExportAsFile = (collection, options = {}
text: si.request.body.text, text: si.request.body.text,
xml: si.request.body.xml, xml: si.request.body.xml,
graphql: si.request.body.graphql, graphql: si.request.body.graphql,
sparql: si.request.body.sparql,
formUrlEncoded: copyFormUrlEncodedParams(si.request.body.formUrlEncoded), formUrlEncoded: copyFormUrlEncodedParams(si.request.body.formUrlEncoded),
multipartForm: copyMultipartFormParams(si.request.body.multipartForm) multipartForm: copyMultipartFormParams(si.request.body.multipartForm)
}, },
@ -459,6 +461,10 @@ export const humanizeRequestBodyMode = (mode) => {
label = 'XML'; label = 'XML';
break; break;
} }
case 'sparql': {
label = 'SPARQL';
break;
}
case 'formUrlEncoded': { case 'formUrlEncoded': {
label = 'Form URL Encoded'; label = 'Form URL Encoded';
break; break;

View File

@ -60,6 +60,8 @@ export const getCodeMirrorModeBasedOnContentType = (contentType) => {
return 'application/xml'; return 'application/xml';
} else if (contentType.includes('yaml')) { } else if (contentType.includes('yaml')) {
return 'application/yaml'; return 'application/yaml';
} else if (contentType.includes('image')) {
return 'application/image';
} else { } else {
return 'application/text'; return 'application/text';
} }

View File

@ -1,3 +1,5 @@
import { safeStringifyJSON } from 'utils/common';
export const sendNetworkRequest = async (item, collection, environment, collectionVariables) => { export const sendNetworkRequest = async (item, collection, environment, collectionVariables) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (['http-request', 'graphql-request'].includes(item.type)) { if (['http-request', 'graphql-request'].includes(item.type)) {
@ -7,7 +9,7 @@ export const sendNetworkRequest = async (item, collection, environment, collecti
state: 'success', state: 'success',
data: response.data, data: response.data,
headers: Object.entries(response.headers), headers: Object.entries(response.headers),
size: response.headers['content-length'] || 0, size: getResponseSize(response),
status: response.status, status: response.status,
statusText: response.statusText, statusText: response.statusText,
duration: response.duration duration: response.duration
@ -29,6 +31,10 @@ const sendHttpRequest = async (item, collection, environment, collectionVariable
}); });
}; };
const getResponseSize = (response) => {
return response.headers['content-length'] || Buffer.byteLength(safeStringifyJSON(response.data)) || 0;
};
export const fetchGqlSchema = async (endpoint, environment, request, collection) => { export const fetchGqlSchema = async (endpoint, environment, request, collection) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const { ipcRenderer } = window; const { ipcRenderer } = window;

View File

@ -25,7 +25,7 @@
], ],
"dependencies": { "dependencies": {
"@usebruno/js": "0.8.0", "@usebruno/js": "0.8.0",
"@usebruno/lang": "0.6.0", "@usebruno/lang": "0.8.0",
"axios": "^1.5.1", "axios": "^1.5.1",
"chai": "^4.3.7", "chai": "^4.3.7",
"chalk": "^3.0.0", "chalk": "^3.0.0",

View File

@ -1,5 +1,5 @@
{ {
"version": "v0.22.0", "version": "v0.23.0",
"name": "bruno", "name": "bruno",
"description": "Opensource API Client for Exploring and Testing APIs", "description": "Opensource API Client for Exploring and Testing APIs",
"homepage": "https://www.usebruno.com", "homepage": "https://www.usebruno.com",
@ -15,11 +15,12 @@
}, },
"dependencies": { "dependencies": {
"@usebruno/js": "0.8.0", "@usebruno/js": "0.8.0",
"@usebruno/lang": "0.6.0", "@usebruno/lang": "0.8.0",
"@usebruno/schema": "0.5.0", "@usebruno/schema": "0.5.0",
"about-window": "^1.15.2", "about-window": "^1.15.2",
"axios": "^1.5.1", "axios": "^1.5.1",
"chai": "^4.3.7", "chai": "^4.3.7",
"chai-string": "^1.5.0",
"chokidar": "^3.5.3", "chokidar": "^3.5.3",
"decomment": "^0.9.5", "decomment": "^0.9.5",
"dotenv": "^16.0.3", "dotenv": "^16.0.3",

View File

@ -23,9 +23,9 @@ function makeAxiosInstance() {
return response; return response;
}, },
(error) => { (error) => {
const end = Date.now();
const start = error.config.headers['request-start-time'];
if (error.response) { if (error.response) {
const end = Date.now();
const start = error.config.headers['request-start-time'];
error.response.headers['request-duration'] = end - start; error.response.headers['request-duration'] = end - start;
} }
return Promise.reject(error); return Promise.reject(error);

View File

@ -75,7 +75,7 @@ const getSize = (data) => {
} }
if (typeof data === 'object') { if (typeof data === 'object') {
return Buffer.byteLength(JSON.stringify(data), 'utf8'); return Buffer.byteLength(safeStringifyJSON(data), 'utf8');
} }
return 0; return 0;
@ -487,7 +487,8 @@ const registerNetworkIpc = (mainWindow) => {
ipcMain.handle('fetch-gql-schema', async (event, endpoint, environment, request, collection) => { ipcMain.handle('fetch-gql-schema', async (event, endpoint, environment, request, collection) => {
try { try {
const envVars = getEnvVars(environment); const envVars = getEnvVars(environment);
const preparedRequest = prepareGqlIntrospectionRequest(endpoint, envVars, request); const collectionRoot = get(collection, 'root', {});
const preparedRequest = prepareGqlIntrospectionRequest(endpoint, envVars, request, collectionRoot);
if (!preferences.isTlsVerification()) { if (!preferences.isTlsVerification()) {
request.httpsAgent = new https.Agent({ request.httpsAgent = new https.Agent({

View File

@ -1,15 +1,14 @@
const Handlebars = require('handlebars'); const Handlebars = require('handlebars');
const { getIntrospectionQuery } = require('graphql'); const { getIntrospectionQuery } = require('graphql');
const { get } = require('lodash'); const { setAuthHeaders } = require('./prepare-request');
const prepareGqlIntrospectionRequest = (endpoint, envVars, request) => { const prepareGqlIntrospectionRequest = (endpoint, envVars, request, collectionRoot) => {
if (endpoint && endpoint.length) { if (endpoint && endpoint.length) {
endpoint = Handlebars.compile(endpoint, { noEscape: true })(envVars); endpoint = Handlebars.compile(endpoint, { noEscape: true })(envVars);
} }
const introspectionQuery = getIntrospectionQuery();
const queryParams = { const queryParams = {
query: introspectionQuery query: getIntrospectionQuery()
}; };
let axiosRequest = { let axiosRequest = {
@ -23,20 +22,7 @@ const prepareGqlIntrospectionRequest = (endpoint, envVars, request) => {
data: JSON.stringify(queryParams) data: JSON.stringify(queryParams)
}; };
if (request.auth) { return setAuthHeaders(axiosRequest, request, collectionRoot);
if (request.auth.mode === 'basic') {
axiosRequest.auth = {
username: get(request, 'auth.basic.username'),
password: get(request, 'auth.basic.password')
};
}
if (request.auth.mode === 'bearer') {
axiosRequest.headers.authorization = `Bearer ${get(request, 'auth.bearer.token')}`;
}
}
return axiosRequest;
}; };
const mapHeaders = (headers) => { const mapHeaders = (headers) => {

View File

@ -1,6 +1,41 @@
const { get, each, filter } = require('lodash'); const { get, each, filter } = require('lodash');
const decomment = require('decomment'); const decomment = require('decomment');
// Authentication
// A request can override the collection auth with another auth
// But it cannot override the collection auth with no auth
// We will provide support for disabling the auth via scripting in the future
const setAuthHeaders = (axiosRequest, request, collectionRoot) => {
const collectionAuth = get(collectionRoot, 'request.auth');
if (collectionAuth) {
if (collectionAuth.mode === 'basic') {
axiosRequest.auth = {
username: get(collectionAuth, 'basic.username'),
password: get(collectionAuth, 'basic.password')
};
}
if (collectionAuth.mode === 'bearer') {
axiosRequest.headers['authorization'] = `Bearer ${get(collectionAuth, 'bearer.token')}`;
}
}
if (request.auth) {
if (request.auth.mode === 'basic') {
axiosRequest.auth = {
username: get(request, 'auth.basic.username'),
password: get(request, 'auth.basic.password')
};
}
if (request.auth.mode === 'bearer') {
axiosRequest.headers['authorization'] = `Bearer ${get(request, 'auth.bearer.token')}`;
}
}
return axiosRequest;
};
const prepareRequest = (request, collectionRoot) => { const prepareRequest = (request, collectionRoot) => {
const headers = {}; const headers = {};
let contentTypeDefined = false; let contentTypeDefined = false;
@ -30,36 +65,7 @@ const prepareRequest = (request, collectionRoot) => {
headers: headers headers: headers
}; };
// Authentication axiosRequest = setAuthHeaders(axiosRequest, request, collectionRoot);
// A request can override the collection auth with another auth
// But it cannot override the collection auth with no auth
// We will provide support for disabling the auth via scripting in the future
const collectionAuth = get(collectionRoot, 'request.auth');
if (collectionAuth) {
if (collectionAuth.mode === 'basic') {
axiosRequest.auth = {
username: get(collectionAuth, 'basic.username'),
password: get(collectionAuth, 'basic.password')
};
}
if (collectionAuth.mode === 'bearer') {
axiosRequest.headers['authorization'] = `Bearer ${get(collectionAuth, 'bearer.token')}`;
}
}
if (request.auth) {
if (request.auth.mode === 'basic') {
axiosRequest.auth = {
username: get(request, 'auth.basic.username'),
password: get(request, 'auth.basic.password')
};
}
if (request.auth.mode === 'bearer') {
axiosRequest.headers['authorization'] = `Bearer ${get(request, 'auth.bearer.token')}`;
}
}
if (request.body.mode === 'json') { if (request.body.mode === 'json') {
if (!contentTypeDefined) { if (!contentTypeDefined) {
@ -87,6 +93,13 @@ const prepareRequest = (request, collectionRoot) => {
axiosRequest.data = request.body.xml; axiosRequest.data = request.body.xml;
} }
if (request.body.mode === 'sparql') {
if (!contentTypeDefined) {
axiosRequest.headers['content-type'] = 'application/sparql-query';
}
axiosRequest.data = request.body.sparql;
}
if (request.body.mode === 'formUrlEncoded') { if (request.body.mode === 'formUrlEncoded') {
axiosRequest.headers['content-type'] = 'application/x-www-form-urlencoded'; axiosRequest.headers['content-type'] = 'application/x-www-form-urlencoded';
const params = {}; const params = {};
@ -125,3 +138,4 @@ const prepareRequest = (request, collectionRoot) => {
}; };
module.exports = prepareRequest; module.exports = prepareRequest;
module.exports.setAuthHeaders = setAuthHeaders;

View File

@ -6,6 +6,7 @@ const BrunoRequest = require('../bruno-request');
const { evaluateJsTemplateLiteral, evaluateJsExpression, createResponseParser } = require('../utils'); const { evaluateJsTemplateLiteral, evaluateJsExpression, createResponseParser } = require('../utils');
const { expect } = chai; const { expect } = chai;
chai.use(require('chai-string'));
chai.use(function (chai, utils) { chai.use(function (chai, utils) {
// Custom assertion for checking if a variable is JSON // Custom assertion for checking if a variable is JSON
chai.Assertion.addProperty('json', function () { chai.Assertion.addProperty('json', function () {

View File

@ -1,6 +1,6 @@
{ {
"name": "@usebruno/lang", "name": "@usebruno/lang",
"version": "0.6.0", "version": "0.8.0",
"license": "MIT", "license": "MIT",
"main": "src/index.js", "main": "src/index.js",
"files": [ "files": [
@ -14,6 +14,7 @@
}, },
"dependencies": { "dependencies": {
"arcsecond": "^5.0.0", "arcsecond": "^5.0.0",
"dotenv": "^16.3.1",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"ohm-js": "^16.6.0" "ohm-js": "^16.6.0"
} }

View File

@ -24,7 +24,7 @@ const { outdentString } = require('../../v1/src/utils');
const grammar = ohm.grammar(`Bru { const grammar = ohm.grammar(`Bru {
BruFile = (meta | http | query | headers | auths | bodies | varsandassert | script | tests | docs)* BruFile = (meta | http | query | headers | auths | bodies | varsandassert | script | tests | docs)*
auths = authbasic | authbearer auths = authbasic | authbearer
bodies = bodyjson | bodytext | bodyxml | bodygraphql | bodygraphqlvars | bodyforms | body bodies = bodyjson | bodytext | bodyxml | bodysparql | bodygraphql | bodygraphqlvars | bodyforms | body
bodyforms = bodyformurlencoded | bodymultipart bodyforms = bodyformurlencoded | bodymultipart
nl = "\\r"? "\\n" nl = "\\r"? "\\n"
@ -83,6 +83,7 @@ const grammar = ohm.grammar(`Bru {
bodyjson = "body:json" st* "{" nl* textblock tagend bodyjson = "body:json" st* "{" nl* textblock tagend
bodytext = "body:text" st* "{" nl* textblock tagend bodytext = "body:text" st* "{" nl* textblock tagend
bodyxml = "body:xml" st* "{" nl* textblock tagend bodyxml = "body:xml" st* "{" nl* textblock tagend
bodysparql = "body:sparql" st* "{" nl* textblock tagend
bodygraphql = "body:graphql" st* "{" nl* textblock tagend bodygraphql = "body:graphql" st* "{" nl* textblock tagend
bodygraphqlvars = "body:graphql:vars" st* "{" nl* textblock tagend bodygraphqlvars = "body:graphql:vars" st* "{" nl* textblock tagend
@ -366,6 +367,13 @@ const sem = grammar.createSemantics().addAttribute('ast', {
} }
}; };
}, },
bodysparql(_1, _2, _3, _4, textblock, _5) {
return {
body: {
sparql: outdentString(textblock.sourceString)
}
};
},
bodygraphql(_1, _2, _3, _4, textblock, _5) { bodygraphql(_1, _2, _3, _4, textblock, _5) {
return { return {
body: { body: {

View File

@ -1,80 +1,9 @@
const ohm = require('ohm-js'); const dotenv = require('dotenv');
const _ = require('lodash');
const grammar = ohm.grammar(`Env {
EnvFile = (entry)*
entry = st* key st* "=" st* value st* nl*
key = keychar*
value = valuechar*
keychar = ~(nl | st | nl | "=") any
valuechar = ~nl any
nl = "\\r"? "\\n"
st = " " | "\\t"
}`);
const concatArrays = (objValue, srcValue) => {
if (_.isArray(objValue) && _.isArray(srcValue)) {
return objValue.concat(srcValue);
}
};
const sem = grammar.createSemantics().addAttribute('ast', {
EnvFile(entries) {
return _.reduce(
entries.ast,
(result, item) => {
return _.mergeWith(result, item, concatArrays);
},
{}
);
},
entry(_1, key, _2, _3, _4, value, _5, _6) {
return { [key.ast.trim()]: value.ast.trim() };
},
key(chars) {
return chars.sourceString;
},
value(chars) {
return chars.sourceString;
},
nl(_1, _2) {
return '';
},
st(_) {
return '';
},
_iter(...elements) {
return elements.map((e) => e.ast);
}
});
const parser = (input) => { const parser = (input) => {
const match = grammar.match(input); const buf = Buffer.from(input);
const parsed = dotenv.parse(buf);
if (match.succeeded()) { return parsed;
const ast = sem(match).ast;
return postProcessEntries(ast);
} else {
throw new Error(match.message);
}
}; };
function postProcessEntries(ast) {
const processed = {};
for (const key in ast) {
const value = ast[key];
if (!isNaN(value)) {
processed[key] = parseFloat(value); // Convert to number if it's a valid number
} else if (value.toLowerCase() === 'true' || value.toLowerCase() === 'false') {
processed[key] = value.toLowerCase() === 'true'; // Convert to boolean if it's 'true' or 'false'
} else {
processed[key] = value; // Otherwise, keep it as a string
}
}
return processed;
}
module.exports = parser; module.exports = parser;

View File

@ -125,6 +125,14 @@ ${indentString(body.text)}
${indentString(body.xml)} ${indentString(body.xml)}
} }
`;
}
if (body && body.sparql && body.sparql.length) {
bru += `body:sparql {
${indentString(body.sparql)}
}
`; `;
} }

View File

@ -26,16 +26,25 @@ BEEP=false
`; `;
const expected = { const expected = {
FOO: 'bar', FOO: 'bar',
BAZ: 2, BAZ: '2',
BEEP: false BEEP: 'false'
}; };
const output = parser(input); const output = parser(input);
expect(output).toEqual(expected); expect(output).toEqual(expected);
}); });
test('it should handle leading and trailing whitespace', () => { test('it should not strip leading and trailing whitespace when using quotes', () => {
const input = ` const input = `
SPACE = value SPACE=" value "
`;
const expected = { SPACE: ' value ' };
const output = parser(input);
expect(output).toEqual(expected);
});
test('it should strip leading and trailing whitespace when NOT using quotes', () => {
const input = `
SPACE= value
`; `;
const expected = { SPACE: 'value' }; const expected = { SPACE: 'value' };
const output = parser(input); const output = parser(input);

View File

@ -48,6 +48,13 @@ body:xml {
</xml> </xml>
} }
body:sparql {
SELECT * WHERE {
?subject ?predicate ?object .
}
LIMIT 10
}
body:form-urlencoded { body:form-urlencoded {
apikey: secret apikey: secret
numbers: +91998877665 numbers: +91998877665

View File

@ -57,6 +57,7 @@
"json": "{\n \"hello\": \"world\"\n}", "json": "{\n \"hello\": \"world\"\n}",
"text": "This is a text body", "text": "This is a text body",
"xml": "<xml>\n <name>John</name>\n <age>30</age>\n</xml>", "xml": "<xml>\n <name>John</name>\n <age>30</age>\n</xml>",
"sparql": "SELECT * WHERE {\n ?subject ?predicate ?object .\n}\nLIMIT 10",
"graphql": { "graphql": {
"query": "{\n launchesPast {\n launch_site {\n site_name\n }\n launch_success\n }\n}", "query": "{\n launchesPast {\n launch_site {\n site_name\n }\n launch_success\n }\n}",
"variables": "{\n \"limit\": 5\n}" "variables": "{\n \"limit\": 5\n}"

View File

@ -57,11 +57,12 @@ const graphqlBodySchema = Yup.object({
const requestBodySchema = Yup.object({ const requestBodySchema = Yup.object({
mode: Yup.string() mode: Yup.string()
.oneOf(['none', 'json', 'text', 'xml', 'formUrlEncoded', 'multipartForm', 'graphql']) .oneOf(['none', 'json', 'text', 'xml', 'formUrlEncoded', 'multipartForm', 'graphql', 'sparql'])
.required('mode is required'), .required('mode is required'),
json: Yup.string().nullable(), json: Yup.string().nullable(),
text: Yup.string().nullable(), text: Yup.string().nullable(),
xml: Yup.string().nullable(), xml: Yup.string().nullable(),
sparql: Yup.string().nullable(),
formUrlEncoded: Yup.array().of(keyValueSchema).nullable(), formUrlEncoded: Yup.array().of(keyValueSchema).nullable(),
multipartForm: Yup.array().of(keyValueSchema).nullable(), multipartForm: Yup.array().of(keyValueSchema).nullable(),
graphql: graphqlBodySchema.nullable() graphql: graphqlBodySchema.nullable()