@azrico/webobject 1.4.34 → 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.
|
@@ -52,7 +52,7 @@ export declare class WebObject extends SimpleObject {
|
|
|
52
52
|
*/
|
|
53
53
|
static getMetaValue(o: WebObject | null | undefined, key: string): any;
|
|
54
54
|
static zipSaveList(svlist: any): string;
|
|
55
|
-
static unzipSaveList(svlist: any): any;
|
|
55
|
+
static unzipSaveList(svlist: any): any[];
|
|
56
56
|
static saveList(itemList: WebObject[], extraOptions?: {
|
|
57
57
|
[key: string]: any;
|
|
58
58
|
}): Promise<boolean>;
|
|
@@ -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
|
|
@@ -576,11 +576,9 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
576
576
|
if (_typeof(svlist) === "object") {
|
|
577
577
|
if (Array.isArray(svlist)) return svlist;
|
|
578
578
|
if (svlist.__save_list) return this.unzipSaveList(svlist.__save_list);
|
|
579
|
-
|
|
580
|
-
}
|
|
581
|
-
if (typeof svlist === "string") return JSON.parse((0, _string.string_decompress)(svlist));
|
|
579
|
+
} else if (typeof svlist === "string") return (0, _object.wrap_array)(JSON.parse((0, _string.string_decompress)(svlist)));
|
|
582
580
|
} catch (_unused) {}
|
|
583
|
-
return svlist;
|
|
581
|
+
return (0, _object.wrap_array)(svlist);
|
|
584
582
|
}
|
|
585
583
|
}, {
|
|
586
584
|
key: "saveList",
|
|
@@ -714,20 +712,6 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
714
712
|
if (_typeof(s) !== "object" || s == null || !s) return false;
|
|
715
713
|
return s.insertedId || s._id || s._index_value && !Number.isNaN(s._index_value);
|
|
716
714
|
}
|
|
717
|
-
/**
|
|
718
|
-
* check if the web result of a save action is acknowledged
|
|
719
|
-
* @param result_object
|
|
720
|
-
* @returns
|
|
721
|
-
*/
|
|
722
|
-
}, {
|
|
723
|
-
key: "isResultValid",
|
|
724
|
-
value: function isResultValid(result_object) {
|
|
725
|
-
if ((0, _object.object_isEmpty)(result_object)) return false;
|
|
726
|
-
if ((0, _object.object_isTrue)(result_object.acknowledged)) {
|
|
727
|
-
return true;
|
|
728
|
-
}
|
|
729
|
-
return false;
|
|
730
|
-
}
|
|
731
715
|
/**
|
|
732
716
|
* Load Id and _index_value from the given save result into our object
|
|
733
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
|
-
|
|
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
|
|
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);
|