@azrico/webobject 1.2.18 → 1.2.19
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.
- package/dist/index.js +18 -1
- package/dist/src/WebObjects/ParentWebObject.js +94 -13
- package/dist/src/WebObjects/WebObject.js +740 -220
- package/dist/src/WebObjects/WebObjectManager.js +351 -74
- package/dist/src/index.js +109 -8
- package/dist/src/structs/DummyObject.js +54 -8
- package/dist/src/structs/MapableObject.js +141 -72
- package/dist/src/structs/MetaObject.js +171 -35
- package/dist/src/structs/ObjectArray.js +84 -43
- package/dist/src/structs/ObjectManager.js +657 -202
- package/dist/src/structs/SimpleObject.js +1010 -580
- package/package.json +1 -1
|
@@ -1,598 +1,1028 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
__saveResultObject;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = exports.SimpleObject = void 0;
|
|
7
|
+
|
|
8
|
+
var _global = require("@azrico/global");
|
|
9
|
+
|
|
10
|
+
var _object = require("@azrico/object");
|
|
11
|
+
|
|
12
|
+
var _MapableObject2 = require("./MapableObject");
|
|
13
|
+
|
|
14
|
+
var _ObjectManager = _interopRequireDefault(require("./ObjectManager"));
|
|
15
|
+
|
|
16
|
+
var _string = require("@azrico/string");
|
|
17
|
+
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
|
+
|
|
20
|
+
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); }
|
|
21
|
+
|
|
22
|
+
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; }
|
|
23
|
+
|
|
24
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
25
|
+
|
|
26
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
27
|
+
|
|
28
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
29
|
+
|
|
30
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
31
|
+
|
|
32
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
33
|
+
|
|
34
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
35
|
+
|
|
36
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
37
|
+
|
|
38
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
39
|
+
|
|
40
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
41
|
+
|
|
42
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
43
|
+
|
|
44
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
45
|
+
|
|
46
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
47
|
+
|
|
48
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
49
|
+
|
|
50
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
51
|
+
|
|
52
|
+
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
|
53
|
+
|
|
54
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
55
|
+
|
|
56
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
57
|
+
|
|
58
|
+
function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
|
|
59
|
+
|
|
60
|
+
var _setSubProperty = /*#__PURE__*/new WeakSet();
|
|
61
|
+
|
|
62
|
+
var _getSubProperty = /*#__PURE__*/new WeakSet();
|
|
63
|
+
|
|
64
|
+
var _setProperty = /*#__PURE__*/new WeakSet();
|
|
65
|
+
|
|
66
|
+
var _setDefaultProperty = /*#__PURE__*/new WeakSet();
|
|
67
|
+
|
|
68
|
+
var _getProperty = /*#__PURE__*/new WeakSet();
|
|
69
|
+
|
|
70
|
+
var _setSaveResultObject = /*#__PURE__*/new WeakSet();
|
|
71
|
+
|
|
72
|
+
var SimpleObject = /*#__PURE__*/function (_MapableObject) {
|
|
73
|
+
_inherits(SimpleObject, _MapableObject);
|
|
74
|
+
|
|
75
|
+
var _super = _createSuper(SimpleObject);
|
|
76
|
+
|
|
77
|
+
function SimpleObject() {
|
|
78
|
+
var _this;
|
|
79
|
+
|
|
80
|
+
var is_readonly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
81
|
+
|
|
82
|
+
_classCallCheck(this, SimpleObject);
|
|
83
|
+
|
|
84
|
+
_this = _super.call(this);
|
|
85
|
+
|
|
86
|
+
_classPrivateMethodInitSpec(_assertThisInitialized(_this), _setSaveResultObject);
|
|
87
|
+
|
|
88
|
+
_classPrivateMethodInitSpec(_assertThisInitialized(_this), _getProperty);
|
|
89
|
+
|
|
90
|
+
_classPrivateMethodInitSpec(_assertThisInitialized(_this), _setDefaultProperty);
|
|
91
|
+
|
|
92
|
+
_classPrivateMethodInitSpec(_assertThisInitialized(_this), _setProperty);
|
|
93
|
+
|
|
94
|
+
_classPrivateMethodInitSpec(_assertThisInitialized(_this), _getSubProperty);
|
|
95
|
+
|
|
96
|
+
_classPrivateMethodInitSpec(_assertThisInitialized(_this), _setSubProperty);
|
|
97
|
+
|
|
98
|
+
_defineProperty(_assertThisInitialized(_this), "__originalobject", void 0);
|
|
99
|
+
|
|
100
|
+
_defineProperty(_assertThisInitialized(_this), "__delta", void 0);
|
|
101
|
+
|
|
102
|
+
_defineProperty(_assertThisInitialized(_this), "__changed", false);
|
|
103
|
+
|
|
104
|
+
_defineProperty(_assertThisInitialized(_this), "__lastChanged", "");
|
|
105
|
+
|
|
106
|
+
_defineProperty(_assertThisInitialized(_this), "__is_readonly", void 0);
|
|
107
|
+
|
|
108
|
+
_defineProperty(_assertThisInitialized(_this), "__throw_errors", void 0);
|
|
109
|
+
|
|
110
|
+
_defineProperty(_assertThisInitialized(_this), "__errors", void 0);
|
|
111
|
+
|
|
112
|
+
_defineProperty(_assertThisInitialized(_this), "__showErrors", void 0);
|
|
113
|
+
|
|
114
|
+
_defineProperty(_assertThisInitialized(_this), "__saveResultObject", void 0);
|
|
115
|
+
|
|
116
|
+
_defineProperty(_assertThisInitialized(_this), "__saveResultIsSuccess", void 0);
|
|
117
|
+
|
|
118
|
+
_defineProperty(_assertThisInitialized(_this), "__saveResultType", null);
|
|
119
|
+
|
|
120
|
+
_defineProperty(_assertThisInitialized(_this), "_index_key", "");
|
|
121
|
+
|
|
122
|
+
_defineProperty(_assertThisInitialized(_this), "_index_value", -1);
|
|
123
|
+
|
|
124
|
+
_defineProperty(_assertThisInitialized(_this), "getValue", _classPrivateMethodGet(_assertThisInitialized(_this), _getProperty, _getProperty2));
|
|
125
|
+
|
|
126
|
+
_defineProperty(_assertThisInitialized(_this), "get", _classPrivateMethodGet(_assertThisInitialized(_this), _getProperty, _getProperty2));
|
|
127
|
+
|
|
128
|
+
_defineProperty(_assertThisInitialized(_this), "set", _this.setValue);
|
|
129
|
+
|
|
130
|
+
_defineProperty(_assertThisInitialized(_this), "setDefault", _this.setDefaultValue);
|
|
131
|
+
|
|
132
|
+
_defineProperty(_assertThisInitialized(_this), "get_managerClass", function () {
|
|
133
|
+
return null;
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
_this.__delta = {};
|
|
137
|
+
_this.__is_readonly = is_readonly;
|
|
138
|
+
_this.__throw_errors = true;
|
|
139
|
+
|
|
140
|
+
_this.clear_changes();
|
|
141
|
+
|
|
142
|
+
return _this;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
_createClass(SimpleObject, [{
|
|
146
|
+
key: "_static",
|
|
147
|
+
value: function _static() {
|
|
148
|
+
return this.constructor;
|
|
149
|
+
}
|
|
150
|
+
}, {
|
|
151
|
+
key: "loadValues",
|
|
152
|
+
value:
|
|
153
|
+
/* -------------------------------------------------------------------------- */
|
|
154
|
+
|
|
155
|
+
/* Load */
|
|
156
|
+
|
|
157
|
+
/* -------------------------------------------------------------------------- */
|
|
158
|
+
function loadValues(initObject) {
|
|
159
|
+
var fullUpdate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
160
|
+
return SimpleObject.loadValues(this, initObject, fullUpdate);
|
|
161
|
+
}
|
|
162
|
+
}, {
|
|
163
|
+
key: "setValue",
|
|
164
|
+
value:
|
|
122
165
|
/**
|
|
123
166
|
* set value
|
|
124
167
|
* @param key
|
|
125
168
|
* @param value
|
|
126
169
|
* @return true if changed , false otherwise
|
|
127
|
-
*/
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
170
|
+
*/
|
|
171
|
+
function () {
|
|
172
|
+
var _setValue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(key, value) {
|
|
173
|
+
var sendChanges,
|
|
174
|
+
isValueChanged,
|
|
175
|
+
oldval,
|
|
176
|
+
_args = arguments;
|
|
177
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
178
|
+
while (1) {
|
|
179
|
+
switch (_context.prev = _context.next) {
|
|
180
|
+
case 0:
|
|
181
|
+
sendChanges = _args.length > 2 && _args[2] !== undefined ? _args[2] : "auto";
|
|
182
|
+
|
|
183
|
+
if (this.canModify) {
|
|
184
|
+
_context.next = 7;
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (!this.__throw_errors) {
|
|
189
|
+
_context.next = 6;
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
throw Error("Cant use setValue when on readonly mode");
|
|
194
|
+
|
|
195
|
+
case 6:
|
|
196
|
+
return _context.abrupt("return", false);
|
|
197
|
+
|
|
198
|
+
case 7:
|
|
199
|
+
isValueChanged = false;
|
|
200
|
+
_context.prev = 8;
|
|
201
|
+
oldval = this.getValue(key);
|
|
202
|
+
|
|
203
|
+
if (!(0, _object.object_equals)(oldval, value, {
|
|
204
|
+
ignoredStartingWords: "_"
|
|
205
|
+
})) {
|
|
206
|
+
_classPrivateMethodGet(this, _setProperty, _setProperty2).call(this, key, value);
|
|
207
|
+
|
|
208
|
+
isValueChanged = true;
|
|
209
|
+
} else isValueChanged = false; //console.log("SV:", isValueChanged, oldval, key, value);
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
case 11:
|
|
213
|
+
_context.prev = 11;
|
|
214
|
+
|
|
215
|
+
if (!(sendChanges === true || sendChanges === "auto" && isValueChanged)) {
|
|
216
|
+
_context.next = 15;
|
|
217
|
+
break;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
_context.next = 15;
|
|
221
|
+
return this.notifyChanged("", String(key), value);
|
|
222
|
+
|
|
223
|
+
case 15:
|
|
224
|
+
return _context.finish(11);
|
|
225
|
+
|
|
226
|
+
case 16:
|
|
227
|
+
return _context.abrupt("return", isValueChanged);
|
|
228
|
+
|
|
229
|
+
case 17:
|
|
230
|
+
case "end":
|
|
231
|
+
return _context.stop();
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}, _callee, this, [[8,, 11, 16]]);
|
|
235
|
+
}));
|
|
236
|
+
|
|
237
|
+
function setValue(_x, _x2) {
|
|
238
|
+
return _setValue.apply(this, arguments);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return setValue;
|
|
242
|
+
}()
|
|
243
|
+
}, {
|
|
244
|
+
key: "setDefaultValue",
|
|
245
|
+
value: function setDefaultValue(key, value) {
|
|
246
|
+
return _classPrivateMethodGet(this, _setDefaultProperty, _setDefaultProperty2).call(this, key, value);
|
|
247
|
+
}
|
|
248
|
+
}, {
|
|
249
|
+
key: "setSubValue",
|
|
250
|
+
value:
|
|
159
251
|
/**
|
|
160
252
|
* set key of subObject
|
|
161
253
|
* @param key
|
|
162
254
|
* @param value
|
|
163
255
|
* @param subvalue
|
|
164
256
|
* @return true if changed , false otherwise
|
|
165
|
-
*/
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
(
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
257
|
+
*/
|
|
258
|
+
function () {
|
|
259
|
+
var _setSubValue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(key, objKey, subvalue) {
|
|
260
|
+
var sendChanges,
|
|
261
|
+
isValueChanged,
|
|
262
|
+
subval,
|
|
263
|
+
_args2 = arguments;
|
|
264
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
265
|
+
while (1) {
|
|
266
|
+
switch (_context2.prev = _context2.next) {
|
|
267
|
+
case 0:
|
|
268
|
+
sendChanges = _args2.length > 3 && _args2[3] !== undefined ? _args2[3] : "auto";
|
|
269
|
+
|
|
270
|
+
if (this.canModify) {
|
|
271
|
+
_context2.next = 7;
|
|
272
|
+
break;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
if (!this.__throw_errors) {
|
|
276
|
+
_context2.next = 6;
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
throw Error("Cant use setValue when on readonly mode");
|
|
281
|
+
|
|
282
|
+
case 6:
|
|
283
|
+
return _context2.abrupt("return", false);
|
|
284
|
+
|
|
285
|
+
case 7:
|
|
286
|
+
isValueChanged = false;
|
|
287
|
+
_context2.prev = 8;
|
|
288
|
+
//if accessing subval of an object, make sure the object is not null
|
|
289
|
+
subval = _classPrivateMethodGet(this, _getSubProperty, _getSubProperty2).call(this, key, objKey);
|
|
290
|
+
|
|
291
|
+
if (!(0, _object.object_equals)(subval, subvalue, {
|
|
292
|
+
ignoredStartingWords: "_"
|
|
293
|
+
})) {
|
|
294
|
+
_classPrivateMethodGet(this, _setSubProperty, _setSubProperty2).call(this, key, objKey, subvalue);
|
|
295
|
+
|
|
296
|
+
isValueChanged = true;
|
|
297
|
+
} else isValueChanged = false;
|
|
298
|
+
|
|
299
|
+
case 11:
|
|
300
|
+
_context2.prev = 11;
|
|
301
|
+
|
|
302
|
+
if (!(sendChanges === true || sendChanges === "auto" && isValueChanged)) {
|
|
303
|
+
_context2.next = 15;
|
|
304
|
+
break;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
_context2.next = 15;
|
|
308
|
+
return this.notifyChanged("", String(key), objKey, subvalue);
|
|
309
|
+
|
|
310
|
+
case 15:
|
|
311
|
+
return _context2.finish(11);
|
|
312
|
+
|
|
313
|
+
case 16:
|
|
314
|
+
return _context2.abrupt("return", isValueChanged);
|
|
315
|
+
|
|
316
|
+
case 17:
|
|
317
|
+
case "end":
|
|
318
|
+
return _context2.stop();
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}, _callee2, this, [[8,, 11, 16]]);
|
|
322
|
+
}));
|
|
323
|
+
|
|
324
|
+
function setSubValue(_x3, _x4, _x5) {
|
|
325
|
+
return _setSubValue.apply(this, arguments);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
return setSubValue;
|
|
329
|
+
}() //Push value on array
|
|
330
|
+
|
|
331
|
+
}, {
|
|
332
|
+
key: "pushValue",
|
|
333
|
+
value: function () {
|
|
334
|
+
var _pushValue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(key, value) {
|
|
335
|
+
var sendChanges,
|
|
336
|
+
tempArray,
|
|
337
|
+
_args3 = arguments;
|
|
338
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
339
|
+
while (1) {
|
|
340
|
+
switch (_context3.prev = _context3.next) {
|
|
341
|
+
case 0:
|
|
342
|
+
sendChanges = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : "auto";
|
|
343
|
+
|
|
344
|
+
if (!(value == null)) {
|
|
345
|
+
_context3.next = 3;
|
|
346
|
+
break;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
return _context3.abrupt("return", false);
|
|
350
|
+
|
|
351
|
+
case 3:
|
|
352
|
+
if (this.canModify) {
|
|
353
|
+
_context3.next = 9;
|
|
354
|
+
break;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
if (!this.__throw_errors) {
|
|
358
|
+
_context3.next = 8;
|
|
359
|
+
break;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
throw Error("Cant use pushValue when on readonly mode");
|
|
363
|
+
|
|
364
|
+
case 8:
|
|
365
|
+
return _context3.abrupt("return", false);
|
|
366
|
+
|
|
367
|
+
case 9:
|
|
368
|
+
if (_classPrivateMethodGet(this, _getProperty, _getProperty2).call(this, key) == null) {
|
|
369
|
+
_classPrivateMethodGet(this, _setProperty, _setProperty2).call(this, key, this.getValue(key));
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
tempArray = _classPrivateMethodGet(this, _getProperty, _getProperty2).call(this, key);
|
|
373
|
+
|
|
374
|
+
if (Array.isArray(tempArray)) {
|
|
375
|
+
_context3.next = 17;
|
|
376
|
+
break;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
if (!this.__throw_errors) {
|
|
380
|
+
_context3.next = 16;
|
|
381
|
+
break;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
throw Error("Cant use pushValue on non Array keys");
|
|
385
|
+
|
|
386
|
+
case 16:
|
|
387
|
+
return _context3.abrupt("return", false);
|
|
388
|
+
|
|
389
|
+
case 17:
|
|
390
|
+
tempArray.push(value);
|
|
391
|
+
|
|
392
|
+
_classPrivateMethodGet(this, _setProperty, _setProperty2).call(this, key, tempArray);
|
|
393
|
+
|
|
394
|
+
if (!(sendChanges === true || sendChanges === "auto")) {
|
|
395
|
+
_context3.next = 22;
|
|
396
|
+
break;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
_context3.next = 22;
|
|
400
|
+
return this.notifyChanged("", String(key), value);
|
|
401
|
+
|
|
402
|
+
case 22:
|
|
403
|
+
return _context3.abrupt("return", tempArray);
|
|
404
|
+
|
|
405
|
+
case 23:
|
|
406
|
+
case "end":
|
|
407
|
+
return _context3.stop();
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}, _callee3, this);
|
|
411
|
+
}));
|
|
412
|
+
|
|
413
|
+
function pushValue(_x6, _x7) {
|
|
414
|
+
return _pushValue.apply(this, arguments);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
return pushValue;
|
|
418
|
+
}()
|
|
419
|
+
}, {
|
|
420
|
+
key: "notifyChanged",
|
|
421
|
+
value: function () {
|
|
422
|
+
var _notifyChanged = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(type, key, value, subvalue) {
|
|
423
|
+
var lc, manager_class;
|
|
424
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
425
|
+
while (1) {
|
|
426
|
+
switch (_context4.prev = _context4.next) {
|
|
427
|
+
case 0:
|
|
428
|
+
if (value === undefined && type != "meta") value = this.getValue(key);
|
|
429
|
+
this.__changed = true;
|
|
430
|
+
lc = "";
|
|
431
|
+
if (type) lc += "[".concat(String(type), "] ");
|
|
432
|
+
|
|
433
|
+
if (subvalue) {
|
|
434
|
+
lc += "".concat(String(key), "->").concat(value, " = ").concat(subvalue);
|
|
435
|
+
} else {
|
|
436
|
+
lc += "".concat(String(key), " = ").concat(value);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
this.__lastChanged = lc;
|
|
440
|
+
/* --------------------------- notify the manager --------------------------- */
|
|
441
|
+
|
|
442
|
+
manager_class = this.get_managerClass();
|
|
443
|
+
|
|
444
|
+
if (!(manager_class instanceof _ObjectManager["default"])) {
|
|
445
|
+
_context4.next = 10;
|
|
446
|
+
break;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
_context4.next = 10;
|
|
450
|
+
return manager_class.notifyChanged(type, key, value, subvalue);
|
|
451
|
+
|
|
452
|
+
case 10:
|
|
453
|
+
case "end":
|
|
454
|
+
return _context4.stop();
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
}, _callee4, this);
|
|
458
|
+
}));
|
|
459
|
+
|
|
460
|
+
function notifyChanged(_x8, _x9, _x10, _x11) {
|
|
461
|
+
return _notifyChanged.apply(this, arguments);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
return notifyChanged;
|
|
465
|
+
}()
|
|
466
|
+
}, {
|
|
467
|
+
key: "apply_changes",
|
|
468
|
+
value:
|
|
469
|
+
/* -------------------------------------------------------------------------- */
|
|
470
|
+
|
|
471
|
+
/* Changes */
|
|
472
|
+
|
|
473
|
+
/* -------------------------------------------------------------------------- */
|
|
474
|
+
|
|
260
475
|
/**
|
|
261
476
|
* Apply the changes and empty the delta object
|
|
262
|
-
*/
|
|
263
|
-
apply_changes() {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
this
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
477
|
+
*/
|
|
478
|
+
function apply_changes() {
|
|
479
|
+
if (!this.__use_delta) {
|
|
480
|
+
console.warn("you cant use apply_changes if you are not using Delta mode");
|
|
481
|
+
return false;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
if (!this.isChanged) {
|
|
485
|
+
console.warn("No changes to apply");
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
for (var key in this.__delta) {
|
|
489
|
+
var nv = this.__delta[key];
|
|
490
|
+
this[key] = nv;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
this.clear_changes();
|
|
494
|
+
}
|
|
495
|
+
}, {
|
|
496
|
+
key: "clear_changes",
|
|
497
|
+
value: function clear_changes() {
|
|
498
|
+
this.__delta = {};
|
|
499
|
+
this.__changed = false;
|
|
500
|
+
}
|
|
281
501
|
/**
|
|
282
502
|
* Sets readonly property on given objects
|
|
283
503
|
* @param objs array of given objects or a single object
|
|
284
504
|
* @param readonlyval readonly
|
|
285
505
|
* @param clearChanges should we clean the changes after setting readonly
|
|
286
|
-
*/
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
get
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
return
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
}
|
|
598
|
-
|
|
506
|
+
*/
|
|
507
|
+
|
|
508
|
+
}, {
|
|
509
|
+
key: "isChanged",
|
|
510
|
+
get:
|
|
511
|
+
/* -------------------------------------------------------------------------- */
|
|
512
|
+
|
|
513
|
+
/* Get/Check */
|
|
514
|
+
|
|
515
|
+
/* -------------------------------------------------------------------------- */
|
|
516
|
+
function get() {
|
|
517
|
+
var _this2 = this;
|
|
518
|
+
|
|
519
|
+
if (this.__use_delta) return !(0, _object.object_isEmpty)(this.__delta);else {
|
|
520
|
+
var orig = this.getOriginal();
|
|
521
|
+
if (!orig) return false; //we dont know if anything has changed
|
|
522
|
+
|
|
523
|
+
/* if object is not using delta mode, check changes by comparing changable fields with original object */
|
|
524
|
+
|
|
525
|
+
if (Array.isArray(this.__changeables)) {
|
|
526
|
+
//console.log("chk", this.__changeables, "for changes");
|
|
527
|
+
return this.__changeables.find(function (c) {
|
|
528
|
+
return !(0, _object.object_equals)(_this2[c], orig[c]);
|
|
529
|
+
}) != undefined;
|
|
530
|
+
} else {
|
|
531
|
+
/* check all fields */
|
|
532
|
+
for (var key in this) {
|
|
533
|
+
if (key.startsWith("__")) continue;
|
|
534
|
+
if (!(0, _object.object_equals)(this[key], orig[key])) return true;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
return false;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
return false;
|
|
541
|
+
}
|
|
542
|
+
}, {
|
|
543
|
+
key: "isDeleted",
|
|
544
|
+
get: function get() {
|
|
545
|
+
return false;
|
|
546
|
+
}
|
|
547
|
+
}, {
|
|
548
|
+
key: "d",
|
|
549
|
+
get: function get() {
|
|
550
|
+
return this.__use_delta ? this.__delta : this;
|
|
551
|
+
}
|
|
552
|
+
/* all updated properties */
|
|
553
|
+
|
|
554
|
+
}, {
|
|
555
|
+
key: "allproperties",
|
|
556
|
+
get: function get() {
|
|
557
|
+
var result = _objectSpread(_objectSpread({}, this), this.__delta);
|
|
558
|
+
|
|
559
|
+
result.__delta = {};
|
|
560
|
+
return result;
|
|
561
|
+
}
|
|
562
|
+
}, {
|
|
563
|
+
key: "canModify",
|
|
564
|
+
get: function get() {
|
|
565
|
+
return !Boolean(this.__is_readonly);
|
|
566
|
+
}
|
|
567
|
+
}, {
|
|
568
|
+
key: "__cache_name",
|
|
569
|
+
get: function get() {
|
|
570
|
+
return this.constructor["__cache_name"];
|
|
571
|
+
}
|
|
572
|
+
}, {
|
|
573
|
+
key: "__changeables",
|
|
574
|
+
get: function get() {
|
|
575
|
+
return this.constructor["__changeables"];
|
|
576
|
+
}
|
|
577
|
+
}, {
|
|
578
|
+
key: "__unchangeables",
|
|
579
|
+
get: function get() {
|
|
580
|
+
return this.constructor["__unchangeables"];
|
|
581
|
+
}
|
|
582
|
+
}, {
|
|
583
|
+
key: "__use_delta",
|
|
584
|
+
get: function get() {
|
|
585
|
+
return this.constructor["__use_delta"];
|
|
586
|
+
}
|
|
587
|
+
}, {
|
|
588
|
+
key: "isSaved",
|
|
589
|
+
get: function get() {
|
|
590
|
+
var _this$__saveResultIsS;
|
|
591
|
+
|
|
592
|
+
return Boolean((_this$__saveResultIsS = this.__saveResultIsSuccess) !== null && _this$__saveResultIsS !== void 0 ? _this$__saveResultIsS : false);
|
|
593
|
+
}
|
|
594
|
+
}, {
|
|
595
|
+
key: "isNew",
|
|
596
|
+
get: function get() {
|
|
597
|
+
var mid = this.getID();
|
|
598
|
+
if (!mid) return true;
|
|
599
|
+
if (typeof mid === "string") return mid === "" || mid === "-1";
|
|
600
|
+
if (typeof mid === "number") return mid === -1;
|
|
601
|
+
return false;
|
|
602
|
+
}
|
|
603
|
+
}, {
|
|
604
|
+
key: "get_lastChanged",
|
|
605
|
+
value: function get_lastChanged() {
|
|
606
|
+
return !this.__lastChanged;
|
|
607
|
+
}
|
|
608
|
+
}, {
|
|
609
|
+
key: "manager",
|
|
610
|
+
get: function get() {
|
|
611
|
+
return this.get_managerClass();
|
|
612
|
+
}
|
|
613
|
+
}, {
|
|
614
|
+
key: "getIndexOrID",
|
|
615
|
+
value: function getIndexOrID() {
|
|
616
|
+
return SimpleObject.getIndexOrID(this);
|
|
617
|
+
}
|
|
618
|
+
}, {
|
|
619
|
+
key: "getIndex",
|
|
620
|
+
value: function getIndex() {
|
|
621
|
+
return SimpleObject.getIndex(this);
|
|
622
|
+
}
|
|
623
|
+
}, {
|
|
624
|
+
key: "getID",
|
|
625
|
+
value: function getID() {
|
|
626
|
+
return SimpleObject.getID(this);
|
|
627
|
+
}
|
|
628
|
+
}, {
|
|
629
|
+
key: "getOriginal",
|
|
630
|
+
value:
|
|
631
|
+
/* -------------------------------------------------------------------------- */
|
|
632
|
+
|
|
633
|
+
/* Original */
|
|
634
|
+
|
|
635
|
+
/* -------------------------------------------------------------------------- */
|
|
636
|
+
function getOriginal() {
|
|
637
|
+
return this.__originalobject || undefined;
|
|
638
|
+
}
|
|
639
|
+
}, {
|
|
640
|
+
key: "setOriginal",
|
|
641
|
+
value: function setOriginal() {
|
|
642
|
+
var toObj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
643
|
+
|
|
644
|
+
if (toObj === null) {
|
|
645
|
+
delete this.__originalobject;
|
|
646
|
+
return;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
if (!this.canModify) {
|
|
650
|
+
console.warn("Cant use setOriginal on non original OR readonly objects ! this will create an infinite loop");
|
|
651
|
+
delete this.__originalobject;
|
|
652
|
+
return;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
if (toObj === 0) {
|
|
656
|
+
toObj = this;
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
var cloneObject = (0, _object.object_clone)(toObj);
|
|
660
|
+
SimpleObject.setReadonly(cloneObject, true);
|
|
661
|
+
this.__originalobject = (0, _object.object_removeKeys)(cloneObject, ["__"]);
|
|
662
|
+
return this;
|
|
663
|
+
}
|
|
664
|
+
}, {
|
|
665
|
+
key: "setSaveResult",
|
|
666
|
+
value: function setSaveResult(toObj, type) {
|
|
667
|
+
this.__saveResultType = type;
|
|
668
|
+
|
|
669
|
+
if (toObj === true) {} else if (toObj === false) {} else {
|
|
670
|
+
if (toObj) {
|
|
671
|
+
_classPrivateMethodGet(this, _setSaveResultObject, _setSaveResultObject2).call(this, toObj);
|
|
672
|
+
} else {
|
|
673
|
+
_classPrivateMethodGet(this, _setSaveResultObject, _setSaveResultObject2).call(this, null);
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
this.__saveResultIsSuccess = (type === "normal" || type === "nothing") && toObj != null;
|
|
678
|
+
}
|
|
679
|
+
}, {
|
|
680
|
+
key: "getSaveResult",
|
|
681
|
+
value: function getSaveResult() {
|
|
682
|
+
if (this.isSaved) return this.__saveResultObject;
|
|
683
|
+
return false;
|
|
684
|
+
}
|
|
685
|
+
}, {
|
|
686
|
+
key: "getSaveResultType",
|
|
687
|
+
value: function getSaveResultType() {
|
|
688
|
+
return this.__saveResultType || null;
|
|
689
|
+
}
|
|
690
|
+
/* -------------------------------------------------------------------------- */
|
|
691
|
+
|
|
692
|
+
/* statics */
|
|
693
|
+
|
|
694
|
+
/* -------------------------------------------------------------------------- */
|
|
695
|
+
|
|
696
|
+
}], [{
|
|
697
|
+
key: "loadValues",
|
|
698
|
+
value: function loadValues(obj, initObject) {
|
|
699
|
+
var fullUpdate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
700
|
+
SimpleObject.factoryClear(obj);
|
|
701
|
+
|
|
702
|
+
if (initObject == null) {
|
|
703
|
+
for (var key in obj) {
|
|
704
|
+
if (typeof obj[key] === "function") continue;
|
|
705
|
+
if (key.startsWith("__")) continue;
|
|
706
|
+
delete obj[key];
|
|
707
|
+
}
|
|
708
|
+
} else if (_typeof(initObject) == "object") {
|
|
709
|
+
for (var _key in initObject) {
|
|
710
|
+
if (_key.startsWith("__")) continue;
|
|
711
|
+
|
|
712
|
+
if (fullUpdate || Object.prototype.hasOwnProperty.call(obj, _key)) {
|
|
713
|
+
obj[_key] = initObject[_key];
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
return true;
|
|
719
|
+
}
|
|
720
|
+
/* -------------------------------------------------------------------------- */
|
|
721
|
+
|
|
722
|
+
}, {
|
|
723
|
+
key: "getValue",
|
|
724
|
+
value: function getValue(o, key) {
|
|
725
|
+
var original = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
726
|
+
if (o == null) return undefined;
|
|
727
|
+
if (o instanceof SimpleObject && typeof o.getValue === "function") return o.getValue(key, original);
|
|
728
|
+
|
|
729
|
+
if (!original && o.__use_delta != false && _typeof(o.__delta) === "object" && key in o.__delta) {
|
|
730
|
+
//@ts-ignore
|
|
731
|
+
return o.__delta[key];
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
return o[key];
|
|
735
|
+
}
|
|
736
|
+
}, {
|
|
737
|
+
key: "canChangeKey",
|
|
738
|
+
value: function canChangeKey(object, key, useExtraProps) {
|
|
739
|
+
if (!object || !key) return false;
|
|
740
|
+
|
|
741
|
+
if (useExtraProps) {
|
|
742
|
+
var __extraProperties = object.constructor["__extraProperties"];
|
|
743
|
+
if (__extraProperties != null && __extraProperties.includes(key)) return true;
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
var __changeables = object.constructor["__changeables"];
|
|
747
|
+
var __unchangeables = object.constructor["__unchangeables"];
|
|
748
|
+
if (__changeables != null && !__changeables.includes(key)) return false;
|
|
749
|
+
if (__unchangeables != null && __unchangeables.includes(key)) return false;
|
|
750
|
+
return true;
|
|
751
|
+
}
|
|
752
|
+
}, {
|
|
753
|
+
key: "setReadonly",
|
|
754
|
+
value: function setReadonly(objs) {
|
|
755
|
+
var readonlyval = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
756
|
+
var clearChanges = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
757
|
+
var checkObjs = [];
|
|
758
|
+
if (!objs) objs = [];
|
|
759
|
+
if (!Array.isArray(objs)) checkObjs = [objs];else checkObjs = objs;
|
|
760
|
+
|
|
761
|
+
for (var index = 0; index < checkObjs.length; index++) {
|
|
762
|
+
var obj = checkObjs[index];
|
|
763
|
+
obj.__is_readonly = readonlyval;
|
|
764
|
+
|
|
765
|
+
if (obj instanceof SimpleObject) {
|
|
766
|
+
if (obj.canModify) {
|
|
767
|
+
if (!obj.getOriginal()) obj.setOriginal();
|
|
768
|
+
} else {
|
|
769
|
+
if (clearChanges) obj.clear_changes(); //we dont need the original object in readonly mode
|
|
770
|
+
|
|
771
|
+
obj.setOriginal(null);
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
}, {
|
|
777
|
+
key: "setThrowErrors",
|
|
778
|
+
value: function setThrowErrors(objs) {
|
|
779
|
+
var throwErr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
780
|
+
var checkObjs = [];
|
|
781
|
+
if (!objs) objs = [];
|
|
782
|
+
if (!Array.isArray(objs)) checkObjs = [objs];else checkObjs = objs;
|
|
783
|
+
|
|
784
|
+
for (var index = 0; index < checkObjs.length; index++) {
|
|
785
|
+
var element = checkObjs[index];
|
|
786
|
+
element.__throw_errors = throwErr;
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
}, {
|
|
790
|
+
key: "isDeleted",
|
|
791
|
+
value: function isDeleted(obj) {
|
|
792
|
+
if (obj instanceof SimpleObject) return obj.isDeleted === true;
|
|
793
|
+
return false;
|
|
794
|
+
}
|
|
795
|
+
}, {
|
|
796
|
+
key: "getIndexOrID",
|
|
797
|
+
value: function getIndexOrID(o) {
|
|
798
|
+
var res = SimpleObject.getIndex(o);
|
|
799
|
+
if (!res || res == -1) res = SimpleObject.getID(o);
|
|
800
|
+
return res || -1;
|
|
801
|
+
}
|
|
802
|
+
}, {
|
|
803
|
+
key: "getIndex",
|
|
804
|
+
value: function getIndex(o) {
|
|
805
|
+
if (o == null || o == undefined) return -1;
|
|
806
|
+
|
|
807
|
+
switch (_typeof(o)) {
|
|
808
|
+
case "object":
|
|
809
|
+
return o._index_value || -1;
|
|
810
|
+
|
|
811
|
+
case "number":
|
|
812
|
+
case "string":
|
|
813
|
+
return Number(o);
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
return -1;
|
|
817
|
+
}
|
|
818
|
+
}, {
|
|
819
|
+
key: "getID",
|
|
820
|
+
value: function getID(o) {
|
|
821
|
+
if (o == null || o == undefined) return "";
|
|
822
|
+
|
|
823
|
+
switch (_typeof(o)) {
|
|
824
|
+
case "object":
|
|
825
|
+
return o.__data_id || o._id || o.id || o.ID || "";
|
|
826
|
+
|
|
827
|
+
case "string":
|
|
828
|
+
case "number":
|
|
829
|
+
return String(o);
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
return "";
|
|
833
|
+
}
|
|
834
|
+
}, {
|
|
835
|
+
key: "setOriginal",
|
|
836
|
+
value: function setOriginal(obj) {
|
|
837
|
+
var toObj = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
838
|
+
if (!(obj instanceof SimpleObject)) return undefined;
|
|
839
|
+
return obj.setOriginal(toObj);
|
|
840
|
+
}
|
|
841
|
+
}, {
|
|
842
|
+
key: "getOriginal",
|
|
843
|
+
value: function getOriginal(obj) {
|
|
844
|
+
if (obj instanceof SimpleObject) return obj.getOriginal();
|
|
845
|
+
return obj === null || obj === void 0 ? void 0 : obj.__originalobject;
|
|
846
|
+
}
|
|
847
|
+
/* -------------------------------------------------------------------------- */
|
|
848
|
+
|
|
849
|
+
/* Errors */
|
|
850
|
+
|
|
851
|
+
/* -------------------------------------------------------------------------- */
|
|
852
|
+
|
|
853
|
+
}, {
|
|
854
|
+
key: "addError",
|
|
855
|
+
value: function addError(o, title, message) {
|
|
856
|
+
var sendToRegister = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "auto";
|
|
857
|
+
var errStr = (0, _string.combine_if_not_blank)(title, " : ", message);
|
|
858
|
+
|
|
859
|
+
if (o) {
|
|
860
|
+
if (!Array.isArray(o.__errors)) o.__errors = [];
|
|
861
|
+
|
|
862
|
+
o.__errors.push(errStr);
|
|
863
|
+
|
|
864
|
+
if (o.__showErrors === false) return;
|
|
865
|
+
} else if (sendToRegister === "auto") sendToRegister = true;
|
|
866
|
+
|
|
867
|
+
if (sendToRegister === true) {
|
|
868
|
+
console.error("[REGISTER-ERROR]", errStr);
|
|
869
|
+
|
|
870
|
+
_global.gfunc.run_action("add_error", {
|
|
871
|
+
title: title,
|
|
872
|
+
message: message,
|
|
873
|
+
type: "error"
|
|
874
|
+
});
|
|
875
|
+
} else {
|
|
876
|
+
console.error("[ERROR]", errStr);
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
return (o === null || o === void 0 ? void 0 : o.__errors) || [];
|
|
880
|
+
}
|
|
881
|
+
}, {
|
|
882
|
+
key: "getErrors",
|
|
883
|
+
value: function getErrors(o) {
|
|
884
|
+
return (o === null || o === void 0 ? void 0 : o.__errors) || [];
|
|
885
|
+
}
|
|
886
|
+
}, {
|
|
887
|
+
key: "clearErrors",
|
|
888
|
+
value: function clearErrors(o) {
|
|
889
|
+
if (o) o.__errors = [];
|
|
890
|
+
return true;
|
|
891
|
+
}
|
|
892
|
+
/* -------------------------------------------------------------------------- */
|
|
893
|
+
|
|
894
|
+
/* Save Results */
|
|
895
|
+
|
|
896
|
+
/* -------------------------------------------------------------------------- */
|
|
897
|
+
|
|
898
|
+
}, {
|
|
899
|
+
key: "isResultValid",
|
|
900
|
+
value: function isResultValid(result_object) {
|
|
901
|
+
if ((0, _object.object_isEmpty)(result_object)) return false;
|
|
902
|
+
|
|
903
|
+
switch (_typeof(result_object)) {
|
|
904
|
+
case "string":
|
|
905
|
+
try {
|
|
906
|
+
result_object = JSON.parse(result_object);
|
|
907
|
+
return this.isResultValid(result_object);
|
|
908
|
+
} catch (_unused) {
|
|
909
|
+
return false;
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
case "object":
|
|
913
|
+
if ((0, _object.object_isTrue)(result_object.acknowledged)) {
|
|
914
|
+
return true;
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
if (result_object.expected && result_object.result) {
|
|
918
|
+
return (0, _object.object_equals)(result_object.expected, result_object.result);
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
return Number(this.getID(result_object)) >= 0;
|
|
922
|
+
|
|
923
|
+
case "number":
|
|
924
|
+
return result_object > 0;
|
|
925
|
+
|
|
926
|
+
case "boolean":
|
|
927
|
+
return result_object === true;
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
return false;
|
|
931
|
+
}
|
|
932
|
+
}, {
|
|
933
|
+
key: "factoryClear",
|
|
934
|
+
value: function factoryClear(obj) {
|
|
935
|
+
obj.clear_changes();
|
|
936
|
+
SimpleObject.clearErrors(obj);
|
|
937
|
+
}
|
|
938
|
+
}, {
|
|
939
|
+
key: "delete_cache",
|
|
940
|
+
value: function delete_cache() {
|
|
941
|
+
if (!this.__cache_name) return;
|
|
942
|
+
|
|
943
|
+
_global.gcache.delete_cache(this.__cache_name);
|
|
944
|
+
}
|
|
945
|
+
}, {
|
|
946
|
+
key: "get_canModify",
|
|
947
|
+
value: function get_canModify(o) {
|
|
948
|
+
if (o instanceof SimpleObject) return o.canModify;
|
|
949
|
+
return false;
|
|
950
|
+
}
|
|
951
|
+
/* -------------------------------------------------------------------------- */
|
|
952
|
+
|
|
953
|
+
}, {
|
|
954
|
+
key: "equals",
|
|
955
|
+
value: function equals(a, b) {
|
|
956
|
+
console.warn("Dont use the default equals method !");
|
|
957
|
+
if (a == undefined || b == undefined) return false;
|
|
958
|
+
return a === b;
|
|
959
|
+
}
|
|
960
|
+
}]);
|
|
961
|
+
|
|
962
|
+
return SimpleObject;
|
|
963
|
+
}(_MapableObject2.MapableObject);
|
|
964
|
+
|
|
965
|
+
exports.SimpleObject = SimpleObject;
|
|
966
|
+
|
|
967
|
+
function _setSubProperty2(key, subkey, value) {
|
|
968
|
+
var subobj = _classPrivateMethodGet(this, _getProperty, _getProperty2).call(this, key); //@ts-ignore
|
|
969
|
+
|
|
970
|
+
|
|
971
|
+
if (subobj == null || _typeof(subobj) !== "object") subobj = {};
|
|
972
|
+
subobj[subkey] = value;
|
|
973
|
+
|
|
974
|
+
_classPrivateMethodGet(this, _setProperty, _setProperty2).call(this, key, subobj);
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
function _getSubProperty2(key, subkey) {
|
|
978
|
+
var original = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
979
|
+
|
|
980
|
+
var subobj = _classPrivateMethodGet(this, _getProperty, _getProperty2).call(this, key, original);
|
|
981
|
+
|
|
982
|
+
if (subobj == null || _typeof(subobj) !== "object") return undefined;
|
|
983
|
+
return subobj[subkey];
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
function _setProperty2(key, value) {
|
|
987
|
+
if (this.__use_delta) this.__delta[key] = value;else this[key] = value;
|
|
988
|
+
return true;
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
function _setDefaultProperty2(key, value) {
|
|
992
|
+
//@ts-ignore
|
|
993
|
+
if (this[key] == undefined || this[key] === "" || this[key] === 0) {
|
|
994
|
+
this[key] = value;
|
|
995
|
+
return true;
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
return false;
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
function _getProperty2(key) {
|
|
1002
|
+
var original = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
1003
|
+
|
|
1004
|
+
//check if we should use delta version or normal version for this property
|
|
1005
|
+
if (this.__use_delta && !original && key in this.__delta) {
|
|
1006
|
+
//@ts-ignore
|
|
1007
|
+
return this.__delta[key];
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
return this[key];
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
function _setSaveResultObject2(toObj) {
|
|
1014
|
+
this.__saveResultObject = toObj;
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
_defineProperty(SimpleObject, "__cache_name", void 0);
|
|
1018
|
+
|
|
1019
|
+
_defineProperty(SimpleObject, "__unchangeables", void 0);
|
|
1020
|
+
|
|
1021
|
+
_defineProperty(SimpleObject, "__changeables", void 0);
|
|
1022
|
+
|
|
1023
|
+
_defineProperty(SimpleObject, "__extraProperties", void 0);
|
|
1024
|
+
|
|
1025
|
+
_defineProperty(SimpleObject, "__use_delta", true);
|
|
1026
|
+
|
|
1027
|
+
var _default = SimpleObject;
|
|
1028
|
+
exports["default"] = _default;
|