feat(medusa): Align product import and export (#2471)

**What**

Create a data structure that facilitate the addition of new column descriptor for both export and import and ensure that the column name is shared between bother import and export to facilitate the import with an exported file. 

**Tests**

Add an additional integration tests that export a file, update the data, and re import the same file

FIXES CORE-716
FIXES CORE-713
This commit is contained in:
Adrien de Peretti
2022-10-20 14:48:34 +00:00
committed by GitHub
parent 13611e3e53
commit 299c4ae7f5
17 changed files with 1319 additions and 802 deletions
+21 -12
View File
@@ -40,21 +40,30 @@ export abstract class AbstractCsvValidator<TCsvLine, TBuiltLine>
): Promise<boolean | never>
}
export type CsvSchemaColumn<TCsvLine, TBuiltLine> = {
name: string
export type CsvSchemaColumn<
TCsvLine,
TBuiltLine,
NameAsOptional = false
> = (NameAsOptional extends false
? {
name: string
}
: {
name?: string
}) & {
required?: boolean
validator?: AbstractCsvValidator<TCsvLine, TBuiltLine>
} & (
| {
mapTo?: string
transform?: ColumnTransformer<TCsvLine>
}
| {
match?: RegExp
reducer?: ColumnReducer<TCsvLine, TBuiltLine>
transform?: ColumnTransformer<TCsvLine>
}
)
| {
mapTo?: string
transform?: ColumnTransformer<TCsvLine>
}
| {
match?: RegExp
reducer?: ColumnReducer<TCsvLine, TBuiltLine>
transform?: ColumnTransformer<TCsvLine>
}
)
export type ColumnTransformer<TCsvLine> = (
value: string,