@azrico/webobject 1.1.36 → 1.1.37

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.
@@ -71,11 +71,11 @@ export declare class WebObject extends SimpleObject {
71
71
  * get a single web object
72
72
  * default order of parameters : search,readonly,fetchID
73
73
  */
74
- static get_single(...p: any[]): Promise<WebObject | undefined>;
74
+ static get_single<T extends WebObject>(...p: any[]): Promise<T | any | undefined>;
75
75
  /**
76
76
  * Get a list of web objects
77
77
  * default order of parameters : search,readonly,fetchID
78
78
  */
79
- static get_list(...p: any[]): Promise<WebObject[]>;
79
+ static get_list<T extends WebObject>(...p: any[]): Promise<T[]>;
80
80
  }
81
81
  export default WebObject;
@@ -5,7 +5,7 @@
5
5
  * @param createIfNotExists should we create a new meta if key does not exist
6
6
  * @param sendChange
7
7
  * @returns
8
- */_inherits(b,a);var c=_createSuper(b);return _createClass(b,[{key:"setMetaValue",value:function setMetaValue(a,c){var d=!(2<arguments.length&&void 0!==arguments[2])||arguments[2],e=3<arguments.length&&void 0!==arguments[3]?arguments[3]:"auto";if(!this.canModify)if(this.__throw_errors)throw Error("Cant use setMetaValue on ".concat(a," when on readonly mode"));else return!1;var f=b.getMetaValue(this,a);if((0,_object.object_equals)(f,c))return!1;var g=(this.getValue("meta_data")||[]).map(function(a){return(0,_object.object_shallow_clone)(a)}),h=(0,_object.setInArray)(g,"key",a,"value",c,d);return this.setValue("meta_data",h),!1!==e&&this.notifyChanged("meta",a,c),!0}/**
8
+ */_inherits(b,a);var c=_createSuper(b);return _createClass(b,[{key:"setMetaValue",value:function setMetaValue(a,c){var d=!(2<arguments.length&&void 0!==arguments[2])||arguments[2],e=3<arguments.length&&void 0!==arguments[3]?arguments[3]:"auto";if(!this.canModify)if(this.__throw_errors)throw Error("Cant use setMetaValue on ".concat(a," when on readonly mode"));else return!1;var f=b.getMetaValue(this,a);if((0,_object.object_equals)(f,c))return!1;var g=(0,_object.to_array)(this.getValue("meta_data")).map(function(a){return(0,_object.object_shallow_clone)(a)}),h=(0,_object.setInArray)(g,"key",a,"value",c,d);return this.setValue("meta_data",h),!1!==e&&this.notifyChanged("meta",a,c),!0}/**
9
9
  * Get meta object by key
10
10
  * @param key
11
11
  * @returns meta object
@@ -1,3 +1,4 @@
1
+ import { PropOf } from "./SimpleObject";
1
2
  import SimpleObject from "./SimpleObject";
2
3
  import { saveResultType } from "./SimpleObject";
3
4
  /**
@@ -34,8 +35,8 @@ export declare class ObjectManager<ObjType extends SimpleObject> {
34
35
  getSaveResultType(): saveResultType | null;
35
36
  setSaveResult(toObj: any, type: saveResultType): any;
36
37
  apply_changes(): false | undefined;
37
- getValue(key: string, original?: boolean): any;
38
- get(key: string, original?: boolean): any;
38
+ getValue(key: PropOf<ObjType>, original?: boolean): NonNullable<ObjType>[any] | undefined;
39
+ get: (key: PropOf<ObjType>, original?: boolean) => NonNullable<ObjType>[any] | undefined;
39
40
  /**
40
41
  * set value
41
42
  * @param key
@@ -50,8 +51,8 @@ export declare class ObjectManager<ObjType extends SimpleObject> {
50
51
  * @param subvalue
51
52
  * @return true if changed , false otherwise
52
53
  */
53
- setSubValue(key: string, objKey: string, subvalue: any): Promise<boolean>;
54
- pushValue(key: string, value: any): Promise<boolean>;
54
+ setSubValue(key: PropOf<ObjType>, objKey: string, subvalue: any): Promise<boolean>;
55
+ pushValue(key: PropOf<ObjType>, value: any): Promise<false | NonNullable<ObjType>[any]>;
55
56
  getIndexOrID(): number | string;
56
57
  getIndex(): number;
57
58
  getID(): string;
@@ -1,18 +1,18 @@
1
1
  "use strict";function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=exports.ObjectManager=void 0;var _global=require("@azrico/global"),_object=require("@azrico/object"),_event=require("@azrico/event"),_SimpleObject=_interopRequireDefault(require("./SimpleObject")),_string=require("@azrico/string");function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function _regeneratorRuntime(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */function a(a,b,c){return Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}),a[b]}function b(a,b,e,f){var g=b&&b.prototype instanceof d?b:d,h=Object.create(g.prototype),j=new l(f||[]);return h._invoke=function(a,b,d){var e="suspendedStart";return function(f,g){if("executing"===e)throw new Error("Generator is already running");if("completed"===e){if("throw"===f)throw g;return n()}for(d.method=f,d.arg=g;;){var h=d.delegate;if(h){var j=i(h,d);if(j){if(j===v)continue;return j}}if("next"===d.method)d.sent=d._sent=d.arg;else if("throw"===d.method){if("suspendedStart"===e)throw e="completed",d.arg;d.dispatchException(d.arg)}else"return"===d.method&&d.abrupt("return",d.arg);e="executing";var k=c(a,b,d);if("normal"===k.type){if(e=d.done?"completed":"suspendedYield",k.arg===v)continue;return{value:k.arg,done:d.done}}"throw"===k.type&&(e="completed",d.method="throw",d.arg=k.arg)}}}(a,e,j),h}function c(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}function d(){}function e(){}function f(){}function g(b){["next","throw","return"].forEach(function(c){a(b,c,function(a){return this._invoke(c,a)})})}function h(a,b){function d(e,f,g,h){var i=c(a[e],a,f);if("throw"!==i.type){var j=i.arg,k=j.value;return k&&"object"==_typeof(k)&&q.call(k,"__await")?b.resolve(k.__await).then(function(a){d("next",a,g,h)},function(a){d("throw",a,g,h)}):b.resolve(k).then(function(a){j.value=a,g(j)},function(a){return d("throw",a,g,h)})}h(i.arg)}var e;this._invoke=function(a,c){function f(){return new b(function(b,e){d(a,c,b,e)})}return e=e?e.then(f,f):f()}}function i(a,b){var d=a.iterator[b.method];if(void 0===d){if(b.delegate=null,"throw"===b.method){if(a.iterator["return"]&&(b.method="return",b.arg=void 0,i(a,b),"throw"===b.method))return v;b.method="throw",b.arg=new TypeError("The iterator does not provide a 'throw' method")}return v}var e=c(d,a.iterator,b.arg);if("throw"===e.type)return b.method="throw",b.arg=e.arg,b.delegate=null,v;var f=e.arg;return f?f.done?(b[a.resultName]=f.value,b.next=a.nextLoc,"return"!==b.method&&(b.method="next",b.arg=void 0),b.delegate=null,v):f:(b.method="throw",b.arg=new TypeError("iterator result is not an object"),b.delegate=null,v)}function j(a){var b={tryLoc:a[0]};1 in a&&(b.catchLoc=a[1]),2 in a&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}function k(a){var b=a.completion||{};b.type="normal",delete b.arg,a.completion=b}function l(a){this.tryEntries=[{tryLoc:"root"}],a.forEach(j,this),this.reset(!0)}function m(a){if(a){var b=a[s];if(b)return b.call(a);if("function"==typeof a.next)return a;if(!isNaN(a.length)){var c=-1,d=function b(){for(;++c<a.length;)if(q.call(a,c))return b.value=a[c],b.done=!1,b;return b.value=void 0,b.done=!0,b};return d.next=d}}return{next:n}}function n(){return{value:void 0,done:!0}}_regeneratorRuntime=function(){return o};var o={},p=Object.prototype,q=p.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},s=r.iterator||"@@iterator",t=r.asyncIterator||"@@asyncIterator",u=r.toStringTag||"@@toStringTag";try{a({},"")}catch(b){a=function(a,b,c){return a[b]=c}}o.wrap=b;var v={},w={};a(w,s,function(){return this});var x=Object.getPrototypeOf,y=x&&x(x(m([])));y&&y!==p&&q.call(y,s)&&(w=y);var z=f.prototype=d.prototype=Object.create(w);return e.prototype=f,a(z,"constructor",f),a(f,"constructor",e),e.displayName=a(f,u,"GeneratorFunction"),o.isGeneratorFunction=function(a){var b="function"==typeof a&&a.constructor;return!!b&&(b===e||"GeneratorFunction"===(b.displayName||b.name))},o.mark=function(b){return Object.setPrototypeOf?Object.setPrototypeOf(b,f):(b.__proto__=f,a(b,u,"GeneratorFunction")),b.prototype=Object.create(z),b},o.awrap=function(a){return{__await:a}},g(h.prototype),a(h.prototype,t,function(){return this}),o.AsyncIterator=h,o.async=function(a,c,d,e,f){void 0===f&&(f=Promise);var g=new h(b(a,c,d,e),f);return o.isGeneratorFunction(c)?g:g.next().then(function(a){return a.done?a.value:g.next()})},g(z),a(z,u,"Generator"),a(z,s,function(){return this}),a(z,"toString",function(){return"[object Generator]"}),o.keys=function(a){var b=[];for(var c in a)b.push(c);return b.reverse(),function c(){for(;b.length;){var d=b.pop();if(d in a)return c.value=d,c.done=!1,c}return c.done=!0,c}},o.values=m,l.prototype={constructor:l,reset:function reset(a){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!a)for(var b in this)"t"===b.charAt(0)&&q.call(this,b)&&!isNaN(+b.slice(1))&&(this[b]=void 0)},stop:function stop(){this.done=!0;var a=this.tryEntries[0].completion;if("throw"===a.type)throw a.arg;return this.rval},dispatchException:function dispatchException(a){function b(b,d){return f.type="throw",f.arg=a,c.next=b,d&&(c.method="next",c.arg=void 0),!!d}if(this.done)throw a;for(var c=this,d=this.tryEntries.length-1;0<=d;--d){var e=this.tryEntries[d],f=e.completion;if("root"===e.tryLoc)return b("end");if(e.tryLoc<=this.prev){var g=q.call(e,"catchLoc"),h=q.call(e,"finallyLoc");if(g&&h){if(this.prev<e.catchLoc)return b(e.catchLoc,!0);if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(!g){if(!h)throw new Error("try statement without catch or finally");if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(this.prev<e.catchLoc)return b(e.catchLoc,!0)}}},abrupt:function abrupt(a,b){for(var c,d=this.tryEntries.length-1;0<=d;--d)if(c=this.tryEntries[d],c.tryLoc<=this.prev&&q.call(c,"finallyLoc")&&this.prev<c.finallyLoc){var e=c;break}e&&("break"===a||"continue"===a)&&e.tryLoc<=b&&b<=e.finallyLoc&&(e=null);var f=e?e.completion:{};return f.type=a,f.arg=b,e?(this.method="next",this.next=e.finallyLoc,v):this.complete(f)},complete:function complete(a,b){if("throw"===a.type)throw a.arg;return"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):"normal"===a.type&&b&&(this.next=b),v},finish:function finish(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)return this.complete(b.completion,b.afterLoc),k(b),v},catch:function _catch(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){var d=b.completion;if("throw"===d.type){var e=d.arg;k(b)}return e}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(a,b,c){return this.delegate={iterator:m(a),resultName:b,nextLoc:c},"next"===this.method&&(this.arg=void 0),v}},o}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}/**
2
2
  * This class manages the events of an Simple Object
3
- */var ObjectManager=/*#__PURE__*/function(){function a(){_classCallCheck(this,a),_defineProperty(this,"__eventList",void 0),_defineProperty(this,"__eventPrefix",void 0),_defineProperty(this,"__sendEvents",!0),_defineProperty(this,"__currentObject",void 0),_defineProperty(this,"__options",void 0)}return _createClass(a,[{key:"notifyChanged",value:function(){function a(){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function d(a,b,c){var e,f;return _regeneratorRuntime().wrap(function g(d){for(;1;)switch(d.prev=d.next){case 0:if(e=this.getObject(),e){d.next=3;break}return d.abrupt("return",!1);case 3:return void 0===c&&(c=e.getValue(b)),f=(a?"$".concat(a,"$"):"")+b,d.next=7,this.event_run("on_change",f,c);case 7:return d.abrupt("return",d.sent);case 8:case"end":return d.stop();}},d,this)}));return a}()/* -------------------------------------------------------------------------- */},{key:"obj",get:function get(){return this.getObject()}/**
3
+ */var ObjectManager=/*#__PURE__*/function(){function a(){_classCallCheck(this,a),_defineProperty(this,"__eventList",void 0),_defineProperty(this,"__eventPrefix",void 0),_defineProperty(this,"__sendEvents",!0),_defineProperty(this,"__currentObject",void 0),_defineProperty(this,"__options",void 0),_defineProperty(this,"get",this.getValue)}return _createClass(a,[{key:"notifyChanged",value:function(){function a(){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function d(a,b,c){var e,f;return _regeneratorRuntime().wrap(function g(d){for(;1;)switch(d.prev=d.next){case 0:if(e=this.getObject(),e){d.next=3;break}return d.abrupt("return",!1);case 3:return void 0===c&&"meta"!=a&&(c=e.getValue(b)),f=(a?"$".concat(a,"$"):"")+(b+""),d.next=7,this.event_run("on_change",f,c);case 7:return d.abrupt("return",d.sent);case 8:case"end":return d.stop();}},d,this)}));return a}()/* -------------------------------------------------------------------------- */},{key:"obj",get:function get(){return this.getObject()}/**
4
4
  * Get the object this manager is managing
5
5
  * @returns the object
6
6
  */},{key:"getObject",value:function getObject(){var a;return null!==(a=this.__currentObject)&&void 0!==a?a:void 0}/**
7
7
  * Set the object this manager is managing
8
8
  * @param toObj
9
9
  * @returns
10
- */},{key:"setObject",value:function setObject(a){var b=this;return this.__currentObject=a,this.__currentObject&&(this.__currentObject.get_managerClass=function(){return b}),!0}/* -------------------------------------------------------------------------- */ /* Child functions */ /* -------------------------------------------------------------------------- */},{key:"isChanged",get:function get(){return null!=this.obj&&this.obj.isChanged}},{key:"isDeleted",get:function get(){return null==this.obj||this.obj.isDeleted}},{key:"d",get:function get(){var a;return null===(a=this.obj)||void 0===a?void 0:a.d}},{key:"canModify",get:function get(){var a;return!(null!==(a=this.obj)&&void 0!==a&&a.canModify)}},{key:"isEditMode",get:function get(){var a;return null===(a=this.obj)||void 0===a?void 0:a.isEditMode}},{key:"isNew",get:function get(){return null==this.obj||this.obj.isNew}},{key:"isSaved",get:function get(){var a;return(null===(a=this.obj)||void 0===a?void 0:a.isSaved)||!1}},{key:"__cache_name",get:function get(){return this.constructor.__cache_name}},{key:"getSaveResult",value:function getSaveResult(){var a;return(null===(a=this.getObject())||void 0===a?void 0:a.getSaveResult())||void 0}},{key:"getSaveResultType",value:function getSaveResultType(){var a;return(null===(a=this.getObject())||void 0===a?void 0:a.getSaveResultType())||null}},{key:"setSaveResult",value:function setSaveResult(a,b){return this.setSaveResult(a,b)}},{key:"apply_changes",value:function apply_changes(){var a;return null===(a=this.obj)||void 0===a?void 0:a.apply_changes()}},{key:"getValue",value:function getValue(a){var b,c=!!(1<arguments.length&&void 0!==arguments[1])&&arguments[1];return null===(b=this.obj)||void 0===b?void 0:b.getValue(a,c)}},{key:"get",value:function get(a){var b,c=!!(1<arguments.length&&void 0!==arguments[1])&&arguments[1];return null===(b=this.obj)||void 0===b?void 0:b.get(a,c)}/**
10
+ */},{key:"setObject",value:function setObject(a){var b=this;return this.__currentObject=a,this.__currentObject&&(this.__currentObject.get_managerClass=function(){return b}),!0}/* -------------------------------------------------------------------------- */ /* Child functions */ /* -------------------------------------------------------------------------- */},{key:"isChanged",get:function get(){return null!=this.obj&&this.obj.isChanged}},{key:"isDeleted",get:function get(){return null==this.obj||this.obj.isDeleted}},{key:"d",get:function get(){var a;return null===(a=this.obj)||void 0===a?void 0:a.d}},{key:"canModify",get:function get(){var a;return!(null!==(a=this.obj)&&void 0!==a&&a.canModify)}},{key:"isEditMode",get:function get(){var a;return null===(a=this.obj)||void 0===a?void 0:a.isEditMode}},{key:"isNew",get:function get(){return null==this.obj||this.obj.isNew}},{key:"isSaved",get:function get(){var a;return(null===(a=this.obj)||void 0===a?void 0:a.isSaved)||!1}},{key:"__cache_name",get:function get(){return this.constructor.__cache_name}},{key:"getSaveResult",value:function getSaveResult(){var a;return(null===(a=this.getObject())||void 0===a?void 0:a.getSaveResult())||void 0}},{key:"getSaveResultType",value:function getSaveResultType(){var a;return(null===(a=this.getObject())||void 0===a?void 0:a.getSaveResultType())||null}},{key:"setSaveResult",value:function setSaveResult(a,b){return this.setSaveResult(a,b)}},{key:"apply_changes",value:function apply_changes(){var a;return null===(a=this.obj)||void 0===a?void 0:a.apply_changes()}},{key:"getValue",value:function getValue(a){var b,c=!!(1<arguments.length&&void 0!==arguments[1])&&arguments[1];return null===(b=this.obj)||void 0===b?void 0:b.getValue(a,c)}},{key:"setValue",value:/**
11
11
  * set value
12
12
  * @param key
13
13
  * @param value
14
14
  * @return true if changed , false otherwise
15
- */},{key:"setValue",value:function(){function a(a,c){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function c(a,b){var d;return _regeneratorRuntime().wrap(function e(c){for(;1;)switch(c.prev=c.next){case 0:return c.next=2,null===(d=this.obj)||void 0===d?void 0:d.setValue(a,b);case 2:if(c.t0=c.sent,c.t0){c.next=5;break}c.t0=!1;case 5:return c.abrupt("return",c.t0);case 6:case"end":return c.stop();}},c,this)}));return a}()/**
15
+ */function(){function a(a,c){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function c(a,b){var d;return _regeneratorRuntime().wrap(function e(c){for(;1;)switch(c.prev=c.next){case 0:return c.next=2,null===(d=this.obj)||void 0===d?void 0:d.setValue(a,b);case 2:if(c.t0=c.sent,c.t0){c.next=5;break}c.t0=!1;case 5:return c.abrupt("return",c.t0);case 6:case"end":return c.stop();}},c,this)}));return a}()/**
16
16
  * set key of subObject
17
17
  * @param key
18
18
  * @param value
@@ -3,6 +3,12 @@ import ObjectManager from "./ObjectManager";
3
3
  export declare type saveResultType = "normal" | "nothing" | "error" | "canceled";
4
4
  export declare type saveType = "normal" | "quick";
5
5
  export declare type sendChangesType = boolean | "auto";
6
+ declare type PropType<obj, prop extends keyof obj> = obj[prop];
7
+ declare type NonFunctionKeyNames<T> = Exclude<{
8
+ [key in keyof T]: T[key] extends Function ? never : key;
9
+ }[keyof T], undefined>;
10
+ declare type RemoveFunctions<T> = Pick<T, NonFunctionKeyNames<T>>;
11
+ export declare type PropOf<obj> = keyof RemoveFunctions<obj>;
6
12
  export declare class SimpleObject extends MapableObject {
7
13
  #private;
8
14
  static readonly __cache_name?: string;
@@ -27,17 +33,17 @@ export declare class SimpleObject extends MapableObject {
27
33
  constructor(isEditMode?: boolean, is_readonly?: boolean);
28
34
  loadValues(initObject: any, fullUpdate?: boolean): boolean;
29
35
  static loadValues(obj: SimpleObject, initObject: any, fullUpdate?: boolean): boolean;
30
- static getValue(o: any, key: string, original?: boolean): any;
31
- getValue(key: string, original?: boolean): any;
32
- get(key: string, original?: boolean): any;
36
+ static getValue<T extends SimpleObject, MKey extends PropOf<T>>(o: T, key: MKey, original?: boolean): PropType<T, MKey> | undefined;
37
+ getValue: <MKey extends Exclude<{ [key in keyof this]: this[key] extends Function ? never : key; }[keyof this], undefined>>(key: MKey, original?: boolean) => PropType<this, MKey>;
38
+ get: <MKey extends Exclude<{ [key in keyof this]: this[key] extends Function ? never : key; }[keyof this], undefined>>(key: MKey, original?: boolean) => PropType<this, MKey>;
33
39
  /**
34
40
  * set value
35
41
  * @param key
36
42
  * @param value
37
43
  * @return true if changed , false otherwise
38
44
  */
39
- setValue(key: any, value: any, sendChanges?: sendChangesType): Promise<boolean>;
40
- set(key: any, value: any, sendChanges?: sendChangesType): Promise<boolean>;
45
+ setValue(key: PropOf<this>, value: any, sendChanges?: sendChangesType): Promise<boolean>;
46
+ set: (key: PropOf<this>, value: any, sendChanges?: sendChangesType) => Promise<boolean>;
41
47
  /**
42
48
  * set key of subObject
43
49
  * @param key
@@ -45,8 +51,8 @@ export declare class SimpleObject extends MapableObject {
45
51
  * @param subvalue
46
52
  * @return true if changed , false otherwise
47
53
  */
48
- setSubValue(key: string, objKey: string, subvalue: any, sendChanges?: sendChangesType): Promise<boolean>;
49
- pushValue(key: string, value: any, sendChanges?: sendChangesType): Promise<any>;
54
+ setSubValue(key: PropOf<this>, objKey: string, subvalue: any, sendChanges?: sendChangesType): Promise<boolean>;
55
+ pushValue<MKey extends PropOf<this>>(key: MKey, value: any, sendChanges?: sendChangesType): Promise<this[MKey] | false>;
50
56
  notifyChanged(type: string, key: string, value: any, subvalue?: any): Promise<void>;
51
57
  static canChangeKey(object: SimpleObject, key: string): boolean;
52
58
  /**
@@ -65,7 +71,7 @@ export declare class SimpleObject extends MapableObject {
65
71
  get __cache_name(): string;
66
72
  get __changeables(): string;
67
73
  get __unchangeables(): string;
68
- get __use_delta(): string;
74
+ get __use_delta(): boolean;
69
75
  get isSaved(): boolean;
70
76
  get isNew(): boolean;
71
77
  get manager(): ObjectManager<this> | null;
@@ -1,17 +1,18 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=exports.SimpleObject=void 0;var _global=require("@azrico/global"),_object=require("@azrico/object"),_MapableObject2=require("./MapableObject"),_ObjectManager=_interopRequireDefault(require("./ObjectManager")),_string=require("@azrico/string");function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _regeneratorRuntime(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */function a(a,b,c){return Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}),a[b]}function b(a,b,e,f){var g=b&&b.prototype instanceof d?b:d,h=Object.create(g.prototype),j=new l(f||[]);return h._invoke=function(a,b,d){var e="suspendedStart";return function(f,g){if("executing"===e)throw new Error("Generator is already running");if("completed"===e){if("throw"===f)throw g;return n()}for(d.method=f,d.arg=g;;){var h=d.delegate;if(h){var j=i(h,d);if(j){if(j===v)continue;return j}}if("next"===d.method)d.sent=d._sent=d.arg;else if("throw"===d.method){if("suspendedStart"===e)throw e="completed",d.arg;d.dispatchException(d.arg)}else"return"===d.method&&d.abrupt("return",d.arg);e="executing";var k=c(a,b,d);if("normal"===k.type){if(e=d.done?"completed":"suspendedYield",k.arg===v)continue;return{value:k.arg,done:d.done}}"throw"===k.type&&(e="completed",d.method="throw",d.arg=k.arg)}}}(a,e,j),h}function c(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}function d(){}function e(){}function f(){}function g(b){["next","throw","return"].forEach(function(c){a(b,c,function(a){return this._invoke(c,a)})})}function h(a,b){function d(e,f,g,h){var i=c(a[e],a,f);if("throw"!==i.type){var j=i.arg,k=j.value;return k&&"object"==_typeof(k)&&q.call(k,"__await")?b.resolve(k.__await).then(function(a){d("next",a,g,h)},function(a){d("throw",a,g,h)}):b.resolve(k).then(function(a){j.value=a,g(j)},function(a){return d("throw",a,g,h)})}h(i.arg)}var e;this._invoke=function(a,c){function f(){return new b(function(b,e){d(a,c,b,e)})}return e=e?e.then(f,f):f()}}function i(a,b){var d=a.iterator[b.method];if(void 0===d){if(b.delegate=null,"throw"===b.method){if(a.iterator["return"]&&(b.method="return",b.arg=void 0,i(a,b),"throw"===b.method))return v;b.method="throw",b.arg=new TypeError("The iterator does not provide a 'throw' method")}return v}var e=c(d,a.iterator,b.arg);if("throw"===e.type)return b.method="throw",b.arg=e.arg,b.delegate=null,v;var f=e.arg;return f?f.done?(b[a.resultName]=f.value,b.next=a.nextLoc,"return"!==b.method&&(b.method="next",b.arg=void 0),b.delegate=null,v):f:(b.method="throw",b.arg=new TypeError("iterator result is not an object"),b.delegate=null,v)}function j(a){var b={tryLoc:a[0]};1 in a&&(b.catchLoc=a[1]),2 in a&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}function k(a){var b=a.completion||{};b.type="normal",delete b.arg,a.completion=b}function l(a){this.tryEntries=[{tryLoc:"root"}],a.forEach(j,this),this.reset(!0)}function m(a){if(a){var b=a[s];if(b)return b.call(a);if("function"==typeof a.next)return a;if(!isNaN(a.length)){var c=-1,d=function b(){for(;++c<a.length;)if(q.call(a,c))return b.value=a[c],b.done=!1,b;return b.value=void 0,b.done=!0,b};return d.next=d}}return{next:n}}function n(){return{value:void 0,done:!0}}_regeneratorRuntime=function(){return o};var o={},p=Object.prototype,q=p.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},s=r.iterator||"@@iterator",t=r.asyncIterator||"@@asyncIterator",u=r.toStringTag||"@@toStringTag";try{a({},"")}catch(b){a=function(a,b,c){return a[b]=c}}o.wrap=b;var v={},w={};a(w,s,function(){return this});var x=Object.getPrototypeOf,y=x&&x(x(m([])));y&&y!==p&&q.call(y,s)&&(w=y);var z=f.prototype=d.prototype=Object.create(w);return e.prototype=f,a(z,"constructor",f),a(f,"constructor",e),e.displayName=a(f,u,"GeneratorFunction"),o.isGeneratorFunction=function(a){var b="function"==typeof a&&a.constructor;return!!b&&(b===e||"GeneratorFunction"===(b.displayName||b.name))},o.mark=function(b){return Object.setPrototypeOf?Object.setPrototypeOf(b,f):(b.__proto__=f,a(b,u,"GeneratorFunction")),b.prototype=Object.create(z),b},o.awrap=function(a){return{__await:a}},g(h.prototype),a(h.prototype,t,function(){return this}),o.AsyncIterator=h,o.async=function(a,c,d,e,f){void 0===f&&(f=Promise);var g=new h(b(a,c,d,e),f);return o.isGeneratorFunction(c)?g:g.next().then(function(a){return a.done?a.value:g.next()})},g(z),a(z,u,"Generator"),a(z,s,function(){return this}),a(z,"toString",function(){return"[object Generator]"}),o.keys=function(a){var b=[];for(var c in a)b.push(c);return b.reverse(),function c(){for(;b.length;){var d=b.pop();if(d in a)return c.value=d,c.done=!1,c}return c.done=!0,c}},o.values=m,l.prototype={constructor:l,reset:function reset(a){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!a)for(var b in this)"t"===b.charAt(0)&&q.call(this,b)&&!isNaN(+b.slice(1))&&(this[b]=void 0)},stop:function stop(){this.done=!0;var a=this.tryEntries[0].completion;if("throw"===a.type)throw a.arg;return this.rval},dispatchException:function dispatchException(a){function b(b,d){return f.type="throw",f.arg=a,c.next=b,d&&(c.method="next",c.arg=void 0),!!d}if(this.done)throw a;for(var c=this,d=this.tryEntries.length-1;0<=d;--d){var e=this.tryEntries[d],f=e.completion;if("root"===e.tryLoc)return b("end");if(e.tryLoc<=this.prev){var g=q.call(e,"catchLoc"),h=q.call(e,"finallyLoc");if(g&&h){if(this.prev<e.catchLoc)return b(e.catchLoc,!0);if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(!g){if(!h)throw new Error("try statement without catch or finally");if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(this.prev<e.catchLoc)return b(e.catchLoc,!0)}}},abrupt:function abrupt(a,b){for(var c,d=this.tryEntries.length-1;0<=d;--d)if(c=this.tryEntries[d],c.tryLoc<=this.prev&&q.call(c,"finallyLoc")&&this.prev<c.finallyLoc){var e=c;break}e&&("break"===a||"continue"===a)&&e.tryLoc<=b&&b<=e.finallyLoc&&(e=null);var f=e?e.completion:{};return f.type=a,f.arg=b,e?(this.method="next",this.next=e.finallyLoc,v):this.complete(f)},complete:function complete(a,b){if("throw"===a.type)throw a.arg;return"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):"normal"===a.type&&b&&(this.next=b),v},finish:function finish(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)return this.complete(b.completion,b.afterLoc),k(b),v},catch:function _catch(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){var d=b.completion;if("throw"===d.type){var e=d.arg;k(b)}return e}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(a,b,c){return this.delegate={iterator:m(a),resultName:b,nextLoc:c},"next"===this.method&&(this.arg=void 0),v}},o}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _inherits(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function");a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,writable:!0,configurable:!0}}),Object.defineProperty(a,"prototype",{writable:!1}),b&&_setPrototypeOf(a,b)}function _setPrototypeOf(a,b){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,b){return a.__proto__=b,a},_setPrototypeOf(a,b)}function _createSuper(a){var b=_isNativeReflectConstruct();return function(){var c,d=_getPrototypeOf(a);if(b){var e=_getPrototypeOf(this).constructor;c=Reflect.construct(d,arguments,e)}else c=d.apply(this,arguments);return _possibleConstructorReturn(this,c)}}function _possibleConstructorReturn(a,b){if(b&&("object"===_typeof(b)||"function"==typeof b))return b;if(void 0!==b)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(a)}function _assertThisInitialized(a){if(void 0===a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}function _getPrototypeOf(a){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(a){return a.__proto__||Object.getPrototypeOf(a)},_getPrototypeOf(a)}function _classPrivateMethodInitSpec(a,b){_checkPrivateRedeclaration(a,b),b.add(a)}function _checkPrivateRedeclaration(a,b){if(b.has(a))throw new TypeError("Cannot initialize the same private elements twice on an object")}function _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _classPrivateMethodGet(a,b,c){if(!b.has(a))throw new TypeError("attempted to get private field on non-instance");return c}var _setSubProperty=/*#__PURE__*/new WeakSet,_getSubProperty=/*#__PURE__*/new WeakSet,_setProperty=/*#__PURE__*/new WeakSet,_getProperty=/*#__PURE__*/new WeakSet,_setSaveResultObject=/*#__PURE__*/new WeakSet,SimpleObject=/*#__PURE__*/function(a){function b(){var a,d=!(0<arguments.length&&void 0!==arguments[0])||arguments[0],e=!!(1<arguments.length&&void 0!==arguments[1])&&arguments[1];return _classCallCheck(this,b),a=c.call(this),_classPrivateMethodInitSpec(_assertThisInitialized(a),_setSaveResultObject),_classPrivateMethodInitSpec(_assertThisInitialized(a),_getProperty),_classPrivateMethodInitSpec(_assertThisInitialized(a),_setProperty),_classPrivateMethodInitSpec(_assertThisInitialized(a),_getSubProperty),_classPrivateMethodInitSpec(_assertThisInitialized(a),_setSubProperty),_defineProperty(_assertThisInitialized(a),"__originalobject",void 0),_defineProperty(_assertThisInitialized(a),"__delta",void 0),_defineProperty(_assertThisInitialized(a),"__changed",!1),_defineProperty(_assertThisInitialized(a),"__lastChanged",""),_defineProperty(_assertThisInitialized(a),"__is_readonly",void 0),_defineProperty(_assertThisInitialized(a),"__throw_errors",void 0),_defineProperty(_assertThisInitialized(a),"__is_edit_mode",void 0),_defineProperty(_assertThisInitialized(a),"__errors",void 0),_defineProperty(_assertThisInitialized(a),"__showErrors",void 0),_defineProperty(_assertThisInitialized(a),"__saveResultObject",void 0),_defineProperty(_assertThisInitialized(a),"__saveResultIsSuccess",void 0),_defineProperty(_assertThisInitialized(a),"__saveResultType",null),_defineProperty(_assertThisInitialized(a),"_index_key",void 0),_defineProperty(_assertThisInitialized(a),"_index_value",void 0),_defineProperty(_assertThisInitialized(a),"get_managerClass",function(){return null}),a.__delta={},a.__is_edit_mode=d,a.__is_readonly=e||!a.__is_edit_mode,a.__throw_errors=!0,a.clear_changes(),a}_inherits(b,a);var c=_createSuper(b);return _createClass(b,[{key:"_static",value:function _static(){return this.constructor}},{key:"loadValues",value:/* -------------------------------------------------------------------------- */ /* Load */ /* -------------------------------------------------------------------------- */function loadValues(a){var c=!!(1<arguments.length&&void 0!==arguments[1])&&arguments[1];return b.loadValues(this,a,c)}},{key:"getValue",value:function getValue(a){var b=!!(1<arguments.length&&void 0!==arguments[1])&&arguments[1];return _classPrivateMethodGet(this,_getProperty,_getProperty2).call(this,a,b)}},{key:"get",value:function get(a){var b=!!(1<arguments.length&&void 0!==arguments[1])&&arguments[1];return _classPrivateMethodGet(this,_getProperty,_getProperty2).call(this,a,b)}/**
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=exports.SimpleObject=void 0;var _global=require("@azrico/global"),_object=require("@azrico/object"),_MapableObject2=require("./MapableObject"),_ObjectManager=_interopRequireDefault(require("./ObjectManager")),_string=require("@azrico/string");function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _regeneratorRuntime(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */function a(a,b,c){return Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}),a[b]}function b(a,b,e,f){var g=b&&b.prototype instanceof d?b:d,h=Object.create(g.prototype),j=new l(f||[]);return h._invoke=function(a,b,d){var e="suspendedStart";return function(f,g){if("executing"===e)throw new Error("Generator is already running");if("completed"===e){if("throw"===f)throw g;return n()}for(d.method=f,d.arg=g;;){var h=d.delegate;if(h){var j=i(h,d);if(j){if(j===v)continue;return j}}if("next"===d.method)d.sent=d._sent=d.arg;else if("throw"===d.method){if("suspendedStart"===e)throw e="completed",d.arg;d.dispatchException(d.arg)}else"return"===d.method&&d.abrupt("return",d.arg);e="executing";var k=c(a,b,d);if("normal"===k.type){if(e=d.done?"completed":"suspendedYield",k.arg===v)continue;return{value:k.arg,done:d.done}}"throw"===k.type&&(e="completed",d.method="throw",d.arg=k.arg)}}}(a,e,j),h}function c(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}function d(){}function e(){}function f(){}function g(b){["next","throw","return"].forEach(function(c){a(b,c,function(a){return this._invoke(c,a)})})}function h(a,b){function d(e,f,g,h){var i=c(a[e],a,f);if("throw"!==i.type){var j=i.arg,k=j.value;return k&&"object"==_typeof(k)&&q.call(k,"__await")?b.resolve(k.__await).then(function(a){d("next",a,g,h)},function(a){d("throw",a,g,h)}):b.resolve(k).then(function(a){j.value=a,g(j)},function(a){return d("throw",a,g,h)})}h(i.arg)}var e;this._invoke=function(a,c){function f(){return new b(function(b,e){d(a,c,b,e)})}return e=e?e.then(f,f):f()}}function i(a,b){var d=a.iterator[b.method];if(void 0===d){if(b.delegate=null,"throw"===b.method){if(a.iterator["return"]&&(b.method="return",b.arg=void 0,i(a,b),"throw"===b.method))return v;b.method="throw",b.arg=new TypeError("The iterator does not provide a 'throw' method")}return v}var e=c(d,a.iterator,b.arg);if("throw"===e.type)return b.method="throw",b.arg=e.arg,b.delegate=null,v;var f=e.arg;return f?f.done?(b[a.resultName]=f.value,b.next=a.nextLoc,"return"!==b.method&&(b.method="next",b.arg=void 0),b.delegate=null,v):f:(b.method="throw",b.arg=new TypeError("iterator result is not an object"),b.delegate=null,v)}function j(a){var b={tryLoc:a[0]};1 in a&&(b.catchLoc=a[1]),2 in a&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}function k(a){var b=a.completion||{};b.type="normal",delete b.arg,a.completion=b}function l(a){this.tryEntries=[{tryLoc:"root"}],a.forEach(j,this),this.reset(!0)}function m(a){if(a){var b=a[s];if(b)return b.call(a);if("function"==typeof a.next)return a;if(!isNaN(a.length)){var c=-1,d=function b(){for(;++c<a.length;)if(q.call(a,c))return b.value=a[c],b.done=!1,b;return b.value=void 0,b.done=!0,b};return d.next=d}}return{next:n}}function n(){return{value:void 0,done:!0}}_regeneratorRuntime=function(){return o};var o={},p=Object.prototype,q=p.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},s=r.iterator||"@@iterator",t=r.asyncIterator||"@@asyncIterator",u=r.toStringTag||"@@toStringTag";try{a({},"")}catch(b){a=function(a,b,c){return a[b]=c}}o.wrap=b;var v={},w={};a(w,s,function(){return this});var x=Object.getPrototypeOf,y=x&&x(x(m([])));y&&y!==p&&q.call(y,s)&&(w=y);var z=f.prototype=d.prototype=Object.create(w);return e.prototype=f,a(z,"constructor",f),a(f,"constructor",e),e.displayName=a(f,u,"GeneratorFunction"),o.isGeneratorFunction=function(a){var b="function"==typeof a&&a.constructor;return!!b&&(b===e||"GeneratorFunction"===(b.displayName||b.name))},o.mark=function(b){return Object.setPrototypeOf?Object.setPrototypeOf(b,f):(b.__proto__=f,a(b,u,"GeneratorFunction")),b.prototype=Object.create(z),b},o.awrap=function(a){return{__await:a}},g(h.prototype),a(h.prototype,t,function(){return this}),o.AsyncIterator=h,o.async=function(a,c,d,e,f){void 0===f&&(f=Promise);var g=new h(b(a,c,d,e),f);return o.isGeneratorFunction(c)?g:g.next().then(function(a){return a.done?a.value:g.next()})},g(z),a(z,u,"Generator"),a(z,s,function(){return this}),a(z,"toString",function(){return"[object Generator]"}),o.keys=function(a){var b=[];for(var c in a)b.push(c);return b.reverse(),function c(){for(;b.length;){var d=b.pop();if(d in a)return c.value=d,c.done=!1,c}return c.done=!0,c}},o.values=m,l.prototype={constructor:l,reset:function reset(a){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!a)for(var b in this)"t"===b.charAt(0)&&q.call(this,b)&&!isNaN(+b.slice(1))&&(this[b]=void 0)},stop:function stop(){this.done=!0;var a=this.tryEntries[0].completion;if("throw"===a.type)throw a.arg;return this.rval},dispatchException:function dispatchException(a){function b(b,d){return f.type="throw",f.arg=a,c.next=b,d&&(c.method="next",c.arg=void 0),!!d}if(this.done)throw a;for(var c=this,d=this.tryEntries.length-1;0<=d;--d){var e=this.tryEntries[d],f=e.completion;if("root"===e.tryLoc)return b("end");if(e.tryLoc<=this.prev){var g=q.call(e,"catchLoc"),h=q.call(e,"finallyLoc");if(g&&h){if(this.prev<e.catchLoc)return b(e.catchLoc,!0);if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(!g){if(!h)throw new Error("try statement without catch or finally");if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(this.prev<e.catchLoc)return b(e.catchLoc,!0)}}},abrupt:function abrupt(a,b){for(var c,d=this.tryEntries.length-1;0<=d;--d)if(c=this.tryEntries[d],c.tryLoc<=this.prev&&q.call(c,"finallyLoc")&&this.prev<c.finallyLoc){var e=c;break}e&&("break"===a||"continue"===a)&&e.tryLoc<=b&&b<=e.finallyLoc&&(e=null);var f=e?e.completion:{};return f.type=a,f.arg=b,e?(this.method="next",this.next=e.finallyLoc,v):this.complete(f)},complete:function complete(a,b){if("throw"===a.type)throw a.arg;return"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):"normal"===a.type&&b&&(this.next=b),v},finish:function finish(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)return this.complete(b.completion,b.afterLoc),k(b),v},catch:function _catch(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){var d=b.completion;if("throw"===d.type){var e=d.arg;k(b)}return e}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(a,b,c){return this.delegate={iterator:m(a),resultName:b,nextLoc:c},"next"===this.method&&(this.arg=void 0),v}},o}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _inherits(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function");a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,writable:!0,configurable:!0}}),Object.defineProperty(a,"prototype",{writable:!1}),b&&_setPrototypeOf(a,b)}function _setPrototypeOf(a,b){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,b){return a.__proto__=b,a},_setPrototypeOf(a,b)}function _createSuper(a){var b=_isNativeReflectConstruct();return function(){var c,d=_getPrototypeOf(a);if(b){var e=_getPrototypeOf(this).constructor;c=Reflect.construct(d,arguments,e)}else c=d.apply(this,arguments);return _possibleConstructorReturn(this,c)}}function _possibleConstructorReturn(a,b){if(b&&("object"===_typeof(b)||"function"==typeof b))return b;if(void 0!==b)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(a)}function _assertThisInitialized(a){if(void 0===a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}function _getPrototypeOf(a){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(a){return a.__proto__||Object.getPrototypeOf(a)},_getPrototypeOf(a)}function _classPrivateMethodInitSpec(a,b){_checkPrivateRedeclaration(a,b),b.add(a)}function _checkPrivateRedeclaration(a,b){if(b.has(a))throw new TypeError("Cannot initialize the same private elements twice on an object")}function _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _classPrivateMethodGet(a,b,c){if(!b.has(a))throw new TypeError("attempted to get private field on non-instance");return c}var _setSubProperty=/*#__PURE__*/new WeakSet,_getSubProperty=/*#__PURE__*/new WeakSet,_setProperty=/*#__PURE__*/new WeakSet,_getProperty=/*#__PURE__*/new WeakSet,_setSaveResultObject=/*#__PURE__*/new WeakSet,SimpleObject=/*#__PURE__*/function(a){function b(){var a,d=!(0<arguments.length&&void 0!==arguments[0])||arguments[0],e=!!(1<arguments.length&&void 0!==arguments[1])&&arguments[1];return _classCallCheck(this,b),a=c.call(this),_classPrivateMethodInitSpec(_assertThisInitialized(a),_setSaveResultObject),_classPrivateMethodInitSpec(_assertThisInitialized(a),_getProperty),_classPrivateMethodInitSpec(_assertThisInitialized(a),_setProperty),_classPrivateMethodInitSpec(_assertThisInitialized(a),_getSubProperty),_classPrivateMethodInitSpec(_assertThisInitialized(a),_setSubProperty),_defineProperty(_assertThisInitialized(a),"__originalobject",void 0),_defineProperty(_assertThisInitialized(a),"__delta",void 0),_defineProperty(_assertThisInitialized(a),"__changed",!1),_defineProperty(_assertThisInitialized(a),"__lastChanged",""),_defineProperty(_assertThisInitialized(a),"__is_readonly",void 0),_defineProperty(_assertThisInitialized(a),"__throw_errors",void 0),_defineProperty(_assertThisInitialized(a),"__is_edit_mode",void 0),_defineProperty(_assertThisInitialized(a),"__errors",void 0),_defineProperty(_assertThisInitialized(a),"__showErrors",void 0),_defineProperty(_assertThisInitialized(a),"__saveResultObject",void 0),_defineProperty(_assertThisInitialized(a),"__saveResultIsSuccess",void 0),_defineProperty(_assertThisInitialized(a),"__saveResultType",null),_defineProperty(_assertThisInitialized(a),"_index_key",void 0),_defineProperty(_assertThisInitialized(a),"_index_value",void 0),_defineProperty(_assertThisInitialized(a),"getValue",_classPrivateMethodGet(_assertThisInitialized(a),_getProperty,_getProperty2)),_defineProperty(_assertThisInitialized(a),"get",_classPrivateMethodGet(_assertThisInitialized(a),_getProperty,_getProperty2)),_defineProperty(_assertThisInitialized(a),"set",a.setValue),_defineProperty(_assertThisInitialized(a),"get_managerClass",function(){return null}),a.__delta={},a.__is_edit_mode=d,a.__is_readonly=e||!a.__is_edit_mode,a.__throw_errors=!0,a.clear_changes(),a}_inherits(b,a);var c=_createSuper(b);return _createClass(b,[{key:"_static",value:function _static(){var a=new b;return this.constructor}},{key:"loadValues",value:/* -------------------------------------------------------------------------- */ /* Load */ /* -------------------------------------------------------------------------- */function loadValues(a){var c=!!(1<arguments.length&&void 0!==arguments[1])&&arguments[1];return b.loadValues(this,a,c)}},{key:"setValue",value:/**
2
2
  * set value
3
3
  * @param key
4
4
  * @param value
5
5
  * @return true if changed , false otherwise
6
- */},{key:"setValue",value:function(){function a(){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function c(a,b){var d,e,f,g=arguments;return _regeneratorRuntime().wrap(function h(c){for(;1;)switch(c.prev=c.next){case 0:if(d=2<g.length&&void 0!==g[2]?g[2]:"auto",this.canModify){c.next=7;break}if(!this.__throw_errors){c.next=6;break}throw Error("Cant use setValue when on readonly mode");case 6:return c.abrupt("return",!1);case 7:e=!1,c.prev=8,f=this.getValue(a),(0,_object.object_equals)(f,b,{ignoredStartingWords:"_"})?e=!1:(_classPrivateMethodGet(this,_setProperty,_setProperty2).call(this,a,b),e=!0);case 11:if(c.prev=11,!(!0===d||"auto"===d&&e)){c.next=15;break}return c.next=15,this.notifyChanged("",a,b);case 15:return c.finish(11);case 16:return c.abrupt("return",e);case 17:case"end":return c.stop();}},c,this,[[8,,11,16]])}));return a}()},{key:"set",value:function(){function a(a,c){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function c(a,b){var d,e=arguments;return _regeneratorRuntime().wrap(function f(c){for(;1;)switch(c.prev=c.next){case 0:return d=2<e.length&&void 0!==e[2]?e[2]:"auto",c.next=3,this.setValue(a,b,d);case 3:return c.abrupt("return",c.sent);case 4:case"end":return c.stop();}},c,this)}));return a}()/**
6
+ */function(){function a(){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function c(a,b){var d,e,f,g=arguments;return _regeneratorRuntime().wrap(function h(c){for(;1;)switch(c.prev=c.next){case 0:if(d=2<g.length&&void 0!==g[2]?g[2]:"auto",this.canModify){c.next=7;break}if(!this.__throw_errors){c.next=6;break}throw Error("Cant use setValue when on readonly mode");case 6:return c.abrupt("return",!1);case 7:e=!1,c.prev=8,f=this.getValue(a),(0,_object.object_equals)(f,b,{ignoredStartingWords:"_"})?e=!1:(_classPrivateMethodGet(this,_setProperty,_setProperty2).call(this,a,b),e=!0);case 11:if(c.prev=11,!(!0===d||"auto"===d&&e)){c.next=15;break}return c.next=15,this.notifyChanged("",a+"",b);case 15:return c.finish(11);case 16:return c.abrupt("return",e);case 17:case"end":return c.stop();}},c,this,[[8,,11,16]])}));return a}()},{key:"setSubValue",value:/**
7
7
  * set key of subObject
8
8
  * @param key
9
9
  * @param value
10
10
  * @param subvalue
11
11
  * @return true if changed , false otherwise
12
- */},{key:"setSubValue",value:function(){function a(a,c,d){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function d(a,b,c){var e,f,g,h=arguments;return _regeneratorRuntime().wrap(function i(d){for(;1;)switch(d.prev=d.next){case 0:if(e=3<h.length&&void 0!==h[3]?h[3]:"auto",this.canModify){d.next=7;break}if(!this.__throw_errors){d.next=6;break}throw Error("Cant use setValue when on readonly mode");case 6:return d.abrupt("return",!1);case 7:f=!1,d.prev=8,g=_classPrivateMethodGet(this,_getSubProperty,_getSubProperty2).call(this,a,b),(0,_object.object_equals)(g,c,{ignoredStartingWords:"_"})?f=!1:(_classPrivateMethodGet(this,_setSubProperty,_setSubProperty2).call(this,a,b,c),f=!0);case 11:if(d.prev=11,!(!0===e||"auto"===e&&f)){d.next=15;break}return d.next=15,this.notifyChanged("",a,b,c);case 15:return d.finish(11);case 16:return d.abrupt("return",f);case 17:case"end":return d.stop();}},d,this,[[8,,11,16]])}));return a}()//Push value on array
13
- },{key:"pushValue",value:function(){function a(a,c){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function c(a,b){var d,e,f=arguments;return _regeneratorRuntime().wrap(function g(c){for(;1;)switch(c.prev=c.next){case 0:if(d=2<f.length&&void 0!==f[2]?f[2]:"auto",null!=b){c.next=3;break}return c.abrupt("return",null);case 3:if(this.canModify){c.next=9;break}if(!this.__throw_errors){c.next=8;break}throw Error("Cant use pushValue when on readonly mode");case 8:return c.abrupt("return",!1);case 9:if(null==_classPrivateMethodGet(this,_getProperty,_getProperty2).call(this,a)&&_classPrivateMethodGet(this,_setProperty,_setProperty2).call(this,a,this.getValue(a)),Array.isArray(_classPrivateMethodGet(this,_getProperty,_getProperty2).call(this,a))){c.next=16;break}if(!this.__throw_errors){c.next=15;break}throw Error("Cant use pushValue on non Array keys");case 15:return c.abrupt("return",!1);case 16:if(e=_classPrivateMethodGet(this,_getProperty,_getProperty2).call(this,a),e.push(b),_classPrivateMethodGet(this,_setProperty,_setProperty2).call(this,a,e),!0!==d&&"auto"!==d){c.next=22;break}return c.next=22,this.notifyChanged("",a,b);case 22:return c.abrupt("return",e);case 23:case"end":return c.stop();}},c,this)}));return a}()},{key:"notifyChanged",value:function(){function a(a,c,d,e){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function e(a,b,c,d){var f,g;return _regeneratorRuntime().wrap(function h(e){for(;1;)switch(e.prev=e.next){case 0:if(void 0===c&&(c=this.getValue(b)),this.__changed=!0,f="",a&&(f+="[".concat(a,"] ")),f+=d?"".concat(b,"->").concat(c," = ").concat(d):"".concat(b," = ").concat(c),this.__lastChanged=f,g=this.get_managerClass(),!(g instanceof _ObjectManager["default"])){e.next=10;break}return e.next=10,g.notifyChanged(a,b,c,d);case 10:case"end":return e.stop();}},e,this)}));return a}()},{key:"apply_changes",value:/* -------------------------------------------------------------------------- */ /* Changes */ /* -------------------------------------------------------------------------- */ /**
12
+ */function(){function a(a,c,d){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function d(a,b,c){var e,f,g,h=arguments;return _regeneratorRuntime().wrap(function i(d){for(;1;)switch(d.prev=d.next){case 0:if(e=3<h.length&&void 0!==h[3]?h[3]:"auto",this.canModify){d.next=7;break}if(!this.__throw_errors){d.next=6;break}throw Error("Cant use setValue when on readonly mode");case 6:return d.abrupt("return",!1);case 7:f=!1,d.prev=8,g=_classPrivateMethodGet(this,_getSubProperty,_getSubProperty2).call(this,a,b),(0,_object.object_equals)(g,c,{ignoredStartingWords:"_"})?f=!1:(_classPrivateMethodGet(this,_setSubProperty,_setSubProperty2).call(this,a,b,c),f=!0);case 11:if(d.prev=11,!(!0===e||"auto"===e&&f)){d.next=15;break}return d.next=15,this.notifyChanged("",a+"",b,c);case 15:return d.finish(11);case 16:return d.abrupt("return",f);case 17:case"end":return d.stop();}},d,this,[[8,,11,16]])}));return a}()//Push value on array
13
+ },{key:"pushValue",value:function(){function a(a,c){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function c(a,b){var d,e,f=arguments;return _regeneratorRuntime().wrap(function g(c){for(;1;)switch(c.prev=c.next){case 0:if(d=2<f.length&&void 0!==f[2]?f[2]:"auto",null!=b){c.next=3;break}return c.abrupt("return",!1);case 3:if(this.canModify){c.next=9;break}if(!this.__throw_errors){c.next=8;break}throw Error("Cant use pushValue when on readonly mode");case 8:return c.abrupt("return",!1);case 9:if(null==_classPrivateMethodGet(this,_getProperty,_getProperty2).call(this,a)&&_classPrivateMethodGet(this,_setProperty,_setProperty2).call(this,a,this.getValue(a)),e=_classPrivateMethodGet(this,_getProperty,_getProperty2).call(this,a),Array.isArray(e)){c.next=17;break}if(!this.__throw_errors){c.next=16;break}throw Error("Cant use pushValue on non Array keys");case 16:return c.abrupt("return",!1);case 17:if(e.push(b),_classPrivateMethodGet(this,_setProperty,_setProperty2).call(this,a,e),!0!==d&&"auto"!==d){c.next=22;break}return c.next=22,this.notifyChanged("",a+"",b);case 22:return c.abrupt("return",e);case 23:case"end":return c.stop();}},c,this)}));return a}()},{key:"notifyChanged",value:function(){function a(a,c,d,e){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function e(a,b,c,d){var f,g;return _regeneratorRuntime().wrap(function h(e){for(;1;)switch(e.prev=e.next){case 0:if(void 0===c&&"meta"!=a&&(c=this.getValue(b)),this.__changed=!0,f="",a&&(f+="[".concat(a+"","] ")),f+=d?"".concat(b+"","->").concat(c," = ").concat(d):"".concat(b+""," = ").concat(c),this.__lastChanged=f,g=this.get_managerClass(),!(g instanceof _ObjectManager["default"])){e.next=10;break}return e.next=10,g.notifyChanged(a,b,c,d);case 10:case"end":return e.stop();}},e,this)}));return a}()},{key:"apply_changes",value:/* -------------------------------------------------------------------------- */ /* Changes */ /* -------------------------------------------------------------------------- */ /**
14
14
  * Apply the changes and empty the delta object
15
15
  */function apply_changes(){if(!this.__use_delta)return console.warn("you cant use apply_changes if you are not using Delta mode"),!1;for(var a in this.isChanged||console.warn("No changes to apply"),this.__delta){var b=this.__delta[a];this[a]=b}this.clear_changes()}},{key:"clear_changes",value:function clear_changes(){this.__delta={},this.__changed=!1}},{key:"isChanged",get:/* -------------------------------------------------------------------------- */ /* Get/Check */ /* -------------------------------------------------------------------------- */function get(){return!!this.__use_delta&&!(0,_object.object_isEmpty)(this.__delta)}},{key:"isDeleted",get:function get(){return!1}},{key:"d",get:function get(){return this.__use_delta?this.__delta:this}/* all updated properties */},{key:"allproperties",get:function get(){var a=_objectSpread(_objectSpread({},this),this.__delta);return a.__delta={},a}},{key:"canModify",get:function get(){return!this.__is_readonly&&this.isEditMode}},{key:"isEditMode",get:function get(){return!1!==this.__is_edit_mode}},{key:"__cache_name",get:function get(){return this.constructor.__cache_name}},{key:"__changeables",get:function get(){return this.constructor.__changeables}},{key:"__unchangeables",get:function get(){return this.constructor.__unchangeables}},{key:"__use_delta",get:function get(){return this.constructor.__use_delta}},{key:"isSaved",get:function get(){var a;return null!==(a=this.__saveResultIsSuccess)&&void 0!==a&&a}},{key:"isNew",get:function get(){var a=this.getID();return!a||("string"==typeof a?""==a||"-1"==a:"number"==typeof a&&-1==a)}},{key:"manager",get:function get(){return this.get_managerClass()}},{key:"get_lastChanged",value:function get_lastChanged(){return!this.__lastChanged}},{key:"getIndexOrID",value:function getIndexOrID(){return b.getIndexOrID(this)}},{key:"getIndex",value:function getIndex(){return b.getIndex(this)}},{key:"getID",value:function getID(){return b.getID(this)}},{key:"getOriginal",value:/* -------------------------------------------------------------------------- */ /* Original */ /* -------------------------------------------------------------------------- */function getOriginal(){return this.__originalobject||void 0}},{key:"setOriginal",value:function setOriginal(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0;if(null===a)return void delete this.__originalobject;if(!this.isEditMode)return void console.warn("Cant use setOriginal on non original objects ! this will create an infinite loop");if(this.__is_readonly)return void delete this.__originalobject;0===a&&(a=this);var b=(0,_object.object_clone)(a);//this.__originalobject = cloneObject, ["__"];
16
- return this.__originalobject=(0,_object.object_removeKeys)(b,["__"]),this}},{key:"setSaveResult",value:function setSaveResult(a,b){this.__saveResultType=b,!0===a||!1===a||(a?_classPrivateMethodGet(this,_setSaveResultObject,_setSaveResultObject2).call(this,a):_classPrivateMethodGet(this,_setSaveResultObject,_setSaveResultObject2).call(this,null)),this.__saveResultIsSuccess=("normal"===b||"nothing"===b)&&null!=a}},{key:"getSaveResult",value:function getSaveResult(){return!!this.isSaved&&this.__saveResultObject}},{key:"getSaveResultType",value:function getSaveResultType(){return this.__saveResultType||null}/* -------------------------------------------------------------------------- */ /* statics */ /* -------------------------------------------------------------------------- */}],[{key:"loadValues",value:function loadValues(a,c){var d=!!(2<arguments.length&&void 0!==arguments[2])&&arguments[2];if(b.factoryClear(a),null==c)for(var e in a)e.startsWith("__")||delete a[e];else if("object"==_typeof(c))for(var f in c)f.startsWith("__")||(d||Object.prototype.hasOwnProperty.call(a,f))&&(a[f]=c[f]);return!0}/* -------------------------------------------------------------------------- */},{key:"getValue",value:function getValue(a,c){var d=!!(2<arguments.length&&void 0!==arguments[2])&&arguments[2];return null==a?void 0:a instanceof b&&"function"==typeof a.getValue?a.getValue(c,d):!d&&!1!=a.__use_delta&&"object"===_typeof(a.__delta)&&c in a.__delta?a.__delta[c]:a[c]}},{key:"canChangeKey",value:function canChangeKey(a,b){if(!a||!b)return!1;var c=a.constructor.__changeables,d=a.constructor.__unchangeables;return!!(null==c||c.includes(b))&&!(null!=d&&d.includes(b))}},{key:"setReadonly",value:function setReadonly(a){var b=!(1<arguments.length&&void 0!==arguments[1])||arguments[1],c=[];a||(a=[]),c=Array.isArray(a)?a:[a];for(var d,e=0;e<c.length;e++)d=c[e],d.__is_readonly=b}},{key:"setThrowErrors",value:function setThrowErrors(a){var b=!(1<arguments.length&&void 0!==arguments[1])||arguments[1],c=[];a||(a=[]),c=Array.isArray(a)?a:[a];for(var d,e=0;e<c.length;e++)d=c[e],d.__throw_errors=b}},{key:"isDeleted",value:function isDeleted(a){return!!(a instanceof b)&&!0===a.isDeleted}},{key:"getIndexOrID",value:function getIndexOrID(a){var c=b.getIndex(a);return c&&-1!=c||(c=b.getID(a)),c||-1}},{key:"getIndex",value:function getIndex(a){if(null==a||null==a)return-1;switch(_typeof(a)){case"object":return a._index_value||-1;case"number":case"string":return+a;}return-1}},{key:"getID",value:function getID(a){if(null==a||null==a)return"";switch(_typeof(a)){case"object":return a.__data_id||a._id||a.id||a.ID||"";case"string":case"number":return a+"";}return""}},{key:"setOriginal",value:function setOriginal(a){var c=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;return a instanceof b?a.setOriginal(c):void 0}},{key:"getOriginal",value:function getOriginal(a){return a instanceof b?a.getOriginal():null===a||void 0===a?void 0:a.__originalobject}/* -------------------------------------------------------------------------- */ /* Errors */ /* -------------------------------------------------------------------------- */},{key:"addError",value:function addError(a,b,c){var d=3<arguments.length&&void 0!==arguments[3]?arguments[3]:"auto",e=(0,_string.combine_if_not_blank)(b," : ",c);if(!a)"auto"===d&&(d=!0);else if(Array.isArray(a.__errors)||(a.__errors=[]),a.__errors.push(e),!1===a.__showErrors)return;return!0===d?(console.error("[REGISTER-ERROR]",e),_global.gfunc.run_action("add_error",{title:b,message:c,type:"error"})):console.error("[ERROR]",e),(null===a||void 0===a?void 0:a.__errors)||[]}},{key:"getErrors",value:function getErrors(a){return(null===a||void 0===a?void 0:a.__errors)||[]}},{key:"clearErrors",value:function clearErrors(a){return a&&(a.__errors=[]),!0}/* -------------------------------------------------------------------------- */ /* Save Results */ /* -------------------------------------------------------------------------- */},{key:"isResultValid",value:function isResultValid(a){if((0,_object.object_isEmpty)(a))return!1;switch(_typeof(a)){case"string":try{return a=JSON.parse(a),this.isResultValid(a)}catch(a){return!1}case"object":return!!(0,_object.object_isTrue)(a.acknowledged)||(a.expected&&a.result?(0,_object.object_equals)(a.expected,a.result):0<=+this.getID(a));case"number":return 0<a;case"boolean":return!0===a;}return!1}},{key:"factoryClear",value:function factoryClear(a){a.clear_changes(),b.clearErrors(a)}},{key:"delete_cache",value:function delete_cache(){this.__cache_name&&_global.gcache.delete_cache(this.__cache_name)}},{key:"get_canModify",value:function get_canModify(a){return!!(a instanceof b)&&a.canModify}/* -------------------------------------------------------------------------- */},{key:"equals",value:function equals(c,a){return console.warn("Dont use the default equals method !"),null!=c&&null!=a&&c===a}}]),b}(_MapableObject2.MapableObject);exports.SimpleObject=SimpleObject;function _setSubProperty2(a,b,c){var d=_classPrivateMethodGet(this,_getProperty,_getProperty2).call(this,a);"object"!==_typeof(d)&&(d={}),d[b]=c,_classPrivateMethodGet(this,_setProperty,_setProperty2).call(this,a,d)}function _getSubProperty2(a,b){var c=!!(2<arguments.length&&arguments[2]!==void 0)&&arguments[2],d=_classPrivateMethodGet(this,_getProperty,_getProperty2).call(this,a,c);return"object"===_typeof(d)?d[b]:void 0}function _setProperty2(a,b){this.__use_delta?this.__delta[a]=b:this[a]=b}function _getProperty2(a){var b=!!(1<arguments.length&&arguments[1]!==void 0)&&arguments[1];//check if we should use delta version or normal version for this property
16
+ return this.__originalobject=(0,_object.object_removeKeys)(b,["__"]),this}},{key:"setSaveResult",value:function setSaveResult(a,b){this.__saveResultType=b,!0===a||!1===a||(a?_classPrivateMethodGet(this,_setSaveResultObject,_setSaveResultObject2).call(this,a):_classPrivateMethodGet(this,_setSaveResultObject,_setSaveResultObject2).call(this,null)),this.__saveResultIsSuccess=("normal"===b||"nothing"===b)&&null!=a}},{key:"getSaveResult",value:function getSaveResult(){return!!this.isSaved&&this.__saveResultObject}},{key:"getSaveResultType",value:function getSaveResultType(){return this.__saveResultType||null}/* -------------------------------------------------------------------------- */ /* statics */ /* -------------------------------------------------------------------------- */}],[{key:"loadValues",value:function loadValues(a,c){var d=!!(2<arguments.length&&void 0!==arguments[2])&&arguments[2];if(b.factoryClear(a),null==c)for(var e in a)e.startsWith("__")||delete a[e];else if("object"==_typeof(c))for(var f in c)f.startsWith("__")||(d||Object.prototype.hasOwnProperty.call(a,f))&&(a[f]=c[f]);return!0}/* -------------------------------------------------------------------------- */},{key:"getValue",value:function getValue(a,c){var d=!!(2<arguments.length&&void 0!==arguments[2])&&arguments[2];return null==a?void 0:a instanceof b&&"function"==typeof a.getValue?a.getValue(c,d):!d&&!1!=a.__use_delta&&"object"===_typeof(a.__delta)&&c in a.__delta?a.__delta[c]:a[c]}},{key:"canChangeKey",value:function canChangeKey(a,b){if(!a||!b)return!1;var c=a.constructor.__changeables,d=a.constructor.__unchangeables;return!!(null==c||c.includes(b))&&!(null!=d&&d.includes(b))}},{key:"setReadonly",value:function setReadonly(a){var b=!(1<arguments.length&&void 0!==arguments[1])||arguments[1],c=[];a||(a=[]),c=Array.isArray(a)?a:[a];for(var d,e=0;e<c.length;e++)d=c[e],d.__is_readonly=b}},{key:"setThrowErrors",value:function setThrowErrors(a){var b=!(1<arguments.length&&void 0!==arguments[1])||arguments[1],c=[];a||(a=[]),c=Array.isArray(a)?a:[a];for(var d,e=0;e<c.length;e++)d=c[e],d.__throw_errors=b}},{key:"isDeleted",value:function isDeleted(a){return!!(a instanceof b)&&!0===a.isDeleted}},{key:"getIndexOrID",value:function getIndexOrID(a){var c=b.getIndex(a);return c&&-1!=c||(c=b.getID(a)),c||-1}},{key:"getIndex",value:function getIndex(a){if(null==a||null==a)return-1;switch(_typeof(a)){case"object":return a._index_value||-1;case"number":case"string":return+a;}return-1}},{key:"getID",value:function getID(a){if(null==a||null==a)return"";switch(_typeof(a)){case"object":return a.__data_id||a._id||a.id||a.ID||"";case"string":case"number":return a+"";}return""}},{key:"setOriginal",value:function setOriginal(a){var c=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;return a instanceof b?a.setOriginal(c):void 0}},{key:"getOriginal",value:function getOriginal(a){return a instanceof b?a.getOriginal():null===a||void 0===a?void 0:a.__originalobject}/* -------------------------------------------------------------------------- */ /* Errors */ /* -------------------------------------------------------------------------- */},{key:"addError",value:function addError(a,b,c){var d=3<arguments.length&&void 0!==arguments[3]?arguments[3]:"auto",e=(0,_string.combine_if_not_blank)(b," : ",c);if(!a)"auto"===d&&(d=!0);else if(Array.isArray(a.__errors)||(a.__errors=[]),a.__errors.push(e),!1===a.__showErrors)return;return!0===d?(console.error("[REGISTER-ERROR]",e),_global.gfunc.run_action("add_error",{title:b,message:c,type:"error"})):console.error("[ERROR]",e),(null===a||void 0===a?void 0:a.__errors)||[]}},{key:"getErrors",value:function getErrors(a){return(null===a||void 0===a?void 0:a.__errors)||[]}},{key:"clearErrors",value:function clearErrors(a){return a&&(a.__errors=[]),!0}/* -------------------------------------------------------------------------- */ /* Save Results */ /* -------------------------------------------------------------------------- */},{key:"isResultValid",value:function isResultValid(a){if((0,_object.object_isEmpty)(a))return!1;switch(_typeof(a)){case"string":try{return a=JSON.parse(a),this.isResultValid(a)}catch(a){return!1}case"object":return!!(0,_object.object_isTrue)(a.acknowledged)||(a.expected&&a.result?(0,_object.object_equals)(a.expected,a.result):0<=+this.getID(a));case"number":return 0<a;case"boolean":return!0===a;}return!1}},{key:"factoryClear",value:function factoryClear(a){a.clear_changes(),b.clearErrors(a)}},{key:"delete_cache",value:function delete_cache(){this.__cache_name&&_global.gcache.delete_cache(this.__cache_name)}},{key:"get_canModify",value:function get_canModify(a){return!!(a instanceof b)&&a.canModify}/* -------------------------------------------------------------------------- */},{key:"equals",value:function equals(c,a){return console.warn("Dont use the default equals method !"),null!=c&&null!=a&&c===a}}]),b}(_MapableObject2.MapableObject);exports.SimpleObject=SimpleObject;function _setSubProperty2(a,b,c){var d=_classPrivateMethodGet(this,_getProperty,_getProperty2).call(this,a);//@ts-ignore
17
+ (null==d||"object"!==_typeof(d))&&(d={}),d[b]=c,_classPrivateMethodGet(this,_setProperty,_setProperty2).call(this,a,d)}function _getSubProperty2(a,b){var c=!!(2<arguments.length&&arguments[2]!==void 0)&&arguments[2],d=_classPrivateMethodGet(this,_getProperty,_getProperty2).call(this,a,c);return null==d||"object"!==_typeof(d)?void 0:d[b]}function _setProperty2(a,b){return this.__use_delta?this.__delta[a]=b:this[a]=b,!0}function _getProperty2(a){var b=!!(1<arguments.length&&arguments[1]!==void 0)&&arguments[1];//check if we should use delta version or normal version for this property
17
18
  return this.__use_delta&&!b&&a in this.__delta?this.__delta[a]:this[a]}function _setSaveResultObject2(a){this.__saveResultObject=a}_defineProperty(SimpleObject,"__cache_name",void 0),_defineProperty(SimpleObject,"__unchangeables",void 0),_defineProperty(SimpleObject,"__changeables",void 0),_defineProperty(SimpleObject,"__use_delta",!0);var _default=SimpleObject;exports["default"]=_default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azrico/webobject",
3
- "version": "1.1.36",
3
+ "version": "1.1.37",
4
4
  "description": "Stateful object",
5
5
  "author": "Azrideus",
6
6
  "license": "MIT",