read-excel-file 7.0.3 → 8.0.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/CHANGELOG.md +37 -0
- package/README.md +212 -205
- package/browser/index.cjs +8 -5
- package/browser/index.d.ts +58 -16
- package/browser/index.js +7 -5
- package/browser/input.d.ts +1 -0
- package/bundle/read-excel-file.min.js +1 -1
- package/bundle/read-excel-file.min.js.map +1 -1
- package/commonjs/export/parseSheet.js +20 -0
- package/commonjs/export/parseSheet.js.map +1 -0
- package/commonjs/export/readSheetBrowser.js +29 -0
- package/commonjs/export/readSheetBrowser.js.map +1 -0
- package/commonjs/export/readSheetNode.js +29 -0
- package/commonjs/export/readSheetNode.js.map +1 -0
- package/commonjs/export/readSheetUniversal.js +29 -0
- package/commonjs/export/readSheetUniversal.js.map +1 -0
- package/commonjs/export/readSheetWebWorker.js +29 -0
- package/commonjs/export/readSheetWebWorker.js.map +1 -0
- package/commonjs/export/readXlsxFileBrowser.js +6 -8
- package/commonjs/export/readXlsxFileBrowser.js.map +1 -1
- package/commonjs/export/readXlsxFileNode.js +7 -9
- package/commonjs/export/readXlsxFileNode.js.map +1 -1
- package/commonjs/export/readXlsxFileUniversal.js +7 -9
- package/commonjs/export/readXlsxFileUniversal.js.map +1 -1
- package/commonjs/export/readXlsxFileWebWorker.js +6 -8
- package/commonjs/export/readXlsxFileWebWorker.js.map +1 -1
- package/commonjs/export/unpackXlsxFileBrowser.js +2 -1
- package/commonjs/export/unpackXlsxFileBrowser.js.map +1 -1
- package/commonjs/export/unpackXlsxFileNode.js +4 -3
- package/commonjs/export/unpackXlsxFileNode.js.map +1 -1
- package/commonjs/export/unpackXlsxFileUniversal.js +13 -3
- package/commonjs/export/unpackXlsxFileUniversal.js.map +1 -1
- package/commonjs/parseData/InvalidError.js.map +1 -0
- package/commonjs/parseData/parseData.js +503 -0
- package/commonjs/parseData/parseData.js.map +1 -0
- package/commonjs/parseData/parseData.test.js.map +1 -0
- package/commonjs/{types → parseData/types}/Boolean.js +1 -1
- package/commonjs/parseData/types/Boolean.js.map +1 -0
- package/commonjs/parseData/types/Date.js +21 -0
- package/commonjs/parseData/types/Date.js.map +1 -0
- package/commonjs/{types → parseData/types}/Number.js +1 -1
- package/commonjs/parseData/types/Number.js.map +1 -0
- package/commonjs/{types → parseData/types}/String.js +1 -1
- package/commonjs/parseData/types/String.js.map +1 -0
- package/commonjs/{types → parseData/types/additional}/Email.js +3 -3
- package/commonjs/parseData/types/additional/Email.js.map +1 -0
- package/commonjs/parseData/types/additional/Email.test.js.map +1 -0
- package/commonjs/{types → parseData/types/additional}/Integer.js +2 -2
- package/commonjs/parseData/types/additional/Integer.js.map +1 -0
- package/commonjs/parseData/types/additional/Integer.test.js.map +1 -0
- package/commonjs/{types → parseData/types/additional}/URL.js +3 -3
- package/commonjs/parseData/types/additional/URL.js.map +1 -0
- package/commonjs/parseData/types/additional/URL.test.js.map +1 -0
- package/commonjs/xlsx/{getData.js → convertCellsToData2dArray.js} +16 -37
- package/commonjs/xlsx/convertCellsToData2dArray.js.map +1 -0
- package/commonjs/xlsx/{isDateTimestamp.js → isDateFormat.js} +58 -56
- package/commonjs/xlsx/isDateFormat.js.map +1 -0
- package/commonjs/xlsx/isDateFormat.test.js.map +1 -0
- package/commonjs/xlsx/isDateFormatStyle.js +193 -0
- package/commonjs/xlsx/isDateFormatStyle.js.map +1 -0
- package/commonjs/xlsx/parseCell.js +16 -18
- package/commonjs/xlsx/parseCell.js.map +1 -1
- package/commonjs/xlsx/parseCellCoordinates.js +44 -0
- package/commonjs/xlsx/parseCellCoordinates.js.map +1 -0
- package/commonjs/xlsx/parseCellValue.js +14 -11
- package/commonjs/xlsx/parseCellValue.js.map +1 -1
- package/commonjs/xlsx/parseCells.js +14 -6
- package/commonjs/xlsx/parseCells.js.map +1 -1
- package/commonjs/xlsx/parseExcelDate.js +139 -0
- package/commonjs/xlsx/parseExcelDate.js.map +1 -0
- package/commonjs/xlsx/parseExcelDate.test.js.map +1 -0
- package/commonjs/xlsx/parseSheet.js +9 -11
- package/commonjs/xlsx/parseSheet.js.map +1 -1
- package/commonjs/xlsx/{parseDimensions.js → parseSheetDimensions.js} +7 -6
- package/commonjs/xlsx/parseSheetDimensions.js.map +1 -0
- package/commonjs/xlsx/parseSpreadsheetContents.js +96 -0
- package/commonjs/xlsx/parseSpreadsheetContents.js.map +1 -0
- package/commonjs/xlsx/parseSpreadsheetInfo.js +47 -0
- package/commonjs/xlsx/parseSpreadsheetInfo.js.map +1 -0
- package/commonjs/xlsx/reconstructSheetDimensionsFromSheetCells.js +29 -0
- package/commonjs/xlsx/reconstructSheetDimensionsFromSheetCells.js.map +1 -0
- package/commonjs/xml/xlsx.js +9 -9
- package/commonjs/xml/xlsx.js.map +1 -1
- package/commonjs/xml/xpath/xlsx-xpath.js +8 -8
- package/commonjs/xml/xpath/xlsx-xpath.js.map +1 -1
- package/commonjs/xml/xpath/xpathBrowser.js +4 -4
- package/commonjs/xml/xpath/xpathBrowser.js.map +1 -1
- package/commonjs/xml/xpath/xpathNode.js +2 -2
- package/commonjs/xml/xpath/xpathNode.js.map +1 -1
- package/modules/export/parseSheet.js +13 -0
- package/modules/export/parseSheet.js.map +1 -0
- package/modules/export/readSheetBrowser.js +23 -0
- package/modules/export/readSheetBrowser.js.map +1 -0
- package/modules/export/readSheetNode.js +23 -0
- package/modules/export/readSheetNode.js.map +1 -0
- package/modules/export/readSheetUniversal.js +23 -0
- package/modules/export/readSheetUniversal.js.map +1 -0
- package/modules/export/readSheetWebWorker.js +23 -0
- package/modules/export/readSheetWebWorker.js.map +1 -0
- package/modules/export/readXlsxFileBrowser.js +6 -8
- package/modules/export/readXlsxFileBrowser.js.map +1 -1
- package/modules/export/readXlsxFileNode.js +7 -9
- package/modules/export/readXlsxFileNode.js.map +1 -1
- package/modules/export/readXlsxFileUniversal.js +7 -9
- package/modules/export/readXlsxFileUniversal.js.map +1 -1
- package/modules/export/readXlsxFileWebWorker.js +6 -8
- package/modules/export/readXlsxFileWebWorker.js.map +1 -1
- package/modules/export/unpackXlsxFileBrowser.js +3 -1
- package/modules/export/unpackXlsxFileBrowser.js.map +1 -1
- package/modules/export/unpackXlsxFileNode.js +4 -3
- package/modules/export/unpackXlsxFileNode.js.map +1 -1
- package/modules/export/unpackXlsxFileUniversal.js +13 -3
- package/modules/export/unpackXlsxFileUniversal.js.map +1 -1
- package/modules/parseData/InvalidError.js.map +1 -0
- package/modules/parseData/parseData.js +494 -0
- package/modules/parseData/parseData.js.map +1 -0
- package/modules/parseData/parseData.test.js.map +1 -0
- package/modules/{types → parseData/types}/Boolean.js +1 -1
- package/modules/parseData/types/Boolean.js.map +1 -0
- package/modules/parseData/types/Date.js +14 -0
- package/modules/parseData/types/Date.js.map +1 -0
- package/modules/{types → parseData/types}/Number.js +1 -1
- package/modules/parseData/types/Number.js.map +1 -0
- package/modules/{types → parseData/types}/String.js +1 -1
- package/modules/parseData/types/String.js.map +1 -0
- package/modules/{types → parseData/types/additional}/Email.js +3 -3
- package/modules/parseData/types/additional/Email.js.map +1 -0
- package/modules/parseData/types/additional/Email.test.js.map +1 -0
- package/modules/{types → parseData/types/additional}/Integer.js +2 -2
- package/modules/parseData/types/additional/Integer.js.map +1 -0
- package/modules/parseData/types/additional/Integer.test.js.map +1 -0
- package/modules/{types → parseData/types/additional}/URL.js +3 -3
- package/modules/parseData/types/additional/URL.js.map +1 -0
- package/modules/parseData/types/additional/URL.test.js.map +1 -0
- package/modules/xlsx/{getData.js → convertCellsToData2dArray.js} +15 -36
- package/modules/xlsx/convertCellsToData2dArray.js.map +1 -0
- package/modules/xlsx/{isDateTimestamp.js → isDateFormat.js} +57 -55
- package/modules/xlsx/isDateFormat.js.map +1 -0
- package/modules/xlsx/isDateFormat.test.js.map +1 -0
- package/modules/xlsx/isDateFormatStyle.js +186 -0
- package/modules/xlsx/isDateFormatStyle.js.map +1 -0
- package/modules/xlsx/parseCell.js +17 -19
- package/modules/xlsx/parseCell.js.map +1 -1
- package/modules/xlsx/parseCellCoordinates.js +38 -0
- package/modules/xlsx/parseCellCoordinates.js.map +1 -0
- package/modules/xlsx/parseCellValue.js +14 -11
- package/modules/xlsx/parseCellValue.js.map +1 -1
- package/modules/xlsx/parseCells.js +14 -6
- package/modules/xlsx/parseCells.js.map +1 -1
- package/modules/xlsx/parseExcelDate.js +133 -0
- package/modules/xlsx/parseExcelDate.js.map +1 -0
- package/modules/xlsx/parseExcelDate.test.js.map +1 -0
- package/modules/xlsx/parseSheet.js +9 -11
- package/modules/xlsx/parseSheet.js.map +1 -1
- package/modules/xlsx/{parseDimensions.js → parseSheetDimensions.js} +4 -4
- package/modules/xlsx/parseSheetDimensions.js.map +1 -0
- package/modules/xlsx/parseSpreadsheetContents.js +91 -0
- package/modules/xlsx/parseSpreadsheetContents.js.map +1 -0
- package/modules/xlsx/parseSpreadsheetInfo.js +42 -0
- package/modules/xlsx/parseSpreadsheetInfo.js.map +1 -0
- package/modules/xlsx/reconstructSheetDimensionsFromSheetCells.js +23 -0
- package/modules/xlsx/reconstructSheetDimensionsFromSheetCells.js.map +1 -0
- package/modules/xml/xlsx.js +6 -6
- package/modules/xml/xlsx.js.map +1 -1
- package/modules/xml/xpath/xlsx-xpath.js +6 -6
- package/modules/xml/xpath/xlsx-xpath.js.map +1 -1
- package/modules/xml/xpath/xpathBrowser.js +4 -4
- package/modules/xml/xpath/xpathBrowser.js.map +1 -1
- package/modules/xml/xpath/xpathNode.js +2 -2
- package/modules/xml/xpath/xpathNode.js.map +1 -1
- package/node/index.cjs +8 -5
- package/node/index.d.ts +56 -21
- package/node/index.js +7 -5
- package/node/input.d.ts +5 -0
- package/package.json +1 -1
- package/rollup.config.mjs +1 -1
- package/types/parseData/parseData.d.ts +38 -0
- package/types/parseData/parseDataError.d.ts +239 -0
- package/types/parseData/parseDataSchema.d.ts +48 -0
- package/types/parseData/parseDataValueType.d.ts +45 -0
- package/types/types.d.ts +20 -0
- package/universal/index.cjs +8 -5
- package/universal/index.d.ts +58 -16
- package/universal/index.js +7 -5
- package/universal/input.d.ts +1 -0
- package/web-worker/index.cjs +8 -5
- package/web-worker/index.d.ts +58 -16
- package/web-worker/index.js +7 -5
- package/web-worker/input.d.ts +1 -0
- package/commonjs/export/readSheetNamesBrowser.js +0 -23
- package/commonjs/export/readSheetNamesBrowser.js.map +0 -1
- package/commonjs/export/readSheetNamesNode.js +0 -23
- package/commonjs/export/readSheetNamesNode.js.map +0 -1
- package/commonjs/export/readSheetNamesUniversal.js +0 -23
- package/commonjs/export/readSheetNamesUniversal.js.map +0 -1
- package/commonjs/export/readSheetNamesWebWorker.js +0 -23
- package/commonjs/export/readSheetNamesWebWorker.js.map +0 -1
- package/commonjs/types/Boolean.js.map +0 -1
- package/commonjs/types/Date.js +0 -36
- package/commonjs/types/Date.js.map +0 -1
- package/commonjs/types/Email.js.map +0 -1
- package/commonjs/types/Email.test.js.map +0 -1
- package/commonjs/types/Integer.js.map +0 -1
- package/commonjs/types/Integer.test.js.map +0 -1
- package/commonjs/types/InvalidError.js.map +0 -1
- package/commonjs/types/Number.js.map +0 -1
- package/commonjs/types/String.js.map +0 -1
- package/commonjs/types/URL.js.map +0 -1
- package/commonjs/types/URL.test.js.map +0 -1
- package/commonjs/xlsx/coordinates.js +0 -55
- package/commonjs/xlsx/coordinates.js.map +0 -1
- package/commonjs/xlsx/getData.js.map +0 -1
- package/commonjs/xlsx/isDateTimestamp.js.map +0 -1
- package/commonjs/xlsx/parseDate.js +0 -73
- package/commonjs/xlsx/parseDate.js.map +0 -1
- package/commonjs/xlsx/parseDate.test.js.map +0 -1
- package/commonjs/xlsx/parseDimensions.js.map +0 -1
- package/commonjs/xlsx/parseProperties.js +0 -46
- package/commonjs/xlsx/parseProperties.js.map +0 -1
- package/commonjs/xlsx/parseXlsxFileContents.js +0 -119
- package/commonjs/xlsx/parseXlsxFileContents.js.map +0 -1
- package/commonjs/xlsx/parseXlsxFileContentsWithOptionalSchema.js +0 -45
- package/commonjs/xlsx/parseXlsxFileContentsWithOptionalSchema.js.map +0 -1
- package/commonjs/xlsx/schema/mapToObjects.js +0 -482
- package/commonjs/xlsx/schema/mapToObjects.js.map +0 -1
- package/commonjs/xlsx/schema/mapToObjects.test.js.map +0 -1
- package/modules/export/readSheetNamesBrowser.js +0 -17
- package/modules/export/readSheetNamesBrowser.js.map +0 -1
- package/modules/export/readSheetNamesNode.js +0 -17
- package/modules/export/readSheetNamesNode.js.map +0 -1
- package/modules/export/readSheetNamesUniversal.js +0 -17
- package/modules/export/readSheetNamesUniversal.js.map +0 -1
- package/modules/export/readSheetNamesWebWorker.js +0 -17
- package/modules/export/readSheetNamesWebWorker.js.map +0 -1
- package/modules/types/Boolean.js.map +0 -1
- package/modules/types/Date.js +0 -29
- package/modules/types/Date.js.map +0 -1
- package/modules/types/Email.js.map +0 -1
- package/modules/types/Email.test.js.map +0 -1
- package/modules/types/Integer.js.map +0 -1
- package/modules/types/Integer.test.js.map +0 -1
- package/modules/types/InvalidError.js.map +0 -1
- package/modules/types/Number.js.map +0 -1
- package/modules/types/String.js.map +0 -1
- package/modules/types/URL.js.map +0 -1
- package/modules/types/URL.test.js.map +0 -1
- package/modules/xlsx/coordinates.js +0 -48
- package/modules/xlsx/coordinates.js.map +0 -1
- package/modules/xlsx/getData.js.map +0 -1
- package/modules/xlsx/isDateTimestamp.js.map +0 -1
- package/modules/xlsx/parseDate.js +0 -67
- package/modules/xlsx/parseDate.js.map +0 -1
- package/modules/xlsx/parseDate.test.js.map +0 -1
- package/modules/xlsx/parseDimensions.js.map +0 -1
- package/modules/xlsx/parseProperties.js +0 -41
- package/modules/xlsx/parseProperties.js.map +0 -1
- package/modules/xlsx/parseXlsxFileContents.js +0 -114
- package/modules/xlsx/parseXlsxFileContents.js.map +0 -1
- package/modules/xlsx/parseXlsxFileContentsWithOptionalSchema.js +0 -39
- package/modules/xlsx/parseXlsxFileContentsWithOptionalSchema.js.map +0 -1
- package/modules/xlsx/schema/mapToObjects.js +0 -472
- package/modules/xlsx/schema/mapToObjects.js.map +0 -1
- package/modules/xlsx/schema/mapToObjects.test.js.map +0 -1
- package/types.d.ts +0 -121
- /package/commonjs/{types → parseData}/InvalidError.js +0 -0
- /package/modules/{types → parseData}/InvalidError.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xpathBrowser.js","names":["xpath","document","
|
|
1
|
+
{"version":3,"file":"xpathBrowser.js","names":["xpath","document","element","path","namespaces","arguments","length","undefined","elements","evaluate","prefix","XPathResult","ANY_TYPE","results","result","iterateNext","push"],"sources":["../../../source/xml/xpath/xpathBrowser.js"],"sourcesContent":["// This file is no longer used.\r\n\r\n// Turns out IE11 doesn't support XPath, so not using `./xpathBrowser` for browsers.\r\n// https://github.com/catamphetamine/read-excel-file/issues/26\r\n// The inclusion of `xpath` package in `./xpathNode`\r\n// increases the bundle size by about 100 kilobytes.\r\n// IE11 is a wide-spread browser and it's unlikely that\r\n// anyone would ignore it for now.\r\n// There could be a separate export `read-excel-file/ie11`\r\n// for using `./xpathNode` instead of `./xpathBrowser`\r\n// but this library has been migrated to not using `xpath` anyway.\r\n// This code is just alternative/historical now, it seems.\r\nexport default function xpath(document, element, path, namespaces = {}) {\r\n\tconst elements = document.evaluate(\r\n\t\tpath,\r\n\t\telement || document,\r\n\t\tprefix => namespaces[prefix],\r\n\t\tXPathResult.ANY_TYPE,\r\n\t\tnull\r\n\t)\r\n\t// Convert iterator to an array.\r\n\tconst results = []\r\n\tlet result = elements.iterateNext()\r\n\twhile (result) {\r\n\t\tresults.push(result)\r\n\t\tresult = elements.iterateNext()\r\n\t}\r\n\treturn results\r\n}"],"mappings":"AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASA,KAAKA,CAACC,QAAQ,EAAEC,OAAO,EAAEC,IAAI,EAAmB;EAAA,IAAjBC,UAAU,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EACrE,IAAMG,QAAQ,GAAGP,QAAQ,CAACQ,QAAQ,CACjCN,IAAI,EACJD,OAAO,IAAID,QAAQ,EACnB,UAAAS,MAAM;IAAA,OAAIN,UAAU,CAACM,MAAM,CAAC;EAAA,GAC5BC,WAAW,CAACC,QAAQ,EACpB,IACD,CAAC;EACD;EACA,IAAMC,OAAO,GAAG,EAAE;EAClB,IAAIC,MAAM,GAAGN,QAAQ,CAACO,WAAW,CAAC,CAAC;EACnC,OAAOD,MAAM,EAAE;IACdD,OAAO,CAACG,IAAI,CAACF,MAAM,CAAC;IACpBA,MAAM,GAAGN,QAAQ,CAACO,WAAW,CAAC,CAAC;EAChC;EACA,OAAOF,OAAO;AACf"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// This file is no longer used.
|
|
2
2
|
|
|
3
3
|
import xpath from 'xpath';
|
|
4
|
-
export default function (document,
|
|
4
|
+
export default function (document, element, path) {
|
|
5
5
|
var namespaces = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
6
6
|
var select = xpath.useNamespaces(namespaces);
|
|
7
|
-
return select(path,
|
|
7
|
+
return select(path, element || document);
|
|
8
8
|
}
|
|
9
9
|
//# sourceMappingURL=xpathNode.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xpathNode.js","names":["xpath","document","
|
|
1
|
+
{"version":3,"file":"xpathNode.js","names":["xpath","document","element","path","namespaces","arguments","length","undefined","select","useNamespaces"],"sources":["../../../source/xml/xpath/xpathNode.js"],"sourcesContent":["// This file is no longer used.\r\n\r\nimport xpath from 'xpath'\r\n\r\nexport default function(document, element, path, namespaces = {}) {\r\n\tconst select = xpath.useNamespaces(namespaces)\r\n\treturn select(path, element || document)\r\n}"],"mappings":"AAAA;;AAEA,OAAOA,KAAK,MAAM,OAAO;AAEzB,eAAe,UAASC,QAAQ,EAAEC,OAAO,EAAEC,IAAI,EAAmB;EAAA,IAAjBC,UAAU,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAC/D,IAAMG,MAAM,GAAGR,KAAK,CAACS,aAAa,CAACL,UAAU,CAAC;EAC9C,OAAOI,MAAM,CAACL,IAAI,EAAED,OAAO,IAAID,QAAQ,CAAC;AACzC"}
|
package/node/index.cjs
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
exports = module.exports = require('../commonjs/export/readXlsxFileNode.js').default
|
|
2
2
|
exports['default'] = require('../commonjs/export/readXlsxFileNode.js').default
|
|
3
|
-
|
|
4
|
-
exports.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
exports.
|
|
3
|
+
|
|
4
|
+
exports.readSheet = require('../commonjs/export/readSheetNode.js').default
|
|
5
|
+
|
|
6
|
+
// `parseData()`
|
|
7
|
+
exports.parseData = require('../commonjs/parseData/parseData.js').default
|
|
8
|
+
exports.Integer = require('../commonjs/parseData/types/additional/Integer.js').default
|
|
9
|
+
exports.Email = require('../commonjs/parseData/types/additional/Email.js').default
|
|
10
|
+
exports.URL = require('../commonjs/parseData/types/additional/URL.js').default
|
package/node/index.d.ts
CHANGED
|
@@ -1,36 +1,71 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
1
|
+
// The contents of this file is identical between the different exports:
|
|
2
|
+
// `/node`, `/browser`, etc.
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import { Stream } from 'stream';
|
|
6
|
-
import { Blob } from 'buffer'
|
|
4
|
+
import { Input } from './input.d.js'
|
|
7
5
|
|
|
8
6
|
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
SheetData,
|
|
8
|
+
ReadOptions,
|
|
9
|
+
ReadFileResult
|
|
10
|
+
} from '../types/types.d.js';
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
ParseDataOptions,
|
|
14
|
+
ParseDataResult
|
|
15
|
+
} from '../types/parseData/parseData.d.js';
|
|
16
|
+
|
|
17
|
+
import {
|
|
18
|
+
Schema
|
|
19
|
+
} from '../types/parseData/parseDataSchema.d.js';
|
|
14
20
|
|
|
15
21
|
export {
|
|
16
|
-
Schema,
|
|
17
|
-
ParsedObjectsResult,
|
|
18
|
-
SchemaParseCellValueError,
|
|
19
|
-
CellValueRequiredError,
|
|
20
22
|
CellValue,
|
|
21
23
|
Row,
|
|
24
|
+
SheetData
|
|
25
|
+
} from '../types/types.d.js';
|
|
26
|
+
|
|
27
|
+
export {
|
|
28
|
+
ParseDataValueCustomType as ParseDataValueType,
|
|
29
|
+
// Additional built-in `type`s when parsing data.
|
|
22
30
|
Integer,
|
|
23
31
|
Email,
|
|
24
32
|
URL
|
|
25
|
-
} from '../types.d.js';
|
|
33
|
+
} from '../types/parseData/parseDataValueType.d.js';
|
|
26
34
|
|
|
27
|
-
export
|
|
35
|
+
export {
|
|
36
|
+
ParseDataError,
|
|
37
|
+
ParseDataValueRequiredError
|
|
38
|
+
} from '../types/parseData/parseDataError.d.js';
|
|
39
|
+
|
|
40
|
+
export {
|
|
41
|
+
ParseDataResult
|
|
42
|
+
} from '../types/parseData/parseData.d.js';
|
|
43
|
+
|
|
44
|
+
export {
|
|
45
|
+
Schema
|
|
46
|
+
} from '../types/parseData/parseDataSchema.d.js';
|
|
28
47
|
|
|
29
|
-
|
|
48
|
+
export default function readXlsxFile<ParsedNumber = number>(
|
|
49
|
+
input: Input,
|
|
50
|
+
options?: ReadOptions<ParsedNumber>
|
|
51
|
+
): Promise<ReadFileResult<ParsedNumber>>;
|
|
30
52
|
|
|
31
|
-
export function
|
|
32
|
-
|
|
53
|
+
export function readSheet<ParsedNumber = number>(
|
|
54
|
+
input: Input,
|
|
55
|
+
sheet?: number | string,
|
|
56
|
+
options?: ReadOptions<ParsedNumber>
|
|
57
|
+
): Promise<SheetData<ParsedNumber>>;
|
|
33
58
|
|
|
34
|
-
export function
|
|
59
|
+
export function readSheet<ParsedNumber = number>(
|
|
60
|
+
input: Input,
|
|
61
|
+
options?: ReadOptions<ParsedNumber>
|
|
62
|
+
): Promise<SheetData<ParsedNumber>>;
|
|
35
63
|
|
|
36
|
-
export
|
|
64
|
+
export function parseData<
|
|
65
|
+
Object extends object,
|
|
66
|
+
ColumnTitle extends string
|
|
67
|
+
>(
|
|
68
|
+
data: SheetData,
|
|
69
|
+
schema: Schema<Object, ColumnTitle>,
|
|
70
|
+
options?: ParseDataOptions
|
|
71
|
+
): ParseDataResult<Object>;
|
package/node/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { default as default } from '../modules/export/readXlsxFileNode.js'
|
|
2
|
-
export { default as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export { default as
|
|
6
|
-
export { default as
|
|
2
|
+
export { default as readSheet } from '../modules/export/readSheetNode.js'
|
|
3
|
+
|
|
4
|
+
// `parseData()`
|
|
5
|
+
export { default as parseData } from '../modules/parseData/parseData.js'
|
|
6
|
+
export { default as Integer } from '../modules/parseData/types/additional/Integer.js'
|
|
7
|
+
export { default as Email } from '../modules/parseData/types/additional/Email.js'
|
|
8
|
+
export { default as URL } from '../modules/parseData/types/additional/URL.js'
|
package/node/input.d.ts
ADDED
package/package.json
CHANGED
package/rollup.config.mjs
CHANGED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ParseDataPossibleError } from './parseDataError.d.js'
|
|
2
|
+
import { ParseDataValueCustomType } from './parseDataValueType.d.js'
|
|
3
|
+
|
|
4
|
+
export type ParseDataResult<
|
|
5
|
+
Object,
|
|
6
|
+
ParseDataValueCustomType_ extends ParseDataValueCustomType<unknown> = never
|
|
7
|
+
> = ParseDataResultItem<
|
|
8
|
+
Object,
|
|
9
|
+
ParseDataValueCustomType_
|
|
10
|
+
>[]
|
|
11
|
+
|
|
12
|
+
type ParseDataResultItem<
|
|
13
|
+
Object,
|
|
14
|
+
ParseDataValueCustomType_ extends ParseDataValueCustomType<unknown> = never
|
|
15
|
+
> =
|
|
16
|
+
| ParseDataResultItemSuccess<Object>
|
|
17
|
+
| ParseDataResultItemError<ParseDataValueCustomType_>
|
|
18
|
+
|
|
19
|
+
interface ParseDataResultItemSuccess<Object> {
|
|
20
|
+
object: Object;
|
|
21
|
+
errors: undefined;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface ParseDataResultItemError<
|
|
25
|
+
ParseDataValueCustomType_ extends ParseDataValueCustomType<unknown> = never
|
|
26
|
+
> {
|
|
27
|
+
object: undefined;
|
|
28
|
+
errors: ParseDataPossibleError<ParseDataValueCustomType_>[];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface ParseDataOptions {
|
|
32
|
+
propertyValueWhenColumnIsMissing?: any;
|
|
33
|
+
propertyValueWhenCellIsEmpty?: any;
|
|
34
|
+
transformEmptyArray?(arrayPropertyValue: never[], parameters: { path: string }): any;
|
|
35
|
+
transformEmptyObject?(object: Record<string, undefined | null>, parameters: { path?: string }): any;
|
|
36
|
+
// shouldSkipRequiredValidationWhenColumnIsMissing?(columnTitle: string, parameters: { object: Record<string, any> }): boolean;
|
|
37
|
+
arrayValueSeparator?: string;
|
|
38
|
+
}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { CellValue } from '../types.d.js'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
Constructor,
|
|
5
|
+
ParseDataValueCustomType,
|
|
6
|
+
ParseDataValueType,
|
|
7
|
+
Integer,
|
|
8
|
+
Email,
|
|
9
|
+
URL
|
|
10
|
+
} from './parseDataValueType.d.js'
|
|
11
|
+
|
|
12
|
+
// When `error` is `"required"`, `value` could only be `null` or `undefined`.
|
|
13
|
+
export interface ParseDataValueRequiredError<
|
|
14
|
+
ParseDataValueType = unknown,
|
|
15
|
+
ColumnTitle = string
|
|
16
|
+
> {
|
|
17
|
+
// row: number;
|
|
18
|
+
column: ColumnTitle;
|
|
19
|
+
type?: ParseDataValueType;
|
|
20
|
+
error: 'required';
|
|
21
|
+
reason: undefined;
|
|
22
|
+
value: null | undefined;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// When `error` is not `"required"`, `value` is known to not be `null` or `undefined`
|
|
26
|
+
// because when `value` is `null` or `undefined`, it won't be parsed at all,
|
|
27
|
+
// so there can't be any error thrown during parsing phase.
|
|
28
|
+
interface ParseDataError_<
|
|
29
|
+
ParseDataValueType extends ParseDataValueCustomType<unknown> | undefined = ParseDataValueCustomType<unknown>,
|
|
30
|
+
ColumnTitle = string,
|
|
31
|
+
ErrorMessage extends string = string,
|
|
32
|
+
ErrorReason extends string | undefined = string | undefined
|
|
33
|
+
> {
|
|
34
|
+
// row: number;
|
|
35
|
+
column: ColumnTitle;
|
|
36
|
+
type: ParseDataValueType;
|
|
37
|
+
error: ErrorMessage;
|
|
38
|
+
reason: ErrorReason;
|
|
39
|
+
value: CellValue;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface ParseDataError<
|
|
43
|
+
ParseDataValueType extends ParseDataValueCustomType<unknown> = ParseDataValueCustomType<unknown>,
|
|
44
|
+
ColumnTitle = string,
|
|
45
|
+
ErrorMessage extends string = string,
|
|
46
|
+
ErrorReason extends string | undefined = string | undefined
|
|
47
|
+
> extends ParseDataError_<
|
|
48
|
+
ParseDataValueType,
|
|
49
|
+
ColumnTitle,
|
|
50
|
+
ErrorMessage,
|
|
51
|
+
ErrorReason
|
|
52
|
+
> {}
|
|
53
|
+
|
|
54
|
+
interface ParseDataErrorNotABoolean<ColumnTitle = string> extends ParseDataError_<
|
|
55
|
+
Constructor<Boolean>,
|
|
56
|
+
ColumnTitle,
|
|
57
|
+
'not_a_boolean',
|
|
58
|
+
undefined
|
|
59
|
+
> {
|
|
60
|
+
value: Exclude<CellValue, boolean>;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
interface ParseDataErrorNotADate<ColumnTitle = string> extends ParseDataError_<
|
|
64
|
+
Constructor<Date>,
|
|
65
|
+
ColumnTitle,
|
|
66
|
+
'not_a_date',
|
|
67
|
+
undefined
|
|
68
|
+
> {
|
|
69
|
+
value: Exclude<CellValue, typeof Date | number>;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
interface ParseDataErrorDateOutOfBounds<ColumnTitle = string> extends ParseDataError_<
|
|
73
|
+
Constructor<Date>,
|
|
74
|
+
ColumnTitle,
|
|
75
|
+
'out_of_bounds',
|
|
76
|
+
undefined
|
|
77
|
+
> {
|
|
78
|
+
value: typeof Date;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
interface ParseDataErrorNotAString<ColumnTitle = string> extends ParseDataError_<
|
|
82
|
+
Constructor<String> | undefined,
|
|
83
|
+
ColumnTitle,
|
|
84
|
+
'not_a_string',
|
|
85
|
+
undefined
|
|
86
|
+
> {
|
|
87
|
+
value: Exclude<CellValue, string | number>;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
interface ParseDataErrorStringInvalidNumber<ColumnTitle = string> extends ParseDataError_<
|
|
91
|
+
Constructor<String> | undefined,
|
|
92
|
+
ColumnTitle,
|
|
93
|
+
'invalid_number',
|
|
94
|
+
undefined
|
|
95
|
+
> {
|
|
96
|
+
value: number;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
interface ParseDataErrorStringNumberOutOfBounds<ColumnTitle = string> extends ParseDataError_<
|
|
100
|
+
Constructor<String> | undefined,
|
|
101
|
+
ColumnTitle,
|
|
102
|
+
'out_of_bounds',
|
|
103
|
+
undefined
|
|
104
|
+
> {
|
|
105
|
+
value: number;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
interface ParseDataErrorNotANumber<
|
|
109
|
+
Type extends ParseDataValueCustomType<unknown> | undefined = Constructor<Number>,
|
|
110
|
+
ColumnTitle = string
|
|
111
|
+
> extends ParseDataError_<
|
|
112
|
+
Type,
|
|
113
|
+
ColumnTitle,
|
|
114
|
+
'not_a_number',
|
|
115
|
+
undefined
|
|
116
|
+
> {
|
|
117
|
+
value: Exclude<CellValue, number | string>;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
interface ParseDataErrorNotANumberString<
|
|
121
|
+
Type extends ParseDataValueCustomType<unknown> | undefined = Constructor<Number>,
|
|
122
|
+
ColumnTitle = string
|
|
123
|
+
> extends ParseDataError_<
|
|
124
|
+
Type,
|
|
125
|
+
ColumnTitle,
|
|
126
|
+
'not_a_number',
|
|
127
|
+
undefined
|
|
128
|
+
> {
|
|
129
|
+
value: string;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
interface ParseDataErrorNumberInvalid<
|
|
133
|
+
Type extends ParseDataValueCustomType<unknown> | undefined = Constructor<Number>,
|
|
134
|
+
ColumnTitle = string
|
|
135
|
+
> extends ParseDataError_<
|
|
136
|
+
Type,
|
|
137
|
+
ColumnTitle,
|
|
138
|
+
'invalid_number',
|
|
139
|
+
undefined
|
|
140
|
+
> {
|
|
141
|
+
value: number | string;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
interface ParseDataErrorNumberOutOfBounds<
|
|
145
|
+
Type extends ParseDataValueCustomType<unknown> | undefined = Constructor<Number>,
|
|
146
|
+
ColumnTitle = string
|
|
147
|
+
> extends ParseDataError_<
|
|
148
|
+
Type,
|
|
149
|
+
ColumnTitle,
|
|
150
|
+
'out_of_bounds',
|
|
151
|
+
undefined
|
|
152
|
+
> {
|
|
153
|
+
value: number | string;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
type ParseDataBaseValueTypeError<ColumnTitle = string> =
|
|
157
|
+
| ParseDataErrorNotABoolean<ColumnTitle>
|
|
158
|
+
| ParseDataErrorNotADate<ColumnTitle>
|
|
159
|
+
| ParseDataErrorDateOutOfBounds<ColumnTitle>
|
|
160
|
+
| ParseDataErrorNotAString<ColumnTitle>
|
|
161
|
+
| ParseDataErrorStringInvalidNumber<ColumnTitle>
|
|
162
|
+
| ParseDataErrorStringNumberOutOfBounds<ColumnTitle>
|
|
163
|
+
| ParseDataErrorNotANumber<Constructor<Number>, ColumnTitle>
|
|
164
|
+
| ParseDataErrorNotANumberString<Constructor<Number>, ColumnTitle>
|
|
165
|
+
| ParseDataErrorNumberInvalid<Constructor<Number>, ColumnTitle>
|
|
166
|
+
| ParseDataErrorNumberOutOfBounds<Constructor<Number>, ColumnTitle>;
|
|
167
|
+
|
|
168
|
+
interface ParseDataErrorNotAnInteger<ColumnTitle = string> extends ParseDataError_<
|
|
169
|
+
typeof Integer,
|
|
170
|
+
ColumnTitle,
|
|
171
|
+
'not_an_integer',
|
|
172
|
+
undefined
|
|
173
|
+
> {
|
|
174
|
+
value: number | string;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
interface ParseDataErrorIntegerNotANumber<ColumnTitle = string> extends ParseDataErrorNotANumber<typeof Integer, ColumnTitle> {}
|
|
178
|
+
interface ParseDataErrorIntegerNotANumberString<ColumnTitle = string> extends ParseDataErrorNotANumberString<typeof Integer, ColumnTitle> {}
|
|
179
|
+
interface ParseDataErrorIntegerNumberInvalid<ColumnTitle = string> extends ParseDataErrorNumberInvalid<typeof Integer, ColumnTitle> {}
|
|
180
|
+
interface ParseDataErrorIntegerNumberOutOfBounds<ColumnTitle = string> extends ParseDataErrorNumberOutOfBounds<typeof Integer, ColumnTitle> {}
|
|
181
|
+
|
|
182
|
+
interface ParseDataErrorNotAUrl<ColumnTitle = string> extends ParseDataError_<
|
|
183
|
+
typeof URL,
|
|
184
|
+
ColumnTitle,
|
|
185
|
+
'not_a_url',
|
|
186
|
+
undefined
|
|
187
|
+
> {
|
|
188
|
+
value: string;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
interface ParseDataErrorUrlNotAString<ColumnTitle = string> extends ParseDataError_<
|
|
192
|
+
typeof URL,
|
|
193
|
+
ColumnTitle,
|
|
194
|
+
'not_a_string',
|
|
195
|
+
undefined
|
|
196
|
+
> {
|
|
197
|
+
value: Exclude<CellValue, string>;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
interface ParseDataErrorNotAnEmail<ColumnTitle = string> extends ParseDataError_<
|
|
201
|
+
typeof Email,
|
|
202
|
+
ColumnTitle,
|
|
203
|
+
'not_an_email',
|
|
204
|
+
undefined
|
|
205
|
+
> {
|
|
206
|
+
value: string;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
interface ParseDataErrorEmailNotAString<ColumnTitle = string> extends ParseDataError_<
|
|
210
|
+
typeof Email,
|
|
211
|
+
ColumnTitle,
|
|
212
|
+
'not_a_string',
|
|
213
|
+
undefined
|
|
214
|
+
> {
|
|
215
|
+
value: Exclude<CellValue, string>;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
type ParseDataAdditionalBuiltInValueTypeError<ColumnTitle = string> =
|
|
219
|
+
| ParseDataErrorNotAnInteger<ColumnTitle>
|
|
220
|
+
| ParseDataErrorIntegerNotANumber<ColumnTitle>
|
|
221
|
+
| ParseDataErrorIntegerNotANumberString<ColumnTitle>
|
|
222
|
+
| ParseDataErrorIntegerNumberInvalid<ColumnTitle>
|
|
223
|
+
| ParseDataErrorIntegerNumberOutOfBounds<ColumnTitle>
|
|
224
|
+
| ParseDataErrorNotAUrl<ColumnTitle>
|
|
225
|
+
| ParseDataErrorUrlNotAString<ColumnTitle>
|
|
226
|
+
| ParseDataErrorNotAnEmail<ColumnTitle>
|
|
227
|
+
| ParseDataErrorEmailNotAString<ColumnTitle>;
|
|
228
|
+
|
|
229
|
+
type ParseDataBuiltInValueTypeError<ColumnTitle = string> =
|
|
230
|
+
| ParseDataBaseValueTypeError<ColumnTitle>
|
|
231
|
+
| ParseDataAdditionalBuiltInValueTypeError<ColumnTitle>;
|
|
232
|
+
|
|
233
|
+
export type ParseDataPossibleError<
|
|
234
|
+
ParseDataValueCustomType_ extends ParseDataValueCustomType<unknown>,
|
|
235
|
+
ColumnTitle = string
|
|
236
|
+
> =
|
|
237
|
+
| ParseDataBuiltInValueTypeError<ColumnTitle>
|
|
238
|
+
| ParseDataValueRequiredError<ParseDataValueType<ParseDataValueCustomType_>, ColumnTitle>
|
|
239
|
+
| ParseDataError<ParseDataValueType<ParseDataValueCustomType_>, ColumnTitle>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ParseDataValueType, ParseDataValueCustomType } from './parseDataValueType.js'
|
|
2
|
+
|
|
3
|
+
type SchemaEntryRequiredOrNot<Object> = boolean | ((row: Object) => boolean);
|
|
4
|
+
|
|
5
|
+
interface SchemaEntryForValue<
|
|
6
|
+
Key extends keyof Object,
|
|
7
|
+
Object,
|
|
8
|
+
TopLevelObject,
|
|
9
|
+
ColumnTitle extends string
|
|
10
|
+
> {
|
|
11
|
+
column: ColumnTitle;
|
|
12
|
+
type?: ParseDataValueType<ParseDataValueCustomType<Object[Key]>>;
|
|
13
|
+
oneOf?: Object[Key][];
|
|
14
|
+
required?: SchemaEntryRequiredOrNot<TopLevelObject>;
|
|
15
|
+
validate?(value: Object[Key]): void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Implementing recursive types in TypeScript:
|
|
19
|
+
// https://dev.to/busypeoples/notes-on-typescript-recursive-types-and-immutability-5ck1
|
|
20
|
+
interface SchemaEntryRecursive<
|
|
21
|
+
Key extends keyof Object,
|
|
22
|
+
Object,
|
|
23
|
+
TopLevelObject,
|
|
24
|
+
ColumnTitle extends string
|
|
25
|
+
> {
|
|
26
|
+
schema: Record<
|
|
27
|
+
keyof Object[Key],
|
|
28
|
+
SchemaEntry<keyof Object[Key], Object[Key], TopLevelObject, ColumnTitle>
|
|
29
|
+
>;
|
|
30
|
+
required?: SchemaEntryRequiredOrNot<TopLevelObject>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
type SchemaEntry<
|
|
34
|
+
Key extends keyof Object,
|
|
35
|
+
Object,
|
|
36
|
+
TopLevelObject,
|
|
37
|
+
ColumnTitle extends string
|
|
38
|
+
> =
|
|
39
|
+
| SchemaEntryForValue<Key, Object, TopLevelObject, ColumnTitle>
|
|
40
|
+
| SchemaEntryRecursive<Key, Object, TopLevelObject, ColumnTitle>;
|
|
41
|
+
|
|
42
|
+
export type Schema<
|
|
43
|
+
Object = Record<string, any>,
|
|
44
|
+
ColumnTitle extends string = string
|
|
45
|
+
> = Record<
|
|
46
|
+
keyof Object,
|
|
47
|
+
SchemaEntry<keyof Object, Object, Object, ColumnTitle>
|
|
48
|
+
>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { CellValue } from '../types.d.js';
|
|
2
|
+
|
|
3
|
+
// A way to define a `type = String` or `type = Number` variable in TypeScript
|
|
4
|
+
// is by defining it as `type: StringConstructor` or `type: NumberConstructor`.
|
|
5
|
+
// https://gitlab.com/catamphetamine/write-excel-file/-/issues/4#note_715204034
|
|
6
|
+
// https://www.typescriptlang.org/docs/handbook/2/conditional-types.html
|
|
7
|
+
export type Constructor<Type> =
|
|
8
|
+
Type extends String
|
|
9
|
+
? StringConstructor
|
|
10
|
+
: Type extends Date
|
|
11
|
+
? DateConstructor
|
|
12
|
+
: Type extends Number
|
|
13
|
+
? NumberConstructor
|
|
14
|
+
: Type extends Boolean
|
|
15
|
+
? BooleanConstructor
|
|
16
|
+
: never;
|
|
17
|
+
|
|
18
|
+
// Parsed value `type` (foundational ones).
|
|
19
|
+
type BaseType =
|
|
20
|
+
Constructor<String> |
|
|
21
|
+
Constructor<Date> |
|
|
22
|
+
Constructor<Number> |
|
|
23
|
+
Constructor<Boolean>;
|
|
24
|
+
|
|
25
|
+
// Parsed value `type` (custom one).
|
|
26
|
+
// A function that receives a cell `value` and returns a "parsed" value.
|
|
27
|
+
// Returning `undefined` will have same effect as returning `null`.
|
|
28
|
+
// When cell value is `undefined` or `null`, its `type` is completely ignored (skipped).
|
|
29
|
+
export type ParseDataValueCustomType<ParsedValue> = (value: CellValue) => ParsedValue | undefined | null;
|
|
30
|
+
|
|
31
|
+
// Parsed value `type` (additional built-in ones).
|
|
32
|
+
export function Integer(value: CellValue): number;
|
|
33
|
+
export function URL(value: CellValue): string;
|
|
34
|
+
export function Email(value: CellValue): string;
|
|
35
|
+
|
|
36
|
+
type AdditionalBuiltInParseDataValueType =
|
|
37
|
+
| typeof Integer
|
|
38
|
+
| typeof URL
|
|
39
|
+
| typeof Email;
|
|
40
|
+
|
|
41
|
+
// Schema entry `type`: foundational ones, additional ones, custom ones.
|
|
42
|
+
export type ParseDataValueType<ParseDataValueCustomType> =
|
|
43
|
+
| BaseType
|
|
44
|
+
| AdditionalBuiltInParseDataValueType
|
|
45
|
+
| ParseDataValueCustomType;
|
package/types/types.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type CellValue<ParsedNumber = number> =
|
|
2
|
+
| string
|
|
3
|
+
| ParsedNumber
|
|
4
|
+
| boolean
|
|
5
|
+
| typeof Date
|
|
6
|
+
|
|
7
|
+
export type Row<ParsedNumber = number> = (CellValue<ParsedNumber> | null)[]
|
|
8
|
+
|
|
9
|
+
export type SheetData<ParsedNumber = number> = Row<ParsedNumber>[]
|
|
10
|
+
|
|
11
|
+
export type ReadFileResult<ParsedNumber = number> = {
|
|
12
|
+
sheet: string;
|
|
13
|
+
data: SheetData<ParsedNumber>;
|
|
14
|
+
}[]
|
|
15
|
+
|
|
16
|
+
export interface ReadOptions<ParsedNumber = number> {
|
|
17
|
+
trim?: boolean;
|
|
18
|
+
parseNumber?: (string: string) => ParsedNumber;
|
|
19
|
+
dateFormat?: string;
|
|
20
|
+
}
|
package/universal/index.cjs
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
exports = module.exports = require('../commonjs/export/readXlsxFileUniversal.js').default
|
|
2
2
|
exports['default'] = require('../commonjs/export/readXlsxFileUniversal.js').default
|
|
3
|
-
|
|
4
|
-
exports.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
exports.
|
|
3
|
+
|
|
4
|
+
exports.readSheet = require('../commonjs/export/readSheetUniversal.js').default
|
|
5
|
+
|
|
6
|
+
// `parseData()`
|
|
7
|
+
exports.parseData = require('../commonjs/parseData/parseData.js').default
|
|
8
|
+
exports.Integer = require('../commonjs/parseData/types/additional/Integer.js').default
|
|
9
|
+
exports.Email = require('../commonjs/parseData/types/additional/Email.js').default
|
|
10
|
+
exports.URL = require('../commonjs/parseData/types/additional/URL.js').default
|