diff --git a/package.json b/package.json index 5493f6eb..88795c8d 100644 --- a/package.json +++ b/package.json @@ -21,10 +21,10 @@ ], "dependencies": { "husky": "^7.0.4", - "lint-staged": "^12.1.3" + "lint-staged": "^12.1.4" }, "devDependencies": { - "@commitlint/cli": "^15.0.0", - "@commitlint/config-conventional": "^15.0.0" + "@commitlint/cli": "^16.0.0", + "@commitlint/config-conventional": "^16.0.0" } } diff --git a/packages/codemirror-lang-graphql/package.json b/packages/codemirror-lang-graphql/package.json index 25168b2f..bd4b82c2 100644 --- a/packages/codemirror-lang-graphql/package.json +++ b/packages/codemirror-lang-graphql/package.json @@ -23,8 +23,8 @@ "devDependencies": { "@lezer/generator": "^0.15.0", "mocha": "^9.0.1", - "rollup": "^2.61.1", - "rollup-plugin-dts": "^4.0.1", + "rollup": "^2.62.0", + "rollup-plugin-dts": "^4.1.0", "rollup-plugin-ts": "^2.0.4", "typescript": "^4.5.4" }, diff --git a/packages/hoppscotch-app/assets/scss/styles.scss b/packages/hoppscotch-app/assets/scss/styles.scss index c71d6316..439da74f 100644 --- a/packages/hoppscotch-app/assets/scss/styles.scss +++ b/packages/hoppscotch-app/assets/scss/styles.scss @@ -246,7 +246,7 @@ button { @apply transform; @apply origin-top-left; @apply scale-75; - @apply -translate-y-5; + @apply -translate-y-4; @apply translate-x-1; } diff --git a/packages/hoppscotch-app/components/app/Header.vue b/packages/hoppscotch-app/components/app/Header.vue index bff8d96a..02291762 100644 --- a/packages/hoppscotch-app/components/app/Header.vue +++ b/packages/hoppscotch-app/components/app/Header.vue @@ -85,7 +85,7 @@ svg="user" /> -
+
{{ currentUser.displayName }} diff --git a/packages/hoppscotch-app/components/app/Interceptor.vue b/packages/hoppscotch-app/components/app/Interceptor.vue index 39418609..f9979204 100644 --- a/packages/hoppscotch-app/components/app/Interceptor.vue +++ b/packages/hoppscotch-app/components/app/Interceptor.vue @@ -1,10 +1,10 @@ diff --git a/packages/hoppscotch-app/components/collections/ImportExport.vue b/packages/hoppscotch-app/components/collections/ImportExport.vue index eeb8f918..9f51f6ba 100644 --- a/packages/hoppscotch-app/components/collections/ImportExport.vue +++ b/packages/hoppscotch-app/components/collections/ImportExport.vue @@ -277,6 +277,7 @@ const createCollectionGist = async () => { const fileImported = () => { toast.success(t("state.file_imported").toString()) + hideModal() } const failedImport = () => { @@ -403,6 +404,10 @@ const parsePostmanRequest = ({ headers: [] as { name?: string; type?: string }[], params: [] as { disabled?: boolean }[], bodyParams: [] as { type?: string }[], + body: { + body: "", + contentType: "application/json", + }, rawParams: "", rawInput: false, contentType: "", @@ -418,31 +423,40 @@ const parsePostmanRequest = ({ if (requestObjectUrl) { pwRequest.url = requestObjectUrl[1] pwRequest.path = requestObjectUrl[2] ? requestObjectUrl[2] : "" + } else { + pwRequest.url = request.url.raw } } + pwRequest.method = request.method const itemAuth = request.auth ? request.auth : "" const authType = itemAuth ? itemAuth.type : "" - if (authType === "basic") { - pwRequest.auth = "Basic Auth" - pwRequest.httpUser = - itemAuth.basic[0].key === "username" - ? itemAuth.basic[0].value - : itemAuth.basic[1].value - pwRequest.httpPassword = - itemAuth.basic[0].key === "password" - ? itemAuth.basic[0].value - : itemAuth.basic[1].value - } else if (authType === "oauth2") { - pwRequest.auth = "OAuth 2.0" - pwRequest.bearerToken = - itemAuth.oauth2[0].key === "accessToken" - ? itemAuth.oauth2[0].value - : itemAuth.oauth2[1].value - } else if (authType === "bearer") { - pwRequest.auth = "Bearer Token" - pwRequest.bearerToken = itemAuth.bearer[0].value + + try { + if (authType === "basic") { + pwRequest.auth = "Basic Auth" + pwRequest.httpUser = + itemAuth.basic[0].key === "username" + ? itemAuth.basic[0].value + : itemAuth.basic[1].value + pwRequest.httpPassword = + itemAuth.basic[0].key === "password" + ? itemAuth.basic[0].value + : itemAuth.basic[1].value + } else if (authType === "oauth2") { + pwRequest.auth = "OAuth 2.0" + pwRequest.bearerToken = + itemAuth.oauth2[0].key === "accessToken" + ? itemAuth.oauth2[0].value + : itemAuth.oauth2[1].value + } else if (authType === "bearer") { + pwRequest.auth = "Bearer Token" + pwRequest.bearerToken = itemAuth.bearer[0].value + } + } catch (error) { + console.error(error) } + const requestObjectHeaders = request.header if (requestObjectHeaders) { pwRequest.headers = requestObjectHeaders @@ -470,6 +484,12 @@ const parsePostmanRequest = ({ } else if (request.body.mode === "raw") { pwRequest.rawInput = true pwRequest.rawParams = request.body.raw + try { + const body = JSON.parse(request.body.raw) + pwRequest.body.body = JSON.stringify(body, null, 2) + } catch (error) { + console.error(error) + } } } return translateToNewRequest(pwRequest) diff --git a/packages/hoppscotch-app/components/graphql/RequestOptions.vue b/packages/hoppscotch-app/components/graphql/RequestOptions.vue index b5bfe60f..0417e70a 100644 --- a/packages/hoppscotch-app/components/graphql/RequestOptions.vue +++ b/packages/hoppscotch-app/components/graphql/RequestOptions.vue @@ -323,9 +323,9 @@ const bulkHeaders = ref("") watch(bulkHeaders, () => { try { const transformation = bulkHeaders.value.split("\n").map((item) => ({ - key: item.substring(0, item.indexOf(":")).trim().replace(/^\/\//, ""), + key: item.substring(0, item.indexOf(":")).trim().replace(/^#/, ""), value: item.substring(item.indexOf(":") + 1).trim(), - active: !item.trim().startsWith("//"), + active: !item.trim().startsWith("#"), })) setGQLHeaders(transformation as GQLHeader[]) } catch (e) { @@ -414,8 +414,8 @@ const editBulkHeadersLine = (index: number, item?: GQLHeader | null) => { .reduce((all, header, pIndex) => { const current = index === pIndex && item != null - ? `${item.active ? "" : "//"}${item.key}: ${item.value}` - : `${header.active ? "" : "//"}${header.key}: ${header.value}` + ? `${item.active ? "" : "#"}${item.key}: ${item.value}` + : `${header.active ? "" : "#"}${header.key}: ${header.value}` return [...all, current] }, [] as string[]) .join("\n") diff --git a/packages/hoppscotch-app/components/http/Authorization.vue b/packages/hoppscotch-app/components/http/Authorization.vue index c5bcb8d9..e0a4b496 100644 --- a/packages/hoppscotch-app/components/http/Authorization.vue +++ b/packages/hoppscotch-app/components/http/Authorization.vue @@ -29,6 +29,7 @@ ? 'radio_button_checked' : 'radio_button_unchecked' " + :active="authName === 'None'" @click.native=" () => { authType = 'none' @@ -43,6 +44,7 @@ ? 'radio_button_checked' : 'radio_button_unchecked' " + :active="authName === 'Basic Auth'" @click.native=" () => { authType = 'basic' @@ -57,6 +59,7 @@ ? 'radio_button_checked' : 'radio_button_unchecked' " + :active="authName === 'Bearer'" @click.native=" () => { authType = 'bearer' @@ -71,6 +74,7 @@ ? 'radio_button_checked' : 'radio_button_unchecked' " + :active="authName === 'OAuth 2.0'" @click.native=" () => { authType = 'oauth-2' @@ -85,6 +89,7 @@ ? 'radio_button_checked' : 'radio_button_unchecked' " + :active="authName === 'API key'" @click.native=" () => { authType = 'api-key' @@ -223,6 +228,7 @@ ? 'radio_button_checked' : 'radio_button_unchecked' " + :active="addTo === 'Headers'" :label="'Headers'" @click.native=" () => { @@ -237,6 +243,7 @@ ? 'radio_button_checked' : 'radio_button_unchecked' " + :active="addTo === 'Query params'" :label="'Query params'" @click.native=" () => { diff --git a/packages/hoppscotch-app/components/http/Headers.vue b/packages/hoppscotch-app/components/http/Headers.vue index ed4facaa..8c6c1dae 100644 --- a/packages/hoppscotch-app/components/http/Headers.vue +++ b/packages/hoppscotch-app/components/http/Headers.vue @@ -188,9 +188,9 @@ useCodemirror(bulkEditor, bulkHeaders, { watch(bulkHeaders, () => { try { const transformation = bulkHeaders.value.split("\n").map((item) => ({ - key: item.substring(0, item.indexOf(":")).trim().replace(/^\/\//, ""), + key: item.substring(0, item.indexOf(":")).trim().replace(/^#/, ""), value: item.substring(item.indexOf(":") + 1).trim(), - active: !item.trim().startsWith("//"), + active: !item.trim().startsWith("#"), })) setRESTHeaders(transformation as HoppRESTHeader[]) } catch (e) { @@ -218,14 +218,12 @@ watch( onBeforeUpdate(() => editBulkHeadersLine(-1, null)) const editBulkHeadersLine = (index: number, item?: HoppRESTHeader | null) => { - const headers = headers$.value - - bulkHeaders.value = headers + bulkHeaders.value = headers$.value .reduce((all, header, pIndex) => { const current = index === pIndex && item != null - ? `${item.active ? "" : "//"}${item.key}: ${item.value}` - : `${header.active ? "" : "//"}${header.key}: ${header.value}` + ? `${item.active ? "" : "#"}${item.key}: ${item.value}` + : `${header.active ? "" : "#"}${header.key}: ${header.value}` return [...all, current] }, []) .join("\n") diff --git a/packages/hoppscotch-app/components/http/ImportCurl.vue b/packages/hoppscotch-app/components/http/ImportCurl.vue index 2f922cc1..e9a38c85 100644 --- a/packages/hoppscotch-app/components/http/ImportCurl.vue +++ b/packages/hoppscotch-app/components/http/ImportCurl.vue @@ -84,6 +84,7 @@ const handleImport = () => { const endpoint = origin + pathname const headers: HoppRESTHeader[] = [] const params: HoppRESTParam[] = [] + const body = parsedCurl.body if (parsedCurl.query) { for (const key of Object.keys(parsedCurl.query)) { const val = parsedCurl.query[key]! @@ -114,6 +115,7 @@ const handleImport = () => { }) } } + const method = parsedCurl.method.toUpperCase() setRESTRequest( @@ -131,7 +133,7 @@ const handleImport = () => { }, body: { contentType: "application/json", - body: "", + body, }, }) ) diff --git a/packages/hoppscotch-app/components/http/Parameters.vue b/packages/hoppscotch-app/components/http/Parameters.vue index d137c942..c8d11e74 100644 --- a/packages/hoppscotch-app/components/http/Parameters.vue +++ b/packages/hoppscotch-app/components/http/Parameters.vue @@ -169,9 +169,9 @@ const bulkParams = ref("") watch(bulkParams, () => { try { const transformation = bulkParams.value.split("\n").map((item) => ({ - key: item.substring(0, item.indexOf(":")).trim().replace(/^\/\//, ""), + key: item.substring(0, item.indexOf(":")).trim().replace(/^#/, ""), value: item.substring(item.indexOf(":") + 1).trim(), - active: !item.trim().startsWith("//"), + active: !item.trim().startsWith("#"), })) setRESTParams(transformation as HoppRESTParam[]) } catch (e) { @@ -211,14 +211,12 @@ watch( onBeforeUpdate(() => editBulkParamsLine(-1, null)) const editBulkParamsLine = (index: number, item?: HoppRESTParam | null) => { - const params = params$.value - - bulkParams.value = params + bulkParams.value = params$.value .reduce((all, param, pIndex) => { const current = index === pIndex && item != null - ? `${item.active ? "" : "//"}${item.key}: ${item.value}` - : `${param.active ? "" : "//"}${param.key}: ${param.value}` + ? `${item.active ? "" : "#"}${item.key}: ${item.value}` + : `${param.active ? "" : "#"}${param.key}: ${param.value}` return [...all, current] }, []) .join("\n") diff --git a/packages/hoppscotch-app/components/http/Response.vue b/packages/hoppscotch-app/components/http/Response.vue index 6923f12b..63ee6c21 100644 --- a/packages/hoppscotch-app/components/http/Response.vue +++ b/packages/hoppscotch-app/components/http/Response.vue @@ -1,5 +1,5 @@ - + + + diff --git a/packages/hoppscotch-app/components/smart/EnvInput.vue b/packages/hoppscotch-app/components/smart/EnvInput.vue index 02793c40..063fd7f6 100644 --- a/packages/hoppscotch-app/components/smart/EnvInput.vue +++ b/packages/hoppscotch-app/components/smart/EnvInput.vue @@ -115,6 +115,7 @@ export default defineComponent({ methods: { handlePaste(ev) { + this.handleChange() this.$emit("paste", { event: ev, previousValue: this.internalValue }) }, handleChange() { diff --git a/packages/hoppscotch-app/components/smart/FontSizePicker.vue b/packages/hoppscotch-app/components/smart/FontSizePicker.vue index 9f86c4ac..03b90dd4 100644 --- a/packages/hoppscotch-app/components/smart/FontSizePicker.vue +++ b/packages/hoppscotch-app/components/smart/FontSizePicker.vue @@ -22,10 +22,11 @@ :icon=" size === active ? 'radio_button_checked' : 'radio_button_unchecked' " + :active="size === active" @click.native=" () => { setActiveFont(size) - $refs.fontSize.tippy().hide() + fontSize.tippy().hide() } " /> @@ -34,6 +35,7 @@