feat: support importing HAR ( Http Archive Format ) files (#4307)

* feat: import har files to hoppscotch

* chore: fix some edge cases

* chore: exclude query params from the generated request endpoint

---------

Co-authored-by: jamesgeorge007 <25279263+jamesgeorge007@users.noreply.github.com>
This commit is contained in:
Akash K
2024-08-29 14:33:07 +05:30
committed by GitHub
parent 55c1c31b73
commit 9a86d0c207
4 changed files with 287 additions and 0 deletions

View File

@@ -24,6 +24,7 @@ import {
hoppPostmanImporter,
toTeamsImporter,
hoppOpenAPIImporter,
harImporter,
} from "~/helpers/import-export/import/importers"
import { defineStep } from "~/composables/step-components"
@@ -505,6 +506,38 @@ const HoppGistCollectionsExporter: ImporterOrExporter = {
},
}
const HARImporter: ImporterOrExporter = {
metadata: {
id: "har",
name: "import.from_har",
title: "import.from_har_description",
icon: IconFile,
disabled: false,
applicableTo: ["personal-workspace", "team-workspace"],
},
component: FileSource({
caption: "import.from_file",
acceptedFileTypes: ".har",
onImportFromFile: async (content) => {
const res = await harImporter(content)
if (E.isLeft(res)) {
showImportFailedError()
return
}
handleImportToStore(res.right)
platform.analytics?.logEvent({
type: "HOPP_IMPORT_COLLECTION",
importer: "import.from_har",
platform: "rest",
workspaceType: isTeamWorkspace.value ? "team" : "personal",
})
},
}),
}
const importerModules = computed(() => {
const enabledImporters = [
HoppRESTImporter,
@@ -513,6 +546,7 @@ const importerModules = computed(() => {
HoppPostmanImporter,
HoppInsomniaImporter,
HoppGistImporter,
HARImporter,
]
const isTeams = props.collectionsType.type === "team-collections"