@azrico/webobject 1.5.69 → 1.5.71
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 -1
- package/dist/src/WebObjects/ParentWebObject.d.ts +24 -24
- package/dist/src/WebObjects/ParentWebObject.js +7 -7
- package/dist/src/WebObjects/WebObject.d.ts +153 -153
- package/dist/src/WebObjects/WebObject.js +476 -561
- package/dist/src/WebObjects/WebObjectHelper.d.ts +9 -9
- package/dist/src/WebObjects/WebObjectHelper.js +4 -4
- package/dist/src/WebObjects/WebObjectHelper.test.d.ts +1 -1
- package/dist/src/WebObjects/WebObjectHelper.test.js +1 -1
- package/dist/src/WebObjects/WebObjectManager.d.ts +68 -68
- package/dist/src/WebObjects/WebObjectManager.js +303 -350
- package/dist/src/WebObjects/WebObjectPathHelper.d.ts +36 -36
- package/dist/src/WebObjects/WebObjectPathHelper.js +31 -39
- package/dist/src/WebObjects/WebObjectPathHelper.test.d.ts +1 -1
- package/dist/src/WebObjects/WebObjectPathHelper.test.js +55 -61
- package/dist/src/index.d.ts +10 -10
- package/dist/src/structs/DummyObject.d.ts +5 -5
- package/dist/src/structs/DummyObject.js +1 -1
- package/dist/src/structs/MapableObject.d.ts +43 -43
- package/dist/src/structs/MapableObject.js +3 -3
- package/dist/src/structs/MetaObject.d.ts +15 -15
- package/dist/src/structs/MetaObject.js +19 -25
- package/dist/src/structs/ObjectArray.d.ts +10 -10
- package/dist/src/structs/ObjectArray.js +1 -1
- package/dist/src/structs/ObjectManager.d.ts +140 -140
- package/dist/src/structs/ObjectManager.js +202 -223
- package/dist/src/structs/ObjectWithTemp.d.ts +17 -17
- package/dist/src/structs/ObjectWithTemp.js +13 -17
- package/dist/src/structs/SimpleObject.d.ts +318 -303
- package/dist/src/structs/SimpleObject.js +423 -467
- package/package.json +63 -82
|
@@ -23,9 +23,9 @@ function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new T
|
|
|
23
23
|
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
24
24
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
25
25
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
26
|
-
function _toPrimitive(t,
|
|
27
|
-
/**
|
|
28
|
-
* This object can be mapped and converted
|
|
26
|
+
function _toPrimitive(t, e) { if ("object" != _typeof(t) || !t) return t; var r; if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) { var i = r.call(t, e || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); }
|
|
27
|
+
/**
|
|
28
|
+
* This object can be mapped and converted
|
|
29
29
|
*/
|
|
30
30
|
var MapableObject = exports.MapableObject = /*#__PURE__*/function (_ObjectWithTemp) {
|
|
31
31
|
function MapableObject() {
|
|
@@ -1,15 +1,15 @@
|
|
|
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
|
+
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;
|
|
@@ -7,7 +7,8 @@ exports["default"] = exports.MetaObject = void 0;
|
|
|
7
7
|
var _object = require("@azrico/object");
|
|
8
8
|
var _SimpleObject2 = _interopRequireDefault(require("./SimpleObject"));
|
|
9
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
10
|
-
function
|
|
10
|
+
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
11
|
+
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
11
12
|
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
12
13
|
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
13
14
|
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); }
|
|
@@ -23,7 +24,7 @@ function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new T
|
|
|
23
24
|
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
24
25
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
25
26
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
26
|
-
function _toPrimitive(t,
|
|
27
|
+
function _toPrimitive(t, e) { if ("object" != _typeof(t) || !t) return t; var r; if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) { var i = r.call(t, e || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); }
|
|
27
28
|
var MetaObject = exports.MetaObject = /*#__PURE__*/function (_SimpleObject) {
|
|
28
29
|
function MetaObject(initObject, value) {
|
|
29
30
|
var _this;
|
|
@@ -47,17 +48,14 @@ var MetaObject = exports.MetaObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
47
48
|
return _createClass(MetaObject, [{
|
|
48
49
|
key: "get_saveObject",
|
|
49
50
|
value: function () {
|
|
50
|
-
var _get_saveObject = _asyncToGenerator(/*#__PURE__*/
|
|
51
|
-
return
|
|
52
|
-
while (1) switch (_context.
|
|
51
|
+
var _get_saveObject = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
52
|
+
return _regenerator().w(function (_context) {
|
|
53
|
+
while (1) switch (_context.n) {
|
|
53
54
|
case 0:
|
|
54
|
-
_context.
|
|
55
|
+
_context.n = 1;
|
|
55
56
|
return MetaObject.get_saveObject(this);
|
|
56
|
-
case
|
|
57
|
-
return _context.
|
|
58
|
-
case 3:
|
|
59
|
-
case "end":
|
|
60
|
-
return _context.stop();
|
|
57
|
+
case 1:
|
|
58
|
+
return _context.a(2, _context.v);
|
|
61
59
|
}
|
|
62
60
|
}, _callee, this);
|
|
63
61
|
}));
|
|
@@ -69,18 +67,15 @@ var MetaObject = exports.MetaObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
69
67
|
}, {
|
|
70
68
|
key: "Prepare",
|
|
71
69
|
value: function () {
|
|
72
|
-
var _Prepare = _asyncToGenerator(/*#__PURE__*/
|
|
73
|
-
return
|
|
74
|
-
while (1) switch (_context2.
|
|
70
|
+
var _Prepare = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
71
|
+
return _regenerator().w(function (_context2) {
|
|
72
|
+
while (1) switch (_context2.n) {
|
|
75
73
|
case 0:
|
|
76
74
|
this.key = String(this.key);
|
|
77
|
-
_context2.
|
|
75
|
+
_context2.n = 1;
|
|
78
76
|
return Promise.resolve(true);
|
|
79
|
-
case
|
|
80
|
-
return _context2.
|
|
81
|
-
case 4:
|
|
82
|
-
case "end":
|
|
83
|
-
return _context2.stop();
|
|
77
|
+
case 1:
|
|
78
|
+
return _context2.a(2, _context2.v);
|
|
84
79
|
}
|
|
85
80
|
}, _callee2, this);
|
|
86
81
|
}));
|
|
@@ -102,12 +97,11 @@ var MetaObject = exports.MetaObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
102
97
|
}], [{
|
|
103
98
|
key: "get_saveObject",
|
|
104
99
|
value: function () {
|
|
105
|
-
var _get_saveObject2 = _asyncToGenerator(/*#__PURE__*/
|
|
106
|
-
return
|
|
107
|
-
while (1) switch (_context3.
|
|
100
|
+
var _get_saveObject2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(obj) {
|
|
101
|
+
return _regenerator().w(function (_context3) {
|
|
102
|
+
while (1) switch (_context3.n) {
|
|
108
103
|
case 0:
|
|
109
|
-
|
|
110
|
-
return _context3.stop();
|
|
104
|
+
return _context3.a(2);
|
|
111
105
|
}
|
|
112
106
|
}, _callee3);
|
|
113
107
|
}));
|
|
@@ -1,10 +1,10 @@
|
|
|
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
|
+
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;
|
|
@@ -10,7 +10,7 @@ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o =
|
|
|
10
10
|
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
11
11
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
12
12
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
13
|
-
function _toPrimitive(t,
|
|
13
|
+
function _toPrimitive(t, e) { if ("object" != _typeof(t) || !t) return t; var r; if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) { var i = r.call(t, e || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); }
|
|
14
14
|
var ObjectArray = exports.ObjectArray = /*#__PURE__*/function () {
|
|
15
15
|
/* -------------------------------------------------------------------------- */
|
|
16
16
|
/* Base */
|
|
@@ -1,140 +1,140 @@
|
|
|
1
|
-
import { PropOf, PropType, WriteablePropOf } from "@azrico/types";
|
|
2
|
-
import EventContext from "@azrico/event";
|
|
3
|
-
import SimpleObject, { WithManager } from "./SimpleObject";
|
|
4
|
-
import { saveResultType, sendChangesType } from "./SimpleObject";
|
|
5
|
-
import { ClassType } from "@azrico/types";
|
|
6
|
-
import MapableObject from "./MapableObject";
|
|
7
|
-
/**
|
|
8
|
-
* This class manages the events of an Simple Object
|
|
9
|
-
*/
|
|
10
|
-
export declare class ObjectManager<ObjType extends SimpleObject> extends MapableObject {
|
|
11
|
-
__eventContext: EventContext |
|
|
12
|
-
protected static readonly __object_type: () => typeof SimpleObject | ClassType<SimpleObject>;
|
|
13
|
-
protected __last_object_data: {
|
|
14
|
-
[key: string]: string;
|
|
15
|
-
};
|
|
16
|
-
protected __currentObject?: ObjType | null;
|
|
17
|
-
protected __options?: object;
|
|
18
|
-
__object_nullable: boolean;
|
|
19
|
-
constructor(defaultObject?: ObjType);
|
|
20
|
-
notifyChanged(type: string, key: PropOf<ObjType> | string, value?: any, subvalue?: string): Promise<false | any[]>;
|
|
21
|
-
/**
|
|
22
|
-
* Get the object this manager is managing
|
|
23
|
-
* @returns the object
|
|
24
|
-
*/
|
|
25
|
-
get obj(): WithManager<ObjType> | undefined;
|
|
26
|
-
/**
|
|
27
|
-
* Get the object this manager is managing
|
|
28
|
-
* @returns the object
|
|
29
|
-
*/
|
|
30
|
-
getObject(): WithManager<ObjType> | undefined;
|
|
31
|
-
/**
|
|
32
|
-
* Set the object this manager is managing
|
|
33
|
-
* @param toObj
|
|
34
|
-
* @returns
|
|
35
|
-
*/
|
|
36
|
-
setObject(toObj: ObjType | undefined): boolean;
|
|
37
|
-
get d(): any;
|
|
38
|
-
get isChanged(): boolean;
|
|
39
|
-
get isDeleted(): boolean;
|
|
40
|
-
get isArchived(): boolean;
|
|
41
|
-
get isLocked(): boolean;
|
|
42
|
-
get canModify(): boolean;
|
|
43
|
-
get isNew(): boolean;
|
|
44
|
-
get isSaved(): boolean;
|
|
45
|
-
getSaveResult(): any | null;
|
|
46
|
-
getSaveResultType(): saveResultType | null;
|
|
47
|
-
setSaveResult(toObj: any, type: saveResultType): saveResultType | undefined;
|
|
48
|
-
apply_changes(): boolean;
|
|
49
|
-
get(key: PropOf<ObjType>, original?: boolean): PropType<ObjType, any> | null;
|
|
50
|
-
/**
|
|
51
|
-
* use a property from the object, this will return latest value of the property
|
|
52
|
-
* uses `EventManager` to detect changes
|
|
53
|
-
*/
|
|
54
|
-
use<MKey extends PropOf<ObjType>>(key: MKey): PropType<ObjType, MKey>;
|
|
55
|
-
/**
|
|
56
|
-
* set value
|
|
57
|
-
* @param key
|
|
58
|
-
* @param value
|
|
59
|
-
* @return true if changed , false otherwise
|
|
60
|
-
*/
|
|
61
|
-
set(key: WriteablePropOf<ObjType>, value: any): Promise<boolean>;
|
|
62
|
-
/**
|
|
63
|
-
* set key of subObject
|
|
64
|
-
* @param key
|
|
65
|
-
* @param value
|
|
66
|
-
* @param subvalue
|
|
67
|
-
* @return true if changed , false otherwise
|
|
68
|
-
*/
|
|
69
|
-
setSubValue(key: PropOf<ObjType>, objKey: string, subvalue: any): Promise<boolean>;
|
|
70
|
-
pushValue(key: PropOf<ObjType>, value: any): Promise<false | NonNullable<Awaited<ObjType[any]>>>;
|
|
71
|
-
set_temp(key: string, value: any, sendChanges?: sendChangesType): Promise<boolean>;
|
|
72
|
-
setTemp: (key: string, value: any, sendChanges?: sendChangesType) => Promise<boolean>;
|
|
73
|
-
setObjectTemp(key: string, value: any, sendChanges?: sendChangesType): Promise<boolean>;
|
|
74
|
-
getObjectTemp(key: string): any;
|
|
75
|
-
getIndexOrID(): number | string;
|
|
76
|
-
getIndex(): number;
|
|
77
|
-
getID(): string;
|
|
78
|
-
event_run(eventName: string, ...params: any): Promise<any[]>;
|
|
79
|
-
event_use(name: string, runEvent: (...inputdata: any) => any, onlyOn?: any, runOnce?: boolean): any;
|
|
80
|
-
/**
|
|
81
|
-
* only useful for getter functions that dont rely on states
|
|
82
|
-
* @param name
|
|
83
|
-
* @param runEvent
|
|
84
|
-
* @param onlyOn
|
|
85
|
-
* @returns
|
|
86
|
-
*/
|
|
87
|
-
event_use_getter(name: string, runEvent: (...inputdata: any) => any, onlyOn?: any): any;
|
|
88
|
-
event_remove(name: string, uname: string): Promise<boolean | undefined>;
|
|
89
|
-
event_add(eventName: string, uniqueName: string, eventFunction: (...inputdata: any) => any, eventChecker?: any, runOnRegister?: boolean): Promise<void>;
|
|
90
|
-
events_start(): void;
|
|
91
|
-
events_stop(): void;
|
|
92
|
-
events_clear(): void;
|
|
93
|
-
clear_changes(): boolean;
|
|
94
|
-
clear_cache(): boolean;
|
|
95
|
-
static events_clear(obj: ObjectManager<any>): void;
|
|
96
|
-
/**
|
|
97
|
-
* Set an option to some value, if its already equal to the value it will be deleted instead
|
|
98
|
-
* @param key
|
|
99
|
-
* @param value
|
|
100
|
-
* @returns
|
|
101
|
-
*/
|
|
102
|
-
toggleOption(key: string, value: any): Promise<void>;
|
|
103
|
-
getOption(key: string): any;
|
|
104
|
-
/**
|
|
105
|
-
* updates `__options` and runs the `event_run`
|
|
106
|
-
* @param key
|
|
107
|
-
* @param value
|
|
108
|
-
* @returns true if changed, false otherwise
|
|
109
|
-
*/
|
|
110
|
-
setOption(key: string, value: any): Promise<boolean>;
|
|
111
|
-
/**
|
|
112
|
-
* use an option and detect its changes in real time. similar to React state
|
|
113
|
-
* @param key name of the option
|
|
114
|
-
* @returns value of the option
|
|
115
|
-
*/
|
|
116
|
-
useOption(key: string): any;
|
|
117
|
-
/**
|
|
118
|
-
* Sets an option then does an action,
|
|
119
|
-
* after the action is run, updates the option again
|
|
120
|
-
* @param key
|
|
121
|
-
* @param value
|
|
122
|
-
* @param nextvalue
|
|
123
|
-
* @param action
|
|
124
|
-
*/
|
|
125
|
-
holdOption(key: string, value: any, nextvalue: any, action:
|
|
126
|
-
/**
|
|
127
|
-
* @returns isChanged
|
|
128
|
-
*/
|
|
129
|
-
useIsChanged(): any;
|
|
130
|
-
checkIsChanged(): Promise<void>;
|
|
131
|
-
addError(title?: string, message?: string, sendToRegister?: boolean | "auto"): any[] | undefined;
|
|
132
|
-
getErrors(): any[];
|
|
133
|
-
clearErrors(): boolean;
|
|
134
|
-
static addError(o?: ObjectManager<any>, title?: string, message?: string, sendToRegister?: boolean | "auto"): any[] | undefined;
|
|
135
|
-
static getErrors(o: ObjectManager<any>): any[];
|
|
136
|
-
static clearErrors(o: ObjectManager<any>): boolean;
|
|
137
|
-
getObjectType(): typeof SimpleObject;
|
|
138
|
-
static getObjectType(): typeof SimpleObject | ClassType<SimpleObject>;
|
|
139
|
-
}
|
|
140
|
-
export default ObjectManager;
|
|
1
|
+
import { PropOf, PropType, WriteablePropOf } from "@azrico/types";
|
|
2
|
+
import EventContext from "@azrico/event";
|
|
3
|
+
import SimpleObject, { WithManager } from "./SimpleObject";
|
|
4
|
+
import { saveResultType, sendChangesType } from "./SimpleObject";
|
|
5
|
+
import { ClassType } from "@azrico/types";
|
|
6
|
+
import MapableObject from "./MapableObject";
|
|
7
|
+
/**
|
|
8
|
+
* This class manages the events of an Simple Object
|
|
9
|
+
*/
|
|
10
|
+
export declare class ObjectManager<ObjType extends SimpleObject> extends MapableObject {
|
|
11
|
+
__eventContext: EventContext | Record<string, never>;
|
|
12
|
+
protected static readonly __object_type: () => typeof SimpleObject | ClassType<SimpleObject>;
|
|
13
|
+
protected __last_object_data: {
|
|
14
|
+
[key: string]: string;
|
|
15
|
+
};
|
|
16
|
+
protected __currentObject?: ObjType | null;
|
|
17
|
+
protected __options?: object;
|
|
18
|
+
__object_nullable: boolean;
|
|
19
|
+
constructor(defaultObject?: ObjType);
|
|
20
|
+
notifyChanged(type: string, key: PropOf<ObjType> | string, value?: any, subvalue?: string): Promise<false | any[]>;
|
|
21
|
+
/**
|
|
22
|
+
* Get the object this manager is managing
|
|
23
|
+
* @returns the object
|
|
24
|
+
*/
|
|
25
|
+
get obj(): WithManager<ObjType> | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Get the object this manager is managing
|
|
28
|
+
* @returns the object
|
|
29
|
+
*/
|
|
30
|
+
getObject(): WithManager<ObjType> | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Set the object this manager is managing
|
|
33
|
+
* @param toObj
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
36
|
+
setObject(toObj: ObjType | undefined): boolean;
|
|
37
|
+
get d(): any;
|
|
38
|
+
get isChanged(): boolean;
|
|
39
|
+
get isDeleted(): boolean;
|
|
40
|
+
get isArchived(): boolean;
|
|
41
|
+
get isLocked(): boolean;
|
|
42
|
+
get canModify(): boolean;
|
|
43
|
+
get isNew(): boolean;
|
|
44
|
+
get isSaved(): boolean;
|
|
45
|
+
getSaveResult(): any | null;
|
|
46
|
+
getSaveResultType(): saveResultType | null;
|
|
47
|
+
setSaveResult(toObj: any, type: saveResultType): saveResultType | undefined;
|
|
48
|
+
apply_changes(): boolean;
|
|
49
|
+
get(key: PropOf<ObjType>, original?: boolean): PropType<ObjType, any> | null;
|
|
50
|
+
/**
|
|
51
|
+
* use a property from the object, this will return latest value of the property
|
|
52
|
+
* uses `EventManager` to detect changes
|
|
53
|
+
*/
|
|
54
|
+
use<MKey extends PropOf<ObjType>>(key: MKey): PropType<ObjType, MKey>;
|
|
55
|
+
/**
|
|
56
|
+
* set value
|
|
57
|
+
* @param key
|
|
58
|
+
* @param value
|
|
59
|
+
* @return true if changed , false otherwise
|
|
60
|
+
*/
|
|
61
|
+
set(key: WriteablePropOf<ObjType>, value: any): Promise<boolean>;
|
|
62
|
+
/**
|
|
63
|
+
* set key of subObject
|
|
64
|
+
* @param key
|
|
65
|
+
* @param value
|
|
66
|
+
* @param subvalue
|
|
67
|
+
* @return true if changed , false otherwise
|
|
68
|
+
*/
|
|
69
|
+
setSubValue(key: PropOf<ObjType>, objKey: string, subvalue: any): Promise<boolean>;
|
|
70
|
+
pushValue(key: PropOf<ObjType>, value: any): Promise<false | NonNullable<Awaited<ObjType[any]>>>;
|
|
71
|
+
set_temp(key: string, value: any, sendChanges?: sendChangesType): Promise<boolean>;
|
|
72
|
+
setTemp: (key: string, value: any, sendChanges?: sendChangesType) => Promise<boolean>;
|
|
73
|
+
setObjectTemp(key: string, value: any, sendChanges?: sendChangesType): Promise<boolean>;
|
|
74
|
+
getObjectTemp(key: string): any;
|
|
75
|
+
getIndexOrID(): number | string;
|
|
76
|
+
getIndex(): number;
|
|
77
|
+
getID(): string;
|
|
78
|
+
event_run(eventName: string, ...params: any): Promise<any[]>;
|
|
79
|
+
event_use(name: string, runEvent: (...inputdata: any) => any, onlyOn?: any, runOnce?: boolean): any;
|
|
80
|
+
/**
|
|
81
|
+
* only useful for getter functions that dont rely on states
|
|
82
|
+
* @param name
|
|
83
|
+
* @param runEvent
|
|
84
|
+
* @param onlyOn
|
|
85
|
+
* @returns
|
|
86
|
+
*/
|
|
87
|
+
event_use_getter(name: string, runEvent: (...inputdata: any) => any, onlyOn?: any): any;
|
|
88
|
+
event_remove(name: string, uname: string): Promise<boolean | undefined>;
|
|
89
|
+
event_add(eventName: string, uniqueName: string, eventFunction: (...inputdata: any) => any, eventChecker?: any, runOnRegister?: boolean): Promise<void>;
|
|
90
|
+
events_start(): void;
|
|
91
|
+
events_stop(): void;
|
|
92
|
+
events_clear(): void;
|
|
93
|
+
clear_changes(): boolean;
|
|
94
|
+
clear_cache(): boolean;
|
|
95
|
+
static events_clear(obj: ObjectManager<any>): void;
|
|
96
|
+
/**
|
|
97
|
+
* Set an option to some value, if its already equal to the value it will be deleted instead
|
|
98
|
+
* @param key
|
|
99
|
+
* @param value
|
|
100
|
+
* @returns
|
|
101
|
+
*/
|
|
102
|
+
toggleOption(key: string, value: any): Promise<void>;
|
|
103
|
+
getOption(key: string): any;
|
|
104
|
+
/**
|
|
105
|
+
* updates `__options` and runs the `event_run`
|
|
106
|
+
* @param key
|
|
107
|
+
* @param value
|
|
108
|
+
* @returns true if changed, false otherwise
|
|
109
|
+
*/
|
|
110
|
+
setOption(key: string, value: any): Promise<boolean>;
|
|
111
|
+
/**
|
|
112
|
+
* use an option and detect its changes in real time. similar to React state
|
|
113
|
+
* @param key name of the option
|
|
114
|
+
* @returns value of the option
|
|
115
|
+
*/
|
|
116
|
+
useOption(key: string): any;
|
|
117
|
+
/**
|
|
118
|
+
* Sets an option then does an action,
|
|
119
|
+
* after the action is run, updates the option again
|
|
120
|
+
* @param key
|
|
121
|
+
* @param value
|
|
122
|
+
* @param nextvalue
|
|
123
|
+
* @param action
|
|
124
|
+
*/
|
|
125
|
+
holdOption(key: string, value: any, nextvalue: any, action: () => unknown): Promise<void>;
|
|
126
|
+
/**
|
|
127
|
+
* @returns isChanged
|
|
128
|
+
*/
|
|
129
|
+
useIsChanged(): any;
|
|
130
|
+
checkIsChanged(): Promise<void>;
|
|
131
|
+
addError(title?: string, message?: string, sendToRegister?: boolean | "auto"): any[] | undefined;
|
|
132
|
+
getErrors(): any[];
|
|
133
|
+
clearErrors(): boolean;
|
|
134
|
+
static addError(o?: ObjectManager<any>, title?: string, message?: string, sendToRegister?: boolean | "auto"): any[] | undefined;
|
|
135
|
+
static getErrors(o: ObjectManager<any>): any[];
|
|
136
|
+
static clearErrors(o: ObjectManager<any>): boolean;
|
|
137
|
+
getObjectType(): typeof SimpleObject;
|
|
138
|
+
static getObjectType(): typeof SimpleObject | ClassType<SimpleObject>;
|
|
139
|
+
}
|
|
140
|
+
export default ObjectManager;
|