diff --git a/CHANGELOG.md b/CHANGELOG.md index 63af150c..b46d963e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - Export validateSequenceArray [`#2`](https://github.com/TeselaGen/tg-oss/pull/2) - genbank ss-DNA should not be overwirte to DNA [`#1`](https://github.com/TeselaGen/tg-oss/pull/1) - closes #35 [`#35`](https://github.com/TeselaGen/tg-oss/issues/35) -- trying out updating auto-changelog to run on publish [`4b8537f`](https://github.com/TeselaGen/tg-oss/commit/4b8537f4d375d2e74edf3dee5e3340c12e6faac5) -- merging in master [`04c5445`](https://github.com/TeselaGen/tg-oss/commit/04c544591eb3f2630408e5bb2756e75d8eaacdd0) - updating table styling to remove table last row bottom margin, removing unused S3Download, removing axios dep, updating deps [`8a6fb1f`](https://github.com/TeselaGen/tg-oss/commit/8a6fb1f047550f617c3e56b8c3ebf145967076ef) +- updating normalizeCsvHeader so camel case -> snake case is preserved, and allowing TooFewFields as csv parse error [`81fb224`](https://github.com/TeselaGen/tg-oss/commit/81fb22445e42a2786e73ffeae72c3052b82b0710) +- trying out updating auto-changelog to run on publish [`4b8537f`](https://github.com/TeselaGen/tg-oss/commit/4b8537f4d375d2e74edf3dee5e3340c12e6faac5) diff --git a/packages/file-utils/package.json b/packages/file-utils/package.json index d941095c..5cc29578 100644 --- a/packages/file-utils/package.json +++ b/packages/file-utils/package.json @@ -1,6 +1,6 @@ { "name": "@teselagen/file-utils", - "version": "0.3.12", + "version": "0.3.14", "type": "commonjs", "dependencies": { "bluebird": "^3.7.2", diff --git a/packages/ui/package.json b/packages/ui/package.json index ba9ec90e..55c75169 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -1,6 +1,6 @@ { "name": "@teselagen/ui", - "version": "0.3.62", + "version": "0.3.63", "main": "./src/index.js", "exports": { ".": { diff --git a/packages/ui/src/FormComponents/Uploader.js b/packages/ui/src/FormComponents/Uploader.js index 841f04ac..260d9fd2 100644 --- a/packages/ui/src/FormComponents/Uploader.js +++ b/packages/ui/src/FormComponents/Uploader.js @@ -705,7 +705,15 @@ function UploaderInner({ if (isCsvOrExcelFile(file)) { let parsedF; try { - parsedF = await parseCsvOrExcelFile(file); + parsedF = await parseCsvOrExcelFile(file, { + csvParserOptions: isFunction( + validateAgainstSchema.csvParserOptions + ) + ? validateAgainstSchema.csvParserOptions({ + validateAgainstSchema + }) + : validateAgainstSchema.csvParserOptions + }); } catch (error) { console.error("error:", error); window.toastr && diff --git a/packages/ui/src/FormComponents/tryToMatchSchemas.js b/packages/ui/src/FormComponents/tryToMatchSchemas.js index 5153d9d7..49b02fd6 100644 --- a/packages/ui/src/FormComponents/tryToMatchSchemas.js +++ b/packages/ui/src/FormComponents/tryToMatchSchemas.js @@ -1,4 +1,4 @@ -import { forEach, isArray, map } from "lodash"; +import { forEach, isArray, map, snakeCase } from "lodash"; import { nanoid } from "nanoid"; import Fuse from "fuse.js"; import { editCellHelper } from "../DataTable/editCellHelper"; @@ -89,24 +89,17 @@ async function matchSchemas({ userSchema, officialSchema }) { //if there are any exact matches, push them onto the results array userSchema.fields.forEach((uh, i) => { - const pathMatch = - uh.path.toLowerCase().replace(/ /g, "") === - h.path.toLowerCase().replace(/ /g, ""); + const pathMatch = norm(uh.path) === norm(h.path); const displayNameMatch = - h.displayName && - uh.path.toLowerCase().replace(/ /g, "") === - getTextFromEl(h.displayName).toLowerCase().replace(/ /g, ""); + h.displayName && norm(uh.path) === norm(getTextFromEl(h.displayName)); const hasAlternatePathMatch = h.alternatePathMatch && (isArray(h.alternatePathMatch) - ? h.alternatePathMatch.some(alternatePathMatch => { - return ( - uh.path.toLowerCase().replace(/ /g, "") === - alternatePathMatch.toLowerCase().replace(/ /g, "") - ); - }) - : uh.path.toLowerCase().replace(/ /g, "") === - h.alternatePathMatch.toLowerCase().replace(/ /g, "")); + ? h.alternatePathMatch + : [h.alternatePathMatch] + ).some(alternatePathMatch => { + return norm(uh.path) === norm(alternatePathMatch); + }); if (pathMatch || displayNameMatch || hasAlternatePathMatch) { result = result.filter(({ path }) => path === uh.path); @@ -232,3 +225,7 @@ async function resolveValidateAgainstSchema() { // } // }) } + +function norm(h) { + return snakeCase(h).toLowerCase().replace(/ /g, ""); +}