fuse-importer 0.26.7 → 0.26.8
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.js +13 -11
- package/lib/esm/Importer/Review/ReviewContextProvider.d.ts +3 -2
- package/lib/esm/Importer/Review/ReviewContextProvider.js +20 -20
- package/lib/esm/Importer/Stepper/index.js +14 -13
- package/lib/esm/Importer/Uploader/HeadersPreview.js +16 -8
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/filterMethods.d.ts +5 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/filterMethods.js +67 -0
- package/lib/esm/Importer/common/Spreadsheet/{SpreadsheetContextProvider.d.ts → SpreadsheetContextProvider/index.d.ts} +12 -8
- package/lib/esm/Importer/common/Spreadsheet/{SpreadsheetContextProvider.js → SpreadsheetContextProvider/index.js} +23 -17
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/useSpreadsheetFilter.d.ts +14 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/useSpreadsheetFilter.js +45 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/utils.d.ts +2 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/utils.js +14 -0
- package/lib/esm/Importer/common/Spreadsheet/common/types.d.ts +2 -2
- package/lib/esm/Importer/common/Spreadsheet/components/FieldHeader.js +5 -2
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetData.d.ts +2 -1
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetData.js +9 -4
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetRowCheckboxes.d.ts +1 -2
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetRowCheckboxes.js +18 -13
- package/lib/esm/Importer/common/Spreadsheet/hooks.d.ts +1 -3
- package/lib/esm/Importer/common/Spreadsheet/hooks.js +7 -4
- package/lib/esm/Importer/common/Spreadsheet/index.js +1 -1
- package/lib/esm/Importer/common/Spreadsheet/styles.d.ts +1 -1
- package/lib/esm/Importer/common/Spreadsheet/transformation/index.d.ts +7 -0
- package/lib/esm/Importer/common/Spreadsheet/transformation/index.js +25 -0
- package/lib/esm/Importer/common/Spreadsheet/transformation/transformators.d.ts +8 -0
- package/lib/esm/Importer/common/Spreadsheet/transformation/transformators.js +106 -0
- package/lib/esm/Importer/contexts/ImporterContextProvider.d.ts +6 -2
- package/lib/esm/Importer/contexts/ImporterContextProvider.js +26 -22
- package/lib/esm/Importer/data/index.d.ts +19 -3
- package/lib/esm/Importer/data/index.js +27 -30
- package/lib/esm/Importer/index.js +1 -1
- package/lib/esm/common/Table/TableActions/FilterByErrors/FilterByErrors.js +9 -5
- package/lib/esm/common/Table/TableActions/RowFilters.d.ts +1 -0
- package/lib/esm/common/Table/TableActions/RowFilters.js +42 -0
- package/lib/esm/common/Table/TableActions/TableActions.js +2 -1
- package/lib/esm/common/Table/TableActions/hooks.d.ts +0 -2
- package/lib/esm/common/Table/TableActions/hooks.js +0 -39
- package/lib/esm/common/Table/TableView/TableRows/TableRow.d.ts +2 -2
- package/lib/esm/common/Table/TableView/TableRows/TableRow.js +4 -4
- package/lib/esm/common/Table/TableView/TableRows/index.js +7 -4
- package/lib/esm/common/Table/TableView/index.d.ts +1 -1
- package/lib/esm/common/Table/TableView/index.js +1 -2
- package/lib/esm/common/Table/TableView/types.d.ts +0 -1
- package/lib/esm/common/columnsTransformations.d.ts +15 -0
- package/lib/esm/common/columnsTransformations.js +92 -0
- package/lib/esm/common/columnsValidations.js +83 -3
- package/lib/esm/common/index.d.ts +1 -0
- package/lib/esm/common/index.js +1 -0
- package/lib/esm/common/inputs/Autocomplete.js +1 -1
- package/lib/esm/common/inputs/Checkbox.js +1 -1
- package/lib/esm/index.d.ts +2 -1
- package/lib/esm/index.js +3 -0
- package/lib/esm/locales/de.d.ts +5 -0
- package/lib/esm/locales/de.js +6 -1
- package/lib/esm/locales/en.d.ts +5 -0
- package/lib/esm/locales/en.js +6 -1
- package/lib/esm/locales/es.d.ts +5 -0
- package/lib/esm/locales/es.js +6 -1
- package/lib/esm/locales/fr.d.ts +5 -0
- package/lib/esm/locales/fr.js +6 -1
- package/lib/esm/types.d.ts +33 -2
- package/lib/esm/types.js +15 -0
- package/lib/main.js +24 -24
- package/package.json +1 -1
|
@@ -102,7 +102,7 @@ var Autocomplete = function (_a) {
|
|
|
102
102
|
if (!isTyping && prefix)
|
|
103
103
|
setIsTyping(true);
|
|
104
104
|
setText(v);
|
|
105
|
-
}, icon: isDisabled ? null : inputIconUI, labelTooltip: labelTooltip }) })), !isDisabled && filteredOptions.length > 0 && (_jsx(SelectMenu, __assign({ referenceElement: referenceElement, placement: placement, isOpen: isMenuOpen, onClose: function () { return setIsMenuOpen(false); } }, { children: filteredOptions.map(function (o, index) { return (_jsx(Div, { children: _jsx(MenuItem, __assign({ id: id ? "".concat(id, "-option-").concat(o.label) : null, isSelected: value === (o === null || o === void 0 ? void 0 : o.value), onClick: function () { return onSelect(o === null || o === void 0 ? void 0 : o.value); } }, { children: o.label })) }, index)); }) })))] })));
|
|
105
|
+
}, icon: isDisabled ? null : inputIconUI, labelTooltip: labelTooltip }) })), !isDisabled && filteredOptions.length > 0 && (_jsx(SelectMenu, __assign({ referenceElement: referenceElement, placement: placement, isOpen: isMenuOpen, onClose: function () { return setIsMenuOpen(false); } }, { children: filteredOptions.map(function (o, index) { return (_jsx(Div, __assign({ "data-test-id": "autocomplete-menu-item" }, { children: _jsx(MenuItem, __assign({ id: id ? "".concat(id, "-option-").concat(o.label) : null, isSelected: value === (o === null || o === void 0 ? void 0 : o.value), onClick: function () { return onSelect(o === null || o === void 0 ? void 0 : o.value); } }, { children: o.label })) }), index)); }) })))] })));
|
|
106
106
|
};
|
|
107
107
|
var chevronDownIcon = (_jsx("svg", __assign({ width: "16", height: "9", viewBox: "0 0 16 9", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: _jsx("path", { d: "M14.9263 1L7.9631 7.96317L0.999928 1", stroke: "black", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })));
|
|
108
108
|
var clearIcon = (_jsxs("svg", __assign({ width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [_jsx("path", { d: "M4 4L12.5161 12.5161", stroke: "#333333", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }), _jsx("path", { d: "M4 12.5161L12.5161 3.99998", stroke: "#333333", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })] })));
|
|
@@ -45,7 +45,7 @@ var Checkbox = function (_a) {
|
|
|
45
45
|
var newValue = !isChecked || isIndeterminate;
|
|
46
46
|
onChange(newValue);
|
|
47
47
|
};
|
|
48
|
-
return (_jsx(Container, __assign({}, __assign({ isChecked: isChecked, isDisabled: isDisabled, isIndeterminate: isIndeterminate, onClick: handleOnChange }, props), { children: isIndeterminate ? (_jsx(IndeterminateIcon, {})) : (_jsx(Div, __assign({ centered: true }, { children: isChecked && (icon || checkIcon) }))) })));
|
|
48
|
+
return (_jsx(Container, __assign({}, __assign({ isChecked: isChecked, isDisabled: isDisabled, isIndeterminate: isIndeterminate, onClick: handleOnChange }, props), { "data-test-id": "checkbox" }, { children: isIndeterminate ? (_jsx(IndeterminateIcon, {})) : (_jsx(Div, __assign({ centered: true }, { children: isChecked && (icon || checkIcon) }))) })));
|
|
49
49
|
};
|
|
50
50
|
var checkIcon = (_jsx("svg", __assign({ width: "14", height: "10", viewBox: "0 0 14 10", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: _jsx("path", { d: "M1.10254 4.74355L5.2051 8.84612L12.8974 1.15381", stroke: "white", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })));
|
|
51
51
|
var IndeterminateIcon = function () { return (_jsx("svg", __assign({ width: "14", height: "2", viewBox: "0 0 14 2", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: _jsx("path", { d: "M1 1H13", stroke: "white", strokeWidth: "2", strokeLinecap: "round" }) }))); };
|
package/lib/esm/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { ColumnRequiredProps, EnvironmentType, FieldTypesAsUnion, FormatRecord, ImporterOptions, OnSubmit, OnValidateRecord } from "./types";
|
|
1
|
+
import { ColumnRequiredProps, EnvironmentType, FieldTypesAsUnion, FormatRecord, ImporterOptions, OnSubmit, OnValidateRecord, Record } from "./types";
|
|
2
2
|
declare class FuseImporter {
|
|
3
3
|
apiToken: string;
|
|
4
4
|
templateSlug: string;
|
|
5
5
|
env: EnvironmentType;
|
|
6
6
|
zIndex: number;
|
|
7
7
|
options: ImporterOptions;
|
|
8
|
+
records: Record[];
|
|
8
9
|
constructor(apiToken: string, templateSlug: string, options?: ImporterOptions);
|
|
9
10
|
private dynamicColumns;
|
|
10
11
|
private cleanupIframe;
|
package/lib/esm/index.js
CHANGED
|
@@ -132,9 +132,11 @@ var FuseImporter = /** @class */ (function () {
|
|
|
132
132
|
});
|
|
133
133
|
};
|
|
134
134
|
FuseImporter.prototype.addColumn = function (_a) {
|
|
135
|
+
var _b;
|
|
135
136
|
var options = _a.options, requiredProps = __rest(_a, ["options"]);
|
|
136
137
|
validateColumn(__assign(__assign({}, options), requiredProps));
|
|
137
138
|
var validations = __spreadArray(__spreadArray([], getDefaultValidations(requiredProps.column_type), true), ((options === null || options === void 0 ? void 0 : options.validations) || []), true);
|
|
139
|
+
var transformations = (_b = options === null || options === void 0 ? void 0 : options.transformations) !== null && _b !== void 0 ? _b : [];
|
|
138
140
|
var column = {
|
|
139
141
|
column_type: requiredProps.column_type,
|
|
140
142
|
internal_key: requiredProps.internal_key,
|
|
@@ -145,6 +147,7 @@ var FuseImporter = /** @class */ (function () {
|
|
|
145
147
|
unique: (options === null || options === void 0 ? void 0 : options.unique) || false,
|
|
146
148
|
values: requiredProps.column_type === "enum" ? (options === null || options === void 0 ? void 0 : options.values) || [] : [],
|
|
147
149
|
validations: validations,
|
|
150
|
+
transformations: transformations,
|
|
148
151
|
};
|
|
149
152
|
this.dynamicColumns.push(column);
|
|
150
153
|
};
|
package/lib/esm/locales/de.d.ts
CHANGED
package/lib/esm/locales/de.js
CHANGED
|
@@ -11,7 +11,7 @@ export default {
|
|
|
11
11
|
},
|
|
12
12
|
upload: {
|
|
13
13
|
headers_preview: {
|
|
14
|
-
title: "
|
|
14
|
+
title: "Wählen Sie eine Kopfzeile aus",
|
|
15
15
|
description: "Die Datei muss Spaltenüberschriften enthalten, um fortzufahren.",
|
|
16
16
|
cancel: "Nein, Datei erneut hochladen",
|
|
17
17
|
continue: "Ja, Weiter",
|
|
@@ -56,6 +56,11 @@ export default {
|
|
|
56
56
|
export: "Exportieren",
|
|
57
57
|
description: "Einige Zellen im Dokument können Fehler im Format oder fehlende Informationen aufweisen. Bitte überprüfen Sie diese, um fortzufahren.",
|
|
58
58
|
table_actions: {
|
|
59
|
+
filters_by_rows: {
|
|
60
|
+
all_rows: "Alle Zeilen",
|
|
61
|
+
valid_rows: "Gültige Zeilen",
|
|
62
|
+
invalid_rows: "Ungültige Zeilen",
|
|
63
|
+
},
|
|
59
64
|
search_rows: {
|
|
60
65
|
tooltip: "Etwas suchen",
|
|
61
66
|
placeholder: "Etwas suchen...",
|
package/lib/esm/locales/en.d.ts
CHANGED
package/lib/esm/locales/en.js
CHANGED
|
@@ -11,7 +11,7 @@ export default {
|
|
|
11
11
|
},
|
|
12
12
|
upload: {
|
|
13
13
|
headers_preview: {
|
|
14
|
-
title: "
|
|
14
|
+
title: "Select a Header Row",
|
|
15
15
|
description: "File must contain column headers to proceed.",
|
|
16
16
|
cancel: "Re-upload file",
|
|
17
17
|
continue: "Continue",
|
|
@@ -56,6 +56,11 @@ export default {
|
|
|
56
56
|
export: "Export",
|
|
57
57
|
description: "Some cells in the document might have errors in format or missing information. Please review these to continue.",
|
|
58
58
|
table_actions: {
|
|
59
|
+
filters_by_rows: {
|
|
60
|
+
all_rows: "All Rows",
|
|
61
|
+
valid_rows: "Valid Rows",
|
|
62
|
+
invalid_rows: "Invalid Rows",
|
|
63
|
+
},
|
|
59
64
|
search_rows: {
|
|
60
65
|
tooltip: "Search something",
|
|
61
66
|
placeholder: "Search something...",
|
package/lib/esm/locales/es.d.ts
CHANGED
package/lib/esm/locales/es.js
CHANGED
|
@@ -11,7 +11,7 @@ export default {
|
|
|
11
11
|
},
|
|
12
12
|
upload: {
|
|
13
13
|
headers_preview: {
|
|
14
|
-
title: "
|
|
14
|
+
title: "Seleccione una fila de encabezado",
|
|
15
15
|
description: "El archivo debe contener encabezados de columna para continuar.",
|
|
16
16
|
cancel: "No, vuelva a cargar el archivo",
|
|
17
17
|
continue: "Sí, continuar",
|
|
@@ -56,6 +56,11 @@ export default {
|
|
|
56
56
|
export: "Exportar",
|
|
57
57
|
description: "Algunas celdas en el documento pueden tener errores en el formato o información faltante. Por favor revise esto para continuar.",
|
|
58
58
|
table_actions: {
|
|
59
|
+
filters_by_rows: {
|
|
60
|
+
all_rows: "Todas las Filas",
|
|
61
|
+
valid_rows: "Filas Válidas",
|
|
62
|
+
invalid_rows: "Filas Inválidas",
|
|
63
|
+
},
|
|
59
64
|
search_rows: {
|
|
60
65
|
tooltip: "Buscar algo",
|
|
61
66
|
placeholder: "Buscar algo...",
|
package/lib/esm/locales/fr.d.ts
CHANGED
package/lib/esm/locales/fr.js
CHANGED
|
@@ -11,7 +11,7 @@ export default {
|
|
|
11
11
|
},
|
|
12
12
|
upload: {
|
|
13
13
|
headers_preview: {
|
|
14
|
-
title: "
|
|
14
|
+
title: "Sélectionnez une ligne d'en-tête",
|
|
15
15
|
description: "Le fichier doit contenir des en-têtes de colonne pour continuer.",
|
|
16
16
|
cancel: "Non, re-télécharger le fichier",
|
|
17
17
|
continue: "Oui, continuer",
|
|
@@ -56,6 +56,11 @@ export default {
|
|
|
56
56
|
export: "Exporter",
|
|
57
57
|
description: "Certaines cellules du document peuvent avoir des erreurs de format ou des informations manquantes. Veuillez les examiner pour continuer.",
|
|
58
58
|
table_actions: {
|
|
59
|
+
filters_by_rows: {
|
|
60
|
+
all_rows: "Toutes les lignes",
|
|
61
|
+
valid_rows: "Lignes valides",
|
|
62
|
+
invalid_rows: "Lignes invalides",
|
|
63
|
+
},
|
|
59
64
|
search_rows: {
|
|
60
65
|
tooltip: "Rechercher quelque chose",
|
|
61
66
|
placeholder: "Rechercher quelque chose...",
|
package/lib/esm/types.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export type SpreadsheetOptions = {
|
|
|
5
5
|
batchValidationDelayMs?: number;
|
|
6
6
|
batchValidationSize?: number;
|
|
7
7
|
showCheckboxColumn?: boolean;
|
|
8
|
-
|
|
8
|
+
withSingleRowSelect?: boolean;
|
|
9
9
|
};
|
|
10
10
|
export type ImporterOptions = {
|
|
11
11
|
zIndex?: number;
|
|
@@ -13,6 +13,7 @@ export type ImporterOptions = {
|
|
|
13
13
|
previewMode?: boolean;
|
|
14
14
|
loadingComponent?: () => JSX.Element;
|
|
15
15
|
disableSubmitIfInvalid?: boolean;
|
|
16
|
+
records?: Record[];
|
|
16
17
|
language?: string;
|
|
17
18
|
} & SpreadsheetOptions;
|
|
18
19
|
export declare enum FieldTypes {
|
|
@@ -42,7 +43,7 @@ export type Meta = {
|
|
|
42
43
|
};
|
|
43
44
|
export type Record = {
|
|
44
45
|
[key: string]: any;
|
|
45
|
-
_meta
|
|
46
|
+
_meta?: Meta;
|
|
46
47
|
};
|
|
47
48
|
export type RecordDataSet = {
|
|
48
49
|
[key: string]: Record;
|
|
@@ -73,6 +74,10 @@ export type ValidationOptionKeys = "pattern" | "max_length" | "min_length" | "le
|
|
|
73
74
|
export declare const validationTypesBase: readonly ["cannot_contain", "contain", "max_length", "min_length", "length_exactly", "unique_case_sensitive", "unique_case_insensitive", "regex", "integer", "less_than", "greater_than", "even", "odd", "float", "email", "url", "boolean", "before_date", "after_date"];
|
|
74
75
|
export declare const mutableValidationTypes: ("boolean" | "max_length" | "min_length" | "cannot_contain" | "contain" | "length_exactly" | "unique_case_sensitive" | "unique_case_insensitive" | "regex" | "integer" | "less_than" | "greater_than" | "even" | "odd" | "float" | "email" | "url" | "before_date" | "after_date")[];
|
|
75
76
|
export type ValidationTypes = typeof validationTypesBase[number];
|
|
77
|
+
export type TransformationOptionKeys = "prefix" | "number_of_decimals";
|
|
78
|
+
export declare const transformationTypesBase: readonly ["sentence_case", "capitalize", "uppercase", "lowercase", "trim_whitespace", "autoformat", "prefix", "number_of_decimals", "round", "floor", "ceiling", "autodetect"];
|
|
79
|
+
export declare const mutableTransformationTypes: ("prefix" | "number_of_decimals" | "sentence_case" | "capitalize" | "uppercase" | "lowercase" | "trim_whitespace" | "autoformat" | "round" | "floor" | "ceiling" | "autodetect")[];
|
|
80
|
+
export type TransformationTypes = typeof transformationTypesBase[number];
|
|
76
81
|
export interface FieldValidation {
|
|
77
82
|
id?: number;
|
|
78
83
|
validation_type?: ValidationTypes;
|
|
@@ -82,6 +87,13 @@ export interface FieldValidation {
|
|
|
82
87
|
[key in ValidationOptionKeys]?: any;
|
|
83
88
|
};
|
|
84
89
|
}
|
|
90
|
+
export interface FieldTransformation {
|
|
91
|
+
id?: number;
|
|
92
|
+
transformation_type?: TransformationTypes;
|
|
93
|
+
options?: {
|
|
94
|
+
[key in TransformationOptionKeys]?: any;
|
|
95
|
+
};
|
|
96
|
+
}
|
|
85
97
|
export type TemplateHeader = {
|
|
86
98
|
label: string;
|
|
87
99
|
required: boolean;
|
|
@@ -91,6 +103,7 @@ export type TemplateHeader = {
|
|
|
91
103
|
values: string[];
|
|
92
104
|
pattern: string;
|
|
93
105
|
validations: FieldValidation[];
|
|
106
|
+
transformations: FieldTransformation[];
|
|
94
107
|
position: number;
|
|
95
108
|
};
|
|
96
109
|
export type Organization = {
|
|
@@ -126,6 +139,7 @@ export type Field = {
|
|
|
126
139
|
options?: any;
|
|
127
140
|
pattern?: string;
|
|
128
141
|
validations?: FieldValidation[];
|
|
142
|
+
transformations?: FieldTransformation[];
|
|
129
143
|
};
|
|
130
144
|
export type ColumnRequiredProps<T extends FieldTypesAsUnion> = {
|
|
131
145
|
internal_key: string;
|
|
@@ -135,6 +149,7 @@ export type ColumnRequiredProps<T extends FieldTypesAsUnion> = {
|
|
|
135
149
|
options?: ColumnOptions<T>;
|
|
136
150
|
};
|
|
137
151
|
export type ValidationTypesRules<T extends FieldTypesAsUnion> = T extends "integer" ? IntegerValidationRule : T extends "float" ? FloatValidationRule : T extends "string" ? StringValidationRule : T extends "email" ? EmailValidationRule : T extends "enum" ? EnumValidationRule : T extends "url" ? UrlValidationRule : T extends "boolean" ? BooleanValidationRule : T extends "date" ? DateValidationRule : T extends "datetime" ? DateTimeValidationRule : T extends "time" ? TimeValidationRule : never;
|
|
152
|
+
export type TransformationTypesRules<T extends FieldTypesAsUnion> = T extends "integer" ? IntegerTransformationRule : T extends "float" ? FloatTransformationRule : T extends "string" ? StringTransformationRule : T extends "enum" ? EnumTransformationRule : T extends "url" ? UrlTransformationRule : T extends "date" | "datetime" | "time" ? DateDateTimesAndTimesTransformationRule : never;
|
|
138
153
|
export type ValidationTypeOptions<T extends ValidationTypesRules<FieldTypesAsUnion>> = T extends "cannot_contain" | "contain" | "regex" ? {
|
|
139
154
|
pattern: string;
|
|
140
155
|
} : T extends "max_length" ? {
|
|
@@ -148,11 +163,20 @@ export type ValidationTypeOptions<T extends ValidationTypesRules<FieldTypesAsUni
|
|
|
148
163
|
} : T extends "greater_than" | "after_date" ? {
|
|
149
164
|
min: string | number;
|
|
150
165
|
} : never;
|
|
166
|
+
export type TransformationTypeOptions<T extends TransformationTypesRules<FieldTypesAsUnion>> = T extends "prefix" ? {
|
|
167
|
+
prefix: string;
|
|
168
|
+
} : T extends "number_of_decimals" ? {
|
|
169
|
+
number_of_decimals: number;
|
|
170
|
+
} : never;
|
|
151
171
|
export interface ColumnValidations<T extends FieldTypesAsUnion> {
|
|
152
172
|
validation_type: ValidationTypesRules<T>;
|
|
153
173
|
message: string;
|
|
154
174
|
options?: ValidationTypeOptions<ValidationTypesRules<T>>;
|
|
155
175
|
}
|
|
176
|
+
export interface ColumnTransformations<T extends FieldTypesAsUnion> {
|
|
177
|
+
transformation_type: TransformationTypesRules<T>;
|
|
178
|
+
options?: TransformationTypeOptions<TransformationTypesRules<T>>;
|
|
179
|
+
}
|
|
156
180
|
type EnumOptions = {
|
|
157
181
|
values: string[];
|
|
158
182
|
};
|
|
@@ -164,15 +188,22 @@ type OtherOptions = {
|
|
|
164
188
|
};
|
|
165
189
|
export type ColumnOptions<T extends FieldTypesAsUnion> = Partial<Pick<TemplateHeader, "unique" | "position" | "pattern">> & {
|
|
166
190
|
validations?: ColumnValidations<T>[];
|
|
191
|
+
transformations?: ColumnTransformations<T>[];
|
|
167
192
|
} & (T extends "enum" ? EnumOptions : T extends "time" ? TimeOptions : OtherOptions);
|
|
168
193
|
type StringValidationRule = "cannot_contain" | "contain" | "max_length" | "min_length" | "length_exactly" | "unique_case_sensitive" | "unique_case_insensitive" | "regex";
|
|
194
|
+
type StringTransformationRule = "sentence_case" | "capitalize" | "uppercase" | "lowercase" | "trim_whitespace";
|
|
169
195
|
type IntegerValidationRule = "less_than" | "greater_than" | "even" | "odd" | "unique_case_sensitive" | "unique_case_insensitive" | "regex";
|
|
196
|
+
type IntegerTransformationRule = "round" | "floor" | "ceiling";
|
|
170
197
|
type FloatValidationRule = "less_than" | "greater_than" | "even" | "odd" | "unique_case_sensitive" | "unique_case_insensitive" | "regex";
|
|
198
|
+
type FloatTransformationRule = "number_of_decimals";
|
|
171
199
|
type EmailValidationRule = "cannot_contain" | "contain" | "max_length" | "min_length" | "length_exactly" | "unique_case_sensitive" | "unique_case_insensitive" | "regex";
|
|
172
200
|
type EnumValidationRule = "unique_case_sensitive" | "unique_case_insensitive";
|
|
201
|
+
type EnumTransformationRule = "autodetect";
|
|
173
202
|
type UrlValidationRule = "cannot_contain" | "contain" | "max_length" | "min_length" | "length_exactly" | "unique_case_sensitive" | "unique_case_insensitive" | "regex";
|
|
203
|
+
type UrlTransformationRule = "prefix";
|
|
174
204
|
type BooleanValidationRule = "boolean";
|
|
175
205
|
type DateValidationRule = "unique_case_sensitive" | "unique_case_insensitive" | "before_date" | "after_date";
|
|
176
206
|
type DateTimeValidationRule = "unique_case_sensitive" | "unique_case_insensitive" | "before_date" | "after_date";
|
|
177
207
|
type TimeValidationRule = "unique_case_sensitive" | "unique_case_insensitive";
|
|
208
|
+
type DateDateTimesAndTimesTransformationRule = "autoformat";
|
|
178
209
|
export {};
|
package/lib/esm/types.js
CHANGED
|
@@ -48,3 +48,18 @@ export var validationTypesBase = [
|
|
|
48
48
|
"after_date",
|
|
49
49
|
];
|
|
50
50
|
export var mutableValidationTypes = __spreadArray([], validationTypesBase, true);
|
|
51
|
+
export var transformationTypesBase = [
|
|
52
|
+
"sentence_case",
|
|
53
|
+
"capitalize",
|
|
54
|
+
"uppercase",
|
|
55
|
+
"lowercase",
|
|
56
|
+
"trim_whitespace",
|
|
57
|
+
"autoformat",
|
|
58
|
+
"prefix",
|
|
59
|
+
"number_of_decimals",
|
|
60
|
+
"round",
|
|
61
|
+
"floor",
|
|
62
|
+
"ceiling",
|
|
63
|
+
"autodetect",
|
|
64
|
+
];
|
|
65
|
+
export var mutableTransformationTypes = __spreadArray([], transformationTypesBase, true);
|