Comparing version 3.0.0-alpha.2 to 3.0.0-alpha.3
@@ -0,1 +1,10 @@ | ||
##### 3.0.0-alpha.3 - 29 December 2015 | ||
- Implemented more methods from 2.x. | ||
- Better compatibility for the classes exposed by js-data. | ||
- Switched from Webpack to Rollup for a 7% smaller build | ||
(automatic tree-shaking) and built code that's simpler and easier to read. | ||
##### 3.0.0-alpha.2 - 22 December 2015 | ||
##### 3.0.0-alpha.1 - 12 December 2015 | ||
@@ -2,0 +11,0 @@ |
/*! | ||
* js-data | ||
* @version 3.0.0-alpha.2 - Homepage <http://www.js-data.io/> | ||
* @version 3.0.0-alpha.3 - Homepage <http://www.js-data.io/> | ||
* @author Jason Dobry <jason.dobry@gmail.com> | ||
@@ -10,4 +10,4 @@ * @copyright (c) 2014-2015 Jason Dobry | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.JSData=t():e.JSData=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}Object.defineProperty(t,"__esModule",{value:!0}),t.version=t.utils=void 0;var i=n(1),o=function(e){return"default"===e?"continue":void Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})};for(var a in i){o(a)}var u=n(14),s=function(e){return"default"===e?"continue":void Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})};for(var c in u){s(c)}var l=n(4),f=function(e){return"default"===e?"continue":void Object.defineProperty(t,e,{enumerable:!0,get:function(){return l[e]}})};for(var d in l){f(d)}var h=n(15),v=function(e){return"default"===e?"continue":void Object.defineProperty(t,e,{enumerable:!0,get:function(){return h[e]}})};for(var p in h){v(p)}var g=n(10),y=function(e){return"default"===e?"continue":void Object.defineProperty(t,e,{enumerable:!0,get:function(){return g[e]}})};for(var b in g){y(b)}var m=n(3),A=r(m);Promise.prototype.spread||(Promise.prototype.spread=function(e){return this.then(function(t){return e.apply(this,t)})});t.utils=A,t.version={full:"<%= pkg.version %>",major:parseInt("<%= major %>",10),minor:parseInt("<%= minor %>",10),patch:parseInt("<%= patch %>",10),alpha:"<%= alpha %>",beta:"<%= beta %>"}},function(e,t,n){"use strict";function r(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function i(){var e=this,t=arguments.length<=0||void 0===arguments[0]?[]:arguments[0],n=arguments.length<=1||void 0===arguments[1]?"id":arguments[1];if(!(0,a.isArray)(t))throw new TypeError("new Collection([data]): data: Expected array. Found "+("undefined"==typeof t?"undefined":r(t)));this.idAttribute=n,this.index=new s.Index([n],n),this.indexes={},t.forEach(function(t){e.index.insertRecord(t),t&&(0,a.isFunction)(t.on)&&t.on("all",e._onModelEvent,e)})}Object.defineProperty(t,"__esModule",{value:!0}),t.Collection=i;var o=n(2),a=n(3),u=n(4),s=n(12);t.Query=o.Query,(0,u.configure)({_onModelEvent:function(){this.emit.apply(this,arguments)},createIndex:function(e,t){(0,a.isString)(e)&&void 0===t&&(t=[e]);var n=this.indexes[e]=new s.Index(t,this.idAttribute);return this.index.visitAll(n.insertRecord,n),this},query:function(){return new o.Query(this)},between:function(){var e;return(e=this.query()).between.apply(e,arguments).run()},get:function(){var e;return(e=this.query()).get.apply(e,arguments).run()},getAll:function(){var e;return(e=this.query()).getAll.apply(e,arguments).run()},filter:function(e){return this.query().filter(e).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},insert:function(e){this.index.insertRecord(e),(0,a.forOwn)(this.indexes,function(t,n){t.insertRecord(e)}),e&&(0,a.isFunction)(e.on)&&e.on("all",this._onModelEvent,this)},update:function(e){this.index.updateRecord(e),(0,a.forOwn)(this.indexes,function(t,n){t.updateRecord(e)})},remove:function(e){this.index.removeRecord(e),(0,a.forOwn)(this.indexes,function(t,n){t.removeRecord(e)}),e&&(0,a.isFunction)(e.off)&&e.off("all",this._onModelEvent,this)},updateRecord:function(e,t){t||(t={});var n=t.index?this.indexes[t.index]:this.index;n.updateRecord(e)}})(i.prototype),(0,a.eventify)(i.prototype,function(){return this._events},function(e){this._events=e})},function(e,t,n){"use strict";function r(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function i(e){this.collection=e,this.data=null}function o(e,t,n,r){var i=e[t],a=(0,c.get)(n,i[0]),u=(0,c.get)(r,i[0]);return a&&(0,c.isString)(a)&&(a=a.toUpperCase()),u&&(0,c.isString)(u)&&(u=u.toUpperCase()),"DESC"===i[1]?a>u?-1:u>a?1:t<e.length-1?o(e,t+1,n,r):0:u>a?-1:a>u?1:t<e.length-1?o(e,t+1,n,r):0}function a(e){return e.replace(d,"\\$1")}function u(e,t){return new RegExp("^"+a(e).replace(h,".*").replace(v,".")+"$",t)}function s(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!(0,c.intersection)(e||[],n||[]).length;case"isectNotEmpty":return(0,c.intersection)(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!==u(n,t.substr(4)).exec(e);if(0===t.indexOf("notLike"))return null===u(n,t.substr(7)).exec(e)}}Object.defineProperty(t,"__esModule",{value:!0}),t.Query=i;var c=n(3),l=n(4),f={skip:"",offset:"",where:"",limit:"",orderBy:"",sort:""},d=/([.*+?^=!:${}()|[\]\/\\])/g,h=/%/g,v=/_/g;(0,l.configure)({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&&!(0,c.isArray)(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,t={};if(this.data)throw new Error("Cannot access index after first operation!");for(var n=arguments.length,r=Array(n),i=0;n>i;i++)r[i]=arguments[i];if(!r.length||1===r.length&&(0,c.isObject)(r[0]))return this.getData(),this;r.length&&(0,c.isObject)(r[r.length-1])&&(t=r[r.length-1],r.pop());var o=this.collection,a=t.index?o.indexes[t.index]:o.index;return this.data=[],r.forEach(function(t){e.data=e.data.concat(a.get(t))}),this},filter:function(e,t){var n=this;return e||(e={}),this.getData(),(0,c.isObject)(e)?!function(){var t={};(0,c.isObject)(e.where)&&(t=e.where),(0,c.forOwn)(e,function(e,n){n in f||n in t||(t[n]={"==":e})});var r=[],i=[],a=[];(0,c.forOwn)(t,function(e,t){(0,c.isObject)(e)||(e={"==":e}),(0,c.forOwn)(e,function(e,n){r.push(t),i.push(n),a.push(e)})}),r.length&&!function(){var e=void 0,t=r.length;n.data=n.data.filter(function(n){var o=!0,u=!0;for(e=0;t>e;e++){var l=i[e],f="|"===l.charAt(0);l=f?l.substr(1):l;var d=s((0,c.get)(n,r[e]),l,a[e]);void 0!==d&&(u=o?d:f?u||d:u&&d),o=!1}return u})}();var u=e.orderBy||e.sort;(0,c.isString)(u)&&(u=[[u,"ASC"]]),(0,c.isArray)(u)||(u=null),u&&!function(){var e=0;u.forEach(function(e,t){(0,c.isString)(e)&&(u[t]=[e,"ASC"])}),n.data.sort(function(t,n){return o(u,e,t,n)})}(),(0,c.isNumber)(e.skip)?n.skip(e.skip):(0,c.isNumber)(e.offset)&&n.skip(e.offset),(0,c.isNumber)(e.limit)&&n.limit(e.limit)}():(0,c.isFunction)(e)&&(this.data=this.data.filter(e,t)),this},skip:function(e){if(!(0,c.isNumber)(e))throw new TypeError("skip: Expected number but found "+("undefined"==typeof e?"undefined":r(e))+"!");var t=this.getData();return e<t.length?this.data=t.slice(e):this.data=[],this},limit:function(e){if(!(0,c.isNumber)(e))throw new TypeError("limit: Expected number but found "+("undefined"==typeof e?"undefined":r(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},run:function(){var e=this.data;return this.data=null,e}})(i.prototype)},function(e,t){"use strict";function n(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function r(e){return"[object Object]"===toString.call(e)||!1}function i(e){return!!e&&"object"===("undefined"==typeof e?"undefined":n(e))&&e.constructor===Object}function o(e){return"[object RegExp]"===toString.call(e)||!1}function a(e){return"string"==typeof e||e&&"object"===("undefined"==typeof e?"undefined":n(e))&&"[object String]"===toString.call(e)||!1}function u(e){return e&&"object"===("undefined"==typeof e?"undefined":n(e))&&"[object Date]"===toString.call(e)||!1}function s(e){var t="undefined"==typeof e?"undefined":n(e);return"number"===t||e&&"object"===t&&"[object Number]"===toString.call(e)||!1}function c(e){return"[object Boolean]"===toString.call(e)}function l(e){return"function"==typeof e||e&&"[object Function]"===toString.call(e)||!1}function f(e){return a(e)||s(e)}function d(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 h(e,t){for(var n=t.split("."),r=n.pop();t=n.shift();)if(e=e[t],null==e)return;delete e[r]}function v(e,t){if(!t)return e;var n=t.split(".");return n.forEach(function(t){e[t]||(e[t]={}),e=e[t]}),e}function p(e,t,n){if(r(t))g(t,function(t,n){p(e,n,t)});else{var i=I.exec(t);i?v(e,i[1])[i[2]]=n:e[t]=n}}function g(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 y(e,t){return t&&g(t,function(e,t){var n=this[t];i(e)&&i(n)?y(n,e):this[t]=e},e),e}function b(e){return Promise.resolve(e)}function m(e){return Promise.reject(e)}function A(e,t){for(var n in e){var r=e[n];void 0!==t[n]||l(r)||(t[n]=r)}}function x(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 k(e,t){g(t,function(t,n){void 0===e[n]&&(e[n]=t)})}function O(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 a(e)?JSON.parse(e):e}function w(e,t,n,i,a){if(t){if(e===t)throw new Error("Cannot copy! Source and destination are identical.");if(n=n||[],i=i||[],r(e)){var s=n.indexOf(e);if(-1!==s)return i[s];n.push(e),i.push(t)}var c=void 0;if(C(e)){var l=void 0;for(t.length=0,l=0;l<e.length;l++)c=w(e[l],null,n,i,a),r(e[l])&&(n.push(e[l]),i.push(c)),t.push(c)}else{C(t)?t.length=0:g(t,function(e,n){delete t[n]});for(var f in e)if(e.hasOwnProperty(f)){if(O(f,a))continue;c=w(e[f],null,n,i,a),r(e[f])&&(n.push(e[f]),i.push(c)),t[f]=c}}}else t=e,e&&(C(e)?t=w(e,[],n,i,a):u(e)?t=new Date(e.getTime()):o(e)?(t=new RegExp(e.source,e.toString().match(/[^\/]*$/)[0]),t.lastIndex=e.lastIndex):r(e)&&(t=w(e,Object.create(Object.getPrototypeOf(e)),n,i,a)));return t}function j(e,t,n){return""+t.toUpperCase()+n.toLowerCase()}function E(e){return e.replace(R,"").replace(N,j)}function S(e){return e.split(F).map(E).join("")}function P(e){return e=S(e),e?e.charAt(0).toLowerCase()+e.slice(1):e}function M(e,t,n){e=e||this;var r={};t||n||(t=function(){return r},n=function(e){r=e}),Object.defineProperties(e,{on:{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:{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:{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)}}})}Object.defineProperty(t,"__esModule",{value:!0}),t.isObject=r,t.isRegExp=o,t.isString=a,t.isDate=u,t.isNumber=s,t.isBoolean=c,t.isFunction=l,t.isSorN=f,t.get=d,t.unset=h,t.set=p,t.forOwn=g,t.deepMixIn=y,t.resolve=b,t.reject=m,t._=A,t.intersection=x,t.fillIn=k,t.isBlacklisted=O,t.fromJson=_,t.copy=w,t.pascalCase=S,t.camelCase=P,t.eventify=M;var C=t.isArray=Array.isArray,I=/^(.+)\.(.+)$/,F=(t.toJson=JSON.stringify,/\s+/),R=/[^A-Za-z]/g,N=/(\w)(\w*)/g},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(5),i=function(e){return"default"===e?"continue":void Object.defineProperty(t,e,{enumerable:!0,get:function(){return r[e]}})};for(var o in r){i(o)}var a=n(6),u=function(e){return"default"===e?"continue":void Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})};for(var s in a){u(s)}var c=n(7),l=function(e){return"default"===e?"continue":void Object.defineProperty(t,e,{enumerable:!0,get:function(){return c[e]}})};for(var f in c){l(f)}var d=n(8),h=function(e){return"default"===e?"continue":void Object.defineProperty(t,e,{enumerable:!0,get:function(){return d[e]}})};for(var v in d){h(v)}var p=n(9),g=function(e){return"default"===e?"continue":void Object.defineProperty(t,e,{enumerable:!0,get:function(){return p[e]}})};for(var y in p){g(y)}var b=n(11),m=function(e){return"default"===e?"continue":void Object.defineProperty(t,e,{enumerable:!0,get:function(){return b[e]}})};for(var A in b){m(A)}t.DECORATORS="FIXME"},function(e,t,n){"use strict";function r(e,t,n){n||(n={});var r=n.localField=n.localField||t.name.toLowerCase(),o=n.localKey=n.localKey||t.name.toLowerCase()+"_id",a={enumerable:void 0!==n.enumerable?!!n.enumerable:!1,get:function(){if(!this._get("$"))return this._get("links."+r);var e=(0,i.get)(this,o),n=void 0!==e?t.get(e):void 0;return this._set("links."+r,n),n},set:function(e){return this._set("links."+r,e),(0,i.set)(this,o,e[t.idAttribute]),(0,i.get)(this,r)}};return(n.link===!1||void 0===n.link&&!e.linkRelations)&&(delete a.get,delete a.set,a.writable=!0),n.get&&!function(){var r=a.get;a.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=a.set;a.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,a),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.collection.createIndex(o),e}var i=n(3),o="belongsTo";t.belongsTo=function(e,t){return function(n){return n.dbg(o,"Model:",e,"opts:",t),r(n,e,t)}}},function(e,t,n){"use strict";function r(e){var t=arguments.length<=1||void 0===arguments[1]?!0:arguments[1];return e=e||{},function(n){return(0,i.forOwn)(e,function(e,r){(void 0===n[r]||t)&&(n[r]=(0,i.copy)(e))}),n}}Object.defineProperty(t,"__esModule",{value:!0}),t.configure=r;var i=n(3)},function(e,t,n){"use strict";function r(e,t,n){n||(n={});var r=n.localField||(0,o.camelCase)(t.name)+"Collection",i=n.foreignKey,a=n.localKeys,u=n.foreignKeys;i||a||u||(i=n.foreignKey=(0,o.camelCase)(e.name)+"Id"),i&&t.collection.createIndex(i);var s={enumerable:void 0!==n.enumerable?!!n.enumerable:!1,get:function(){if(!this._get("$"))return this._get("links."+r);var n={},s=void 0;if(i)s=t.getAll((0,o.get)(this,e.idAttribute),{index:i});else if(a){var c=(0,o.get)(this,a)||[],l=(0,o.isArray)(c)?c:Object.keys(c);s=t.getAll.apply(t,l)}else u&&((0,o.set)(n,"where."+u+".contains",(0,o.get)(this,e.idAttribute)),s=t.filter(n));return this._set("links."+r,s),s},set:function(n){var s=this;return this._set("links."+r,n),n&&n.length&&!function(){var r=(0,o.get)(s,e.idAttribute);i?n.forEach(function(e){(0,o.set)(e,i,r)}):a?!function(){var e=[];n.forEach(function(n){e.push((0,o.get)(n,t.idAttribute))}),(0,o.set)(s,a,e)}():u&&n.forEach(function(e){var t=(0,o.get)(e,u);t?-1===t.indexOf(r)&&t.push(r):(0,o.set)(e,u,[r])})}(),(0,o.get)(this,r)}};return(n.link===!1||void 0===n.link&&!e.linkRelations)&&(delete s.get,delete s.set,s.writable=!0),n.get&&!function(){var r=s.get;s.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=s.set;s.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,s),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 i(e,t){return function(n){return n.dbg(a,"Model:",e,"opts:",t),r(n,e,t)}}Object.defineProperty(t,"__esModule",{value:!0}),t.hasMany=i;var o=n(3),a="hasMany"},function(e,t,n){"use strict";function r(e,t,n){n||(n={});var r=n.localField=n.localField||(0,o.camelCase)(t.name),i=n.foreignKey=n.foreignKey||(0,o.camelCase)(e.name)+"Id",a={enumerable:void 0!==n.enumerable?!!n.enumerable:!1,get:function(){if(!this._get("$"))return this._get("links."+r);var n=t.getAll((0,o.get)(this,e.idAttribute),{index:i}),a=n&&n.length?n[0]:void 0;return this._set("links."+r,a),a},set:function(t){return this._set("links."+r,t),(0,o.set)(t,i,(0,o.get)(this,e.idAttribute)),(0,o.get)(this,r)}};return(n.link===!1||void 0===n.link&&!e.linkRelations)&&(delete a.get,delete a.set),n.get&&!function(){var r=a.get;a.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=a.set;a.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,a),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.collection.createIndex(i),e}function i(e,t){return function(n){return n.dbg(a,"Model:",e,"opts:",t),r(n,e,t)}}Object.defineProperty(t,"__esModule",{value:!0}),t.hasOne=i;var o=n(3),a="hasOne"},function(e,t,n){"use strict";function r(e,t,n){var r={enumerable:void 0!==n.enumerable?n.enumerable:!0,configurable:void 0!==n.configurable?n.configurable:!0};return r.get=function(){return this._get("props."+t)},r.set=function(r){var i=this,u=this._get,s=this._set,c=this._unset;if(!u("noValidate")){var l=(0,a.validate)(n,r);if(l)throw new Error(l.join(", "))}return n.track&&!u("creating")&&!function(){var e=u("changing"),n=u("previous."+t),a=u("props."+t),l=u("changed");e||(l=[]),a!==r&&l.push(t),n!==r?s("changes."+t,r):c("changes."+t),!e&&l.length&&(s("changed",l),s("changing",!0),s("eventId",setTimeout(function(){c("changed"),c("eventId"),c("changing");var e=void 0;for(e=0;e<l.length;e++)i.emit("change:"+l[e],i,(0,o.get)(i,l[e]));i.emit("change",i,u("changes"))},0)))}(),s("props."+t,r),u("$")&&n.indexed&&e.collection.updateRecord(this,{index:t}),r},n.indexed&&e.createIndex(t),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 i(e){return e||(e={}),function(t){return t.dbg(s,"opts:",e),t.schema||(t.schema={}),(0,u.configure)(t.schema,e),(0,o.forOwn)(e,function(e,n){var i=r(t,n,e);i.writable||Object.defineProperty(t.prototype,n,i)}),t}}Object.defineProperty(t,"__esModule",{value:!0}),t.setSchema=i;var o=n(3),a=n(10),u=n(6),s="setSchema"},function(e,t,n){"use strict";function r(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function i(e,t){var n=[];return(0,o.forOwn)(e,function(e,r){var i=u[r];if(i){var o=i(e,t);o&&n.push(o)}}),n.length?n:void 0}Object.defineProperty(t,"__esModule",{value:!0}),t.rules=void 0,t.validate=i;var o=n(3),a={array:o.isArray,boolean:o.isBoolean,integer:o.isNumber,number:o.isNumber,null:function(e){return null===e},object:o.isObject,string:o.isString},u=t.rules={type:function(e,t){if(void 0!==t){(0,o.isString)(e)&&(e=[e]);var n=e.map(function(n){var r=a[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":r(t))}},anyOf:function(e,t){var n=!1,r=[];return e.forEach(function(e){var o=i(e,t);o?r=r.concat(o):n=!0}),n?void 0:r},allOf:function(e,t){var n=[];return e.forEach(function(e){n=n.concat(i(e,t)||[])}),n.length?void 0:n},oneOf:function(e,t){var n=!1,r=[];return e.forEach(function(e){var o=i(e,t);if(o)r=r.concat(o);else{if(n)return r=["more than one schema validated"],n=!1,!1;n=!0}}),n?void 0:r}}},function(e,t){"use strict";function n(e,t,n){return n||(n={}),n.op=r,function(i){i.dbg(r,"name:",e,"adapter:",t,"opts:",n),i.adapters[e]=t,(n===!0||n.default)&&(i.defaultAdapter=e)}}Object.defineProperty(t,"__esModule",{value:!0}),t.registerAdapter=n;var r="registerAdapter"},function(e,t,n){"use strict";function r(){var e=arguments.length<=0||void 0===arguments[0]?[]:arguments[0],t=arguments[1];if(!(0,i.isArray)(e))throw new Error("fieldList must be an array.");this.fieldList=e,this.idAttribute=t,this.isIndex=!0,this.keys=[],this.values=[]}Object.defineProperty(t,"__esModule",{value:!0}),t.Index=r;var i=n(3),o=n(4),a=n(13);(0,o.configure)({set:function(e,t){(0,i.isArray)(e)||(e=[e]);var n=e.shift()||null,o=(0,a.binarySearch)(this.keys,n);if(0===e.length)if(o.found){var u=(0,a.binarySearch)(this.values[o.index],t,this.idAttribute);u.found||(0,a.insertAt)(this.values[o.index],u.index,t)}else(0,a.insertAt)(this.keys,o.index,n),(0,a.insertAt)(this.values,o.index,[t]);else if(o.found)this.values[o.index].set(e,t);else{(0,a.insertAt)(this.keys,o.index,n);var s=new r([],this.idAttribute);s.set(e,t),(0,a.insertAt)(this.values,o.index,s)}},get:function(e){(0,i.isArray)(e)||(e=[e]);var t=e.shift()||null,n=(0,a.binarySearch)(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");return this.between(t,n,(0,i.omit)(e,[">",">=","<","<="]))},between:function(e,t){var n=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];(0,i.isArray)(e)||(e=[e]),(0,i.isArray)(t)||(t=[t]),(0,i.fillIn)(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=[],o=e.shift(),u=t.shift(),s=void 0;if(s=void 0!==o?(0,a.binarySearch)(this.keys,o):{found:!1,index:0},0===e.length){s.found&&n.leftInclusive===!1&&(s.index+=1);for(var c=s.index;c<this.keys.length;c+=1){if(void 0!==u)if(n.rightInclusive){if(this.keys[c]>u)break}else if(this.keys[c]>=u)break;if(r=this.values[c].isIndex?r.concat(this.values[c].getAll()):r.concat(this.values[c]),n.limit&&r.length>=n.limit+n.offset)break}}else for(var c=s.index;c<this.keys.length;c+=1){var l=this.keys[c];if(l>u)break;if(r=this.values[c].isIndex?l===o?r.concat(this.values[c]._between((0,i.copy)(e),t.map(function(){}),n)):l===u?r.concat(this.values[c]._between(e.map(function(){}),(0,i.copy)(t),n)):r.concat(this.values[c].getAll()):r.concat(this.values[c]),n.limit&&r.length>=n.limit+n.offset)break}return n.limit?r.slice(0,n.limit+n.offset):r},remove:function(e,t){(0,i.isArray)(e)||(e=[e]);var n=e.shift(),r=(0,a.binarySearch)(this.keys,n);if(0===e.length){if(r.found){var o=(0,a.binarySearch)(this.values[r.index],t,this.idAttribute);o.found&&((0,a.removeAt)(this.values[r.index],o.index),0===this.values[r.index].length&&((0,a.removeAt)(this.keys,r.index),(0,a.removeAt)(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 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&&((0,a.removeAt)(t.keys,i),(0,a.removeAt)(t.values,i)),n=!0,!1}else{var o=(0,a.binarySearch)(r,e,t.idAttribute);if(o.found)return(0,a.removeAt)(r,o.index),0===r.length&&((0,a.removeAt)(t.keys,i),(0,a.removeAt)(t.values,i)),n=!0,!1}}),n?e:void 0},updateRecord:function(e){this.removeRecord(e),this.insertRecord(e)}})(r.prototype)},function(e,t){"use strict";function n(e,t,n){return e===t?0:(n&&(e=e[n],t=t[n]),null===e&&null===t?0:null===e?-1:null===t?1:t>e?-1:e>t?1:0)}function r(e,t,n){return e.splice(t,0,n),e}function i(e,t){return e.splice(t,1),e}function o(e,t,r){for(var i=0,o=e.length,a=void 0,u=void 0;o>i;){if(u=(i+o)/2|0,a=n(t,e[u],r),0===a)return{found:!0,index:u};0>a?o=u:i=u+1}return{found:!1,index:o}}Object.defineProperty(t,"__esModule",{value:!0}),t.sort=n,t.insertAt=r,t.removeAt=i,t.binarySearch=o},function(e,t,n){"use strict";function r(e){e||(e={}),this.definitions={}}Object.defineProperty(t,"__esModule",{value:!0}),t.DS=r;var i=n(4),o=n(3),a=n(15);(0,i.configure)({clear:function(){var e={};return(0,o.forOwn)(this.definitions,function(t){var n=t.name;e[n]=t.ejectAll()}),e},defineModel:function(e){var t=a.Model.extend(e.methods||{},e);return this.definitions[t.name]=t,t}})(r.prototype),r.prototype.defineResource=r.prototype.defineModel,(0,o.forOwn)(a.Model,function(e,t){(0,o.isFunction)(e)&&(r.prototype[t]=function(e){var n;if(!this.definitions[e])throw new Error(e+" is not a registered Model!");for(var r=arguments.length,i=Array(r>1?r-1:0),o=1;r>o;o++)i[o-1]=arguments[o];return(n=this.definitions[e])[t].apply(n,i)})})},function(e,t,n){"use strict";function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function i(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var s=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();Object.defineProperty(t,"__esModule",{value:!0}),t.Model=void 0;var c=n(3),l=r(c),f=n(4),d=n(1),h=n(10),v=r(h),p=l.resolve,g=!1;try{g=!!window}catch(e){}var y=function(e,t,n,r){return n.raw?(t.adapter=r,n.autoInject&&(t.data=e.inject(t.data)),t):(n.autoInject&&(t=e.inject(t)),t)},b=function e(){u(this,e)},m=t.Model=function(e){function t(e,n){u(this,t);var r=o(this,Object.getPrototypeOf(t).call(this));e||(e={}),n||(n={});var i={};return Object.defineProperties(r,{_get:{value:function(e){return l.get(i,e)}},_set:{value:function(e,t,r){return l.set(i,e,t,n)}},_unset:{value:function(e){return l.unset(i,e)}}}),r._set("creating",!0),n.noValidate&&r._set("noValidate",!0),l.fillIn(r,e),r._unset("creating"),r._unset("noValidate"),r._set("previous",l.copy(e)),r}return a(t,e),s(t,[{key:"schema",value:function(e){var t=this.constructor.schema;return e?t[e]:t}},{key:"validate",value:function(e,t){var n=[],r=this.schema();if(e)if(l.isString(e)){var i=r[e];i&&(n=v.validate(i,t)||[])}else l.forOwn(r,function(t,r){n=n.concat(v.validate(t,l.get(e,r))||[])});else e=this;return n.length?n:void 0}},{key:"create",value:function(e){return this.constructor.create(this,e)}},{key:"save",value:function(e){var t=this.constructor,n=t.getAdapterName(e);return t.getAdapter(n).update(t,l.get(this,t.idAttribute),this,e)}},{key:"destroy",value:function(e){var t=this.constructor;return t.destroy(l.get(this,t.idAttribute),e)}},{key:"get",value:function(e){return l.get(this,e)}},{key:"set",value:function(e,t,n){return n||(n={}),l.set(this,e,t)}},{key:"toJSON",value:function(e){var n=this;e||(e={});var r=this.constructor,i=this;return this instanceof t&&(i={},l.set(i,this),r&&r.relationList&&e.with&&(l.isString(e.with)&&(e.with=[e.with]),r.relationList.forEach(function(t){var r=void 0;-1!==e.with.indexOf(t.relation)?r=t.relation:-1!==e.with.indexOf(t.localField)&&(r=t.localField),r&&!function(){var o={with:e.with.slice()};o.with.splice(o.with.indexOf(r),1),o.with.forEach(function(e,t){e&&0===e.indexOf(r)&&e.length>=r.length&&"."===e[r.length]?o.with[t]=e.substr(r.length+1):o.with[t]=""});var a=l.get(n,t.localField);a&&(l.isArray(a)?l.set(i,t.localField,a.map(function(e){return t.Relation.prototype.toJSON.call(e,o)})):l.set(i,t.localField,t.Relation.prototype.toJSON.call(a,o)))}()}))),i}}],[{key:"createIndex",value:function(e,t){this.dbg("createIndex","name:",e,"keyList:",t),this.collection.createIndex(e,t)}},{key:"createInstance",value:function(e){var t=this;return e instanceof t?e:new t(e)}},{key:"is",value:function(e){return e instanceof this}},{key:"inject",value:function(e,t){var n=this,r="inject";n.dbg(r,"item(s):",e,"opts:",t),t||(t={}),t.op=r;var o=!1,a=n.collection,u=n.idAttribute,s=n.relationList||[];return l.isArray(e)||(e=[e],o=!0),e=e.map(function(e){var r=l.get(e,u);if(!l.isSorN(r))throw new TypeError("User#"+u+": Expected string or number, found "+("undefined"==typeof r?"undefined":i(r))+"!");var o=n.get(r);if(e===o)return o;if(s.forEach(function(t){var i=t.Relation,o=i.idAttribute,a=t.foreignKey,s=l.get(e,t.localField);if(l.isFunction(t.inject))t.inject(n,t,e);else if(s&&t.inject!==!1)if(l.isArray(s))s=s.map(function(e){if(e!==i.get(l.get(e,o)))try{a&&l.set(e,a,r),e=i.inject(e)}catch(e){throw new Error("Failed to inject "+t.type+' relation: "'+t.relation+'"! '+e.message)}return e}),t.localKeys&&l.set(e,t.localKeys,s.map(function(e){return l.get(e,o)}));else if(s!==i.get(l.get(s,o)))try{t.localKey&&l.set(e,t.localKey,l.get(s,i.idAttribute)),a&&l.set(s,t.foreignKey,l.get(e,u)),s=i.inject(s)}catch(e){throw new Error("Failed to inject "+t.type+' relation: "'+t.relation+'"!')}t.link||void 0===t.link&&n.linkRelations?l.unset(e,t.localField):l.set(e,t.localField,s)}),o){var c=t.onConflict||n.onConflict;"merge"===c?l.deepMixIn(o,e):"replace"===c&&(l.forOwn(o,function(t,n){n===u||e.hasOwnProperty(n)||delete o[n]}),o.set(e)),e=o,a.update(e)}else e=n.createInstance(e),e._set("$",!0),a.insert(e);return e}),o?e.length?e[0]:void 0:e}},{key:"eject",value:function(e,t){var n="eject";this.dbg(n,"id:",e,"opts:",t),t||(t={}),t.op=n;var r=this.get(e);return r&&(r._unset("$"),this.collection.remove(r)),r}},{key:"ejectAll",value:function(e,t){var n="ejectAll";this.dbg(n,"params:",e,"opts:",t),t||(t={}),t.op=n;var r=this.filter(e),i=this.collection;return r.forEach(function(e){i.remove(e)}),r}},{key:"get",value:function(e){this.dbg("get","id:",e);var t=this.collection.get(e);return t.length?t[0]:void 0}},{key:"between",value:function(){var e;return(e=this.collection).between.apply(e,arguments)}},{key:"getAll",value:function(){var e;return(e=this.collection).getAll.apply(e,arguments)}},{key:"filter",value:function(e){return this.collection.filter(e)}},{ | ||
key:"query",value:function(){return this.collection.query()}},{key:"getAdapter",value:function(e){this.dbg("getAdapter","name:",e);var t=this.getAdapterName(e);if(!t)throw new ReferenceError(t+" not found!");return this.adapters[t]}},{key:"getAdapterName",value:function(e){return e||(e={}),l.isString(e)&&(e={adapter:e}),e.adapter||e.defaultAdapter}},{key:"beforeCreate",value:function(){}},{key:"create",value:function(e,t){var n=this,r="create";this.dbg(r,"props:",e,"opts:",t);var i=void 0;return e||(e={}),t||(t={}),l._(this,t),t.op=r,t.upsert&&l.get(e,this.idAttribute)?this.update(l.get(e,this.idAttribute),e,t):p(this.beforeCreate(e,t)).then(function(){return i=n.getAdapterName(t),n.getAdapter(i).create(n,n.prototype.toJSON.call(e,t),t)}).then(function(e){return p(n.afterCreate(e,t)).then(function(){return y(n,e,t,i)})})}},{key:"afterCreate",value:function(){}},{key:"beforeCreateMany",value:function(){}},{key:"createMany",value:function(e,t){var n=this,r="createMany";this.dbg(r,"items:",e,"opts:",t);var o=void 0;if(e||(e=[]),t||(t={}),l._(this,t),t.op=r,t.upsert){var a=function(){var r=!0;return e.forEach(function(e){r=r&&l.get(e,n.idAttribute)}),r?{v:n.updateMany(e,t)}:void 0}();if("object"===("undefined"==typeof a?"undefined":i(a)))return a.v}return p(this.beforeCreateMany(e,t)).then(function(){return o=n.getAdapterName(t),n.getAdapter(o).createMany(n,e.map(function(e){return n.prototype.toJSON.call(e,t)}),t)}).then(function(e){return p(n.afterCreateMany(e,t)).then(function(){return y(n,e,t,o)})})}},{key:"afterCreateMany",value:function(){}},{key:"beforeFind",value:function(){}},{key:"find",value:function(e,t){var n=this,r="find";this.dbg(r,"id:",e,"opts:",t);var i=void 0;return t||(t={}),l._(this,t),t.op=r,p(this.beforeFind(e,t)).then(function(){return i=n.getAdapterName(t),n.getAdapter(i).find(n,e,t)}).then(function(e){return p(n.afterFind(e,t)).then(function(){return y(n,e,t,i)})})}},{key:"afterFind",value:function(){}},{key:"beforeFindAll",value:function(){}},{key:"findAll",value:function(e,t){var n=this,r="findAll";this.dbg(r,"query:",e,"opts:",t);var i=void 0;return e||(e={}),t||(t={}),l._(this,t),t.op=r,p(this.beforeFindAll(e,t)).then(function(){return i=n.getAdapterName(t),n.getAdapter(i).findAll(n,e,t)}).then(function(e){return p(n.afterFindAll(e,t)).then(function(){return y(n,e,t,i)})})}},{key:"afterFindAll",value:function(){}},{key:"beforeUpdate",value:function(){}},{key:"update",value:function(e,t,n){var r=this,i="update";this.dbg(i,"id:",e,"props:",t,"opts:",n);var o=void 0;return t||(t={}),n||(n={}),l._(this,n),n.op=i,p(this.beforeUpdate(e,t,n)).then(function(){return o=r.getAdapterName(n),r.getAdapter(o).update(r,e,r.prototype.toJSON.call(t,n),n)}).then(function(t){return p(r.afterUpdate(e,t,n)).then(function(){return y(r,t,n,o)})})}},{key:"afterUpdate",value:function(){}},{key:"beforeUpdateMany",value:function(){}},{key:"updateMany",value:function(e,t){var n=this,r="updateMany";this.dbg(r,"items:",e,"opts:",t);var i=void 0;return e||(e=[]),t||(t={}),l._(this,t),t.op=r,p(this.beforeUpdateMany(e,t)).then(function(){return i=n.getAdapterName(t),n.getAdapter(i).updateMany(n,e.map(function(e){return n.prototype.toJSON.call(e,t)}),t)}).then(function(e){return p(n.afterUpdateMany(e,t)).then(function(){return y(n,e,t,i)})})}},{key:"afterUpdateMany",value:function(){}},{key:"beforeUpdateAll",value:function(){}},{key:"updateAll",value:function(e,t,n){var r=this,i="updateAll";this.dbg(i,"query:",e,"props:",t,"opts:",n);var o=void 0;return e||(e={}),t||(t={}),n||(n={}),l._(this,n),n.op=i,p(this.beforeUpdateAll(e,t,n)).then(function(){return o=r.getAdapterName(n),r.getAdapter(o).updateAll(r,e,t,n)}).then(function(t){return p(r.afterUpdateAll(e,t,n)).then(function(){return y(r,t,n,o)})})}},{key:"afterUpdateAll",value:function(){}},{key:"beforeDestroy",value:function(){}},{key:"destroy",value:function(e,t){var n=this,r="destroy";this.dbg(r,"id:",e,"opts:",t);var i=void 0;return t||(t={}),l._(this,t),t.op=r,p(this.beforeDestroy(e,t)).then(function(){return i=n.getAdapterName(t),n.getAdapter(i).destroy(n,e,t)}).then(function(r){return p(n.afterDestroy(e,t)).then(function(){return t.raw?(r.adapter=i,t.autoEject&&(r.data=n.eject(e,t)),r):(t.autoEject&&(r=n.eject(e,t)),r)})})}},{key:"afterDestroy",value:function(){}},{key:"beforeDestroyAll",value:function(){}},{key:"destroyAll",value:function(e,t){var n=this,r="destroyAll";this.dbg(r,"query:",e,"opts:",t);var i=void 0;return e||(e={}),t||(t={}),l._(this,t),t.op=r,p(this.beforeDestroyAll(e,t)).then(function(){return i=n.getAdapterName(t),n.getAdapter(i).destroyAll(n,e,t)}).then(function(r){return p(n.afterDestroyAll(e,t)).then(function(){return t.raw?(r.adapter=i,t.autoEject&&(r.data=n.ejectAll(e,t)),r):(t.autoEject&&(r=n.ejectAll(e,t)),r)})})}},{key:"afterDestroyAll",value:function(){}},{key:"log",value: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))}}}},{key:"dbg",value: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))}},{key:"belongsTo",value:function(e,t){return(0,f.belongsTo)(e,t)(this)}},{key:"hasMany",value:function(e,t){return(0,f.hasMany)(e,t)(this)}},{key:"hasOne",value:function(e,t){return(0,f.hasOne)(e,t)(this)}},{key:"setSchema",value:function(e){return(0,f.setSchema)(e)(this)}},{key:"configure",value:function(e){return(0,f.configure)(e)(this)}},{key:"registerAdapter",value:function(e,t,n){return(0,f.registerAdapter)(e,t,n)(this)}},{key:"extend",value:function(e,t){var n=this,r=void 0;n.dbg("extend","props:",e,"classProps:",t),e||(e={}),t||(t={});var s=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 "+i(t.name)+"!");if(t.csp)r=function(){u(this,r);for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];var i=o(this,Object.getPrototypeOf(r).apply(this,t));return s&&s.apply(this,t),i};else{var c=l.pascalCase(t.name),d="return function "+c+"() {\n _classCallCheck(this, "+c+")\n var _this = _possibleConstructorReturn(this, Object.getPrototypeOf("+c+").apply(this, arguments));\n if (initialize) {\n initialize.apply(this, arguments)\n }\n return _this\n }";r=new Function("_classCallCheck","_possibleConstructorReturn","Parent","initialize",d)(u,o,n,s)}}t.shortname=t.shortname||l.camelCase(r.name||t.name),delete t.name;var h=t.schema;return delete t.schema,a(r,n),(0,f.configure)(e)(r.prototype),(0,f.configure)(t)(r),h&&(0,f.setSchema)(h)(r),r}}]),t}(b);m.__events={},Object.defineProperty(m,"_events",{get:function(){return this.__events===Object.getPrototypeOf(this).__events&&(this.__events={}),this.__events}}),m._adapters={},Object.defineProperty(m,"adapters",{get:function(){var e=Object.getPrototypeOf(this)._adapters;return this._adapters===e&&(this._adapters={},l.fillIn(this._adapters,e)),this._adapters}}),m._collection=new d.Collection([],"id"),Object.defineProperty(m,"collection",{get:function(){return this._collection===Object.getPrototypeOf(this)._collection&&(this._collection=new d.Collection([],this.idAttribute),this._collection.on("all",this.emit,this)),this._collection}}),m.autoEject=!0,m.autoInject=g,m.bypassCache=!1,m.csp=!1,m.defaultAdapter="http",m.debug=!1,m.eagerEject=!1,m.idAttribute="id",m.linkRelations=g,m.onConflict="merge",m.relationsEnumerable=!1,m.raw=!1,m.upsert=!0,l.eventify(m,function(){return this._events},function(e){this._events=e}),l.eventify(m.prototype,function(){return this._get("events")},function(e){this._set("events",e)})}])}); | ||
!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 c(t){return r(t)||a(t)}function l(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)||(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 _(t,e){p(e,function(e,n){void 0===t[n]&&(t[n]=e)})}function A(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 x(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 c=void 0;if(rt(t)){var l=void 0;for(n.length=0,l=0;l<t.length;l++)c=w(t[l],null,r,a,s),e(t[l])&&(r.push(t[l]),a.push(c)),n.push(c)}else{rt(n)?n.length=0:p(n,function(t,e){delete n[e]});for(var f in t)if(t.hasOwnProperty(f)){if(A(f,s))continue;c=w(t[f],null,r,a,s),e(t[f])&&(r.push(t[f]),a.push(c)),n[f]=c}}}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 O(t){return t.replace(ut,"").replace(ct,j)}function k(t){return t.split(st).map(O).join("")}function E(t){return t=k(t),t?t.charAt(0).toLowerCase()+t.slice(1):t}function C(t,e,n){t=t||this;var i={};e||n||(e=function(){return i},n=function(t){i=t}),Object.defineProperties(t,{on:{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:{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:{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 R(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 I(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function P(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 M(t){I(this,M),this.collection=t,this.data=null}function S(t,e,n,i){var o=t[e],a=l(n,o[0]),s=l(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?S(t,e+1,n,i):0:s>a?-1:a>s?1:e<t.length-1?S(t,e+1,n,i):0}function L(t){return t.replace(ht,"\\$1")}function N(t,e){return new RegExp("^"+L(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!==N(n,e.substr(4)).exec(t);if(0===e.indexOf("notLike"))return null===N(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 $(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 q(t,e){if(I(this,q),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 J(){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(I(this,J),!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 q([n],{hashCode:function(t){return l(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=l(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]),l(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,a?function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];return a.apply(i,e)}:void 0)},delete o.writable),n.set&&(o.set=function(i){var r=this;return n.set(t,e,this,i,s?function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];return s.apply(r,e)}:void 0)},delete o.writable),o.get&&(o.set||(o.set=function(){})),Object.defineProperty(t.prototype,i,o),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.collection.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||E(e.name)+"Collection",r=n.foreignKey,o=n.localKeys,a=n.foreignKeys;r||o||a||(r=n.foreignKey=E(t.name)+"Id"),r&&e.collection.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(l(this,t.idAttribute),{index:r});else if(o){var u=l(this,o)||[],c=rt(u)?u:Object.keys(u);s=e.getAll.apply(e,c)}else a&&(d(n,"where."+a+".contains",l(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=l(s,t.idAttribute);r?n.forEach(function(t){d(t,r,i)}):o?!function(){var t=[];n.forEach(function(n){t.push(l(n,e.idAttribute))}),d(s,o,t)}():a&&n.forEach(function(t){var e=l(t,a);e?-1===e.indexOf(i)&&e.push(i):d(t,a,[i])})}(),l(this,i)}};return(n.link===!1||void 0===n.link&&!t.linkRelations)&&(delete s.get,delete s.set,s.writable=!0),n.get&&!function(){var i=s.get;s.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=s.set;s.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,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||E(e.name),r=n.foreignKey=n.foreignKey||E(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(l(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,l(this,t.idAttribute)),l(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.collection.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=_t[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),c=o("changed");t||(c=[]);var f=c.indexOf(e);u!==i&&-1===f&&c.push(e),n!==i?a("changes."+e,i):(s("changes."+e),f>=0&&c.splice(f,1)),c.length||(t=!1,s("changing"),s("changed"),o("eventId")&&(clearTimeout(o("eventId")),s("eventId"))),!t&&c.length&&(a("changed",c),a("changing",!0),a("eventId",setTimeout(function(){if(s("changed"),s("eventId"),s("changing"),!o("silent")){var t=void 0;for(t=0;t<c.length;t++)r.emit("change:"+c[t],r,l(r,c[t]));r.emit("change",r,o("changes"))}s("silent")},0)))}(),a("props."+e,i),o("$")&&n.indexed&&t.collection.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(At,"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=xt,function(i){i.dbg(xt,"name:",t,"adapter:",e,"opts:",n),i.adapters[t]=e,(n===!0||n.default)&&(i.defaultAdapter=t)}}function et(t,e){I(this,et),t||(t={}),e||(e={});var n={};Object.defineProperties(this,{_get:{value:function(t){return l(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),_(this,t),this._unset("creating"),this._set("changes",{}),this._unset("noValidate"),this._set("previous",w(t))}function nt(t){I(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,ct=/(\w)(\w*)/g,lt=Object.freeze({isArray:rt,isObject:e,isRegExp:i,isString:r,isDate:o,isNumber:a,isBoolean:s,isFunction:u,isSorN:c,get:l,unset:f,set:d,forOwn:p,deepMixIn:g,resolve:v,reject:y,_:m,intersection:b,fillIn:_,isBlacklisted:A,fromJson:x,toJson:at,copy:w,pascalCase:k,camelCase:E,eventify:C,uuid:R,classCallCheck:I,possibleConstructorReturn:P,addHiddenPropsToTarget:F}),ft={skip:"",offset:"",where:"",limit:"",orderBy:"",sort:""},ht=/([.*+?^=!:${}()|[\]\/\\])/g,dt=/%/g,pt=/_/g;F(M.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],c="|"===a.charAt(0);a=c?a.substr(1):a;var f=D(l(n,o[t]),a,u[t]);void 0!==f&&(r=i?f:c?r||f:r&&f),i=!1}return r})}();var c=t.orderBy||t.sort;r(c)&&(c=[[c,"ASC"]]),rt(c)||(c=null),c&&!function(){var t=0;c.forEach(function(t,e){r(t)&&(c[e]=[t,"ASC"])}),i.data.sort(function(e,n){return S(c,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},run:function(){var t=this.data;return this.data=null,t}});var gt={">":1,">=":1,"<":1,"<=":1};F(q.prototype,{set:function(t,e){rt(t)||(t=[t]);var n=t.shift()||null,i=$(this.keys,n);if(0===t.length)if(i.found){var r=$(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 q([],{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=$(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]),_(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?$(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=$(this.keys,n);if(0===t.length){if(i.found){var r=$(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=$(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(J.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=function(t){return l(t,i)};var o=this.indexes[t]=new q(e,n);return this.index.visitAll(o.insertRecord,o),this},query:function(){return new M(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)},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)},updateRecord:function(t,e){e||(e={});var n=e.index?this.indexes[e.index]:this.index;n.updateRecord(t)}}),C(J.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},_t={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}},At="setSchema",xt="registerAdapter",wt=v,jt={length:1,name:1,arguments:1,prototype:1,caller:1,__super__:1},Ot=!1;try{Ot=!!window}catch(t){}var kt=function(t,e,n,i){return n.raw?(e.adapter=i,n.autoInject&&(e.data=t.inject(e.data)),e):(n.autoInject&&(e=t.inject(e)),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,l(t,i))||[])});else t=this;return n.length?n:void 0},create:function(t){return this.constructor.create(this,t)},save:function(t){var e=this.constructor,n=e.getAdapterName(t);return e.getAdapter(n).update(e,l(this,e.idAttribute),this,t)},destroy:function(t){var e=this.constructor;return e.destroy(l(this,e.idAttribute),t)},get:function(t){return l(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 l(this,this.constructor.idAttribute)},changes:function(t){return t?this._get("changes."+t):this._get("changes")},changed:function(){return this._get("changed")},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;return this instanceof et&&(i={},d(i,this),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=l(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)))}()}))),i}}),_(et,{autoEject:!0,autoInject:Ot,bypassCache:!1,csp:!1,defaultAdapter:"http",debug:!1,eagerEject:!1,idAttribute:"id",linkRelations:Ot,onConflict:"merge",relationsEnumerable:!1,raw:!1,upsert:!0,createIndex:function(t,e){this.dbg("createIndex","name:",t,"keyList:",e),this.collection.createIndex(t,e)},createInstance:function(t){var e=this;return t instanceof e?t:new e(t)},is:function(t){return t instanceof this},getAutoPkItems:function(){return this.getAll().filter(function(t){return t._get("autoPk")})},changes:function(t,e){this.dbg("changes","id:",t);var n=this.get(t);return n?n.changes(e):void 0},changed:function(t){this.dbg("changed","id:",t);var e=this.get(t);return e?e.changed():void 0},hasChanges:function(t){this.dbg("hasChanges","id:",t);var e=this.get(t);return e?e.hasChanges():void 0},inject:function(t,e){var n=this,i="inject";n.dbg(i,"item(s):",t,"opts:",e),e||(e={}),e.op=i;var r=!1,o=n.collection,a=n.idAttribute,s=n.relationList||[];rt(t)||(t=[t],r=!0);var h=(new Date).getTime();return t=t.map(function(t){var i=l(t,a),r=!1;if(!c(i)){if(!(e.autoPk||void 0===e.autoPk&&n.autoPk))throw new TypeError("User#"+a+": Expected string or number, found "+("undefined"==typeof i?"undefined":it.typeof(i))+"!");i=R(),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,c=l(t,e.localField);if(u(e.inject))e.inject(n,e,t);else if(c&&e.inject!==!1)if(rt(c))c=c.map(function(t){if(t!==r.get(l(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,c.map(function(t){return l(t,o)}));else if(c!==r.get(l(c,o)))try{e.localKey&&d(t,e.localKey,l(c,r.idAttribute)),s&&d(c,e.foreignKey,l(t,a)),c=r.inject(c)}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,c)}),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}),r?t.length?t[0]:void 0:t},eject:function(t,e){var n="eject";this.dbg(n,"id:",t,"opts:",e),e||(e={}),e.op=n;var i=this.get(t);return i&&(i._unset("$"),this.collection.remove(i)),i},ejectAll:function(t,e){var n="ejectAll";this.dbg(n,"params:",t,"opts:",e),e||(e={}),e.op=n;var i=this.filter(t),r=this.collection;return i.forEach(function(t){r.remove(t)}),i},get:function(t){this.dbg("get","id:",t);var e=this.collection.get(t);return e.length?e[0]:void 0},between:function(){var t;return(t=this.collection).between.apply(t,arguments)},getAll:function(){var t;return(t=this.collection).getAll.apply(t,arguments)},filter:function(t,e){return e||(e={}),this.collection.filter(t,e)},query:function(){return this.collection.query()},getAdapter:function(t){this.dbg("getAdapter","name:",t);var e=this.getAdapterName(t);if(!e)throw new ReferenceError(e+" not found!");return this.adapters[e]},getAdapterName:function(t){return t||(t={}),r(t)&&(t={adapter:t}),t.adapter||t.defaultAdapter},beforeCreate:function(){},create:function(t,e){var n=this,i="create";this.dbg(i,"props:",t,"opts:",e);var r=void 0;return t||(t={}),e||(e={}),m(this,e),e.op=i,!e.upsert||!l(t,this.idAttribute)||this.is(t)&&t._get("autoPk")?wt(this.beforeCreate(t,e)).then(function(){return r=n.getAdapterName(e),n.getAdapter(r).create(n,n.prototype.toJSON.call(t,e),e)}).then(function(i){return wt(n.afterCreate(i,e)).then(function(){return n.is(t)&&t._get("$")&&n.eject(l(t,n.idAttribute)),kt(n,i,e,r)})}):this.update(l(t,this.idAttribute),t,e)},afterCreate:function(){},beforeCreateMany:function(){},createMany:function(t,e){var n=this,i="createMany";this.dbg(i,"items:",t,"opts:",e);var r=void 0;if(t||(t=[]),e||(e={}),m(this,e),e.op=i,e.upsert){var o=function(){var i=!0;return t.forEach(function(t){i=i&&l(t,n.idAttribute)&&(!u(t._get)||!t._get("autoPk"))}),i?{v:n.updateMany(t,e)}:void 0}();if("object"===("undefined"==typeof o?"undefined":it.typeof(o)))return o.v}return wt(this.beforeCreateMany(t,e)).then(function(){return r=n.getAdapterName(e),n.getAdapter(r).createMany(n,t.map(function(t){return n.prototype.toJSON.call(t,e)}),e)}).then(function(i){return wt(n.afterCreateMany(i,e)).then(function(){return t.forEach(function(t){n.is(t)&&t._get("$")&&n.eject(l(t,n.idAttribute))}),kt(n,i,e,r)})})},afterCreateMany:function(){},beforeFind:function(){},find:function(t,e){var n=this,i="find";this.dbg(i,"id:",t,"opts:",e);var r=void 0;return e||(e={}),m(this,e),e.op=i,wt(this.beforeFind(t,e)).then(function(){return r=n.getAdapterName(e),n.getAdapter(r).find(n,t,e)}).then(function(t){return wt(n.afterFind(t,e)).then(function(){return kt(n,t,e,r)})})},afterFind:function(){},beforeFindAll:function(){},findAll:function(t,e){var n=this,i="findAll";this.dbg(i,"query:",t,"opts:",e);var r=void 0;return t||(t={}),e||(e={}),m(this,e),e.op=i,wt(this.beforeFindAll(t,e)).then(function(){return r=n.getAdapterName(e),n.getAdapter(r).findAll(n,t,e)}).then(function(t){return wt(n.afterFindAll(t,e)).then(function(){return kt(n,t,e,r)})})},afterFindAll:function(){},beforeUpdate:function(){},update:function(t,e,n){var i=this,r="update";this.dbg(r,"id:",t,"props:",e,"opts:",n);var o=void 0;return e||(e={}),n||(n={}),m(this,n),n.op=r,wt(this.beforeUpdate(t,e,n)).then(function(){return o=i.getAdapterName(n),i.getAdapter(o).update(i,t,i.prototype.toJSON.call(e,n),n)}).then(function(e){return wt(i.afterUpdate(t,e,n)).then(function(){return kt(i,e,n,o)})})},afterUpdate:function(){},beforeUpdateMany:function(){},updateMany:function(t,e){var n=this,i="updateMany";this.dbg(i,"items:",t,"opts:",e);var r=void 0;return t||(t=[]),e||(e={}),m(this,e),e.op=i,wt(this.beforeUpdateMany(t,e)).then(function(){return r=n.getAdapterName(e),n.getAdapter(r).updateMany(n,t.map(function(t){return n.prototype.toJSON.call(t,e)}),e)}).then(function(t){return wt(n.afterUpdateMany(t,e)).then(function(){return kt(n,t,e,r)})})},afterUpdateMany:function(){},beforeUpdateAll:function(){},updateAll:function(t,e,n){var i=this,r="updateAll";this.dbg(r,"query:",t,"props:",e,"opts:",n);var o=void 0;return t||(t={}),e||(e={}),n||(n={}),m(this,n),n.op=r,wt(this.beforeUpdateAll(t,e,n)).then(function(){return o=i.getAdapterName(n),i.getAdapter(o).updateAll(i,t,e,n)}).then(function(e){return wt(i.afterUpdateAll(t,e,n)).then(function(){return kt(i,e,n,o)})})},afterUpdateAll:function(){},beforeDestroy:function(){},destroy:function(t,e){var n=this,i="destroy";this.dbg(i,"id:",t,"opts:",e);var r=void 0;return e||(e={}),m(this,e),e.op=i,wt(this.beforeDestroy(t,e)).then(function(){return r=n.getAdapterName(e),n.getAdapter(r).destroy(n,t,e)}).then(function(i){return wt(n.afterDestroy(t,e)).then(function(){return e.raw?(i.adapter=r,e.autoEject&&(i.data=n.eject(t,e)),i):(e.autoEject&&(i=n.eject(t,e)),i)})})},afterDestroy:function(){},beforeDestroyAll:function(){},destroyAll:function(t,e){var n=this,i="destroyAll";this.dbg(i,"query:",t,"opts:",e);var r=void 0;return t||(t={}),e||(e={}),m(this,e),e.op=i,wt(this.beforeDestroyAll(t,e)).then(function(){return r=n.getAdapterName(e),n.getAdapter(r).destroyAll(n,t,e)}).then(function(i){return wt(n.afterDestroyAll(t,e)).then(function(){return e.raw?(i.adapter=r,e.autoEject&&(i.data=n.ejectAll(t,e)),i):(e.autoEject&&(i=n.ejectAll(t,e)),i)})})},afterDestroyAll:function(){},beforeLoadRelations:function(){},loadRelations:function(t,e,n){var i=this,o=this,a=o.is(t)?t:void 0;t=a?l(a,o.idAttribute):t;var s="loadRelations";o.dbg(s,"id:",t,"relations:",e,"opts:",n),e||(e=[]),n||(n={});var f=o.relationList||[];return m(o,n),n.op=s,wt(o.beforeLoadRelations(t,e,n)).then(function(){ | ||
if(c(t)&&!a&&(a=o.get(a)),!a)throw new Error("You passed an id of an instance not found in the collection of the Model!");return r(e)&&(e=[e]),Promise.all(f.map(function(e){if(u(e.load))return e.load(o,e,a,n);var i=void 0;if(e.foreignKey)i=e.Relation.findAll(it.defineProperty({},e.foreignKey,t),n);else if(e.localKey){var r=l(a,e.localKey);c(r)&&(i=e.Relation.find(r,n))}else e.localKeys?i=e.Relation.findAll(it.defineProperty({},e.Relation.idAttribute,{in:l(a,e.localKeys)}),n):e.foreignKeys&&(i=e.Relation.findAll(it.defineProperty({},e.Relation.idAttribute,{contains:l(a,o.idAttribute)}),n));return i&&(i=i.then(function(t){n.raw&&(t=t.data),d(a,e.localField,"hasOne"===e.type?t.length?t[0]:void 0:t)})),i}))}).then(function(){return wt(i.afterLoadRelations(a,e,n)).then(function(){return a})})},afterLoadRelations:function(){},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(){I(this,i);for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];var o=P(this,(i.__super__||Object.getPrototypeOf(i)).apply(this,e));return r&&r.apply(o,e),o};else{var o=k(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)(I,P,n,r)}}e.shortname=e.shortname||E(i.name||e.name),delete e.name;var s=e.schema;if(delete e.schema,i.prototype=Object.create(n&&n.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),n&&e.strictEs6Class)Object.setPrototypeOf?Object.setPrototypeOf(i,n):i.__proto__=n;else{var u=Object.getOwnPropertyNames(n);u.forEach(function(t){jt[t]||Object.defineProperty(i,t,Object.getOwnPropertyDescriptor(n,t))})}return Object.defineProperty(i,"__super__",{configurable:!0,value:n}),V(t)(i.prototype),V(e)(i),s&&X(s)(i),i}}),Object.defineProperties(et,{__events:{configurable:!0,value:{}},_events:{get:function(){return this.__events===(this.__super__?this.__super__:Object.getPrototypeOf(this)).__events&&Object.defineProperty(this,"__events",{value:{}}),this.__events}},_adapters:{configurable:!0,value:{}},adapters:{get:function(){var t=(this.__super__?this.__super__:Object.getPrototypeOf(this))._adapters;return this._adapters===t&&(Object.defineProperty(this,"_adapters",{value:{}}),_(this._adapters,t)),this._adapters}},_collection:{configurable:!0,value:new J([],"id")},collection:{get:function(){return this._collection===(this.__super__?this.__super__:Object.getPrototypeOf(this))._collection&&(Object.defineProperty(this,"_collection",{value:new J([],this.idAttribute)}),this._collection.on("all",this.emit,this),this._collection.createIndex("lastInjected",["$"],{fieldGetter:function(t){return t._get("$")}})),this._collection}}}),C(et,function(){return this._events},function(t){this._events=t}),C(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 Et=lt,Ct={full:"<%= pkg.version %>",major:parseInt("<%= major %>",10),minor:parseInt("<%= minor %>",10),patch:parseInt("<%= patch %>",10),alpha:"<%= alpha %>",beta:"<%= beta %>"};t.utils=Et,t.version=Ct,t.Collection=J,t.Query=M,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=_t,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.2", | ||
"version": "3.0.0-alpha.3", | ||
"homepage": "http://www.js-data.io", | ||
@@ -29,2 +29,3 @@ "repository": { | ||
"globals": [ | ||
"babelHelpers", | ||
"__callCheck__", | ||
@@ -44,7 +45,7 @@ "__get__", | ||
"scripts": { | ||
"rollup": "rollup -c", | ||
"rollup-tests": "rollup -c rollup-tests.config.js", | ||
"doc": "jsdoc -c conf.json src", | ||
"lint": "standard src/**/*.js test/**/*.js", | ||
"webpack": "webpack --config webpack.config.js", | ||
"helpers": "node scripts/helpers.js", | ||
"watch": "npm run webpack -- --watch", | ||
"min": "uglifyjs dist/js-data.js -o dist/js-data.min.js --source-map dist/js-data.min.map -v -m -c --screw-ie8", | ||
@@ -55,17 +56,19 @@ "debug": "node scripts/debug.js", | ||
"gzip": "echo gzipped size: $(cat dist/js-data.min.js | gzip -f9 | wc -c)kb", | ||
"build": "npm run lint && npm run webpack && npm run debug && npm run min && npm run version && npm run banner", | ||
"build": "npm run lint && npm run rollup && npm run debug && npm run min && npm run version && npm run banner", | ||
"karma": "karma start", | ||
"mocha": "mocha -t 20000 -R spec -r source-map-support/register mocha.start.js", | ||
"r": "npm run rollup && npm run mocha", | ||
"t": "npm run rollup-tests && npm run mocha", | ||
"rt": "npm run rollup && npm run rollup-tests && npm run mocha", | ||
"cover": "istanbul cover -x dist/js-data-tests.js --hook-run-in-context node_modules/mocha/bin/_mocha -- -t 20000 -R dot -r source-map-support/register mocha.start.js", | ||
"test": "npm run build && npm run cover", | ||
"test": "npm run build && npm run rollup-tests && npm run cover", | ||
"ci": "npm test && cat coverage/lcov.info | coveralls || true && cat ./coverage/lcov.info | codacy-coverage || true" | ||
}, | ||
"devDependencies": { | ||
"babel-core": "6.3.21", | ||
"babel-core": "6.3.26", | ||
"babel-eslint": "4.1.6", | ||
"babel-loader": "6.2.0", | ||
"babel-plugin-syntax-async-functions": "6.3.13", | ||
"babel-plugin-transform-regenerator": "6.3.18", | ||
"babel-plugin-transform-regenerator": "6.3.26", | ||
"babel-polyfill": "6.3.14", | ||
"babel-preset-es2015": "6.3.13", | ||
"babel-preset-es2015-rollup": "1.0.0", | ||
"babel-preset-stage-0": "6.3.13", | ||
@@ -79,9 +82,10 @@ "chai": "3.4.1", | ||
"mocha": "2.3.4", | ||
"rollup": "0.22.0", | ||
"rollup-plugin-babel": "2.2.0", | ||
"sinon": "1.17.2", | ||
"source-map-support": "0.4.0", | ||
"standard": "5.4.1", | ||
"uglify-js": "2.6.1", | ||
"webpack": "1.12.9" | ||
"uglify-js": "2.6.1" | ||
}, | ||
"dependencies": {} | ||
} |
@@ -71,5 +71,2 @@ <img src="https://raw.githubusercontent.com/js-data/js-data/master/js-data.png" alt="js-data logo" title="js-data" align="right" width="64" height="64" /> | ||
// Allow "User" to store data | ||
User.initialize() | ||
let user = await User.find(1) | ||
@@ -117,7 +114,4 @@ | ||
// "User" will use an http adapter by default | ||
User.setAdapter('http', new DSHttpAdapter(), { default: true }) | ||
User.registerAdapter('http', new DSHttpAdapter(), { default: true }) | ||
// Allow "User" to store data | ||
User.initialize() | ||
let user = yield User.find(1) | ||
@@ -266,3 +260,3 @@ | ||
1. `git clone git@github.com:<you>/js-data.git` | ||
1. `cd js-data; npm install; bower install;` | ||
1. `cd js-data; npm install;` | ||
1. Write your code, including relevant documentation and tests | ||
@@ -269,0 +263,0 @@ 1. Run `npm test` (build and test) |
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
634195
16
9042
322