@azrico/webobject 1.0.11 → 1.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,6 @@
1
- import SimpleObject, { saveResultType, sendChangesType } from "../structs/SimpleObject";
1
+ import SimpleObject, { sendChangesType } from "../structs/SimpleObject";
2
2
  import MetaObject from "../structs/MetaObject";
3
3
  export declare class WebObject extends SimpleObject {
4
- __saveResultObject?: any;
5
- __saveResultIsSuccess?: boolean;
6
- __saveResultType?: saveResultType;
7
4
  static __web_path: string;
8
5
  static __web_type: string;
9
6
  meta_data?: MetaObject[];
@@ -37,12 +34,5 @@ export declare class WebObject extends SimpleObject {
37
34
  * @returns
38
35
  */
39
36
  onSave(...p: any): Promise<any>;
40
- getID(): number;
41
- static getID(o: any): number;
42
- static isResultValid(result_object: any): any;
43
- get isSaved(): boolean;
44
- setSaveResult(toObj: any, type: saveResultType): void;
45
- setSaveResultObject(toObj: any): void;
46
- getSaveResult(): any;
47
37
  }
48
38
  export default WebObject;
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=exports.WebObject=void 0;var _SimpleObject2=_interopRequireDefault(require("../structs/SimpleObject")),_global=require("@azrico/global"),_object=require("@azrico/object");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 _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 _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}var WebObject=/*#__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,d,e),_defineProperty(_assertThisInitialized(a),"__saveResultObject",void 0),_defineProperty(_assertThisInitialized(a),"__saveResultIsSuccess",void 0),_defineProperty(_assertThisInitialized(a),"__saveResultType",void 0),_defineProperty(_assertThisInitialized(a),"meta_data",void 0),a}/* -------------------------------------------------------------------------- */ /* Meta data */ /* -------------------------------------------------------------------------- */ /**
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.WebObject=void 0;var _SimpleObject2=_interopRequireDefault(require("../structs/SimpleObject")),_global=require("@azrico/global"),_object=require("@azrico/object");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 _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 _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}var WebObject=/*#__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,d,e),_defineProperty(_assertThisInitialized(a),"meta_data",void 0),a}/* -------------------------------------------------------------------------- */ /* Meta data */ /* -------------------------------------------------------------------------- */ /**
2
2
  * Update meta value of this object , meta data is stored in meta_data variable
3
3
  * @param key
4
4
  * @param value
@@ -13,4 +13,4 @@
13
13
  * Use this after succesful save to Database
14
14
  * @param p
15
15
  * @returns
16
- */},{key:"onSave",value:function(){function a(){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function a(){return _regeneratorRuntime().wrap(function b(a){for(;1;)switch(a.prev=a.next){case 0:return this.isSaved&&this.apply_changes(),a.next=3,Promise.resolve(!0);case 3:return a.abrupt("return",a.sent);case 4:case"end":return a.stop();}},a,this)}));return a}()/* -------------------------------------------------------------------------- */},{key:"getID",value:function getID(){return this.__data_id||-1}},{key:"isSaved",get:function get(){var a;return null!==(a=this.__saveResultIsSuccess)&&void 0!==a&&a}},{key:"setSaveResult",value:function setSaveResult(a,b){this.__saveResultType=b,!0===a||!1===a||(a?this.setSaveResultObject(a):this.setSaveResultObject(null)),this.__saveResultIsSuccess=("normal"===b||"nothing"===b)&&null!=a}},{key:"setSaveResultObject",value:function setSaveResultObject(a){this.__saveResultObject=a}},{key:"getSaveResult",value:function getSaveResult(){return!!this.isSaved&&this.__saveResultObject}}],[{key:"setMetaValue",value:function setMetaValue(a,c,d){var e=!(3<arguments.length&&void 0!==arguments[3])||arguments[3],f=4<arguments.length&&void 0!==arguments[4]?arguments[4]:"auto";if(!a)return!1;if(!a.canModify)return b.addError(a,"Readonly mode is set to true","Cant use setMetaValue on ".concat(c," when on readonly mode"),!0),!1;var g=b.getMetaValue(a,c);return!(0,_object.object_equals)(g,d)&&(a.setValue("meta_data",(0,_object.setInArray)(a.meta_data,"key",c,"value",d,e)),!1!==f&&a.notifyChanged("meta",c,d),!0)}},{key:"getMeta",value:function getMeta(a,b){return null==a?null:(0,_object.getInArray)(a.getValue("meta_data"),"key",b)}},{key:"getMetaValue",value:function getMetaValue(a,c){var d;return null===(d=b.getMeta(a,c))||void 0===d?void 0:d.value}},{key:"getID",value:function getID(a){var c;if(null==a||null==a)return-1;if(a instanceof b)return null!==(c=a.getID())&&void 0!==c?c:-1;switch(_typeof(a)){case"object":return a.__data_id||a.id||a.ID||-1;case"number":return a;}return-1}/* -------------------------------------------------------------------------- */ /* 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 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}}]),b}(_SimpleObject2["default"]);exports.WebObject=WebObject,_defineProperty(WebObject,"__web_path",""),_defineProperty(WebObject,"__web_type","");var _default=WebObject;exports["default"]=_default;
16
+ */},{key:"onSave",value:function(){function a(){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function a(){return _regeneratorRuntime().wrap(function b(a){for(;1;)switch(a.prev=a.next){case 0:return this.isSaved&&this.apply_changes(),a.next=3,Promise.resolve(!0);case 3:return a.abrupt("return",a.sent);case 4:case"end":return a.stop();}},a,this)}));return a}()}],[{key:"setMetaValue",value:function setMetaValue(a,c,d){var e=!(3<arguments.length&&void 0!==arguments[3])||arguments[3],f=4<arguments.length&&void 0!==arguments[4]?arguments[4]:"auto";if(!a)return!1;if(!a.canModify)return b.addError(a,"Readonly mode is set to true","Cant use setMetaValue on ".concat(c," when on readonly mode"),!0),!1;var g=b.getMetaValue(a,c);return!(0,_object.object_equals)(g,d)&&(a.setValue("meta_data",(0,_object.setInArray)(a.meta_data,"key",c,"value",d,e)),!1!==f&&a.notifyChanged("meta",c,d),!0)}},{key:"getMeta",value:function getMeta(a,b){return null==a?null:(0,_object.getInArray)(a.getValue("meta_data"),"key",b)}},{key:"getMetaValue",value:function getMetaValue(a,c){var d;return null===(d=b.getMeta(a,c))||void 0===d?void 0:d.value}}]),b}(_SimpleObject2["default"]);exports.WebObject=WebObject,_defineProperty(WebObject,"__web_path",""),_defineProperty(WebObject,"__web_type","");var _default=WebObject;exports["default"]=_default;
@@ -9,8 +9,17 @@ export declare class ObjectManager<ObjType extends SimpleObject> {
9
9
  __currentObject?: ObjType | null;
10
10
  __options?: object;
11
11
  notifyChanged(type: string, key: string, value?: any, subvalue?: string): false | undefined;
12
+ get obj(): ObjType | undefined;
12
13
  getObject(): ObjType | undefined;
13
14
  setObject(toObj: ObjType | undefined): boolean;
15
+ get isChanged(): boolean;
16
+ get isDeleted(): boolean;
17
+ get d(): Partial<NonNullable<ObjType>> | undefined;
18
+ get canModify(): boolean;
19
+ get isEditMode(): boolean | undefined;
20
+ get isNew(): boolean;
21
+ get __cache_name(): string;
22
+ apply_changes(): void | undefined;
14
23
  event_run(eventName: string, ...params: any): Promise<void>;
15
24
  event_use(name: string, runEvent: (...inputdata: any) => any, onlyOn?: any, runOnce?: boolean): any;
16
25
  event_add(name: string, uname: string, runEvent: (...inputdata: any) => any, onlyOn?: any, runOnce?: boolean): Promise<void>;
@@ -1,6 +1,6 @@
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 _object=require("@azrico/object"),_event=require("@azrico/event");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 notifyChanged(a,b,c){var d=this.getObject();if(!d)return!1;void 0===c&&(c=d.getValue(b));var e=(a?"$".concat(a,"$"):"")+b;this.event_run("on_change",e,c)}/* -------------------------------------------------------------------------- */},{key:"getObject",value:function getObject(){var a;return null!==(a=this.__currentObject)&&void 0!==a?a:void 0}},{key:"setObject",value:function setObject(a){var b=this;return this.__currentObject=a,this.__currentObject&&(this.__currentObject.get_managerClass=function(){return b}),!0}/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ /* Events */ /* -------------------------------------------------------------------------- */},{key:"event_run",value:function(){function a(){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){var c,d,e,f=arguments;return _regeneratorRuntime().wrap(function g(b){for(;1;)switch(b.prev=b.next){case 0:if(this.__sendEvents){b.next=2;break}return b.abrupt("return");case 2:for(c=f.length,d=Array(1<c?c-1:0),e=1;e<c;e++)d[e-1]=f[e];return b.next=5,_event.EventManager.run.apply(_event.EventManager,[this,a].concat(d));case 5:case"end":return b.stop();}},b,this)}));return a}()},{key:"event_use",value:function event_use(a,b){var c=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,d=!!(3<arguments.length&&void 0!==arguments[3])&&arguments[3];return _event.EventManager.use(this,a,b,c,d)}},{key:"event_add",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=arguments;return _regeneratorRuntime().wrap(function h(d){for(;1;)switch(d.prev=d.next){case 0:return e=3<g.length&&void 0!==g[3]?g[3]:null,f=!!(4<g.length&&void 0!==g[4])&&g[4],d.next=4,_event.EventManager.add(this,a,b,c,e,f);case 4:case"end":return d.stop();}},d,this)}));return a}()},{key:"events_stop",value:function events_stop(){this.__sendEvents=!1}},{key:"events_clear",value:function events_clear(){a.events_clear(this)}},{key:"toggleOption",value:/* -------------------------------------------------------------------------- */ /* Options */ /* -------------------------------------------------------------------------- */ /**
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 notifyChanged(a,b,c){var d=this.getObject();if(!d)return!1;void 0===c&&(c=d.getValue(b));var e=(a?"$".concat(a,"$"):"")+b;this.event_run("on_change",e,c)}/* -------------------------------------------------------------------------- */},{key:"obj",get:function get(){return this.getObject()}},{key:"getObject",value:function getObject(){var a;return null!==(a=this.__currentObject)&&void 0!==a?a:void 0}},{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:"__cache_name",get:function get(){return this.constructor.__cache_name}},{key:"apply_changes",value:function apply_changes(){var a;return null===(a=this.obj)||void 0===a?void 0:a.apply_changes()}/* -------------------------------------------------------------------------- */ /* Events */ /* -------------------------------------------------------------------------- */},{key:"event_run",value:function(){function a(){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){var c,d,e,f=arguments;return _regeneratorRuntime().wrap(function g(b){for(;1;)switch(b.prev=b.next){case 0:if(this.__sendEvents){b.next=2;break}return b.abrupt("return");case 2:for(c=f.length,d=Array(1<c?c-1:0),e=1;e<c;e++)d[e-1]=f[e];return b.next=5,_event.EventManager.run.apply(_event.EventManager,[this,a].concat(d));case 5:case"end":return b.stop();}},b,this)}));return a}()},{key:"event_use",value:function event_use(a,b){var c=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,d=!!(3<arguments.length&&void 0!==arguments[3])&&arguments[3];return _event.EventManager.use(this,a,b,c,d)}},{key:"event_add",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=arguments;return _regeneratorRuntime().wrap(function h(d){for(;1;)switch(d.prev=d.next){case 0:return e=3<g.length&&void 0!==g[3]?g[3]:null,f=!!(4<g.length&&void 0!==g[4])&&g[4],d.next=4,_event.EventManager.add(this,a,b,c,e,f);case 4:case"end":return d.stop();}},d,this)}));return a}()},{key:"events_stop",value:function events_stop(){this.__sendEvents=!1}},{key:"events_clear",value:function events_clear(){a.events_clear(this)}},{key:"toggleOption",value:/* -------------------------------------------------------------------------- */ /* Options */ /* -------------------------------------------------------------------------- */ /**
4
4
  * Set an option to some value, if its already equal to the value it will be deleted instead
5
5
  * @param key
6
6
  * @param value
@@ -13,6 +13,9 @@ export declare class SimpleObject extends MapableObject {
13
13
  readonly __is_edit_mode: boolean;
14
14
  __errors?: any[];
15
15
  __showErrors?: boolean;
16
+ __saveResultObject?: any;
17
+ __saveResultIsSuccess?: boolean;
18
+ __saveResultType?: saveResultType;
16
19
  constructor(isEditMode?: boolean, is_readonly?: boolean);
17
20
  loadValues(initObject: any, fullUpdate?: boolean): boolean;
18
21
  static loadValues(obj: any, initObject: any, fullUpdate?: boolean): boolean;
@@ -55,9 +58,13 @@ export declare class SimpleObject extends MapableObject {
55
58
  get canModify(): boolean;
56
59
  get isEditMode(): boolean;
57
60
  get __cache_name(): string;
61
+ get isSaved(): boolean;
62
+ get isNew(): boolean;
58
63
  get_lastChanged(): boolean;
59
64
  get_managerClass: () => ObjectManager<this> | null;
60
65
  static isDeleted<T extends SimpleObject>(obj: T): boolean;
66
+ getID(): number;
67
+ static getID(o: any): number;
61
68
  getOriginal(): this | undefined;
62
69
  setOriginal(toObj?: null | 0 | any): this | undefined;
63
70
  static setOriginal<T>(obj: T, toObj?: null | 0 | any): T | undefined;
@@ -65,6 +72,10 @@ export declare class SimpleObject extends MapableObject {
65
72
  static addError(o: SimpleObject, title: string, message?: string, sendToRegister?: boolean): any[];
66
73
  static getErrors(o: SimpleObject): any[];
67
74
  static clearErrors(o: SimpleObject): boolean;
75
+ static isResultValid(result_object: any): any;
76
+ setSaveResult(toObj: any, type: saveResultType): void;
77
+ setSaveResultObject(toObj: any): void;
78
+ getSaveResult(): any;
68
79
  static delete_cache(): void;
69
80
  static get_canModify(o: SimpleObject): boolean;
70
81
  static equals(a?: SimpleObject | any, b?: SimpleObject | any): boolean;
@@ -1,5 +1,5 @@
1
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 _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 _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}var SimpleObject=/*#__PURE__*/function(a){//changes
2
- 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),_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),"__is_edit_mode",void 0),_defineProperty(_assertThisInitialized(a),"__errors",void 0),_defineProperty(_assertThisInitialized(a),"__showErrors",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}/* -------------------------------------------------------------------------- */ /* Load */ /* -------------------------------------------------------------------------- */_inherits(b,a);var c=_createSuper(b);return _createClass(b,[{key:"loadValues",value:function loadValues(a){var c=!!(1<arguments.length&&void 0!==arguments[1])&&arguments[1];return b.loadValues(this,a,c),!0}},{key:"getValue",value:function getValue(a){var b=!!(1<arguments.length&&void 0!==arguments[1])&&arguments[1];return!b&&this.__delta[a]?this.__delta[a]:this[a]}},{key:"get",value:function get(a){var b=!!(1<arguments.length&&void 0!==arguments[1])&&arguments[1];return!b&&this.__delta[a]?this.__delta[a]:this[a]}/**
2
+ 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),_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),"__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",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}/* -------------------------------------------------------------------------- */ /* Load */ /* -------------------------------------------------------------------------- */_inherits(b,a);var c=_createSuper(b);return _createClass(b,[{key:"loadValues",value:function loadValues(a){var c=!!(1<arguments.length&&void 0!==arguments[1])&&arguments[1];return b.loadValues(this,a,c),!0}},{key:"getValue",value:function getValue(a){var b=!!(1<arguments.length&&void 0!==arguments[1])&&arguments[1];return!b&&this.__delta[a]?this.__delta[a]:this[a]}},{key:"get",value:function get(a){var b=!!(1<arguments.length&&void 0!==arguments[1])&&arguments[1];return!b&&this.__delta[a]?this.__delta[a]:this[a]}/**
3
3
  * set value
4
4
  * @param key
5
5
  * @param value
@@ -19,8 +19,8 @@ function b(){var a,d=!(0<arguments.length&&void 0!==arguments[0])||arguments[0],
19
19
  * @returns
20
20
  */},{key:"rn",value:function rn(a,b,c){return"object"==_typeof(a)&&"string"==typeof b&&"string"==typeof c?(0,_object.prop_rn)(a,b,c):"string"==typeof a&&"string"==typeof b&&(0,_object.prop_rn)(this,a,b)}/* -------------------------------------------------------------------------- */ /* Changes */ /* -------------------------------------------------------------------------- */ /**
21
21
  * Apply the changes and empty the delta object
22
- */},{key:"apply_changes",value:function apply_changes(){for(var a in this.isChanged||console.warn("No changes to apply"),this.__delta){var b=this.__delta[a];this[a]=b}this.__delta={},this.__changed=!1}},{key:"isChanged",get:/* -------------------------------------------------------------------------- */ /* Get/Check */ /* -------------------------------------------------------------------------- */function get(){return!(0,_object.object_isEmpty)(this.__delta)}},{key:"isDeleted",get:function get(){return!1}},{key:"d",get:function get(){return this.__delta}},{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:"get_lastChanged",value:function get_lastChanged(){return!this.__lastChanged}},{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, ["__"];
23
- return this.__originalobject=(0,_object.object_removeKeys)(b,["__"]),this}}],[{key:"loadValues",value:function loadValues(a,b){!!(2<arguments.length&&void 0!==arguments[2])&&arguments[2];if(null==b)for(var c in a)delete a[c];else if("object"==_typeof(b))for(var d in b)//if (fullUpdate != true) {
22
+ */},{key:"apply_changes",value:function apply_changes(){for(var a in this.isChanged||console.warn("No changes to apply"),this.__delta){var b=this.__delta[a];this[a]=b}this.__delta={},this.__changed=!1}},{key:"isChanged",get:/* -------------------------------------------------------------------------- */ /* Get/Check */ /* -------------------------------------------------------------------------- */function get(){return!(0,_object.object_isEmpty)(this.__delta)}},{key:"isDeleted",get:function get(){return!1}},{key:"d",get:function get(){return this.__delta}},{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:"isSaved",get:function get(){var a;return null!==(a=this.__saveResultIsSuccess)&&void 0!==a&&a}},{key:"isNew",get:function get(){return 0<this.getID()}},{key:"get_lastChanged",value:function get_lastChanged(){return!this.__lastChanged}},{key:"getID",value:function getID(){return this.__data_id||-1}},{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, ["__"];
23
+ return this.__originalobject=(0,_object.object_removeKeys)(b,["__"]),this}},{key:"setSaveResult",value:function setSaveResult(a,b){this.__saveResultType=b,!0===a||!1===a||(a?this.setSaveResultObject(a):this.setSaveResultObject(null)),this.__saveResultIsSuccess=("normal"===b||"nothing"===b)&&null!=a}},{key:"setSaveResultObject",value:function setSaveResultObject(a){this.__saveResultObject=a}},{key:"getSaveResult",value:function getSaveResult(){return!!this.isSaved&&this.__saveResultObject}/* -------------------------------------------------------------------------- */ /* statics */ /* -------------------------------------------------------------------------- */}],[{key:"loadValues",value:function loadValues(a,b){!!(2<arguments.length&&void 0!==arguments[2])&&arguments[2];if(null==b)for(var c in a)delete a[c];else if("object"==_typeof(b))for(var d in b)//if (fullUpdate != true) {
24
24
  // if (key.startsWith("_")) continue;
25
25
  //}
26
- d.startsWith("__")||Object.prototype.hasOwnProperty.call(a,d)&&(a[d]=b[d]);return!0}/* -------------------------------------------------------------------------- */},{key:"getValue",value:function getValue(a,c){var d=!!(2<arguments.length&&void 0!==arguments[2])&&arguments[2];return a instanceof b&&"function"==typeof a.getValue?a.getValue(c,d):!d&&a.__delta[c]?a.__delta[c]:a[c]}},{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:"isDeleted",value:function isDeleted(a){return!!(a instanceof b)&&!0===a.isDeleted}},{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];Array.isArray(a.__errors)||(a.__errors=[]);var e=(0,_string.combine_if_not_blank)(b," : ",c);return console.error("[ERR]",e),a.__errors.push(e),!1!==a.__showErrors&&d&&_global.gfunc.run_action("add_error",{title:b,message:c,type:"error"}),a.__errors}},{key:"getErrors",value:function getErrors(a){return a.__errors||[]}},{key:"clearErrors",value:function clearErrors(a){return a.__errors=[],!0}/* -------------------------------------------------------------------------- */ /* statics */ /* -------------------------------------------------------------------------- */},{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,_defineProperty(SimpleObject,"__cache_name","");var _default=SimpleObject;exports["default"]=_default;
26
+ d.startsWith("__")||Object.prototype.hasOwnProperty.call(a,d)&&(a[d]=b[d]);return!0}/* -------------------------------------------------------------------------- */},{key:"getValue",value:function getValue(a,c){var d=!!(2<arguments.length&&void 0!==arguments[2])&&arguments[2];return a instanceof b&&"function"==typeof a.getValue?a.getValue(c,d):!d&&a.__delta[c]?a.__delta[c]:a[c]}},{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:"isDeleted",value:function isDeleted(a){return!!(a instanceof b)&&!0===a.isDeleted}},{key:"getID",value:function getID(a){var c;if(null==a||null==a)return-1;if(a instanceof b)return null!==(c=a.getID())&&void 0!==c?c:-1;switch(_typeof(a)){case"object":return a.__data_id||a.id||a.ID||-1;case"number":return a;}return-1}},{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];Array.isArray(a.__errors)||(a.__errors=[]);var e=(0,_string.combine_if_not_blank)(b," : ",c);return console.error("[ERR]",e),a.__errors.push(e),!1!==a.__showErrors&&d&&_global.gfunc.run_action("add_error",{title:b,message:c,type:"error"}),a.__errors}},{key:"getErrors",value:function getErrors(a){return a.__errors||[]}},{key:"clearErrors",value:function clearErrors(a){return 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 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:"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,_defineProperty(SimpleObject,"__cache_name","");var _default=SimpleObject;exports["default"]=_default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azrico/webobject",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "Stateful object",
5
5
  "author": "Azrideus",
6
6
  "license": "MIT",