@azrico/webobject 1.3.2 → 1.3.4

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,115 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = exports.MapableObject = void 0;
7
- var _ObjectArray = _interopRequireDefault(require("./ObjectArray"));
8
- var _object = require("@azrico/object");
9
- var _string = require("@azrico/string");
10
- var _uid = require("@azrico/uid");
11
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
12
- 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); }
13
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
14
- 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); } }
15
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
16
- 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; }
17
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
18
- 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); }
19
- /**
20
- * This object can be mapped and converted
21
- */
22
- var MapableObject = /*#__PURE__*/function () {
23
- function MapableObject() {
24
- _classCallCheck(this, MapableObject);
25
- _defineProperty(this, "__uid", void 0);
26
- _defineProperty(this, "__data_id", void 0);
27
- _defineProperty(this, "__table_id", void 0);
28
- _defineProperty(this, "__parent__table_id", void 0);
29
- _defineProperty(this, "__row_number", void 0);
30
- this.__uid = _uid.uid.localuid();
31
- this.__table_id = this.__uid;
32
- }
33
- _createClass(MapableObject, [{
34
- key: "getUID",
35
- value: function getUID() {
36
- return MapableObject.getUID(this);
37
- }
38
- /* -------------------------------------------------------------------------- */
39
- }], [{
40
- key: "getUID",
41
- value: function getUID(o) {
42
- return o.__uid;
43
- }
44
- }, {
45
- key: "mapto",
46
- value: function mapto(maptoType, objectlist) {
47
- var _this = this;
48
- var is_readonly = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
49
- for (var _len = arguments.length, p = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
50
- p[_key - 3] = arguments[_key];
51
- }
52
- if (objectlist === undefined) {
53
- if (maptoType === undefined) return [];
54
- if (maptoType instanceof Object) return [];
55
- objectlist = maptoType;
56
- maptoType = this;
57
- }
58
- if (objectlist == null) return [];
59
- if (objectlist instanceof _ObjectArray["default"]) objectlist = objectlist.getObjects();
60
- if (!Array.isArray(objectlist)) {
61
- objectlist = [objectlist];
62
- }
63
- return objectlist.map(function (r) {
64
- return _this.ensure.apply(_this, [maptoType, r, is_readonly].concat(p));
65
- });
66
- }
67
- }, {
68
- key: "ensure",
69
- value: function ensure(maptoType, object, is_readonly) {
70
- if (object === undefined) {
71
- object = maptoType;
72
- maptoType = this;
73
- }
74
- for (var _len2 = arguments.length, p = new Array(_len2 > 3 ? _len2 - 3 : 0), _key2 = 3; _key2 < _len2; _key2++) {
75
- p[_key2 - 3] = arguments[_key2];
76
- }
77
- return _object.object_ensure.apply(void 0, [maptoType, object, is_readonly].concat(p));
78
- }
79
- /* -------------------------------------------------------------------------- */
80
- }, {
81
- key: "map_rowindex",
82
- value: function map_rowindex(objectlist) {
83
- var _objectlist$map;
84
- var index = 0;
85
- return (_objectlist$map = objectlist === null || objectlist === void 0 ? void 0 : objectlist.map(function (r, i) {
86
- r.__row_number = ++index;
87
- return r;
88
- })) !== null && _objectlist$map !== void 0 ? _objectlist$map : [];
89
- }
90
- }, {
91
- key: "map_tableid",
92
- value: function map_tableid(objectlist) {
93
- var _objectlist$map2;
94
- var index = 0;
95
- return (_objectlist$map2 = objectlist === null || objectlist === void 0 ? void 0 : objectlist.map(function (r, i) {
96
- var _r$__uid;
97
- r.__table_id = (_r$__uid = r.__uid) !== null && _r$__uid !== void 0 ? _r$__uid : String(++index);
98
- return r;
99
- })) !== null && _objectlist$map2 !== void 0 ? _objectlist$map2 : [];
100
- }
101
- }, {
102
- key: "equals",
103
- value: function equals(a, b) {
104
- console.warn("Dont use the default equals method !");
105
- if (a == undefined || b == undefined) return false;
106
- if (_typeof(a) === "object") a = a.__uid;
107
- if (_typeof(b) === "object") b = b.__uid;
108
- return (0, _string.string_equals_ignorecase)(a, b);
109
- }
110
- }]);
111
- return MapableObject;
112
- }();
113
- exports.MapableObject = MapableObject;
114
- var _default = MapableObject;
115
- exports["default"] = _default;
@@ -1,15 +0,0 @@
1
- import SimpleObject from "./SimpleObject";
2
- export declare class MetaObject extends SimpleObject {
3
- id?: number;
4
- key: string;
5
- value: any;
6
- constructor(initObject: string, value: string);
7
- constructor(initObject: string, value: object);
8
- constructor(initObject: object, value: undefined);
9
- get_saveObject(): Promise<void>;
10
- static get_saveObject(obj: MetaObject): Promise<void>;
11
- Prepare(): Promise<boolean>;
12
- get isNew(): boolean;
13
- get isDeleted(): boolean;
14
- }
15
- export default MetaObject;
@@ -1,125 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = exports.MetaObject = void 0;
7
- var _object = require("@azrico/object");
8
- var _SimpleObject2 = _interopRequireDefault(require("./SimpleObject"));
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
10
- 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; }
11
- 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); } }
12
- 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); }); }; }
13
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
14
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15
- 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); } }
16
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
17
- 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); }
18
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
19
- 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); }; }
20
- 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); }
21
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
22
- 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; } }
23
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
24
- 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; }
25
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
26
- 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); }
27
- var MetaObject = /*#__PURE__*/function (_SimpleObject) {
28
- _inherits(MetaObject, _SimpleObject);
29
- var _super = _createSuper(MetaObject);
30
- function MetaObject(initObject, value) {
31
- var _this;
32
- _classCallCheck(this, MetaObject);
33
- _this = _super.call(this, false);
34
- _defineProperty(_assertThisInitialized(_this), "id", void 0);
35
- _defineProperty(_assertThisInitialized(_this), "key", "");
36
- _defineProperty(_assertThisInitialized(_this), "value", void 0);
37
- if (_typeof(initObject) === "object") {
38
- _this.id = initObject.id;
39
- _this.key = initObject.key;
40
- _this.value = initObject.value;
41
- } else if (typeof initObject === "string") {
42
- _this.key = initObject;
43
- _this.value = value;
44
- }
45
- _this.setOriginal();
46
- return _this;
47
- }
48
- _createClass(MetaObject, [{
49
- key: "get_saveObject",
50
- value: function () {
51
- var _get_saveObject = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
52
- return _regeneratorRuntime().wrap(function _callee$(_context) {
53
- while (1) switch (_context.prev = _context.next) {
54
- case 0:
55
- _context.next = 2;
56
- return MetaObject.get_saveObject(this);
57
- case 2:
58
- return _context.abrupt("return", _context.sent);
59
- case 3:
60
- case "end":
61
- return _context.stop();
62
- }
63
- }, _callee, this);
64
- }));
65
- function get_saveObject() {
66
- return _get_saveObject.apply(this, arguments);
67
- }
68
- return get_saveObject;
69
- }()
70
- }, {
71
- key: "Prepare",
72
- value: function () {
73
- var _Prepare = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
74
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
75
- while (1) switch (_context2.prev = _context2.next) {
76
- case 0:
77
- this.key = String(this.key);
78
- _context2.next = 3;
79
- return Promise.resolve(true);
80
- case 3:
81
- return _context2.abrupt("return", _context2.sent);
82
- case 4:
83
- case "end":
84
- return _context2.stop();
85
- }
86
- }, _callee2, this);
87
- }));
88
- function Prepare() {
89
- return _Prepare.apply(this, arguments);
90
- }
91
- return Prepare;
92
- }()
93
- }, {
94
- key: "isNew",
95
- get: function get() {
96
- return this.id == null || Number(this.id) <= 0;
97
- }
98
- }, {
99
- key: "isDeleted",
100
- get: function get() {
101
- return (0, _object.object_isExactlyEmpty)(this.value);
102
- }
103
- }], [{
104
- key: "get_saveObject",
105
- value: function () {
106
- var _get_saveObject2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(obj) {
107
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
108
- while (1) switch (_context3.prev = _context3.next) {
109
- case 0:
110
- case "end":
111
- return _context3.stop();
112
- }
113
- }, _callee3);
114
- }));
115
- function get_saveObject(_x) {
116
- return _get_saveObject2.apply(this, arguments);
117
- }
118
- return get_saveObject;
119
- }()
120
- }]);
121
- return MetaObject;
122
- }(_SimpleObject2["default"]);
123
- exports.MetaObject = MetaObject;
124
- var _default = MetaObject;
125
- exports["default"] = _default;
@@ -1,10 +0,0 @@
1
- type wobjInput<T> = ObjectArray<any> | ObjectArray<any>[] | T | T[];
2
- export declare class ObjectArray<T> {
3
- objArray: T[];
4
- constructor(initObject?: wobjInput<T>, mapto_type?: any);
5
- addObjects(initObject?: wobjInput<T>, mapto_type?: any): boolean;
6
- setObjects(initObject?: wobjInput<T>, mapto_type?: any): void;
7
- getObjects(): T[];
8
- static flattenWebObjects<T>(inputData: wobjInput<T>): T[];
9
- }
10
- export default ObjectArray;
@@ -1,72 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = exports.ObjectArray = void 0;
7
- 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); }
8
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
9
- 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); } }
10
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
11
- 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; }
12
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
13
- 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); }
14
- var ObjectArray = /*#__PURE__*/function () {
15
- /* -------------------------------------------------------------------------- */
16
- /* Values */
17
- /* -------------------------------------------------------------------------- */
18
-
19
- /* -------------------------------------------------------------------------- */
20
- /* Base */
21
- /* -------------------------------------------------------------------------- */
22
- function ObjectArray(initObject, mapto_type) {
23
- _classCallCheck(this, ObjectArray);
24
- _defineProperty(this, "objArray", []);
25
- this.setObjects(initObject, mapto_type);
26
- }
27
- _createClass(ObjectArray, [{
28
- key: "addObjects",
29
- value: function addObjects(initObject, mapto_type) {
30
- var _this = this;
31
- if (initObject == null) return false;
32
- var resultObjects = ObjectArray.flattenWebObjects(initObject);
33
- if (mapto_type) resultObjects = resultObjects.map(function (r) {
34
- return r instanceof mapto_type ? r : new mapto_type(r);
35
- });
36
- resultObjects.map(function (s) {
37
- return _this.objArray.push(s);
38
- });
39
- return true;
40
- }
41
- }, {
42
- key: "setObjects",
43
- value: function setObjects(initObject, mapto_type) {
44
- this.objArray = [];
45
- this.addObjects(initObject, mapto_type);
46
- }
47
- }, {
48
- key: "getObjects",
49
- value: function getObjects() {
50
- return this.objArray;
51
- }
52
- }], [{
53
- key: "flattenWebObjects",
54
- value: function flattenWebObjects(inputData) {
55
- if (inputData instanceof ObjectArray) {
56
- return ObjectArray.flattenWebObjects(inputData.objArray);
57
- } else if (Array.isArray(inputData)) {
58
- var final_result = [];
59
- inputData.map(function (ind) {
60
- ObjectArray.flattenWebObjects(ind).map(function (s) {
61
- return final_result.push(s);
62
- });
63
- });
64
- return final_result;
65
- } else return [inputData];
66
- }
67
- }]);
68
- return ObjectArray;
69
- }();
70
- exports.ObjectArray = ObjectArray;
71
- var _default = ObjectArray;
72
- exports["default"] = _default;
@@ -1,90 +0,0 @@
1
- import { PropOf, WriteablePropOf } from "./SimpleObject";
2
- import SimpleObject from "./SimpleObject";
3
- import { saveResultType } from "./SimpleObject";
4
- /**
5
- * This class manages the events of an Simple Object
6
- */
7
- export declare class ObjectManager<ObjType extends SimpleObject> {
8
- __eventList: any;
9
- __eventPrefix?: string;
10
- __sendEvents: boolean;
11
- __currentObject?: ObjType | null;
12
- __options?: object;
13
- notifyChanged(type: string, key: PropOf<ObjType>, value?: any, subvalue?: string): Promise<false | void>;
14
- get obj(): ObjType | undefined;
15
- /**
16
- * Get the object this manager is managing
17
- * @returns the object
18
- */
19
- getObject(): ObjType | undefined;
20
- /**
21
- * Set the object this manager is managing
22
- * @param toObj
23
- * @returns
24
- */
25
- setObject(toObj: ObjType | undefined): boolean;
26
- get isChanged(): boolean;
27
- get isDeleted(): boolean;
28
- get d(): any;
29
- get canModify(): boolean;
30
- get isNew(): boolean;
31
- get isSaved(): boolean;
32
- get __cache_name(): string;
33
- getSaveResult(): any;
34
- getSaveResultType(): saveResultType | null;
35
- setSaveResult(toObj: any, type: saveResultType): void | undefined;
36
- apply_changes(): boolean;
37
- getValue(key: PropOf<ObjType>, original?: boolean): import("./SimpleObject").PropType<ObjType, any> | undefined;
38
- get: (key: PropOf<ObjType>, original?: boolean) => import("./SimpleObject").PropType<ObjType, any> | undefined;
39
- /**
40
- * set value
41
- * @param key
42
- * @param value
43
- * @return true if changed , false otherwise
44
- */
45
- setValue(key: WriteablePropOf<ObjType>, value: any): Promise<boolean>;
46
- /**
47
- * set key of subObject
48
- * @param key
49
- * @param value
50
- * @param subvalue
51
- * @return true if changed , false otherwise
52
- */
53
- setSubValue(key: PropOf<ObjType>, objKey: string, subvalue: any): Promise<boolean>;
54
- pushValue(key: PropOf<ObjType>, value: any): Promise<false | NonNullable<Awaited<ObjType[any]>>>;
55
- getIndexOrID(): number | string;
56
- getIndex(): number;
57
- getID(): string;
58
- event_run(eventName: string, ...params: any): Promise<void>;
59
- event_use(name: string, runEvent: (...inputdata: any) => any, onlyOn?: any, runOnce?: boolean): any;
60
- event_remove(name: string, uname: string): boolean;
61
- event_add(name: string, uname: string, runEvent: (...inputdata: any) => any, onlyOn?: any, runOnce?: boolean): Promise<void>;
62
- events_stop(): void;
63
- events_clear(): void;
64
- static events_clear(obj: ObjectManager<any>): void;
65
- /**
66
- * Set an option to some value, if its already equal to the value it will be deleted instead
67
- * @param key
68
- * @param value
69
- * @returns
70
- */
71
- toggleOption(key: string, value: any): Promise<void>;
72
- setOption(key: string, value: any): Promise<void>;
73
- /**
74
- * Sets an option then does an action,
75
- * after the action is run, updates the option again
76
- * @param key
77
- * @param value
78
- * @param nextvalue
79
- * @param action
80
- */
81
- holdOption(key: string, value: any, nextvalue: any, action: Function): Promise<void>;
82
- getOption(key: string): any;
83
- addError(title?: string, message?: string, sendToRegister?: boolean | "auto"): any[] | undefined;
84
- getErrors(): any[];
85
- clearErrors(): boolean;
86
- static addError(o?: ObjectManager<any>, title?: string, message?: string, sendToRegister?: boolean | "auto"): any[] | undefined;
87
- static getErrors(o: ObjectManager<any>): any[];
88
- static clearErrors(o: ObjectManager<any>): boolean;
89
- }
90
- export default ObjectManager;