Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

js-data

Package Overview
Dependencies
Maintainers
1
Versions
144
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-data - npm Package Compare versions

Comparing version 3.0.0-alpha.7 to 3.0.0-alpha.8

7

CHANGELOG.md

@@ -0,1 +1,8 @@

##### 3.0.0-alpha.8 - 09 January 2016
###### Breaking API changes
- The Model class is now stateless
- All stateful functionality has been moved to the Collection class
- The DS class no longer proxies Model methods.
##### 3.0.0-alpha.6 - 05 January 2016

@@ -2,0 +9,0 @@

6

dist/js-data.min.js
/*!
* js-data
* @version 3.0.0-alpha.7 - Homepage <http://www.js-data.io/>
* @version 3.0.0-alpha.8 - Homepage <http://www.js-data.io/>
* @author Jason Dobry <jason.dobry@gmail.com>

@@ -10,4 +10,4 @@ * @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)},!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});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.JSData={})}(this,function(e){"use strict";function t(e){return"[object Object]"===toString.call(e)||!1}function n(e){return!!e&&"object"===("undefined"==typeof e?"undefined":ie.typeof(e))&&e.constructor===Object}function r(e){return"[object RegExp]"===toString.call(e)||!1}function i(e){return"string"==typeof e||e&&"object"===("undefined"==typeof e?"undefined":ie.typeof(e))&&"[object String]"===toString.call(e)||!1}function o(e){return e&&"object"===("undefined"==typeof e?"undefined":ie.typeof(e))&&"[object Date]"===toString.call(e)||!1}function a(e){var t="undefined"==typeof e?"undefined":ie.typeof(e);return"number"===t||e&&"object"===t&&"[object Number]"===toString.call(e)||!1}function u(e){return"[object Boolean]"===toString.call(e)}function s(e){return"function"==typeof e||e&&"[object Function]"===toString.call(e)||!1}function l(e){return i(e)||a(e)}function f(e,t){if(t){for(var n=t.split("."),r=n.pop();t=n.shift();)if(e=e[t],null==e)return;return e[r]}}function c(e,t){for(var n=t.split("."),r=n.pop();t=n.shift();)if(e=e[t],null==e)return;e[r]=void 0,delete e[r]}function d(e,t){if(!t)return e;var n=t.split(".");return n.forEach(function(t){e[t]||(e[t]={}),e=e[t]}),e}function h(e,n,r){if(t(n))p(n,function(t,n){h(e,n,t)});else{var i=ae.exec(n);i?d(e,i[1])[i[2]]=r:e[n]=r}}function p(e,t,n){var r=Object.keys(e),i=r.length,o=void 0;for(o=0;i>o;o++)t.call(n,e[r[o]],r[o],e)}function v(e,t){return t&&p(t,function(e,t){var r=this[t];n(e)&&n(r)?v(r,e):this[t]=e},e),e}function g(e){return Promise.resolve(e)}function m(e){return Promise.reject(e)}function y(e,t){for(var n in e){var r=e[n];void 0===t[n]&&!s(r)&&n&&0!==n.indexOf("_")&&(t[n]=r)}}function b(e,t){if(!e||!t)return[];var n=[],r=void 0,i=void 0,o=e.length;for(i=0;o>i;i++)r=e[i],-1===n.indexOf(r)&&-1!==t.indexOf(r)&&n.push(r);return n}function A(e,t){p(t,function(t,n){void 0===e[n]&&(e[n]=t)})}function x(e,t){if(!t||!t.length)return!1;for(var n=void 0,r=0;r<t.length;r++)if("[object RegExp]"===Object.prototype.toString.call(t[r])&&t[r].test(e)||t[r]===e)return n=e;return!!n}function _(e){return i(e)?JSON.parse(e):e}function w(e,n,i,a,u){if(n){if(e===n)throw new Error("Cannot copy! Source and destination are identical.");if(i=i||[],a=a||[],t(e)){var s=i.indexOf(e);if(-1!==s)return a[s];i.push(e),a.push(n)}var l=void 0;if(oe(e)){var f=void 0;for(n.length=0,f=0;f<e.length;f++)l=w(e[f],null,i,a,u),t(e[f])&&(i.push(e[f]),a.push(l)),n.push(l)}else{oe(n)?n.length=0:p(n,function(e,t){delete n[t]});for(var c in e)if(e.hasOwnProperty(c)){if(x(c,u))continue;l=w(e[c],null,i,a,u),t(e[c])&&(i.push(e[c]),a.push(l)),n[c]=l}}}else n=e,e&&(oe(e)?n=w(e,[],i,a,u):o(e)?n=new Date(e.getTime()):r(e)?(n=new RegExp(e.source,e.toString().match(/[^\/]*$/)[0]),n.lastIndex=e.lastIndex):t(e)&&(n=w(e,Object.create(Object.getPrototypeOf(e)),i,a,u)));return n}function O(e,t,n){return""+t.toUpperCase()+n.toLowerCase()}function k(e){return e.replace(le,"").replace(fe,O)}function C(e){return e.split(se).map(k).join("")}function E(e){return e=C(e),e?e.charAt(0).toLowerCase()+e.slice(1):e}function R(e,t,n,r){e=e||this;var i={};t||n||(t=function(){return i},n=function(e){i=e}),Object.defineProperties(e,{on:{enumerable:!!r,value:function(e,r,i){t.call(this)||n.call(this,{});var o=t.call(this);o[e]=o[e]||[],o[e].push({f:r,c:i})}},off:{enumerable:!!r,value:function(e,r){var i=t.call(this),o=i[e];if(o)if(r){for(var a=0;a<o.length;a++)if(o[a].f===r){o.splice(a,1);break}}else o.splice(0,o.length);else n.call(this,{})}},emit:{enumerable:!!r,value:function(){for(var e=t.call(this)||{},n=arguments.length,r=Array(n),i=0;n>i;i++)r[i]=arguments[i];var o=r.shift(),a=e[o]||[],u=void 0;for(u=0;u<a.length;u++)a[u].f.apply(a[u].c,r);for(a=e.all||[],r.unshift(o),u=0;u<a.length;u++)a[u].f.apply(a[u].c,r)}}})}function I(e,t){for(t=e="";e++<36;t+=51*e&52?(15^e?8^Math.random()*(20^e?16:4):4).toString(16):"-");return t}function j(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function P(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==("undefined"==typeof t?"undefined":ie.typeof(t))&&"function"!=typeof t?e:t}function S(e,t){p(t,function(e,n){t[n]={value:e}}),Object.defineProperties(e,t)}function M(e,t){var n=this,r=void 0;return e||(e={}),t||(t={}),e.hasOwnProperty("constructor")?(r=e.constructor,delete e.constructor):r=function(){j(this,r);for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];var i=P(this,(r.__super__||Object.getPrototypeOf(r)).apply(this,t));return i},r.prototype=Object.create(n&&n.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(r,n):t.strictEs6Class?r.__proto__=n:p(n,function(e,t){r[t]=e}),Object.defineProperty(r,"__super__",{configurable:!0,value:n}),v(r.prototype,e),v(r,t),r}function F(e){j(this,F),this.collection=e,this.data=null}function N(e,t,n,r){var o=e[t],a=f(n,o[0]),u=f(r,o[0]);return a&&i(a)&&(a=a.toUpperCase()),u&&i(u)&&(u=u.toUpperCase()),n||(n=null),r||(r=null),"DESC"===o[1]?a>u?-1:u>a?1:t<e.length-1?N(e,t+1,n,r):0:u>a?-1:a>u?1:t<e.length-1?N(e,t+1,n,r):0}function D(e){return e.replace(he,"\\$1")}function L(e,t){return new RegExp("^"+D(e).replace(pe,".*").replace(ve,".")+"$",t)}function K(e,t,n){switch(t){case"==":return e==n;case"===":return e===n;case"!=":return e!=n;case"!==":return e!==n;case">":return e>n;case">=":return e>=n;case"<":return n>e;case"<=":return n>=e;case"isectEmpty":return!b(e||[],n||[]).length;case"isectNotEmpty":return b(e||[],n||[]).length;case"in":return-1!==n.indexOf(e);case"notIn":return-1===n.indexOf(e);case"contains":return-1!==(e||[]).indexOf(n);case"notContains":return-1===(e||[]).indexOf(n);default:if(0===t.indexOf("like"))return null!==L(n,t.substr(4)).exec(e);if(0===t.indexOf("notLike"))return null===L(n,t.substr(7)).exec(e)}}function U(e,t,n){return e===t?0:(n&&(e=n(e),t=n(t)),null===e&&null===t?0:null===e?-1:null===t?1:t>e?-1:e>t?1:0)}function T(e,t,n){return e.splice(t,0,n),e}function J(e,t){return e.splice(t,1),e}function q(e,t,n){for(var r=0,i=e.length,o=void 0,a=void 0;i>r;){if(a=(r+i)/2|0,o=U(t,e[a],n),0===o)return{found:!0,index:a};0>o?i=a:r=a+1}return{found:!1,index:i}}function z(e,t){if(j(this,z),e||(e=[]),!oe(e))throw new Error("fieldList must be an array.");t||(t={}),this.fieldList=e,this.fieldGetter=t.fieldGetter,this.hashCode=t.hashCode,this.isIndex=!0,this.keys=[],this.values=[]}function $(e,n){var r=this;j(r,$),t(e)&&!oe(e)&&(n=e,e=[]),e||(e=[]),n||(n={}),r.model=n.model,r.idAttribute=n.idAttribute,r._listeners={},this.onConflict=n.onConflict||"merge";var i=r.modelId();r.index=new z([i],{hashCode:function(e){return f(e,i)}}),r.indexes={},r.added={},r.autoPks={},r.createIndex("addedTimestamps",["$"],{fieldGetter:function(e){return r.added[f(e,i)]}}),e.forEach(function(e){r.index.insertRecord(e),e&&s(e.on)&&e.on("all",r._onModelEvent,r)})}function B(e,t,n){n||(n={});var r=n.localField=n.localField||t.name.toLowerCase(),i=n.foreignKey=n.localKey||n.foreignKey||t.name.toLowerCase()+"_id",o={enumerable:void 0!==n.enumerable?!!n.enumerable:!1,get:function(){return this._get("links."+r)},set:function(e){return this._set("links."+r,e),h(this,i,e[t.idAttribute]),f(this,r)}},a=o.get,u=o.set;return(n.link===!1||void 0===n.link&&!e.linkRelations)&&(delete o.get,delete o.set,o.writable=!0),n.get&&(o.get=function(){var r=this;return n.get(e,t,this,function(){return a.call(r)})},delete o.writable),n.set&&(o.set=function(r){var i=this;return n.set(e,t,this,r,function(e){return u.call(i,void 0===e?r:e)})},delete o.writable),o.get&&(o.set||(o.set=function(){})),Object.defineProperty(e.prototype,r,o),e.relationList||(e.relationList=[]),e.relationFields||(e.relationFields=[]),n.type="belongsTo",n.name=e.name,n.relation=t.name,n.Relation=t,e.relationList.push(n),e.relationFields.push(r),e}function V(e,t){return function(n){return n.dbg(me,"Model:",e,"opts:",t),B(n,e,t)}}function G(e){var t=arguments.length<=1||void 0===arguments[1]?!0:arguments[1];return e=e||{},function(n){return p(e,function(e,r){(void 0===n[r]||t)&&(n[r]=w(e))}),n}}function H(e,t,n){n||(n={});var r=n.localField=n.localField||E(t.name)+"_collection",i=n.foreignKey,o=n.localKeys,a=n.foreignKeys;i||o||a||(i=n.foreignKey=E(e.name)+"_id");var u={enumerable:void 0!==n.enumerable?!!n.enumerable:!1,get:function(){return this._get("links."+r)},set:function(n){var u=this;return this._set("links."+r,n),n&&n.length&&!function(){var r=f(u,e.idAttribute);i?n.forEach(function(e){h(e,i,r)}):o?!function(){var e=[];n.forEach(function(n){e.push(f(n,t.idAttribute))}),h(u,o,e)}():a&&n.forEach(function(e){var t=f(e,a);t?-1===t.indexOf(r)&&t.push(r):h(e,a,[r])})}(),f(this,r)}},s=u.get,l=u.set;return(n.link===!1||void 0===n.link&&!e.linkRelations)&&(delete u.get,delete u.set,u.writable=!0),n.get&&(u.get=function(){var r=this;return n.get(e,t,this,function(){return s.call(r)})}),n.set&&(u.set=function(r){var i=this;return n.set(e,t,this,r,function(e){return l.call(i,void 0===e?r:e)})}),Object.defineProperty(e.prototype,r,u),e.relationList||(e.relationList=[]),e.relationFields||(e.relationFields=[]),n.type="hasMany",n.name=e.name,n.relation=t.name,n.Relation=t,e.relationList.push(n),e.relationFields.push(r),e}function Q(e,t){return function(n){return n.dbg(ye,"Model:",e,"opts:",t),H(n,e,t)}}function Z(e,t,n){n||(n={});var r=n.localField=n.localField||E(t.name),i=n.foreignKey=n.foreignKey||E(e.name)+"Id",o={enumerable:void 0!==n.enumerable?!!n.enumerable:!1,get:function(){return this._get("links."+r)},set:function(t){return this._set("links."+r,t),h(t,i,f(this,e.idAttribute)),f(this,r)}};return(n.link===!1||void 0===n.link&&!e.linkRelations)&&(delete o.get,delete o.set),n.get&&!function(){var r=o.get;o.get=function(){var i=this;return n.get(e,t,this,r?function(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];return r.apply(i,t)}:void 0)}}(),n.set&&!function(){var r=o.set;o.set=function(i){var o=this;return n.set(e,t,this,i,r?function(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];return r.apply(o,t)}:void 0)}}(),Object.defineProperty(e.prototype,r,o),e.relationList||(e.relationList=[]),e.relationFields||(e.relationFields=[]),n.type="hasOne",n.name=e.name,n.relation=t.name,n.Relation=t,e.relationList.push(n),e.relationFields.push(r),e}function W(e,t){return function(n){return n.dbg(be,"Model:",e,"opts:",t),Z(n,e,t)}}function X(e,t){var n=[];return p(e,function(e,r){var i=xe[r];if(i){var o=i(e,t);o&&n.push(o)}}),n.length?n:void 0}function Y(e,t,n){var r={enumerable:void 0!==n.enumerable?n.enumerable:!0};return r.get=function(){return this._get("props."+t)},r.set=function(e){var r=this,i=this._get,o=this._set,a=this._unset;if(!i("noValidate")){var u=X(n,e);if(u)throw new Error(u.join(", "))}return n.track&&!i("creating")&&!function(){var n=i("changing"),u=i("previous."+t),s=i("props."+t),l=i("changed");n||(l=[]);var c=l.indexOf(t);s!==e&&-1===c&&l.push(t),u!==e?o("changes."+t,e):(a("changes."+t),c>=0&&l.splice(c,1)),l.length||(n=!1,a("changing"),a("changed"),i("eventId")&&(clearTimeout(i("eventId")),a("eventId"))),!n&&l.length&&(o("changed",l),o("changing",!0),o("eventId",setTimeout(function(){if(a("changed"),a("eventId"),a("changing"),!i("silent")){var e=void 0;for(e=0;e<l.length;e++)r.emit("change:"+l[e],r,f(r,l[e]));r.emit("change",r,i("changes"))}a("silent")},0)))}(),o("props."+t,e),e},n.get&&(r.get?!function(){var e=r.get;r.get=function(){return n.get.call(this,e)}}():r.get=n.get),n.set&&(r.set?!function(){var e=r.set;r.set=function(t){return n.set.call(this,t,e)}}():r.set=n.set),r}function ee(e){return e||(e={}),function(t){return t.dbg(_e,"opts:",e),t.schema||(t.schema={}),G(t.schema,e),p(e,function(e,n){var r=Y(t,n,e);r.writable||Object.defineProperty(t.prototype,n,r)}),t}}function te(e,t,n){return n||(n={}),n.op=we,function(r){r.dbg(we,"name:",e,"adapter:",t,"opts:",n),r.getAdapters()[e]=t,(n===!0||n.default)&&(r.defaultAdapter=e)}}function ne(e,t){var n=this;j(n,ne),e||(e={}),t||(t={});var r={};Object.defineProperties(n,{_get:{value:function(e){return f(r,e)}},_set:{value:function(e,t){return h(r,e,t)}},_unset:{value:function(e){return c(r,e)}}}),n._set("creating",!0),t.noValidate&&n._set("noValidate",!0),A(n,e),n._unset("creating"),n._set("changes",{}),n._unset("noValidate"),n._set("previous",w(e))}function re(e){var t=this;j(t,re),e||(e={}),t.defaults={};for(var n in e)t.defaults[n]=e[n];t.models={},t.collections={}}var ie={};ie.typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},ie.defineProperty=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e};var oe=Array.isArray,ae=/^(.+)\.(.+)$/,ue=JSON.stringify,se=/\s+/,le=/[^A-Za-z]/g,fe=/(\w)(\w*)/g,ce=Object.freeze({isArray:oe,isObject:t,isRegExp:r,isString:i,isDate:o,isNumber:a,isBoolean:u,isFunction:s,isSorN:l,get:f,unset:c,set:h,forOwn:p,deepMixIn:v,resolve:g,reject:m,_:y,intersection:b,fillIn:A,isBlacklisted:x,fromJson:_,toJson:ue,copy:w,pascalCase:C,camelCase:E,eventify:R,uuid:I,classCallCheck:j,possibleConstructorReturn:P,addHiddenPropsToTarget:S,extend:M}),de={skip:"",offset:"",where:"",limit:"",orderBy:"",sort:""},he=/([.*+?^=!:${}()|[\]\/\\])/g,pe=/%/g,ve=/_/g;S(F.prototype,{getData:function(){return this.data||(this.data=this.collection.index.getAll()),this.data},between:function(e,t,n){n||(n={});var r=this.collection,i=n.index?r.indexes[n.index]:r.index;if(this.data)throw new Error("Cannot access index after first operation!");return this.data=i.between(e,t,n),this},get:function(){var e=arguments.length<=0||void 0===arguments[0]?[]:arguments[0],t=arguments[1];if(t||(t={}),this.data)throw new Error("Cannot access index after first operation!");if(e&&!oe(e)&&(e=[e]),!e.length)return this.getData(),this;var n=this.collection,r=t.index?n.indexes[t.index]:n.index;return this.data=r.get(e),this},getAll:function(){var e=this,n={};if(this.data)throw new Error("Cannot access index after first operation!");for(var r=arguments.length,i=Array(r),o=0;r>o;o++)i[o]=arguments[o];if(!i.length||1===i.length&&t(i[0]))return this.getData(),this;i.length&&t(i[i.length-1])&&(n=i[i.length-1],i.pop());var a=this.collection,u=n.index?a.indexes[n.index]:a.index;return this.data=[],i.forEach(function(t){e.data=e.data.concat(u.get(t))}),this},filter:function(e,n){var r=this;return e||(e={}),this.getData(),t(e)?!function(){var n={};t(e.where)&&(n=e.where),p(e,function(e,t){t in de||t in n||(n[t]={"==":e})});var o=[],u=[],s=[];p(n,function(e,n){t(e)||(e={"==":e}),p(e,function(e,t){o.push(n),u.push(t),s.push(e)})}),o.length&&!function(){var e=void 0,t=o.length;r.data=r.data.filter(function(n){var r=!0,i=!0;for(e=0;t>e;e++){var a=u[e],l="|"===a.charAt(0);a=l?a.substr(1):a;var c=K(f(n,o[e]),a,s[e]);void 0!==c&&(i=r?c:l?i||c:i&&c),r=!1}return i})}();var l=e.orderBy||e.sort;i(l)&&(l=[[l,"ASC"]]),oe(l)||(l=null),l&&!function(){var e=0;l.forEach(function(e,t){i(e)&&(l[t]=[e,"ASC"])}),r.data.sort(function(t,n){return N(l,e,t,n)})}(),a(e.skip)?r.skip(e.skip):a(e.offset)&&r.skip(e.offset),a(e.limit)&&r.limit(e.limit)}():s(e)&&(this.data=this.data.filter(e,n)),this},skip:function(e){if(!a(e))throw new TypeError("skip: Expected number but found "+("undefined"==typeof e?"undefined":ie.typeof(e))+"!");var t=this.getData();return e<t.length?this.data=t.slice(e):this.data=[],this},limit:function(e){if(!a(e))throw new TypeError("limit: Expected number but found "+("undefined"==typeof e?"undefined":ie.typeof(e))+"!");var t=this.getData();return this.data=t.slice(0,Math.min(t.length,e)),this},forEach:function(e,t){return this.getData().forEach(e,t),this},map:function(e,t){return this.data=this.getData().map(e,t),this},mapCall:function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];return this.data=this.getData().map(function(t){return t[e].apply(t,n)}),this},run:function(){var e=this.data;return this.data=null,e}});var ge={">":1,">=":1,"<":1,"<=":1};S(z.prototype,{set:function(e,t){oe(e)||(e=[e]);var n=e.shift()||null,r=q(this.keys,n);if(0===e.length)if(r.found){var i=q(this.values[r.index],t,this.hashCode);i.found||T(this.values[r.index],i.index,t)}else T(this.keys,r.index,n),T(this.values,r.index,[t]);else if(r.found)this.values[r.index].set(e,t);else{T(this.keys,r.index,n);var o=new z([],{hashCode:this.hashCode});o.set(e,t),T(this.values,r.index,o)}},get:function(e){oe(e)||(e=[e]);var t=e.shift()||null,n=q(this.keys,t);return 0===e.length?n.found?this.values[n.index].isIndex?this.values[n.index].getAll():this.values[n.index]:[]:n.found?this.values[n.index].get(e):[]},getAll:function(){var e=[];return this.values.forEach(function(t){e=t.isIndex?e.concat(t.getAll()):e.concat(t)}),e},visitAll:function(e,t){this.values.forEach(function(n){n.isIndex?n.visitAll(e,t):n.forEach(e,t)})},query:function(e){var t=void 0,n=void 0;if(e[">"]?(t=e[">"],e.leftInclusive=!1):e[">="]&&(t=e[">="],e.leftInclusive=!0),e["<"]?(n=e["<"],e.rightInclusive=!1):e["<="]&&(n=e["<="],e.rightInclusive=!0),t.length!==n.length)throw new Error("Key arrays must be same length");var r={};return p(e,function(e,t){ge[t]||(r[t]=e)}),this.between(t,n,r)},between:function(e,t){var n=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];oe(e)||(e=[e]),oe(t)||(t=[t]),A(n,{leftInclusive:!0,rightInclusive:!1,limit:void 0,offset:0});var r=this._between(e,t,n);return n.limit?r.slice(n.offset,n.limit+n.offset):r.slice(n.offset)},_between:function(e,t,n){var r=[],i=e.shift(),o=t.shift(),a=void 0;if(a=void 0!==i?q(this.keys,i):{found:!1,index:0},0===e.length){a.found&&n.leftInclusive===!1&&(a.index+=1);for(var u=a.index;u<this.keys.length;u+=1){if(void 0!==o)if(n.rightInclusive){if(this.keys[u]>o)break}else if(this.keys[u]>=o)break;if(r=this.values[u].isIndex?r.concat(this.values[u].getAll()):r.concat(this.values[u]),n.limit&&r.length>=n.limit+n.offset)break}}else for(var u=a.index;u<this.keys.length;u+=1){var s=this.keys[u];if(s>o)break;if(r=this.values[u].isIndex?s===i?r.concat(this.values[u]._between(w(e),t.map(function(){}),n)):s===o?r.concat(this.values[u]._between(e.map(function(){}),w(t),n)):r.concat(this.values[u].getAll()):r.concat(this.values[u]),n.limit&&r.length>=n.limit+n.offset)break}return n.limit?r.slice(0,n.limit+n.offset):r},peek:function(){return this.values.length?this.values[0].isIndex?this.values[0].peek():this.values[0]:[]},remove:function(e,t){oe(e)||(e=[e]);var n=e.shift(),r=q(this.keys,n);if(0===e.length){if(r.found){var i=q(this.values[r.index],t,this.hashCode);i.found&&(J(this.values[r.index],i.index),0===this.values[r.index].length&&(J(this.keys,r.index),J(this.values,r.index)))}}else r.found&&this.values[r.index].delete(e,t)},clear:function(){this.keys=[],this.values=[]},insertRecord:function(e){var t=this.fieldList.map(function(t){return s(t)?t(e)||null:e[t]||null});this.set(t,e)},removeRecord:function(e){var t=this,n=void 0;return this.values.forEach(function(r,i){if(r.isIndex){if(r.removeRecord(e))return 0===r.keys.length&&(J(t.keys,i),J(t.values,i)),n=!0,!1}else{var o=q(r,e,t.hashCode);if(o.found)return J(r,o.index),0===r.length&&(J(t.keys,i),J(t.values,i)),n=!0,!1}}),n?e:void 0},updateRecord:function(e){this.removeRecord(e),this.insertRecord(e)}}),S($.prototype,{_onModelEvent:function(){this.emit.apply(this,arguments)},modelId:function(e){var t=this;return e?f(e,t.modelId()):t.model?t.model.idAttribute:t.idAttribute||"id"},createIndex:function(e,t,n){var r=this;i(e)&&void 0===t&&(t=[e]),n||(n={}),n.hashCode=n.hashCode||function(e){return r.modelId(e)};var o=r.indexes[e]=new z(t,n);return r.index.visitAll(o.insertRecord,o),r},getAutoPkItems:function(){var e=this;return e.getAll().filter(function(t){return e.autoPks[e.modelId(t)]})},query:function(){return new F(this)},between:function(e,t,n){return this.query().between(e,t,n).run()},get:function(e){var t=this.query().get(e).run();return t.length?t[0]:void 0},getAll:function(){var e;return(e=this.query()).getAll.apply(e,arguments).run()},filter:function(e,t){return this.query().filter(e,t).run()},skip:function(e){return this.query().skip(e).run()},limit:function(e){return this.query().limit(e).run()},forEach:function(e,t){this.index.visitAll(e,t)},reduce:function(e,t){var n=this.getAll();return n.reduce(e,t)},map:function(e,t){var n=[];return this.index.visitAll(function(r){n.push(e.call(t,r))}),n},beforeAdd:function(){},add:function(e,t){var n=this;t||(t={}),y(n,t),e=n.beforeAdd(e,t)||e;var r=!1,i=n.modelId(),o=[],a=(new Date).getTime();oe(e)||(e=[e],r=!0),e=e.map(function(e){var r=n.modelId(e),u=!1;if(!l(r)){if(!t.autoPk)throw new TypeError(i+": Expected string or number, found "+("undefined"==typeof r?"undefined":ie.typeof(r))+"!");r=I(),h(e,i,r),u=!0}var d=n.get(r);if(e===d)return d;if(o.forEach(function(t){var i=t.Relation,o=i.idAttribute,a=t.foreignKey,u=f(e,t.localField);if(s(t.insert))t.insert(n,t,e);else if(u&&t.insert!==!1)if(oe(u))u=u.map(function(e){if(e!==i.get(f(e,o)))try{a&&h(e,a,r),e=i.add(e)}catch(e){throw new Error("Failed to insert "+t.type+' relation: "'+t.relation+'"! '+e.message)}return e}),t.localKeys&&h(e,t.localKeys,u.map(function(e){return f(e,o)}));else if(u!==i.get(f(u,o)))try{t.foreignKey&&h(e,t.foreignKey,f(u,i.idAttribute)),a&&h(u,t.foreignKey,r),u=i.add(u)}catch(e){throw new Error("Failed to insert "+t.type+' relation: "'+t.relation+'"!')}t.link||void 0===t.link&&n.linkRelations?c(e,t.localField):h(e,t.localField,u)}),d){var g=t.onConflict||n.onConflict;"merge"===g?v(d,e):"replace"===g&&(p(d,function(t,n){n===i||e.hasOwnProperty(n)||delete d[n]}),d.set(e)),e=d,n.updateIndexes(e)}else e=n.model?n.model.createInstance(e):e,n.index.insertRecord(e),p(n.indexes,function(t,n){t.insertRecord(e)}),e&&s(e.on)&&(e.on("all",n._onModelEvent,n),n.emit("add",e));return n.added[r]=a,u&&(n.autoPks[r]=e),e});var u=r?e.length?e[0]:void 0:e;return n.afterAdd(u,t),u},afterAdd:function(){},beforeRemove:function(){},remove:function(e,t){var n=this;t||(t={}),n.beforeRemove(e,t);var r=n.get(e);return r&&(delete n.added[e],delete n.autoPks[e],n.index.removeRecord(r),p(n.indexes,function(e,t){e.removeRecord(r)}),r&&s(r.off)&&(r.off("all",n._onModelEvent,n),n.emit("remove",r))),n.afterRemove(r,t),r},afterRemove:function(){},beforeRemoveAll:function(){},removeAll:function(e,t){var n=this;t||(t={}),n.beforeRemoveAll(e,t);var r=n.filter(e);return r.forEach(function(e){n.remove(n.modelId(e))}),n.afterRemoveAll(r,e,t),r},afterRemoveAll:function(){},updateIndex:function(e,t){t||(t={});var n=t.index?this.indexes[t.index]:this.index;n.updateRecord(e)},updateIndexes:function(e){var t=this;t.index.updateRecord(e),p(t.indexes,function(t,n){t.updateRecord(e)})},mapCall:function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];var i=[];return this.index.visitAll(function(t){i.push(t[e].apply(t,n))}),i},toJSON:function(e){return this.mapCall("toJSON",e)},end:function(e,t){var n=this;return t.raw?(t.autoAdd&&(e.data=n.add(e.data,t)),e):(t.autoAdd&&(e=n.add(e,t)),e)},create:function(e,t){var n=this,r=n.modelId(e);return n.model.create(e,t).then(function(e){return n.autoPks[r]&&n.remove(r),n.end(e)})},createMany:function(e,t){var n=this;return n.model.createMany(e,t).then(function(t){return e.forEach(function(e){var t=n.modelId(e);n.autoPks[t]&&n.remove(t)}),n.end(t)})},find:function(e,t){var n=this;return n.model.find(e,t).then(function(e){return n.end(e)})},findAll:function(e,t){var n=this;return n.model.findAll(e,t).then(function(e){return n.end(e)})},update:function(e,t,n){var r=this;return r.model.update(e,t,n).then(function(e){return r.end(e)})},updateMany:function(e,t){var n=this;return n.model.updateMany(e,t).then(function(e){return n.end(e)})},updateAll:function(e,t,n){var r=this;return r.model.updateAll(e,t,n).then(function(e){return r.end(e)})},destroy:function(e,t){var n=this;return n.model.destroy(e,t).then(function(r){return t.raw?r.data=n.remove(e,t):r=n.remove(e,t),r})},destroyAll:function(e,t){var n=this;return n.model.destroyAll(e,t).then(function(r){return t.raw?r.data=n.removeAll(e,t):r=n.removeAll(e,t),r})}}),R($.prototype,function(){return this._listeners},function(e){this._listeners=e});var me="belongsTo",ye="hasMany",be="hasOne",Ae={array:oe,boolean:u,integer:a,number:a,null:function(e){return null===e},object:t,string:i},xe={type:function(e,t){if(void 0!==t){i(e)&&(e=[e]);var n=e.map(function(n){var r=Ae[n];return r?r(t)?void 0:1:"type: Unknown type "+e});return-1!==n.indexOf(void 0)?void 0:"type: Expected: "+e.join(" or ")+". Actual: "+("undefined"==typeof t?"undefined":ie.typeof(t))}},anyOf:function(e,t){var n=!1,r=[];return e.forEach(function(e){var i=X(e,t);i?r=r.concat(i):n=!0}),n?void 0:r},allOf:function(e,t){var n=[];return e.forEach(function(e){n=n.concat(X(e,t)||[])}),n.length?void 0:n},oneOf:function(e,t){var n=!1,r=[];return e.forEach(function(e){var i=X(e,t);if(i)r=r.concat(i);else{if(n)return r=["more than one schema validated"],n=!1,!1;n=!0}}),n?void 0:r}},_e="setSchema",we="registerAdapter",Oe=g,ke=function(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];var r=this,i=t.pop();r.dbg.apply(r,[i.op].concat(t)),(i.notify||void 0===i.notify&&r.notify)&&setTimeout(function(){r.emit.apply(r,[i.op].concat(t))})};S(ne.prototype,{schema:function(e){var t=this.constructor.schema;return e?t[e]:t},validate:function(e,t){var n=[],r=this.schema();if(e)if(i(e)){var o=r[e];o&&(n=X(o,t)||[])}else p(r,function(t,r){n=n.concat(X(t,f(e,r))||[])});else e=this;return n.length?n:void 0},create:function(e){return this.constructor.create(this,e)},beforeSave:function(){},save:function(e){var t=void 0,n=void 0,r=this,i=r.constructor;return e||(e={}),y(r,e),n=e.adapter=r.getAdapterName(e),t=e.op="beforeSave",Oe(r[t](e)).then(function(){return t=e.op="save",i.dbg(t,r,e),r.getAdapter(n)[t](i,r,e)}).then(function(n){return t=e.op="afterSave",Oe(r[t](n,e)).then(function(t){return n=t||n,e.raw?(r.set(n.data),n.data=r):r.set(n),i.end(n,e)})})},afterSave:function(){},beforeLoadRelations:function(){},loadRelations:function(e,t){var n=void 0,r=this,o=r.constructor,a=o.relationList||[];return e||(e=[]),t||(t={}),y(o,t),t.adapter=o.getAdapterName(t),n=t.op="beforeLoadRelations",Oe(r[n](e,t)).then(function(){return i(e)&&(e=[e]),n=t.op="loadRelations",o.dbg(n,r,e,t),Promise.all(a.map(function(e){if(s(e.load))return e.load(o,e,r,t);var n=void 0;if("hasMany"===e.type&&e.foreignKey)n=e.Relation.findAll(ie.defineProperty({},e.foreignKey,f(r,o.idAttribute)),t);else if(e.foreignKey){var i=f(r,e.foreignKey);l(i)&&(n=e.Relation.find(i,t))}else e.localKeys?n=e.Relation.findAll(ie.defineProperty({},e.Relation.idAttribute,{in:f(r,e.localKeys)}),t):e.foreignKeys&&(n=e.Relation.findAll(ie.defineProperty({},e.Relation.idAttribute,{contains:f(r,o.idAttribute)}),t));return n&&(n=n.then(function(n){t.raw&&(n=n.data),h(r,e.localField,"hasOne"===e.type?n.length?n[0]:void 0:n)})),n}))}).then(function(){return n=t.op="afterLoadRelations",Oe(r[n](e,t)).then(function(){return r})})},afterLoadRelations:function(){},destroy:function(e){var t=this.constructor;return t.destroy(f(this,t.idAttribute),e)},get:function(e){return f(this,e)},set:function(e,n,r){var i=this;t(e)&&(r=n),r||(r={}),r.silent&&i._set("silent",!0),h(i,e,n),i._get("eventId")||i._unset("silent")},unset:function(e,t){t||(t={}),t.silent&&this._set("silent",!0),c(this,e),this._get("eventId")||this._unset("silent")},hashCode:function(){return f(this,this.constructor.idAttribute)},changes:function(e){return e?this._get("changes."+e):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(e){return e?this._get("previous."+e):this._get("previous")},revert:function(e){var t=this,n=this._get("previous")||{};return e||(e={}),e.preserve||(e.preserve=[]),p(this,function(r,i){i!==t.constructor.idAttribute&&!n.hasOwnProperty(i)&&t.hasOwnProperty(i)&&-1===e.preserve.indexOf(i)&&delete t[i]}),p(n,function(n,r){-1===e.preserve.indexOf(r)&&(t[r]=n)}),this.commit(),this},toJSON:function(e){return this.constructor.toJSON(this,e)}}),A(ne,{_adapters:null,_adaptersOwner:null,_listeners:null,_listenersOwner:null,csp:!1,defaultAdapter:"http",debug:!1,idAttribute:"id",linkRelations:!0,notify:!0,pojo:!1,relationsEnumerable:!1,raw:!1,upsert:!0,_events:function(e){return e?this._listeners=e:this._listenersOwner!==this&&(this._listeners={},this._listenersOwner=this),this._listeners},end:function(e,t){var n=this;if(t.raw&&y(t,e),!t.pojo){var r=t.raw?e.data:e;r=oe(r)?r.map(function(e){return n.createInstance(e)}):n.createInstance(r),t.raw?e.data=r:e=r}return t.notify&&setTimeout(function(){n.emit(t.op,e,t)}),e},createInstance:function(e,t){var n=this;return e instanceof n?e:new n(e,t)},is:function(e,t){var n=this;return n.instanceClass&&!t?e instanceof n.instanceClass:e instanceof n},toJSON:function(e,t){var n=this;t||(t={});var r=e;if(n.is(e)){r={};for(var o in e)r[o]=e[o];n&&n.relationList&&t.with&&(i(t.with)&&(t.with=[t.with]),n.relationList.forEach(function(n){var i=void 0;-1!==t.with.indexOf(n.relation)?i=n.relation:-1!==t.with.indexOf(n.localField)&&(i=n.localField),i&&!function(){var o={with:t.with.slice()};o.with.splice(o.with.indexOf(i),1),o.with.forEach(function(e,t){e&&0===e.indexOf(i)&&e.length>=i.length&&"."===e[i.length]?o.with[t]=e.substr(i.length+1):o.with[t]=""});var a=f(e,n.localField);a&&(oe(a)?h(r,n.localField,a.map(function(e){return n.Relation.toJSON(e,o)})):h(r,n.localField,n.Relation.toJSON(a,o)))}()}))}return r},getAdapter:function(e){this.dbg("getAdapter","name:",e);var t=this.getAdapterName(e);if(!t)throw new ReferenceError(t+" not found!");return this.getAdapters()[t]},getAdapterName:function(e){return e||(e={}),i(e)&&(e={adapter:e}),e.adapter||e.defaultAdapter},getAdapters:function(){if(this._adaptersOwner!==this){var e=this._adapters;this._adapters={},e&&A(this._adapters,e),this._adaptersOwner=this}return this._adapters},beforeCreate:ke,checkUpsertCreate:function(e,t){var n=this;return(t.upsert||void 0===t.upsert&&n.upsert)&&f(e,n.idAttribute)},create:function(e,t){var n=void 0,r=void 0,i=this;return e||(e={}),t||(t={}),i.checkUpsertCreate(e,t)?i.update(f(e,i.idAttribute),e,t):(y(i,t),r=t.adapter=i.getAdapterName(t),n=t.op="beforeCreate",Oe(i[n](e,t)).then(function(o){e=o||e,n=t.op="create";var a=i.toJSON(e,t);return i.dbg(n,a,t),i.getAdapter(r)[n](i,a,t)}).then(function(e){return n=t.op="afterCreate",Oe(i[n](e,t)).then(function(n){return e=n||e,i.end(e,t)})}))},afterCreate:ke,beforeCreateMany:ke,checkUpsertCreateMany:function(e,t){var n=this;return t.upsert||void 0===t.upsert&&n.upsert?e.reduce(function(e,t){return e&&f(t,n.idAttribute)},!0):void 0},createMany:function(e,t){var n=void 0,r=void 0,i=this;return e||(e=[]),t||(t={}),i.checkUpsertCreateMany(e,t)?i.updateMany(e,t):(y(i,t),r=t.adapter=i.getAdapterName(t),n=t.op="beforeCreateMany",Oe(i[n](e,t)).then(function(o){e=o||e,n=t.op="createMany";var a=e.map(function(e){return i.toJSON(e,t)});return i.dbg(n,a,t),i.getAdapter(r)[n](i,a,t)}).then(function(e){return n=t.op="afterCreateMany",Oe(i[n](e,t)).then(function(n){return e=n||e,i.end(e,t)})}))},afterCreateMany:ke,beforeFind:ke,find:function(e,t){var n=void 0,r=void 0,i=this;return t||(t={}),y(i,t),r=t.adapter=i.getAdapterName(t),n=t.op="beforeFind",Oe(i[n](e,t)).then(function(o){return e=void 0===o?e:o,n=t.op="find",i.dbg(n,e,t),i.getAdapter(r)[n](i,e,t)}).then(function(e){return n=t.op="afterFind",Oe(i[n](e,t)).then(function(n){return e=n||e,i.end(e,t)})})},afterFind:ke,beforeFindAll:ke,findAll:function(e,t){var n=void 0,r=void 0,i=this;return e||(e={}),t||(t={}),y(i,t),r=t.adapter=i.getAdapterName(t),
n=t.op="beforeFindAll",Oe(i[n](e,t)).then(function(o){return e=o||e,n=t.op="findAll",i.dbg(n,e,t),i.getAdapter(r)[n](i,e,t)}).then(function(r){return n=t.op="afterFindAll",Oe(i[n](r,e,t)).then(function(e){return r=e||r,i.end(r,t)})})},afterFindAll:ke,beforeUpdate:ke,update:function(e,t,n){var r=void 0,i=void 0,o=this;return t||(t={}),n||(n={}),y(o,n),i=n.adapter=o.getAdapterName(n),r=n.op="beforeUpdate",Oe(o[r](e,t,n)).then(function(a){t=a||t,r=n.op="update";var u=o.toJSON(t,n);return o.dbg(r,e,u,n),o.getAdapter(i)[r](o,e,u,n)}).then(function(t){return r=n.op="afterUpdate",Oe(o[r](e,t,n)).then(function(e){return t=e||t,o.end(t,n)})})},afterUpdate:ke,beforeUpdateMany:ke,updateMany:function(e,t){var n=void 0,r=void 0,i=this;return e||(e=[]),t||(t={}),y(i,t),r=t.adapter=i.getAdapterName(t),n=t.op="beforeUpdateMany",Oe(i[n](e,t)).then(function(o){e=o||e,n=t.op="updateMany";var a=e.map(function(e){return i.toJSON(e,t)});return i.dbg(n,a,t),i.getAdapter(r)[n](i,a,t)}).then(function(e){return n=t.op="afterUpdateMany",Oe(i[n](e,t)).then(function(n){return e=n||e,i.end(e,t)})})},afterUpdateMany:ke,beforeUpdateAll:ke,updateAll:function(e,t,n){var r=void 0,i=void 0,o=this;return e||(e={}),t||(t={}),n||(n={}),y(o,n),i=n.adapter=o.getAdapterName(n),r=n.op="beforeUpdateAll",Oe(o[r](e,t,n)).then(function(a){t=a||t,r=n.op="updateAll";var u=o.toJSON(t,n);return o.dbg(r,e,u,n),o.getAdapter(i)[r](o,e,u,n)}).then(function(t){return r=n.op="afterUpdateAll",Oe(o[r](e,t,n)).then(function(e){return t=e||t,o.end(t,n)})})},afterUpdateAll:ke,beforeDestroy:ke,destroy:function(e,t){var n=void 0,r=void 0,i=this;return t||(t={}),y(i,t),r=t.adapter=i.getAdapterName(t),n=t.op="beforeDestroy",Oe(i[n](e,t)).then(function(o){return e=void 0===o?e:o,n=t.op="destroy",i.dbg(n,e,t),i.getAdapter(r)[n](i,e,t)}).then(function(e){return n=t.op="afterDestroy",Oe(i[n](e,t)).then(function(n){return e=n||e,t.raw?(y(t,e),e):e})})},afterDestroy:ke,beforeDestroyAll:ke,destroyAll:function(e,t){var n=void 0,r=void 0,i=this;return e||(e={}),t||(t={}),y(i,t),r=t.adapter=i.getAdapterName(t),n=t.op="beforeDestroyAll",Oe(i[n](e,t)).then(function(o){return e=o||e,n=t.op="destroyAll",i.dbg(n,e,t),i.getAdapter(r)[n](i,e,t)}).then(function(r){return n=t.op="afterDestroyAll",Oe(i[n](r,e,t)).then(function(e){return r=e||r,t.raw?(y(t,r),r):r})})},afterDestroyAll:ke,log:function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];if(e&&!n.length&&(n.push(e),e="debug"),"debug"!==e||this.debug){var i=e.toUpperCase()+": ("+this.name+")";if(console[e]){var o;(o=console)[e].apply(o,[i].concat(n))}else{var a;(a=console).log.apply(a,[i].concat(n))}}},dbg:function(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];this.log.apply(this,["debug"].concat(t))},belongsTo:function(e,t){return V(e,t)(this)},hasMany:function(e,t){return Q(e,t)(this)},hasOne:function(e,t){return W(e,t)(this)},setSchema:function(e){return ee(e)(this)},configure:function(e){return G(e)(this)},registerAdapter:function(e,t,n){return te(e,t,n)(this)},extend:function(e,t){var n=this,r=void 0;n.dbg("extend","props:",e,"classProps:",t),e||(e={}),t||(t={});var i=e.initialize;if(delete e.initialize,e.hasOwnProperty("constructor"))r=e.constructor,delete e.constructor;else{if(!t.name)throw new TypeError("name: Expected string, found "+ie.typeof(t.name)+"!");if(t.csp)r=function(){j(this,r);for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];var o=P(this,(r.__super__||Object.getPrototypeOf(r)).apply(this,t));return i&&i.apply(o,t),o};else{var o=C(t.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 }";r=new Function("classCallCheck","possibleConstructorReturn","Parent","initialize",a)(j,P,n,i)}}t.shortname=t.shortname||E(r.name||t.name),delete t.name;var u=t.schema;return delete t.schema,r.prototype=Object.create(n&&n.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(r,n):t.strictEs6Class?r.__proto__=n:p(n,function(e,t){r[t]=e}),Object.defineProperty(r,"__super__",{configurable:!0,value:n}),G(e)(r.prototype),G(t)(r),u&&ee(u)(r),r}}),R(ne,function(){return this._events()},function(e){this._events(e)},!0),R(ne.prototype,function(){return this._get("events")},function(e){this._set("events",e)}),S(re.prototype,{defineModel:function(e,n){var r=this;t(e)&&(n=e,e=n.name),n||(n={}),A(n,r.defaults);var i=n.methods||{};delete n.methods;var o=r.models[n.extends],a=(o||ne).extend(i,n);return r.models[e]=a,a.getModel=function(e){return r.models[e]},a},defineCollection:function(e,t,n){var r=this;t||(t={}),i(t.model)&&(t.model=r.models[e]);var o=new(n||$)([],t);return r.collection[e]=o,o},model:function(e){return this.models[e]},collection:function(e){return this.collections[e]},registerAdapter:function(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];p(this.models,function(e){e.registerAdapter.apply(e,t)})}}),re.prototype.defineResource=re.prototype.defineModel,Promise.prototype.spread||(Promise.prototype.spread=function(e){return this.then(function(t){return e.apply(this,t)})});var Ce=ce,Ee={full:"<%= pkg.version %>",major:parseInt("<%= major %>",10),minor:parseInt("<%= minor %>",10),patch:parseInt("<%= patch %>",10),alpha:"<%= alpha %>",beta:"<%= beta %>"};e.utils=Ce,e.version=Ee,e.Collection=$,e.Query=F,e.DS=re,e.belongsTo=V,e.configure=G,e.hasMany=Q,e.hasOne=W,e.setSchema=ee,e.registerAdapter=te,e.Model=ne,e.rules=xe,e.validate=X});
//# sourceMappingURL=dist/js-data.min.map
{
"name": "js-data",
"description": "Robust, framework-agnostic in-memory data store.",
"version": "3.0.0-alpha.7",
"version": "3.0.0-alpha.8",
"homepage": "http://www.js-data.io",

@@ -65,3 +65,3 @@ "repository": {

"devDependencies": {
"babel-core": "6.3.26",
"babel-core": "6.4.0",
"babel-eslint": "4.1.6",

@@ -68,0 +68,0 @@ "babel-plugin-syntax-async-functions": "6.3.13",

@@ -56,35 +56,32 @@ <img src="https://raw.githubusercontent.com/js-data/js-data/master/js-data.png" alt="js-data logo" title="js-data" align="right" width="96" height="96" />

```javascript
import {Model, registerAdapter} from 'js-data'
import {Collection, Model, registerAdapter} from 'js-data'
import DSHttpAdapter from 'js-data-http'
async function showExample() {
// "User" will use an http adapter by default
@registerAdapter('http', new DSHttpAdapter(), { default: true })
class User extends Model {}
// "User" will use an http adapter by default
@registerAdapter('http', new DSHttpAdapter(), { default: true })
class User extends Model {}
const UserCollection = new Collection({ model: User })
let user = await User.find(1)
let user = await UserCollection.find(1)
console.log(user) // { id: 1, name: 'John' }
console.log(user instanceof User) // true
console.log(user) // { id: 1, name: 'John' }
console.log(user instanceof User) // true
// The user instance is now stored in the User Model's collection
console.log(User.get(user.id)) // { id: 1, name: 'John' }
console.log(user === User.get(user.id)) // true
// The user instance is now stored in UserCollection
console.log(UserCollection.get(user.id)) // { id: 1, name: 'John' }
console.log(user === UserCollection.get(user.id)) // true
user.name = 'Johnny'
user.name = 'Johnny'
// PUT /user/1 {name:"Johnny"}
user = await user.save()
// PUT /user/1 {name:"Johnny"}
user = await user.save()
// The user instance has been updated
console.log(User.get(user.id)) // { id: 1, name: 'Johnny' }
console.log(user === User.get(user.id)) // true
// The user instance has been updated
console.log(UserCollection.get(user.id)) // { id: 1, name: 'Johnny' }
console.log(user === UserCollection.get(user.id)) // true
await user.destroy()
await user.destroy()
// The user instance no longer stored in User
console.log(User.get(1)) // undefined
}
showExample()
// The user instance no longer stored in UserCollection
console.log(UserCollection.get(1)) // undefined
```

@@ -95,36 +92,33 @@

```javascript
import {Model, registerAdapter} from 'js-data'
import {Collection, Model, registerAdapter} from 'js-data'
import DSHttpAdapter from 'js-data-http'
function* showExample() {
class User extends Model {}
class User extends Model {}
const UserCollection = new Collection({ model: User })
// "User" will use an http adapter by default
User.registerAdapter('http', new DSHttpAdapter(), { default: true })
// "User" will use an http adapter by default
User.registerAdapter('http', new DSHttpAdapter(), { default: true })
let user = yield User.find(1)
let user = yield UserCollection.find(1)
console.log(user) // { id: 1, name: 'John' }
console.log(user instanceof User) // true
console.log(user) // { id: 1, name: 'John' }
console.log(user instanceof User) // true
// The user instance is now stored in the User Model's collection
console.log(User.get(user.id)) // { id: 1, name: 'John' }
console.log(user === User.get(user.id)) // true
// The user instance is now stored in UserCollection
console.log(UserCollection.get(user.id)) // { id: 1, name: 'John' }
console.log(user === UserCollection.get(user.id)) // true
user.name = 'Johnny'
user.name = 'Johnny'
// PUT /user/1 {name:"Johnny"}
user = yield user.save()
// PUT /user/1 {name:"Johnny"}
user = yield user.save()
// The user instance has been updated
console.log(User.get(user.id)) // { id: 1, name: 'Johnny' }
console.log(user === User.get(user.id)) // true
// The user instance has been updated
console.log(UserCollection.get(user.id)) // { id: 1, name: 'Johnny' }
console.log(user === UserCollection.get(user.id)) // true
yield user.destroy()
yield user.destroy()
// The user instance no longer stored in User
console.log(User.get(1)) // undefined
}
showExample()
// The user instance no longer stored in UserCollection
console.log(UserCollection.get(1)) // undefined
```

@@ -136,2 +130,3 @@

var User = JSData.Model.extend({}, { name: 'User' })
var UserCollection = new JSData.Collection({ model: User })
// register and use http by default for async operations

@@ -141,3 +136,3 @@ User.registerAdapter('http', new DSHttpAdapter(), { default: true });

// Example CRUD operations with default configuration
User.find(1)
UserCollection.find(1)
.then(function (user) {

@@ -147,5 +142,5 @@ console.log(user) // { id: 1, name: 'John' }

// The user instance is now stored in the User Model's collection
console.log(User.get(user.id)) // { id: 1, name: 'John' }
console.log(user === User.get(user.id)) // true
// The user instance is now stored in UserCollection
console.log(UserCollection.get(user.id)) // { id: 1, name: 'John' }
console.log(user === UserCollection.get(user.id)) // true

@@ -159,4 +154,4 @@ user.name = 'Johnny'

// The user instance has been updated
console.log(User.get(user.id)) // { id: 1, name: 'Johnny' }
console.log(user === User.get(user.id)) // true
console.log(UserCollection.get(user.id)) // { id: 1, name: 'Johnny' }
console.log(user === UserCollection.get(user.id)) // true

@@ -167,4 +162,4 @@ // DELETE /user/1

.then(function () {
// The user instance no longer stored in User
console.log(User.get(1)) // undefined
// The user instance no longer stored in UserCollection
console.log(UserCollection.get(1)) // undefined
})

@@ -197,3 +192,3 @@ ```

### Dependencies
## Dependencies

@@ -208,3 +203,3 @@ JSData requires the presence of a `Promise` constructor in the global

### Documentation
## Documentation
- [Getting Started with js-data](http://www.js-data.io/docs/home)

@@ -227,3 +222,3 @@ - [Resources/Models](http://www.js-data.io/docs/resources)

### API Reference
## API Reference
- [DS](http://www.js-data.io/docs/ds)

@@ -243,17 +238,17 @@ - [Configuration Options](http://www.js-data.io/docs/dsdefaults)

### Support
## Support
Support questions are handled via [StackOverflow][so], [Slack][slack], and the
Support questions are handled via [Stack Overflow][so], [Slack][slack], and the
[Mailing List][ml]. Ask your questions there.
### Community
- [StackOverflow Channel][so]
- [Slack Chat][slack] [![Slack Status][sl_b]][slack]
## Community
- [StackOverflow][so]
- [Slack chat][slack] [![Slack Status][sl_b]][slack]
- [Announcements](http://www.js-data.io/blog)
- [Mailing List](ml)
- [Issues Tracker](https://github.com/js-data/js-data/issues)
- [Issue Tracker](https://github.com/js-data/js-data/issues)
- [GitHub](https://github.com/js-data/js-data)
- [Contributing Guide](https://github.com/js-data/js-data/blob/master/CONTRIBUTING.md)
### Contributing
## Contributing

@@ -285,3 +280,3 @@ When submitting bug reports or feature requests on GitHub, please include _as

### License
## License

@@ -288,0 +283,0 @@ The MIT License (MIT)

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc