dataflux 1.17.3 → 1.17.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,8 +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 _classPrivateFieldGet3;
267
- var _iterator = _createForOfIteratorHelper((_classPrivateFieldGet3 = _classPrivateFieldGet(_hiddenFields, _this)) !== null && _classPrivateFieldGet3 !== void 0 ? _classPrivateFieldGet3 : []),
268
+ var _ref;
269
+ var _iterator = _createForOfIteratorHelper((_ref = _this === null || _this === void 0 ? void 0 : _classPrivateFieldGet(_hiddenFields, _this)) !== null && _ref !== void 0 ? _ref : []),
268
270
  _step;
269
271
  try {
270
272
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
@@ -279,7 +281,7 @@ var Model = exports["default"] = /*#__PURE__*/_createClass(function Model(name)
279
281
  if (json && _typeof(json) === "object") {
280
282
  for (var _i = 0, _Object$values = Object.values(json); _i < _Object$values.length; _i++) {
281
283
  var obj = _Object$values[_i];
282
- if (_typeof(obj) === "object") {
284
+ if (obj && _typeof(obj) === "object") {
283
285
  _classPrivateFieldGet(_removeHiddenFields, _this).call(_this, obj);
284
286
  }
285
287
  }
@@ -364,14 +366,14 @@ var Model = exports["default"] = /*#__PURE__*/_createClass(function Model(name)
364
366
  });
365
367
  });
366
368
  _classPrivateFieldInitSpec(this, _hanldeApiError, function (error, objects, operation) {
367
- var _error$response$data, _error2, _ref, _error$message, _error3, _error4;
369
+ var _error$response$data, _error2, _ref2, _error$message, _error3, _error4;
368
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;
369
371
  var targets = objects.map(function (object) {
370
372
  return object.getId();
371
373
  });
372
374
 
373
375
  // Set errors
374
- 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;
375
377
  Object.values(objects).map(function (object) {
376
378
  return object.setError(strError);
377
379
  });
@@ -403,19 +405,20 @@ var Model = exports["default"] = /*#__PURE__*/_createClass(function Model(name)
403
405
  });
404
406
  _classPrivateFieldSet(_type, this, name);
405
407
  this.options = _objectSpread(_objectSpread({}, _typeof(options) === "object" ? options : {}), {}, {
406
- deep: (_ref2 = (_options$deep = options.deep) !== null && _options$deep !== void 0 ? _options$deep : defaults.deep) !== null && _ref2 !== void 0 ? _ref2 : true,
407
- 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,
408
410
  lazyLoad: (_options$lazyLoad = options.lazyLoad) !== null && _options$lazyLoad !== void 0 ? _options$lazyLoad : defaults.lazyLoad,
409
- validate: (_ref4 = (_options$validate = options.validate) !== null && _options$validate !== void 0 ? _options$validate : defaults.validate) !== null && _ref4 !== void 0 ? _ref4 : {},
410
- autoSave: (_ref5 = (_options$autoSave = options.autoSave) !== null && _options$autoSave !== void 0 ? _options$autoSave : defaults.autoSave) !== null && _ref5 !== void 0 ? _ref5 : null,
411
- autoRefresh: (_ref6 = (_options$autoRefresh = options.autoRefresh) !== null && _options$autoRefresh !== void 0 ? _options$autoRefresh : defaults.autoRefresh) !== null && _ref6 !== void 0 ? _ref6 : false,
412
- pre: (_ref7 = (_options$pre = options.pre) !== null && _options$pre !== void 0 ? _options$pre : defaults.pre) !== null && _ref7 !== void 0 ? _ref7 : null,
413
- 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
414
417
  });
415
418
  _classPrivateFieldSet(_store, this, null);
416
419
  _classPrivateFieldSet(_includes, this, {});
417
420
  _classPrivateFieldSet(_axios, this, this.options.axios || _redaxios["default"]);
418
- _classPrivateFieldSet(_hiddenFields, this, this.options.hiddenFields || []);
421
+ _classPrivateFieldSet(_hiddenFields, this, this.options.hiddenFields);
419
422
  _classPrivateFieldSet(_loadFunction, this, this.options.load || null);
420
423
  if (!name || !options) {
421
424
  throw new Error("A Model requires at least a name and a hook");
@@ -423,12 +426,12 @@ var Model = exports["default"] = /*#__PURE__*/_createClass(function Model(name)
423
426
  if (_classPrivateFieldGet(_loadFunction, this) && typeof _classPrivateFieldGet(_loadFunction, this) !== "function") {
424
427
  throw new Error("The load option must be a function");
425
428
  }
426
- var _ref9 = _typeof(options) === "object" ? (0, _modelHooksUtils.getHooksFromOptions)(options) : (0, _modelHooksUtils.getHooksFromUrl)(options),
427
- _ref10 = _slicedToArray(_ref9, 4),
428
- retrieveHook = _ref10[0],
429
- insertHook = _ref10[1],
430
- updateHook = _ref10[2],
431
- 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];
432
435
  _classPrivateFieldSet(_retrieveHook, this, retrieveHook);
433
436
  _classPrivateFieldSet(_updateHook, this, updateHook);
434
437
  _classPrivateFieldSet(_insertHook, this, insertHook);