-
-
- check_circle
-
-
- {{ t("import.json_description") }}
-
-
-
-
-
+
+
+
+
+
+
+
+ check_circle
+
+
+ {{ t("import.json_description") }}
+
+
+
+
+
+
+
+
+
+ check_circle
+
+
+ {{ t("import.gist_description") }}
+
+
+
+
+
+
- {{ enableImportButton }}
@@ -81,7 +104,6 @@
:label="t(`${importer.name}`)"
@click.native="importerType = index"
/>
- ---
-
- {
- readCollectionGist()
- }
- "
- />
diff --git a/packages/hoppscotch-app/components/collections/graphql/ImportExport.vue b/packages/hoppscotch-app/components/collections/graphql/ImportExport.vue
index 749de4c2a..d1698579a 100644
--- a/packages/hoppscotch-app/components/collections/graphql/ImportExport.vue
+++ b/packages/hoppscotch-app/components/collections/graphql/ImportExport.vue
@@ -1,7 +1,7 @@
diff --git a/packages/hoppscotch-app/components/environments/ImportExport.vue b/packages/hoppscotch-app/components/environments/ImportExport.vue
index 359946de6..45e93de87 100644
--- a/packages/hoppscotch-app/components/environments/ImportExport.vue
+++ b/packages/hoppscotch-app/components/environments/ImportExport.vue
@@ -1,7 +1,7 @@
diff --git a/packages/hoppscotch-app/helpers/import-export/import/gist.ts b/packages/hoppscotch-app/helpers/import-export/import/gist.ts
new file mode 100644
index 000000000..6d1029c9e
--- /dev/null
+++ b/packages/hoppscotch-app/helpers/import-export/import/gist.ts
@@ -0,0 +1,41 @@
+import { pipe } from "fp-ts/function"
+import * as TE from "fp-ts/TaskEither"
+import * as E from "fp-ts/Either"
+import { step } from "../steps"
+import { defineImporter, IMPORTER_INVALID_FILE_FORMAT } from "."
+import { translateToNewRESTCollection } from "~/newstore/collections"
+
+export default defineImporter({
+ name: "import.gist",
+ icon: "github",
+ steps: [
+ step({
+ stepName: "URL_IMPORT",
+ metadata: {
+ placeholder: "import.gist_url",
+ },
+ }),
+ ] as const,
+ importer: ([content]) =>
+ pipe(
+ E.tryCatch(
+ async () => {
+ await fetch(
+ `https://api.github.com/gists/${content.split("/").pop()}`,
+ {
+ headers: {
+ Accept: "application/vnd.github.v3+json",
+ },
+ }
+ ).then((files) => {
+ debugger
+ return JSON.parse(Object.values(files)[0].content).map(
+ (coll: any) => translateToNewRESTCollection(coll)
+ )
+ })
+ },
+ () => IMPORTER_INVALID_FILE_FORMAT
+ ),
+ TE.fromEither
+ ),
+})
diff --git a/packages/hoppscotch-app/helpers/import-export/import/hopp.ts b/packages/hoppscotch-app/helpers/import-export/import/hopp.ts
index e0741044f..266c7f2b3 100644
--- a/packages/hoppscotch-app/helpers/import-export/import/hopp.ts
+++ b/packages/hoppscotch-app/helpers/import-export/import/hopp.ts
@@ -10,7 +10,7 @@ export default defineImporter({
icon: "folder-plus",
steps: [
step({
- stepName: "FILE_OR_URL_IMPORT",
+ stepName: "FILE_IMPORT",
metadata: {
acceptedFileTypes: "application/json",
},
diff --git a/packages/hoppscotch-app/helpers/import-export/import/importers.ts b/packages/hoppscotch-app/helpers/import-export/import/importers.ts
index 43c49e686..41c281ab2 100644
--- a/packages/hoppscotch-app/helpers/import-export/import/importers.ts
+++ b/packages/hoppscotch-app/helpers/import-export/import/importers.ts
@@ -2,10 +2,12 @@ import HoppRESTCollImporter from "./hopp"
import OpenAPIImporter from "./openapi"
import PostmanImporter from "./postman"
import InsomniaImporter from "./insomnia"
+import GistImporter from "./gist"
export const RESTCollectionImporters = [
HoppRESTCollImporter,
OpenAPIImporter,
PostmanImporter,
InsomniaImporter,
+ GistImporter,
] as const
diff --git a/packages/hoppscotch-app/helpers/import-export/import/insomnia.ts b/packages/hoppscotch-app/helpers/import-export/import/insomnia.ts
index d96e06549..96f3bb801 100644
--- a/packages/hoppscotch-app/helpers/import-export/import/insomnia.ts
+++ b/packages/hoppscotch-app/helpers/import-export/import/insomnia.ts
@@ -14,7 +14,7 @@ export default defineImporter({
icon: "insomnia",
steps: [
step({
- stepName: "FILE_OR_URL_IMPORT",
+ stepName: "FILE_IMPORT",
metadata: {
acceptedFileTypes: ".json",
},
diff --git a/packages/hoppscotch-app/helpers/import-export/import/openapi.ts b/packages/hoppscotch-app/helpers/import-export/import/openapi.ts
index 8ce706f25..52cf127fa 100644
--- a/packages/hoppscotch-app/helpers/import-export/import/openapi.ts
+++ b/packages/hoppscotch-app/helpers/import-export/import/openapi.ts
@@ -589,7 +589,7 @@ export default defineImporter({
icon: "file",
steps: [
step({
- stepName: "FILE_OR_URL_IMPORT",
+ stepName: "FILE_IMPORT",
metadata: {
acceptedFileTypes: ".json, .yaml, .yml",
},
diff --git a/packages/hoppscotch-app/helpers/import-export/import/postman.ts b/packages/hoppscotch-app/helpers/import-export/import/postman.ts
index a1040e134..bc6b4da6e 100644
--- a/packages/hoppscotch-app/helpers/import-export/import/postman.ts
+++ b/packages/hoppscotch-app/helpers/import-export/import/postman.ts
@@ -183,7 +183,7 @@ export default defineImporter({
icon: "postman",
steps: [
step({
- stepName: "FILE_OR_URL_IMPORT",
+ stepName: "FILE_IMPORT",
metadata: {
acceptedFileTypes: ".json",
},
diff --git a/packages/hoppscotch-app/helpers/import-export/steps.ts b/packages/hoppscotch-app/helpers/import-export/steps.ts
index cc54521c2..6d39bdae1 100644
--- a/packages/hoppscotch-app/helpers/import-export/steps.ts
+++ b/packages/hoppscotch-app/helpers/import-export/steps.ts
@@ -3,16 +3,22 @@
* Add an entry here when you define a step
*/
export type StepDefinition = {
- FILE_OR_URL_IMPORT: {
+ FILE_IMPORT: {
returnType: string
metadata: {
acceptedFileTypes: string
}
- } // String content of the file/url
+ } // String content of the file
TARGET_MY_COLLECTION: {
returnType: number
metadata: never
} // folderPath
+ URL_IMPORT: {
+ returnType: string
+ metadata: {
+ placeholder: string
+ }
+ } // String content of the url
}
/**
diff --git a/packages/hoppscotch-app/locales/en.json b/packages/hoppscotch-app/locales/en.json
index 74bb74ebe..cc858b72c 100644
--- a/packages/hoppscotch-app/locales/en.json
+++ b/packages/hoppscotch-app/locales/en.json
@@ -229,7 +229,8 @@
"collections": "Import collections",
"curl": "Import cURL",
"failed": "Error while importing: format not recognized",
- "from_gist": "Import from Gist",
+ "gist": "Import from Gist",
+ "gist_description": "Import a Gist",
"from_insomnia": "Import from Insomnia",
"from_my_collections": "Import from My Collections",
"from_openapi": "Import from OpenAPI",