read-excel-file 5.8.7 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/README.md +223 -271
  3. package/bundle/read-excel-file.min.js +1 -1
  4. package/bundle/read-excel-file.min.js.map +1 -1
  5. package/commonjs/read/dropEmptyRows.js +3 -3
  6. package/commonjs/read/dropEmptyRows.js.map +1 -1
  7. package/commonjs/read/dropEmptyRows.test.js.map +1 -1
  8. package/commonjs/read/getData.js +18 -8
  9. package/commonjs/read/getData.js.map +1 -1
  10. package/commonjs/read/readXlsx.js +2 -2
  11. package/commonjs/read/readXlsx.js.map +1 -1
  12. package/commonjs/read/readXlsxFileContents.js +8 -9
  13. package/commonjs/read/readXlsxFileContents.js.map +1 -1
  14. package/commonjs/read/readXlsxFileNode.test.js.map +1 -1
  15. package/commonjs/read/schema/mapToObjects.js +100 -38
  16. package/commonjs/read/schema/mapToObjects.js.map +1 -1
  17. package/commonjs/read/schema/mapToObjects.test.js.map +1 -1
  18. package/commonjs/read/unpackXlsxFileNode.js +14 -3
  19. package/commonjs/read/unpackXlsxFileNode.js.map +1 -1
  20. package/index.d.ts +0 -2
  21. package/modules/read/dropEmptyRows.js +3 -3
  22. package/modules/read/dropEmptyRows.js.map +1 -1
  23. package/modules/read/dropEmptyRows.test.js.map +1 -1
  24. package/modules/read/getData.js +18 -8
  25. package/modules/read/getData.js.map +1 -1
  26. package/modules/read/readXlsx.js +2 -2
  27. package/modules/read/readXlsx.js.map +1 -1
  28. package/modules/read/readXlsxFileContents.js +8 -9
  29. package/modules/read/readXlsxFileContents.js.map +1 -1
  30. package/modules/read/readXlsxFileNode.test.js.map +1 -1
  31. package/modules/read/schema/mapToObjects.js +100 -38
  32. package/modules/read/schema/mapToObjects.js.map +1 -1
  33. package/modules/read/schema/mapToObjects.test.js.map +1 -1
  34. package/modules/read/unpackXlsxFileNode.js +14 -3
  35. package/modules/read/unpackXlsxFileNode.js.map +1 -1
  36. package/node/index.d.ts +0 -2
  37. package/package.json +5 -15
  38. package/types.d.ts +25 -39
  39. package/web-worker/index.d.ts +0 -2
  40. package/bundle/index.html +0 -261
  41. package/bundle/lib/prism.css +0 -125
  42. package/bundle/lib/prism.js +0 -7
  43. package/bundle/lib/promise-polyfill.min.js +0 -1
  44. package/commonjs/read/schema/convertMapToSchema.js +0 -27
  45. package/commonjs/read/schema/convertMapToSchema.js.map +0 -1
  46. package/commonjs/read/schema/convertMapToSchema.test.js.map +0 -1
  47. package/commonjs/read/schema/mapToObjects.legacy.js +0 -60
  48. package/commonjs/read/schema/mapToObjects.legacy.js.map +0 -1
  49. package/commonjs/read/schema/mapToObjects.legacy.test.js.map +0 -1
  50. package/commonjs/read/schema/mapToObjects.spreadsheet.js +0 -25
  51. package/commonjs/read/schema/mapToObjects.spreadsheet.js.map +0 -1
  52. package/commonjs/read/schema/mapToObjects.spreadsheet.test.js.map +0 -1
  53. package/map/index.cjs +0 -2
  54. package/map/index.cjs.js +0 -7
  55. package/map/index.d.ts +0 -15
  56. package/map/index.js +0 -1
  57. package/map/package.json +0 -17
  58. package/modules/read/schema/convertMapToSchema.js +0 -21
  59. package/modules/read/schema/convertMapToSchema.js.map +0 -1
  60. package/modules/read/schema/convertMapToSchema.test.js.map +0 -1
  61. package/modules/read/schema/mapToObjects.legacy.js +0 -53
  62. package/modules/read/schema/mapToObjects.legacy.js.map +0 -1
  63. package/modules/read/schema/mapToObjects.legacy.test.js.map +0 -1
  64. package/modules/read/schema/mapToObjects.spreadsheet.js +0 -19
  65. package/modules/read/schema/mapToObjects.spreadsheet.js.map +0 -1
  66. package/modules/read/schema/mapToObjects.spreadsheet.test.js.map +0 -1
  67. package/schema/index.cjs +0 -2
  68. package/schema/index.cjs.js +0 -7
  69. package/schema/index.d.ts +0 -11
  70. package/schema/index.js +0 -1
  71. package/schema/package.json +0 -17
  72. package/website/index.html +0 -261
  73. package/website/lib/prism.css +0 -125
  74. package/website/lib/prism.js +0 -7
  75. package/website/lib/promise-polyfill.min.js +0 -1
@@ -11,15 +11,18 @@ var _Number = _interopRequireDefault(require("../../types/Number.js"));
11
11
  var _String = _interopRequireDefault(require("../../types/String.js"));
12
12
  var _Boolean = _interopRequireDefault(require("../../types/Boolean.js"));
13
13
  var _Date = _interopRequireDefault(require("../../types/Date.js"));
14
+ var _excluded = ["isColumnOriented", "ignoreEmptyRows", "rowIndexSourceMap"];
14
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
16
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
15
17
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
16
18
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
17
19
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
18
20
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
19
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
20
21
  function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
21
22
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
22
23
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
24
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
25
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
23
26
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
24
27
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
25
28
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -27,8 +30,7 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _ty
27
30
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
28
31
  var DEFAULT_OPTIONS = {
29
32
  schemaPropertyValueForMissingColumn: undefined,
30
- schemaPropertyValueForUndefinedCellValue: undefined,
31
- schemaPropertyValueForNullCellValue: null,
33
+ schemaPropertyValueForMissingValue: null,
32
34
  schemaPropertyShouldSkipRequiredValidationForMissingColumn: function schemaPropertyShouldSkipRequiredValidationForMissingColumn() {
33
35
  return false;
34
36
  },
@@ -41,24 +43,39 @@ var DEFAULT_OPTIONS = {
41
43
  return null;
42
44
  },
43
45
  isColumnOriented: false,
46
+ ignoreEmptyRows: true,
44
47
  arrayValueSeparator: ','
45
48
  };
46
49
 
47
50
  /**
48
- * (this function is exported from `read-excel-file/map`)
49
51
  * Converts spreadsheet-alike data structure into an array of objects.
50
- * The first row should be the list of column headers.
52
+ *
53
+ * Parameters:
54
+ *
55
+ * * `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.
56
+ * * `schema` — A "to JSON" convertion schema (see above).
57
+ * * `options` — (optional) Schema conversion parameters of `read-excel-file`:
58
+ * * `schemaPropertyValueForMissingColumn` — 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 `schemaPropertyValueForMissingColumn: null` to set such "missing column" properties to `null` in the output objects.
59
+ * * `schemaPropertyValueForNullCellValue` — By default, when it encounters a `null` value in a cell in input `data`, it sets it to `undefined` in the output object. Pass `schemaPropertyValueForNullCellValue: null` to make it set such values as `null`s in output objects.
60
+ * * `schemaPropertyValueForUndefinedCellValue` — By default, when it encounters an `undefined` value in a cell in input `data`, it it sets it to `undefined` in the output object. Pass `schemaPropertyValueForUndefinedCellValue: null` to make it set such values as `null`s in output objects.
61
+ * * `schemaPropertyShouldSkipRequiredValidationForMissingColumn: (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 `schemaPropertyShouldSkipRequiredValidationForMissingColumn(column, { object })` to disable `required` validation for missing columns in some or all cases.
62
+ * * `getEmptyObjectValue(object, { path? })` — By default, it returns `null` for "empty" objects. One could override that value using `getEmptyObjectValue(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.
63
+ * * `getEmptyArrayValue(array, { path })` — By default, it returns `null` for an "empty" array value. One could override that value using `getEmptyArrayValue(array, { path })` parameter.
64
+ *
65
+ * When parsing a property value, in case of an error, the value of that property is gonna be `undefined`.
66
+ *
51
67
  * @param {any[][]} data - An array of rows, each row being an array of cells.
52
68
  * @param {object} schema
53
69
  * @param {object} [options]
54
70
  * @param {null} [options.schemaPropertyValueForMissingColumn] — 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 `schemaPropertyValueForMissingColumn: null` to set such "missing column" properties to `null` in the output objects.
55
- * @param {null} [options.schemaPropertyValueForNullCellValue] — By default, when it encounters a `null` value in a cell in input `data`, it sets it to `undefined` in the output object. Pass `schemaPropertyValueForNullCellValue: null` to make it set such values as `null`s in output objects.
56
- * @param {null} [options.schemaPropertyValueForUndefinedCellValue] — By default, when it encounters an `undefined` value in a cell in input `data`, it it sets it to `undefined` in the output object. Pass `schemaPropertyValueForUndefinedCellValue: null` to make it set such values as `null`s in output objects.
71
+ * @param {null} [options.schemaPropertyValueForMissingValue] — By default, when it encounters a `null` value in a cell in input `data`, it leaves the value as is. Pass a custom `schemaPropertyValueForMissingValue` to make it set such values to that value.
72
+ * @param {object} [options.properties] — An optional object with optional property `epoch1904: true/false`. It is used when parsing dates.
57
73
  * @param {boolean} [options.schemaPropertyShouldSkipRequiredValidationForMissingColumn(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 `schemaPropertyShouldSkipRequiredValidationForMissingColumn(column, { object })` to disable `required` validation for missing columns in some or all cases.
58
74
  * @param {function} [options.getEmptyObjectValue(object, { path })] — By default, it returns `null` for an "empty" resulting object. One could override that value using `getEmptyObjectValue(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.
59
75
  * @param {function} [getEmptyArrayValue(array, { path })] — By default, it returns `null` for an "empty" array value. One could override that value using `getEmptyArrayValue(array, { path })` parameter.
60
76
  * @param {boolean} [options.isColumnOriented] — By default, the headers are assumed to be the first row in the `data`. Pass `isColumnOriented: true` if the headers are the first column in the `data`. i.e. if `data` is "transposed".
61
- * @param {object} [options.rowIndexMap] — Custom row index mapping `data` rows. If present, will overwrite the indexes of `data` rows with the indexes from this `rowIndexMap`.
77
+ * @param {string} [options.arrayValueSeparator] — When specified, string values will be split by this separator to get the array.
78
+ * @param {object} [options.rowIndexSourceMap] — Custom row indexes of `data` rows. If present, will overwrite the indexes of `data` rows with the indexes from this `rowIndexSourceMap`.
62
79
  * @return {object[]}
63
80
  */
64
81
  function mapToObjects(data, schema, options) {
@@ -69,28 +86,50 @@ function mapToObjects(data, schema, options) {
69
86
  }
70
87
  var _options = options,
71
88
  isColumnOriented = _options.isColumnOriented,
72
- rowIndexMap = _options.rowIndexMap;
89
+ ignoreEmptyRows = _options.ignoreEmptyRows,
90
+ rowIndexSourceMapOriginal = _options.rowIndexSourceMap,
91
+ schemaTransformOptions = _objectWithoutProperties(_options, _excluded);
92
+
93
+ // `rowIndexSourceMap` could be mutated by `ignoreEmptyRows: true` option.
94
+ // Create a copy of it so that the original `rowIndexSourceMap` is not affected by those changes.
95
+ var rowIndexSourceMap = rowIndexSourceMapOriginal && rowIndexSourceMapOriginal.slice();
73
96
  validateSchema(schema);
74
97
  if (isColumnOriented) {
75
98
  data = transpose(data);
76
99
  }
100
+ if (ignoreEmptyRows) {
101
+ data = data.filter(function (row, i) {
102
+ var isEmptyRow = row.every(function (cell) {
103
+ return cell === null;
104
+ });
105
+ if (isEmptyRow) {
106
+ // Adjust `rowIndexSourceMap` now that the row has been removed.
107
+ if (rowIndexSourceMap) {
108
+ // Remove the `rowIndexSourceMap` entry that corresponds to the removed row.
109
+ rowIndexSourceMap.splice(i, 1);
110
+ }
111
+ return false;
112
+ }
113
+ return true;
114
+ });
115
+ }
77
116
  var columns = data[0];
78
117
  var results = [];
79
118
  var errors = [];
80
119
  for (var i = 1; i < data.length; i++) {
81
- var result = read(schema, data[i], i, undefined, columns, errors, options);
120
+ var result = read(schema, data[i], i, undefined, columns, errors, schemaTransformOptions);
82
121
  results.push(result);
83
122
  }
84
123
 
85
- // Set the correct `row` number in `errors` if a custom `rowIndexMap` is supplied.
86
- if (rowIndexMap) {
124
+ // Set the correct `row` number in `errors` if a custom `rowIndexSourceMap` is supplied.
125
+ if (rowIndexSourceMap) {
87
126
  for (var _iterator = _createForOfIteratorHelperLoose(errors), _step; !(_step = _iterator()).done;) {
88
127
  var error = _step.value;
89
128
  // Convert the `row` index in `data` to the
90
129
  // actual `row` index in the spreadsheet.
91
130
  // `- 1` converts row number to row index.
92
131
  // `+ 1` converts row index to row number.
93
- error.row = rowIndexMap[error.row - 1] + 1;
132
+ error.row = rowIndexSourceMap[error.row - 1] + 1;
94
133
  }
95
134
  }
96
135
  return {
@@ -102,21 +141,23 @@ function read(schema, row, rowIndex, path, columns, errors, options) {
102
141
  var object = {};
103
142
  var isEmptyObject = true;
104
143
  var createError = function createError(_ref) {
105
- var column = _ref.column,
144
+ var schemaEntry = _ref.schemaEntry,
106
145
  value = _ref.value,
107
146
  errorMessage = _ref.error,
108
147
  reason = _ref.reason;
109
148
  var error = {
110
149
  error: errorMessage,
111
150
  row: rowIndex + 1,
112
- column: column,
151
+ column: schemaEntry.column,
113
152
  value: value
114
153
  };
115
154
  if (reason) {
116
155
  error.reason = reason;
117
156
  }
118
- if (schema[column].type) {
119
- error.type = schema[column].type;
157
+ // * Regular values specify a `type?` property, which is included in the `error` object.
158
+ // * Nested objects specify a `schema` property, which is not included in the `error` object.
159
+ if (schemaEntry.type) {
160
+ error.type = schemaEntry.type;
120
161
  }
121
162
  return error;
122
163
  };
@@ -126,14 +167,19 @@ function read(schema, row, rowIndex, path, columns, errors, options) {
126
167
  var _loop = function _loop() {
127
168
  var key = _Object$keys[_i];
128
169
  var schemaEntry = schema[key];
129
- var isNestedSchema = _typeof(schemaEntry.type) === 'object' && !Array.isArray(schemaEntry.type);
170
+
171
+ // `schemaEntry.prop` property is now deprecated and shouldn't be used.
172
+ // Instead, it now uses `key` as the key in the `object`.
173
+ // And column name is now read not from `key` but from `schemaEntry.column` property.
174
+ var propertyName = key;
175
+ var columnTitle = schemaEntry.column;
130
176
 
131
177
  // The path of this property inside the resulting object.
132
- var propertyPath = "".concat(path || '', ".").concat(schemaEntry.prop);
178
+ var propertyPath = "".concat(path || '', ".").concat(propertyName);
133
179
 
134
180
  // Read the cell value for the schema entry.
135
181
  var cellValue;
136
- var columnIndex = columns.indexOf(key);
182
+ var columnIndex = columns.indexOf(columnTitle);
137
183
  var isMissingColumn = columnIndex < 0;
138
184
  if (!isMissingColumn) {
139
185
  cellValue = row[columnIndex];
@@ -143,15 +189,23 @@ function read(schema, row, rowIndex, path, columns, errors, options) {
143
189
  var reason;
144
190
 
145
191
  // Get property `value` from cell value.
146
- if (isNestedSchema) {
147
- value = read(schemaEntry.type, row, rowIndex, propertyPath, columns, errors, options);
192
+ if (schemaEntry.schema) {
193
+ value = read(schemaEntry.schema, row, rowIndex, propertyPath, columns, errors, options);
148
194
  } else {
149
195
  if (isMissingColumn) {
150
- value = options.schemaPropertyValueForMissingColumn;
196
+ if ('schemaPropertyValueForMissingColumn' in options) {
197
+ value = options.schemaPropertyValueForMissingColumn;
198
+ }
151
199
  } else if (cellValue === undefined) {
152
- value = options.schemaPropertyValueForUndefinedCellValue;
200
+ // This isn't supposed to be possible. Cell values are always `null` when cells are empty.
201
+ // Employ some sensible fallback behavior here.
202
+ if ('schemaPropertyValueForMissingValue' in options) {
203
+ value = options.schemaPropertyValueForMissingValue;
204
+ }
153
205
  } else if (cellValue === null) {
154
- value = options.schemaPropertyValueForNullCellValue;
206
+ if ('schemaPropertyValueForMissingValue' in options) {
207
+ value = options.schemaPropertyValueForMissingValue;
208
+ }
155
209
  } else if (Array.isArray(schemaEntry.type)) {
156
210
  var array = parseArray(cellValue, options.arrayValueSeparator).map(function (_value) {
157
211
  if (error) {
@@ -187,7 +241,7 @@ function read(schema, row, rowIndex, path, columns, errors, options) {
187
241
  // Will perform this `required()` validation in the end,
188
242
  // when all properties of the mapped object have been mapped.
189
243
  pendingRequiredChecks.push({
190
- column: key,
244
+ schemaEntry: schemaEntry,
191
245
  value: value,
192
246
  isMissingColumn: isMissingColumn
193
247
  });
@@ -197,7 +251,7 @@ function read(schema, row, rowIndex, path, columns, errors, options) {
197
251
  // If there was an error then the property value in the `object` will be `undefined`,
198
252
  // i.e it won't add the property value to the mapped object.
199
253
  errors.push(createError({
200
- column: key,
254
+ schemaEntry: schemaEntry,
201
255
  value: value,
202
256
  error: error,
203
257
  reason: reason
@@ -208,9 +262,10 @@ function read(schema, row, rowIndex, path, columns, errors, options) {
208
262
  isEmptyObject = false;
209
263
  }
210
264
  // Set the value in the mapped object.
211
- // Skip setting `undefined` values because they're already `undefined`.
265
+ // Skip setting `undefined` values because they're already `undefined`
266
+ // due to not having previously been set.
212
267
  if (value !== undefined) {
213
- object[schemaEntry.prop] = value;
268
+ object[propertyName] = value;
214
269
  }
215
270
  }
216
271
  };
@@ -228,19 +283,19 @@ function read(schema, row, rowIndex, path, columns, errors, options) {
228
283
  // Perform any `required` validations.
229
284
  for (var _i2 = 0, _pendingRequiredCheck = pendingRequiredChecks; _i2 < _pendingRequiredCheck.length; _i2++) {
230
285
  var _pendingRequiredCheck2 = _pendingRequiredCheck[_i2],
231
- column = _pendingRequiredCheck2.column,
286
+ schemaEntry = _pendingRequiredCheck2.schemaEntry,
232
287
  value = _pendingRequiredCheck2.value,
233
288
  isMissingColumn = _pendingRequiredCheck2.isMissingColumn;
234
289
  // Can optionally skip `required` validation for missing columns.
235
- var skipRequiredValidation = isMissingColumn && options.schemaPropertyShouldSkipRequiredValidationForMissingColumn(column, {
290
+ var skipRequiredValidation = isMissingColumn && options.schemaPropertyShouldSkipRequiredValidationForMissingColumn(schemaEntry.column, {
236
291
  object: object
237
292
  });
238
293
  if (!skipRequiredValidation) {
239
- var required = schema[column].required;
294
+ var required = schemaEntry.required;
240
295
  var isRequired = typeof required === 'boolean' ? required : required(object);
241
296
  if (isRequired) {
242
297
  errors.push(createError({
243
- column: column,
298
+ schemaEntry: schemaEntry,
244
299
  value: value,
245
300
  error: 'required'
246
301
  }));
@@ -266,7 +321,7 @@ function parseValue(value, schemaEntry, options) {
266
321
  }
267
322
  var result;
268
323
  if (schemaEntry.parse) {
269
- result = parseCustomValue(value, schemaEntry.parse);
324
+ throw new Error('`schemaEntry.parse` property was renamed to `schemaEntry.type`');
270
325
  } else if (schemaEntry.type) {
271
326
  result = parseValueOfType(value,
272
327
  // Supports parsing array types.
@@ -279,7 +334,7 @@ function parseValue(value, schemaEntry, options) {
279
334
  result = {
280
335
  value: value
281
336
  };
282
- // throw new Error('Invalid schema entry: no .type and no .parse():\n\n' + JSON.stringify(schemaEntry, null, 2))
337
+ // throw new Error('Invalid schema entry: no `type` specified:\n\n' + JSON.stringify(schemaEntry, null, 2))
283
338
  }
284
339
  // If errored then return the error.
285
340
  if (result.error) {
@@ -412,9 +467,16 @@ var transpose = function transpose(array) {
412
467
  function validateSchema(schema) {
413
468
  for (var _i3 = 0, _Object$keys2 = Object.keys(schema); _i3 < _Object$keys2.length; _i3++) {
414
469
  var key = _Object$keys2[_i3];
415
- var entry = schema[key];
416
- if (!entry.prop) {
417
- throw new Error("\"prop\" not defined for schema entry \"".concat(key, "\"."));
470
+ var schemaEntry = schema[key];
471
+ // Validate that the `schema` is not using a deprecated `type: nestedSchema` format.
472
+ if (_typeof(schemaEntry.type) === 'object' && !Array.isArray(schemaEntry.type)) {
473
+ throw new Error('When defining a nested schema, use a `schema` property instead of a `type` property');
474
+ }
475
+ // Validate that every property has a source `column` title specified for it.
476
+ if (!schemaEntry.schema) {
477
+ if (!schemaEntry.column) {
478
+ throw new Error("\"column\" not defined for schema entry \"".concat(key, "\"."));
479
+ }
418
480
  }
419
481
  }
420
482
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mapToObjects.js","names":["_Number","_interopRequireDefault","require","_String","_Boolean","_Date","obj","__esModule","_slicedToArray","arr","i","_arrayWithHoles","_iterableToArrayLimit","_unsupportedIterableToArray","_nonIterableRest","TypeError","r","l","t","Symbol","iterator","e","n","u","a","f","o","call","next","Object","done","push","value","length","Array","isArray","_typeof","constructor","prototype","_createForOfIteratorHelperLoose","allowArrayLike","it","bind","minLen","_arrayLikeToArray","toString","slice","name","from","test","len","arr2","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","DEFAULT_OPTIONS","schemaPropertyValueForMissingColumn","schemaPropertyValueForUndefinedCellValue","schemaPropertyValueForNullCellValue","schemaPropertyShouldSkipRequiredValidationForMissingColumn","getEmptyObjectValue","getEmptyArrayValue","isColumnOriented","arrayValueSeparator","mapToObjects","data","schema","options","_options","rowIndexMap","validateSchema","transpose","columns","results","errors","result","read","_iterator","_step","error","row","rows","rowIndex","path","object","isEmptyObject","createError","_ref","column","errorMessage","reason","type","pendingRequiredChecks","_loop","_Object$keys","_i","schemaEntry","isNestedSchema","propertyPath","concat","prop","cellValue","columnIndex","indexOf","isMissingColumn","array","parseArray","map","_value","parseValue","isEmpty","every","isEmptyValue","required","_i2","_pendingRequiredCheck","_pendingRequiredCheck2","skipRequiredValidation","isRequired","parse","parseCustomValue","parseValueOfType","oneOf","validate","message","parsedValue","StringType","NumberType","Date","DateType","properties","Boolean","BooleanType","Error","getBlock","string","endCharacter","startIndex","substring","character","block","blocks","index","_getBlock","_getBlock2","trim","_","_i3","_Object$keys2","entry"],"sources":["../../../source/read/schema/mapToObjects.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\nconst DEFAULT_OPTIONS = {\r\n schemaPropertyValueForMissingColumn: undefined,\r\n schemaPropertyValueForUndefinedCellValue: undefined,\r\n schemaPropertyValueForNullCellValue: null,\r\n schemaPropertyShouldSkipRequiredValidationForMissingColumn: () => false,\r\n // `getEmptyObjectValue(object, { path })` applies to both the top-level object\r\n // and any of its sub-objects.\r\n getEmptyObjectValue: () => null,\r\n getEmptyArrayValue: () => null,\r\n isColumnOriented: false,\r\n arrayValueSeparator: ','\r\n}\r\n\r\n/**\r\n * (this function is exported from `read-excel-file/map`)\r\n * Converts spreadsheet-alike data structure into an array of objects.\r\n * The first row should be the list of column headers.\r\n * @param {any[][]} 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 {null} [options.schemaPropertyValueForMissingColumn] — 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 `schemaPropertyValueForMissingColumn: null` to set such \"missing column\" properties to `null` in the output objects.\r\n * @param {null} [options.schemaPropertyValueForNullCellValue] — By default, when it encounters a `null` value in a cell in input `data`, it sets it to `undefined` in the output object. Pass `schemaPropertyValueForNullCellValue: null` to make it set such values as `null`s in output objects.\r\n * @param {null} [options.schemaPropertyValueForUndefinedCellValue] — By default, when it encounters an `undefined` value in a cell in input `data`, it it sets it to `undefined` in the output object. Pass `schemaPropertyValueForUndefinedCellValue: null` to make it set such values as `null`s in output objects.\r\n * @param {boolean} [options.schemaPropertyShouldSkipRequiredValidationForMissingColumn(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 `schemaPropertyShouldSkipRequiredValidationForMissingColumn(column, { object })` to disable `required` validation for missing columns in some or all cases.\r\n * @param {function} [options.getEmptyObjectValue(object, { path })] — By default, it returns `null` for an \"empty\" resulting object. One could override that value using `getEmptyObjectValue(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} [getEmptyArrayValue(array, { path })] — By default, it returns `null` for an \"empty\" array value. One could override that value using `getEmptyArrayValue(array, { path })` parameter.\r\n * @param {boolean} [options.isColumnOriented] — By default, the headers are assumed to be the first row in the `data`. Pass `isColumnOriented: true` if the headers are the first column in the `data`. i.e. if `data` is \"transposed\".\r\n * @param {object} [options.rowIndexMap] — Custom row index mapping `data` rows. If present, will overwrite the indexes of `data` rows with the indexes from this `rowIndexMap`.\r\n * @return {object[]}\r\n */\r\nexport default function mapToObjects(data, schema, options) {\r\n if (options) {\r\n options = {\r\n ...DEFAULT_OPTIONS,\r\n ...options\r\n }\r\n } else {\r\n options = DEFAULT_OPTIONS\r\n }\r\n\r\n const {\r\n isColumnOriented,\r\n rowIndexMap\r\n } = options\r\n\r\n validateSchema(schema)\r\n\r\n if (isColumnOriented) {\r\n data = transpose(data)\r\n }\r\n\r\n const columns = data[0]\r\n\r\n const results = []\r\n const errors = []\r\n\r\n for (let i = 1; i < data.length; i++) {\r\n const result = read(schema, data[i], i, undefined, columns, errors, options)\r\n results.push(result)\r\n }\r\n\r\n // Set the correct `row` number in `errors` if a custom `rowIndexMap` is supplied.\r\n if (rowIndexMap) {\r\n for (const error of errors) {\r\n // Convert the `row` index in `data` to the\r\n // actual `row` index in the spreadsheet.\r\n // `- 1` converts row number to row index.\r\n // `+ 1` converts row index to row number.\r\n error.row = rowIndexMap[error.row - 1] + 1\r\n }\r\n }\r\n\r\n return {\r\n rows: results,\r\n errors\r\n }\r\n}\r\n\r\nfunction read(schema, row, rowIndex, path, columns, errors, options) {\r\n const object = {}\r\n let isEmptyObject = true\r\n\r\n const createError = ({\r\n column,\r\n value,\r\n error: errorMessage,\r\n reason\r\n }) => {\r\n const error = {\r\n error: errorMessage,\r\n row: rowIndex + 1,\r\n column,\r\n value\r\n }\r\n if (reason) {\r\n error.reason = reason\r\n }\r\n if (schema[column].type) {\r\n error.type = schema[column].type\r\n }\r\n return error\r\n }\r\n\r\n const pendingRequiredChecks = []\r\n\r\n // For each schema entry.\r\n for (const key of Object.keys(schema)) {\r\n const schemaEntry = schema[key]\r\n const isNestedSchema = typeof schemaEntry.type === 'object' && !Array.isArray(schemaEntry.type)\r\n\r\n // The path of this property inside the resulting object.\r\n const propertyPath = `${path || ''}.${schemaEntry.prop}`\r\n\r\n // Read the cell value for the schema entry.\r\n let cellValue\r\n const columnIndex = columns.indexOf(key)\r\n const isMissingColumn = columnIndex < 0\r\n if (!isMissingColumn) {\r\n cellValue = row[columnIndex]\r\n }\r\n\r\n let value\r\n let error\r\n let reason\r\n\r\n // Get property `value` from cell value.\r\n if (isNestedSchema) {\r\n value = read(schemaEntry.type, row, rowIndex, propertyPath, columns, errors, options)\r\n } else {\r\n if (isMissingColumn) {\r\n value = options.schemaPropertyValueForMissingColumn\r\n }\r\n else if (cellValue === undefined) {\r\n value = options.schemaPropertyValueForUndefinedCellValue\r\n }\r\n else if (cellValue === null) {\r\n value = options.schemaPropertyValueForNullCellValue\r\n }\r\n else if (Array.isArray(schemaEntry.type)) {\r\n const array = parseArray(cellValue, options.arrayValueSeparator).map((_value) => {\r\n if (error) {\r\n return\r\n }\r\n const result = parseValue(_value, schemaEntry, options)\r\n if (result.error) {\r\n // In case of an error, `value` won't be returned and will just be reported\r\n // as part of an `error` object, so it's fine assigning just an element of the array.\r\n value = _value\r\n error = result.error\r\n reason = result.reason\r\n }\r\n return result.value\r\n })\r\n if (!error) {\r\n const isEmpty = array.every(isEmptyValue)\r\n value = isEmpty ? options.getEmptyArrayValue(array, { path: propertyPath }) : array\r\n }\r\n } else {\r\n const result = parseValue(cellValue, schemaEntry, options)\r\n error = result.error\r\n reason = result.reason\r\n value = error ? cellValue : result.value\r\n }\r\n }\r\n\r\n // Apply `required` validation if the value is \"empty\".\r\n if (!error && isEmptyValue(value)) {\r\n if (schemaEntry.required) {\r\n // Will perform this `required()` validation in the end,\r\n // when all properties of the mapped object have been mapped.\r\n pendingRequiredChecks.push({ column: key, value, isMissingColumn })\r\n }\r\n }\r\n\r\n if (error) {\r\n // If there was an error then the property value in the `object` will be `undefined`,\r\n // i.e it won't add the property value to the mapped object.\r\n errors.push(createError({\r\n column: key,\r\n value,\r\n error,\r\n reason\r\n }))\r\n } else {\r\n // Possibly unmark the mapped object as \"empty\".\r\n if (isEmptyObject && !isEmptyValue(value)) {\r\n isEmptyObject = false\r\n }\r\n // Set the value in the mapped object.\r\n // Skip setting `undefined` values because they're already `undefined`.\r\n if (value !== undefined) {\r\n object[schemaEntry.prop] = value\r\n }\r\n }\r\n }\r\n\r\n // Return `null` for an \"empty\" mapped object.\r\n if (isEmptyObject) {\r\n return options.getEmptyObjectValue(object, { path })\r\n }\r\n\r\n // Perform any `required` validations.\r\n for (const { column, value, isMissingColumn } of pendingRequiredChecks) {\r\n // Can optionally skip `required` validation for missing columns.\r\n const skipRequiredValidation = isMissingColumn && options.schemaPropertyShouldSkipRequiredValidationForMissingColumn(column, { object })\r\n if (!skipRequiredValidation) {\r\n const { required } = schema[column]\r\n const isRequired = typeof required === 'boolean' ? required : required(object)\r\n if (isRequired) {\r\n errors.push(createError({\r\n column,\r\n value,\r\n error: 'required'\r\n }))\r\n }\r\n }\r\n }\r\n\r\n // Return the mapped object.\r\n return object\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 let result\r\n if (schemaEntry.parse) {\r\n result = parseCustomValue(value, schemaEntry.parse)\r\n } else if (schemaEntry.type) {\r\n result = parseValueOfType(\r\n value,\r\n // Supports parsing array types.\r\n // See `parseArray()` 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 result = { value: value }\r\n // throw new Error('Invalid schema entry: no .type and no .parse():\\n\\n' + JSON.stringify(schemaEntry, null, 2))\r\n }\r\n // If errored then return the error.\r\n if (result.error) {\r\n return result\r\n }\r\n if (result.value !== null) {\r\n if (schemaEntry.oneOf && schemaEntry.oneOf.indexOf(result.value) < 0) {\r\n return { error: 'invalid', reason: 'unknown' }\r\n }\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 result\r\n}\r\n\r\n/**\r\n * Converts textual value to a custom value using supplied `.parse()`.\r\n * @param {any} value\r\n * @param {function} parse\r\n * @return {{ value: any, error: string }}\r\n */\r\nfunction parseCustomValue(value, parse) {\r\n try {\r\n const parsedValue = parse(value)\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\n/**\r\n * Converts textual value to a javascript typed value.\r\n * @param {any} value\r\n * @param {} type\r\n * @return {{ value: (string|number|Date|boolean), error: string, reason?: string }}\r\n */\r\nfunction parseValueOfType(value, type, options) {\r\n switch (type) {\r\n case String:\r\n return parseCustomValue(value, StringType)\r\n\r\n case Number:\r\n return parseCustomValue(value, NumberType)\r\n\r\n case Date:\r\n return parseCustomValue(value, (value) => DateType(value, { properties: options.properties }))\r\n\r\n case Boolean:\r\n return parseCustomValue(value, BooleanType)\r\n\r\n default:\r\n if (typeof type === 'function') {\r\n return parseCustomValue(value, type)\r\n }\r\n throw new Error(`Unsupported schema type: ${type && type.name || type}`)\r\n }\r\n}\r\n\r\nexport function getBlock(string, endCharacter, startIndex) {\r\n let i = 0\r\n let substring = ''\r\n let character\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 else if (character === '\"') {\r\n const block = getBlock(string, '\"', startIndex + i + 1)\r\n substring += block[0]\r\n i += '\"'.length + block[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 parseArray(string, arrayValueSeparator) {\r\n const blocks = []\r\n let index = 0\r\n while (index < string.length) {\r\n const [substring, length] = getBlock(string, arrayValueSeparator, index)\r\n index += length + arrayValueSeparator.length\r\n blocks.push(substring.trim())\r\n }\r\n return blocks\r\n}\r\n\r\n// Transpose a 2D array.\r\n// https://stackoverflow.com/questions/17428587/transposing-a-2d-array-in-javascript\r\nconst transpose = array => array[0].map((_, i) => array.map(row => row[i]))\r\n\r\nfunction validateSchema(schema) {\r\n for (const key of Object.keys(schema)) {\r\n const entry = schema[key]\r\n if (!entry.prop) {\r\n throw new Error(`\"prop\" not defined for schema entry \"${key}\".`)\r\n }\r\n }\r\n}\r\n\r\nfunction isEmptyValue(value) {\r\n return value === undefined || value === null\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;AAA0C,SAAAD,uBAAAK,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,gBAAAA,GAAA;AAAA,SAAAE,eAAAC,GAAA,EAAAC,CAAA,WAAAC,eAAA,CAAAF,GAAA,KAAAG,qBAAA,CAAAH,GAAA,EAAAC,CAAA,KAAAG,2BAAA,CAAAJ,GAAA,EAAAC,CAAA,KAAAI,gBAAA;AAAA,SAAAA,iBAAA,cAAAC,SAAA;AAAA,SAAAH,sBAAAI,CAAA,EAAAC,CAAA,QAAAC,CAAA,WAAAF,CAAA,gCAAAG,MAAA,IAAAH,CAAA,CAAAG,MAAA,CAAAC,QAAA,KAAAJ,CAAA,4BAAAE,CAAA,QAAAG,CAAA,EAAAC,CAAA,EAAAZ,CAAA,EAAAa,CAAA,EAAAC,CAAA,OAAAC,CAAA,OAAAC,CAAA,iBAAAhB,CAAA,IAAAQ,CAAA,GAAAA,CAAA,CAAAS,IAAA,CAAAX,CAAA,GAAAY,IAAA,QAAAX,CAAA,QAAAY,MAAA,CAAAX,CAAA,MAAAA,CAAA,UAAAO,CAAA,uBAAAA,CAAA,IAAAJ,CAAA,GAAAX,CAAA,CAAAiB,IAAA,CAAAT,CAAA,GAAAY,IAAA,MAAAN,CAAA,CAAAO,IAAA,CAAAV,CAAA,CAAAW,KAAA,GAAAR,CAAA,CAAAS,MAAA,KAAAhB,C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AIiC,KAAK,4CAAAlC,MAAA,CAAyC1D,GAAG,QAAI,CAAC;IAClE;EACF;AACF;AAEA,SAASuE,YAAYA,CAACzG,KAAK,EAAE;EAC3B,OAAOA,KAAK,KAAK6C,SAAS,IAAI7C,KAAK,KAAK,IAAI;AAC9C"}
1
+ {"version":3,"file":"mapToObjects.js","names":["_Number","_interopRequireDefault","require","_String","_Boolean","_Date","_excluded","obj","__esModule","_typeof","o","Symbol","iterator","constructor","prototype","_slicedToArray","arr","i","_arrayWithHoles","_iterableToArrayLimit","_unsupportedIterableToArray","_nonIterableRest","TypeError","r","l","t","e","n","u","a","f","call","next","Object","done","push","value","length","Array","isArray","_createForOfIteratorHelperLoose","allowArrayLike","it","bind","minLen","_arrayLikeToArray","toString","slice","name","from","test","len","arr2","_objectWithoutProperties","source","excluded","target","_objectWithoutPropertiesLoose","key","getOwnPropertySymbols","sourceSymbolKeys","indexOf","propertyIsEnumerable","sourceKeys","keys","ownKeys","filter","getOwnPropertyDescriptor","enumerable","apply","_objectSpread","arguments","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","configurable","writable","arg","_toPrimitive","String","input","hint","prim","toPrimitive","undefined","res","Number","DEFAULT_OPTIONS","schemaPropertyValueForMissingColumn","schemaPropertyValueForMissingValue","schemaPropertyShouldSkipRequiredValidationForMissingColumn","getEmptyObjectValue","getEmptyArrayValue","isColumnOriented","ignoreEmptyRows","arrayValueSeparator","mapToObjects","data","schema","options","_options","rowIndexSourceMapOriginal","rowIndexSourceMap","schemaTransformOptions","validateSchema","transpose","row","isEmptyRow","every","cell","splice","columns","results","errors","result","read","_iterator","_step","error","rows","rowIndex","path","object","isEmptyObject","createError","_ref","schemaEntry","errorMessage","reason","column","type","pendingRequiredChecks","_loop","_Object$keys","_i","propertyName","columnTitle","propertyPath","concat","cellValue","columnIndex","isMissingColumn","array","parseArray","map","_value","parseValue","isEmpty","isEmptyValue","required","_i2","_pendingRequiredCheck","_pendingRequiredCheck2","skipRequiredValidation","isRequired","parse","Error","parseValueOfType","oneOf","validate","message","parseCustomValue","parsedValue","StringType","NumberType","Date","DateType","properties","Boolean","BooleanType","getBlock","string","endCharacter","startIndex","substring","character","block","blocks","index","_getBlock","_getBlock2","trim","_","_i3","_Object$keys2"],"sources":["../../../source/read/schema/mapToObjects.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\nconst DEFAULT_OPTIONS = {\r\n schemaPropertyValueForMissingColumn: undefined,\r\n schemaPropertyValueForMissingValue: null,\r\n schemaPropertyShouldSkipRequiredValidationForMissingColumn: () => false,\r\n // `getEmptyObjectValue(object, { path })` applies to both the top-level object\r\n // and any of its sub-objects.\r\n getEmptyObjectValue: () => null,\r\n getEmptyArrayValue: () => null,\r\n isColumnOriented: false,\r\n ignoreEmptyRows: true,\r\n arrayValueSeparator: ','\r\n}\r\n\r\n/**\r\n * Converts spreadsheet-alike data structure into an array of 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 * * `schemaPropertyValueForMissingColumn` — 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 `schemaPropertyValueForMissingColumn: null` to set such \"missing column\" properties to `null` in the output objects.\r\n * * `schemaPropertyValueForNullCellValue` — By default, when it encounters a `null` value in a cell in input `data`, it sets it to `undefined` in the output object. Pass `schemaPropertyValueForNullCellValue: null` to make it set such values as `null`s in output objects.\r\n * * `schemaPropertyValueForUndefinedCellValue` — By default, when it encounters an `undefined` value in a cell in input `data`, it it sets it to `undefined` in the output object. Pass `schemaPropertyValueForUndefinedCellValue: null` to make it set such values as `null`s in output objects.\r\n * * `schemaPropertyShouldSkipRequiredValidationForMissingColumn: (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 `schemaPropertyShouldSkipRequiredValidationForMissingColumn(column, { object })` to disable `required` validation for missing columns in some or all cases.\r\n * * `getEmptyObjectValue(object, { path? })` — By default, it returns `null` for \"empty\" objects. One could override that value using `getEmptyObjectValue(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 * * `getEmptyArrayValue(array, { path })` — By default, it returns `null` for an \"empty\" array value. One could override that value using `getEmptyArrayValue(array, { path })` parameter.\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 {any[][]} 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 {null} [options.schemaPropertyValueForMissingColumn] — 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 `schemaPropertyValueForMissingColumn: null` to set such \"missing column\" properties to `null` in the output objects.\r\n * @param {null} [options.schemaPropertyValueForMissingValue] — By default, when it encounters a `null` value in a cell in input `data`, it leaves the value as is. Pass a custom `schemaPropertyValueForMissingValue` to make it set such values to that value.\r\n * @param {object} [options.properties] — An optional object with optional property `epoch1904: true/false`. It is used when parsing dates.\r\n * @param {boolean} [options.schemaPropertyShouldSkipRequiredValidationForMissingColumn(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 `schemaPropertyShouldSkipRequiredValidationForMissingColumn(column, { object })` to disable `required` validation for missing columns in some or all cases.\r\n * @param {function} [options.getEmptyObjectValue(object, { path })] — By default, it returns `null` for an \"empty\" resulting object. One could override that value using `getEmptyObjectValue(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} [getEmptyArrayValue(array, { path })] — By default, it returns `null` for an \"empty\" array value. One could override that value using `getEmptyArrayValue(array, { path })` parameter.\r\n * @param {boolean} [options.isColumnOriented] — By default, the headers are assumed to be the first row in the `data`. Pass `isColumnOriented: true` if the headers are the first column in the `data`. i.e. if `data` is \"transposed\".\r\n * @param {string} [options.arrayValueSeparator] — When specified, string values will be split by this separator to get the array.\r\n * @param {object} [options.rowIndexSourceMap] — Custom row indexes of `data` rows. If present, will overwrite the indexes of `data` rows with the indexes from this `rowIndexSourceMap`.\r\n * @return {object[]}\r\n */\r\nexport default function mapToObjects(data, schema, options) {\r\n if (options) {\r\n options = {\r\n ...DEFAULT_OPTIONS,\r\n ...options\r\n }\r\n } else {\r\n options = DEFAULT_OPTIONS\r\n }\r\n\r\n const {\r\n isColumnOriented,\r\n ignoreEmptyRows,\r\n rowIndexSourceMap: rowIndexSourceMapOriginal,\r\n ...schemaTransformOptions\r\n } = options\r\n\r\n // `rowIndexSourceMap` could be mutated by `ignoreEmptyRows: true` option.\r\n // Create a copy of it so that the original `rowIndexSourceMap` is not affected by those changes.\r\n let rowIndexSourceMap = rowIndexSourceMapOriginal && rowIndexSourceMapOriginal.slice()\r\n\r\n validateSchema(schema)\r\n\r\n if (isColumnOriented) {\r\n data = transpose(data)\r\n }\r\n\r\n\tif (ignoreEmptyRows) {\r\n\t\tdata = data.filter((row, i) => {\r\n const isEmptyRow = row.every(cell => cell === null)\r\n if (isEmptyRow) {\r\n // Adjust `rowIndexSourceMap` now that the row has been removed.\r\n if (rowIndexSourceMap) {\r\n // Remove the `rowIndexSourceMap` entry that corresponds to the removed row.\r\n rowIndexSourceMap.splice(i, 1)\r\n }\r\n return false;\r\n }\r\n return true;\r\n })\r\n\t}\r\n\r\n const columns = data[0]\r\n\r\n const results = []\r\n const errors = []\r\n\r\n for (let i = 1; i < data.length; i++) {\r\n const result = read(schema, data[i], i, undefined, columns, errors, schemaTransformOptions)\r\n results.push(result)\r\n }\r\n\r\n // Set the correct `row` number in `errors` if a custom `rowIndexSourceMap` is supplied.\r\n if (rowIndexSourceMap) {\r\n for (const error of errors) {\r\n // Convert the `row` index in `data` to the\r\n // actual `row` index in the spreadsheet.\r\n // `- 1` converts row number to row index.\r\n // `+ 1` converts row index to row number.\r\n error.row = rowIndexSourceMap[error.row - 1] + 1\r\n }\r\n }\r\n\r\n return {\r\n rows: results,\r\n errors\r\n }\r\n}\r\n\r\nfunction read(schema, row, rowIndex, path, columns, errors, options) {\r\n const object = {}\r\n let isEmptyObject = true\r\n\r\n const 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 row: rowIndex + 1,\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\n const pendingRequiredChecks = []\r\n\r\n // For each schema entry.\r\n for (const key of Object.keys(schema)) {\r\n const schemaEntry = schema[key]\r\n\r\n // `schemaEntry.prop` property is now deprecated and shouldn't be used.\r\n // Instead, it now uses `key` as the key in the `object`.\r\n // And column name is now read not from `key` but from `schemaEntry.column` property.\r\n const propertyName = key\r\n const columnTitle = schemaEntry.column\r\n\r\n // The path of this property inside the resulting object.\r\n const propertyPath = `${path || ''}.${propertyName}`\r\n\r\n // Read the cell value for the schema entry.\r\n let cellValue\r\n const columnIndex = columns.indexOf(columnTitle)\r\n const isMissingColumn = columnIndex < 0\r\n if (!isMissingColumn) {\r\n cellValue = row[columnIndex]\r\n }\r\n\r\n let value\r\n let error\r\n let reason\r\n\r\n // Get property `value` from cell value.\r\n if (schemaEntry.schema) {\r\n value = read(schemaEntry.schema, row, rowIndex, propertyPath, columns, errors, options)\r\n } else {\r\n if (isMissingColumn) {\r\n if ('schemaPropertyValueForMissingColumn' in options) {\r\n value = options.schemaPropertyValueForMissingColumn\r\n }\r\n }\r\n else if (cellValue === undefined) {\r\n // This isn't supposed to be possible. Cell values are always `null` when cells are empty.\r\n // Employ some sensible fallback behavior here.\r\n if ('schemaPropertyValueForMissingValue' in options) {\r\n value = options.schemaPropertyValueForMissingValue\r\n }\r\n }\r\n else if (cellValue === null) {\r\n if ('schemaPropertyValueForMissingValue' in options) {\r\n value = options.schemaPropertyValueForMissingValue\r\n }\r\n }\r\n else if (Array.isArray(schemaEntry.type)) {\r\n const array = parseArray(cellValue, options.arrayValueSeparator).map((_value) => {\r\n if (error) {\r\n return\r\n }\r\n const result = parseValue(_value, schemaEntry, options)\r\n if (result.error) {\r\n // In case of an error, `value` won't be returned and will just be reported\r\n // as part of an `error` object, so it's fine assigning just an element of the array.\r\n value = _value\r\n error = result.error\r\n reason = result.reason\r\n }\r\n return result.value\r\n })\r\n if (!error) {\r\n const isEmpty = array.every(isEmptyValue)\r\n value = isEmpty ? options.getEmptyArrayValue(array, { path: propertyPath }) : array\r\n }\r\n } else {\r\n const result = parseValue(cellValue, schemaEntry, options)\r\n error = result.error\r\n reason = result.reason\r\n value = error ? cellValue : result.value\r\n }\r\n }\r\n\r\n // Apply `required` validation if the value is \"empty\".\r\n if (!error && isEmptyValue(value)) {\r\n if (schemaEntry.required) {\r\n // Will perform this `required()` validation in the end,\r\n // when all properties of the mapped object have been mapped.\r\n pendingRequiredChecks.push({ schemaEntry, value, isMissingColumn })\r\n }\r\n }\r\n\r\n if (error) {\r\n // If there was an error then the property value in the `object` will be `undefined`,\r\n // i.e it won't add the property value to the mapped object.\r\n errors.push(createError({\r\n schemaEntry,\r\n value,\r\n error,\r\n reason\r\n }))\r\n } else {\r\n // Possibly unmark the mapped object as \"empty\".\r\n if (isEmptyObject && !isEmptyValue(value)) {\r\n isEmptyObject = false\r\n }\r\n // Set the value in the mapped object.\r\n // Skip setting `undefined` values because they're already `undefined`\r\n // due to not having previously been set.\r\n if (value !== undefined) {\r\n object[propertyName] = value\r\n }\r\n }\r\n }\r\n\r\n // Return `null` for an \"empty\" mapped object.\r\n if (isEmptyObject) {\r\n return options.getEmptyObjectValue(object, { path })\r\n }\r\n\r\n // Perform any `required` validations.\r\n for (const { schemaEntry, value, isMissingColumn } of pendingRequiredChecks) {\r\n // Can optionally skip `required` validation for missing columns.\r\n const skipRequiredValidation = isMissingColumn && options.schemaPropertyShouldSkipRequiredValidationForMissingColumn(schemaEntry.column, { object })\r\n if (!skipRequiredValidation) {\r\n const { required } = schemaEntry\r\n const isRequired = typeof required === 'boolean' ? required : required(object)\r\n if (isRequired) {\r\n errors.push(createError({\r\n schemaEntry,\r\n value,\r\n error: 'required'\r\n }))\r\n }\r\n }\r\n }\r\n\r\n // Return the mapped object.\r\n return object\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 let result\r\n if (schemaEntry.parse) {\r\n throw new Error('`schemaEntry.parse` property was renamed to `schemaEntry.type`')\r\n } else if (schemaEntry.type) {\r\n result = parseValueOfType(\r\n value,\r\n // Supports parsing array types.\r\n // See `parseArray()` 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 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 // If errored then return the error.\r\n if (result.error) {\r\n return result\r\n }\r\n if (result.value !== null) {\r\n if (schemaEntry.oneOf && schemaEntry.oneOf.indexOf(result.value) < 0) {\r\n return { error: 'invalid', reason: 'unknown' }\r\n }\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 result\r\n}\r\n\r\n/**\r\n * Converts textual value to a custom value using supplied `.parse()`.\r\n * @param {any} value\r\n * @param {function} parse\r\n * @return {{ value: any, error: string }}\r\n */\r\nfunction parseCustomValue(value, parse) {\r\n try {\r\n const parsedValue = parse(value)\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\n/**\r\n * Converts textual value to a javascript typed value.\r\n * @param {any} value\r\n * @param {} type\r\n * @return {{ value: (string|number|Date|boolean), error: string, reason?: string }}\r\n */\r\nfunction parseValueOfType(value, type, options) {\r\n switch (type) {\r\n case String:\r\n return parseCustomValue(value, StringType)\r\n\r\n case Number:\r\n return parseCustomValue(value, NumberType)\r\n\r\n case Date:\r\n return parseCustomValue(value, (value) => DateType(value, { properties: options.properties }))\r\n\r\n case Boolean:\r\n return parseCustomValue(value, BooleanType)\r\n\r\n default:\r\n if (typeof type === 'function') {\r\n return parseCustomValue(value, type)\r\n }\r\n throw new Error(`Unsupported schema type: ${type && type.name || type}`)\r\n }\r\n}\r\n\r\nexport function getBlock(string, endCharacter, startIndex) {\r\n let i = 0\r\n let substring = ''\r\n let character\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 else if (character === '\"') {\r\n const block = getBlock(string, '\"', startIndex + i + 1)\r\n substring += block[0]\r\n i += '\"'.length + block[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 parseArray(string, arrayValueSeparator) {\r\n const blocks = []\r\n let index = 0\r\n while (index < string.length) {\r\n const [substring, length] = getBlock(string, arrayValueSeparator, index)\r\n index += length + arrayValueSeparator.length\r\n blocks.push(substring.trim())\r\n }\r\n return blocks\r\n}\r\n\r\n// Transpose a 2D array.\r\n// https://stackoverflow.com/questions/17428587/transposing-a-2d-array-in-javascript\r\nconst transpose = array => array[0].map((_, i) => array.map(row => row[i]))\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}"],"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;AAA0C,IAAAI,SAAA;AAAA,SAAAL,uBAAAM,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,gBAAAA,GAAA;AAAA,SAAAE,QAAAC,CAAA,sCAAAD,OAAA,wBAAAE,MAAA,uBAAAA,MAAA,CAAAC,QAAA,aAAAF,CAAA,kBAAAA,CAAA,gBAAAA,CAAA,WAAAA,CAAA,yBAAAC,MAAA,IAAAD,CAAA,CAAAG,WAAA,KAAAF,MAAA,IAAAD,CAAA,KAAAC,MAAA,CAAAG,SAAA,qBAAAJ,CAAA,KAAAD,OAAA,CAAAC,CAAA;AAAA,SAAAK,eAAAC,GAAA,EAAAC,CAAA,WAAAC,eAAA,CAAAF,GAAA,KAAAG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