read-excel-file 9.2.0 → 9.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. package/.gitlab-ci.yml +1 -1
  2. package/CHANGELOG.md +5 -0
  3. package/README.md +153 -50
  4. package/bundle/read-excel-file.min.js +1 -1
  5. package/bundle/read-excel-file.min.js.map +1 -1
  6. package/bundle/read-excel-file.min.old.js +2 -0
  7. package/bundle/read-excel-file.min.old.js.map +1 -0
  8. package/commonjs/export/convertValuesFromUint8ArraysToStrings.js +3 -0
  9. package/commonjs/export/convertValuesFromUint8ArraysToStrings.js.map +1 -1
  10. package/commonjs/export/parseSheet.js +12 -9
  11. package/commonjs/export/parseSheet.js.map +1 -1
  12. package/commonjs/export/readSheetBrowser.js +6 -2
  13. package/commonjs/export/readSheetBrowser.js.map +1 -1
  14. package/commonjs/export/readSheetNode.js +6 -2
  15. package/commonjs/export/readSheetNode.js.map +1 -1
  16. package/commonjs/export/readSheetUniversal.js +14 -2
  17. package/commonjs/export/readSheetUniversal.js.map +1 -1
  18. package/commonjs/export/readSheetWebWorker.js +12 -2
  19. package/commonjs/export/readSheetWebWorker.js.map +1 -1
  20. package/commonjs/export/readXlsxFileBrowser.js +6 -2
  21. package/commonjs/export/readXlsxFileBrowser.js.map +1 -1
  22. package/commonjs/export/readXlsxFileNode.js +6 -2
  23. package/commonjs/export/readXlsxFileNode.js.map +1 -1
  24. package/commonjs/export/readXlsxFileUniversal.js +14 -2
  25. package/commonjs/export/readXlsxFileUniversal.js.map +1 -1
  26. package/commonjs/export/readXlsxFileWebWorker.js +12 -2
  27. package/commonjs/export/readXlsxFileWebWorker.js.map +1 -1
  28. package/commonjs/export/unpackXlsxFileBrowser.js +29 -6
  29. package/commonjs/export/unpackXlsxFileBrowser.js.map +1 -1
  30. package/commonjs/export/unpackXlsxFileNode.js +6 -0
  31. package/commonjs/export/unpackXlsxFileNode.js.map +1 -1
  32. package/commonjs/export/unpackXlsxFileUniversal.js +6 -0
  33. package/commonjs/export/unpackXlsxFileUniversal.js.map +1 -1
  34. package/commonjs/export/unpackXlsxFileWebWorker.js +14 -0
  35. package/commonjs/export/unpackXlsxFileWebWorker.js.map +1 -0
  36. package/commonjs/parseSheetData/parseSheetData.js +6 -6
  37. package/commonjs/parseSheetData/parseSheetData.js.map +1 -1
  38. package/commonjs/utility/checkpoint.js +33 -0
  39. package/commonjs/utility/checkpoint.js.map +1 -0
  40. package/commonjs/utility/isObject.js +15 -0
  41. package/commonjs/utility/isObject.js.map +1 -0
  42. package/commonjs/utility/isPromise.js +18 -0
  43. package/commonjs/utility/isPromise.js.map +1 -0
  44. package/commonjs/xlsx/convertCellsToData2dArray.js +0 -3
  45. package/commonjs/xlsx/convertCellsToData2dArray.js.map +1 -1
  46. package/commonjs/xlsx/isDateFormatStyle.js +2 -2
  47. package/commonjs/xlsx/isDateFormatStyle.js.map +1 -1
  48. package/commonjs/xlsx/parseCell.js +89 -24
  49. package/commonjs/xlsx/parseCell.js.map +1 -1
  50. package/{modules/xlsx/parseCellCoordinates.js → commonjs/xlsx/parseCellAddress.js} +18 -7
  51. package/commonjs/xlsx/parseCellAddress.js.map +1 -0
  52. package/commonjs/xlsx/parseCellValue.js +7 -23
  53. package/commonjs/xlsx/parseCellValue.js.map +1 -1
  54. package/commonjs/xlsx/parseFilePaths.js +31 -32
  55. package/commonjs/xlsx/parseFilePaths.js.map +1 -1
  56. package/commonjs/xlsx/parseNumber.js +20 -0
  57. package/commonjs/xlsx/parseNumber.js.map +1 -0
  58. package/commonjs/xlsx/parseSharedString.js +64 -0
  59. package/commonjs/xlsx/parseSharedString.js.map +1 -0
  60. package/commonjs/xlsx/parseSharedStrings.js +45 -5
  61. package/commonjs/xlsx/parseSharedStrings.js.map +1 -1
  62. package/commonjs/xlsx/parseSheet.js +93 -9
  63. package/commonjs/xlsx/parseSheet.js.map +1 -1
  64. package/commonjs/xlsx/parseSheetData.js +68 -0
  65. package/commonjs/xlsx/parseSheetData.js.map +1 -0
  66. package/commonjs/xlsx/parseSpreadsheetContents.js +244 -43
  67. package/commonjs/xlsx/parseSpreadsheetContents.js.map +1 -1
  68. package/commonjs/xlsx/parseSpreadsheetInfo.js +67 -36
  69. package/commonjs/xlsx/parseSpreadsheetInfo.js.map +1 -1
  70. package/commonjs/xlsx/parseStyles.js +89 -36
  71. package/commonjs/xlsx/parseStyles.js.map +1 -1
  72. package/commonjs/xml/dom.js +2 -1
  73. package/commonjs/xml/dom.js.map +1 -1
  74. package/commonjs/xml/parseXmlStream.js +14 -0
  75. package/commonjs/xml/parseXmlStream.js.map +1 -0
  76. package/commonjs/xml/parseXmlStream.sax.js +109 -0
  77. package/commonjs/xml/parseXmlStream.sax.js.map +1 -0
  78. package/commonjs/xml/parseXmlStream.saxen.code.js +953 -0
  79. package/commonjs/xml/parseXmlStream.saxen.code.js.map +1 -0
  80. package/commonjs/xml/parseXmlStream.saxen.js +85 -0
  81. package/commonjs/xml/parseXmlStream.saxen.js.map +1 -0
  82. package/commonjs/xml/xlsx.js +75 -40
  83. package/commonjs/xml/xlsx.js.map +1 -1
  84. package/commonjs/zip/unzipFromArrayBuffer.js +5 -14
  85. package/commonjs/zip/unzipFromArrayBuffer.js.map +1 -1
  86. package/commonjs/zip/unzipFromStream.fflate.js +154 -25
  87. package/commonjs/zip/unzipFromStream.fflate.js.map +1 -1
  88. package/commonjs/zip/unzipFromStream.js.map +1 -1
  89. package/commonjs/zip/unzipFromStream.unzipper.js +37 -26
  90. package/commonjs/zip/unzipFromStream.unzipper.js.map +1 -1
  91. package/modules/export/convertValuesFromUint8ArraysToStrings.js +2 -0
  92. package/modules/export/convertValuesFromUint8ArraysToStrings.js.map +1 -1
  93. package/modules/export/parseSheet.js +12 -9
  94. package/modules/export/parseSheet.js.map +1 -1
  95. package/modules/export/readSheetBrowser.js +5 -2
  96. package/modules/export/readSheetBrowser.js.map +1 -1
  97. package/modules/export/readSheetNode.js +5 -2
  98. package/modules/export/readSheetNode.js.map +1 -1
  99. package/modules/export/readSheetUniversal.js +14 -2
  100. package/modules/export/readSheetUniversal.js.map +1 -1
  101. package/modules/export/readSheetWebWorker.js +12 -2
  102. package/modules/export/readSheetWebWorker.js.map +1 -1
  103. package/modules/export/readXlsxFileBrowser.js +5 -2
  104. package/modules/export/readXlsxFileBrowser.js.map +1 -1
  105. package/modules/export/readXlsxFileNode.js +5 -2
  106. package/modules/export/readXlsxFileNode.js.map +1 -1
  107. package/modules/export/readXlsxFileUniversal.js +14 -2
  108. package/modules/export/readXlsxFileUniversal.js.map +1 -1
  109. package/modules/export/readXlsxFileWebWorker.js +12 -2
  110. package/modules/export/readXlsxFileWebWorker.js.map +1 -1
  111. package/modules/export/unpackXlsxFileBrowser.js +26 -6
  112. package/modules/export/unpackXlsxFileBrowser.js.map +1 -1
  113. package/modules/export/unpackXlsxFileNode.js +3 -0
  114. package/modules/export/unpackXlsxFileNode.js.map +1 -1
  115. package/modules/export/unpackXlsxFileUniversal.js +3 -0
  116. package/modules/export/unpackXlsxFileUniversal.js.map +1 -1
  117. package/modules/export/unpackXlsxFileWebWorker.js +6 -0
  118. package/modules/export/unpackXlsxFileWebWorker.js.map +1 -0
  119. package/modules/parseSheetData/parseSheetData.js +4 -4
  120. package/modules/parseSheetData/parseSheetData.js.map +1 -1
  121. package/modules/utility/checkpoint.js +25 -0
  122. package/modules/utility/checkpoint.js.map +1 -0
  123. package/modules/utility/isObject.js +9 -0
  124. package/modules/utility/isObject.js.map +1 -0
  125. package/modules/utility/isPromise.js +12 -0
  126. package/modules/utility/isPromise.js.map +1 -0
  127. package/modules/xlsx/convertCellsToData2dArray.js +0 -3
  128. package/modules/xlsx/convertCellsToData2dArray.js.map +1 -1
  129. package/modules/xlsx/isDateFormatStyle.js +2 -2
  130. package/modules/xlsx/isDateFormatStyle.js.map +1 -1
  131. package/modules/xlsx/parseCell.js +85 -24
  132. package/modules/xlsx/parseCell.js.map +1 -1
  133. package/{commonjs/xlsx/parseCellCoordinates.js → modules/xlsx/parseCellAddress.js} +12 -13
  134. package/modules/xlsx/parseCellAddress.js.map +1 -0
  135. package/modules/xlsx/parseCellValue.js +7 -23
  136. package/modules/xlsx/parseCellValue.js.map +1 -1
  137. package/modules/xlsx/parseFilePaths.js +31 -33
  138. package/modules/xlsx/parseFilePaths.js.map +1 -1
  139. package/modules/xlsx/parseNumber.js +14 -0
  140. package/modules/xlsx/parseNumber.js.map +1 -0
  141. package/modules/xlsx/parseSharedString.js +55 -0
  142. package/modules/xlsx/parseSharedString.js.map +1 -0
  143. package/modules/xlsx/parseSharedStrings.js +46 -5
  144. package/modules/xlsx/parseSharedStrings.js.map +1 -1
  145. package/modules/xlsx/parseSheet.js +91 -9
  146. package/modules/xlsx/parseSheet.js.map +1 -1
  147. package/modules/xlsx/parseSheetData.js +55 -0
  148. package/modules/xlsx/parseSheetData.js.map +1 -0
  149. package/modules/xlsx/parseSpreadsheetContents.js +242 -43
  150. package/modules/xlsx/parseSpreadsheetContents.js.map +1 -1
  151. package/modules/xlsx/parseSpreadsheetInfo.js +67 -37
  152. package/modules/xlsx/parseSpreadsheetInfo.js.map +1 -1
  153. package/modules/xlsx/parseStyles.js +88 -36
  154. package/modules/xlsx/parseStyles.js.map +1 -1
  155. package/modules/xml/dom.js +2 -1
  156. package/modules/xml/dom.js.map +1 -1
  157. package/modules/xml/parseXmlStream.js +18 -0
  158. package/modules/xml/parseXmlStream.js.map +1 -0
  159. package/modules/xml/parseXmlStream.sax.js +103 -0
  160. package/modules/xml/parseXmlStream.sax.js.map +1 -0
  161. package/modules/xml/parseXmlStream.saxen.code.js +947 -0
  162. package/modules/xml/parseXmlStream.saxen.code.js.map +1 -0
  163. package/modules/xml/parseXmlStream.saxen.js +79 -0
  164. package/modules/xml/parseXmlStream.saxen.js.map +1 -0
  165. package/modules/xml/xlsx.js +72 -36
  166. package/modules/xml/xlsx.js.map +1 -1
  167. package/modules/zip/unzipFromArrayBuffer.js +5 -14
  168. package/modules/zip/unzipFromArrayBuffer.js.map +1 -1
  169. package/modules/zip/unzipFromStream.fflate.js +157 -24
  170. package/modules/zip/unzipFromStream.fflate.js.map +1 -1
  171. package/modules/zip/unzipFromStream.js +56 -2
  172. package/modules/zip/unzipFromStream.js.map +1 -1
  173. package/modules/zip/unzipFromStream.unzipper.js +38 -26
  174. package/modules/zip/unzipFromStream.unzipper.js.map +1 -1
  175. package/package.json +4 -6
  176. package/commonjs/xlsx/parseCellCoordinates.js.map +0 -1
  177. package/commonjs/xlsx/parseCells.js +0 -34
  178. package/commonjs/xlsx/parseCells.js.map +0 -1
  179. package/commonjs/xlsx/parseSheetDimensions.js +0 -43
  180. package/commonjs/xlsx/parseSheetDimensions.js.map +0 -1
  181. package/commonjs/xml/xml.js +0 -13
  182. package/commonjs/xml/xml.js.map +0 -1
  183. package/commonjs/xml/xmlBrowser.js +0 -17
  184. package/commonjs/xml/xmlBrowser.js.map +0 -1
  185. package/commonjs/xml/xpath/xlsx-xpath.js +0 -92
  186. package/commonjs/xml/xpath/xlsx-xpath.js.map +0 -1
  187. package/commonjs/xml/xpath/xpathBrowser.js +0 -33
  188. package/commonjs/xml/xpath/xpathBrowser.js.map +0 -1
  189. package/commonjs/xml/xpath/xpathNode.js +0 -16
  190. package/commonjs/xml/xpath/xpathNode.js.map +0 -1
  191. package/modules/xlsx/parseCellCoordinates.js.map +0 -1
  192. package/modules/xlsx/parseCells.js +0 -27
  193. package/modules/xlsx/parseCells.js.map +0 -1
  194. package/modules/xlsx/parseSheetDimensions.js +0 -37
  195. package/modules/xlsx/parseSheetDimensions.js.map +0 -1
  196. package/modules/xml/xml.js +0 -7
  197. package/modules/xml/xml.js.map +0 -1
  198. package/modules/xml/xmlBrowser.js +0 -11
  199. package/modules/xml/xmlBrowser.js.map +0 -1
  200. package/modules/xml/xpath/xlsx-xpath.js +0 -73
  201. package/modules/xml/xpath/xlsx-xpath.js.map +0 -1
  202. package/modules/xml/xpath/xpathBrowser.js +0 -27
  203. package/modules/xml/xpath/xpathBrowser.js.map +0 -1
  204. package/modules/xml/xpath/xpathNode.js +0 -9
  205. package/modules/xml/xpath/xpathNode.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"parseSheetData.js","names":["NumberType","StringType","BooleanType","DateType","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","isObject","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","objectConstructor","constructor"],"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\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 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 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 = {}\r\n\r\nconst objectConstructor = {}.constructor\r\n\r\nfunction isObject(object) {\r\n return object !== undefined && object !== null && object.constructor === objectConstructor\r\n}"],"mappings":";;;;;;;;;;;;;;;AAAA,OAAOA,UAAU,MAAM,mBAAmB;AAC1C,OAAOC,UAAU,MAAM,mBAAmB;AAC1C,OAAOC,WAAW,MAAM,oBAAoB;AAC5C,OAAOC,QAAQ,MAAM,iBAAiB;;AAEtC;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;EAClE,IAAMC,OAAO,GAAG,EAAE;EAClB,IAAIC,MAAM,GAAG,EAAE;EAEf,IAAMC,UAAU,GAAGC,8BAA8B,CAACN,IAAI,EAAEC,MAAM,EAAEC,aAAa,CAAC;EAC9E,IAAIK,cAAc,GAAG,CAAC;EACtB,SAAAC,SAAA,GAAAC,+BAAA,CAA4CJ,UAAU,GAAAK,KAAA,IAAAA,KAAA,GAAAF,SAAA,IAAAG,IAAA,GAAE;IAAA,IAAAC,WAAA,GAAAF,KAAA,CAAAG,KAAA;MAA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,eAAe,GAAG;EACtBzE,gCAAgC,EAAExB,SAAS;EAC3CoC,4BAA4B,EAAE,IAAI;EAClC;EACA;EACA;EACAuC,oBAAoB,EAAE,SAAAA,qBAAA;IAAA,OAAM,IAAI;EAAA;EAChCC,mBAAmB,EAAE,SAAAA,oBAAA;IAAA,OAAM,IAAI;EAAA;EAC/B/B,kBAAkB,EAAE;AACtB,CAAC;AAED,SAASxD,mBAAmBA,CAACD,OAAO,EAAE;EACpC,IAAIA,OAAO,EAAE;IACX,OAAAL,aAAA,CAAAA,aAAA,KACKkH,eAAe,GACf7G,OAAO;EAEd,CAAC,MAAM;IACL,OAAO6G,eAAe;EACxB;AACF;;AAEA;AACA,IAAM7F,wBAAwB,GAAG,CAAC,CAAC;AAEnC,IAAM8F,iBAAiB,GAAG,CAAC,CAAC,CAACC,WAAW;AAExC,SAASzB,QAAQA,CAAChG,MAAM,EAAE;EACxB,OAAOA,MAAM,KAAKsB,SAAS,IAAItB,MAAM,KAAK,IAAI,IAAIA,MAAM,CAACyH,WAAW,KAAKD,iBAAiB;AAC5F"}
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,MAAM,mBAAmB;AAC1C,OAAOC,UAAU,MAAM,mBAAmB;AAC1C,OAAOC,WAAW,MAA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
+ // It shows how much time each stage executes for.
3
+ // To enable the logs with the timing, set a global variable
4
+ // called `READ_EXCEL_FILE_CHECKPOINTS` in Node.js or web browser.
5
+
6
+ // This global variable is only exported to be added in the dependencies of a worker function.
7
+ // See `worker-f` package for more info.
8
+ export var latestCheckpointTimestamp;
9
+ export default function checkpoint(name) {
10
+ var now = Date.now();
11
+
12
+ // See if the global flag for "should output log" is set to `true`.
13
+ var shouldOutputLog = typeof global !== 'undefined' ? Boolean(global.READ_EXCEL_FILE_CHECKPOINTS) : typeof window !== 'undefined' ? Boolean(window.READ_EXCEL_FILE_CHECKPOINTS) : false;
14
+ if (shouldOutputLog) {
15
+ if (latestCheckpointTimestamp) {
16
+ console.log(' -', now - latestCheckpointTimestamp, 'ms');
17
+ }
18
+ console.log('*', name);
19
+ }
20
+ latestCheckpointTimestamp = now;
21
+ }
22
+ export function resetCheckpoint() {
23
+ latestCheckpointTimestamp = undefined;
24
+ }
25
+ //# sourceMappingURL=checkpoint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkpoint.js","names":["latestCheckpointTimestamp","checkpoint","name","now","Date","shouldOutputLog","global","Boolean","READ_EXCEL_FILE_CHECKPOINTS","window","console","log","resetCheckpoint","undefined"],"sources":["../../source/utility/checkpoint.js"],"sourcesContent":["// This code is used to profile reading `.xlsx` files.\r\n// It shows how much time each stage executes for.\r\n// To enable the logs with the timing, set a global variable\r\n// called `READ_EXCEL_FILE_CHECKPOINTS` in Node.js or web browser.\r\n\r\n// This global variable is only exported to be added in the dependencies of a worker function.\r\n// See `worker-f` package for more info.\r\nexport let latestCheckpointTimestamp\r\n\r\nexport default function checkpoint(name) {\r\n\tconst now = Date.now()\r\n\r\n\t// See if the global flag for \"should output log\" is set to `true`.\r\n\tconst shouldOutputLog = typeof global !== 'undefined'\r\n\t\t? Boolean(global.READ_EXCEL_FILE_CHECKPOINTS)\r\n\t\t: (\r\n\t\t\ttypeof window !== 'undefined'\r\n\t\t\t\t? Boolean(window.READ_EXCEL_FILE_CHECKPOINTS)\r\n\t\t\t\t: false\r\n\t\t)\r\n\r\n\tif (shouldOutputLog) {\r\n\t\tif (latestCheckpointTimestamp) {\r\n\t\t\tconsole.log(' -', now - latestCheckpointTimestamp, 'ms')\r\n\t\t}\r\n\t\tconsole.log('*', name)\r\n\t}\r\n\r\n\tlatestCheckpointTimestamp = now\r\n}\r\n\r\nexport function resetCheckpoint() {\r\n\tlatestCheckpointTimestamp = undefined\r\n}"],"mappings":"AAAA;AACA;AACA;AACA;;AAEA;AACA;AACA,OAAO,IAAIA,yBAAyB;AAEpC,eAAe,SAASC,UAAUA,CAACC,IAAI,EAAE;EACxC,IAAMC,GAAG,GAAGC,IAAI,CAACD,GAAG,CAAC,CAAC;;EAEtB;EACA,IAAME,eAAe,GAAG,OAAOC,MAAM,KAAK,WAAW,GAClDC,OAAO,CAACD,MAAM,CAACE,2BAA2B,CAAC,GAE5C,OAAOC,MAAM,KAAK,WAAW,GAC1BF,OAAO,CAACE,MAAM,CAACD,2BAA2B,CAAC,GAC3C,KACH;EAEF,IAAIH,eAAe,EAAE;IACpB,IAAIL,yBAAyB,EAAE;MAC9BU,OAAO,CAACC,GAAG,CAAC,KAAK,EAAER,GAAG,GAAGH,yBAAyB,EAAE,IAAI,CAAC;IAC1D;IACAU,OAAO,CAACC,GAAG,CAAC,GAAG,EAAET,IAAI,CAAC;EACvB;EAEAF,yBAAyB,GAAGG,GAAG;AAChC;AAEA,OAAO,SAASS,eAAeA,CAAA,EAAG;EACjCZ,yBAAyB,GAAGa,SAAS;AACtC"}
@@ -0,0 +1,9 @@
1
+ var objectConstructor = {}.constructor;
2
+ export default function isObject(object) {
3
+ return object !== undefined && object !== null && object.constructor === objectConstructor;
4
+ }
5
+
6
+ // export default function isObject(object: unknown): object is object {
7
+ // return object !== undefined && object !== null && object.constructor === objectConstructor
8
+ // }
9
+ //# sourceMappingURL=isObject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isObject.js","names":["objectConstructor","constructor","isObject","object","undefined"],"sources":["../../source/utility/isObject.js"],"sourcesContent":["const objectConstructor = {}.constructor\r\n\r\nexport default function isObject(object) {\r\n return object !== undefined && object !== null && object.constructor === objectConstructor\r\n}\r\n\r\n// export default function isObject(object: unknown): object is object {\r\n// return object !== undefined && object !== null && object.constructor === objectConstructor\r\n// }\r\n"],"mappings":"AAAA,IAAMA,iBAAiB,GAAG,CAAC,CAAC,CAACC,WAAW;AAExC,eAAe,SAASC,QAAQA,CAACC,MAAM,EAAE;EACvC,OAAOA,MAAM,KAAKC,SAAS,IAAID,MAAM,KAAK,IAAI,IAAIA,MAAM,CAACF,WAAW,KAAKD,iBAAiB;AAC5F;;AAEA;AACA;AACA"}
@@ -0,0 +1,12 @@
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
+ export default function isPromise(anything) {
3
+ return _typeof(anything) === 'object' && typeof anything.then === 'function';
4
+ }
5
+
6
+ // export default function isPromise<Value>(anything: unknown): anything is Promise<Value> {
7
+ // return (
8
+ // typeof anything === 'object' &&
9
+ // typeof (anything as Promise<unknown>).then === 'function'
10
+ // )
11
+ // }
12
+ //# sourceMappingURL=isPromise.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isPromise.js","names":["isPromise","anything","_typeof","then"],"sources":["../../source/utility/isPromise.js"],"sourcesContent":["export default function isPromise(anything) {\r\n return typeof anything === 'object' && typeof anything.then === 'function'\r\n}\r\n\r\n// export default function isPromise<Value>(anything: unknown): anything is Promise<Value> {\r\n// return (\r\n// typeof anything === 'object' &&\r\n// typeof (anything as Promise<unknown>).then === 'function'\r\n// )\r\n// }\r\n"],"mappings":";AAAA,eAAe,SAASA,SAASA,CAACC,QAAQ,EAAE;EAC1C,OAAOC,OAAA,CAAOD,QAAQ,MAAK,QAAQ,IAAI,OAAOA,QAAQ,CAACE,IAAI,KAAK,UAAU;AAC5E;;AAEA;AACA;AACA;AACA;AACA;AACA"}
@@ -39,9 +39,6 @@ export default function convertCellsToData2dArray(cells, dimensions) {
39
39
  }
40
40
 
41
41
  // Fill in spreadsheet `data`.
42
- // (this code implies that `cells` aren't necessarily sorted by row and column:
43
- // maybe that's not correct, this piece code was initially copy-pasted
44
- // from some other library that used `XPath`)
45
42
  for (var _iterator = _createForOfIteratorHelperLoose(cells), _step; !(_step = _iterator()).done;) {
46
43
  var cell = _step.value;
47
44
  // Don't discard empty rows or columns at the start of the spreadsheet,
@@ -1 +1 @@
1
- {"version":3,"file":"convertCellsToData2dArray.js","names":["dropEmptyRows","dropEmptyColumns","convertCellsToData2dArray","cells","dimensions","length","_dimensions","_slicedToArray","leftTop","rightBottom","colsCount","column","rowsCount","row","data","Array","i","j","_iterator","_createForOfIteratorHelperLoose","_step","done","cell","value","rowIndex","columnIndex","onlyTrimAtTheEnd"],"sources":["../../source/xlsx/convertCellsToData2dArray.js"],"sourcesContent":["import dropEmptyRows from './dropEmptyRows.js'\r\nimport dropEmptyColumns from './dropEmptyColumns.js'\r\n\r\nexport default function convertCellsToData2dArray(cells, dimensions) {\r\n // If the sheet is empty.\r\n if (cells.length === 0) {\r\n return []\r\n }\r\n\r\n const [leftTop, rightBottom] = dimensions\r\n\r\n // Don't discard empty rows or columns at the start of the spreadsheet,\r\n // even when the `*.xlsx` file itself tells that the content starts at an offset.\r\n // https://github.com/catamphetamine/read-excel-file/issues/102\r\n // const colsCount = (rightBottom.column - leftTop.column) + 1\r\n // const rowsCount = (rightBottom.row - leftTop.row) + 1\r\n\r\n const colsCount = rightBottom.column\r\n const rowsCount = rightBottom.row\r\n\r\n // Initialize spreadsheet data structure.\r\n let data = new Array(rowsCount)\r\n let i = 0\r\n while (i < rowsCount) {\r\n data[i] = new Array(colsCount)\r\n let j = 0\r\n while (j < colsCount) {\r\n data[i][j] = null\r\n j++\r\n }\r\n i++\r\n }\r\n\r\n // Fill in spreadsheet `data`.\r\n // (this code implies that `cells` aren't necessarily sorted by row and column:\r\n // maybe that's not correct, this piece code was initially copy-pasted\r\n // from some other library that used `XPath`)\r\n for (const cell of cells) {\r\n // Don't discard empty rows or columns at the start of the spreadsheet,\r\n // even when the `*.xlsx` file itself tells that the content starts at an offset.\r\n // https://github.com/catamphetamine/read-excel-file/issues/102\r\n // const rowIndex = cell.row - leftTop.row\r\n // const columnIndex = cell.column - leftTop.column\r\n const rowIndex = cell.row - 1\r\n const columnIndex = cell.column - 1\r\n // Ignore the data in the cell if it's outside of the spreadsheet's \"dimensions\".\r\n if (columnIndex < colsCount && rowIndex < rowsCount) {\r\n data[rowIndex][columnIndex] = cell.value\r\n }\r\n }\r\n\r\n // // Fill in the row map, if the row map was passed.\r\n // if (options.rowIndexSourceMap) {\r\n // let i = 0\r\n // while (i < data.length) {\r\n // options.rowIndexSourceMap[i] = i\r\n // i++\r\n // }\r\n // }\r\n\r\n // Drop (discard) empty columns at the right side.\r\n // Drop (discard) empty rows at the bottom.\r\n data = dropEmptyRows(\r\n dropEmptyColumns(data, { onlyTrimAtTheEnd: true }),\r\n { onlyTrimAtTheEnd: true } // { onlyTrimAtTheEnd: true, rowIndexSourceMap: options.rowIndexSourceMap }\r\n )\r\n\r\n return data\r\n}"],"mappings":";;;;;;;AAAA,OAAOA,aAAa,MAAM,oBAAoB;AAC9C,OAAOC,gBAAgB,MAAM,uBAAuB;AAEpD,eAAe,SAASC,yBAAyBA,CAACC,KAAK,EAAEC,UAAU,EAAE;EACnE;EACA,IAAID,KAAK,CAACE,MAAM,KAAK,CAAC,EAAE;IACtB,OAAO,EAAE;EACX;EAEA,IAAAC,WAAA,GAAAC,cAAA,CAA+BH,UAAU;IAAlCI,OAAO,GAAAF,WAAA;IAAEG,WAAW,GAAAH,WAAA;;EAE3B;EACA;EACA;EACA;EACA;;EAEA,IAAMI,SAAS,GAAGD,WAAW,CAACE,MAAM;EACpC,IAAMC,SAAS,GAAGH,WAAW,CAACI,GAAG;;EAEjC;EACA,IAAIC,IAAI,GAAG,IAAIC,KAAK,CAACH,SAAS,CAAC;EAC/B,IAAII,CAAC,GAAG,CAAC;EACT,OAAOA,CAAC,GAAGJ,SAAS,EAAE;IACpBE,IAAI,CAACE,CAAC,CAAC,GAAG,IAAID,KAAK,CAACL,SAAS,CAAC;IAC9B,IAAIO,CAAC,GAAG,CAAC;IACT,OAAOA,CAAC,GAAGP,SAAS,EAAE;MACpBI,IAAI,CAACE,CAAC,CAAC,CAACC,CAAC,CAAC,GAAG,IAAI;MACjBA,CAAC,EAAE;IACL;IACAD,CAAC,EAAE;EACL;;EAEA;EACA;EACA;EACA;EACA,SAAAE,SAAA,GAAAC,+BAAA,CAAmBhB,KAAK,GAAAiB,KAAA,IAAAA,KAAA,GAAAF,SAAA,IAAAG,IAAA,GAAE;IAAA,IAAfC,IAAI,GAAAF,KAAA,CAAAG,KAAA;IACb;IACA;IACA;IACA;IACA;IACA,IAAMC,QAAQ,GAAGF,IAAI,CAACT,GAAG,GAAG,CAAC;IAC7B,IAAMY,WAAW,GAAGH,IAAI,CAACX,MAAM,GAAG,CAAC;IACnC;IACA,IAAIc,WAAW,GAAGf,SAAS,IAAIc,QAAQ,GAAGZ,SAAS,EAAE;MACnDE,IAAI,CAACU,QAAQ,CAAC,CAACC,WAAW,CAAC,GAAGH,IAAI,CAACC,KAAK;IAC1C;EACF;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACAT,IAAI,GAAGd,aAAa,CAClBC,gBAAgB,CAACa,IAAI,EAAE;IAAEY,gBAAgB,EAAE;EAAK,CAAC,CAAC,EAClD;IAAEA,gBAAgB,EAAE;EAAK,CAAC,CAAC;EAC7B,CAAC;;EAED,OAAOZ,IAAI;AACb"}
1
+ {"version":3,"file":"convertCellsToData2dArray.js","names":["dropEmptyRows","dropEmptyColumns","convertCellsToData2dArray","cells","dimensions","length","_dimensions","_slicedToArray","leftTop","rightBottom","colsCount","column","rowsCount","row","data","Array","i","j","_iterator","_createForOfIteratorHelperLoose","_step","done","cell","value","rowIndex","columnIndex","onlyTrimAtTheEnd"],"sources":["../../source/xlsx/convertCellsToData2dArray.js"],"sourcesContent":["import dropEmptyRows from './dropEmptyRows.js'\r\nimport dropEmptyColumns from './dropEmptyColumns.js'\r\n\r\nexport default function convertCellsToData2dArray(cells, dimensions) {\r\n // If the sheet is empty.\r\n if (cells.length === 0) {\r\n return []\r\n }\r\n\r\n const [leftTop, rightBottom] = dimensions\r\n\r\n // Don't discard empty rows or columns at the start of the spreadsheet,\r\n // even when the `*.xlsx` file itself tells that the content starts at an offset.\r\n // https://github.com/catamphetamine/read-excel-file/issues/102\r\n // const colsCount = (rightBottom.column - leftTop.column) + 1\r\n // const rowsCount = (rightBottom.row - leftTop.row) + 1\r\n\r\n const colsCount = rightBottom.column\r\n const rowsCount = rightBottom.row\r\n\r\n // Initialize spreadsheet data structure.\r\n let data = new Array(rowsCount)\r\n let i = 0\r\n while (i < rowsCount) {\r\n data[i] = new Array(colsCount)\r\n let j = 0\r\n while (j < colsCount) {\r\n data[i][j] = null\r\n j++\r\n }\r\n i++\r\n }\r\n\r\n // Fill in spreadsheet `data`.\r\n for (const cell of cells) {\r\n // Don't discard empty rows or columns at the start of the spreadsheet,\r\n // even when the `*.xlsx` file itself tells that the content starts at an offset.\r\n // https://github.com/catamphetamine/read-excel-file/issues/102\r\n // const rowIndex = cell.row - leftTop.row\r\n // const columnIndex = cell.column - leftTop.column\r\n const rowIndex = cell.row - 1\r\n const columnIndex = cell.column - 1\r\n // Ignore the data in the cell if it's outside of the spreadsheet's \"dimensions\".\r\n if (columnIndex < colsCount && rowIndex < rowsCount) {\r\n data[rowIndex][columnIndex] = cell.value\r\n }\r\n }\r\n\r\n // // Fill in the row map, if the row map was passed.\r\n // if (options.rowIndexSourceMap) {\r\n // let i = 0\r\n // while (i < data.length) {\r\n // options.rowIndexSourceMap[i] = i\r\n // i++\r\n // }\r\n // }\r\n\r\n // Drop (discard) empty columns at the right side.\r\n // Drop (discard) empty rows at the bottom.\r\n data = dropEmptyRows(\r\n dropEmptyColumns(data, { onlyTrimAtTheEnd: true }),\r\n { onlyTrimAtTheEnd: true } // { onlyTrimAtTheEnd: true, rowIndexSourceMap: options.rowIndexSourceMap }\r\n )\r\n\r\n return data\r\n}"],"mappings":";;;;;;;AAAA,OAAOA,aAAa,MAAM,oBAAoB;AAC9C,OAAOC,gBAAgB,MAAM,uBAAuB;AAEpD,eAAe,SAASC,yBAAyBA,CAACC,KAAK,EAAEC,UAAU,EAAE;EACnE;EACA,IAAID,KAAK,CAACE,MAAM,KAAK,CAAC,EAAE;IACtB,OAAO,EAAE;EACX;EAEA,IAAAC,WAAA,GAAAC,cAAA,CAA+BH,UAAU;IAAlCI,OAAO,GAAAF,WAAA;IAAEG,WAAW,GAAAH,WAAA;;EAE3B;EACA;EACA;EACA;EACA;;EAEA,IAAMI,SAAS,GAAGD,WAAW,CAACE,MAAM;EACpC,IAAMC,SAAS,GAAGH,WAAW,CAACI,GAAG;;EAEjC;EACA,IAAIC,IAAI,GAAG,IAAIC,KAAK,CAACH,SAAS,CAAC;EAC/B,IAAII,CAAC,GAAG,CAAC;EACT,OAAOA,CAAC,GAAGJ,SAAS,EAAE;IACpBE,IAAI,CAACE,CAAC,CAAC,GAAG,IAAID,KAAK,CAACL,SAAS,CAAC;IAC9B,IAAIO,CAAC,GAAG,CAAC;IACT,OAAOA,CAAC,GAAGP,SAAS,EAAE;MACpBI,IAAI,CAACE,CAAC,CAAC,CAACC,CAAC,CAAC,GAAG,IAAI;MACjBA,CAAC,EAAE;IACL;IACAD,CAAC,EAAE;EACL;;EAEA;EACA,SAAAE,SAAA,GAAAC,+BAAA,CAAmBhB,KAAK,GAAAiB,KAAA,IAAAA,KAAA,GAAAF,SAAA,IAAAG,IAAA,GAAE;IAAA,IAAfC,IAAI,GAAAF,KAAA,CAAAG,KAAA;IACb;IACA;IACA;IACA;IACA;IACA,IAAMC,QAAQ,GAAGF,IAAI,CAACT,GAAG,GAAG,CAAC;IAC7B,IAAMY,WAAW,GAAGH,IAAI,CAACX,MAAM,GAAG,CAAC;IACnC;IACA,IAAIc,WAAW,GAAGf,SAAS,IAAIc,QAAQ,GAAGZ,SAAS,EAAE;MACnDE,IAAI,CAACU,QAAQ,CAAC,CAACC,WAAW,CAAC,GAAGH,IAAI,CAACC,KAAK;IAC1C;EACF;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACAT,IAAI,GAAGd,aAAa,CAClBC,gBAAgB,CAACa,IAAI,EAAE;IAAEY,gBAAgB,EAAE;EAAK,CAAC,CAAC,EAClD;IAAEA,gBAAgB,EAAE;EAAK,CAAC,CAAC;EAC7B,CAAC;;EAED,OAAOZ,IAAI;AACb"}
@@ -6,7 +6,7 @@
6
6
 
7
7
  import isDateFormat from './isDateFormat.js';
8
8
  export default function isDateFormatStyle(styleId, styles, options) {
9
- if (styleId) {
9
+ if (styleId !== undefined) {
10
10
  var style = styles[styleId];
11
11
  if (!style) {
12
12
  throw new Error("Cell style not found: ".concat(styleId));
@@ -16,7 +16,7 @@ export default function isDateFormatStyle(styleId, styles, options) {
16
16
  }
17
17
  if (
18
18
  // Whether it's a "number format" that's conventionally used for storing date timestamps.
19
- BUILT_IN_DATE_FORMAT_IDS.indexOf(Number(style.numberFormat.id)) >= 0 ||
19
+ BUILT_IN_DATE_FORMAT_IDS.indexOf(style.numberFormat.id) >= 0 ||
20
20
  // Whether it's a "number format" that uses a "formatting template"
21
21
  // that the developer is certain is a date formatting template.
22
22
  options.dateFormat && style.numberFormat.template === options.dateFormat ||
@@ -1 +1 @@
1
- {"version":3,"file":"isDateFormatStyle.js","names":["isDateFormat","isDateFormatStyle","styleId","styles","options","style","Error","concat","numberFormat","BUILT_IN_DATE_FORMAT_IDS","indexOf","Number","id","dateFormat","template","smartDateParser","LOCALE_INDEPENDENT_BUILT_IN_DATE_FORMAT_IDS","MAINLAND_CHINESE_OR_TAIWANESE_LOCALE_BUILT_IN_DATE_FORMAT_IDS","JAPANESE_OR_KOREAN_LOCALE_BUILT_IN_DATE_FORMAT_IDS","THAI_LOCALE_BUILT_IN_DATE_FORMAT_IDS","filter","numberFormatId"],"sources":["../../source/xlsx/isDateFormatStyle.js"],"sourcesContent":["// XLSX does have \"d\" type for dates, but it's not commonly used.\r\n// Instead, it prefers using \"n\" type for storing dates as timestamps.\r\n//\r\n// Whether a numeric value is a number or a date timestamp, it sometimes could be\r\n// detected by looking at the value \"format\" and seeing if it's a date-specific one.\r\n\r\nimport isDateFormat from './isDateFormat.js'\r\n\r\nexport default function isDateFormatStyle(styleId, styles, options) {\r\n if (styleId) {\r\n const style = styles[styleId]\r\n if (!style) {\r\n throw new Error(`Cell style not found: ${styleId}`)\r\n }\r\n if (!style.numberFormat) {\r\n return false\r\n }\r\n if (\r\n // Whether it's a \"number format\" that's conventionally used for storing date timestamps.\r\n BUILT_IN_DATE_FORMAT_IDS.indexOf(Number(style.numberFormat.id)) >= 0 ||\r\n // Whether it's a \"number format\" that uses a \"formatting template\"\r\n // that the developer is certain is a date formatting template.\r\n (options.dateFormat && style.numberFormat.template === options.dateFormat) ||\r\n // Whether the \"smart formatting template\" feature is not disabled\r\n // and it has detected that it's a date formatting template by looking at it.\r\n (options.smartDateParser !== false && style.numberFormat.template && isDateFormat(style.numberFormat.template))\r\n ) {\r\n return true\r\n }\r\n }\r\n}\r\n\r\n// Built-in formats have ID < 164.\r\n// Some of those formats are intended to use when displaying dates.\r\n//\r\n// Depending on the \"locale\" used by the spreadsheet viewing application,\r\n// different built-in format IDs might correspond to different templates.\r\n// https://learn.microsoft.com/en-us/dotnet/api/documentformat.openxml.spreadsheet.numberingformat?view=openxml-2.8.1\r\n//\r\n// Here's a list of \"locale\"-independent built-in format IDs that're known to represent dates.\r\n//\r\nconst LOCALE_INDEPENDENT_BUILT_IN_DATE_FORMAT_IDS = [\r\n 14, // mm-dd-yy\r\n 15, // d-mmm-yy\r\n 16, // d-mmm\r\n 17, // mmm-yy\r\n 18, // h:mm AM/PM\r\n 19, // h:mm:ss AM/PM\r\n 20, // h:mm\r\n 21, // h:mm:ss\r\n 22, // m/d/yy h:mm\r\n 45, // mm:ss\r\n 46, // [h]:mm:ss\r\n 47 // mmss.0\r\n]\r\n\r\n// \"zh-tw\" OR \"zh-cn\" locales.\r\n// Language glyphs (aka \"hieroglyphs\") are not replaced with their respective unicode values here.\r\nconst MAINLAND_CHINESE_OR_TAIWANESE_LOCALE_BUILT_IN_DATE_FORMAT_IDS = [\r\n 27, // [$-404]e/m/d OR yyyy\"年\"m\"月\"\r\n 28, // [$-404]e\"年\"m\"月\"d\"日\" OR m\"月\"d\"日\"\r\n 29, // [$-404]e\"年\"m\"月\"d\"日\" OR m\"月\"d\"日\"\r\n 30, // m/d/yy OR m-d-yy\r\n 31, // yyyy\"年\"m\"月\"d\"日\" OR yyyy\"年\"m\"月\"d\"日\"\r\n 32, // hh\"時\"mm\"分\" OR h\"时\"mm\"分\"\r\n 33, // hh\"時\"mm\"分\"ss\"秒\" OR h\"时\"mm\"分\"ss\"秒\"\r\n 34, // 上午/下午hh\"時\"mm\"分\" OR 上午/下午h\"时\"mm\"分\"\r\n 35, // 上午/下午hh\"時\"mm\"分\"ss\"秒\" OR 上午/下午h\"时\"mm\"分\"ss\"秒\"\r\n 36, // [$-404]e/m/d OR yyyy\"年\"m\"月\"\r\n 50, // [$-404]e/m/d OR yyyy\"年\"m\"月\"\r\n 51, // [$-404]e\"年\"m\"月\"d\"日\" OR m\"月\"d\"日\"\r\n 52, // 上午/下午hh\"時\"mm\"分\" OR yyyy\"年\"m\"月\"\r\n 53, // 上午/下午hh\"時\"mm\"分\"ss\"秒\" OR m\"月\"d\"日\"\r\n 54, // [$-404]e\"年\"m\"月\"d\"日\" OR m\"月\"d\"日\"\r\n 55, // 上午/下午hh\"時\"mm\"分\" OR 上午/下午h\"时\"mm\"分\"\r\n 56, // 上午/下午hh\"時\"mm\"分\"ss\"秒\" OR 上午/下午h\"时\"mm\"分\"ss\"秒\"\r\n 57, // [$-404]e/m/d OR yyyy\"年\"m\"月\"\r\n 58 // [$-404]e\"年\"m\"月\"d\"日\" OR m\"月\"d\"日\"\r\n]\r\n\r\n// \"ja-jp\" OR \"ko-kr\" locales.\r\n// Language glyphs (aka \"hieroglyphs\") are not replaced with their respective unicode values here.\r\nconst JAPANESE_OR_KOREAN_LOCALE_BUILT_IN_DATE_FORMAT_IDS = [\r\n 27, // [$-411]ge.m.d OR yyyy\"年\" mm\"月\" dd\"日\"\r\n 28, // [$-411]ggge\"年\"m\"月\"d\"日\" OR mm-dd\r\n 29, // [$-411]ggge\"年\"m\"月\"d\"日\" OR mm-dd\r\n 30, // m/d/yy OR mm-dd-yy\r\n 31, // yyyy\"年\"m\"月\"d\"日\" OR yyyy\"년\" mm\"월\" dd\"일\"\r\n 32, // h\"時\"mm\"分\" OR h\"시\" mm\"분\"\r\n 33, // h\"時\"mm\"分\"ss\"秒\" OR h\"시\" mm\"분\" ss\"초\"\r\n 34, // yyyy\"年\"m\"月\" OR yyyy-mm-dd\r\n 35, // m\"月\"d\"日\" OR yyyy-mm-dd\r\n 36, // [$-411]ge.m.d OR yyyy\"年\" mm\"月\" dd\"日\"\r\n 50, // [$-411]ge.m.d OR yyyy\"年\" mm\"月\" dd\"日\"\r\n 51, // [$-411]ggge\"年\"m\"月\"d\"日\" OR mm-dd\r\n 52, // yyyy\"年\"m\"月\" OR yyyy-mm-dd\r\n 53, // m\"月\"d\"日\" OR yyyy-mm-dd\r\n 54, // [$-411]ggge\"年\"m\"月\"d\"日\" OR mm-dd\r\n 55, // yyyy\"年\"m\"月\" OR yyyy-mm-dd\r\n 56, // m\"月\"d\"日\" OR yyyy-mm-dd\r\n 57, // [$-411]ge.m.d OR yyyy\"年\" mm\"月\" dd\"日\"\r\n 58 // [$-411]ggge\"年\"m\"月\"d\"日\" OR mm-dd\r\n]\r\n\r\n// \"th-th\" locale.\r\n// Language glyphs (aka \"hieroglyphs\") are not replaced with their respective unicode values here.\r\nconst THAI_LOCALE_BUILT_IN_DATE_FORMAT_IDS = [\r\n 71, // ว/ด/ปปปป\r\n 72, // ว-ดดด-ปป\r\n 73, // ว-ดดด\r\n 74, // ดดด-ปป\r\n 75, // ช:นน\r\n 76, // ช:นน:ทท\r\n 77, // ว/ด/ปปปป ช:นน\r\n 78, // นน:ทท\r\n 79, // [ช]:นน:ทท\r\n 80, // นน:ทท.0\r\n 81 // d/m/bb\r\n]\r\n\r\n// Start with language-agnostic date format IDs.\r\nconst BUILT_IN_DATE_FORMAT_IDS = LOCALE_INDEPENDENT_BUILT_IN_DATE_FORMAT_IDS.concat(\r\n // Add Mainland Chinese or Taiwanese date format IDs that haven't already been added.\r\n MAINLAND_CHINESE_OR_TAIWANESE_LOCALE_BUILT_IN_DATE_FORMAT_IDS\r\n).concat(\r\n // Add Japanese or Korean date format IDs that haven't already been added.\r\n JAPANESE_OR_KOREAN_LOCALE_BUILT_IN_DATE_FORMAT_IDS.filter(\r\n numberFormatId => MAINLAND_CHINESE_OR_TAIWANESE_LOCALE_BUILT_IN_DATE_FORMAT_IDS.indexOf(numberFormatId) < 0\r\n )\r\n).concat(\r\n // Add Thai date format IDs that haven't already been added.\r\n THAI_LOCALE_BUILT_IN_DATE_FORMAT_IDS.filter(\r\n numberFormatId => MAINLAND_CHINESE_OR_TAIWANESE_LOCALE_BUILT_IN_DATE_FORMAT_IDS.indexOf(numberFormatId) < 0\r\n ).filter(\r\n numberFormatId => JAPANESE_OR_KOREAN_LOCALE_BUILT_IN_DATE_FORMAT_IDS.indexOf(numberFormatId) < 0\r\n )\r\n)\r\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,YAAY,MAAM,mBAAmB;AAE5C,eAAe,SAASC,iBAAiBA,CAACC,OAAO,EAAEC,MAAM,EAAEC,OAAO,EAAE;EAClE,IAAIF,OAAO,EAAE;IACX,IAAMG,KAAK,GAAGF,MAAM,CAACD,OAAO,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CAAE;AAAA,CACL;;AAED;AACA;AACA,IAAMC,kDAAkD,GAAG,CACzD,EAAE;AAAE;AACJ,EAAE;AAAE;AACJ,EAAE;AAAE;AACJ,EAAE;AAAE;AACJ,EAAE;AAAE;AACJ,EAAE;AAAE;AACJ,EAAE;AAAE;AACJ,EAAE;AAAE;AACJ,EAAE;AAAE;AACJ,EAAE;AAAE;AACJ,EAAE;AAAE;AACJ,EAAE;AAAE;AACJ,EAAE;AAAE;AACJ,EAAE;AAAE;AACJ,EAAE;AAAE;AACJ,EAAE;AAAE;AACJ,EAAE;AAAE;AACJ,EAAE;AAAE;AACJ,EAAE,CAAE;AAAA,CACL;;AAED;AACA;AACA,IAAMC,oCAAoC,GAAG,CAC3C,EAAE;AAAE;AACJ,EAAE;AAAE;AACJ,EAAE;AAAE;AACJ,EAAE;AAAE;AACJ,EAAE;AAAE;AACJ,EAAE;AAAE;AACJ,EAAE;AAAE;AACJ,EAAE;AAAE;AACJ,EAAE;AAAE;AACJ,EAAE;AAAE;AACJ,EAAE,CAAE;AAAA,CACL;;AAED;AACA,IAAMV,wBAAwB,GAAGO,2CAA2C,CAACT,MAAM;AACjF;AACAU,6DACF,CAAC,CAACV,MAAM;AACN;AACAW,kDAAkD,CAACE,MAAM,CACvD,UAAAC,cAAc;EAAA,OAAIJ,6DAA6D,CAACP,OAAO,CAACW,cAAc,CAAC,GAAG,CAAC;AAAA,CAC7G,CACF,CAAC,CAACd,MAAM;AACN;AACAY,oCAAoC,CAACC,MAAM,CACzC,UAAAC,cAAc;EAAA,OAAIJ,6DAA6D,CAACP,OAAO,CAACW,cAAc,CAAC,GAAG,CAAC;AAAA,CAC7G,CAAC,CAACD,MAAM,CACN,UAAAC,cAAc;EAAA,OAAIH,kDAAkD,CAACR,OAAO,CAACW,cAAc,CAAC,GAAG,CAAC;AAAA,CAClG,CACF,CAAC"}
1
+ {"version":3,"file":"isDateFormatStyle.js","names":["isDateFormat","isDateFormatStyle","styleId","styles","options","undefined","style","Error","concat","numberFormat","BUILT_IN_DATE_FORMAT_IDS","indexOf","id","dateFormat","template","smartDateParser","LOCALE_INDEPENDENT_BUILT_IN_DATE_FORMAT_IDS","MAINLAND_CHINESE_OR_TAIWANESE_LOCALE_BUILT_IN_DATE_FORMAT_IDS","JAPANESE_OR_KOREAN_LOCALE_BUILT_IN_DATE_FORMAT_IDS","THAI_LOCALE_BUILT_IN_DATE_FORMAT_IDS","filter","numberFormatId"],"sources":["../../source/xlsx/isDateFormatStyle.js"],"sourcesContent":["// XLSX does have \"d\" type for dates, but it's not commonly used.\r\n// Instead, it prefers using \"n\" type for storing dates as timestamps.\r\n//\r\n// Whether a numeric value is a number or a date timestamp, it sometimes could be\r\n// detected by looking at the value \"format\" and seeing if it's a date-specific one.\r\n\r\nimport isDateFormat from './isDateFormat.js'\r\n\r\nexport default function isDateFormatStyle(styleId, styles, options) {\r\n if (styleId !== undefined) {\r\n const style = styles[styleId]\r\n if (!style) {\r\n throw new Error(`Cell style not found: ${styleId}`)\r\n }\r\n if (!style.numberFormat) {\r\n return false\r\n }\r\n if (\r\n // Whether it's a \"number format\" that's conventionally used for storing date timestamps.\r\n BUILT_IN_DATE_FORMAT_IDS.indexOf(style.numberFormat.id) >= 0 ||\r\n // Whether it's a \"number format\" that uses a \"formatting template\"\r\n // that the developer is certain is a date formatting template.\r\n (options.dateFormat && style.numberFormat.template === options.dateFormat) ||\r\n // Whether the \"smart formatting template\" feature is not disabled\r\n // and it has detected that it's a date formatting template by looking at it.\r\n (options.smartDateParser !== false && style.numberFormat.template && isDateFormat(style.numberFormat.template))\r\n ) {\r\n return true\r\n }\r\n }\r\n}\r\n\r\n// Built-in formats have ID < 164.\r\n// Some of those formats are intended to use when displaying dates.\r\n//\r\n// Depending on the \"locale\" used by the spreadsheet viewing application,\r\n// different built-in format IDs might correspond to different templates.\r\n// https://learn.microsoft.com/en-us/dotnet/api/documentformat.openxml.spreadsheet.numberingformat?view=openxml-2.8.1\r\n//\r\n// Here's a list of \"locale\"-independent built-in format IDs that're known to represent dates.\r\n//\r\nconst LOCALE_INDEPENDENT_BUILT_IN_DATE_FORMAT_IDS = [\r\n 14, // mm-dd-yy\r\n 15, // d-mmm-yy\r\n 16, // d-mmm\r\n 17, // mmm-yy\r\n 18, // h:mm AM/PM\r\n 19, // h:mm:ss AM/PM\r\n 20, // h:mm\r\n 21, // h:mm:ss\r\n 22, // m/d/yy h:mm\r\n 45, // mm:ss\r\n 46, // [h]:mm:ss\r\n 47 // mmss.0\r\n]\r\n\r\n// \"zh-tw\" OR \"zh-cn\" locales.\r\n// Language glyphs (aka \"hieroglyphs\") are not replaced with their respective unicode values here.\r\nconst MAINLAND_CHINESE_OR_TAIWANESE_LOCALE_BUILT_IN_DATE_FORMAT_IDS = [\r\n 27, // [$-404]e/m/d OR yyyy\"年\"m\"月\"\r\n 28, // [$-404]e\"年\"m\"月\"d\"日\" OR m\"月\"d\"日\"\r\n 29, // [$-404]e\"年\"m\"月\"d\"日\" OR m\"月\"d\"日\"\r\n 30, // m/d/yy OR m-d-yy\r\n 31, // yyyy\"年\"m\"月\"d\"日\" OR yyyy\"年\"m\"月\"d\"日\"\r\n 32, // hh\"時\"mm\"分\" OR h\"时\"mm\"分\"\r\n 33, // hh\"時\"mm\"分\"ss\"秒\" OR h\"时\"mm\"分\"ss\"秒\"\r\n 34, // 上午/下午hh\"時\"mm\"分\" OR 上午/下午h\"时\"mm\"分\"\r\n 35, // 上午/下午hh\"時\"mm\"分\"ss\"秒\" OR 上午/下午h\"时\"mm\"分\"ss\"秒\"\r\n 36, // [$-404]e/m/d OR yyyy\"年\"m\"月\"\r\n 50, // [$-404]e/m/d OR yyyy\"年\"m\"月\"\r\n 51, // [$-404]e\"年\"m\"月\"d\"日\" OR m\"月\"d\"日\"\r\n 52, // 上午/下午hh\"時\"mm\"分\" OR yyyy\"年\"m\"月\"\r\n 53, // 上午/下午hh\"時\"mm\"分\"ss\"秒\" OR m\"月\"d\"日\"\r\n 54, // [$-404]e\"年\"m\"月\"d\"日\" OR m\"月\"d\"日\"\r\n 55, // 上午/下午hh\"時\"mm\"分\" OR 上午/下午h\"时\"mm\"分\"\r\n 56, // 上午/下午hh\"時\"mm\"分\"ss\"秒\" OR 上午/下午h\"时\"mm\"分\"ss\"秒\"\r\n 57, // [$-404]e/m/d OR yyyy\"年\"m\"月\"\r\n 58 // [$-404]e\"年\"m\"月\"d\"日\" OR m\"月\"d\"日\"\r\n]\r\n\r\n// \"ja-jp\" OR \"ko-kr\" locales.\r\n// Language glyphs (aka \"hieroglyphs\") are not replaced with their respective unicode values here.\r\nconst JAPANESE_OR_KOREAN_LOCALE_BUILT_IN_DATE_FORMAT_IDS = [\r\n 27, // [$-411]ge.m.d OR yyyy\"年\" mm\"月\" dd\"日\"\r\n 28, // [$-411]ggge\"年\"m\"月\"d\"日\" OR mm-dd\r\n 29, // [$-411]ggge\"年\"m\"月\"d\"日\" OR mm-dd\r\n 30, // m/d/yy OR mm-dd-yy\r\n 31, // yyyy\"年\"m\"月\"d\"日\" OR yyyy\"년\" mm\"월\" dd\"일\"\r\n 32, // h\"時\"mm\"分\" OR h\"시\" mm\"분\"\r\n 33, // h\"時\"mm\"分\"ss\"秒\" OR h\"시\" mm\"분\" ss\"초\"\r\n 34, // yyyy\"年\"m\"月\" OR yyyy-mm-dd\r\n 35, // m\"月\"d\"日\" OR yyyy-mm-dd\r\n 36, // [$-411]ge.m.d OR yyyy\"年\" mm\"月\" dd\"日\"\r\n 50, // [$-411]ge.m.d OR yyyy\"年\" mm\"月\" dd\"日\"\r\n 51, // [$-411]ggge\"年\"m\"月\"d\"日\" OR mm-dd\r\n 52, // yyyy\"年\"m\"月\" OR yyyy-mm-dd\r\n 53, // m\"月\"d\"日\" OR yyyy-mm-dd\r\n 54, // [$-411]ggge\"年\"m\"月\"d\"日\" OR mm-dd\r\n 55, // yyyy\"年\"m\"月\" OR yyyy-mm-dd\r\n 56, // m\"月\"d\"日\" OR yyyy-mm-dd\r\n 57, // [$-411]ge.m.d OR yyyy\"年\" mm\"月\" dd\"日\"\r\n 58 // [$-411]ggge\"年\"m\"月\"d\"日\" OR mm-dd\r\n]\r\n\r\n// \"th-th\" locale.\r\n// Language glyphs (aka \"hieroglyphs\") are not replaced with their respective unicode values here.\r\nconst THAI_LOCALE_BUILT_IN_DATE_FORMAT_IDS = [\r\n 71, // ว/ด/ปปปป\r\n 72, // ว-ดดด-ปป\r\n 73, // ว-ดดด\r\n 74, // ดดด-ปป\r\n 75, // ช:นน\r\n 76, // ช:นน:ทท\r\n 77, // ว/ด/ปปปป ช:นน\r\n 78, // นน:ทท\r\n 79, // [ช]:นน:ทท\r\n 80, // นน:ทท.0\r\n 81 // d/m/bb\r\n]\r\n\r\n// Start with language-agnostic date format IDs.\r\nconst BUILT_IN_DATE_FORMAT_IDS = LOCALE_INDEPENDENT_BUILT_IN_DATE_FORMAT_IDS.concat(\r\n // Add Mainland Chinese or Taiwanese date format IDs that haven't already been added.\r\n MAINLAND_CHINESE_OR_TAIWANESE_LOCALE_BUILT_IN_DATE_FORMAT_IDS\r\n).concat(\r\n // Add Japanese or Korean date format IDs that haven't already been added.\r\n JAPANESE_OR_KOREAN_LOCALE_BUILT_IN_DATE_FORMAT_IDS.filter(\r\n numberFormatId => MAINLAND_CHINESE_OR_TAIWANESE_LOCALE_BUILT_IN_DATE_FORMAT_IDS.indexOf(numberFormatId) < 0\r\n )\r\n).concat(\r\n // Add Thai date format IDs that haven't already been added.\r\n THAI_LOCALE_BUILT_IN_DATE_FORMAT_IDS.filter(\r\n numberFormatId => MAINLAND_CHINESE_OR_TAIWANESE_LOCALE_BUILT_IN_DATE_FORMAT_IDS.indexOf(numberFormatId) < 0\r\n ).filter(\r\n numberFormatId => JAPANESE_OR_KOREAN_LOCALE_BUILT_IN_DATE_FORMAT_IDS.indexOf(numberFormatId) < 0\r\n )\r\n)\r\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,YAAY,MAAM,mBAAmB;AAE5C,eAAe,SAASC,iBAA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AG,CAAC;AAAA,CAClG,CACF,CAAC"}
@@ -1,7 +1,11 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure 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 _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
1
7
  import parseCellValue from './parseCellValue.js';
2
- import parseCellCoordinates from './parseCellCoordinates.js';
3
- import { getCellValueElement, getCellInlineStringValue } from '../xml/xlsx.js';
4
- import { getOuterXml } from '../xml/dom.js';
8
+ import parseCellAddress from './parseCellAddress.js';
5
9
 
6
10
  // Example of a `<c/>`ell element:
7
11
  //
@@ -28,29 +32,19 @@ import { getOuterXml } from '../xml/dom.js';
28
32
  // </extLst>
29
33
  // </c>
30
34
  //
31
- export default function parseCell(element, sheetDocument, sharedStrings, styles, epoch1904, options) {
32
- var coordinates = parseCellCoordinates(element.getAttribute('r'));
33
- var valueElement = getCellValueElement(sheetDocument, element);
34
-
35
- // When the value element doesn't exist, it would be returned as `undefined`
36
- // when using `xpath` and as `null` when using `DOMParser`.
37
- // So here it uses `value && ...` syntax instead of `if (value !== undefined) { ... }`
38
- // for compatibility with both `xpath` and `DOMParser`.
39
- var value = valueElement && valueElement.textContent;
40
- var type = element.getAttribute('t');
35
+ export default function parseCell(attributes, value, inlineString, sharedStrings, styles, epoch1904, options) {
36
+ var _parseCellAddress = parseCellAddress(attributes.r),
37
+ _parseCellAddress2 = _slicedToArray(_parseCellAddress, 2),
38
+ row = _parseCellAddress2[0],
39
+ column = _parseCellAddress2[1];
40
+ var type = attributes.t;
41
+ var styleId = attributes.s ? Number(attributes.s) : undefined;
41
42
  return {
42
- row: coordinates[0],
43
- column: coordinates[1],
43
+ row: row,
44
+ column: column,
44
45
  value: parseCellValue(value, type, {
45
- getInlineStringValue: function getInlineStringValue() {
46
- return getCellInlineStringValue(sheetDocument, element);
47
- },
48
- getInlineStringXml: function getInlineStringXml() {
49
- return getOuterXml(element);
50
- },
51
- getStyleId: function getStyleId() {
52
- return element.getAttribute('s');
53
- },
46
+ inlineString: inlineString,
47
+ styleId: styleId,
54
48
  styles: styles,
55
49
  sharedStrings: sharedStrings,
56
50
  epoch1904: epoch1904,
@@ -58,4 +52,71 @@ export default function parseCell(element, sheetDocument, sharedStrings, styles,
58
52
  })
59
53
  };
60
54
  }
55
+ export function createInitialStateInCell() {
56
+ return {
57
+ v: false,
58
+ is: false,
59
+ t: false,
60
+ r: false,
61
+ rPh: false,
62
+ value: undefined,
63
+ inlineString: undefined,
64
+ attributes: undefined
65
+ };
66
+ }
67
+ export function onOpenTagInCell(tagName, attributes, state) {
68
+ if (tagName === 'v') {
69
+ state.v = true;
70
+ } else if (tagName === 'is') {
71
+ // The possible children of <is> are:
72
+ // * <t> (Text): The standard child to hold plain, simple text.
73
+ // * <r> (Rich Text Run): Used for applying different formatting styles (like bold or italic) to specific segments of text within a single cell.
74
+ // * <rPh> (Phonetic Run): Used primarily for East Asian languages to provide phonetic reading/pronunciation data (e.g., furigana in Japanese). It associates a phonetic pronunciation run right alongside the base string text tag <t>.
75
+ // * <phoneticPr> (Phonetic Properties): Defines formatting and settings for the phonetic text.
76
+ state.is = true;
77
+ state.inlineString = '';
78
+ } else if (tagName === 't') {
79
+ state.t = true;
80
+ } else if (tagName === 'r') {
81
+ // The possible children of <r/> are:
82
+ // * <rPr> (Run Properties): The formatting properties for the text (font, size, color, bold, italic, etc.).
83
+ // * <t> (Text): The actual text payload.
84
+ // * <rPh> (Phonetic Run): Phonetic pronunciation guidance (used for East Asian languages like Japanese). It associates a phonetic pronunciation run right alongside the base string text tag <t>.
85
+ state.r = true;
86
+ } else if (tagName === 'rPh') {
87
+ // The possible children of <rPh/> are:
88
+ // * <t> (Text): Contains the actual phonetic text or reading (usually in Katakana for Japanese) that corresponds to the associated character string.
89
+ state.rPh = true;
90
+ }
91
+ }
92
+ export function onCloseTagInCell(tagName, state) {
93
+ if (tagName === 'v') {
94
+ state.v = false;
95
+ } else if (tagName === 'is') {
96
+ state.is = false;
97
+ } else if (tagName === 't') {
98
+ state.t = false;
99
+ } else if (tagName === 'r') {
100
+ state.r = false;
101
+ } else if (tagName === 'rPh') {
102
+ state.rPh = false;
103
+ }
104
+ }
105
+ export function onTextInCell(text, state) {
106
+ if (state.v) {
107
+ state.value = text;
108
+ } else if (state.is) {
109
+ if (state.rPh) {
110
+ // Ignore anything inside `<rPh/>` tags
111
+ } else if (state.t) {
112
+ if (state.r) {
113
+ // An `<r/>` element could contain multiple `<t/>` elements,
114
+ // the text content from all of which should be concatenated.
115
+ state.inlineString += text;
116
+ } else {
117
+ state.inlineString = text;
118
+ }
119
+ }
120
+ }
121
+ }
61
122
  //# sourceMappingURL=parseCell.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"parseCell.js","names":["parseCellValue","parseCellCoordinates","getCellValueElement","getCellInlineStringValue","getOuterXml","parseCell","element","sheetDocument","sharedStrings","styles","epoch1904","options","coordinates","getAttribute","valueElement","value","textContent","type","row","column","getInlineStringValue","getInlineStringXml","getStyleId"],"sources":["../../source/xlsx/parseCell.js"],"sourcesContent":["import parseCellValue from './parseCellValue.js'\r\nimport parseCellCoordinates from './parseCellCoordinates.js'\r\n\r\nimport {\r\n getCellValueElement,\r\n getCellInlineStringValue\r\n} from '../xml/xlsx.js'\r\n\r\nimport {\r\n getOuterXml\r\n} from '../xml/dom.js'\r\n\r\n// Example of a `<c/>`ell element:\r\n//\r\n// <c>\r\n// <f>string</f> — formula.\r\n// <v>string</v> — formula pre-computed value.\r\n// <is>\r\n// <t>string</t> — an `inlineStr` string (rather than a \"common string\" from a dictionary).\r\n// <r>\r\n// <rPr>\r\n// ...\r\n// </rPr>\r\n// <t>string</t>\r\n// </r>\r\n// <rPh sb=\"1\" eb=\"1\">\r\n// <t>string</t>\r\n// </rPh>\r\n// <phoneticPr fontId=\"1\"/>\r\n// </is>\r\n// <extLst>\r\n// <ext>\r\n// <!--any element-->\r\n// </ext>\r\n// </extLst>\r\n// </c>\r\n//\r\nexport default function parseCell(element, sheetDocument, sharedStrings, styles, epoch1904, options) {\r\n const coordinates = parseCellCoordinates(element.getAttribute('r'))\r\n const valueElement = getCellValueElement(sheetDocument, element)\r\n\r\n // When the value element doesn't exist, it would be returned as `undefined`\r\n // when using `xpath` and as `null` when using `DOMParser`.\r\n // So here it uses `value && ...` syntax instead of `if (value !== undefined) { ... }`\r\n // for compatibility with both `xpath` and `DOMParser`.\r\n const value = valueElement && valueElement.textContent\r\n const type = element.getAttribute('t')\r\n\r\n return {\r\n row: coordinates[0],\r\n column: coordinates[1],\r\n value: parseCellValue(value, type, {\r\n getInlineStringValue: () => getCellInlineStringValue(sheetDocument, element),\r\n getInlineStringXml: () => getOuterXml(element),\r\n getStyleId: () => element.getAttribute('s'),\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EAATA,SAAS;MACTC,OAAO,EAAPA;IACF,CAAC;EACH,CAAC;AACH"}
1
+ {"version":3,"file":"parseCell.js","names":["parseCellValue","parseCellAddress","parseCell","attributes","value","inlineString","sharedStrings","styles","epoch1904","options","_parseCellAddress","r","_parseCellAddress2","_slicedToArray","row","column","type","t","styleId","s","Number","undefined","createInitialStateInCell","v","is","rPh","onOpenTagInCell","tagName","state","onCloseTagInCell","onTextInCell","text"],"sources":["../../source/xlsx/parseCell.js"],"sourcesContent":["import parseCellValue from './parseCellValue.js'\r\nimport parseCellAddress from './parseCellAddress.js'\r\n\r\n// Example of a `<c/>`ell element:\r\n//\r\n// <c>\r\n// <f>string</f> — formula.\r\n// <v>string</v> — formula pre-computed value.\r\n// <is>\r\n// <t>string</t> — an `inlineStr` string (rather than a \"common string\" from a dictionary).\r\n// <r>\r\n// <rPr>\r\n// ...\r\n// </rPr>\r\n// <t>string</t>\r\n// </r>\r\n// <rPh sb=\"1\" eb=\"1\">\r\n// <t>string</t>\r\n// </rPh>\r\n// <phoneticPr fontId=\"1\"/>\r\n// </is>\r\n// <extLst>\r\n// <ext>\r\n// <!--any element-->\r\n// </ext>\r\n// </extLst>\r\n// </c>\r\n//\r\nexport default function parseCell(\r\n attributes,\r\n value,\r\n inlineString,\r\n sharedStrings,\r\n styles,\r\n epoch1904,\r\n options\r\n) {\r\n const [row, column] = parseCellAddress(attributes.r)\r\n const type = attributes.t\r\n const styleId = attributes.s ? Number(attributes.s) : undefined\r\n\r\n return {\r\n row,\r\n column,\r\n value: parseCellValue(value, type, {\r\n inlineString,\r\n styleId,\r\n styles,\r\n sharedStrings,\r\n epoch1904,\r\n options\r\n })\r\n }\r\n}\r\n\r\nexport function createInitialStateInCell() {\r\n return {\r\n v: false,\r\n is: false,\r\n t: false,\r\n r: false,\r\n rPh: false,\r\n value: undefined,\r\n inlineString: undefined,\r\n attributes: undefined\r\n }\r\n}\r\n\r\nexport function onOpenTagInCell(tagName, attributes, state) {\r\n if (tagName === 'v') {\r\n state.v = true\r\n } else if (tagName === 'is') {\r\n // The possible children of <is> are:\r\n // * <t> (Text): The standard child to hold plain, simple text.\r\n // * <r> (Rich Text Run): Used for applying different formatting styles (like bold or italic) to specific segments of text within a single cell.\r\n // * <rPh> (Phonetic Run): Used primarily for East Asian languages to provide phonetic reading/pronunciation data (e.g., furigana in Japanese). It associates a phonetic pronunciation run right alongside the base string text tag <t>.\r\n // * <phoneticPr> (Phonetic Properties): Defines formatting and settings for the phonetic text.\r\n state.is = true\r\n state.inlineString = ''\r\n } else if (tagName === 't') {\r\n state.t = true\r\n } else if (tagName === 'r') {\r\n // The possible children of <r/> are:\r\n // * <rPr> (Run Properties): The formatting properties for the text (font, size, color, bold, italic, etc.).\r\n // * <t> (Text): The actual text payload.\r\n // * <rPh> (Phonetic Run): Phonetic pronunciation guidance (used for East Asian languages like Japanese). It associates a phonetic pronunciation run right alongside the base string text tag <t>.\r\n state.r = true\r\n } else if (tagName === 'rPh') {\r\n // The possible children of <rPh/> are:\r\n // * <t> (Text): Contains the actual phonetic text or reading (usually in Katakana for Japanese) that corresponds to the associated character string.\r\n state.rPh = true\r\n }\r\n}\r\n\r\nexport function onCloseTagInCell(tagName, state) {\r\n if (tagName === 'v') {\r\n state.v = false\r\n } else if (tagName === 'is') {\r\n state.is = false\r\n } else if (tagName === 't') {\r\n state.t = false\r\n } else if (tagName === 'r') {\r\n state.r = false\r\n } else if (tagName === 'rPh') {\r\n state.rPh = false\r\n }\r\n}\r\n\r\nexport function onTextInCell(text, state) {\r\n if (state.v) {\r\n state.value = text\r\n } else if (state.is) {\r\n if (state.rPh) {\r\n // Ignore anything inside `<rPh/>` tags\r\n } else if (state.t) {\r\n if (state.r) {\r\n // An `<r/>` element could contain multiple `<t/>` elements,\r\n // the text content from all of which should be concatenated.\r\n state.inlineString += text\r\n } else {\r\n state.inlineString = text\r\n }\r\n }\r\n }\r\n}\r\n"],"mappings":";;;;;;AAAA,OAAOA,cAAc,MAAM,qBAAqB;AAChD,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