1 line
14 KiB
JavaScript
1 line
14 KiB
JavaScript
!function(t){var r={};function e(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,e),o.l=!0,o.exports}e.m=t,e.c=r,e.d=function(t,r,n){e.o(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:n})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,r){if(1&r&&(t=e(t)),8&r)return t;if(4&r&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(e.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&r&&"string"!=typeof t)for(var o in t)e.d(n,o,function(r){return t[r]}.bind(null,o));return n},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},e.p="",e(e.s=0)}([function(t,r,e){"use strict";function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}e.r(r),e.d(r,"Table",(function(){return o})),e.d(r,"Nodule",(function(){return a})),e.d(r,"FilterNodule",(function(){return h})),e.d(r,"JoinNodule",(function(){return j})),e.d(r,"TransformNodule",(function(){return L}));var o=function t(r){var e=this;!function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,t),this.getProperties=function(){return{id:e.id,label:e.label,rows:e.rows,type:e.type,isValid:e.isValid}},this.export=function(){return e.rows},this.setRows=function(t){var r=e._validateRows(t);if("ERR"===r.status)throw r;Array.isArray(t)?e.rows=t:e.rows=[t]},this._assignProps=function(t){e.id=t.id,e.label=t.label,e.type="Table",e.isValid=!0,t.rows?e.setRows(t.rows):e.rows=[]},this._validateConstructionProps=function(t){var r={status:"ERR",error:{label:"Error Creating Table",messages:[]}};return t?(t.id||r.error.messages.push("No id on creation of Table"),t.label||r.error.messages.push("No label on creation of Table"),0===r.error.messages.length?{status:"OK"}:r):(r.error.messages.push("No props on creation of Table"),r)},this._validateRows=function(t){var r={status:"ERR",error:{label:"Error Creating Table",messages:[]}},e=[];0===(e=Array.isArray(t)?t:[t]).length&&r.error.messages.push("No Tables imported");for(var o=0;o<e.length;o++)"object"!==n(e[o])&&r.error.messages.push("row[".concat(o,"] is not an object"));return r.error.messages.length>0?r:{status:"OK"}};var o=this._validateConstructionProps(r);if("ERR"===o.status)throw o;this._assignProps(r)};var a=function t(r){var e=this;!function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,t),this.asTable=function(){if(!e.export)return null;try{return new o({id:e.id,label:e.label,rows:e.export()})}catch(t){throw t}},this.getProperties=function(){var t=[];return t=Array.isArray(e.tables)?0===e.tables.length?[]:e.tables.map((function(t){return t.getProperties()})):[],{id:e.id,label:e.label,type:e.type,tables:t,isValid:e.isValid}},this.importTables=function(t){var r=e._validateTables(t);if("ERR"===r.status)throw r;var n=[];n=Array.isArray(t)?t:[t],e.tables=n},this._assignProps=function(t){e.id=t.id,e.label=t.label,e.type="Nodule",e.isValid=!0,t.tables?e.importTables(t.tables):e.tables=[]},this._validateTables=function(t){var r={status:"ERR",error:{label:"Not all imported Tables are valid",messages:[]}},e=[];if(!t)return r.error.messages.push("No Tables imported"),r;e=Array.isArray(t)?t:[t];for(var n=0;n<e.length;n++)e[n].isValid||r.error.messages.push("Table[".concat(n,"] is not valid"));return 0===r.error.messages.length?{status:"OK"}:r},this._validateConstructionProps=function(t){var r={status:"ERR",error:{label:"Error Creating Node",messages:[]}};return t.id||r.error.messages.push("No id on creation of Node"),t.label||r.error.messages.push("No label on creation of Node"),0===r.error.messages.length?{status:"OK"}:r};var n=this._validateConstructionProps(r);if("ERR"===n.status)throw n;this._assignProps(r)},i={EQUAL:"EQUAL",GREATER:"GREATER",GREATEREQUAL:"GREATEREQUAL",LESSER:"LESSER",LESSEREQUAL:"LESSEREQUAL"};function s(t){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function u(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),e.push.apply(e,n)}return e}function c(t){for(var r=1;r<arguments.length;r++){var e=null!=arguments[r]?arguments[r]:{};r%2?u(Object(e),!0).forEach((function(r){f(t,r,e[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):u(Object(e)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}))}return t}function f(t,r,e){return r in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function l(t,r){return(l=Object.setPrototypeOf||function(t,r){return t.__proto__=r,t})(t,r)}function p(t){var r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var e,n=y(t);if(r){var o=y(this).constructor;e=Reflect.construct(n,arguments,o)}else e=n.apply(this,arguments);return b(this,e)}}function b(t,r){return!r||"object"!==s(r)&&"function"!=typeof r?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):r}function y(t){return(y=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var h=function(t){!function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),r&&l(t,r)}(e,t);var r=p(e);function e(t){var n;return function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,e),(n=r.call(this,t)).addFilter=function(t){var r=n._validateFilters(t);if("ERR"===r.status)throw r;n.filterParams=c(c({},n.filterParams),t)},n.setFilterType=function(t){var r=n._validateType(t);if("ERR"===r.status)throw r;n.filterType=t},n.export=function(){var t=n.tables.map((function(t){return t.export()})).flat();return n._createFilterMethods().forEach((function(r){t=t.filter(r)})),t},n._assignProps=function(t){n.filterParams=t.filterParams||{},t.filterType&&n.setFilterType(t.filterType)},n._createFilterMethods=function(){var t=n._validateType(n.filterType);if("OK"!==t.status)throw t;var r=[],e=function(t){var e={};n.filterType===i.EQUAL?e=function(r){return r[t]===n.filterParams[t]}:n.filterType===i.GREATER?e=function(r){return r[t]>n.filterParams[t]}:n.filterType===i.GREATEREQUAL?e=function(r){return r[t]>=n.filterParams[t]}:n.filterType===i.LESSER?e=function(r){return r[t]<n.filterParams[t]}:n.filterType===i.LESSEREQUAL&&(e=function(r){return r[t]<=n.filterParams[t]}),r.push(e)};for(var o in n.filterParams)e(o);return r},n._validateFilters=function(t){var r={status:"ERR",error:{label:"Filter Parameter are not valid",messages:[]}};if("object"!==s(t)){var e=s(t);r.error.messages.push("Filter was of type ".concat(e," should be an object"))}return r.error.messages.length>0?r:{status:"OK"}},n._validateType=function(t){var r={status:"ERR",error:{label:"Filter Type is not valid",messages:[]}};return Object.values(i).indexOf(t)<0&&r.error.messages.push("Type must be one of: ".concat(Object.keys(i))),r.error.messages.length>0?r:{status:"OK"}},n._assignProps(t),n}return e}(a);function d(t){return(d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function m(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),e.push.apply(e,n)}return e}function v(t){for(var r=1;r<arguments.length;r++){var e=null!=arguments[r]?arguments[r]:{};r%2?m(Object(e),!0).forEach((function(r){g(t,r,e[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):m(Object(e)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}))}return t}function g(t,r,e){return r in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function O(t,r){return(O=Object.setPrototypeOf||function(t,r){return t.__proto__=r,t})(t,r)}function P(t){var r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var e,n=w(t);if(r){var o=w(this).constructor;e=Reflect.construct(n,arguments,o)}else e=n.apply(this,arguments);return R(this,e)}}function R(t,r){return!r||"object"!==d(r)&&"function"!=typeof r?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):r}function w(t){return(w=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var j=function(t){!function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),r&&O(t,r)}(e,t);var r=P(e);function e(t){var n;return function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,e),(n=r.call(this,t)).export=function(){var t=n.tables.find((function(t){return t.label===n.baseTableLabel})).export(),r=n.tables.filter((function(t){return t.label!==n.baseTableLabel}));return n.joinParams.map((function(e){var n=r.find((function(t){return t.label===e.foreignTable})).export();return t.map((function(t){var r=n.find((function(r){return t[e.primaryTableKey]===r[e.matchingKey]})),o={};for(var a in r)o["".concat(e.foreignTable,"::").concat(a)]=r[a];return v(v({},t),o)}))}))[0]},n.setJoinBy=function(t){var r=n._validateJoinBy(t);if("ERR"===r.status)throw r;n.baseTableLabel=t.baseTableLabel,n.joinParams=t.joinParams},n._assignProps=function(t){t.joinBy&&n.setJoinBy(t.joinBy)},n._validateJoinBy=function(t){var r={status:"ERR",error:{label:"JoinBy Parameters are not valid",messages:[]}},e=t.baseTableLabel,n=t.joinParams;if(e||r.error.messages.push("No baseTableLabel provided"),!Array.isArray(n)){var o=d(n);return r.error.messages.push("Keys was of type ".concat(o," should be an array")),r}for(var a=0;a<n.length;a++)"object"!==d(n[a])&&r.error.messages.push("joinParams[".concat(a,"] is not an object"));return r.error.messages.length>0?r:{status:"OK"}},n._assignProps(t),n}return e}(a);function E(t){return(E="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function T(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var e=[],n=!0,o=!1,a=void 0;try{for(var i,s=t[Symbol.iterator]();!(n=(i=s.next()).done)&&(e.push(i.value),!r||e.length!==r);n=!0);}catch(t){o=!0,a=t}finally{try{n||null==s.return||s.return()}finally{if(o)throw a}}return e}(t,r)||function(t,r){if(!t)return;if("string"==typeof t)return _(t,r);var e=Object.prototype.toString.call(t).slice(8,-1);"Object"===e&&t.constructor&&(e=t.constructor.name);if("Map"===e||"Set"===e)return Array.from(t);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return _(t,r)}(t,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=new Array(r);e<r;e++)n[e]=t[e];return n}function S(t,r){return(S=Object.setPrototypeOf||function(t,r){return t.__proto__=r,t})(t,r)}function A(t){var r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var e,n=N(t);if(r){var o=N(this).constructor;e=Reflect.construct(n,arguments,o)}else e=n.apply(this,arguments);return x(this,e)}}function x(t,r){return!r||"object"!==E(r)&&"function"!=typeof r?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):r}function N(t){return(N=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var L=function(t){!function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),r&&S(t,r)}(e,t);var r=A(e);function e(t){var n;return function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,e),(n=r.call(this,t)).export=function(){return n.tables.map((function(t){return t.export()})).flat().map((function(t){for(var r={},e=0,o=Object.entries(n.structure);e<o.length;e++){var a=T(o[e],2),i=a[0];r[a[1]]=t[i]}return r}))},n.setStructure=function(t){var r=n._validateStructureProps(t);if("ERR"===r.status)throw r;n.structure=t},n._assignProps=function(t){t.structure&&n.setStructure(t.structure)},n._validateStructureProps=function(t){var r={status:"ERR",error:{label:"Ptructure Parameters are not valid",messages:[]}};if(!t)return r.error.messages.push("No structure provided"),r;for(var e in t)"string"!=typeof t[e]&&r.error.messages.push("Key [".concat(t,"] is not a String"));return r.error.messages.length>0?r:{status:"OK"}},n._assignProps(t),n}return e}(a);r.default={Table:o,Nodule:a,FilterNodule:h,JoinNodule:j,TransformNodule:L}}]); |