commerce/framework/csv/product/get-all-collections.ts
2021-04-18 14:51:03 -03:00

28 lines
523 B
TypeScript

import api from '../api/product'
interface CollectionEdge {
entityId: string
name: string
path: string
}
interface GetAllCollections {
categories: CollectionEdge[]
}
const getAllCollections = async (): Promise<GetAllCollections> => {
const products = await api.list().then((products) =>
products.map((product) => ({
entityId: product.id,
name: product.name,
path: product.path,
}))
)
return {
categories: products as CollectionEdge[],
}
}
export default getAllCollections