@azrico/webobject 1.5.44 → 1.5.46
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.
|
@@ -590,7 +590,7 @@ var WebObject = exports.WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
590
590
|
case 0:
|
|
591
591
|
_parseObj = function _parseObj3() {
|
|
592
592
|
_parseObj = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(key, obj) {
|
|
593
|
-
var _p, keydot, child_changeableKeys, newobj_dlt;
|
|
593
|
+
var _p, _child_changeableKeys, keydot, child_changeableKeys, newobj_dlt;
|
|
594
594
|
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
595
595
|
while (1) switch (_context12.prev = _context12.next) {
|
|
596
596
|
case 0:
|
|
@@ -628,7 +628,7 @@ var WebObject = exports.WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
628
628
|
return _context12.abrupt("return", _context12.sent);
|
|
629
629
|
case 6:
|
|
630
630
|
if (!(obj instanceof WebObject && typeof obj.get_deltaObject === "function")) {
|
|
631
|
-
_context12.next =
|
|
631
|
+
_context12.next = 18;
|
|
632
632
|
break;
|
|
633
633
|
}
|
|
634
634
|
/* -------------------- parse changeableKeys for children -------------------- */
|
|
@@ -637,24 +637,33 @@ var WebObject = exports.WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
637
637
|
return s.startsWith(keydot);
|
|
638
638
|
}).map(function (r) {
|
|
639
639
|
return r.substring(keydot.length);
|
|
640
|
-
});
|
|
641
|
-
|
|
640
|
+
});
|
|
641
|
+
/**
|
|
642
|
+
* if no key is set for children consider it as undefined
|
|
643
|
+
* if we send the empty array to get_delta we get no keys
|
|
644
|
+
*/
|
|
645
|
+
if (child_changeableKeys == null || ((_child_changeableKeys = child_changeableKeys) === null || _child_changeableKeys === void 0 ? void 0 : _child_changeableKeys.length) === 0) {
|
|
646
|
+
child_changeableKeys = undefined;
|
|
647
|
+
}
|
|
648
|
+
/* -------------------------------------------------------------------------- */
|
|
649
|
+
//child elements have different kind of delta
|
|
650
|
+
_context12.next = 12;
|
|
642
651
|
return obj.get_deltaObject(_objectSpread(_objectSpread({}, p), {}, {
|
|
643
652
|
isChild: true,
|
|
644
653
|
changeableKeys: child_changeableKeys
|
|
645
654
|
}));
|
|
646
|
-
case
|
|
655
|
+
case 12:
|
|
647
656
|
newobj_dlt = _context12.sent;
|
|
648
657
|
if ((0, _object.object_isEmpty)(newobj_dlt)) {
|
|
649
|
-
_context12.next =
|
|
658
|
+
_context12.next = 17;
|
|
650
659
|
break;
|
|
651
660
|
}
|
|
652
661
|
return _context12.abrupt("return", newobj_dlt);
|
|
653
|
-
case 16:
|
|
654
|
-
return _context12.abrupt("return", obj);
|
|
655
662
|
case 17:
|
|
656
663
|
return _context12.abrupt("return", obj);
|
|
657
664
|
case 18:
|
|
665
|
+
return _context12.abrupt("return", obj);
|
|
666
|
+
case 19:
|
|
658
667
|
case "end":
|
|
659
668
|
return _context12.stop();
|
|
660
669
|
}
|
|
@@ -282,7 +282,7 @@ export declare class SimpleObject extends MapableObject {
|
|
|
282
282
|
* @param result_object
|
|
283
283
|
* @returns
|
|
284
284
|
*/
|
|
285
|
-
static isResultValid(result_object: any,
|
|
285
|
+
static isResultValid(result_object: any, depth?: number): boolean;
|
|
286
286
|
/**
|
|
287
287
|
* set the response of last save from site
|
|
288
288
|
* and its type
|
|
@@ -1479,18 +1479,43 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
1479
1479
|
}, {
|
|
1480
1480
|
key: "isResultValid",
|
|
1481
1481
|
value: function isResultValid(result_object) {
|
|
1482
|
-
var
|
|
1482
|
+
var _this4 = this;
|
|
1483
|
+
var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
1483
1484
|
if ((0, _object.object_isEmpty)(result_object)) return false;
|
|
1484
1485
|
switch (_typeof(result_object)) {
|
|
1486
|
+
case "string":
|
|
1487
|
+
try {
|
|
1488
|
+
result_object = JSON.parse(result_object);
|
|
1489
|
+
return this.isResultValid(result_object);
|
|
1490
|
+
} catch (_unused) {
|
|
1491
|
+
return false;
|
|
1492
|
+
}
|
|
1493
|
+
case "number":
|
|
1494
|
+
return result_object > 0;
|
|
1495
|
+
case "boolean":
|
|
1496
|
+
return result_object === true;
|
|
1485
1497
|
case "object":
|
|
1486
1498
|
/* ----------------------------- result is error ---------------------------- */
|
|
1487
1499
|
if (result_object instanceof Error) {
|
|
1488
1500
|
return false;
|
|
1489
1501
|
}
|
|
1490
|
-
/*
|
|
1502
|
+
/* ----------------- maybe website sends the result as array ---------------- */
|
|
1491
1503
|
if (Array.isArray(result_object)) {
|
|
1492
|
-
if (
|
|
1493
|
-
|
|
1504
|
+
if (depth > 0) return false; //avoid going too deep
|
|
1505
|
+
var allResults = result_object.map(function (r) {
|
|
1506
|
+
return Boolean(_this4.isResultValid(r, depth + 1));
|
|
1507
|
+
});
|
|
1508
|
+
return allResults.find(function (s) {
|
|
1509
|
+
return s === false;
|
|
1510
|
+
}) == null;
|
|
1511
|
+
}
|
|
1512
|
+
/* ----------------------------- check products ----------------------------- */
|
|
1513
|
+
if (result_object.products) {
|
|
1514
|
+
/**
|
|
1515
|
+
* if one product is not valid the result is not valid
|
|
1516
|
+
* but if all products are valid we still need to check the object itself
|
|
1517
|
+
*/
|
|
1518
|
+
if (!this.isResultValid(result_object.products, depth + 1)) return false;
|
|
1494
1519
|
}
|
|
1495
1520
|
/* -------------------------- check if acknowledged ------------------------- */
|
|
1496
1521
|
if ((0, _object.object_isTrue)(result_object.acknowledged)) {
|
|
@@ -1500,17 +1525,6 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
1500
1525
|
return (0, _object.object_equals)(result_object.expected, result_object.result);
|
|
1501
1526
|
}
|
|
1502
1527
|
return !(0, _string.string_isEmpty)(this.getID(result_object));
|
|
1503
|
-
case "string":
|
|
1504
|
-
try {
|
|
1505
|
-
result_object = JSON.parse(result_object);
|
|
1506
|
-
return this.isResultValid(result_object);
|
|
1507
|
-
} catch (_unused) {
|
|
1508
|
-
return false;
|
|
1509
|
-
}
|
|
1510
|
-
case "number":
|
|
1511
|
-
return result_object > 0;
|
|
1512
|
-
case "boolean":
|
|
1513
|
-
return result_object === true;
|
|
1514
1528
|
}
|
|
1515
1529
|
return false;
|
|
1516
1530
|
}
|