feat: Add basic support for importing products (#8266)
This commit is contained in:
12
packages/core/utils/src/csv/csvtojson.ts
Normal file
12
packages/core/utils/src/csv/csvtojson.ts
Normal 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[]
|
||||
}
|
||||
@@ -1 +1,2 @@
|
||||
export * from "./jsontocsv"
|
||||
export * from "./csvtojson"
|
||||
|
||||
@@ -12,6 +12,7 @@ export const convertJsonToCsv = <T extends object>(
|
||||
expandNestedObjects: true,
|
||||
expandArrayObjects: true,
|
||||
unwindArrays: false,
|
||||
preventCsvInjection: true,
|
||||
emptyFieldValue: "",
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user