@azrico/webobject 1.4.60 → 1.4.62

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.
@@ -1,12 +1,12 @@
1
1
  import SimpleObject, { sendChangesType } from "../structs/SimpleObject";
2
- import MetaObject from "../structs/MetaObject";
3
- import WebObjectManager from "./WebObjectManager";
2
+ import { MetaObject, WebObjectManager } from "../index";
4
3
  export type deltaParams = {
5
4
  type?: string;
6
5
  isChild?: boolean;
7
6
  useDelta?: boolean;
8
7
  allProperties?: boolean;
9
8
  extraProperties?: boolean;
9
+ applyFilter?: boolean;
10
10
  };
11
11
  export declare class WebObject extends SimpleObject {
12
12
  static readonly __web_path: string;
@@ -75,15 +75,6 @@ export declare class WebObject extends SimpleObject {
75
75
  Delete(): Promise<boolean>;
76
76
  canSave(deltaObj?: any): true | string;
77
77
  deltaIsValid(d: any): true | string;
78
- /**
79
- * filter fields of the delta object and prepare them for saving into db
80
- * this is usually used on SERVER after client sends get_deltaObject result to them
81
- * so server parses the deltaObject again to make sure data is not broken during send
82
- * @param inputobject
83
- * @param p
84
- * @returns
85
- */
86
- filterDeltaObject(inputobject: any, p?: deltaParams): Promise<any>;
87
78
  /**
88
79
  * You will post this to the server for saving
89
80
  * automatically removes unchangable fields
@@ -8,6 +8,7 @@ var _SimpleObject2 = _interopRequireDefault(require("../structs/SimpleObject"));
8
8
  var _object = require("@azrico/object");
9
9
  var _string = require("@azrico/string");
10
10
  var _global = require("@azrico/global");
11
+ var _convertHelper = _interopRequireDefault(require("@azrico/convert-helper"));
11
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
12
13
  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); }
13
14
  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; } } }; }
@@ -196,44 +197,6 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
196
197
  value: function deltaIsValid(d) {
197
198
  return true;
198
199
  }
199
- /**
200
- * filter fields of the delta object and prepare them for saving into db
201
- * this is usually used on SERVER after client sends get_deltaObject result to them
202
- * so server parses the deltaObject again to make sure data is not broken during send
203
- * @param inputobject
204
- * @param p
205
- * @returns
206
- */
207
- }, {
208
- key: "filterDeltaObject",
209
- value: function () {
210
- var _filterDeltaObject = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(inputobject, p) {
211
- var tempusers;
212
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
213
- while (1) switch (_context3.prev = _context3.next) {
214
- case 0:
215
- /* -------------------------------------------------------------------------- */
216
- /* fix _user property */
217
- /* -------------------------------------------------------------------------- */
218
- if (inputobject["_users"]) {
219
- tempusers = inputobject["_users"];
220
- if (typeof tempusers === "string") tempusers = tempusers.split(",").filter(function (s) {
221
- return s;
222
- });
223
- inputobject["_users"] = (0, _object.wrap_array)(tempusers);
224
- }
225
- return _context3.abrupt("return", inputobject);
226
- case 2:
227
- case "end":
228
- return _context3.stop();
229
- }
230
- }, _callee3);
231
- }));
232
- function filterDeltaObject(_x, _x2) {
233
- return _filterDeltaObject.apply(this, arguments);
234
- }
235
- return filterDeltaObject;
236
- }()
237
200
  /**
238
201
  * You will post this to the server for saving
239
202
  * automatically removes unchangable fields
@@ -242,79 +205,79 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
242
205
  }, {
243
206
  key: "get_deltaObject",
244
207
  value: function () {
245
- var _get_deltaObject = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(p) {
208
+ var _get_deltaObject = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(p) {
246
209
  var _this2 = this;
247
- var final_object, isChild, useDelta, allProperties, chkChangables, useExtraProps, dlt, allkeys, changableKeys, functionProps, index, fp, formats, use_formats, simpleProps, _loop, formatname, parseObj, _parseObj, _iterator, _step, key;
248
- return _regeneratorRuntime().wrap(function _callee6$(_context7) {
249
- while (1) switch (_context7.prev = _context7.next) {
210
+ var final_object, isChild, useDelta, allProperties, chkChangables, useExtraProps, dlt, allkeys, changableKeys, functionProps, index, fp, parseObj, _parseObj, _iterator, _step, key, tempusers;
211
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
212
+ while (1) switch (_context5.prev = _context5.next) {
250
213
  case 0:
251
214
  _parseObj = function _parseObj3() {
252
- _parseObj = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(obj) {
215
+ _parseObj = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(obj) {
253
216
  var newobj_dlt;
254
- return _regeneratorRuntime().wrap(function _callee5$(_context6) {
255
- while (1) switch (_context6.prev = _context6.next) {
217
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
218
+ while (1) switch (_context4.prev = _context4.next) {
256
219
  case 0:
257
220
  if (!(obj == null)) {
258
- _context6.next = 2;
221
+ _context4.next = 2;
259
222
  break;
260
223
  }
261
- return _context6.abrupt("return", undefined);
224
+ return _context4.abrupt("return", undefined);
262
225
  case 2:
263
226
  if (!Array.isArray(obj)) {
264
- _context6.next = 6;
227
+ _context4.next = 6;
265
228
  break;
266
229
  }
267
- _context6.next = 5;
230
+ _context4.next = 5;
268
231
  return Promise.all(obj.map( /*#__PURE__*/function () {
269
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(r) {
270
- return _regeneratorRuntime().wrap(function _callee4$(_context5) {
271
- while (1) switch (_context5.prev = _context5.next) {
232
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(r) {
233
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
234
+ while (1) switch (_context3.prev = _context3.next) {
272
235
  case 0:
273
- _context5.next = 2;
236
+ _context3.next = 2;
274
237
  return parseObj(r);
275
238
  case 2:
276
- return _context5.abrupt("return", _context5.sent);
239
+ return _context3.abrupt("return", _context3.sent);
277
240
  case 3:
278
241
  case "end":
279
- return _context5.stop();
242
+ return _context3.stop();
280
243
  }
281
- }, _callee4);
244
+ }, _callee3);
282
245
  }));
283
- return function (_x5) {
246
+ return function (_x3) {
284
247
  return _ref.apply(this, arguments);
285
248
  };
286
249
  }()));
287
250
  case 5:
288
- return _context6.abrupt("return", _context6.sent);
251
+ return _context4.abrupt("return", _context4.sent);
289
252
  case 6:
290
253
  if (!(obj instanceof WebObject && typeof obj.get_deltaObject === "function")) {
291
- _context6.next = 15;
254
+ _context4.next = 15;
292
255
  break;
293
256
  }
294
- _context6.next = 9;
257
+ _context4.next = 9;
295
258
  return obj.get_deltaObject(_objectSpread(_objectSpread({}, p), {}, {
296
259
  isChild: true
297
260
  }));
298
261
  case 9:
299
- newobj_dlt = _context6.sent;
262
+ newobj_dlt = _context4.sent;
300
263
  if ((0, _object.object_isEmpty)(newobj_dlt)) {
301
- _context6.next = 14;
264
+ _context4.next = 14;
302
265
  break;
303
266
  }
304
- return _context6.abrupt("return", newobj_dlt);
267
+ return _context4.abrupt("return", newobj_dlt);
305
268
  case 14:
306
- return _context6.abrupt("return", obj);
269
+ return _context4.abrupt("return", obj);
307
270
  case 15:
308
- return _context6.abrupt("return", obj);
271
+ return _context4.abrupt("return", obj);
309
272
  case 16:
310
273
  case "end":
311
- return _context6.stop();
274
+ return _context4.stop();
312
275
  }
313
- }, _callee5);
276
+ }, _callee4);
314
277
  }));
315
278
  return _parseObj.apply(this, arguments);
316
279
  };
317
- parseObj = function _parseObj2(_x4) {
280
+ parseObj = function _parseObj2(_x2) {
318
281
  return _parseObj.apply(this, arguments);
319
282
  };
320
283
  if (!p) p = {};
@@ -332,6 +295,9 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
332
295
  ignoreProtected: allProperties
333
296
  });
334
297
  }) : allkeys;
298
+ _context5.next = 14;
299
+ return _convertHelper["default"].applyFormats(dlt, (0, _object.object_getStatic)(this, "__formatList"), changableKeys);
300
+ case 14:
335
301
  /* -------------------------------------------------------------------------- */
336
302
  /* __functionProperties */
337
303
  /* -------------------------------------------------------------------------- */
@@ -343,90 +309,36 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
343
309
  }
344
310
  }
345
311
  /* -------------------------------------------------------------------------- */
346
- /* __formatList */
347
- /* -------------------------------------------------------------------------- */
348
- formats = (0, _object.object_getStatic)(this, "__formatList");
349
- if (!formats) {
350
- _context7.next = 27;
351
- break;
352
- }
353
- use_formats = _objectSpread({}, formats);
354
- simpleProps = (0, _object.wrap_array)(use_formats.simple);
355
- delete use_formats.simple;
356
- _loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop(formatname) {
357
- var formatKeys;
358
- return _regeneratorRuntime().wrap(function _loop$(_context4) {
359
- while (1) switch (_context4.prev = _context4.next) {
360
- case 0:
361
- formatKeys = use_formats[formatname];
362
- if (Array.isArray(formatKeys)) {
363
- formatKeys.forEach(function (fk) {
364
- if (typeof dlt[fk] === "number") dlt[fk] = String(dlt[fk]);
365
- if (typeof dlt[fk] !== "string") return;
366
- dlt[fk] = (0, _string.string_do)(formatname, dlt[fk]);
367
- });
368
- }
369
- case 2:
370
- case "end":
371
- return _context4.stop();
372
- }
373
- }, _loop);
374
- });
375
- _context7.t0 = _regeneratorRuntime().keys(use_formats);
376
- case 21:
377
- if ((_context7.t1 = _context7.t0()).done) {
378
- _context7.next = 26;
379
- break;
380
- }
381
- formatname = _context7.t1.value;
382
- return _context7.delegateYield(_loop(formatname), "t2", 24);
383
- case 24:
384
- _context7.next = 21;
385
- break;
386
- case 26:
387
- /* -------------------------------------------------------------------------- */
388
- /* __simpleProperties */
312
+ /* parse all changableKeys */
389
313
  /* -------------------------------------------------------------------------- */
390
- if (Array.isArray(simpleProps)) {
391
- simpleProps.forEach(function (sp) {
392
- if (dlt[sp] == null) return;
393
- var oldValue = dlt[sp];
394
- var newKey = "simple_" + sp;
395
- var newValue = typeof oldValue === "string" ? (0, _string.convert_to_simple_string)(oldValue) : undefined;
396
- dlt[newKey] = newValue;
397
- //make sure we include this key in delta!
398
- changableKeys.push(newKey);
399
- });
400
- }
401
- case 27:
402
314
  _iterator = _createForOfIteratorHelper(changableKeys);
403
- _context7.prev = 28;
315
+ _context5.prev = 17;
404
316
  _iterator.s();
405
- case 30:
317
+ case 19:
406
318
  if ((_step = _iterator.n()).done) {
407
- _context7.next = 37;
319
+ _context5.next = 26;
408
320
  break;
409
321
  }
410
322
  key = _step.value;
411
- _context7.next = 34;
323
+ _context5.next = 23;
412
324
  return parseObj(dlt[key]);
413
- case 34:
414
- final_object[key] = _context7.sent;
415
- case 35:
416
- _context7.next = 30;
325
+ case 23:
326
+ final_object[key] = _context5.sent;
327
+ case 24:
328
+ _context5.next = 19;
417
329
  break;
418
- case 37:
419
- _context7.next = 42;
330
+ case 26:
331
+ _context5.next = 31;
420
332
  break;
421
- case 39:
422
- _context7.prev = 39;
423
- _context7.t3 = _context7["catch"](28);
424
- _iterator.e(_context7.t3);
425
- case 42:
426
- _context7.prev = 42;
333
+ case 28:
334
+ _context5.prev = 28;
335
+ _context5.t0 = _context5["catch"](17);
336
+ _iterator.e(_context5.t0);
337
+ case 31:
338
+ _context5.prev = 31;
427
339
  _iterator.f();
428
- return _context7.finish(42);
429
- case 45:
340
+ return _context5.finish(31);
341
+ case 34:
430
342
  /* -------------------------------------------------------------------------- */
431
343
  /* add id properties */
432
344
  /* -------------------------------------------------------------------------- */
@@ -436,17 +348,24 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
436
348
  final_object["_index_value"] = this.getIndex();
437
349
  final_object["_created_date"] = this["_created_date"];
438
350
  }
439
- _context7.next = 48;
440
- return this.filterDeltaObject(final_object, p);
441
- case 48:
442
- return _context7.abrupt("return", _context7.sent);
443
- case 49:
351
+ /* -------------------------------------------------------------------------- */
352
+ /* fix _user property */
353
+ /* -------------------------------------------------------------------------- */
354
+ if (final_object["_users"]) {
355
+ tempusers = final_object["_users"];
356
+ if (typeof tempusers === "string") tempusers = tempusers.split(",").filter(function (s) {
357
+ return s;
358
+ });
359
+ final_object["_users"] = (0, _object.wrap_array)(tempusers);
360
+ }
361
+ return _context5.abrupt("return", final_object);
362
+ case 37:
444
363
  case "end":
445
- return _context7.stop();
364
+ return _context5.stop();
446
365
  }
447
- }, _callee6, this, [[28, 39, 42, 45]]);
366
+ }, _callee5, this, [[17, 28, 31, 34]]);
448
367
  }));
449
- function get_deltaObject(_x3) {
368
+ function get_deltaObject(_x) {
450
369
  return _get_deltaObject.apply(this, arguments);
451
370
  }
452
371
  return get_deltaObject;
@@ -470,28 +389,28 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
470
389
  }, {
471
390
  key: "onDelete",
472
391
  value: function () {
473
- var _onDelete = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
392
+ var _onDelete = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
474
393
  var _this$manager;
475
394
  var _len,
476
395
  p,
477
396
  _key,
478
- _args8 = arguments;
479
- return _regeneratorRuntime().wrap(function _callee7$(_context8) {
480
- while (1) switch (_context8.prev = _context8.next) {
397
+ _args6 = arguments;
398
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
399
+ while (1) switch (_context6.prev = _context6.next) {
481
400
  case 0:
482
401
  this.isDeleted = true;
483
- for (_len = _args8.length, p = new Array(_len), _key = 0; _key < _len; _key++) {
484
- p[_key] = _args8[_key];
402
+ for (_len = _args6.length, p = new Array(_len), _key = 0; _key < _len; _key++) {
403
+ p[_key] = _args6[_key];
485
404
  }
486
- _context8.next = 4;
405
+ _context6.next = 4;
487
406
  return (_this$manager = this.manager) === null || _this$manager === void 0 ? void 0 : _this$manager.onDelete.apply(_this$manager, p);
488
407
  case 4:
489
- return _context8.abrupt("return", _context8.sent);
408
+ return _context6.abrupt("return", _context6.sent);
490
409
  case 5:
491
410
  case "end":
492
- return _context8.stop();
411
+ return _context6.stop();
493
412
  }
494
- }, _callee7, this);
413
+ }, _callee6, this);
495
414
  }));
496
415
  function onDelete() {
497
416
  return _onDelete.apply(this, arguments);
@@ -501,28 +420,28 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
501
420
  }, {
502
421
  key: "onLoad",
503
422
  value: function () {
504
- var _onLoad = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
423
+ var _onLoad = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
505
424
  var _this$manager2;
506
425
  var _len2,
507
426
  p,
508
427
  _key2,
509
- _args9 = arguments;
510
- return _regeneratorRuntime().wrap(function _callee8$(_context9) {
511
- while (1) switch (_context9.prev = _context9.next) {
428
+ _args7 = arguments;
429
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
430
+ while (1) switch (_context7.prev = _context7.next) {
512
431
  case 0:
513
432
  this.isDeleted = false;
514
- for (_len2 = _args9.length, p = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
515
- p[_key2] = _args9[_key2];
433
+ for (_len2 = _args7.length, p = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
434
+ p[_key2] = _args7[_key2];
516
435
  }
517
- _context9.next = 4;
436
+ _context7.next = 4;
518
437
  return (_this$manager2 = this.manager) === null || _this$manager2 === void 0 ? void 0 : _this$manager2.onLoad.apply(_this$manager2, p);
519
438
  case 4:
520
- return _context9.abrupt("return", _context9.sent);
439
+ return _context7.abrupt("return", _context7.sent);
521
440
  case 5:
522
441
  case "end":
523
- return _context9.stop();
442
+ return _context7.stop();
524
443
  }
525
- }, _callee8, this);
444
+ }, _callee7, this);
526
445
  }));
527
446
  function onLoad() {
528
447
  return _onLoad.apply(this, arguments);
@@ -532,47 +451,47 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
532
451
  }, {
533
452
  key: "onSave",
534
453
  value: function () {
535
- var _onSave = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
454
+ var _onSave = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
536
455
  var _this$manager4;
537
456
  var srObject,
538
457
  _this$manager3,
539
458
  _len3,
540
459
  p,
541
460
  _key3,
542
- _args10 = arguments;
543
- return _regeneratorRuntime().wrap(function _callee9$(_context10) {
544
- while (1) switch (_context10.prev = _context10.next) {
461
+ _args8 = arguments;
462
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
463
+ while (1) switch (_context8.prev = _context8.next) {
545
464
  case 0:
546
465
  if (!this.isSaved) {
547
- _context10.next = 7;
466
+ _context8.next = 7;
548
467
  break;
549
468
  }
550
469
  this.apply_changes();
551
470
  srObject = this.getSaveResult(true);
552
471
  if (!this.saveResultHasID(srObject)) {
553
- _context10.next = 7;
472
+ _context8.next = 7;
554
473
  break;
555
474
  }
556
475
  /* -------------------------------------------------------------------------- */
557
476
  WebObject.LoadIdsFromSaveResult(this, srObject);
558
- _context10.next = 7;
477
+ _context8.next = 7;
559
478
  return (_this$manager3 = this.manager) === null || _this$manager3 === void 0 ? void 0 : _this$manager3.event_run("on_id_change");
560
479
  case 7:
561
- for (_len3 = _args10.length, p = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
562
- p[_key3] = _args10[_key3];
480
+ for (_len3 = _args8.length, p = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
481
+ p[_key3] = _args8[_key3];
563
482
  }
564
- _context10.next = 10;
483
+ _context8.next = 10;
565
484
  return (_this$manager4 = this.manager) === null || _this$manager4 === void 0 ? void 0 : _this$manager4.onSave.apply(_this$manager4, p);
566
485
  case 10:
567
- _context10.next = 12;
486
+ _context8.next = 12;
568
487
  return this.onAfterSave();
569
488
  case 12:
570
- return _context10.abrupt("return", true);
489
+ return _context8.abrupt("return", true);
571
490
  case 13:
572
491
  case "end":
573
- return _context10.stop();
492
+ return _context8.stop();
574
493
  }
575
- }, _callee9, this);
494
+ }, _callee8, this);
576
495
  }));
577
496
  function onSave() {
578
497
  return _onSave.apply(this, arguments);
@@ -582,27 +501,27 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
582
501
  }, {
583
502
  key: "onAfterSave",
584
503
  value: function () {
585
- var _onAfterSave = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
504
+ var _onAfterSave = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
586
505
  var _this$manager5;
587
506
  var _len4,
588
507
  p,
589
508
  _key4,
590
- _args11 = arguments;
591
- return _regeneratorRuntime().wrap(function _callee10$(_context11) {
592
- while (1) switch (_context11.prev = _context11.next) {
509
+ _args9 = arguments;
510
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
511
+ while (1) switch (_context9.prev = _context9.next) {
593
512
  case 0:
594
- for (_len4 = _args11.length, p = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
595
- p[_key4] = _args11[_key4];
513
+ for (_len4 = _args9.length, p = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
514
+ p[_key4] = _args9[_key4];
596
515
  }
597
- _context11.next = 3;
516
+ _context9.next = 3;
598
517
  return (_this$manager5 = this.manager) === null || _this$manager5 === void 0 ? void 0 : _this$manager5.onAfterSave.apply(_this$manager5, p);
599
518
  case 3:
600
- return _context11.abrupt("return", true);
519
+ return _context9.abrupt("return", true);
601
520
  case 4:
602
521
  case "end":
603
- return _context11.stop();
522
+ return _context9.stop();
604
523
  }
605
- }, _callee10, this);
524
+ }, _callee9, this);
606
525
  }));
607
526
  function onAfterSave() {
608
527
  return _onAfterSave.apply(this, arguments);
@@ -627,27 +546,27 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
627
546
  }, {
628
547
  key: "onNew",
629
548
  value: function () {
630
- var _onNew = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
549
+ var _onNew = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
631
550
  var _this$manager6;
632
551
  var _len5,
633
552
  p,
634
553
  _key5,
635
- _args12 = arguments;
636
- return _regeneratorRuntime().wrap(function _callee11$(_context12) {
637
- while (1) switch (_context12.prev = _context12.next) {
554
+ _args10 = arguments;
555
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
556
+ while (1) switch (_context10.prev = _context10.next) {
638
557
  case 0:
639
- for (_len5 = _args12.length, p = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
640
- p[_key5] = _args12[_key5];
558
+ for (_len5 = _args10.length, p = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
559
+ p[_key5] = _args10[_key5];
641
560
  }
642
- _context12.next = 3;
561
+ _context10.next = 3;
643
562
  return (_this$manager6 = this.manager) === null || _this$manager6 === void 0 ? void 0 : _this$manager6.onNew.apply(_this$manager6, p);
644
563
  case 3:
645
- return _context12.abrupt("return", _context12.sent);
564
+ return _context10.abrupt("return", _context10.sent);
646
565
  case 4:
647
566
  case "end":
648
- return _context12.stop();
567
+ return _context10.stop();
649
568
  }
650
- }, _callee11, this);
569
+ }, _callee10, this);
651
570
  }));
652
571
  function onNew() {
653
572
  return _onNew.apply(this, arguments);
@@ -710,7 +629,7 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
710
629
  }, {
711
630
  key: "saveList",
712
631
  value: function () {
713
- var _saveList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(itemList) {
632
+ var _saveList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(itemList) {
714
633
  var _extraOptions$chunksi;
715
634
  var extraOptions,
716
635
  chunks,
@@ -727,11 +646,11 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
727
646
  _item,
728
647
  _index2,
729
648
  _item2,
730
- _args13 = arguments;
731
- return _regeneratorRuntime().wrap(function _callee12$(_context13) {
732
- while (1) switch (_context13.prev = _context13.next) {
649
+ _args11 = arguments;
650
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
651
+ while (1) switch (_context11.prev = _context11.next) {
733
652
  case 0:
734
- extraOptions = _args13.length > 1 && _args13[1] !== undefined ? _args13[1] : {};
653
+ extraOptions = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : {};
735
654
  if (!extraOptions) extraOptions = {};
736
655
  chunks = (0, _object.array_chunks)(itemList, (_extraOptions$chunksi = extraOptions.chunksize) !== null && _extraOptions$chunksi !== void 0 ? _extraOptions$chunksi : 50);
737
656
  delete extraOptions.chunksize;
@@ -739,7 +658,7 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
739
658
  index = 0;
740
659
  case 6:
741
660
  if (!(index < chunks.length)) {
742
- _context13.next = 36;
661
+ _context11.next = 36;
743
662
  break;
744
663
  }
745
664
  items_to_save = chunks[index];
@@ -747,83 +666,83 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
747
666
  k = 0;
748
667
  case 10:
749
668
  if (!(k < items_to_save.length)) {
750
- _context13.next = 19;
669
+ _context11.next = 19;
751
670
  break;
752
671
  }
753
672
  item = items_to_save[k];
754
- _context13.next = 14;
673
+ _context11.next = 14;
755
674
  return item.get_deltaObject();
756
675
  case 14:
757
- dlt = _context13.sent;
676
+ dlt = _context11.sent;
758
677
  save_array.push(item.isNew ? _objectSpread({}, dlt) : _objectSpread({
759
678
  _id: item.getID()
760
679
  }, dlt));
761
680
  case 16:
762
681
  k++;
763
- _context13.next = 10;
682
+ _context11.next = 10;
764
683
  break;
765
684
  case 19:
766
- _context13.next = 21;
685
+ _context11.next = 21;
767
686
  return _global.gfunc.run_action("post", putAddress, _objectSpread({
768
687
  __save_list: WebObject.zipSaveList(save_array)
769
688
  }, extraOptions));
770
689
  case 21:
771
- resultObject = _context13.sent;
690
+ resultObject = _context11.sent;
772
691
  if (!Array.isArray(resultObject)) {
773
- _context13.next = 33;
692
+ _context11.next = 33;
774
693
  break;
775
694
  }
776
695
  _index = 0;
777
696
  case 24:
778
697
  if (!(_index < Math.min(resultObject.length, items_to_save.length))) {
779
- _context13.next = 33;
698
+ _context11.next = 33;
780
699
  break;
781
700
  }
782
701
  res = resultObject[_index];
783
702
  _item = items_to_save[_index];
784
703
  _item.setSaveResult(res);
785
- _context13.next = 30;
704
+ _context11.next = 30;
786
705
  return _item.onSave();
787
706
  case 30:
788
707
  _index++;
789
- _context13.next = 24;
708
+ _context11.next = 24;
790
709
  break;
791
710
  case 33:
792
711
  index++;
793
- _context13.next = 6;
712
+ _context11.next = 6;
794
713
  break;
795
714
  case 36:
796
715
  _index2 = 0;
797
716
  case 37:
798
717
  if (!(_index2 < itemList.length)) {
799
- _context13.next = 46;
718
+ _context11.next = 46;
800
719
  break;
801
720
  }
802
721
  _item2 = itemList[_index2];
803
722
  if (_item2.isSaved) {
804
- _context13.next = 41;
723
+ _context11.next = 41;
805
724
  break;
806
725
  }
807
- return _context13.abrupt("return", false);
726
+ return _context11.abrupt("return", false);
808
727
  case 41:
809
728
  if (!(_item2.getSaveResultType() != "normal")) {
810
- _context13.next = 43;
729
+ _context11.next = 43;
811
730
  break;
812
731
  }
813
- return _context13.abrupt("return", false);
732
+ return _context11.abrupt("return", false);
814
733
  case 43:
815
734
  _index2++;
816
- _context13.next = 37;
735
+ _context11.next = 37;
817
736
  break;
818
737
  case 46:
819
- return _context13.abrupt("return", true);
738
+ return _context11.abrupt("return", true);
820
739
  case 47:
821
740
  case "end":
822
- return _context13.stop();
741
+ return _context11.stop();
823
742
  }
824
- }, _callee12, this);
743
+ }, _callee11, this);
825
744
  }));
826
- function saveList(_x6) {
745
+ function saveList(_x4) {
827
746
  return _saveList.apply(this, arguments);
828
747
  }
829
748
  return saveList;
@@ -871,7 +790,7 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
871
790
  }, {
872
791
  key: "get_single",
873
792
  value: function () {
874
- var _get_single = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
793
+ var _get_single = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
875
794
  var _len6,
876
795
  p,
877
796
  _key6,
@@ -880,55 +799,55 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
880
799
  fetchID,
881
800
  res,
882
801
  params,
883
- _args14 = arguments;
884
- return _regeneratorRuntime().wrap(function _callee13$(_context14) {
885
- while (1) switch (_context14.prev = _context14.next) {
802
+ _args12 = arguments;
803
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
804
+ while (1) switch (_context12.prev = _context12.next) {
886
805
  case 0:
887
- for (_len6 = _args14.length, p = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
888
- p[_key6] = _args14[_key6];
806
+ for (_len6 = _args12.length, p = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
807
+ p[_key6] = _args12[_key6];
889
808
  }
890
809
  search = p.shift();
891
810
  readonly = p.shift();
892
811
  fetchID = p.shift();
893
812
  if (!(0, _object.object_isEmpty)(search)) {
894
- _context14.next = 6;
813
+ _context12.next = 6;
895
814
  break;
896
815
  }
897
- return _context14.abrupt("return", undefined);
816
+ return _context12.abrupt("return", undefined);
898
817
  case 6:
899
818
  params = {};
900
819
  params.context = readonly ? "view" : "edit";
901
- _context14.t0 = _typeof(search);
902
- _context14.next = _context14.t0 === "string" ? 11 : _context14.t0 === "number" ? 11 : _context14.t0 === "object" ? 19 : 19;
820
+ _context12.t0 = _typeof(search);
821
+ _context12.next = _context12.t0 === "string" ? 11 : _context12.t0 === "number" ? 11 : _context12.t0 === "object" ? 19 : 19;
903
822
  break;
904
823
  case 11:
905
824
  search = String(search);
906
- _context14.t1 = this;
907
- _context14.t2 = this;
908
- _context14.next = 16;
825
+ _context12.t1 = this;
826
+ _context12.t2 = this;
827
+ _context12.next = 16;
909
828
  return _global.gfunc.run_action("get", this.__web_path + "/" + search, params, {
910
829
  fetchID: fetchID
911
830
  });
912
831
  case 16:
913
- _context14.t3 = _context14.sent;
914
- res = _context14.t1.ensure.call(_context14.t1, _context14.t2, _context14.t3);
915
- return _context14.abrupt("break", 25);
832
+ _context12.t3 = _context12.sent;
833
+ res = _context12.t1.ensure.call(_context12.t1, _context12.t2, _context12.t3);
834
+ return _context12.abrupt("break", 25);
916
835
  case 19:
917
- _context14.t4 = _object.object_first;
918
- _context14.next = 22;
836
+ _context12.t4 = _object.object_first;
837
+ _context12.next = 22;
919
838
  return this.get_list(search, readonly, fetchID);
920
839
  case 22:
921
- _context14.t5 = _context14.sent;
922
- res = (0, _context14.t4)(_context14.t5);
923
- return _context14.abrupt("break", 25);
840
+ _context12.t5 = _context12.sent;
841
+ res = (0, _context12.t4)(_context12.t5);
842
+ return _context12.abrupt("break", 25);
924
843
  case 25:
925
844
  WebObject.setReadonly(res, readonly);
926
- return _context14.abrupt("return", res);
845
+ return _context12.abrupt("return", res);
927
846
  case 27:
928
847
  case "end":
929
- return _context14.stop();
848
+ return _context12.stop();
930
849
  }
931
- }, _callee13, this);
850
+ }, _callee12, this);
932
851
  }));
933
852
  function get_single() {
934
853
  return _get_single.apply(this, arguments);
@@ -942,7 +861,7 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
942
861
  }, {
943
862
  key: "get_list",
944
863
  value: function () {
945
- var _get_list = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
864
+ var _get_list = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
946
865
  var _len7,
947
866
  p,
948
867
  _key7,
@@ -952,32 +871,32 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
952
871
  result_items,
953
872
  selftype,
954
873
  res,
955
- _args15 = arguments;
956
- return _regeneratorRuntime().wrap(function _callee14$(_context15) {
957
- while (1) switch (_context15.prev = _context15.next) {
874
+ _args13 = arguments;
875
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
876
+ while (1) switch (_context13.prev = _context13.next) {
958
877
  case 0:
959
- for (_len7 = _args15.length, p = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
960
- p[_key7] = _args15[_key7];
878
+ for (_len7 = _args13.length, p = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
879
+ p[_key7] = _args13[_key7];
961
880
  }
962
881
  search = p.shift();
963
882
  readonly = p.shift();
964
883
  fetchID = p.shift();
965
884
  if (!search) search = {};
966
- _context15.next = 7;
885
+ _context13.next = 7;
967
886
  return _global.gfunc.run_action("get", this.__web_path, search, {
968
887
  fetchID: fetchID
969
888
  });
970
889
  case 7:
971
- result_items = _context15.sent;
890
+ result_items = _context13.sent;
972
891
  selftype = this.prototype;
973
892
  res = WebObject.map_rowindex(WebObject.mapto(selftype, result_items, readonly));
974
893
  WebObject.setReadonly(res, readonly);
975
- return _context15.abrupt("return", res);
894
+ return _context13.abrupt("return", res);
976
895
  case 12:
977
896
  case "end":
978
- return _context15.stop();
897
+ return _context13.stop();
979
898
  }
980
- }, _callee14, this);
899
+ }, _callee13, this);
981
900
  }));
982
901
  function get_list() {
983
902
  return _get_list.apply(this, arguments);
@@ -1,4 +1,4 @@
1
- import { strAction } from "@azrico/string";
1
+ import { convObject } from "@azrico/convert-helper";
2
2
  import { MapableObject } from "./MapableObject";
3
3
  import ObjectManager from "./ObjectManager";
4
4
  export type saveResultType = "normal" | "nothing" | "error" | "canceled";
@@ -14,9 +14,7 @@ export declare class SimpleObject extends MapableObject {
14
14
  static readonly __changeables?: string[];
15
15
  static readonly __protectedProperties?: string[];
16
16
  static readonly __functionProperties?: string[];
17
- static readonly __formatList?: {
18
- [Property in strAction]?: string[];
19
- };
17
+ static readonly __formatList?: convObject;
20
18
  static readonly __extraProperties?: string[];
21
19
  static readonly __childTypes?: any[];
22
20
  static readonly __importColumns?: string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azrico/webobject",
3
- "version": "1.4.60",
3
+ "version": "1.4.62",
4
4
  "description": "Stateful object",
5
5
  "author": "Azrideus",
6
6
  "license": "MIT",
@@ -61,18 +61,22 @@
61
61
  "dist"
62
62
  ],
63
63
  "peerDependencies": {
64
+ "@azrico/convert-helper": "*",
64
65
  "@azrico/event": "*",
65
66
  "@azrico/global": "*",
67
+ "@azrico/math": "*",
66
68
  "@azrico/object": "*",
67
69
  "@azrico/string": "*",
68
- "@azrico/uid": "*",
69
- "lodash.clonedeep": "*"
70
+ "@azrico/types": "*",
71
+ "@azrico/uid": "*"
70
72
  },
71
73
  "dependencies": {
74
+ "@azrico/convert-helper": "^1.0.2",
72
75
  "@azrico/event": "^1.2.16",
73
76
  "@azrico/global": "^1.3.44",
74
- "@azrico/object": "^1.4.69",
75
- "@azrico/string": "^1.2.65",
77
+ "@azrico/math": "^1.0.3",
78
+ "@azrico/object": "^1.4.70",
79
+ "@azrico/string": "^1.2.70",
76
80
  "@azrico/types": "^1.0.1",
77
81
  "@azrico/uid": "^1.0.5"
78
82
  }