@smallstack/common
Advanced tools
Comparing version 0.5.0 to 0.5.1
@@ -28,2 +28,3 @@ export * from "./InitLevelService"; | ||
export * from "./data/QueryObject"; | ||
export * from "./data/QueryObjectBuilder"; | ||
export * from "./data/DefaultQueryObject"; | ||
@@ -30,0 +31,0 @@ export * from "./data/QueryOptions"; |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("underscore"),require("window-or-global"),require("pluralize")):"function"==typeof define&&define.amd?define(["exports","underscore","window-or-global","pluralize"],t):t(e["@smallstack/common"]={},e._,e.root,e.pluralize)}(this,function(e,t,n,o){"use strict";n=n&&n.hasOwnProperty("default")?n.default:n,o=o&&o.hasOwnProperty("default")?o.default:o;var r=function(){function e(){}return e.log=function(e,t,n,o){if(this.loggingModule(e,t)){t.length>this.loggerMaxLength&&(this.loggerMaxLength=t.length);var r=this.loggerMaxLength-t.length;if(r>0)for(var i=0;i<r;i++)t+=" ";var c="debug"===e?"log":e;"undefined"!=typeof console&&"function"==typeof console[c]&&(o?console[c](t+" "+n,o):console[c](t+" "+n))}},e.info=function(e,t,n){this.log("info",e,t,n)},e.warning=function(e,t,n){this.log("warn",e,t,n)},e.error=function(e,t,n){this.log("error",e,t,n)},e.debug=function(e,t,n){this.log("debug",e,t,n)},e.loggingModule=function(e,t){return!!this.debugMode||("debug"!==e||-1!==this.debugModules.indexOf(t))},e.printSmallstackLogo=function(){console.log(" "),console.log(" _ _ _ _ "),console.log(" ___ _ __ ___ __ _ | || | ___ | |_ __ _ ___ | | __"),console.log("/ __|| '_ ` _ \\ / _` || || |/ __|| __| / _` | / __|| |/ /"),console.log("\\__ \\| | | | | || (_| || || |\\__ \\| |_ | (_| || (__ | < "),console.log("|___/|_| |_| |_| \\__,_||_||_||___/ \\__| \\__,_| \\___||_|\\_\\"),console.log("visit us on https://smallstack.io!"),console.log(" ")},e.addDebugModule=function(e){this.debugModules.push(e)},e.debugMode=!1,e.loggerMaxLength=24,e.debugModules=[],e}(),i=function(){function e(e){void 0===e&&(e=!1);var n=this;this.container={},this.onRegisterCallbacks={},this.id=t.random(0,99999).toString(),e&&setTimeout(function(){var e="";t.each(n.onRegisterCallbacks,function(t,o){n.container[o]||(""!==e&&(e+=", "),e+=o)}),""!==e&&r.error("IOC","After 10s the following references could not be resolved : "+e,n.id)},1e4)}return e.prototype.register=function(e,n,o){void 0===o&&(o=!1);{if(!this.container[e]||o)return this.container[e]=n,r.debug("IOC","registered Object with ID: "+e+", Type:"+typeof n,this.id),this.onRegisterCallbacks[e]&&(t.each(this.onRegisterCallbacks[e],function(e){e.callback(n)}),this.onRegisterCallbacks[e]=t.reject(this.onRegisterCallbacks[e],function(e){return!0===e.callOnlyOnce})),n;r.debug("IOC","Ignoring re-registering of "+e+" since there is already an instance!",this.id)}},e.register=function(t,n,o){return void 0===o&&(o=!1),e.instance().register(t,n,o)},e.prototype.get=function(e){if(this.isRegistered(e))return this.container[e];throw new Error("Could not find an ioc instance for id : '"+e+"'!")},e.get=function(t){return e.instance().get(t)},e.prototype.isRegistered=function(e){return void 0!==this.container[e]},e.isRegistered=function(t){return e.instance().isRegistered(t)},e.instance=function(){return void 0===n.smallstack_ioc&&(n.smallstack_ioc=new e),n.smallstack_ioc},e.prototype.onRegister=function(e,t,n){void 0===n&&(n=!1),this.isRegistered(e)&&t(this.get(e)),this.onRegisterCallbacks[e]||(this.onRegisterCallbacks[e]=[]),this.onRegisterCallbacks[e].push({callback:t,callOnlyOnce:n})},e.onRegister=function(t,n,o){void 0===o&&(o=!1),e.instance().onRegister(t,n,o)},e.prototype.getIOCID=function(){return this.id},e.prototype.clear=function(){this.container=[],this.onRegisterCallbacks={}},e.clear=function(){e.instance().clear()},e}(),c=function(e,t,n,o){return new(n||(n=Promise))(function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){e.done?r(e.value):new n(function(t){t(e.value)}).then(c,s)}a((o=o.apply(e,t||[])).next())})},s=function(e,t){var n,o,r,i,c={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;c;)try{if(n=1,o&&(r=o[2&i[0]?"return":i[0]?"throw":"next"])&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[0,r.value]),i[0]){case 0:case 1:r=i;break;case 4:return c.label++,{value:i[1],done:!1};case 5:c.label++,o=i[1],i=[0];continue;case 7:i=c.ops.pop(),c.trys.pop();continue;default:if(!(r=(r=c.trys).length>0&&r[r.length-1])&&(6===i[0]||2===i[0])){c=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){c.label=i[1];break}if(6===i[0]&&c.label<r[1]){c.label=r[1],r=i;break}if(r&&c.label<r[2]){c.label=r[2],c.ops.push(i);break}r[2]&&c.ops.pop(),c.trys.pop();continue}i=t.call(e,c)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},a=function(){function e(){this.initLevels={}}return e.instance=function(){return i.get("initLevelService")},e.prototype.addInitLevelFn=function(e){if("function"!=typeof e.fn)throw new Error("No fn set for init level function: "+JSON.stringify(e));if("string"!=typeof e.identifier||""===e.identifier)throw new Error("No identifier set for init level function: "+JSON.stringify(e));if(void 0===e.level&&(e.level=50),void 0!==e.stopOnFailure&&"boolean"==typeof e.stopOnFailure||(e.stopOnFailure=!0),e.level<0||e.level>100)throw new Error("InitLevel should be between 0 and 100 (both inclusive): "+JSON.stringify(e));void 0===this.initLevels[e.level]&&(this.initLevels[e.level]=[]),r.debug("InitLevelService","Added '"+e.identifier+"' on init level "+e.level),this.initLevels[e.level].push(e)},e.prototype.execute=function(){return c(this,void 0,void 0,function(){var e,t,n,o,i;return s(this,function(c){switch(c.label){case 0:e=0,c.label=1;case 1:if(!(e<=100))return[3,8];if(!this.initLevels[e])return[3,7];t=0,n=this.initLevels[e],c.label=2;case 2:if(!(t<n.length))return[3,7];o=n[t],r.debug("InitLevelService","Executing '"+o.identifier+"'!"),c.label=3;case 3:return c.trys.push([3,5,,6]),[4,o.fn()];case 4:return c.sent(),[3,6];case 5:if(i=c.sent(),o.stopOnFailure)throw r.error("InitLevelService","Execution of '"+o.identifier+"' failed! InitLevel execution will stop!"),i;return r.warning("InitLevelService","Execution of '"+o.identifier+"' failed! InitLevel execution continuing due stopOnFailure === false!"),[3,6];case 6:return t++,[3,2];case 7:return e++,[3,1];case 8:return[2]}})})},e}();function u(e){if("string"==typeof e)throw new Error("Passing a string is deprecated, please pass an object instead!");return function(t,n){var o=e&&void 0!==e.name?e.name:n;e&&void 0!==e.lazyLoading&&!0!==e.lazyLoading?i.isRegistered(o)?t[n]=i.get(o):r.debug("Autowired","Could not autowire dependency '"+o+"'",{target:t,decoratedPropertyName:n}):i.onRegister(o,function(e){t[n]=e})}}(l=e.PadDirection||(e.PadDirection={}))[l.RIGHT=0]="RIGHT",l[l.LEFT=1]="LEFT";var l,f=function(){function n(){}return n.isNonEmptyString=function(e){return t.isString(e)&&!t.isUndefined(e)&&!t.isEmpty(e)&&null!==e&&void 0!==e},n.isEmptyString=function(e){return!n.isNonEmptyString(e)},n.stringEndsWith=function(e,t){return-1!==e.indexOf(t,e.length-t.length)},n.dasherize=function(e){return e.replace(/[A-Z]/g,function(e,t){return(0!==t?"-":"")+e.toLowerCase()})},n.decapitalize=function(e){return e.charAt(0).toLowerCase()+e.slice(1)},n.capitalize=function(e){return e.charAt(0).toUpperCase()+e.slice(1)},n.spaceBeforeUppercase=function(e){return e.replace(/([A-Z])/g," $1").trim()},n.padString=function(t,n,o,r){void 0===o&&(o=e.PadDirection.LEFT),void 0===r&&(r=" "),length=t.length;var i=length-t.length;switch(r.length>1&&(r=r.charAt(0)),o){case e.PadDirection.RIGHT:for(var c=0;c<i;c++)t+=r;return t;default:for(c=0;c<i;c++)t=r+t;return t}},n.isMobile=function(){var e=navigator.userAgent||navigator.vendor||window.opera;return!(!/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(e)&&!/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(e.substr(0,4)))},n.getUrlParameterByName=function(e,t){e=e.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var n=new RegExp("[\\?&]"+e+"=([^&#]*)").exec(t);return null===n?void 0:decodeURIComponent(n[1].replace(/\+/g," "))},n.check=function(e,t,n,o){return r.debug("Utils","Utils.check is deprecated in favor of Utils.typeOfCheck!"),this.typeOfCheck(e,t,n,o)},n.typeOfCheck=function(e,t,n,o){if(typeof e!==t){var r=new Error(n+" is not of type "+t+", rather of type : "+typeof e);throw o&&o(r),r}},n.createUrlConformIdFromInput=function(e,t){return void 0===e?"":(e=(e=(e=(e=(e=(e=e.replace(/[üÜ]/g,"ue")).replace(/[äÄ]/g,"ae")).replace(/[öÖ]/g,"oe")).replace(/[ß]/g,"ss")).replace(/ /g,"_")).replace(/[^a-zA-Z0-9\_\-]/g,"").toLowerCase(),t?e.substring(0,t):e)},n.isValidEmail=function(e){return/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(e)},n.unflattenJSON=function(e){if(Object(e)!==e||Array.isArray(e))return e;var t=/\.?([^.\[\]]+)|\[(\d+)\]/g,n={};for(var o in e)if(e.hasOwnProperty(o)){for(var r=n,i="",c=void 0;c=t.exec(o);)r=r[i]||(r[i]=c[2]?[]:{}),i=c[2]||c[1];r[i]=e[o]}return n[""]||n},n.flattenJSON=function(e,t){void 0===t&&(t=!0);var n={};return function e(o,r){if(Object(o)!==o)n[r]=o;else if(Array.isArray(o))if(t){for(var i=0,c=o.length;i<c;i++)e(o[i],r+"["+i+"]");0===o.length&&(n[r]=[])}else n[r]=o;else{var s=!0;for(var a in o)o.hasOwnProperty(a)&&(s=!1,e(o[a],r?r+"."+a:a));s&&r&&(n[r]={})}}(e,""),n},n.prettyPrintJson=function(e,n){if(void 0===e)return"-";var o=e;return t.isObject(e)&&(o=JSON.stringify(e,void 0,4)),n&&o.length>n?o.substring(0,n-6)+" (...)":o},n.convertHexToRGB=function(e){if(6!==(e=e.replace("#","")).length)throw new Error("Please provide hex colors in 6-digit format!");return{r:parseInt(e.substring(0,2),16),g:parseInt(e.substring(2,4),16),b:parseInt(e.substring(4,6),16)}},n.isValidUrlName=function(e){return/\b((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b/.test(e)},n.dataURLtoBlob=function(e){for(var t=e.split(","),n=t[0].match(/:(.*?);/)[1],o=atob(t[1]),r=o.length,i=new Uint8Array(r);r--;)i[r]=o.charCodeAt(r);return new Blob([i],{type:n})},n.blobToDataURL=function(e,t){var n=new FileReader;n.onload=function(e){t(e.target.result)},n.readAsDataURL(e)},n.blobToArrayBuffer=function(e,t){var n=new FileReader;n.onload=function(){t(this.result)},n.readAsArrayBuffer(e)},n.dataUrlToBuffer=function(e,t){this.blobToArrayBuffer(this.dataURLtoBlob(e),t)},n.imageUrlToBlob=function(e,t){var n=new Image;n.onerror=function(){r.error("Utils","Could not convert url to blob: ",e)},n.onload=function(){var e=document.createElement("canvas");e.width=this.width,e.height=this.height;e.getContext("2d").drawImage(this,0,0),e.toBlob(function(e){t(e)})},n.src=e},n.getApiURL=function(e,t){return e+"/"+n.decapitalize(t.replace("get","")).toLowerCase()},n}(),p=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){e(t,n);function o(){this.constructor=t}t.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}(),d=function(e){p(t,e);function t(t,n){var o=this;return"string"==typeof t?(o=e.call(this,t)||this).i18nKey=t:((o=e.call(this,t.i18nKey)||this).i18nKey=t.i18nKey,o.supportCode=t.supportCode,o.internalDescription=t.internalDescription),o.context=n,o}return t.prototype.setContext=function(e){return this.context=e,this},t}(Error),g=function(){function e(){this.errors={}}return e.instance=function(){return i.get("frontendErrorRegistry")},e.prototype.addCollection=function(e){for(var n=0,o=t.values(e);n<o.length;n++){var r=o[n];this.add(r)}},e.prototype.add=function(e){if("string"!=typeof e.supportCode||""===e.supportCode)throw new Error("Please provide a support code while adding frontend errors!");this.errors[e.supportCode]=new d(e)},e.prototype.getAllFrontendErrors=function(){return t.values(this.errors)},e}(),h=function(){function e(){this.configuration={},this.onSetCallbacks={}}return e.prototype.set=function(e,t,n){this.configuration[e]={key:e,value:t,scope:n}},e.prototype.unset=function(e){delete this.configuration[e]},e.prototype.get=function(e,t){return this.contains(e)?this.configuration[e].value:t},e.prototype.onSet=function(e,t){void 0===this.onSetCallbacks[e]&&(this.onSetCallbacks[e]=[]),this.onSetCallbacks[e].push(t)},e.prototype.contains=function(e){return void 0!==this.configuration[e]},e}(),y=function(){function e(){}return e.prototype.log=function(e,t,n){switch(n){case"debug":console.debug(e+" - "+t);break;case"error":console.error(e+" - "+t);break;case"warn":console.warn(e+" - "+t);break;case"info":case"success":default:console.log(e+" - "+t)}},e.prototype.info=function(e,t){this.log(e,t,"info")},e.prototype.success=function(e,t){this.log(e,t,"success")},e.prototype.debug=function(e,t){this.log(e,t,"debug")},e.prototype.warn=function(e,t){this.log(e,t,"warn")},e.prototype.error=function(e,t){this.log(e,t,"error")},e.prototype.confirmation=function(e,t,n){throw new Error("Console Notifier cannot ask questions!")},e}(),v=function(e,t,n,o){var r,i=arguments.length,c=i<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(c=(i<3?r(c):i>3?r(t,n,c):r(t,n))||c);return i>3&&c&&Object.defineProperty(t,n,c),c},b=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},m=function(){function e(e){var t=this;e&&this.loadGA(e),i.onRegister("configurationService",function(e){e.onSet("googleanalytics.trackingid",function(e){t.loadGA(e)})})}return e.prototype.track=function(e,t){"undefined"==typeof ga?r.debug("GoogleAnalyticsService","ga not loaded!"):ga(function(t){void 0===t?r.debug("GoogleAnalyticsService","No GA Tracker defined yet!"):(r.debug("GoogleAnalyticsService","Sending GA tracking for path : ",e),ga("send","pageview",e))})},e.prototype.event=function(e,t){t||(t={}),t.category||(t.category="default"),"undefined"==typeof ga?r.debug("GoogleAnalyticsService","ga not loaded!"):ga(function(n){void 0===n?r.debug("GoogleAnalyticsService","No GA Tracker defined yet!"):(r.debug("GoogleAnalyticsService","Sending GA event for eventname : ",e),ga("send","event",t.category,e,t.label,t.value))})},e.prototype.loadGA=function(e){void 0!==e&&(t=window,n=document,o=void 0,i=void 0,t.GoogleAnalyticsObject="ga",t.ga=t.ga||function(){(t.ga.q=t.ga.q||[]).push(arguments)},t.ga.l=(new Date).getTime(),o=n.createElement("script"),i=n.getElementsByTagName("script")[0],o.async=1,o.src="https://www.google-analytics.com/analytics.js",i.parentNode.insertBefore(o,i),ga("create",e,"auto"),ga("send","pageview"),r.debug("GoogleAnalyticsService","Successfully initialized ga object!"));var t,n,o,i},v([u(),b("design:type",Object)],e.prototype,"dataBridge",void 0),e}(),w=function(){function e(){this.types={},this.afterTypeAddedCallbacks=[]}return e.instance=function(){return i.get("typesystem")},e.prototype.addType=function(e){r.debug("Typesystem","Adding type '"+e.getModelName()+"'!"),this.types[e.getModelName()]=e,t.each(this.afterTypeAddedCallbacks,function(t){t(e)})},e.prototype.afterTypeAdded=function(e){this.afterTypeAddedCallbacks.push(e)},e.prototype.getTypeByModelName=function(e){return t.find(this.types,function(t){if(-1!==e.indexOf("::")){var n=e.split("::");return t.model&&t.packageName===n[0]&&t.model.name===n[1]}return t.model&&t.model.name===e})},e.prototype.getTypeByCollectionName=function(e){return t.find(this.types,function(t){return t.collection&&t.collection.name===e})},e.prototype.getAllTypes=function(){return t.values(this.types)},e.prototype.getTypeByServiceName=function(e){return t.find(this.types,function(t){return void 0!==t.service&&t.service.name===e})},e.prototype.getCollectionNameForServiceName=function(e){var t=this.getTypeByServiceName(f.capitalize(e));if(t&&t.collection)return t.collection.name},e}(),C=function(e,t,n,o){var r,i=arguments.length,c=i<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(c=(i<3?r(c):i>3?r(t,n,c):r(t,n))||c);return i>3&&c&&Object.defineProperty(t,n,c),c},_=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},P=function(){function e(){}return e.prototype.subscribe=function(e,t,n){var o=this;return new Promise(function(i,c){r.debug("Collection","Subscribing to "+e),o.dataBridge.ddpSubscribe(e,t,n,{onStop:function(t){t?c(t):r.debug("Collection","Successfully stopped subscription to "+o.getCollectionName()+"->"+e)},onError:function(t){c(t||new Error("An unknown error occured while subscribing to : "+o.getCollectionName()+"->"+e))},onReady:function(){i()}})})},e.prototype.syncViaJSONAPI=function(e){var n=this;return new Promise(function(o,i){n.dataBridge.httpCall("GET",e,{}).then(function(e){r.debug("Collection","Syncing models: ",e),t.each(e,function(e){e.id&&!e._id&&(e._id=e.id,delete e.id),r.debug("Collection","Syncing model: ",JSON.stringify(e)),n.mongoDBCollection.upsert({_id:e._id},e)}),o()}).catch(function(e){i(e)})})},e.prototype.subscribeForeignKeys=function(e,t){return this.collectionsService.subscribeForeignKeys(this,e,t)},e.prototype.getQueryCount=function(e,t){return this.dataBridge.ddpCall("server-counts",{queryName:e,parameters:t})},e.prototype.getMongoDBCollection=function(){return this.mongoDBCollection},e.prototype.applyAllowDenyRules=function(){var e=this.getMongoDBCollectionAllowRules(),t=this.getMongoDBCollectionDenyRules();e&&this.mongoDBCollection.allow(e),t&&this.mongoDBCollection.deny(t)},e.prototype.getMongoDBCollectionAllowRules=function(){},e.prototype.getMongoDBCollectionDenyRules=function(){return{insert:function(e,t){return!1},update:function(e,t,n,o){return!1},remove:function(e,t){return!1}}},C([u(),_("design:type",Object)],e.prototype,"collectionsService",void 0),C([u(),_("design:type",w)],e.prototype,"typesystem",void 0),C([u(),_("design:type",Object)],e.prototype,"dataBridge",void 0),e}(),S=function(){function e(){this.publisherMethods={}}return e.instance=function(){return i.get("collectionAccessService")},e.prototype.checkAccess=function(e,n,o){var r=this;if(void 0!==e.access){var i={context:n,parameters:o,accessObject:e.access};switch(typeof e.access){case"string":return[this.executePublisherMethod(e.access,i)];case"object":var c=[];return t.each(e.access,function(e,t){c.push(r.executePublisherMethod(t,i))}),c;default:throw new Error("Type of query.access: '"+typeof e.access+"' is not allowed!")}}},e.prototype.addPublisherMethod=function(e,t){this.publisherMethods[e]=t},e.prototype.executePublisherMethod=function(e,t){var n=this.publisherMethods[e];if(!n)throw new Error("Publication method '"+e+"' could not be found!");var o=n(t);if("boolean"===o.type&&!1===o.value)throw new Error("Access restricted by '"+e+"'!");return o},e.prototype.getAccessMethod=function(e){return this.publisherMethods[e]},e.prototype.publisherMethodAvailable=function(e){return void 0!==this.publisherMethods[e]},e}(),N=function(e,t,n,o){var r,i=arguments.length,c=i<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(c=(i<3?r(c):i>3?r(t,n,c):r(t,n))||c);return i>3&&c&&Object.defineProperty(t,n,c),c},O=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},k=function(e,t,n,o){return new(n||(n=Promise))(function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){e.done?r(e.value):new n(function(t){t(e.value)}).then(c,s)}a((o=o.apply(e,t||[])).next())})},A=function(e,t){var n,o,r,i,c={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;c;)try{if(n=1,o&&(r=o[2&i[0]?"return":i[0]?"throw":"next"])&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[0,r.value]),i[0]){case 0:case 1:r=i;break;case 4:return c.label++,{value:i[1],done:!1};case 5:c.label++,o=i[1],i=[0];continue;case 7:i=c.ops.pop(),c.trys.pop();continue;default:if(!(r=(r=c.trys).length>0&&r[r.length-1])&&(6===i[0]||2===i[0])){c=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){c.label=i[1];break}if(6===i[0]&&c.label<r[1]){c.label=r[1],r=i;break}if(r&&c.label<r[2]){c.label=r[2],c.ops.push(i);break}r[2]&&c.ops.pop(),c.trys.pop();continue}i=t.call(e,c)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},x=function(){function e(){this.isSubscribed=!1}return e.prototype.create=function(e,t,n,o,r,i){this.queryOptions=n||{},this.queryOptions.currentPage=this.queryOptions.currentPage||1,this.queryOptions.entriesPerPage=this.queryOptions.entriesPerPage||10,this.sorting=r,this.subscriptionName=t,this.selector=e,this.parameters=o,this.collection=i;var c=this.collection.getCollectionName(),s=this.typesystem.getTypeByCollectionName(c);if(void 0===s)throw new Error("Could not find type by collectionName '"+c+"'!");return this.ModelConstructor=s.getModel(),this},e.prototype.getSelector=function(){return this.selector},e.prototype.getCursor=function(){return this.collection.getMongoDBCollection().find(this.selector,this.convertQueryOptionsToMongoSelector(this.queryOptions,this.sorting))},e.prototype.convertQueryOptionsToMongoSelector=function(e,t,n){void 0===n&&(n=!0);var o={sort:t,reactive:e&&!0===e.reactive};return n?(e&&e.currentPage&&e.entriesPerPage&&(o.skip=(e.currentPage-1)*e.entriesPerPage),e&&e.entriesPerPage&&(o.limit=e.entriesPerPage)):(o.skip=0,e&&e.entriesPerPage&&(o.limit=e.currentPage*e.entriesPerPage)),o},e.prototype.getModels=function(){return this.cursorResolver.resolve(this.getCursor(),{ModelConstructor:this.ModelConstructor})},e.prototype.getModel=function(e){var t=this;return new Promise(function(n){return k(t,void 0,void 0,function(){var t;return A(this,function(o){switch(o.label){case 0:return[4,this.getModels()];case 1:return t=o.sent(),n(t[e]),[2]}})})})},e.prototype.subscribe=function(){var e=this;return new Promise(function(t,n){return k(e,void 0,void 0,function(){var e;return A(this,function(n){switch(n.label){case 0:return r.debug("QueryObject","Subscribing to '"+this.subscriptionName+"'!"),[4,this.collection.subscribe(this.subscriptionName,this.parameters,this.convertQueryOptionsToMongoSelector(this.queryOptions,this.sorting,!1))];case 1:return n.sent(),this.isSubscribed=!0,e=this,[4,this.collection.getQueryCount(this.subscriptionName,this.parameters)];case 2:return e.totalCount=n.sent(),t(this),[2]}})})})},e.prototype.syncViaJSONAPI=function(){var e=this;return new Promise(function(n,o){var i=e.typesystem.getTypeByCollectionName(e.collection.getCollectionName()).getServiceQueryByName(e.subscriptionName);if(void 0===i)o("Could not find TypeServiceQuery for collection "+e.collection.getCollectionName()+" and serviceQuery "+e.subscriptionName);else{var c=e.configurationService.get("smallstack.api.url");if(c){f.stringEndsWith(c,"/")||(c+="/");var s=c+f.getApiURL(e.collection.getCollectionName(),e.subscriptionName);s=s+"?currentPage="+e.queryOptions.currentPage+"&entriesPerPage="+e.queryOptions.entriesPerPage,t.each(e.parameters,function(e,t){e instanceof Array&&(e=JSON.stringify(e)),s+="&"+t+"="+e}),void 0===i.api?o("API Endpoint "+s+" does not exist!"):(r.info("QueryObject","Querying "+s),e.collection.syncViaJSONAPI(s).then(function(t){return n(e)}).catch(function(e){return o(e)}))}else o("No smallstack.api.url configuration set! Can't call JSON API!")}})},e.prototype.expand=function(e){return e instanceof Array&&e.length>0?this.collection.subscribeForeignKeys(this.getCursor(),e):Promise.resolve()},e.prototype.getCount=function(){return this.collection.getQueryCount(this.subscriptionName,this.parameters)},e.prototype.getPage=function(e){var t=this;return new Promise(function(n,o){return k(t,void 0,void 0,function(){return A(this,function(t){switch(t.label){case 0:return[4,this.subscribe()];case 1:return t.sent(),this.queryOptions.currentPage=e,n(this.getModels()),[2]}})})})},e.prototype.getNextPage=function(){var e=this;return new Promise(function(t,n){return k(e,void 0,void 0,function(){var e;return A(this,function(o){switch(o.label){case 0:return this.hasNextPage()?(this.queryOptions.currentPage++,[4,this.subscribe()]):[3,3];case 1:return o.sent(),e=t,[4,this.getModels()];case 2:return e.apply(void 0,[o.sent()]),[3,4];case 3:n("No next page available!"),o.label=4;case 4:return[2]}})})})},e.prototype.getCurrentPage=function(){var e=this;return new Promise(function(t,n){return k(e,void 0,void 0,function(){var e;return A(this,function(n){switch(n.label){case 0:return[4,this.subscribe()];case 1:return n.sent(),e=t,[4,this.getModels()];case 2:return e.apply(void 0,[n.sent()]),[2]}})})})},e.prototype.getPreviousPage=function(){var e=this;return new Promise(function(t,n){return k(e,void 0,void 0,function(){var e;return A(this,function(o){switch(o.label){case 0:return this.hasPreviousPage()?(this.queryOptions.currentPage--,[4,this.subscribe()]):[3,3];case 1:return o.sent(),e=t,[4,this.getModels()];case 2:return e.apply(void 0,[o.sent()]),[3,4];case 3:n("No previous page available!"),o.label=4;case 4:return[2]}})})})},e.prototype.hasNextPage=function(){return void 0!==this.totalCount&&this.totalCount>this.queryOptions.entriesPerPage*this.queryOptions.currentPage},e.prototype.hasPreviousPage=function(){return this.queryOptions.currentPage>1},N([u(),O("design:type",w)],e.prototype,"typesystem",void 0),N([u(),O("design:type",Object)],e.prototype,"cursorResolver",void 0),N([u(),O("design:type",Object)],e.prototype,"dataBridge",void 0),N([u(),O("design:type",Object)],e.prototype,"configurationService",void 0),e}(),R=function(){function e(){}return e.interpolate=function(e,n){var o=this;if(void 0!==e){var i=JSON.stringify(e);if(void 0!==i){var c=(i=i.replace(/\$currentUserId/g,n.userId)).match(/\"\:([a-zA-Z\[\]\:]{2,})\"/g);null!==c&&t.forEach(c,function(t){var c=t.split(":")[1];if(c=c.replace('"',""),!n.parameters||void 0===n.parameters[c]){var s="Expected missing parameter '"+c+"' while interpolating query!";return r.error("QueryUtils",s,{selector:e,context:n}),new Error(s+" - "+JSON.stringify(e))}var a=new RegExp(o.escapeRegExp(t),"g");i=i.replace(a,JSON.stringify(n.parameters[c]))}),e=JSON.parse(i)}else e={}}else e={};return e},e.escapeRegExp=function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},e}(),M=function(){function e(){}return e.fromDocument=function(n){var o=new e;return t.extend(o,n),o},e.prototype.getServiceName=function(){if(void 0!==this.service)return void 0!==this.service.name?this.service.name:this.getModelName()+"Service"},e.prototype.getServiceClassName=function(){return this.getServiceName()},e.prototype.getGeneratedServiceClassName=function(){return"Generated"+this.getServiceClassName()},e.prototype.getModelName=function(){if(this.model.name)return this.model.name;throw new Error("No model name given! How did that happen...")},e.prototype.getModelClassName=function(){return this.getModelName()},e.prototype.getGeneratedModelClassName=function(){return"Generated"+this.getModelClassName()},e.prototype.getService=function(){var e=this.getServiceName();return e=e.charAt(0).toLowerCase()+e.slice(1),i.get(e)},e.prototype.getCollectionName=function(){if(this.collection)return this.collection.name},e.prototype.getCollectionClassName=function(){var e=this.getCollectionName();if(e)return f.capitalize(e)+"Collection"},e.prototype.getGeneratedCollectionClassName=function(){return"Generated"+this.getCollectionClassName()},e.prototype.getModel=function(){return i.get(this.getModelName())},e.prototype.getServiceQueryByName=function(e){if(this.service)return t.find(this.service.queries,function(t){return t.name===e})},e.prototype.getSchemaEntryByName=function(e){return t.find(this.model.schema,function(t){return t.name===e})},e.prototype.getSearchableFields=function(){for(var e=[],t=0,n=this.model.schema;t<n.length;t++){var o=n[t];"foreign[]"!==o.type&&"foreign"!==o.type&&e.push(o)}return e.push({name:"_id",optional:!1,type:"string"}),e},e.prototype.getForeignGetter=function(){return"get"+o(this.getModelName())+"ByIds"},e}(),E=function(){function e(){}return e.extractServiceQuery=function(e){if("string"==typeof e){var t=e.split(".");return{queryName:t[1],serviceName:t[0]}}},e.getQueryObjectMethod=function(e,t){if(void 0===e)throw new Error("No Service Name given!");e=f.decapitalize(e);var n=i.get(e);if(void 0===n)throw new Error("Service not found : "+e);if("function"!=typeof n[t]){var o="get"+f.capitalize(t);if("function"!=typeof n[o])throw new Error("Query not found : "+t+" or "+o);t=o}return n[t].bind(n)},e.isPrimitiveType=function(e){switch(e=e.toLowerCase().replace(/\[|\]/g,"")){case"number":case"string":case"date":case"boolean":case"blob":case"file":case"any":case"object":return!0}return!1},e.extractSelectorParameters=function(e){if(void 0===e)return[];var t=JSON.stringify(e);t=t.replace(/\'/g,'"');for(var n,o=[],r=/\":([a-zA-Z]*):([a-zA-Z\[\]]*)\"/g;null!==(n=r.exec(t));)o.push(n[1]);return o},e}();i.register("QueryObject",x),e.InitLevelService=a,e.IOC=i,e.Autowired=u,e.Logger=r,e.Utils=f,e.FrontendError=d,e.FrontendErrorRegistry=g,e.InMemoryConfigurationService=h,e.ConsoleNotifier=y,e.GoogleAnalyticsService=m,e.Collection=P,e.CollectionAccessService=S,e.DefaultQueryObject=x,e.QueryUtils=R,e.Type=M,e.Typesystem=w,e.TypesystemUtils=E,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("underscore"),require("window-or-global"),require("pluralize")):"function"==typeof define&&define.amd?define(["exports","underscore","window-or-global","pluralize"],t):t(e["@smallstack/common"]={},e._,e.root,e.pluralize)}(this,function(e,t,n,o){"use strict";n=n&&n.hasOwnProperty("default")?n.default:n,o=o&&o.hasOwnProperty("default")?o.default:o;var r=function(){function e(){}return e.log=function(e,t,n,o){if(this.loggingModule(e,t)){t.length>this.loggerMaxLength&&(this.loggerMaxLength=t.length);var r=this.loggerMaxLength-t.length;if(r>0)for(var i=0;i<r;i++)t+=" ";var c="debug"===e?"log":e;"undefined"!=typeof console&&"function"==typeof console[c]&&(o?console[c](t+" "+n,o):console[c](t+" "+n))}},e.info=function(e,t,n){this.log("info",e,t,n)},e.warning=function(e,t,n){this.log("warn",e,t,n)},e.error=function(e,t,n){this.log("error",e,t,n)},e.debug=function(e,t,n){this.log("debug",e,t,n)},e.loggingModule=function(e,t){return!!this.debugMode||("debug"!==e||-1!==this.debugModules.indexOf(t))},e.printSmallstackLogo=function(){console.log(" "),console.log(" _ _ _ _ "),console.log(" ___ _ __ ___ __ _ | || | ___ | |_ __ _ ___ | | __"),console.log("/ __|| '_ ` _ \\ / _` || || |/ __|| __| / _` | / __|| |/ /"),console.log("\\__ \\| | | | | || (_| || || |\\__ \\| |_ | (_| || (__ | < "),console.log("|___/|_| |_| |_| \\__,_||_||_||___/ \\__| \\__,_| \\___||_|\\_\\"),console.log("visit us on https://smallstack.io!"),console.log(" ")},e.addDebugModule=function(e){this.debugModules.push(e)},e.debugMode=!1,e.loggerMaxLength=24,e.debugModules=[],e}(),i=function(){function e(e){void 0===e&&(e=!1);var n=this;this.container={},this.onRegisterCallbacks={},this.id=t.random(0,99999).toString(),e&&setTimeout(function(){var e="";t.each(n.onRegisterCallbacks,function(t,o){n.container[o]||(""!==e&&(e+=", "),e+=o)}),""!==e&&r.error("IOC","After 10s the following references could not be resolved : "+e,n.id)},1e4)}return e.prototype.register=function(e,n,o){void 0===o&&(o=!1);{if(!this.container[e]||o)return this.container[e]=n,r.debug("IOC","registered Object with ID: "+e+", Type:"+typeof n,this.id),this.onRegisterCallbacks[e]&&(t.each(this.onRegisterCallbacks[e],function(e){e.callback(n)}),this.onRegisterCallbacks[e]=t.reject(this.onRegisterCallbacks[e],function(e){return!0===e.callOnlyOnce})),n;r.debug("IOC","Ignoring re-registering of "+e+" since there is already an instance!",this.id)}},e.register=function(t,n,o){return void 0===o&&(o=!1),e.instance().register(t,n,o)},e.prototype.get=function(e){if(this.isRegistered(e))return this.container[e];throw new Error("Could not find an ioc instance for id : '"+e+"'!")},e.get=function(t){return e.instance().get(t)},e.prototype.isRegistered=function(e){return void 0!==this.container[e]},e.isRegistered=function(t){return e.instance().isRegistered(t)},e.instance=function(){return void 0===n.smallstack_ioc&&(n.smallstack_ioc=new e),n.smallstack_ioc},e.prototype.onRegister=function(e,t,n){void 0===n&&(n=!1),this.isRegistered(e)&&t(this.get(e)),this.onRegisterCallbacks[e]||(this.onRegisterCallbacks[e]=[]),this.onRegisterCallbacks[e].push({callback:t,callOnlyOnce:n})},e.onRegister=function(t,n,o){void 0===o&&(o=!1),e.instance().onRegister(t,n,o)},e.prototype.getIOCID=function(){return this.id},e.prototype.clear=function(){this.container=[],this.onRegisterCallbacks={}},e.clear=function(){e.instance().clear()},e}(),c=function(e,t,n,o){return new(n||(n=Promise))(function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){e.done?r(e.value):new n(function(t){t(e.value)}).then(c,s)}a((o=o.apply(e,t||[])).next())})},s=function(e,t){var n,o,r,i,c={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;c;)try{if(n=1,o&&(r=o[2&i[0]?"return":i[0]?"throw":"next"])&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[0,r.value]),i[0]){case 0:case 1:r=i;break;case 4:return c.label++,{value:i[1],done:!1};case 5:c.label++,o=i[1],i=[0];continue;case 7:i=c.ops.pop(),c.trys.pop();continue;default:if(!(r=(r=c.trys).length>0&&r[r.length-1])&&(6===i[0]||2===i[0])){c=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){c.label=i[1];break}if(6===i[0]&&c.label<r[1]){c.label=r[1],r=i;break}if(r&&c.label<r[2]){c.label=r[2],c.ops.push(i);break}r[2]&&c.ops.pop(),c.trys.pop();continue}i=t.call(e,c)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},a=function(){function e(){this.initLevels={}}return e.instance=function(){return i.get("initLevelService")},e.prototype.addInitLevelFn=function(e){if("function"!=typeof e.fn)throw new Error("No fn set for init level function: "+JSON.stringify(e));if("string"!=typeof e.identifier||""===e.identifier)throw new Error("No identifier set for init level function: "+JSON.stringify(e));if(void 0===e.level&&(e.level=50),void 0!==e.stopOnFailure&&"boolean"==typeof e.stopOnFailure||(e.stopOnFailure=!0),e.level<0||e.level>100)throw new Error("InitLevel should be between 0 and 100 (both inclusive): "+JSON.stringify(e));void 0===this.initLevels[e.level]&&(this.initLevels[e.level]=[]),r.debug("InitLevelService","Added '"+e.identifier+"' on init level "+e.level),this.initLevels[e.level].push(e)},e.prototype.execute=function(){return c(this,void 0,void 0,function(){var e,t,n,o,i;return s(this,function(c){switch(c.label){case 0:e=0,c.label=1;case 1:if(!(e<=100))return[3,8];if(!this.initLevels[e])return[3,7];t=0,n=this.initLevels[e],c.label=2;case 2:if(!(t<n.length))return[3,7];o=n[t],r.debug("InitLevelService","Executing '"+o.identifier+"'!"),c.label=3;case 3:return c.trys.push([3,5,,6]),[4,o.fn()];case 4:return c.sent(),[3,6];case 5:if(i=c.sent(),o.stopOnFailure)throw r.error("InitLevelService","Execution of '"+o.identifier+"' failed! InitLevel execution will stop!"),i;return r.warning("InitLevelService","Execution of '"+o.identifier+"' failed! InitLevel execution continuing due stopOnFailure === false!"),[3,6];case 6:return t++,[3,2];case 7:return e++,[3,1];case 8:return[2]}})})},e}();function u(e){if("string"==typeof e)throw new Error("Passing a string is deprecated, please pass an object instead!");return function(t,n){var o=e&&void 0!==e.name?e.name:n;e&&void 0!==e.lazyLoading&&!0!==e.lazyLoading?i.isRegistered(o)?t[n]=i.get(o):r.debug("Autowired","Could not autowire dependency '"+o+"'",{target:t,decoratedPropertyName:n}):i.onRegister(o,function(e){t[n]=e})}}(l=e.PadDirection||(e.PadDirection={}))[l.RIGHT=0]="RIGHT",l[l.LEFT=1]="LEFT";var l,f=function(){function n(){}return n.isNonEmptyString=function(e){return t.isString(e)&&!t.isUndefined(e)&&!t.isEmpty(e)&&null!==e&&void 0!==e},n.isEmptyString=function(e){return!n.isNonEmptyString(e)},n.stringEndsWith=function(e,t){return-1!==e.indexOf(t,e.length-t.length)},n.dasherize=function(e){return e.replace(/[A-Z]/g,function(e,t){return(0!==t?"-":"")+e.toLowerCase()})},n.decapitalize=function(e){return e.charAt(0).toLowerCase()+e.slice(1)},n.capitalize=function(e){return e.charAt(0).toUpperCase()+e.slice(1)},n.spaceBeforeUppercase=function(e){return e.replace(/([A-Z])/g," $1").trim()},n.padString=function(t,n,o,r){void 0===o&&(o=e.PadDirection.LEFT),void 0===r&&(r=" "),length=t.length;var i=length-t.length;switch(r.length>1&&(r=r.charAt(0)),o){case e.PadDirection.RIGHT:for(var c=0;c<i;c++)t+=r;return t;default:for(c=0;c<i;c++)t=r+t;return t}},n.isMobile=function(){var e=navigator.userAgent||navigator.vendor||window.opera;return!(!/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(e)&&!/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(e.substr(0,4)))},n.getUrlParameterByName=function(e,t){e=e.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var n=new RegExp("[\\?&]"+e+"=([^&#]*)").exec(t);return null===n?void 0:decodeURIComponent(n[1].replace(/\+/g," "))},n.check=function(e,t,n,o){return r.debug("Utils","Utils.check is deprecated in favor of Utils.typeOfCheck!"),this.typeOfCheck(e,t,n,o)},n.typeOfCheck=function(e,t,n,o){if(typeof e!==t){var r=new Error(n+" is not of type "+t+", rather of type : "+typeof e);throw o&&o(r),r}},n.createUrlConformIdFromInput=function(e,t){return void 0===e?"":(e=(e=(e=(e=(e=(e=e.replace(/[üÜ]/g,"ue")).replace(/[äÄ]/g,"ae")).replace(/[öÖ]/g,"oe")).replace(/[ß]/g,"ss")).replace(/ /g,"_")).replace(/[^a-zA-Z0-9\_\-]/g,"").toLowerCase(),t?e.substring(0,t):e)},n.isValidEmail=function(e){return/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(e)},n.unflattenJSON=function(e){if(Object(e)!==e||Array.isArray(e))return e;var t=/\.?([^.\[\]]+)|\[(\d+)\]/g,n={};for(var o in e)if(e.hasOwnProperty(o)){for(var r=n,i="",c=void 0;c=t.exec(o);)r=r[i]||(r[i]=c[2]?[]:{}),i=c[2]||c[1];r[i]=e[o]}return n[""]||n},n.flattenJSON=function(e,t){void 0===t&&(t=!0);var n={};return function e(o,r){if(Object(o)!==o)n[r]=o;else if(Array.isArray(o))if(t){for(var i=0,c=o.length;i<c;i++)e(o[i],r+"["+i+"]");0===o.length&&(n[r]=[])}else n[r]=o;else{var s=!0;for(var a in o)o.hasOwnProperty(a)&&(s=!1,e(o[a],r?r+"."+a:a));s&&r&&(n[r]={})}}(e,""),n},n.prettyPrintJson=function(e,n){if(void 0===e)return"-";var o=e;return t.isObject(e)&&(o=JSON.stringify(e,void 0,4)),n&&o.length>n?o.substring(0,n-6)+" (...)":o},n.convertHexToRGB=function(e){if(6!==(e=e.replace("#","")).length)throw new Error("Please provide hex colors in 6-digit format!");return{r:parseInt(e.substring(0,2),16),g:parseInt(e.substring(2,4),16),b:parseInt(e.substring(4,6),16)}},n.isValidUrlName=function(e){return/\b((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b/.test(e)},n.dataURLtoBlob=function(e){for(var t=e.split(","),n=t[0].match(/:(.*?);/)[1],o=atob(t[1]),r=o.length,i=new Uint8Array(r);r--;)i[r]=o.charCodeAt(r);return new Blob([i],{type:n})},n.blobToDataURL=function(e,t){var n=new FileReader;n.onload=function(e){t(e.target.result)},n.readAsDataURL(e)},n.blobToArrayBuffer=function(e,t){var n=new FileReader;n.onload=function(){t(this.result)},n.readAsArrayBuffer(e)},n.dataUrlToBuffer=function(e,t){this.blobToArrayBuffer(this.dataURLtoBlob(e),t)},n.imageUrlToBlob=function(e,t){var n=new Image;n.onerror=function(){r.error("Utils","Could not convert url to blob: ",e)},n.onload=function(){var e=document.createElement("canvas");e.width=this.width,e.height=this.height;e.getContext("2d").drawImage(this,0,0),e.toBlob(function(e){t(e)})},n.src=e},n.getApiURL=function(e,t){return e+"/"+n.decapitalize(t.replace("get","")).toLowerCase()},n}(),p=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){e(t,n);function o(){this.constructor=t}t.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}(),d=function(e){p(t,e);function t(t,n){var o=this;return"string"==typeof t?(o=e.call(this,t)||this).i18nKey=t:((o=e.call(this,t.i18nKey)||this).i18nKey=t.i18nKey,o.supportCode=t.supportCode,o.internalDescription=t.internalDescription),o.context=n,o}return t.prototype.setContext=function(e){return this.context=e,this},t}(Error),g=function(){function e(){this.errors={}}return e.instance=function(){return i.get("frontendErrorRegistry")},e.prototype.addCollection=function(e){for(var n=0,o=t.values(e);n<o.length;n++){var r=o[n];this.add(r)}},e.prototype.add=function(e){if("string"!=typeof e.supportCode||""===e.supportCode)throw new Error("Please provide a support code while adding frontend errors!");this.errors[e.supportCode]=new d(e)},e.prototype.getAllFrontendErrors=function(){return t.values(this.errors)},e}(),h=function(){function e(){this.configuration={},this.onSetCallbacks={}}return e.prototype.set=function(e,t,n){this.configuration[e]={key:e,value:t,scope:n}},e.prototype.unset=function(e){delete this.configuration[e]},e.prototype.get=function(e,t){return this.contains(e)?this.configuration[e].value:t},e.prototype.onSet=function(e,t){void 0===this.onSetCallbacks[e]&&(this.onSetCallbacks[e]=[]),this.onSetCallbacks[e].push(t)},e.prototype.contains=function(e){return void 0!==this.configuration[e]},e}(),y=function(){function e(){}return e.prototype.log=function(e,t,n){switch(n){case"debug":console.debug(e+" - "+t);break;case"error":console.error(e+" - "+t);break;case"warn":console.warn(e+" - "+t);break;case"info":case"success":default:console.log(e+" - "+t)}},e.prototype.info=function(e,t){this.log(e,t,"info")},e.prototype.success=function(e,t){this.log(e,t,"success")},e.prototype.debug=function(e,t){this.log(e,t,"debug")},e.prototype.warn=function(e,t){this.log(e,t,"warn")},e.prototype.error=function(e,t){this.log(e,t,"error")},e.prototype.confirmation=function(e,t,n){throw new Error("Console Notifier cannot ask questions!")},e}(),v=function(e,t,n,o){var r,i=arguments.length,c=i<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(c=(i<3?r(c):i>3?r(t,n,c):r(t,n))||c);return i>3&&c&&Object.defineProperty(t,n,c),c},b=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},m=function(){function e(e){var t=this;e&&this.loadGA(e),i.onRegister("configurationService",function(e){e.onSet("googleanalytics.trackingid",function(e){t.loadGA(e)})})}return e.prototype.track=function(e,t){"undefined"==typeof ga?r.debug("GoogleAnalyticsService","ga not loaded!"):ga(function(t){void 0===t?r.debug("GoogleAnalyticsService","No GA Tracker defined yet!"):(r.debug("GoogleAnalyticsService","Sending GA tracking for path : ",e),ga("send","pageview",e))})},e.prototype.event=function(e,t){t||(t={}),t.category||(t.category="default"),"undefined"==typeof ga?r.debug("GoogleAnalyticsService","ga not loaded!"):ga(function(n){void 0===n?r.debug("GoogleAnalyticsService","No GA Tracker defined yet!"):(r.debug("GoogleAnalyticsService","Sending GA event for eventname : ",e),ga("send","event",t.category,e,t.label,t.value))})},e.prototype.loadGA=function(e){void 0!==e&&(t=window,n=document,o=void 0,i=void 0,t.GoogleAnalyticsObject="ga",t.ga=t.ga||function(){(t.ga.q=t.ga.q||[]).push(arguments)},t.ga.l=(new Date).getTime(),o=n.createElement("script"),i=n.getElementsByTagName("script")[0],o.async=1,o.src="https://www.google-analytics.com/analytics.js",i.parentNode.insertBefore(o,i),ga("create",e,"auto"),ga("send","pageview"),r.debug("GoogleAnalyticsService","Successfully initialized ga object!"));var t,n,o,i},v([u(),b("design:type",Object)],e.prototype,"dataBridge",void 0),e}(),w=function(){function e(){this.types={},this.afterTypeAddedCallbacks=[]}return e.instance=function(){return i.get("typesystem")},e.prototype.addType=function(e){r.debug("Typesystem","Adding type '"+e.getModelName()+"'!"),this.types[e.getModelName()]=e,t.each(this.afterTypeAddedCallbacks,function(t){t(e)})},e.prototype.afterTypeAdded=function(e){this.afterTypeAddedCallbacks.push(e)},e.prototype.getTypeByModelName=function(e){return t.find(this.types,function(t){if(-1!==e.indexOf("::")){var n=e.split("::");return t.model&&t.packageName===n[0]&&t.model.name===n[1]}return t.model&&t.model.name===e})},e.prototype.getTypeByCollectionName=function(e){return t.find(this.types,function(t){return t.collection&&t.collection.name===e})},e.prototype.getAllTypes=function(){return t.values(this.types)},e.prototype.getTypeByServiceName=function(e){return t.find(this.types,function(t){return void 0!==t.service&&t.service.name===e})},e.prototype.getCollectionNameForServiceName=function(e){var t=this.getTypeByServiceName(f.capitalize(e));if(t&&t.collection)return t.collection.name},e}(),C=function(e,t,n,o){var r,i=arguments.length,c=i<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(c=(i<3?r(c):i>3?r(t,n,c):r(t,n))||c);return i>3&&c&&Object.defineProperty(t,n,c),c},_=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},O=function(){function e(){}return e.prototype.subscribe=function(e,t,n){var o=this;return new Promise(function(i,c){r.debug("Collection","Subscribing to "+e),o.dataBridge.ddpSubscribe(e,t,n,{onStop:function(t){t?c(t):r.debug("Collection","Successfully stopped subscription to "+o.getCollectionName()+"->"+e)},onError:function(t){c(t||new Error("An unknown error occured while subscribing to : "+o.getCollectionName()+"->"+e))},onReady:function(){i()}})})},e.prototype.syncViaJSONAPI=function(e){var n=this;return new Promise(function(o,i){n.dataBridge.httpCall("GET",e,{}).then(function(e){r.debug("Collection","Syncing models: ",e),t.each(e,function(e){e.id&&!e._id&&(e._id=e.id,delete e.id),r.debug("Collection","Syncing model: ",JSON.stringify(e)),n.mongoDBCollection.upsert({_id:e._id},e)}),o()}).catch(function(e){i(e)})})},e.prototype.subscribeForeignKeys=function(e,t){return this.collectionsService.subscribeForeignKeys(this,e,t)},e.prototype.getQueryCount=function(e,t){return this.dataBridge.ddpCall("server-counts",{queryName:e,parameters:t})},e.prototype.getMongoDBCollection=function(){return this.mongoDBCollection},e.prototype.applyAllowDenyRules=function(){var e=this.getMongoDBCollectionAllowRules(),t=this.getMongoDBCollectionDenyRules();e&&this.mongoDBCollection.allow(e),t&&this.mongoDBCollection.deny(t)},e.prototype.getMongoDBCollectionAllowRules=function(){},e.prototype.getMongoDBCollectionDenyRules=function(){return{insert:function(e,t){return!1},update:function(e,t,n,o){return!1},remove:function(e,t){return!1}}},C([u(),_("design:type",Object)],e.prototype,"collectionsService",void 0),C([u(),_("design:type",w)],e.prototype,"typesystem",void 0),C([u(),_("design:type",Object)],e.prototype,"dataBridge",void 0),e}(),P=function(){function e(){this.publisherMethods={}}return e.instance=function(){return i.get("collectionAccessService")},e.prototype.checkAccess=function(e,n,o){var r=this;if(void 0!==e.access){var i={context:n,parameters:o,accessObject:e.access};switch(typeof e.access){case"string":return[this.executePublisherMethod(e.access,i)];case"object":var c=[];return t.each(e.access,function(e,t){c.push(r.executePublisherMethod(t,i))}),c;default:throw new Error("Type of query.access: '"+typeof e.access+"' is not allowed!")}}},e.prototype.addPublisherMethod=function(e,t){this.publisherMethods[e]=t},e.prototype.executePublisherMethod=function(e,t){var n=this.publisherMethods[e];if(!n)throw new Error("Publication method '"+e+"' could not be found!");var o=n(t);if("boolean"===o.type&&!1===o.value)throw new Error("Access restricted by '"+e+"'!");return o},e.prototype.getAccessMethod=function(e){return this.publisherMethods[e]},e.prototype.publisherMethodAvailable=function(e){return void 0!==this.publisherMethods[e]},e}(),S=function(){function e(){}return e.create=function(e,t,n,o,r,c){return(new(i.get("QueryObject"))).create(e,t,n,o,r,c)},e}(),N=function(e,t,n,o){var r,i=arguments.length,c=i<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(c=(i<3?r(c):i>3?r(t,n,c):r(t,n))||c);return i>3&&c&&Object.defineProperty(t,n,c),c},k=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},A=function(e,t,n,o){return new(n||(n=Promise))(function(r,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){e.done?r(e.value):new n(function(t){t(e.value)}).then(c,s)}a((o=o.apply(e,t||[])).next())})},x=function(e,t){var n,o,r,i,c={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;c;)try{if(n=1,o&&(r=o[2&i[0]?"return":i[0]?"throw":"next"])&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[0,r.value]),i[0]){case 0:case 1:r=i;break;case 4:return c.label++,{value:i[1],done:!1};case 5:c.label++,o=i[1],i=[0];continue;case 7:i=c.ops.pop(),c.trys.pop();continue;default:if(!(r=(r=c.trys).length>0&&r[r.length-1])&&(6===i[0]||2===i[0])){c=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){c.label=i[1];break}if(6===i[0]&&c.label<r[1]){c.label=r[1],r=i;break}if(r&&c.label<r[2]){c.label=r[2],c.ops.push(i);break}r[2]&&c.ops.pop(),c.trys.pop();continue}i=t.call(e,c)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},R=function(){function e(){this.isSubscribed=!1}return e.prototype.create=function(e,t,n,o,r,i){this.queryOptions=n||{},this.queryOptions.currentPage=this.queryOptions.currentPage||1,this.queryOptions.entriesPerPage=this.queryOptions.entriesPerPage||10,this.sorting=r,this.subscriptionName=t,this.selector=e,this.parameters=o,this.collection=i;var c=this.collection.getCollectionName(),s=this.typesystem.getTypeByCollectionName(c);if(void 0===s)throw new Error("Could not find type by collectionName '"+c+"'!");return this.ModelConstructor=s.getModel(),this},e.prototype.getSelector=function(){return this.selector},e.prototype.getCursor=function(){return this.collection.getMongoDBCollection().find(this.selector,this.convertQueryOptionsToMongoSelector(this.queryOptions,this.sorting))},e.prototype.convertQueryOptionsToMongoSelector=function(e,t,n){void 0===n&&(n=!0);var o={sort:t,reactive:e&&!0===e.reactive};return n?(e&&e.currentPage&&e.entriesPerPage&&(o.skip=(e.currentPage-1)*e.entriesPerPage),e&&e.entriesPerPage&&(o.limit=e.entriesPerPage)):(o.skip=0,e&&e.entriesPerPage&&(o.limit=e.currentPage*e.entriesPerPage)),o},e.prototype.getModels=function(){return this.cursorResolver.resolve(this.getCursor(),{ModelConstructor:this.ModelConstructor})},e.prototype.getModel=function(e){var t=this;return new Promise(function(n){return A(t,void 0,void 0,function(){var t;return x(this,function(o){switch(o.label){case 0:return[4,this.getModels()];case 1:return t=o.sent(),n(t[e]),[2]}})})})},e.prototype.subscribe=function(){var e=this;return new Promise(function(t,n){return A(e,void 0,void 0,function(){var e;return x(this,function(n){switch(n.label){case 0:return r.debug("QueryObject","Subscribing to '"+this.subscriptionName+"'!"),[4,this.collection.subscribe(this.subscriptionName,this.parameters,this.convertQueryOptionsToMongoSelector(this.queryOptions,this.sorting,!1))];case 1:return n.sent(),this.isSubscribed=!0,e=this,[4,this.collection.getQueryCount(this.subscriptionName,this.parameters)];case 2:return e.totalCount=n.sent(),t(this),[2]}})})})},e.prototype.syncViaJSONAPI=function(){var e=this;return new Promise(function(n,o){var i=e.typesystem.getTypeByCollectionName(e.collection.getCollectionName()).getServiceQueryByName(e.subscriptionName);if(void 0===i)o("Could not find TypeServiceQuery for collection "+e.collection.getCollectionName()+" and serviceQuery "+e.subscriptionName);else{var c=e.configurationService.get("smallstack.api.url");if(c){f.stringEndsWith(c,"/")||(c+="/");var s=c+f.getApiURL(e.collection.getCollectionName(),e.subscriptionName);s=s+"?currentPage="+e.queryOptions.currentPage+"&entriesPerPage="+e.queryOptions.entriesPerPage,t.each(e.parameters,function(e,t){e instanceof Array&&(e=JSON.stringify(e)),s+="&"+t+"="+e}),void 0===i.api?o("API Endpoint "+s+" does not exist!"):(r.info("QueryObject","Querying "+s),e.collection.syncViaJSONAPI(s).then(function(t){return n(e)}).catch(function(e){return o(e)}))}else o("No smallstack.api.url configuration set! Can't call JSON API!")}})},e.prototype.expand=function(e){return e instanceof Array&&e.length>0?this.collection.subscribeForeignKeys(this.getCursor(),e):Promise.resolve()},e.prototype.getCount=function(){return this.collection.getQueryCount(this.subscriptionName,this.parameters)},e.prototype.getPage=function(e){var t=this;return new Promise(function(n,o){return A(t,void 0,void 0,function(){return x(this,function(t){switch(t.label){case 0:return[4,this.subscribe()];case 1:return t.sent(),this.queryOptions.currentPage=e,n(this.getModels()),[2]}})})})},e.prototype.getNextPage=function(){var e=this;return new Promise(function(t,n){return A(e,void 0,void 0,function(){var e;return x(this,function(o){switch(o.label){case 0:return this.hasNextPage()?(this.queryOptions.currentPage++,[4,this.subscribe()]):[3,3];case 1:return o.sent(),e=t,[4,this.getModels()];case 2:return e.apply(void 0,[o.sent()]),[3,4];case 3:n("No next page available!"),o.label=4;case 4:return[2]}})})})},e.prototype.getCurrentPage=function(){var e=this;return new Promise(function(t,n){return A(e,void 0,void 0,function(){var e;return x(this,function(n){switch(n.label){case 0:return[4,this.subscribe()];case 1:return n.sent(),e=t,[4,this.getModels()];case 2:return e.apply(void 0,[n.sent()]),[2]}})})})},e.prototype.getPreviousPage=function(){var e=this;return new Promise(function(t,n){return A(e,void 0,void 0,function(){var e;return x(this,function(o){switch(o.label){case 0:return this.hasPreviousPage()?(this.queryOptions.currentPage--,[4,this.subscribe()]):[3,3];case 1:return o.sent(),e=t,[4,this.getModels()];case 2:return e.apply(void 0,[o.sent()]),[3,4];case 3:n("No previous page available!"),o.label=4;case 4:return[2]}})})})},e.prototype.hasNextPage=function(){return void 0!==this.totalCount&&this.totalCount>this.queryOptions.entriesPerPage*this.queryOptions.currentPage},e.prototype.hasPreviousPage=function(){return this.queryOptions.currentPage>1},N([u(),k("design:type",w)],e.prototype,"typesystem",void 0),N([u(),k("design:type",Object)],e.prototype,"cursorResolver",void 0),N([u(),k("design:type",Object)],e.prototype,"dataBridge",void 0),N([u(),k("design:type",Object)],e.prototype,"configurationService",void 0),e}(),M=function(){function e(){}return e.interpolate=function(e,n){var o=this;if(void 0!==e){var i=JSON.stringify(e);if(void 0!==i){var c=(i=i.replace(/\$currentUserId/g,n.userId)).match(/\"\:([a-zA-Z\[\]\:]{2,})\"/g);null!==c&&t.forEach(c,function(t){var c=t.split(":")[1];if(c=c.replace('"',""),!n.parameters||void 0===n.parameters[c]){var s="Expected missing parameter '"+c+"' while interpolating query!";return r.error("QueryUtils",s,{selector:e,context:n}),new Error(s+" - "+JSON.stringify(e))}var a=new RegExp(o.escapeRegExp(t),"g");i=i.replace(a,JSON.stringify(n.parameters[c]))}),e=JSON.parse(i)}else e={}}else e={};return e},e.escapeRegExp=function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},e}(),E=function(){function e(){}return e.fromDocument=function(n){var o=new e;return t.extend(o,n),o},e.prototype.getServiceName=function(){if(void 0!==this.service)return void 0!==this.service.name?this.service.name:this.getModelName()+"Service"},e.prototype.getServiceClassName=function(){return this.getServiceName()},e.prototype.getGeneratedServiceClassName=function(){return"Generated"+this.getServiceClassName()},e.prototype.getModelName=function(){if(this.model.name)return this.model.name;throw new Error("No model name given! How did that happen...")},e.prototype.getModelClassName=function(){return this.getModelName()},e.prototype.getGeneratedModelClassName=function(){return"Generated"+this.getModelClassName()},e.prototype.getService=function(){var e=this.getServiceName();return e=e.charAt(0).toLowerCase()+e.slice(1),i.get(e)},e.prototype.getCollectionName=function(){if(this.collection)return this.collection.name},e.prototype.getCollectionClassName=function(){var e=this.getCollectionName();if(e)return f.capitalize(e)+"Collection"},e.prototype.getGeneratedCollectionClassName=function(){return"Generated"+this.getCollectionClassName()},e.prototype.getModel=function(){return i.get(this.getModelName())},e.prototype.getServiceQueryByName=function(e){if(this.service)return t.find(this.service.queries,function(t){return t.name===e})},e.prototype.getSchemaEntryByName=function(e){return t.find(this.model.schema,function(t){return t.name===e})},e.prototype.getSearchableFields=function(){for(var e=[],t=0,n=this.model.schema;t<n.length;t++){var o=n[t];"foreign[]"!==o.type&&"foreign"!==o.type&&e.push(o)}return e.push({name:"_id",optional:!1,type:"string"}),e},e.prototype.getForeignGetter=function(){return"get"+o(this.getModelName())+"ByIds"},e}(),j=function(){function e(){}return e.extractServiceQuery=function(e){if("string"==typeof e){var t=e.split(".");return{queryName:t[1],serviceName:t[0]}}},e.getQueryObjectMethod=function(e,t){if(void 0===e)throw new Error("No Service Name given!");e=f.decapitalize(e);var n=i.get(e);if(void 0===n)throw new Error("Service not found : "+e);if("function"!=typeof n[t]){var o="get"+f.capitalize(t);if("function"!=typeof n[o])throw new Error("Query not found : "+t+" or "+o);t=o}return n[t].bind(n)},e.isPrimitiveType=function(e){switch(e=e.toLowerCase().replace(/\[|\]/g,"")){case"number":case"string":case"date":case"boolean":case"blob":case"file":case"any":case"object":return!0}return!1},e.extractSelectorParameters=function(e){if(void 0===e)return[];var t=JSON.stringify(e);t=t.replace(/\'/g,'"');for(var n,o=[],r=/\":([a-zA-Z]*):([a-zA-Z\[\]]*)\"/g;null!==(n=r.exec(t));)o.push(n[1]);return o},e}();i.register("QueryObject",R),e.InitLevelService=a,e.IOC=i,e.Autowired=u,e.Logger=r,e.Utils=f,e.FrontendError=d,e.FrontendErrorRegistry=g,e.InMemoryConfigurationService=h,e.ConsoleNotifier=y,e.GoogleAnalyticsService=m,e.Collection=O,e.CollectionAccessService=P,e.QueryObjectBuilder=S,e.DefaultQueryObject=R,e.QueryUtils=M,e.Type=E,e.Typesystem=w,e.TypesystemUtils=j,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=index.umd.js.map |
{ | ||
"name": "@smallstack/common", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"description": "common functionality for smallstack projects", | ||
@@ -5,0 +5,0 @@ "main": "dist/bundle/index.umd.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
169262
42
859