import * as TE from "fp-ts/TaskEither" import { StepsOutputList } from "../steps" /** * A common error state to be used when the file formats are not expected */ export const IMPORTER_INVALID_FILE_FORMAT = "importer_invalid_file_format" as const export type HoppImporterError = typeof IMPORTER_INVALID_FILE_FORMAT type HoppImporter = ( stepValues: StepsOutputList ) => TE.TaskEither type HoppImporterApplicableTo = Array< "team-collections" | "my-collections" | "url-import" > /** * Definition for importers */ type HoppImporterDefinition = { /** * the id */ id: string /** * Name of the importer, shown on the Select Importer dropdown */ name: string /** * Icon for importer button */ icon: string /** * Identifier for the importer */ applicableTo: HoppImporterApplicableTo /** * The importer function, It is a Promise because its supposed to be loaded in lazily (dynamic imports ?) */ importer: HoppImporter /** * The steps to fetch information required to run an importer */ steps: Y } /** * Defines a Hoppscotch importer */ export const defineImporter = (input: { id: string name: string icon: string importer: HoppImporter applicableTo: HoppImporterApplicableTo steps: StepType }) => { return >{ ...input, } }