fix: import hopp collection (#2824)
This commit is contained in:
@@ -33,12 +33,7 @@ export default defineImporter({
|
||||
O.chain(
|
||||
flow(
|
||||
makeCollectionsArray,
|
||||
RA.map(
|
||||
flow(
|
||||
O.fromPredicate(isValidCollection),
|
||||
O.map(translateToNewRESTCollection)
|
||||
)
|
||||
),
|
||||
RA.map(validateCollection),
|
||||
O.sequenceArray,
|
||||
O.map(RA.toArray)
|
||||
)
|
||||
@@ -61,6 +56,18 @@ const isValidCollection = (
|
||||
): collection is HoppCollection<HoppRESTRequest> =>
|
||||
isPlainObject(collection) && "v" in collection
|
||||
|
||||
/**
|
||||
* checks if a collection is a valid hoppscotch collection.
|
||||
* else translate it into one.
|
||||
*/
|
||||
const validateCollection = (collection: unknown) => {
|
||||
if (isValidCollection(collection)) {
|
||||
return O.some(collection)
|
||||
} else {
|
||||
return O.some(translateToNewRESTCollection(collection))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* convert single collection object into an array so it can be handled the same as multiple collections
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user