"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "packages/hoppscotch-app/helpers/import-export/import/gist.ts" between
hoppscotch-2.2.1.tar.gz and hoppscotch-3.0.0.tar.gz

About: Hoppscotch is a light-weight, web based API development suite.

gist.ts  (hoppscotch-2.2.1):gist.ts  (hoppscotch-3.0.0)
import IconGithub from "~icons/lucide/github"
import { pipe } from "fp-ts/function" import { pipe } from "fp-ts/function"
import * as TE from "fp-ts/TaskEither" import * as TE from "fp-ts/TaskEither"
import * as TO from "fp-ts/TaskOption" import * as TO from "fp-ts/TaskOption"
import * as O from "fp-ts/Option" import * as O from "fp-ts/Option"
import axios from "axios" import axios from "axios"
import { HoppRESTRequest, HoppCollection } from "@hoppscotch/data" import { HoppRESTRequest, HoppCollection } from "@hoppscotch/data"
import { step } from "../steps" import { step } from "../steps"
import { defineImporter, IMPORTER_INVALID_FILE_FORMAT } from "." import { defineImporter, IMPORTER_INVALID_FILE_FORMAT } from "."
// TODO: Add validation to output // TODO: Add validation to output
const fetchGist = ( const fetchGist = (
url: string url: string
): TO.TaskOption<HoppCollection<HoppRESTRequest>> => ): TO.TaskOption<HoppCollection<HoppRESTRequest>[]> =>
pipe( pipe(
TO.tryCatch(() => TO.tryCatch(() =>
axios.get(`https://api.github.com/gists/${url.split("/").pop()}`, { axios.get(`https://api.github.com/gists/${url.split("/").pop()}`, {
headers: { headers: {
Accept: "application/vnd.github.v3+json", Accept: "application/vnd.github.v3+json",
}, },
}) })
), ),
TO.chain((res) => TO.chain((res) =>
pipe( pipe(
O.tryCatch(() => O.tryCatch(() =>
JSON.parse((Object.values(res.data.files)[0] as any).content) JSON.parse((Object.values(res.data.files)[0] as any).content)
), ),
TO.fromOption TO.fromOption
) )
) )
) )
export default defineImporter({ export default defineImporter({
id: "gist",
name: "import.from_gist", name: "import.from_gist",
icon: "github", icon: IconGithub,
applicableTo: ["my-collections", "team-collections"],
steps: [ steps: [
step({ step({
stepName: "URL_IMPORT", stepName: "URL_IMPORT",
metadata: { metadata: {
caption: "import.from_gist_description", caption: "import.from_gist_description",
placeholder: "import.gist_url", placeholder: "import.gist_url",
}, },
}), }),
] as const, ] as const,
importer: ([content]) => importer: ([content]) =>
 End of changes. 4 change blocks. 
2 lines changed or deleted 5 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)