dataflux 1.10.3 → 1.10.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/Store.js CHANGED
@@ -4,81 +4,46 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = void 0;
7
-
8
7
  var _Obj = _interopRequireDefault(require("./Obj"));
9
-
10
8
  var _PubSub = _interopRequireDefault(require("./PubSub"));
11
-
12
9
  var _batchPromises = _interopRequireDefault(require("batch-promises"));
13
-
14
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
15
-
16
11
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
17
-
18
12
  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); }
19
-
20
13
  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; }
21
-
22
14
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
23
-
24
15
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
25
-
26
16
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
27
-
28
17
  function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
29
-
30
18
  function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
31
-
32
19
  function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
33
-
34
20
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
35
-
36
21
  function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
37
-
38
22
  function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
39
-
40
23
  function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
41
-
42
24
  function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
43
-
44
25
  var objectStatuses = ["new", "old", "mock", "deleted"];
45
-
46
26
  var _merge = /*#__PURE__*/new WeakMap();
47
-
48
27
  var _error = /*#__PURE__*/new WeakSet();
49
-
50
28
  var _deleteByObject = /*#__PURE__*/new WeakMap();
51
-
52
29
  var _deleteByFilter = /*#__PURE__*/new WeakSet();
53
-
54
30
  var _getPromise = /*#__PURE__*/new WeakSet();
55
-
56
31
  var _insertObject = /*#__PURE__*/new WeakMap();
57
-
58
32
  var _loadObjects = /*#__PURE__*/new WeakSet();
59
-
60
33
  var Store = /*#__PURE__*/function () {
61
34
  function Store() {
62
35
  var _this = this,
63
- _options$autoSave,
64
- _options$lazyLoad;
65
-
36
+ _options$autoSave,
37
+ _options$lazyLoad;
66
38
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
67
-
68
39
  _classCallCheck(this, Store);
69
-
70
40
  _classPrivateMethodInitSpec(this, _loadObjects);
71
-
72
41
  _classPrivateMethodInitSpec(this, _getPromise);
73
-
74
42
  _classPrivateMethodInitSpec(this, _deleteByFilter);
75
-
76
43
  _classPrivateMethodInitSpec(this, _error);
77
-
78
44
  _defineProperty(this, "getModels", function () {
79
45
  return Object.keys(_this.models);
80
46
  });
81
-
82
47
  _defineProperty(this, "refreshObjectByType", function (type) {
83
48
  return _classPrivateMethodGet(_this, _getPromise, _getPromise2).call(_this, type).then(function () {
84
49
  var item = _this.models[type];
@@ -97,37 +62,31 @@ var Store = /*#__PURE__*/function () {
97
62
  });
98
63
  }).then(function (objects) {
99
64
  var _iterator = _createForOfIteratorHelper(objects),
100
- _step;
101
-
65
+ _step;
102
66
  try {
103
67
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
104
68
  var object = _step.value;
105
69
  var wrapper = new _Obj["default"](object, item.model);
106
-
107
70
  var _id = wrapper.getId();
108
-
109
71
  var currentObject = item === null || item === void 0 ? void 0 : item.storedObjects[_id];
110
-
111
72
  if (currentObject) {
112
73
  currentObject.deleted = false;
113
74
  var newFingerprint = wrapper.getFingerprint();
114
75
  var oldFingerprint = currentObject.fingerprint;
115
-
116
76
  if (oldFingerprint !== newFingerprint) {
117
77
  // Nothing to do otherwise
118
78
  if (_this.hasChanged(type, currentObject.object)) {// Was the object edited locally?
79
+
119
80
  // Nothing for now
120
81
  } else {
121
82
  // Update with the new object
122
83
  _classPrivateFieldGet(_this, _merge).call(_this, currentObject.object, wrapper.toJSON());
123
-
124
84
  currentObject.fingerprint = newFingerprint;
125
85
  updated.push(currentObject.object);
126
86
  }
127
87
  }
128
88
  } else {
129
89
  var newObject = _classPrivateFieldGet(_this, _insertObject).call(_this, type, object, "old");
130
-
131
90
  item.storedObjects[newObject.getId()].deleted = false;
132
91
  inserted.push(newObject);
133
92
  }
@@ -137,10 +96,8 @@ var Store = /*#__PURE__*/function () {
137
96
  } finally {
138
97
  _iterator.f();
139
98
  }
140
-
141
99
  for (var id in item === null || item === void 0 ? void 0 : item.storedObjects) {
142
100
  var obj = item.storedObjects[id];
143
-
144
101
  if (obj.deleted === undefined) {
145
102
  deleted.push(obj.object);
146
103
  delete item.storedObjects[id];
@@ -148,61 +105,49 @@ var Store = /*#__PURE__*/function () {
148
105
  delete obj.deleted;
149
106
  }
150
107
  }
151
-
152
108
  return [inserted, updated, deleted];
153
109
  });
154
110
  return item.promise;
155
111
  });
156
112
  });
157
-
158
113
  _classPrivateFieldInitSpec(this, _merge, {
159
114
  writable: true,
160
115
  value: function value(originalObject, newObject) {
161
116
  for (var key in newObject) {
162
117
  originalObject[key] = newObject[key];
163
- } // originalObject.update();
164
-
118
+ }
119
+ // originalObject.update();
165
120
  }
166
121
  });
167
-
168
122
  _classPrivateFieldInitSpec(this, _deleteByObject, {
169
123
  writable: true,
170
124
  value: function value(object) {
171
125
  var id = object.getId();
172
-
173
126
  var filterFunction = function filterFunction(item) {
174
127
  return id === item.getId();
175
128
  };
176
-
177
129
  return _classPrivateMethodGet(_this, _deleteByFilter, _deleteByFilter2).call(_this, object.getModel().getType(), filterFunction);
178
130
  }
179
131
  });
180
-
181
132
  _classPrivateFieldInitSpec(this, _insertObject, {
182
133
  writable: true,
183
134
  value: function value(type, item, status) {
184
135
  var model = _this.models[type].model;
185
136
  var wrapper = new _Obj["default"](item, model);
186
137
  var id = wrapper.getId();
187
-
188
138
  if (_this.models[type].storedObjects[id]) {
189
139
  throw new Error("The IDs provided for the model ".concat(type, " are not unique"));
190
140
  }
191
-
192
141
  if (!objectStatuses.includes(status)) {
193
142
  throw new Error("The provided status is not valid");
194
143
  }
195
-
196
144
  if (status === "mock") {
197
145
  wrapper.insert = function () {
198
146
  _this.models[type].storedObjects[id].status = "new";
199
-
200
147
  _this.update([wrapper]);
201
-
202
148
  delete wrapper.insert;
203
149
  };
204
150
  }
205
-
206
151
  _this.models[type].storedObjects[id] = {
207
152
  id: id,
208
153
  fingerprint: wrapper.getFingerprint(),
@@ -212,7 +157,6 @@ var Store = /*#__PURE__*/function () {
212
157
  return wrapper;
213
158
  }
214
159
  });
215
-
216
160
  this.options = {
217
161
  autoSave: (_options$autoSave = options.autoSave) !== null && _options$autoSave !== void 0 ? _options$autoSave : true,
218
162
  saveDelay: options.saveDelay || 1000,
@@ -222,7 +166,6 @@ var Store = /*#__PURE__*/function () {
222
166
  this.models = {};
223
167
  this.pubSub = new _PubSub["default"]();
224
168
  }
225
-
226
169
  _createClass(Store, [{
227
170
  key: "on",
228
171
  value: function on(channel, callback) {
@@ -232,7 +175,6 @@ var Store = /*#__PURE__*/function () {
232
175
  key: "validateModel",
233
176
  value: function validateModel(model) {
234
177
  var type = model.getType();
235
-
236
178
  if (typeof type !== "string" || type === "") {
237
179
  throw new Error("Not valid model object: type missing");
238
180
  }
@@ -241,22 +183,17 @@ var Store = /*#__PURE__*/function () {
241
183
  key: "addModel",
242
184
  value: function addModel(model) {
243
185
  var _this2 = this;
244
-
245
186
  return new Promise(function (resolve, reject) {
246
187
  _this2.validateModel(model);
247
-
248
188
  var type = model.getType();
249
-
250
189
  if (!_this2.models[type]) {
251
190
  var _model$options$lazyLo;
252
-
253
191
  _this2.models[type] = {
254
192
  model: model,
255
193
  storedObjects: {}
256
194
  };
257
195
  model.setStore(_this2);
258
196
  var lazyLoad = (_model$options$lazyLo = model.options.lazyLoad) !== null && _model$options$lazyLo !== void 0 ? _model$options$lazyLo : _this2.options.lazyLoad;
259
-
260
197
  if (lazyLoad) {
261
198
  resolve();
262
199
  } else {
@@ -264,9 +201,7 @@ var Store = /*#__PURE__*/function () {
264
201
  }
265
202
  } else {
266
203
  var error = "The model already exists";
267
-
268
204
  _this2.pubSub.publish("error", error);
269
-
270
205
  reject(error);
271
206
  }
272
207
  });
@@ -297,7 +232,6 @@ var Store = /*#__PURE__*/function () {
297
232
  key: "insert",
298
233
  value: function insert(type, objects) {
299
234
  var _this3 = this;
300
-
301
235
  return _classPrivateMethodGet(this, _getPromise, _getPromise2).call(this, type).then(function () {
302
236
  return objects.map(function (object) {
303
237
  return _classPrivateFieldGet(_this3, _insertObject).call(_this3, type, object, "new");
@@ -308,7 +242,6 @@ var Store = /*#__PURE__*/function () {
308
242
  key: "mock",
309
243
  value: function mock(type, objects) {
310
244
  var _this4 = this;
311
-
312
245
  return _classPrivateMethodGet(this, _getPromise, _getPromise2).call(this, type).then(function () {
313
246
  return objects.map(function (object) {
314
247
  return _classPrivateFieldGet(_this4, _insertObject).call(_this4, type, object, "mock");
@@ -319,7 +252,6 @@ var Store = /*#__PURE__*/function () {
319
252
  key: "get",
320
253
  value: function get(type, id) {
321
254
  var _this5 = this;
322
-
323
255
  return _classPrivateMethodGet(this, _getPromise, _getPromise2).call(this, type).then(function () {
324
256
  try {
325
257
  return _this5.models[type].storedObjects[id].object;
@@ -332,7 +264,6 @@ var Store = /*#__PURE__*/function () {
332
264
  key: "find",
333
265
  value: function find(type, filterFunction) {
334
266
  var _this6 = this;
335
-
336
267
  return _classPrivateMethodGet(this, _getPromise, _getPromise2).call(this, type).then(function () {
337
268
  var all = Object.values(_this6.models[type].storedObjects).filter(function (i) {
338
269
  return i.status !== "deleted";
@@ -342,7 +273,6 @@ var Store = /*#__PURE__*/function () {
342
273
  return filterFunction ? all.filter(filterFunction) : all;
343
274
  })["catch"](function (error) {
344
275
  _this6.pubSub.publish("error", error);
345
-
346
276
  return Promise.reject(error);
347
277
  });
348
278
  }
@@ -350,18 +280,16 @@ var Store = /*#__PURE__*/function () {
350
280
  key: "applyDiff",
351
281
  value: function applyDiff(_ref, type) {
352
282
  var _this7 = this;
353
-
354
283
  var _ref$inserted = _ref.inserted,
355
- inserted = _ref$inserted === void 0 ? [] : _ref$inserted,
356
- _ref$updated = _ref.updated,
357
- updated = _ref$updated === void 0 ? [] : _ref$updated,
358
- _ref$deleted = _ref.deleted,
359
- deleted = _ref$deleted === void 0 ? [] : _ref$deleted;
284
+ inserted = _ref$inserted === void 0 ? [] : _ref$inserted,
285
+ _ref$updated = _ref.updated,
286
+ updated = _ref$updated === void 0 ? [] : _ref$updated,
287
+ _ref$deleted = _ref.deleted,
288
+ deleted = _ref$deleted === void 0 ? [] : _ref$deleted;
360
289
  return new Promise(function (resolve, reject) {
361
290
  try {
362
291
  var _iterator2 = _createForOfIteratorHelper(inserted.concat(updated)),
363
- _step2;
364
-
292
+ _step2;
365
293
  try {
366
294
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
367
295
  var object = _step2.value;
@@ -369,12 +297,10 @@ var Store = /*#__PURE__*/function () {
369
297
  var newId = object.object.getId();
370
298
  var oldId = object.id;
371
299
  var item = _this7.models[type].storedObjects[object.id];
372
-
373
300
  if (newId !== oldId) {
374
301
  _this7.models[type].storedObjects[newId] = item;
375
302
  delete _this7.models[type].storedObjects[object.id];
376
303
  }
377
-
378
304
  item.fingerprint = object.object.getFingerprint();
379
305
  item.status = "old";
380
306
  }
@@ -383,10 +309,8 @@ var Store = /*#__PURE__*/function () {
383
309
  } finally {
384
310
  _iterator2.f();
385
311
  }
386
-
387
312
  var _iterator3 = _createForOfIteratorHelper(deleted),
388
- _step3;
389
-
313
+ _step3;
390
314
  try {
391
315
  for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
392
316
  var _object = _step3.value;
@@ -397,7 +321,6 @@ var Store = /*#__PURE__*/function () {
397
321
  } finally {
398
322
  _iterator3.f();
399
323
  }
400
-
401
324
  resolve();
402
325
  } catch (error) {
403
326
  reject(error);
@@ -419,16 +342,13 @@ var Store = /*#__PURE__*/function () {
419
342
  key: "getDiff",
420
343
  value: function getDiff(type) {
421
344
  var _this8 = this;
422
-
423
345
  return _classPrivateMethodGet(this, _getPromise, _getPromise2).call(this, type).then(function () {
424
346
  var objects = Object.values(_this8.models[type].storedObjects);
425
347
  var inserted = [];
426
348
  var updated = [];
427
349
  var deleted = [];
428
-
429
350
  for (var _i = 0, _objects = objects; _i < _objects.length; _i++) {
430
351
  var object = _objects[_i];
431
-
432
352
  if (object.status === "new") {
433
353
  inserted.push(object);
434
354
  } else if (object.status === "deleted") {
@@ -436,7 +356,6 @@ var Store = /*#__PURE__*/function () {
436
356
  } else if (object.status === "old" && _this8.hasChanged(type, object.object)) {
437
357
  updated.push(object);
438
358
  } // Nothing for mock objects
439
-
440
359
  }
441
360
 
442
361
  return {
@@ -450,7 +369,6 @@ var Store = /*#__PURE__*/function () {
450
369
  key: "factory",
451
370
  value: function factory(type, params) {
452
371
  var _this9 = this;
453
-
454
372
  var item = this.models[type];
455
373
  this.pubSub.publish("loading", {
456
374
  status: "start",
@@ -458,12 +376,10 @@ var Store = /*#__PURE__*/function () {
458
376
  });
459
377
  item.promise = item.model.factory(params).then(function (items) {
460
378
  var _iterator4 = _createForOfIteratorHelper(items),
461
- _step4;
462
-
379
+ _step4;
463
380
  try {
464
381
  for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
465
382
  var _item = _step4.value;
466
-
467
383
  _classPrivateFieldGet(_this9, _insertObject).call(_this9, type, _item, "old");
468
384
  }
469
385
  } catch (err) {
@@ -471,7 +387,6 @@ var Store = /*#__PURE__*/function () {
471
387
  } finally {
472
388
  _iterator4.f();
473
389
  }
474
-
475
390
  _this9.pubSub.publish("loading", {
476
391
  status: "end",
477
392
  model: type
@@ -480,29 +395,22 @@ var Store = /*#__PURE__*/function () {
480
395
  return item.promise;
481
396
  }
482
397
  }]);
483
-
484
398
  return Store;
485
399
  }();
486
-
487
400
  exports["default"] = Store;
488
-
489
401
  function _error2(error) {
490
402
  error = error.message || error;
491
403
  this.pubSub.publish("error", error);
492
404
  return Promise.reject(error);
493
405
  }
494
-
495
406
  function _deleteByFilter2(type, filterFunction) {
496
407
  var _this10 = this;
497
-
498
408
  return _classPrivateMethodGet(this, _getPromise, _getPromise2).call(this, type).then(function () {
499
409
  var deleted = Object.values(_this10.models[type].storedObjects).filter(function (i) {
500
410
  return filterFunction(i.object);
501
411
  });
502
-
503
412
  var _iterator5 = _createForOfIteratorHelper(deleted),
504
- _step5;
505
-
413
+ _step5;
506
414
  try {
507
415
  for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
508
416
  var object = _step5.value;
@@ -513,16 +421,13 @@ function _deleteByFilter2(type, filterFunction) {
513
421
  } finally {
514
422
  _iterator5.f();
515
423
  }
516
-
517
424
  return deleted.map(function (i) {
518
425
  return i.object;
519
426
  });
520
427
  });
521
428
  }
522
-
523
429
  function _getPromise2(type) {
524
430
  var _this11 = this;
525
-
526
431
  if (!this.models[type]) {
527
432
  return Promise.reject("The model doesn't exist");
528
433
  } else if (!this.models[type].promise && !this.options.lazyLoad) {
@@ -535,10 +440,8 @@ function _getPromise2(type) {
535
440
  return this.models[type].promise;
536
441
  }
537
442
  }
538
-
539
443
  function _loadObjects2(type) {
540
444
  var _this12 = this;
541
-
542
445
  var item = this.models[type];
543
446
  this.pubSub.publish("loading", {
544
447
  status: "start",
@@ -546,12 +449,10 @@ function _loadObjects2(type) {
546
449
  });
547
450
  item.promise = item.model.retrieveAll().then(function (items) {
548
451
  var _iterator6 = _createForOfIteratorHelper(items),
549
- _step6;
550
-
452
+ _step6;
551
453
  try {
552
454
  for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
553
455
  var _item2 = _step6.value;
554
-
555
456
  _classPrivateFieldGet(_this12, _insertObject).call(_this12, type, _item2, "old");
556
457
  }
557
458
  } catch (err) {
@@ -559,7 +460,6 @@ function _loadObjects2(type) {
559
460
  } finally {
560
461
  _iterator6.f();
561
462
  }
562
-
563
463
  _this12.pubSub.publish("loading", {
564
464
  status: "end",
565
465
  model: type
package/dist/SubObj.js CHANGED
@@ -1,98 +1,61 @@
1
1
  "use strict";
2
2
 
3
3
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports["default"] = void 0;
9
-
10
8
  var _BasicObj2 = require("./BasicObj");
11
-
12
9
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
13
-
14
10
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
15
-
16
11
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
17
-
18
12
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
19
-
20
13
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
21
-
22
14
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
23
-
24
15
  function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
25
-
26
16
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
27
-
28
17
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
29
-
30
18
  function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
31
-
32
19
  function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
33
-
34
20
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
35
-
36
21
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
37
-
38
22
  function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
39
-
40
23
  function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
41
-
42
24
  function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
43
-
44
25
  function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
45
-
46
26
  function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
47
-
48
27
  function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
49
-
50
28
  function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
51
-
52
29
  var _model = /*#__PURE__*/new WeakMap();
53
-
54
30
  var _parent = /*#__PURE__*/new WeakMap();
55
-
56
31
  var _parentField = /*#__PURE__*/new WeakMap();
57
-
58
32
  var SubObj = /*#__PURE__*/function (_BasicObj) {
59
33
  _inherits(SubObj, _BasicObj);
60
-
61
34
  var _super = _createSuper(SubObj);
62
-
63
35
  function SubObj(parent, field, values, model) {
64
36
  var _thisSuper, _this;
65
-
66
37
  _classCallCheck(this, SubObj);
67
-
68
38
  _this = _super.call(this, values, model);
69
-
70
39
  _classPrivateFieldInitSpec(_assertThisInitialized(_this), _model, {
71
40
  writable: true,
72
41
  value: void 0
73
42
  });
74
-
75
43
  _classPrivateFieldInitSpec(_assertThisInitialized(_this), _parent, {
76
44
  writable: true,
77
45
  value: void 0
78
46
  });
79
-
80
47
  _classPrivateFieldInitSpec(_assertThisInitialized(_this), _parentField, {
81
48
  writable: true,
82
49
  value: void 0
83
50
  });
84
-
85
51
  _defineProperty(_assertThisInitialized(_this), "set", function (attribute, value, hidden) {
86
52
  return _get((_thisSuper = _assertThisInitialized(_this), _getPrototypeOf(SubObj.prototype)), "set", _thisSuper).call(_thisSuper, attribute, value, hidden);
87
53
  });
88
-
89
54
  _defineProperty(_assertThisInitialized(_this), "save", function () {
90
55
  return _classPrivateFieldGet(_assertThisInitialized(_this), _model).getStore().save([_classPrivateFieldGet(_assertThisInitialized(_this), _parent)]);
91
56
  });
92
-
93
57
  _defineProperty(_assertThisInitialized(_this), "destroy", function () {
94
58
  var _classPrivateFieldGet2;
95
-
96
59
  if (Array.isArray(_classPrivateFieldGet(_assertThisInitialized(_this), _parent)[_classPrivateFieldGet(_assertThisInitialized(_this), _parentField)])) {
97
60
  _classPrivateFieldGet(_assertThisInitialized(_this), _parent)[_classPrivateFieldGet(_assertThisInitialized(_this), _parentField)] = _classPrivateFieldGet(_assertThisInitialized(_this), _parent)[_classPrivateFieldGet(_assertThisInitialized(_this), _parentField)].filter(function (i) {
98
61
  return i.getId() !== _this.getId();
@@ -100,25 +63,17 @@ var SubObj = /*#__PURE__*/function (_BasicObj) {
100
63
  } else if ((_classPrivateFieldGet2 = _classPrivateFieldGet(_assertThisInitialized(_this), _parent)[_classPrivateFieldGet(_assertThisInitialized(_this), _parentField)]) !== null && _classPrivateFieldGet2 !== void 0 && _classPrivateFieldGet2.getId) {
101
64
  _classPrivateFieldGet(_assertThisInitialized(_this), _parent)[_classPrivateFieldGet(_assertThisInitialized(_this), _parentField)] = null;
102
65
  }
103
-
104
66
  return _classPrivateFieldGet(_assertThisInitialized(_this), _model).getStore().update([_classPrivateFieldGet(_assertThisInitialized(_this), _parent)]);
105
67
  });
106
-
107
68
  _defineProperty(_assertThisInitialized(_this), "update", function () {
108
69
  return _classPrivateFieldGet(_assertThisInitialized(_this), _model).getStore().update([_classPrivateFieldGet(_assertThisInitialized(_this), _parent)]);
109
70
  });
110
-
111
71
  _classPrivateFieldSet(_assertThisInitialized(_this), _model, model);
112
-
113
72
  _classPrivateFieldSet(_assertThisInitialized(_this), _parent, parent);
114
-
115
73
  _classPrivateFieldSet(_assertThisInitialized(_this), _parentField, field);
116
-
117
74
  (0, _BasicObj2.setValues)(values, model, SubObj, _classPrivateFieldGet(_assertThisInitialized(_this), _parent), _assertThisInitialized(_this));
118
75
  return _this;
119
76
  }
120
-
121
77
  return _createClass(SubObj);
122
78
  }(_BasicObj2.BasicObj);
123
-
124
79
  exports["default"] = SubObj;