@vuu-ui/vuu-table-extras 3.3.15 → 3.3.17
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/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "3.3.
|
|
2
|
+
"version": "3.3.17",
|
|
3
3
|
"author": "heswell",
|
|
4
4
|
"main": "./src/index.js",
|
|
5
5
|
"license": "Apache-2.0",
|
|
@@ -11,19 +11,19 @@
|
|
|
11
11
|
"lezer-generate:column": "lezer-generator --output ./src/column-expression-input/column-language-parser/generated/column-parser.js ./src/column-expression-input/column-language-parser/grammar/column.grammar"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
|
-
"@vuu-ui/vuu-filter-types": "3.3.
|
|
15
|
-
"@vuu-ui/vuu-protocol-types": "3.3.
|
|
14
|
+
"@vuu-ui/vuu-filter-types": "3.3.17",
|
|
15
|
+
"@vuu-ui/vuu-protocol-types": "3.3.17"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@vuu-ui/vuu-codemirror": "3.3.
|
|
19
|
-
"@vuu-ui/vuu-data-editing": "3.3.
|
|
20
|
-
"@vuu-ui/vuu-data-react": "3.3.
|
|
21
|
-
"@vuu-ui/vuu-data-types": "3.3.
|
|
22
|
-
"@vuu-ui/vuu-table-types": "3.3.
|
|
23
|
-
"@vuu-ui/vuu-popups": "3.3.
|
|
24
|
-
"@vuu-ui/vuu-table": "3.3.
|
|
25
|
-
"@vuu-ui/vuu-utils": "3.3.
|
|
26
|
-
"@vuu-ui/vuu-ui-controls": "3.3.
|
|
18
|
+
"@vuu-ui/vuu-codemirror": "3.3.17",
|
|
19
|
+
"@vuu-ui/vuu-data-editing": "3.3.17",
|
|
20
|
+
"@vuu-ui/vuu-data-react": "3.3.17",
|
|
21
|
+
"@vuu-ui/vuu-data-types": "3.3.17",
|
|
22
|
+
"@vuu-ui/vuu-table-types": "3.3.17",
|
|
23
|
+
"@vuu-ui/vuu-popups": "3.3.17",
|
|
24
|
+
"@vuu-ui/vuu-table": "3.3.17",
|
|
25
|
+
"@vuu-ui/vuu-utils": "3.3.17",
|
|
26
|
+
"@vuu-ui/vuu-ui-controls": "3.3.17",
|
|
27
27
|
"@lezer/lr": "1.4.2",
|
|
28
28
|
"@salt-ds/core": "1.54.1",
|
|
29
29
|
"@salt-ds/lab": "1.0.0-alpha.83",
|
|
@@ -13,7 +13,7 @@ var csv_errors_CsvValidationErrorEnum = /*#__PURE__*/ function(CsvValidationErro
|
|
|
13
13
|
CsvValidationErrorEnum["MISSING_KEY_COLUMN"] = "MISSING_KEY_COLUMN";
|
|
14
14
|
CsvValidationErrorEnum["UNKNOWN_COLUMN"] = "UNKNOWN_COLUMN";
|
|
15
15
|
CsvValidationErrorEnum["MAX_ROWS_EXCEEDED"] = "MAX_ROWS_EXCEEDED";
|
|
16
|
-
CsvValidationErrorEnum["
|
|
16
|
+
CsvValidationErrorEnum["REQUIRED_FIELD_MISSING"] = "REQUIRED_FIELD_MISSING";
|
|
17
17
|
CsvValidationErrorEnum["TYPE_MISMATCH"] = "TYPE_MISMATCH";
|
|
18
18
|
CsvValidationErrorEnum["CUSTOM_VALIDATION"] = "CUSTOM_VALIDATION";
|
|
19
19
|
return CsvValidationErrorEnum;
|
|
@@ -41,7 +41,7 @@ const getFriendlyErrorMessage = (errMessage, rawValue, toType)=>{
|
|
|
41
41
|
const validateCsvAgainstSchema = (parsed, tableSchema, options)=>{
|
|
42
42
|
const schemaColumns = new Map(tableSchema.columns.map((col)=>[
|
|
43
43
|
col.name,
|
|
44
|
-
col
|
|
44
|
+
col
|
|
45
45
|
]));
|
|
46
46
|
const maxRows = options?.maxRows ?? MAX_ROWS_IN_CSV;
|
|
47
47
|
const errorState = createCsvErrorState();
|
|
@@ -60,8 +60,13 @@ const validateCsvAgainstSchema = (parsed, tableSchema, options)=>{
|
|
|
60
60
|
}, {});
|
|
61
61
|
parsed.header.forEach((columnName, columnIndex)=>{
|
|
62
62
|
const rawValue = rowValues[columnIndex] ?? "";
|
|
63
|
-
const
|
|
64
|
-
|
|
63
|
+
const schemaColumn = schemaColumns.get(columnName);
|
|
64
|
+
const schemaType = schemaColumn?.serverDataType;
|
|
65
|
+
const isRequired = schemaColumn?.required === true;
|
|
66
|
+
if (0 === rawValue.length) {
|
|
67
|
+
if (isRequired) addCsvRowError(errorState, rowNum, columnName, CsvValidationErrorEnum.REQUIRED_FIELD_MISSING, "This field is required and cannot be left blank", rawValue);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
65
70
|
let value;
|
|
66
71
|
const toType = schemaType ?? "string";
|
|
67
72
|
try {
|
|
@@ -11,7 +11,7 @@ export declare enum CsvValidationErrorEnum {
|
|
|
11
11
|
MISSING_KEY_COLUMN = "MISSING_KEY_COLUMN",
|
|
12
12
|
UNKNOWN_COLUMN = "UNKNOWN_COLUMN",
|
|
13
13
|
MAX_ROWS_EXCEEDED = "MAX_ROWS_EXCEEDED",
|
|
14
|
-
|
|
14
|
+
REQUIRED_FIELD_MISSING = "REQUIRED_FIELD_MISSING",
|
|
15
15
|
TYPE_MISMATCH = "TYPE_MISMATCH",
|
|
16
16
|
CUSTOM_VALIDATION = "CUSTOM_VALIDATION"
|
|
17
17
|
}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import type { TableSchema } from "@vuu-ui/vuu-data-types";
|
|
1
|
+
import type { TableSchema, SchemaColumn } from "@vuu-ui/vuu-data-types";
|
|
2
2
|
import type { VuuRowDataItemType } from "@vuu-ui/vuu-protocol-types";
|
|
3
3
|
import type { CsvValidationError, CsvValidationErrorMap, CsvParseError } from "./csv-errors";
|
|
4
4
|
import type { CsvParseResult } from "./csv-parse";
|
|
5
5
|
export { CsvValidationErrorEnum, type CsvValidationError, type CsvValidationErrorMap, type CsvValidationErrorType, type CsvValidationStructuredError, } from "./csv-errors";
|
|
6
|
+
export interface ImportSchemaColumn extends SchemaColumn {
|
|
7
|
+
required?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface ImportTableSchema extends Omit<TableSchema, "columns"> {
|
|
10
|
+
readonly columns: readonly ImportSchemaColumn[];
|
|
11
|
+
}
|
|
6
12
|
export type CsvColumnValidator = (value: string, columnName: string, row: Record<string, string>) => boolean | string;
|
|
7
13
|
export type CsvValidationResult = {
|
|
8
14
|
columns: string[];
|
|
@@ -15,4 +21,4 @@ export type CsvValidationOptions = {
|
|
|
15
21
|
maxRows?: number;
|
|
16
22
|
validators?: Record<string, CsvColumnValidator>;
|
|
17
23
|
};
|
|
18
|
-
export declare const validateCsvAgainstSchema: (parsed: CsvParseResult, tableSchema: TableSchema, options?: CsvValidationOptions) => CsvValidationResult;
|
|
24
|
+
export declare const validateCsvAgainstSchema: (parsed: CsvParseResult, tableSchema: TableSchema | ImportTableSchema, options?: CsvValidationOptions) => CsvValidationResult;
|