@azrico/webobject 1.4.35 → 1.4.37

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; }
@@ -161,6 +161,7 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject) {
161
161
  _context.prev = 8;
162
162
  oldval = this.getValue(key);
163
163
  if (!(0, _object.object_equals)(oldval, value, {
164
+ strictArrayCheck: true,
164
165
  ignoredStartingWords: "_"
165
166
  })) {
166
167
  _classPrivateMethodGet(this, _setProperty, _setProperty2).call(this, key, value);
@@ -795,11 +796,7 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject) {
795
796
  */
796
797
  function setSaveResult(toObj) {
797
798
  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
- }
799
+ _classPrivateMethodGet(this, _setSaveResultObject, _setSaveResultObject2).call(this, toObj);
803
800
  //check if the given object is a valid save result
804
801
  if (type === "error") this.__saveResultIsSuccess = false;else this.__saveResultIsSuccess = Boolean(type === "nothing" || this.constructor["isResultValid"](toObj));
805
802
  if (type === "auto") {
@@ -1044,13 +1041,19 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject) {
1044
1041
  return false;
1045
1042
  }
1046
1043
  case "object":
1044
+ /* --------- maybe website sends the result as array with 1 element --------- */
1045
+ if (Array.isArray(result_object)) {
1046
+ if (sub) return false; //avoid going too deep
1047
+ return this.isResultValid((0, _object.array_first)(result_object), true);
1048
+ }
1049
+ /* -------------------------- check if acknowledged ------------------------- */
1047
1050
  if ((0, _object.object_isTrue)(result_object.acknowledged)) {
1048
1051
  return true;
1049
1052
  }
1050
1053
  if (result_object.expected && result_object.result) {
1051
1054
  return (0, _object.object_equals)(result_object.expected, result_object.result);
1052
1055
  }
1053
- return Number(this.getID(result_object)) >= 0;
1056
+ return !(0, _string.string_isEmpty)(this.getID(result_object));
1054
1057
  case "number":
1055
1058
  return result_object > 0;
1056
1059
  case "boolean":
@@ -1144,6 +1147,7 @@ function _setTempProperty2(key, value) {
1144
1147
  this.__temp[key] = value;
1145
1148
  }
1146
1149
  function _setSaveResultObject2(toObj) {
1150
+ if (toObj == null) toObj = null; //null or undefined
1147
1151
  this.__saveResultObject = toObj;
1148
1152
  }
1149
1153
  _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.37",
4
4
  "description": "Stateful object",
5
5
  "author": "Azrideus",
6
6
  "license": "MIT",
@@ -71,8 +71,8 @@
71
71
  "dependencies": {
72
72
  "@azrico/event": "^1.2.15",
73
73
  "@azrico/global": "^1.3.22",
74
- "@azrico/object": "^1.4.41",
75
- "@azrico/string": "^1.2.32",
74
+ "@azrico/object": "^1.4.54",
75
+ "@azrico/string": "^1.2.47",
76
76
  "@azrico/uid": "^1.0.5"
77
77
  }
78
78
  }