fuse-importer 0.24.4 → 0.25.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/README.md +14 -5
- package/lib/esm/Importer/ImporterWithContext.js +1 -1
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider.d.ts +2 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider.js +17 -7
- package/lib/esm/Importer/common/Spreadsheet/components/FieldHeader.d.ts +1 -0
- package/lib/esm/Importer/common/Spreadsheet/components/FieldHeader.js +9 -3
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetData.js +7 -2
- package/lib/esm/Importer/common/Spreadsheet/components/fields/SpeadsheetAutocomplete.js +10 -6
- package/lib/esm/Importer/common/Spreadsheet/components/fields/SpreadsheetInput.d.ts +1 -0
- package/lib/esm/Importer/common/Spreadsheet/components/fields/SpreadsheetInput.js +7 -5
- package/lib/esm/Importer/common/Spreadsheet/components/fields/index.d.ts +4 -2
- package/lib/esm/Importer/common/Spreadsheet/components/fields/index.js +12 -9
- package/lib/esm/Importer/common/Spreadsheet/hooks.d.ts +5 -0
- package/lib/esm/Importer/common/Spreadsheet/hooks.js +53 -20
- package/lib/esm/Importer/common/Spreadsheet/validation/index.d.ts +4 -1
- package/lib/esm/Importer/common/Spreadsheet/validation/index.js +39 -15
- package/lib/esm/Importer/common/theme.d.ts +2 -0
- package/lib/esm/Importer/data/index.js +0 -1
- package/lib/esm/styled/theme/colorPalette.d.ts +4 -0
- package/lib/esm/styled/theme/colorPalette.js +2 -0
- package/lib/esm/styled/theme/index.d.ts +2 -0
- package/lib/esm/types.d.ts +6 -2
- package/lib/main.js +5 -5
- package/package.json +1 -1
|
@@ -60,17 +60,29 @@ var datePatternTypes = ["date", "datetime", "time"];
|
|
|
60
60
|
function safeCallOnValidateRecord(_a) {
|
|
61
61
|
var onValidateRecord = _a.onValidateRecord, record = _a.record;
|
|
62
62
|
return __awaiter(this, void 0, void 0, function () {
|
|
63
|
-
var error_1;
|
|
63
|
+
var result, isNewVersion, mappedResult, errors, warnings, error_1;
|
|
64
64
|
return __generator(this, function (_b) {
|
|
65
65
|
switch (_b.label) {
|
|
66
66
|
case 0:
|
|
67
67
|
_b.trys.push([0, 2, , 3]);
|
|
68
68
|
return [4 /*yield*/, onValidateRecord(record)];
|
|
69
|
-
case 1:
|
|
69
|
+
case 1:
|
|
70
|
+
result = _b.sent();
|
|
71
|
+
isNewVersion = "errors" in result || "warnings" in result;
|
|
72
|
+
mappedResult = isNewVersion
|
|
73
|
+
? result
|
|
74
|
+
: result;
|
|
75
|
+
errors = isNewVersion
|
|
76
|
+
? mappedResult.errors
|
|
77
|
+
: mappedResult;
|
|
78
|
+
warnings = isNewVersion
|
|
79
|
+
? mappedResult.warnings
|
|
80
|
+
: mappedResult;
|
|
81
|
+
return [2 /*return*/, { errors: errors || {}, warnings: warnings || {} }];
|
|
70
82
|
case 2:
|
|
71
83
|
error_1 = _b.sent();
|
|
72
84
|
console.warn("onValidateRecord hook failed with error: ".concat(error_1));
|
|
73
|
-
return [2 /*return*/, {}];
|
|
85
|
+
return [2 /*return*/, { errors: {}, warnings: {} }];
|
|
74
86
|
case 3: return [2 /*return*/];
|
|
75
87
|
}
|
|
76
88
|
});
|
|
@@ -105,7 +117,7 @@ function runValidatorsFor(_a) {
|
|
|
105
117
|
break;
|
|
106
118
|
}
|
|
107
119
|
}
|
|
108
|
-
return __assign(__assign({}, currentErrors), errors);
|
|
120
|
+
return __assign(__assign({}, currentErrors), { errors: __assign(__assign({}, (currentErrors.errors || {})), errors), warnings: __assign({}, (currentErrors.warnings || {})) });
|
|
109
121
|
}, {});
|
|
110
122
|
}
|
|
111
123
|
export function selectValidatorsFor(fields) {
|
|
@@ -144,28 +156,40 @@ export function validateRecord(_a) {
|
|
|
144
156
|
var _b, _c;
|
|
145
157
|
var record = _a.record, fields = _a.fields, data = _a.data, onValidateRecord = _a.onValidateRecord, validatorsCache = _a.validatorsCache;
|
|
146
158
|
return __awaiter(this, void 0, void 0, function () {
|
|
147
|
-
var isTouched, backendErrors, hasBackendErrors, validators, validatorErrors, errors,
|
|
148
|
-
return __generator(this, function (
|
|
149
|
-
switch (
|
|
159
|
+
var isTouched, backendErrors, hasBackendErrors, validators, _d, validatorErrors, validatorWarnings, errors, warnings, _e, onValidateRecordErrors, onValidateRecordWarnings;
|
|
160
|
+
return __generator(this, function (_f) {
|
|
161
|
+
switch (_f.label) {
|
|
150
162
|
case 0:
|
|
151
163
|
if (isRecordEmpty(record, fields)) {
|
|
152
164
|
//TODO: Check this logic because this can skip the validation of touched rows because all fields are empty
|
|
153
|
-
return [2 /*return*/, {}];
|
|
165
|
+
return [2 /*return*/, { errors: {}, warnings: {} }];
|
|
154
166
|
}
|
|
155
167
|
isTouched = (_b = record._meta) === null || _b === void 0 ? void 0 : _b.touched;
|
|
156
168
|
backendErrors = ((_c = record._meta) === null || _c === void 0 ? void 0 : _c.backendErrors) || {};
|
|
157
169
|
hasBackendErrors = Object.keys(backendErrors).length > 0;
|
|
158
170
|
if (!isTouched && hasBackendErrors) {
|
|
159
|
-
return [2 /*return*/, backendErrors];
|
|
171
|
+
return [2 /*return*/, { errors: backendErrors, warnings: {} }];
|
|
160
172
|
}
|
|
161
173
|
validators = validatorsCache !== null && validatorsCache !== void 0 ? validatorsCache : selectValidatorsFor(fields);
|
|
162
|
-
|
|
174
|
+
_d = runValidatorsFor({
|
|
175
|
+
record: record,
|
|
176
|
+
data: data,
|
|
177
|
+
validators: validators,
|
|
178
|
+
}), validatorErrors = _d.errors, validatorWarnings = _d.warnings;
|
|
163
179
|
errors = ignoreNullOrUndefinedKeyValues(validatorErrors);
|
|
164
|
-
|
|
165
|
-
if (
|
|
166
|
-
return [4 /*yield*/, safeCallOnValidateRecord({
|
|
167
|
-
|
|
168
|
-
|
|
180
|
+
warnings = ignoreNullOrUndefinedKeyValues(validatorWarnings);
|
|
181
|
+
if (!!isNullOrUndefined(onValidateRecord)) return [3 /*break*/, 2];
|
|
182
|
+
return [4 /*yield*/, safeCallOnValidateRecord({
|
|
183
|
+
onValidateRecord: onValidateRecord,
|
|
184
|
+
record: record,
|
|
185
|
+
})];
|
|
186
|
+
case 1:
|
|
187
|
+
_e = _f.sent(), onValidateRecordErrors = _e.errors, onValidateRecordWarnings = _e.warnings;
|
|
188
|
+
return [2 /*return*/, {
|
|
189
|
+
errors: __assign(__assign({}, errors), onValidateRecordErrors),
|
|
190
|
+
warnings: __assign(__assign({}, warnings), onValidateRecordWarnings),
|
|
191
|
+
}];
|
|
192
|
+
case 2: return [2 /*return*/, { errors: errors, warnings: warnings }];
|
|
169
193
|
}
|
|
170
194
|
});
|
|
171
195
|
});
|
|
@@ -92,6 +92,8 @@ declare const getCustomTheme: (importerStylePreferences: ImporterStylePreference
|
|
|
92
92
|
orange800: string;
|
|
93
93
|
orange900: string;
|
|
94
94
|
orange1000: string;
|
|
95
|
+
orange1100: string;
|
|
96
|
+
orange1200: string;
|
|
95
97
|
};
|
|
96
98
|
readonly textStyles: {
|
|
97
99
|
h1: import("styled-components").FlattenSimpleInterpolation;
|
|
@@ -116,7 +116,6 @@ export var getReviewDataSet = function (_a) {
|
|
|
116
116
|
name: templateHeader.internal_key,
|
|
117
117
|
type: FieldTypes[templateHeader.column_type] || FieldTypes.string,
|
|
118
118
|
isRequired: templateHeader.required,
|
|
119
|
-
isUnique: templateHeader.unique,
|
|
120
119
|
options: templateHeader.values,
|
|
121
120
|
pattern: templateHeader.pattern,
|
|
122
121
|
validations: templateHeader.validations,
|
|
@@ -63,6 +63,8 @@ export declare const colorPalette: {
|
|
|
63
63
|
orange800: string;
|
|
64
64
|
orange900: string;
|
|
65
65
|
orange1000: string;
|
|
66
|
+
orange1100: string;
|
|
67
|
+
orange1200: string;
|
|
66
68
|
};
|
|
67
69
|
export declare const colorLabels: {
|
|
68
70
|
readonly backgroundInterface: string;
|
|
@@ -164,4 +166,6 @@ export declare const colors: {
|
|
|
164
166
|
orange800: string;
|
|
165
167
|
orange900: string;
|
|
166
168
|
orange1000: string;
|
|
169
|
+
orange1100: string;
|
|
170
|
+
orange1200: string;
|
|
167
171
|
};
|
package/lib/esm/types.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ export type Meta = {
|
|
|
34
34
|
id: string;
|
|
35
35
|
rowIndex: number;
|
|
36
36
|
isInvalid?: boolean;
|
|
37
|
+
hasWarning?: boolean;
|
|
37
38
|
touched?: boolean;
|
|
38
39
|
backendErrors?: ValidationErrors;
|
|
39
40
|
};
|
|
@@ -44,10 +45,14 @@ export type Record = {
|
|
|
44
45
|
export type RecordDataSet = {
|
|
45
46
|
[key: string]: Record;
|
|
46
47
|
};
|
|
48
|
+
export type ValidationResult = {
|
|
49
|
+
errors: ValidationErrors;
|
|
50
|
+
warnings: ValidationErrors;
|
|
51
|
+
};
|
|
47
52
|
export type ValidationErrors = {
|
|
48
53
|
[k: string]: string;
|
|
49
54
|
};
|
|
50
|
-
export type OnValidateRecord = (record: Record) => Promise<ValidationErrors>;
|
|
55
|
+
export type OnValidateRecord = (record: Record) => Promise<ValidationResult | ValidationErrors>;
|
|
51
56
|
export type FormatRecord = (record: Record) => Record;
|
|
52
57
|
export type RowValidationError = {
|
|
53
58
|
rowId: string;
|
|
@@ -112,7 +117,6 @@ export type Field = {
|
|
|
112
117
|
label: string;
|
|
113
118
|
type: FieldTypes;
|
|
114
119
|
isRequired?: boolean;
|
|
115
|
-
isUnique?: boolean;
|
|
116
120
|
options?: any;
|
|
117
121
|
pattern?: string;
|
|
118
122
|
validations?: FieldValidation[];
|