Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia
TypeScript apiapi-clientapi-restapi-testingdeveloper-toolsgraphqlhttphttp-clientpwarestrest-apispatestingtesting-toolstoolsvuevuejswebsocket
fix: sidebar codegen crashing and AWS Signature Auth flow (#4315)
Andrew Bastin519b520913cf
diff --git a/packages/hoppscotch-common/locales/en.json b/packages/hoppscotch-common/locales/en.jsonindex 0733917d6..745b6b3a6 100644--- a/packages/hoppscotch-common/locales/en.json+++ b/packages/hoppscotch-common/locales/en.json@@ -292,7 +292,8 @@"team_name": "Workspace name empty","teams": "You don't belong to any workspaces","tests": "There are no tests for this request",- "access_tokens": "Access tokens are empty"+ "access_tokens": "Access tokens are empty",+ "response": "No response received"},"environment": {"add_to_global": "Add to Global",diff --git a/packages/hoppscotch-common/src/components/graphql/Authorization.vue b/packages/hoppscotch-common/src/components/graphql/Authorization.vueindex 4ab5feadb..560237642 100644--- a/packages/hoppscotch-common/src/components/graphql/Authorization.vue+++ b/packages/hoppscotch-common/src/components/graphql/Authorization.vue@@ -259,6 +259,10 @@ const selectAWSSignatureAuthType = () => {...auth.value,authType: "aws-signature",addTo: "HEADERS",+ accessKey: "",+ secretKey: "",+ region: "",+ serviceName: "",} as HoppGQLAuth}diff --git a/packages/hoppscotch-common/src/components/http/Authorization.vue b/packages/hoppscotch-common/src/components/http/Authorization.vueindex a13f1433d..05c188a54 100644--- a/packages/hoppscotch-common/src/components/http/Authorization.vue+++ b/packages/hoppscotch-common/src/components/http/Authorization.vue@@ -184,6 +184,7 @@ import IconHelpCircle from "~icons/lucide/help-circle"import IconTrash2 from "~icons/lucide/trash-2"import { getDefaultAuthCodeOauthFlowParams } from "~/services/oauth/flows/authCode"+import { HoppRESTAuth, HoppRESTAuthOAuth2 } from "@hoppscotch/data"const t = useI18n()@@ -239,6 +240,10 @@ const selectAWSSignatureAuthType = () => {...auth.value,authType: "aws-signature",addTo: "HEADERS",+ accessKey: "",+ secretKey: "",+ region: "",+ serviceName: "",} as HoppRESTAuth}diff --git a/packages/hoppscotch-common/src/components/http/Codegen.vue b/packages/hoppscotch-common/src/components/http/Codegen.vueindex 9d490640d..d3a25058c 100644--- a/packages/hoppscotch-common/src/components/http/Codegen.vue+++ b/packages/hoppscotch-common/src/components/http/Codegen.vue@@ -135,6 +135,7 @@ import { platform } from "~/platform"import { RESTTabService } from "~/services/tab/rest"import IconCheck from "~icons/lucide/check"import IconWrapText from "~icons/lucide/wrap-text"+import { asyncComputed } from "@vueuse/core"const t = useI18n()@@ -156,7 +157,7 @@ const emit = defineEmits<{(e: "request-code", value: string): void}>()-const requestCode = computed(() => {+const requestCode = asyncComputed(async () => {const aggregateEnvs = getAggregateEnvs()const requestVariables = request.value.requestVariables.map((requestVariable) => {@@ -178,10 +179,19 @@ const requestCode = computed(() => {...aggregateEnvs,],}- const effectiveRequest = getEffectiveRESTRequest(request.value, env, true)++ // Calculating this before to keep the reactivity as asyncComputed will lose+ // reactivity tracking after the await point+ const lang = codegenType.value++ const effectiveRequest = await getEffectiveRESTRequest(+ request.value,+ env,+ true+ )const result = generateCode(- codegenType.value,+ lang,makeRESTRequest({...effectiveRequest,body: resolvesEnvsInBody(effectiveRequest.body, env),diff --git a/packages/hoppscotch-common/src/components/http/ResponseInterface.vue b/packages/hoppscotch-common/src/components/http/ResponseInterface.vueindex 87a3ae1e7..0927b3f8d 100644--- a/packages/hoppscotch-common/src/components/http/ResponseInterface.vue+++ b/packages/hoppscotch-common/src/components/http/ResponseInterface.vue@@ -5,7 +5,7 @@@close="close()"><template #content>- <div class="flex flex-col px-4 flex-1 overflow-y-auto">+ <div v-if="response" class="flex flex-col px-4 flex-1 overflow-y-auto"><div class="flex flex-col"><tippyinteractive@@ -110,6 +110,14 @@</div></div></div>++ <HoppSmartPlaceholder+ v-else+ :src="`/images/states/${colorMode.value}/add_files.svg`"+ :alt="`${t('empty.response')}`"+ :text="`${t('empty.response')}`"+ >+ </HoppSmartPlaceholder></template></HoppSmartSlideOver></template>@@ -134,8 +142,10 @@ import IconWrapText from "~icons/lucide/wrap-text"import jsonToLanguage from "~/helpers/utils/json-to-language"import { watch } from "vue"import { GQLTabService } from "~/services/tab/graphql"+import { useColorMode } from "~/composables/theming"const t = useI18n()+const colorMode = useColorMode()defineProps<{show: boolean@@ -189,7 +199,10 @@ const errorState = ref(false)const interfaceCode = ref("")const setInterfaceCode = async () => {- const res = await jsonToLanguage(selectedInterface.value, response.value)+ const res = await jsonToLanguage(+ selectedInterface.value,+ response.value || "{}"+ ) // to avoid possible errors empty object is passedinterfaceCode.value = res.lines.join("\n")}diff --git a/packages/hoppscotch-common/src/helpers/RequestRunner.ts b/packages/hoppscotch-common/src/helpers/RequestRunner.tsindex 685c6d0f1..6ac2ac8d7 100644--- a/packages/hoppscotch-common/src/helpers/RequestRunner.ts+++ b/packages/hoppscotch-common/src/helpers/RequestRunner.ts@@ -247,7 +247,7 @@ export function runRESTRequest$(combineEnvVariables(finalEnvs))- const effectiveRequest = getEffectiveRESTRequest(finalRequest, {+ const effectiveRequest = await getEffectiveRESTRequest(finalRequest, {id: "env-id",v: 1,name: "Env",@@ -321,7 +321,7 @@ export function runRESTRequest$({name: env.name,v: 1,- id: env.id ?? "",+ id: "id" in env ? env.id : "",variables: updatedRunResult.envs.selected,})diff --git a/packages/hoppscotch-common/src/helpers/utils/EffectiveURL.ts b/packages/hoppscotch-common/src/helpers/utils/EffectiveURL.tsindex 1b1bcaf03..c1cc5a258 100644--- a/packages/hoppscotch-common/src/helpers/utils/EffectiveURL.ts+++ b/packages/hoppscotch-common/src/helpers/utils/EffectiveURL.ts@@ -1,30 +1,32 @@-import * as A from "fp-ts/Array"-import * as E from "fp-ts/Either"-import * as O from "fp-ts/Option"-import * as RA from "fp-ts/ReadonlyArray"-import * as S from "fp-ts/string"-import qs from "qs"-import { flow, pipe } from "fp-ts/function"-import { combineLatest, Observable } from "rxjs"-import { map } from "rxjs/operators"import {+ Environment,FormDataKeyValue,+ HoppRESTAuth,+ HoppRESTHeader,+ HoppRESTHeaders,+ HoppRESTParam,+ HoppRESTParams,HoppRESTReqBody,HoppRESTRequest,- parseTemplateString,parseBodyEnvVariables,- Environment,- HoppRESTHeader,- HoppRESTParam,parseRawKeyValueEntriesE,+ parseTemplateString,parseTemplateStringE,- HoppRESTAuth,- HoppRESTHeaders,} from "@hoppscotch/data"+import { AwsV4Signer } from "aws4fetch"+import * as A from "fp-ts/Array"+import * as E from "fp-ts/Either"+import { flow, pipe } from "fp-ts/function"+import * as O from "fp-ts/Option"+import * as RA from "fp-ts/ReadonlyArray"+import * as S from "fp-ts/string"+import qs from "qs"+import { combineLatest, Observable } from "rxjs"+import { map } from "rxjs/operators"+import { arrayFlatMap, arraySort } from "../functional/array"import { toFormData } from "../functional/formData"import { tupleWithSameKeysToRecord } from "../functional/record"-import { AwsV4Signer } from "aws4fetch"export interface EffectiveHoppRESTRequest extends HoppRESTRequest {/**@@ -33,8 +35,8 @@ export interface EffectiveHoppRESTRequest extends HoppRESTRequest {* This contains path, params and environment variables all applied to it*/effectiveFinalURL: string- effectiveFinalHeaders: { key: string; value: string }[]- effectiveFinalParams: { key: string; value: string }[]+ effectiveFinalHeaders: HoppRESTHeaders+ effectiveFinalParams: HoppRESTParamseffectiveFinalBody: FormData | string | nulleffectiveFinalRequestVariables: { key: string; value: string }[]}@@ -502,6 +504,7 @@ export async function getEffectiveRESTRequest(false,showKeyIfSecret),+ description: x.description,})))@@ -525,6 +528,7 @@ export async function getEffectiveRESTRequest(false,showKeyIfSecret),+ description: x.description,})))