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 1.5.0 to 1.5.1

13

CHANGELOG.md

@@ -0,1 +1,11 @@

##### 1.5.1 - 02 March 2015
###### Backwards compatible bug fixes
- #66 - "saved" and "lastSaved" method seems to be a misnomer
- #69 - Using resource base class w/additional properties has some side effects
- #70 - "lastSaved" timestamp changes too often
###### Other
- Removed use of `DSUtils.copy` in the event hooks. This should increase performance quite a bit.
##### 1.5.0 - 27 February 2015

@@ -7,2 +17,3 @@

###### Backwards compatible bug fixes
- #62 - getAdapter when called from a Resource fails
- #65 - internal emit api was not updated to use Resource instead of Resource.name like the lifecycle hooks were

@@ -16,3 +27,3 @@

###### Backwards compatible bug fixes
- # - Two possible error cases in `DS#find`
- #64 - Two possible error cases in `DS#find`

@@ -19,0 +30,0 @@ ##### 1.4.0 - 24 February 2015

6

dist/js-data.min.js
/**
* @author Jason Dobry <jason.dobry@gmail.com>
* @file js-data.min.js
* @version 1.5.0 - Homepage <http://www.js-data.io/>
* @version 1.5.1 - Homepage <http://www.js-data.io/>
* @copyright (c) 2014 Jason Dobry

@@ -11,4 +11,4 @@ * @license MIT <https://github.com/js-data/js-data/blob/master/LICENSE>

!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;"undefined"!=typeof window?b=window:"undefined"!=typeof global?b=global:"undefined"!=typeof self&&(b=self),b.JSData=a()}}(function(){var define,module,exports;return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(require,module,exports){!function(global){"use strict";function detectObjectObserve(){function a(a){b=a}if("function"!=typeof Object.observe||"function"!=typeof Array.observe)return!1;var b=[],c={},d=[];return Object.observe(c,a),Array.observe(d,a),c.id=1,c.id=2,delete c.id,d.push(1,2),d.length=0,Object.deliverChangeRecords(a),5!==b.length?!1:"add"!=b[0].type||"update"!=b[1].type||"delete"!=b[2].type||"splice"!=b[3].type||"splice"!=b[4].type?!1:(Object.unobserve(c,a),Array.unobserve(d,a),!0)}function detectEval(){if("undefined"!=typeof chrome&&chrome.app&&chrome.app.runtime)return!1;try{var a=new Function("","return true;");return a()}catch(b){return!1}}function dirtyCheck(a){for(var b=0;MAX_DIRTY_CHECK_CYCLES>b&&a.check_();)b++;return global.testingExposeCycleCount&&(global.dirtyCheckCycleCount=b),b>0}function objectIsEmpty(a){for(var b in a)return!1;return!0}function diffIsEmpty(a){return objectIsEmpty(a.added)&&objectIsEmpty(a.removed)&&objectIsEmpty(a.changed)}function isBlacklisted(a,b){if(!b||!b.length)return!1;for(var c,d=0;d<b.length;d++)if("[object RegExp]"===Object.prototype.toString.call(b[d])&&b[d].test(a)||b[d]===a)return c=a;return!!c}function diffObjectFromOldObject(a,b,c,d){var e={},f={},g={};for(var h in b){var i=a[h];isBlacklisted(h,d)||void 0!==i&&(c?c(i,b[h]):i===b[h])||(h in a?(c?c(i,b[h]):i===b[h])||(g[h]=i):f[h]=void 0)}for(var h in a)h in b||isBlacklisted(h,d)||(e[h]=a[h]);return Array.isArray(a)&&a.length!==b.length&&(g.length=a.length),{added:e,removed:f,changed:g}}function runEOMTasks(){if(!eomTasks.length)return!1;for(var a=0;a<eomTasks.length;a++)eomTasks[a]();return eomTasks.length=0,!0}function newObservedObject(){function a(a){b&&b.state_===OPENED&&!d&&b.check_(a)}var b,c,d=!1,e=!0;return{open:function(c){if(b)throw Error("ObservedObject in use");e||Object.deliverChangeRecords(a),b=c,e=!1},observe:function(b,d){c=b,d?Array.observe(c,a):Object.observe(c,a)},deliver:function(b){d=b,Object.deliverChangeRecords(a),d=!1},close:function(){b=void 0,Object.unobserve(c,a),observedObjectCache.push(this)}}}function getObservedObject(a,b,c){var d=observedObjectCache.pop()||newObservedObject();return d.open(a),d.observe(b,c),d}function Observer(){this.state_=UNOPENED,this.callback_=void 0,this.target_=void 0,this.directObserver_=void 0,this.value_=void 0,this.id_=nextObserverId++}function addToAll(a){Observer._allObserversCount++,collectObservers&&allObservers.push(a)}function removeFromAll(){Observer._allObserversCount--}function ObjectObserver(a){Observer.call(this),this.value_=a,this.oldObject_=void 0}function diffObjectFromChangeRecords(a,b,c){for(var d={},e={},f=0;f<b.length;f++){var g=b[f];expectedRecordTypes[g.type]?(g.name in c||(c[g.name]=g.oldValue),"update"!=g.type&&("add"!=g.type?g.name in d?(delete d[g.name],delete c[g.name]):e[g.name]=!0:g.name in e?delete e[g.name]:d[g.name]=!0)):(console.error("Unknown changeRecord type: "+g.type),console.error(g))}for(var h in d)d[h]=a[h];for(var h in e)e[h]=void 0;var i={};for(var h in c)if(!(h in d||h in e)){var j=a[h];c[h]!==j&&(i[h]=j)}return{added:d,removed:e,changed:i}}var equalityFn=function(a,b){return a===b},blacklist=[],hasObserve=detectObjectObserve(),hasEval=detectEval(),createObject="__proto__"in{}?function(a){return a}:function(a){var b=a.__proto__;if(!b)return a;var c=Object.create(b);return Object.getOwnPropertyNames(a).forEach(function(b){Object.defineProperty(c,b,Object.getOwnPropertyDescriptor(a,b))}),c},MAX_DIRTY_CHECK_CYCLES=1e3,eomTasks=[],runEOM=hasObserve?function(){var a={pingPong:!0},b=!1;return Object.observe(a,function(){runEOMTasks(),b=!1}),function(c){eomTasks.push(c),b||(b=!0,a.pingPong=!a.pingPong)}}():function(){return function(a){eomTasks.push(a)}}(),observedObjectCache=[],UNOPENED=0,OPENED=1,CLOSED=2,nextObserverId=1;Observer.prototype={open:function(a,b){if(this.state_!=UNOPENED)throw Error("Observer has already been opened.");return addToAll(this),this.callback_=a,this.target_=b,this.connect_(),this.state_=OPENED,this.value_},close:function(){this.state_==OPENED&&(removeFromAll(this),this.disconnect_(),this.value_=void 0,this.callback_=void 0,this.target_=void 0,this.state_=CLOSED)},deliver:function(){this.state_==OPENED&&dirtyCheck(this)},report_:function(a){try{this.callback_.apply(this.target_,a)}catch(b){Observer._errorThrownDuringCallback=!0,console.error("Exception caught during observer callback: "+(b.stack||b))}},discardChanges:function(){return this.check_(void 0,!0),this.value_}};var collectObservers=!hasObserve,allObservers;Observer._allObserversCount=0,collectObservers&&(allObservers=[]);var runningMicrotaskCheckpoint=!1,hasDebugForceFullDelivery=hasObserve&&hasEval&&function(){try{return eval("%RunMicrotasks()"),!0}catch(ex){return!1}}();global.Platform=global.Platform||{},global.Platform.performMicrotaskCheckpoint=function(){if(!runningMicrotaskCheckpoint){if(hasDebugForceFullDelivery)return void eval("%RunMicrotasks()");if(collectObservers){runningMicrotaskCheckpoint=!0;var cycles=0,anyChanged,toCheck;do{cycles++,toCheck=allObservers,allObservers=[],anyChanged=!1;for(var i=0;i<toCheck.length;i++){var observer=toCheck[i];observer.state_==OPENED&&(observer.check_()&&(anyChanged=!0),allObservers.push(observer))}runEOMTasks()&&(anyChanged=!0)}while(MAX_DIRTY_CHECK_CYCLES>cycles&&anyChanged);global.testingExposeCycleCount&&(global.dirtyCheckCycleCount=cycles),runningMicrotaskCheckpoint=!1}}},collectObservers&&(global.Platform.clearObservers=function(){allObservers=[]}),ObjectObserver.prototype=createObject({__proto__:Observer.prototype,arrayObserve:!1,connect_:function(){hasObserve?this.directObserver_=getObservedObject(this,this.value_,this.arrayObserve):this.oldObject_=this.copyObject(this.value_)},copyObject:function(a){var b=Array.isArray(a)?[]:{};for(var c in a)b[c]=a[c];return Array.isArray(a)&&(b.length=a.length),b},check_:function(a){var b,c;if(hasObserve){if(!a)return!1;c={},b=diffObjectFromChangeRecords(this.value_,a,c)}else c=this.oldObject_,b=diffObjectFromOldObject(this.value_,this.oldObject_);return diffIsEmpty(b)?!1:(hasObserve||(this.oldObject_=this.copyObject(this.value_)),this.report_([b.added||{},b.removed||{},b.changed||{},function(a){return c[a]}]),!0)},disconnect_:function(){hasObserve?(this.directObserver_.close(),this.directObserver_=void 0):this.oldObject_=void 0},deliver:function(){this.state_==OPENED&&(hasObserve?this.directObserver_.deliver(!1):dirtyCheck(this))},discardChanges:function(){return this.directObserver_?this.directObserver_.deliver(!0):this.oldObject_=this.copyObject(this.value_),this.value_}});var observerSentinel={},expectedRecordTypes={add:!0,update:!0,"delete":!0};global.Observer=Observer,global.diffObjectFromOldObject=diffObjectFromOldObject,global.setEqualityFn=function(a){equalityFn=a},global.setBlacklist=function(a){blacklist=a},global.Observer.runEOM_=runEOM,global.Observer.observerSentinel_=observerSentinel,global.Observer.hasObjectObserve=hasObserve,global.ObjectObserver=ObjectObserver}(exports)},{}],2:[function(a,b){(function(a,c){(function(){"use strict";function d(a){return"function"==typeof a||"object"==typeof a&&null!==a}function e(a){return"function"==typeof a}function f(a){return"object"==typeof a&&null!==a}function g(){}function h(){return function(){a.nextTick(l)}}function i(){var a=0,b=new O(l),c=document.createTextNode("");return b.observe(c,{characterData:!0}),function(){c.data=a=++a%2}}function j(){var a=new MessageChannel;return a.port1.onmessage=l,function(){a.port2.postMessage(0)}}function k(){return function(){setTimeout(l,1)}}function l(){for(var a=0;L>a;a+=2){var b=Q[a],c=Q[a+1];b(c),Q[a]=void 0,Q[a+1]=void 0}L=0}function m(){}function n(){return new TypeError("You cannot resolve a promise with itself")}function o(){return new TypeError("A promises callback cannot return that same promise.")}function p(a){try{return a.then}catch(b){return U.error=b,U}}function q(a,b,c,d){try{a.call(b,c,d)}catch(e){return e}}function r(a,b,c){M(function(a){var d=!1,e=q(c,b,function(c){d||(d=!0,b!==c?u(a,c):w(a,c))},function(b){d||(d=!0,x(a,b))},"Settle: "+(a._label||" unknown promise"));!d&&e&&(d=!0,x(a,e))},a)}function s(a,b){b._state===S?w(a,b._result):a._state===T?x(a,b._result):y(b,void 0,function(b){u(a,b)},function(b){x(a,b)})}function t(a,b){if(b.constructor===a.constructor)s(a,b);else{var c=p(b);c===U?x(a,U.error):void 0===c?w(a,b):e(c)?r(a,b,c):w(a,b)}}function u(a,b){a===b?x(a,n()):d(b)?t(a,b):w(a,b)}function v(a){a._onerror&&a._onerror(a._result),z(a)}function w(a,b){a._state===R&&(a._result=b,a._state=S,0===a._subscribers.length||M(z,a))}function x(a,b){a._state===R&&(a._state=T,a._result=b,M(v,a))}function y(a,b,c,d){var e=a._subscribers,f=e.length;a._onerror=null,e[f]=b,e[f+S]=c,e[f+T]=d,0===f&&a._state&&M(z,a)}function z(a){var b=a._subscribers,c=a._state;if(0!==b.length){for(var d,e,f=a._result,g=0;g<b.length;g+=3)d=b[g],e=b[g+c],d?C(c,d,e,f):e(f);a._subscribers.length=0}}function A(){this.error=null}function B(a,b){try{return a(b)}catch(c){return V.error=c,V}}function C(a,b,c,d){var f,g,h,i,j=e(c);if(j){if(f=B(c,d),f===V?(i=!0,g=f.error,f=null):h=!0,b===f)return void x(b,o())}else f=d,h=!0;b._state!==R||(j&&h?u(b,f):i?x(b,g):a===S?w(b,f):a===T&&x(b,f))}function D(a,b){try{b(function(b){u(a,b)},function(b){x(a,b)})}catch(c){x(a,c)}}function E(a,b,c,d){this._instanceConstructor=a,this.promise=new a(m,d),this._abortOnReject=c,this._validateInput(b)?(this._input=b,this.length=b.length,this._remaining=b.length,this._init(),0===this.length?w(this.promise,this._result):(this.length=this.length||0,this._enumerate(),0===this._remaining&&w(this.promise,this._result))):x(this.promise,this._validationError())}function F(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function G(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function H(a){this._id=_++,this._state=void 0,this._result=void 0,this._subscribers=[],m!==a&&(e(a)||F(),this instanceof H||G(),D(this,a))}var I;I=Array.isArray?Array.isArray:function(a){return"[object Array]"===Object.prototype.toString.call(a)};var J,K=I,L=(Date.now||function(){return(new Date).getTime()},Object.create||function(a){if(arguments.length>1)throw new Error("Second argument not supported");if("object"!=typeof a)throw new TypeError("Argument must be an object");return g.prototype=a,new g},0),M=function(a,b){Q[L]=a,Q[L+1]=b,L+=2,2===L&&J()},N="undefined"!=typeof window?window:{},O=N.MutationObserver||N.WebKitMutationObserver,P="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,Q=new Array(1e3);J="undefined"!=typeof a&&"[object process]"==={}.toString.call(a)?h():O?i():P?j():k();var R=void 0,S=1,T=2,U=new A,V=new A;E.prototype._validateInput=function(a){return K(a)},E.prototype._validationError=function(){return new Error("Array Methods must be provided an Array")},E.prototype._init=function(){this._result=new Array(this.length)};var W=E;E.prototype._enumerate=function(){for(var a=this.length,b=this.promise,c=this._input,d=0;b._state===R&&a>d;d++)this._eachEntry(c[d],d)},E.prototype._eachEntry=function(a,b){var c=this._instanceConstructor;f(a)?a.constructor===c&&a._state!==R?(a._onerror=null,this._settledAt(a._state,b,a._result)):this._willSettleAt(c.resolve(a),b):(this._remaining--,this._result[b]=this._makeResult(S,b,a))},E.prototype._settledAt=function(a,b,c){var d=this.promise;d._state===R&&(this._remaining--,this._abortOnReject&&a===T?x(d,c):this._result[b]=this._makeResult(a,b,c)),0===this._remaining&&w(d,this._result)},E.prototype._makeResult=function(a,b,c){return c},E.prototype._willSettleAt=function(a,b){var c=this;y(a,void 0,function(a){c._settledAt(S,b,a)},function(a){c._settledAt(T,b,a)})};var X=function(a,b){return new W(this,a,!0,b).promise},Y=function(a,b){function c(a){u(f,a)}function d(a){x(f,a)}var e=this,f=new e(m,b);if(!K(a))return x(f,new TypeError("You must pass an array to race.")),f;for(var g=a.length,h=0;f._state===R&&g>h;h++)y(e.resolve(a[h]),void 0,c,d);return f},Z=function(a,b){var c=this;if(a&&"object"==typeof a&&a.constructor===c)return a;var d=new c(m,b);return u(d,a),d},$=function(a,b){var c=this,d=new c(m,b);return x(d,a),d},_=0,ab=H;H.all=X,H.race=Y,H.resolve=Z,H.reject=$,H.prototype={constructor:H,then:function(a,b){var c=this,d=c._state;if(d===S&&!a||d===T&&!b)return this;var e=new this.constructor(m),f=c._result;if(d){var g=arguments[d-1];M(function(){C(d,e,g,f)})}else y(c,e,a,b);return e},"catch":function(a){return this.then(null,a)}};var bb=function(){var a;a="undefined"!=typeof c?c:"undefined"!=typeof window&&window.document?window:self;var b="Promise"in a&&"resolve"in a.Promise&&"reject"in a.Promise&&"all"in a.Promise&&"race"in a.Promise&&function(){var b;return new a.Promise(function(a){b=a}),e(b)}();b||(a.Promise=ab)},cb={Promise:ab,polyfill:bb};"function"==typeof define&&define.amd?define(function(){return cb}):"undefined"!=typeof b&&b.exports?b.exports=cb:"undefined"!=typeof this&&(this.ES6Promise=cb)}).call(this)}).call(this,a("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:3}],3:[function(a,b){function c(){if(!g){g=!0;for(var a,b=f.length;b;){a=f,f=[];for(var c=-1;++c<b;)a[c]();b=f.length}g=!1}}function d(){}var e=b.exports={},f=[],g=!1;e.nextTick=function(a){f.push(a),g||setTimeout(c,0)},e.title="browser",e.browser=!0,e.env={},e.argv=[],e.version="",e.on=d,e.addListener=d,e.once=d,e.off=d,e.removeListener=d,e.removeAllListeners=d,e.emit=d,e.binding=function(){throw new Error("process.binding is not supported")},e.cwd=function(){return"/"},e.chdir=function(){throw new Error("process.chdir is not supported")},e.umask=function(){return 0}},{}],4:[function(a,b){function c(a,b){return-1!==d(a,b)}var d=a("./indexOf");b.exports=c},{"./indexOf":6}],5:[function(a,b){function c(a,b,c){if(null!=a)for(var d=-1,e=a.length;++d<e&&b.call(c,a[d],d,a)!==!1;);}b.exports=c},{}],6:[function(a,b){function c(a,b,c){if(c=c||0,null==a)return-1;for(var d=a.length,e=0>c?d+c:c;d>e;){if(a[e]===b)return e;e++}return-1}b.exports=c},{}],7:[function(a,b){function c(a,b){var c=d(a,b);-1!==c&&a.splice(c,1)}var d=a("./indexOf");b.exports=c},{"./indexOf":6}],8:[function(a,b){function c(a,b,c){var d=a.length;b=null==b?0:0>b?Math.max(d+b,0):Math.min(b,d),c=null==c?d:0>c?Math.max(d+c,0):Math.min(c,d);for(var e=[];c>b;)e.push(a[b++]);return e}b.exports=c},{}],9:[function(a,b){function c(a,b){if(null==a)return[];if(a.length<2)return a;null==b&&(b=d);var f,g,h;return f=~~(a.length/2),g=c(a.slice(0,f),b),h=c(a.slice(f,a.length),b),e(g,h,b)}function d(a,b){return b>a?-1:a>b?1:0}function e(a,b,c){for(var d=[];a.length&&b.length;)d.push(c(a[0],b[0])<=0?a.shift():b.shift());return a.length&&d.push.apply(d,a),b.length&&d.push.apply(d,b),d}b.exports=c},{}],10:[function(a,b){function c(a){return!!a&&"object"==typeof a&&a.constructor===Object}b.exports=c},{}],11:[function(a,b){function c(a){switch(typeof a){case"string":case"number":case"boolean":return!0}return null==a}b.exports=c},{}],12:[function(a,b){function c(a){return null==a?"":a.toString()}b.exports=c},{}],13:[function(a,b){function c(a){for(var b,c=0,f=arguments.length;++c<f;)b=arguments[c],b&&e(b,d,a);return a}function d(a,b){var d=this[b];f(a)&&f(d)?c(d,a):this[b]=a}var e=a("./forOwn"),f=a("../lang/isPlainObject");b.exports=c},{"../lang/isPlainObject":10,"./forOwn":15}],14:[function(a,b){function c(){g=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],f=!0;for(var a in{toString:null})f=!1}function d(a,b,d){var i,j=0;null==f&&c();for(i in a)if(e(b,a,i,d)===!1)break;if(f)for(var k=a.constructor,l=!!k&&a===k.prototype;(i=g[j++])&&("constructor"===i&&(l||!h(a,i))||a[i]===Object.prototype[i]||e(b,a,i,d)!==!1););}function e(a,b,c,d){return a.call(d,b[c],c,b)}var f,g,h=a("./hasOwn");b.exports=d},{"./hasOwn":17}],15:[function(a,b){function c(a,b,c){e(a,function(e,f){return d(a,f)?b.call(c,a[f],f,a):void 0})}var d=a("./hasOwn"),e=a("./forIn");b.exports=c},{"./forIn":14,"./hasOwn":17}],16:[function(a,b){function c(a,b){for(var c=b.split("."),d=c.pop();b=c.shift();)if(a=a[b],null==a)return;return a[d]}a("../lang/isPrimitive");b.exports=c},{"../lang/isPrimitive":11}],17:[function(a,b){function c(a,b){return Object.prototype.hasOwnProperty.call(a,b)}b.exports=c},{}],18:[function(a,b){function c(a,b){return b?(d(b.split("."),function(b){a[b]||(a[b]={}),a=a[b]}),a):a}var d=a("../array/forEach");b.exports=c},{"../array/forEach":5}],19:[function(a,b){function c(a){for(var b,c="string"!=typeof arguments[1]?arguments[1]:d(arguments,1),e={},f=0;b=c[f++];)e[b]=a[b];return e}var d=a("../array/slice");b.exports=c},{"../array/slice":8}],20:[function(a,b){function c(a,b,c){var e=/^(.+)\.(.+)$/.exec(b);e?d(a,e[1])[e[2]]=c:a[b]=c}var d=a("./namespace");b.exports=c},{"./namespace":18}],21:[function(a,b){function c(a){return a=d(a),a=e(a),a=f(a).replace(/[\-_]/g," ").replace(/\s[a-z]/g,g).replace(/\s+/g,"").replace(/^[A-Z]/g,h)}var d=a("../lang/toString"),e=a("./replaceAccents"),f=a("./removeNonWord"),g=a("./upperCase"),h=a("./lowerCase");b.exports=c},{"../lang/toString":12,"./lowerCase":22,"./removeNonWord":24,"./replaceAccents":25,"./upperCase":26}],22:[function(a,b){function c(a){return a=d(a),a.toLowerCase()}var d=a("../lang/toString");b.exports=c},{"../lang/toString":12}],23:[function(a,b){function c(a){return a=d(a),e(a).replace(/^[a-z]/,f)}var d=a("../lang/toString"),e=a("./camelCase"),f=a("./upperCase");b.exports=c},{"../lang/toString":12,"./camelCase":21,"./upperCase":26}],24:[function(a,b){function c(a){return a=d(a),a.replace(e,"")}var d=a("../lang/toString"),e=/[^\x20\x2D0-9A-Z\x5Fa-z\xC0-\xD6\xD8-\xF6\xF8-\xFF]/g;b.exports=c},{"../lang/toString":12}],25:[function(a,b){function c(a){return a=d(a),a.search(/[\xC0-\xFF]/g)>-1&&(a=a.replace(/[\xC0-\xC5]/g,"A").replace(/[\xC6]/g,"AE").replace(/[\xC7]/g,"C").replace(/[\xC8-\xCB]/g,"E").replace(/[\xCC-\xCF]/g,"I").replace(/[\xD0]/g,"D").replace(/[\xD1]/g,"N").replace(/[\xD2-\xD6\xD8]/g,"O").replace(/[\xD9-\xDC]/g,"U").replace(/[\xDD]/g,"Y").replace(/[\xDE]/g,"P").replace(/[\xE0-\xE5]/g,"a").replace(/[\xE6]/g,"ae").replace(/[\xE7]/g,"c").replace(/[\xE8-\xEB]/g,"e").replace(/[\xEC-\xEF]/g,"i").replace(/[\xF1]/g,"n").replace(/[\xF2-\xF6\xF8]/g,"o").replace(/[\xF9-\xFC]/g,"u").replace(/[\xFE]/g,"p").replace(/[\xFD\xFF]/g,"y")),a}var d=a("../lang/toString");b.exports=c},{"../lang/toString":12}],26:[function(a,b){function c(a){return a=d(a),a.toUpperCase()}var d=a("../lang/toString");b.exports=c},{"../lang/toString":12}],27:[function(a,b){function c(a,b,c){var f=this,g=f.defs[a];c=c||{},b=b||{};var h;if(g)if(d._o(b)){if(c=d._(g,c),c.upsert&&d._sn(b[g.idAttribute]))return f.update(a,b[g.idAttribute],b,c)}else h=d._oErr("attrs");else h=new e.NER(a);return new d.Promise(function(a,c){h?c(h):a(b)}).then(function(a){return c.beforeValidate.call(a,c,a)}).then(function(a){return c.validate.call(a,c,a)}).then(function(a){return c.afterValidate.call(a,c,a)}).then(function(a){return c.beforeCreate.call(a,c,a)}).then(function(a){return c.notify&&g.emit("DS.beforeCreate",g,d.copy(a)),f.getAdapter(c).create(g,a,c)}).then(function(a){return c.afterCreate.call(a,c,a)}).then(function(b){if(c.notify&&g.emit("DS.afterCreate",g,d.copy(b)),c.cacheResponse){var e=f.inject(g.n,b,c),h=e[g.idAttribute];return f.s[a].completedQueries[h]=(new Date).getTime(),e}return f.createInstance(a,b,c)})}var d=a("../../utils"),e=a("../../errors");b.exports=c},{"../../errors":48,"../../utils":50}],28:[function(a,b){function c(a,b,c){var f,g=this,h=g.defs[a];return new d.Promise(function(i,j){b=d.resolveId(h,b),h?d._sn(b)?(f=g.get(a,b)||{id:b},c=d._(h,c),i(f)):j(d._snErr("id")):j(new e.NER(a))}).then(function(a){return c.beforeDestroy.call(a,c,a)}).then(function(e){return c.notify&&h.emit("DS.beforeDestroy",h,d.copy(e)),c.eagerEject&&g.eject(a,b),g.getAdapter(c).destroy(h,b,c)}).then(function(){return c.afterDestroy.call(f,c,f)}).then(function(e){return c.notify&&h.emit("DS.afterDestroy",h,d.copy(e)),g.eject(a,b),b})["catch"](function(b){throw c&&c.eagerEject&&f&&g.inject(a,f,{notify:!1}),b})}var d=a("../../utils"),e=a("../../errors");b.exports=c},{"../../errors":48,"../../utils":50}],29:[function(a,b){function c(a,b,c){var f,g,h=this,i=h.defs[a];return b=b||{},new d.Promise(function(f,g){i?d._o(b)?(c=d._(i,c),f()):g(d._oErr("attrs")):g(new e.NER(a))}).then(function(){return g=h.defaults.defaultFilter.call(h,a,b),c.beforeDestroy(c,g)}).then(function(){return c.notify&&i.emit("DS.beforeDestroy",i,d.copy(g)),c.eagerEject&&(f=h.ejectAll(a,b)),h.getAdapter(c).destroyAll(i,b,c)}).then(function(){return c.afterDestroy(c,g)}).then(function(){return c.notify&&i.emit("DS.afterDestroy",i,d.copy(g)),f||h.ejectAll(a,b)})["catch"](function(b){throw c&&c.eagerEject&&f&&h.inject(a,f,{notify:!1}),b})}var d=a("../../utils"),e=a("../../errors");b.exports=c},{"../../errors":48,"../../utils":50}],30:[function(a,b){function c(a,b,c){var f=this,g=f.defs[a],h=f.s[a];return new d.Promise(function(i,j){g?d._sn(b)?(c=d._(g,c),c.params&&(c.params=d.copy(c.params)),(c.bypassCache||!c.cacheResponse)&&delete h.completedQueries[b],b in h.completedQueries&&f.get(a,b)?i(f.get(a,b)):(delete h.completedQueries[b],i())):j(d._snErr("id")):j(new e.NER(a))}).then(function(d){function e(a){return f.getAdapter((c.findFallbackAdapters||c.fallbackAdapters)[a]).find(g,b,c)["catch"](function(b){return a++,a<c.fallbackAdapters.length?e(a):Promise.reject(b)})}if(d)return d;if(!(b in h.pendingQueries)){var i,j=c.findStrategy||c.strategy;i="fallback"===j?e(0):f.getAdapter(c).find(g,b,c),h.pendingQueries[b]=i.then(function(d){if(delete h.pendingQueries[b],c.cacheResponse){var e=f.inject(a,d,c);return h.completedQueries[b]=(new Date).getTime(),e}return f.createInstance(a,d,c)})}return h.pendingQueries[b]})["catch"](function(a){throw h&&delete h.pendingQueries[b],a})}var d=a("../../utils"),e=a("../../errors");b.exports=c},{"../../errors":48,"../../utils":50}],31:[function(a,b){function c(a,b,c,d){var f=this,g=f.s[b],h=f.defs[b].idAttribute,i=(new Date).getTime();a=a||[],delete g.pendingQueries[c],g.completedQueries[c]=i,g.collectionModified=e.updateTimestamp(g.collectionModified);var j=f.inject(b,a,d);return e._a(j)?e.forEach(j,function(a){a&&a[h]&&(g.completedQueries[a[h]]=i)}):(d.errorFn("response is expected to be an array!"),g.completedQueries[j[h]]=i),j}function d(a,b,d){var g,h=this,i=h.defs[a],j=h.s[a];return new e.Promise(function(c,k){b=b||{},h.defs[a]?e._o(b)?(d=e._(i,d),g=e.toJson(b),d.params&&(d.params=e.copy(d.params)),(d.bypassCache||!d.cacheResponse)&&(delete j.completedQueries[g],delete j.queryData[g]),g in j.completedQueries?c(d.useFilter?h.filter(a,b,d):j.queryData[g]):c()):k(e._oErr("params")):k(new f.NER(a))}).then(function(f){function k(a){return h.getAdapter((d.findAllFallbackAdapters||d.fallbackAdapters)[a]).findAll(i,b,d)["catch"](function(b){return a++,a<d.fallbackAdapters.length?k(a):Promise.reject(b)})}if(g in j.completedQueries)return f;if(!(g in j.pendingQueries)){var l,m=d.findAllStrategy||d.strategy;l="fallback"===m?k(0):h.getAdapter(d).findAll(i,b,d),j.pendingQueries[g]=l.then(function(b){return delete j.pendingQueries[g],d.cacheResponse?(j.queryData[g]=c.call(h,b,a,g,d),j.queryData[g].$$injected=!0,j.queryData[g]):(e.forEach(b,function(c,e){b[e]=h.createInstance(a,c,d)}),b)})}return j.pendingQueries[g]})["catch"](function(a){throw j&&delete j.pendingQueries[g],a})}var e=a("../../utils"),f=a("../../errors");b.exports=d},{"../../errors":48,"../../utils":50}],32:[function(a,b){function c(a,b){var c=this,d=c.defs[a],f=c.s[a];return new e.Promise(function(g,h){if(d){b=e._(d,b),b.hasOwnProperty("notify")||(b.notify=!1);for(var i,j=[],k=(new Date).getTime();(i=f.expiresHeap.peek())&&i.expires<k;)j.push(i.item),delete i.item,f.expiresHeap.pop();g(j)}else h(new c.errors.NER(a))}).then(function(g){if((b.isInterval||b.notify)&&(d.beforeReap(b,g),d.emit("DS.beforeReap",d,e.copy(g))),"inject"===b.reapAction)e.forEach(g,function(a){var b=a[d.idAttribute];f.expiresHeap.push({item:a,timestamp:f.saved[b],expires:d.maxAge?f.saved[b]+d.maxAge:Number.MAX_VALUE})});else if("eject"===b.reapAction)e.forEach(g,function(b){c.eject(a,b[d.idAttribute])});else if("refresh"===b.reapAction){var h=[];return e.forEach(g,function(b){h.push(c.refresh(a,b[d.idAttribute]))}),e.Promise.all(h)}return g}).then(function(a){return(b.isInterval||b.notify)&&(d.afterReap(b,a),d.emit("DS.afterReap",d,e.copy(a))),a})}function d(a,b,c){var d=this;return new e.Promise(function(f,g){var h=d.defs[a];b=e.resolveId(d.defs[a],b),h?e._sn(b)?(c=e._(h,c),c.bypassCache=!0,f(d.get(a,b))):g(e._snErr("id")):g(new d.errors.NER(a))}).then(function(e){return e?d.find(a,b,c):e})}{var e=a("../../utils");a("../../errors")}b.exports={create:a("./create"),destroy:a("./destroy"),destroyAll:a("./destroyAll"),find:a("./find"),findAll:a("./findAll"),loadRelations:a("./loadRelations"),reap:c,refresh:d,save:a("./save"),update:a("./update"),updateAll:a("./updateAll")}},{"../../errors":48,"../../utils":50,"./create":27,"./destroy":28,"./destroyAll":29,"./find":30,"./findAll":31,"./loadRelations":33,"./save":34,"./update":35,"./updateAll":36}],33:[function(a,b){function c(a,b,c,f){var g=this,h=g.defs[a],i=[];return new d.Promise(function(j,k){if(d._sn(b)&&(b=g.get(a,b)),d._s(c)&&(c=[c]),h)if(d._o(b))if(d._a(c)){var l=d._(h,f);l.hasOwnProperty("findBelongsTo")||(l.findBelongsTo=!0),l.hasOwnProperty("findHasMany")||(l.findHasMany=!0);var m=[];d.forEach(h.relationList,function(a){var e=a.relation,j=h.getResource(e),k=d._(j,f);if(d.contains(c,e)||d.contains(c,a.localField)){var l,n={};k.allowSimpleWhere?n[a.foreignKey]=b[h.idAttribute]:(n.where={},n.where[a.foreignKey]={"==":b[h.idAttribute]}),"hasMany"===a.type&&n[a.foreignKey]?l=g.findAll(e,n,k):"hasOne"===a.type?a.localKey&&b[a.localKey]?l=g.find(e,b[a.localKey],k):a.foreignKey&&n[a.foreignKey]&&(l=g.findAll(e,n,k).then(function(a){return a.length?a[0]:null})):b[a.localKey]&&(l=g.find(e,b[a.localKey],f)),l&&(m.push(l),i.push(a.localField))}}),j(m)}else k(new e.IA('"relations" must be a string or an array!'));else k(new e.IA('"instance(id)" must be a string, number or object!'));else k(new e.NER(a))}).then(function(a){return d.Promise.all(a)}).then(function(a){return d.forEach(i,function(c,d){b[c]=a[d]}),b})}var d=a("../../utils"),e=a("../../errors");b.exports=c},{"../../errors":48,"../../utils":50}],34:[function(a,b){function c(a,b,c){var f,g=this,h=g.defs[a];return new d.Promise(function(i,j){b=d.resolveId(h,b),h?d._sn(b)?g.get(a,b)?(f=g.get(a,b),c=d._(h,c),i(f)):j(new e.R('id "'+b+'" not found in cache!')):j(d._snErr("id")):j(new e.NER(a))}).then(function(a){return c.beforeValidate.call(a,c,a)}).then(function(a){return c.validate.call(a,c,a)}).then(function(a){return c.afterValidate.call(a,c,a)}).then(function(a){return c.beforeUpdate.call(a,c,a)}).then(function(e){if(c.notify&&h.emit("DS.beforeUpdate",h,d.copy(e)),c.changesOnly){var f=g.s[a];d.w&&f.observers[b].deliver();var i=[],j=g.changes(a,b);for(var k in j.added)i.push(k);for(k in j.changed)i.push(k);if(j=d.pick(e,i),d.isEmpty(j))return e;e=j}return g.getAdapter(c).update(h,b,e,c)}).then(function(a){return c.afterUpdate.call(a,c,a)}).then(function(b){return c.notify&&h.emit("DS.afterUpdate",h,d.copy(b)),c.cacheResponse?g.inject(h.n,b,c):g.createInstance(a,b,c)})}var d=a("../../utils"),e=a("../../errors");b.exports=c},{"../../errors":48,"../../utils":50}],35:[function(a,b){function c(a,b,c,f){var g=this,h=g.defs[a];return new d.Promise(function(g,i){b=d.resolveId(h,b),h?d._sn(b)?(f=d._(h,f),g(c)):i(d._snErr("id")):i(new e.NER(a))}).then(function(a){return f.beforeValidate.call(a,f,a)}).then(function(a){return f.validate.call(a,f,a)}).then(function(a){return f.afterValidate.call(a,f,a)}).then(function(a){return f.beforeUpdate.call(a,f,a)}).then(function(a){return f.notify&&h.emit("DS.beforeUpdate",h,d.copy(a)),g.getAdapter(f).update(h,b,a,f)}).then(function(a){return f.afterUpdate.call(a,f,a)}).then(function(b){return f.notify&&h.emit("DS.afterUpdate",h,d.copy(b)),f.cacheResponse?g.inject(h.n,b,f):g.createInstance(a,b,f)})}var d=a("../../utils"),e=a("../../errors");b.exports=c},{"../../errors":48,"../../utils":50}],36:[function(a,b){function c(a,b,c,f){var g=this,h=g.defs[a];return new d.Promise(function(c,g){h?(f=d._(h,f),c(b)):g(new e.NER(a))}).then(function(a){return f.beforeValidate.call(a,f,a)}).then(function(a){return f.validate.call(a,f,a)}).then(function(a){return f.afterValidate.call(a,f,a)}).then(function(a){return f.beforeUpdate.call(a,f,a)}).then(function(a){return f.notify&&h.emit("DS.beforeUpdate",h,d.copy(a)),g.getAdapter(f).updateAll(h,a,c,f)}).then(function(a){return f.afterUpdate.call(a,f,a)}).then(function(c){if(f.notify&&h.emit("DS.afterUpdate",h,d.copy(b)),f.cacheResponse)return g.inject(h.n,c,f);var e=[];return d.forEach(c,function(b){e.push(g.createInstance(a,b,f))}),e})}var d=a("../../utils"),e=a("../../errors");b.exports=c},{"../../errors":48,"../../utils":50}],37:[function(a,b){function c(a,b,c){c(null,b)}function d(a,b){return b}function e(a,b,c,d){var f=a[b],g=i.get(c,f[0]),h=i.get(d,f[0]);return i._s(g)&&(g=i.upperCase(g)),i._s(h)&&(h=i.upperCase(h)),"DESC"===f[1]?g>h?-1:h>g?1:b<a.length-1?e(a,b+1,c,d):0:h>g?-1:g>h?1:b<a.length-1?e(a,b+1,c,d):0}function f(){}function g(b){var c=this;b=b||{};try{h=a("js-data-schema")}catch(d){}if(!h||i.isEmpty(h))try{h=window.Schemator}catch(d){}(h||b.schemator)&&(c.schemator=b.schemator||new h),c.store={},c.s=c.store,c.definitions={},c.defs=c.definitions,c.adapters={},c.defaults=new f,c.observe=i.observe,i.forOwn(b,function(a,b){c.defaults[b]=a})}var h,i=a("../utils"),j=a("../errors"),k=a("./sync_methods"),l=a("./async_methods"),m=f.prototype;m.actions={},m.afterCreate=c,m.afterCreateInstance=d,m.afterDestroy=c,m.afterEject=d,m.afterInject=d,m.afterReap=d,m.afterUpdate=c,m.afterValidate=c,m.allowSimpleWhere=!0,m.basePath="",m.beforeCreate=c,m.beforeCreateInstance=d,m.beforeDestroy=c,m.beforeEject=d,m.beforeInject=d,m.beforeReap=d,m.beforeUpdate=c,m.beforeValidate=c,m.bypassCache=!1,m.cacheResponse=!!i.w,m.defaultAdapter="http",m.debug=!0,m.eagerEject=!1,m.eagerInject=!1,m.endpoint="",m.error=console?function(a,b,c){console["function"==typeof console.error?"error":"log"](a,b,c)}:!1,m.errorFn=function(a,b){if(this.error&&"function"==typeof this.error){try{throw"string"==typeof a?new Error(a):a}catch(c){a=c}this.error(this.name||null,a||null,b||null)}},m.fallbackAdapters=["http"],m.findBelongsTo=!0,m.findHasOne=!0,m.findHasMany=!0,m.findInverseLinks=!0,m.idAttribute="id",m.ignoredChanges=[/\$/],m.ignoreMissing=!1,m.keepChangeHistory=!1,m.loadFromServer=!1,m.log=console?function(a,b,c,d,e){console["function"==typeof console.info?"info":"log"](a,b,c,d,e)}:!1,m.logFn=function(a,b,c,d){this.debug&&this.log&&"function"==typeof this.log&&this.log(this.name||null,a||null,b||null,c||null,d||null)},m.maxAge=!1,m.notify=!!i.w,m.reapAction=i.w?"inject":"none",m.reapInterval=i.w?3e4:!1,m.resetHistoryOnInject=!0,m.strategy="single",m.upsert=!!i.w,m.useClass=!0,m.useFilter=!1,m.validate=c,m.defaultFilter=function(a,b,c,d){var f=a,g=null,h={skip:"",offset:"",where:"",limit:"",orderBy:"",sort:""};
c=c||{},d=d||{},g=i._o(c.where)?c.where:{},d.allowSimpleWhere&&i.forOwn(c,function(a,b){b in h||b in g||(g[b]={"==":a})}),i.isEmpty(g)&&(g=null),g&&(f=i.filter(f,function(a){var b=!0,c=!0;return i.forOwn(g,function(d,e){i._s(d)?d={"===":d}:(i._n(d)||i.isBoolean(d))&&(d={"==":d}),i._o(d)&&i.forOwn(d,function(d,f){var g,h="|"===f[0],j=a[e];f=h?f.substr(1):f,"=="===f?g=j==d:"==="===f?g=j===d:"!="===f?g=j!=d:"!=="===f?g=j!==d:">"===f?g=j>d:">="===f?g=j>=d:"<"===f?g=d>j:"<="===f?g=d>=j:"isectEmpty"===f?g=!i.intersection(j||[],d||[]).length:"isectNotEmpty"===f?g=i.intersection(j||[],d||[]).length:"in"===f?g=i._s(d)?-1!==d.indexOf(j):i.contains(d,j):"notIn"===f?g=i._s(d)?-1===d.indexOf(j):!i.contains(d,j):"contains"===f?g=i._s(j)?-1!==j.indexOf(d):i.contains(j,d):"notContains"===f&&(g=i._s(j)?-1===j.indexOf(d):!i.contains(j,d)),void 0!==g&&(c=b?g:h?c||g:c&&g),b=!1})}),c}));var k=null;if(i._s(c.orderBy)?k=[[c.orderBy,"ASC"]]:i._a(c.orderBy)&&(k=c.orderBy),!k&&i._s(c.sort)?k=[[c.sort,"ASC"]]:!k&&i._a(c.sort)&&(k=c.sort),k){var l=0;i.forEach(k,function(a,b){if(i._s(a))k[b]=[a,"ASC"];else if(!i._a(a))throw new j.IA("DS.filter(resourceName[, params][, options]): "+i.toJson(a)+": Must be a string or an array!",{params:{"orderBy[i]":{actual:typeof a,expected:"string|array"}}})}),f=i.sort(f,function(a,b){return e(k,l,a,b)})}var m=i._n(c.limit)?c.limit:null,n=null;return i._n(c.skip)?n=c.skip:i._n(c.offset)&&(n=c.offset),m&&n?f=i.slice(f,n,Math.min(f.length,n+m)):i._n(m)?f=i.slice(f,0,Math.min(f.length,m)):i._n(n)&&(f=n<f.length?i.slice(f,n):[]),f};var n=g.prototype;n.getAdapter=function(a){var b=!1;a=a||{},i._s(a)&&(b=!0,a={adapter:a});var c=this.adapters[a.adapter];if(c)return c;if(b)throw new Error(a.adapter+" is not a registered adapter!");return this.adapters[a.defaultAdapter]},n.getAdapter.shorthand=!1,n.registerAdapter=function(a,b,c){var d=this;c=c||{},d.adapters[a]=i.isFunction(b)?new b(c):b,c["default"]&&(d.defaults.defaultAdapter=a)},n.registerAdapter.shorthand=!1,n.is=function(a,b){var c=this.defs[a];if(!c)throw new j.NER(a);return b instanceof c[c["class"]]},n.errors=a("../errors"),n.utils=i,i.deepMixIn(n,k),i.deepMixIn(n,l),b.exports=g},{"../errors":48,"../utils":50,"./async_methods":32,"./sync_methods":42,"js-data-schema":"js-data-schema"}],38:[function(require,module,exports){function Resource(a){DSUtils.deepMixIn(this,a),this.endpoint="endpoint"in a?a.endpoint:this.name}function defineResource(definition){var _this=this,definitions=_this.defs;if(DSUtils._s(definition)&&(definition={name:definition.replace(/\s/gi,"")}),!DSUtils._o(definition))throw DSUtils._oErr("definition");if(!DSUtils._s(definition.name))throw new DSErrors.IA('"name" must be a string!');if(_this.s[definition.name])throw new DSErrors.R(definition.name+" is already registered!");try{Resource.prototype=_this.defaults,definitions[definition.name]=new Resource(definition);var def=definitions[definition.name];if(def.n=def.name,!DSUtils._s(def.idAttribute))throw new DSErrors.IA('"idAttribute" must be a string!');def.relations&&(def.relationList=[],def.relationFields=[],DSUtils.forOwn(def.relations,function(a,b){DSUtils.forOwn(a,function(c,d){DSUtils._a(c)||(a[d]=[c]),DSUtils.forEach(a[d],function(a){a.type=b,a.relation=d,a.name=def.n,def.relationList.push(a),def.relationFields.push(a.localField)})})}),def.relations.belongsTo&&DSUtils.forOwn(def.relations.belongsTo,function(a,b){DSUtils.forEach(a,function(a){a.parent&&(def.parent=b,def.parentKey=a.localKey,def.parentField=a.localField)})}),"function"==typeof Object.freeze&&(Object.freeze(def.relations),Object.freeze(def.relationList))),def.getResource=function(a){return _this.defs[a]},def.getEndpoint=function(a,b){b.params=b.params||{};var c,d=def.parentKey,e=b.hasOwnProperty("endpoint")?b.endpoint:def.endpoint,f=def.parentField,g=definitions[def.parent],h=b.params[d];if(h!==!1&&d&&g){if(delete b.params[d],DSUtils._sn(a)?c=def.get(a):DSUtils._o(a)&&(c=a),c&&(h=h||c[d]||(c[f]?c[f][g.idAttribute]:null)),h){delete b.endpoint;var i={};return DSUtils.forOwn(b,function(a,b){i[b]=a}),DSUtils.makePath(g.getEndpoint(h,DSUtils._(g,i)),h,e)}return e}return h===!1&&delete b.params[d],e},def.filter&&(def.defaultFilter=def.filter,delete def.filter),def["class"]=DSUtils.pascalCase(def.name);try{"function"==typeof def.useClass?(eval("function "+def["class"]+"() { def.useClass.call(this); }"),def[def["class"]]=eval(def["class"]),def[def["class"]].prototype=function(a){function b(){}return b.prototype=a,new b}(def.useClass.prototype)):(eval("function "+def["class"]+"() {}"),def[def["class"]]=eval(def["class"]))}catch(e){def[def["class"]]=function(){}}def.methods&&DSUtils.deepMixIn(def[def["class"]].prototype,def.methods),def[def["class"]].prototype.set=function(a,b){DSUtils.set(this,a,b);var c=_this.s[def.n].observers[this[def.idAttribute]];return c&&!DSUtils.observe.hasObjectObserve?c.deliver():_this.compute(def.n,this),this},def[def["class"]].prototype.get=function(a){return DSUtils.get(this,a)},def.computed&&DSUtils.forOwn(def.computed,function(a,b){DSUtils.isFunction(a)&&(def.computed[b]=[a],a=def.computed[b]),def.methods&&b in def.methods&&def.errorFn('Computed property "'+b+'" conflicts with previously defined prototype method!');var c;if(1===a.length){var d=a[0].toString().match(/function.*?\(([\s\S]*?)\)/);c=d[1].split(","),def.computed[b]=c.concat(a),a=def.computed[b],c.length&&def.errorFn("Use the computed property array syntax for compatibility with minified code!")}c=a.slice(0,a.length-1),DSUtils.forEach(c,function(a,b){c[b]=a.trim()}),a.deps=DSUtils.filter(c,function(a){return!!a})}),definition.schema&&_this.schemator&&(def.schema=_this.schemator.defineSchema(def.n,definition.schema),definition.hasOwnProperty("validate")||(def.validate=function(a,b,c){def.schema.validate(b,{ignoreMissing:def.ignoreMissing},function(a){return a?c(a):c(null,b)})})),DSUtils.forEach(instanceMethods,function(a){def[def["class"]].prototype["DS"+DSUtils.pascalCase(a)]=function(){var b=Array.prototype.slice.call(arguments);return b.unshift(this[def.idAttribute]||this),b.unshift(def.n),_this[a].apply(_this,b)}}),def[def["class"]].prototype.DSCreate=function(){var a=Array.prototype.slice.call(arguments);return a.unshift(this),a.unshift(def.n),_this.create.apply(_this,a)},_this.s[def.n]={collection:[],expiresHeap:new DSUtils.DSBinaryHeap(function(a){return a.expires},function(a,b){return a.item===b}),completedQueries:{},queryData:{},pendingQueries:{},index:{},modified:{},saved:{},previousAttributes:{},observers:{},changeHistories:{},changeHistory:[],collectionModified:0},def.reapInterval&&setInterval(function(){_this.reap(def.n,{isInterval:!0})},def.reapInterval);for(var key in _this)"function"==typeof _this[key]&&(_this[key].shorthand!==!1?!function(a){def[a]=function(){var b=Array.prototype.slice.call(arguments);return b.unshift(def.n),_this[a].apply(_this,b)}}(key):!function(a){def[a]=function(){return _this[a].apply(_this,Array.prototype.slice.call(arguments))}}(key));return def.beforeValidate=DSUtils.promisify(def.beforeValidate),def.validate=DSUtils.promisify(def.validate),def.afterValidate=DSUtils.promisify(def.afterValidate),def.beforeCreate=DSUtils.promisify(def.beforeCreate),def.afterCreate=DSUtils.promisify(def.afterCreate),def.beforeUpdate=DSUtils.promisify(def.beforeUpdate),def.afterUpdate=DSUtils.promisify(def.afterUpdate),def.beforeDestroy=DSUtils.promisify(def.beforeDestroy),def.afterDestroy=DSUtils.promisify(def.afterDestroy),DSUtils.forOwn(def.actions,function(a,b){if(def[b])throw new Error('Cannot override existing method "'+b+'"!');def[b]=function(c){c=c||{};var d=_this.getAdapter(a.adapter||"http"),e=DSUtils.deepMixIn({},a);return!c.hasOwnProperty("endpoint")&&e.endpoint&&(c.endpoint=e.endpoint),e.url="function"==typeof c.getEndpoint?c.getEndpoint(def,c):DSUtils.makePath(c.basePath||d.defaults.basePath||def.basePath,def.getEndpoint(null,c),b),e.method=e.method||"GET",DSUtils.deepMixIn(e,c),d.HTTP(e)}}),DSUtils.Events(def),def}catch(err){throw delete definitions[definition.name],delete _this.s[definition.name],err}}var DSUtils=require("../../utils"),DSErrors=require("../../errors"),instanceMethods=["compute","refresh","save","update","destroy","loadRelations","changeHistory","changes","hasChanges","lastModified","lastSaved","link","linkInverse","previous","unlinkInverse"];module.exports=defineResource},{"../../errors":48,"../../utils":50}],39:[function(a,b){function c(a,b,c){var f,g=this,h=g.defs[a],i=g.s[a],j=!1;if(b=d.resolveId(h,b),!h)throw new e.NER(a);if(!d._sn(b))throw d._snErr("id");c=d._(h,c);for(var k=0;k<i.collection.length;k++)if(i.collection[k][h.idAttribute]==b){f=i.collection[k],i.expiresHeap.remove(f),j=!0;break}if(j){c.notify&&(h.beforeEject(c,f),h.emit("DS.beforeEject",h,d.copy(f))),g.unlinkInverse(h.n,b),i.collection.splice(k,1),d.w&&i.observers[b].close(),delete i.observers[b],delete i.index[b],delete i.previousAttributes[b],delete i.completedQueries[b],delete i.pendingQueries[b],d.forEach(i.changeHistories[b],function(a){d.remove(i.changeHistory,a)});var l=[];return d.forOwn(i.queryData,function(a,b){a.$$injected&&d.remove(a,f),a.length||l.push(b)}),d.forEach(l,function(a){delete i.completedQueries[a],delete i.queryData[a]}),delete i.changeHistories[b],delete i.modified[b],delete i.saved[b],i.collectionModified=d.updateTimestamp(i.collectionModified),c.notify&&(h.afterEject(c,f),h.emit("DS.afterEject",h,d.copy(f))),f}}var d=a("../../utils"),e=a("../../errors");b.exports=c},{"../../errors":48,"../../utils":50}],40:[function(a,b){function c(a,b,c){var f=this,g=f.defs[a];if(b=b||{},!g)throw new e.NER(a);if(!d._o(b))throw d._oErr("params");var h=f.s[a];d.isEmpty(b)&&(h.completedQueries={});var i=d.toJson(b),j=f.filter(g.n,b),k=[];return d.forEach(j,function(a){a&&a[g.idAttribute]&&k.push(a[g.idAttribute])}),d.forEach(k,function(a){f.eject(g.n,a,c)}),delete h.completedQueries[i],h.collectionModified=d.updateTimestamp(h.collectionModified),j}var d=a("../../utils"),e=a("../../errors");b.exports=c},{"../../errors":48,"../../utils":50}],41:[function(a,b){function c(a,b,c){var f=this,g=f.defs[a],h=f.s[a];if(!g)throw new e.NER(a);if(b&&!d._o(b))throw d._oErr("params");c=d._(g,c),b=b||{};var i=d.toJson(b);return i in h.completedQueries||!c.loadFromServer||h.pendingQueries[i]||f.findAll(a,b,c),g.defaultFilter.call(f,h.collection,a,b,c)}var d=a("../../utils"),e=a("../../errors");b.exports=c},{"../../errors":48,"../../utils":50}],42:[function(a,b){function c(a,b,c){var d=this,e=d.defs[a];if(c=c||{},b=o.resolveId(e,b),!e)throw new q(a);if(!o._sn(b))throw o._snErr("id");c=o._(e,c);var f=d.get(a,b);if(f){o.w&&d.s[a].observers[b].deliver();var g=o.diffObjectFromOldObject(f,d.s[a].previousAttributes[b],o.equals,c.ignoredChanges);return o.forOwn(g,function(a,b){var c=[];o.forOwn(a,function(a,b){o.isFunction(a)||c.push(b)}),g[b]=o.pick(g[b],c)}),o.forEach(e.relationFields,function(a){delete g.added[a],delete g.removed[a],delete g.changed[a]}),g}}function d(a,b){var c=this,d=c.defs[a],e=c.s[a];if(b=o.resolveId(d,b),a&&!c.defs[a])throw new q(a);if(b&&!o._sn(b))throw o._snErr("id");if(d.keepChangeHistory){if(!a)return e.changeHistory;var f=c.get(a,b);if(f)return e.changeHistories[b]}else d.errorFn("changeHistory is disabled for this resource!")}function e(a,b){var c=this,d=c.defs[a];if(b=o.resolveItem(c.s[a],b),!d)throw new q(a);if(!b)throw new s("Item not in the store!");if(!o._o(b)&&!o._sn(b))throw new r('"instance" must be an object, string or number!');return o.forOwn(d.computed,function(a,c){o.compute.call(b,a,c)}),b}function f(a,b,c){var d,e=this.defs[a];if(b=b||{},!e)throw new q(a);if(b&&!o.isObject(b))throw new r('"attrs" must be an object!');if(c=o._(e,c),c.notify&&c.beforeCreateInstance(c,b),c.useClass){var f=e[e["class"]];d=new f}else d={};return o.deepMixIn(d,b),c.notify&&c.afterCreateInstance(c,b),d}function g(a){return!(o.isEmpty(a.added)&&o.isEmpty(a.removed)&&o.isEmpty(a.changed))}function h(){this.observe.Platform.performMicrotaskCheckpoint()}function i(a,b,c){var d=this,e=d.defs[a];if(!e)throw new q(a);if(!o._sn(b))throw o._snErr("id");c=o._(e,c);var f=d.s[a].index[b];return!f&&c.loadFromServer&&d.find(a,b,c),f}function j(a,b){var c=this,d=c.defs[a],e=c.s[a],f=[];if(!d)throw new q(a);if(b&&!o._a(b))throw o._aErr("ids");if(o._a(b))for(var g=b.length,h=0;g>h;h++)e.index[b[h]]&&f.push(e.index[b[h]]);else f=e.collection.slice();return f}function k(a,b){var c=this,d=c.defs[a];if(b=o.resolveId(d,b),!d)throw new q(a);if(!o._sn(b))throw o._snErr("id");return c.get(a,b)?g(c.changes(a,b)):!1}function l(a,b){var c=this.defs[a],d=this.s[a];if(b=o.resolveId(c,b),!c)throw new q(a);return b?(b in d.modified||(d.modified[b]=0),d.modified[b]):d.collectionModified}function m(a,b){var c=this.defs[a],d=this.s[a];if(b=o.resolveId(c,b),!c)throw new q(a);return b in d.saved||(d.saved[b]=0),d.saved[b]}function n(a,b){var c=this,d=c.defs[a],e=c.s[a];if(b=o.resolveId(d,b),!d)throw new q(a);if(!o._sn(b))throw o._snErr("id");return e.previousAttributes[b]?o.copy(e.previousAttributes[b]):void 0}var o=a("../../utils"),p=a("../../errors"),q=p.NER,r=p.IA,s=p.R;b.exports={changes:c,changeHistory:d,compute:e,createInstance:f,defineResource:a("./defineResource"),digest:h,eject:a("./eject"),ejectAll:a("./ejectAll"),filter:a("./filter"),get:i,getAll:j,hasChanges:k,inject:a("./inject"),lastModified:l,lastSaved:m,link:a("./link"),linkAll:a("./linkAll"),linkInverse:a("./linkInverse"),previous:n,unlinkInverse:a("./unlinkInverse")}},{"../../errors":48,"../../utils":50,"./defineResource":38,"./eject":39,"./ejectAll":40,"./filter":41,"./inject":43,"./link":44,"./linkAll":45,"./linkInverse":46,"./unlinkInverse":47}],43:[function(a,b){function c(a,b,c){var d=b.n;return function(e,f,h,i,j){var k,l=this,m=i&&i(b.idAttribute)?i(b.idAttribute):l[b.idAttribute];if(g.forEach(b.relationFields,function(a){delete e[a],delete f[a],delete h[a]}),(!g.isEmpty(e)||!g.isEmpty(f)||!g.isEmpty(h)||j)&&(k=a.get(d,m),c.modified[m]=g.updateTimestamp(c.modified[m]),c.collectionModified=g.updateTimestamp(c.collectionModified),b.keepChangeHistory)){var n={resourceName:d,target:k,added:e,removed:f,changed:h,timestamp:c.modified[m]};c.changeHistories[m].push(n),c.changeHistory.push(n)}b.computed&&(k=k||a.get(d,m),g.forOwn(b.computed,function(a,b){var c=!1;g.forEach(a.deps,function(a){(a in e||a in f||a in h||!(b in k))&&(c=!0)}),c=c||!a.deps.length,c&&g.compute.call(k,a,b)})),b.relations&&(k=k||a.get(d,m),g.forEach(b.relationList,function(c){k[c.localField]&&(c.localKey in e||c.localKey in f||c.localKey in h)&&a.link(d,k[b.idAttribute],[c.relation])})),b.idAttribute in h&&b.errorFn('Doh! You just changed the primary key of an object! Your data for the "'+d+'" resource is now in an undefined (probably broken) state.')}}function d(a,b,e,f){var i,j=this,k=c(j,a,b,e,f);if(g._a(e)){i=[];for(var l=0;l<e.length;l++)i.push(d.call(j,a,b,e[l],f))}else{var m=a.computed,n=a.idAttribute;if(m&&m[n]){var o=[];g.forEach(m[n].deps,function(a){o.push(e[a])}),e[n]=m[n][m[n].length-1].apply(e,o)}if(!(n in e)){var p=new h.R(a.n+'.inject: "attrs" must contain the property specified by `idAttribute`!');throw f.errorFn(p),p}try{g.forEach(a.relationList,function(b){var c=b.relation,d=j.defs[c],i=e[b.localField];if(i){if(!d)throw new h.R(a.n+" relation is defined but the resource is not!");if(g._a(i)){var k=[];g.forEach(i,function(g){if(g!==j.s[c][g[d.idAttribute]])try{var h=j.inject(c,g,f);b.foreignKey&&(h[b.foreignKey]=e[a.idAttribute]),k.push(h)}catch(i){f.errorFn(i,"Failed to inject "+b.type+' relation: "'+c+'"!')}}),e[b.localField]=k}else if(i!==j.s[c][i[d.idAttribute]])try{e[b.localField]=j.inject(c,e[b.localField],f),b.foreignKey&&(e[b.localField][b.foreignKey]=e[a.idAttribute])}catch(l){f.errorFn(l,"Failed to inject "+b.type+' relation: "'+c+'"!')}}});var q=e[n],r=j.get(a.n,q),s=r?b.modified[q]:0;r?(g.deepMixIn(r,e),a.resetHistoryOnInject&&(b.previousAttributes[q]={},g.deepMixIn(b.previousAttributes[q],e),b.changeHistories[q].length&&(g.forEach(b.changeHistories[q],function(a){g.remove(b.changeHistory,a)}),b.changeHistories[q].splice(0,b.changeHistories[q].length))),g.w&&b.observers[q].deliver()):(r=f.useClass?e instanceof a[a["class"]]?e:new a[a["class"]]:{},b.previousAttributes[q]=g.copy(e),g.deepMixIn(r,e),b.collection.push(r),b.changeHistories[q]=[],g.w&&(b.observers[q]=new j.observe.ObjectObserver(r),b.observers[q].open(k,r)),b.index[q]=r,k.call(r,{},{},{},null,!0)),b.saved[q]=g.updateTimestamp(b.saved[q]),b.modified[q]=s&&b.modified[q]===s?g.updateTimestamp(b.modified[q]):b.modified[q],b.expiresHeap.remove(r),b.expiresHeap.push({item:r,timestamp:b.saved[q],expires:a.maxAge?b.saved[q]+a.maxAge:Number.MAX_VALUE}),i=r}catch(t){f.errorFn(t,e)}}return i}function e(a,b,c){var d=this;g.forEach(a.relationList,function(e){c.findBelongsTo&&"belongsTo"===e.type&&b[a.idAttribute]?d.link(a.n,b[a.idAttribute],[e.relation]):(c.findHasMany&&"hasMany"===e.type||c.findHasOne&&"hasOne"===e.type)&&d.link(a.n,b[a.idAttribute],[e.relation])})}function f(a,b,c){var f,i=this,j=i.defs[a],k=i.s[a];if(!j)throw new h.NER(a);if(!g._o(b)&&!g._a(b))throw new h.IA(a+'.inject: "attrs" must be an object or an array!');var l=j.n;return c=g._(j,c),c.notify&&(c.beforeInject(c,b),j.emit("DS.beforeInject",j,g.copy(b))),f=d.call(i,j,k,b,c),k.collectionModified=g.updateTimestamp(k.collectionModified),c.findInverseLinks&&(g._a(f)?f.length&&i.linkInverse(l,f[0][j.idAttribute]):i.linkInverse(l,f[j.idAttribute])),g._a(f)?g.forEach(f,function(a){e.call(i,j,a,c)}):e.call(i,j,f,c),c.notify&&(c.afterInject(c,f),j.emit("DS.afterInject",j,g.copy(f))),f}var g=a("../../utils"),h=a("../../errors");b.exports=f},{"../../errors":48,"../../utils":50}],44:[function(a,b){function c(a,b,c){var f=this,g=f.defs[a];if(c=c||[],b=d.resolveId(g,b),!g)throw new e.NER(a);if(!d._sn(b))throw d._snErr("id");if(!d._a(c))throw d._aErr("relations");var h=f.get(a,b);return h&&d.forEach(g.relationList,function(a){var b=a.relation;if(!c.length||d.contains(c,b)){var e={};if("belongsTo"===a.type){var i=h[a.localKey]?f.get(b,h[a.localKey]):null;i&&(h[a.localField]=i)}else if("hasMany"===a.type)e[a.foreignKey]=h[g.idAttribute],h[a.localField]=f.defaults.constructor.prototype.defaultFilter.call(f,f.s[b].collection,b,e,{allowSimpleWhere:!0});else if("hasOne"===a.type){e[a.foreignKey]=h[g.idAttribute];var j=f.defaults.constructor.prototype.defaultFilter.call(f,f.s[b].collection,b,e,{allowSimpleWhere:!0});j.length&&(h[a.localField]=j[0])}}}),h}var d=a("../../utils"),e=a("../../errors");b.exports=c},{"../../errors":48,"../../utils":50}],45:[function(a,b){function c(a,b,c){var f=this,g=f.defs[a];if(c=c||[],!g)throw new e.NER(a);if(!d._a(c))throw d._aErr("relations");var h=f.filter(a,b);return h&&d.forEach(g.relationList,function(a){var b=a.relation;(!c.length||d.contains(c,b))&&("belongsTo"===a.type?d.forEach(h,function(c){var d=c[a.localKey]?f.get(b,c[a.localKey]):null;d&&(c[a.localField]=d)}):"hasMany"===a.type?d.forEach(h,function(c){var d={};d[a.foreignKey]=c[g.idAttribute],c[a.localField]=f.defaults.constructor.prototype.defaultFilter.call(f,f.s[b].collection,b,d,{allowSimpleWhere:!0})}):"hasOne"===a.type&&d.forEach(h,function(c){var d={};d[a.foreignKey]=c[g.idAttribute];var e=f.defaults.constructor.prototype.defaultFilter.call(f,f.s[b].collection,b,d,{allowSimpleWhere:!0});e.length&&(c[a.localField]=e[0])}))}),h}var d=a("../../utils"),e=a("../../errors");b.exports=c},{"../../errors":48,"../../utils":50}],46:[function(a,b){function c(a,b,c){var f=this,g=f.defs[a];if(c=c||[],b=d.resolveId(g,b),!g)throw new e.NER(a);if(!d._sn(b))throw d._snErr("id");if(!d._a(c))throw d._aErr("relations");var h=f.get(a,b);return h&&d.forOwn(f.defs,function(a){d.forOwn(a.relations,function(b){d.forOwn(b,function(b,e){(!c.length||d.contains(c,a.n))&&g.n===e&&f.linkAll(a.n,{},[g.n])})})}),h}var d=a("../../utils"),e=a("../../errors");b.exports=c},{"../../errors":48,"../../utils":50}],47:[function(a,b){function c(a,b,c){var f=this,g=f.defs[a];if(c=c||[],b=d.resolveId(g,b),!g)throw new e.NER(a);if(!d._sn(b))throw d._snErr("id");if(!d._a(c))throw d._aErr("relations");var h=f.get(a,b);return h&&d.forOwn(f.defs,function(a){d.forOwn(a.relations,function(a){d.forOwn(a,function(a,b){g.n===b&&d.forEach(a,function(a){d.forEach(f.s[a.name].collection,function(b){if("hasMany"===a.type&&b[a.localField]){var c;d.forEach(b[a.localField],function(a,b){a===h&&(c=b)}),b[a.localField].splice(c,1)}else b[a.localField]===h&&delete b[a.localField]})})})})}),h}var d=a("../../utils"),e=a("../../errors");b.exports=c},{"../../errors":48,"../../utils":50}],48:[function(a,b){function c(a){Error.call(this),"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.type=this.constructor.name,this.message=a||"Illegal Argument!"}function d(a){Error.call(this),"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.type=this.constructor.name,this.message=a||"RuntimeError Error!"}function e(a){Error.call(this),"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.type=this.constructor.name,this.message=(a||"")+" is not a registered resource!"}c.prototype=new Error,c.prototype.constructor=c,d.prototype=new Error,d.prototype.constructor=d,e.prototype=new Error,e.prototype.constructor=e,b.exports={IllegalArgumentError:c,IA:c,RuntimeError:d,R:d,NonexistentResourceError:e,NER:e}},{}],49:[function(a,b){var c=a("./datastore");b.exports={DS:c,createStore:function(a){return new c(a)},DSUtils:a("./utils"),DSErrors:a("./errors"),version:{full:"1.5.0",major:parseInt("1",10),minor:parseInt("5",10),patch:parseInt("0",10),alpha:!1,beta:!1}}},{"./datastore":37,"./errors":48,"./utils":50}],50:[function(a,b){function c(a){return"[object RegExp]"==G.call(a)||!1}function d(a){return a===!0||a===!1||a&&"object"==typeof a&&"[object Boolean]"==G.call(a)||!1}function e(a){return"string"==typeof a||a&&"object"==typeof a&&"[object String]"==G.call(a)||!1}function f(a){return"[object Object]"==G.call(a)||!1}function g(a){return a&&"object"==typeof a&&"[object Date]"==G.call(a)||!1}function h(a){var b=typeof a;return"number"==b||a&&"object"==b&&"[object Number]"==G.call(a)||!1}function i(a){return"function"==typeof a||a&&"[object Function]"===G.call(a)||!1}function j(a){return e(a)||h(a)}function k(a){return new H.IA('"'+a+'" must be a string or a number!')}function l(a){return new H.IA('"'+a+'" must be an object!')}function m(a){return new H.IA('"'+a+'" must be an array!')}function n(a){if(null==a)return!0;if("string"==typeof a||N(a))return!a.length;if("object"==typeof a){var b=!0;return K(a,function(){return b=!1,!1}),b}return!0}function o(a,b){if(!a||!b)return[];for(var c,d=[],e=0,f=a.length;f>e;e++)c=a[e],R.contains(d,c)||R.contains(b,c)&&d.push(c);return d}function p(a,b,c){var d=[];return I(a,function(a,c,e){b(a,c,e)&&d.push(a)},c),d}function q(a){var b=this.constructor;return this.then(function(c){return b.resolve(a()).then(function(){return c})},function(c){return b.resolve(a()).then(function(){throw c})})}function r(a){var b="function"==typeof Date.now?Date.now():(new Date).getTime();return a&&a>=b?a+1:b}function s(a){var b={};a=a||this,a.on=function(a,c,d){b[a]=b[a]||[],b[a].push({f:c,c:d})},a.off=function(a,c){var d=b[a];if(d)if(c){for(var e=0;e<d.length;e++)if(d[e]===c){d.splice(e,1);break}}else d.splice(0,d.length);else b={}},a.emit=function(){var a=Array.prototype.slice.call(arguments),c=b[a.shift()]||[];if(c)for(var d=0;d<c.length;d++)c[d].f.apply(c[d].c,a)}}function t(a,b,c){for(var d=a[c],e=b(d);c>0;){var f=Math.floor((c+1)/2)-1,g=a[f];if(e>=b(g))break;a[f]=d,a[c]=g,c=f}}function u(a,b,c){for(var d=a.length,e=a[c],f=b(e);;){var g=2*(c+1),h=g-1,i=null;if(d>h){var j=a[h],k=b(j);f>k&&(i=h)}if(d>g){var l=a[g],m=b(l);m<(null===i?f:b(a[h]))&&(i=g)}if(null===i)break;a[c]=a[i],a[i]=e,c=i}}function v(a,b){if(a&&!i(a))throw new Error("DSBinaryHeap(weightFunc): weightFunc: must be a function!");a=a||function(a){return a},b=b||function(a,b){return a===b},this.weightFunc=a,this.compareFunc=b,this.heap=[]}function w(a,b,d,e){if(b){if(a===b)throw new Error("Cannot copy! Source and destination are identical.");if(d=d||[],e=e||[],f(a)){var h=d.indexOf(a);if(-1!==h)return e[h];d.push(a),e.push(b)}var i;if(N(a)){b.length=0;for(var j=0;j<a.length;j++)i=w(a[j],null,d,e),f(a[j])&&(d.push(a[j]),e.push(i)),b.push(i)}else{N(b)?b.length=0:I(b,function(a,c){delete b[c]});for(var k in a)a.hasOwnProperty(k)&&(i=w(a[k],null,d,e),f(a[k])&&(d.push(a[k]),e.push(i)),b[k]=i)}}else if(b=a,a)if(N(a))b=w(a,[],d,e);else if(g(a))b=new Date(a.getTime());else if(c(a))b=new RegExp(a.source,a.toString().match(/[^\/]*$/)[0]),b.lastIndex=a.lastIndex;else if(f(a)){var l=Object.create(Object.getPrototypeOf(a));b=w(a,l,d,e)}return b}function x(a,b){if(a===b)return!0;if(null===a||null===b)return!1;if(a!==a&&b!==b)return!0;var d,e,f,h=typeof a,j=typeof b;if(h==j&&"object"==h){if(!N(a)){if(g(a))return g(b)?x(a.getTime(),b.getTime()):!1;if(c(a)&&c(b))return a.toString()==b.toString();if(N(b))return!1;f={};for(e in a)if("$"!==e.charAt(0)&&!i(a[e])){if(!x(a[e],b[e]))return!1;f[e]=!0}for(e in b)if(!f.hasOwnProperty(e)&&"$"!==e.charAt(0)&&void 0!==b[e]&&!i(b[e]))return!1;return!0}if(!N(b))return!1;if((d=a.length)==b.length){for(e=0;d>e;e++)if(!x(a[e],b[e]))return!1;return!0}}return!1}function y(a,b){return this.isString(b)||h(b)?b:b&&a?b[a.idAttribute]||b:b}function z(a,b){return a&&(e(b)||h(b))?a.index[b]||b:b}function A(a){return null!=a&&""!==a}function B(a,b){return b=b||"",p(a,A).join(b)}function C(){var a=B(J(arguments),"/");return a.replace(/([^:\/]|^)\/{2,}/g,"$1/")}var D,E,F=Object.prototype,G=F.toString,H=a("./errors"),I=a("mout/array/forEach"),J=a("mout/array/slice"),K=a("mout/object/forOwn"),L=a("../lib/observe-js/observe-js"),M=a("es6-promise");M.polyfill();var N=Array.isArray||function(a){return"[object Array]"==G.call(a)||!1};try{D=window,D.Promise.prototype["finally"]||(D.Promise.prototype["finally"]=q),E=D.Promise,D={}}catch(O){D=null,E=a("bluebird")}var P=v.prototype;P.push=function(a){this.heap.push(a),t(this.heap,this.weightFunc,this.heap.length-1)},P.peek=function(){return this.heap[0]},P.pop=function(){var a=this.heap[0],b=this.heap.pop();return this.heap.length>0&&(this.heap[0]=b,u(this.heap,this.weightFunc,0)),a},P.remove=function(a){for(var b=this.heap.length,c=0;b>c;c++)if(this.compareFunc(this.heap[c],a)){var d=this.heap[c],e=this.heap.pop();return c!==b-1&&(this.heap[c]=e,t(this.heap,this.weightFunc,c),u(this.heap,this.weightFunc,c)),d}return null},P.removeAll=function(){this.heap=[]},P.size=function(){return this.heap.length};var Q=["beforeValidate","validate","afterValidate","beforeCreate","afterCreate","beforeUpdate","afterUpdate","beforeDestroy","afterDestroy"];L.setEqualityFn(x);var R={_:function(a,b){var c=this;if(b=b||{},b&&b.constructor===a.constructor)return b;if(!f(b))throw new H.IA('"options" must be an object!');I(Q,function(a){"function"==typeof b[a]&&-1===b[a].toString().indexOf("var args = Array")&&(b[a]=c.promisify(b[a]))});var d=function(a){var b=this;K(a,function(a,c){b[c]=a})};return d.prototype=a,new d(b)},_n:h,_s:e,_sn:j,_snErr:k,_o:f,_oErr:l,_a:N,_aErr:m,compute:function(a,b){var c=this,d=[];I(a.deps,function(a){d.push(c[a])}),c[b]=a[a.length-1].apply(c,d)},contains:a("mout/array/contains"),copy:w,deepMixIn:a("mout/object/deepMixIn"),diffObjectFromOldObject:L.diffObjectFromOldObject,DSBinaryHeap:v,equals:x,Events:s,filter:p,forEach:I,forOwn:K,fromJson:function(a){return e(a)?JSON.parse(a):a},get:a("mout/object/get"),intersection:o,isArray:N,isBoolean:d,isDate:g,isEmpty:n,isFunction:i,isObject:f,isNumber:h,isRegExp:c,isString:e,makePath:C,observe:L,pascalCase:a("mout/string/pascalCase"),pick:a("mout/object/pick"),Promise:E,promisify:function(a,b){var c=this.Promise;if(a){if("function"!=typeof a)throw new Error("Can only promisify functions!");return function(){var d=Array.prototype.slice.apply(arguments);return new c(function(c,e){d.push(function(a,b){a?e(a):c(b)});try{var f=a.apply(b||this,d);f&&f.then&&f.then(c,e)}catch(g){e(g)}})}}},remove:a("mout/array/remove"),set:a("mout/object/set"),slice:J,sort:a("mout/array/sort"),toJson:JSON.stringify,updateTimestamp:r,upperCase:a("mout/string/upperCase"),removeCircular:function(a){var b=[];return function c(a){var d,e;if(!("object"!=typeof a||null===a||a instanceof Boolean||a instanceof Date||a instanceof Number||a instanceof RegExp||a instanceof String)){for(d=0;d<b.length;d+=1)if(b[d]===a)return void 0;if(b.push(a),R.isArray(a))for(e=[],d=0;d<a.length;d+=1)e[d]=c(a[d]);else e={},K(a,function(b,d){e[d]=c(a[d])});return e}return a}(a)},resolveItem:z,resolveId:y,w:D};b.exports=R},{"../lib/observe-js/observe-js":1,"./errors":48,bluebird:"bluebird","es6-promise":2,"mout/array/contains":4,"mout/array/forEach":5,"mout/array/remove":7,"mout/array/slice":8,"mout/array/sort":9,"mout/object/deepMixIn":13,"mout/object/forOwn":15,"mout/object/get":16,"mout/object/pick":19,"mout/object/set":20,"mout/string/pascalCase":23,"mout/string/upperCase":26}]},{},[49])(49)});
!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;"undefined"!=typeof window?b=window:"undefined"!=typeof global?b=global:"undefined"!=typeof self&&(b=self),b.JSData=a()}}(function(){var define,module,exports;return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(require,module,exports){!function(global){"use strict";function detectObjectObserve(){function a(a){b=a}if("function"!=typeof Object.observe||"function"!=typeof Array.observe)return!1;var b=[],c={},d=[];return Object.observe(c,a),Array.observe(d,a),c.id=1,c.id=2,delete c.id,d.push(1,2),d.length=0,Object.deliverChangeRecords(a),5!==b.length?!1:"add"!=b[0].type||"update"!=b[1].type||"delete"!=b[2].type||"splice"!=b[3].type||"splice"!=b[4].type?!1:(Object.unobserve(c,a),Array.unobserve(d,a),!0)}function detectEval(){if("undefined"!=typeof chrome&&chrome.app&&chrome.app.runtime)return!1;try{var a=new Function("","return true;");return a()}catch(b){return!1}}function dirtyCheck(a){for(var b=0;MAX_DIRTY_CHECK_CYCLES>b&&a.check_();)b++;return global.testingExposeCycleCount&&(global.dirtyCheckCycleCount=b),b>0}function objectIsEmpty(a){for(var b in a)return!1;return!0}function diffIsEmpty(a){return objectIsEmpty(a.added)&&objectIsEmpty(a.removed)&&objectIsEmpty(a.changed)}function isBlacklisted(a,b){if(!b||!b.length)return!1;for(var c,d=0;d<b.length;d++)if("[object RegExp]"===Object.prototype.toString.call(b[d])&&b[d].test(a)||b[d]===a)return c=a;return!!c}function diffObjectFromOldObject(a,b,c,d){var e={},f={},g={};for(var h in b){var i=a[h];isBlacklisted(h,d)||void 0!==i&&(c?c(i,b[h]):i===b[h])||(h in a?(c?c(i,b[h]):i===b[h])||(g[h]=i):f[h]=void 0)}for(var h in a)h in b||isBlacklisted(h,d)||(e[h]=a[h]);return Array.isArray(a)&&a.length!==b.length&&(g.length=a.length),{added:e,removed:f,changed:g}}function runEOMTasks(){if(!eomTasks.length)return!1;for(var a=0;a<eomTasks.length;a++)eomTasks[a]();return eomTasks.length=0,!0}function newObservedObject(){function a(a){b&&b.state_===OPENED&&!d&&b.check_(a)}var b,c,d=!1,e=!0;return{open:function(c){if(b)throw Error("ObservedObject in use");e||Object.deliverChangeRecords(a),b=c,e=!1},observe:function(b,d){c=b,d?Array.observe(c,a):Object.observe(c,a)},deliver:function(b){d=b,Object.deliverChangeRecords(a),d=!1},close:function(){b=void 0,Object.unobserve(c,a),observedObjectCache.push(this)}}}function getObservedObject(a,b,c){var d=observedObjectCache.pop()||newObservedObject();return d.open(a),d.observe(b,c),d}function Observer(){this.state_=UNOPENED,this.callback_=void 0,this.target_=void 0,this.directObserver_=void 0,this.value_=void 0,this.id_=nextObserverId++}function addToAll(a){Observer._allObserversCount++,collectObservers&&allObservers.push(a)}function removeFromAll(){Observer._allObserversCount--}function ObjectObserver(a){Observer.call(this),this.value_=a,this.oldObject_=void 0}function diffObjectFromChangeRecords(a,b,c){for(var d={},e={},f=0;f<b.length;f++){var g=b[f];expectedRecordTypes[g.type]?(g.name in c||(c[g.name]=g.oldValue),"update"!=g.type&&("add"!=g.type?g.name in d?(delete d[g.name],delete c[g.name]):e[g.name]=!0:g.name in e?delete e[g.name]:d[g.name]=!0)):(console.error("Unknown changeRecord type: "+g.type),console.error(g))}for(var h in d)d[h]=a[h];for(var h in e)e[h]=void 0;var i={};for(var h in c)if(!(h in d||h in e)){var j=a[h];c[h]!==j&&(i[h]=j)}return{added:d,removed:e,changed:i}}var equalityFn=function(a,b){return a===b},blacklist=[],hasObserve=detectObjectObserve(),hasEval=detectEval(),createObject="__proto__"in{}?function(a){return a}:function(a){var b=a.__proto__;if(!b)return a;var c=Object.create(b);return Object.getOwnPropertyNames(a).forEach(function(b){Object.defineProperty(c,b,Object.getOwnPropertyDescriptor(a,b))}),c},MAX_DIRTY_CHECK_CYCLES=1e3,eomTasks=[],runEOM=hasObserve?function(){var a={pingPong:!0},b=!1;return Object.observe(a,function(){runEOMTasks(),b=!1}),function(c){eomTasks.push(c),b||(b=!0,a.pingPong=!a.pingPong)}}():function(){return function(a){eomTasks.push(a)}}(),observedObjectCache=[],UNOPENED=0,OPENED=1,CLOSED=2,nextObserverId=1;Observer.prototype={open:function(a,b){if(this.state_!=UNOPENED)throw Error("Observer has already been opened.");return addToAll(this),this.callback_=a,this.target_=b,this.connect_(),this.state_=OPENED,this.value_},close:function(){this.state_==OPENED&&(removeFromAll(this),this.disconnect_(),this.value_=void 0,this.callback_=void 0,this.target_=void 0,this.state_=CLOSED)},deliver:function(){this.state_==OPENED&&dirtyCheck(this)},report_:function(a){try{this.callback_.apply(this.target_,a)}catch(b){Observer._errorThrownDuringCallback=!0,console.error("Exception caught during observer callback: "+(b.stack||b))}},discardChanges:function(){return this.check_(void 0,!0),this.value_}};var collectObservers=!hasObserve,allObservers;Observer._allObserversCount=0,collectObservers&&(allObservers=[]);var runningMicrotaskCheckpoint=!1,hasDebugForceFullDelivery=hasObserve&&hasEval&&function(){try{return eval("%RunMicrotasks()"),!0}catch(ex){return!1}}();global.Platform=global.Platform||{},global.Platform.performMicrotaskCheckpoint=function(){if(!runningMicrotaskCheckpoint){if(hasDebugForceFullDelivery)return void eval("%RunMicrotasks()");if(collectObservers){runningMicrotaskCheckpoint=!0;var cycles=0,anyChanged,toCheck;do{cycles++,toCheck=allObservers,allObservers=[],anyChanged=!1;for(var i=0;i<toCheck.length;i++){var observer=toCheck[i];observer.state_==OPENED&&(observer.check_()&&(anyChanged=!0),allObservers.push(observer))}runEOMTasks()&&(anyChanged=!0)}while(MAX_DIRTY_CHECK_CYCLES>cycles&&anyChanged);global.testingExposeCycleCount&&(global.dirtyCheckCycleCount=cycles),runningMicrotaskCheckpoint=!1}}},collectObservers&&(global.Platform.clearObservers=function(){allObservers=[]}),ObjectObserver.prototype=createObject({__proto__:Observer.prototype,arrayObserve:!1,connect_:function(){hasObserve?this.directObserver_=getObservedObject(this,this.value_,this.arrayObserve):this.oldObject_=this.copyObject(this.value_)},copyObject:function(a){var b=Array.isArray(a)?[]:{};for(var c in a)b[c]=a[c];return Array.isArray(a)&&(b.length=a.length),b},check_:function(a){var b,c;if(hasObserve){if(!a)return!1;c={},b=diffObjectFromChangeRecords(this.value_,a,c)}else c=this.oldObject_,b=diffObjectFromOldObject(this.value_,this.oldObject_);return diffIsEmpty(b)?!1:(hasObserve||(this.oldObject_=this.copyObject(this.value_)),this.report_([b.added||{},b.removed||{},b.changed||{},function(a){return c[a]}]),!0)},disconnect_:function(){hasObserve?(this.directObserver_.close(),this.directObserver_=void 0):this.oldObject_=void 0},deliver:function(){this.state_==OPENED&&(hasObserve?this.directObserver_.deliver(!1):dirtyCheck(this))},discardChanges:function(){return this.directObserver_?this.directObserver_.deliver(!0):this.oldObject_=this.copyObject(this.value_),this.value_}});var observerSentinel={},expectedRecordTypes={add:!0,update:!0,"delete":!0};global.Observer=Observer,global.diffObjectFromOldObject=diffObjectFromOldObject,global.setEqualityFn=function(a){equalityFn=a},global.setBlacklist=function(a){blacklist=a},global.Observer.runEOM_=runEOM,global.Observer.observerSentinel_=observerSentinel,global.Observer.hasObjectObserve=hasObserve,global.ObjectObserver=ObjectObserver}(exports)},{}],2:[function(a,b){(function(a,c){(function(){"use strict";function d(a){return"function"==typeof a||"object"==typeof a&&null!==a}function e(a){return"function"==typeof a}function f(a){return"object"==typeof a&&null!==a}function g(){}function h(){return function(){a.nextTick(l)}}function i(){var a=0,b=new O(l),c=document.createTextNode("");return b.observe(c,{characterData:!0}),function(){c.data=a=++a%2}}function j(){var a=new MessageChannel;return a.port1.onmessage=l,function(){a.port2.postMessage(0)}}function k(){return function(){setTimeout(l,1)}}function l(){for(var a=0;L>a;a+=2){var b=Q[a],c=Q[a+1];b(c),Q[a]=void 0,Q[a+1]=void 0}L=0}function m(){}function n(){return new TypeError("You cannot resolve a promise with itself")}function o(){return new TypeError("A promises callback cannot return that same promise.")}function p(a){try{return a.then}catch(b){return U.error=b,U}}function q(a,b,c,d){try{a.call(b,c,d)}catch(e){return e}}function r(a,b,c){M(function(a){var d=!1,e=q(c,b,function(c){d||(d=!0,b!==c?u(a,c):w(a,c))},function(b){d||(d=!0,x(a,b))},"Settle: "+(a._label||" unknown promise"));!d&&e&&(d=!0,x(a,e))},a)}function s(a,b){b._state===S?w(a,b._result):a._state===T?x(a,b._result):y(b,void 0,function(b){u(a,b)},function(b){x(a,b)})}function t(a,b){if(b.constructor===a.constructor)s(a,b);else{var c=p(b);c===U?x(a,U.error):void 0===c?w(a,b):e(c)?r(a,b,c):w(a,b)}}function u(a,b){a===b?x(a,n()):d(b)?t(a,b):w(a,b)}function v(a){a._onerror&&a._onerror(a._result),z(a)}function w(a,b){a._state===R&&(a._result=b,a._state=S,0===a._subscribers.length||M(z,a))}function x(a,b){a._state===R&&(a._state=T,a._result=b,M(v,a))}function y(a,b,c,d){var e=a._subscribers,f=e.length;a._onerror=null,e[f]=b,e[f+S]=c,e[f+T]=d,0===f&&a._state&&M(z,a)}function z(a){var b=a._subscribers,c=a._state;if(0!==b.length){for(var d,e,f=a._result,g=0;g<b.length;g+=3)d=b[g],e=b[g+c],d?C(c,d,e,f):e(f);a._subscribers.length=0}}function A(){this.error=null}function B(a,b){try{return a(b)}catch(c){return V.error=c,V}}function C(a,b,c,d){var f,g,h,i,j=e(c);if(j){if(f=B(c,d),f===V?(i=!0,g=f.error,f=null):h=!0,b===f)return void x(b,o())}else f=d,h=!0;b._state!==R||(j&&h?u(b,f):i?x(b,g):a===S?w(b,f):a===T&&x(b,f))}function D(a,b){try{b(function(b){u(a,b)},function(b){x(a,b)})}catch(c){x(a,c)}}function E(a,b,c,d){this._instanceConstructor=a,this.promise=new a(m,d),this._abortOnReject=c,this._validateInput(b)?(this._input=b,this.length=b.length,this._remaining=b.length,this._init(),0===this.length?w(this.promise,this._result):(this.length=this.length||0,this._enumerate(),0===this._remaining&&w(this.promise,this._result))):x(this.promise,this._validationError())}function F(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function G(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function H(a){this._id=_++,this._state=void 0,this._result=void 0,this._subscribers=[],m!==a&&(e(a)||F(),this instanceof H||G(),D(this,a))}var I;I=Array.isArray?Array.isArray:function(a){return"[object Array]"===Object.prototype.toString.call(a)};var J,K=I,L=(Date.now||function(){return(new Date).getTime()},Object.create||function(a){if(arguments.length>1)throw new Error("Second argument not supported");if("object"!=typeof a)throw new TypeError("Argument must be an object");return g.prototype=a,new g},0),M=function(a,b){Q[L]=a,Q[L+1]=b,L+=2,2===L&&J()},N="undefined"!=typeof window?window:{},O=N.MutationObserver||N.WebKitMutationObserver,P="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,Q=new Array(1e3);J="undefined"!=typeof a&&"[object process]"==={}.toString.call(a)?h():O?i():P?j():k();var R=void 0,S=1,T=2,U=new A,V=new A;E.prototype._validateInput=function(a){return K(a)},E.prototype._validationError=function(){return new Error("Array Methods must be provided an Array")},E.prototype._init=function(){this._result=new Array(this.length)};var W=E;E.prototype._enumerate=function(){for(var a=this.length,b=this.promise,c=this._input,d=0;b._state===R&&a>d;d++)this._eachEntry(c[d],d)},E.prototype._eachEntry=function(a,b){var c=this._instanceConstructor;f(a)?a.constructor===c&&a._state!==R?(a._onerror=null,this._settledAt(a._state,b,a._result)):this._willSettleAt(c.resolve(a),b):(this._remaining--,this._result[b]=this._makeResult(S,b,a))},E.prototype._settledAt=function(a,b,c){var d=this.promise;d._state===R&&(this._remaining--,this._abortOnReject&&a===T?x(d,c):this._result[b]=this._makeResult(a,b,c)),0===this._remaining&&w(d,this._result)},E.prototype._makeResult=function(a,b,c){return c},E.prototype._willSettleAt=function(a,b){var c=this;y(a,void 0,function(a){c._settledAt(S,b,a)},function(a){c._settledAt(T,b,a)})};var X=function(a,b){return new W(this,a,!0,b).promise},Y=function(a,b){function c(a){u(f,a)}function d(a){x(f,a)}var e=this,f=new e(m,b);if(!K(a))return x(f,new TypeError("You must pass an array to race.")),f;for(var g=a.length,h=0;f._state===R&&g>h;h++)y(e.resolve(a[h]),void 0,c,d);return f},Z=function(a,b){var c=this;if(a&&"object"==typeof a&&a.constructor===c)return a;var d=new c(m,b);return u(d,a),d},$=function(a,b){var c=this,d=new c(m,b);return x(d,a),d},_=0,ab=H;H.all=X,H.race=Y,H.resolve=Z,H.reject=$,H.prototype={constructor:H,then:function(a,b){var c=this,d=c._state;if(d===S&&!a||d===T&&!b)return this;var e=new this.constructor(m),f=c._result;if(d){var g=arguments[d-1];M(function(){C(d,e,g,f)})}else y(c,e,a,b);return e},"catch":function(a){return this.then(null,a)}};var bb=function(){var a;a="undefined"!=typeof c?c:"undefined"!=typeof window&&window.document?window:self;var b="Promise"in a&&"resolve"in a.Promise&&"reject"in a.Promise&&"all"in a.Promise&&"race"in a.Promise&&function(){var b;return new a.Promise(function(a){b=a}),e(b)}();b||(a.Promise=ab)},cb={Promise:ab,polyfill:bb};"function"==typeof define&&define.amd?define(function(){return cb}):"undefined"!=typeof b&&b.exports?b.exports=cb:"undefined"!=typeof this&&(this.ES6Promise=cb)}).call(this)}).call(this,a("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:3}],3:[function(a,b){function c(){if(!g){g=!0;for(var a,b=f.length;b;){a=f,f=[];for(var c=-1;++c<b;)a[c]();b=f.length}g=!1}}function d(){}var e=b.exports={},f=[],g=!1;e.nextTick=function(a){f.push(a),g||setTimeout(c,0)},e.title="browser",e.browser=!0,e.env={},e.argv=[],e.version="",e.on=d,e.addListener=d,e.once=d,e.off=d,e.removeListener=d,e.removeAllListeners=d,e.emit=d,e.binding=function(){throw new Error("process.binding is not supported")},e.cwd=function(){return"/"},e.chdir=function(){throw new Error("process.chdir is not supported")},e.umask=function(){return 0}},{}],4:[function(a,b){function c(a,b){return-1!==d(a,b)}var d=a("./indexOf");b.exports=c},{"./indexOf":6}],5:[function(a,b){function c(a,b,c){if(null!=a)for(var d=-1,e=a.length;++d<e&&b.call(c,a[d],d,a)!==!1;);}b.exports=c},{}],6:[function(a,b){function c(a,b,c){if(c=c||0,null==a)return-1;for(var d=a.length,e=0>c?d+c:c;d>e;){if(a[e]===b)return e;e++}return-1}b.exports=c},{}],7:[function(a,b){function c(a,b){var c=d(a,b);-1!==c&&a.splice(c,1)}var d=a("./indexOf");b.exports=c},{"./indexOf":6}],8:[function(a,b){function c(a,b,c){var d=a.length;b=null==b?0:0>b?Math.max(d+b,0):Math.min(b,d),c=null==c?d:0>c?Math.max(d+c,0):Math.min(c,d);for(var e=[];c>b;)e.push(a[b++]);return e}b.exports=c},{}],9:[function(a,b){function c(a,b){if(null==a)return[];if(a.length<2)return a;null==b&&(b=d);var f,g,h;return f=~~(a.length/2),g=c(a.slice(0,f),b),h=c(a.slice(f,a.length),b),e(g,h,b)}function d(a,b){return b>a?-1:a>b?1:0}function e(a,b,c){for(var d=[];a.length&&b.length;)d.push(c(a[0],b[0])<=0?a.shift():b.shift());return a.length&&d.push.apply(d,a),b.length&&d.push.apply(d,b),d}b.exports=c},{}],10:[function(a,b){function c(a){return!!a&&"object"==typeof a&&a.constructor===Object}b.exports=c},{}],11:[function(a,b){function c(a){switch(typeof a){case"string":case"number":case"boolean":return!0}return null==a}b.exports=c},{}],12:[function(a,b){function c(a){return null==a?"":a.toString()}b.exports=c},{}],13:[function(a,b){function c(a){for(var b,c=0,f=arguments.length;++c<f;)b=arguments[c],b&&e(b,d,a);return a}function d(a,b){var d=this[b];f(a)&&f(d)?c(d,a):this[b]=a}var e=a("./forOwn"),f=a("../lang/isPlainObject");b.exports=c},{"../lang/isPlainObject":10,"./forOwn":15}],14:[function(a,b){function c(){g=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],f=!0;for(var a in{toString:null})f=!1}function d(a,b,d){var i,j=0;null==f&&c();for(i in a)if(e(b,a,i,d)===!1)break;if(f)for(var k=a.constructor,l=!!k&&a===k.prototype;(i=g[j++])&&("constructor"===i&&(l||!h(a,i))||a[i]===Object.prototype[i]||e(b,a,i,d)!==!1););}function e(a,b,c,d){return a.call(d,b[c],c,b)}var f,g,h=a("./hasOwn");b.exports=d},{"./hasOwn":17}],15:[function(a,b){function c(a,b,c){e(a,function(e,f){return d(a,f)?b.call(c,a[f],f,a):void 0})}var d=a("./hasOwn"),e=a("./forIn");b.exports=c},{"./forIn":14,"./hasOwn":17}],16:[function(a,b){function c(a,b){for(var c=b.split("."),d=c.pop();b=c.shift();)if(a=a[b],null==a)return;return a[d]}a("../lang/isPrimitive");b.exports=c},{"../lang/isPrimitive":11}],17:[function(a,b){function c(a,b){return Object.prototype.hasOwnProperty.call(a,b)}b.exports=c},{}],18:[function(a,b){function c(a,b){return b?(d(b.split("."),function(b){a[b]||(a[b]={}),a=a[b]}),a):a}var d=a("../array/forEach");b.exports=c},{"../array/forEach":5}],19:[function(a,b){function c(a){for(var b,c="string"!=typeof arguments[1]?arguments[1]:d(arguments,1),e={},f=0;b=c[f++];)e[b]=a[b];return e}var d=a("../array/slice");b.exports=c},{"../array/slice":8}],20:[function(a,b){function c(a,b,c){var e=/^(.+)\.(.+)$/.exec(b);e?d(a,e[1])[e[2]]=c:a[b]=c}var d=a("./namespace");b.exports=c},{"./namespace":18}],21:[function(a,b){function c(a){return a=d(a),a=e(a),a=f(a).replace(/[\-_]/g," ").replace(/\s[a-z]/g,g).replace(/\s+/g,"").replace(/^[A-Z]/g,h)}var d=a("../lang/toString"),e=a("./replaceAccents"),f=a("./removeNonWord"),g=a("./upperCase"),h=a("./lowerCase");b.exports=c},{"../lang/toString":12,"./lowerCase":22,"./removeNonWord":24,"./replaceAccents":25,"./upperCase":26}],22:[function(a,b){function c(a){return a=d(a),a.toLowerCase()}var d=a("../lang/toString");b.exports=c},{"../lang/toString":12}],23:[function(a,b){function c(a){return a=d(a),e(a).replace(/^[a-z]/,f)}var d=a("../lang/toString"),e=a("./camelCase"),f=a("./upperCase");b.exports=c},{"../lang/toString":12,"./camelCase":21,"./upperCase":26}],24:[function(a,b){function c(a){return a=d(a),a.replace(e,"")}var d=a("../lang/toString"),e=/[^\x20\x2D0-9A-Z\x5Fa-z\xC0-\xD6\xD8-\xF6\xF8-\xFF]/g;b.exports=c},{"../lang/toString":12}],25:[function(a,b){function c(a){return a=d(a),a.search(/[\xC0-\xFF]/g)>-1&&(a=a.replace(/[\xC0-\xC5]/g,"A").replace(/[\xC6]/g,"AE").replace(/[\xC7]/g,"C").replace(/[\xC8-\xCB]/g,"E").replace(/[\xCC-\xCF]/g,"I").replace(/[\xD0]/g,"D").replace(/[\xD1]/g,"N").replace(/[\xD2-\xD6\xD8]/g,"O").replace(/[\xD9-\xDC]/g,"U").replace(/[\xDD]/g,"Y").replace(/[\xDE]/g,"P").replace(/[\xE0-\xE5]/g,"a").replace(/[\xE6]/g,"ae").replace(/[\xE7]/g,"c").replace(/[\xE8-\xEB]/g,"e").replace(/[\xEC-\xEF]/g,"i").replace(/[\xF1]/g,"n").replace(/[\xF2-\xF6\xF8]/g,"o").replace(/[\xF9-\xFC]/g,"u").replace(/[\xFE]/g,"p").replace(/[\xFD\xFF]/g,"y")),a}var d=a("../lang/toString");b.exports=c},{"../lang/toString":12}],26:[function(a,b){function c(a){return a=d(a),a.toUpperCase()}var d=a("../lang/toString");b.exports=c},{"../lang/toString":12}],27:[function(a,b){function c(a,b,c){var f=this,g=f.defs[a];c=c||{},b=b||{};var h;if(g)if(d._o(b)){if(c=d._(g,c),c.upsert&&d._sn(b[g.idAttribute]))return f.update(a,b[g.idAttribute],b,c)}else h=d._oErr("attrs");else h=new e.NER(a);return new d.Promise(function(a,c){h?c(h):a(b)}).then(function(a){return c.beforeValidate.call(a,c,a)}).then(function(a){return c.validate.call(a,c,a)}).then(function(a){return c.afterValidate.call(a,c,a)}).then(function(a){return c.beforeCreate.call(a,c,a)}).then(function(a){return c.notify&&g.emit("DS.beforeCreate",g,a),f.getAdapter(c).create(g,a,c)}).then(function(a){return c.afterCreate.call(a,c,a)}).then(function(b){if(c.notify&&g.emit("DS.afterCreate",g,b),c.cacheResponse){var e=f.inject(g.n,b,c),h=e[g.idAttribute],i=f.s[a];return i.completedQueries[h]=(new Date).getTime(),i.saved[h]=d.updateTimestamp(i.saved[h]),e}return f.createInstance(a,b,c)})}var d=a("../../utils"),e=a("../../errors");b.exports=c},{"../../errors":48,"../../utils":50}],28:[function(a,b){function c(a,b,c){var f,g=this,h=g.defs[a];return new d.Promise(function(i,j){b=d.resolveId(h,b),h?d._sn(b)?(f=g.get(a,b)||{id:b},c=d._(h,c),i(f)):j(d._snErr("id")):j(new e.NER(a))}).then(function(a){return c.beforeDestroy.call(a,c,a)}).then(function(d){return c.notify&&h.emit("DS.beforeDestroy",h,d),c.eagerEject&&g.eject(a,b),g.getAdapter(c).destroy(h,b,c)}).then(function(){return c.afterDestroy.call(f,c,f)}).then(function(d){return c.notify&&h.emit("DS.afterDestroy",h,d),g.eject(a,b),b})["catch"](function(b){throw c&&c.eagerEject&&f&&g.inject(a,f,{notify:!1}),b})}var d=a("../../utils"),e=a("../../errors");b.exports=c},{"../../errors":48,"../../utils":50}],29:[function(a,b){function c(a,b,c){var f,g,h=this,i=h.defs[a];return b=b||{},new d.Promise(function(f,g){i?d._o(b)?(c=d._(i,c),f()):g(d._oErr("attrs")):g(new e.NER(a))}).then(function(){return g=h.defaults.defaultFilter.call(h,a,b),c.beforeDestroy(c,g)}).then(function(){return c.notify&&i.emit("DS.beforeDestroy",i,g),c.eagerEject&&(f=h.ejectAll(a,b)),h.getAdapter(c).destroyAll(i,b,c)}).then(function(){return c.afterDestroy(c,g)}).then(function(){return c.notify&&i.emit("DS.afterDestroy",i,g),f||h.ejectAll(a,b)})["catch"](function(b){throw c&&c.eagerEject&&f&&h.inject(a,f,{notify:!1}),b})}var d=a("../../utils"),e=a("../../errors");b.exports=c},{"../../errors":48,"../../utils":50}],30:[function(a,b){function c(a,b,c){var f=this,g=f.defs[a],h=f.s[a];return new d.Promise(function(i,j){g?d._sn(b)?(c=d._(g,c),c.params&&(c.params=d.copy(c.params)),(c.bypassCache||!c.cacheResponse)&&delete h.completedQueries[b],b in h.completedQueries&&f.get(a,b)?i(f.get(a,b)):(delete h.completedQueries[b],i())):j(d._snErr("id")):j(new e.NER(a))}).then(function(e){function i(a){return f.getAdapter((c.findFallbackAdapters||c.fallbackAdapters)[a]).find(g,b,c)["catch"](function(b){return a++,a<c.fallbackAdapters.length?i(a):Promise.reject(b)})}if(e)return e;if(!(b in h.pendingQueries)){var j,k=c.findStrategy||c.strategy;j="fallback"===k?i(0):f.getAdapter(c).find(g,b,c),h.pendingQueries[b]=j.then(function(e){if(delete h.pendingQueries[b],c.cacheResponse){var g=f.inject(a,e,c);return h.completedQueries[b]=(new Date).getTime(),h.saved[b]=d.updateTimestamp(h.saved[b]),g}return f.createInstance(a,e,c)})}return h.pendingQueries[b]})["catch"](function(a){throw h&&delete h.pendingQueries[b],a})}var d=a("../../utils"),e=a("../../errors");b.exports=c},{"../../errors":48,"../../utils":50}],31:[function(a,b){function c(a,b,c,d){var f=this,g=f.s[b],h=f.defs[b].idAttribute,i=(new Date).getTime();a=a||[],delete g.pendingQueries[c],g.completedQueries[c]=i,g.collectionModified=e.updateTimestamp(g.collectionModified);var j=f.inject(b,a,d);return e._a(j)?e.forEach(j,function(a){if(a){var b=a[h];b&&(g.completedQueries[b]=i,g.saved[b]=e.updateTimestamp(g.saved[b]))}}):(d.errorFn("response is expected to be an array!"),g.completedQueries[j[h]]=i),j}function d(a,b,d){var g,h=this,i=h.defs[a],j=h.s[a];return new e.Promise(function(c,k){b=b||{},h.defs[a]?e._o(b)?(d=e._(i,d),g=e.toJson(b),d.params&&(d.params=e.copy(d.params)),(d.bypassCache||!d.cacheResponse)&&(delete j.completedQueries[g],delete j.queryData[g]),g in j.completedQueries?c(d.useFilter?h.filter(a,b,d):j.queryData[g]):c()):k(e._oErr("params")):k(new f.NER(a))}).then(function(f){function k(a){return h.getAdapter((d.findAllFallbackAdapters||d.fallbackAdapters)[a]).findAll(i,b,d)["catch"](function(b){return a++,a<d.fallbackAdapters.length?k(a):Promise.reject(b)})}if(g in j.completedQueries)return f;if(!(g in j.pendingQueries)){var l,m=d.findAllStrategy||d.strategy;l="fallback"===m?k(0):h.getAdapter(d).findAll(i,b,d),j.pendingQueries[g]=l.then(function(b){return delete j.pendingQueries[g],d.cacheResponse?(j.queryData[g]=c.call(h,b,a,g,d),j.queryData[g].$$injected=!0,j.queryData[g]):(e.forEach(b,function(c,e){b[e]=h.createInstance(a,c,d)}),b)})}return j.pendingQueries[g]})["catch"](function(a){throw j&&delete j.pendingQueries[g],a})}var e=a("../../utils"),f=a("../../errors");b.exports=d},{"../../errors":48,"../../utils":50}],32:[function(a,b){function c(a,b){var c=this,d=c.defs[a],f=c.s[a];return new e.Promise(function(g,h){if(d){b=e._(d,b),b.hasOwnProperty("notify")||(b.notify=!1);for(var i,j=[],k=(new Date).getTime();(i=f.expiresHeap.peek())&&i.expires<k;)j.push(i.item),delete i.item,f.expiresHeap.pop();g(j)}else h(new c.errors.NER(a))}).then(function(g){if((b.isInterval||b.notify)&&(d.beforeReap(b,g),d.emit("DS.beforeReap",d,g)),"inject"===b.reapAction){var h=(new Date).getTime();e.forEach(g,function(a){a[d.idAttribute];f.expiresHeap.push({item:a,timestamp:h,expires:d.maxAge?h+d.maxAge:Number.MAX_VALUE})})}else if("eject"===b.reapAction)e.forEach(g,function(b){c.eject(a,b[d.idAttribute])});else if("refresh"===b.reapAction){var i=[];return e.forEach(g,function(b){i.push(c.refresh(a,b[d.idAttribute]))}),e.Promise.all(i)}return g}).then(function(a){return(b.isInterval||b.notify)&&(d.afterReap(b,a),d.emit("DS.afterReap",d,a)),a})}function d(a,b,c){var d=this;return new e.Promise(function(f,g){var h=d.defs[a];b=e.resolveId(d.defs[a],b),h?e._sn(b)?(c=e._(h,c),c.bypassCache=!0,f(d.get(a,b))):g(e._snErr("id")):g(new d.errors.NER(a))}).then(function(e){return e?d.find(a,b,c):e})}{var e=a("../../utils");a("../../errors")}b.exports={create:a("./create"),destroy:a("./destroy"),destroyAll:a("./destroyAll"),find:a("./find"),findAll:a("./findAll"),loadRelations:a("./loadRelations"),reap:c,refresh:d,save:a("./save"),update:a("./update"),updateAll:a("./updateAll")}},{"../../errors":48,"../../utils":50,"./create":27,"./destroy":28,"./destroyAll":29,"./find":30,"./findAll":31,"./loadRelations":33,"./save":34,"./update":35,"./updateAll":36}],33:[function(a,b){function c(a,b,c,f){var g=this,h=g.defs[a],i=[];return new d.Promise(function(j,k){if(d._sn(b)&&(b=g.get(a,b)),d._s(c)&&(c=[c]),h)if(d._o(b))if(d._a(c)){var l=d._(h,f);l.hasOwnProperty("findBelongsTo")||(l.findBelongsTo=!0),l.hasOwnProperty("findHasMany")||(l.findHasMany=!0);var m=[];d.forEach(h.relationList,function(a){var e=a.relation,j=h.getResource(e),k=d._(j,f);if(d.contains(c,e)||d.contains(c,a.localField)){var l,n={};k.allowSimpleWhere?n[a.foreignKey]=b[h.idAttribute]:(n.where={},n.where[a.foreignKey]={"==":b[h.idAttribute]}),"hasMany"===a.type&&n[a.foreignKey]?l=g.findAll(e,n,k):"hasOne"===a.type?a.localKey&&b[a.localKey]?l=g.find(e,b[a.localKey],k):a.foreignKey&&n[a.foreignKey]&&(l=g.findAll(e,n,k).then(function(a){return a.length?a[0]:null})):b[a.localKey]&&(l=g.find(e,b[a.localKey],f)),l&&(m.push(l),i.push(a.localField))}}),j(m)}else k(new e.IA('"relations" must be a string or an array!'));else k(new e.IA('"instance(id)" must be a string, number or object!'));else k(new e.NER(a))}).then(function(a){return d.Promise.all(a)}).then(function(a){return d.forEach(i,function(c,d){b[c]=a[d]}),b})}var d=a("../../utils"),e=a("../../errors");b.exports=c},{"../../errors":48,"../../utils":50}],34:[function(a,b){function c(a,b,c){var f,g=this,h=g.defs[a];return new d.Promise(function(i,j){b=d.resolveId(h,b),h?d._sn(b)?g.get(a,b)?(f=g.get(a,b),c=d._(h,c),i(f)):j(new e.R('id "'+b+'" not found in cache!')):j(d._snErr("id")):j(new e.NER(a))}).then(function(a){return c.beforeValidate.call(a,c,a)}).then(function(a){return c.validate.call(a,c,a)}).then(function(a){return c.afterValidate.call(a,c,a)}).then(function(a){return c.beforeUpdate.call(a,c,a)}).then(function(e){if(c.notify&&h.emit("DS.beforeUpdate",h,e),c.changesOnly){var f=g.s[a];d.w&&f.observers[b].deliver();var i=[],j=g.changes(a,b);for(var k in j.added)i.push(k);for(k in j.changed)i.push(k);if(j=d.pick(e,i),d.isEmpty(j))return e;e=j}return g.getAdapter(c).update(h,b,e,c)}).then(function(a){return c.afterUpdate.call(a,c,a)}).then(function(b){if(c.notify&&h.emit("DS.afterUpdate",h,b),c.cacheResponse){var e=g.inject(h.n,b,c),f=g.s[a].saved;return f[e[h.idAttribute]]=d.updateTimestamp(f[e[h.idAttribute]]),e}return g.createInstance(a,b,c)})}var d=a("../../utils"),e=a("../../errors");b.exports=c},{"../../errors":48,"../../utils":50}],35:[function(a,b){function c(a,b,c,f){var g=this,h=g.defs[a];return new d.Promise(function(g,i){b=d.resolveId(h,b),h?d._sn(b)?(f=d._(h,f),g(c)):i(d._snErr("id")):i(new e.NER(a))}).then(function(a){return f.beforeValidate.call(a,f,a)}).then(function(a){return f.validate.call(a,f,a)}).then(function(a){return f.afterValidate.call(a,f,a)}).then(function(a){return f.beforeUpdate.call(a,f,a)}).then(function(a){return f.notify&&h.emit("DS.beforeUpdate",h,a),g.getAdapter(f).update(h,b,a,f)}).then(function(a){return f.afterUpdate.call(a,f,a)}).then(function(b){if(f.notify&&h.emit("DS.afterUpdate",h,b),f.cacheResponse){var c=g.inject(h.n,b,f),e=g.s[a].saved;return e[c[h.idAttribute]]=d.updateTimestamp(e[c[h.idAttribute]]),c}return g.createInstance(a,b,f)})}var d=a("../../utils"),e=a("../../errors");b.exports=c},{"../../errors":48,"../../utils":50}],36:[function(a,b){function c(a,b,c,f){var g=this,h=g.defs[a];return new d.Promise(function(c,g){h?(f=d._(h,f),c(b)):g(new e.NER(a))}).then(function(a){return f.beforeValidate.call(a,f,a)}).then(function(a){return f.validate.call(a,f,a)}).then(function(a){return f.afterValidate.call(a,f,a)}).then(function(a){return f.beforeUpdate.call(a,f,a)}).then(function(a){return f.notify&&h.emit("DS.beforeUpdate",h,a),g.getAdapter(f).updateAll(h,a,c,f)}).then(function(a){return f.afterUpdate.call(a,f,a)}).then(function(c){if(f.notify&&h.emit("DS.afterUpdate",h,b),f.cacheResponse){var e=g.inject(h.n,c,f),i=g.s[a].saved;return d.forEach(e,function(a){i[a[h.idAttribute]]=d.updateTimestamp(i[a[h.idAttribute]])}),e}var j=[];return d.forEach(c,function(b){j.push(g.createInstance(a,b,f))}),j})}var d=a("../../utils"),e=a("../../errors");b.exports=c},{"../../errors":48,"../../utils":50}],37:[function(a,b){function c(a,b,c){c(null,b)}function d(a,b){return b}function e(a,b,c,d){var f=a[b],g=i.get(c,f[0]),h=i.get(d,f[0]);return i._s(g)&&(g=i.upperCase(g)),i._s(h)&&(h=i.upperCase(h)),"DESC"===f[1]?g>h?-1:h>g?1:b<a.length-1?e(a,b+1,c,d):0:h>g?-1:g>h?1:b<a.length-1?e(a,b+1,c,d):0}function f(){}function g(b){var c=this;b=b||{};try{h=a("js-data-schema")}catch(d){}if(!h||i.isEmpty(h))try{h=window.Schemator}catch(d){}(h||b.schemator)&&(c.schemator=b.schemator||new h),c.store={},c.s=c.store,c.definitions={},c.defs=c.definitions,c.adapters={},c.defaults=new f,c.observe=i.observe,i.forOwn(b,function(a,b){c.defaults[b]=a})}var h,i=a("../utils"),j=a("../errors"),k=a("./sync_methods"),l=a("./async_methods"),m=f.prototype;m.actions={},m.afterCreate=c,m.afterCreateInstance=d,m.afterDestroy=c,m.afterEject=d,m.afterInject=d,m.afterReap=d,m.afterUpdate=c,m.afterValidate=c,m.allowSimpleWhere=!0,m.basePath="",m.beforeCreate=c,m.beforeCreateInstance=d,m.beforeDestroy=c,m.beforeEject=d,m.beforeInject=d,m.beforeReap=d,m.beforeUpdate=c,m.beforeValidate=c,m.bypassCache=!1,m.cacheResponse=!!i.w,m.defaultAdapter="http",m.debug=!0,m.eagerEject=!1,m.eagerInject=!1,m.endpoint="",m.error=console?function(a,b,c){console["function"==typeof console.error?"error":"log"](a,b,c)}:!1,m.errorFn=function(a,b){if(this.error&&"function"==typeof this.error){try{throw"string"==typeof a?new Error(a):a}catch(c){a=c}this.error(this.name||null,a||null,b||null)}},m.fallbackAdapters=["http"],m.findBelongsTo=!0,m.findHasOne=!0,m.findHasMany=!0,m.findInverseLinks=!0,m.idAttribute="id",m.ignoredChanges=[/\$/],m.ignoreMissing=!1,m.keepChangeHistory=!1,m.loadFromServer=!1,m.log=console?function(a,b,c,d,e){console["function"==typeof console.info?"info":"log"](a,b,c,d,e)
}:!1,m.logFn=function(a,b,c,d){this.debug&&this.log&&"function"==typeof this.log&&this.log(this.name||null,a||null,b||null,c||null,d||null)},m.maxAge=!1,m.notify=!!i.w,m.reapAction=i.w?"inject":"none",m.reapInterval=i.w?3e4:!1,m.resetHistoryOnInject=!0,m.strategy="single",m.upsert=!!i.w,m.useClass=!0,m.useFilter=!1,m.validate=c,m.defaultFilter=function(a,b,c,d){var f=a,g=null,h={skip:"",offset:"",where:"",limit:"",orderBy:"",sort:""};c=c||{},d=d||{},g=i._o(c.where)?c.where:{},d.allowSimpleWhere&&i.forOwn(c,function(a,b){b in h||b in g||(g[b]={"==":a})}),i.isEmpty(g)&&(g=null),g&&(f=i.filter(f,function(a){var b=!0,c=!0;return i.forOwn(g,function(d,e){i._s(d)?d={"===":d}:(i._n(d)||i.isBoolean(d))&&(d={"==":d}),i._o(d)&&i.forOwn(d,function(d,f){var g,h="|"===f[0],j=a[e];f=h?f.substr(1):f,"=="===f?g=j==d:"==="===f?g=j===d:"!="===f?g=j!=d:"!=="===f?g=j!==d:">"===f?g=j>d:">="===f?g=j>=d:"<"===f?g=d>j:"<="===f?g=d>=j:"isectEmpty"===f?g=!i.intersection(j||[],d||[]).length:"isectNotEmpty"===f?g=i.intersection(j||[],d||[]).length:"in"===f?g=i._s(d)?-1!==d.indexOf(j):i.contains(d,j):"notIn"===f?g=i._s(d)?-1===d.indexOf(j):!i.contains(d,j):"contains"===f?g=i._s(j)?-1!==j.indexOf(d):i.contains(j,d):"notContains"===f&&(g=i._s(j)?-1===j.indexOf(d):!i.contains(j,d)),void 0!==g&&(c=b?g:h?c||g:c&&g),b=!1})}),c}));var k=null;if(i._s(c.orderBy)?k=[[c.orderBy,"ASC"]]:i._a(c.orderBy)&&(k=c.orderBy),!k&&i._s(c.sort)?k=[[c.sort,"ASC"]]:!k&&i._a(c.sort)&&(k=c.sort),k){var l=0;i.forEach(k,function(a,b){if(i._s(a))k[b]=[a,"ASC"];else if(!i._a(a))throw new j.IA("DS.filter(resourceName[, params][, options]): "+i.toJson(a)+": Must be a string or an array!",{params:{"orderBy[i]":{actual:typeof a,expected:"string|array"}}})}),f=i.sort(f,function(a,b){return e(k,l,a,b)})}var m=i._n(c.limit)?c.limit:null,n=null;return i._n(c.skip)?n=c.skip:i._n(c.offset)&&(n=c.offset),m&&n?f=i.slice(f,n,Math.min(f.length,n+m)):i._n(m)?f=i.slice(f,0,Math.min(f.length,m)):i._n(n)&&(f=n<f.length?i.slice(f,n):[]),f};var n=g.prototype;n.getAdapter=function(a){var b=!1;a=a||{},i._s(a)&&(b=!0,a={adapter:a});var c=this.adapters[a.adapter];if(c)return c;if(b)throw new Error(a.adapter+" is not a registered adapter!");return this.adapters[a.defaultAdapter]},n.getAdapter.shorthand=!1,n.registerAdapter=function(a,b,c){var d=this;c=c||{},d.adapters[a]=i.isFunction(b)?new b(c):b,c["default"]&&(d.defaults.defaultAdapter=a)},n.registerAdapter.shorthand=!1,n.is=function(a,b){var c=this.defs[a];if(!c)throw new j.NER(a);return b instanceof c[c["class"]]},n.errors=a("../errors"),n.utils=i,i.deepMixIn(n,k),i.deepMixIn(n,l),b.exports=g},{"../errors":48,"../utils":50,"./async_methods":32,"./sync_methods":42,"js-data-schema":"js-data-schema"}],38:[function(require,module,exports){function Resource(a){DSUtils.deepMixIn(this,a),this.endpoint="endpoint"in a?a.endpoint:this.name}function defineResource(definition){var _this=this,definitions=_this.defs;if(DSUtils._s(definition)&&(definition={name:definition.replace(/\s/gi,"")}),!DSUtils._o(definition))throw DSUtils._oErr("definition");if(!DSUtils._s(definition.name))throw new DSErrors.IA('"name" must be a string!');if(_this.s[definition.name])throw new DSErrors.R(definition.name+" is already registered!");try{Resource.prototype=_this.defaults,definitions[definition.name]=new Resource(definition);var def=definitions[definition.name];if(def.n=def.name,!DSUtils._s(def.idAttribute))throw new DSErrors.IA('"idAttribute" must be a string!');def.relations&&(def.relationList=[],def.relationFields=[],DSUtils.forOwn(def.relations,function(a,b){DSUtils.forOwn(a,function(c,d){DSUtils._a(c)||(a[d]=[c]),DSUtils.forEach(a[d],function(a){a.type=b,a.relation=d,a.name=def.n,def.relationList.push(a),def.relationFields.push(a.localField)})})}),def.relations.belongsTo&&DSUtils.forOwn(def.relations.belongsTo,function(a,b){DSUtils.forEach(a,function(a){a.parent&&(def.parent=b,def.parentKey=a.localKey,def.parentField=a.localField)})}),"function"==typeof Object.freeze&&(Object.freeze(def.relations),Object.freeze(def.relationList))),def.getResource=function(a){return _this.defs[a]},def.getEndpoint=function(a,b){b.params=b.params||{};var c,d=def.parentKey,e=b.hasOwnProperty("endpoint")?b.endpoint:def.endpoint,f=def.parentField,g=definitions[def.parent],h=b.params[d];if(h!==!1&&d&&g){if(delete b.params[d],DSUtils._sn(a)?c=def.get(a):DSUtils._o(a)&&(c=a),c&&(h=h||c[d]||(c[f]?c[f][g.idAttribute]:null)),h){delete b.endpoint;var i={};return DSUtils.forOwn(b,function(a,b){i[b]=a}),DSUtils.makePath(g.getEndpoint(h,DSUtils._(g,i)),h,e)}return e}return h===!1&&delete b.params[d],e},def.filter&&(def.defaultFilter=def.filter,delete def.filter),def["class"]=DSUtils.pascalCase(def.name);try{"function"==typeof def.useClass?(eval("function "+def["class"]+"() { def.useClass.call(this); }"),def[def["class"]]=eval(def["class"]),def[def["class"]].prototype=function(a){function b(){}return b.prototype=a,new b}(def.useClass.prototype)):(eval("function "+def["class"]+"() {}"),def[def["class"]]=eval(def["class"]))}catch(e){def[def["class"]]=function(){}}def.methods&&DSUtils.deepMixIn(def[def["class"]].prototype,def.methods),def[def["class"]].prototype.set=function(a,b){DSUtils.set(this,a,b);var c=_this.s[def.n].observers[this[def.idAttribute]];return c&&!DSUtils.observe.hasObjectObserve?c.deliver():_this.compute(def.n,this),this},def[def["class"]].prototype.get=function(a){return DSUtils.get(this,a)},def.computed&&DSUtils.forOwn(def.computed,function(a,b){DSUtils.isFunction(a)&&(def.computed[b]=[a],a=def.computed[b]),def.methods&&b in def.methods&&def.errorFn('Computed property "'+b+'" conflicts with previously defined prototype method!');var c;if(1===a.length){var d=a[0].toString().match(/function.*?\(([\s\S]*?)\)/);c=d[1].split(","),def.computed[b]=c.concat(a),a=def.computed[b],c.length&&def.errorFn("Use the computed property array syntax for compatibility with minified code!")}c=a.slice(0,a.length-1),DSUtils.forEach(c,function(a,b){c[b]=a.trim()}),a.deps=DSUtils.filter(c,function(a){return!!a})}),definition.schema&&_this.schemator&&(def.schema=_this.schemator.defineSchema(def.n,definition.schema),definition.hasOwnProperty("validate")||(def.validate=function(a,b,c){def.schema.validate(b,{ignoreMissing:def.ignoreMissing},function(a){return a?c(a):c(null,b)})})),DSUtils.forEach(instanceMethods,function(a){def[def["class"]].prototype["DS"+DSUtils.pascalCase(a)]=function(){var b=Array.prototype.slice.call(arguments);return b.unshift(this[def.idAttribute]||this),b.unshift(def.n),_this[a].apply(_this,b)}}),def[def["class"]].prototype.DSCreate=function(){var a=Array.prototype.slice.call(arguments);return a.unshift(this),a.unshift(def.n),_this.create.apply(_this,a)},_this.s[def.n]={collection:[],expiresHeap:new DSUtils.DSBinaryHeap(function(a){return a.expires},function(a,b){return a.item===b}),completedQueries:{},queryData:{},pendingQueries:{},index:{},modified:{},saved:{},previousAttributes:{},observers:{},changeHistories:{},changeHistory:[],collectionModified:0},def.reapInterval&&setInterval(function(){_this.reap(def.n,{isInterval:!0})},def.reapInterval);for(var key in _this)"function"==typeof _this[key]&&(_this[key].shorthand!==!1?!function(a){def[a]=function(){var b=Array.prototype.slice.call(arguments);return b.unshift(def.n),_this[a].apply(_this,b)}}(key):!function(a){def[a]=function(){return _this[a].apply(_this,Array.prototype.slice.call(arguments))}}(key));return def.beforeValidate=DSUtils.promisify(def.beforeValidate),def.validate=DSUtils.promisify(def.validate),def.afterValidate=DSUtils.promisify(def.afterValidate),def.beforeCreate=DSUtils.promisify(def.beforeCreate),def.afterCreate=DSUtils.promisify(def.afterCreate),def.beforeUpdate=DSUtils.promisify(def.beforeUpdate),def.afterUpdate=DSUtils.promisify(def.afterUpdate),def.beforeDestroy=DSUtils.promisify(def.beforeDestroy),def.afterDestroy=DSUtils.promisify(def.afterDestroy),DSUtils.forOwn(def.actions,function(a,b){if(def[b])throw new Error('Cannot override existing method "'+b+'"!');def[b]=function(c){c=c||{};var d=_this.getAdapter(a.adapter||"http"),e=DSUtils.deepMixIn({},a);return!c.hasOwnProperty("endpoint")&&e.endpoint&&(c.endpoint=e.endpoint),e.url="function"==typeof c.getEndpoint?c.getEndpoint(def,c):DSUtils.makePath(c.basePath||d.defaults.basePath||def.basePath,def.getEndpoint(null,c),b),e.method=e.method||"GET",DSUtils.deepMixIn(e,c),d.HTTP(e)}}),DSUtils.Events(def),def}catch(err){throw delete definitions[definition.name],delete _this.s[definition.name],err}}var DSUtils=require("../../utils"),DSErrors=require("../../errors"),instanceMethods=["compute","refresh","save","update","destroy","loadRelations","changeHistory","changes","hasChanges","lastModified","lastSaved","link","linkInverse","previous","unlinkInverse"];module.exports=defineResource},{"../../errors":48,"../../utils":50}],39:[function(a,b){function c(a,b,c){var f,g=this,h=g.defs[a],i=g.s[a],j=!1;if(b=d.resolveId(h,b),!h)throw new e.NER(a);if(!d._sn(b))throw d._snErr("id");c=d._(h,c);for(var k=0;k<i.collection.length;k++)if(i.collection[k][h.idAttribute]==b){f=i.collection[k],i.expiresHeap.remove(f),j=!0;break}if(j){c.notify&&(h.beforeEject(c,f),h.emit("DS.beforeEject",h,f)),g.unlinkInverse(h.n,b),i.collection.splice(k,1),d.w&&i.observers[b].close(),delete i.observers[b],delete i.index[b],delete i.previousAttributes[b],delete i.completedQueries[b],delete i.pendingQueries[b],d.forEach(i.changeHistories[b],function(a){d.remove(i.changeHistory,a)});var l=[];return d.forOwn(i.queryData,function(a,b){a.$$injected&&d.remove(a,f),a.length||l.push(b)}),d.forEach(l,function(a){delete i.completedQueries[a],delete i.queryData[a]}),delete i.changeHistories[b],delete i.modified[b],delete i.saved[b],i.collectionModified=d.updateTimestamp(i.collectionModified),c.notify&&(h.afterEject(c,f),h.emit("DS.afterEject",h,f)),f}}var d=a("../../utils"),e=a("../../errors");b.exports=c},{"../../errors":48,"../../utils":50}],40:[function(a,b){function c(a,b,c){var f=this,g=f.defs[a];if(b=b||{},!g)throw new e.NER(a);if(!d._o(b))throw d._oErr("params");var h=f.s[a];d.isEmpty(b)&&(h.completedQueries={});var i=d.toJson(b),j=f.filter(g.n,b),k=[];return d.forEach(j,function(a){a&&a[g.idAttribute]&&k.push(a[g.idAttribute])}),d.forEach(k,function(a){f.eject(g.n,a,c)}),delete h.completedQueries[i],h.collectionModified=d.updateTimestamp(h.collectionModified),j}var d=a("../../utils"),e=a("../../errors");b.exports=c},{"../../errors":48,"../../utils":50}],41:[function(a,b){function c(a,b,c){var f=this,g=f.defs[a],h=f.s[a];if(!g)throw new e.NER(a);if(b&&!d._o(b))throw d._oErr("params");c=d._(g,c),b=b||{};var i=d.toJson(b);return i in h.completedQueries||!c.loadFromServer||h.pendingQueries[i]||f.findAll(a,b,c),g.defaultFilter.call(f,h.collection,a,b,c)}var d=a("../../utils"),e=a("../../errors");b.exports=c},{"../../errors":48,"../../utils":50}],42:[function(a,b){function c(a,b,c){var d=this,e=d.defs[a];if(c=c||{},b=o.resolveId(e,b),!e)throw new q(a);if(!o._sn(b))throw o._snErr("id");c=o._(e,c);var f=d.get(a,b);if(f){o.w&&d.s[a].observers[b].deliver();var g=o.diffObjectFromOldObject(f,d.s[a].previousAttributes[b],o.equals,c.ignoredChanges);return o.forOwn(g,function(a,b){var c=[];o.forOwn(a,function(a,b){o.isFunction(a)||c.push(b)}),g[b]=o.pick(g[b],c)}),o.forEach(e.relationFields,function(a){delete g.added[a],delete g.removed[a],delete g.changed[a]}),g}}function d(a,b){var c=this,d=c.defs[a],e=c.s[a];if(b=o.resolveId(d,b),a&&!c.defs[a])throw new q(a);if(b&&!o._sn(b))throw o._snErr("id");if(d.keepChangeHistory){if(!a)return e.changeHistory;var f=c.get(a,b);if(f)return e.changeHistories[b]}else d.errorFn("changeHistory is disabled for this resource!")}function e(a,b){var c=this,d=c.defs[a];if(b=o.resolveItem(c.s[a],b),!d)throw new q(a);if(!b)throw new s("Item not in the store!");if(!o._o(b)&&!o._sn(b))throw new r('"instance" must be an object, string or number!');return o.forOwn(d.computed,function(a,c){o.compute.call(b,a,c)}),b}function f(a,b,c){var d,e=this.defs[a];if(b=b||{},!e)throw new q(a);if(b&&!o.isObject(b))throw new r('"attrs" must be an object!');if(c=o._(e,c),c.notify&&c.beforeCreateInstance(c,b),c.useClass){var f=e[e["class"]];d=new f}else d={};return o.deepMixIn(d,b),c.notify&&c.afterCreateInstance(c,b),d}function g(a){return!(o.isEmpty(a.added)&&o.isEmpty(a.removed)&&o.isEmpty(a.changed))}function h(){this.observe.Platform.performMicrotaskCheckpoint()}function i(a,b,c){var d=this,e=d.defs[a];if(!e)throw new q(a);if(!o._sn(b))throw o._snErr("id");c=o._(e,c);var f=d.s[a].index[b];return!f&&c.loadFromServer&&d.find(a,b,c),f}function j(a,b){var c=this,d=c.defs[a],e=c.s[a],f=[];if(!d)throw new q(a);if(b&&!o._a(b))throw o._aErr("ids");if(o._a(b))for(var g=b.length,h=0;g>h;h++)e.index[b[h]]&&f.push(e.index[b[h]]);else f=e.collection.slice();return f}function k(a,b){var c=this,d=c.defs[a];if(b=o.resolveId(d,b),!d)throw new q(a);if(!o._sn(b))throw o._snErr("id");return c.get(a,b)?g(c.changes(a,b)):!1}function l(a,b){var c=this.defs[a],d=this.s[a];if(b=o.resolveId(c,b),!c)throw new q(a);return b?(b in d.modified||(d.modified[b]=0),d.modified[b]):d.collectionModified}function m(a,b){var c=this.defs[a],d=this.s[a];if(b=o.resolveId(c,b),!c)throw new q(a);return b in d.saved||(d.saved[b]=0),d.saved[b]}function n(a,b){var c=this,d=c.defs[a],e=c.s[a];if(b=o.resolveId(d,b),!d)throw new q(a);if(!o._sn(b))throw o._snErr("id");return e.previousAttributes[b]?o.copy(e.previousAttributes[b]):void 0}var o=a("../../utils"),p=a("../../errors"),q=p.NER,r=p.IA,s=p.R;b.exports={changes:c,changeHistory:d,compute:e,createInstance:f,defineResource:a("./defineResource"),digest:h,eject:a("./eject"),ejectAll:a("./ejectAll"),filter:a("./filter"),get:i,getAll:j,hasChanges:k,inject:a("./inject"),lastModified:l,lastSaved:m,link:a("./link"),linkAll:a("./linkAll"),linkInverse:a("./linkInverse"),previous:n,unlinkInverse:a("./unlinkInverse")}},{"../../errors":48,"../../utils":50,"./defineResource":38,"./eject":39,"./ejectAll":40,"./filter":41,"./inject":43,"./link":44,"./linkAll":45,"./linkInverse":46,"./unlinkInverse":47}],43:[function(a,b){function c(a,b,c){var d=b.n;return function(e,f,h,i,j){var k,l=this,m=i&&i(b.idAttribute)?i(b.idAttribute):l[b.idAttribute];if(g.forEach(b.relationFields,function(a){delete e[a],delete f[a],delete h[a]}),(!g.isEmpty(e)||!g.isEmpty(f)||!g.isEmpty(h)||j)&&(k=a.get(d,m),c.modified[m]=g.updateTimestamp(c.modified[m]),c.collectionModified=g.updateTimestamp(c.collectionModified),b.keepChangeHistory)){var n={resourceName:d,target:k,added:e,removed:f,changed:h,timestamp:c.modified[m]};c.changeHistories[m].push(n),c.changeHistory.push(n)}b.computed&&(k=k||a.get(d,m),g.forOwn(b.computed,function(a,b){var c=!1;g.forEach(a.deps,function(a){(a in e||a in f||a in h||!(b in k))&&(c=!0)}),c=c||!a.deps.length,c&&g.compute.call(k,a,b)})),b.relations&&(k=k||a.get(d,m),g.forEach(b.relationList,function(c){k[c.localField]&&(c.localKey in e||c.localKey in f||c.localKey in h)&&a.link(d,k[b.idAttribute],[c.relation])})),b.idAttribute in h&&b.errorFn('Doh! You just changed the primary key of an object! Your data for the "'+d+'" resource is now in an undefined (probably broken) state.')}}function d(a,b,e,f){var i,j=this,k=c(j,a,b,e,f);if(g._a(e)){i=[];for(var l=0;l<e.length;l++)i.push(d.call(j,a,b,e[l],f))}else{var m=a.computed,n=a.idAttribute;if(m&&m[n]){var o=[];g.forEach(m[n].deps,function(a){o.push(e[a])}),e[n]=m[n][m[n].length-1].apply(e,o)}if(!(n in e)){var p=new h.R(a.n+'.inject: "attrs" must contain the property specified by `idAttribute`!');throw f.errorFn(p),p}try{g.forEach(a.relationList,function(b){var c=b.relation,d=j.defs[c],i=e[b.localField];if(i){if(!d)throw new h.R(a.n+" relation is defined but the resource is not!");if(g._a(i)){var k=[];g.forEach(i,function(g){if(g!==j.s[c][g[d.idAttribute]])try{var h=j.inject(c,g,f);b.foreignKey&&(h[b.foreignKey]=e[a.idAttribute]),k.push(h)}catch(i){f.errorFn(i,"Failed to inject "+b.type+' relation: "'+c+'"!')}}),e[b.localField]=k}else if(i!==j.s[c][i[d.idAttribute]])try{e[b.localField]=j.inject(c,e[b.localField],f),b.foreignKey&&(e[b.localField][b.foreignKey]=e[a.idAttribute])}catch(l){f.errorFn(l,"Failed to inject "+b.type+' relation: "'+c+'"!')}}});var q=e[n],r=j.get(a.n,q),s=r?b.modified[q]:0;r?(g.deepMixIn(r,e),a.resetHistoryOnInject&&(b.previousAttributes[q]={},g.deepMixIn(b.previousAttributes[q],e),b.changeHistories[q].length&&(g.forEach(b.changeHistories[q],function(a){g.remove(b.changeHistory,a)}),b.changeHistories[q].splice(0,b.changeHistories[q].length))),g.w&&b.observers[q].deliver()):(r=f.useClass?e instanceof a[a["class"]]?e:new a[a["class"]]:{},g.deepMixIn(r,e),b.collection.push(r),b.changeHistories[q]=[],g.w&&(b.observers[q]=new j.observe.ObjectObserver(r),b.observers[q].open(k,r)),b.index[q]=r,k.call(r,{},{},{},null,!0),b.previousAttributes[q]={},g.deepMixIn(b.previousAttributes[q],r)),b.modified[q]=s&&b.modified[q]===s?g.updateTimestamp(b.modified[q]):b.modified[q],b.expiresHeap.remove(r);var t=(new Date).getTime();b.expiresHeap.push({item:r,timestamp:t,expires:a.maxAge?t+a.maxAge:Number.MAX_VALUE}),i=r}catch(u){f.errorFn(u,e)}}return i}function e(a,b,c){var d=this;g.forEach(a.relationList,function(e){c.findBelongsTo&&"belongsTo"===e.type&&b[a.idAttribute]?d.link(a.n,b[a.idAttribute],[e.relation]):(c.findHasMany&&"hasMany"===e.type||c.findHasOne&&"hasOne"===e.type)&&d.link(a.n,b[a.idAttribute],[e.relation])})}function f(a,b,c){var f,i=this,j=i.defs[a],k=i.s[a];if(!j)throw new h.NER(a);if(!g._o(b)&&!g._a(b))throw new h.IA(a+'.inject: "attrs" must be an object or an array!');var l=j.n;return c=g._(j,c),c.notify&&(c.beforeInject(c,b),j.emit("DS.beforeInject",j,b)),f=d.call(i,j,k,b,c),k.collectionModified=g.updateTimestamp(k.collectionModified),c.findInverseLinks&&(g._a(f)?f.length&&i.linkInverse(l,f[0][j.idAttribute]):i.linkInverse(l,f[j.idAttribute])),g._a(f)?g.forEach(f,function(a){e.call(i,j,a,c)}):e.call(i,j,f,c),c.notify&&(c.afterInject(c,f),j.emit("DS.afterInject",j,f)),f}var g=a("../../utils"),h=a("../../errors");b.exports=f},{"../../errors":48,"../../utils":50}],44:[function(a,b){function c(a,b,c){var f=this,g=f.defs[a];if(c=c||[],b=d.resolveId(g,b),!g)throw new e.NER(a);if(!d._sn(b))throw d._snErr("id");if(!d._a(c))throw d._aErr("relations");var h=f.get(a,b);return h&&d.forEach(g.relationList,function(a){var b=a.relation;if(!c.length||d.contains(c,b)){var e={};if("belongsTo"===a.type){var i=h[a.localKey]?f.get(b,h[a.localKey]):null;i&&(h[a.localField]=i)}else if("hasMany"===a.type)e[a.foreignKey]=h[g.idAttribute],h[a.localField]=f.defaults.constructor.prototype.defaultFilter.call(f,f.s[b].collection,b,e,{allowSimpleWhere:!0});else if("hasOne"===a.type){e[a.foreignKey]=h[g.idAttribute];var j=f.defaults.constructor.prototype.defaultFilter.call(f,f.s[b].collection,b,e,{allowSimpleWhere:!0});j.length&&(h[a.localField]=j[0])}}}),h}var d=a("../../utils"),e=a("../../errors");b.exports=c},{"../../errors":48,"../../utils":50}],45:[function(a,b){function c(a,b,c){var f=this,g=f.defs[a];if(c=c||[],!g)throw new e.NER(a);if(!d._a(c))throw d._aErr("relations");var h=f.filter(a,b);return h&&d.forEach(g.relationList,function(a){var b=a.relation;(!c.length||d.contains(c,b))&&("belongsTo"===a.type?d.forEach(h,function(c){var d=c[a.localKey]?f.get(b,c[a.localKey]):null;d&&(c[a.localField]=d)}):"hasMany"===a.type?d.forEach(h,function(c){var d={};d[a.foreignKey]=c[g.idAttribute],c[a.localField]=f.defaults.constructor.prototype.defaultFilter.call(f,f.s[b].collection,b,d,{allowSimpleWhere:!0})}):"hasOne"===a.type&&d.forEach(h,function(c){var d={};d[a.foreignKey]=c[g.idAttribute];var e=f.defaults.constructor.prototype.defaultFilter.call(f,f.s[b].collection,b,d,{allowSimpleWhere:!0});e.length&&(c[a.localField]=e[0])}))}),h}var d=a("../../utils"),e=a("../../errors");b.exports=c},{"../../errors":48,"../../utils":50}],46:[function(a,b){function c(a,b,c){var f=this,g=f.defs[a];if(c=c||[],b=d.resolveId(g,b),!g)throw new e.NER(a);if(!d._sn(b))throw d._snErr("id");if(!d._a(c))throw d._aErr("relations");var h=f.get(a,b);return h&&d.forOwn(f.defs,function(a){d.forOwn(a.relations,function(b){d.forOwn(b,function(b,e){(!c.length||d.contains(c,a.n))&&g.n===e&&f.linkAll(a.n,{},[g.n])})})}),h}var d=a("../../utils"),e=a("../../errors");b.exports=c},{"../../errors":48,"../../utils":50}],47:[function(a,b){function c(a,b,c){var f=this,g=f.defs[a];if(c=c||[],b=d.resolveId(g,b),!g)throw new e.NER(a);if(!d._sn(b))throw d._snErr("id");if(!d._a(c))throw d._aErr("relations");var h=f.get(a,b);return h&&d.forOwn(f.defs,function(a){d.forOwn(a.relations,function(a){d.forOwn(a,function(a,b){g.n===b&&d.forEach(a,function(a){d.forEach(f.s[a.name].collection,function(b){if("hasMany"===a.type&&b[a.localField]){var c;d.forEach(b[a.localField],function(a,b){a===h&&(c=b)}),b[a.localField].splice(c,1)}else b[a.localField]===h&&delete b[a.localField]})})})})}),h}var d=a("../../utils"),e=a("../../errors");b.exports=c},{"../../errors":48,"../../utils":50}],48:[function(a,b){function c(a){Error.call(this),"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.type=this.constructor.name,this.message=a||"Illegal Argument!"}function d(a){Error.call(this),"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.type=this.constructor.name,this.message=a||"RuntimeError Error!"}function e(a){Error.call(this),"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.type=this.constructor.name,this.message=(a||"")+" is not a registered resource!"}c.prototype=new Error,c.prototype.constructor=c,d.prototype=new Error,d.prototype.constructor=d,e.prototype=new Error,e.prototype.constructor=e,b.exports={IllegalArgumentError:c,IA:c,RuntimeError:d,R:d,NonexistentResourceError:e,NER:e}},{}],49:[function(a,b){var c=a("./datastore");b.exports={DS:c,createStore:function(a){return new c(a)},DSUtils:a("./utils"),DSErrors:a("./errors"),version:{full:"1.5.1",major:parseInt("1",10),minor:parseInt("5",10),patch:parseInt("1",10),alpha:!1,beta:!1}}},{"./datastore":37,"./errors":48,"./utils":50}],50:[function(a,b){function c(a){return"[object RegExp]"==G.call(a)||!1}function d(a){return a===!0||a===!1||a&&"object"==typeof a&&"[object Boolean]"==G.call(a)||!1}function e(a){return"string"==typeof a||a&&"object"==typeof a&&"[object String]"==G.call(a)||!1}function f(a){return"[object Object]"==G.call(a)||!1}function g(a){return a&&"object"==typeof a&&"[object Date]"==G.call(a)||!1}function h(a){var b=typeof a;return"number"==b||a&&"object"==b&&"[object Number]"==G.call(a)||!1}function i(a){return"function"==typeof a||a&&"[object Function]"===G.call(a)||!1}function j(a){return e(a)||h(a)}function k(a){return new H.IA('"'+a+'" must be a string or a number!')}function l(a){return new H.IA('"'+a+'" must be an object!')}function m(a){return new H.IA('"'+a+'" must be an array!')}function n(a){if(null==a)return!0;if("string"==typeof a||N(a))return!a.length;if("object"==typeof a){var b=!0;return K(a,function(){return b=!1,!1}),b}return!0}function o(a,b){if(!a||!b)return[];for(var c,d=[],e=0,f=a.length;f>e;e++)c=a[e],R.contains(d,c)||R.contains(b,c)&&d.push(c);return d}function p(a,b,c){var d=[];return I(a,function(a,c,e){b(a,c,e)&&d.push(a)},c),d}function q(a){var b=this.constructor;return this.then(function(c){return b.resolve(a()).then(function(){return c})},function(c){return b.resolve(a()).then(function(){throw c})})}function r(a){var b="function"==typeof Date.now?Date.now():(new Date).getTime();return a&&a>=b?a+1:b}function s(a){var b={};a=a||this,a.on=function(a,c,d){b[a]=b[a]||[],b[a].push({f:c,c:d})},a.off=function(a,c){var d=b[a];if(d)if(c){for(var e=0;e<d.length;e++)if(d[e]===c){d.splice(e,1);break}}else d.splice(0,d.length);else b={}},a.emit=function(){var a=Array.prototype.slice.call(arguments),c=b[a.shift()]||[];if(c)for(var d=0;d<c.length;d++)c[d].f.apply(c[d].c,a)}}function t(a,b,c){for(var d=a[c],e=b(d);c>0;){var f=Math.floor((c+1)/2)-1,g=a[f];if(e>=b(g))break;a[f]=d,a[c]=g,c=f}}function u(a,b,c){for(var d=a.length,e=a[c],f=b(e);;){var g=2*(c+1),h=g-1,i=null;if(d>h){var j=a[h],k=b(j);f>k&&(i=h)}if(d>g){var l=a[g],m=b(l);m<(null===i?f:b(a[h]))&&(i=g)}if(null===i)break;a[c]=a[i],a[i]=e,c=i}}function v(a,b){if(a&&!i(a))throw new Error("DSBinaryHeap(weightFunc): weightFunc: must be a function!");a=a||function(a){return a},b=b||function(a,b){return a===b},this.weightFunc=a,this.compareFunc=b,this.heap=[]}function w(a,b,d,e){if(b){if(a===b)throw new Error("Cannot copy! Source and destination are identical.");if(d=d||[],e=e||[],f(a)){var h=d.indexOf(a);if(-1!==h)return e[h];d.push(a),e.push(b)}var i;if(N(a)){b.length=0;for(var j=0;j<a.length;j++)i=w(a[j],null,d,e),f(a[j])&&(d.push(a[j]),e.push(i)),b.push(i)}else{N(b)?b.length=0:I(b,function(a,c){delete b[c]});for(var k in a)a.hasOwnProperty(k)&&(i=w(a[k],null,d,e),f(a[k])&&(d.push(a[k]),e.push(i)),b[k]=i)}}else if(b=a,a)if(N(a))b=w(a,[],d,e);else if(g(a))b=new Date(a.getTime());else if(c(a))b=new RegExp(a.source,a.toString().match(/[^\/]*$/)[0]),b.lastIndex=a.lastIndex;else if(f(a)){var l=Object.create(Object.getPrototypeOf(a));b=w(a,l,d,e)}return b}function x(a,b){if(a===b)return!0;if(null===a||null===b)return!1;if(a!==a&&b!==b)return!0;var d,e,f,h=typeof a,j=typeof b;if(h==j&&"object"==h){if(!N(a)){if(g(a))return g(b)?x(a.getTime(),b.getTime()):!1;if(c(a)&&c(b))return a.toString()==b.toString();if(N(b))return!1;f={};for(e in a)if("$"!==e.charAt(0)&&!i(a[e])){if(!x(a[e],b[e]))return!1;f[e]=!0}for(e in b)if(!f.hasOwnProperty(e)&&"$"!==e.charAt(0)&&void 0!==b[e]&&!i(b[e]))return!1;return!0}if(!N(b))return!1;if((d=a.length)==b.length){for(e=0;d>e;e++)if(!x(a[e],b[e]))return!1;return!0}}return!1}function y(a,b){return this.isString(b)||h(b)?b:b&&a?b[a.idAttribute]||b:b}function z(a,b){return a&&(e(b)||h(b))?a.index[b]||b:b}function A(a){return null!=a&&""!==a}function B(a,b){return b=b||"",p(a,A).join(b)}function C(){var a=B(J(arguments),"/");return a.replace(/([^:\/]|^)\/{2,}/g,"$1/")}var D,E,F=Object.prototype,G=F.toString,H=a("./errors"),I=a("mout/array/forEach"),J=a("mout/array/slice"),K=a("mout/object/forOwn"),L=a("../lib/observe-js/observe-js"),M=a("es6-promise");M.polyfill();var N=Array.isArray||function(a){return"[object Array]"==G.call(a)||!1};try{D=window,D.Promise.prototype["finally"]||(D.Promise.prototype["finally"]=q),E=D.Promise,D={}}catch(O){D=null,E=a("bluebird")}var P=v.prototype;P.push=function(a){this.heap.push(a),t(this.heap,this.weightFunc,this.heap.length-1)},P.peek=function(){return this.heap[0]},P.pop=function(){var a=this.heap[0],b=this.heap.pop();return this.heap.length>0&&(this.heap[0]=b,u(this.heap,this.weightFunc,0)),a},P.remove=function(a){for(var b=this.heap.length,c=0;b>c;c++)if(this.compareFunc(this.heap[c],a)){var d=this.heap[c],e=this.heap.pop();return c!==b-1&&(this.heap[c]=e,t(this.heap,this.weightFunc,c),u(this.heap,this.weightFunc,c)),d}return null},P.removeAll=function(){this.heap=[]},P.size=function(){return this.heap.length};var Q=["beforeValidate","validate","afterValidate","beforeCreate","afterCreate","beforeUpdate","afterUpdate","beforeDestroy","afterDestroy"];L.setEqualityFn(x);var R={_:function(a,b){var c=this;if(b=b||{},b&&b.constructor===a.constructor)return b;if(!f(b))throw new H.IA('"options" must be an object!');I(Q,function(a){"function"==typeof b[a]&&-1===b[a].toString().indexOf("var args = Array")&&(b[a]=c.promisify(b[a]))});var d=function(a){var b=this;K(a,function(a,c){b[c]=a})};return d.prototype=a,new d(b)},_n:h,_s:e,_sn:j,_snErr:k,_o:f,_oErr:l,_a:N,_aErr:m,compute:function(a,b){var c=this,d=[];I(a.deps,function(a){d.push(c[a])}),c[b]=a[a.length-1].apply(c,d)},contains:a("mout/array/contains"),copy:w,deepMixIn:a("mout/object/deepMixIn"),diffObjectFromOldObject:L.diffObjectFromOldObject,DSBinaryHeap:v,equals:x,Events:s,filter:p,forEach:I,forOwn:K,fromJson:function(a){return e(a)?JSON.parse(a):a},get:a("mout/object/get"),intersection:o,isArray:N,isBoolean:d,isDate:g,isEmpty:n,isFunction:i,isObject:f,isNumber:h,isRegExp:c,isString:e,makePath:C,observe:L,pascalCase:a("mout/string/pascalCase"),pick:a("mout/object/pick"),Promise:E,promisify:function(a,b){var c=this.Promise;if(a){if("function"!=typeof a)throw new Error("Can only promisify functions!");return function(){var d=Array.prototype.slice.apply(arguments);return new c(function(c,e){d.push(function(a,b){a?e(a):c(b)});try{var f=a.apply(b||this,d);f&&f.then&&f.then(c,e)}catch(g){e(g)}})}}},remove:a("mout/array/remove"),set:a("mout/object/set"),slice:J,sort:a("mout/array/sort"),toJson:JSON.stringify,updateTimestamp:r,upperCase:a("mout/string/upperCase"),removeCircular:function(a){var b=[];return function c(a){var d,e;if(!("object"!=typeof a||null===a||a instanceof Boolean||a instanceof Date||a instanceof Number||a instanceof RegExp||a instanceof String)){for(d=0;d<b.length;d+=1)if(b[d]===a)return void 0;if(b.push(a),R.isArray(a))for(e=[],d=0;d<a.length;d+=1)e[d]=c(a[d]);else e={},K(a,function(b,d){e[d]=c(a[d])});return e}return a}(a)},resolveItem:z,resolveId:y,w:D};b.exports=R},{"../lib/observe-js/observe-js":1,"./errors":48,bluebird:"bluebird","es6-promise":2,"mout/array/contains":4,"mout/array/forEach":5,"mout/array/remove":7,"mout/array/slice":8,"mout/array/sort":9,"mout/object/deepMixIn":13,"mout/object/forOwn":15,"mout/object/get":16,"mout/object/pick":19,"mout/object/set":20,"mout/string/pascalCase":23,"mout/string/upperCase":26}]},{},[49])(49)});
//# sourceMappingURL=js-data.min.map
{
"name": "js-data",
"description": "Robust, framework-agnostic in-memory data store.",
"version": "1.5.0",
"version": "1.5.1",
"homepage": "http://www.js-data.io",

@@ -6,0 +6,0 @@ "repository": {

<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" />
## JSData [![Bower version](https://badge.fury.io/bo/js-data.png)](http://badge.fury.io/bo/js-data) [![NPM version](https://badge.fury.io/js/js-data.png)](http://badge.fury.io/js/js-data)
## JSData [![bower version](https://img.shields.io/bower/v/js-data.svg?style=flat-square)](https://www.npmjs.org/package/js-data) [![npm version](https://img.shields.io/npm/v/js-data.svg?style=flat-square)](https://www.npmjs.org/package/js-data) [![Circle CI](https://img.shields.io/circleci/project/js-data/js-data/master.svg?style=flat-square)](https://circleci.com/gh/js-data/js-data/tree/master) [![npm downloads](https://img.shields.io/npm/dm/js-data.svg?style=flat-square)](https://www.npmjs.org/package/js-data) [![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](https://github.com/js-data/js-data/blob/master/LICENSE)

@@ -13,23 +13,13 @@ Inspired by [Ember Data](https://github.com/emberjs/data), js-data is the model layer you've been craving. It consists of a convenient framework-agnostic, in-memory cache for managing your data, which uses adapters to communicate with various persistence layers.

__See Latest Release:__ [JSData Releases](https://github.com/js-data/js-data/releases)
__Latest Release:__ [![Latest Release](https://img.shields.io/github/release/js-data/js-data.svg?style=flat-square)](https://github.com/js-data/js-data/releases)
## Project Status
__Status:__
| Project | js-data |
| ------ | ------ |
| Tasks | [![Stories in Backlog](https://badge.waffle.io/js-data/js-data.svg?label=backlog&title=Backlog)](http://waffle.io/js-data/js-data) [![Stories in Ready](https://badge.waffle.io/js-data/js-data.svg?label=ready&title=Ready)](http://waffle.io/js-data/js-data) [![Stories in progress](https://badge.waffle.io/js-data/js-data.svg?label=in%20progress&title=In%20Progress)](http://waffle.io/js-data/js-data) |
| Bower | [![Bower version](https://badge.fury.io/bo/js-data.png)](http://badge.fury.io/bo/js-data) |
| NPM | [![NPM](https://nodei.co/npm/js-data.png?downloads=true&stars=true)](https://nodei.co/npm/js-data/) |
| Build Status | [![Circle CI](https://circleci.com/gh/js-data/js-data/tree/master.png?style=badge)](https://circleci.com/gh/js-data/js-data/tree/master) |
| Code Climate | [![Code Climate](https://codeclimate.com/github/js-data/js-data.png)](https://codeclimate.com/github/js-data/js-data) |
| Dependency Status | [![Dependency Status](https://gemnasium.com/js-data/js-data.png)](https://gemnasium.com/js-data/js-data) |
| Coverage | [![Coverage Status](https://coveralls.io/repos/js-data/js-data/badge.png?branch=master)](https://coveralls.io/r/js-data/js-data?branch=master) |
[![Dependency Status](https://img.shields.io/gemnasium/js-data/js-data.svg?style=flat-square)](https://gemnasium.com/js-data/js-data) [![Coverage Status](https://img.shields.io/coveralls/js-data/js-data/master.svg?style=flat-square)](https://coveralls.io/r/js-data/js-data?branch=master) [![Codacity](https://img.shields.io/codacy/88b55f71c45a47838d24ed1e5fd2476c.svg?style=flat-square)](https://www.codacy.com/public/jasondobry/js-data/dashboard)
## Supported Platforms
__Supported Platforms:__
Browsers: Chrome, Firefox, IE 9+, Safari, Opera, iOS Safari 7.1+, Android Browser 2.3+
[![node version](https://img.shields.io/badge/Node-0.10%2B-green.svg?style=flat-square)](https://github.com/js-data/js-data) [![browsers](https://img.shields.io/badge/Browser-Chrome%2CFirefox%2CSafari%2COpera%2CIE%209%2B%2CiOS%20Safari%207.1%2B%2CAndroid%20Browser%202.3%2B-green.svg?style=flat-square)](https://github.com/js-data/js-data)
Node: 0.10+
## Quick Start
### Quick Start
`bower install --save js-data js-data-http` or `npm install --save js-data js-data-http`.

@@ -110,3 +100,3 @@

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

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

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

@@ -140,6 +130,6 @@ - [js-data-schema](http://www.js-data.io/docs/js-data-schema)

## Changelog
### Changelog
[CHANGELOG.md](https://github.com/js-data/js-data/blob/master/CHANGELOG.md)
## Community
### Community
- [Mailing List](https://groups.io/org/groupsio/jsdata) - Ask your questions!

@@ -150,3 +140,3 @@ - [Issues](https://github.com/js-data/js-data/issues) - Found a bug? Feature request? Submit an issue!

## Contributing
### Contributing

@@ -165,3 +155,3 @@ First, feel free to contact me with questions. [Mailing List](https://groups.io/org/groupsio/jsdata).

## License
### License

@@ -168,0 +158,0 @@ The MIT License (MIT)

@@ -45,3 +45,3 @@ var DSUtils = require('../../utils');

if (options.notify) {
definition.emit('DS.beforeCreate', definition, DSUtils.copy(attrs));
definition.emit('DS.beforeCreate', definition, attrs);
}

@@ -55,3 +55,3 @@ return _this.getAdapter(options).create(definition, attrs, options);

if (options.notify) {
definition.emit('DS.afterCreate', definition, DSUtils.copy(attrs));
definition.emit('DS.afterCreate', definition, attrs);
}

@@ -61,3 +61,5 @@ if (options.cacheResponse) {

var id = created[definition.idAttribute];
_this.s[resourceName].completedQueries[id] = new Date().getTime();
var resource = _this.s[resourceName];
resource.completedQueries[id] = new Date().getTime();
resource.saved[id] = DSUtils.updateTimestamp(resource.saved[id]);
return created;

@@ -64,0 +66,0 @@ } else {

@@ -27,3 +27,3 @@ var DSUtils = require('../../utils');

if (options.notify) {
definition.emit('DS.beforeDestroy', definition, DSUtils.copy(attrs));
definition.emit('DS.beforeDestroy', definition, attrs);
}

@@ -40,3 +40,3 @@ if (options.eagerEject) {

if (options.notify) {
definition.emit('DS.afterDestroy', definition, DSUtils.copy(item));
definition.emit('DS.afterDestroy', definition, item);
}

@@ -43,0 +43,0 @@ _this.eject(resourceName, id);

@@ -26,3 +26,3 @@ var DSUtils = require('../../utils');

if (options.notify) {
definition.emit('DS.beforeDestroy', definition, DSUtils.copy(toEject));
definition.emit('DS.beforeDestroy', definition, toEject);
}

@@ -37,3 +37,3 @@ if (options.eagerEject) {

if (options.notify) {
definition.emit('DS.afterDestroy', definition, DSUtils.copy(toEject));
definition.emit('DS.afterDestroy', definition, toEject);
}

@@ -40,0 +40,0 @@ return ejected || _this.ejectAll(resourceName, params);

@@ -61,2 +61,3 @@ /* jshint -W082 */

resource.completedQueries[id] = new Date().getTime();
resource.saved[id] = DSUtils.updateTimestamp(resource.saved[id]);
return injected;

@@ -63,0 +64,0 @@ } else {

@@ -26,4 +26,8 @@ /* jshint -W082 */

DSUtils.forEach(injected, function (item) {
if (item && item[idAttribute]) {
resource.completedQueries[item[idAttribute]] = date;
if (item) {
var id = item[idAttribute];
if (id) {
resource.completedQueries[id] = date;
resource.saved[id] = DSUtils.updateTimestamp(resource.saved[id]);
}
}

@@ -30,0 +34,0 @@ });

@@ -32,5 +32,6 @@ var DSUtils = require('../../utils');

definition.beforeReap(options, items);
definition.emit('DS.beforeReap', definition, DSUtils.copy(items));
definition.emit('DS.beforeReap', definition, items);
}
if (options.reapAction === 'inject') {
var timestamp = new Date().getTime();
DSUtils.forEach(items, function (item) {

@@ -40,4 +41,4 @@ var id = item[definition.idAttribute];

item: item,
timestamp: resource.saved[id],
expires: definition.maxAge ? resource.saved[id] + definition.maxAge : Number.MAX_VALUE
timestamp: timestamp,
expires: definition.maxAge ? timestamp + definition.maxAge : Number.MAX_VALUE
});

@@ -60,3 +61,3 @@ });

definition.afterReap(options, items);
definition.emit('DS.afterReap', definition, DSUtils.copy(items));
definition.emit('DS.afterReap', definition, items);
}

@@ -63,0 +64,0 @@ return items;

@@ -37,3 +37,3 @@ var DSUtils = require('../../utils');

if (options.notify) {
definition.emit('DS.beforeUpdate', definition, DSUtils.copy(attrs));
definition.emit('DS.beforeUpdate', definition, attrs);
}

@@ -69,6 +69,9 @@ if (options.changesOnly) {

if (options.notify) {
definition.emit('DS.afterUpdate', definition, DSUtils.copy(attrs));
definition.emit('DS.afterUpdate', definition, attrs);
}
if (options.cacheResponse) {
return _this.inject(definition.n, attrs, options);
var injected = _this.inject(definition.n, attrs, options);
var saved = _this.s[resourceName].saved;
saved[injected[definition.idAttribute]] = DSUtils.updateTimestamp(saved[injected[definition.idAttribute]]);
return injected;
} else {

@@ -75,0 +78,0 @@ return _this.createInstance(resourceName, attrs, options);

@@ -33,3 +33,3 @@ var DSUtils = require('../../utils');

if (options.notify) {
definition.emit('DS.beforeUpdate', definition, DSUtils.copy(attrs));
definition.emit('DS.beforeUpdate', definition, attrs);
}

@@ -43,6 +43,9 @@ return _this.getAdapter(options).update(definition, id, attrs, options);

if (options.notify) {
definition.emit('DS.afterUpdate', definition, DSUtils.copy(attrs));
definition.emit('DS.afterUpdate', definition, attrs);
}
if (options.cacheResponse) {
return _this.inject(definition.n, attrs, options);
var injected = _this.inject(definition.n, attrs, options);
var saved = _this.s[resourceName].saved;
saved[injected[definition.idAttribute]] = DSUtils.updateTimestamp(saved[injected[definition.idAttribute]]);
return injected;
} else {

@@ -49,0 +52,0 @@ return _this.createInstance(resourceName, attrs, options);

@@ -30,3 +30,3 @@ var DSUtils = require('../../utils');

if (options.notify) {
definition.emit('DS.beforeUpdate', definition, DSUtils.copy(attrs));
definition.emit('DS.beforeUpdate', definition, attrs);
}

@@ -40,6 +40,11 @@ return _this.getAdapter(options).updateAll(definition, attrs, params, options);

if (options.notify) {
definition.emit('DS.afterUpdate', definition, DSUtils.copy(attrs));
definition.emit('DS.afterUpdate', definition, attrs);
}
if (options.cacheResponse) {
return _this.inject(definition.n, data, options);
var injected = _this.inject(definition.n, data, options);
var saved = _this.s[resourceName].saved;
DSUtils.forEach(injected, function (i) {
saved[i[definition.idAttribute]] = DSUtils.updateTimestamp(saved[i[definition.idAttribute]]);
});
return injected;
} else {

@@ -46,0 +51,0 @@ var instances = [];

@@ -34,3 +34,3 @@ var DSUtils = require('../../utils');

definition.beforeEject(options, item);
definition.emit('DS.beforeEject', definition, DSUtils.copy(item));
definition.emit('DS.beforeEject', definition, item);
}

@@ -71,3 +71,3 @@ _this.unlinkInverse(definition.n, id);

definition.afterEject(options, item);
definition.emit('DS.afterEject', definition, DSUtils.copy(item));
definition.emit('DS.afterEject', definition, item);
}

@@ -74,0 +74,0 @@

@@ -148,4 +148,2 @@ var DSUtils = require('../../utils');

}
resource.previousAttributes[id] = DSUtils.copy(attrs);
DSUtils.deepMixIn(item, attrs);

@@ -163,2 +161,4 @@

_react.call(item, {}, {}, {}, null, true);
resource.previousAttributes[id] = {};
DSUtils.deepMixIn(resource.previousAttributes[id], item);
} else {

@@ -180,9 +180,9 @@ DSUtils.deepMixIn(item, attrs);

}
resource.saved[id] = DSUtils.updateTimestamp(resource.saved[id]);
resource.modified[id] = initialLastModified && resource.modified[id] === initialLastModified ? DSUtils.updateTimestamp(resource.modified[id]) : resource.modified[id];
resource.expiresHeap.remove(item);
var timestamp = new Date().getTime();
resource.expiresHeap.push({
item: item,
timestamp: resource.saved[id],
expires: definition.maxAge ? resource.saved[id] + definition.maxAge : Number.MAX_VALUE
timestamp: timestamp,
expires: definition.maxAge ? timestamp + definition.maxAge : Number.MAX_VALUE
});

@@ -229,3 +229,3 @@ injected = item;

options.beforeInject(options, attrs);
definition.emit('DS.beforeInject', definition, DSUtils.copy(attrs));
definition.emit('DS.beforeInject', definition, attrs);
}

@@ -256,3 +256,3 @@

options.afterInject(options, injected);
definition.emit('DS.afterInject', definition, DSUtils.copy(injected));
definition.emit('DS.afterInject', definition, injected);
}

@@ -259,0 +259,0 @@

@@ -35,5 +35,8 @@ describe('DS#reap', function () {

console.log(Thing.lastSaved(1));
console.log(Thing.lastSaved(2));
setTimeout(function () {
try {
assert.equal(expiresHeap.peek().item.id, 1);
assert.isTrue(expiresHeap.peek().item.id === 1 || expiresHeap.peek().item.id === 2);
assert.equal(expiresHeap.heap.length, 2);

@@ -43,3 +46,3 @@

assert.equal(expiresHeap.peek().item.id, 2);
assert.isTrue(expiresHeap.peek().item.id === 1 || expiresHeap.peek().item.id === 2);
assert.equal(expiresHeap.heap.length, 2);

@@ -46,0 +49,0 @@

@@ -218,7 +218,9 @@ describe('DS#defineResource', function () {

function MyBaseClass(){
this.instanceMethod = function( value ){
function MyBaseClass() {
this.foo = 'bar';
this.instanceMethod = function (value) {
return 'instanceMethod' + value;
};
this.firstNameBackwards = function(){
this.firstNameBackwards = function () {
return this.first.split("").reverse().join("");

@@ -228,3 +230,3 @@ };

MyBaseClass.prototype.protoMethod = function( value ){
MyBaseClass.prototype.protoMethod = function (value) {
return 'protoMethod' + value;

@@ -244,3 +246,3 @@ };

var Thing2 = store.defineResource({

@@ -276,16 +278,16 @@ name: 'thing2',

assert.equal(thing2.protoMethod('Other'), 'protoMethodOther');
assert.equal(thing1.firstNameBackwards(), 'nhoJ');
assert.equal(thing2.firstNameBackwards(), 'sirreF');
/* Is this really necessary to test?
thing2.firstNameBackwards = function(){
return this.first.split("").reverse().join(".");
}
assert.equal(thing1.firstNameBackwards(), 'nhoJ');
assert.equal(thing2.firstNameBackwards(), 's.i.r.r.e.F');
*/
thing2.firstNameBackwards = function(){
return this.first.split("").reverse().join(".");
}
assert.equal(thing1.firstNameBackwards(), 'nhoJ');
assert.equal(thing2.firstNameBackwards(), 's.i.r.r.e.F');
*/
});
});

@@ -127,11 +127,21 @@ describe('DS#update', function () {

function onBeforeUpdate(resource, attrs) {
attrs.other = 'stuff';
assert.equal(resource.name, 'comment');
assert.deepEqual(attrs, { content: 'stuff', other: 'stuff' });
try {
attrs.other = 'stuff';
assert.equal(resource.name, 'comment');
assert.deepEqual(attrs, { content: 'stuff', other: 'stuff' });
} catch (err) {
console.log(err.stack);
done(err);
}
}
function onAfterUpdate(resource, attrs) {
assert.equal(resource.name, 'comment');
assert.deepEqual(attrs, testComment2);
assert.isFalse(testComment2 === attrs);
try {
assert.equal(resource.name, 'comment');
assert.deepEqual(JSON.stringify(attrs), JSON.stringify({ id: 6, content: 'stuff', approvedBy: 4 }));
assert.isFalse(testComment2 === attrs);
} catch (err) {
console.log(err.stack);
done(err);
}
}

@@ -149,7 +159,10 @@

}).then(function (comment) {
assert.deepEqual(JSON.stringify(comment), JSON.stringify(testComment2));
assert.deepEqual(JSON.stringify(comment), JSON.stringify(store.get('comment', 6)));
try {
assert.deepEqual(JSON.stringify(comment), JSON.stringify(testComment2));
assert.deepEqual(JSON.stringify(comment), JSON.stringify(store.get('comment', 6)));
store.inject('comment', testComment2);
store.inject('comment', testComment2);
} catch (err) {
console.log(err.stack);
}
store.update('comment', 6, {

@@ -171,7 +184,12 @@ content: 'stuff'

setTimeout(function () {
assert.equal(3, _this.requests.length);
assert.equal(_this.requests[2].url, 'http://test.js-data.io/comment/6');
assert.equal(_this.requests[2].method, 'PUT');
assert.equal(_this.requests[2].requestBody, DSUtils.toJson({ content: 'stuff' }));
_this.requests[2].respond(200, { 'Content-Type': 'application/json' }, DSUtils.toJson(testComment2));
try {
assert.equal(3, _this.requests.length);
assert.equal(_this.requests[2].url, 'http://test.js-data.io/comment/6');
assert.equal(_this.requests[2].method, 'PUT');
assert.equal(_this.requests[2].requestBody, DSUtils.toJson({ content: 'stuff', other: 'stuff' }));
_this.requests[2].respond(200, { 'Content-Type': 'application/json' }, DSUtils.toJson(testComment2));
} catch (err) {
console.log(err.stack);
done(err);
}
}, 30);

@@ -184,7 +202,12 @@ }).catch(function (err) {

setTimeout(function () {
assert.equal(2, _this.requests.length);
assert.equal(_this.requests[1].url, 'http://test.js-data.io/user/4/comment/6');
assert.equal(_this.requests[1].method, 'PUT');
assert.equal(_this.requests[1].requestBody, DSUtils.toJson({ content: 'stuff' }));
_this.requests[1].respond(200, { 'Content-Type': 'application/json' }, DSUtils.toJson(testComment2));
try {
assert.equal(2, _this.requests.length);
assert.equal(_this.requests[1].url, 'http://test.js-data.io/user/4/comment/6');
assert.equal(_this.requests[1].method, 'PUT');
assert.equal(_this.requests[1].requestBody, DSUtils.toJson({ content: 'stuff', other: 'stuff' }));
_this.requests[1].respond(200, { 'Content-Type': 'application/json' }, DSUtils.toJson(testComment2));
} catch (err) {
console.log(err.stack);
done(err);
}
}, 30);

@@ -191,0 +214,0 @@ }).catch(function (err) {

@@ -11,3 +11,3 @@ describe('DS#lastSaved', function () {

assert.notEqual(lastSaved, store.lastSaved('post', 5));
assert.equal(lastSaved, store.lastSaved('post', 5));

@@ -14,0 +14,0 @@ lastSaved = store.lastSaved('post', 5);

Sorry, the diff of this file is too big to display

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