fuse-importer 0.26.7 → 0.26.9
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 +56 -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} +28 -18
- 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 +29 -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 +3 -2
- package/lib/esm/index.js +15 -24
- 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 +36 -8
- 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;
|
|
@@ -15,7 +16,7 @@ declare class FuseImporter {
|
|
|
15
16
|
private windowScrollPosition;
|
|
16
17
|
close(): void;
|
|
17
18
|
show(): Promise<void>;
|
|
18
|
-
addColumn<T extends FieldTypesAsUnion>(
|
|
19
|
+
addColumn<T extends FieldTypesAsUnion>(columnData: ColumnRequiredProps<T>): void;
|
|
19
20
|
private renderImporterComponent;
|
|
20
21
|
private createDivComponent;
|
|
21
22
|
private createIframe;
|
package/lib/esm/index.js
CHANGED
|
@@ -45,17 +45,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
45
45
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
49
|
-
var t = {};
|
|
50
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
51
|
-
t[p] = s[p];
|
|
52
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
53
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
54
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
55
|
-
t[p[i]] = s[p[i]];
|
|
56
|
-
}
|
|
57
|
-
return t;
|
|
58
|
-
};
|
|
59
48
|
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
60
49
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
61
50
|
if (ar || !(i in from)) {
|
|
@@ -131,20 +120,22 @@ var FuseImporter = /** @class */ (function () {
|
|
|
131
120
|
});
|
|
132
121
|
});
|
|
133
122
|
};
|
|
134
|
-
FuseImporter.prototype.addColumn = function (
|
|
135
|
-
var
|
|
136
|
-
validateColumn(
|
|
137
|
-
var
|
|
123
|
+
FuseImporter.prototype.addColumn = function (columnData) {
|
|
124
|
+
var column_type = columnData.column_type, internal_key = columnData.internal_key, label = columnData.label, required = columnData.required, pattern = columnData.pattern, position = columnData.position, transformations = columnData.transformations, unique = columnData.unique, validations = columnData.validations, values = columnData.values;
|
|
125
|
+
validateColumn(columnData);
|
|
126
|
+
var treatedValidations = __spreadArray(__spreadArray([], getDefaultValidations(column_type), true), (validations || []), true);
|
|
127
|
+
var treatedTransformations = transformations !== null && transformations !== void 0 ? transformations : [];
|
|
138
128
|
var column = {
|
|
139
|
-
column_type:
|
|
140
|
-
internal_key:
|
|
141
|
-
label:
|
|
142
|
-
required:
|
|
143
|
-
pattern:
|
|
144
|
-
position:
|
|
145
|
-
unique:
|
|
146
|
-
values:
|
|
147
|
-
validations:
|
|
129
|
+
column_type: column_type,
|
|
130
|
+
internal_key: internal_key,
|
|
131
|
+
label: label,
|
|
132
|
+
required: required,
|
|
133
|
+
pattern: pattern || null,
|
|
134
|
+
position: position || null,
|
|
135
|
+
unique: unique || false,
|
|
136
|
+
values: column_type === "enum" ? values || [] : [],
|
|
137
|
+
validations: treatedValidations,
|
|
138
|
+
transformations: treatedTransformations,
|
|
148
139
|
};
|
|
149
140
|
this.dynamicColumns.push(column);
|
|
150
141
|
};
|
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,15 +139,18 @@ export type Field = {
|
|
|
126
139
|
options?: any;
|
|
127
140
|
pattern?: string;
|
|
128
141
|
validations?: FieldValidation[];
|
|
142
|
+
transformations?: FieldTransformation[];
|
|
129
143
|
};
|
|
130
|
-
export type ColumnRequiredProps<T extends FieldTypesAsUnion> = {
|
|
144
|
+
export type ColumnRequiredProps<T extends FieldTypesAsUnion> = Partial<Pick<TemplateHeader, "unique" | "position" | "pattern">> & {
|
|
131
145
|
internal_key: string;
|
|
132
146
|
label: string;
|
|
133
147
|
column_type: T;
|
|
134
148
|
required: boolean;
|
|
135
|
-
|
|
136
|
-
|
|
149
|
+
validations?: ColumnValidations<T>[];
|
|
150
|
+
transformations?: ColumnTransformations<T>[];
|
|
151
|
+
} & (T extends "enum" ? EnumOptions : T extends "time" ? TimeOptions : OtherOptions);
|
|
137
152
|
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;
|
|
153
|
+
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
154
|
export type ValidationTypeOptions<T extends ValidationTypesRules<FieldTypesAsUnion>> = T extends "cannot_contain" | "contain" | "regex" ? {
|
|
139
155
|
pattern: string;
|
|
140
156
|
} : T extends "max_length" ? {
|
|
@@ -148,11 +164,20 @@ export type ValidationTypeOptions<T extends ValidationTypesRules<FieldTypesAsUni
|
|
|
148
164
|
} : T extends "greater_than" | "after_date" ? {
|
|
149
165
|
min: string | number;
|
|
150
166
|
} : never;
|
|
167
|
+
export type TransformationTypeOptions<T extends TransformationTypesRules<FieldTypesAsUnion>> = T extends "prefix" ? {
|
|
168
|
+
prefix: string;
|
|
169
|
+
} : T extends "number_of_decimals" ? {
|
|
170
|
+
number_of_decimals: number;
|
|
171
|
+
} : never;
|
|
151
172
|
export interface ColumnValidations<T extends FieldTypesAsUnion> {
|
|
152
173
|
validation_type: ValidationTypesRules<T>;
|
|
153
174
|
message: string;
|
|
154
175
|
options?: ValidationTypeOptions<ValidationTypesRules<T>>;
|
|
155
176
|
}
|
|
177
|
+
export interface ColumnTransformations<T extends FieldTypesAsUnion> {
|
|
178
|
+
transformation_type: TransformationTypesRules<T>;
|
|
179
|
+
options?: TransformationTypeOptions<TransformationTypesRules<T>>;
|
|
180
|
+
}
|
|
156
181
|
type EnumOptions = {
|
|
157
182
|
values: string[];
|
|
158
183
|
};
|
|
@@ -162,17 +187,20 @@ type TimeOptions = {
|
|
|
162
187
|
type OtherOptions = {
|
|
163
188
|
values?: never;
|
|
164
189
|
};
|
|
165
|
-
export type ColumnOptions<T extends FieldTypesAsUnion> = Partial<Pick<TemplateHeader, "unique" | "position" | "pattern">> & {
|
|
166
|
-
validations?: ColumnValidations<T>[];
|
|
167
|
-
} & (T extends "enum" ? EnumOptions : T extends "time" ? TimeOptions : OtherOptions);
|
|
168
190
|
type StringValidationRule = "cannot_contain" | "contain" | "max_length" | "min_length" | "length_exactly" | "unique_case_sensitive" | "unique_case_insensitive" | "regex";
|
|
191
|
+
type StringTransformationRule = "sentence_case" | "capitalize" | "uppercase" | "lowercase" | "trim_whitespace";
|
|
169
192
|
type IntegerValidationRule = "less_than" | "greater_than" | "even" | "odd" | "unique_case_sensitive" | "unique_case_insensitive" | "regex";
|
|
193
|
+
type IntegerTransformationRule = "round" | "floor" | "ceiling";
|
|
170
194
|
type FloatValidationRule = "less_than" | "greater_than" | "even" | "odd" | "unique_case_sensitive" | "unique_case_insensitive" | "regex";
|
|
195
|
+
type FloatTransformationRule = "number_of_decimals";
|
|
171
196
|
type EmailValidationRule = "cannot_contain" | "contain" | "max_length" | "min_length" | "length_exactly" | "unique_case_sensitive" | "unique_case_insensitive" | "regex";
|
|
172
197
|
type EnumValidationRule = "unique_case_sensitive" | "unique_case_insensitive";
|
|
198
|
+
type EnumTransformationRule = "autodetect";
|
|
173
199
|
type UrlValidationRule = "cannot_contain" | "contain" | "max_length" | "min_length" | "length_exactly" | "unique_case_sensitive" | "unique_case_insensitive" | "regex";
|
|
200
|
+
type UrlTransformationRule = "prefix";
|
|
174
201
|
type BooleanValidationRule = "boolean";
|
|
175
202
|
type DateValidationRule = "unique_case_sensitive" | "unique_case_insensitive" | "before_date" | "after_date";
|
|
176
203
|
type DateTimeValidationRule = "unique_case_sensitive" | "unique_case_insensitive" | "before_date" | "after_date";
|
|
177
204
|
type TimeValidationRule = "unique_case_sensitive" | "unique_case_insensitive";
|
|
205
|
+
type DateDateTimesAndTimesTransformationRule = "autoformat";
|
|
178
206
|
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);
|