fuse-importer 0.27.0 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/esm/Importer/ImporterWithContext.d.ts +2 -0
- package/lib/esm/Importer/ImporterWithContext.js +51 -13
- package/lib/esm/Importer/Matcher/EnumFieldsMatchers/EnumFieldMatcher/index.js +2 -2
- package/lib/esm/Importer/Matcher/EnumFieldsMatchers/index.js +4 -3
- package/lib/esm/Importer/Matcher/HeaderMatcher/index.js +14 -9
- package/lib/esm/Importer/Matcher/index.js +0 -11
- package/lib/esm/Importer/PreviewFirstTime.js +1 -1
- package/lib/esm/Importer/Review/AppResponseModal.js +2 -2
- package/lib/esm/Importer/Review/ReviewContextProvider.d.ts +8 -6
- package/lib/esm/Importer/Review/ReviewContextProvider.js +72 -195
- package/lib/esm/Importer/Review/ReviewWithContext.js +2 -2
- package/lib/esm/Importer/Stepper/StepperSubmitModal.d.ts +2 -1
- package/lib/esm/Importer/Stepper/StepperSubmitModal.js +4 -2
- package/lib/esm/Importer/Stepper/UnmatchedHeadersModal.js +1 -1
- package/lib/esm/Importer/Stepper/index.js +36 -13
- package/lib/esm/Importer/Uploader/DragAndDropImporter/ImporterDropzone.d.ts +2 -1
- package/lib/esm/Importer/Uploader/DragAndDropImporter/ImporterDropzone.js +15 -64
- package/lib/esm/Importer/Uploader/DragAndDropImporter/ImporterSectionHeader/index.js +2 -2
- package/lib/esm/Importer/Uploader/DragAndDropImporter/index.js +11 -3
- package/lib/esm/Importer/Uploader/HeadersPreview.js +1 -1
- package/lib/esm/Importer/common/Spreadsheet/DataSetContextProvider/index.d.ts +16 -0
- package/lib/esm/Importer/common/Spreadsheet/DataSetContextProvider/index.js +63 -0
- package/lib/esm/Importer/common/Spreadsheet/DuplicateDataContextProvider/index.d.ts +19 -0
- package/lib/esm/Importer/common/Spreadsheet/DuplicateDataContextProvider/index.js +155 -0
- package/lib/esm/Importer/common/Spreadsheet/FilteredDataContextProvider/index.d.ts +29 -0
- package/lib/esm/Importer/common/Spreadsheet/FilteredDataContextProvider/index.js +150 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/filterMethods.d.ts +6 -4
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/filterMethods.js +38 -45
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/hashCalculators.d.ts +7 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/hashCalculators.js +152 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/index.d.ts +7 -30
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/index.js +10 -141
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/useBatchProcessing.d.ts +5 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/useBatchProcessing.js +81 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/useDataSetManipulation.d.ts +5 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/useDataSetManipulation.js +119 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/useSpreadsheetFilter.d.ts +1 -1
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/utils.d.ts +1 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/utils.js +8 -0
- package/lib/esm/Importer/common/Spreadsheet/ValidationContextProvider/index.d.ts +31 -0
- package/lib/esm/Importer/common/Spreadsheet/ValidationContextProvider/index.js +324 -0
- package/lib/esm/Importer/common/Spreadsheet/common/index.js +18 -9
- package/lib/esm/Importer/common/Spreadsheet/common/types.d.ts +2 -3
- package/lib/esm/Importer/common/Spreadsheet/components/FieldHeader.d.ts +0 -2
- package/lib/esm/Importer/common/Spreadsheet/components/FieldHeader.js +26 -11
- package/lib/esm/Importer/common/Spreadsheet/components/FindAndReplace/index.d.ts +6 -0
- package/lib/esm/Importer/common/Spreadsheet/components/FindAndReplace/index.js +88 -0
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetData.js +25 -17
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetRowCheckboxes.js +48 -47
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetRowNumbers.js +3 -3
- package/lib/esm/Importer/common/Spreadsheet/components/fields/SpeadsheetAutocomplete.d.ts +1 -0
- package/lib/esm/Importer/common/Spreadsheet/components/fields/SpeadsheetAutocomplete.js +7 -3
- package/lib/esm/Importer/common/Spreadsheet/components/fields/SpreadsheetInput.d.ts +3 -1
- package/lib/esm/Importer/common/Spreadsheet/components/fields/SpreadsheetInput.js +45 -11
- package/lib/esm/Importer/common/Spreadsheet/components/fields/index.d.ts +12 -5
- package/lib/esm/Importer/common/Spreadsheet/components/fields/index.js +81 -26
- package/lib/esm/Importer/common/Spreadsheet/components/fields/utils.d.ts +11 -0
- package/lib/esm/Importer/common/Spreadsheet/components/fields/utils.js +29 -0
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/index.js +1 -2
- package/lib/esm/Importer/common/Spreadsheet/index.d.ts +0 -1
- package/lib/esm/Importer/common/Spreadsheet/index.js +1 -84
- package/lib/esm/Importer/common/Spreadsheet/styles.d.ts +1 -2
- package/lib/esm/Importer/common/Spreadsheet/styles.js +13 -1
- package/lib/esm/Importer/common/Spreadsheet/transformation/index.d.ts +2 -2
- package/lib/esm/Importer/common/Spreadsheet/transformation/index.js +35 -13
- package/lib/esm/Importer/common/Spreadsheet/transformation/transformators/dateTimeAutoformatUtils.d.ts +5 -0
- package/lib/esm/Importer/common/Spreadsheet/transformation/transformators/dateTimeAutoformatUtils.js +231 -0
- package/lib/esm/Importer/common/Spreadsheet/transformation/transformators/index.d.ts +18 -0
- package/lib/esm/Importer/common/Spreadsheet/transformation/transformators/index.js +179 -0
- package/lib/esm/Importer/common/Spreadsheet/useFieldSorting.d.ts +5 -0
- package/lib/esm/Importer/common/Spreadsheet/useFieldSorting.js +81 -0
- package/lib/esm/Importer/common/Spreadsheet/validation/index.d.ts +5 -3
- package/lib/esm/Importer/common/Spreadsheet/validation/index.js +13 -17
- package/lib/esm/Importer/common/Spreadsheet/validation/validators.d.ts +3 -2
- package/lib/esm/Importer/common/Spreadsheet/validation/validators.js +23 -7
- package/lib/esm/Importer/common/theme.d.ts +1 -0
- package/lib/esm/Importer/contexts/ImporterContextProvider.d.ts +13 -4
- package/lib/esm/Importer/contexts/ImporterContextProvider.js +150 -21
- package/lib/esm/Importer/data/index.d.ts +7 -3
- package/lib/esm/Importer/data/index.js +49 -20
- package/lib/esm/Importer/hooks/useExportDataToFile.d.ts +5 -0
- package/lib/esm/Importer/hooks/useExportDataToFile.js +54 -0
- package/lib/esm/Importer/hooks/useSubmitToServer.d.ts +7 -0
- package/lib/esm/Importer/hooks/useSubmitToServer.js +214 -0
- package/lib/esm/Importer/index.d.ts +4 -3
- package/lib/esm/Importer/index.js +2 -2
- package/lib/esm/common/CircleSpinner.d.ts +1 -0
- package/lib/esm/common/CircleSpinner.js +13 -0
- package/lib/esm/common/ConfirmationModal.js +1 -1
- package/lib/esm/common/EventManagerContextProvider/index.d.ts +22 -0
- package/lib/esm/common/EventManagerContextProvider/index.js +38 -0
- package/lib/esm/common/FileUploadDropzone/ImporterDropzone.d.ts +16 -0
- package/lib/esm/common/FileUploadDropzone/ImporterDropzone.js +143 -0
- package/lib/esm/common/FileUploadDropzone/index.d.ts +1 -0
- package/lib/esm/common/FileUploadDropzone/index.js +1 -0
- package/lib/esm/common/Modal.js +2 -2
- package/lib/esm/common/Table/TableActions/CustomActions/CustomActions.d.ts +1 -0
- package/lib/esm/common/Table/TableActions/CustomActions/CustomActions.js +150 -0
- package/lib/esm/common/Table/TableActions/CustomActions/index.d.ts +1 -0
- package/lib/esm/common/Table/TableActions/CustomActions/index.js +1 -0
- package/lib/esm/common/Table/TableActions/DeleteSelectedRows.js +25 -8
- package/lib/esm/common/Table/TableActions/ExportData.js +5 -3
- package/lib/esm/common/Table/TableActions/FilterByErrors/FilterByErrors.js +41 -10
- package/lib/esm/common/Table/TableActions/RowFilters.js +63 -11
- package/lib/esm/common/Table/TableActions/SearchRows.js +28 -17
- package/lib/esm/common/Table/TableActions/TableActions.js +15 -4
- package/lib/esm/common/Table/TableActions/TableActions.styles.d.ts +1 -0
- package/lib/esm/common/Table/TableActions/TableActions.styles.js +4 -3
- package/lib/esm/common/Table/TableActions/TransformedRecordsCount.d.ts +6 -0
- package/lib/esm/common/Table/TableActions/TransformedRecordsCount.js +71 -0
- package/lib/esm/common/Table/TableActions/ValidationProgress.d.ts +2 -0
- package/lib/esm/common/Table/TableActions/ValidationProgress.js +22 -0
- package/lib/esm/common/Table/TableActions/icons.d.ts +3 -0
- package/lib/esm/common/Table/TableActions/icons.js +3 -0
- package/lib/esm/common/Table/TableActions/useFindAndReplace.d.ts +5 -0
- package/lib/esm/common/Table/TableActions/useFindAndReplace.js +45 -0
- package/lib/esm/common/Table/TableView/TableRows/TableRow.d.ts +1 -1
- package/lib/esm/common/Table/TableView/TableRows/TableRow.js +3 -3
- package/lib/esm/common/Table/TableView/TableRows/index.js +21 -6
- package/lib/esm/common/Table/TableView/index.d.ts +1 -1
- package/lib/esm/common/Table/TableView/index.js +7 -16
- package/lib/esm/common/Table/TableView/types.d.ts +9 -9
- package/lib/esm/common/Table/index.d.ts +2 -1
- package/lib/esm/common/Table/index.js +2 -2
- package/lib/esm/common/Toast.d.ts +42 -3
- package/lib/esm/common/Toast.js +56 -18
- package/lib/esm/common/TooltipProvider.d.ts +2 -0
- package/lib/esm/common/TooltipProvider.js +12 -9
- package/lib/esm/common/buttons.d.ts +5 -1
- package/lib/esm/common/buttons.js +19 -13
- package/lib/esm/common/columnsTransformations.d.ts +1 -0
- package/lib/esm/common/columnsTransformations.js +10 -16
- package/lib/esm/common/columnsValidations.d.ts +0 -26
- package/lib/esm/common/columnsValidations.js +1 -31
- package/lib/esm/common/datePatterns.d.ts +26 -0
- package/lib/esm/common/datePatterns.js +327 -0
- package/lib/esm/common/icons/index.d.ts +4 -0
- package/lib/esm/common/icons/index.js +6 -2
- package/lib/esm/common/index.d.ts +2 -0
- package/lib/esm/common/index.js +2 -0
- package/lib/esm/common/inputs/Autocomplete.js +2 -2
- package/lib/esm/common/inputs/Checkbox.d.ts +2 -1
- package/lib/esm/common/inputs/Checkbox.js +9 -7
- package/lib/esm/common/inputs/SelectMenu.d.ts +2 -1
- package/lib/esm/common/inputs/SelectMenu.js +14 -3
- package/lib/esm/common/inputs/TextInput.js +1 -1
- package/lib/esm/index.d.ts +3 -1
- package/lib/esm/index.js +9 -2
- package/lib/esm/locales/de.d.ts +13 -1
- package/lib/esm/locales/de.js +14 -2
- package/lib/esm/locales/en.d.ts +26 -1
- package/lib/esm/locales/en.js +30 -5
- package/lib/esm/locales/es.d.ts +13 -1
- package/lib/esm/locales/es.js +14 -2
- package/lib/esm/locales/fr.d.ts +13 -1
- package/lib/esm/locales/fr.js +14 -2
- package/lib/esm/styled/theme/colorPalette.d.ts +2 -0
- package/lib/esm/styled/theme/colorPalette.js +1 -0
- package/lib/esm/styled/theme/index.d.ts +1 -0
- package/lib/esm/styled/theme/textCss.js +1 -1
- package/lib/esm/types.d.ts +48 -5
- package/lib/esm/types.js +0 -1
- package/lib/esm/utils/index.d.ts +1 -0
- package/lib/esm/utils/index.js +4 -0
- package/lib/main.js +24 -24
- package/lib/main.js.LICENSE.txt +2 -0
- package/package.json +8 -6
- package/lib/esm/Importer/Stepper/common/getEnumFieldValueMatchingsInitialValue.d.ts +0 -8
- package/lib/esm/Importer/Stepper/common/getEnumFieldValueMatchingsInitialValue.js +0 -33
- package/lib/esm/Importer/common/Spreadsheet/components/ValidationProgress.d.ts +0 -5
- package/lib/esm/Importer/common/Spreadsheet/components/ValidationProgress.js +0 -19
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/EmailInput.d.ts +0 -3
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/EmailInput.js +0 -14
- package/lib/esm/Importer/common/Spreadsheet/hooks.d.ts +0 -34
- package/lib/esm/Importer/common/Spreadsheet/hooks.js +0 -254
- package/lib/esm/Importer/common/Spreadsheet/transformation/transformators.d.ts +0 -8
- package/lib/esm/Importer/common/Spreadsheet/transformation/transformators.js +0 -106
- package/lib/esm/common/Table/TableActions/FilterByErrors/functions.d.ts +0 -11
- package/lib/esm/common/Table/TableActions/FilterByErrors/functions.js +0 -35
- package/lib/esm/common/Table/TableActions/hooks.d.ts +0 -18
- package/lib/esm/common/Table/TableActions/hooks.js +0 -41
- package/lib/esm/common/Table/TableView/CustomScrollbar.d.ts +0 -2
- package/lib/esm/common/Table/TableView/CustomScrollbar.js +0 -34
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { parseDateFromUserInput, parseDateTimeFromUserInput, parseTimeFromDateTimeorTimeInput, } from "./dateTimeAutoformatUtils";
|
|
13
|
+
export var isTransformationNeeded = function (fieldValue, transformedValue) { return ({
|
|
14
|
+
transformationWasNeeded: !!transformedValue
|
|
15
|
+
? fieldValue !== transformedValue
|
|
16
|
+
: false,
|
|
17
|
+
original: fieldValue,
|
|
18
|
+
transformed: fieldValue === transformedValue || transformedValue === undefined
|
|
19
|
+
? null
|
|
20
|
+
: transformedValue,
|
|
21
|
+
}); };
|
|
22
|
+
var isNotANumber = function (fieldValue) {
|
|
23
|
+
return fieldValue === null || fieldValue === undefined || isNaN(fieldValue);
|
|
24
|
+
};
|
|
25
|
+
var isNotAString = function (fieldValue) {
|
|
26
|
+
return !fieldValue || typeof fieldValue !== "string" || fieldValue.trim() === "";
|
|
27
|
+
};
|
|
28
|
+
var stringFieldTransformations = {
|
|
29
|
+
sentence_case: function (fieldValue) {
|
|
30
|
+
var _a, _b;
|
|
31
|
+
if (isNotAString(fieldValue))
|
|
32
|
+
return {
|
|
33
|
+
transformationWasNeeded: false,
|
|
34
|
+
original: fieldValue,
|
|
35
|
+
transformed: null,
|
|
36
|
+
};
|
|
37
|
+
var transformedValue = ((_b = (_a = fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.toLowerCase()) === null || _a === void 0 ? void 0 : _a.charAt(0)) === null || _b === void 0 ? void 0 : _b.toUpperCase()) +
|
|
38
|
+
(fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.slice(1).toLowerCase());
|
|
39
|
+
return isTransformationNeeded(fieldValue, transformedValue);
|
|
40
|
+
},
|
|
41
|
+
capitalize: function (fieldValue) {
|
|
42
|
+
if (isNotAString(fieldValue)) {
|
|
43
|
+
return {
|
|
44
|
+
transformationWasNeeded: false,
|
|
45
|
+
original: fieldValue,
|
|
46
|
+
transformed: null,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
var transformedValue = fieldValue
|
|
50
|
+
.split(" ")
|
|
51
|
+
.map(function (word) { return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase(); })
|
|
52
|
+
.join(" ");
|
|
53
|
+
return isTransformationNeeded(fieldValue, transformedValue);
|
|
54
|
+
},
|
|
55
|
+
uppercase: function (fieldValue) {
|
|
56
|
+
if (isNotAString(fieldValue))
|
|
57
|
+
return {
|
|
58
|
+
transformationWasNeeded: false,
|
|
59
|
+
original: fieldValue,
|
|
60
|
+
transformed: null,
|
|
61
|
+
};
|
|
62
|
+
var transformedValue = fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.toUpperCase();
|
|
63
|
+
return isTransformationNeeded(fieldValue, transformedValue);
|
|
64
|
+
},
|
|
65
|
+
lowercase: function (fieldValue) {
|
|
66
|
+
if (isNotAString(fieldValue))
|
|
67
|
+
return {
|
|
68
|
+
transformationWasNeeded: false,
|
|
69
|
+
original: fieldValue,
|
|
70
|
+
transformed: null,
|
|
71
|
+
};
|
|
72
|
+
var transformedValue = fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.toLowerCase();
|
|
73
|
+
return isTransformationNeeded(fieldValue, transformedValue);
|
|
74
|
+
},
|
|
75
|
+
trim_whitespace: function (fieldValue) {
|
|
76
|
+
if (typeof fieldValue !== "string")
|
|
77
|
+
return {
|
|
78
|
+
transformationWasNeeded: false,
|
|
79
|
+
original: fieldValue,
|
|
80
|
+
transformed: null,
|
|
81
|
+
};
|
|
82
|
+
var transformedValue = fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.trim();
|
|
83
|
+
return isTransformationNeeded(fieldValue, transformedValue);
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
export var datesDateTimesAndTimesTransformations = {
|
|
87
|
+
autoformat: function (fieldValue, _, fieldOptions) {
|
|
88
|
+
if (fieldValue === null || fieldValue === undefined)
|
|
89
|
+
return {
|
|
90
|
+
transformationWasNeeded: false,
|
|
91
|
+
original: fieldValue,
|
|
92
|
+
transformed: null,
|
|
93
|
+
};
|
|
94
|
+
var type = fieldOptions.type, pattern = fieldOptions.pattern;
|
|
95
|
+
var parseFunctions = {
|
|
96
|
+
date: parseDateFromUserInput,
|
|
97
|
+
datetime: parseDateTimeFromUserInput,
|
|
98
|
+
time: parseTimeFromDateTimeorTimeInput,
|
|
99
|
+
};
|
|
100
|
+
var parseFn = parseFunctions[type];
|
|
101
|
+
var dateValue = parseFn(fieldValue);
|
|
102
|
+
var transformedValue = dateValue === null || dateValue === void 0 ? void 0 : dateValue.toFormat(pattern);
|
|
103
|
+
return isTransformationNeeded(fieldValue, transformedValue);
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
var urlTransformations = {
|
|
107
|
+
prefix: function (fieldValue, transformation) {
|
|
108
|
+
var _a;
|
|
109
|
+
var prefixValue = (_a = transformation === null || transformation === void 0 ? void 0 : transformation.options) === null || _a === void 0 ? void 0 : _a.prefix;
|
|
110
|
+
var fieldValueHasPrefix = fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.startsWith(prefixValue);
|
|
111
|
+
if (isNotAString(prefixValue) ||
|
|
112
|
+
isNotAString(fieldValue) ||
|
|
113
|
+
fieldValueHasPrefix)
|
|
114
|
+
return {
|
|
115
|
+
transformationWasNeeded: false,
|
|
116
|
+
original: fieldValue,
|
|
117
|
+
transformed: null,
|
|
118
|
+
};
|
|
119
|
+
var transformedValue = "".concat(prefixValue).concat(fieldValue);
|
|
120
|
+
return isTransformationNeeded(fieldValue, transformedValue);
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
var floatTransformations = {
|
|
124
|
+
number_of_decimals: function (fieldValue, transformation) {
|
|
125
|
+
var _a;
|
|
126
|
+
var numberOfDecimalsValue = Number((_a = transformation === null || transformation === void 0 ? void 0 : transformation.options) === null || _a === void 0 ? void 0 : _a.number_of_decimals);
|
|
127
|
+
if (isNotANumber(numberOfDecimalsValue) || isNotANumber(fieldValue)) {
|
|
128
|
+
return {
|
|
129
|
+
transformationWasNeeded: false,
|
|
130
|
+
original: fieldValue,
|
|
131
|
+
transformed: null,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
var transformedValue = parseFloat(Number(fieldValue).toFixed(numberOfDecimalsValue));
|
|
135
|
+
return isTransformationNeeded(fieldValue, transformedValue);
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
var integerTransformations = {
|
|
139
|
+
round: function (fieldValue) {
|
|
140
|
+
if (fieldValue === "" || isNotANumber(fieldValue)) {
|
|
141
|
+
return {
|
|
142
|
+
transformationWasNeeded: false,
|
|
143
|
+
original: fieldValue,
|
|
144
|
+
transformed: null,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
var typeofFieldValue = typeof fieldValue;
|
|
148
|
+
var roundedValue = Math.round(fieldValue);
|
|
149
|
+
var valueWithCorrectType = typeofFieldValue === "string" ? "".concat(roundedValue) : roundedValue;
|
|
150
|
+
return isTransformationNeeded(fieldValue, valueWithCorrectType);
|
|
151
|
+
},
|
|
152
|
+
floor: function (fieldValue) {
|
|
153
|
+
if (fieldValue === "" || isNotANumber(fieldValue)) {
|
|
154
|
+
return {
|
|
155
|
+
transformationWasNeeded: false,
|
|
156
|
+
original: fieldValue,
|
|
157
|
+
transformed: null,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
var typeofFieldValue = typeof fieldValue;
|
|
161
|
+
var flooredValue = Math.floor(fieldValue);
|
|
162
|
+
var valueWithCorrectType = typeofFieldValue === "string" ? "".concat(flooredValue) : flooredValue;
|
|
163
|
+
return isTransformationNeeded(fieldValue, valueWithCorrectType);
|
|
164
|
+
},
|
|
165
|
+
ceiling: function (fieldValue) {
|
|
166
|
+
if (fieldValue === "" || isNotANumber(fieldValue)) {
|
|
167
|
+
return {
|
|
168
|
+
transformationWasNeeded: false,
|
|
169
|
+
original: fieldValue,
|
|
170
|
+
transformed: null,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
var typeofFieldValue = typeof fieldValue;
|
|
174
|
+
var ceilingValue = Math.ceil(fieldValue);
|
|
175
|
+
var valueWithCorrectType = typeofFieldValue === "string" ? "".concat(ceilingValue) : ceilingValue;
|
|
176
|
+
return isTransformationNeeded(fieldValue, valueWithCorrectType);
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
export var fieldTransformations = __assign(__assign(__assign(__assign(__assign({}, stringFieldTransformations), datesDateTimesAndTimesTransformations), urlTransformations), floatTransformations), integerTransformations);
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { get } from "lodash";
|
|
2
|
+
import { DateTime } from "luxon";
|
|
3
|
+
import { useImporterContext } from "../../contexts/ImporterContextProvider";
|
|
4
|
+
export var useFieldSorting = function () {
|
|
5
|
+
var templateHeaders = useImporterContext().templateHeaders;
|
|
6
|
+
var getDefaultSortCompareFn = function (sortBy) {
|
|
7
|
+
return function (a, b) {
|
|
8
|
+
var aField = get(a, sortBy.field);
|
|
9
|
+
var bField = get(b, sortBy.field);
|
|
10
|
+
var fieldTypes = templateHeaders.reduce(function (acc, header) {
|
|
11
|
+
var type = header.column_type;
|
|
12
|
+
var pattern = header.pattern || null;
|
|
13
|
+
acc[header.internal_key] = { type: type, pattern: pattern };
|
|
14
|
+
return acc;
|
|
15
|
+
}, {});
|
|
16
|
+
var fieldType = fieldTypes[sortBy.field];
|
|
17
|
+
var isAEmpty = aField === undefined || aField === null || aField === "";
|
|
18
|
+
var isBEmpty = bField === undefined || bField === null || bField === "";
|
|
19
|
+
// sort empty values to the end
|
|
20
|
+
if (isAEmpty && isBEmpty) {
|
|
21
|
+
if (a._meta.rowIndex === b._meta.rowIndex)
|
|
22
|
+
return 0;
|
|
23
|
+
return a._meta.rowIndex < b._meta.rowIndex ? -1 : 1;
|
|
24
|
+
}
|
|
25
|
+
if (isAEmpty)
|
|
26
|
+
return 1;
|
|
27
|
+
if (isBEmpty)
|
|
28
|
+
return -1;
|
|
29
|
+
if (fieldType && fieldType.type === "boolean") {
|
|
30
|
+
var aString = aField ? "true" : "false";
|
|
31
|
+
var bString = bField ? "true" : "false";
|
|
32
|
+
if (aString === bString) {
|
|
33
|
+
if (a._meta.rowIndex === b._meta.rowIndex)
|
|
34
|
+
return 0;
|
|
35
|
+
return a._meta.rowIndex < b._meta.rowIndex ? -1 : 1;
|
|
36
|
+
}
|
|
37
|
+
if (aString === "true")
|
|
38
|
+
return sortBy.direction === "asc" ? -1 : 1;
|
|
39
|
+
if (bString === "true")
|
|
40
|
+
return sortBy.direction === "asc" ? 1 : -1;
|
|
41
|
+
}
|
|
42
|
+
else if (fieldType &&
|
|
43
|
+
(fieldType.type === "date" ||
|
|
44
|
+
fieldType.type === "datetime" ||
|
|
45
|
+
fieldType.type === "time")) {
|
|
46
|
+
var aDateTime = aField
|
|
47
|
+
? DateTime.fromFormat(aField, fieldType.pattern)
|
|
48
|
+
: null;
|
|
49
|
+
var bDateTime = bField
|
|
50
|
+
? DateTime.fromFormat(bField, fieldType.pattern)
|
|
51
|
+
: null;
|
|
52
|
+
// sort invalid date values to the end before empty values
|
|
53
|
+
if (aDateTime && !aDateTime.isValid)
|
|
54
|
+
return 1;
|
|
55
|
+
if (bDateTime && !bDateTime.isValid)
|
|
56
|
+
return -1;
|
|
57
|
+
if (aDateTime && bDateTime && aDateTime.equals(bDateTime)) {
|
|
58
|
+
if (a._meta.rowIndex === b._meta.rowIndex)
|
|
59
|
+
return 0;
|
|
60
|
+
return a._meta.rowIndex < b._meta.rowIndex ? -1 : 1;
|
|
61
|
+
}
|
|
62
|
+
if (sortBy.direction === "asc") {
|
|
63
|
+
return (aDateTime === null || aDateTime === void 0 ? void 0 : aDateTime.valueOf()) - (bDateTime === null || bDateTime === void 0 ? void 0 : bDateTime.valueOf());
|
|
64
|
+
}
|
|
65
|
+
return (bDateTime === null || bDateTime === void 0 ? void 0 : bDateTime.valueOf()) - (aDateTime === null || aDateTime === void 0 ? void 0 : aDateTime.valueOf());
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
if (aField === bField) {
|
|
69
|
+
if (a._meta.rowIndex === b._meta.rowIndex)
|
|
70
|
+
return 0;
|
|
71
|
+
return a._meta.rowIndex < b._meta.rowIndex ? -1 : 1;
|
|
72
|
+
}
|
|
73
|
+
if (sortBy.direction === "asc") {
|
|
74
|
+
return aField > bField ? 1 : -1;
|
|
75
|
+
}
|
|
76
|
+
return aField < bField ? 1 : -1;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
return { getDefaultSortCompareFn: getDefaultSortCompareFn };
|
|
81
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MutableRefObject } from "react";
|
|
2
|
+
import { DuplicateValuesCollection, Field, FieldValidation, OnValidateRecord, Record, ValidationErrors } from "../../../../types";
|
|
2
3
|
import { FieldValidator } from "./validators";
|
|
3
4
|
type SelectedValidator = {
|
|
4
5
|
validator: FieldValidation;
|
|
@@ -13,10 +14,11 @@ type ValidateRecordArgs = {
|
|
|
13
14
|
validatorsCache?: SelectedFieldValidators[];
|
|
14
15
|
record: Record;
|
|
15
16
|
fields: Field[];
|
|
16
|
-
|
|
17
|
+
duplicateValues: MutableRefObject<DuplicateValuesCollection>;
|
|
18
|
+
backendErrors?: ValidationErrors;
|
|
17
19
|
};
|
|
18
20
|
export declare function selectValidatorsFor(fields: Field[]): SelectedFieldValidators[];
|
|
19
|
-
export declare function validateRecord({ record, fields,
|
|
21
|
+
export declare function validateRecord({ record, fields, onValidateRecord, validatorsCache, duplicateValues, backendErrors, }: ValidateRecordArgs): Promise<{
|
|
20
22
|
errors?: ValidationErrors;
|
|
21
23
|
warnings?: ValidationErrors;
|
|
22
24
|
}>;
|
|
@@ -89,9 +89,9 @@ function safeCallOnValidateRecord(_a) {
|
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
91
|
function safeCallValidator(_a) {
|
|
92
|
-
var field = _a.field, record = _a.record, validator = _a.validator, validatorFunction = _a.validatorFunction,
|
|
92
|
+
var field = _a.field, record = _a.record, validator = _a.validator, validatorFunction = _a.validatorFunction, duplicateValues = _a.duplicateValues;
|
|
93
93
|
try {
|
|
94
|
-
return validatorFunction(field, record[field.name], validator,
|
|
94
|
+
return validatorFunction(field, record[field.name], validator, duplicateValues);
|
|
95
95
|
}
|
|
96
96
|
catch (e) {
|
|
97
97
|
console.error("Validator ".concat(validator === null || validator === void 0 ? void 0 : validator.validation_type, " for field ").concat(JSON.stringify(field), " and value ").concat(record[field.name], " failed."), e);
|
|
@@ -102,7 +102,7 @@ function mergeErrorsAndWarnings(currentErrors, errors) {
|
|
|
102
102
|
return __assign(__assign({}, currentErrors), { errors: __assign(__assign({}, (currentErrors.errors || {})), errors), warnings: __assign({}, (currentErrors.warnings || {})) });
|
|
103
103
|
}
|
|
104
104
|
function runValidatorsFor(_a) {
|
|
105
|
-
var record = _a.record,
|
|
105
|
+
var record = _a.record, validators = _a.validators, duplicateValues = _a.duplicateValues;
|
|
106
106
|
return validators.reduce(function (currentErrors, _a) {
|
|
107
107
|
var field = _a.field, validators = _a.validators;
|
|
108
108
|
var errors = {};
|
|
@@ -115,8 +115,8 @@ function runValidatorsFor(_a) {
|
|
|
115
115
|
field: field,
|
|
116
116
|
record: record,
|
|
117
117
|
validator: validator,
|
|
118
|
-
data: data,
|
|
119
118
|
validatorFunction: validatorFunction,
|
|
119
|
+
duplicateValues: duplicateValues,
|
|
120
120
|
});
|
|
121
121
|
if (error) {
|
|
122
122
|
errors[field.name] = error;
|
|
@@ -159,29 +159,25 @@ export function selectValidatorsFor(fields) {
|
|
|
159
159
|
});
|
|
160
160
|
}
|
|
161
161
|
export function validateRecord(_a) {
|
|
162
|
-
var
|
|
163
|
-
var record = _a.record, fields = _a.fields, data = _a.data, onValidateRecord = _a.onValidateRecord, validatorsCache = _a.validatorsCache;
|
|
162
|
+
var record = _a.record, fields = _a.fields, onValidateRecord = _a.onValidateRecord, validatorsCache = _a.validatorsCache, duplicateValues = _a.duplicateValues, backendErrors = _a.backendErrors;
|
|
164
163
|
return __awaiter(this, void 0, void 0, function () {
|
|
165
|
-
var
|
|
166
|
-
return __generator(this, function (
|
|
167
|
-
switch (
|
|
164
|
+
var validators, _b, validatorErrors, validatorWarnings, errors, warnings, _c, onValidateRecordErrors, onValidateRecordWarnings;
|
|
165
|
+
return __generator(this, function (_d) {
|
|
166
|
+
switch (_d.label) {
|
|
168
167
|
case 0:
|
|
169
168
|
if (isRecordEmpty(record, fields)) {
|
|
170
169
|
//TODO: Check this logic because this can skip the validation of touched rows because all fields are empty
|
|
171
170
|
return [2 /*return*/, { errors: {}, warnings: {} }];
|
|
172
171
|
}
|
|
173
|
-
|
|
174
|
-
backendErrors = ((_c = record._meta) === null || _c === void 0 ? void 0 : _c.backendErrors) || {};
|
|
175
|
-
hasBackendErrors = Object.keys(backendErrors).length > 0;
|
|
176
|
-
if (!isTouched && hasBackendErrors) {
|
|
172
|
+
if (backendErrors) {
|
|
177
173
|
return [2 /*return*/, { errors: backendErrors, warnings: {} }];
|
|
178
174
|
}
|
|
179
175
|
validators = validatorsCache !== null && validatorsCache !== void 0 ? validatorsCache : selectValidatorsFor(fields);
|
|
180
|
-
|
|
176
|
+
_b = runValidatorsFor({
|
|
181
177
|
record: record,
|
|
182
|
-
data: data,
|
|
183
178
|
validators: validators,
|
|
184
|
-
|
|
179
|
+
duplicateValues: duplicateValues,
|
|
180
|
+
}), validatorErrors = _b.errors, validatorWarnings = _b.warnings;
|
|
185
181
|
errors = ignoreNullOrUndefinedKeyValues(validatorErrors);
|
|
186
182
|
warnings = ignoreNullOrUndefinedKeyValues(validatorWarnings);
|
|
187
183
|
if (!!isNullOrUndefined(onValidateRecord)) return [3 /*break*/, 2];
|
|
@@ -190,7 +186,7 @@ export function validateRecord(_a) {
|
|
|
190
186
|
record: record,
|
|
191
187
|
})];
|
|
192
188
|
case 1:
|
|
193
|
-
|
|
189
|
+
_c = _d.sent(), onValidateRecordErrors = _c.errors, onValidateRecordWarnings = _c.warnings;
|
|
194
190
|
return [2 /*return*/, {
|
|
195
191
|
errors: __assign(__assign({}, errors), onValidateRecordErrors),
|
|
196
192
|
warnings: __assign(__assign({}, warnings), onValidateRecordWarnings),
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { MutableRefObject } from "react";
|
|
2
|
+
import { DuplicateValuesCollection, Field, FieldValidation } from "../../../../types";
|
|
3
|
+
export type FieldValidator = (field: Field, fieldValue: any, validation?: FieldValidation, duplicateValues?: MutableRefObject<DuplicateValuesCollection>, customErrorMessage?: string) => null | string;
|
|
3
4
|
export type FieldValidations = Partial<{
|
|
4
5
|
[key: string]: FieldValidator;
|
|
5
6
|
}>;
|
|
@@ -85,21 +85,37 @@ export var fieldValidations = {
|
|
|
85
85
|
if (!isNullOrUndefined(field.pattern) &&
|
|
86
86
|
!isNullOrUndefined(fieldValue) &&
|
|
87
87
|
!DateTime.fromFormat(fieldValue, field.pattern).isValid) {
|
|
88
|
-
|
|
88
|
+
var randomDate = DateTime.fromISO("1990-01-15T14:35:55.150", {
|
|
89
|
+
zone: "utc",
|
|
90
|
+
});
|
|
91
|
+
var transformedValue = randomDate === null || randomDate === void 0 ? void 0 : randomDate.toFormat(field.pattern);
|
|
92
|
+
var defaultMessage = "".concat(field.label, " must match the pattern ").concat(field.pattern);
|
|
93
|
+
return transformedValue
|
|
94
|
+
? "Must be formatted as \"".concat(field.pattern, "\" (e.g. ").concat(transformedValue, ")")
|
|
95
|
+
: defaultMessage;
|
|
89
96
|
}
|
|
90
97
|
},
|
|
91
|
-
unique_case_sensitive: function (field, fieldValue, validator,
|
|
98
|
+
unique_case_sensitive: function (field, fieldValue, validator, duplicateValues) {
|
|
92
99
|
var _a;
|
|
93
|
-
if (!isNullOrUndefined(fieldValue) &&
|
|
94
|
-
|
|
100
|
+
if (!isNullOrUndefined(fieldValue) &&
|
|
101
|
+
!isNullOrUndefined(duplicateValues.current)) {
|
|
102
|
+
fieldValue = String(fieldValue);
|
|
103
|
+
var isDuplicated = duplicateValues.current[field.name] &&
|
|
104
|
+
duplicateValues.current[field.name][fieldValue] &&
|
|
105
|
+
duplicateValues.current[field.name][fieldValue].length > 1;
|
|
95
106
|
var message = (_a = validator.message) !== null && _a !== void 0 ? _a : "".concat(field.label, " must be unique case sensitive");
|
|
96
107
|
return isDuplicated ? message : undefined;
|
|
97
108
|
}
|
|
98
109
|
},
|
|
99
|
-
unique_case_insensitive: function (field, fieldValue, validator,
|
|
110
|
+
unique_case_insensitive: function (field, fieldValue, validator, duplicateValues) {
|
|
100
111
|
var _a;
|
|
101
|
-
if (!isNullOrUndefined(fieldValue) &&
|
|
102
|
-
|
|
112
|
+
if (!isNullOrUndefined(fieldValue) &&
|
|
113
|
+
!isNullOrUndefined(duplicateValues.current)) {
|
|
114
|
+
fieldValue = String(fieldValue);
|
|
115
|
+
var isDuplicated = duplicateValues.current[field.name] &&
|
|
116
|
+
duplicateValues.current[field.name][fieldValue.toLowerCase()] &&
|
|
117
|
+
duplicateValues.current[field.name][fieldValue.toLowerCase()].length >
|
|
118
|
+
1;
|
|
103
119
|
var message = (_a = validator.message) !== null && _a !== void 0 ? _a : "".concat(field.label, " must be unique case insensitive");
|
|
104
120
|
return isDuplicated ? message : undefined;
|
|
105
121
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import Fuse from "fuse.js";
|
|
2
1
|
import React from "react";
|
|
3
|
-
import { FormatRecord, ImporterOptions, Integration, OnSubmit, OnValidateRecord, Record, TemplateHeader } from "../../types";
|
|
2
|
+
import { CustomAction, FormatRecord, ImporterOptions, Integration, OnSubmit, OnValidateRecord, Record, TemplateHeader } from "../../types";
|
|
4
3
|
import { FuseApi } from "../common/FuseApi";
|
|
5
|
-
export declare const fusejsOptions: Fuse.IFuseOptions<string>;
|
|
6
4
|
export type HeaderMatchings = {
|
|
7
5
|
[templateHeaderLabel: string]: string;
|
|
8
6
|
};
|
|
@@ -25,6 +23,7 @@ export type State = {
|
|
|
25
23
|
initialRecords: Record[];
|
|
26
24
|
enumFieldValueMatchings: EnumFieldValueMatchings;
|
|
27
25
|
templateHeaders: TemplateHeader[];
|
|
26
|
+
userDynamicColumns: string[];
|
|
28
27
|
templateHeaderMatchings: HeaderMatchings;
|
|
29
28
|
uploadedDataHeaders: string[];
|
|
30
29
|
matcherSubstep: number;
|
|
@@ -46,6 +45,7 @@ export type State = {
|
|
|
46
45
|
setCurrentStepIndex: React.Dispatch<number>;
|
|
47
46
|
setEnumFieldValueMatchings: React.Dispatch<React.SetStateAction<EnumFieldValueMatchings>>;
|
|
48
47
|
setUploadedData: React.Dispatch<any[]>;
|
|
48
|
+
setHeadersMappings: React.Dispatch<any[]>;
|
|
49
49
|
setTemplateHeaderMatchings: React.Dispatch<React.SetStateAction<HeaderMatchings>>;
|
|
50
50
|
setPreviewFirstTime: React.Dispatch<boolean>;
|
|
51
51
|
formatRecord: FormatRecord;
|
|
@@ -56,6 +56,10 @@ export type State = {
|
|
|
56
56
|
isUsingManualImport: React.MutableRefObject<boolean>;
|
|
57
57
|
resetImporterWhenUsingManualImport: () => void;
|
|
58
58
|
manualDataImportSelected: () => void;
|
|
59
|
+
customActions: CustomAction[];
|
|
60
|
+
headerMappingsLoaded: boolean;
|
|
61
|
+
valueMappingsLoaded: boolean;
|
|
62
|
+
headersMappings: HeaderMappings[];
|
|
59
63
|
};
|
|
60
64
|
export type Props = {
|
|
61
65
|
templateSlug: string;
|
|
@@ -68,6 +72,11 @@ export type Props = {
|
|
|
68
72
|
formatRecord: FormatRecord;
|
|
69
73
|
onValidateRecord?: OnValidateRecord;
|
|
70
74
|
dynamicColumns: TemplateHeader[] | null;
|
|
75
|
+
customActions: CustomAction[];
|
|
71
76
|
};
|
|
72
|
-
|
|
77
|
+
type HeaderMappings = {
|
|
78
|
+
[key: string]: string;
|
|
79
|
+
};
|
|
80
|
+
export declare const ImporterContextProvider: ({ templateSlug, initialRecords, apiToken, children, options, onSubmit, onClose, formatRecord, onValidateRecord, dynamicColumns, customActions, }: Props) => JSX.Element;
|
|
73
81
|
export declare const useImporterContext: () => State;
|
|
82
|
+
export {};
|