feat: save api responses (#4382)

Co-authored-by: jamesgeorge007 <25279263+jamesgeorge007@users.noreply.github.com>
This commit is contained in:
Nivedin
2024-09-30 19:06:53 +05:30
committed by GitHub
parent fdf5bf34ed
commit 58857be650
84 changed files with 3080 additions and 321 deletions

View File

@@ -8,7 +8,10 @@ import {
import { Service } from "dioc"
import { Ref, markRaw } from "vue"
import IconPlusCircle from "~icons/lucide/plus-circle"
import { HoppRESTRequest } from "@hoppscotch/data"
import {
HoppRESTRequest,
HoppRESTResponseOriginalRequest,
} from "@hoppscotch/data"
import {
AggregateEnvironment,
aggregateEnvsWithSecrets$,
@@ -71,8 +74,13 @@ export class EnvironmentInspectorService extends Service implements Inspector {
const currentTab = this.restTabs.currentActiveTab.value
const currentTabRequest =
currentTab.document.type === "request"
? currentTab.document.request
: currentTab.document.response.originalRequest
const environmentVariables = [
...currentTab.document.request.requestVariables,
...currentTabRequest.requestVariables,
...this.aggregateEnvsWithSecrets.value,
]
@@ -180,9 +188,14 @@ export class EnvironmentInspectorService extends Service implements Inspector {
const currentTab = this.restTabs.currentActiveTab.value
const currentTabRequest =
currentTab.document.type === "request"
? currentTab.document.request
: currentTab.document.response.originalRequest
const environmentVariables =
this.filterNonEmptyEnvironmentVariables([
...currentTab.document.request.requestVariables.map((env) => ({
...currentTabRequest.requestVariables.map((env) => ({
...env,
secret: false,
sourceEnv: "RequestVariable",
@@ -244,7 +257,10 @@ export class EnvironmentInspectorService extends Service implements Inspector {
"inspections.environment.add_environment_value"
),
apply: () => {
if (env.sourceEnv === "RequestVariable") {
if (
env.sourceEnv === "RequestVariable" &&
currentTab.document.type === "request"
) {
currentTab.document.optionTabPreference =
"requestVariables"
} else {
@@ -278,7 +294,9 @@ export class EnvironmentInspectorService extends Service implements Inspector {
return newErrors
}
getInspections(req: Readonly<Ref<HoppRESTRequest>>) {
getInspections(
req: Readonly<Ref<HoppRESTRequest | HoppRESTResponseOriginalRequest>>
) {
return computed(() => {
const results: InspectorResult[] = []