feat: Add basic support for importing products (#8266)

This commit is contained in:
Stevche Radevski
2024-07-25 11:07:24 +02:00
committed by GitHub
parent a26b7cf253
commit 444a244eab
10 changed files with 520 additions and 115 deletions

View File

@@ -0,0 +1,12 @@
import { csv2json } from "json-2-csv"
export interface ConvertCsvToJsonOptions<T> {}
export const convertCsvToJson = <T extends object>(
data: string,
options?: ConvertCsvToJsonOptions<T>
): T[] => {
return csv2json(data, {
preventCsvInjection: true,
}) as T[]
}

View File

@@ -1 +1,2 @@
export * from "./jsontocsv"
export * from "./csvtojson"

View File

@@ -12,6 +12,7 @@ export const convertJsonToCsv = <T extends object>(
expandNestedObjects: true,
expandArrayObjects: true,
unwindArrays: false,
preventCsvInjection: true,
emptyFieldValue: "",
})
}