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:
1 parent
13611e3e53
commit
299c4ae7f5
17 files changed
+1319
-802
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import { TransactionBaseService } from "./transaction-base-service"
|
||||
import { BatchJobResultError, CreateBatchJobInput } from "../types/batch-job"
|
||||
import { ProductExportBatchJob } from "../strategies/batch-jobs/product"
|
||||
import { ProductExportBatchJob } from "../strategies/batch-jobs/product/types"
|
||||
import { BatchJobService } from "../services"
|
||||
import { BatchJob } from "../models"
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user