@azrico/webobject 1.4.162 → 1.4.163
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.d.ts +1 -0
- package/dist/index.js +16 -0
- package/dist/src/WebObjects/ParentWebObject.d.ts +24 -0
- package/dist/src/WebObjects/ParentWebObject.js +121 -0
- package/dist/src/WebObjects/WebObject.d.ts +120 -0
- package/dist/src/WebObjects/WebObject.js +1319 -0
- package/dist/src/WebObjects/WebObjectManager.d.ts +65 -0
- package/dist/src/WebObjects/WebObjectManager.js +806 -0
- package/dist/src/WebObjects/WebObjectPathHelper.d.ts +36 -0
- package/dist/src/WebObjects/WebObjectPathHelper.js +155 -0
- package/dist/src/WebObjects/WebObjectPathHelper.test.d.ts +1 -0
- package/dist/src/WebObjects/WebObjectPathHelper.test.js +122 -0
- package/dist/src/index.d.ts +10 -0
- package/dist/src/index.js +115 -0
- package/dist/src/structs/DummyObject.d.ts +5 -0
- package/dist/src/structs/DummyObject.js +32 -0
- package/dist/src/structs/MapableObject.d.ts +43 -0
- package/dist/src/structs/MapableObject.js +123 -0
- package/dist/src/structs/MetaObject.d.ts +15 -0
- package/dist/src/structs/MetaObject.js +121 -0
- package/dist/src/structs/ObjectArray.d.ts +10 -0
- package/dist/src/structs/ObjectArray.js +68 -0
- package/dist/src/structs/ObjectManager.d.ts +123 -0
- package/dist/src/structs/ObjectManager.js +737 -0
- package/dist/src/structs/ObjectWithTemp.d.ts +11 -0
- package/dist/src/structs/ObjectWithTemp.js +66 -0
- package/dist/src/structs/SimpleObject.d.ts +266 -0
- package/dist/src/structs/SimpleObject.js +1586 -0
- package/package.json +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This object supports temp values
|
|
3
|
+
*/
|
|
4
|
+
export declare class ObjectWithTemp {
|
|
5
|
+
#private;
|
|
6
|
+
protected __temp: any;
|
|
7
|
+
constructor();
|
|
8
|
+
getTemp: (key: string) => any;
|
|
9
|
+
setTemp(key: string, value: any): Promise<boolean>;
|
|
10
|
+
}
|
|
11
|
+
export default ObjectWithTemp;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports["default"] = exports.ObjectWithTemp = void 0;
|
|
8
|
+
var _object = require("@azrico/object");
|
|
9
|
+
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 e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
10
|
+
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); } }
|
|
11
|
+
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); }); }; }
|
|
12
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
13
|
+
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); } }
|
|
14
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
15
|
+
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
|
16
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
17
|
+
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; }
|
|
18
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
19
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
20
|
+
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
|
21
|
+
/**
|
|
22
|
+
* This object supports temp values
|
|
23
|
+
*/
|
|
24
|
+
var _ObjectWithTemp_brand = /*#__PURE__*/new WeakSet();
|
|
25
|
+
var ObjectWithTemp = exports.ObjectWithTemp = /*#__PURE__*/function () {
|
|
26
|
+
function ObjectWithTemp() {
|
|
27
|
+
_classCallCheck(this, ObjectWithTemp);
|
|
28
|
+
/* ---------------------------------- temp ---------------------------------- */
|
|
29
|
+
_classPrivateMethodInitSpec(this, _ObjectWithTemp_brand);
|
|
30
|
+
_defineProperty(this, "__temp", undefined);
|
|
31
|
+
_defineProperty(this, "getTemp", _assertClassBrand(_ObjectWithTemp_brand, this, _getTempProperty));
|
|
32
|
+
}
|
|
33
|
+
return _createClass(ObjectWithTemp, [{
|
|
34
|
+
key: "setTemp",
|
|
35
|
+
value: function () {
|
|
36
|
+
var _setTemp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(key, value) {
|
|
37
|
+
var isValueChanged;
|
|
38
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
39
|
+
while (1) switch (_context.prev = _context.next) {
|
|
40
|
+
case 0:
|
|
41
|
+
isValueChanged = false;
|
|
42
|
+
isValueChanged = _assertClassBrand(_ObjectWithTemp_brand, this, _getTempProperty).call(this, key) != value;
|
|
43
|
+
_assertClassBrand(_ObjectWithTemp_brand, this, _setTempProperty).call(this, key, value);
|
|
44
|
+
return _context.abrupt("return", isValueChanged);
|
|
45
|
+
case 4:
|
|
46
|
+
case "end":
|
|
47
|
+
return _context.stop();
|
|
48
|
+
}
|
|
49
|
+
}, _callee, this);
|
|
50
|
+
}));
|
|
51
|
+
function setTemp(_x, _x2) {
|
|
52
|
+
return _setTemp.apply(this, arguments);
|
|
53
|
+
}
|
|
54
|
+
return setTemp;
|
|
55
|
+
}()
|
|
56
|
+
}]);
|
|
57
|
+
}();
|
|
58
|
+
function _getTempProperty(key) {
|
|
59
|
+
if (this.__temp == null) return undefined;
|
|
60
|
+
return (0, _object.object_get)(this.__temp, key);
|
|
61
|
+
}
|
|
62
|
+
function _setTempProperty(key, value) {
|
|
63
|
+
if (this.__temp == null) this.__temp = {};
|
|
64
|
+
return (0, _object.object_set)(this.__temp, key, value);
|
|
65
|
+
}
|
|
66
|
+
var _default = exports["default"] = ObjectWithTemp;
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import { PropType, WriteablePropOf, PropOf, Ensure } from "@azrico/types";
|
|
2
|
+
import { formatObject } from "@azrico/convert";
|
|
3
|
+
import { MapableObject } from "./MapableObject";
|
|
4
|
+
import ObjectManager from "./ObjectManager";
|
|
5
|
+
export type saveResultType = "normal" | "nothing" | "error" | "canceled";
|
|
6
|
+
export type saveType = "normal" | "quick";
|
|
7
|
+
export type sendChangesType = boolean | "auto";
|
|
8
|
+
export type WithManager<T extends SimpleObject> = Ensure<T, "manager">;
|
|
9
|
+
export type WithManagerOrNot<T extends SimpleObject> = T | WithManager<T>;
|
|
10
|
+
export declare class SimpleObject extends MapableObject {
|
|
11
|
+
#private;
|
|
12
|
+
static readonly __db_name: string;
|
|
13
|
+
static readonly __object_name: string;
|
|
14
|
+
static readonly __unchangeables?: string[];
|
|
15
|
+
static readonly __changeables?: string[];
|
|
16
|
+
static readonly __protectedProperties?: string[];
|
|
17
|
+
static readonly __functionProperties?: string[];
|
|
18
|
+
static readonly __formatList?: formatObject;
|
|
19
|
+
static readonly __extraProperties?: string[];
|
|
20
|
+
static readonly __childTypes?: any[];
|
|
21
|
+
static readonly __importColumns?: string[];
|
|
22
|
+
static readonly __checkProperties?: string[];
|
|
23
|
+
static readonly __use_delta: boolean;
|
|
24
|
+
_static(): Function;
|
|
25
|
+
protected __originalobject?: this;
|
|
26
|
+
protected __delta: Partial<this>;
|
|
27
|
+
protected __changed: boolean;
|
|
28
|
+
protected __lastChanged?: string;
|
|
29
|
+
protected __is_readonly?: boolean;
|
|
30
|
+
protected __throw_errors?: boolean;
|
|
31
|
+
_deleted?: boolean;
|
|
32
|
+
_archived?: boolean;
|
|
33
|
+
_deletedBy?: string;
|
|
34
|
+
_locked?: boolean;
|
|
35
|
+
protected __errors?: any[];
|
|
36
|
+
protected __showErrors?: boolean;
|
|
37
|
+
protected __refresh_functions?: {
|
|
38
|
+
[key: string]: any;
|
|
39
|
+
};
|
|
40
|
+
protected __saveResultObject?: any;
|
|
41
|
+
protected __saveResultIsSuccess: boolean;
|
|
42
|
+
protected __saveResultType?: saveResultType;
|
|
43
|
+
_id: string;
|
|
44
|
+
_index_key: string;
|
|
45
|
+
_index_value: number;
|
|
46
|
+
constructor(is_readonly?: boolean);
|
|
47
|
+
/**
|
|
48
|
+
* load all properties in `initObject` into the current object
|
|
49
|
+
* @param initObject
|
|
50
|
+
* @param fullUpdate
|
|
51
|
+
* @returns
|
|
52
|
+
*/
|
|
53
|
+
loadValues(initObject: any, fullUpdate?: boolean): boolean;
|
|
54
|
+
static loadValues(obj: SimpleObject, initObject: any, fullUpdate?: boolean): boolean;
|
|
55
|
+
static getValue<T extends SimpleObject, MKey extends PropOf<T>>(o: T, key: MKey, original?: boolean): PropType<T, MKey> | undefined;
|
|
56
|
+
getValue: <MKey extends keyof this>(key: MKey, original?: boolean) => PropType<this, MKey>;
|
|
57
|
+
get: <MKey extends keyof this>(key: MKey, original?: boolean) => PropType<this, MKey>;
|
|
58
|
+
/**
|
|
59
|
+
* set value
|
|
60
|
+
* @param key
|
|
61
|
+
* @param value
|
|
62
|
+
* @return true if changed , false otherwise
|
|
63
|
+
*/
|
|
64
|
+
setValue(key: WriteablePropOf<this>, value: any, shouldNotify?: sendChangesType): Promise<boolean>;
|
|
65
|
+
/**
|
|
66
|
+
* set value
|
|
67
|
+
* @param key
|
|
68
|
+
* @param value
|
|
69
|
+
* @return true if changed , false otherwise
|
|
70
|
+
*/
|
|
71
|
+
set: (key: WriteablePropOf<this>, value: any, shouldNotify?: sendChangesType) => Promise<boolean>;
|
|
72
|
+
setTemp(key: string, value: any, sendChanges?: sendChangesType): Promise<boolean>;
|
|
73
|
+
clearRefreshFunction(): Promise<void>;
|
|
74
|
+
setRefreshFunction(new_fnc: any): Promise<any>;
|
|
75
|
+
addRefreshFunction(new_fnc: any): any;
|
|
76
|
+
runRefreshFunction(...params: any): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* calls `setValue` function for all props of `setObj`
|
|
79
|
+
* @param setObj
|
|
80
|
+
* @param changeablesOnly only updates the `__changeables` fields
|
|
81
|
+
* @returns
|
|
82
|
+
*/
|
|
83
|
+
setAll<K extends WriteablePropOf<this>>(setObj: Partial<{
|
|
84
|
+
[key in K]: any;
|
|
85
|
+
}>, changeablesOnly?: boolean): Promise<boolean>;
|
|
86
|
+
/**
|
|
87
|
+
* set value of a key only if the value is empty (null,undef,"")
|
|
88
|
+
* @param key
|
|
89
|
+
* @param value
|
|
90
|
+
* @returns
|
|
91
|
+
*/
|
|
92
|
+
setDefaultValue(key: WriteablePropOf<this>, value: any): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* set value of a key to now date time
|
|
95
|
+
* @param key
|
|
96
|
+
* @param value
|
|
97
|
+
* @returns
|
|
98
|
+
*/
|
|
99
|
+
setDefaultValueNow: (key: PropOf<this>) => boolean;
|
|
100
|
+
/**
|
|
101
|
+
* set value of a key only if the value is empty (null,undef,"")
|
|
102
|
+
* @param key
|
|
103
|
+
* @param value
|
|
104
|
+
* @returns
|
|
105
|
+
*/
|
|
106
|
+
setDefault: (key: WriteablePropOf<this>, value: any) => boolean;
|
|
107
|
+
/**
|
|
108
|
+
* set key of subObject
|
|
109
|
+
* @param key
|
|
110
|
+
* @param value
|
|
111
|
+
* @param subvalue
|
|
112
|
+
* @return true if changed , false otherwise
|
|
113
|
+
*/
|
|
114
|
+
setSubValue<MKey extends PropOf<this>>(key: MKey, objKey: string, subvalue: any, sendChanges?: sendChangesType): Promise<boolean>;
|
|
115
|
+
getSubValue: (key: PropOf<this>, subkey: string, original?: boolean) => any;
|
|
116
|
+
/**
|
|
117
|
+
* Push a single value to array property
|
|
118
|
+
* @param key
|
|
119
|
+
* @param value
|
|
120
|
+
* @param sendChanges
|
|
121
|
+
* @returns
|
|
122
|
+
*/
|
|
123
|
+
pushValue<MKey extends PropOf<this>>(key: MKey, value: any, sendChanges?: sendChangesType): Promise<this[MKey] | false>;
|
|
124
|
+
/**
|
|
125
|
+
* Push a list of values to array property
|
|
126
|
+
* @param key
|
|
127
|
+
* @param values
|
|
128
|
+
* @param sendChanges
|
|
129
|
+
* @returns
|
|
130
|
+
*/
|
|
131
|
+
pushValues<MKey extends PropOf<this>>(key: MKey, values: any[], sendChanges?: sendChangesType): Promise<this[MKey] | false>;
|
|
132
|
+
/**
|
|
133
|
+
*
|
|
134
|
+
* @param type
|
|
135
|
+
* @param key
|
|
136
|
+
* @param value
|
|
137
|
+
* @param subvalue
|
|
138
|
+
* @returns true if manager was notified. false otherwise
|
|
139
|
+
*/
|
|
140
|
+
notifyChanged<MKey extends PropOf<this>>(type: string, key: MKey | string, value: any, subvalue?: any): Promise<false | any[] | undefined>;
|
|
141
|
+
/**
|
|
142
|
+
* check if a key can be changed on an object
|
|
143
|
+
* @param object the object we are checking
|
|
144
|
+
* @param key key of the object
|
|
145
|
+
* @param useExtraProps should we check extra props?
|
|
146
|
+
* @returns
|
|
147
|
+
*/
|
|
148
|
+
static canChangeKey(object: SimpleObject, key: string, options: {
|
|
149
|
+
useExtraProps?: boolean;
|
|
150
|
+
ignoreProtected?: boolean;
|
|
151
|
+
}): boolean;
|
|
152
|
+
static hasIllegalChanges(referenceObject: any, changesObject: any, updaterUser: any): boolean;
|
|
153
|
+
/**
|
|
154
|
+
* Apply all the changes and empty the delta object
|
|
155
|
+
*/
|
|
156
|
+
apply_changes(): boolean;
|
|
157
|
+
/**
|
|
158
|
+
* apply changes for the given fields
|
|
159
|
+
* @param key
|
|
160
|
+
* @returns
|
|
161
|
+
*/
|
|
162
|
+
apply(keylist: PropOf<this> | Array<PropOf<this>>): boolean;
|
|
163
|
+
/**
|
|
164
|
+
* set the value to its original
|
|
165
|
+
* @param key
|
|
166
|
+
*/
|
|
167
|
+
reset(key: WriteablePropOf<this>, shouldNotify?: sendChangesType): Promise<boolean>;
|
|
168
|
+
/**
|
|
169
|
+
* reset all values back to their original
|
|
170
|
+
* difference between this and clear_changes is that this function also calls on_change
|
|
171
|
+
* @param key
|
|
172
|
+
*/
|
|
173
|
+
resetAll(shouldNotify?: sendChangesType): Promise<boolean>;
|
|
174
|
+
/**
|
|
175
|
+
* clear and discard all changes
|
|
176
|
+
* does not call any on_change functions
|
|
177
|
+
* @returns
|
|
178
|
+
*/
|
|
179
|
+
clear_changes(): boolean;
|
|
180
|
+
/**
|
|
181
|
+
* clear and discard all temp values
|
|
182
|
+
* @returns
|
|
183
|
+
*/
|
|
184
|
+
clear_cache(): boolean;
|
|
185
|
+
/**
|
|
186
|
+
* Sets readonly property on given objects
|
|
187
|
+
* @param objs array of given objects or a single object
|
|
188
|
+
* @param readonlyval readonly
|
|
189
|
+
* @param clearChanges should we clean the changes after setting readonly
|
|
190
|
+
*/
|
|
191
|
+
static setReadonly(objs?: SimpleObject[] | SimpleObject, readonlyval?: boolean, clearChanges?: boolean): void;
|
|
192
|
+
static setThrowErrors(objs?: SimpleObject[] | SimpleObject, throwErr?: boolean): void;
|
|
193
|
+
get __object_name(): string;
|
|
194
|
+
get __db_name(): string;
|
|
195
|
+
get isChanged(): boolean;
|
|
196
|
+
get isArchived(): boolean;
|
|
197
|
+
set isArchived(v: boolean);
|
|
198
|
+
get isDeleted(): boolean;
|
|
199
|
+
get isLocked(): boolean;
|
|
200
|
+
set isLocked(v: boolean);
|
|
201
|
+
set isDeleted(v: boolean);
|
|
202
|
+
get d(): Partial<this>;
|
|
203
|
+
get allproperties(): Partial<this>;
|
|
204
|
+
get canModify(): boolean;
|
|
205
|
+
get __changeables(): string[];
|
|
206
|
+
get __unchangeables(): string[];
|
|
207
|
+
get __use_delta(): boolean;
|
|
208
|
+
get isSaved(): boolean;
|
|
209
|
+
get isNew(): boolean;
|
|
210
|
+
get lastChanged(): string;
|
|
211
|
+
get manager(): ObjectManager<any> | undefined;
|
|
212
|
+
get_managerClass: () => ObjectManager<any> | undefined;
|
|
213
|
+
/**
|
|
214
|
+
* @deprecated use setManager
|
|
215
|
+
* @param mng
|
|
216
|
+
*/
|
|
217
|
+
set_managerClass(mng: any): boolean | undefined;
|
|
218
|
+
/**
|
|
219
|
+
* update the manager class for this object
|
|
220
|
+
* @param mng
|
|
221
|
+
*/
|
|
222
|
+
setManager(mng: any): boolean | undefined;
|
|
223
|
+
static isDeleted<T extends SimpleObject>(obj: T): boolean;
|
|
224
|
+
getIndexOrID(): number | string;
|
|
225
|
+
getIndex(): number;
|
|
226
|
+
getID(): string;
|
|
227
|
+
static getIndexOrID(o: any): number;
|
|
228
|
+
static getIndex(o: any): number;
|
|
229
|
+
static getID(o: any): string;
|
|
230
|
+
event_run(eventName: string, ...params: any): Promise<any[] | undefined>;
|
|
231
|
+
event_use(name: string, runEvent: (...inputdata: any) => any, onlyOn?: any, runOnce?: boolean): any;
|
|
232
|
+
event_remove(name: string, uname: string): boolean | undefined;
|
|
233
|
+
event_add(name: string, uname: string, runEvent: (...inputdata: any) => any, onlyOn?: any, runOnce?: boolean): Promise<void>;
|
|
234
|
+
getOriginal(): this | undefined;
|
|
235
|
+
setOriginal(toObj?: null | 0 | any): this | undefined;
|
|
236
|
+
static setOriginal<T>(obj: T, toObj?: null | 0 | any): T | undefined;
|
|
237
|
+
static getOriginal<T extends SimpleObject>(obj: T): T | undefined;
|
|
238
|
+
addError(title?: string, message?: string, sendToRegister?: boolean | "auto"): any[] | undefined;
|
|
239
|
+
clearErrors(): boolean;
|
|
240
|
+
getErrors(): any[];
|
|
241
|
+
static addError(o?: SimpleObject, title?: string, message?: string, sendToRegister?: boolean | "auto"): any[] | undefined;
|
|
242
|
+
static getErrors(o: SimpleObject): any[];
|
|
243
|
+
static clearErrors(o: SimpleObject): boolean;
|
|
244
|
+
/**
|
|
245
|
+
* Checks if the given object is a valid and truthy save result
|
|
246
|
+
* @param result_object
|
|
247
|
+
* @returns
|
|
248
|
+
*/
|
|
249
|
+
static isResultValid(result_object: any, sub?: boolean): any;
|
|
250
|
+
/**
|
|
251
|
+
* set the response of last save from site
|
|
252
|
+
* and its type
|
|
253
|
+
* @param toObj
|
|
254
|
+
*/
|
|
255
|
+
setSaveResult(toObj: any, type?: saveResultType | "auto", registerErrors?: boolean): saveResultType;
|
|
256
|
+
getSaveResult(original?: boolean): any;
|
|
257
|
+
getSaveResultType(): saveResultType;
|
|
258
|
+
/** did we create on the last save */
|
|
259
|
+
getIsLastSaveCreate(): boolean;
|
|
260
|
+
static setTemp(obj: SimpleObject | any, key: string, value: any, sendChanges?: sendChangesType): Promise<boolean | undefined>;
|
|
261
|
+
static factoryClear(obj: SimpleObject): void;
|
|
262
|
+
static delete_cache(context?: string): Promise<void>;
|
|
263
|
+
static get_canModify(o: SimpleObject): boolean;
|
|
264
|
+
static equals(a?: SimpleObject | any, b?: SimpleObject | any): boolean;
|
|
265
|
+
}
|
|
266
|
+
export default SimpleObject;
|