@azrico/webobject 1.3.22 → 1.3.24

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.
@@ -1,292 +1,670 @@
1
- import SimpleObject from "../structs/SimpleObject";
2
- import { getInArray, object_equals, object_first, object_isEmpty, object_isTrue, object_shallow_clone, setInArray, to_array, } from "@azrico/object";
3
- import { gfunc } from "@azrico/global";
4
- export class WebObject extends SimpleObject {
5
- static __web_path = "";
6
- static __web_type = "";
7
- meta_data;
8
- _id = "";
9
- _created_date = "";
10
- constructor(is_readonly = false) {
11
- super(is_readonly);
12
- this.meta_data = [];
13
- }
14
- /* -------------------------------------------------------------------------- */
15
- /* Meta data */
16
- /* -------------------------------------------------------------------------- */
17
- /**
18
- * Update meta value of this object , meta data is stored in meta_data variable
19
- * @param key
20
- * @param value
21
- * @param createIfNotExists should we create a new meta if key does not exist
22
- * @param sendChange
23
- * @returns
24
- */
25
- setMetaValue(key, value, createIfNotExists = true, sendChange = "auto") {
26
- if (!this.canModify) {
27
- if (this.__throw_errors !== false)
28
- throw Error(`Cant use setMetaValue on ${key} when on readonly mode`);
29
- else
30
- return false;
31
- }
32
- if (!key || typeof key != "string") {
33
- if (this.__throw_errors !== false)
34
- throw Error(`Bad key at setMetaValue`);
35
- else
36
- return false;
37
- }
38
- const old_value = WebObject.getMetaValue(this, key);
39
- if (object_equals(old_value, value))
40
- return false; //same value, no changes
41
- const old_metalist = to_array(this.getValue("meta_data")).map((s) => object_shallow_clone(s));
42
- const new_metalist = setInArray(old_metalist, "key", key, "value", value, createIfNotExists);
43
- this.setValue("meta_data", new_metalist);
44
- if (sendChange !== false)
45
- this.notifyChanged("meta", key, value);
46
- return true;
47
- }
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = exports.WebObject = void 0;
7
+ var _SimpleObject2 = _interopRequireDefault(require("../structs/SimpleObject"));
8
+ var _object = require("@azrico/object");
9
+ var _global = require("@azrico/global");
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
11
+ 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); }
12
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
13
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
14
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
15
+ 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; }
16
+ 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; }
17
+ 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, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $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 defineProperty(generator, "_invoke", { value: makeInvokeMethod(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; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(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); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), 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, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), 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 (val) { var object = Object(val), 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; }
18
+ 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); } }
19
+ 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); }); }; }
20
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
21
+ 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, _toPropertyKey(descriptor.key), descriptor); } }
22
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
23
+ 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); }
24
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
25
+ 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); }; }
26
+ 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); }
27
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
28
+ 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; } }
29
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
30
+ function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
31
+ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
32
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
33
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
34
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
35
+ function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
36
+ var _isValidSR = /*#__PURE__*/new WeakSet();
37
+ var WebObject = /*#__PURE__*/function (_SimpleObject) {
38
+ _inherits(WebObject, _SimpleObject);
39
+ var _super = _createSuper(WebObject);
40
+ function WebObject() {
41
+ var _this;
42
+ var is_readonly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
43
+ _classCallCheck(this, WebObject);
44
+ _this = _super.call(this, is_readonly);
45
+ _classPrivateMethodInitSpec(_assertThisInitialized(_this), _isValidSR);
46
+ _defineProperty(_assertThisInitialized(_this), "meta_data", void 0);
47
+ _defineProperty(_assertThisInitialized(_this), "_id", "");
48
+ _defineProperty(_assertThisInitialized(_this), "_created_date", "");
49
+ _defineProperty(_assertThisInitialized(_this), "get_webtype", function () {
50
+ return _this.__web_type || _this.get_webpath();
51
+ });
52
+ _defineProperty(_assertThisInitialized(_this), "get_webpath", function () {
53
+ return _this.__web_path;
54
+ });
55
+ _this.meta_data = [];
56
+ return _this;
57
+ }
58
+ /* -------------------------------------------------------------------------- */
59
+ /* Meta data */
60
+ /* -------------------------------------------------------------------------- */
61
+ /**
62
+ * Update meta value of this object , meta data is stored in meta_data variable
63
+ * @param key
64
+ * @param value
65
+ * @param createIfNotExists should we create a new meta if key does not exist
66
+ * @param sendChange
67
+ * @returns
68
+ */
69
+ _createClass(WebObject, [{
70
+ key: "setMetaValue",
71
+ value: function setMetaValue(key, value) {
72
+ var createIfNotExists = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
73
+ var sendChange = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "auto";
74
+ if (!this.canModify) {
75
+ if (this.__throw_errors !== false) throw Error("Cant use setMetaValue on ".concat(key, " when on readonly mode"));else return false;
76
+ }
77
+ if (!key || typeof key != "string") {
78
+ if (this.__throw_errors !== false) throw Error("Bad key at setMetaValue");else return false;
79
+ }
80
+ var old_value = WebObject.getMetaValue(this, key);
81
+ if ((0, _object.object_equals)(old_value, value)) return false; //same value, no changes
82
+ var old_metalist = (0, _object.to_array)(this.getValue("meta_data")).map(function (s) {
83
+ return (0, _object.object_shallow_clone)(s);
84
+ });
85
+ var new_metalist = (0, _object.setInArray)(old_metalist, "key", key, "value", value, createIfNotExists);
86
+ this.setValue("meta_data", new_metalist);
87
+ if (sendChange !== false) this.notifyChanged("meta", key, value);
88
+ return true;
89
+ }
48
90
  /**
49
91
  * Get meta object by key
50
92
  * @param key
51
93
  * @returns meta object
52
- */
53
- getMeta(key) {
54
- return WebObject.getMeta(this, key);
55
- }
94
+ */
95
+ }, {
96
+ key: "getMeta",
97
+ value: function getMeta(key) {
98
+ return WebObject.getMeta(this, key);
99
+ }
56
100
  /**
57
101
  * Get meta value by key
58
102
  * @param key
59
103
  * @returns value or undefined
60
- */
61
- getMetaValue(key) {
62
- return WebObject.getMetaValue(this, key);
63
- }
104
+ */
105
+ }, {
106
+ key: "getMetaValue",
107
+ value: function getMetaValue(key) {
108
+ return WebObject.getMetaValue(this, key);
109
+ }
64
110
  /**
65
111
  * Get meta object by key
66
112
  * @param o
67
113
  * @param key
68
114
  * @returns meta object
69
- */
70
- static getMeta(o, key) {
71
- if (o == null)
72
- return null;
73
- if (!key || typeof key != "string")
74
- return undefined;
75
- let metalist = [];
76
- if (typeof o === "object") {
77
- metalist =
78
- typeof o.getValue === "function"
79
- ? o.getValue("meta_data")
80
- : o.meta_data;
81
- }
82
- return getInArray(metalist, "key", key);
83
- }
84
- /**
85
- * Get meta value by key
86
- * @param o
87
- * @param key
88
- * @returns value or undefined
89
- */
90
- static getMetaValue(o, key) {
91
- return WebObject.getMeta(o, key)?.value;
92
- }
93
- /* -------------------------------------------------------------------------- */
94
- /* Save */
95
- /* -------------------------------------------------------------------------- */
96
- async Save() {
97
- if (this.__throw_errors !== false)
98
- throw new Error("Save not implented");
99
- WebObject.addError(this, "Save not implented", "NOSAVE", true);
100
- this.setSaveResult(false, "canceled");
101
- return false;
102
- }
103
- async Delete() {
104
- if (this.__throw_errors !== false)
105
- throw new Error("Delete not implented");
106
- WebObject.addError(this, "Delete not implented", "NOSAVE", true);
107
- this.setSaveResult(false, "canceled");
108
- return false;
109
- }
110
- /* -------------------------------------------------------------------------- */
111
- canSave(deltaObj) {
112
- const deltaRes = this.deltaIsValid(deltaObj);
113
- if (deltaRes !== true)
114
- return deltaRes;
115
- return true;
116
- }
117
- deltaIsValid(d) {
118
- return true;
119
- }
120
- static isResultValid(result_object) {
121
- if (object_isEmpty(result_object))
122
- return false;
123
- if (object_isTrue(result_object.acknowledged)) {
124
- return true;
125
- }
126
- return false;
127
- }
115
+ */
116
+ }, {
117
+ key: "Save",
118
+ value:
119
+ /* -------------------------------------------------------------------------- */
120
+ /* Save */
121
+ /* -------------------------------------------------------------------------- */
122
+ function () {
123
+ var _Save = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
124
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
125
+ while (1) switch (_context.prev = _context.next) {
126
+ case 0:
127
+ if (!(this.__throw_errors !== false)) {
128
+ _context.next = 2;
129
+ break;
130
+ }
131
+ throw new Error("Save not implented");
132
+ case 2:
133
+ WebObject.addError(this, "Save not implented", "NOSAVE", true);
134
+ this.setSaveResult(false, "canceled");
135
+ return _context.abrupt("return", false);
136
+ case 5:
137
+ case "end":
138
+ return _context.stop();
139
+ }
140
+ }, _callee, this);
141
+ }));
142
+ function Save() {
143
+ return _Save.apply(this, arguments);
144
+ }
145
+ return Save;
146
+ }()
147
+ }, {
148
+ key: "Delete",
149
+ value: function () {
150
+ var _Delete = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
151
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
152
+ while (1) switch (_context2.prev = _context2.next) {
153
+ case 0:
154
+ if (!(this.__throw_errors !== false)) {
155
+ _context2.next = 2;
156
+ break;
157
+ }
158
+ throw new Error("Delete not implented");
159
+ case 2:
160
+ WebObject.addError(this, "Delete not implented", "NOSAVE", true);
161
+ this.setSaveResult(false, "canceled");
162
+ return _context2.abrupt("return", false);
163
+ case 5:
164
+ case "end":
165
+ return _context2.stop();
166
+ }
167
+ }, _callee2, this);
168
+ }));
169
+ function Delete() {
170
+ return _Delete.apply(this, arguments);
171
+ }
172
+ return Delete;
173
+ }() /* -------------------------------------------------------------------------- */
174
+ }, {
175
+ key: "canSave",
176
+ value: function canSave(deltaObj) {
177
+ var deltaRes = this.deltaIsValid(deltaObj);
178
+ if (deltaRes !== true) return deltaRes;
179
+ return true;
180
+ }
181
+ }, {
182
+ key: "deltaIsValid",
183
+ value: function deltaIsValid(d) {
184
+ return true;
185
+ }
186
+ }, {
187
+ key: "get_deltaObject",
188
+ value:
128
189
  /**
129
190
  * You will post this to the server for saving
130
191
  * automatically removes unchangable fields
131
192
  * @returns
132
- */
133
- async get_deltaObject(p) {
134
- if (!p)
135
- p = {};
136
- const final_object = {};
137
- //@ts-ignore
138
- const isChild = Boolean(p.isChild || p.ischild);
139
- //@ts-ignore
140
- const useDelta = this.__use_delta || Boolean(p.useDelta || p.usedelta);
141
- //@ts-ignore
142
- const allProperties = Boolean(p.allProperties || p.allproperties);
143
- const chkChangables = this.__changeables != null || this.__unchangeables != null;
144
- const useExtraProps = Boolean(p.extraProperties);
145
- //child objects usually dont update their __delta, so we read info from all of its properties
146
- const dlt = allProperties || (!useDelta && isChild && chkChangables)
147
- ? { ...this.allproperties }
148
- : { ...this.__delta };
149
- const allkeys = Object.keys(dlt);
150
- const changableKeys = chkChangables
151
- ? allkeys.filter((s) => SimpleObject.canChangeKey(this, s, useExtraProps))
152
- : allkeys;
153
- async function parseObj(obj) {
154
- if (obj == null)
155
- return undefined;
156
- if (Array.isArray(obj))
157
- return await Promise.all(obj.map(async (r) => await parseObj(r)));
158
- if (obj instanceof WebObject &&
159
- typeof obj.get_deltaObject === "function") {
160
- //child elements have different kind of delta
161
- const newobj_dlt = await obj.get_deltaObject({
162
- ...p,
163
- isChild: true,
164
- });
165
- if (!object_isEmpty(newobj_dlt))
166
- return newobj_dlt;
167
- else
168
- return obj;
169
- }
170
- return obj;
171
- }
172
- for (const key of changableKeys) {
173
- final_object[key] = await parseObj(dlt[key]);
174
- }
175
- if (allProperties) {
176
- final_object["_id"] = this.getID();
177
- final_object["_index_value"] = this.getIndex();
178
- final_object["_index_key"] = this["_index_key"];
179
- final_object["_created_date"] = this["_created_date"];
180
- }
181
- return final_object;
182
- }
183
- /* --------------------------------- Getters -------------------------------- */
184
- get __web_path() {
185
- return this.constructor["__web_path"];
186
- }
187
- get __web_type() {
188
- return this.constructor["__web_type"];
189
- }
190
- get_webtype = () => this.__web_type || this.get_webpath();
191
- get_webpath = () => this.__web_path;
192
- static get_webname() {
193
- return this.__web_path || this.__web_type || this.__cache_name;
194
- }
195
- get manager() {
196
- return this.get_managerClass();
197
- }
198
- get_managerClass = () => null;
199
- set_managerClass(mng) {
200
- this.get_managerClass = () => mng;
201
- }
202
- /* -------------------------------------------------------------------------- */
203
- async onDelete(...p) {
204
- this.isDeleted = true;
205
- return await this.manager?.onDelete(...p); //events are handled by the manager
206
- }
207
- async onLoad(...p) {
208
- this.isDeleted = false;
209
- return await this.manager?.onLoad(...p); //events are handled by the manager
210
- }
211
- async onSave(...p) {
212
- if (this.isSaved) {
213
- this.apply_changes();
214
- var srObject = this.getSaveResult(true);
215
- if (srObject != null) {
216
- //we may have some extra data in the save result.
217
- //try to find the main data
218
- if (Array.isArray(srObject)) {
219
- const actual_sr = srObject.find((s) => this.#isValidSR(s));
220
- if (actual_sr)
221
- srObject = actual_sr;
222
- }
223
- if (this.#isValidSR(srObject)) {
224
- if (srObject.insertedId || srObject._id) {
225
- this._id = srObject.insertedId || srObject._id;
226
- }
227
- if (srObject._index_value &&
228
- !Number.isNaN(srObject._index_value)) {
229
- this._index_value = Number(srObject._index_value);
230
- }
231
- await this.manager?.event_run("on_id_change");
232
- }
233
- }
234
- }
235
- return await this.manager?.onSave(...p); //events are handled by the manager
236
- }
237
- #isValidSR(s) {
238
- if (typeof s !== "object" && s == null)
239
- return false;
240
- return (s.insertedId ||
241
- s._id ||
242
- (s._index_value && !Number.isNaN(s._index_value)));
243
- }
244
- async onNew(...p) {
245
- return await this.manager?.onNew(...p); //events are handled by the manager
246
- }
247
- /* -------------------------------------------------------------------------- */
193
+ */
194
+ function () {
195
+ var _get_deltaObject = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(p) {
196
+ var _this2 = this;
197
+ var final_object, isChild, useDelta, allProperties, chkChangables, useExtraProps, dlt, allkeys, changableKeys, parseObj, _parseObj, _iterator, _step, key;
198
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
199
+ while (1) switch (_context5.prev = _context5.next) {
200
+ case 0:
201
+ _parseObj = function _parseObj3() {
202
+ _parseObj = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(obj) {
203
+ var newobj_dlt;
204
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
205
+ while (1) switch (_context4.prev = _context4.next) {
206
+ case 0:
207
+ if (!(obj == null)) {
208
+ _context4.next = 2;
209
+ break;
210
+ }
211
+ return _context4.abrupt("return", undefined);
212
+ case 2:
213
+ if (!Array.isArray(obj)) {
214
+ _context4.next = 6;
215
+ break;
216
+ }
217
+ _context4.next = 5;
218
+ return Promise.all(obj.map( /*#__PURE__*/function () {
219
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(r) {
220
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
221
+ while (1) switch (_context3.prev = _context3.next) {
222
+ case 0:
223
+ _context3.next = 2;
224
+ return parseObj(r);
225
+ case 2:
226
+ return _context3.abrupt("return", _context3.sent);
227
+ case 3:
228
+ case "end":
229
+ return _context3.stop();
230
+ }
231
+ }, _callee3);
232
+ }));
233
+ return function (_x3) {
234
+ return _ref.apply(this, arguments);
235
+ };
236
+ }()));
237
+ case 5:
238
+ return _context4.abrupt("return", _context4.sent);
239
+ case 6:
240
+ if (!(obj instanceof WebObject && typeof obj.get_deltaObject === "function")) {
241
+ _context4.next = 15;
242
+ break;
243
+ }
244
+ _context4.next = 9;
245
+ return obj.get_deltaObject(_objectSpread(_objectSpread({}, p), {}, {
246
+ isChild: true
247
+ }));
248
+ case 9:
249
+ newobj_dlt = _context4.sent;
250
+ if ((0, _object.object_isEmpty)(newobj_dlt)) {
251
+ _context4.next = 14;
252
+ break;
253
+ }
254
+ return _context4.abrupt("return", newobj_dlt);
255
+ case 14:
256
+ return _context4.abrupt("return", obj);
257
+ case 15:
258
+ return _context4.abrupt("return", obj);
259
+ case 16:
260
+ case "end":
261
+ return _context4.stop();
262
+ }
263
+ }, _callee4);
264
+ }));
265
+ return _parseObj.apply(this, arguments);
266
+ };
267
+ parseObj = function _parseObj2(_x2) {
268
+ return _parseObj.apply(this, arguments);
269
+ };
270
+ if (!p) p = {};
271
+ final_object = {}; //@ts-ignore
272
+ isChild = Boolean(p.isChild || p.ischild); //@ts-ignore
273
+ useDelta = this.__use_delta || Boolean(p.useDelta || p.usedelta); //@ts-ignore
274
+ allProperties = Boolean(p.allProperties || p.allproperties);
275
+ chkChangables = this.__changeables != null || this.__unchangeables != null;
276
+ useExtraProps = Boolean(p.extraProperties); //child objects usually dont update their __delta, so we read info from all of its properties
277
+ dlt = allProperties || !useDelta && isChild && chkChangables ? _objectSpread({}, this.allproperties) : _objectSpread({}, this.__delta);
278
+ allkeys = Object.keys(dlt);
279
+ changableKeys = chkChangables ? allkeys.filter(function (s) {
280
+ return _SimpleObject2["default"].canChangeKey(_this2, s, useExtraProps);
281
+ }) : allkeys;
282
+ _iterator = _createForOfIteratorHelper(changableKeys);
283
+ _context5.prev = 13;
284
+ _iterator.s();
285
+ case 15:
286
+ if ((_step = _iterator.n()).done) {
287
+ _context5.next = 22;
288
+ break;
289
+ }
290
+ key = _step.value;
291
+ _context5.next = 19;
292
+ return parseObj(dlt[key]);
293
+ case 19:
294
+ final_object[key] = _context5.sent;
295
+ case 20:
296
+ _context5.next = 15;
297
+ break;
298
+ case 22:
299
+ _context5.next = 27;
300
+ break;
301
+ case 24:
302
+ _context5.prev = 24;
303
+ _context5.t0 = _context5["catch"](13);
304
+ _iterator.e(_context5.t0);
305
+ case 27:
306
+ _context5.prev = 27;
307
+ _iterator.f();
308
+ return _context5.finish(27);
309
+ case 30:
310
+ if (allProperties) {
311
+ final_object["_id"] = this.getID();
312
+ final_object["_index_value"] = this.getIndex();
313
+ final_object["_index_key"] = this["_index_key"];
314
+ final_object["_created_date"] = this["_created_date"];
315
+ }
316
+ return _context5.abrupt("return", final_object);
317
+ case 32:
318
+ case "end":
319
+ return _context5.stop();
320
+ }
321
+ }, _callee5, this, [[13, 24, 27, 30]]);
322
+ }));
323
+ function get_deltaObject(_x) {
324
+ return _get_deltaObject.apply(this, arguments);
325
+ }
326
+ return get_deltaObject;
327
+ }() /* --------------------------------- Getters -------------------------------- */
328
+ }, {
329
+ key: "__web_path",
330
+ get: function get() {
331
+ return this.constructor["__web_path"];
332
+ }
333
+ }, {
334
+ key: "__web_type",
335
+ get: function get() {
336
+ return this.constructor["__web_type"];
337
+ }
338
+ }, {
339
+ key: "manager",
340
+ get: function get() {
341
+ return this.get_managerClass() || undefined;
342
+ }
343
+ /* -------------------------------------------------------------------------- */
344
+ }, {
345
+ key: "onDelete",
346
+ value: function () {
347
+ var _onDelete = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
348
+ var _this$manager;
349
+ var _len,
350
+ p,
351
+ _key,
352
+ _args6 = arguments;
353
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
354
+ while (1) switch (_context6.prev = _context6.next) {
355
+ case 0:
356
+ this.isDeleted = true;
357
+ for (_len = _args6.length, p = new Array(_len), _key = 0; _key < _len; _key++) {
358
+ p[_key] = _args6[_key];
359
+ }
360
+ _context6.next = 4;
361
+ return (_this$manager = this.manager) === null || _this$manager === void 0 ? void 0 : _this$manager.onDelete.apply(_this$manager, p);
362
+ case 4:
363
+ return _context6.abrupt("return", _context6.sent);
364
+ case 5:
365
+ case "end":
366
+ return _context6.stop();
367
+ }
368
+ }, _callee6, this);
369
+ }));
370
+ function onDelete() {
371
+ return _onDelete.apply(this, arguments);
372
+ }
373
+ return onDelete;
374
+ }()
375
+ }, {
376
+ key: "onLoad",
377
+ value: function () {
378
+ var _onLoad = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
379
+ var _this$manager2;
380
+ var _len2,
381
+ p,
382
+ _key2,
383
+ _args7 = arguments;
384
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
385
+ while (1) switch (_context7.prev = _context7.next) {
386
+ case 0:
387
+ this.isDeleted = false;
388
+ for (_len2 = _args7.length, p = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
389
+ p[_key2] = _args7[_key2];
390
+ }
391
+ _context7.next = 4;
392
+ return (_this$manager2 = this.manager) === null || _this$manager2 === void 0 ? void 0 : _this$manager2.onLoad.apply(_this$manager2, p);
393
+ case 4:
394
+ return _context7.abrupt("return", _context7.sent);
395
+ case 5:
396
+ case "end":
397
+ return _context7.stop();
398
+ }
399
+ }, _callee7, this);
400
+ }));
401
+ function onLoad() {
402
+ return _onLoad.apply(this, arguments);
403
+ }
404
+ return onLoad;
405
+ }()
406
+ }, {
407
+ key: "onSave",
408
+ value: function () {
409
+ var _onSave = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
410
+ var _this3 = this,
411
+ _this$manager4;
412
+ var srObject,
413
+ actual_sr,
414
+ _this$manager3,
415
+ _len3,
416
+ p,
417
+ _key3,
418
+ _args8 = arguments;
419
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
420
+ while (1) switch (_context8.prev = _context8.next) {
421
+ case 0:
422
+ if (!this.isSaved) {
423
+ _context8.next = 10;
424
+ break;
425
+ }
426
+ this.apply_changes();
427
+ srObject = this.getSaveResult(true);
428
+ if (!(srObject != null)) {
429
+ _context8.next = 10;
430
+ break;
431
+ }
432
+ //we may have some extra data in the save result.
433
+ //try to find the main data
434
+ if (Array.isArray(srObject)) {
435
+ actual_sr = srObject.find(function (s) {
436
+ return _classPrivateMethodGet(_this3, _isValidSR, _isValidSR2).call(_this3, s);
437
+ });
438
+ if (actual_sr) srObject = actual_sr;
439
+ }
440
+ if (!_classPrivateMethodGet(this, _isValidSR, _isValidSR2).call(this, srObject)) {
441
+ _context8.next = 10;
442
+ break;
443
+ }
444
+ if (srObject.insertedId || srObject._id) {
445
+ this._id = srObject.insertedId || srObject._id;
446
+ }
447
+ if (srObject._index_value && !Number.isNaN(srObject._index_value)) {
448
+ this._index_value = Number(srObject._index_value);
449
+ }
450
+ _context8.next = 10;
451
+ return (_this$manager3 = this.manager) === null || _this$manager3 === void 0 ? void 0 : _this$manager3.event_run("on_id_change");
452
+ case 10:
453
+ for (_len3 = _args8.length, p = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
454
+ p[_key3] = _args8[_key3];
455
+ }
456
+ _context8.next = 13;
457
+ return (_this$manager4 = this.manager) === null || _this$manager4 === void 0 ? void 0 : _this$manager4.onSave.apply(_this$manager4, p);
458
+ case 13:
459
+ return _context8.abrupt("return", _context8.sent);
460
+ case 14:
461
+ case "end":
462
+ return _context8.stop();
463
+ }
464
+ }, _callee8, this);
465
+ }));
466
+ function onSave() {
467
+ return _onSave.apply(this, arguments);
468
+ }
469
+ return onSave;
470
+ }()
471
+ }, {
472
+ key: "onNew",
473
+ value: function () {
474
+ var _onNew = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
475
+ var _this$manager5;
476
+ var _len4,
477
+ p,
478
+ _key4,
479
+ _args9 = arguments;
480
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
481
+ while (1) switch (_context9.prev = _context9.next) {
482
+ case 0:
483
+ for (_len4 = _args9.length, p = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
484
+ p[_key4] = _args9[_key4];
485
+ }
486
+ _context9.next = 3;
487
+ return (_this$manager5 = this.manager) === null || _this$manager5 === void 0 ? void 0 : _this$manager5.onNew.apply(_this$manager5, p);
488
+ case 3:
489
+ return _context9.abrupt("return", _context9.sent);
490
+ case 4:
491
+ case "end":
492
+ return _context9.stop();
493
+ }
494
+ }, _callee9, this);
495
+ }));
496
+ function onNew() {
497
+ return _onNew.apply(this, arguments);
498
+ }
499
+ return onNew;
500
+ }()
501
+ /* -------------------------------------------------------------------------- */
248
502
  /**
249
503
  * get a single web object
250
504
  * default order of parameters : search,readonly,fetchID
251
- */
252
- static async get_single(...p) {
253
- let search = p.shift();
254
- let readonly = p.shift();
255
- let fetchID = p.shift();
256
- if (object_isEmpty(search))
257
- return undefined;
258
- let res;
259
- const params = {};
260
- params.context = readonly ? "view" : "edit";
261
- switch (typeof search) {
262
- case "string":
263
- case "number":
264
- search = String(search);
265
- res = this.ensure(this, await gfunc.run_action("get", this.__web_path + "/" + search, params, { fetchID: fetchID }));
266
- break;
267
- case "object":
268
- default:
269
- res = object_first(await this.get_list(search, readonly, fetchID));
270
- break;
271
- }
272
- WebObject.setReadonly(res, readonly);
273
- return res;
274
- }
505
+ */
506
+ }], [{
507
+ key: "getMeta",
508
+ value: function getMeta(o, key) {
509
+ if (o == null) return null;
510
+ if (!key || typeof key != "string") return undefined;
511
+ var metalist = [];
512
+ if (_typeof(o) === "object") {
513
+ metalist = typeof o.getValue === "function" ? o.getValue("meta_data") : o.meta_data;
514
+ }
515
+ return (0, _object.getInArray)(metalist, "key", key);
516
+ }
517
+ /**
518
+ * Get meta value by key
519
+ * @param o
520
+ * @param key
521
+ * @returns value or undefined
522
+ */
523
+ }, {
524
+ key: "getMetaValue",
525
+ value: function getMetaValue(o, key) {
526
+ var _WebObject$getMeta;
527
+ return (_WebObject$getMeta = WebObject.getMeta(o, key)) === null || _WebObject$getMeta === void 0 ? void 0 : _WebObject$getMeta.value;
528
+ }
529
+ }, {
530
+ key: "isResultValid",
531
+ value: function isResultValid(result_object) {
532
+ if ((0, _object.object_isEmpty)(result_object)) return false;
533
+ if ((0, _object.object_isTrue)(result_object.acknowledged)) {
534
+ return true;
535
+ }
536
+ return false;
537
+ }
538
+ }, {
539
+ key: "get_webname",
540
+ value: function get_webname() {
541
+ return this.__web_path || this.__web_type || this.__cache_name;
542
+ }
543
+ }, {
544
+ key: "get_single",
545
+ value: function () {
546
+ var _get_single = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
547
+ var _len5,
548
+ p,
549
+ _key5,
550
+ search,
551
+ readonly,
552
+ fetchID,
553
+ res,
554
+ params,
555
+ _args10 = arguments;
556
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
557
+ while (1) switch (_context10.prev = _context10.next) {
558
+ case 0:
559
+ for (_len5 = _args10.length, p = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
560
+ p[_key5] = _args10[_key5];
561
+ }
562
+ search = p.shift();
563
+ readonly = p.shift();
564
+ fetchID = p.shift();
565
+ if (!(0, _object.object_isEmpty)(search)) {
566
+ _context10.next = 6;
567
+ break;
568
+ }
569
+ return _context10.abrupt("return", undefined);
570
+ case 6:
571
+ params = {};
572
+ params.context = readonly ? "view" : "edit";
573
+ _context10.t0 = _typeof(search);
574
+ _context10.next = _context10.t0 === "string" ? 11 : _context10.t0 === "number" ? 11 : _context10.t0 === "object" ? 19 : 19;
575
+ break;
576
+ case 11:
577
+ search = String(search);
578
+ _context10.t1 = this;
579
+ _context10.t2 = this;
580
+ _context10.next = 16;
581
+ return _global.gfunc.run_action("get", this.__web_path + "/" + search, params, {
582
+ fetchID: fetchID
583
+ });
584
+ case 16:
585
+ _context10.t3 = _context10.sent;
586
+ res = _context10.t1.ensure.call(_context10.t1, _context10.t2, _context10.t3);
587
+ return _context10.abrupt("break", 25);
588
+ case 19:
589
+ _context10.t4 = _object.object_first;
590
+ _context10.next = 22;
591
+ return this.get_list(search, readonly, fetchID);
592
+ case 22:
593
+ _context10.t5 = _context10.sent;
594
+ res = (0, _context10.t4)(_context10.t5);
595
+ return _context10.abrupt("break", 25);
596
+ case 25:
597
+ WebObject.setReadonly(res, readonly);
598
+ return _context10.abrupt("return", res);
599
+ case 27:
600
+ case "end":
601
+ return _context10.stop();
602
+ }
603
+ }, _callee10, this);
604
+ }));
605
+ function get_single() {
606
+ return _get_single.apply(this, arguments);
607
+ }
608
+ return get_single;
609
+ }()
275
610
  /**
276
611
  * Get a list of web objects
277
612
  * default order of parameters : search,readonly,fetchID
278
- */
279
- static async get_list(...p) {
280
- let search = p.shift();
281
- let readonly = p.shift();
282
- let fetchID = p.shift();
283
- if (!search)
284
- search = {};
285
- let result_items = await gfunc.run_action("get", this.__web_path, search, { fetchID: fetchID });
286
- const selftype = this.prototype;
287
- const res = WebObject.map_rowindex(WebObject.mapto(selftype, result_items, readonly));
288
- WebObject.setReadonly(res, readonly);
289
- return res;
290
- }
291
- }
292
- export default WebObject;
613
+ */
614
+ }, {
615
+ key: "get_list",
616
+ value: function () {
617
+ var _get_list = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
618
+ var _len6,
619
+ p,
620
+ _key6,
621
+ search,
622
+ readonly,
623
+ fetchID,
624
+ result_items,
625
+ selftype,
626
+ res,
627
+ _args11 = arguments;
628
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
629
+ while (1) switch (_context11.prev = _context11.next) {
630
+ case 0:
631
+ for (_len6 = _args11.length, p = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
632
+ p[_key6] = _args11[_key6];
633
+ }
634
+ search = p.shift();
635
+ readonly = p.shift();
636
+ fetchID = p.shift();
637
+ if (!search) search = {};
638
+ _context11.next = 7;
639
+ return _global.gfunc.run_action("get", this.__web_path, search, {
640
+ fetchID: fetchID
641
+ });
642
+ case 7:
643
+ result_items = _context11.sent;
644
+ selftype = this.prototype;
645
+ res = WebObject.map_rowindex(WebObject.mapto(selftype, result_items, readonly));
646
+ WebObject.setReadonly(res, readonly);
647
+ return _context11.abrupt("return", res);
648
+ case 12:
649
+ case "end":
650
+ return _context11.stop();
651
+ }
652
+ }, _callee11, this);
653
+ }));
654
+ function get_list() {
655
+ return _get_list.apply(this, arguments);
656
+ }
657
+ return get_list;
658
+ }()
659
+ }]);
660
+ return WebObject;
661
+ }(_SimpleObject2["default"]);
662
+ exports.WebObject = WebObject;
663
+ function _isValidSR2(s) {
664
+ if (_typeof(s) !== "object" && s == null) return false;
665
+ return s.insertedId || s._id || s._index_value && !Number.isNaN(s._index_value);
666
+ }
667
+ _defineProperty(WebObject, "__web_path", "");
668
+ _defineProperty(WebObject, "__web_type", "");
669
+ var _default = WebObject;
670
+ exports["default"] = _default;