refactor: import validate using version 2
This commit is contained in:
@@ -2,11 +2,7 @@ import { pipe, flow } from "fp-ts/function"
|
|||||||
import * as TE from "fp-ts/TaskEither"
|
import * as TE from "fp-ts/TaskEither"
|
||||||
import * as O from "fp-ts/Option"
|
import * as O from "fp-ts/Option"
|
||||||
import * as RA from "fp-ts/ReadonlyArray"
|
import * as RA from "fp-ts/ReadonlyArray"
|
||||||
import {
|
import { translateToNewRESTCollection, HoppCollection } from "@hoppscotch/data"
|
||||||
translateToNewRESTCollection,
|
|
||||||
HoppCollection,
|
|
||||||
HoppRESTRequest,
|
|
||||||
} from "@hoppscotch/data"
|
|
||||||
import { isPlainObject as _isPlainObject } from "lodash-es"
|
import { isPlainObject as _isPlainObject } from "lodash-es"
|
||||||
|
|
||||||
import { IMPORTER_INVALID_FILE_FORMAT } from "."
|
import { IMPORTER_INVALID_FILE_FORMAT } from "."
|
||||||
@@ -33,12 +29,9 @@ const isPlainObject = (value: any): value is object => _isPlainObject(value)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* checks if a collection matches the schema for a hoppscotch collection.
|
* checks if a collection matches the schema for a hoppscotch collection.
|
||||||
* as of now we are only checking if the collection has a "v" key in it.
|
|
||||||
*/
|
*/
|
||||||
const isValidCollection = (
|
const isValidCollection = (collection: unknown): collection is HoppCollection =>
|
||||||
collection: unknown
|
isPlainObject(collection) && "v" in collection && collection.v === 2
|
||||||
): collection is HoppCollection<HoppRESTRequest> =>
|
|
||||||
isPlainObject(collection) && "v" in collection
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* checks if a collection is a valid hoppscotch collection.
|
* checks if a collection is a valid hoppscotch collection.
|
||||||
|
|||||||
Reference in New Issue
Block a user