dataflux 1.17.2 → 1.17.4

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/dist/Model.js CHANGED
@@ -80,20 +80,22 @@ var _cleanApiError = /*#__PURE__*/new WeakMap();
80
80
  var _removeFromStoreSilentlyAfterFailure = /*#__PURE__*/new WeakMap();
81
81
  var Model = exports["default"] = /*#__PURE__*/_createClass(function Model(name) {
82
82
  var _this = this,
83
- _ref2,
84
- _options$deep,
85
83
  _ref3,
84
+ _options$deep,
85
+ _ref4,
86
86
  _options$parseMoment,
87
87
  _options$lazyLoad,
88
- _ref4,
89
- _options$validate,
90
88
  _ref5,
91
- _options$autoSave,
89
+ _options$validate,
92
90
  _ref6,
93
- _options$autoRefresh,
91
+ _options$autoSave,
94
92
  _ref7,
95
- _options$pre,
93
+ _options$autoRefresh,
96
94
  _ref8,
95
+ _options$pre,
96
+ _ref9,
97
+ _options$hiddenFields,
98
+ _ref10,
97
99
  _options$post;
98
100
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
99
101
  var defaults = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
@@ -263,7 +265,8 @@ var Model = exports["default"] = /*#__PURE__*/_createClass(function Model(name)
263
265
  _classPrivateFieldGet(_includes, _this)[includedType] = filterFunction;
264
266
  });
265
267
  _classPrivateFieldInitSpec(this, _removeHiddenFields, function (json) {
266
- var _iterator = _createForOfIteratorHelper(_classPrivateFieldGet(_hiddenFields, _this)),
268
+ var _ref;
269
+ var _iterator = _createForOfIteratorHelper((_ref = _this === null || _this === void 0 ? void 0 : _classPrivateFieldGet(_hiddenFields, _this)) !== null && _ref !== void 0 ? _ref : []),
267
270
  _step;
268
271
  try {
269
272
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
@@ -275,10 +278,12 @@ var Model = exports["default"] = /*#__PURE__*/_createClass(function Model(name)
275
278
  } finally {
276
279
  _iterator.f();
277
280
  }
278
- for (var _i = 0, _Object$values = Object.values(json); _i < _Object$values.length; _i++) {
279
- var obj = _Object$values[_i];
280
- if (_typeof(obj) === "object") {
281
- _classPrivateFieldGet(_removeHiddenFields, _this).call(_this, obj);
281
+ if (json && _typeof(json) === "object") {
282
+ for (var _i = 0, _Object$values = Object.values(json); _i < _Object$values.length; _i++) {
283
+ var obj = _Object$values[_i];
284
+ if (_typeof(obj) === "object") {
285
+ _classPrivateFieldGet(_removeHiddenFields, _this).call(_this, obj);
286
+ }
282
287
  }
283
288
  }
284
289
  return json;
@@ -361,14 +366,14 @@ var Model = exports["default"] = /*#__PURE__*/_createClass(function Model(name)
361
366
  });
362
367
  });
363
368
  _classPrivateFieldInitSpec(this, _hanldeApiError, function (error, objects, operation) {
364
- var _error$response$data, _error2, _ref, _error$message, _error3, _error4;
369
+ var _error$response$data, _error2, _ref2, _error$message, _error3, _error4;
365
370
  error = (_error$response$data = (_error2 = error) === null || _error2 === void 0 || (_error2 = _error2.response) === null || _error2 === void 0 ? void 0 : _error2.data) !== null && _error$response$data !== void 0 ? _error$response$data : error;
366
371
  var targets = objects.map(function (object) {
367
372
  return object.getId();
368
373
  });
369
374
 
370
375
  // Set errors
371
- var strError = (_ref = (_error$message = (_error3 = error) === null || _error3 === void 0 ? void 0 : _error3.message) !== null && _error$message !== void 0 ? _error$message : (_error4 = error) === null || _error4 === void 0 ? void 0 : _error4.error) !== null && _ref !== void 0 ? _ref : error;
376
+ var strError = (_ref2 = (_error$message = (_error3 = error) === null || _error3 === void 0 ? void 0 : _error3.message) !== null && _error$message !== void 0 ? _error$message : (_error4 = error) === null || _error4 === void 0 ? void 0 : _error4.error) !== null && _ref2 !== void 0 ? _ref2 : error;
372
377
  Object.values(objects).map(function (object) {
373
378
  return object.setError(strError);
374
379
  });
@@ -400,19 +405,20 @@ var Model = exports["default"] = /*#__PURE__*/_createClass(function Model(name)
400
405
  });
401
406
  _classPrivateFieldSet(_type, this, name);
402
407
  this.options = _objectSpread(_objectSpread({}, _typeof(options) === "object" ? options : {}), {}, {
403
- deep: (_ref2 = (_options$deep = options.deep) !== null && _options$deep !== void 0 ? _options$deep : defaults.deep) !== null && _ref2 !== void 0 ? _ref2 : true,
404
- parseMoment: (_ref3 = (_options$parseMoment = options.parseMoment) !== null && _options$parseMoment !== void 0 ? _options$parseMoment : defaults.parseMoment) !== null && _ref3 !== void 0 ? _ref3 : false,
408
+ deep: (_ref3 = (_options$deep = options.deep) !== null && _options$deep !== void 0 ? _options$deep : defaults.deep) !== null && _ref3 !== void 0 ? _ref3 : true,
409
+ parseMoment: (_ref4 = (_options$parseMoment = options.parseMoment) !== null && _options$parseMoment !== void 0 ? _options$parseMoment : defaults.parseMoment) !== null && _ref4 !== void 0 ? _ref4 : false,
405
410
  lazyLoad: (_options$lazyLoad = options.lazyLoad) !== null && _options$lazyLoad !== void 0 ? _options$lazyLoad : defaults.lazyLoad,
406
- validate: (_ref4 = (_options$validate = options.validate) !== null && _options$validate !== void 0 ? _options$validate : defaults.validate) !== null && _ref4 !== void 0 ? _ref4 : {},
407
- autoSave: (_ref5 = (_options$autoSave = options.autoSave) !== null && _options$autoSave !== void 0 ? _options$autoSave : defaults.autoSave) !== null && _ref5 !== void 0 ? _ref5 : null,
408
- autoRefresh: (_ref6 = (_options$autoRefresh = options.autoRefresh) !== null && _options$autoRefresh !== void 0 ? _options$autoRefresh : defaults.autoRefresh) !== null && _ref6 !== void 0 ? _ref6 : false,
409
- pre: (_ref7 = (_options$pre = options.pre) !== null && _options$pre !== void 0 ? _options$pre : defaults.pre) !== null && _ref7 !== void 0 ? _ref7 : null,
410
- post: (_ref8 = (_options$post = options.post) !== null && _options$post !== void 0 ? _options$post : defaults.post) !== null && _ref8 !== void 0 ? _ref8 : null
411
+ validate: (_ref5 = (_options$validate = options.validate) !== null && _options$validate !== void 0 ? _options$validate : defaults.validate) !== null && _ref5 !== void 0 ? _ref5 : {},
412
+ autoSave: (_ref6 = (_options$autoSave = options.autoSave) !== null && _options$autoSave !== void 0 ? _options$autoSave : defaults.autoSave) !== null && _ref6 !== void 0 ? _ref6 : null,
413
+ autoRefresh: (_ref7 = (_options$autoRefresh = options.autoRefresh) !== null && _options$autoRefresh !== void 0 ? _options$autoRefresh : defaults.autoRefresh) !== null && _ref7 !== void 0 ? _ref7 : false,
414
+ pre: (_ref8 = (_options$pre = options.pre) !== null && _options$pre !== void 0 ? _options$pre : defaults.pre) !== null && _ref8 !== void 0 ? _ref8 : null,
415
+ hiddenFields: (_ref9 = (_options$hiddenFields = options.hiddenFields) !== null && _options$hiddenFields !== void 0 ? _options$hiddenFields : defaults.hiddenFields) !== null && _ref9 !== void 0 ? _ref9 : [],
416
+ post: (_ref10 = (_options$post = options.post) !== null && _options$post !== void 0 ? _options$post : defaults.post) !== null && _ref10 !== void 0 ? _ref10 : null
411
417
  });
412
418
  _classPrivateFieldSet(_store, this, null);
413
419
  _classPrivateFieldSet(_includes, this, {});
414
420
  _classPrivateFieldSet(_axios, this, this.options.axios || _redaxios["default"]);
415
- _classPrivateFieldSet(_hiddenFields, this, this.options.hiddenFields || []);
421
+ _classPrivateFieldSet(_hiddenFields, this, this.options.hiddenFields);
416
422
  _classPrivateFieldSet(_loadFunction, this, this.options.load || null);
417
423
  if (!name || !options) {
418
424
  throw new Error("A Model requires at least a name and a hook");
@@ -420,12 +426,12 @@ var Model = exports["default"] = /*#__PURE__*/_createClass(function Model(name)
420
426
  if (_classPrivateFieldGet(_loadFunction, this) && typeof _classPrivateFieldGet(_loadFunction, this) !== "function") {
421
427
  throw new Error("The load option must be a function");
422
428
  }
423
- var _ref9 = _typeof(options) === "object" ? (0, _modelHooksUtils.getHooksFromOptions)(options) : (0, _modelHooksUtils.getHooksFromUrl)(options),
424
- _ref10 = _slicedToArray(_ref9, 4),
425
- retrieveHook = _ref10[0],
426
- insertHook = _ref10[1],
427
- updateHook = _ref10[2],
428
- deleteHook = _ref10[3];
429
+ var _ref11 = _typeof(options) === "object" ? (0, _modelHooksUtils.getHooksFromOptions)(options) : (0, _modelHooksUtils.getHooksFromUrl)(options),
430
+ _ref12 = _slicedToArray(_ref11, 4),
431
+ retrieveHook = _ref12[0],
432
+ insertHook = _ref12[1],
433
+ updateHook = _ref12[2],
434
+ deleteHook = _ref12[3];
429
435
  _classPrivateFieldSet(_retrieveHook, this, retrieveHook);
430
436
  _classPrivateFieldSet(_updateHook, this, updateHook);
431
437
  _classPrivateFieldSet(_insertHook, this, insertHook);