read-excel-file 9.3.4 → 9.3.5

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.
Files changed (251) hide show
  1. package/CHANGELOG.md +6 -2
  2. package/README.md +32 -2
  3. package/browser/index.cjs +3 -0
  4. package/browser/index.d.ts +16 -0
  5. package/browser/index.js +4 -1
  6. package/bundle/read-excel-file.min.js +1 -1
  7. package/bundle/read-excel-file.min.js.map +1 -1
  8. package/commonjs/export/convertInputToNodeStream.js +0 -12
  9. package/commonjs/export/convertInputToNodeStream.js.map +1 -1
  10. package/commonjs/export/parseSheet.js +14 -7
  11. package/commonjs/export/parseSheet.js.map +1 -1
  12. package/commonjs/export/readSheetBrowser.js +3 -6
  13. package/commonjs/export/readSheetBrowser.js.map +1 -1
  14. package/commonjs/export/readSheetNode.js +3 -6
  15. package/commonjs/export/readSheetNode.js.map +1 -1
  16. package/commonjs/export/readSheetUniversal.js +2 -2
  17. package/commonjs/export/readSheetUniversal.js.map +1 -1
  18. package/commonjs/export/readSheetWebWorker.js +5 -5
  19. package/commonjs/export/readSheetWebWorker.js.map +1 -1
  20. package/commonjs/export/readXlsxFileBrowser.js +3 -6
  21. package/commonjs/export/readXlsxFileBrowser.js.map +1 -1
  22. package/commonjs/export/readXlsxFileNode.js +3 -6
  23. package/commonjs/export/readXlsxFileNode.js.map +1 -1
  24. package/commonjs/export/readXlsxFileUniversal.js +2 -2
  25. package/commonjs/export/readXlsxFileUniversal.js.map +1 -1
  26. package/commonjs/export/readXlsxFileWebWorker.js +5 -5
  27. package/commonjs/export/readXlsxFileWebWorker.js.map +1 -1
  28. package/commonjs/export/unpackXlsxFileBrowser.js +15 -4
  29. package/commonjs/export/unpackXlsxFileBrowser.js.map +1 -1
  30. package/commonjs/export/unpackXlsxFileBrowser.test.js.map +1 -0
  31. package/commonjs/export/unpackXlsxFileNode.js +32 -5
  32. package/commonjs/export/unpackXlsxFileNode.js.map +1 -1
  33. package/commonjs/export/unpackXlsxFileNode.test.js.map +1 -0
  34. package/commonjs/export/unpackXlsxFileUniversal.js +14 -3
  35. package/commonjs/export/unpackXlsxFileUniversal.js.map +1 -1
  36. package/commonjs/export/unpackXlsxFileUniversal.test.js.map +1 -0
  37. package/commonjs/parseSheetData/parseSheetData.js +9 -6
  38. package/commonjs/parseSheetData/parseSheetData.js.map +1 -1
  39. package/commonjs/utility/convertValuesFromUint8ArraysToStrings.js +100 -0
  40. package/commonjs/utility/convertValuesFromUint8ArraysToStrings.js.map +1 -0
  41. package/commonjs/xlsx/InvalidSpreadsheetError.js +55 -0
  42. package/commonjs/xlsx/InvalidSpreadsheetError.js.map +1 -0
  43. package/commonjs/xlsx/SheetNotFoundError.js +55 -0
  44. package/commonjs/xlsx/SheetNotFoundError.js.map +1 -0
  45. package/commonjs/xlsx/file/InputValidationStream.js +101 -0
  46. package/commonjs/xlsx/file/InputValidationStream.js.map +1 -0
  47. package/commonjs/xlsx/file/InputValidationStream.test.js.map +1 -0
  48. package/commonjs/xlsx/file/InvalidInputError.js +105 -0
  49. package/commonjs/xlsx/file/InvalidInputError.js.map +1 -0
  50. package/commonjs/xlsx/file/createFileTypeDetector.js +70 -0
  51. package/commonjs/xlsx/file/createFileTypeDetector.js.map +1 -0
  52. package/commonjs/xlsx/file/createFileTypeDetector.test.js.map +1 -0
  53. package/commonjs/xlsx/file/validateLeadingBytes.js +47 -0
  54. package/commonjs/xlsx/file/validateLeadingBytes.js.map +1 -0
  55. package/commonjs/xlsx/file/validateLeadingBytes.test.js.map +1 -0
  56. package/commonjs/xlsx/isDateFormat.js +32 -27
  57. package/commonjs/xlsx/isDateFormat.js.map +1 -1
  58. package/commonjs/xlsx/isDateFormatStyle.js +19 -21
  59. package/commonjs/xlsx/isDateFormatStyle.js.map +1 -1
  60. package/commonjs/xlsx/parseCell.js +252 -115
  61. package/commonjs/xlsx/parseCell.js.map +1 -1
  62. package/commonjs/xlsx/parseCellAddress.js +22 -18
  63. package/commonjs/xlsx/parseCellAddress.js.map +1 -1
  64. package/commonjs/xlsx/parseExcelDate.js +4 -124
  65. package/commonjs/xlsx/parseExcelDate.js.map +1 -1
  66. package/commonjs/xlsx/parseExcelDate.test.js.map +1 -1
  67. package/commonjs/xlsx/parseExcelTimestamp.js +139 -0
  68. package/commonjs/xlsx/parseExcelTimestamp.js.map +1 -0
  69. package/commonjs/xlsx/parseFilePaths.js +48 -47
  70. package/commonjs/xlsx/parseFilePaths.js.map +1 -1
  71. package/commonjs/xlsx/parseSharedStrings.js +91 -36
  72. package/commonjs/xlsx/parseSharedStrings.js.map +1 -1
  73. package/commonjs/xlsx/parseSheet.js +527 -69
  74. package/commonjs/xlsx/parseSheet.js.map +1 -1
  75. package/commonjs/xlsx/parseSpreadsheetContents.js +154 -83
  76. package/commonjs/xlsx/parseSpreadsheetContents.js.map +1 -1
  77. package/commonjs/xlsx/parseSpreadsheetInfo.js +60 -59
  78. package/commonjs/xlsx/parseSpreadsheetInfo.js.map +1 -1
  79. package/commonjs/xlsx/parseStyles.js +75 -75
  80. package/commonjs/xlsx/parseStyles.js.map +1 -1
  81. package/commonjs/xml/parseXml.js +112 -0
  82. package/commonjs/xml/parseXml.js.map +1 -0
  83. package/commonjs/xml/parseXml.test.js.map +1 -0
  84. package/commonjs/xml/parseXmlStream.js.map +1 -1
  85. package/commonjs/xml/parseXmlStream.sax.js +69 -28
  86. package/commonjs/xml/parseXmlStream.sax.js.map +1 -1
  87. package/commonjs/xml/parseXmlStream.saxen.js +66 -40
  88. package/commonjs/xml/parseXmlStream.saxen.js.map +1 -1
  89. package/commonjs/zip/UnzipError.js +55 -0
  90. package/commonjs/zip/UnzipError.js.map +1 -0
  91. package/commonjs/zip/unzipFromArrayBuffer.js +21 -1
  92. package/commonjs/zip/unzipFromArrayBuffer.js.map +1 -1
  93. package/commonjs/zip/unzipFromArrayBuffer.test.js.map +1 -0
  94. package/commonjs/zip/unzipFromStream.fflate.js +43 -35
  95. package/commonjs/zip/unzipFromStream.fflate.js.map +1 -1
  96. package/commonjs/zip/unzipFromStream.js +188 -6
  97. package/commonjs/zip/unzipFromStream.js.map +1 -1
  98. package/commonjs/zip/unzipFromStream.unzipper.js +19 -34
  99. package/commonjs/zip/unzipFromStream.unzipper.js.map +1 -1
  100. package/modules/export/convertInputToNodeStream.js +0 -12
  101. package/modules/export/convertInputToNodeStream.js.map +1 -1
  102. package/modules/export/parseSheet.js +13 -6
  103. package/modules/export/parseSheet.js.map +1 -1
  104. package/modules/export/readSheetBrowser.js +3 -5
  105. package/modules/export/readSheetBrowser.js.map +1 -1
  106. package/modules/export/readSheetNode.js +3 -5
  107. package/modules/export/readSheetNode.js.map +1 -1
  108. package/modules/export/readSheetUniversal.js +2 -2
  109. package/modules/export/readSheetUniversal.js.map +1 -1
  110. package/modules/export/readSheetWebWorker.js +7 -8
  111. package/modules/export/readSheetWebWorker.js.map +1 -1
  112. package/modules/export/readXlsxFileBrowser.js +3 -5
  113. package/modules/export/readXlsxFileBrowser.js.map +1 -1
  114. package/modules/export/readXlsxFileNode.js +3 -5
  115. package/modules/export/readXlsxFileNode.js.map +1 -1
  116. package/modules/export/readXlsxFileUniversal.js +2 -2
  117. package/modules/export/readXlsxFileUniversal.js.map +1 -1
  118. package/modules/export/readXlsxFileWebWorker.js +7 -8
  119. package/modules/export/readXlsxFileWebWorker.js.map +1 -1
  120. package/modules/export/unpackXlsxFileBrowser.js +15 -4
  121. package/modules/export/unpackXlsxFileBrowser.js.map +1 -1
  122. package/modules/export/unpackXlsxFileBrowser.test.js.map +1 -0
  123. package/modules/export/unpackXlsxFileNode.js +32 -5
  124. package/modules/export/unpackXlsxFileNode.js.map +1 -1
  125. package/modules/export/unpackXlsxFileNode.test.js.map +1 -0
  126. package/modules/export/unpackXlsxFileUniversal.js +14 -3
  127. package/modules/export/unpackXlsxFileUniversal.js.map +1 -1
  128. package/modules/export/unpackXlsxFileUniversal.test.js.map +1 -0
  129. package/modules/parseSheetData/parseSheetData.js +9 -6
  130. package/modules/parseSheetData/parseSheetData.js.map +1 -1
  131. package/modules/utility/convertValuesFromUint8ArraysToStrings.js +92 -0
  132. package/modules/utility/convertValuesFromUint8ArraysToStrings.js.map +1 -0
  133. package/modules/xlsx/InvalidSpreadsheetError.js +50 -0
  134. package/modules/xlsx/InvalidSpreadsheetError.js.map +1 -0
  135. package/modules/xlsx/SheetNotFoundError.js +50 -0
  136. package/modules/xlsx/SheetNotFoundError.js.map +1 -0
  137. package/modules/xlsx/file/InputValidationStream.js +96 -0
  138. package/modules/xlsx/file/InputValidationStream.js.map +1 -0
  139. package/modules/xlsx/file/InputValidationStream.test.js.map +1 -0
  140. package/modules/xlsx/file/InvalidInputError.js +100 -0
  141. package/modules/xlsx/file/InvalidInputError.js.map +1 -0
  142. package/modules/xlsx/file/createFileTypeDetector.js +63 -0
  143. package/modules/xlsx/file/createFileTypeDetector.js.map +1 -0
  144. package/modules/xlsx/file/createFileTypeDetector.test.js.map +1 -0
  145. package/modules/xlsx/file/validateLeadingBytes.js +37 -0
  146. package/modules/xlsx/file/validateLeadingBytes.js.map +1 -0
  147. package/modules/xlsx/file/validateLeadingBytes.test.js.map +1 -0
  148. package/modules/xlsx/isDateFormat.js +31 -27
  149. package/modules/xlsx/isDateFormat.js.map +1 -1
  150. package/modules/xlsx/isDateFormatStyle.js +18 -21
  151. package/modules/xlsx/isDateFormatStyle.js.map +1 -1
  152. package/modules/xlsx/parseCell.js +251 -111
  153. package/modules/xlsx/parseCell.js.map +1 -1
  154. package/modules/xlsx/parseCellAddress.js +21 -18
  155. package/modules/xlsx/parseCellAddress.js.map +1 -1
  156. package/modules/xlsx/parseExcelDate.js +4 -124
  157. package/modules/xlsx/parseExcelDate.js.map +1 -1
  158. package/modules/xlsx/parseExcelDate.test.js.map +1 -1
  159. package/modules/xlsx/parseExcelTimestamp.js +133 -0
  160. package/modules/xlsx/parseExcelTimestamp.js.map +1 -0
  161. package/modules/xlsx/parseFilePaths.js +48 -47
  162. package/modules/xlsx/parseFilePaths.js.map +1 -1
  163. package/modules/xlsx/parseSharedStrings.js +91 -37
  164. package/modules/xlsx/parseSharedStrings.js.map +1 -1
  165. package/modules/xlsx/parseSheet.js +526 -68
  166. package/modules/xlsx/parseSheet.js.map +1 -1
  167. package/modules/xlsx/parseSpreadsheetContents.js +153 -81
  168. package/modules/xlsx/parseSpreadsheetContents.js.map +1 -1
  169. package/modules/xlsx/parseSpreadsheetInfo.js +60 -59
  170. package/modules/xlsx/parseSpreadsheetInfo.js.map +1 -1
  171. package/modules/xlsx/parseStyles.js +75 -75
  172. package/modules/xlsx/parseStyles.js.map +1 -1
  173. package/modules/xml/parseXml.js +106 -0
  174. package/modules/xml/parseXml.js.map +1 -0
  175. package/modules/xml/parseXml.test.js.map +1 -0
  176. package/modules/xml/parseXmlStream.js +2 -0
  177. package/modules/xml/parseXmlStream.js.map +1 -1
  178. package/modules/xml/parseXmlStream.sax.js +69 -28
  179. package/modules/xml/parseXmlStream.sax.js.map +1 -1
  180. package/modules/xml/parseXmlStream.saxen.js +67 -40
  181. package/modules/xml/parseXmlStream.saxen.js.map +1 -1
  182. package/modules/zip/UnzipError.js +49 -0
  183. package/modules/zip/UnzipError.js.map +1 -0
  184. package/modules/zip/unzipFromArrayBuffer.js +21 -1
  185. package/modules/zip/unzipFromArrayBuffer.js.map +1 -1
  186. package/modules/zip/unzipFromArrayBuffer.test.js.map +1 -0
  187. package/modules/zip/unzipFromStream.fflate.js +41 -35
  188. package/modules/zip/unzipFromStream.fflate.js.map +1 -1
  189. package/modules/zip/unzipFromStream.js +124 -1
  190. package/modules/zip/unzipFromStream.js.map +1 -1
  191. package/modules/zip/unzipFromStream.unzipper.js +19 -35
  192. package/modules/zip/unzipFromStream.unzipper.js.map +1 -1
  193. package/node/index.cjs +3 -0
  194. package/node/index.d.ts +16 -0
  195. package/node/index.js +3 -0
  196. package/package.json +5 -3
  197. package/types/InvalidInputError.d.ts +16 -0
  198. package/types/InvalidSpreadsheetError.d.ts +4 -0
  199. package/types/SheetNotFoundError.d.ts +4 -0
  200. package/universal/index.cjs +3 -0
  201. package/universal/index.d.ts +16 -0
  202. package/universal/index.js +3 -0
  203. package/web-worker/index.cjs +3 -0
  204. package/web-worker/index.d.ts +16 -0
  205. package/web-worker/index.js +3 -0
  206. package/commonjs/export/convertValuesFromUint8ArraysToStrings.js +0 -23
  207. package/commonjs/export/convertValuesFromUint8ArraysToStrings.js.map +0 -1
  208. package/commonjs/xlsx/convertCellsToData2dArray.js +0 -84
  209. package/commonjs/xlsx/convertCellsToData2dArray.js.map +0 -1
  210. package/commonjs/xlsx/dropEmptyColumns.js +0 -40
  211. package/commonjs/xlsx/dropEmptyColumns.js.map +0 -1
  212. package/commonjs/xlsx/dropEmptyColumns.test.js.map +0 -1
  213. package/commonjs/xlsx/dropEmptyRows.js +0 -43
  214. package/commonjs/xlsx/dropEmptyRows.js.map +0 -1
  215. package/commonjs/xlsx/dropEmptyRows.test.js.map +0 -1
  216. package/commonjs/xlsx/parseCellValue.js +0 -189
  217. package/commonjs/xlsx/parseCellValue.js.map +0 -1
  218. package/commonjs/xlsx/parseNumber.js +0 -20
  219. package/commonjs/xlsx/parseNumber.js.map +0 -1
  220. package/commonjs/xlsx/parseSharedString.js +0 -64
  221. package/commonjs/xlsx/parseSharedString.js.map +0 -1
  222. package/commonjs/xlsx/parseSheetData.js +0 -68
  223. package/commonjs/xlsx/parseSheetData.js.map +0 -1
  224. package/commonjs/xlsx/reconstructSheetDimensionsFromSheetCells.js +0 -29
  225. package/commonjs/xlsx/reconstructSheetDimensionsFromSheetCells.js.map +0 -1
  226. package/commonjs/xml/parseXmlStream.saxen.code.js +0 -953
  227. package/commonjs/xml/parseXmlStream.saxen.code.js.map +0 -1
  228. package/commonjs/xml/parseXmlStream.test.js.map +0 -1
  229. package/modules/export/convertValuesFromUint8ArraysToStrings.js +0 -17
  230. package/modules/export/convertValuesFromUint8ArraysToStrings.js.map +0 -1
  231. package/modules/xlsx/convertCellsToData2dArray.js +0 -77
  232. package/modules/xlsx/convertCellsToData2dArray.js.map +0 -1
  233. package/modules/xlsx/dropEmptyColumns.js +0 -34
  234. package/modules/xlsx/dropEmptyColumns.js.map +0 -1
  235. package/modules/xlsx/dropEmptyColumns.test.js.map +0 -1
  236. package/modules/xlsx/dropEmptyRows.js +0 -37
  237. package/modules/xlsx/dropEmptyRows.js.map +0 -1
  238. package/modules/xlsx/dropEmptyRows.test.js.map +0 -1
  239. package/modules/xlsx/parseCellValue.js +0 -183
  240. package/modules/xlsx/parseCellValue.js.map +0 -1
  241. package/modules/xlsx/parseNumber.js +0 -14
  242. package/modules/xlsx/parseNumber.js.map +0 -1
  243. package/modules/xlsx/parseSharedString.js +0 -55
  244. package/modules/xlsx/parseSharedString.js.map +0 -1
  245. package/modules/xlsx/parseSheetData.js +0 -55
  246. package/modules/xlsx/parseSheetData.js.map +0 -1
  247. package/modules/xlsx/reconstructSheetDimensionsFromSheetCells.js +0 -23
  248. package/modules/xlsx/reconstructSheetDimensionsFromSheetCells.js.map +0 -1
  249. package/modules/xml/parseXmlStream.saxen.code.js +0 -947
  250. package/modules/xml/parseXmlStream.saxen.code.js.map +0 -1
  251. package/modules/xml/parseXmlStream.test.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"parseSheetData.js","names":["NumberType","StringType","BooleanType","DateType","isObject","checkpoint","parseSheetData","data","schema","optionsCustom","objects","errors","parsedRows","parseSheetDataWithPerRowErrors","parsedRowIndex","_iterator","_createForOfIteratorHelperLoose","_step","done","_step$value","value","object","rowErrors","concat","map","rowError","_objectSpread","row","push","length","validateSchema","options","applyDefaultOptions","_data","_toArray","columns","dataRows","slice","parseDataRow","dataRow","schemaEntry","_parseProperty","parseProperty","undefined","isEmptyValue","children","dummyParentObject","PARSED_OBJECT_TREE_START","isRequired","requiredErrors","runPendingRequiredValidations","transformValue","parseObject","path","isEmptyObject","_i","_Object$keys","Object","keys","key","child","getPropertyPath","columnIndex","column","indexOf","isMissingColumn","_ref","propertyValueWhenColumnIsMissing","parseCellValueWithPossibleErrors","cellValue","_parseCellValue","parseCellValue","errorMessage","error","errorReason","reason","createError","valueType","type","propertyValueWhenCellIsEmpty","Array","isArray","parseArrayValue","parseValue","isEmptyArray","reasons","values","parseSeparatedSubstrings","separatorCharacter","substring","_parseValue","result","parseValueOfType","oneOf","errorAndReason","validateOneOf","validate","message","String","parseValueUsingTypeParser","Number","Date","Boolean","Error","name","parsedValue","getNextSubstring","string","startIndex","i","character","elements","index","_getNextSubstring","_getNextSubstring2","_slicedToArray","trim","transformEmptyObject","transformEmptyArray","propertyName","parentObjectPath","parentObjectIsRequired","parentObjectValue","parentObjectValueIsEmpty","parentObjectErrors","isPropertyRequired","_iterator2","_step2","requiredErrorsOfChild","required","_ref2","_i2","_Object$keys2","_typeof","validateObjectSchemaRequiredProperty","_i3","_Object$keys3","JSON","stringify","DEFAULT_OPTIONS"],"sources":["../../source/parseSheetData/parseSheetData.js"],"sourcesContent":["import NumberType from './types/Number.js'\r\nimport StringType from './types/String.js'\r\nimport BooleanType from './types/Boolean.js'\r\nimport DateType from './types/Date.js'\r\n\r\nimport isObject from '../utility/isObject.js'\r\nimport checkpoint from '../utility/checkpoint.js'\r\n\r\n/**\r\n * Converts spreadsheet-alike data structure into an array of JSON objects.\r\n *\r\n * Parameters:\r\n *\r\n * * `data` — An array of rows, each row being an array of cells. The first row should be the list of column headers and the rest of the rows should be the data.\r\n * * `schema` — A \"to JSON\" convertion schema (see above).\r\n * * `options` — (optional) Schema conversion parameters of `read-excel-file`:\r\n * * `propertyValueWhenColumnIsMissing` — By default, when some of the `schema` columns are missing in the input `data`, those properties are set to `undefined` in the output objects. Pass `propertyValueWhenColumnIsMissing: null` to set such \"missing column\" properties to `null` in the output objects.\r\n * * `propertyValueWhenCellIsEmpty` — By default, when it encounters a `null` value in a cell in input `data`, it sets it to `undefined` in the output object. Pass `propertyValueWhenCellIsEmpty: null` to make it set such values as `null`s in output objects.\r\n * // * `shouldSkipRequiredValidationWhenColumnIsMissing: (column: string, { object }) => boolean` — By default, it does apply `required` validation to `schema` properties for which columns are missing in the input `data`. One could pass a custom `shouldSkipRequiredValidationWhenColumnIsMissing(column, { object })` to disable `required` validation for missing columns in some or all cases.\r\n * * `transformEmptyObject(object, { path? })` — By default, it returns `null` for \"empty\" objects. One could override that value using `transformEmptyObject(object, { path })` parameter. The value applies to both top-level object and any nested sub-objects in case of a nested schema, hence the additional (optional) `path?: string` parameter.\r\n * * `transformEmptyArray(array, { path })` — By default, it returns `null` for an \"empty\" array value. One could override that value using `transformEmptyArray(array, { path })` parameter.\r\n * * `separatorCharacter` — By default, it splits array-type cell values by a comma character.\r\n *\r\n * When parsing a property value, in case of an error, the value of that property is gonna be `undefined`.\r\n *\r\n * @param {SheetData} data - An array of rows, each row being an array of cells.\r\n * @param {object} schema\r\n * @param {object} [options]\r\n * @param {any} [options.propertyValueWhenColumnIsMissing] — By default, when some of the `schema` columns are missing in the input `data`, those properties are set to `undefined` in the output objects. Pass `propertyValueWhenColumnIsMissing: null` to set such \"missing column\" properties to `null` in the output objects.\r\n * @param {any} [options.propertyValueWhenCellIsEmpty] — By default, when it encounters a `null` value in a cell in input `data`, it leaves the value as is. Pass a custom `propertyValueWhenCellIsEmpty` to make it set such values to that value.\r\n * // @param {boolean} [options.shouldSkipRequiredValidationWhenColumnIsMissing(column: string, { object })] — By default, it does apply `required` validation to `schema` properties for which columns are missing in the input `data`. One could pass a custom `shouldSkipRequiredValidationWhenColumnIsMissing(column, { object })` to disable `required` validation for missing columns in some or all cases.\r\n * @param {function} [options.transformEmptyObject(object, { path })] — By default, it returns `null` for an \"empty\" resulting object. One could override that value using `transformEmptyObject(object, { path })` parameter. The value applies to both top-level object and any nested sub-objects in case of a nested schema, hence the additional `path?: string` parameter.\r\n * @param {function} [options.transformEmptyArray(array, { path })] — By default, it returns `null` for an \"empty\" array value. One could override that value using `transformEmptyArray(array, { path })` parameter.\r\n * @param {string} [options.separatorCharacter] — When specified, string values will be split by this separator to get the array.\r\n * @return {object} — An object of shape `{ objects, errors }`. Either `objects` or `errors` is going to be `undefined`.\r\n */\r\nexport default function parseSheetData(data, schema, optionsCustom) {\r\n checkpoint('parse sheet data using schema')\r\n\r\n const objects = []\r\n let errors = []\r\n\r\n const parsedRows = parseSheetDataWithPerRowErrors(data, schema, optionsCustom)\r\n let parsedRowIndex = 0\r\n for (const { object, errors: rowErrors } of parsedRows) {\r\n if (rowErrors) {\r\n errors = errors.concat(\r\n rowErrors.map(\r\n // Add row number property to each row error.\r\n rowError => ({ ...rowError, row: parsedRowIndex + 1 })\r\n )\r\n )\r\n } else {\r\n objects.push(object)\r\n }\r\n parsedRowIndex++\r\n }\r\n\r\n checkpoint('end')\r\n\r\n if (errors.length > 0) {\r\n return { errors }\r\n }\r\n\r\n return { objects }\r\n}\r\n\r\n// This one is only used in tests.\r\nexport function parseSheetDataWithPerRowErrors(data, schema, optionsCustom) {\r\n validateSchema(schema)\r\n\r\n const options = applyDefaultOptions(optionsCustom)\r\n\r\n const [columns, ...dataRows] = data\r\n\r\n return dataRows.map(row => parseDataRow(row, schema, columns, options))\r\n}\r\n\r\nfunction parseDataRow(dataRow, schema, columns, options) {\r\n // Create a `schemaEntry` for the top-level object.\r\n const schemaEntry = {\r\n schema\r\n }\r\n\r\n // Parse the values in the given data row into an object.\r\n const {\r\n value,\r\n isEmptyValue,\r\n errors,\r\n children\r\n } = parseProperty(dataRow, schemaEntry, undefined, columns, options)\r\n\r\n // Simulate a \"dummy\" parent object for the top-level object.\r\n // It will be used when running `required` validations.\r\n const dummyParentObject = {\r\n // The \"dummy\" parent object has a \"dummy\" value.\r\n // This value is irrelevant because it won't be read anywhere.\r\n value: PARSED_OBJECT_TREE_START,\r\n // The \"dummy\" parent object is empty if the parsed row is empty.\r\n isEmptyValue,\r\n // The \"dummy\" object has the same errors as the parsed row.\r\n errors,\r\n // The parsed object by default is not required to have any data\r\n // so the \"dummy\" object is not required.\r\n isRequired: undefined\r\n }\r\n\r\n // Run any `required` validations.\r\n //\r\n // `required` validations should be run after the entire data row has been parsed,\r\n // i.e. when the entire object structure has been parsed.\r\n // The reason is that a `required` validation could be either a simple boolean or a \"complex\" function.\r\n // In the latter case, the result of a `required()` function may depend on any other property of the object,\r\n // hence the actual `required` flag value could only be obtained after the entire data row has been parsed.\r\n //\r\n // For example, consider a top-level object:\r\n //\r\n // {\r\n // firstName: string,\r\n // lastName: string,\r\n // pet?: { name: string }\r\n // }\r\n //\r\n // A corresponding schema would be:\r\n //\r\n // {\r\n // firstName: {\r\n // required: true\r\n // },\r\n // lastName: {\r\n // required: true\r\n // },\r\n // pet: {\r\n // required: false,\r\n // schema: {\r\n // name: {\r\n // required: true\r\n // }\r\n // }\r\n // }\r\n // }\r\n //\r\n // I.e. when a `pet` exists, it must have a `name`.\r\n //\r\n // In such case, the `required: true` check of the `pet`'s `name` property\r\n // should not be performed if the `pet` is not present, because the `pet` nested object\r\n // is marked as `required: false`, meaning that `pet` data is not required to be present.\r\n //\r\n const requiredErrors = runPendingRequiredValidations(\r\n schemaEntry,\r\n value,\r\n isEmptyValue,\r\n errors,\r\n children,\r\n // Simulate a \"dummy\" parent object for the top-level object.\r\n dummyParentObject.isRequired,\r\n dummyParentObject.value,\r\n dummyParentObject.isEmptyValue,\r\n dummyParentObject.errors,\r\n columns\r\n )\r\n\r\n // If there were any errors, whether caused by `required`\r\n // or occured while parsing the values, return those errors.\r\n if (errors || requiredErrors) {\r\n return {\r\n errors: (errors || []).concat(requiredErrors || [])\r\n }\r\n }\r\n\r\n // Return the parsed object.\r\n return {\r\n object: transformValue(value, isEmptyValue, undefined, options)\r\n }\r\n}\r\n\r\nfunction parseObject(row, schema, path, columns, options) {\r\n const object = {}\r\n let isEmptyObject = true\r\n\r\n let errors = []\r\n\r\n const children = []\r\n\r\n // For each property of the object.\r\n for (const key of Object.keys(schema)) {\r\n const child = parseProperty(row, schema[key], getPropertyPath(key, path), columns, options)\r\n\r\n if (child.errors) {\r\n errors = errors.concat(child.errors)\r\n } else {\r\n object[key] = transformValue(child.value, child.isEmptyValue, getPropertyPath(key, path), options)\r\n // Potentially unmark the object as \"empty\".\r\n if (isEmptyObject && !child.isEmptyValue) {\r\n isEmptyObject = false\r\n }\r\n }\r\n\r\n children.push({\r\n ...child,\r\n // `schemaEntry` will be used when running `required` validation of this property (later),\r\n schemaEntry: schema[key]\r\n })\r\n }\r\n\r\n // If there were any errors, return them.\r\n if (errors.length > 0) {\r\n return {\r\n // Return the errors.\r\n errors,\r\n // Return the `children` because `required` validations still have to be run (later).\r\n children\r\n }\r\n }\r\n\r\n return {\r\n value: object,\r\n isEmptyValue: isEmptyObject,\r\n // Return the `children` because `required` validations still have to be run (later).\r\n children\r\n }\r\n}\r\n\r\nfunction parseProperty(row, schemaEntry, path, columns, options) {\r\n const columnIndex = schemaEntry.column ? columns.indexOf(schemaEntry.column) : undefined\r\n const isMissingColumn = schemaEntry.column ? columnIndex < 0 : undefined\r\n\r\n const {\r\n value,\r\n isEmptyValue,\r\n errors,\r\n children\r\n } = schemaEntry.column\r\n ? (\r\n isMissingColumn\r\n ? { value: options.propertyValueWhenColumnIsMissing, isEmptyValue: true }\r\n : parseCellValueWithPossibleErrors(row[columnIndex], schemaEntry, columnIndex, options)\r\n )\r\n : parseObject(\r\n row,\r\n schemaEntry.schema,\r\n path,\r\n columns,\r\n options\r\n )\r\n\r\n // If there were any errors, return them.\r\n if (errors) {\r\n return {\r\n // Return the errors.\r\n errors,\r\n // Return the `children` because `required` validations still have to be run (later).\r\n children\r\n }\r\n }\r\n\r\n return {\r\n value,\r\n isEmptyValue,\r\n // Return the `children` because `required` validations still have to be run (later).\r\n children\r\n }\r\n}\r\n\r\nfunction parseCellValueWithPossibleErrors(cellValue, schemaEntry, columnIndex, options) {\r\n const {\r\n value,\r\n isEmptyValue,\r\n error: errorMessage,\r\n reason: errorReason\r\n } = parseCellValue(cellValue, schemaEntry, options)\r\n\r\n if (errorMessage) {\r\n const error = createError({\r\n error: errorMessage,\r\n reason: errorReason,\r\n column: schemaEntry.column,\r\n columnIndex,\r\n valueType: schemaEntry.type,\r\n value: cellValue\r\n })\r\n return {\r\n errors: [error]\r\n }\r\n }\r\n\r\n return {\r\n value,\r\n isEmptyValue\r\n }\r\n}\r\n\r\n/**\r\n * Converts a cell value value to a javascript typed value.\r\n * @param {any} cellValue\r\n * @param {object} schemaEntry\r\n * @param {string} propertyPath\r\n * @param {object} options\r\n * @return {{ value?: any, isEmptyValue: boolean } | { error: string, reason?: string }}\r\n */\r\nfunction parseCellValue(cellValue, schemaEntry, options) {\r\n if (cellValue === undefined) {\r\n // This isn't supposed to be possible when reading spreadsheet data:\r\n // cell values are always read as `null` when those cells are empty.\r\n // It's currently impossible for `read-excel-file` to return `undefined` cell value.\r\n // Here it uses some \"sensible default\" fallback by treating `undefined` as \"column missing\".\r\n return {\r\n value: options.propertyValueWhenColumnIsMissing,\r\n isEmptyValue: true\r\n }\r\n }\r\n\r\n if (cellValue === null) {\r\n return {\r\n value: options.propertyValueWhenCellIsEmpty,\r\n isEmptyValue: true\r\n }\r\n }\r\n\r\n // Parse comma-separated cell value.\r\n if (Array.isArray(schemaEntry.type)) {\r\n return parseArrayValue(cellValue, schemaEntry, options)\r\n }\r\n\r\n return parseValue(cellValue, schemaEntry, options)\r\n}\r\n\r\n/**\r\n * Converts textual value to a javascript typed array value.\r\n * @param {any} value\r\n * @param {object} schemaEntry\r\n * @param {object} options\r\n * @return {{ value?: any, isEmptyValue: boolean } | { error: string, reason?: string }}\r\n */\r\nfunction parseArrayValue(value, schemaEntry, options) {\r\n // If the cell value is not a string — i.e. a number, a boolean, a Date —\r\n // then throw an error.\r\n if (typeof value !== 'string') {\r\n return {\r\n error: 'not_a_string'\r\n }\r\n }\r\n\r\n let isEmptyArray = true\r\n\r\n const errors = []\r\n const reasons = []\r\n\r\n const values = parseSeparatedSubstrings(value, options.separatorCharacter).map((substring) => {\r\n // If any substring was already detected to be invalid\r\n // don't attempt to parse any other substrings.\r\n if (errors.length > 0) {\r\n return\r\n }\r\n\r\n // If an empty substring was extracted, it means that there was an out-of-place separator.\r\n if (!substring) {\r\n errors.push('invalid')\r\n reasons.push('syntax')\r\n return\r\n }\r\n\r\n const {\r\n value,\r\n isEmptyValue,\r\n error,\r\n reason\r\n } = parseValue(substring, schemaEntry, options)\r\n\r\n if (error) {\r\n errors.push(error)\r\n reasons.push(reason)\r\n return\r\n }\r\n\r\n if (isEmptyArray && !isEmptyValue) {\r\n isEmptyArray = false\r\n }\r\n\r\n return value\r\n })\r\n\r\n if (errors.length > 0) {\r\n return {\r\n error: errors[0],\r\n reason: reasons[0]\r\n }\r\n }\r\n\r\n return {\r\n value: values,\r\n isEmptyValue: isEmptyArray\r\n }\r\n}\r\n\r\n/**\r\n * Converts textual value to a javascript typed value.\r\n * @param {any} value\r\n * @param {object} schemaEntry\r\n * @param {object} options\r\n * @return {{ value?: any, isEmptyValue: boolean } | { error: string }}\r\n */\r\nexport function parseValue(value, schemaEntry, options) {\r\n // `null` values (i.e. empty cells) don't get parsed.\r\n if (value === null) {\r\n return {\r\n value: null,\r\n isEmptyValue: true\r\n }\r\n }\r\n\r\n // Parse the value according to the `type` that is specified in the schema entry.\r\n let result\r\n if (schemaEntry.type) {\r\n result = parseValueOfType(\r\n value,\r\n // Get the type of the value.\r\n //\r\n // Handle the case if it's a comma-separated value.\r\n // Example `type`: String[]\r\n // Example Input Value: 'Barack Obama, \"String, with, colons\", Donald Trump'\r\n // Example Parsed Value: ['Barack Obama', 'String, with, colons', 'Donald Trump']\r\n //\r\n Array.isArray(schemaEntry.type) ? schemaEntry.type[0] : schemaEntry.type,\r\n options\r\n )\r\n } else {\r\n // If the `type` is not specified for a given schema entry, the `value` will be returned as is.\r\n result = { value }\r\n // throw new Error('Invalid schema entry: no `type` specified:\\n\\n' + JSON.stringify(schemaEntry, null, 2))\r\n }\r\n\r\n // If there was an error when parsing the value then return the error.\r\n if (result.error) {\r\n return result\r\n }\r\n\r\n // If the parsed value is empty, return it.\r\n if (value === null) {\r\n return {\r\n value: null,\r\n isEmptyValue: true\r\n }\r\n }\r\n\r\n // Value is not empty.\r\n // Validate it and return.\r\n\r\n // Perform `oneOf` validation.\r\n if (schemaEntry.oneOf) {\r\n const errorAndReason = validateOneOf(result.value, schemaEntry.oneOf)\r\n if (errorAndReason) {\r\n return errorAndReason\r\n }\r\n }\r\n\r\n // Perform `validate()` validation.\r\n if (schemaEntry.validate) {\r\n try {\r\n schemaEntry.validate(result.value)\r\n } catch (error) {\r\n return { error: error.message }\r\n }\r\n }\r\n\r\n // Return the value.\r\n return {\r\n value: result.value,\r\n isEmptyValue: isEmptyValue(result.value)\r\n }\r\n}\r\n\r\nfunction validateOneOf(value, oneOf) {\r\n if (oneOf.indexOf(value) < 0) {\r\n return { error: 'invalid', reason: 'unknown' }\r\n }\r\n}\r\n\r\n/**\r\n * Converts cell value to a javascript typed value.\r\n * @param {(string|number|boolean|Date)} value\r\n * @param {function} type\r\n * @return {object} Either `{ value: (string|number|Date|boolean) }` or `{ error: string, reason?: string }`\r\n */\r\nfunction parseValueOfType(value, type) {\r\n switch (type) {\r\n case String:\r\n return parseValueUsingTypeParser(value, StringType)\r\n\r\n case Number:\r\n return parseValueUsingTypeParser(value, NumberType)\r\n\r\n case Date:\r\n return parseValueUsingTypeParser(value, DateType)\r\n\r\n case Boolean:\r\n return parseValueUsingTypeParser(value, BooleanType)\r\n\r\n default:\r\n // Validate `type`\r\n if (typeof type !== 'function') {\r\n throw new Error(`Unsupported schema \\`type\\`: ${type && type.name || type}`)\r\n }\r\n return parseValueUsingTypeParser(value, type)\r\n }\r\n}\r\n\r\n/**\r\n * Converts textual value to a custom value using supplied `type`.\r\n * @param {any} value\r\n * @param {function} type\r\n * @return {{ value: any, error: string }}\r\n */\r\nfunction parseValueUsingTypeParser(value, type) {\r\n try {\r\n const parsedValue = type(value)\r\n // Returning `undefined` from a `type` parser is treated as returning `null`.\r\n if (parsedValue === undefined) {\r\n return { value: null }\r\n }\r\n return { value: parsedValue }\r\n } catch (error) {\r\n const result = { error: error.message }\r\n // Built-in types such as `Number` or `Date` may also report\r\n // a specific `reason` of the error.\r\n if (error.reason) {\r\n result.reason = error.reason;\r\n }\r\n return result\r\n }\r\n}\r\n\r\n// Extracts a substring from a string.\r\nexport function getNextSubstring(string, separatorCharacter, startIndex) {\r\n let i = 0\r\n let substring = ''\r\n while (startIndex + i < string.length) {\r\n const character = string[startIndex + i]\r\n if (character === separatorCharacter) {\r\n return [substring, i]\r\n }\r\n // Previously, it used to treat `\"` character similar to how it's treated in `.csv` files:\r\n // any commas inside quotes are ignored. But then I thought that it could introduce more\r\n // issues than it was originally intending to fix, and it also didn't provide an \"escape\" mechanism.\r\n // Overall, a decision was made to simplify the whole thing and drop the concept of quotes as special characters.\r\n //\r\n // else if (character === '\"') {\r\n // const quotedSubstring = getNextSubstring(string, '\"', startIndex + i + 1)\r\n // substring += quotedSubstring[0]\r\n // i += '\"'.length + quotedSubstring[1] + '\"'.length\r\n // }\r\n else {\r\n substring += character\r\n i++\r\n }\r\n }\r\n return [substring, i]\r\n}\r\n\r\n/**\r\n * Parses a string of comma-separated substrings into an array of substrings.\r\n * (the `export` is just for tests)\r\n * @param {string} string — A string of comma-separated substrings.\r\n * @return {string[]} An array of substrings.\r\n */\r\nexport function parseSeparatedSubstrings(string, separatorCharacter) {\r\n const elements = []\r\n let index = 0\r\n while (index < string.length) {\r\n const [substring, length] = getNextSubstring(string, separatorCharacter, index)\r\n index += length + separatorCharacter.length\r\n elements.push(substring.trim())\r\n }\r\n return elements\r\n}\r\n\r\nfunction transformValue(value, isEmptyValue, path, options) {\r\n if (isEmptyValue) {\r\n if (isObject(value)) {\r\n return options.transformEmptyObject(value, { path })\r\n } else if (Array.isArray(value)) {\r\n return options.transformEmptyArray(value, { path })\r\n }\r\n }\r\n return value\r\n}\r\n\r\nfunction getPropertyPath(propertyName, parentObjectPath) {\r\n return `${parentObjectPath ? parentObjectPath + '.' : ''}${propertyName}`\r\n}\r\n\r\n// Recursively runs `required` validations for the parsed data row tree.\r\nfunction runPendingRequiredValidations(\r\n schemaEntry,\r\n value,\r\n isEmptyValue,\r\n errors,\r\n children,\r\n parentObjectIsRequired,\r\n parentObjectValue,\r\n parentObjectValueIsEmpty,\r\n parentObjectErrors,\r\n columns\r\n) {\r\n let requiredErrors = []\r\n\r\n // See if this property is required.\r\n const isRequired = isPropertyRequired(\r\n schemaEntry,\r\n parentObjectIsRequired,\r\n parentObjectValue,\r\n parentObjectValueIsEmpty,\r\n parentObjectErrors\r\n )\r\n\r\n // If this property is required and empty, create a \"required\" error.\r\n if (isRequired && isEmptyValue) {\r\n requiredErrors.push(createError({\r\n error: 'required',\r\n column: schemaEntry.column,\r\n columnIndex: columns.indexOf(schemaEntry.column),\r\n valueType: schemaEntry.type,\r\n value\r\n }))\r\n }\r\n\r\n // Run `required` validations of the children.\r\n if (children) {\r\n for (const child of children) {\r\n const requiredErrorsOfChild = runPendingRequiredValidations(\r\n child.schemaEntry,\r\n child.value,\r\n child.isEmptyValue,\r\n child.errors,\r\n child.children,\r\n // The following properties describe the parent object of the `child`,\r\n // i.e. the current (iterated) object.\r\n isRequired,\r\n value,\r\n isEmptyValue,\r\n errors,\r\n columns\r\n )\r\n if (requiredErrorsOfChild) {\r\n requiredErrors = requiredErrors.concat(requiredErrorsOfChild)\r\n }\r\n }\r\n }\r\n if (requiredErrors.length > 0) {\r\n return requiredErrors\r\n }\r\n}\r\n\r\nfunction isPropertyRequired(\r\n schemaEntry,\r\n parentObjectIsRequired,\r\n parentObjectValue,\r\n parentObjectValueIsEmpty,\r\n parentObjectErrors\r\n) {\r\n // If the parent object is marked as `required: false` then it's allowed\r\n // to be absent entirely from the input data. If that's the case,\r\n // i.e. if the parent object is absent entirely from the input data,\r\n // then any descendant properties of such object are allowed to be absent too,\r\n // which means that they should also be considered being `required: false`.\r\n //\r\n // Also, if the parent object couldn't be parsed due to some non-`required` errors,\r\n // it can't be known whether it's actually empty or not. In case of such uncertainty,\r\n // the code shouldn't attempt to be overly smart and do things that might not be necessary,\r\n // so such parent object is just assumed to be empty in order to not falsly trigger\r\n // any `required` validations that otherwise wouldn't have been run.\r\n // In other words, skipping some `required` validations is better than\r\n // running `required` validations that shouldn't have been run.\r\n //\r\n if (parentObjectIsRequired === false && (parentObjectValueIsEmpty || parentObjectErrors)) {\r\n return false\r\n }\r\n\r\n return schemaEntry.required && (\r\n typeof schemaEntry.required === 'boolean'\r\n ? schemaEntry.required\r\n : (\r\n // If there were any non-`required` errors when parsing the parent object,\r\n // the `parentObject` will be `undefined`. In that case, \"complex\" `required()`\r\n // validations — the ones where `required` is a function — can't really be run\r\n // because those validations assume a fully and correctly parsed parent object\r\n // be passed as an argument, and the thing is that the `parentObject` is unknown.\r\n // As a result, only \"basic\" `required` validations could be run,\r\n // i.e. the ones where `required` is just a boolean, and \"complex\" `required`\r\n // validations, i.e. the ones where `required` is a functions, should be skipped,\r\n // because it's better to skip some `required` errors than to trigger falsy ones.\r\n parentObjectErrors ? false : schemaEntry.required(parentObjectValue)\r\n )\r\n )\r\n}\r\n\r\nfunction createError({\r\n column,\r\n columnIndex,\r\n valueType,\r\n value,\r\n error: errorMessage,\r\n reason\r\n}) {\r\n const error = {\r\n error: errorMessage,\r\n column,\r\n columnIndex,\r\n value\r\n }\r\n if (reason) {\r\n error.reason = reason\r\n }\r\n // * Regular values specify a `type?` property, which is included in the `error` object.\r\n // * Nested objects specify a `schema` property, which is not included in the `error` object.\r\n if (valueType) {\r\n error.type = valueType\r\n }\r\n return error\r\n}\r\n\r\nfunction validateSchema(schema) {\r\n for (const key of Object.keys(schema)) {\r\n const schemaEntry = schema[key]\r\n // Validate that the `schema` is not using a deprecated `type: nestedSchema` format.\r\n if (typeof schemaEntry.type === 'object' && !Array.isArray(schemaEntry.type)) {\r\n throw new Error('When defining a nested schema, use a `schema` property instead of a `type` property')\r\n }\r\n // Validate that every property has a source `column` title specified for it.\r\n if (!schemaEntry.schema) {\r\n if (!schemaEntry.column) {\r\n throw new Error(`\"column\" not defined for schema entry \"${key}\".`)\r\n }\r\n }\r\n }\r\n\r\n // A nested object could have a `required` property but the only allowed value is `false`.\r\n // The reason why `true` value is not allowed is because in case of a \"required\" error\r\n // there's no single column title corresponding to such nested object, and column title\r\n // is required to create a \"required\" error.\r\n validateObjectSchemaRequiredProperty(schema, undefined)\r\n}\r\n\r\nfunction validateObjectSchemaRequiredProperty(schema, required) {\r\n if (required !== undefined && required !== false) {\r\n throw new Error(`In a schema, a nested object can have a \\`required\\` property but the only allowed value is \\`undefined\\` or \\`false\\`. Otherwise, a \"required\" error for a nested object would have to include a specific \\`column\\` title and a nested object doesn't have one. You've specified the following \\`required\\`: ${required}`)\r\n }\r\n // For each property of the described object.\r\n for (const key of Object.keys(schema)) {\r\n // If this property is itself an object.\r\n if (isObject(schema[key].schema)) {\r\n // Validate that a `column` property can't coexist with a `schema` property.\r\n if (schema[key].column) {\r\n throw new Error(`In a schema, \\`column\\` property is only allowed when describing a property value rather than a nested object. Key: ${key}. Schema:\\n${JSON.stringify(schema[key], null, 2)}`)\r\n }\r\n // Recurse into the child object.\r\n validateObjectSchemaRequiredProperty(schema[key].schema, schema[key].required)\r\n }\r\n }\r\n}\r\n\r\nfunction isEmptyValue(value) {\r\n return value === undefined || value === null\r\n}\r\n\r\nconst DEFAULT_OPTIONS = {\r\n propertyValueWhenColumnIsMissing: undefined,\r\n propertyValueWhenCellIsEmpty: null,\r\n // shouldSkipRequiredValidationWhenColumnIsMissing: () => false,\r\n // `transformEmptyObject(object, { path })` applies to both the top-level object\r\n // and any of its nested objects.\r\n transformEmptyObject: () => null,\r\n transformEmptyArray: () => null,\r\n separatorCharacter: ','\r\n}\r\n\r\nfunction applyDefaultOptions(options) {\r\n if (options) {\r\n return {\r\n ...DEFAULT_OPTIONS,\r\n ...options\r\n }\r\n } else {\r\n return DEFAULT_OPTIONS\r\n }\r\n}\r\n\r\n// This `value` marks the start of a tree structure that is parsed from a given data row.\r\nconst PARSED_OBJECT_TREE_START = {}"],"mappings":";;;;;;;;;;;;;;;AAAA,OAAOA,UAAU,MAA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GAAG,CAAC,CAAC"}
1
+ {"version":3,"file":"parseSheetData.js","names":["NumberType","StringType","BooleanType","DateType","isObject","checkpoint","EMPTY_CELL_VALUE","parseSheetData","data","schema","optionsCustom","objects","errors","parsedRows","parseSheetDataWithPerRowErrors","parsedRowIndex","_iterator","_createForOfIteratorHelperLoose","_step","done","_step$value","value","object","rowErrors","concat","map","rowError","_objectSpread","row","push","length","validateSchema","options","applyDefaultOptions","_data","_toArray","columns","dataRows","slice","parseDataRow","dataRow","schemaEntry","_parseProperty","parseProperty","undefined","isEmptyValue","children","dummyParentObject","PARSED_OBJECT_TREE_START","isRequired","requiredErrors","runPendingRequiredValidations","transformValue","parseObject","path","isEmptyObject","_i","_Object$keys","Object","keys","key","child","getPropertyPath","columnIndex","column","indexOf","isMissingColumn","_ref","propertyValueWhenColumnIsMissing","parseCellValueWithPossibleErrors","cellValue","_parseCellValue","parseCellValue","errorMessage","error","errorReason","reason","createError","valueType","type","propertyValueWhenCellIsEmpty","Array","isArray","parseArrayValue","parseValue","isEmptyArray","reasons","values","parseSeparatedSubstrings","separatorCharacter","substring","_parseValue","result","parseValueOfType","oneOf","errorAndReason","validateOneOf","validate","message","String","parseValueUsingTypeParser","Number","Date","Boolean","Error","name","parsedValue","getNextSubstring","string","startIndex","i","character","elements","index","_getNextSubstring","_getNextSubstring2","_slicedToArray","trim","transformEmptyObject","transformEmptyArray","propertyName","parentObjectPath","parentObjectIsRequired","parentObjectValue","parentObjectValueIsEmpty","parentObjectErrors","isPropertyRequired","_iterator2","_step2","requiredErrorsOfChild","required","_ref2","_i2","_Object$keys2","_typeof","validateObjectSchemaRequiredProperty","_i3","_Object$keys3","JSON","stringify","DEFAULT_OPTIONS"],"sources":["../../source/parseSheetData/parseSheetData.js"],"sourcesContent":["import NumberType from './types/Number.js'\r\nimport StringType from './types/String.js'\r\nimport BooleanType from './types/Boolean.js'\r\nimport DateType from './types/Date.js'\r\n\r\nimport isObject from '../utility/isObject.js'\r\nimport checkpoint from '../utility/checkpoint.js'\r\n\r\n// An empty cell has `null` value.\r\nconst EMPTY_CELL_VALUE = null\r\n\r\n/**\r\n * Converts spreadsheet-alike data structure into an array of JSON objects.\r\n *\r\n * Parameters:\r\n *\r\n * * `data` — An array of rows, each row being an array of cells. The first row should be the list of column headers and the rest of the rows should be the data.\r\n * * `schema` — A \"to JSON\" convertion schema (see above).\r\n * * `options` — (optional) Schema conversion parameters of `read-excel-file`:\r\n * * `propertyValueWhenColumnIsMissing` — By default, when some of the `schema` columns are missing in the input `data`, those properties are set to `undefined` in the output objects. Pass `propertyValueWhenColumnIsMissing: null` to set such \"missing column\" properties to `null` in the output objects.\r\n * * `propertyValueWhenCellIsEmpty` — By default, when it encounters a `null` value in a cell in input `data`, it sets it to `undefined` in the output object. Pass `propertyValueWhenCellIsEmpty: null` to make it set such values as `null`s in output objects.\r\n * // * `shouldSkipRequiredValidationWhenColumnIsMissing: (column: string, { object }) => boolean` — By default, it does apply `required` validation to `schema` properties for which columns are missing in the input `data`. One could pass a custom `shouldSkipRequiredValidationWhenColumnIsMissing(column, { object })` to disable `required` validation for missing columns in some or all cases.\r\n * * `transformEmptyObject(object, { path? })` — By default, it returns `null` for \"empty\" objects. One could override that value using `transformEmptyObject(object, { path })` parameter. The value applies to both top-level object and any nested sub-objects in case of a nested schema, hence the additional (optional) `path?: string` parameter.\r\n * * `transformEmptyArray(array, { path })` — By default, it returns `null` for an \"empty\" array value. One could override that value using `transformEmptyArray(array, { path })` parameter.\r\n * * `separatorCharacter` — By default, it splits array-type cell values by a comma character.\r\n *\r\n * When parsing a property value, in case of an error, the value of that property is gonna be `undefined`.\r\n *\r\n * @param {SheetData} data - An array of rows, each row being an array of cells.\r\n * @param {object} schema\r\n * @param {object} [options]\r\n * @param {any} [options.propertyValueWhenColumnIsMissing] — By default, when some of the `schema` columns are missing in the input `data`, those properties are set to `undefined` in the output objects. Pass `propertyValueWhenColumnIsMissing: null` to set such \"missing column\" properties to `null` in the output objects.\r\n * @param {any} [options.propertyValueWhenCellIsEmpty] — By default, when it encounters a `null` value in a cell in input `data`, it leaves the value as is. Pass a custom `propertyValueWhenCellIsEmpty` to make it set such values to that value.\r\n * // @param {boolean} [options.shouldSkipRequiredValidationWhenColumnIsMissing(column: string, { object })] — By default, it does apply `required` validation to `schema` properties for which columns are missing in the input `data`. One could pass a custom `shouldSkipRequiredValidationWhenColumnIsMissing(column, { object })` to disable `required` validation for missing columns in some or all cases.\r\n * @param {function} [options.transformEmptyObject(object, { path })] — By default, it returns `null` for an \"empty\" resulting object. One could override that value using `transformEmptyObject(object, { path })` parameter. The value applies to both top-level object and any nested sub-objects in case of a nested schema, hence the additional `path?: string` parameter.\r\n * @param {function} [options.transformEmptyArray(array, { path })] — By default, it returns `null` for an \"empty\" array value. One could override that value using `transformEmptyArray(array, { path })` parameter.\r\n * @param {string} [options.separatorCharacter] — When specified, string values will be split by this separator to get the array.\r\n * @return {object} — An object of shape `{ objects, errors }`. Either `objects` or `errors` is going to be `undefined`.\r\n */\r\nexport default function parseSheetData(data, schema, optionsCustom) {\r\n checkpoint('parse sheet data using schema')\r\n\r\n const objects = []\r\n let errors = []\r\n\r\n const parsedRows = parseSheetDataWithPerRowErrors(data, schema, optionsCustom)\r\n let parsedRowIndex = 0\r\n for (const { object, errors: rowErrors } of parsedRows) {\r\n if (rowErrors) {\r\n errors = errors.concat(\r\n rowErrors.map(\r\n // Add row number property to each row error.\r\n rowError => ({ ...rowError, row: parsedRowIndex + 1 })\r\n )\r\n )\r\n } else {\r\n objects.push(object)\r\n }\r\n parsedRowIndex++\r\n }\r\n\r\n checkpoint('end')\r\n\r\n if (errors.length > 0) {\r\n return { errors }\r\n }\r\n\r\n return { objects }\r\n}\r\n\r\n// This one is only used in tests.\r\nexport function parseSheetDataWithPerRowErrors(data, schema, optionsCustom) {\r\n validateSchema(schema)\r\n\r\n const options = applyDefaultOptions(optionsCustom)\r\n\r\n const [columns, ...dataRows] = data\r\n\r\n return dataRows.map(row => parseDataRow(row, schema, columns, options))\r\n}\r\n\r\nfunction parseDataRow(dataRow, schema, columns, options) {\r\n // Create a `schemaEntry` for the top-level object.\r\n const schemaEntry = {\r\n schema\r\n }\r\n\r\n // Parse the values in the given data row into an object.\r\n const {\r\n value,\r\n isEmptyValue,\r\n errors,\r\n children\r\n } = parseProperty(dataRow, schemaEntry, undefined, columns, options)\r\n\r\n // Simulate a \"dummy\" parent object for the top-level object.\r\n // It will be used when running `required` validations.\r\n const dummyParentObject = {\r\n // The \"dummy\" parent object has a \"dummy\" value.\r\n // This value is irrelevant because it won't be read anywhere.\r\n value: PARSED_OBJECT_TREE_START,\r\n // The \"dummy\" parent object is empty if the parsed row is empty.\r\n isEmptyValue,\r\n // The \"dummy\" object has the same errors as the parsed row.\r\n errors,\r\n // The parsed object by default is not required to have any data\r\n // so the \"dummy\" object is not required.\r\n isRequired: undefined\r\n }\r\n\r\n // Run any `required` validations.\r\n //\r\n // `required` validations should be run after the entire data row has been parsed,\r\n // i.e. when the entire object structure has been parsed.\r\n // The reason is that a `required` validation could be either a simple boolean or a \"complex\" function.\r\n // In the latter case, the result of a `required()` function may depend on any other property of the object,\r\n // hence the actual `required` flag value could only be obtained after the entire data row has been parsed.\r\n //\r\n // For example, consider a top-level object:\r\n //\r\n // {\r\n // firstName: string,\r\n // lastName: string,\r\n // pet?: { name: string }\r\n // }\r\n //\r\n // A corresponding schema would be:\r\n //\r\n // {\r\n // firstName: {\r\n // required: true\r\n // },\r\n // lastName: {\r\n // required: true\r\n // },\r\n // pet: {\r\n // required: false,\r\n // schema: {\r\n // name: {\r\n // required: true\r\n // }\r\n // }\r\n // }\r\n // }\r\n //\r\n // I.e. when a `pet` exists, it must have a `name`.\r\n //\r\n // In such case, the `required: true` check of the `pet`'s `name` property\r\n // should not be performed if the `pet` is not present, because the `pet` nested object\r\n // is marked as `required: false`, meaning that `pet` data is not required to be present.\r\n //\r\n const requiredErrors = runPendingRequiredValidations(\r\n schemaEntry,\r\n value,\r\n isEmptyValue,\r\n errors,\r\n children,\r\n // Simulate a \"dummy\" parent object for the top-level object.\r\n dummyParentObject.isRequired,\r\n dummyParentObject.value,\r\n dummyParentObject.isEmptyValue,\r\n dummyParentObject.errors,\r\n columns\r\n )\r\n\r\n // If there were any errors, whether caused by `required`\r\n // or occured while parsing the values, return those errors.\r\n if (errors || requiredErrors) {\r\n return {\r\n errors: (errors || []).concat(requiredErrors || [])\r\n }\r\n }\r\n\r\n // Return the parsed object.\r\n return {\r\n object: transformValue(value, isEmptyValue, undefined, options)\r\n }\r\n}\r\n\r\nfunction parseObject(row, schema, path, columns, options) {\r\n const object = {}\r\n let isEmptyObject = true\r\n\r\n let errors = []\r\n\r\n const children = []\r\n\r\n // For each property of the object.\r\n for (const key of Object.keys(schema)) {\r\n const child = parseProperty(row, schema[key], getPropertyPath(key, path), columns, options)\r\n\r\n if (child.errors) {\r\n errors = errors.concat(child.errors)\r\n } else {\r\n object[key] = transformValue(child.value, child.isEmptyValue, getPropertyPath(key, path), options)\r\n // Potentially unmark the object as \"empty\".\r\n if (isEmptyObject && !child.isEmptyValue) {\r\n isEmptyObject = false\r\n }\r\n }\r\n\r\n children.push({\r\n ...child,\r\n // `schemaEntry` will be used when running `required` validation of this property (later),\r\n schemaEntry: schema[key]\r\n })\r\n }\r\n\r\n // If there were any errors, return them.\r\n if (errors.length > 0) {\r\n return {\r\n // Return the errors.\r\n errors,\r\n // Return the `children` because `required` validations still have to be run (later).\r\n children\r\n }\r\n }\r\n\r\n return {\r\n value: object,\r\n isEmptyValue: isEmptyObject,\r\n // Return the `children` because `required` validations still have to be run (later).\r\n children\r\n }\r\n}\r\n\r\nfunction parseProperty(row, schemaEntry, path, columns, options) {\r\n const columnIndex = schemaEntry.column ? columns.indexOf(schemaEntry.column) : undefined\r\n const isMissingColumn = schemaEntry.column ? columnIndex < 0 : undefined\r\n\r\n const {\r\n value,\r\n isEmptyValue,\r\n errors,\r\n children\r\n } = schemaEntry.column\r\n ? (\r\n isMissingColumn\r\n ? { value: options.propertyValueWhenColumnIsMissing, isEmptyValue: true }\r\n : parseCellValueWithPossibleErrors(row[columnIndex], schemaEntry, columnIndex, options)\r\n )\r\n : parseObject(\r\n row,\r\n schemaEntry.schema,\r\n path,\r\n columns,\r\n options\r\n )\r\n\r\n // If there were any errors, return them.\r\n if (errors) {\r\n return {\r\n // Return the errors.\r\n errors,\r\n // Return the `children` because `required` validations still have to be run (later).\r\n children\r\n }\r\n }\r\n\r\n return {\r\n value,\r\n isEmptyValue,\r\n // Return the `children` because `required` validations still have to be run (later).\r\n children\r\n }\r\n}\r\n\r\nfunction parseCellValueWithPossibleErrors(cellValue, schemaEntry, columnIndex, options) {\r\n const {\r\n value,\r\n isEmptyValue,\r\n error: errorMessage,\r\n reason: errorReason\r\n } = parseCellValue(cellValue, schemaEntry, options)\r\n\r\n if (errorMessage) {\r\n const error = createError({\r\n error: errorMessage,\r\n reason: errorReason,\r\n column: schemaEntry.column,\r\n columnIndex,\r\n valueType: schemaEntry.type,\r\n value: cellValue\r\n })\r\n return {\r\n errors: [error]\r\n }\r\n }\r\n\r\n return {\r\n value,\r\n isEmptyValue\r\n }\r\n}\r\n\r\n/**\r\n * Converts a cell value value to a javascript typed value.\r\n * @param {any} cellValue\r\n * @param {object} schemaEntry\r\n * @param {string} propertyPath\r\n * @param {object} options\r\n * @return {{ value?: any, isEmptyValue: boolean } | { error: string, reason?: string }}\r\n */\r\nfunction parseCellValue(cellValue, schemaEntry, options) {\r\n if (cellValue === undefined) {\r\n // This isn't supposed to be possible when reading spreadsheet data:\r\n // cell values are always read as `null` when those cells are empty.\r\n // It's currently impossible for `read-excel-file` to return `undefined` cell value.\r\n // Here it uses some \"sensible default\" fallback by treating `undefined` as \"column missing\".\r\n return {\r\n value: options.propertyValueWhenColumnIsMissing,\r\n isEmptyValue: true\r\n }\r\n }\r\n\r\n if (cellValue === EMPTY_CELL_VALUE) {\r\n return {\r\n value: options.propertyValueWhenCellIsEmpty,\r\n isEmptyValue: true\r\n }\r\n }\r\n\r\n // Parse comma-separated cell value.\r\n if (Array.isArray(schemaEntry.type)) {\r\n return parseArrayValue(cellValue, schemaEntry, options)\r\n }\r\n\r\n return parseValue(cellValue, schemaEntry, options)\r\n}\r\n\r\n/**\r\n * Converts textual value to a javascript typed array value.\r\n * @param {any} value\r\n * @param {object} schemaEntry\r\n * @param {object} options\r\n * @return {{ value?: any, isEmptyValue: boolean } | { error: string, reason?: string }}\r\n */\r\nfunction parseArrayValue(value, schemaEntry, options) {\r\n // If the cell value is not a string — i.e. a number, a boolean, a Date —\r\n // then throw an error.\r\n if (typeof value !== 'string') {\r\n return {\r\n error: 'not_a_string'\r\n }\r\n }\r\n\r\n let isEmptyArray = true\r\n\r\n const errors = []\r\n const reasons = []\r\n\r\n const values = parseSeparatedSubstrings(value, options.separatorCharacter).map((substring) => {\r\n // If any substring was already detected to be invalid\r\n // don't attempt to parse any other substrings.\r\n if (errors.length > 0) {\r\n return\r\n }\r\n\r\n // If an empty substring was extracted, it means that there was an out-of-place separator.\r\n if (!substring) {\r\n errors.push('invalid')\r\n reasons.push('syntax')\r\n return\r\n }\r\n\r\n const {\r\n value,\r\n isEmptyValue,\r\n error,\r\n reason\r\n } = parseValue(substring, schemaEntry, options)\r\n\r\n if (error) {\r\n errors.push(error)\r\n reasons.push(reason)\r\n return\r\n }\r\n\r\n if (isEmptyArray && !isEmptyValue) {\r\n isEmptyArray = false\r\n }\r\n\r\n return value\r\n })\r\n\r\n if (errors.length > 0) {\r\n return {\r\n error: errors[0],\r\n reason: reasons[0]\r\n }\r\n }\r\n\r\n return {\r\n value: values,\r\n isEmptyValue: isEmptyArray\r\n }\r\n}\r\n\r\n/**\r\n * Converts textual value to a javascript typed value.\r\n * @param {any} value\r\n * @param {object} schemaEntry\r\n * @param {object} options\r\n * @return {{ value?: any, isEmptyValue: boolean } | { error: string }}\r\n */\r\nexport function parseValue(value, schemaEntry, options) {\r\n // `null` values (i.e. empty cells) don't get parsed.\r\n if (value === EMPTY_CELL_VALUE) {\r\n return {\r\n value,\r\n isEmptyValue: true\r\n }\r\n }\r\n\r\n // Parse the value according to the `type` that is specified in the schema entry.\r\n let result\r\n if (schemaEntry.type) {\r\n result = parseValueOfType(\r\n value,\r\n // Get the type of the value.\r\n //\r\n // Handle the case if it's a comma-separated value.\r\n // Example `type`: String[]\r\n // Example Input Value: 'Barack Obama, \"String, with, colons\", Donald Trump'\r\n // Example Parsed Value: ['Barack Obama', 'String, with, colons', 'Donald Trump']\r\n //\r\n Array.isArray(schemaEntry.type) ? schemaEntry.type[0] : schemaEntry.type,\r\n options\r\n )\r\n } else {\r\n // If the `type` is not specified for a given schema entry, the `value` will be returned as is.\r\n result = { value }\r\n // throw new Error('Invalid schema entry: no `type` specified:\\n\\n' + JSON.stringify(schemaEntry, null, 2))\r\n }\r\n\r\n // If there was an error when parsing the value then return the error.\r\n if (result.error) {\r\n return result\r\n }\r\n\r\n // If the parsed value is empty, return it.\r\n if (value === EMPTY_CELL_VALUE) {\r\n return {\r\n value,\r\n isEmptyValue: true\r\n }\r\n }\r\n\r\n // Value is not empty.\r\n // Validate it and return.\r\n\r\n // Perform `oneOf` validation.\r\n if (schemaEntry.oneOf) {\r\n const errorAndReason = validateOneOf(result.value, schemaEntry.oneOf)\r\n if (errorAndReason) {\r\n return errorAndReason\r\n }\r\n }\r\n\r\n // Perform `validate()` validation.\r\n if (schemaEntry.validate) {\r\n try {\r\n schemaEntry.validate(result.value)\r\n } catch (error) {\r\n return { error: error.message }\r\n }\r\n }\r\n\r\n // Return the value.\r\n return {\r\n value: result.value,\r\n isEmptyValue: isEmptyValue(result.value)\r\n }\r\n}\r\n\r\nfunction validateOneOf(value, oneOf) {\r\n if (oneOf.indexOf(value) < 0) {\r\n return { error: 'invalid', reason: 'unknown' }\r\n }\r\n}\r\n\r\n/**\r\n * Converts cell value to a javascript typed value.\r\n * @param {(string|number|boolean|Date)} value\r\n * @param {function} type\r\n * @return {object} Either `{ value: (string|number|Date|boolean) }` or `{ error: string, reason?: string }`\r\n */\r\nfunction parseValueOfType(value, type) {\r\n switch (type) {\r\n case String:\r\n return parseValueUsingTypeParser(value, StringType)\r\n\r\n case Number:\r\n return parseValueUsingTypeParser(value, NumberType)\r\n\r\n case Date:\r\n return parseValueUsingTypeParser(value, DateType)\r\n\r\n case Boolean:\r\n return parseValueUsingTypeParser(value, BooleanType)\r\n\r\n default:\r\n // Validate `type`\r\n if (typeof type !== 'function') {\r\n throw new Error(`Unsupported schema \\`type\\`: ${type && type.name || type}`)\r\n }\r\n return parseValueUsingTypeParser(value, type)\r\n }\r\n}\r\n\r\n/**\r\n * Converts textual value to a custom value using supplied `type`.\r\n * @param {any} value\r\n * @param {function} type\r\n * @return {{ value: any, error: string }}\r\n */\r\nfunction parseValueUsingTypeParser(value, type) {\r\n try {\r\n const parsedValue = type(value)\r\n // Returning `undefined` from a `type` parser is treated as returning `null`.\r\n if (parsedValue === undefined) {\r\n return { value: EMPTY_CELL_VALUE }\r\n }\r\n return { value: parsedValue }\r\n } catch (error) {\r\n const result = { error: error.message }\r\n // Built-in types such as `Number` or `Date` may also report\r\n // a specific `reason` of the error.\r\n if (error.reason) {\r\n result.reason = error.reason;\r\n }\r\n return result\r\n }\r\n}\r\n\r\n// Extracts a substring from a string.\r\nexport function getNextSubstring(string, separatorCharacter, startIndex) {\r\n let i = 0\r\n let substring = ''\r\n while (startIndex + i < string.length) {\r\n const character = string[startIndex + i]\r\n if (character === separatorCharacter) {\r\n return [substring, i]\r\n }\r\n // Previously, it used to treat `\"` character similar to how it's treated in `.csv` files:\r\n // any commas inside quotes are ignored. But then I thought that it could introduce more\r\n // issues than it was originally intending to fix, and it also didn't provide an \"escape\" mechanism.\r\n // Overall, a decision was made to simplify the whole thing and drop the concept of quotes as special characters.\r\n //\r\n // else if (character === '\"') {\r\n // const quotedSubstring = getNextSubstring(string, '\"', startIndex + i + 1)\r\n // substring += quotedSubstring[0]\r\n // i += '\"'.length + quotedSubstring[1] + '\"'.length\r\n // }\r\n else {\r\n substring += character\r\n i++\r\n }\r\n }\r\n return [substring, i]\r\n}\r\n\r\n/**\r\n * Parses a string of comma-separated substrings into an array of substrings.\r\n * (the `export` is just for tests)\r\n * @param {string} string — A string of comma-separated substrings.\r\n * @return {string[]} An array of substrings.\r\n */\r\nexport function parseSeparatedSubstrings(string, separatorCharacter) {\r\n const elements = []\r\n let index = 0\r\n while (index < string.length) {\r\n const [substring, length] = getNextSubstring(string, separatorCharacter, index)\r\n index += length + separatorCharacter.length\r\n elements.push(substring.trim())\r\n }\r\n return elements\r\n}\r\n\r\nfunction transformValue(value, isEmptyValue, path, options) {\r\n if (isEmptyValue) {\r\n if (isObject(value)) {\r\n return options.transformEmptyObject(value, { path })\r\n } else if (Array.isArray(value)) {\r\n return options.transformEmptyArray(value, { path })\r\n }\r\n }\r\n return value\r\n}\r\n\r\nfunction getPropertyPath(propertyName, parentObjectPath) {\r\n return `${parentObjectPath ? parentObjectPath + '.' : ''}${propertyName}`\r\n}\r\n\r\n// Recursively runs `required` validations for the parsed data row tree.\r\nfunction runPendingRequiredValidations(\r\n schemaEntry,\r\n value,\r\n isEmptyValue,\r\n errors,\r\n children,\r\n parentObjectIsRequired,\r\n parentObjectValue,\r\n parentObjectValueIsEmpty,\r\n parentObjectErrors,\r\n columns\r\n) {\r\n let requiredErrors = []\r\n\r\n // See if this property is required.\r\n const isRequired = isPropertyRequired(\r\n schemaEntry,\r\n parentObjectIsRequired,\r\n parentObjectValue,\r\n parentObjectValueIsEmpty,\r\n parentObjectErrors\r\n )\r\n\r\n // If this property is required and empty, create a \"required\" error.\r\n if (isRequired && isEmptyValue) {\r\n requiredErrors.push(createError({\r\n error: 'required',\r\n column: schemaEntry.column,\r\n columnIndex: columns.indexOf(schemaEntry.column),\r\n valueType: schemaEntry.type,\r\n value\r\n }))\r\n }\r\n\r\n // Run `required` validations of the children.\r\n if (children) {\r\n for (const child of children) {\r\n const requiredErrorsOfChild = runPendingRequiredValidations(\r\n child.schemaEntry,\r\n child.value,\r\n child.isEmptyValue,\r\n child.errors,\r\n child.children,\r\n // The following properties describe the parent object of the `child`,\r\n // i.e. the current (iterated) object.\r\n isRequired,\r\n value,\r\n isEmptyValue,\r\n errors,\r\n columns\r\n )\r\n if (requiredErrorsOfChild) {\r\n requiredErrors = requiredErrors.concat(requiredErrorsOfChild)\r\n }\r\n }\r\n }\r\n if (requiredErrors.length > 0) {\r\n return requiredErrors\r\n }\r\n}\r\n\r\nfunction isPropertyRequired(\r\n schemaEntry,\r\n parentObjectIsRequired,\r\n parentObjectValue,\r\n parentObjectValueIsEmpty,\r\n parentObjectErrors\r\n) {\r\n // If the parent object is marked as `required: false` then it's allowed\r\n // to be absent entirely from the input data. If that's the case,\r\n // i.e. if the parent object is absent entirely from the input data,\r\n // then any descendant properties of such object are allowed to be absent too,\r\n // which means that they should also be considered being `required: false`.\r\n //\r\n // Also, if the parent object couldn't be parsed due to some non-`required` errors,\r\n // it can't be known whether it's actually empty or not. In case of such uncertainty,\r\n // the code shouldn't attempt to be overly smart and do things that might not be necessary,\r\n // so such parent object is just assumed to be empty in order to not falsly trigger\r\n // any `required` validations that otherwise wouldn't have been run.\r\n // In other words, skipping some `required` validations is better than\r\n // running `required` validations that shouldn't have been run.\r\n //\r\n if (parentObjectIsRequired === false && (parentObjectValueIsEmpty || parentObjectErrors)) {\r\n return false\r\n }\r\n\r\n return schemaEntry.required && (\r\n typeof schemaEntry.required === 'boolean'\r\n ? schemaEntry.required\r\n : (\r\n // If there were any non-`required` errors when parsing the parent object,\r\n // the `parentObject` will be `undefined`. In that case, \"complex\" `required()`\r\n // validations — the ones where `required` is a function — can't really be run\r\n // because those validations assume a fully and correctly parsed parent object\r\n // be passed as an argument, and the thing is that the `parentObject` is unknown.\r\n // As a result, only \"basic\" `required` validations could be run,\r\n // i.e. the ones where `required` is just a boolean, and \"complex\" `required`\r\n // validations, i.e. the ones where `required` is a functions, should be skipped,\r\n // because it's better to skip some `required` errors than to trigger falsy ones.\r\n parentObjectErrors ? false : schemaEntry.required(parentObjectValue)\r\n )\r\n )\r\n}\r\n\r\nfunction createError({\r\n column,\r\n columnIndex,\r\n valueType,\r\n value,\r\n error: errorMessage,\r\n reason\r\n}) {\r\n const error = {\r\n error: errorMessage,\r\n column,\r\n columnIndex,\r\n value\r\n }\r\n if (reason) {\r\n error.reason = reason\r\n }\r\n // * Regular values specify a `type?` property, which is included in the `error` object.\r\n // * Nested objects specify a `schema` property, which is not included in the `error` object.\r\n if (valueType) {\r\n error.type = valueType\r\n }\r\n return error\r\n}\r\n\r\nfunction validateSchema(schema) {\r\n for (const key of Object.keys(schema)) {\r\n const schemaEntry = schema[key]\r\n // Validate that the `schema` is not using a deprecated `type: nestedSchema` format.\r\n if (typeof schemaEntry.type === 'object' && !Array.isArray(schemaEntry.type)) {\r\n throw new Error('When defining a nested schema, use a `schema` property instead of a `type` property')\r\n }\r\n // Validate that every property has a source `column` title specified for it.\r\n if (!schemaEntry.schema) {\r\n if (!schemaEntry.column) {\r\n throw new Error(`\"column\" not defined for schema entry \"${key}\".`)\r\n }\r\n }\r\n }\r\n\r\n // A nested object could have a `required` property but the only allowed value is `false`.\r\n // The reason why `true` value is not allowed is because in case of a \"required\" error\r\n // there's no single column title corresponding to such nested object, and column title\r\n // is required to create a \"required\" error.\r\n validateObjectSchemaRequiredProperty(schema, undefined)\r\n}\r\n\r\nfunction validateObjectSchemaRequiredProperty(schema, required) {\r\n if (required !== undefined && required !== false) {\r\n throw new Error(`In a schema, a nested object can have a \\`required\\` property but the only allowed value is \\`undefined\\` or \\`false\\`. Otherwise, a \"required\" error for a nested object would have to include a specific \\`column\\` title and a nested object doesn't have one. You've specified the following \\`required\\`: ${required}`)\r\n }\r\n // For each property of the described object.\r\n for (const key of Object.keys(schema)) {\r\n // If this property is itself an object.\r\n if (isObject(schema[key].schema)) {\r\n // Validate that a `column` property can't coexist with a `schema` property.\r\n if (schema[key].column) {\r\n throw new Error(`In a schema, \\`column\\` property is only allowed when describing a property value rather than a nested object. Key: ${key}. Schema:\\n${JSON.stringify(schema[key], null, 2)}`)\r\n }\r\n // Recurse into the child object.\r\n validateObjectSchemaRequiredProperty(schema[key].schema, schema[key].required)\r\n }\r\n }\r\n}\r\n\r\nfunction isEmptyValue(value) {\r\n return value === undefined || value === null\r\n}\r\n\r\nconst DEFAULT_OPTIONS = {\r\n propertyValueWhenColumnIsMissing: undefined,\r\n propertyValueWhenCellIsEmpty: null,\r\n // shouldSkipRequiredValidationWhenColumnIsMissing: () => false,\r\n // `transformEmptyObject(object, { path })` applies to both the top-level object\r\n // and any of its nested objects.\r\n transformEmptyObject: () => null,\r\n transformEmptyArray: () => null,\r\n separatorCharacter: ','\r\n}\r\n\r\nfunction applyDefaultOptions(options) {\r\n if (options) {\r\n return {\r\n ...DEFAULT_OPTIONS,\r\n ...options\r\n }\r\n } else {\r\n return DEFAULT_OPTIONS\r\n }\r\n}\r\n\r\n// This `value` marks the start of a tree structure that is parsed from a given data row.\r\nconst PARSED_OBJECT_TREE_START = {}"],"mappings":";;;;;;;;;;;;;;;AAAA,OAAOA,UAAU,MAAM,mBAAmB;AAC1C,OAAOC,UAAU,MAAM,mBAAmB;AAC1C,OAAOC,WAAW,MAAM,oBAAoB;AAC5C,OAAOC,QAAQ,MAAM,iBAAiB;AAEtC,OAAOC,QAAQ,MAAM,wBAAwB;AAC7C,OAAOC,UAAU,MAAM,0BAA0B;;AAEjD;AACA,IAAMC,gBAAgB,GAAG,IAAI;;AAE7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,cAAcA,CAACC,IAAI,EAAEC,MAAM,EAAEC,aAAa,EAAE;EAClEL,UAAU,CAAC,+BAA+B,CAAC;EAE3C,IAAMM,OAAO,GAAG,EAAE;EAClB,IAAIC,MAAM,GAAG,EAAE;EAEf,IAAMC,UAAU,GAAGC,8BAA8B,CAACN,IAAI,EAAEC,MAA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ACA2E,oCAAoC,CAAC9H,MAAM,CAACmD,GAAG,CAAC,CAACnD,MAAM,EAAEA,MAAM,CAACmD,GAAG,CAAC,CAACsE,QAAQ,CAAC;IAChF;EACF;AACF;AAEA,SAASrF,YAAYA,CAACxB,KAAK,EAAE;EAC3B,OAAOA,KAAK,KAAKuB,SAAS,IAAIvB,KAAK,KAAK,IAAI;AAC9C;AAEA,IAAMuH,eAAe,GAAG;EACtBxE,gCAAgC,EAAExB,SAAS;EAC3CoC,4BAA4B,EAAE,IAAI;EAClC;EACA;EACA;EACAsC,oBAAoB,EAAE,SAAAA,qBAAA;IAAA,OAAM,IAAI;EAAA;EAChCC,mBAAmB,EAAE,SAAAA,oBAAA;IAAA,OAAM,IAAI;EAAA;EAC/B9B,kBAAkB,EAAE;AACtB,CAAC;AAED,SAASxD,mBAAmBA,CAACD,OAAO,EAAE;EACpC,IAAIA,OAAO,EAAE;IACX,OAAAL,aAAA,CAAAA,aAAA,KACKiH,eAAe,GACf5G,OAAO;EAEd,CAAC,MAAM;IACL,OAAO4G,eAAe;EACxB;AACF;;AAEA;AACA,IAAM5F,wBAAwB,GAAG,CAAC,CAAC"}
@@ -0,0 +1,92 @@
1
+ // Sidenote: `strFromU8()` function from `fflate` is not "self-contained",
2
+ // i.e. it references some variables outside of its scope,
3
+ // which doesn't work with `worker-f` package and throws an error: "td is not defined".
4
+ //
5
+ // But `woker-f` package is currently not used, so this `import` is not commented out.
6
+ //
7
+ import { strFromU8 as strFromU8_ } from 'fflate';
8
+ import checkpoint from './checkpoint.js';
9
+
10
+ /**
11
+ * @param {Record<string,Uint8Array} entries
12
+ * @returns {Record<string,string>}
13
+ */
14
+ export default function convertValuesFromUint8ArraysToStrings(entries) {
15
+ checkpoint('convert files to strings');
16
+ var convertedEntries = {};
17
+ for (var _i = 0, _Object$keys = Object.keys(entries); _i < _Object$keys.length; _i++) {
18
+ var key = _Object$keys[_i];
19
+ convertedEntries[key] = strFromU8(entries[key]);
20
+ }
21
+ return convertedEntries;
22
+ }
23
+
24
+ // There's a strange thing with using `fflate`'s `strFromU8()` function:
25
+ // when `import`ed directly from `fflate` package, the benchmark runs about 10% slower
26
+ // then when using `new TextDecoder().decode(data)`, even though `strFromU8()`
27
+ // does the same thing internally. So it's a bit mysterious.
28
+ //
29
+ // Because manually calling `new TextDecoder().decode(data)` is measurably faster for some reason,
30
+ // `fflate`'s `strFromU8()` is used as a backup for old web browsers that don't support `TextDecoder`.
31
+ //
32
+ /**
33
+ * Converts a Uint8Array to a string
34
+ * @param data The data to decode to string
35
+ * @param latin1 Whether or not to interpret the data as Latin-1. This should
36
+ * not need to be true unless encoding to binary string.
37
+ * @returns The original UTF-8/Latin-1 string
38
+ */
39
+ export function strFromU8(data) {
40
+ // https://caniuse.com/?search=TextDecoder
41
+ if (typeof TextDecoder !== 'undefined') {
42
+ return new TextDecoder().decode(data);
43
+ } else {
44
+ return strFromU8_(data);
45
+ // Alternatively, it could call a copy-pasted "rest" part of the `strFromU8()` function:
46
+ // const [string, leftovers] = decodeUtf8String(data)
47
+ // console.log(leftovers)
48
+ // if (leftovers.length) {
49
+ // throw new Error('Decode UTF8')
50
+ // }
51
+ // return string
52
+ }
53
+ }
54
+
55
+ // This function's code is a copy-paste of `dutf8()` function in `fflate` repository from Jul 12th, 2026.
56
+ // https://github.com/101arrowz/fflate/blob/master/src/index.ts
57
+ //
58
+ // By the way, this function errors when running test case:
59
+ // "made-in-macos-excel-2011-with-custom-font".
60
+ // The leftover is `Uint8Array(2) [ 255, 217 ]`.
61
+ // To reproduce the error, replace the entire `strFromU8()` function
62
+ // in `convertValuesFromUint8ArraysToStrings()` with this function and see what happens.
63
+ //
64
+ // /**
65
+ // * Decodes a `Uint8Array` into a UTF8 string.
66
+ // * @param {Uint8Array} d
67
+ // * @returns {[string, Uint8Array]} — The decoded string and what's left undecoded
68
+ // */
69
+ // export function decodeUtf8String(d) {
70
+ // for (let s = '', i = 0;;) {
71
+ // let c = d[i++]
72
+ // const charType = (c > 127) + (c > 223) + (c > 239)
73
+ // if (i + charType > d.length) {
74
+ // // Returns a slice of an array.
75
+ // // Allows garbage collector to free the original reference.
76
+ // // This function is browser-compatible than `Uint8Array.slice()`.
77
+ // const leftovers = new Uint8Array(d.subarray(i - 1))
78
+ // return [s, leftovers]
79
+ // }
80
+ // if (!charType) {
81
+ // s += String.fromCharCode(c)
82
+ // } else if (charType == 3) {
83
+ // c = ((c & 15) << 18 | (d[i++] & 63) << 12 | (d[i++] & 63) << 6 | (d[i++] & 63)) - 65536
84
+ // s += String.fromCharCode(55296 | (c >> 10), 56320 | (c & 1023))
85
+ // } else if (charType & 1) {
86
+ // s += String.fromCharCode((c & 31) << 6 | (d[i++] & 63))
87
+ // } else {
88
+ // s += String.fromCharCode((c & 15) << 12 | (d[i++] & 63) << 6 | (d[i++] & 63))
89
+ // }
90
+ // }
91
+ // }
92
+ //# sourceMappingURL=convertValuesFromUint8ArraysToStrings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convertValuesFromUint8ArraysToStrings.js","names":["strFromU8","strFromU8_","checkpoint","convertValuesFromUint8ArraysToStrings","entries","convertedEntries","_i","_Object$keys","Object","keys","length","key","data","TextDecoder","decode"],"sources":["../../source/utility/convertValuesFromUint8ArraysToStrings.js"],"sourcesContent":["// Sidenote: `strFromU8()` function from `fflate` is not \"self-contained\",\r\n// i.e. it references some variables outside of its scope,\r\n// which doesn't work with `worker-f` package and throws an error: \"td is not defined\".\r\n//\r\n// But `woker-f` package is currently not used, so this `import` is not commented out.\r\n//\r\nimport { strFromU8 as strFromU8_ } from 'fflate'\r\n\r\nimport checkpoint from './checkpoint.js'\r\n\r\n/**\r\n * @param {Record<string,Uint8Array} entries\r\n * @returns {Record<string,string>}\r\n */\r\nexport default function convertValuesFromUint8ArraysToStrings(entries) {\r\n\tcheckpoint('convert files to strings')\r\n\tconst convertedEntries = {}\r\n\tfor (const key of Object.keys(entries)) {\r\n\t\tconvertedEntries[key] = strFromU8(entries[key])\r\n\t}\r\n\treturn convertedEntries\r\n}\r\n\r\n// There's a strange thing with using `fflate`'s `strFromU8()` function:\r\n// when `import`ed directly from `fflate` package, the benchmark runs about 10% slower\r\n// then when using `new TextDecoder().decode(data)`, even though `strFromU8()`\r\n// does the same thing internally. So it's a bit mysterious.\r\n//\r\n// Because manually calling `new TextDecoder().decode(data)` is measurably faster for some reason,\r\n// `fflate`'s `strFromU8()` is used as a backup for old web browsers that don't support `TextDecoder`.\r\n//\r\n/**\r\n * Converts a Uint8Array to a string\r\n * @param data The data to decode to string\r\n * @param latin1 Whether or not to interpret the data as Latin-1. This should\r\n * not need to be true unless encoding to binary string.\r\n * @returns The original UTF-8/Latin-1 string\r\n */\r\nexport function strFromU8(data) {\r\n\t// https://caniuse.com/?search=TextDecoder\r\n if (typeof TextDecoder !== 'undefined') {\r\n return new TextDecoder().decode(data)\r\n } else {\r\n\t\treturn strFromU8_(data)\r\n\t\t// Alternatively, it could call a copy-pasted \"rest\" part of the `strFromU8()` function:\r\n // const [string, leftovers] = decodeUtf8String(data)\r\n\t\t// console.log(leftovers)\r\n // if (leftovers.length) {\r\n\t\t// \tthrow new Error('Decode UTF8')\r\n\t\t// }\r\n // return string\r\n }\r\n}\r\n\r\n// This function's code is a copy-paste of `dutf8()` function in `fflate` repository from Jul 12th, 2026.\r\n// https://github.com/101arrowz/fflate/blob/master/src/index.ts\r\n//\r\n// By the way, this function errors when running test case:\r\n// \"made-in-macos-excel-2011-with-custom-font\".\r\n// The leftover is `Uint8Array(2) [ 255, 217 ]`.\r\n// To reproduce the error, replace the entire `strFromU8()` function\r\n// in `convertValuesFromUint8ArraysToStrings()` with this function and see what happens.\r\n//\r\n// /**\r\n// * Decodes a `Uint8Array` into a UTF8 string.\r\n// * @param {Uint8Array} d\r\n// * @returns {[string, Uint8Array]} — The decoded string and what's left undecoded\r\n// */\r\n// export function decodeUtf8String(d) {\r\n// for (let s = '', i = 0;;) {\r\n// let c = d[i++]\r\n// const charType = (c > 127) + (c > 223) + (c > 239)\r\n// if (i + charType > d.length) {\r\n// \t\t\t// Returns a slice of an array.\r\n// \t\t\t// Allows garbage collector to free the original reference.\r\n// \t\t\t// This function is browser-compatible than `Uint8Array.slice()`.\r\n// \t\t\tconst leftovers = new Uint8Array(d.subarray(i - 1))\r\n// \t\t\treturn [s, leftovers]\r\n// \t\t}\r\n// if (!charType) {\r\n// \t\t\ts += String.fromCharCode(c)\r\n// \t\t} else if (charType == 3) {\r\n// c = ((c & 15) << 18 | (d[i++] & 63) << 12 | (d[i++] & 63) << 6 | (d[i++] & 63)) - 65536\r\n// s += String.fromCharCode(55296 | (c >> 10), 56320 | (c & 1023))\r\n// } else if (charType & 1) {\r\n// \t\t\ts += String.fromCharCode((c & 31) << 6 | (d[i++] & 63))\r\n// \t\t} else {\r\n// \t\t\ts += String.fromCharCode((c & 15) << 12 | (d[i++] & 63) << 6 | (d[i++] & 63))\r\n// \t\t}\r\n// }\r\n// }"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,SAAS,IAAIC,UAAU,QAAQ,QAAQ;AAEhD,OAAOC,UAAU,MAAM,iBAAiB;;AAExC;AACA;AACA;AACA;AACA,eAAe,SAASC,qCAAqCA,CAACC,OAAO,EAAE;EACtEF,UAAU,CAAC,0BAA0B,CAAC;EACtC,IAAMG,gBAAgB,GAAG,CAAC,CAAC;EAC3B,SAAAC,EAAA,MAAAC,YAAA,GAAkBC,MAAM,CAACC,IAAI,CAACL,OAAO,CAAC,EAAAE,EAAA,GAAAC,YAAA,CAAAG,MAAA,EAAAJ,EAAA,IAAE;IAAnC,IAAMK,GAAG,GAAAJ,YAAA,CAAAD,EAAA;IACbD,gBAAgB,CAACM,GAAG,CAAC,GAAGX,SAAS,CAACI,OAAO,CAACO,GAAG,CAAC,CAAC;EAChD;EACA,OAAON,gBAAgB;AACxB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASL,SAASA,CAACY,IAAI,EAAE;EAC/B;EACC,IAAI,OAAOC,WAAW,KAAK,WAAW,EAAE;IACtC,OAAO,IAAIA,WAAW,CAAC,CAAC,CAACC,MAAM,CAACF,IAAI,CAAC;EACvC,CAAC,MAAM;IACP,OAAOX,UAAU,CAACW,IAAI,CAAC;IACvB;IACE;IACF;IACE;IACF;IACA;IACE;EACF;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
@@ -0,0 +1,50 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
3
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
4
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
5
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
6
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
7
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
8
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
9
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
10
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
11
+ function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
12
+ function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
13
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
14
+ function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
15
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
16
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
17
+ var InvalidSpreadsheetError = /*#__PURE__*/function (_Error) {
18
+ _inherits(InvalidSpreadsheetError, _Error);
19
+ var _super = _createSuper(InvalidSpreadsheetError);
20
+ function InvalidSpreadsheetError(message) {
21
+ var _this;
22
+ _classCallCheck(this, InvalidSpreadsheetError);
23
+ _this = _super.call(this, message);
24
+
25
+ // Set `name` property.
26
+ //
27
+ // This error could be detected either by `instanceof InvalidInputError`
28
+ // or by comparing its `name` property value to "InvalidInputError".
29
+ // Why use the `name` comparison when `instanceof` operator is available?
30
+ // Google AI tells that it does make sense in the cases when an error is
31
+ // "serialized" and then "deserialized" in a "distributed" environment such as
32
+ // throwing an error in a worker thread and then handling it in a main thread,
33
+ // or when throwing it in one "microservice" and then catching it in another one,
34
+ // or just logging as in `sentry.io`. And in those cases, `error.constructor.name`
35
+ // isn't always available for same reason of "serializing" and then "deserializing".
36
+ //
37
+ // For example, even if `InvalidInputError` is a named export of this package,
38
+ // when later bunding the application code with a bundler it will still be minified and renamed.
39
+ // That's when the `name` property could be used to find out the actual type of the error
40
+ // in case it gets thrown and reported to a remote system like `sentry.io`.
41
+ //
42
+ // By the way, core Node.js errors themselves have a `name` property.
43
+ //
44
+ _this.name = 'InvalidSpreadsheetError';
45
+ return _this;
46
+ }
47
+ return _createClass(InvalidSpreadsheetError);
48
+ }( /*#__PURE__*/_wrapNativeSuper(Error));
49
+ export { InvalidSpreadsheetError as default };
50
+ //# sourceMappingURL=InvalidSpreadsheetError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InvalidSpreadsheetError.js","names":["InvalidSpreadsheetError","_Error","_inherits","_super","_createSuper","message","_this","_classCallCheck","call","name","_createClass","_wrapNativeSuper","Error","default"],"sources":["../../source/xlsx/InvalidSpreadsheetError.js"],"sourcesContent":["export default class InvalidSpreadsheetError extends Error {\r\n\tconstructor(message) {\r\n\t\tsuper(message)\r\n\r\n\t\t// Set `name` property.\r\n\t\t//\r\n\t\t// This error could be detected either by `instanceof InvalidInputError`\r\n\t\t// or by comparing its `name` property value to \"InvalidInputError\".\r\n\t\t// Why use the `name` comparison when `instanceof` operator is available?\r\n\t\t// Google AI tells that it does make sense in the cases when an error is\r\n\t\t// \"serialized\" and then \"deserialized\" in a \"distributed\" environment such as\r\n\t\t// throwing an error in a worker thread and then handling it in a main thread,\r\n\t\t// or when throwing it in one \"microservice\" and then catching it in another one,\r\n\t\t// or just logging as in `sentry.io`. And in those cases, `error.constructor.name`\r\n\t\t// isn't always available for same reason of \"serializing\" and then \"deserializing\".\r\n\t\t//\r\n\t\t// For example, even if `InvalidInputError` is a named export of this package,\r\n\t\t// when later bunding the application code with a bundler it will still be minified and renamed.\r\n\t\t// That's when the `name` property could be used to find out the actual type of the error\r\n\t\t// in case it gets thrown and reported to a remote system like `sentry.io`.\r\n\t\t//\r\n\t\t// By the way, core Node.js errors themselves have a `name` property.\r\n\t\t//\r\n\t\tthis.name = 'InvalidSpreadsheetError'\r\n\t}\r\n}"],"mappings":";;;;;;;;;;;;;;;;IAAqBA,uBAAuB,0BAAAC,MAAA;EAAAC,SAAA,CAAAF,uBAAA,EAAAC,MAAA;EAAA,IAAAE,MAAA,GAAAC,YAAA,CAAAJ,uBAAA;EAC3C,SAAAA,wBAAYK,OAAO,EAAE;IAAA,IAAAC,KAAA;IAAAC,eAAA,OAAAP,uBAAA;IACpBM,KAAA,GAAAH,MAAA,CAAAK,IAAA,OAAMH,OAAO;;IAEb;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACAC,KAAA,CAAKG,IAAI,GAAG,yBAAyB;IAAA,OAAAH,KAAA;EACtC;EAAC,OAAAI,YAAA,CAAAV,uBAAA;AAAA,gBAAAW,gBAAA,CAxBmDC,KAAK;AAAA,SAArCZ,uBAAuB,IAAAa,OAAA"}
@@ -0,0 +1,50 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
3
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
4
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
5
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
6
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
7
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
8
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
9
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
10
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
11
+ function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
12
+ function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
13
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
14
+ function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
15
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
16
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
17
+ var SheetNotFoundError = /*#__PURE__*/function (_Error) {
18
+ _inherits(SheetNotFoundError, _Error);
19
+ var _super = _createSuper(SheetNotFoundError);
20
+ function SheetNotFoundError(message) {
21
+ var _this;
22
+ _classCallCheck(this, SheetNotFoundError);
23
+ _this = _super.call(this, message);
24
+
25
+ // Set `name` property.
26
+ //
27
+ // This error could be detected either by `instanceof InvalidInputError`
28
+ // or by comparing its `name` property value to "InvalidInputError".
29
+ // Why use the `name` comparison when `instanceof` operator is available?
30
+ // Google AI tells that it does make sense in the cases when an error is
31
+ // "serialized" and then "deserialized" in a "distributed" environment such as
32
+ // throwing an error in a worker thread and then handling it in a main thread,
33
+ // or when throwing it in one "microservice" and then catching it in another one,
34
+ // or just logging as in `sentry.io`. And in those cases, `error.constructor.name`
35
+ // isn't always available for same reason of "serializing" and then "deserializing".
36
+ //
37
+ // For example, even if `InvalidInputError` is a named export of this package,
38
+ // when later bunding the application code with a bundler it will still be minified and renamed.
39
+ // That's when the `name` property could be used to find out the actual type of the error
40
+ // in case it gets thrown and reported to a remote system like `sentry.io`.
41
+ //
42
+ // By the way, core Node.js errors themselves have a `name` property.
43
+ //
44
+ _this.name = 'SheetNotFoundError';
45
+ return _this;
46
+ }
47
+ return _createClass(SheetNotFoundError);
48
+ }( /*#__PURE__*/_wrapNativeSuper(Error));
49
+ export { SheetNotFoundError as default };
50
+ //# sourceMappingURL=SheetNotFoundError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SheetNotFoundError.js","names":["SheetNotFoundError","_Error","_inherits","_super","_createSuper","message","_this","_classCallCheck","call","name","_createClass","_wrapNativeSuper","Error","default"],"sources":["../../source/xlsx/SheetNotFoundError.js"],"sourcesContent":["export default class SheetNotFoundError extends Error {\r\n\tconstructor(message) {\r\n\t\tsuper(message)\r\n\r\n\t\t// Set `name` property.\r\n\t\t//\r\n\t\t// This error could be detected either by `instanceof InvalidInputError`\r\n\t\t// or by comparing its `name` property value to \"InvalidInputError\".\r\n\t\t// Why use the `name` comparison when `instanceof` operator is available?\r\n\t\t// Google AI tells that it does make sense in the cases when an error is\r\n\t\t// \"serialized\" and then \"deserialized\" in a \"distributed\" environment such as\r\n\t\t// throwing an error in a worker thread and then handling it in a main thread,\r\n\t\t// or when throwing it in one \"microservice\" and then catching it in another one,\r\n\t\t// or just logging as in `sentry.io`. And in those cases, `error.constructor.name`\r\n\t\t// isn't always available for same reason of \"serializing\" and then \"deserializing\".\r\n\t\t//\r\n\t\t// For example, even if `InvalidInputError` is a named export of this package,\r\n\t\t// when later bunding the application code with a bundler it will still be minified and renamed.\r\n\t\t// That's when the `name` property could be used to find out the actual type of the error\r\n\t\t// in case it gets thrown and reported to a remote system like `sentry.io`.\r\n\t\t//\r\n\t\t// By the way, core Node.js errors themselves have a `name` property.\r\n\t\t//\r\n\t\tthis.name = 'SheetNotFoundError'\r\n\t}\r\n}"],"mappings":";;;;;;;;;;;;;;;;IAAqBA,kBAAkB,0BAAAC,MAAA;EAAAC,SAAA,CAAAF,kBAAA,EAAAC,MAAA;EAAA,IAAAE,MAAA,GAAAC,YAAA,CAAAJ,kBAAA;EACtC,SAAAA,mBAAYK,OAAO,EAAE;IAAA,IAAAC,KAAA;IAAAC,eAAA,OAAAP,kBAAA;IACpBM,KAAA,GAAAH,MAAA,CAAAK,IAAA,OAAMH,OAAO;;IAEb;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACAC,KAAA,CAAKG,IAAI,GAAG,oBAAoB;IAAA,OAAAH,KAAA;EACjC;EAAC,OAAAI,YAAA,CAAAV,kBAAA;AAAA,gBAAAW,gBAAA,CAxB8CC,KAAK;AAAA,SAAhCZ,kBAAkB,IAAAa,OAAA"}
@@ -0,0 +1,96 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
7
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
8
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
9
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
10
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
11
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
12
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
13
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
14
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
15
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
16
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
17
+ import { Transform } from 'node:stream';
18
+ import createFileTypeDetector from './createFileTypeDetector.js';
19
+ import { validateByte, noFileTypeCouldBeDetermined } from './validateLeadingBytes.js';
20
+ import InvalidInputError from './InvalidInputError.js';
21
+
22
+ /**
23
+ * Verifies that an input stream represents a valid `.xlsx` file.
24
+ *
25
+ * Throws an `InvalidInputError` when the input isn't an `.xlsx` file.
26
+ */
27
+ var InputValidationStream = /*#__PURE__*/function (_Transform) {
28
+ _inherits(InputValidationStream, _Transform);
29
+ var _super = _createSuper(InputValidationStream);
30
+ function InputValidationStream() {
31
+ var _this;
32
+ _classCallCheck(this, InputValidationStream);
33
+ _this = _super.call(this);
34
+ _this.d = createFileTypeDetector();
35
+ _this.i = 0;
36
+ _this.chunks = [];
37
+ return _this;
38
+ }
39
+ _createClass(InputValidationStream, [{
40
+ key: "_transform",
41
+ value: function _transform(chunk, encoding, callback) {
42
+ if (this.d) {
43
+ // Don't send this chunk to the unzipper stream yet,
44
+ // otherwise it might throw an invalid `.zip` archive error
45
+ // before it has detected an `.xls` file.
46
+ this.chunks.push(chunk);
47
+ // Validate the bytes of the chunk.
48
+ for (var _iterator = _createForOfIteratorHelperLoose(chunk), _step; !(_step = _iterator()).done;) {
49
+ var _byte = _step.value;
50
+ try {
51
+ if (validateByte(_byte, this.d)) {
52
+ this.d = undefined;
53
+ chunk = Buffer.concat(this.chunks);
54
+ this.chunks = undefined;
55
+ break;
56
+ }
57
+ } catch (error) {
58
+ // Destroy the stream with a validation error,
59
+ // halt further processing and emit an "error" event.
60
+ return callback(error);
61
+ }
62
+ this.i++;
63
+ }
64
+ if (this.d) {
65
+ return callback();
66
+ }
67
+ }
68
+
69
+ // Pass the chunk down to the next stream destination
70
+ this.push(chunk);
71
+ callback();
72
+ }
73
+
74
+ // `_flush()` is called when there will be no more input, before the "end" event is emitted.
75
+ }, {
76
+ key: "_flush",
77
+ value: function _flush(callback) {
78
+ // If it's still deciding on the file type and there will be no more bytes to read
79
+ // then the file is too short and it should throw an error.
80
+ if (this.d) {
81
+ try {
82
+ noFileTypeCouldBeDetermined(this.i);
83
+ } catch (error) {
84
+ // Destroy the stream with a validation error
85
+ // and emit an "error" event instead of an "end" event.
86
+ return callback(error);
87
+ }
88
+ }
89
+ // Call the callback to signal that flushing is complete.
90
+ callback();
91
+ }
92
+ }]);
93
+ return InputValidationStream;
94
+ }(Transform);
95
+ export { InputValidationStream as default };
96
+ //# sourceMappingURL=InputValidationStream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InputValidationStream.js","names":["Transform","createFileTypeDetector","validateByte","noFileTypeCouldBeDetermined","InvalidInputError","InputValidationStream","_Transform","_inherits","_super","_createSuper","_this","_classCallCheck","call","d","i","chunks","_createClass","key","value","_transform","chunk","encoding","callback","push","_iterator","_createForOfIteratorHelperLoose","_step","done","byte","undefined","Buffer","concat","error","_flush","default"],"sources":["../../../source/xlsx/file/InputValidationStream.js"],"sourcesContent":["import { Transform } from 'node:stream'\r\n\r\nimport createFileTypeDetector from './createFileTypeDetector.js'\r\nimport { validateByte, noFileTypeCouldBeDetermined } from './validateLeadingBytes.js'\r\n\r\nimport InvalidInputError from './InvalidInputError.js'\r\n\r\n/**\r\n * Verifies that an input stream represents a valid `.xlsx` file.\r\n *\r\n * Throws an `InvalidInputError` when the input isn't an `.xlsx` file.\r\n */\r\nexport default class InputValidationStream extends Transform {\r\n constructor() {\r\n super()\r\n this.d = createFileTypeDetector()\r\n this.i = 0\r\n this.chunks = []\r\n }\r\n\r\n _transform(chunk, encoding, callback) {\r\n if (this.d) {\r\n // Don't send this chunk to the unzipper stream yet,\r\n // otherwise it might throw an invalid `.zip` archive error\r\n // before it has detected an `.xls` file.\r\n this.chunks.push(chunk)\r\n // Validate the bytes of the chunk.\r\n for (const byte of chunk) {\r\n try {\r\n if (validateByte(byte, this.d)) {\r\n this.d = undefined\r\n chunk = Buffer.concat(this.chunks)\r\n this.chunks = undefined\r\n break\r\n }\r\n } catch (error) {\r\n // Destroy the stream with a validation error,\r\n // halt further processing and emit an \"error\" event.\r\n return callback(error)\r\n }\r\n this.i++\r\n }\r\n if (this.d) {\r\n return callback()\r\n }\r\n }\r\n\r\n // Pass the chunk down to the next stream destination\r\n this.push(chunk)\r\n callback()\r\n }\r\n\r\n // `_flush()` is called when there will be no more input, before the \"end\" event is emitted.\r\n _flush(callback) {\r\n // If it's still deciding on the file type and there will be no more bytes to read\r\n // then the file is too short and it should throw an error.\r\n if (this.d) {\r\n try {\r\n noFileTypeCouldBeDetermined(this.i)\r\n } catch (error) {\r\n // Destroy the stream with a validation error\r\n // and emit an \"error\" event instead of an \"end\" event.\r\n return callback(error)\r\n }\r\n }\r\n // Call the callback to signal that flushing is complete.\r\n callback()\r\n }\r\n}"],"mappings":";;;;;;;;;;;;;;;;AAAA,SAASA,SAAS,QAAQ,aAAa;AAEvC,OAAOC,sBAAsB,MAAM,6BAA6B;AAChE,SAASC,YAAY,EAAEC,2BAA2B,QAAQ,2BAA2B;AAErF,OAAOC,iBAAiB,MAAM,wBAAwB;;AAEtD;AACA;AACA;AACA;AACA;AAJA,IAKqBC,qBAAqB,0BAAAC,UAAA;EAAAC,SAAA,CAAAF,qBAAA,EAAAC,UAAA;EAAA,IAAAE,MAAA,GAAAC,YAAA,CAAAJ,qBAAA;EACxC,SAAAA,sBAAA,EAAc;IAAA,IAAAK,KAAA;IAAAC,eAAA,OAAAN,qBAAA;IACZK,KAAA,GAAAF,MAAA,CAAAI,IAAA;IACAF,KAAA,CAAKG,CAAC,GAAGZ,sBAAs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