Files
hoppscotch/packages/hoppscotch-app/helpers/import-export/import/hopp.ts
2022-01-06 19:35:33 +05:30

21 lines
556 B
TypeScript

import { HoppRESTRequest } from "@hoppscotch/data"
import { pipe } from "fp-ts/function"
import * as TE from "fp-ts/TaskEither"
import * as E from "fp-ts/Either"
import { HoppImporter, IMPORTER_INVALID_FILE_FORMAT } from "."
import {
Collection,
translateToNewRESTCollection,
} from "~/newstore/collections"
const importer: HoppImporter<Collection<HoppRESTRequest>> = (content) =>
pipe(
E.tryCatch(
() => translateToNewRESTCollection(content),
() => IMPORTER_INVALID_FILE_FORMAT
),
TE.fromEither
)
export default importer