Comparing version 3.0.0-alpha.6 to 3.0.0-alpha.7
/*! | ||
* js-data | ||
* @version 3.0.0-alpha.6 - Homepage <http://www.js-data.io/> | ||
* @version 3.0.0-alpha.7 - Homepage <http://www.js-data.io/> | ||
* @author Jason Dobry <jason.dobry@gmail.com> | ||
@@ -11,3 +11,3 @@ * @copyright (c) 2014-2015 Jason Dobry | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.JSData={})}(this,function(t){"use strict";function e(t){return"[object Object]"===toString.call(t)||!1}function n(t){return!!t&&"object"===("undefined"==typeof t?"undefined":it.typeof(t))&&t.constructor===Object}function i(t){return"[object RegExp]"===toString.call(t)||!1}function r(t){return"string"==typeof t||t&&"object"===("undefined"==typeof t?"undefined":it.typeof(t))&&"[object String]"===toString.call(t)||!1}function o(t){return t&&"object"===("undefined"==typeof t?"undefined":it.typeof(t))&&"[object Date]"===toString.call(t)||!1}function a(t){var e="undefined"==typeof t?"undefined":it.typeof(t);return"number"===e||t&&"object"===e&&"[object Number]"===toString.call(t)||!1}function s(t){return"[object Boolean]"===toString.call(t)}function u(t){return"function"==typeof t||t&&"[object Function]"===toString.call(t)||!1}function l(t){return r(t)||a(t)}function c(t,e){if(e){for(var n=e.split("."),i=n.pop();e=n.shift();)if(t=t[e],null==t)return;return t[i]}}function f(t,e){for(var n=e.split("."),i=n.pop();e=n.shift();)if(t=t[e],null==t)return;t[i]=void 0,delete t[i]}function h(t,e){if(!e)return t;var n=e.split(".");return n.forEach(function(e){t[e]||(t[e]={}),t=t[e]}),t}function d(t,n,i){if(e(n))p(n,function(e,n){d(t,n,e)});else{var r=ot.exec(n);r?h(t,r[1])[r[2]]=i:t[n]=i}}function p(t,e,n){var i=Object.keys(t),r=i.length,o=void 0;for(o=0;r>o;o++)e.call(n,t[i[o]],i[o],t)}function g(t,e){return e&&p(e,function(t,e){var i=this[e];n(t)&&n(i)?g(i,t):this[e]=t},t),t}function v(t){return Promise.resolve(t)}function y(t){return Promise.reject(t)}function m(t,e){for(var n in t){var i=t[n];void 0===e[n]&&!u(i)&&n&&0!==n.indexOf("_")&&(e[n]=i)}}function b(t,e){if(!t||!e)return[];var n=[],i=void 0,r=void 0,o=t.length;for(r=0;o>r;r++)i=t[r],-1===n.indexOf(i)&&-1!==e.indexOf(i)&&n.push(i);return n}function A(t,e){p(e,function(e,n){void 0===t[n]&&(t[n]=e)})}function x(t,e){if(!e||!e.length)return!1;for(var n=void 0,i=0;i<e.length;i++)if("[object RegExp]"===Object.prototype.toString.call(e[i])&&e[i].test(t)||e[i]===t)return n=t;return!!n}function _(t){return r(t)?JSON.parse(t):t}function w(t,n,r,a,s){if(n){if(t===n)throw new Error("Cannot copy! Source and destination are identical.");if(r=r||[],a=a||[],e(t)){var u=r.indexOf(t);if(-1!==u)return a[u];r.push(t),a.push(n)}var l=void 0;if(rt(t)){var c=void 0;for(n.length=0,c=0;c<t.length;c++)l=w(t[c],null,r,a,s),e(t[c])&&(r.push(t[c]),a.push(l)),n.push(l)}else{rt(n)?n.length=0:p(n,function(t,e){delete n[e]});for(var f in t)if(t.hasOwnProperty(f)){if(x(f,s))continue;l=w(t[f],null,r,a,s),e(t[f])&&(r.push(t[f]),a.push(l)),n[f]=l}}}else n=t,t&&(rt(t)?n=w(t,[],r,a,s):o(t)?n=new Date(t.getTime()):i(t)?(n=new RegExp(t.source,t.toString().match(/[^\/]*$/)[0]),n.lastIndex=t.lastIndex):e(t)&&(n=w(t,Object.create(Object.getPrototypeOf(t)),r,a,s)));return n}function j(t,e,n){return""+e.toUpperCase()+n.toLowerCase()}function C(t){return t.replace(ut,"").replace(lt,j)}function O(t){return t.split(st).map(C).join("")}function k(t){return t=O(t),t?t.charAt(0).toLowerCase()+t.slice(1):t}function E(t,e,n,i){t=t||this;var r={};e||n||(e=function(){return r},n=function(t){r=t}),Object.defineProperties(t,{on:{enumerable:!!i,value:function(t,i,r){e.call(this)||n.call(this,{});var o=e.call(this);o[t]=o[t]||[],o[t].push({f:i,c:r})}},off:{enumerable:!!i,value:function(t,i){var r=e.call(this),o=r[t];if(o)if(i){for(var a=0;a<o.length;a++)if(o[a].f===i){o.splice(a,1);break}}else o.splice(0,o.length);else n.call(this,{})}},emit:{enumerable:!!i,value:function(){for(var t=e.call(this)||{},n=arguments.length,i=Array(n),r=0;n>r;r++)i[r]=arguments[r];var o=i.shift(),a=t[o]||[],s=void 0;for(s=0;s<a.length;s++)a[s].f.apply(a[s].c,i);for(a=t.all||[],i.unshift(o),s=0;s<a.length;s++)a[s].f.apply(a[s].c,i)}}})}function I(t,e){for(e=t="";t++<36;e+=51*t&52?(15^t?8^Math.random()*(20^t?16:4):4).toString(16):"-");return e}function R(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function S(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!==("undefined"==typeof e?"undefined":it.typeof(e))&&"function"!=typeof e?t:e}function F(t,e){p(e,function(t,n){e[n]={value:t}}),Object.defineProperties(t,e)}function P(t){R(this,P),this.collection=t,this.data=null}function M(t,e,n,i){var o=t[e],a=c(n,o[0]),s=c(i,o[0]);return a&&r(a)&&(a=a.toUpperCase()),s&&r(s)&&(s=s.toUpperCase()),"DESC"===o[1]?a>s?-1:s>a?1:e<t.length-1?M(t,e+1,n,i):0:s>a?-1:a>s?1:e<t.length-1?M(t,e+1,n,i):0}function N(t){return t.replace(ht,"\\$1")}function L(t,e){return new RegExp("^"+N(t).replace(dt,".*").replace(pt,".")+"$",e)}function D(t,e,n){switch(e){case"==":return t==n;case"===":return t===n;case"!=":return t!=n;case"!==":return t!==n;case">":return t>n;case">=":return t>=n;case"<":return n>t;case"<=":return n>=t;case"isectEmpty":return!b(t||[],n||[]).length;case"isectNotEmpty":return b(t||[],n||[]).length;case"in":return-1!==n.indexOf(t);case"notIn":return-1===n.indexOf(t);case"contains":return-1!==(t||[]).indexOf(n);case"notContains":return-1===(t||[]).indexOf(n);default:if(0===e.indexOf("like"))return null!==L(n,e.substr(4)).exec(t);if(0===e.indexOf("notLike"))return null===L(n,e.substr(7)).exec(t)}}function K(t,e,n){return t===e?0:(n&&(t=n(t),e=n(e)),null===t&&null===e?0:null===t?-1:null===e?1:e>t?-1:t>e?1:0)}function U(t,e,n){return t.splice(e,0,n),t}function T(t,e){return t.splice(e,1),t}function J(t,e,n){for(var i=0,r=t.length,o=void 0,a=void 0;r>i;){if(a=(i+r)/2|0,o=K(e,t[a],n),0===o)return{found:!0,index:a};0>o?r=a:i=a+1}return{found:!1,index:r}}function $(t,e){if(R(this,$),t||(t=[]),!rt(t))throw new Error("fieldList must be an array.");e||(e={}),this.fieldList=t,this.fieldGetter=e.fieldGetter,this.hashCode=e.hashCode,this.isIndex=!0,this.keys=[],this.values=[]}function q(){var t=this,e=arguments.length<=0||void 0===arguments[0]?[]:arguments[0],n=arguments.length<=1||void 0===arguments[1]?"id":arguments[1];if(R(this,q),!rt(e))throw new TypeError("new Collection([data]): data: Expected array. Found "+("undefined"==typeof e?"undefined":it.typeof(e)));this.idAttribute=n,this.index=new $([n],{hashCode:function(t){return c(t,n)}}),this.indexes={},e.forEach(function(e){t.index.insertRecord(e),e&&u(e.on)&&e.on("all",t._onModelEvent,t)})}function z(t,e,n){n||(n={});var i=n.localField=n.localField||e.name.toLowerCase(),r=n.localKey=n.localKey||e.name.toLowerCase()+"_id",o={enumerable:void 0!==n.enumerable?!!n.enumerable:!1,get:function(){if(!this._get("$"))return this._get("links."+i);var t=c(this,r),n=void 0!==t?e.get(t):void 0;return this._set("links."+i,n),n},set:function(t){return this._set("links."+i,t),d(this,r,t[e.idAttribute]),c(this,i)}},a=o.get,s=o.set;return(n.link===!1||void 0===n.link&&!t.linkRelations)&&(delete o.get,delete o.set,o.writable=!0),n.get&&(o.get=function(){var i=this;return n.get(t,e,this,function(){return a.call(i)})},delete o.writable),n.set&&(o.set=function(i){var r=this;return n.set(t,e,this,i,function(t){return s.call(r,void 0===t?i:t)})},delete o.writable),o.get&&(o.set||(o.set=function(){})),Object.defineProperty(t.prototype,i,o),Object.defineProperty(t.prototype,r,{configurable:!0,enumerable:!0,get:function(){return this._get("props."+r)},set:function(e){this._set("props."+r,e),this._get("$")&&t.getCollection().indexes[r].updateRecord(this,{index:r})}}),t.relationList||(t.relationList=[]),t.relationFields||(t.relationFields=[]),n.type="belongsTo",n.name=t.name,n.relation=e.name,n.Relation=e,t.relationList.push(n),t.relationFields.push(i),t.getCollection().createIndex(r),t}function B(t,e){return function(n){return n.dbg(vt,"Model:",t,"opts:",e),z(n,t,e)}}function V(t){var e=arguments.length<=1||void 0===arguments[1]?!0:arguments[1];return t=t||{},function(n){return p(t,function(t,i){(void 0===n[i]||e)&&(n[i]=w(t))}),n}}function G(t,e,n){n||(n={});var i=n.localField=n.localField||k(e.name)+"Collection",r=n.foreignKey,o=n.localKeys,a=n.foreignKeys;r||o||a||(r=n.foreignKey=k(t.name)+"_id"),r&&e.getCollection().createIndex(r);var s={enumerable:void 0!==n.enumerable?!!n.enumerable:!1,get:function(){if(!this._get("$"))return this._get("links."+i);var n={},s=void 0;if(r)s=e.getAll(c(this,t.idAttribute),{index:r});else if(o){var u=c(this,o)||[],l=rt(u)?u:Object.keys(u);s=e.getAll.apply(e,l)}else a&&(d(n,"where."+a+".contains",c(this,t.idAttribute)),s=e.filter(n));return this._set("links."+i,s),s},set:function(n){var s=this;return this._set("links."+i,n),n&&n.length&&!function(){var i=c(s,t.idAttribute);r?n.forEach(function(t){d(t,r,i)}):o?!function(){var t=[];n.forEach(function(n){t.push(c(n,e.idAttribute))}),d(s,o,t)}():a&&n.forEach(function(t){var e=c(t,a);e?-1===e.indexOf(i)&&e.push(i):d(t,a,[i])})}(),c(this,i)}},u=s.get,l=s.set;return(n.link===!1||void 0===n.link&&!t.linkRelations)&&(delete s.get,delete s.set,s.writable=!0),n.get&&(s.get=function(){var i=this;return n.get(t,e,this,function(){return u.call(i)})}),n.set&&(s.set=function(i){var r=this;return n.set(t,e,this,i,function(t){return l.call(r,void 0===t?i:t)})}),Object.defineProperty(t.prototype,i,s),t.relationList||(t.relationList=[]),t.relationFields||(t.relationFields=[]),n.type="hasMany",n.name=t.name,n.relation=e.name,n.Relation=e,t.relationList.push(n),t.relationFields.push(i),t}function H(t,e){return function(n){return n.dbg(yt,"Model:",t,"opts:",e),G(n,t,e)}}function Q(t,e,n){n||(n={});var i=n.localField=n.localField||k(e.name),r=n.foreignKey=n.foreignKey||k(t.name)+"Id",o={enumerable:void 0!==n.enumerable?!!n.enumerable:!1,get:function(){if(!this._get("$"))return this._get("links."+i);var n=e.getAll(c(this,t.idAttribute),{index:r}),o=n&&n.length?n[0]:void 0;return this._set("links."+i,o),o},set:function(e){return this._set("links."+i,e),d(e,r,c(this,t.idAttribute)),c(this,i)}};return(n.link===!1||void 0===n.link&&!t.linkRelations)&&(delete o.get,delete o.set),n.get&&!function(){var i=o.get;o.get=function(){var r=this;return n.get(t,e,this,i?function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];return i.apply(r,e)}:void 0)}}(),n.set&&!function(){var i=o.set;o.set=function(r){var o=this;return n.set(t,e,this,r,i?function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];return i.apply(o,e)}:void 0)}}(),Object.defineProperty(t.prototype,i,o),t.relationList||(t.relationList=[]),t.relationFields||(t.relationFields=[]),n.type="hasOne",n.name=t.name,n.relation=e.name,n.Relation=e,t.relationList.push(n),t.relationFields.push(i),t.getCollection().createIndex(r),t}function Y(t,e){return function(n){return n.dbg(mt,"Model:",t,"opts:",e),Q(n,t,e)}}function Z(t,e){var n=[];return p(t,function(t,i){var r=At[i];if(r){var o=r(t,e);o&&n.push(o)}}),n.length?n:void 0}function W(t,e,n){var i={enumerable:void 0!==n.enumerable?n.enumerable:!0};return i.get=function(){return this._get("props."+e)},i.set=function(i){var r=this,o=this._get,a=this._set,s=this._unset;if(!o("noValidate")){var u=Z(n,i);if(u)throw new Error(u.join(", "))}return n.track&&!o("creating")&&!function(){var t=o("changing"),n=o("previous."+e),u=o("props."+e),l=o("changed");t||(l=[]);var f=l.indexOf(e);u!==i&&-1===f&&l.push(e),n!==i?a("changes."+e,i):(s("changes."+e),f>=0&&l.splice(f,1)),l.length||(t=!1,s("changing"),s("changed"),o("eventId")&&(clearTimeout(o("eventId")),s("eventId"))),!t&&l.length&&(a("changed",l),a("changing",!0),a("eventId",setTimeout(function(){if(s("changed"),s("eventId"),s("changing"),!o("silent")){var t=void 0;for(t=0;t<l.length;t++)r.emit("change:"+l[t],r,c(r,l[t]));r.emit("change",r,o("changes"))}s("silent")},0)))}(),a("props."+e,i),o("$")&&n.indexed&&t.getCollection().updateRecord(this,{index:e}),i},n.indexed&&t.createIndex(e),n.get&&(i.get?!function(){var t=i.get;i.get=function(){return n.get.call(this,t)}}():i.get=n.get),n.set&&(i.set?!function(){var t=i.set;i.set=function(e){return n.set.call(this,e,t)}}():i.set=n.set),i}function X(t){return t||(t={}),function(e){return e.dbg(xt,"opts:",t),e.schema||(e.schema={}),V(e.schema,t),p(t,function(t,n){var i=W(e,n,t);i.writable||Object.defineProperty(e.prototype,n,i)}),e}}function tt(t,e,n){return n||(n={}),n.op=_t,function(i){i.dbg(_t,"name:",t,"adapter:",e,"opts:",n),i.getAdapters()[t]=e,(n===!0||n.default)&&(i.defaultAdapter=t)}}function et(t,e){R(this,et),t||(t={}),e||(e={});var n={};Object.defineProperties(this,{_get:{value:function(t){return c(n,t)}},_set:{value:function(t,e){return d(n,t,e)}},_unset:{value:function(t){return f(n,t)}}}),this._set("creating",!0),e.noValidate&&this._set("noValidate",!0),A(this,t),this._unset("creating"),this._set("changes",{}),this._unset("noValidate"),this._set("previous",w(t))}function nt(t){R(this,nt),t||(t={}),this.definitions={}}var it={};it.typeof=function(t){return t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},it.defineProperty=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t};var rt=Array.isArray,ot=/^(.+)\.(.+)$/,at=JSON.stringify,st=/\s+/,ut=/[^A-Za-z]/g,lt=/(\w)(\w*)/g,ct=Object.freeze({isArray:rt,isObject:e,isRegExp:i,isString:r,isDate:o,isNumber:a,isBoolean:s,isFunction:u,isSorN:l,get:c,unset:f,set:d,forOwn:p,deepMixIn:g,resolve:v,reject:y,_:m,intersection:b,fillIn:A,isBlacklisted:x,fromJson:_,toJson:at,copy:w,pascalCase:O,camelCase:k,eventify:E,uuid:I,classCallCheck:R,possibleConstructorReturn:S,addHiddenPropsToTarget:F}),ft={skip:"",offset:"",where:"",limit:"",orderBy:"",sort:""},ht=/([.*+?^=!:${}()|[\]\/\\])/g,dt=/%/g,pt=/_/g;F(P.prototype,{getData:function(){return this.data||(this.data=this.collection.index.getAll()),this.data},between:function(t,e,n){n||(n={});var i=this.collection,r=n.index?i.indexes[n.index]:i.index;if(this.data)throw new Error("Cannot access index after first operation!");return this.data=r.between(t,e,n),this},get:function(){var t=arguments.length<=0||void 0===arguments[0]?[]:arguments[0],e=arguments[1];if(e||(e={}),this.data)throw new Error("Cannot access index after first operation!");if(t&&!rt(t)&&(t=[t]),!t.length)return this.getData(),this;var n=this.collection,i=e.index?n.indexes[e.index]:n.index;return this.data=i.get(t),this},getAll:function(){var t=this,n={};if(this.data)throw new Error("Cannot access index after first operation!");for(var i=arguments.length,r=Array(i),o=0;i>o;o++)r[o]=arguments[o];if(!r.length||1===r.length&&e(r[0]))return this.getData(),this;r.length&&e(r[r.length-1])&&(n=r[r.length-1],r.pop());var a=this.collection,s=n.index?a.indexes[n.index]:a.index;return this.data=[],r.forEach(function(e){t.data=t.data.concat(s.get(e))}),this},filter:function(t,n){var i=this;return t||(t={}),this.getData(),e(t)?!function(){var n={};e(t.where)&&(n=t.where),p(t,function(t,e){e in ft||e in n||(n[e]={"==":t})});var o=[],s=[],u=[];p(n,function(t,n){e(t)||(t={"==":t}),p(t,function(t,e){o.push(n),s.push(e),u.push(t)})}),o.length&&!function(){var t=void 0,e=o.length;i.data=i.data.filter(function(n){var i=!0,r=!0;for(t=0;e>t;t++){var a=s[t],l="|"===a.charAt(0);a=l?a.substr(1):a;var f=D(c(n,o[t]),a,u[t]);void 0!==f&&(r=i?f:l?r||f:r&&f),i=!1}return r})}();var l=t.orderBy||t.sort;r(l)&&(l=[[l,"ASC"]]),rt(l)||(l=null),l&&!function(){var t=0;l.forEach(function(t,e){r(t)&&(l[e]=[t,"ASC"])}),i.data.sort(function(e,n){return M(l,t,e,n)})}(),a(t.skip)?i.skip(t.skip):a(t.offset)&&i.skip(t.offset),a(t.limit)&&i.limit(t.limit)}():u(t)&&(this.data=this.data.filter(t,n)),this},skip:function(t){if(!a(t))throw new TypeError("skip: Expected number but found "+("undefined"==typeof t?"undefined":it.typeof(t))+"!");var e=this.getData();return t<e.length?this.data=e.slice(t):this.data=[],this},limit:function(t){if(!a(t))throw new TypeError("limit: Expected number but found "+("undefined"==typeof t?"undefined":it.typeof(t))+"!");var e=this.getData();return this.data=e.slice(0,Math.min(e.length,t)),this},forEach:function(t,e){return this.getData().forEach(t,e),this},map:function(t,e){return this.data=this.getData().map(t,e),this},mapCall:function(t){for(var e=arguments.length,n=Array(e>1?e-1:0),i=1;e>i;i++)n[i-1]=arguments[i];return this.data=this.getData().map(function(e){return e[t].apply(e,n)}),this},run:function(){var t=this.data;return this.data=null,t}});var gt={">":1,">=":1,"<":1,"<=":1};F($.prototype,{set:function(t,e){rt(t)||(t=[t]);var n=t.shift()||null,i=J(this.keys,n);if(0===t.length)if(i.found){var r=J(this.values[i.index],e,this.hashCode);r.found||U(this.values[i.index],r.index,e)}else U(this.keys,i.index,n),U(this.values,i.index,[e]);else if(i.found)this.values[i.index].set(t,e);else{U(this.keys,i.index,n);var o=new $([],{hashCode:this.hashCode});o.set(t,e),U(this.values,i.index,o)}},get:function(t){rt(t)||(t=[t]);var e=t.shift()||null,n=J(this.keys,e);return 0===t.length?n.found?this.values[n.index].isIndex?this.values[n.index].getAll():this.values[n.index]:[]:n.found?this.values[n.index].get(t):[]},getAll:function(){var t=[];return this.values.forEach(function(e){t=e.isIndex?t.concat(e.getAll()):t.concat(e)}),t},visitAll:function(t,e){this.values.forEach(function(n){n.isIndex?n.visitAll(t,e):n.forEach(t,e)})},query:function(t){var e=void 0,n=void 0;if(t[">"]?(e=t[">"],t.leftInclusive=!1):t[">="]&&(e=t[">="],t.leftInclusive=!0),t["<"]?(n=t["<"],t.rightInclusive=!1):t["<="]&&(n=t["<="],t.rightInclusive=!0),e.length!==n.length)throw new Error("Key arrays must be same length");var i={};return p(t,function(t,e){gt[e]||(i[e]=t)}),this.between(e,n,i)},between:function(t,e){var n=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];rt(t)||(t=[t]),rt(e)||(e=[e]),A(n,{leftInclusive:!0,rightInclusive:!1,limit:void 0,offset:0});var i=this._between(t,e,n);return n.limit?i.slice(n.offset,n.limit+n.offset):i.slice(n.offset)},_between:function(t,e,n){var i=[],r=t.shift(),o=e.shift(),a=void 0;if(a=void 0!==r?J(this.keys,r):{found:!1,index:0},0===t.length){a.found&&n.leftInclusive===!1&&(a.index+=1);for(var s=a.index;s<this.keys.length;s+=1){if(void 0!==o)if(n.rightInclusive){if(this.keys[s]>o)break}else if(this.keys[s]>=o)break;if(i=this.values[s].isIndex?i.concat(this.values[s].getAll()):i.concat(this.values[s]),n.limit&&i.length>=n.limit+n.offset)break}}else for(var s=a.index;s<this.keys.length;s+=1){var u=this.keys[s];if(u>o)break;if(i=this.values[s].isIndex?u===r?i.concat(this.values[s]._between(w(t),e.map(function(){}),n)):u===o?i.concat(this.values[s]._between(t.map(function(){}),w(e),n)):i.concat(this.values[s].getAll()):i.concat(this.values[s]),n.limit&&i.length>=n.limit+n.offset)break}return n.limit?i.slice(0,n.limit+n.offset):i},peek:function(){return this.values.length?this.values[0].isIndex?this.values[0].peek():this.values[0]:[]},remove:function(t,e){rt(t)||(t=[t]);var n=t.shift(),i=J(this.keys,n);if(0===t.length){if(i.found){var r=J(this.values[i.index],e,this.hashCode);r.found&&(T(this.values[i.index],r.index),0===this.values[i.index].length&&(T(this.keys,i.index),T(this.values,i.index)))}}else i.found&&this.values[i.index].delete(t,e)},clear:function(){this.keys=[],this.values=[]},insertRecord:function(t){var e=this.fieldList.map(function(e){return u(e)?e(t)||null:t[e]||null});this.set(e,t)},removeRecord:function(t){var e=this,n=void 0;return this.values.forEach(function(i,r){if(i.isIndex){if(i.removeRecord(t))return 0===i.keys.length&&(T(e.keys,r),T(e.values,r)),n=!0,!1}else{var o=J(i,t,e.hashCode);if(o.found)return T(i,o.index),0===i.length&&(T(e.keys,r),T(e.values,r)),n=!0,!1}}),n?t:void 0},updateRecord:function(t){this.removeRecord(t),this.insertRecord(t)}}),F(q.prototype,{_onModelEvent:function(){this.emit.apply(this,arguments)},createIndex:function(t,e,n){r(t)&&void 0===e&&(e=[t]),n||(n={});var i=this.idAttribute;n.hashCode=n.hashCode||function(t){return c(t,i)};var o=this.indexes[t]=new $(e,n);return this.index.visitAll(o.insertRecord,o),this},query:function(){return new P(this)},between:function(t,e,n){return this.query().between(t,e,n).run()},get:function(t,e){return this.query().get(t,e).run()},getAll:function(){var t;return(t=this.query()).getAll.apply(t,arguments).run()},filter:function(t,e){return this.query().filter(t,e).run()},skip:function(t){return this.query().skip(t).run()},limit:function(t){return this.query().limit(t).run()},forEach:function(t,e){this.index.visitAll(t,e)},reduce:function(t,e){var n=this.getAll();return n.reduce(t,e)},map:function(t,e){var n=[];return this.index.visitAll(function(i){n.push(t.call(e,i))}),n},insert:function(t){this.index.insertRecord(t),p(this.indexes,function(e,n){e.insertRecord(t)}),t&&u(t.on)&&(t.on("all",this._onModelEvent,this),this.emit("add",t))},update:function(t){this.index.updateRecord(t),p(this.indexes,function(e,n){e.updateRecord(t)})},remove:function(t){this.index.removeRecord(t),p(this.indexes,function(e,n){e.removeRecord(t)}),t&&u(t.off)&&(t.off("all",this._onModelEvent,this),this.emit("remove",t))},updateRecord:function(t,e){e||(e={});var n=e.index?this.indexes[e.index]:this.index;n.updateRecord(t)},mapCall:function(t){for(var e=arguments.length,n=Array(e>1?e-1:0),i=1;e>i;i++)n[i-1]=arguments[i];var r=[];return this.index.visitAll(function(e){r.push(e[t].apply(e,n))}),r}}),E(q.prototype,function(){return this._events},function(t){this._events=t});var vt="belongsTo",yt="hasMany",mt="hasOne",bt={array:rt,boolean:s,integer:a,number:a,null:function(t){return null===t},object:e,string:r},At={type:function(t,e){if(void 0!==e){r(t)&&(t=[t]);var n=t.map(function(n){var i=bt[n];return i?i(e)?void 0:1:"type: Unknown type "+t});return-1!==n.indexOf(void 0)?void 0:"type: Expected: "+t.join(" or ")+". Actual: "+("undefined"==typeof e?"undefined":it.typeof(e))}},anyOf:function(t,e){var n=!1,i=[];return t.forEach(function(t){var r=Z(t,e);r?i=i.concat(r):n=!0}),n?void 0:i},allOf:function(t,e){var n=[];return t.forEach(function(t){n=n.concat(Z(t,e)||[])}),n.length?void 0:n},oneOf:function(t,e){var n=!1,i=[];return t.forEach(function(t){var r=Z(t,e);if(r)i=i.concat(r);else{if(n)return i=["more than one schema validated"],n=!1,!1;n=!0}}),n?void 0:i}},xt="setSchema",_t="registerAdapter",wt=v,jt=!1;try{jt=!!window}catch(t){}var Ct=function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];var i=this,r=e.pop();i.dbg.apply(i,[r.op].concat(e)),(r.notify||void 0===r.notify&&i.notify)&&setTimeout(function(){i.emit.apply(i,[r.op].concat(e))})};F(et.prototype,{schema:function(t){var e=this.constructor.schema;return t?e[t]:e},validate:function(t,e){var n=[],i=this.schema();if(t)if(r(t)){var o=i[t];o&&(n=Z(o,e)||[])}else p(i,function(e,i){n=n.concat(Z(e,c(t,i))||[])});else t=this;return n.length?n:void 0},create:function(t){return this.constructor.create(this,t)},beforeSave:function(){},save:function(t){var e=this,n=this.constructor,i="save";n.dbg(i,"instance:",this,"opts:",t);var r=void 0;return t||(t={}),m(n,t),t.op=i,wt(this.beforeSave(t)).then(function(){return r=n.getAdapterName(t),n.getAdapter(r).update(n,c(e,n.idAttribute),e.toJSON(t),t)}).then(function(i){return wt(e.afterSave(t)).then(function(){return n.end(i,t,r)})})},afterSave:function(){},destroy:function(t){var e=this.constructor;return e.destroy(c(this,e.idAttribute),t)},get:function(t){return c(this,t)},set:function(t,n,i){e(t)&&(i=n),i||(i={}),i.silent&&this._set("silent",!0),d(this,t,n),this._get("eventId")||this._unset("silent")},unset:function(t,e){e||(e={}),e.silent&&this._set("silent",!0),f(this,t),this._get("eventId")||this._unset("silent")},hashCode:function(){return c(this,this.constructor.idAttribute)},changes:function(t){return t?this._get("changes."+t):this._get("changes")},hasChanges:function(){return!!(this._get("changed")||[]).length},commit:function(){return this._unset("changed"),this._set("changes",{}),this._set("previous",w(this)),this},previous:function(t){return t?this._get("previous."+t):this._get("previous")},revert:function(t){var e=this,n=this._get("previous")||{};return t||(t={}),t.preserve||(t.preserve=[]),p(this,function(i,r){r!==e.constructor.idAttribute&&!n.hasOwnProperty(r)&&e.hasOwnProperty(r)&&-1===t.preserve.indexOf(r)&&delete e[r]}),p(n,function(n,i){-1===t.preserve.indexOf(i)&&(e[i]=n)}),this.commit(),this},toJSON:function(t){var e=this;t||(t={});var n=this.constructor,i=this;if(this instanceof et){i={};for(var o in this)i[o]=this[o];n&&n.relationList&&t.with&&(r(t.with)&&(t.with=[t.with]),n.relationList.forEach(function(n){var r=void 0;-1!==t.with.indexOf(n.relation)?r=n.relation:-1!==t.with.indexOf(n.localField)&&(r=n.localField),r&&!function(){var o={with:t.with.slice()};o.with.splice(o.with.indexOf(r),1),o.with.forEach(function(t,e){t&&0===t.indexOf(r)&&t.length>=r.length&&"."===t[r.length]?o.with[e]=t.substr(r.length+1):o.with[e]=""});var a=c(e,n.localField);a&&(rt(a)?d(i,n.localField,a.map(function(t){return n.Relation.prototype.toJSON.call(t,o)})):d(i,n.localField,n.Relation.prototype.toJSON.call(a,o)))}()}))}return i}}),A(et,{_adapters:null,_adaptersOwner:null,_collection:null,_collectionOwner:null,_listeners:null,_listenersOwner:null,autoEject:!0,autoInject:jt,bypassCache:!1,csp:!1,defaultAdapter:"http",debug:!1,eagerEject:!1,idAttribute:"id",linkRelations:jt,notify:jt,onConflict:"merge",relationsEnumerable:!1,raw:!1,upsert:!0,_events:function(t){return t?this._listeners=t:this._listenersOwner!==this&&(this._listeners={},this._listenersOwner=this),this._listeners},end:function(t,e){var n=this;return e.raw?(e.autoInject&&(t.data=n.inject(t.data)),m(e,t),t):(e.autoInject&&(t=n.inject(t)),e.notify&&setTimeout(function(){n.emit(e.op,t,e)}),t)},createIndex:function(t,e,n){this.dbg("createIndex","name:",t,"fieldList:",e,"opts:",n),this.getCollection().createIndex(t,e,n)},createInstance:function(t,e){var n=this;return t instanceof n?t:new n(t,e)},is:function(t){return t instanceof this},getAutoPkItems:function(){return this.getAll().filter(function(t){return t._get("autoPk")})},changes:function(t){if(this.dbg("changes","id:",t),l(t)){var e=this.get(t);return e?e.changes():void 0}return this.getCollection().mapCall("changes")},hasChanges:function(t){var e=this;if(this.dbg("hasChanges","id:",t),l(t)){var n=this.get(t);if(n)return n.hasChanges()}else{var i=function(){var t=!1;return e.getCollection().forEach(function(e){t=t||e.hasChanges()}),{v:t}}();if("object"===("undefined"==typeof i?"undefined":it.typeof(i)))return i.v}},beforeInject:function(){},inject:function(t,e){var n=this,i="inject";n.dbg(i,"entities:",t,"opts:",e),e||(e={}),m(n,e),e.op=i,t=this.beforeInject(t,e)||t;var r=!1,o=n.getCollection(),a=n.idAttribute,s=n.relationList||[],h=(new Date).getTime();rt(t)||(t=[t],r=!0),t=t.map(function(t){var i=c(t,a),r=!1;if(!l(i)){if(!e.autoPk)throw new TypeError("User#"+a+": Expected string or number, found "+("undefined"==typeof i?"undefined":it.typeof(i))+"!");i=I(),d(t,a,i),r=!0}var v=n.get(i);if(t===v)return v;if(s.forEach(function(e){var r=e.Relation,o=r.idAttribute,s=e.foreignKey,l=c(t,e.localField);if(u(e.inject))e.inject(n,e,t);else if(l&&e.inject!==!1)if(rt(l))l=l.map(function(t){if(t!==r.get(c(t,o)))try{s&&d(t,s,i),t=r.inject(t)}catch(t){throw new Error("Failed to inject "+e.type+' relation: "'+e.relation+'"! '+t.message)}return t}),e.localKeys&&d(t,e.localKeys,l.map(function(t){return c(t,o)}));else if(l!==r.get(c(l,o)))try{e.localKey&&d(t,e.localKey,c(l,r.idAttribute)),s&&d(l,e.foreignKey,c(t,a)),l=r.inject(l)}catch(t){throw new Error("Failed to inject "+e.type+' relation: "'+e.relation+'"!')}e.link||void 0===e.link&&n.linkRelations?f(t,e.localField):d(t,e.localField,l)}),v){var y=e.onConflict||n.onConflict;"merge"===y?g(v,t):"replace"===y&&(p(v,function(e,n){n===a||t.hasOwnProperty(n)||delete v[n]}),v.set(t)),t=v,o.update(t)}else t=n.createInstance(t),r&&t._set("autoPk",r),o.insert(t);return t._set("$",h),t});var v=r?t.length?t[0]:void 0:t;return this.afterInject(v,e),v},afterInject:function(){},beforeEject:function(){},eject:function(t,e){var n="eject";this.dbg(n,"id:",t,"opts:",e),e||(e={}),e.op=n,this.beforeEject(t,e);var i=this.get(t);return i&&(i._unset("$"),this.getCollection().remove(i)),this.afterEject(i,e),i},afterEject:function(){},beforeEjectAll:function(){},ejectAll:function(t,e){var n="ejectAll";this.dbg(n,"query:",t,"opts:",e),e||(e={}),e.op=n,this.beforeEjectAll(t,e);var i=this.filter(t),r=this.getCollection();return i.forEach(function(t){r.remove(t)}),this.afterEjectAll(i,t,e),i},afterEjectAll:function(){},get:function(t){this.dbg("get","id:",t);var e=this.getCollection().get(t);return e.length?e[0]:void 0},between:function(){var t;return(t=this.getCollection()).between.apply(t,arguments)},getAll:function(){var t;return(t=this.getCollection()).getAll.apply(t,arguments)},filter:function(t,e){return e||(e={}),this.getCollection().filter(t,e)},forEach:function(t,e){return this.getCollection().forEach(t,e)},map:function(t,e){return this.getCollection().map(t,e)},reduce:function(t,e){return this.getCollection().reduce(t,e)},mapCall:function(){var t;return(t=this.getCollection()).mapCall.apply(t,arguments)},toJSON:function(t){return this.mapCall("toJSON",t)},query:function(){return this.getCollection().query()},getAdapter:function(t){this.dbg("getAdapter","name:",t);var e=this.getAdapterName(t);if(!e)throw new ReferenceError(e+" not found!");return this.getAdapters()[e]},getAdapterName:function(t){return t||(t={}),r(t)&&(t={adapter:t}),t.adapter||t.defaultAdapter},getAdapters:function(){if(this._adaptersOwner!==this){var t=this._adapters;this._adapters={},t&&A(this._adapters,t),this._adaptersOwner=this}return this._adapters},getCollection:function(){return this._collectionOwner!==this&&(this._collection=new q([],this.idAttribute),this._collection.on("all",this.emit,this),this._collection.createIndex("lastInjected",["$"],{fieldGetter:function(t){return t._get("$")}}),this._collectionOwner=this),this._collection},beforeCreate:Ct,checkUpsertCreate:function(t,e){var n=this;return(e.upsert||void 0===e.upsert&&n.upsert)&&c(t,n.idAttribute)&&(!n.is(t)||!t._get("autoPk"))},create:function(t,e){var n=void 0,i=void 0,r=this;return t||(t={}),e||(e={}),r.checkUpsertCreate(t,e)?r.update(c(t,r.idAttribute),t,e):(m(r,e),i=e.adapter=r.getAdapterName(e),n=e.op="beforeCreate",wt(r[n](t,e)).then(function(o){t=o||t,n=e.op="create";var a=r.prototype.toJSON.call(t,e);return r.dbg(n,a,e),r.getAdapter(i)[n](r,a,e)}).then(function(i){return n=e.op="afterCreate",wt(r[n](i,e)).then(function(n){return i=n||i,r.is(t)&&t._get("$")&&r.eject(c(t,r.idAttribute)),r.end(i,e)})}))},afterCreate:Ct,beforeCreateMany:Ct,checkUpsertCreateMany:function(t,e){var n=this;return e.upsert||void 0===e.upsert&&n.upsert?t.reduce(function(t,e){return t&&c(e,n.idAttribute)&&(!u(e._get)||!e._get("autoPk"))},!0):void 0},createMany:function(t,e){var n=void 0,i=void 0,r=this;return t||(t=[]),e||(e={}),r.checkUpsertCreateMany(t,e)?r.updateMany(t,e):(m(r,e),i=e.adapter=r.getAdapterName(e),n=e.op="beforeCreateMany",wt(r[n](t,e)).then(function(o){t=o||t,n=e.op="createMany";var a=t.map(function(t){return r.prototype.toJSON.call(t,e)});return r.dbg(n,a,e),r.getAdapter(i)[n](r,a,e)}).then(function(i){return n=e.op="afterCreateMany",wt(r[n](i,e)).then(function(n){return i=n||i,t.forEach(function(t){r.is(t)&&t._get("$")&&r.eject(c(t,r.idAttribute))}),r.end(i,e)})}))},afterCreateMany:Ct,beforeFind:Ct,find:function(t,e){var n=void 0,i=void 0,r=this;return e||(e={}),m(r,e),i=e.adapter=r.getAdapterName(e),n=e.op="beforeFind",wt(r[n](t,e)).then(function(o){return t=void 0===o?t:o,n=e.op="find",r.dbg(n,t,e),r.getAdapter(i)[n](r,t,e)}).then(function(t){return n=e.op="afterFind",wt(r[n](t,e)).then(function(n){return t=n||t,r.end(t,e)})})},afterFind:Ct,beforeFindAll:Ct,findAll:function(t,e){var n=void 0,i=void 0,r=this;return t||(t={}),e||(e={}),m(r,e),i=e.adapter=r.getAdapterName(e),n=e.op="beforeFindAll",wt(r[n](t,e)).then(function(o){return t=o||t,n=e.op="findAll",r.dbg(n,t,e),r.getAdapter(i)[n](r,t,e)}).then(function(i){return n=e.op="afterFindAll", | ||
wt(r[n](i,t,e)).then(function(t){return i=t||i,r.end(i,e)})})},afterFindAll:Ct,beforeSave:Ct,save:function(t,e){var n=void 0,i=this,r=i.get(t);return e||(e={}),m(i,e),e.adapter=i.getAdapterName(e),n=e.op="beforeSave",wt(i[n](r,e)).then(function(o){if(r=o||r,!r)throw new Error('instance with "'+i.idAttribute+'" of '+t+" not in Model's collection!");return n=e.op="save",i.dbg(n,t,e),r[n](e)}).then(function(t){return n=e.op="afterSave",wt(i[n](r,e)).then(function(){return t})})},afterSave:Ct,beforeUpdate:Ct,update:function(t,e,n){var i=void 0,r=void 0,o=this;return e||(e={}),n||(n={}),m(o,n),r=n.adapter=o.getAdapterName(n),i=n.op="beforeUpdate",wt(o[i](t,e,n)).then(function(a){e=a||e,i=n.op="update";var s=o.prototype.toJSON.call(e,n);return o.dbg(i,t,s,n),o.getAdapter(r)[i](o,t,s,n)}).then(function(e){return i=n.op="afterUpdate",wt(o[i](t,e,n)).then(function(t){return e=t||e,o.end(e,n)})})},afterUpdate:Ct,beforeUpdateMany:Ct,updateMany:function(t,e){var n=void 0,i=void 0,r=this;return t||(t=[]),e||(e={}),m(r,e),i=e.adapter=r.getAdapterName(e),n=e.op="beforeUpdateMany",wt(r[n](t,e)).then(function(o){t=o||t,n=e.op="updateMany";var a=t.map(function(t){return r.prototype.toJSON.call(t,e)});return r.dbg(n,a,e),r.getAdapter(i)[n](r,a,e)}).then(function(t){return n=e.op="afterUpdateMany",wt(r[n](t,e)).then(function(n){return t=n||t,r.end(t,e)})})},afterUpdateMany:Ct,beforeUpdateAll:Ct,updateAll:function(t,e,n){var i=void 0,r=void 0,o=this;return t||(t={}),e||(e={}),n||(n={}),m(o,n),r=n.adapter=o.getAdapterName(n),i=n.op="beforeUpdateAll",wt(o[i](t,e,n)).then(function(a){e=a||e,i=n.op="updateAll";var s=o.prototype.toJSON.call(e,n);return o.dbg(i,t,s,n),o.getAdapter(r)[i](o,t,s,n)}).then(function(e){return i=n.op="afterUpdateAll",wt(o[i](t,e,n)).then(function(t){return e=t||e,o.end(e,n)})})},afterUpdateAll:Ct,beforeDestroy:Ct,destroy:function(t,e){var n=void 0,i=void 0,r=this;return e||(e={}),m(r,e),i=e.adapter=r.getAdapterName(e),n=e.op="beforeDestroy",wt(r[n](t,e)).then(function(o){return t=void 0===o?t:o,n=e.op="destroy",r.dbg(n,t,e),r.getAdapter(i)[n](r,t,e)}).then(function(i){return n=e.op="afterDestroy",wt(r[n](i,e)).then(function(n){return i=n||i,e.raw?(e.autoEject&&(i.data=r.eject(t,e)),m(e,i),i):(e.autoEject&&(i=r.eject(t,e)),i)})})},afterDestroy:Ct,beforeDestroyAll:Ct,destroyAll:function(t,e){var n=void 0,i=void 0,r=this;return t||(t={}),e||(e={}),m(r,e),i=e.adapter=r.getAdapterName(e),n=e.op="beforeDestroyAll",wt(r[n](t,e)).then(function(o){return t=o||t,n=e.op="destroyAll",r.dbg(n,t,e),r.getAdapter(i)[n](r,t,e)}).then(function(i){return n=e.op="afterDestroyAll",wt(r[n](i,t,e)).then(function(n){return i=n||i,e.raw?(e.autoEject&&(i.data=r.ejectAll(t,e)),m(e,i),i):(e.autoEject&&(i=r.ejectAll(t,e)),i)})})},afterDestroyAll:Ct,beforeLoadRelations:Ct,loadRelations:function(t,e,n){var i=void 0,o=this,a=o.relationList||[],s=o.is(t)?t:void 0;return t=s?c(s,o.idAttribute):t,e||(e=[]),n||(n={}),m(o,n),n.adapter=o.getAdapterName(n),i=n.op="beforeLoadRelations",wt(o[i](t,e,n)).then(function(){if(l(t)&&!s&&(s=o.get(s)),!s)throw new Error("You passed an id of an instance not found in the collection of the Model!");return r(e)&&(e=[e]),i=n.op="loadRelations",o.dbg(i,s,e,n),Promise.all(a.map(function(e){if(u(e.load))return e.load(o,e,s,n);var i=void 0;if(e.foreignKey)i=e.Relation.findAll(it.defineProperty({},e.foreignKey,t),n);else if(e.localKey){var r=c(s,e.localKey);l(r)&&(i=e.Relation.find(r,n))}else e.localKeys?i=e.Relation.findAll(it.defineProperty({},e.Relation.idAttribute,{in:c(s,e.localKeys)}),n):e.foreignKeys&&(i=e.Relation.findAll(it.defineProperty({},e.Relation.idAttribute,{contains:c(s,o.idAttribute)}),n));return i&&(i=i.then(function(t){n.raw&&(t=t.data),d(s,e.localField,"hasOne"===e.type?t.length?t[0]:void 0:t)})),i}))}).then(function(){return i=n.op="afterLoadRelations",wt(o[i](s,e,n)).then(function(){return s})})},afterLoadRelations:Ct,log:function(t){for(var e=arguments.length,n=Array(e>1?e-1:0),i=1;e>i;i++)n[i-1]=arguments[i];if(t&&!n.length&&(n.push(t),t="debug"),"debug"!==t||this.debug){var r=t.toUpperCase()+": ("+this.name+")";if(console[t]){var o;(o=console)[t].apply(o,[r].concat(n))}else{var a;(a=console).log.apply(a,[r].concat(n))}}},dbg:function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];this.log.apply(this,["debug"].concat(e))},belongsTo:function(t,e){return B(t,e)(this)},hasMany:function(t,e){return H(t,e)(this)},hasOne:function(t,e){return Y(t,e)(this)},setSchema:function(t){return X(t)(this)},configure:function(t){return V(t)(this)},registerAdapter:function(t,e,n){return tt(t,e,n)(this)},extend:function(t,e){var n=this,i=void 0;n.dbg("extend","props:",t,"classProps:",e),t||(t={}),e||(e={});var r=t.initialize;if(delete t.initialize,t.hasOwnProperty("constructor"))i=t.constructor,delete t.constructor;else{if(!e.name)throw new TypeError("name: Expected string, found "+it.typeof(e.name)+"!");if(e.csp)i=function(){R(this,i);for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];var o=S(this,(i.__super__||Object.getPrototypeOf(i)).apply(this,e));return r&&r.apply(o,e),o};else{var o=O(e.name),a="return function "+o+"() {\n classCallCheck(this, "+o+")\n for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n var _this = possibleConstructorReturn(this, ("+o+".__super__ || Object.getPrototypeOf("+o+")).apply(this, args));\n if (initialize) {\n initialize.apply(_this, arguments)\n }\n return _this\n }";i=new Function("classCallCheck","possibleConstructorReturn","Parent","initialize",a)(R,S,n,r)}}e.shortname=e.shortname||k(i.name||e.name),delete e.name;var s=e.schema;return delete e.schema,i.prototype=Object.create(n&&n.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(i,n):e.strictEs6Class?i.__proto__=n:p(n,function(t,e){i[e]=t}),Object.defineProperty(i,"__super__",{configurable:!0,value:n}),V(t)(i.prototype),V(e)(i),s&&X(s)(i),i}}),E(et,function(){return this._events()},function(t){this._events(t)}),E(et.prototype,function(){return this._get("events")},function(t){this._set("events",t)}),F(nt.prototype,{clear:function(){var t={};return p(this.definitions,function(e){var n=e.name;t[n]=e.ejectAll()}),t},defineModel:function(t){var e=et.extend(t.methods||{},t);return this.definitions[e.name]=e,e}}),nt.prototype.defineResource=nt.prototype.defineModel,p(et,function(t,e){u(t)&&(nt.prototype[e]=function(t){var n;if(!this.definitions[t])throw new Error(t+" is not a registered Model!");for(var i=arguments.length,r=Array(i>1?i-1:0),o=1;i>o;o++)r[o-1]=arguments[o];return(n=this.definitions[t])[e].apply(n,r)})}),Promise.prototype.spread||(Promise.prototype.spread=function(t){return this.then(function(e){return t.apply(this,e)})});var Ot=ct,kt={full:"<%= pkg.version %>",major:parseInt("<%= major %>",10),minor:parseInt("<%= minor %>",10),patch:parseInt("<%= patch %>",10),alpha:"<%= alpha %>",beta:"<%= beta %>"};t.utils=Ot,t.version=kt,t.Collection=q,t.Query=P,t.DS=nt,t.belongsTo=B,t.configure=V,t.hasMany=H,t.hasOne=Y,t.setSchema=X,t.registerAdapter=tt,t.Model=et,t.rules=At,t.validate=Z}); | ||
wt(r[n](i,t,e)).then(function(t){return i=t||i,r.end(i,e)})})},afterFindAll:Ct,beforeSave:Ct,save:function(t,e){var n=void 0,i=this,r=i.get(t);return e||(e={}),m(i,e),e.adapter=i.getAdapterName(e),n=e.op="beforeSave",wt(i[n](r,e)).then(function(o){if(r=o||r,!r)throw new Error('instance with "'+i.idAttribute+'" of '+t+" not in Model's collection!");return n=e.op="save",i.dbg(n,t,e),r[n](e)}).then(function(t){return n=e.op="afterSave",wt(i[n](r,e)).then(function(){return t})})},afterSave:Ct,beforeUpdate:Ct,update:function(t,e,n){var i=void 0,r=void 0,o=this;return e||(e={}),n||(n={}),m(o,n),r=n.adapter=o.getAdapterName(n),i=n.op="beforeUpdate",wt(o[i](t,e,n)).then(function(a){e=a||e,i=n.op="update";var s=o.prototype.toJSON.call(e,n);return o.dbg(i,t,s,n),o.getAdapter(r)[i](o,t,s,n)}).then(function(e){return i=n.op="afterUpdate",wt(o[i](t,e,n)).then(function(t){return e=t||e,o.end(e,n)})})},afterUpdate:Ct,beforeUpdateMany:Ct,updateMany:function(t,e){var n=void 0,i=void 0,r=this;return t||(t=[]),e||(e={}),m(r,e),i=e.adapter=r.getAdapterName(e),n=e.op="beforeUpdateMany",wt(r[n](t,e)).then(function(o){t=o||t,n=e.op="updateMany";var a=t.map(function(t){return r.prototype.toJSON.call(t,e)});return r.dbg(n,a,e),r.getAdapter(i)[n](r,a,e)}).then(function(t){return n=e.op="afterUpdateMany",wt(r[n](t,e)).then(function(n){return t=n||t,r.end(t,e)})})},afterUpdateMany:Ct,beforeUpdateAll:Ct,updateAll:function(t,e,n){var i=void 0,r=void 0,o=this;return t||(t={}),e||(e={}),n||(n={}),m(o,n),r=n.adapter=o.getAdapterName(n),i=n.op="beforeUpdateAll",wt(o[i](t,e,n)).then(function(a){e=a||e,i=n.op="updateAll";var s=o.prototype.toJSON.call(e,n);return o.dbg(i,t,s,n),o.getAdapter(r)[i](o,t,s,n)}).then(function(e){return i=n.op="afterUpdateAll",wt(o[i](t,e,n)).then(function(t){return e=t||e,o.end(e,n)})})},afterUpdateAll:Ct,beforeDestroy:Ct,destroy:function(t,e){var n=void 0,i=void 0,r=this;return e||(e={}),m(r,e),i=e.adapter=r.getAdapterName(e),n=e.op="beforeDestroy",wt(r[n](t,e)).then(function(o){return t=void 0===o?t:o,n=e.op="destroy",r.dbg(n,t,e),r.getAdapter(i)[n](r,t,e)}).then(function(i){return n=e.op="afterDestroy",wt(r[n](i,e)).then(function(n){return i=n||i,e.raw?(e.autoEject&&(i.data=r.eject(t,e)),m(e,i),i):(e.autoEject&&(i=r.eject(t,e)),i)})})},afterDestroy:Ct,beforeDestroyAll:Ct,destroyAll:function(t,e){var n=void 0,i=void 0,r=this;return t||(t={}),e||(e={}),m(r,e),i=e.adapter=r.getAdapterName(e),n=e.op="beforeDestroyAll",wt(r[n](t,e)).then(function(o){return t=o||t,n=e.op="destroyAll",r.dbg(n,t,e),r.getAdapter(i)[n](r,t,e)}).then(function(i){return n=e.op="afterDestroyAll",wt(r[n](i,t,e)).then(function(n){return i=n||i,e.raw?(e.autoEject&&(i.data=r.ejectAll(t,e)),m(e,i),i):(e.autoEject&&(i=r.ejectAll(t,e)),i)})})},afterDestroyAll:Ct,beforeLoadRelations:Ct,loadRelations:function(t,e,n){var i=void 0,o=this,a=o.relationList||[],s=o.is(t)?t:void 0;return t=s?c(s,o.idAttribute):t,e||(e=[]),n||(n={}),m(o,n),n.adapter=o.getAdapterName(n),i=n.op="beforeLoadRelations",wt(o[i](t,e,n)).then(function(){if(l(t)&&!s&&(s=o.get(s)),!s)throw new Error("You passed an id of an instance not found in the collection of the Model!");return r(e)&&(e=[e]),i=n.op="loadRelations",o.dbg(i,s,e,n),Promise.all(a.map(function(e){if(u(e.load))return e.load(o,e,s,n);var i=void 0;if(e.foreignKey)i=e.Relation.findAll(it.defineProperty({},e.foreignKey,t),n);else if(e.localKey){var r=c(s,e.localKey);l(r)&&(i=e.Relation.find(r,n))}else e.localKeys?i=e.Relation.findAll(it.defineProperty({},e.Relation.idAttribute,{in:c(s,e.localKeys)}),n):e.foreignKeys&&(i=e.Relation.findAll(it.defineProperty({},e.Relation.idAttribute,{contains:c(s,o.idAttribute)}),n));return i&&(i=i.then(function(t){n.raw&&(t=t.data),d(s,e.localField,"hasOne"===e.type?t.length?t[0]:void 0:t)})),i}))}).then(function(){return i=n.op="afterLoadRelations",wt(o[i](s,e,n)).then(function(){return s})})},afterLoadRelations:Ct,log:function(t){for(var e=arguments.length,n=Array(e>1?e-1:0),i=1;e>i;i++)n[i-1]=arguments[i];if(t&&!n.length&&(n.push(t),t="debug"),"debug"!==t||this.debug){var r=t.toUpperCase()+": ("+this.name+")";if(console[t]){var o;(o=console)[t].apply(o,[r].concat(n))}else{var a;(a=console).log.apply(a,[r].concat(n))}}},dbg:function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];this.log.apply(this,["debug"].concat(e))},belongsTo:function(t,e){return B(t,e)(this)},hasMany:function(t,e){return H(t,e)(this)},hasOne:function(t,e){return Y(t,e)(this)},setSchema:function(t){return X(t)(this)},configure:function(t){return V(t)(this)},registerAdapter:function(t,e,n){return tt(t,e,n)(this)},extend:function(t,e){var n=this,i=void 0;n.dbg("extend","props:",t,"classProps:",e),t||(t={}),e||(e={});var r=t.initialize;if(delete t.initialize,t.hasOwnProperty("constructor"))i=t.constructor,delete t.constructor;else{if(!e.name)throw new TypeError("name: Expected string, found "+it.typeof(e.name)+"!");if(e.csp)i=function(){R(this,i);for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];var o=S(this,(i.__super__||Object.getPrototypeOf(i)).apply(this,e));return r&&r.apply(o,e),o};else{var o=O(e.name),a="return function "+o+"() {\n classCallCheck(this, "+o+")\n for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n var _this = possibleConstructorReturn(this, ("+o+".__super__ || Object.getPrototypeOf("+o+")).apply(this, args));\n if (initialize) {\n initialize.apply(_this, arguments)\n }\n return _this\n }";i=new Function("classCallCheck","possibleConstructorReturn","Parent","initialize",a)(R,S,n,r)}}e.shortname=e.shortname||k(i.name||e.name),delete e.name;var s=e.schema;return delete e.schema,i.prototype=Object.create(n&&n.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(i,n):e.strictEs6Class?i.__proto__=n:p(n,function(t,e){i[e]=t}),Object.defineProperty(i,"__super__",{configurable:!0,value:n}),V(t)(i.prototype),V(e)(i),s&&X(s)(i),i}}),E(et,function(){return this._events()},function(t){this._events(t)},!0),E(et.prototype,function(){return this._get("events")},function(t){this._set("events",t)}),F(nt.prototype,{clear:function(){var t={};return p(this.definitions,function(e){var n=e.name;t[n]=e.ejectAll()}),t},defineModel:function(t){var e=et.extend(t.methods||{},t);return this.definitions[e.name]=e,e}}),nt.prototype.defineResource=nt.prototype.defineModel,p(et,function(t,e){u(t)&&(nt.prototype[e]=function(t){var n;if(!this.definitions[t])throw new Error(t+" is not a registered Model!");for(var i=arguments.length,r=Array(i>1?i-1:0),o=1;i>o;o++)r[o-1]=arguments[o];return(n=this.definitions[t])[e].apply(n,r)})}),Promise.prototype.spread||(Promise.prototype.spread=function(t){return this.then(function(e){return t.apply(this,e)})});var Ot=ct,kt={full:"<%= pkg.version %>",major:parseInt("<%= major %>",10),minor:parseInt("<%= minor %>",10),patch:parseInt("<%= patch %>",10),alpha:"<%= alpha %>",beta:"<%= beta %>"};t.utils=Ot,t.version=kt,t.Collection=q,t.Query=P,t.DS=nt,t.belongsTo=B,t.configure=V,t.hasMany=H,t.hasOne=Y,t.setSchema=X,t.registerAdapter=tt,t.Model=et,t.rules=At,t.validate=Z}); | ||
//# sourceMappingURL=dist/js-data.min.map |
{ | ||
"name": "js-data", | ||
"description": "Robust, framework-agnostic in-memory data store.", | ||
"version": "3.0.0-alpha.6", | ||
"version": "3.0.0-alpha.7", | ||
"homepage": "http://www.js-data.io", | ||
@@ -6,0 +6,0 @@ "repository": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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
752208