@azrico/webobject 1.4.53 → 1.4.55

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.
@@ -12,6 +12,7 @@ export declare class WebObject extends SimpleObject {
12
12
  static readonly __web_path: string;
13
13
  static readonly __web_type: string;
14
14
  static readonly __protectedProperties: string[];
15
+ static readonly __requiredProperties: never[];
15
16
  meta_data: MetaObject[];
16
17
  _id: string;
17
18
  _created_date?: string | Date;
@@ -206,39 +206,39 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
206
206
  value: function () {
207
207
  var _get_deltaObject = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(p) {
208
208
  var _this2 = this;
209
- var final_object, isChild, useDelta, allProperties, chkChangables, useExtraProps, dlt, allkeys, changableKeys, parseObj, _parseObj, functionProps, index, fp, _iterator, _step, key, tempusers;
210
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
211
- while (1) switch (_context5.prev = _context5.next) {
209
+ var final_object, isChild, useDelta, allProperties, chkChangables, useExtraProps, dlt, allkeys, changableKeys, functionProps, index, fp, simpleProps, formats, _loop, formatname, parseObj, _parseObj, _iterator, _step, key, tempusers;
210
+ return _regeneratorRuntime().wrap(function _callee5$(_context6) {
211
+ while (1) switch (_context6.prev = _context6.next) {
212
212
  case 0:
213
213
  _parseObj = function _parseObj3() {
214
214
  _parseObj = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(obj) {
215
215
  var newobj_dlt;
216
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
217
- while (1) switch (_context4.prev = _context4.next) {
216
+ return _regeneratorRuntime().wrap(function _callee4$(_context5) {
217
+ while (1) switch (_context5.prev = _context5.next) {
218
218
  case 0:
219
219
  if (!(obj == null)) {
220
- _context4.next = 2;
220
+ _context5.next = 2;
221
221
  break;
222
222
  }
223
- return _context4.abrupt("return", undefined);
223
+ return _context5.abrupt("return", undefined);
224
224
  case 2:
225
225
  if (!Array.isArray(obj)) {
226
- _context4.next = 6;
226
+ _context5.next = 6;
227
227
  break;
228
228
  }
229
- _context4.next = 5;
229
+ _context5.next = 5;
230
230
  return Promise.all(obj.map( /*#__PURE__*/function () {
231
231
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(r) {
232
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
233
- while (1) switch (_context3.prev = _context3.next) {
232
+ return _regeneratorRuntime().wrap(function _callee3$(_context4) {
233
+ while (1) switch (_context4.prev = _context4.next) {
234
234
  case 0:
235
- _context3.next = 2;
235
+ _context4.next = 2;
236
236
  return parseObj(r);
237
237
  case 2:
238
- return _context3.abrupt("return", _context3.sent);
238
+ return _context4.abrupt("return", _context4.sent);
239
239
  case 3:
240
240
  case "end":
241
- return _context3.stop();
241
+ return _context4.stop();
242
242
  }
243
243
  }, _callee3);
244
244
  }));
@@ -247,30 +247,30 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
247
247
  };
248
248
  }()));
249
249
  case 5:
250
- return _context4.abrupt("return", _context4.sent);
250
+ return _context5.abrupt("return", _context5.sent);
251
251
  case 6:
252
252
  if (!(obj instanceof WebObject && typeof obj.get_deltaObject === "function")) {
253
- _context4.next = 15;
253
+ _context5.next = 15;
254
254
  break;
255
255
  }
256
- _context4.next = 9;
256
+ _context5.next = 9;
257
257
  return obj.get_deltaObject(_objectSpread(_objectSpread({}, p), {}, {
258
258
  isChild: true
259
259
  }));
260
260
  case 9:
261
- newobj_dlt = _context4.sent;
261
+ newobj_dlt = _context5.sent;
262
262
  if ((0, _object.object_isEmpty)(newobj_dlt)) {
263
- _context4.next = 14;
263
+ _context5.next = 14;
264
264
  break;
265
265
  }
266
- return _context4.abrupt("return", newobj_dlt);
266
+ return _context5.abrupt("return", newobj_dlt);
267
267
  case 14:
268
- return _context4.abrupt("return", obj);
268
+ return _context5.abrupt("return", obj);
269
269
  case 15:
270
- return _context4.abrupt("return", obj);
270
+ return _context5.abrupt("return", obj);
271
271
  case 16:
272
272
  case "end":
273
- return _context4.stop();
273
+ return _context5.stop();
274
274
  }
275
275
  }, _callee4);
276
276
  }));
@@ -294,6 +294,9 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
294
294
  ignoreProtected: allProperties
295
295
  });
296
296
  }) : allkeys;
297
+ /* -------------------------------------------------------------------------- */
298
+ /* __functionProperties */
299
+ /* -------------------------------------------------------------------------- */
297
300
  functionProps = (0, _object.object_getStatic)(this, "__functionProperties");
298
301
  if (Array.isArray(functionProps)) {
299
302
  for (index = 0; index < functionProps.length; index++) {
@@ -301,40 +304,99 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
301
304
  if (dlt[fp]) dlt[fp] = (0, _object.fn_eval_this)(this, dlt[fp]);
302
305
  }
303
306
  }
307
+ /* -------------------------------------------------------------------------- */
308
+ /* __simpleProperties */
309
+ /* -------------------------------------------------------------------------- */
310
+ simpleProps = (0, _object.object_getStatic)(this, "__simpleProperties");
311
+ if (Array.isArray(simpleProps)) {
312
+ simpleProps.forEach(function (sp) {
313
+ if (dlt[sp] == null) return;
314
+ var oldValue = dlt[sp];
315
+ var newKey = "simple_" + sp;
316
+ var newValue = typeof oldValue === "string" ? (0, _string.convert_to_simple_string)(oldValue) : undefined;
317
+ dlt[newKey] = newValue;
318
+ //make sure we include this key in delta!
319
+ changableKeys.push(newKey);
320
+ });
321
+ }
322
+ /* -------------------------------------------------------------------------- */
323
+ /* __formatList */
324
+ /* -------------------------------------------------------------------------- */
325
+ formats = (0, _object.object_getStatic)(this, "__formatList");
326
+ if (!formats) {
327
+ _context6.next = 25;
328
+ break;
329
+ }
330
+ _loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop(formatname) {
331
+ var formatKeys;
332
+ return _regeneratorRuntime().wrap(function _loop$(_context3) {
333
+ while (1) switch (_context3.prev = _context3.next) {
334
+ case 0:
335
+ formatKeys = formats[formatname];
336
+ if (Array.isArray(formatKeys)) {
337
+ formatKeys.forEach(function (fk) {
338
+ if (typeof dlt[fk] !== "string") return;
339
+ dlt[fk] = (0, _string.string_do)(formatname, dlt[fk]);
340
+ });
341
+ }
342
+ case 2:
343
+ case "end":
344
+ return _context3.stop();
345
+ }
346
+ }, _loop);
347
+ });
348
+ _context6.t0 = _regeneratorRuntime().keys(formats);
349
+ case 20:
350
+ if ((_context6.t1 = _context6.t0()).done) {
351
+ _context6.next = 25;
352
+ break;
353
+ }
354
+ formatname = _context6.t1.value;
355
+ return _context6.delegateYield(_loop(formatname), "t2", 23);
356
+ case 23:
357
+ _context6.next = 20;
358
+ break;
359
+ case 25:
304
360
  _iterator = _createForOfIteratorHelper(changableKeys);
305
- _context5.prev = 15;
361
+ _context6.prev = 26;
306
362
  _iterator.s();
307
- case 17:
363
+ case 28:
308
364
  if ((_step = _iterator.n()).done) {
309
- _context5.next = 24;
365
+ _context6.next = 35;
310
366
  break;
311
367
  }
312
368
  key = _step.value;
313
- _context5.next = 21;
369
+ _context6.next = 32;
314
370
  return parseObj(dlt[key]);
315
- case 21:
316
- final_object[key] = _context5.sent;
317
- case 22:
318
- _context5.next = 17;
371
+ case 32:
372
+ final_object[key] = _context6.sent;
373
+ case 33:
374
+ _context6.next = 28;
319
375
  break;
320
- case 24:
321
- _context5.next = 29;
376
+ case 35:
377
+ _context6.next = 40;
322
378
  break;
323
- case 26:
324
- _context5.prev = 26;
325
- _context5.t0 = _context5["catch"](15);
326
- _iterator.e(_context5.t0);
327
- case 29:
328
- _context5.prev = 29;
379
+ case 37:
380
+ _context6.prev = 37;
381
+ _context6.t3 = _context6["catch"](26);
382
+ _iterator.e(_context6.t3);
383
+ case 40:
384
+ _context6.prev = 40;
329
385
  _iterator.f();
330
- return _context5.finish(29);
331
- case 32:
386
+ return _context6.finish(40);
387
+ case 43:
388
+ /* -------------------------------------------------------------------------- */
389
+ /* add id properties */
390
+ /* -------------------------------------------------------------------------- */
332
391
  if (allProperties) {
333
392
  final_object["_id"] = this.getID();
334
393
  final_object["_index_key"] = this["_index_key"];
335
394
  final_object["_index_value"] = this.getIndex();
336
395
  final_object["_created_date"] = this["_created_date"];
337
396
  }
397
+ /* -------------------------------------------------------------------------- */
398
+ /* fix _user property */
399
+ /* -------------------------------------------------------------------------- */
338
400
  if (final_object["_users"]) {
339
401
  tempusers = final_object["_users"];
340
402
  if (typeof tempusers === "string") tempusers = tempusers.split(",").filter(function (s) {
@@ -342,12 +404,12 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
342
404
  });
343
405
  final_object["_users"] = (0, _object.wrap_array)(tempusers);
344
406
  }
345
- return _context5.abrupt("return", final_object);
346
- case 35:
407
+ return _context6.abrupt("return", final_object);
408
+ case 46:
347
409
  case "end":
348
- return _context5.stop();
410
+ return _context6.stop();
349
411
  }
350
- }, _callee5, this, [[15, 26, 29, 32]]);
412
+ }, _callee5, this, [[26, 37, 40, 43]]);
351
413
  }));
352
414
  function get_deltaObject(_x) {
353
415
  return _get_deltaObject.apply(this, arguments);
@@ -378,21 +440,21 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
378
440
  var _len,
379
441
  p,
380
442
  _key,
381
- _args6 = arguments;
382
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
383
- while (1) switch (_context6.prev = _context6.next) {
443
+ _args7 = arguments;
444
+ return _regeneratorRuntime().wrap(function _callee6$(_context7) {
445
+ while (1) switch (_context7.prev = _context7.next) {
384
446
  case 0:
385
447
  this.isDeleted = true;
386
- for (_len = _args6.length, p = new Array(_len), _key = 0; _key < _len; _key++) {
387
- p[_key] = _args6[_key];
448
+ for (_len = _args7.length, p = new Array(_len), _key = 0; _key < _len; _key++) {
449
+ p[_key] = _args7[_key];
388
450
  }
389
- _context6.next = 4;
451
+ _context7.next = 4;
390
452
  return (_this$manager = this.manager) === null || _this$manager === void 0 ? void 0 : _this$manager.onDelete.apply(_this$manager, p);
391
453
  case 4:
392
- return _context6.abrupt("return", _context6.sent);
454
+ return _context7.abrupt("return", _context7.sent);
393
455
  case 5:
394
456
  case "end":
395
- return _context6.stop();
457
+ return _context7.stop();
396
458
  }
397
459
  }, _callee6, this);
398
460
  }));
@@ -409,21 +471,21 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
409
471
  var _len2,
410
472
  p,
411
473
  _key2,
412
- _args7 = arguments;
413
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
414
- while (1) switch (_context7.prev = _context7.next) {
474
+ _args8 = arguments;
475
+ return _regeneratorRuntime().wrap(function _callee7$(_context8) {
476
+ while (1) switch (_context8.prev = _context8.next) {
415
477
  case 0:
416
478
  this.isDeleted = false;
417
- for (_len2 = _args7.length, p = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
418
- p[_key2] = _args7[_key2];
479
+ for (_len2 = _args8.length, p = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
480
+ p[_key2] = _args8[_key2];
419
481
  }
420
- _context7.next = 4;
482
+ _context8.next = 4;
421
483
  return (_this$manager2 = this.manager) === null || _this$manager2 === void 0 ? void 0 : _this$manager2.onLoad.apply(_this$manager2, p);
422
484
  case 4:
423
- return _context7.abrupt("return", _context7.sent);
485
+ return _context8.abrupt("return", _context8.sent);
424
486
  case 5:
425
487
  case "end":
426
- return _context7.stop();
488
+ return _context8.stop();
427
489
  }
428
490
  }, _callee7, this);
429
491
  }));
@@ -442,38 +504,38 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
442
504
  _len3,
443
505
  p,
444
506
  _key3,
445
- _args8 = arguments;
446
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
447
- while (1) switch (_context8.prev = _context8.next) {
507
+ _args9 = arguments;
508
+ return _regeneratorRuntime().wrap(function _callee8$(_context9) {
509
+ while (1) switch (_context9.prev = _context9.next) {
448
510
  case 0:
449
511
  if (!this.isSaved) {
450
- _context8.next = 7;
512
+ _context9.next = 7;
451
513
  break;
452
514
  }
453
515
  this.apply_changes();
454
516
  srObject = this.getSaveResult(true);
455
517
  if (!this.saveResultHasID(srObject)) {
456
- _context8.next = 7;
518
+ _context9.next = 7;
457
519
  break;
458
520
  }
459
521
  /* -------------------------------------------------------------------------- */
460
522
  WebObject.LoadIdsFromSaveResult(this, srObject);
461
- _context8.next = 7;
523
+ _context9.next = 7;
462
524
  return (_this$manager3 = this.manager) === null || _this$manager3 === void 0 ? void 0 : _this$manager3.event_run("on_id_change");
463
525
  case 7:
464
- for (_len3 = _args8.length, p = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
465
- p[_key3] = _args8[_key3];
526
+ for (_len3 = _args9.length, p = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
527
+ p[_key3] = _args9[_key3];
466
528
  }
467
- _context8.next = 10;
529
+ _context9.next = 10;
468
530
  return (_this$manager4 = this.manager) === null || _this$manager4 === void 0 ? void 0 : _this$manager4.onSave.apply(_this$manager4, p);
469
531
  case 10:
470
- _context8.next = 12;
532
+ _context9.next = 12;
471
533
  return this.onAfterSave();
472
534
  case 12:
473
- return _context8.abrupt("return", true);
535
+ return _context9.abrupt("return", true);
474
536
  case 13:
475
537
  case "end":
476
- return _context8.stop();
538
+ return _context9.stop();
477
539
  }
478
540
  }, _callee8, this);
479
541
  }));
@@ -490,20 +552,20 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
490
552
  var _len4,
491
553
  p,
492
554
  _key4,
493
- _args9 = arguments;
494
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
495
- while (1) switch (_context9.prev = _context9.next) {
555
+ _args10 = arguments;
556
+ return _regeneratorRuntime().wrap(function _callee9$(_context10) {
557
+ while (1) switch (_context10.prev = _context10.next) {
496
558
  case 0:
497
- for (_len4 = _args9.length, p = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
498
- p[_key4] = _args9[_key4];
559
+ for (_len4 = _args10.length, p = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
560
+ p[_key4] = _args10[_key4];
499
561
  }
500
- _context9.next = 3;
562
+ _context10.next = 3;
501
563
  return (_this$manager5 = this.manager) === null || _this$manager5 === void 0 ? void 0 : _this$manager5.onAfterSave.apply(_this$manager5, p);
502
564
  case 3:
503
- return _context9.abrupt("return", true);
565
+ return _context10.abrupt("return", true);
504
566
  case 4:
505
567
  case "end":
506
- return _context9.stop();
568
+ return _context10.stop();
507
569
  }
508
570
  }, _callee9, this);
509
571
  }));
@@ -535,20 +597,20 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
535
597
  var _len5,
536
598
  p,
537
599
  _key5,
538
- _args10 = arguments;
539
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
540
- while (1) switch (_context10.prev = _context10.next) {
600
+ _args11 = arguments;
601
+ return _regeneratorRuntime().wrap(function _callee10$(_context11) {
602
+ while (1) switch (_context11.prev = _context11.next) {
541
603
  case 0:
542
- for (_len5 = _args10.length, p = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
543
- p[_key5] = _args10[_key5];
604
+ for (_len5 = _args11.length, p = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
605
+ p[_key5] = _args11[_key5];
544
606
  }
545
- _context10.next = 3;
607
+ _context11.next = 3;
546
608
  return (_this$manager6 = this.manager) === null || _this$manager6 === void 0 ? void 0 : _this$manager6.onNew.apply(_this$manager6, p);
547
609
  case 3:
548
- return _context10.abrupt("return", _context10.sent);
610
+ return _context11.abrupt("return", _context11.sent);
549
611
  case 4:
550
612
  case "end":
551
- return _context10.stop();
613
+ return _context11.stop();
552
614
  }
553
615
  }, _callee10, this);
554
616
  }));
@@ -630,11 +692,11 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
630
692
  _item,
631
693
  _index2,
632
694
  _item2,
633
- _args11 = arguments;
634
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
635
- while (1) switch (_context11.prev = _context11.next) {
695
+ _args12 = arguments;
696
+ return _regeneratorRuntime().wrap(function _callee11$(_context12) {
697
+ while (1) switch (_context12.prev = _context12.next) {
636
698
  case 0:
637
- extraOptions = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : {};
699
+ extraOptions = _args12.length > 1 && _args12[1] !== undefined ? _args12[1] : {};
638
700
  if (!extraOptions) extraOptions = {};
639
701
  chunks = (0, _object.array_chunks)(itemList, (_extraOptions$chunksi = extraOptions.chunksize) !== null && _extraOptions$chunksi !== void 0 ? _extraOptions$chunksi : 50);
640
702
  delete extraOptions.chunksize;
@@ -642,7 +704,7 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
642
704
  index = 0;
643
705
  case 6:
644
706
  if (!(index < chunks.length)) {
645
- _context11.next = 36;
707
+ _context12.next = 36;
646
708
  break;
647
709
  }
648
710
  items_to_save = chunks[index];
@@ -650,79 +712,79 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
650
712
  k = 0;
651
713
  case 10:
652
714
  if (!(k < items_to_save.length)) {
653
- _context11.next = 19;
715
+ _context12.next = 19;
654
716
  break;
655
717
  }
656
718
  item = items_to_save[k];
657
- _context11.next = 14;
719
+ _context12.next = 14;
658
720
  return item.get_deltaObject();
659
721
  case 14:
660
- dlt = _context11.sent;
722
+ dlt = _context12.sent;
661
723
  save_array.push(item.isNew ? _objectSpread({}, dlt) : _objectSpread({
662
724
  _id: item.getID()
663
725
  }, dlt));
664
726
  case 16:
665
727
  k++;
666
- _context11.next = 10;
728
+ _context12.next = 10;
667
729
  break;
668
730
  case 19:
669
- _context11.next = 21;
731
+ _context12.next = 21;
670
732
  return _global.gfunc.run_action("post", putAddress, _objectSpread({
671
733
  __save_list: WebObject.zipSaveList(save_array)
672
734
  }, extraOptions));
673
735
  case 21:
674
- resultObject = _context11.sent;
736
+ resultObject = _context12.sent;
675
737
  if (!Array.isArray(resultObject)) {
676
- _context11.next = 33;
738
+ _context12.next = 33;
677
739
  break;
678
740
  }
679
741
  _index = 0;
680
742
  case 24:
681
743
  if (!(_index < Math.min(resultObject.length, items_to_save.length))) {
682
- _context11.next = 33;
744
+ _context12.next = 33;
683
745
  break;
684
746
  }
685
747
  res = resultObject[_index];
686
748
  _item = items_to_save[_index];
687
749
  _item.setSaveResult(res);
688
- _context11.next = 30;
750
+ _context12.next = 30;
689
751
  return _item.onSave();
690
752
  case 30:
691
753
  _index++;
692
- _context11.next = 24;
754
+ _context12.next = 24;
693
755
  break;
694
756
  case 33:
695
757
  index++;
696
- _context11.next = 6;
758
+ _context12.next = 6;
697
759
  break;
698
760
  case 36:
699
761
  _index2 = 0;
700
762
  case 37:
701
763
  if (!(_index2 < itemList.length)) {
702
- _context11.next = 46;
764
+ _context12.next = 46;
703
765
  break;
704
766
  }
705
767
  _item2 = itemList[_index2];
706
768
  if (_item2.isSaved) {
707
- _context11.next = 41;
769
+ _context12.next = 41;
708
770
  break;
709
771
  }
710
- return _context11.abrupt("return", false);
772
+ return _context12.abrupt("return", false);
711
773
  case 41:
712
774
  if (!(_item2.getSaveResultType() != "normal")) {
713
- _context11.next = 43;
775
+ _context12.next = 43;
714
776
  break;
715
777
  }
716
- return _context11.abrupt("return", false);
778
+ return _context12.abrupt("return", false);
717
779
  case 43:
718
780
  _index2++;
719
- _context11.next = 37;
781
+ _context12.next = 37;
720
782
  break;
721
783
  case 46:
722
- return _context11.abrupt("return", true);
784
+ return _context12.abrupt("return", true);
723
785
  case 47:
724
786
  case "end":
725
- return _context11.stop();
787
+ return _context12.stop();
726
788
  }
727
789
  }, _callee11, this);
728
790
  }));
@@ -783,53 +845,53 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
783
845
  fetchID,
784
846
  res,
785
847
  params,
786
- _args12 = arguments;
787
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
788
- while (1) switch (_context12.prev = _context12.next) {
848
+ _args13 = arguments;
849
+ return _regeneratorRuntime().wrap(function _callee12$(_context13) {
850
+ while (1) switch (_context13.prev = _context13.next) {
789
851
  case 0:
790
- for (_len6 = _args12.length, p = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
791
- p[_key6] = _args12[_key6];
852
+ for (_len6 = _args13.length, p = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
853
+ p[_key6] = _args13[_key6];
792
854
  }
793
855
  search = p.shift();
794
856
  readonly = p.shift();
795
857
  fetchID = p.shift();
796
858
  if (!(0, _object.object_isEmpty)(search)) {
797
- _context12.next = 6;
859
+ _context13.next = 6;
798
860
  break;
799
861
  }
800
- return _context12.abrupt("return", undefined);
862
+ return _context13.abrupt("return", undefined);
801
863
  case 6:
802
864
  params = {};
803
865
  params.context = readonly ? "view" : "edit";
804
- _context12.t0 = _typeof(search);
805
- _context12.next = _context12.t0 === "string" ? 11 : _context12.t0 === "number" ? 11 : _context12.t0 === "object" ? 19 : 19;
866
+ _context13.t0 = _typeof(search);
867
+ _context13.next = _context13.t0 === "string" ? 11 : _context13.t0 === "number" ? 11 : _context13.t0 === "object" ? 19 : 19;
806
868
  break;
807
869
  case 11:
808
870
  search = String(search);
809
- _context12.t1 = this;
810
- _context12.t2 = this;
811
- _context12.next = 16;
871
+ _context13.t1 = this;
872
+ _context13.t2 = this;
873
+ _context13.next = 16;
812
874
  return _global.gfunc.run_action("get", this.__web_path + "/" + search, params, {
813
875
  fetchID: fetchID
814
876
  });
815
877
  case 16:
816
- _context12.t3 = _context12.sent;
817
- res = _context12.t1.ensure.call(_context12.t1, _context12.t2, _context12.t3);
818
- return _context12.abrupt("break", 25);
878
+ _context13.t3 = _context13.sent;
879
+ res = _context13.t1.ensure.call(_context13.t1, _context13.t2, _context13.t3);
880
+ return _context13.abrupt("break", 25);
819
881
  case 19:
820
- _context12.t4 = _object.object_first;
821
- _context12.next = 22;
882
+ _context13.t4 = _object.object_first;
883
+ _context13.next = 22;
822
884
  return this.get_list(search, readonly, fetchID);
823
885
  case 22:
824
- _context12.t5 = _context12.sent;
825
- res = (0, _context12.t4)(_context12.t5);
826
- return _context12.abrupt("break", 25);
886
+ _context13.t5 = _context13.sent;
887
+ res = (0, _context13.t4)(_context13.t5);
888
+ return _context13.abrupt("break", 25);
827
889
  case 25:
828
890
  WebObject.setReadonly(res, readonly);
829
- return _context12.abrupt("return", res);
891
+ return _context13.abrupt("return", res);
830
892
  case 27:
831
893
  case "end":
832
- return _context12.stop();
894
+ return _context13.stop();
833
895
  }
834
896
  }, _callee12, this);
835
897
  }));
@@ -855,30 +917,30 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
855
917
  result_items,
856
918
  selftype,
857
919
  res,
858
- _args13 = arguments;
859
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
860
- while (1) switch (_context13.prev = _context13.next) {
920
+ _args14 = arguments;
921
+ return _regeneratorRuntime().wrap(function _callee13$(_context14) {
922
+ while (1) switch (_context14.prev = _context14.next) {
861
923
  case 0:
862
- for (_len7 = _args13.length, p = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
863
- p[_key7] = _args13[_key7];
924
+ for (_len7 = _args14.length, p = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
925
+ p[_key7] = _args14[_key7];
864
926
  }
865
927
  search = p.shift();
866
928
  readonly = p.shift();
867
929
  fetchID = p.shift();
868
930
  if (!search) search = {};
869
- _context13.next = 7;
931
+ _context14.next = 7;
870
932
  return _global.gfunc.run_action("get", this.__web_path, search, {
871
933
  fetchID: fetchID
872
934
  });
873
935
  case 7:
874
- result_items = _context13.sent;
936
+ result_items = _context14.sent;
875
937
  selftype = this.prototype;
876
938
  res = WebObject.map_rowindex(WebObject.mapto(selftype, result_items, readonly));
877
939
  WebObject.setReadonly(res, readonly);
878
- return _context13.abrupt("return", res);
940
+ return _context14.abrupt("return", res);
879
941
  case 12:
880
942
  case "end":
881
- return _context13.stop();
943
+ return _context14.stop();
882
944
  }
883
945
  }, _callee13, this);
884
946
  }));
@@ -894,5 +956,7 @@ exports.WebObject = WebObject;
894
956
  _defineProperty(WebObject, "__web_path", "");
895
957
  _defineProperty(WebObject, "__web_type", "");
896
958
  _defineProperty(WebObject, "__protectedProperties", ["_users"]);
959
+ //you cant create a new weboject without these properties
960
+ _defineProperty(WebObject, "__requiredProperties", []);
897
961
  var _default = WebObject;
898
962
  exports["default"] = _default;
@@ -1,3 +1,4 @@
1
+ import { strAction } from "@azrico/string";
1
2
  import { MapableObject } from "./MapableObject";
2
3
  import ObjectManager from "./ObjectManager";
3
4
  export type saveResultType = "normal" | "nothing" | "error" | "canceled";
@@ -13,6 +14,10 @@ export declare class SimpleObject extends MapableObject {
13
14
  static readonly __changeables?: string[];
14
15
  static readonly __protectedProperties?: string[];
15
16
  static readonly __functionProperties?: string[];
17
+ static readonly __simpleProperties?: string[];
18
+ static readonly __formatList?: {
19
+ [Property in strAction]?: string[];
20
+ };
16
21
  static readonly __extraProperties?: string[];
17
22
  static readonly __childTypes?: any[];
18
23
  static readonly __importColumns?: string[];
@@ -65,16 +70,6 @@ export declare class SimpleObject extends MapableObject {
65
70
  * @returns
66
71
  */
67
72
  setDefault: (key: WriteablePropOf<this>, value: any) => boolean;
68
- /**
69
- * set the value to its original
70
- * @param key
71
- */
72
- reset(key: WriteablePropOf<this>, notifyChanged?: sendChangesType): Promise<boolean>;
73
- /**
74
- * reset all values back to their original
75
- * @param key
76
- */
77
- resetAll(notifyChanged?: sendChangesType): Promise<boolean>;
78
73
  /**
79
74
  * set key of subObject
80
75
  * @param key
@@ -109,8 +104,20 @@ export declare class SimpleObject extends MapableObject {
109
104
  * Apply the changes and empty the delta object
110
105
  */
111
106
  apply_changes(): boolean;
107
+ /**
108
+ * set the value to its original
109
+ * @param key
110
+ */
111
+ reset(key: WriteablePropOf<this>, notifyChanged?: sendChangesType): Promise<boolean>;
112
+ /**
113
+ * reset all values back to their original
114
+ * difference between this and clear_changes is that this function also calls on_change
115
+ * @param key
116
+ */
117
+ resetAll(notifyChanged?: sendChangesType): Promise<boolean>;
112
118
  /**
113
119
  * clear and discard all changes
120
+ * does not call any on_change functions
114
121
  * @returns
115
122
  */
116
123
  clear_changes(): boolean;
@@ -205,85 +205,8 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject) {
205
205
  return _classPrivateMethodGet(this, _setDefaultProperty, _setDefaultProperty2).call(this, key, value);
206
206
  }
207
207
  }, {
208
- key: "reset",
208
+ key: "setSubValue",
209
209
  value:
210
- /**
211
- * set the value to its original
212
- * @param key
213
- */
214
- function () {
215
- var _reset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(key) {
216
- var notifyChanged,
217
- _args2 = arguments;
218
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
219
- while (1) switch (_context2.prev = _context2.next) {
220
- case 0:
221
- notifyChanged = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : "auto";
222
- _context2.next = 3;
223
- return this.setValue(key, this[key], notifyChanged);
224
- case 3:
225
- return _context2.abrupt("return", _context2.sent);
226
- case 4:
227
- case "end":
228
- return _context2.stop();
229
- }
230
- }, _callee2, this);
231
- }));
232
- function reset(_x3) {
233
- return _reset.apply(this, arguments);
234
- }
235
- return reset;
236
- }()
237
- /**
238
- * reset all values back to their original
239
- * @param key
240
- */
241
- }, {
242
- key: "resetAll",
243
- value: function () {
244
- var _resetAll = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
245
- var notifyChanged,
246
- fr,
247
- key,
248
- _args3 = arguments;
249
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
250
- while (1) switch (_context3.prev = _context3.next) {
251
- case 0:
252
- notifyChanged = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : "auto";
253
- fr = true;
254
- _context3.t0 = _regeneratorRuntime().keys(this.__delta);
255
- case 3:
256
- if ((_context3.t1 = _context3.t0()).done) {
257
- _context3.next = 13;
258
- break;
259
- }
260
- key = _context3.t1.value;
261
- _context3.t2 = fr;
262
- if (!_context3.t2) {
263
- _context3.next = 10;
264
- break;
265
- }
266
- _context3.next = 9;
267
- return this.reset(key, notifyChanged);
268
- case 9:
269
- _context3.t2 = _context3.sent;
270
- case 10:
271
- fr = _context3.t2;
272
- _context3.next = 3;
273
- break;
274
- case 13:
275
- return _context3.abrupt("return", fr);
276
- case 14:
277
- case "end":
278
- return _context3.stop();
279
- }
280
- }, _callee3, this);
281
- }));
282
- function resetAll() {
283
- return _resetAll.apply(this, arguments);
284
- }
285
- return resetAll;
286
- }()
287
210
  /**
288
211
  * set key of subObject
289
212
  * @param key
@@ -291,32 +214,30 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject) {
291
214
  * @param subvalue
292
215
  * @return true if changed , false otherwise
293
216
  */
294
- }, {
295
- key: "setSubValue",
296
- value: function () {
297
- var _setSubValue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(key, objKey, subvalue) {
217
+ function () {
218
+ var _setSubValue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(key, objKey, subvalue) {
298
219
  var sendChanges,
299
220
  isValueChanged,
300
221
  subval,
301
- _args4 = arguments;
302
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
303
- while (1) switch (_context4.prev = _context4.next) {
222
+ _args2 = arguments;
223
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
224
+ while (1) switch (_context2.prev = _context2.next) {
304
225
  case 0:
305
- sendChanges = _args4.length > 3 && _args4[3] !== undefined ? _args4[3] : "auto";
226
+ sendChanges = _args2.length > 3 && _args2[3] !== undefined ? _args2[3] : "auto";
306
227
  if (this.canModify) {
307
- _context4.next = 7;
228
+ _context2.next = 7;
308
229
  break;
309
230
  }
310
231
  if (!(this.__throw_errors !== false)) {
311
- _context4.next = 6;
232
+ _context2.next = 6;
312
233
  break;
313
234
  }
314
235
  throw Error("Cant use setValue when on readonly mode");
315
236
  case 6:
316
- return _context4.abrupt("return", false);
237
+ return _context2.abrupt("return", false);
317
238
  case 7:
318
239
  isValueChanged = false;
319
- _context4.prev = 8;
240
+ _context2.prev = 8;
320
241
  //if accessing subval of an object, make sure the object is not null
321
242
  subval = _classPrivateMethodGet(this, _getSubProperty, _getSubProperty2).call(this, key, objKey);
322
243
  if (!(0, _object.object_equals)(subval, subvalue, {
@@ -327,24 +248,24 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject) {
327
248
  isValueChanged = true;
328
249
  } else isValueChanged = false;
329
250
  case 11:
330
- _context4.prev = 11;
251
+ _context2.prev = 11;
331
252
  if (!(sendChanges === true || sendChanges === "auto" && isValueChanged)) {
332
- _context4.next = 15;
253
+ _context2.next = 15;
333
254
  break;
334
255
  }
335
- _context4.next = 15;
256
+ _context2.next = 15;
336
257
  return this.notifyChanged("", key, objKey, subvalue);
337
258
  case 15:
338
- return _context4.finish(11);
259
+ return _context2.finish(11);
339
260
  case 16:
340
- return _context4.abrupt("return", isValueChanged);
261
+ return _context2.abrupt("return", isValueChanged);
341
262
  case 17:
342
263
  case "end":
343
- return _context4.stop();
264
+ return _context2.stop();
344
265
  }
345
- }, _callee4, this, [[8,, 11, 16]]);
266
+ }, _callee2, this, [[8,, 11, 16]]);
346
267
  }));
347
- function setSubValue(_x4, _x5, _x6) {
268
+ function setSubValue(_x3, _x4, _x5) {
348
269
  return _setSubValue.apply(this, arguments);
349
270
  }
350
271
  return setSubValue;
@@ -360,64 +281,64 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject) {
360
281
  * @returns
361
282
  */
362
283
  function () {
363
- var _pushValue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(key, value) {
284
+ var _pushValue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(key, value) {
364
285
  var sendChanges,
365
286
  tempArray,
366
- _args5 = arguments;
367
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
368
- while (1) switch (_context5.prev = _context5.next) {
287
+ _args3 = arguments;
288
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
289
+ while (1) switch (_context3.prev = _context3.next) {
369
290
  case 0:
370
- sendChanges = _args5.length > 2 && _args5[2] !== undefined ? _args5[2] : "auto";
291
+ sendChanges = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : "auto";
371
292
  if (!(value == null)) {
372
- _context5.next = 3;
293
+ _context3.next = 3;
373
294
  break;
374
295
  }
375
- return _context5.abrupt("return", false);
296
+ return _context3.abrupt("return", false);
376
297
  case 3:
377
298
  if (this.canModify) {
378
- _context5.next = 9;
299
+ _context3.next = 9;
379
300
  break;
380
301
  }
381
302
  if (!(this.__throw_errors !== false)) {
382
- _context5.next = 8;
303
+ _context3.next = 8;
383
304
  break;
384
305
  }
385
306
  throw Error("Cant use pushValue when on readonly mode");
386
307
  case 8:
387
- return _context5.abrupt("return", false);
308
+ return _context3.abrupt("return", false);
388
309
  case 9:
389
310
  if (_classPrivateMethodGet(this, _getProperty, _getProperty2).call(this, key) == null) {
390
311
  _classPrivateMethodGet(this, _setProperty, _setProperty2).call(this, key, []);
391
312
  }
392
313
  tempArray = _classPrivateMethodGet(this, _getProperty, _getProperty2).call(this, key);
393
314
  if (Array.isArray(tempArray)) {
394
- _context5.next = 17;
315
+ _context3.next = 17;
395
316
  break;
396
317
  }
397
318
  if (!(this.__throw_errors !== false)) {
398
- _context5.next = 16;
319
+ _context3.next = 16;
399
320
  break;
400
321
  }
401
322
  throw Error("Cant use pushValue on non Array keys");
402
323
  case 16:
403
- return _context5.abrupt("return", false);
324
+ return _context3.abrupt("return", false);
404
325
  case 17:
405
326
  _classPrivateMethodGet(this, _setProperty, _setProperty2).call(this, key, [].concat(_toConsumableArray(tempArray), [value]));
406
327
  if (!(sendChanges === true || sendChanges === "auto")) {
407
- _context5.next = 21;
328
+ _context3.next = 21;
408
329
  break;
409
330
  }
410
- _context5.next = 21;
331
+ _context3.next = 21;
411
332
  return this.notifyChanged("", key, value);
412
333
  case 21:
413
- return _context5.abrupt("return", tempArray);
334
+ return _context3.abrupt("return", tempArray);
414
335
  case 22:
415
336
  case "end":
416
- return _context5.stop();
337
+ return _context3.stop();
417
338
  }
418
- }, _callee5, this);
339
+ }, _callee3, this);
419
340
  }));
420
- function pushValue(_x7, _x8) {
341
+ function pushValue(_x6, _x7) {
421
342
  return _pushValue.apply(this, arguments);
422
343
  }
423
344
  return pushValue;
@@ -425,10 +346,10 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject) {
425
346
  }, {
426
347
  key: "notifyChanged",
427
348
  value: function () {
428
- var _notifyChanged = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(type, key, value, subvalue) {
349
+ var _notifyChanged = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(type, key, value, subvalue) {
429
350
  var lc, manager_class;
430
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
431
- while (1) switch (_context6.prev = _context6.next) {
351
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
352
+ while (1) switch (_context4.prev = _context4.next) {
432
353
  case 0:
433
354
  if (value === undefined && type != "meta") value = this.getValue(key);
434
355
  this.__changed = true;
@@ -443,18 +364,18 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject) {
443
364
  /* --------------------------- notify the manager --------------------------- */
444
365
  manager_class = this.manager;
445
366
  if (!(manager_class instanceof _ObjectManager["default"])) {
446
- _context6.next = 10;
367
+ _context4.next = 10;
447
368
  break;
448
369
  }
449
- _context6.next = 10;
370
+ _context4.next = 10;
450
371
  return manager_class.notifyChanged(type, key, value, subvalue);
451
372
  case 10:
452
373
  case "end":
453
- return _context6.stop();
374
+ return _context4.stop();
454
375
  }
455
- }, _callee6, this);
376
+ }, _callee4, this);
456
377
  }));
457
- function notifyChanged(_x9, _x10, _x11, _x12) {
378
+ function notifyChanged(_x8, _x9, _x10, _x11) {
458
379
  return _notifyChanged.apply(this, arguments);
459
380
  }
460
381
  return notifyChanged;
@@ -494,8 +415,89 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject) {
494
415
  this.clear_changes();
495
416
  }
496
417
  }
418
+ /**
419
+ * set the value to its original
420
+ * @param key
421
+ */
422
+ }, {
423
+ key: "reset",
424
+ value: function () {
425
+ var _reset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(key) {
426
+ var notifyChanged,
427
+ _args5 = arguments;
428
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
429
+ while (1) switch (_context5.prev = _context5.next) {
430
+ case 0:
431
+ notifyChanged = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : "auto";
432
+ _context5.next = 3;
433
+ return this.setValue(key, this[key], notifyChanged);
434
+ case 3:
435
+ return _context5.abrupt("return", _context5.sent);
436
+ case 4:
437
+ case "end":
438
+ return _context5.stop();
439
+ }
440
+ }, _callee5, this);
441
+ }));
442
+ function reset(_x12) {
443
+ return _reset.apply(this, arguments);
444
+ }
445
+ return reset;
446
+ }()
447
+ /**
448
+ * reset all values back to their original
449
+ * difference between this and clear_changes is that this function also calls on_change
450
+ * @param key
451
+ */
452
+ }, {
453
+ key: "resetAll",
454
+ value: function () {
455
+ var _resetAll = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
456
+ var notifyChanged,
457
+ fr,
458
+ key,
459
+ _args6 = arguments;
460
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
461
+ while (1) switch (_context6.prev = _context6.next) {
462
+ case 0:
463
+ notifyChanged = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : "auto";
464
+ fr = true;
465
+ _context6.t0 = _regeneratorRuntime().keys(this.__delta);
466
+ case 3:
467
+ if ((_context6.t1 = _context6.t0()).done) {
468
+ _context6.next = 13;
469
+ break;
470
+ }
471
+ key = _context6.t1.value;
472
+ _context6.t2 = fr;
473
+ if (!_context6.t2) {
474
+ _context6.next = 10;
475
+ break;
476
+ }
477
+ _context6.next = 9;
478
+ return this.reset(key, notifyChanged);
479
+ case 9:
480
+ _context6.t2 = _context6.sent;
481
+ case 10:
482
+ fr = _context6.t2;
483
+ _context6.next = 3;
484
+ break;
485
+ case 13:
486
+ return _context6.abrupt("return", fr);
487
+ case 14:
488
+ case "end":
489
+ return _context6.stop();
490
+ }
491
+ }, _callee6, this);
492
+ }));
493
+ function resetAll() {
494
+ return _resetAll.apply(this, arguments);
495
+ }
496
+ return resetAll;
497
+ }()
497
498
  /**
498
499
  * clear and discard all changes
500
+ * does not call any on_change functions
499
501
  * @returns
500
502
  */
501
503
  }, {
@@ -1082,7 +1084,7 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject) {
1082
1084
  key: "delete_cache",
1083
1085
  value: function delete_cache() {
1084
1086
  if (!this.__cache_name) return;
1085
- _global.gcache.delete_cache(this.__cache_name);
1087
+ _global.gcache.delete_session_cache(this.__cache_name);
1086
1088
  }
1087
1089
  }, {
1088
1090
  key: "get_canModify",
@@ -1173,6 +1175,10 @@ _defineProperty(SimpleObject, "__changeables", void 0);
1173
1175
  _defineProperty(SimpleObject, "__protectedProperties", void 0);
1174
1176
  //these properties will be evaluated when needed
1175
1177
  _defineProperty(SimpleObject, "__functionProperties", void 0);
1178
+ //a lowercase copy of these properties will be saved
1179
+ _defineProperty(SimpleObject, "__simpleProperties", void 0);
1180
+ //apply these string formats
1181
+ _defineProperty(SimpleObject, "__formatList", void 0);
1176
1182
  //these properties usually are not directly changed and sometimes are included in deltaObject
1177
1183
  _defineProperty(SimpleObject, "__extraProperties", void 0);
1178
1184
  //types for children can be used when importing children
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azrico/webobject",
3
- "version": "1.4.53",
3
+ "version": "1.4.55",
4
4
  "description": "Stateful object",
5
5
  "author": "Azrideus",
6
6
  "license": "MIT",
@@ -70,9 +70,9 @@
70
70
  },
71
71
  "dependencies": {
72
72
  "@azrico/event": "^1.2.16",
73
- "@azrico/global": "^1.3.22",
74
- "@azrico/object": "^1.4.56",
75
- "@azrico/string": "^1.2.47",
73
+ "@azrico/global": "^1.3.44",
74
+ "@azrico/object": "^1.4.69",
75
+ "@azrico/string": "^1.2.65",
76
76
  "@azrico/types": "^1.0.1",
77
77
  "@azrico/uid": "^1.0.5"
78
78
  }