-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathconfig.interface.ts
More file actions
32 lines (30 loc) · 1.41 KB
/
config.interface.ts
File metadata and controls
32 lines (30 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { ParseConfig } from "papaparse";
export interface ImportConfig {
// Enable logging
logging?: boolean;
// Disable the attempt to use "createMany", will instead just use "create" calls
disableCreateMany?: boolean,
// Disable the attempt to use "updateMany", will instead just use "update" calls
disableUpdateMany?: boolean,
// Disable the attempt to use "getMany", will instead just use "getOne" calls
disableGetMany?: boolean,
// Disable "import new" button
disableImportNew?: boolean;
// Disable "import overwrite" button
disableImportOverwrite?: boolean;
// Provide metadata to dataProvider
meta?: any[];
// A function to translate the CSV rows on import
preCommitCallback?: PrecommitCallback;
// A function to handle row errors after import
postCommitCallback?: ErrorCallback;
// Transform rows before anything is sent to dataprovider
transformRows?: (csvRows: any[]) => Promise<any[]>;
// Async function to Validate a row, reject the promise if it's not valid
validateRow?: ValidateRowFunction;
// Any option from the "papaparse" library, for all options see: https://www.papaparse.com/docs#config
parseConfig?: ParseConfig,
};
export type PrecommitCallback = (action: "create" | "overwrite", values: any[]) => Promise<any[]>;
export type ValidateRowFunction = (csvRowItem: any, index?: any, allItems?: any[]) => Promise<void>;
export type ErrorCallback = (error: any) => void;