read-excel-file 8.0.2 → 8.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -26,11 +26,12 @@
26
26
  * `getEmptyArrayValue` → `transformEmptyArray`
27
27
  * The leading `.` character is now removed from the `path` parameter.
28
28
  * Previously, when parsing comma-separated values, it used to ignore any commas that're surrounded by quotes, similar to how it's done in `.csv` files. Now it no longer does that.
29
+ * Previously, when parsing comma-separated values, it used to allow empty-string elements. Now it no longer does that and such empty-string elements will now result in an error with properties: `{ error: "invalid", reason: "syntax" }`.
29
30
  * Previously, when parsing using a schema, it used to force-convert all `type: Date` schema properties from any numeric cell value to a `Date` with a given timestamp. Now it demands the cell values for all such `type: Date` schema properties to already be correctly recognized as `Date`s when they're returned from `readSheet()` or `readExcelFile()` function. And I'd personally assume that in any sane (non-contrived) real-world usage scenario that would be the case, so it doesn't really seem like a "breaking change". And if, for some strange reason, that happens not to be the case, `parseData()` function will throw an error: `not_a_date`.
30
31
  * Previously, when parsing using a schema, it used to skip `required` validation for completely-empty rows. It no longer does that.
31
32
  * Removed exported function `parseExcelDate()` because there seems to be no need to have it exported.
32
33
  * (TypeScript) Renamed exported types:
33
- * `Type` → `ParseDataValueType`
34
+ * `Type` → `ParseDataCustomType`
34
35
  * `Error` or `SchemaParseCellValueError` → `ParseDataError`
35
36
  * `CellValueRequiredError` → `ParseDataValueRequiredError`
36
37
  * `ParsedObjectsResult` → `ParseDataResult`
package/README.md CHANGED
@@ -49,11 +49,12 @@ Also check out [`write-excel-file`](https://www.npmjs.com/package/write-excel-fi
49
49
  * `getEmptyArrayValue` → `transformEmptyArray`
50
50
  * The leading `.` character is now removed from the `path` parameter.
51
51
  * Previously, when parsing comma-separated values, it used to ignore any commas that're surrounded by quotes, similar to how it's done in `.csv` files. Now it no longer does that.
52
+ * Previously, when parsing comma-separated values, it used to allow empty-string elements. Now it no longer does that and such empty-string elements will now result in an error with properties: `{ error: "invalid", reason: "syntax" }`.
52
53
  * Previously, when parsing using a schema, it used to force-convert all `type: Date` schema properties from any numeric cell value to a `Date` with a given timestamp. Now it demands the cell values for all such `type: Date` schema properties to already be correctly recognized as `Date`s when they're returned from `readSheet()` or `readExcelFile()` function. And I'd personally assume that in any sane (non-contrived) real-world usage scenario that would be the case, so it doesn't really seem like a "breaking change". And if, for some strange reason, that happens not to be the case, `parseData()` function will throw an error: `not_a_date`.
53
54
  * Previously, when parsing using a schema, it used to skip `required` validation for completely-empty rows. It no longer does that.
54
55
  * Removed exported function `parseExcelDate()` because there seems to be no need to have it exported.
55
56
  * (TypeScript) Renamed exported types:
56
- * `Type` → `ParseDataValueType`
57
+ * `Type` → `ParseDataCustomType`
57
58
  * `Error` or `SchemaParseCellValueError` → `ParseDataError`
58
59
  * `CellValueRequiredError` → `ParseDataValueRequiredError`
59
60
  * `ParsedObjectsResult` → `ParseDataResult`
@@ -71,6 +72,11 @@ Alternatively, it could be included on a web page [directly](#cdn) via a `<scrip
71
72
 
72
73
  If your `.xlsx` file only has a single "sheet", or if you only care for a single "sheet", or if you don't know or care what a "sheet" is, use `readSheet()` function.
73
74
 
75
+ | Name | Date of Birth | Married | Kids |
76
+ | ---------- | ------------- | ------- | ---- |
77
+ | John Smith | 1/1/1995 | TRUE | 3 |
78
+ | Kate Brown | 3/1/2010 | FALSE | 0 |
79
+
74
80
  ```js
75
81
  import { readSheet } from 'read-excel-file/node'
76
82
 
@@ -78,9 +84,9 @@ await readSheet(file)
78
84
 
79
85
  // Returns
80
86
  [
81
- ['John Smith',35,true,...],
82
- ['Kate Brown',28,false,...],
83
- ...
87
+ ['Name', 'Date of Birth', 'Married', 'Kids'],
88
+ ['John Smith', 1995-01-01T00:00:00.000Z, true, 3],
89
+ ['Kate Brown', 2010-03-01T00:00:00.000Z, false, 0]
84
90
  ]
85
91
  ```
86
92
 
@@ -101,9 +107,9 @@ await readExcelFile(file)
101
107
  [{
102
108
  sheet: 'Sheet1',
103
109
  data: [
104
- ['John Smith',35,true,...],
105
- ['Kate Brown',28,false,...],
106
- ...
110
+ ['Name', 'Age'],
111
+ ['John Smith', 30],
112
+ ['Kate Brown', 15]
107
113
  ]
108
114
  }, {
109
115
  sheet: 'Sheet2',
@@ -115,7 +121,9 @@ At least one "sheet" always exists. Each "sheet" is an object with properties:
115
121
  * `sheet` — Sheet name.
116
122
  * Example: `"Sheet1"`
117
123
  * `data` — Sheet data. An array of rows. Each row is an array of values — `string`, `number`, `boolean` or `Date`.
118
- * Example: `[ ['John Smith',35,true,...], ['Kate Brown',28,false,...], ... ]`
124
+ * Example: `[ ['Name','Age'], ['John Smith',30], ['Kate Brown',15] ]`
125
+
126
+ ## API
119
127
 
120
128
  This package provides a separate `import` path for each different environment, as described below.
121
129
 
@@ -351,107 +359,222 @@ Example:
351
359
 
352
360
  ```js
353
361
  // An example .xlsx document:
354
- // -----------------------------------------------------------------------------------------
355
- // | START DATE | NUMBER OF STUDENTS | IS FREE | COURSE TITLE | CONTACT | STATUS |
356
- // -----------------------------------------------------------------------------------------
357
- // | 03/24/2018 | 10 | true | Chemistry | (123) 456-7890 | SCHEDULED |
358
- // -----------------------------------------------------------------------------------------
362
+ // --------------------------------------------------------------------------------------------------------
363
+ // | START DATE | SEATS | STATUS | CONTACT | COURSE TITLE | COURSE CATEGORY | COURSE IS FREE |
364
+ // --------------------------------------------------------------------------------------------------------
365
+ // | 03/24/2018 | 10 | SCHEDULED | (123) 456-7890 | Basic Algebra | Math, Arithmetic | TRUE |
366
+ // --------------------------------------------------------------------------------------------------------
359
367
 
360
368
  const schema = {
361
- date: {
369
+ startDate: {
362
370
  column: 'START DATE',
363
371
  type: Date
364
372
  },
365
- numberOfStudents: {
366
- column: 'NUMBER OF STUDENTS',
373
+ seats: {
374
+ column: 'SEATS',
367
375
  type: Number,
368
376
  required: true
369
377
  },
370
- // Nested object example.
371
- course: {
372
- schema: {
373
- isFree: {
374
- column: 'IS FREE',
375
- type: Boolean
376
- },
377
- title: {
378
- column: 'COURSE TITLE',
379
- type: String
380
- }
381
- }
382
- // required: true/false
383
- },
384
- contact: {
385
- column: 'CONTACT',
386
- required: true,
387
- // A custom `type` parsing function can be specified.
388
- // It will parse the cell value if it's not empty.
389
- type: (value) => {
390
- const number = parsePhoneNumber(value)
391
- if (!number) {
392
- throw new Error('invalid')
393
- }
394
- return number
395
- }
396
- },
397
378
  status: {
398
379
  column: 'STATUS',
399
380
  type: String,
381
+ // An example of using `oneOf`
400
382
  oneOf: [
401
383
  'SCHEDULED',
402
384
  'STARTED',
403
385
  'FINISHED'
404
386
  ]
387
+ },
388
+ contact: {
389
+ column: 'CONTACT',
390
+ required: true,
391
+ // An example of using a custom `type`
392
+ type: PhoneNumber
393
+ },
394
+ // Nested object example
395
+ course: {
396
+ // required: true/false,
397
+ schema: {
398
+ title: {
399
+ column: 'COURSE TITLE',
400
+ type: String
401
+ },
402
+ categories: {
403
+ column: 'COURSE CATEGORY',
404
+ // An example of parsing comma-separated values
405
+ type: [String]
406
+ },
407
+ isFree: {
408
+ column: 'COURSE IS FREE',
409
+ type: Boolean
410
+ }
411
+ }
405
412
  }
406
413
  }
407
414
 
415
+ // If this code was written in TypeScript, `schema` would've been declared as:
416
+ // const schema: Schema<Object, ColumnTitle> = { ... }
417
+
418
+ // Read `data` from an `.xlsx` file
408
419
  const data = await readSheet(file)
409
420
 
421
+ // Parse `data` using the `schema`
410
422
  const results = parseData(data, schema)
411
423
 
424
+ // There's one data row in the `.xlsx` file.
412
425
  results.length === 1
413
426
 
414
- // `errors` items have shape: `{ column, error, reason?, value?, type? }`.
427
+ // There have been no errors when parsing the first data row, so `errors` is `undefined`.
428
+ // Should there have been any errors when parsing the row, `errors` would've been an array
429
+ // with items having shape: `{ column, error, reason?, value?, type? }`.
415
430
  results[0].errors === undefined
416
431
 
417
432
  results[0].object === {
418
- date: new Date(2018, 3 - 1, 24),
419
- numberOfStudents: 10,
420
- course: {
421
- isFree: true,
422
- title: 'Chemistry'
423
- },
433
+ startDate: new Date(Date.UTC(2018, 3 - 1, 24)),
434
+ seats: 10,
435
+ status: 'SCHEDULED',
424
436
  contact: '+11234567890',
425
- status: 'SCHEDULED'
437
+ course: {
438
+ title: 'Basic Algebra',
439
+ categories: ['Math', 'Arithmetic']
440
+ isFree: true
441
+ }
442
+ }
443
+
444
+ // An example of a custom `type` parser function.
445
+ // It will parse the cell value when it's not empty.
446
+ function PhoneNumber(value) {
447
+ const number = parsePhoneNumber(value)
448
+ if (!number) {
449
+ throw new Error('invalid')
450
+ }
451
+ return number
426
452
  }
427
453
  ```
428
454
 
429
- <!-- #### Schema: Tips and Features -->
455
+ An example of how an application could handle the `results`:
430
456
 
431
- <!-- If no `type` is specified then the cell value is returned "as is": as a string, number, date or boolean. -->
457
+ ```js
458
+ const errors = []
459
+ const objects = []
460
+
461
+ // If this code was written in TypeScript, `errors` and `objects` would've been declared as:
462
+ // const errors: { error: ParseDataError, row: number }[] = []
463
+ // const objects: Object[] = []
464
+
465
+ let row = 1
466
+ for (const { errors: errorsInRow, object } of results) {
467
+ if (errorsInRow) {
468
+ for (const error of errorsInRow) {
469
+ errors.push({ error, row })
470
+ }
471
+ } else {
472
+ objects.push(object)
473
+ }
474
+ row++
475
+ }
432
476
 
433
- <!-- There are also some additional exported `type`s available: -->
477
+ if (errors.length > 0) {
478
+ for (const { error, row } of errors) {
479
+ console.error('Error in data row', row, 'column', error.column, ':', error.error, error.reason || '')
480
+ }
481
+ } else {
482
+ console.log('Objects', objects)
483
+ }
484
+ ```
434
485
 
435
486
  <details>
436
- <summary>An example of a <strong>custom <code>type</code></strong></summary>
487
+ <summary>An example of defining a <strong>custom <code>type</code></strong> in <strong>TypeScript</strong></summary>
437
488
 
438
489
  #####
439
490
 
440
- Here's an example of a basic custom `type`. It calls a custom `parseValue()` function to parse a cell value, and produces an `"invalid"` error if the value couldn't be parsed. If a cell is empty, it will not be parsed.
491
+ ```ts
492
+ import type {
493
+ Schema,
494
+ CellValue,
495
+ ParseDataError,
496
+ ParseDataCustomType,
497
+ ParseDataCustomTypeErrorMessage
498
+ } from 'read-excel-file/node'
441
499
 
442
- ```js
443
- {
444
- property: {
445
- column: 'COLUMN TITLE',
446
- type: (value) => {
447
- try {
448
- return parseValue(value)
449
- } catch (error) {
450
- console.error(error)
451
- throw new Error('invalid')
452
- }
500
+ type ColumnTitle = 'COLUMN TITLE 1' | 'COLUMN TITLE 2'
501
+
502
+ type CustomTypeValue = string
503
+
504
+ function CustomType(value: CellValue): CustomTypeValue {
505
+ if (typeof value !== 'string') {
506
+ throw new Error('not_a_string')
507
+ }
508
+ return '~' + value + '~'
509
+ }
510
+
511
+ type CustomTypeErrorMessage<Type extends ParseDataCustomType<unknown>> =
512
+ Type extends typeof CustomType
513
+ ? 'not_a_string'
514
+ : never
515
+
516
+ // type CustomTypeErrorReason<
517
+ // Type extends ParseDataCustomType<unknown>,
518
+ // ErrorMessage extends ParseDataCustomTypeErrorMessage<Type>
519
+ // > =
520
+ // Type extends typeof CustomType
521
+ // ? (ErrorMessage extends 'not_a_string' ? undefined : never)
522
+ // : never
523
+
524
+ type PossibleError = ParseDataError<
525
+ ColumnTitle,
526
+ typeof CustomType,
527
+ CustomTypeErrorMessage<typeof CustomType>
528
+ // CustomTypeErrorReason<typeof CustomType, CustomTypeErrorMessage<typeof CustomType>>
529
+ >
530
+
531
+ interface Object {
532
+ property1: CustomTypeValue;
533
+ property2?: string;
534
+ }
535
+
536
+ const schema: Schema<Object, ColumnTitle> = {
537
+ property1: {
538
+ column: 'COLUMN TITLE 1',
539
+ type: CustomType,
540
+ required: true
541
+ },
542
+ property2: {
543
+ column: 'COLUMN TITLE 2',
544
+ type: String
545
+ }
546
+ }
547
+
548
+ const results = parseData<Object, ColumnTitle, PossibleError>([
549
+ ['COLUMN TITLE 1', 'COLUMN TITLE 2'],
550
+ ['Value 1', 'Value 2']
551
+ ], schema)
552
+
553
+ const errors: {
554
+ error: PossibleError,
555
+ row: number
556
+ }[] = []
557
+
558
+ const objects: Object[] = []
559
+
560
+ let row = 1
561
+ for (const { errors: errorsInRow, object } of results) {
562
+ if (errorsInRow) {
563
+ for (const error of errorsInRow) {
564
+ errors.push({ error, row })
453
565
  }
566
+ } else {
567
+ objects.push(object)
568
+ }
569
+ row++
570
+ }
571
+
572
+ if (errors.length > 0) {
573
+ for (const { error, row } of errors) {
574
+ console.error('Error in data row', row, 'column', error.column, ':', error.error, error.reason || '')
454
575
  }
576
+ } else {
577
+ console.log('Objects', objects)
455
578
  }
456
579
  ```
457
580
  </details>
@@ -18,6 +18,10 @@ import {
18
18
  Schema
19
19
  } from '../types/parseData/parseDataSchema.d.js';
20
20
 
21
+ import {
22
+ ParseDataError
23
+ } from '../types/parseData/parseDataError.d.js';
24
+
21
25
  export {
22
26
  CellValue,
23
27
  Row,
@@ -25,7 +29,12 @@ export {
25
29
  } from '../types/types.d.js';
26
30
 
27
31
  export {
28
- ParseDataValueCustomType as ParseDataValueType,
32
+ ParseDataCustomType,
33
+ // Base `type`s when parsing data.
34
+ StringType as String,
35
+ DateType as Date,
36
+ NumberType as Number,
37
+ BooleanType as Boolean,
29
38
  // Additional built-in `type`s when parsing data.
30
39
  Integer,
31
40
  Email,
@@ -33,6 +42,8 @@ export {
33
42
  } from '../types/parseData/parseDataValueType.d.js';
34
43
 
35
44
  export {
45
+ ParseDataCustomTypeErrorMessage,
46
+ ParseDataCustomTypeErrorReason,
36
47
  ParseDataError,
37
48
  ParseDataValueRequiredError
38
49
  } from '../types/parseData/parseDataError.d.js';
@@ -63,9 +74,10 @@ export function readSheet<ParsedNumber = number>(
63
74
 
64
75
  export function parseData<
65
76
  Object extends object,
66
- ColumnTitle extends string
77
+ ColumnTitle extends string,
78
+ Error extends ParseDataError
67
79
  >(
68
80
  data: SheetData,
69
81
  schema: Schema<Object, ColumnTitle>,
70
82
  options?: ParseDataOptions
71
- ): ParseDataResult<Object>;
83
+ ): ParseDataResult<Object, Error>;
@@ -253,6 +253,12 @@ function parseDataCellValue_(cellValue, schemaEntry, propertyPath, options) {
253
253
  if (errors.length > 0) {
254
254
  return;
255
255
  }
256
+ // If an empty substring was extracted, it means that there was an out-of-place separator.
257
+ if (!substring) {
258
+ errors.push('invalid');
259
+ reasons.push('syntax');
260
+ return;
261
+ }
256
262
  var _parseValue = parseValue(substring, schemaEntry, options),
257
263
  value = _parseValue.value,
258
264
  error = _parseValue.error,
@@ -1 +1 @@
1
- {"version":3,"file":"parseData.js","names":["_Number","_interopRequireDefault","require","_String","_Boolean","_Date","obj","__esModule","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","key","value","_toPropertyKey","configurable","writable","arg","_toPrimitive","_typeof","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","iterator","constructor","prototype","_slicedToArray","arr","i","_arrayWithHoles","_iterableToArrayLimit","_unsupportedIterableToArray","_nonIterableRest","l","n","u","a","f","next","done","_toArray","_iterableToArray","minLen","_arrayLikeToArray","toString","slice","name","Array","from","test","len","arr2","iter","isArray","parseData","data","schema","optionsCustom","validateSchema","options","applyDefaultOptions","_data","columns","dataRows","map","dataRow","parseDataRow","row","path","object","errors","isEmptyObject","pendingRequiredValidations","_i","_Object$keys","_parseProperty","parseProperty","propertyErrors","pendingRequiredValidation","concat","isEmptyValue","_i2","_pendingRequiredValid","_pendingRequiredValid2","required","schemaEntry","createError","error","_i3","_pendingRequiredValid3","_pendingRequiredValid4","transformEmptyObject","columnIndex","column","indexOf","isMissingColumn","propertyPath","_ref","parseNestedObject","propertyValueWhenColumnIsMissing","parseDataCellValue","_parseDataRow","cellValue","_parseDataCellValue_","parseDataCellValue_","propertyValue","errorMessage","reason","propertyValueWhenCellIsEmpty","type","reasons","values","parseSeparatedSubstrings","arrayValueSeparator","substring","_parseValue","parseValue","isEmpty","every","transformEmptyArray","result","parseValueOfType","oneOf","validate","message","parseValueUsingTypeParser","StringType","NumberType","Date","DateType","Boolean","BooleanType","Error","parsedValue","getNextSubstring","string","endCharacter","startIndex","character","elements","index","_getNextSubstring","_getNextSubstring2","trim","_ref2","_i4","_Object$keys2","DEFAULT_OPTIONS"],"sources":["../../source/parseData/parseData.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 * * `arrayValueSeparator` — 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.arrayValueSeparator] — When specified, string values will be split by this separator to get the array.\r\n * @return {object[]} — An array of objects of shape `{ object, errors }`. Either `object` or `errors` is going to be `undefined`.\r\n */\r\nexport default function parseData(data, schema, optionsCustom) {\r\n validateSchema(schema)\r\n const options = applyDefaultOptions(optionsCustom)\r\n const [columns, ...dataRows] = data\r\n return dataRows.map((dataRow) => {\r\n return parseDataRow(dataRow, schema, undefined, columns, options)\r\n })\r\n}\r\n\r\nfunction parseDataRow(row, schema, path, columns, options) {\r\n const object = {}\r\n let errors = []\r\n\r\n let isEmptyObject = true\r\n\r\n const pendingRequiredValidations = []\r\n\r\n // For each property of the object.\r\n for (const key of Object.keys(schema)) {\r\n const {\r\n errors: propertyErrors,\r\n pendingRequiredValidation,\r\n value\r\n } = parseProperty(key, row, path, schema, columns, options)\r\n\r\n if (propertyErrors) {\r\n errors = errors.concat(propertyErrors)\r\n } else {\r\n object[key] = value\r\n // Will perform `required` validation later, when all properties have been parsed.\r\n if (pendingRequiredValidation) {\r\n pendingRequiredValidations.push(pendingRequiredValidation)\r\n }\r\n // Potentially unmark the object as \"empty\".\r\n if (isEmptyObject && !isEmptyValue(value)) {\r\n isEmptyObject = false\r\n }\r\n }\r\n }\r\n\r\n // Perform basic `required` validations (i.e. when `required` property is a boolean).\r\n for (const { required, schemaEntry, value } of pendingRequiredValidations) {\r\n if (required === true) {\r\n errors.push(createError({\r\n error: 'required',\r\n schemaEntry,\r\n value\r\n }))\r\n }\r\n }\r\n\r\n // If there were any errors, return them.\r\n if (errors.length > 0) {\r\n return { errors }\r\n }\r\n\r\n // Perform \"complex\" `required` validations (i.e. when `required` property is a function).\r\n // These \"complex\" `required` validations should only be performed when all properties\r\n // of an object have been parsed correctly because these validations rely on the values\r\n // of other properties.\r\n for (const { required, schemaEntry, value } of pendingRequiredValidations) {\r\n if (typeof required !== 'boolean' && required(object)) {\r\n errors.push(createError({\r\n error: 'required',\r\n schemaEntry,\r\n value\r\n }))\r\n }\r\n }\r\n\r\n // If there were any \"complex\" `required` errors, return them.\r\n if (errors.length > 0) {\r\n return { errors }\r\n }\r\n\r\n // Return `null` for an \"empty\" mapped object.\r\n if (isEmptyObject) {\r\n return {\r\n object: options.transformEmptyObject(object, { path })\r\n }\r\n }\r\n\r\n return { object }\r\n}\r\n\r\nfunction parseProperty(key, row, path, schema, columns, options) {\r\n const schemaEntry = schema[key]\r\n\r\n const columnIndex = schemaEntry.column ? columns.indexOf(schemaEntry.column) : undefined\r\n const isMissingColumn = columnIndex < 0\r\n\r\n // The path of this property inside the top-level object.\r\n const propertyPath = `${path ? path + '.' : ''}${key}`\r\n\r\n const {\r\n errors,\r\n value\r\n } = schemaEntry.schema\r\n ? parseNestedObject(row, schemaEntry.schema, propertyPath, columns, options)\r\n : (\r\n isMissingColumn\r\n ? { value: options.propertyValueWhenColumnIsMissing }\r\n : parseDataCellValue(row[columnIndex], schemaEntry, propertyPath, options)\r\n )\r\n\r\n if (errors) {\r\n return { errors }\r\n }\r\n\r\n // Should apply `required` validation if the value is \"empty\".\r\n let pendingRequiredValidation\r\n if (schemaEntry.required && isEmptyValue(value)) {\r\n // // Can optionally skip `required` validation for certain missing columns.\r\n // const skipRequiredValidation = isMissingColumn && options.shouldSkipRequiredValidationWhenColumnIsMissing(schemaEntry.column, { object: ... })\r\n // if (!skipRequiredValidation) { ... }\r\n\r\n // Will perform `required` validation in the end,\r\n // when all properties of the object have been parsed.\r\n // This is because `required` could also be a function of `object`.\r\n pendingRequiredValidation = {\r\n required: schemaEntry.required,\r\n schemaEntry,\r\n value\r\n }\r\n }\r\n\r\n return { value, pendingRequiredValidation }\r\n}\r\n\r\nfunction parseNestedObject(row, schema, propertyPath, columns, options) {\r\n const {\r\n object,\r\n errors\r\n } = parseDataRow(row, schema, propertyPath, columns, options)\r\n return {\r\n value: object,\r\n errors\r\n }\r\n}\r\n\r\nfunction parseDataCellValue(cellValue, schemaEntry, propertyPath, options) {\r\n const {\r\n value: propertyValue,\r\n error: errorMessage,\r\n reason\r\n } = parseDataCellValue_(cellValue, schemaEntry, propertyPath, options)\r\n\r\n if (errorMessage) {\r\n const error = createError({\r\n schemaEntry,\r\n value: cellValue,\r\n error: errorMessage,\r\n reason\r\n })\r\n return { errors: [error] }\r\n } else {\r\n return { value: propertyValue }\r\n }\r\n}\r\n\r\n/**\r\n * Converts a cell value value to a javascript typed value.\r\n * @param {any} value\r\n * @param {object} schemaEntry\r\n * @param {string} propertyPath\r\n * @param {object} options\r\n * @return {{ value?: any, error?: string, reason?: string }}\r\n */\r\nfunction parseDataCellValue_(cellValue, schemaEntry, propertyPath, 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 }\r\n }\r\n\r\n if (cellValue === null) {\r\n return {\r\n value: options.propertyValueWhenCellIsEmpty\r\n }\r\n }\r\n\r\n if (Array.isArray(schemaEntry.type)) {\r\n const errors = []\r\n const reasons = []\r\n const values = parseSeparatedSubstrings(cellValue, options.arrayValueSeparator).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 const { value, error, reason } = parseValue(substring, schemaEntry, options)\r\n if (error) {\r\n errors.push(error)\r\n reasons.push(reason)\r\n return\r\n }\r\n return value\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 const isEmpty = values.every(isEmptyValue)\r\n if (isEmpty) {\r\n return {\r\n value: options.transformEmptyArray(values, { path: propertyPath })\r\n }\r\n }\r\n return {\r\n value: values\r\n }\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 value.\r\n * @param {any} value\r\n * @param {object} schemaEntry\r\n * @return {{ value: any, error: string }}\r\n */\r\nexport function parseValue(value, schemaEntry, options) {\r\n if (value === null) {\r\n return { value: null }\r\n }\r\n\r\n let result\r\n if (schemaEntry.type) {\r\n result = parseValueOfType(\r\n value,\r\n // Supports parsing array types.\r\n // See `parseSeparatedSubstrings()` function for more details.\r\n // Example `type`: String[]\r\n // Input: 'Barack Obama, \"String, with, colons\", Donald Trump'\r\n // Output: ['Barack Obama', 'String, with, colons', 'Donald Trump']\r\n Array.isArray(schemaEntry.type) ? schemaEntry.type[0] : schemaEntry.type,\r\n options\r\n )\r\n } else {\r\n // The default `type` is `String`.\r\n result = { value: 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 errored then return the error.\r\n if (result.error) {\r\n return result\r\n }\r\n\r\n // Validate the value.\r\n if (result.value !== null) {\r\n // Perform `oneOf` validation.\r\n if (schemaEntry.oneOf && schemaEntry.oneOf.indexOf(result.value) < 0) {\r\n return { error: 'invalid', reason: 'unknown' }\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\r\n return result\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 if (error.reason) {\r\n result.reason = error.reason;\r\n }\r\n return result\r\n }\r\n}\r\n\r\nexport function getNextSubstring(string, endCharacter, 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 === endCharacter) {\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, arrayValueSeparator) {\r\n const elements = []\r\n let index = 0\r\n while (index < string.length) {\r\n const [substring, length] = getNextSubstring(string, arrayValueSeparator, index)\r\n index += length + arrayValueSeparator.length\r\n elements.push(substring.trim())\r\n }\r\n return elements\r\n}\r\n\r\nfunction createError({\r\n schemaEntry,\r\n value,\r\n error: errorMessage,\r\n reason\r\n}) {\r\n const error = {\r\n error: errorMessage,\r\n column: schemaEntry.column,\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 (schemaEntry.type) {\r\n error.type = schemaEntry.type\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\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 arrayValueSeparator: ','\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}"],"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,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,gBAAAA,GAAA;AAAA,SAAAE,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAAAL,CAAA,GAAAC,CAAA,KAAAK,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAN,CAAA,WAAAE,MAAA,CAAAK,wBAAA,CAAAR,CAAA,EAAAC,CAAA,EAAAQ,UAAA,OAAAP,CAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,CAAA,EAAAI,CAAA,YAAAJ,CAAA;AAAA,SAAAU,cAAAZ,CAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAY,SA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A8I,aAAA,CAAAD,GAAA;IACZ,IAAM5D,WAAW,GAAG7B,MAAM,CAACpD,GAAG,CAAC;IAC/B;IACA,IAAIO,OAAA,CAAO0E,WAAW,CAACwB,IAAI,MAAK,QAAQ,IAAI,CAAC9D,KAAK,CAACM,OAAO,CAACgC,WAAW,CAACwB,IAAI,CAAC,EAAE;MAC5E,MAAM,IAAIuB,KAAK,CAAC,qFAAqF,CAAC;IACxG;IACA;IACA,IAAI,CAAC/C,WAAW,CAAC7B,MAAM,EAAE;MACvB,IAAI,CAAC6B,WAAW,CAACQ,MAAM,EAAE;QACvB,MAAM,IAAIuC,KAAK,8CAAArD,MAAA,CAA2C3E,GAAG,QAAI,CAAC;MACpE;IACF;EACF;AACF;AAEA,SAAS4E,YAAYA,CAAC3E,KAAK,EAAE;EAC3B,OAAOA,KAAK,KAAKa,SAAS,IAAIb,KAAK,KAAK,IAAI;AAC9C;AAEA,IAAM8I,eAAe,GAAG;EACtBhD,gCAAgC,EAAEjF,SAAS;EAC3C0F,4BAA4B,EAAE,IAAI;EAClC;EACA;EACA;EACAjB,oBAAoB,EAAE,SAAAA,qBAAA;IAAA,OAAM,IAAI;EAAA;EAChC4B,mBAAmB,EAAE,SAAAA,oBAAA;IAAA,OAAM,IAAI;EAAA;EAC/BN,mBAAmB,EAAE;AACvB,CAAC;AAED,SAASrD,mBAAmBA,CAACD,OAAO,EAAE;EACpC,IAAIA,OAAO,EAAE;IACX,OAAA/D,aAAA,CAAAA,aAAA,KACKuJ,eAAe,GACfxF,OAAO;EAEd,CAAC,MAAM;IACL,OAAOwF,eAAe;EACxB;AACF"}
1
+ {"version":3,"file":"parseData.js","names":["_Number","_interopRequireDefault","require","_String","_Boolean","_Date","obj","__esModule","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","key","value","_toPropertyKey","configurable","writable","arg","_toPrimitive","_typeof","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","iterator","constructor","prototype","_slicedToArray","arr","i","_arrayWithHoles","_iterableToArrayLimit","_unsupportedIterableToArray","_nonIterableRest","l","n","u","a","f","next","done","_toArray","_iterableToArray","minLen","_arrayLikeToArray","toString","slice","name","Array","from","test","len","arr2","iter","isArray","parseData","data","schema","optionsCustom","validateSchema","options","applyDefaultOptions","_data","columns","dataRows","map","dataRow","parseDataRow","row","path","object","errors","isEmptyObject","pendingRequiredValidations","_i","_Object$keys","_parseProperty","parseProperty","propertyErrors","pendingRequiredValidation","concat","isEmptyValue","_i2","_pendingRequiredValid","_pendingRequiredValid2","required","schemaEntry","createError","error","_i3","_pendingRequiredValid3","_pendingRequiredValid4","transformEmptyObject","columnIndex","column","indexOf","isMissingColumn","propertyPath","_ref","parseNestedObject","propertyValueWhenColumnIsMissing","parseDataCellValue","_parseDataRow","cellValue","_parseDataCellValue_","parseDataCellValue_","propertyValue","errorMessage","reason","propertyValueWhenCellIsEmpty","type","reasons","values","parseSeparatedSubstrings","arrayValueSeparator","substring","_parseValue","parseValue","isEmpty","every","transformEmptyArray","result","parseValueOfType","oneOf","validate","message","parseValueUsingTypeParser","StringType","NumberType","Date","DateType","Boolean","BooleanType","Error","parsedValue","getNextSubstring","string","endCharacter","startIndex","character","elements","index","_getNextSubstring","_getNextSubstring2","trim","_ref2","_i4","_Object$keys2","DEFAULT_OPTIONS"],"sources":["../../source/parseData/parseData.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 * * `arrayValueSeparator` — 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.arrayValueSeparator] — When specified, string values will be split by this separator to get the array.\r\n * @return {object[]} — An array of objects of shape `{ object, errors }`. Either `object` or `errors` is going to be `undefined`.\r\n */\r\nexport default function parseData(data, schema, optionsCustom) {\r\n validateSchema(schema)\r\n const options = applyDefaultOptions(optionsCustom)\r\n const [columns, ...dataRows] = data\r\n return dataRows.map((dataRow) => {\r\n return parseDataRow(dataRow, schema, undefined, columns, options)\r\n })\r\n}\r\n\r\nfunction parseDataRow(row, schema, path, columns, options) {\r\n const object = {}\r\n let errors = []\r\n\r\n let isEmptyObject = true\r\n\r\n const pendingRequiredValidations = []\r\n\r\n // For each property of the object.\r\n for (const key of Object.keys(schema)) {\r\n const {\r\n errors: propertyErrors,\r\n pendingRequiredValidation,\r\n value\r\n } = parseProperty(key, row, path, schema, columns, options)\r\n\r\n if (propertyErrors) {\r\n errors = errors.concat(propertyErrors)\r\n } else {\r\n object[key] = value\r\n // Will perform `required` validation later, when all properties have been parsed.\r\n if (pendingRequiredValidation) {\r\n pendingRequiredValidations.push(pendingRequiredValidation)\r\n }\r\n // Potentially unmark the object as \"empty\".\r\n if (isEmptyObject && !isEmptyValue(value)) {\r\n isEmptyObject = false\r\n }\r\n }\r\n }\r\n\r\n // Perform basic `required` validations (i.e. when `required` property is a boolean).\r\n for (const { required, schemaEntry, value } of pendingRequiredValidations) {\r\n if (required === true) {\r\n errors.push(createError({\r\n error: 'required',\r\n schemaEntry,\r\n value\r\n }))\r\n }\r\n }\r\n\r\n // If there were any errors, return them.\r\n if (errors.length > 0) {\r\n return { errors }\r\n }\r\n\r\n // Perform \"complex\" `required` validations (i.e. when `required` property is a function).\r\n // These \"complex\" `required` validations should only be performed when all properties\r\n // of an object have been parsed correctly because these validations rely on the values\r\n // of other properties.\r\n for (const { required, schemaEntry, value } of pendingRequiredValidations) {\r\n if (typeof required !== 'boolean' && required(object)) {\r\n errors.push(createError({\r\n error: 'required',\r\n schemaEntry,\r\n value\r\n }))\r\n }\r\n }\r\n\r\n // If there were any \"complex\" `required` errors, return them.\r\n if (errors.length > 0) {\r\n return { errors }\r\n }\r\n\r\n // Return `null` for an \"empty\" mapped object.\r\n if (isEmptyObject) {\r\n return {\r\n object: options.transformEmptyObject(object, { path })\r\n }\r\n }\r\n\r\n return { object }\r\n}\r\n\r\nfunction parseProperty(key, row, path, schema, columns, options) {\r\n const schemaEntry = schema[key]\r\n\r\n const columnIndex = schemaEntry.column ? columns.indexOf(schemaEntry.column) : undefined\r\n const isMissingColumn = columnIndex < 0\r\n\r\n // The path of this property inside the top-level object.\r\n const propertyPath = `${path ? path + '.' : ''}${key}`\r\n\r\n const {\r\n errors,\r\n value\r\n } = schemaEntry.schema\r\n ? parseNestedObject(row, schemaEntry.schema, propertyPath, columns, options)\r\n : (\r\n isMissingColumn\r\n ? { value: options.propertyValueWhenColumnIsMissing }\r\n : parseDataCellValue(row[columnIndex], schemaEntry, propertyPath, options)\r\n )\r\n\r\n if (errors) {\r\n return { errors }\r\n }\r\n\r\n // Should apply `required` validation if the value is \"empty\".\r\n let pendingRequiredValidation\r\n if (schemaEntry.required && isEmptyValue(value)) {\r\n // // Can optionally skip `required` validation for certain missing columns.\r\n // const skipRequiredValidation = isMissingColumn && options.shouldSkipRequiredValidationWhenColumnIsMissing(schemaEntry.column, { object: ... })\r\n // if (!skipRequiredValidation) { ... }\r\n\r\n // Will perform `required` validation in the end,\r\n // when all properties of the object have been parsed.\r\n // This is because `required` could also be a function of `object`.\r\n pendingRequiredValidation = {\r\n required: schemaEntry.required,\r\n schemaEntry,\r\n value\r\n }\r\n }\r\n\r\n return { value, pendingRequiredValidation }\r\n}\r\n\r\nfunction parseNestedObject(row, schema, propertyPath, columns, options) {\r\n const {\r\n object,\r\n errors\r\n } = parseDataRow(row, schema, propertyPath, columns, options)\r\n return {\r\n value: object,\r\n errors\r\n }\r\n}\r\n\r\nfunction parseDataCellValue(cellValue, schemaEntry, propertyPath, options) {\r\n const {\r\n value: propertyValue,\r\n error: errorMessage,\r\n reason\r\n } = parseDataCellValue_(cellValue, schemaEntry, propertyPath, options)\r\n\r\n if (errorMessage) {\r\n const error = createError({\r\n schemaEntry,\r\n value: cellValue,\r\n error: errorMessage,\r\n reason\r\n })\r\n return { errors: [error] }\r\n } else {\r\n return { value: propertyValue }\r\n }\r\n}\r\n\r\n/**\r\n * Converts a cell value value to a javascript typed value.\r\n * @param {any} value\r\n * @param {object} schemaEntry\r\n * @param {string} propertyPath\r\n * @param {object} options\r\n * @return {{ value?: any, error?: string, reason?: string }}\r\n */\r\nfunction parseDataCellValue_(cellValue, schemaEntry, propertyPath, 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 }\r\n }\r\n\r\n if (cellValue === null) {\r\n return {\r\n value: options.propertyValueWhenCellIsEmpty\r\n }\r\n }\r\n\r\n if (Array.isArray(schemaEntry.type)) {\r\n const errors = []\r\n const reasons = []\r\n const values = parseSeparatedSubstrings(cellValue, options.arrayValueSeparator).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 // 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 const { value, error, reason } = parseValue(substring, schemaEntry, options)\r\n if (error) {\r\n errors.push(error)\r\n reasons.push(reason)\r\n return\r\n }\r\n return value\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 const isEmpty = values.every(isEmptyValue)\r\n if (isEmpty) {\r\n return {\r\n value: options.transformEmptyArray(values, { path: propertyPath })\r\n }\r\n }\r\n return {\r\n value: values\r\n }\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 value.\r\n * @param {any} value\r\n * @param {object} schemaEntry\r\n * @return {{ value: any, error: string }}\r\n */\r\nexport function parseValue(value, schemaEntry, options) {\r\n if (value === null) {\r\n return { value: null }\r\n }\r\n\r\n let result\r\n if (schemaEntry.type) {\r\n result = parseValueOfType(\r\n value,\r\n // Supports parsing array types.\r\n // See `parseSeparatedSubstrings()` function for more details.\r\n // Example `type`: String[]\r\n // Input: 'Barack Obama, \"String, with, colons\", Donald Trump'\r\n // Output: ['Barack Obama', 'String, with, colons', 'Donald Trump']\r\n Array.isArray(schemaEntry.type) ? schemaEntry.type[0] : schemaEntry.type,\r\n options\r\n )\r\n } else {\r\n // The default `type` is `String`.\r\n result = { value: 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 errored then return the error.\r\n if (result.error) {\r\n return result\r\n }\r\n\r\n // Validate the value.\r\n if (result.value !== null) {\r\n // Perform `oneOf` validation.\r\n if (schemaEntry.oneOf && schemaEntry.oneOf.indexOf(result.value) < 0) {\r\n return { error: 'invalid', reason: 'unknown' }\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\r\n return result\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 if (error.reason) {\r\n result.reason = error.reason;\r\n }\r\n return result\r\n }\r\n}\r\n\r\nexport function getNextSubstring(string, endCharacter, 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 === endCharacter) {\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, arrayValueSeparator) {\r\n const elements = []\r\n let index = 0\r\n while (index < string.length) {\r\n const [substring, length] = getNextSubstring(string, arrayValueSeparator, index)\r\n index += length + arrayValueSeparator.length\r\n elements.push(substring.trim())\r\n }\r\n return elements\r\n}\r\n\r\nfunction createError({\r\n schemaEntry,\r\n value,\r\n error: errorMessage,\r\n reason\r\n}) {\r\n const error = {\r\n error: errorMessage,\r\n column: schemaEntry.column,\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 (schemaEntry.type) {\r\n error.type = schemaEntry.type\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\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 arrayValueSeparator: ','\r\n}\r\n\r\nfunction applyDefaultOptions(options) {\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