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
chore: update response original request version (#4555)
Nivedinb81cf87fd657
diff --git a/packages/hoppscotch-common/src/components/http/Response.vue b/packages/hoppscotch-common/src/components/http/Response.vueindex 0869b32d2..466741ca5 100644--- a/packages/hoppscotch-common/src/components/http/Response.vue+++ b/packages/hoppscotch-common/src/components/http/Response.vue@@ -4,6 +4,7 @@<LensesResponseBodyRendererv-if="!loading && hasResponse"v-model:document="doc"+ :is-editable="false"@save-as-example="saveAsExample"/></div>@@ -84,7 +85,7 @@ const onSaveAsExample = () => {} = response.reqconst originalRequest: HoppRESTResponseOriginalRequest = {- v: "1",+ v: "2",method,endpoint,headers,diff --git a/packages/hoppscotch-common/src/components/http/SaveResponseName.vue b/packages/hoppscotch-common/src/components/http/SaveResponseName.vueindex 4ce36e2d5..431be738e 100644--- a/packages/hoppscotch-common/src/components/http/SaveResponseName.vue+++ b/packages/hoppscotch-common/src/components/http/SaveResponseName.vue@@ -47,7 +47,7 @@ const t = useI18n()const props = withDefaults(defineProps<{show: boolean- loadingState: boolean+ loadingState?: booleanmodelValue?: string}>(),{diff --git a/packages/hoppscotch-common/src/components/lenses/ResponseBodyRenderer.vue b/packages/hoppscotch-common/src/components/lenses/ResponseBodyRenderer.vueindex 7a496f109..061cf897b 100644--- a/packages/hoppscotch-common/src/components/lenses/ResponseBodyRenderer.vue+++ b/packages/hoppscotch-common/src/components/lenses/ResponseBodyRenderer.vue@@ -26,7 +26,7 @@:info="`${maybeHeaders.length}`"class="flex flex-1 flex-col">- <LensesHeadersRenderer v-model="maybeHeaders" />+ <LensesHeadersRenderer v-model="maybeHeaders" :is-editable="false" /></HoppSmartTab><HoppSmartTabv-if="!isEditable"diff --git a/packages/hoppscotch-common/src/helpers/import-export/import/openapi.ts b/packages/hoppscotch-common/src/helpers/import-export/import/openapi.tsindex 09159b6bc..4e38ddccd 100644--- a/packages/hoppscotch-common/src/helpers/import-export/import/openapi.ts+++ b/packages/hoppscotch-common/src/helpers/import-export/import/openapi.ts@@ -812,7 +812,7 @@ const convertPathToHoppReqs = (requestVariables: parseOpenAPIVariables((info.parameters as OpenAPIParamsType[] | undefined) ?? []),- v: "1",+ v: "2",}),}),metadata: {diff --git a/packages/hoppscotch-common/src/helpers/import-export/import/postman.ts b/packages/hoppscotch-common/src/helpers/import-export/import/postman.tsindex b3eeef4f9..5872000c8 100644--- a/packages/hoppscotch-common/src/helpers/import-export/import/postman.ts+++ b/packages/hoppscotch-common/src/helpers/import-export/import/postman.ts@@ -30,7 +30,7 @@ import {import { stringArrayJoin } from "~/helpers/functional/array"import { PMRawLanguage } from "~/types/pm-coll-exts"import { IMPORTER_INVALID_FILE_FORMAT } from "."-import { HoppRESTRequestResponses } from "@hoppscotch/data/dist/rest/v/8"+import { HoppRESTRequestResponses } from "@hoppscotch/data"const safeParseJSON = (jsonStr: string) => O.tryCatch(() => JSON.parse(jsonStr))@@ -177,7 +177,7 @@ const getHoppResponses = (requestVariables: getHoppReqVariables(response.originalRequest?.url.variables ?? null),- v: "1" as const,+ v: "2" as const,},}return [response.name, res]diff --git a/packages/hoppscotch-data/src/rest/index.ts b/packages/hoppscotch-data/src/rest/index.tsindex 80c7b02e1..a06c68a95 100644--- a/packages/hoppscotch-data/src/rest/index.ts+++ b/packages/hoppscotch-data/src/rest/index.ts@@ -14,8 +14,8 @@ import V4_VERSION from "./v/4"import V5_VERSION from "./v/5"import V6_VERSION from "./v/6"import V7_VERSION, { HoppRESTHeaders, HoppRESTParams } from "./v/7"-import V8_VERSION, { HoppRESTAuth, HoppRESTRequestResponses } from "./v/8"-import V9_VERSION, { HoppRESTReqBody } from "./v/9"+import V8_VERSION, { HoppRESTAuth } from "./v/8"+import V9_VERSION, { HoppRESTReqBody, HoppRESTRequestResponses } from "./v/9"export * from "./content-types"@@ -46,12 +46,15 @@ export {HoppRESTAuthOAuth2,HoppRESTAuthDigest,PasswordGrantTypeParams,+} from "./v/8"++export {+ FormDataKeyValue,+ HoppRESTReqBody,HoppRESTResponseOriginalRequest,HoppRESTRequestResponse,HoppRESTRequestResponses,-} from "./v/8"--export { FormDataKeyValue, HoppRESTReqBody } from "./v/9"+} from "./v/9"const versionedObject = z.object({// v is a stringified numberdiff --git a/packages/hoppscotch-data/src/rest/v/8.ts b/packages/hoppscotch-data/src/rest/v/8.tsindex 5b34eba5f..6e047cb54 100644--- a/packages/hoppscotch-data/src/rest/v/8.ts+++ b/packages/hoppscotch-data/src/rest/v/8.ts@@ -85,7 +85,7 @@ export const HoppRESTAuth = zexport type HoppRESTAuth = z.infer<typeof HoppRESTAuth>-const ValidCodes = z.union(+export const ValidCodes = z.union(Object.keys(StatusCodes).map((code) => z.literal(parseInt(code))) as [z.ZodLiteral<number>,z.ZodLiteral<number>,@@ -93,7 +93,7 @@ const ValidCodes = z.union(])-const HoppRESTResponseHeaders = z.array(+export const HoppRESTResponseHeaders = z.array(z.object({key: z.string(),value: z.string(),diff --git a/packages/hoppscotch-data/src/rest/v/9.ts b/packages/hoppscotch-data/src/rest/v/9.tsindex 717d4e72f..be20eaf6f 100644--- a/packages/hoppscotch-data/src/rest/v/9.ts+++ b/packages/hoppscotch-data/src/rest/v/9.ts@@ -1,7 +1,14 @@import { defineVersion } from "verzod"import { z } from "zod"-import { V8_SCHEMA } from "./8"+import { HoppRESTRequestVariables } from "./2"+import { HoppRESTHeaders, HoppRESTParams } from "./7"+import {+ HoppRESTAuth,+ HoppRESTResponseHeaders,+ V8_SCHEMA,+ ValidCodes,+} from "./8"export const FormDataKeyValue = z.object({@@ -52,19 +59,78 @@ export const HoppRESTReqBody = z.union([export type HoppRESTReqBody = z.infer<typeof HoppRESTReqBody>+/**+ * The original request that was made to get this response+ * Only the necessary fields are saved+ */+export const HoppRESTResponseOriginalRequest = z.object({+ v: z.literal("2"),+ name: z.string(),+ method: z.string(),+ endpoint: z.string(),+ headers: HoppRESTHeaders,+ params: HoppRESTParams,+ body: HoppRESTReqBody,+ auth: HoppRESTAuth,+ requestVariables: HoppRESTRequestVariables,+})++export type HoppRESTResponseOriginalRequest = z.infer<+ typeof HoppRESTResponseOriginalRequest+>++export const HoppRESTRequestResponse = z.object({+ name: z.string(),+ originalRequest: HoppRESTResponseOriginalRequest,+ status: z.string(),+ code: z.optional(ValidCodes),+ headers: HoppRESTResponseHeaders,+ body: z.string(),+})++export type HoppRESTRequestResponse = z.infer<typeof HoppRESTRequestResponse>++/**+ * The responses saved for a request+ * The key is the name of the response saved by the user+ * The value is the response+ */+export const HoppRESTRequestResponses = z.record(+ z.string(),+ HoppRESTRequestResponse+)++export type HoppRESTRequestResponses = z.infer<typeof HoppRESTRequestResponses>+export const V9_SCHEMA = V8_SCHEMA.extend({v: z.literal("9"),body: HoppRESTReqBody,+ responses: HoppRESTRequestResponses,})export default defineVersion({schema: V9_SCHEMA,initial: false,up(old: z.infer<typeof V8_SCHEMA>) {- // No migration, the new contentType added to each formdata field is optional+ // update the version number of response original request+ const responses = Object.fromEntries(+ Object.entries(old.responses).map(([key, response]) => [+ key,+ {+ ...response,+ originalRequest: {+ ...response.originalRequest,+ v: "2" as const,+ },+ },+ ])+ )++ // No migration for body, the new contentType added to each formdata field is optionalreturn {...old,v: "9" as const,+ responses,}},})