@azrico/webobject 1.4.35 → 1.4.36

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.
@@ -80,12 +80,6 @@ export declare class WebObject extends SimpleObject {
80
80
  onNew(...p: any): Promise<any>;
81
81
  saveResultHasID(s: any): any;
82
82
  static saveResultHasID(s: any): any;
83
- /**
84
- * check if the web result of a save action is acknowledged
85
- * @param result_object
86
- * @returns
87
- */
88
- static isResultValid(result_object: any): boolean;
89
83
  /**
90
84
  * Load Id and _index_value from the given save result into our object
91
85
  * @param o
@@ -712,20 +712,6 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
712
712
  if (_typeof(s) !== "object" || s == null || !s) return false;
713
713
  return s.insertedId || s._id || s._index_value && !Number.isNaN(s._index_value);
714
714
  }
715
- /**
716
- * check if the web result of a save action is acknowledged
717
- * @param result_object
718
- * @returns
719
- */
720
- }, {
721
- key: "isResultValid",
722
- value: function isResultValid(result_object) {
723
- if ((0, _object.object_isEmpty)(result_object)) return false;
724
- if ((0, _object.object_isTrue)(result_object.acknowledged)) {
725
- return true;
726
- }
727
- return false;
728
- }
729
715
  /**
730
716
  * Load Id and _index_value from the given save result into our object
731
717
  * @param o
@@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports["default"] = exports.SimpleObject = void 0;
7
7
  var _object = require("@azrico/object");
8
+ var _string = require("@azrico/string");
8
9
  var _global = require("@azrico/global");
9
10
  var _MapableObject2 = require("./MapableObject");
10
11
  var _ObjectManager = _interopRequireDefault(require("./ObjectManager"));
11
- var _string = require("@azrico/string");
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
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); }
14
14
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
@@ -795,11 +795,7 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject) {
795
795
  */
796
796
  function setSaveResult(toObj) {
797
797
  var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "auto";
798
- if (toObj != null) {
799
- _classPrivateMethodGet(this, _setSaveResultObject, _setSaveResultObject2).call(this, toObj);
800
- } else {
801
- _classPrivateMethodGet(this, _setSaveResultObject, _setSaveResultObject2).call(this, null);
802
- }
798
+ _classPrivateMethodGet(this, _setSaveResultObject, _setSaveResultObject2).call(this, toObj);
803
799
  //check if the given object is a valid save result
804
800
  if (type === "error") this.__saveResultIsSuccess = false;else this.__saveResultIsSuccess = Boolean(type === "nothing" || this.constructor["isResultValid"](toObj));
805
801
  if (type === "auto") {
@@ -1044,13 +1040,19 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject) {
1044
1040
  return false;
1045
1041
  }
1046
1042
  case "object":
1043
+ /* --------- maybe website sends the result as array with 1 element --------- */
1044
+ if (Array.isArray(result_object)) {
1045
+ if (sub) return false; //avoid going too deep
1046
+ return this.isResultValid((0, _object.array_first)(result_object), true);
1047
+ }
1048
+ /* -------------------------- check if acknowledged ------------------------- */
1047
1049
  if ((0, _object.object_isTrue)(result_object.acknowledged)) {
1048
1050
  return true;
1049
1051
  }
1050
1052
  if (result_object.expected && result_object.result) {
1051
1053
  return (0, _object.object_equals)(result_object.expected, result_object.result);
1052
1054
  }
1053
- return Number(this.getID(result_object)) >= 0;
1055
+ return !(0, _string.string_isEmpty)(this.getID(result_object));
1054
1056
  case "number":
1055
1057
  return result_object > 0;
1056
1058
  case "boolean":
@@ -1144,6 +1146,7 @@ function _setTempProperty2(key, value) {
1144
1146
  this.__temp[key] = value;
1145
1147
  }
1146
1148
  function _setSaveResultObject2(toObj) {
1149
+ if (toObj == null) toObj = null; //null or undefined
1147
1150
  this.__saveResultObject = toObj;
1148
1151
  }
1149
1152
  _defineProperty(SimpleObject, "__cache_name", void 0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azrico/webobject",
3
- "version": "1.4.35",
3
+ "version": "1.4.36",
4
4
  "description": "Stateful object",
5
5
  "author": "Azrideus",
6
6
  "license": "MIT",