read-excel-file 9.0.3 → 9.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/CHANGELOG.md +13 -5
  2. package/README.md +37 -21
  3. package/browser/index.cjs +5 -5
  4. package/browser/index.d.ts +20 -20
  5. package/browser/index.js +5 -5
  6. package/commonjs/parseSheetData/InvalidError.js.map +1 -0
  7. package/commonjs/{parseData/parseData.js → parseSheetData/parseSheetData.js} +15 -11
  8. package/commonjs/parseSheetData/parseSheetData.js.map +1 -0
  9. package/commonjs/parseSheetData/parseSheetData.test.js.map +1 -0
  10. package/commonjs/parseSheetData/types/Boolean.js.map +1 -0
  11. package/commonjs/parseSheetData/types/Date.js.map +1 -0
  12. package/commonjs/parseSheetData/types/Number.js.map +1 -0
  13. package/commonjs/parseSheetData/types/String.js.map +1 -0
  14. package/commonjs/parseSheetData/types/additional/Email.js.map +1 -0
  15. package/commonjs/parseSheetData/types/additional/Email.test.js.map +1 -0
  16. package/commonjs/parseSheetData/types/additional/Integer.js.map +1 -0
  17. package/commonjs/parseSheetData/types/additional/Integer.test.js.map +1 -0
  18. package/commonjs/parseSheetData/types/additional/URL.js.map +1 -0
  19. package/commonjs/parseSheetData/types/additional/URL.test.js.map +1 -0
  20. package/modules/parseSheetData/InvalidError.js.map +1 -0
  21. package/modules/{parseData/parseData.js → parseSheetData/parseSheetData.js} +13 -9
  22. package/modules/parseSheetData/parseSheetData.js.map +1 -0
  23. package/modules/parseSheetData/parseSheetData.test.js.map +1 -0
  24. package/modules/parseSheetData/types/Boolean.js.map +1 -0
  25. package/modules/parseSheetData/types/Date.js.map +1 -0
  26. package/modules/parseSheetData/types/Number.js.map +1 -0
  27. package/modules/parseSheetData/types/String.js.map +1 -0
  28. package/modules/parseSheetData/types/additional/Email.js.map +1 -0
  29. package/modules/parseSheetData/types/additional/Email.test.js.map +1 -0
  30. package/modules/parseSheetData/types/additional/Integer.js.map +1 -0
  31. package/modules/parseSheetData/types/additional/Integer.test.js.map +1 -0
  32. package/modules/parseSheetData/types/additional/URL.js.map +1 -0
  33. package/modules/parseSheetData/types/additional/URL.test.js.map +1 -0
  34. package/node/index.cjs +5 -5
  35. package/node/index.d.ts +20 -20
  36. package/node/index.js +5 -5
  37. package/package.json +1 -1
  38. package/types/{parseData/parseData.d.ts → parseSheetData/parseSheetData.d.ts} +9 -9
  39. package/types/parseSheetData/parseSheetDataError.d.ts +294 -0
  40. package/types/{parseData/parseDataSchema.d.ts → parseSheetData/parseSheetDataSchema.d.ts} +2 -2
  41. package/types/{parseData/parseDataValueType.d.ts → parseSheetData/parseSheetDataValueType.d.ts} +7 -7
  42. package/universal/index.cjs +5 -5
  43. package/universal/index.d.ts +20 -20
  44. package/universal/index.js +5 -5
  45. package/web-worker/index.cjs +5 -5
  46. package/web-worker/index.d.ts +20 -20
  47. package/web-worker/index.js +5 -5
  48. package/commonjs/parseData/InvalidError.js.map +0 -1
  49. package/commonjs/parseData/parseData.js.map +0 -1
  50. package/commonjs/parseData/parseData.test.js.map +0 -1
  51. package/commonjs/parseData/types/Boolean.js.map +0 -1
  52. package/commonjs/parseData/types/Date.js.map +0 -1
  53. package/commonjs/parseData/types/Number.js.map +0 -1
  54. package/commonjs/parseData/types/String.js.map +0 -1
  55. package/commonjs/parseData/types/additional/Email.js.map +0 -1
  56. package/commonjs/parseData/types/additional/Email.test.js.map +0 -1
  57. package/commonjs/parseData/types/additional/Integer.js.map +0 -1
  58. package/commonjs/parseData/types/additional/Integer.test.js.map +0 -1
  59. package/commonjs/parseData/types/additional/URL.js.map +0 -1
  60. package/commonjs/parseData/types/additional/URL.test.js.map +0 -1
  61. package/modules/parseData/InvalidError.js.map +0 -1
  62. package/modules/parseData/parseData.js.map +0 -1
  63. package/modules/parseData/parseData.test.js.map +0 -1
  64. package/modules/parseData/types/Boolean.js.map +0 -1
  65. package/modules/parseData/types/Date.js.map +0 -1
  66. package/modules/parseData/types/Number.js.map +0 -1
  67. package/modules/parseData/types/String.js.map +0 -1
  68. package/modules/parseData/types/additional/Email.js.map +0 -1
  69. package/modules/parseData/types/additional/Email.test.js.map +0 -1
  70. package/modules/parseData/types/additional/Integer.js.map +0 -1
  71. package/modules/parseData/types/additional/Integer.test.js.map +0 -1
  72. package/modules/parseData/types/additional/URL.js.map +0 -1
  73. package/modules/parseData/types/additional/URL.test.js.map +0 -1
  74. package/types/parseData/parseDataError.d.ts +0 -292
  75. /package/commonjs/{parseData → parseSheetData}/InvalidError.js +0 -0
  76. /package/commonjs/{parseData → parseSheetData}/types/Boolean.js +0 -0
  77. /package/commonjs/{parseData → parseSheetData}/types/Date.js +0 -0
  78. /package/commonjs/{parseData → parseSheetData}/types/Number.js +0 -0
  79. /package/commonjs/{parseData → parseSheetData}/types/String.js +0 -0
  80. /package/commonjs/{parseData → parseSheetData}/types/additional/Email.js +0 -0
  81. /package/commonjs/{parseData → parseSheetData}/types/additional/Integer.js +0 -0
  82. /package/commonjs/{parseData → parseSheetData}/types/additional/URL.js +0 -0
  83. /package/modules/{parseData → parseSheetData}/InvalidError.js +0 -0
  84. /package/modules/{parseData → parseSheetData}/types/Boolean.js +0 -0
  85. /package/modules/{parseData → parseSheetData}/types/Date.js +0 -0
  86. /package/modules/{parseData → parseSheetData}/types/Number.js +0 -0
  87. /package/modules/{parseData → parseSheetData}/types/String.js +0 -0
  88. /package/modules/{parseData → parseSheetData}/types/additional/Email.js +0 -0
  89. /package/modules/{parseData → parseSheetData}/types/additional/Integer.js +0 -0
  90. /package/modules/{parseData → parseSheetData}/types/additional/URL.js +0 -0
package/CHANGELOG.md CHANGED
@@ -2,10 +2,18 @@
2
2
  ==================
3
3
 
4
4
  * If you were using `parseData()` function:
5
- * Rewrote the code of the `parseData()` function.
6
- * The result of `parseData()` function is now `{ errors, objects }`. If there're no errors, `errors` will be `undefined`. Otherwise, `errors` will be a non-empty array and `objects` will be `undefined`.
7
- * Previously the result of `parseData()` function was `[{ errors, object }, ...]`, i.e. the `errors` were split between each particular data row. Now the `errors` are combined for all data rows. The rationale is that it's simpler to handle the result of the function this way.
8
- * Re-added `row: number` property to the `error` object.
5
+ * Rewrote the code of the `parseData()` function and renamed it to `parseSheetData()`.
6
+ * The result of `parseSheetData()` function is now `{ errors, objects }`. If there're no errors, `errors` will be `undefined`. Otherwise, `errors` will be a non-empty array and `objects` will be `undefined`.
7
+ * Previously the result of `parseSheetData()` function was `[{ errors, object }, ...]`, i.e. the `errors` were split between each particular data row. Now the `errors` are combined for all data rows. The rationale is that it's simpler to handle the result of the function this way.
8
+ * Re-added `row: number` property to the `error` object. It's the number of the data row that caused the error, starting from `1`.
9
+ * Added `columnIndex: number` property to the `error` object.
10
+ * Renamed some of the exported TypeScript types:
11
+ * `ParseDataCustomType` → `ParseSheetDataCustomType`
12
+ * `ParseDataCustomTypeErrorMessage` → `ParseSheetDataCustomTypeErrorMessage`
13
+ * `ParseDataCustomTypeErrorReason` → `ParseSheetDataCustomTypeErrorReason`
14
+ * `ParseDataError` → `ParseSheetDataError`
15
+ * `ParseDataValueRequiredError` → `ParseSheetDataValueRequiredError`
16
+ * `ParseDataResult` → `ParseSheetDataResult`
9
17
  * In a `schema`, a nested object could be declared as: `{ required: true/false, schema: { ... } }`. This is still true but the `required` flag is now only allowed to be either `undefined` or `false`, so `true` value is not allowed. The reason is quite simple. If a nested object as a whole is marked as `required: true`, and then it happens to be empty, a `"required"` error should be returned for it. But that error would also have to include a `column` title, and a nested object simply can't be pinned down to a single column in a sheet because it is by definition spread over multiple columns. So instead of marking a nested object as a whole with `required: true`, mark the specific required properties of it.
10
18
 
11
19
  8.0.0 / 11.03.2026
@@ -54,7 +62,7 @@
54
62
  * Removed `isColumnOriented` parameter because it seemed to be of no use.
55
63
 
56
64
  * If you were using `ignoreEmptyRows` parameter:
57
- * Removed `ignoreEmptyRows` parameter. Empty rows somewhere in the middle of a sheet are not ignored now. That doesn't concern empty rows at the end of a sheet though — those're still ignored.
65
+ * Removed `ignoreEmptyRows` parameter. Passing `ignoreEmptyRows: true` parameter no longer makes it skip empty rows in the middle of a sheet. Now it's always the default behavior, as it used to be: only empty rows at the end of a sheet are ignored.
58
66
 
59
67
  * If you were using TypeScript:
60
68
  * Renamed some of the exported types:
package/README.md CHANGED
@@ -67,7 +67,7 @@ Also check out [`write-excel-file`](https://www.npmjs.com/package/write-excel-fi
67
67
  * Removed `isColumnOriented` parameter because it seemed to be of no use.
68
68
 
69
69
  * If you were using `ignoreEmptyRows` parameter:
70
- * Removed `ignoreEmptyRows` parameter. Empty rows somewhere in the middle of a sheet are not ignored now. That doesn't concern empty rows at the end of a sheet though — those're still ignored.
70
+ * Removed `ignoreEmptyRows` parameter. Passing `ignoreEmptyRows: true` parameter no longer makes it skip empty rows in the middle of a sheet. Now it's always the default behavior, as it used to be: only empty rows at the end of a sheet are ignored.
71
71
 
72
72
  * If you were using TypeScript:
73
73
  * Renamed some of the exported types:
@@ -83,10 +83,18 @@ Also check out [`write-excel-file`](https://www.npmjs.com/package/write-excel-fi
83
83
  ######
84
84
 
85
85
  * If you were using `parseData()` function:
86
- * Rewrote the code of the `parseData()` function.
87
- * The result of `parseData()` function is now `{ errors, objects }`. If there're no errors, `errors` will be `undefined`. Otherwise, `errors` will be a non-empty array and `objects` will be `undefined`.
88
- * Previously the result of `parseData()` function was `[{ errors, object }, ...]`, i.e. the `errors` were split between each particular data row. Now the `errors` are combined for all data rows. The rationale is that it's simpler to handle the result of the function this way.
89
- * Re-added `row: number` property to the `error` object.
86
+ * Rewrote the code of the `parseData()` function and renamed it to `parseSheetData()`.
87
+ * The result of `parseSheetData()` function is now `{ errors, objects }`. If there're no errors, `errors` will be `undefined`. Otherwise, `errors` will be a non-empty array and `objects` will be `undefined`.
88
+ * Previously the result of `parseSheetData()` function was `[{ errors, object }, ...]`, i.e. the `errors` were split between each particular data row. Now the `errors` are combined for all data rows. The rationale is that it's simpler to handle the result of the function this way.
89
+ * Re-added `row: number` property to the `error` object. It's the number of the data row that caused the error, starting from `1`.
90
+ * Added `columnIndex: number` property to the `error` object.
91
+ * Renamed some of the exported TypeScript types:
92
+ * `ParseDataCustomType` → `ParseSheetDataCustomType`
93
+ * `ParseDataCustomTypeErrorMessage` → `ParseSheetDataCustomTypeErrorMessage`
94
+ * `ParseDataCustomTypeErrorReason` → `ParseSheetDataCustomTypeErrorReason`
95
+ * `ParseDataError` → `ParseSheetDataError`
96
+ * `ParseDataValueRequiredError` → `ParseSheetDataValueRequiredError`
97
+ * `ParseDataResult` → `ParseSheetDataResult`
90
98
  * In a `schema`, a nested object could be declared as: `{ required: true/false, schema: { ... } }`. This is still true but the `required` flag is now only allowed to be either `undefined` or `false`, so `true` value is not allowed. The reason is quite simple. If a nested object as a whole is marked as `required: true`, and then it happens to be empty, a `"required"` error should be returned for it. But that error would also have to include a `column` title, and a nested object simply can't be pinned down to a single column in a sheet because it is by definition spread over multiple columns. So instead of marking a nested object as a whole with `required: true`, mark the specific required properties of it.
91
99
  </details>
92
100
 
@@ -317,14 +325,14 @@ Here're the results of reading [sample `.xlsx` files](https://examplefile.com/do
317
325
 
318
326
  ## Schema
319
327
 
320
- Oftentimes, the task is not just to read the "raw" spreadsheet data but also to convert each row of that data to a JSON object having a certain structure. Because it's such a common task, this package exports a named function `parseData(data, schema)` which does exactly that. It parses sheet data into an array of JSON objects according to a pre-defined `schema` which describes how should a row of data be converted to a JSON object.
328
+ Oftentimes, the task is not just to read the "raw" spreadsheet data but also to convert each row of that data to a JSON object having a certain structure. Because it's such a common task, this package exports a named function `parseSheetData(data, schema)` which does exactly that. It parses sheet data into an array of JSON objects according to a pre-defined `schema` which describes how should a row of data be converted to a JSON object.
321
329
 
322
330
  ```js
323
- import { readSheet, parseData } from "read-excel-file/browser"
331
+ import { readSheet, parseSheetData } from "read-excel-file/browser"
324
332
 
325
333
  const data = await readSheet(file)
326
334
  const schema = { ... }
327
- const { objects, errors } = parseData(data, schema)
335
+ const { objects, errors } = parseSheetData(data, schema)
328
336
  if (errors) {
329
337
  console.error(errors)
330
338
  } else {
@@ -332,7 +340,7 @@ if (errors) {
332
340
  }
333
341
  ```
334
342
 
335
- The `parseData()` function returns an object — `{ objects, errors }`. Depending on whether there were any errors when parsing the data, either `objects` or `errors` property will be `undefined`.
343
+ The `parseSheetData()` function returns an object — `{ objects, errors }`. Depending on whether there were any errors when parsing the data, either `objects` or `errors` property will be `undefined`.
336
344
 
337
345
  The sheet data that is being parsed should adhere to a simple structure: the first row should be a header row with just column titles, and each following row should specify the values for those columns.
338
346
 
@@ -459,7 +467,7 @@ const schema = {
459
467
  const data = await readSheet(file)
460
468
 
461
469
  // Parse `data` using a `schema`
462
- const { objects, errors } = parseData(data, schema)
470
+ const { objects, errors } = parseSheetData(data, schema)
463
471
 
464
472
  // There have been no errors when parsing the sheet data, so `errors` is `undefined`.
465
473
  // Should there have been any errors when parsing the sheet data, `errors` would've been
@@ -502,9 +510,9 @@ function PhoneNumber(value) {
502
510
  import type {
503
511
  Schema,
504
512
  CellValue,
505
- ParseDataError,
506
- ParseDataCustomType,
507
- ParseDataCustomTypeErrorMessage
513
+ ParseSheetDataError,
514
+ ParseSheetDataCustomType,
515
+ ParseSheetDataCustomTypeErrorMessage
508
516
  } from 'read-excel-file/node'
509
517
 
510
518
  type ColumnTitle = 'COLUMN TITLE 1' | 'COLUMN TITLE 2'
@@ -518,20 +526,20 @@ function CustomType(value: CellValue): CustomTypeValue {
518
526
  return '~' + value + '~'
519
527
  }
520
528
 
521
- type CustomTypeErrorMessage<Type extends ParseDataCustomType<unknown>> =
529
+ type CustomTypeErrorMessage<Type extends ParseSheetDataCustomType<unknown>> =
522
530
  Type extends typeof CustomType
523
531
  ? 'not_a_string'
524
532
  : never
525
533
 
526
534
  // type CustomTypeErrorReason<
527
- // Type extends ParseDataCustomType<unknown>,
528
- // ErrorMessage extends ParseDataCustomTypeErrorMessage<Type>
535
+ // Type extends ParseSheetDataCustomType<unknown>,
536
+ // ErrorMessage extends ParseSheetDataCustomTypeErrorMessage<Type>
529
537
  // > =
530
538
  // Type extends typeof CustomType
531
539
  // ? (ErrorMessage extends 'not_a_string' ? undefined : never)
532
540
  // : never
533
541
 
534
- type PossibleError = ParseDataError<
542
+ type PossibleError = ParseSheetDataError<
535
543
  ColumnTitle,
536
544
  typeof CustomType,
537
545
  CustomTypeErrorMessage<typeof CustomType>
@@ -555,7 +563,7 @@ const schema: Schema<Object, ColumnTitle> = {
555
563
  }
556
564
  }
557
565
 
558
- const { objects, errors } = parseData<Object, ColumnTitle, PossibleError>([
566
+ const { objects, errors } = parseSheetData<Object, ColumnTitle, PossibleError>([
559
567
  ['COLUMN TITLE 1', 'COLUMN TITLE 2'],
560
568
  ['Value 1', 'Value 2']
561
569
  ], schema)
@@ -590,13 +598,21 @@ function ErrorsList({ errors }) {
590
598
  )
591
599
  }
592
600
 
593
- function ErrorItem({ error: errorDetails }) {
594
- const { type, value, error, reason, row, column } = errorDetails
601
+ function ErrorItem({ error }) {
602
+ const {
603
+ error: errorMessage,
604
+ reason,
605
+ row,
606
+ column,
607
+ columnIndex,
608
+ value,
609
+ type
610
+ } = error
595
611
 
596
612
  // Error summary.
597
613
  return (
598
614
  <div>
599
- <code>"{error}"</code>
615
+ <code>"{errorMessage}"</code>
600
616
  {reason && ' '}
601
617
  {reason && <code>("{reason}")</code>}
602
618
  {' for value '}
package/browser/index.cjs CHANGED
@@ -3,8 +3,8 @@ exports['default'] = require('../commonjs/export/readXlsxFileBrowser.js').defaul
3
3
 
4
4
  exports.readSheet = require('../commonjs/export/readSheetBrowser.js').default
5
5
 
6
- // `parseData()`
7
- exports.parseData = require('../commonjs/parseData/parseData.js').default
8
- exports.Integer = require('../commonjs/parseData/types/additional/Integer.js').default
9
- exports.Email = require('../commonjs/parseData/types/additional/Email.js').default
10
- exports.URL = require('../commonjs/parseData/types/additional/URL.js').default
6
+ // `parseSheetData()`
7
+ exports.parseSheetData = require('../commonjs/parseSheetData/parseSheetData.js').default
8
+ exports.Integer = require('../commonjs/parseSheetData/types/additional/Integer.js').default
9
+ exports.Email = require('../commonjs/parseSheetData/types/additional/Email.js').default
10
+ exports.URL = require('../commonjs/parseSheetData/types/additional/URL.js').default
@@ -10,17 +10,17 @@ import {
10
10
  } from '../types/types.d.js';
11
11
 
12
12
  import {
13
- ParseDataOptions,
14
- ParseDataResult
15
- } from '../types/parseData/parseData.d.js';
13
+ ParseSheetDataOptions,
14
+ ParseSheetDataResult
15
+ } from '../types/parseSheetData/parseSheetData.d.js';
16
16
 
17
17
  import {
18
18
  Schema
19
- } from '../types/parseData/parseDataSchema.d.js';
19
+ } from '../types/parseSheetData/parseSheetDataSchema.d.js';
20
20
 
21
21
  import {
22
- ParseDataError
23
- } from '../types/parseData/parseDataError.d.js';
22
+ ParseSheetDataError
23
+ } from '../types/parseSheetData/parseSheetDataError.d.js';
24
24
 
25
25
  export {
26
26
  CellValue,
@@ -30,7 +30,7 @@ export {
30
30
  } from '../types/types.d.js';
31
31
 
32
32
  export {
33
- ParseDataCustomType,
33
+ ParseSheetDataCustomType,
34
34
  // Base `type`s when parsing data.
35
35
  StringType as String,
36
36
  DateType as Date,
@@ -40,22 +40,22 @@ export {
40
40
  Integer,
41
41
  Email,
42
42
  URL
43
- } from '../types/parseData/parseDataValueType.d.js';
43
+ } from '../types/parseSheetData/parseSheetDataValueType.d.js';
44
44
 
45
45
  export {
46
- ParseDataCustomTypeErrorMessage,
47
- ParseDataCustomTypeErrorReason,
48
- ParseDataError,
49
- ParseDataValueRequiredError
50
- } from '../types/parseData/parseDataError.d.js';
46
+ ParseSheetDataCustomTypeErrorMessage,
47
+ ParseSheetDataCustomTypeErrorReason,
48
+ ParseSheetDataError,
49
+ ParseSheetDataValueRequiredError
50
+ } from '../types/parseSheetData/parseSheetDataError.d.js';
51
51
 
52
52
  export {
53
- ParseDataResult
54
- } from '../types/parseData/parseData.d.js';
53
+ ParseSheetDataResult
54
+ } from '../types/parseSheetData/parseSheetData.d.js';
55
55
 
56
56
  export {
57
57
  Schema
58
- } from '../types/parseData/parseDataSchema.d.js';
58
+ } from '../types/parseSheetData/parseSheetDataSchema.d.js';
59
59
 
60
60
  export default function readXlsxFile<ParsedNumber = number>(
61
61
  input: Input,
@@ -73,12 +73,12 @@ export function readSheet<ParsedNumber = number>(
73
73
  options?: ReadOptions<ParsedNumber>
74
74
  ): Promise<SheetData<ParsedNumber>>;
75
75
 
76
- export function parseData<
76
+ export function parseSheetData<
77
77
  Object extends object,
78
78
  ColumnTitle extends string,
79
- Error extends ParseDataError
79
+ Error extends ParseSheetDataError
80
80
  >(
81
81
  data: SheetData,
82
82
  schema: Schema<Object, ColumnTitle>,
83
- options?: ParseDataOptions
84
- ): ParseDataResult<Object, Error>;
83
+ options?: ParseSheetDataOptions
84
+ ): ParseSheetDataResult<Object, Error>;
package/browser/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  export { default as default } from '../modules/export/readXlsxFileBrowser.js'
2
2
  export { default as readSheet } from '../modules/export/readSheetBrowser.js'
3
3
 
4
- // `parseData()`
5
- export { default as parseData } from '../modules/parseData/parseData.js'
6
- export { default as Integer } from '../modules/parseData/types/additional/Integer.js'
7
- export { default as Email } from '../modules/parseData/types/additional/Email.js'
8
- export { default as URL } from '../modules/parseData/types/additional/URL.js'
4
+ // `parseSheetData()`
5
+ export { default as parseSheetData } from '../modules/parseSheetData/parseSheetData.js'
6
+ export { default as Integer } from '../modules/parseSheetData/types/additional/Integer.js'
7
+ export { default as Email } from '../modules/parseSheetData/types/additional/Email.js'
8
+ export { default as URL } from '../modules/parseSheetData/types/additional/URL.js'
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InvalidError.js","names":["InvalidError","exports","_Error","_inherits","_super","_createSuper","reason","_this","_classCallCheck","call","_createClass","_wrapNativeSuper","Error"],"sources":["../../source/parseSheetData/InvalidError.js"],"sourcesContent":["export default class InvalidError extends Error {\r\n constructor(reason) {\r\n super('invalid')\r\n this.reason = reason\r\n }\r\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;IAAqBA,YAAY,GAAAC,OAAA,qCAAAC,MAAA;EAAAC,SAAA,CAAAH,YAAA,EAAAE,MAAA;EAAA,IAAAE,MAAA,GAAAC,YAAA,CAAAL,YAAA;EAC/B,SAAAA,aAAYM,MAAM,EAAE;IAAA,IAAAC,KAAA;IAAAC,eAAA,OAAAR,YAAA;IAClBO,KAAA,GAAAH,MAAA,CAAAK,IAAA,OAAM,SAAS;IACfF,KAAA,CAAKD,MAAM,GAAGA,MAAM;IAAA,OAAAC,KAAA;EACtB;EAAC,OAAAG,YAAA,CAAAV,YAAA;AAAA,gBAAAW,gBAAA,CAJuCC,KAAK"}
@@ -3,10 +3,10 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports["default"] = parseData;
6
+ exports["default"] = parseSheetData;
7
7
  exports.getNextSubstring = getNextSubstring;
8
- exports.parseDataWithPerRowErrors = parseDataWithPerRowErrors;
9
8
  exports.parseSeparatedSubstrings = parseSeparatedSubstrings;
9
+ exports.parseSheetDataWithPerRowErrors = parseSheetDataWithPerRowErrors;
10
10
  exports.parseValue = parseValue;
11
11
  var _Number = _interopRequireDefault(require("./types/Number.js"));
12
12
  var _String = _interopRequireDefault(require("./types/String.js"));
@@ -56,10 +56,10 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
56
56
  * @param {string} [options.separatorCharacter] — When specified, string values will be split by this separator to get the array.
57
57
  * @return {object} — An object of shape `{ objects, errors }`. Either `objects` or `errors` is going to be `undefined`.
58
58
  */
59
- function parseData(data, schema, optionsCustom) {
59
+ function parseSheetData(data, schema, optionsCustom) {
60
60
  var objects = [];
61
61
  var errors = [];
62
- var parsedRows = parseDataWithPerRowErrors(data, schema, optionsCustom);
62
+ var parsedRows = parseSheetDataWithPerRowErrors(data, schema, optionsCustom);
63
63
  var parsedRowIndex = 0;
64
64
  for (var _iterator = _createForOfIteratorHelperLoose(parsedRows), _step; !(_step = _iterator()).done;) {
65
65
  var _step$value = _step.value,
@@ -86,7 +86,7 @@ function parseData(data, schema, optionsCustom) {
86
86
  }
87
87
 
88
88
  // This one is only used in tests.
89
- function parseDataWithPerRowErrors(data, schema, optionsCustom) {
89
+ function parseSheetDataWithPerRowErrors(data, schema, optionsCustom) {
90
90
  validateSchema(schema);
91
91
  var options = applyDefaultOptions(optionsCustom);
92
92
  var _data = _toArray(data),
@@ -167,7 +167,7 @@ function parseDataRow(dataRow, schema, columns, options) {
167
167
  //
168
168
  var requiredErrors = runPendingRequiredValidations(schemaEntry, value, isEmptyValue, errors, children,
169
169
  // Simulate a "dummy" parent object for the top-level object.
170
- dummyParentObject.isRequired, dummyParentObject.value, dummyParentObject.isEmptyValue, dummyParentObject.errors);
170
+ dummyParentObject.isRequired, dummyParentObject.value, dummyParentObject.isEmptyValue, dummyParentObject.errors, columns);
171
171
 
172
172
  // If there were any errors, whether caused by `required`
173
173
  // or occured while parsing the values, return those errors.
@@ -229,7 +229,7 @@ function parseProperty(row, schemaEntry, path, columns, options) {
229
229
  var _ref = schemaEntry.column ? isMissingColumn ? {
230
230
  value: options.propertyValueWhenColumnIsMissing,
231
231
  isEmptyValue: true
232
- } : parseCellValueWithPossibleErrors(row[columnIndex], schemaEntry, options) : parseObject(row, schemaEntry.schema, path, columns, options),
232
+ } : parseCellValueWithPossibleErrors(row[columnIndex], schemaEntry, columnIndex, options) : parseObject(row, schemaEntry.schema, path, columns, options),
233
233
  value = _ref.value,
234
234
  isEmptyValue = _ref.isEmptyValue,
235
235
  errors = _ref.errors,
@@ -251,7 +251,7 @@ function parseProperty(row, schemaEntry, path, columns, options) {
251
251
  children: children
252
252
  };
253
253
  }
254
- function parseCellValueWithPossibleErrors(cellValue, schemaEntry, options) {
254
+ function parseCellValueWithPossibleErrors(cellValue, schemaEntry, columnIndex, options) {
255
255
  var _parseCellValue = parseCellValue(cellValue, schemaEntry, options),
256
256
  value = _parseCellValue.value,
257
257
  isEmptyValue = _parseCellValue.isEmptyValue,
@@ -262,6 +262,7 @@ function parseCellValueWithPossibleErrors(cellValue, schemaEntry, options) {
262
262
  error: errorMessage,
263
263
  reason: errorReason,
264
264
  column: schemaEntry.column,
265
+ columnIndex: columnIndex,
265
266
  valueType: schemaEntry.type,
266
267
  value: cellValue
267
268
  });
@@ -573,7 +574,7 @@ function getPropertyPath(propertyName, parentObjectPath) {
573
574
  }
574
575
 
575
576
  // Recursively runs `required` validations for the parsed data row tree.
576
- function runPendingRequiredValidations(schemaEntry, value, isEmptyValue, errors, children, parentObjectIsRequired, parentObjectValue, parentObjectValueIsEmpty, parentObjectErrors) {
577
+ function runPendingRequiredValidations(schemaEntry, value, isEmptyValue, errors, children, parentObjectIsRequired, parentObjectValue, parentObjectValueIsEmpty, parentObjectErrors, columns) {
577
578
  var requiredErrors = [];
578
579
 
579
580
  // See if this property is required.
@@ -584,6 +585,7 @@ function runPendingRequiredValidations(schemaEntry, value, isEmptyValue, errors,
584
585
  requiredErrors.push(createError({
585
586
  error: 'required',
586
587
  column: schemaEntry.column,
588
+ columnIndex: columns.indexOf(schemaEntry.column),
587
589
  valueType: schemaEntry.type,
588
590
  value: value
589
591
  }));
@@ -596,7 +598,7 @@ function runPendingRequiredValidations(schemaEntry, value, isEmptyValue, errors,
596
598
  var requiredErrorsOfChild = runPendingRequiredValidations(child.schemaEntry, child.value, child.isEmptyValue, child.errors, child.children,
597
599
  // The following properties describe the parent object of the `child`,
598
600
  // i.e. the current (iterated) object.
599
- isRequired, value, isEmptyValue, errors);
601
+ isRequired, value, isEmptyValue, errors, columns);
600
602
  if (requiredErrorsOfChild) {
601
603
  requiredErrors = requiredErrors.concat(requiredErrorsOfChild);
602
604
  }
@@ -638,6 +640,7 @@ function isPropertyRequired(schemaEntry, parentObjectIsRequired, parentObjectVal
638
640
  }
639
641
  function createError(_ref2) {
640
642
  var column = _ref2.column,
643
+ columnIndex = _ref2.columnIndex,
641
644
  valueType = _ref2.valueType,
642
645
  value = _ref2.value,
643
646
  errorMessage = _ref2.error,
@@ -645,6 +648,7 @@ function createError(_ref2) {
645
648
  var error = {
646
649
  error: errorMessage,
647
650
  column: column,
651
+ columnIndex: columnIndex,
648
652
  value: value
649
653
  };
650
654
  if (reason) {
@@ -728,4 +732,4 @@ var objectConstructor = {}.constructor;
728
732
  function isObject(object) {
729
733
  return object !== undefined && object !== null && object.constructor === objectConstructor;
730
734
  }
731
- //# sourceMappingURL=parseData.js.map
735
+ //# sourceMappingURL=parseSheetData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseSheetData.js","names":["_Number","_interopRequireDefault","require","_String","_Boolean","_Date","obj","__esModule","_typeof","o","Symbol","iterator","constructor","prototype","_slicedToArray","arr","i","_arrayWithHoles","_iterableToArrayLimit","_unsupportedIterableToArray","_nonIterableRest","r","l","t","e","n","u","a","f","call","next","Object","done","push","value","length","_toArray","_iterableToArray","TypeError","iter","Array","from","isArray","ownKeys","keys","getOwnPropertySymbols","filter","getOwnPropertyDescriptor","enumerable","apply","_objectSpread","arguments","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","key","_toPropertyKey","configurable","writable","arg","_toPrimitive","String","input","hint","prim","toPrimitive","undefined","res","Number","_createForOfIteratorHelperLoose","allowArrayLike","it","bind","minLen","_arrayLikeToArray","toString","slice","name","test","len","arr2","parseSheetData","data","schema","optionsCustom","objects","errors","parsedRows","parseSheetDataWithPerRowErrors","parsedRowIndex","_iterator","_step","_step$value","object","rowErrors","concat","map","rowError","row","validateSchema","options","applyDefaultOptions","_data","columns","dataRows","parseDataRow","dataRow","schemaEntry","_parseProperty","parseProperty","isEmptyValue","children","dummyParentObject","PARSED_OBJECT_TREE_START","isRequired","requiredErrors","runPendingRequiredValidations","transformValue","parseObject","path","isEmptyObject","_i","_Object$keys","child","getPropertyPath","columnIndex","column","indexOf","isMissingColumn","_ref","propertyValueWhenColumnIsMissing","parseCellValueWithPossibleErrors","cellValue","_parseCellValue","parseCellValue","errorMessage","error","errorReason","reason","createError","valueType","type","propertyValueWhenCellIsEmpty","parseArrayValue","parseValue","isEmptyArray","reasons","values","parseSeparatedSubstrings","separatorCharacter","substring","_parseValue","result","parseValueOfType","oneOf","errorAndReason","validateOneOf","validate","message","parseValueUsingTypeParser","StringType","NumberType","Date","DateType","Boolean","BooleanType","Error","parsedValue","getNextSubstring","string","startIndex","character","elements","index","_getNextSubstring","_getNextSubstring2","trim","isObject","transformEmptyObject","transformEmptyArray","propertyName","parentObjectPath","parentObjectIsRequired","parentObjectValue","parentObjectValueIsEmpty","parentObjectErrors","isPropertyRequired","_iterator2","_step2","requiredErrorsOfChild","required","_ref2","_i2","_Object$keys2","validateObjectSchemaRequiredProperty","_i3","_Object$keys3","JSON","stringify","DEFAULT_OPTIONS","objectConstructor"],"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(rowErrors.map(rowError => ({ ...rowError, row: parsedRowIndex + 1 })))\r\n } else {\r\n objects.push(object)\r\n }\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 default one is `String`.\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,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,QAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,KAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAAsC,SAAAD,uBAAAK,GAAA,W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