superdata
Version:
A lightweight data layer module motivated by extjs' data layer. It can be used with any client-side framework.
1 lines • 34.9 kB
JavaScript
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).superdata=e()}}(function(){return function s(i,a,u){function d(r,e){if(!a[r]){if(!i[r]){var t="function"==typeof require&&require;if(!e&&t)return t(r,!0);if(c)return c(r,!0);var o=new Error("Cannot find module '"+r+"'");throw o.code="MODULE_NOT_FOUND",o}var n=a[r]={exports:{}};i[r][0].call(n.exports,function(e){return d(i[r][1][e]||e)},n,n.exports,s,i,a,u)}return a[r].exports}for(var c="function"==typeof require&&require,e=0;e<u.length;e++)d(u[e]);return d}({"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/node_modules/component-emitter/index.js":[function(e,r,t){function o(e){if(e)return function(e){for(var r in o.prototype)e[r]=o.prototype[r];return e}(e)}void 0!==r&&(r.exports=o),o.prototype.on=o.prototype.addEventListener=function(e,r){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(r),this},o.prototype.once=function(e,r){function t(){this.off(e,t),r.apply(this,arguments)}return t.fn=r,this.on(e,t),this},o.prototype.off=o.prototype.removeListener=o.prototype.removeAllListeners=o.prototype.removeEventListener=function(e,r){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var t,o=this._callbacks["$"+e];if(!o)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var n=0;n<o.length;n++)if((t=o[n])===r||t.fn===r){o.splice(n,1);break}return this},o.prototype.emit=function(e){this._callbacks=this._callbacks||{};var r=[].slice.call(arguments,1),t=this._callbacks["$"+e];if(t)for(var o=0,n=(t=t.slice(0)).length;o<n;++o)t[o].apply(this,r);return this},o.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},o.prototype.hasListeners=function(e){return!!this.listeners(e).length}},{}],"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/node_modules/form-data/lib/browser.js":[function(e,r,t){r.exports=FormData},{}],"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/node_modules/reduce-component/index.js":[function(e,r,t){r.exports=function(e,r,t){for(var o=0,n=e.length,s=3==arguments.length?t:e[o++];o<n;)s=r.call(null,s,e[o],++o,e);return s}},{}],"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/node_modules/superagent/lib/client.js":[function(e,r,t){var o,n=e("emitter"),s=e("reduce");function c(){}function p(e){switch({}.toString.call(e)){case"[object File]":case"[object Blob]":case"[object FormData]":return!0;default:return!1}}o="undefined"!=typeof window?window:"undefined"!=typeof self?self:this,y.getXHR=function(){if(!(!o.XMLHttpRequest||o.location&&"file:"==o.location.protocol&&o.ActiveXObject))return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(e){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(e){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(e){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(e){}return!1};var d="".trim?function(e){return e.trim()}:function(e){return e.replace(/(^\s*|\s*$)/g,"")};function i(e){return e===Object(e)}function a(e){if(!i(e))return e;var r=[];for(var t in e)null!=e[t]&&u(r,t,e[t]);return r.join("&")}function u(r,t,e){if(Array.isArray(e))return e.forEach(function(e){u(r,t,e)});r.push(encodeURIComponent(t)+"="+encodeURIComponent(e))}function l(e){for(var r,t={},o=e.split("&"),n=0,s=o.length;n<s;++n)r=o[n].split("="),t[decodeURIComponent(r[0])]=decodeURIComponent(r[1]);return t}function f(e,r){r=r||{},this.req=e,this.xhr=this.req.xhr,this.text="HEAD"!=this.req.method&&(""===this.xhr.responseType||"text"===this.xhr.responseType)||void 0===this.xhr.responseType?this.xhr.responseText:null,this.statusText=this.req.xhr.statusText,this.setStatusProperties(this.xhr.status),this.header=this.headers=function(e){var r,t,o,n,s=e.split(/\r?\n/),i={};s.pop();for(var a=0,u=s.length;a<u;++a)r=(t=s[a]).indexOf(":"),o=t.slice(0,r).toLowerCase(),n=d(t.slice(r+1)),i[o]=n;return i}(this.xhr.getAllResponseHeaders()),this.header["content-type"]=this.xhr.getResponseHeader("content-type"),this.setHeaderProperties(this.header),this.body="HEAD"!=this.req.method?this.parseBody(this.text?this.text:this.xhr.response):null}function h(e,r){var o=this;n.call(this),this._query=this._query||[],this.method=e,this.url=r,this.header={},this._header={},this.on("end",function(){var r=null,e=null;try{e=new f(o)}catch(e){return(r=new Error("Parser is unable to parse the response")).parse=!0,r.original=e,r.rawResponse=o.xhr&&o.xhr.responseText?o.xhr.responseText:null,o.callback(r)}if(o.emit("response",e),r)return o.callback(r,e);if(200<=e.status&&e.status<300)return o.callback(r,e);var t=new Error(e.statusText||"Unsuccessful HTTP response");t.original=r,t.response=e,t.status=e.status,o.callback(t,e)})}function y(e,r){return"function"==typeof r?new h("GET",e).end(r):1==arguments.length?new h("GET",e):new h(e,r)}function m(e,r){var t=y("DELETE",e);return r&&t.end(r),t}y.serializeObject=a,y.parseString=l,y.types={html:"text/html",json:"application/json",xml:"application/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},y.serialize={"application/x-www-form-urlencoded":a,"application/json":JSON.stringify},y.parse={"application/x-www-form-urlencoded":l,"application/json":JSON.parse},f.prototype.get=function(e){return this.header[e.toLowerCase()]},f.prototype.setHeaderProperties=function(e){var r=this.header["content-type"]||"";this.type=r.split(/ *; */).shift();var t=s(r.split(/ *; */),function(e,r){var t=r.split(/ *= */),o=t.shift(),n=t.shift();return o&&n&&(e[o]=n),e},{});for(var o in t)this[o]=t[o]},f.prototype.parseBody=function(e){var r=y.parse[this.type];return r&&e&&(e.length||e instanceof Object)?r(e):null},f.prototype.setStatusProperties=function(e){1223===e&&(e=204);var r=e/100|0;this.status=this.statusCode=e,this.statusType=r,this.info=1==r,this.ok=2==r,this.clientError=4==r,this.serverError=5==r,this.error=(4==r||5==r)&&this.toError(),this.accepted=202==e,this.noContent=204==e,this.badRequest=400==e,this.unauthorized=401==e,this.notAcceptable=406==e,this.notFound=404==e,this.forbidden=403==e},f.prototype.toError=function(){var e=this.req,r=e.method,t=e.url,o="cannot "+r+" "+t+" ("+this.status+")",n=new Error(o);return n.status=this.status,n.method=r,n.url=t,n},y.Response=f,n(h.prototype),h.prototype.use=function(e){return e(this),this},h.prototype.timeout=function(e){return this._timeout=e,this},h.prototype.clearTimeout=function(){return this._timeout=0,clearTimeout(this._timer),this},h.prototype.abort=function(){if(!this.aborted)return this.aborted=!0,this.xhr.abort(),this.clearTimeout(),this.emit("abort"),this},h.prototype.set=function(e,r){if(i(e)){for(var t in e)this.set(t,e[t]);return this}return this._header[e.toLowerCase()]=r,this.header[e]=r,this},h.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},h.prototype.getHeader=function(e){return this._header[e.toLowerCase()]},h.prototype.type=function(e){return this.set("Content-Type",y.types[e]||e),this},h.prototype.parse=function(e){return this._parser=e,this},h.prototype.accept=function(e){return this.set("Accept",y.types[e]||e),this},h.prototype.auth=function(e,r){var t=btoa(e+":"+r);return this.set("Authorization","Basic "+t),this},h.prototype.query=function(e){return"string"!=typeof e&&(e=a(e)),e&&this._query.push(e),this},h.prototype.field=function(e,r){return this._formData||(this._formData=new o.FormData),this._formData.append(e,r),this},h.prototype.attach=function(e,r,t){return this._formData||(this._formData=new o.FormData),this._formData.append(e,r,t||r.name),this},h.prototype.send=function(e){var r=i(e),t=this.getHeader("Content-Type");if(r&&i(this._data))for(var o in e)this._data[o]=e[o];else this._data="string"==typeof e?(t||this.type("form"),"application/x-www-form-urlencoded"==(t=this.getHeader("Content-Type"))?this._data?this._data+"&"+e:e:(this._data||"")+e):e;return!r||p(e)||t||this.type("json"),this},h.prototype.callback=function(e,r){var t=this._callback;this.clearTimeout(),t(e,r)},h.prototype.crossDomainError=function(){var e=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");e.crossDomain=!0,e.status=this.status,e.method=this.method,e.url=this.url,this.callback(e)},h.prototype.timeoutError=function(){var e=this._timeout,r=new Error("timeout of "+e+"ms exceeded");r.timeout=e,this.callback(r)},h.prototype.withCredentials=function(){return this._withCredentials=!0,this},h.prototype.end=function(e){var t=this,o=this.xhr=y.getXHR(),r=this._query.join("&"),n=this._timeout,s=this._formData||this._data;this._callback=e||c,o.onreadystatechange=function(){if(4==o.readyState){var r;try{r=o.status}catch(e){r=0}if(0==r){if(t.timedout)return t.timeoutError();if(t.aborted)return;return t.crossDomainError()}t.emit("end")}};var i=function(e){0<e.total&&(e.percent=e.loaded/e.total*100),e.direction="download",t.emit("progress",e)};this.hasListeners("progress")&&(o.onprogress=i);try{o.upload&&this.hasListeners("progress")&&(o.upload.onprogress=i)}catch(e){}if(n&&!this._timer&&(this._timer=setTimeout(function(){t.timedout=!0,t.abort()},n)),r&&(r=y.serializeObject(r),this.url+=~this.url.indexOf("?")?"&"+r:"?"+r),o.open(this.method,this.url,!0),this._withCredentials&&(o.withCredentials=!0),"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof s&&!p(s)){var a=this.getHeader("Content-Type"),u=this._parser||y.serialize[a?a.split(";")[0]:""];!u&&/[\/+]json\b/.test(a)&&(u=y.serialize["application/json"]),u&&(s=u(s))}for(var d in this.header)null!=this.header[d]&&o.setRequestHeader(d,this.header[d]);return this.emit("request",this),o.send(void 0!==s?s:null),this},h.prototype.then=function(t,o){return this.end(function(e,r){e?o(e):t(r)})},y.Request=h,y.get=function(e,r,t){var o=y("GET",e);return"function"==typeof r&&(t=r,r=null),r&&o.query(r),t&&o.end(t),o},y.head=function(e,r,t){var o=y("HEAD",e);return"function"==typeof r&&(t=r,r=null),r&&o.send(r),t&&o.end(t),o},y.del=m,y.delete=m,y.patch=function(e,r,t){var o=y("PATCH",e);return"function"==typeof r&&(t=r,r=null),r&&o.send(r),t&&o.end(t),o},y.post=function(e,r,t){var o=y("POST",e);return"function"==typeof r&&(t=r,r=null),r&&o.send(r),t&&o.end(t),o},y.put=function(e,r,t){var o=y("PUT",e);return"function"==typeof r&&(t=r,r=null),r&&o.send(r),t&&o.end(t),o},r.exports=y},{emitter:"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/node_modules/component-emitter/index.js",reduce:"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/node_modules/reduce-component/index.js"}],"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/src/errorMessages.js":[function(e,r,t){"use strict";r.exports={errorMessages:{NOT_FOUND:"NOT_FOUND",DUPLICATE_KEY:"DUPLICATE_KEY"},exceptionMessages:{NOT_A_FUNCTION:"NOT_A_FUNCTION"}}},{}],"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/src/model/model.js":[function(e,r,t){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},c=e("./modelObject");r.exports=function(e){if(e||(e={}),!e.idField)throw new Error("options.idField is mandatory!");if(!e.fields)throw new Error("options.fields is mandatory!");if(!e.proxy)throw new Error("options.proxy is mandatory!");if(e.belongsTo&&!Array.isArray(e.belongsTo))throw new Error("options.belongsTo has to be an array!");if(Array.isArray(e.belongsTo))for(var r=0;r<e.belongsTo.length;r+=1)if(!e.fields[e.belongsTo[r]])throw new Error("options.belongsTo has to contain field names!");var t=e.idField,o=e.fields,s=e.proxy,i=e.belongsTo||[];function a(e){for(var r=0;r<i.length;r+=1)if(!e[i[r]])return!1;return!0}function u(e){for(var r=0;r<i.length;r+=1)if(n(e[i[r]])!==o[i[r]].type)return!1;return!0}var d=Object.freeze({fields:o,proxy:s,idField:t,belongsTo:i,list:function(e,r,n){if(n||(n=r,r=void 0),!a(r))return n("belongsToValues has to have properties for references given in belongsTo");if(!u(r))return n("Each property of belongsToValues has to match type with corresponding property of options.fields");for(var t={},o=0;o<i.length;o+=1)t[i[o]]=r[i[o]];s.read(e,t,function(e,r){if(e)return n(e);var t=[];r.items.forEach(function(e){t.push(c({model:d,data:e}))});var o={items:t,count:r.count};n(null,o)})},load:function(e,r,o){if(o||(o=r,r=void 0),!a(r))return o("belongsToValues has to have properties for references given in belongsTo");if(!u(r))return o("Each property of belongsToValues has to match type with corresponding property of options.fields");for(var t={},n=0;n<i.length;n+=1)t[i[n]]=r[i[n]];s.readOneById(e,t,function(e,r){if(e)return o(e);var t=c({model:d,data:r});o(null,t)})},create:function(e,t){if(!a(e))return t("modelValues has to have properties for references given in belongsTo");if(!u(e))return t("Each property of modelValues contained by belongsTo has to match type with corresponding property of options.fields");for(var r={},o=0;o<i.length;o+=1)r[i[o]]=e[i[o]];s.createOne(e,r,function(e,r){if(e)return t(e);t(null,c({model:d,data:r}))})}});return d}},{"./modelObject":"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/src/model/modelObject.js"}],"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/src/model/modelObject.js":[function(e,r,t){"use strict";var h=e("./prop");r.exports=function(e){if(e||(e={}),!e.data)throw new Error("options.data is mandatory!");if(!e.model)throw new Error("options.model is mandatory!");if(!e.model.fields)throw new Error("options.model.fields is mandatory!");if(!e.model.idField)throw new Error("options.model.idField is mandatory!");if(void 0===e.data[e.model.idField])throw new Error("options.data has to have a property with same name as value of options.model.idField!");if(!e.model.proxy)throw new Error("options.model.proxy is mandatory!");if(e.model.belongsTo&&!Array.isArray(e.model.belongsTo))throw new Error("options.model.belongsTo has to be an array!");if(Array.isArray(e.model.belongsTo))for(var r=0;r<e.model.belongsTo.length;r+=1)if(!e.model.fields[e.model.belongsTo[r]])throw new Error("options.model.belongsTo has to contain field names!");var t=e.model,a=e.model.fields,n=e.model.idField,s=e.model.proxy,u=e.model.belongsTo||[],o=p(e.data),i=o.belongsToValues,d={data:o.data,model:t,save:function(o){var e=f();if(0===Object.keys(e).length)return o(null,d);var r=d.data[n];s.updateOneById(r,d.data,i,function(e,r){if(e)return o(e);var t=p(r);i=t.belongsToValues,d.data=t.data,c=JSON.parse(JSON.stringify(t.data)),o(null,d)})},patch:function(o){var e=f();if(0===Object.keys(e).length)return o(null,d);var r=d.data[n];s.patchOneById(r,e,i,function(e,r){if(e)return o(e);var t=p(r);i=t.belongsToValues,d.data=t.data,c=JSON.parse(JSON.stringify(t.data)),o(null,d)})},destroy:function(r){var e=d.data[n];s.destroyOneById(e,i,function(e){if(e)return r(e);r(null,d)})}};for(r=0;r<u.length;r+=1)if(!d.data[u[r]])throw new Error("data has to have properties for references given in belongsTo");var c=JSON.parse(JSON.stringify(d.data));function p(e){var r={},t={};for(var o in a){var n=a[o],s=e.hasOwnProperty(o)?e[o]:n.defaultValue;h(r,o,{value:s,beforeChange:l(o),afterChange:function(){}})}for(var i=0;i<u.length;i+=1)t[u[i]]=r[u[i]];return{data:r,belongsToValues:t}}function l(r){return function(e){!function(e){var r=a[e];if(!r)return;if(!r.validators);}(r)}}function f(){var e={};for(var r in d.data)d.data.hasOwnProperty(r)&&JSON.stringify(d.data[r])!==JSON.stringify(c[r])&&(e[r]=d.data[r]);return e}return d}},{"./prop":"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/src/model/prop.js"}],"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/src/model/prop.js":[function(e,r,t){"use strict";r.exports=function(e,r,t){var o=(t=t||{}).value,n=o,s=n;return Object.defineProperty(e,r,{enumerable:!0,configurable:!1,set:function(e){if(e===n)return;"function"==typeof t.beforeChange&&t.beforeChange({lastValue:s,value:n,newValue:e,initialValue:o});s=n,n=e,"function"==typeof t.afterChange&&t.afterChange({lastValue:s,value:n,newValue:e,initialValue:o})},get:function(){return n}}),e}},{}],"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/src/proxy/ajax.js":[function(a,u,e){(function(r){"use strict";var t,e=a("../reader/json"),o=a("./ajaxCore"),n=a("superagent");try{t=window||r}catch(e){t=r}var s=t.FormData;s||(s=a("form-data"));var i=a("./ajaxHelpers")({request:n,createReader:e});u.exports=o({ajaxHelpers:i,FormData:s})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../reader/json":"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/src/reader/json.js","./ajaxCore":"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/src/proxy/ajaxCore.js","./ajaxHelpers":"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/src/proxy/ajaxHelpers.js","form-data":"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/node_modules/form-data/lib/browser.js",superagent:"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/node_modules/superagent/lib/client.js"}],"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/src/proxy/ajaxCore.js":[function(e,r,t){"use strict";var h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};r.exports=function(e){if(!e)throw new Error("dependencies is mandatory!");if(!e.ajaxHelpers)throw new Error("dependencies.ajaxHelpers is mandatory!");if(!e.FormData)throw new Error("dependencies.FormData is mandatory!");var r=e.ajaxHelpers,p=r.createOperationConfig,l=r.dispatchAjax,t=r.prepareOperationsConfig,o=r.assert,f=e.FormData;return function(s){if(s||(s={}),!s.idProperty)throw new Error("config.idProperty is mandatory!");if(!s.operations)throw new Error("config.operations is mandatory!");if(s.fieldsToBeExcluded&&!Array.isArray(s.fieldsToBeExcluded))throw Error("config.fieldsToBeExcluded should be an array!");var e,n=s.idProperty,i=s.timeout||3e3,r=s.generateId||(e=0,function(){return e+=1}),a=s.queryMapping,u=s.fieldsToBeExcluded;function d(e,r){if(r)for(var t=0;t<r.length;t+=1)for(var o in e)r[t]===o&&delete e[o]}function c(e){o("function"==typeof e,"callback should be a function")}return t(s.operations),Object.freeze({idProperty:n,generateId:r,read:function(e,r,t){t||(t=r,r=void 0),c(t),"function"==typeof a&&(e=a(e));var o=p(s.operations.read,i);for(var n in e)o.queries[n]="object"===h(e[n])?JSON.stringify(e[n]):e[n];o.method=o.method.toLowerCase(),l(o,r,t)},createOne:function(e,r,t){t||(t=r,r=void 0),d(e,u),c(t);var o=p(s.operations.createOne,i,null,e);e.constructor===f&&(o.formData=!0),o.idProperty=n,l(o,r,t)},readOneById:function(e,r,t){t||(t=r,r=void 0),c(t);var o=p(s.operations.readOneById,i,e);l(o,r,t)},patchOneById:function(e,r,t,o){o||(o=t,t=void 0),d(r,u),c(o);var n=p(s.operations.patchOneById,i,e,r);l(n,t,o)},updateOneById:function(e,r,t,o){o||(o=t,t=void 0),d(r,u),c(o);var n=p(s.operations.updateOneById,i,e,r);l(n,t,o)},destroyOneById:function(e,r,t){t||(t=r,r=void 0),c(t);var o=p(s.operations.destroyOneById,i,e);l(o,r,t)}})}}},{}],"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/src/proxy/ajaxHelpers.js":[function(e,r,t){"use strict";var s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};r.exports=function(e){if(!e.request)throw new Error("dependencies.request is mandatory!");if(!e.createReader)throw new Error("dependencies.createReader is mandatory!");var f=e.request,o=e.createReader;function n(e,r){if(!e){if(r=r||"Assertion failed","undefined"!=typeof Error)throw new Error(r);throw r}}return{createOperationConfig:function(e,r,t,o){var n={};for(var s in e)n[s]=e[s];return n.data=o||{},n.id=t,n.timeout=n.timeout||r||3e3,n},dispatchAjax:function(i,a,u){"string"==typeof i.route&&(i.route=[i.route]),u||(u=a,a=void 0);var d=i.timeout||3e3,c=i.idProperty,p=0,l=i.route[p];!function o(n){if(a)for(var e in a){var r=new RegExp(":"+e,"g");l=l.replace(r,a[e])}var t=/:id/g;t.test(l)?l=l.replace(t,i.id):i.id&&(i.data[c]=i.id);try{var s=f[i.method](l).withCredentials().query(i.queries).accept(i.accept).timeout(d);!0!==i.formData&&s.type(i.type),s.send(i.data).end(function(e,r){if(e)return n+1<i.route.length?(p+=1,p%=i.route.length,l=i.route[p],o(n+1)):u(e);var t=i.reader.read(r.body)||{};u(t.err,t)})}catch(e){}}(0)},prepareOperationsConfig:function(e){for(var r in n("object"===(void 0===e?"undefined":s(e)),"config.operations should be a config object"),e){var t=e[r];n(t,r+" should be configured"),n(t.route,r+" route should be configured"),n(t.method,r+" method should be configured"),t.method=t.method.toLowerCase(),t.queries=t.queries||{},t.accept=t.accept||"application/json",t.type=t.type||"application/json",t.reader=t.reader?t.reader:{},"read"===r&&(t.reader.out="items"),t.reader=o(t.reader)}},assert:n}}},{}],"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/src/proxy/delayedMemory.js":[function(e,r,t){"use strict";var a=e("./memory");r.exports=function(e){var r=a(e),t=e.delay||1e3,o={};function n(e,r){o[e]=function(){var e=arguments;setTimeout(function(){r.apply(this,e)},t)}}for(var s in r){var i=r[s];"function"==typeof i&&n(s,i)}return Object.freeze(o)}},{"./memory":"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/src/proxy/memory.js"}],"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/src/proxy/localStorage.js":[function(e,r,t){"use strict";var o=e("./memory"),n=e("./localStorageCore"),s=function(){try{var e="adsfj";localStorage.setItem(e,e);var r=localStorage.getItem(e)===e;return localStorage.removeItem(e),r&&localStorage}catch(e){return!1}}();r.exports=n({createMemoryProxy:o,storage:s})},{"./localStorageCore":"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/src/proxy/localStorageCore.js","./memory":"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/src/proxy/memory.js"}],"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/src/proxy/localStorageCore.js":[function(e,r,t){"use strict";var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};r.exports=function(e){if(!e.createMemoryProxy)throw new Error("dependencies.createMemoryProxy is mandatory!");if("object"!==o(e.storage)&&"boolean"!=typeof e.storage)throw new Error("dependencies.storage is mandatory!");var s=e.createMemoryProxy,i=e.storage;return function(e){var r=s(e),t=e.name||"lsProxy";if(i){var o=JSON.parse(i.getItem(t));o&&o.items.forEach(function(e){r.createOne(e,function(){})})}function n(e){return function(){r[e].apply(this,arguments),r.read({},function(e,r){if(e)return console.log(e);i&&i.setItem(t,JSON.stringify(r))})}}return Object.freeze({idProperty:r.idProperty,generateId:r.generateId,read:r.read,createOne:n("createOne"),readOneById:r.readOneById,updateOneById:n("updateOneById"),patchOneById:n("patchOneById"),destroyOneById:n("destroyOneById")})}}},{}],"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/src/proxy/memory.js":[function(e,r,t){"use strict";var o=e("../errorMessages"),n=e("./memoryCore");r.exports=n({messages:o})},{"../errorMessages":"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/src/errorMessages.js","./memoryCore":"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/src/proxy/memoryCore.js"}],"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/src/proxy/memoryCore.js":[function(e,r,t){"use strict";var h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};r.exports=function(e){if(!e)throw new Error("dependencies is mandatory!");if(!e.messages)throw new Error("dependencies.messages is mandatory!");var f=e.messages;return function(e){if(e||(e={}),!e.idProperty)throw new Error("config.idProperty is mandatory!");if(!e.idType)throw new Error("config.idType is mandatory!");var r,i=e.idProperty,a=e.idType.toLowerCase(),o=e.generateId||(r=0,function e(){return-1===d(r+=1)?r:e()}),u=[];function d(e,r){for(var t=function(e,r){if(void 0===e||void 0===r)return console.log("Missing cast parameters");var t=r;switch(e){case"string":if("string"!=typeof t&&"string"!=typeof(t=t.toString()))throw new Error("Id "+r+" could not be parsed as "+e);break;case"number":if("number"!=typeof t&&(t=parseInt(t),isNaN(t)))throw new Error("Id "+r+" could not be parsed as "+e);break;default:return console.log("Unrecognized id type",e)}return t}(a,e),o=0;o<u.length;o+=1){var n=u[o];if(n[i]===t){if("object"===(void 0===r?"undefined":h(r)))for(var s in r){if(!n[s])return-1;if(n[s]!==r[s])return-1}return o}}return-1}function c(e){!function(e,r){if(!e){if(r=r||"Assertion failed","undefined"!=typeof Error)throw new Error(r);throw r}}("function"==typeof e,"callback should be a function")}function p(e,r){for(var t=r.split("."),o=0;o<t.length;o+=1){if(void 0===e[t[o]])return e;e=e[t[o]]}return e}function l(e){var r=e.split("/");if(1===r.length)return new RegExp(e,"i");r.splice(0,1);var t=r.splice(r.length-1,1),o=r.join("/");return new RegExp(o,t)}return Object.freeze({idProperty:i,generateId:o,read:function(e,t,r){r||(r=t,t=void 0),c(r),e||(e={});var s=e.find,i=e.sort,o=e.skip,n=e.limit,a=u;"object"===(void 0===t?"undefined":h(t))&&(a=a.filter(function(e){for(var r in t){if(!e[r])return!1;if(e[r]!==t[r])return!1}return!0})),s&&"object"===(void 0===s?"undefined":h(s))&&(a=a.filter(function(t){function e(e){return"string"==typeof e?l(e):e}function r(e,r){return e&&r.test(t)}for(var o in s){var n=s[o];if(t=p(t,o),"string"==typeof n&&(n=l(n)),n instanceof RegExp){if(!n.test(t))return!1}else{if(Array.isArray(n))return n.map(e).reduce(r,!0);if(n!==t)return!1}}return!0})),i&&"object"===(void 0===i?"undefined":h(i))&&(a=a.sort(function(e,r){for(var t in i){var o=p(e,t),n=p(r,t);if(1===i[t]){if(o<n)return-1;if(n<o)return 1}if(n<o)return-1;if(o<n)return 1}return 0})),("number"!=typeof o||o<0)&&(o=0),("number"!=typeof n||n<0)&&(n=u.length),r(null,{items:a.slice(o,o+n),count:a.length})},createOne:function(e,r,t){if(t||(t=r,r=void 0),c(t),void 0===e[i]&&(e[i]=o()),-1!==d(e[i]))return t(f.errorMessages.DUPLICATE_KEY);u.push(e),t(null,e)},readOneById:function(e,r,t){t||(t=r,r=void 0),c(t);var o=d(e,r);if(-1===o)return t(f.errorMessages.NOT_FOUND);t(null,u[o])},updateOneById:function(e,r,t,o){o||(o=t,t=void 0),c(o);var n=d(e,t);if(-1===n)return o(f.errorMessages.NOT_FOUND);r[i]=e,o(null,u[n]=r)},patchOneById:function(e,r,t,o){o||(o=t,t=void 0),c(o);var n=d(e,t);if(-1===n)return o(f.errorMessages.NOT_FOUND);for(var s in r)s!==i&&r.hasOwnProperty(s)&&(u[n][s]=r[s]);o(null,u[n])},destroyOneById:function(e,r,t){t||(t=r,r=void 0),c(t);var o=d(e,r);if(-1===o)return t(f.errorMessages.NOT_FOUND);t(null,u.splice(o,1)[0])}})}}},{}],"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/src/proxy/rest.js":[function(e,r,t){"use strict";var o=e("./ajax"),n=e("./restCore");r.exports=n({createAjaxProxy:o})},{"./ajax":"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/src/proxy/ajax.js","./restCore":"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/src/proxy/restCore.js"}],"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/src/proxy/restCore.js":[function(e,r,t){"use strict";r.exports=function(e){if(!e)throw new Error("dependencies is mandatory!");if(!e.createAjaxProxy)throw new Error("dependencies.createAjaxProxy is mandatory!");var c=e.createAjaxProxy;return function(e){if(!e)throw new Error("config is mandatory");if(!e.route)throw new Error("config.route is mandatory");if("string"!=typeof e.route&&e.route.constructor!==Array)throw new Error("config.route must be either string or array");var r=e.queries||{},t=r.read||{},o=r.createOne||{},n=r.readOneById||{},s=r.updateOneById||{},i=r.patchOneById||{},a=r.destroyOneById||{},u=e.route;function d(e){var r;r="string"==typeof e?[e]:e.slice(0);for(var t=0;t<r.length;t+=1)r[t]+="/:id";return r}return c({idProperty:e.idProperty,idType:e.idType,timeout:e.timeout,operations:{read:{route:u,method:"GET",reader:e.reader,queries:t},createOne:{route:u,method:"POST",queries:o},readOneById:{route:d(u),method:"GET",queries:n},updateOneById:{route:d(u),method:"PUT",queries:s},patchOneById:{route:d(u),method:"PATCH",queries:i},destroyOneById:{route:d(u),method:"DELETE",queries:a}}})}}},{}],"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/src/reader/json.js":[function(e,r,t){"use strict";r.exports=function(e){if(!e)throw"JSON READER: please provide a config object";if(e&&(e.success||e.message||e.count)&&!e.root&&!e.record)throw"JSON READER: If success, message, or count present, root or record must be specified!";var o=e.record,n=e.root,s=e.count,i=e.success,a=e.message,u=e.err||"err",d=e.out;return Object.freeze({read:function(e){if(null===e)return null;e=e||{};var r=n?e[n]:e,t={};return d?t[d]=o?r[o]:r:t=o?r[o]:r,s&&(t.count=e[s]),i&&(t.success=e[i]),a&&(t.message=e[a]),u&&e[u]&&(t.err=e[u]),t}})}},{}],"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/src/store/store.js":[function(e,r,t){"use strict";var u=e("../model/prop");r.exports=function(e){if(e||(e={}),!e.model)throw new Error("options.model is mandatory!");var r,t=e.model,o=t.proxy,n={model:t,proxy:o,items:[],count:0,load:i,add:function(e,r){t.create(e,r)}},s=(r=null,function(){r||(r=setTimeout(function(){r=null,i()},0))});function i(){var e={find:n.find,sort:n.sort,skip:n.skip,limit:n.limit,select:n.select};i.before(e),t.list(e,n.belongsToValues,function(e,r){if(e)return i.after(e);n.items.splice(0,n.items.length);for(var t=0;t<r.items.length;t+=1)n.items.push(r.items[t]);n.count=r.count,i.after(null,r)})}function a(t,o){function e(r){o.forEach(function(e){e.call(t,r)})}return e.add=function(e){"function"==typeof e&&o.push(e)},e.remove=function(e){var r=o.indexOf(e);-1<r&&o.splice(r,1)},e}return u(n,"find",{value:e.find||{},beforeChange:function(){},afterChange:s}),u(n,"sort",{value:e.sort||{id:-1},beforeChange:function(){},afterChange:s}),u(n,"skip",{value:e.skip||0,beforeChange:function(){},afterChange:s}),u(n,"limit",{value:e.limit||10,beforeChange:function(){},afterChange:s}),u(n,"belongsToValues",{value:e.belongsToValues||{},beforeChange:function(){},afterChange:s}),u(n,"select",{value:e.select||{},beforeChange:function(){},afterChange:s}),i.before=a(n,[]),i.after=a(n,[]),n}},{"../model/prop":"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/src/model/prop.js"}],"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/src/superData.js":[function(e,r,t){"use strict";var o=e("./proxy/memory"),n=e("./proxy/localStorage"),s=e("./proxy/rest"),i=e("./proxy/ajax"),a=e("./proxy/delayedMemory"),u=e("./store/store"),d=e("./model/model"),c=e("./reader/json");r.exports={proxy:{memory:o,localStorage:n,rest:s,ajax:i,delayedMemory:a},model:{model:d},store:{store:u},reader:{json:c}}},{"./model/model":"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/src/model/model.js","./proxy/ajax":"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/src/proxy/ajax.js","./proxy/delayedMemory":"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/src/proxy/delayedMemory.js","./proxy/localStorage":"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/src/proxy/localStorage.js","./proxy/memory":"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/src/proxy/memory.js","./proxy/rest":"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/src/proxy/rest.js","./reader/json":"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/src/reader/json.js","./store/store":"/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/src/store/store.js"}]},{},["/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/src/superData.js"])("/var/lib/jenkins/workspace/DMdesigner_superdata_master-FIZMR43IRA6LJDHEA4SITDEYPVZI5NQ5UJMVH6MHSS4DIJV56ZIQ/src/superData.js")});