loco-js-model
Advanced tools
Comparing version 0.3.2 to 0.3.3
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.LocoModel=e():t.LocoModel=e()}("undefined"!=typeof self?self:this,function(){return function(t){function e(n){if(r[n])return r[n].exports;var s=r[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,e),s.l=!0,s.exports}var r={};return e.m=t,e.c=r,e.d=function(t,r,n){e.o(t,r)||Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:n})},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=7)}([function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n,s=r(3),o=r.n(s);n=function(){function t(){this.obj=null,this.attr=null,this.val=null,this.opts=null}return t.sharedInstances={},t.instance=function(t,e,r){var n,s;return s=this.identity,null==this.sharedInstances[s]&&(this.sharedInstances[s]=new o.a[s]),n=this.sharedInstances[s],n.assignAttribs(t,e,r),n},t.prototype.assignAttribs=function(t,e,r){return this.obj=t,this.attr=e,this.val=this.obj[this.attr],this.opts=r},t}(),e.default=n},function(t,e,r){"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),o=function(){function t(){n(this,t),this.localeVar="en",this.protocolWithHostVar=null,this.scopeVar=null}return s(t,[{key:"locale",get:function(){return this.localeVar},set:function(t){return this.localeVar=t,this.localeVar}},{key:"protocolWithHost",get:function(){return this.protocolWithHostVar},set:function(t){return t?"/"===t[t.length-1]?(this.protocolWithHostVar=t.slice(0,t.length-1),this.protocolWithHostVar):(this.protocolWithHostVar=t,this.protocolWithHostVar):(this.protocolWithHostVar=null,this.protocolWithHostVar)}},{key:"scope",get:function(){return this.scopeVar},set:function(t){return this.scopeVar=t,this.scopeVar}}]),t}(),i=new o;e.default=i},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(10),s=function(t){return t&&t.__esModule?t:{default:t}}(n),o={en:s.default};e.default=o},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var s=r(9),o=n(s),i=r(11),a=n(i),u=r(12),l=n(u),c=r(13),h=n(c),p=r(14),f=n(p),d=r(4),_=n(d),g=r(15),m=n(g),v=r(16),y=n(v),b=r(17),M=n(b),E={Absence:o.default,Confirmation:a.default,Exclusion:l.default,Format:h.default,Inclusion:f.default,Length:_.default,Numericality:m.default,Presence:y.default,Size:M.default};e.default=E},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n,s=r(0),o=r(2),i=r.n(o),a=r(1),u=r.n(a),l=function(t,e){function r(){this.constructor=t}for(var n in e)c.call(e,n)&&(t[n]=e[n]);return r.prototype=e.prototype,t.prototype=new r,t.__super__=e.prototype,t},c={}.hasOwnProperty;n=function(t){function e(){e.__super__.constructor.call(this)}return l(e,t),e.identity="Length",e.prototype.validate=function(){var t;if(null!=this.val&&null!==(t=null!=this._range()[0]&&null!=this._range()[1]&&this._range()[0]===this._range()[1]&&this.val.length!==this._range()[0]?this._selectErrorMessage("wrong_length",this._range()[0]):null!=this._range()[0]&&this.val.length<this._range()[0]?this._selectErrorMessage("too_short",this._range()[0]):null!=this._range()[1]&&this.val.length>this._range()[1]?this._selectErrorMessage("too_long",this._range()[1]):null))return this.obj.addErrorMessage(t,{for:this.attr})},e.prototype._range=function(){var t,e;return t=this.opts.minimum||this.opts.is||null!=this.opts.within&&this.opts.within[0]||null,e=this.opts.maximum||this.opts.is||null!=this.opts.within&&this.opts.within[1]||null,[t,e]},e.prototype._selectErrorMessage=function(t,e){var r,n,s,o,a;if(1===e)return i.a[u.a.locale].errors.messages[t].one;for(s=null,o=["few","many"],r=0,n=o.length;r<n;r++)if(a=o[r],this._checkVariant(a,e)){s=i.a[u.a.locale].errors.messages[t][a];break}return null==s&&(s=i.a[u.a.locale].errors.messages[t].other),null!=this.opts.message&&(s=this.opts.message),/%{count}/.exec(s)&&(s=s.replace("%{count}",e)),s},e.prototype._checkVariant=function(t,e){if(null!=i.a[u.a.locale].variants[t])return i.a[u.a.locale].variants[t](e)},e}(s.default),e.default=n},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n;n=function(){function t(){}return t.imap={},t.clear=function(){return this.imap={}},t.add=function(t){var e;return e=t.getIdentity(),null==this.imap[e]&&(this.imap[e]={}),null==this.imap[e][t.id]&&(this.imap[e][t.id]=[]),this.imap[e][t.id][0]=t},t.connect=function(t,e){var r;return null==e&&(e={}),r=e.with,this.add(r),this.imap[r.getIdentity()][r.id].push(t)},t.addCollection=function(t,e){if(null==e&&(e={}),null==this.imap[t]&&(this.imap[t]={}),null==this.imap[t].collection&&(this.imap[t].collection=[]),-1===this.imap[t].collection.indexOf(e.to))return this.imap[t].collection.push(e.to)},t.all=function(t){var e,r,n,s;if(null==this.imap[t])return null;e=[],s=this.imap[t];for(r in s)n=s[r],"collection"!==r&&e.push(n[0]);return e},t.find=function(t,e){return this.imap[t]&&this.imap[t][e]?this.imap[t][e][0]:null},t.findConnected=function(t,e){var r;return this.imap[t]&&this.imap[t][e]&&this.imap[t][e].length>1?(r=this.imap[t][e],r.slice(1,+(r.length-1)+1||9e9)):[]},t}(),e.default=n},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n={};e.default=n},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0}),e.Validators=e.Models=e.IdentityMap=e.I18n=e.Config=e.Base=void 0;var s=r(8),o=n(s),i=r(5),a=n(i),u=r(0),l=n(u),c=r(3),h=n(c),p=r(1),f=n(p),d=r(2),_=n(d),g=r(6),m=n(g);h.default.Base=l.default,m.default.Base=o.default,e.Base=o.default,e.Config=f.default,e.I18n=_.default,e.IdentityMap=a.default,e.Models=m.default,e.Validators=h.default},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n,s=r(3),o=r.n(s),i=r(1),a=r.n(i),u=r(5),l=r(6),c=r.n(l),h=r(18);r.n(h);n=function(){function t(t){null==t&&(t={}),this.id=null,this.errors=null,this.resource=t.resource,null!=this.constructor.attributes&&this.__initAttributes(),null!=t&&this.__assignAttributes(t)}return t.getIdentity=function(){if(null!=this.identity)return this.identity;throw"Specify Model's @identity!"},t.getRemoteName=function(){return null!=this.remoteName?this.remoteName:this.getIdentity()},t.all=function(t){return null==t&&(t={}),this.get("all",t)},t.get=function(t,e){return null==e&&(e={}),this.__send("GET",t,e)},t.post=function(t,e){return null==e&&(e={}),this.__send("POST",t,e)},t.put=function(t,e){return null==e&&(e={}),this.__send("PUT",t,e)},t.patch=function(t,e){return null==e&&(e={}),this.__send("PATCH",t,e)},t.delete=function(t,e){return null==e&&(e={}),this.__send("DELETE",t,e)},t.find=function(t){var e,r,n;return n={},"object"==typeof t?(n=t,e=t.id,delete n.id):e=t,r=Object(h.sendReq)("GET",this.__getResourcesUrl(n)+"/"+e,n),new Promise(function(e){return function(n,s){return r.onerror=function(t){return s(t)},r.onload=function(r){var s;return s=JSON.parse(r.target.response),n(e.__initFromJSON(s,t.resource))}}}(this))},t.getAttribRemoteName=function(t){return null==this.attributes?null:null==this.attributes[t]?null:null==this.attributes[t].remoteName?t:this.attributes[t].remoteName},t.getResourcesUrlParams=function(t){var e,r,n,s;for(s=this.__getResourcesUrl({resource:t.resource}),n=/:(\w+)\/?/,r=[];e=n.exec(s);)r.push(e[1]),s=s.replace(e[0],e[1]);return r},t.__getResourcesUrl=function(t){var e,r;return r=null==this.resources?"/"+this.getRemoteName().toLowerCase()+"s":t.resource?this.resources[t.resource].url:null!=a.a.scope&&null!=this.resources[a.a.scope]?this.resources[a.a.scope].url:this.resources.url,null!=a.a.protocolWithHost&&(r=""+a.a.protocolWithHost+r),null==(e=/:(\w+)\/?/.exec(r))?r:(null!=t[e[1]]?(r=r.replace(":"+e[1],t[e[1]]),delete t[e[1]]):null!=t.obj&&null!=t.obj[e[1]]&&(r=r.replace(":"+e[1],t.obj[e[1]])),r)},t.__initSubclass=function(t){var e,r;return null==t&&(t={}),r=this.getIdentity().split("."),1===r.length?(e=c.a[r[0]],null==e?new this(t):new e(t)):new(e=c.a[r[0]][r[1]])(t)},t.__page=function(t,e,r){var n,s;return s=e.url,e.params[e.pageParam]=t,n=Object(h.sendReq)(e.method,s,e.params),new Promise(function(t){return function(s,o){return n.onerror=function(t){return o(t)},n.onload=function(n){var o,i,a,u,l,c,h,p,f,d;if(o=JSON.parse(n.target.response),o.constructor===Array)for(i=0,l=o.length;i<l;i++)p=o[i],h=t.__initFromJSON(p,e.resource),r.push(h);else if(null!=o.resources){for(r.constructor===Array&&(r={resources:[],count:0}),f=o.resources,a=0,c=f.length;a<c;a++)p=f[a],h=t.__initFromJSON(p,e.resource),r.resources.push(h);r.count=o.count}else for(u in o)d=o[u],r[u]=d;return s(r)}}}(this))},t.__paginate=function(t){var e;return e={method:t.method,url:t.url,params:t.params,pageParam:t.pageParam,resource:t.resource},this.__page(t.pageNum||1,e,[]).then(function(r){return function(n){var s,o,i,a,u,l;if(l=n.count||t.total,a=Promise.resolve(n),null!=t.pageNum)return a;if(l<=t.perPage)return a;if(i=parseInt(l/t.perPage),i!==l/t.perPage&&(i+=1),1===i)return a;for(s=o=2,u=i;2<=u?o<=u:o>=u;s=2<=u?++o:--o)(function(t){return a=a.then(function(s){return r.__page(t,e,n)})})(s);return a}}(this))},t.__getPaginationParam=function(t){var e,r,n,s,o,i;return e="page",null!=t&&null!=this.resources&&this.resources[t]?(null!=(r=this.resources[t].paginate)?r.param:void 0)||e:null!=a.a.scope&&null!=this.resources&&null!=this.resources[a.a.scope]?(null!=(n=this.resources[a.a.scope])&&null!=(s=n.paginate)?s.param:void 0)||e:null!=(null!=(o=this.resources)&&null!=(i=o.paginate)?i.param:void 0)?this.resources.paginate.param:e},t.__getPaginationPer=function(t){var e,r,n,s,o;return null!=t&&null!=this.resources&&this.resources[t]?null!=(e=this.resources[t].paginate)?e.per:void 0:null!=a.a.scope&&null!=this.resources&&null!=this.resources[a.a.scope]?null!=(r=this.resources[a.a.scope])&&null!=(n=r.paginate)?n.per:void 0:null!=(null!=(s=this.resources)&&null!=(o=s.paginate)?o.per:void 0)?this.resources.paginate.per:null},t.__send=function(t,e,r){var n,s;return s=this.__getResourcesUrl(r),"all"!==e&&(s=s+"/"+e),n={method:t,url:s,params:r,resource:r.resource,perPage:this.__getPaginationPer(r.resource),pageNum:r.page,pageParam:this.__getPaginationParam(r.resource),total:r.total||r.count},this.__paginate(n)},t.__initFromJSON=function(t,e){var r;return r=this.__initSubclass(t),r.resource=e,u.default.add(r),r},t.prototype.setResource=function(t){return this.resource=t},t.prototype.getIdentity=function(){return this.constructor.getIdentity()},t.prototype.getAttrRemoteName=function(t){return null==this.constructor.attributes?null:null==this.constructor.attributes[t]?null:this.constructor.attributes[t].remoteName||t},t.prototype.getAttrName=function(t){var e,r,n;if(null==this.constructor.attributes)return t;if(null!=this.constructor.attributes[t])return t;n=this.constructor.attributes;for(r in n)if(e=n[r],e.remoteName===t)return r;return t},t.prototype.getAttrType=function(t){return null==this.constructor.attributes?null:null==this.constructor.attributes[t]?null:this.constructor.attributes[t].type},t.prototype.assignAttr=function(t,e){var r;if(r=this.getAttrType(t),null==e)return void(this[t]=null);switch(r){case"Date":e=new Date(Date.parse(e));break;case"Integer":case"Int":e=parseInt(e);break;case"Float":e=parseFloat(e);break;case"Boolean":case"Bool":e="boolean"==typeof e?e:Boolean(parseInt(e));break;case"Number":e=Number(e);break;case"String":e=String(e)}return this[t]=e},t.prototype.attributes=function(){var t,e,r;if(t={id:this.id},null==this.constructor.attributes)return t;r=this.constructor.attributes;for(e in r)r[e],t[e]=this[e];return t},t.prototype.isValid=function(){var t,e,r,n,s,i,a,u,l,c,h,p;if(null==this.constructor.attributes)return!0;this.errors=null,a=this.constructor.attributes;for(s in a)if(t=a[s],null!=t.validations){u=t.validations;for(c in u)h=u[c],null!=this.id&&"create"===h.on||null==this.id&&"update"===h.on||(null==h.if||h.if(this))&&(p=c.charAt(0).toUpperCase()+c.slice(1),null!=o.a[p]?(i=this.__processedValidationSettings(h),o.a[p].instance(this,s,i).validate()):console.warn('"'+p+'" validator is not implemented!'))}if(null!=this.constructor.validate)for(l=this.constructor.validate,e=0,r=l.length;e<r;e++)n=l[e],this[n]();return null==this.errors},t.prototype.isInvalid=function(){return!this.isValid()},t.prototype.isEmpty=function(){var t,e;e=this.attributes();for(t in e)if(e[t],null!==this[t])return!1;return!0},t.prototype.addErrorMessage=function(t,e){return null==e&&(e={}),null==this.errors&&(this.errors={}),null==this.errors[e.for]&&(this.errors[e.for]=[]),this.errors[e.for].push(t)},t.prototype.save=function(){var t,e;return t=null!=this.id?"PUT":"POST",e=Object(h.sendReq)(t,this.__getResourceUrl(),this.serialize()),new Promise(function(t){return function(r,n){return e.onerror=function(t){return n(t)},e.onload=function(e){var n;return n=JSON.parse(e.target.response),n.success?void r(n):(null!=n.errors&&t.__assignRemoteErrorMessages(n.errors),r(n))}}}(this))},t.prototype.updateAttribute=function(t){var e;return e=Object(h.sendReq)("PUT",this.__getResourceUrl(),this.serialize(t)),new Promise(function(t){return function(r,n){return e.onerror=function(t){return n(t)},e.onload=function(e){var s;return e.target.status>=200&&e.target.status<400?(s=JSON.parse(e.target.response),s.success?void r(s):(null!=s.errors&&t.__assignRemoteErrorMessages(s.errors),r(s))):e.target.status>=500?n(e):void 0}}}(this))},t.prototype.serialize=function(t){var e,r,n,s;if(null==t&&(t=null),null==this.constructor.attributes)return{};r={},n=this.constructor.getRemoteName().toLowerCase(),r[n]={},e={},null!=t?e[t]=null:e=this.constructor.attributes;for(t in e)e[t],s=this.getAttrRemoteName(t),r[n][s]=this[t];return r},t.prototype.reload=function(){var t,e,r,n,s;for(t={id:this.id,resource:this.resource},s=this.constructor.getResourcesUrlParams({resource:this.resource}),e=0,r=s.length;e<r;e++)n=s[e],t[n]=this[n];return this.constructor.find(t)},t.prototype.changes=function(){var t,e,r,n,s;n={},t=u.default.find(this.getIdentity(),this.id),r=this.attributes();for(e in r)if((s=r[e])!==t[e]){if(null!=s&&s.constructor===Date&&t[e]-s==0)continue;s!==t[e]&&(n[e]={is:t[e],was:s})}return n},t.prototype.applyChanges=function(){var t,e,r,n;e=this.changes(),r=[];for(t in e)n=e[t],r.push(this[t]=n.is);return r},t.prototype.toKey=function(){return this.getIdentity().toLowerCase()+"_"+this.id},t.prototype.get=function(t,e){return null==e&&(e={}),this.__send("GET",t,e)},t.prototype.post=function(t,e){return null==e&&(e={}),this.__send("POST",t,e)},t.prototype.put=function(t,e){return null==e&&(e={}),this.__send("PUT",t,e)},t.prototype.patch=function(t,e){return null==e&&(e={}),this.__send("PATCH",t,e)},t.prototype.delete=function(t,e){return null==e&&(e={}),this.__send("DELETE",t,e)},t.prototype.__send=function(t,e,r){var n,s;return s=this.__getResourceUrl(),null!=e&&(s=s+"/"+e),n=Object(h.sendReq)(t,s,r),new Promise(function(t,e){return n.onerror=function(t){return e(t)},n.onload=function(n){return n.target.status>=200&&n.target.status<400?(r=JSON.parse(n.target.response),t(r)):n.target.status>=500?e(n):void 0}})},t.prototype.__assignAttributes=function(t){var e,r,n,s;n=[];for(r in t)s=t[r],e=this.getAttrName(r),n.push(this.assignAttr(e,s));return n},t.prototype.__initAttributes=function(){var t,e,r;e=this.constructor.attributes,r=[];for(t in e)e[t],r.push(this[t]=null);return r},t.prototype.__assignRemoteErrorMessages=function(t){var e,r,n,s,o;o=[];for(s in t)n=t[s],e=this.getAttrName(s),o.push(function(){var t,s,o;for(o=[],t=0,s=n.length;t<s;t++)r=n[t],o.push(this.addErrorMessage(r,{for:e}));return o}.call(this));return o},t.prototype.__getResourceUrl=function(){var t;return t=this.constructor.__getResourcesUrl({resource:this.resource,obj:this}),null==this.id?t:t+"/"+this.id},t.prototype.__processedValidationSettings=function(t){var e,r,n;n={};for(e in t)r=t[e],n[e]="function"==typeof r?r(this):r;return n},t}(),e.default=n},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n,s=r(0),o=r(2),i=r.n(o),a=r(1),u=r.n(a),l=function(t,e){function r(){this.constructor=t}for(var n in e)c.call(e,n)&&(t[n]=e[n]);return r.prototype=e.prototype,t.prototype=new r,t.__super__=e.prototype,t},c={}.hasOwnProperty;n=function(t){function e(){e.__super__.constructor.call(this)}return l(e,t),e.identity="Absence",e.prototype.validate=function(){switch(typeof this.val){case"string":if(null!=this.val&&0===this.val.length)return;break;default:if(null==this.val)return}return this._addErrorMessage()},e.prototype._addErrorMessage=function(){var t;return t=null!=this.opts.message?this.opts.message:i.a[u.a.locale].errors.messages.present,this.obj.addErrorMessage(t,{for:this.attr})},e}(s.default),e.default=n},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n;n={variants:{},models:{},attributes:{},errors:{messages:{accepted:"must be accepted",blank:"can't be blank",confirmation:"doesn't match %{attribute}",empty:"can't be empty",equal_to:"must be equal to %{count}",even:"must be even",exclusion:"is reserved",greater_than:"must be greater than %{count}",greater_than_or_equal_to:"must be greater than or equal to %{count}",inclusion:"is not included in the list",invalid:"is invalid",less_than:"must be less than %{count}",less_than_or_equal_to:"must be less than or equal to %{count}",not_a_number:"is not a number",not_an_integer:"must be an integer",odd:"must be odd",present:"must be blank",too_long:{one:"is too long (maximum is 1 character)",other:"is too long (maximum is %{count} characters)"},too_short:{one:"is too short (minimum is 1 character)",other:"is too short (minimum is %{count} characters)"},wrong_length:{one:"is the wrong length (should be 1 character)",other:"is the wrong length (should be %{count} characters)"},other_than:"must be other than %{count}"}}},e.default=n},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n,s=r(0),o=r(2),i=r.n(o),a=r(1),u=r.n(a),l=function(t,e){function r(){this.constructor=t}for(var n in e)c.call(e,n)&&(t[n]=e[n]);return r.prototype=e.prototype,t.prototype=new r,t.__super__=e.prototype,t},c={}.hasOwnProperty;n=function(t){function e(){e.__super__.constructor.call(this)}return l(e,t),e.identity="Confirmation",e.prototype.validate=function(){var t;if(t=this.obj[this._properAttr()],null==this.val||null==t||this.val!==t)return this._addErrorMessage()},e.prototype._addErrorMessage=function(){var t,e,r,n;return r=this.attr.charAt(0).toUpperCase()+this.attr.slice(1),e=i.a[u.a.locale].attributes[this.obj.getIdentity()],t=e&&e[this.attr]||r,n=null!=this.opts.message?this.opts.message:i.a[u.a.locale].errors.messages.confirmation,n=n.replace("%{attribute}",t),this.obj.addErrorMessage(n,{for:this._properAttr()})},e.prototype._properAttr=function(){return this.attr+"Confirmation"},e}(s.default),e.default=n},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n,s=r(0),o=r(2),i=r.n(o),a=r(1),u=r.n(a),l=function(t,e){function r(){this.constructor=t}for(var n in e)c.call(e,n)&&(t[n]=e[n]);return r.prototype=e.prototype,t.prototype=new r,t.__super__=e.prototype,t},c={}.hasOwnProperty;n=function(t){function e(){e.__super__.constructor.call(this)}return l(e,t),e.identity="Exclusion",e.prototype.validate=function(){var t;if(t=this.opts.in||this.opts.within||[],-1!==t.indexOf(this.val))return this._addErrorMessage()},e.prototype._addErrorMessage=function(){var t;return t=null!=this.opts.message?this.opts.message:i.a[u.a.locale].errors.messages.exclusion,this.obj.addErrorMessage(t,{for:this.attr})},e}(s.default),e.default=n},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n,s=r(0),o=r(2),i=r.n(o),a=r(1),u=r.n(a),l=function(t,e){function r(){this.constructor=t}for(var n in e)c.call(e,n)&&(t[n]=e[n]);return r.prototype=e.prototype,t.prototype=new r,t.__super__=e.prototype,t},c={}.hasOwnProperty;n=function(t){function e(){e.__super__.constructor.call(this)}return l(e,t),e.identity="Format",e.prototype.validate=function(){if(null==this.opts.with.exec(this.val))return this._addErrorMessage()},e.prototype._addErrorMessage=function(){var t;return t=null!=this.opts.message?this.opts.message:i.a[u.a.locale].errors.messages.invalid,this.obj.addErrorMessage(t,{for:this.attr})},e}(s.default),e.default=n},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n,s=r(0),o=r(2),i=r.n(o),a=r(1),u=r.n(a),l=function(t,e){function r(){this.constructor=t}for(var n in e)c.call(e,n)&&(t[n]=e[n]);return r.prototype=e.prototype,t.prototype=new r,t.__super__=e.prototype,t},c={}.hasOwnProperty;n=function(t){function e(){e.__super__.constructor.call(this)}return l(e,t),e.identity="Inclusion",e.prototype.validate=function(){var t;if(t=this.opts.in||this.opts.within||[],-1===t.indexOf(this.val))return this._addErrorMessage()},e.prototype._addErrorMessage=function(){var t;return t=null!=this.opts.message?this.opts.message:i.a[u.a.locale].errors.messages.inclusion,this.obj.addErrorMessage(t,{for:this.attr})},e}(s.default),e.default=n},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n,s=r(0),o=r(2),i=r.n(o),a=r(1),u=r.n(a),l=function(t,e){function r(){this.constructor=t}for(var n in e)c.call(e,n)&&(t[n]=e[n]);return r.prototype=e.prototype,t.prototype=new r,t.__super__=e.prototype,t},c={}.hasOwnProperty;n=function(t){function e(){e.__super__.constructor.call(this)}return l(e,t),e.identity="Numericality",e.prototype.validate=function(){return isNaN(this.val)?this._addNaNErrorMessage():null!=this.opts.only_integer&&Number(this.val)!==parseInt(this.val)?this._addIntErrorMessage():null!=this.opts.greater_than&&Number(this.val)<=this.opts.greater_than?this._addGreatherThanErrorMessage():null!=this.opts.greater_than_or_equal_to&&Number(this.val)<this.opts.greater_than_or_equal_to?this._addGreatherThanOrEqualToErrorMessage():null!=this.opts.equal_to&&Number(this.val)!==this.opts.equal_to?this._addEqualToErrorMessage():null!=this.opts.less_than&&Number(this.val)>=this.opts.less_than?this._addLessThanErrorMessage():null!=this.opts.less_than_or_equal_to&&Number(this.val)>this.opts.less_than_or_equal_to?this._addLessThanOrEqualToErrorMessage():null!=this.opts.other_than&&Number(this.val)===this.opts.other_than?this._addOtherThanErrorMessage():null!=this.opts.odd&&Number(this.val)%2!=1?this._addOddErrorMessage():null!=this.opts.even&&Number(this.val)%2!=0?this._addEvenErrorMessage():void 0},e.prototype._addNaNErrorMessage=function(){var t;return t=null!=this.opts.message?this.opts.message:i.a[u.a.locale].errors.messages.not_a_number,this.obj.addErrorMessage(t,{for:this.attr})},e.prototype._addIntErrorMessage=function(){var t;return t=i.a[u.a.locale].errors.messages.not_an_integer,this.obj.addErrorMessage(t,{for:this.attr})},e.prototype._addGreatherThanErrorMessage=function(){var t;return t=i.a[u.a.locale].errors.messages.greater_than,t=t.replace("%{count}",this.opts.greater_than),this.obj.addErrorMessage(t,{for:this.attr})},e.prototype._addGreatherThanOrEqualToErrorMessage=function(){var t;return t=i.a[u.a.locale].errors.messages.greater_than_or_equal_to,t=t.replace("%{count}",this.opts.greater_than_or_equal_to),this.obj.addErrorMessage(t,{for:this.attr})},e.prototype._addEqualToErrorMessage=function(){var t;return t=i.a[u.a.locale].errors.messages.equal_to,t=t.replace("%{count}",this.opts.equal_to),this.obj.addErrorMessage(t,{for:this.attr})},e.prototype._addLessThanErrorMessage=function(){var t;return t=i.a[u.a.locale].errors.messages.less_than,t=t.replace("%{count}",this.opts.less_than),this.obj.addErrorMessage(t,{for:this.attr})},e.prototype._addLessThanOrEqualToErrorMessage=function(){var t;return t=i.a[u.a.locale].errors.messages.less_than_or_equal_to,t=t.replace("%{count}",this.opts.less_than_or_equal_to),this.obj.addErrorMessage(t,{for:this.attr})},e.prototype._addOtherThanErrorMessage=function(){var t;return t=i.a[u.a.locale].errors.messages.other_than,t=t.replace("%{count}",this.opts.other_than),this.obj.addErrorMessage(t,{for:this.attr})},e.prototype._addOddErrorMessage=function(){var t;return t=i.a[u.a.locale].errors.messages.odd,this.obj.addErrorMessage(t,{for:this.attr})},e.prototype._addEvenErrorMessage=function(){var t;return t=i.a[u.a.locale].errors.messages.even,this.obj.addErrorMessage(t,{for:this.attr})},e}(s.default),e.default=n},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n,s=r(0),o=r(2),i=r.n(o),a=r(1),u=r.n(a),l=function(t,e){function r(){this.constructor=t}for(var n in e)c.call(e,n)&&(t[n]=e[n]);return r.prototype=e.prototype,t.prototype=new r,t.__super__=e.prototype,t},c={}.hasOwnProperty;n=function(t){function e(){e.__super__.constructor.call(this)}return l(e,t),e.identity="Presence",e.prototype.validate=function(){switch(typeof this.val){case"string":if(null!=this.val&&this.val.length>0)return;break;default:if(null!=this.val)return}return this._addErrorMessage()},e.prototype._addErrorMessage=function(){var t;return t=null!=this.opts.message?this.opts.message:i.a[u.a.locale].errors.messages.blank,this.obj.addErrorMessage(t,{for:this.attr})},e}(s.default),e.default=n},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n,s=r(0),o=r(4),i=function(t,e){function r(){this.constructor=t}for(var n in e)a.call(e,n)&&(t[n]=e[n]);return r.prototype=e.prototype,t.prototype=new r,t.__super__=e.prototype,t},a={}.hasOwnProperty;n=function(t){function e(){e.__super__.constructor.call(this)}return i(e,t),e.identity="Size",e.prototype.validate=function(){return o.default.instance(this.obj,this.attr,this.opts).validate()},e}(s.default),e.default=n},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.sendReq=void 0;var n=r(19),s=function(t){var e={};if(!t)return e;var r=["resource","total","count"];return Object.keys(t).forEach(function(n){-1===r.indexOf(n)&&(e[n]=t[n])}),e},o=e.sendReq=function(t,e,r){var o=s(r),i="GET"===t?e+"?"+(0,n.toURIParams)(o):e,a=document.querySelector("meta[name='csrf-token']"),u=new XMLHttpRequest;return u.open(t,i),u.setRequestHeader("Accept","application/json"),u.setRequestHeader("Content-Type","application/json"),a&&u.setRequestHeader("X-CSRF-Token",a.content),u.send(JSON.stringify(o)),u};e.default=o},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=e.toURIParams=function(t){var e="";return Object.keys(t).forEach(function(r){""!==e&&(e+="&"),e=""+e+r+"="+encodeURIComponent(t[r])}),e};e.default=n}])}); | ||
!function(t,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.LocoModel=r():t.LocoModel=r()}("undefined"!=typeof self?self:this,function(){return function(t){function r(n){if(e[n])return e[n].exports;var s=e[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,r),s.l=!0,s.exports}var e={};return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},r.p="",r(r.s=7)}([function(t,r,e){"use strict";var n,s=e(3);n=function(){function t(){this.obj=null,this.attr=null,this.val=null,this.opts=null}return t.sharedInstances={},t.instance=function(t,r,e){var n,o;return o=this.identity,null==this.sharedInstances[o]&&(this.sharedInstances[o]=new s.a[o]),n=this.sharedInstances[o],n.assignAttribs(t,r,e),n},t.prototype.assignAttribs=function(t,r,e){return this.obj=t,this.attr=r,this.val=this.obj[this.attr],this.opts=e},t}(),r.a=n},function(t,r,e){"use strict";function n(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}var s=function(){function t(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(r,e,n){return e&&t(r.prototype,e),n&&t(r,n),r}}(),o=function(){function t(){n(this,t),this.localeVar="en",this.protocolWithHostVar=null,this.scopeVar=null}return s(t,[{key:"locale",get:function(){return this.localeVar},set:function(t){return this.localeVar=t,this.localeVar}},{key:"protocolWithHost",get:function(){return this.protocolWithHostVar},set:function(t){return t?"/"===t[t.length-1]?(this.protocolWithHostVar=t.slice(0,t.length-1),this.protocolWithHostVar):(this.protocolWithHostVar=t,this.protocolWithHostVar):(this.protocolWithHostVar=null,this.protocolWithHostVar)}},{key:"scope",get:function(){return this.scopeVar},set:function(t){return this.scopeVar=t,this.scopeVar}}]),t}(),i=new o;r.a=i},function(t,r,e){"use strict";var n=e(10),s={en:n.a};r.a=s},function(t,r,e){"use strict";var n=e(9),s=e(11),o=e(12),i=e(13),a=e(14),u=e(4),l=e(15),c=e(16),h=e(17),p={Absence:n.a,Confirmation:s.a,Exclusion:o.a,Format:i.a,Inclusion:a.a,Length:u.a,Numericality:l.a,Presence:c.a,Size:h.a};r.a=p},function(t,r,e){"use strict";var n,s=e(0),o=e(2),i=e(1),a=function(t,r){function e(){this.constructor=t}for(var n in r)u.call(r,n)&&(t[n]=r[n]);return e.prototype=r.prototype,t.prototype=new e,t.__super__=r.prototype,t},u={}.hasOwnProperty;n=function(t){function r(){r.__super__.constructor.call(this)}return a(r,t),r.identity="Length",r.prototype.validate=function(){var t;if(null!=this.val&&null!==(t=null!=this._range()[0]&&null!=this._range()[1]&&this._range()[0]===this._range()[1]&&this.val.length!==this._range()[0]?this._selectErrorMessage("wrong_length",this._range()[0]):null!=this._range()[0]&&this.val.length<this._range()[0]?this._selectErrorMessage("too_short",this._range()[0]):null!=this._range()[1]&&this.val.length>this._range()[1]?this._selectErrorMessage("too_long",this._range()[1]):null))return this.obj.addErrorMessage(t,{for:this.attr})},r.prototype._range=function(){var t,r;return t=this.opts.minimum||this.opts.is||null!=this.opts.within&&this.opts.within[0]||null,r=this.opts.maximum||this.opts.is||null!=this.opts.within&&this.opts.within[1]||null,[t,r]},r.prototype._selectErrorMessage=function(t,r){var e,n,s,a,u;if(1===r)return o.a[i.a.locale].errors.messages[t].one;for(s=null,a=["few","many"],e=0,n=a.length;e<n;e++)if(u=a[e],this._checkVariant(u,r)){s=o.a[i.a.locale].errors.messages[t][u];break}return null==s&&(s=o.a[i.a.locale].errors.messages[t].other),null!=this.opts.message&&(s=this.opts.message),/%{count}/.exec(s)&&(s=s.replace("%{count}",r)),s},r.prototype._checkVariant=function(t,r){if(null!=o.a[i.a.locale].variants[t])return o.a[i.a.locale].variants[t](r)},r}(s.a),r.a=n},function(t,r,e){"use strict";var n;n=function(){function t(){}return t.imap={},t.clear=function(){return this.imap={}},t.add=function(t){var r;return r=t.getIdentity(),null==this.imap[r]&&(this.imap[r]={}),null==this.imap[r][t.id]&&(this.imap[r][t.id]=[]),this.imap[r][t.id][0]=t},t.connect=function(t,r){var e;return null==r&&(r={}),e=r.with,this.add(e),this.imap[e.getIdentity()][e.id].push(t)},t.addCollection=function(t,r){if(null==r&&(r={}),null==this.imap[t]&&(this.imap[t]={}),null==this.imap[t].collection&&(this.imap[t].collection=[]),-1===this.imap[t].collection.indexOf(r.to))return this.imap[t].collection.push(r.to)},t.all=function(t){var r,e,n,s;if(null==this.imap[t])return null;r=[],s=this.imap[t];for(e in s)n=s[e],"collection"!==e&&r.push(n[0]);return r},t.find=function(t,r){return this.imap[t]&&this.imap[t][r]?this.imap[t][r][0]:null},t.findConnected=function(t,r){var e;return this.imap[t]&&this.imap[t][r]&&this.imap[t][r].length>1?(e=this.imap[t][r],e.slice(1,+(e.length-1)+1||9e9)):[]},t}(),r.a=n},function(t,r,e){"use strict";var n={};r.a=n},function(t,r,e){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e(8),s=e(5),o=e(0),i=e(3),a=e(1),u=e(2),l=e(6);e.d(r,"Base",function(){return n.a}),e.d(r,"Config",function(){return a.a}),e.d(r,"I18n",function(){return u.a}),e.d(r,"IdentityMap",function(){return s.a}),e.d(r,"Models",function(){return l.a}),e.d(r,"Validators",function(){return i.a}),i.a.Base=o.a,l.a.Base=n.a},function(t,r,e){"use strict";var n,s=e(3),o=e(1),i=e(5),a=e(6),u=e(18);n=function(){function t(t){null==t&&(t={}),this.id=null,this.errors=null,this.resource=t.resource,null!=this.constructor.attributes&&this.__initAttributes(),null!=t&&this.__assignAttributes(t)}return t.getIdentity=function(){if(null!=this.identity)return this.identity;throw"Specify Model's @identity!"},t.getRemoteName=function(){return null!=this.remoteName?this.remoteName:this.getIdentity()},t.all=function(t){return null==t&&(t={}),this.get("all",t)},t.get=function(t,r){return null==r&&(r={}),this.__send("GET",t,r)},t.post=function(t,r){return null==r&&(r={}),this.__send("POST",t,r)},t.put=function(t,r){return null==r&&(r={}),this.__send("PUT",t,r)},t.patch=function(t,r){return null==r&&(r={}),this.__send("PATCH",t,r)},t.delete=function(t,r){return null==r&&(r={}),this.__send("DELETE",t,r)},t.find=function(t){var r,e,n;return n={},"object"==typeof t?(n=t,r=t.id,delete n.id):r=t,e=Object(u.a)("GET",this.__getResourcesUrl(n)+"/"+r,n),new Promise(function(r){return function(n,s){return e.onerror=function(t){return s(t)},e.onload=function(e){var s;return s=JSON.parse(e.target.response),n(r.__initFromJSON(s,t.resource))}}}(this))},t.getAttribRemoteName=function(t){return null==this.attributes?null:null==this.attributes[t]?null:null==this.attributes[t].remoteName?t:this.attributes[t].remoteName},t.getResourcesUrlParams=function(t){var r,e,n,s;for(s=this.__getResourcesUrl({resource:t.resource}),n=/:(\w+)\/?/,e=[];r=n.exec(s);)e.push(r[1]),s=s.replace(r[0],r[1]);return e},t.__getResourcesUrl=function(t){var r,e;return e=null==this.resources?"/"+this.getRemoteName().toLowerCase()+"s":t.resource?this.resources[t.resource].url:null!=o.a.scope&&null!=this.resources[o.a.scope]?this.resources[o.a.scope].url:this.resources.url,null!=o.a.protocolWithHost&&(e=""+o.a.protocolWithHost+e),null==(r=/:(\w+)\/?/.exec(e))?e:(null!=t[r[1]]?(e=e.replace(":"+r[1],t[r[1]]),delete t[r[1]]):null!=t.obj&&null!=t.obj[r[1]]&&(e=e.replace(":"+r[1],t.obj[r[1]])),e)},t.__initSubclass=function(t){var r,e;return null==t&&(t={}),e=this.getIdentity().split("."),1===e.length?(r=a.a[e[0]],null==r?new this(t):new r(t)):new(r=a.a[e[0]][e[1]])(t)},t.__page=function(t,r,e){var n,s;return s=r.url,r.params[r.pageParam]=t,n=Object(u.a)(r.method,s,r.params),new Promise(function(t){return function(s,o){return n.onerror=function(t){return o(t)},n.onload=function(n){var o,i,a,u,l,c,h,p,f,_;if(o=JSON.parse(n.target.response),o.constructor===Array)for(i=0,l=o.length;i<l;i++)p=o[i],h=t.__initFromJSON(p,r.resource),e.push(h);else if(null!=o.resources){for(e.constructor===Array&&(e={resources:[],count:0}),f=o.resources,a=0,c=f.length;a<c;a++)p=f[a],h=t.__initFromJSON(p,r.resource),e.resources.push(h);e.count=o.count}else for(u in o)_=o[u],e[u]=_;return s(e)}}}(this))},t.__paginate=function(t){var r;return r={method:t.method,url:t.url,params:t.params,pageParam:t.pageParam,resource:t.resource},this.__page(t.pageNum||1,r,[]).then(function(e){return function(n){var s,o,i,a,u,l;if(l=n.count||t.total,a=Promise.resolve(n),null!=t.pageNum)return a;if(l<=t.perPage)return a;if(i=parseInt(l/t.perPage),i!==l/t.perPage&&(i+=1),1===i)return a;for(s=o=2,u=i;2<=u?o<=u:o>=u;s=2<=u?++o:--o)(function(t){return a=a.then(function(s){return e.__page(t,r,n)})})(s);return a}}(this))},t.__getPaginationParam=function(t){var r,e,n,s,i,a;return r="page",null!=t&&null!=this.resources&&this.resources[t]?(null!=(e=this.resources[t].paginate)?e.param:void 0)||r:null!=o.a.scope&&null!=this.resources&&null!=this.resources[o.a.scope]?(null!=(n=this.resources[o.a.scope])&&null!=(s=n.paginate)?s.param:void 0)||r:null!=(null!=(i=this.resources)&&null!=(a=i.paginate)?a.param:void 0)?this.resources.paginate.param:r},t.__getPaginationPer=function(t){var r,e,n,s,i;return null!=t&&null!=this.resources&&this.resources[t]?null!=(r=this.resources[t].paginate)?r.per:void 0:null!=o.a.scope&&null!=this.resources&&null!=this.resources[o.a.scope]?null!=(e=this.resources[o.a.scope])&&null!=(n=e.paginate)?n.per:void 0:null!=(null!=(s=this.resources)&&null!=(i=s.paginate)?i.per:void 0)?this.resources.paginate.per:null},t.__send=function(t,r,e){var n,s;return s=this.__getResourcesUrl(e),"all"!==r&&(s=s+"/"+r),n={method:t,url:s,params:e,resource:e.resource,perPage:this.__getPaginationPer(e.resource),pageNum:e.page,pageParam:this.__getPaginationParam(e.resource),total:e.total||e.count},this.__paginate(n)},t.__initFromJSON=function(t,r){var e;return e=this.__initSubclass(t),e.resource=r,i.a.add(e),e},t.prototype.setResource=function(t){return this.resource=t},t.prototype.getIdentity=function(){return this.constructor.getIdentity()},t.prototype.getAttrRemoteName=function(t){return null==this.constructor.attributes?null:null==this.constructor.attributes[t]?null:this.constructor.attributes[t].remoteName||t},t.prototype.getAttrName=function(t){var r,e,n;if(null==this.constructor.attributes)return t;if(null!=this.constructor.attributes[t])return t;n=this.constructor.attributes;for(e in n)if(r=n[e],r.remoteName===t)return e;return t},t.prototype.getAttrType=function(t){return null==this.constructor.attributes?null:null==this.constructor.attributes[t]?null:this.constructor.attributes[t].type},t.prototype.assignAttr=function(t,r){var e;if(e=this.getAttrType(t),null==r)return void(this[t]=null);switch(e){case"Date":r=new Date(Date.parse(r));break;case"Integer":case"Int":r=parseInt(r);break;case"Float":r=parseFloat(r);break;case"Boolean":case"Bool":r="boolean"==typeof r?r:Boolean(parseInt(r));break;case"Number":r=Number(r);break;case"String":r=String(r)}return this[t]=r},t.prototype.attributes=function(){var t,r,e;if(t={id:this.id},null==this.constructor.attributes)return t;e=this.constructor.attributes;for(r in e)e[r],t[r]=this[r];return t},t.prototype.isValid=function(){var t,r,e,n,o,i,a,u,l,c,h,p;if(null==this.constructor.attributes)return!0;this.errors=null,a=this.constructor.attributes;for(o in a)if(t=a[o],null!=t.validations){u=t.validations;for(c in u)h=u[c],null!=this.id&&"create"===h.on||null==this.id&&"update"===h.on||(null==h.if||h.if(this))&&(p=c.charAt(0).toUpperCase()+c.slice(1),null!=s.a[p]?(i=this.__processedValidationSettings(h),s.a[p].instance(this,o,i).validate()):console.warn('"'+p+'" validator is not implemented!'))}if(null!=this.constructor.validate)for(l=this.constructor.validate,r=0,e=l.length;r<e;r++)n=l[r],this[n]();return null==this.errors},t.prototype.isInvalid=function(){return!this.isValid()},t.prototype.isEmpty=function(){var t,r;r=this.attributes();for(t in r)if(r[t],null!==this[t])return!1;return!0},t.prototype.addErrorMessage=function(t,r){return null==r&&(r={}),null==this.errors&&(this.errors={}),null==this.errors[r.for]&&(this.errors[r.for]=[]),this.errors[r.for].push(t)},t.prototype.save=function(){var t,r;return t=null!=this.id?"PUT":"POST",r=Object(u.a)(t,this.__getResourceUrl(),this.serialize()),new Promise(function(t){return function(e,n){return r.onerror=function(t){return n(t)},r.onload=function(r){var n;return n=JSON.parse(r.target.response),n.success?void e(n):(null!=n.errors&&t.__assignRemoteErrorMessages(n.errors),e(n))}}}(this))},t.prototype.updateAttribute=function(t){var r;return r=Object(u.a)("PUT",this.__getResourceUrl(),this.serialize(t)),new Promise(function(t){return function(e,n){return r.onerror=function(t){return n(t)},r.onload=function(r){var s;return r.target.status>=200&&r.target.status<400?(s=JSON.parse(r.target.response),s.success?void e(s):(null!=s.errors&&t.__assignRemoteErrorMessages(s.errors),e(s))):r.target.status>=500?n(r):void 0}}}(this))},t.prototype.serialize=function(t){var r,e,n,s;if(null==t&&(t=null),null==this.constructor.attributes)return{};e={},n=this.constructor.getRemoteName().toLowerCase(),e[n]={},r={},null!=t?r[t]=null:r=this.constructor.attributes;for(t in r)r[t],s=this.getAttrRemoteName(t),e[n][s]=this[t];return e},t.prototype.reload=function(){var t,r,e,n,s;for(t={id:this.id,resource:this.resource},s=this.constructor.getResourcesUrlParams({resource:this.resource}),r=0,e=s.length;r<e;r++)n=s[r],t[n]=this[n];return this.constructor.find(t)},t.prototype.changes=function(){var t,r,e,n,s;n={},t=i.a.find(this.getIdentity(),this.id),e=this.attributes();for(r in e)if((s=e[r])!==t[r]){if(null!=s&&s.constructor===Date&&t[r]-s==0)continue;s!==t[r]&&(n[r]={is:t[r],was:s})}return n},t.prototype.applyChanges=function(){var t,r,e,n;r=this.changes(),e=[];for(t in r)n=r[t],e.push(this[t]=n.is);return e},t.prototype.toKey=function(){return this.getIdentity().toLowerCase()+"_"+this.id},t.prototype.get=function(t,r){return null==r&&(r={}),this.__send("GET",t,r)},t.prototype.post=function(t,r){return null==r&&(r={}),this.__send("POST",t,r)},t.prototype.put=function(t,r){return null==r&&(r={}),this.__send("PUT",t,r)},t.prototype.patch=function(t,r){return null==r&&(r={}),this.__send("PATCH",t,r)},t.prototype.delete=function(t,r){return null==r&&(r={}),this.__send("DELETE",t,r)},t.prototype.__send=function(t,r,e){var n,s;return s=this.__getResourceUrl(),null!=r&&(s=s+"/"+r),n=Object(u.a)(t,s,e),new Promise(function(t,r){return n.onerror=function(t){return r(t)},n.onload=function(n){return n.target.status>=200&&n.target.status<400?(e=JSON.parse(n.target.response),t(e)):n.target.status>=500?r(n):void 0}})},t.prototype.__assignAttributes=function(t){var r,e,n,s;n=[];for(e in t)s=t[e],r=this.getAttrName(e),n.push(this.assignAttr(r,s));return n},t.prototype.__initAttributes=function(){var t,r,e;r=this.constructor.attributes,e=[];for(t in r)r[t],e.push(this[t]=null);return e},t.prototype.__assignRemoteErrorMessages=function(t){var r,e,n,s,o;o=[];for(s in t)n=t[s],r=this.getAttrName(s),o.push(function(){var t,s,o;for(o=[],t=0,s=n.length;t<s;t++)e=n[t],o.push(this.addErrorMessage(e,{for:r}));return o}.call(this));return o},t.prototype.__getResourceUrl=function(){var t;return t=this.constructor.__getResourcesUrl({resource:this.resource,obj:this}),null==this.id?t:t+"/"+this.id},t.prototype.__processedValidationSettings=function(t){var r,e,n;n={};for(r in t)e=t[r],n[r]="function"==typeof e?e(this):e;return n},t}(),r.a=n},function(t,r,e){"use strict";var n,s=e(0),o=e(2),i=e(1),a=function(t,r){function e(){this.constructor=t}for(var n in r)u.call(r,n)&&(t[n]=r[n]);return e.prototype=r.prototype,t.prototype=new e,t.__super__=r.prototype,t},u={}.hasOwnProperty;n=function(t){function r(){r.__super__.constructor.call(this)}return a(r,t),r.identity="Absence",r.prototype.validate=function(){switch(typeof this.val){case"string":if(null!=this.val&&0===this.val.length)return;break;default:if(null==this.val)return}return this._addErrorMessage()},r.prototype._addErrorMessage=function(){var t;return t=null!=this.opts.message?this.opts.message:o.a[i.a.locale].errors.messages.present,this.obj.addErrorMessage(t,{for:this.attr})},r}(s.a),r.a=n},function(t,r,e){"use strict";var n;n={variants:{},models:{},attributes:{},errors:{messages:{accepted:"must be accepted",blank:"can't be blank",confirmation:"doesn't match %{attribute}",empty:"can't be empty",equal_to:"must be equal to %{count}",even:"must be even",exclusion:"is reserved",greater_than:"must be greater than %{count}",greater_than_or_equal_to:"must be greater than or equal to %{count}",inclusion:"is not included in the list",invalid:"is invalid",less_than:"must be less than %{count}",less_than_or_equal_to:"must be less than or equal to %{count}",not_a_number:"is not a number",not_an_integer:"must be an integer",odd:"must be odd",present:"must be blank",too_long:{one:"is too long (maximum is 1 character)",other:"is too long (maximum is %{count} characters)"},too_short:{one:"is too short (minimum is 1 character)",other:"is too short (minimum is %{count} characters)"},wrong_length:{one:"is the wrong length (should be 1 character)",other:"is the wrong length (should be %{count} characters)"},other_than:"must be other than %{count}"}}},r.a=n},function(t,r,e){"use strict";var n,s=e(0),o=e(2),i=e(1),a=function(t,r){function e(){this.constructor=t}for(var n in r)u.call(r,n)&&(t[n]=r[n]);return e.prototype=r.prototype,t.prototype=new e,t.__super__=r.prototype,t},u={}.hasOwnProperty;n=function(t){function r(){r.__super__.constructor.call(this)}return a(r,t),r.identity="Confirmation",r.prototype.validate=function(){var t;if(t=this.obj[this._properAttr()],null==this.val||null==t||this.val!==t)return this._addErrorMessage()},r.prototype._addErrorMessage=function(){var t,r,e,n;return e=this.attr.charAt(0).toUpperCase()+this.attr.slice(1),r=o.a[i.a.locale].attributes[this.obj.getIdentity()],t=r&&r[this.attr]||e,n=null!=this.opts.message?this.opts.message:o.a[i.a.locale].errors.messages.confirmation,n=n.replace("%{attribute}",t),this.obj.addErrorMessage(n,{for:this._properAttr()})},r.prototype._properAttr=function(){return this.attr+"Confirmation"},r}(s.a),r.a=n},function(t,r,e){"use strict";var n,s=e(0),o=e(2),i=e(1),a=function(t,r){function e(){this.constructor=t}for(var n in r)u.call(r,n)&&(t[n]=r[n]);return e.prototype=r.prototype,t.prototype=new e,t.__super__=r.prototype,t},u={}.hasOwnProperty;n=function(t){function r(){r.__super__.constructor.call(this)}return a(r,t),r.identity="Exclusion",r.prototype.validate=function(){var t;if(t=this.opts.in||this.opts.within||[],-1!==t.indexOf(this.val))return this._addErrorMessage()},r.prototype._addErrorMessage=function(){var t;return t=null!=this.opts.message?this.opts.message:o.a[i.a.locale].errors.messages.exclusion,this.obj.addErrorMessage(t,{for:this.attr})},r}(s.a),r.a=n},function(t,r,e){"use strict";var n,s=e(0),o=e(2),i=e(1),a=function(t,r){function e(){this.constructor=t}for(var n in r)u.call(r,n)&&(t[n]=r[n]);return e.prototype=r.prototype,t.prototype=new e,t.__super__=r.prototype,t},u={}.hasOwnProperty;n=function(t){function r(){r.__super__.constructor.call(this)}return a(r,t),r.identity="Format",r.prototype.validate=function(){if(null==this.opts.with.exec(this.val))return this._addErrorMessage()},r.prototype._addErrorMessage=function(){var t;return t=null!=this.opts.message?this.opts.message:o.a[i.a.locale].errors.messages.invalid,this.obj.addErrorMessage(t,{for:this.attr})},r}(s.a),r.a=n},function(t,r,e){"use strict";var n,s=e(0),o=e(2),i=e(1),a=function(t,r){function e(){this.constructor=t}for(var n in r)u.call(r,n)&&(t[n]=r[n]);return e.prototype=r.prototype,t.prototype=new e,t.__super__=r.prototype,t},u={}.hasOwnProperty;n=function(t){function r(){r.__super__.constructor.call(this)}return a(r,t),r.identity="Inclusion",r.prototype.validate=function(){var t;if(t=this.opts.in||this.opts.within||[],-1===t.indexOf(this.val))return this._addErrorMessage()},r.prototype._addErrorMessage=function(){var t;return t=null!=this.opts.message?this.opts.message:o.a[i.a.locale].errors.messages.inclusion,this.obj.addErrorMessage(t,{for:this.attr})},r}(s.a),r.a=n},function(t,r,e){"use strict";var n,s=e(0),o=e(2),i=e(1),a=function(t,r){function e(){this.constructor=t}for(var n in r)u.call(r,n)&&(t[n]=r[n]);return e.prototype=r.prototype,t.prototype=new e,t.__super__=r.prototype,t},u={}.hasOwnProperty;n=function(t){function r(){r.__super__.constructor.call(this)}return a(r,t),r.identity="Numericality",r.prototype.validate=function(){return isNaN(this.val)?this._addNaNErrorMessage():null!=this.opts.only_integer&&Number(this.val)!==parseInt(this.val)?this._addIntErrorMessage():null!=this.opts.greater_than&&Number(this.val)<=this.opts.greater_than?this._addGreatherThanErrorMessage():null!=this.opts.greater_than_or_equal_to&&Number(this.val)<this.opts.greater_than_or_equal_to?this._addGreatherThanOrEqualToErrorMessage():null!=this.opts.equal_to&&Number(this.val)!==this.opts.equal_to?this._addEqualToErrorMessage():null!=this.opts.less_than&&Number(this.val)>=this.opts.less_than?this._addLessThanErrorMessage():null!=this.opts.less_than_or_equal_to&&Number(this.val)>this.opts.less_than_or_equal_to?this._addLessThanOrEqualToErrorMessage():null!=this.opts.other_than&&Number(this.val)===this.opts.other_than?this._addOtherThanErrorMessage():null!=this.opts.odd&&Number(this.val)%2!=1?this._addOddErrorMessage():null!=this.opts.even&&Number(this.val)%2!=0?this._addEvenErrorMessage():void 0},r.prototype._addNaNErrorMessage=function(){var t;return t=null!=this.opts.message?this.opts.message:o.a[i.a.locale].errors.messages.not_a_number,this.obj.addErrorMessage(t,{for:this.attr})},r.prototype._addIntErrorMessage=function(){var t;return t=o.a[i.a.locale].errors.messages.not_an_integer,this.obj.addErrorMessage(t,{for:this.attr})},r.prototype._addGreatherThanErrorMessage=function(){var t;return t=o.a[i.a.locale].errors.messages.greater_than,t=t.replace("%{count}",this.opts.greater_than),this.obj.addErrorMessage(t,{for:this.attr})},r.prototype._addGreatherThanOrEqualToErrorMessage=function(){var t;return t=o.a[i.a.locale].errors.messages.greater_than_or_equal_to,t=t.replace("%{count}",this.opts.greater_than_or_equal_to),this.obj.addErrorMessage(t,{for:this.attr})},r.prototype._addEqualToErrorMessage=function(){var t;return t=o.a[i.a.locale].errors.messages.equal_to,t=t.replace("%{count}",this.opts.equal_to),this.obj.addErrorMessage(t,{for:this.attr})},r.prototype._addLessThanErrorMessage=function(){var t;return t=o.a[i.a.locale].errors.messages.less_than,t=t.replace("%{count}",this.opts.less_than),this.obj.addErrorMessage(t,{for:this.attr})},r.prototype._addLessThanOrEqualToErrorMessage=function(){var t;return t=o.a[i.a.locale].errors.messages.less_than_or_equal_to,t=t.replace("%{count}",this.opts.less_than_or_equal_to),this.obj.addErrorMessage(t,{for:this.attr})},r.prototype._addOtherThanErrorMessage=function(){var t;return t=o.a[i.a.locale].errors.messages.other_than,t=t.replace("%{count}",this.opts.other_than),this.obj.addErrorMessage(t,{for:this.attr})},r.prototype._addOddErrorMessage=function(){var t;return t=o.a[i.a.locale].errors.messages.odd,this.obj.addErrorMessage(t,{for:this.attr})},r.prototype._addEvenErrorMessage=function(){var t;return t=o.a[i.a.locale].errors.messages.even,this.obj.addErrorMessage(t,{for:this.attr})},r}(s.a),r.a=n},function(t,r,e){"use strict";var n,s=e(0),o=e(2),i=e(1),a=function(t,r){function e(){this.constructor=t}for(var n in r)u.call(r,n)&&(t[n]=r[n]);return e.prototype=r.prototype,t.prototype=new e,t.__super__=r.prototype,t},u={}.hasOwnProperty;n=function(t){function r(){r.__super__.constructor.call(this)}return a(r,t),r.identity="Presence",r.prototype.validate=function(){switch(typeof this.val){case"string":if(null!=this.val&&this.val.length>0)return;break;default:if(null!=this.val)return}return this._addErrorMessage()},r.prototype._addErrorMessage=function(){var t;return t=null!=this.opts.message?this.opts.message:o.a[i.a.locale].errors.messages.blank,this.obj.addErrorMessage(t,{for:this.attr})},r}(s.a),r.a=n},function(t,r,e){"use strict";var n,s=e(0),o=e(4),i=function(t,r){function e(){this.constructor=t}for(var n in r)a.call(r,n)&&(t[n]=r[n]);return e.prototype=r.prototype,t.prototype=new e,t.__super__=r.prototype,t},a={}.hasOwnProperty;n=function(t){function r(){r.__super__.constructor.call(this)}return i(r,t),r.identity="Size",r.prototype.validate=function(){return o.a.instance(this.obj,this.attr,this.opts).validate()},r}(s.a),r.a=n},function(t,r,e){"use strict";e.d(r,"a",function(){return o});var n=e(19),s=function(t){var r={};if(!t)return r;var e=["resource","total","count"];return Object.keys(t).forEach(function(n){-1===e.indexOf(n)&&(r[n]=t[n])}),r},o=function(t,r,e){var o=s(e),i="GET"===t?r+"?"+Object(n.a)(o):r,a=document.querySelector("meta[name='csrf-token']"),u=new XMLHttpRequest;return u.open(t,i),u.setRequestHeader("Accept","application/json"),u.setRequestHeader("Content-Type","application/json"),a&&u.setRequestHeader("X-CSRF-Token",a.content),u.send(JSON.stringify(o)),u}},function(t,r,e){"use strict";e.d(r,"a",function(){return n});var n=function(t){var r="";return Object.keys(t).forEach(function(e){""!==r&&(r+="&"),r=""+r+e+"="+encodeURIComponent(t[e])}),r}}])}); |
{ | ||
"name": "loco-js-model", | ||
"version": "0.3.2", | ||
"version": "0.3.3", | ||
"description": "Model part of loco-js", | ||
@@ -26,5 +26,5 @@ "main": "dist/loco-model.js", | ||
"babel-core": "^6.26.0", | ||
"babel-eslint": "^8.2.1", | ||
"babel-jest": "^22.1.0", | ||
"babel-loader": "^7.1.2", | ||
"babel-eslint": "^8.2.3", | ||
"babel-jest": "^22.4.3", | ||
"babel-loader": "^7.1.4", | ||
"babel-plugin-transform-object-rest-spread": "^6.26.0", | ||
@@ -34,15 +34,15 @@ "babel-preset-env": "^1.6.1", | ||
"coffeescript": "^1.12.7", | ||
"eslint": "^4.16.0", | ||
"eslint": "^4.19.1", | ||
"eslint-config-airbnb-base": "^12.1.0", | ||
"eslint-config-prettier": "^2.9.0", | ||
"eslint-plugin-import": "^2.8.0", | ||
"eslint-plugin-jest": "^21.7.0", | ||
"eslint-plugin-prettier": "^2.5.0", | ||
"express": "^4.16.2", | ||
"jest": "^22.1.4", | ||
"lint-staged": "^6.1.0", | ||
"eslint-plugin-import": "^2.11.0", | ||
"eslint-plugin-jest": "^21.15.0", | ||
"eslint-plugin-prettier": "^2.6.0", | ||
"express": "^4.16.3", | ||
"jest": "^22.4.3", | ||
"lint-staged": "^7.0.4", | ||
"pre-commit": "^1.2.2", | ||
"prettier": "^1.10.2", | ||
"webpack": "^3.10.0", | ||
"webpack-dev-middleware": "^2.0.3" | ||
"prettier": "^1.12.0", | ||
"webpack": "^3.11.0", | ||
"webpack-dev-middleware": "^2.0.6" | ||
}, | ||
@@ -49,0 +49,0 @@ "pre-commit": [ |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
80076
32
1