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

angular-data

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-data - npm Package Compare versions

Comparing version 1.0.0-beta.1 to 1.0.0-beta.2

src/datastore/sync_methods/compute.js

20

CHANGELOG.md

@@ -0,1 +1,20 @@

##### 1.0.0-beta.2 - xx August 2014
###### Breaking API changes
- `findBelongsTo` option of `DS.inject` now defaults to `false`
###### Backwards compatible API changes
- #132 - Added `findHasMany` option and capability to `DS.inject`
- #133 - Override resource end point in async methods
- #136 - Add a way to force computed properties to be computed. Added `DS.compute`. Added `DSCompute` to prototype of instances.
- #137 - Add `DS.link`, `DS.linkAll`, and `DS.linkInverse`, and added `linkInverse` option to `DS.inject`
###### Backwards compatible bug fixes
- #135 - loadrelations loop
- #140 - lastModified changes when loading distant related objects
###### Other
- #138 - Performance optimizations
- #139 - Documentation error
##### 1.0.0-beta.1 - 23 August 2014

@@ -8,2 +27,3 @@

- #132 - Inject relations for parent resource on create
- #141 - Allow lifecycle hooks to be overridden per method as well

@@ -10,0 +30,0 @@ ###### Backwards compatible bug fixes

6

dist/angular-data.min.js
/**
* @author Jason Dobry <jason.dobry@gmail.com>
* @file angular-data.min.js
* @version 1.0.0-beta.1 - Homepage <http://angular-data.pseudobry.com/>
* @version 1.0.0-beta.2 - Homepage <http://angular-data.pseudobry.com/>
* @copyright (c) 2014 Jason Dobry <https://github.com/jmdobry/>

@@ -10,3 +10,3 @@ * @license MIT <https://github.com/jmdobry/angular-data/blob/master/LICENSE>

*/
!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);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.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 diffObjectFromOldObject(a,b){var c={},d={},e={};for(var f in b){var g=a[f];(void 0===g||g!==b[f])&&(f in a?g!==b[f]&&(e[f]=g):d[f]=void 0)}for(var f in a)f in b||(c[f]=a[f]);return Array.isArray(a)&&a.length!==b.length&&(e.length=a.length),{added:c,removed:d,changed:e}}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 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.Observer.runEOM_=runEOM,global.Observer.observerSentinel_=observerSentinel,global.Observer.hasObjectObserve=hasObserve,global.ObjectObserver=ObjectObserver}((exports.Number={isNaN:window.isNaN})?exports:exports)},{}],2:[function(a,b){function c(a,b){return-1!==d(a,b)}var d=a("./indexOf");b.exports=c},{"./indexOf":5}],3:[function(a,b){function c(a,b,c){b=d(b,c);var e=[];if(null==a)return e;for(var f,g=-1,h=a.length;++g<h;)f=a[g],b(f,g,a)&&e.push(f);return e}var d=a("../function/makeIterator_");b.exports=c},{"../function/makeIterator_":11}],4:[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},{}],5:[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},{}],6:[function(a,b){function c(a){return null!=a&&""!==a}function d(a,b){return b=b||"",e(a,c).join(b)}var e=a("./filter");b.exports=d},{"./filter":3}],7:[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},{}],8:[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},{}],9:[function(a,b){function c(a,b){var c={};if(null==a)return c;var e,f=-1,g=a.length;if(d(b))for(;++f<g;)e=a[f],c[b(e)]=e;else for(;++f<g;)e=a[f],c[e[b]]=e;return c}var d=a("../lang/isFunction");b.exports=c},{"../lang/isFunction":16}],10:[function(a,b){function c(a){return a}b.exports=c},{}],11:[function(a,b){function c(a,b){if(null==a)return d;switch(typeof a){case"function":return"undefined"!=typeof b?function(c,d,e){return a.call(b,c,d,e)}:a;case"object":return function(b){return f(b,a)};case"string":case"number":return e(a)}}var d=a("./identity"),e=a("./prop"),f=a("../object/deepMatches");b.exports=c},{"../object/deepMatches":21,"./identity":10,"./prop":12}],12:[function(a,b){function c(a){return function(b){return b[a]}}b.exports=c},{}],13:[function(a,b){var c=a("./isKind"),d=Array.isArray||function(a){return c(a,"Array")};b.exports=d},{"./isKind":17}],14:[function(a,b){function c(a){return d(a,"Boolean")}var d=a("./isKind");b.exports=c},{"./isKind":17}],15:[function(a,b){function c(a){if(null==a)return!1;if("string"==typeof a||e(a))return!a.length;if("object"==typeof a||"function"==typeof a){var b=!0;return d(a,function(){return b=!1,!1}),b}return!1}var d=a("../object/forOwn"),e=a("./isArray");b.exports=c},{"../object/forOwn":24,"./isArray":13}],16:[function(a,b){function c(a){return d(a,"Function")}var d=a("./isKind");b.exports=c},{"./isKind":17}],17:[function(a,b){function c(a,b){return d(a)===b}var d=a("./kindOf");b.exports=c},{"./kindOf":19}],18:[function(a,b){function c(a){return!!a&&"object"==typeof a&&a.constructor===Object}b.exports=c},{}],19:[function(a,b){function c(a){return null===a?"Null":a===d?"Undefined":e.exec(f.call(a))[1]}var d,e=/^\[object (.*)\]$/,f=Object.prototype.toString;b.exports=c},{}],20:[function(a,b){function c(a){return null==a?"":a.toString()}b.exports=c},{}],21:[function(a,b){function c(a,b){for(var c=-1,d=a.length;++c<d;)if(f(a[c],b))return!0;return!1}function d(a,b){for(var d=-1,e=b.length;++d<e;)if(!c(a,b[d]))return!1;return!0}function e(a,b){var c=!0;return g(b,function(b,d){return f(a[d],b)?void 0:c=!1}),c}function f(a,b){return a&&"object"==typeof a?h(a)&&h(b)?d(a,b):e(a,b):a===b}var g=a("./forOwn"),h=a("../lang/isArray");b.exports=f},{"../lang/isArray":13,"./forOwn":24}],22:[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":18,"./forOwn":24}],23:[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":25}],24:[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":23,"./hasOwn":25}],25:[function(a,b){function c(a,b){return Object.prototype.hasOwnProperty.call(a,b)}b.exports=c},{}],26:[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":4}],27:[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":7}],28:[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":26}],29:[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":20,"./lowerCase":30,"./removeNonWord":33,"./replaceAccents":34,"./upperCase":35}],30:[function(a,b){function c(a){return a=d(a),a.toLowerCase()}var d=a("../lang/toString");b.exports=c},{"../lang/toString":20}],31:[function(a,b){function c(){var a=d(e(arguments),"/");return a.replace(/([^:\/]|^)\/{2,}/g,"$1/")}var d=a("../array/join"),e=a("../array/slice");b.exports=c},{"../array/join":6,"../array/slice":7}],32:[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":20,"./camelCase":29,"./upperCase":35}],33:[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":20}],34:[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":20}],35:[function(a,b){function c(a){return a=d(a),a.toUpperCase()}var d=a("../lang/toString");b.exports=c},{"../lang/toString":20}],36:[function(a,b){function c(){var a=this.defaults={queryTransform:function(a,b){return b},$httpConfig:{}};this.$get=["$http","$log","DSUtils",function(b,c,d){return{defaults:a,HTTP:function(e){var f=(new Date).getTime();return e=d.deepMixIn(e,a.$httpConfig),b(e).then(function(a){return c.debug(a.config.method+" request:"+a.config.url+" Time taken: "+((new Date).getTime()-f)+"ms",arguments),a})},GET:function(a,b){return b=b||{},this.HTTP(d.deepMixIn(b,{url:a,method:"GET"}))},POST:function(a,b,c){return c=c||{},this.HTTP(d.deepMixIn(c,{url:a,data:b,method:"POST"}))},PUT:function(a,b,c){return c=c||{},this.HTTP(d.deepMixIn(c,{url:a,data:b||{},method:"PUT"}))},DEL:function(a,b){return b=b||{},this.HTTP(d.deepMixIn(b,{url:a,method:"DELETE"}))},find:function(a,b,c){return c=c||{},this.GET(d.makePath(c.baseUrl||a.baseUrl,a.getEndpoint(b,c),b),c)},findAll:function(b,c,e){return e=e||{},e.params=e.params||{},c&&(c=a.queryTransform(b.name,c),d.deepMixIn(e.params,c)),this.GET(d.makePath(e.baseUrl||b.baseUrl,b.getEndpoint(null,e)),e)},create:function(a,b,c){return c=c||{},this.POST(d.makePath(c.baseUrl||a.baseUrl,a.getEndpoint(b,c)),b,c)},update:function(a,b,c,e){return e=e||{},this.PUT(d.makePath(e.baseUrl||a.baseUrl,a.getEndpoint(b,e),b),c,e)},updateAll:function(b,c,e,f){return f=f||{},f.params=f.params||{},e&&(e=a.queryTransform(b.name,e),d.deepMixIn(f.params,e)),this.PUT(d.makePath(f.baseUrl||b.baseUrl,b.getEndpoint(null,f)),c,f)},destroy:function(a,b,c){return c=c||{},this.DEL(d.makePath(c.baseUrl||a.baseUrl,a.getEndpoint(b,c),b),c)},destroyAll:function(b,c,e){return e=e||{},e.params=e.params||{},c&&(c=a.queryTransform(b.name,c),d.deepMixIn(e.params,c)),this.DEL(d.makePath(e.baseUrl||b.baseUrl,b.getEndpoint(null,e)),e)}}}]}b.exports=c},{}],37:[function(a,b){function c(){this.$get=["$q","DSUtils","DSErrors",function(a,b,c){return{GET:function(b){var c=a.defer();try{var d=localStorage.getItem(b);c.resolve(d?angular.fromJson(d):void 0)}catch(e){c.reject(e)}return c.promise},PUT:function(a,c){var d=this;return d.GET(a).then(function(e){return e&&b.deepMixIn(e,c),localStorage.setItem(a,angular.toJson(e||c)),d.GET(a)})},DEL:function(b){var c=a.defer();try{localStorage.removeItem(b),c.resolve()}catch(d){c.reject(d)}return c.promise},find:function(a,c,d){return d=d||{},this.GET(b.makePath(d.baseUrl||a.baseUrl,a.endpoint,c))},findAll:function(){throw new Error("DSLocalStorageAdapter.findAll is not supported!")},create:function(a,d,e){if(!(a.idAttribute in d))throw new c.IA("DSLocalStorageAdapter.create: You must provide a primary key in the attrs object!");return e=e||{},this.PUT(b.makePath(e.baseUrl||a.baseUrl,a.getEndpoint(d,e),d[a.idAttribute]),d)},update:function(a,c,d,e){return e=e||{},this.PUT(b.makePath(e.baseUrl||a.baseUrl,a.getEndpoint(c,e),c),d)},updateAll:function(){throw new Error("DSLocalStorageAdapter.updateAll is not supported!")},destroy:function(a,c,d){return d=d||{},this.DEL(b.makePath(d.baseUrl||a.baseUrl,a.getEndpoint(c,d),c))},destroyAll:function(){throw new Error("Not supported!")}}}]}b.exports=c},{}],38:[function(a,b){function c(a){return"DS.create("+a+", attrs[, options]): "}function d(a,b,d){var e=this,f=e.$q.defer(),g=f.promise,h=e.definitions[a];try{if(d=d||{},!h)throw new e.errors.NER(c(a)+a);if(!e.utils.isObject(b))throw new e.errors.IA(c(a)+"attrs: Must be an object!");var i=e.store[a];"cacheResponse"in d||(d.cacheResponse=!0),"upsert"in d||(d.upsert=!0),g=d.upsert&&b[h.idAttribute]?e.update(a,b[h.idAttribute],b,d):g.then(function(b){return e.$q.promisify(h.beforeValidate)(a,b)}).then(function(b){return e.$q.promisify(h.validate)(a,b)}).then(function(b){return e.$q.promisify(h.afterValidate)(a,b)}).then(function(b){return e.$q.promisify(h.beforeCreate)(a,b)}).then(function(b){return e.adapters[d.adapter||h.defaultAdapter].create(h,h.serialize(a,b),d)}).then(function(b){return e.$q.promisify(h.afterCreate)(a,h.deserialize(a,b))}).then(function(a){if(d.cacheResponse){var b=e.inject(h.name,a),c=b[h.idAttribute];return i.completedQueries[c]=(new Date).getTime(),i.previousAttributes[c]=e.utils.deepMixIn({},b),i.saved[c]=e.utils.updateTimestamp(i.saved[c]),e.get(h.name,c)}return a}),f.resolve(b)}catch(j){f.reject(j)}return g}b.exports=d},{}],39:[function(a,b){function c(a,b){return"DS.destroy("+a+", "+b+"[, options]): "}function d(a,b,d){var e=this,f=e.$q.defer(),g=f.promise,h=e.definitions[a];try{if(d=d||{},!h)throw new e.errors.NER(c(a,b)+a);if(!e.utils.isString(b)&&!e.utils.isNumber(b))throw new e.errors.IA(c(a,b)+"id: Must be a string or a number!");var i=e.get(a,b);if(!i)throw new e.errors.R(c(a,b)+'id: "'+b+'" not found!');g=g.then(function(b){return e.$q.promisify(h.beforeDestroy)(a,b)}).then(function(){return e.adapters[d.adapter||h.defaultAdapter].destroy(h,b,d)}).then(function(){return e.$q.promisify(h.afterDestroy)(a,i)}).then(function(){return e.eject(a,b),b}),f.resolve(i)}catch(j){f.reject(j)}return g}b.exports=d},{}],40:[function(a,b){function c(a){return"DS.destroyAll("+a+", params[, options]): "}function d(a,b,d){var e=this,f=e.$q.defer(),g=f.promise,h=e.definitions[a];try{var i=e.errors.IA;if(d=d||{},!h)throw new e.errors.NER(c(a)+a);if(!e.utils.isObject(b))throw new i(c(a)+"params: Must be an object!");if(!e.utils.isObject(d))throw new i(c(a)+"options: Must be an object!");g=g.then(function(){return e.adapters[d.adapter||h.defaultAdapter].destroyAll(h,b,d)}).then(function(){return e.ejectAll(a,b)}),f.resolve()}catch(j){f.reject(j)}return g}b.exports=d},{}],41:[function(a,b){function c(a,b){return"DS.find("+a+", "+b+"[, options]): "}function d(a,b,d){var e=this,f=e.$q.defer(),g=f.promise;try{var h=e.errors.IA;if(d=d||{},!e.definitions[a])throw new e.errors.NER(c(a,b)+a);if(!e.utils.isString(b)&&!e.utils.isNumber(b))throw new h(c(a,b)+"id: Must be a string or a number!");if(!e.utils.isObject(d))throw new h(c(a,b)+"options: Must be an object!");"cacheResponse"in d||(d.cacheResponse=!0);var i=e.definitions[a],j=e.store[a];if((d.bypassCache||!d.cacheResponse)&&delete j.completedQueries[b],!(b in j.completedQueries))return b in j.pendingQueries||(g=j.pendingQueries[b]=e.adapters[d.adapter||i.defaultAdapter].find(i,b,d).then(function(c){var f=i.deserialize(a,c);return d.cacheResponse?(delete j.pendingQueries[b],j.completedQueries[b]=(new Date).getTime(),e.inject(a,f)):f},function(a){return delete j.pendingQueries[b],e.$q.reject(a)})),j.pendingQueries[b];f.resolve(e.get(a,b))}catch(k){f.reject(k)}return g}b.exports=d},{}],42:[function(a,b){function c(a){return"DS.findAll("+a+", params[, options]): "}function d(a,b,d){var e=this,f=e.store[b],g=e.definitions[b].idAttribute,h=(new Date).getTime();a=a||[],delete f.pendingQueries[d],f.completedQueries[d]=h,f.collectionModified=e.utils.updateTimestamp(f.collectionModified);var i=e.inject(b,a);return e.utils.isArray(i)?angular.forEach(i,function(a){a&&a[g]&&(f.completedQueries[a[g]]=h)}):(e.$log.warn(c(b)+"response is expected to be an array!"),f.completedQueries[i[g]]=h),i}function e(a,b,c){var e=this,f=e.definitions[a],g=e.store[a],h=e.utils.toJson(b);return(c.bypassCache||!c.cacheResponse)&&delete g.completedQueries[h],h in g.completedQueries?e.filter(a,b,c):(h in g.pendingQueries||(g.pendingQueries[h]=e.adapters[c.adapter||f.defaultAdapter].findAll(f,b,c).then(function(b){var g=f.deserialize(a,b);if(!c.cacheResponse)return g;try{return d.apply(e,[g,a,h])}catch(i){return e.$q.reject(i)}},function(a){return delete g.pendingQueries[h],e.$q.reject(a)})),g.pendingQueries[h])}function f(a,b,d){var f=this,g=f.$q.defer(),h=g.promise;try{var i=f.errors.IA;if(d=d||{},b=b||{},!f.definitions[a])throw new f.errors.NER(c(a)+a);if(!f.utils.isObject(b))throw new i(c(a)+"params: Must be an object!");if(!f.utils.isObject(d))throw new i(c(a)+"options: Must be an object!");"cacheResponse"in d||(d.cacheResponse=!0),h=h.then(function(){return e.apply(f,[a,b,d])}),g.resolve()}catch(j){g.reject(j)}return h}b.exports=f},{}],43:[function(a,b){b.exports={create:a("./create"),destroy:a("./destroy"),destroyAll:a("./destroyAll"),find:a("./find"),findAll:a("./findAll"),loadRelations:a("./loadRelations"),refresh:a("./refresh"),save:a("./save"),update:a("./update"),updateAll:a("./updateAll")}},{"./create":38,"./destroy":39,"./destroyAll":40,"./find":41,"./findAll":42,"./loadRelations":44,"./refresh":45,"./save":46,"./update":47,"./updateAll":48}],44:[function(a,b){function c(a){return"DS.loadRelations("+a+", instance(Id), relations[, options]): "}function d(a,b,d,e){var f=this,g=f.$q.defer(),h=g.promise,i=f.definitions[a];try{var j=f.errors.IA;if(e=e||{},(angular.isString(b)||angular.isNumber(b))&&(b=f.get(a,b)),angular.isString(d)&&(d=[d]),!i)throw new f.errors.NER(c(a)+a);if(!f.utils.isObject(b))throw new j(c(a)+"instance(Id): Must be a string, number or object!");if(!f.utils.isArray(d))throw new j(c(a)+"relations: Must be a string or an array!");if(!f.utils.isObject(e))throw new j(c(a)+"options: Must be an object!");var k=[],l=[];f.utils.forOwn(i.relations,function(a,c){f.utils.forOwn(a,function(a,g){f.utils.isArray(a)||(a=[a]),a.forEach(function(a){if(f.utils.contains(d,g)){var h,j={};j[a.foreignKey]=b[i.idAttribute],"hasMany"===c?h=f.findAll(g,j,e):"hasOne"===c?a.localKey&&b[a.localKey]?h=f.find(g,b[a.localKey],e):a.foreignKey&&(h=f.findAll(g,j,e)):h=f.find(g,b[a.localKey],e),h&&(k.push(h),l.push(a.localField))}})})}),h=h.then(function(){return f.$q.all(k)}).then(function(a){return angular.forEach(l,function(c,d){b[c]=a[d]}),b}),g.resolve()}catch(m){g.reject(m)}return h}b.exports=d},{}],45:[function(a,b){function c(a,b){return"DS.refresh("+a+", "+b+"[, options]): "}function d(a,b,d){var e=this,f=e.errors.IA;if(d=d||{},e.definitions[a]){if(e.utils.isString(b)||e.utils.isNumber(b)){if(e.utils.isObject(d)){if(d.bypassCache=!0,e.get(a,b))return e.find(a,b,d);var g=e.$q.defer();return g.resolve(),g.promise}throw new f(c(a,b)+"options: Must be an object!")}throw new f(c(a,b)+"id: Must be a string or a number!")}throw new e.errors.NER(c(a,b)+a)}b.exports=d},{}],46:[function(a,b){function c(a,b){return"DS.save("+a+", "+b+"[, options]): "}function d(a,b,d){var e=this,f=e.$q.defer(),g=f.promise,h=e.definitions[a];try{var i=e.errors.IA;if(d=d||{},!h)throw new e.errors.NER(c(a,b)+a);if(!e.utils.isString(b)&&!e.utils.isNumber(b))throw new i(c(a,b)+"id: Must be a string or a number!");if(!e.utils.isObject(d))throw new i(c(a,b)+"options: Must be an object!");var j=e.get(a,b);if(!j)throw new e.errors.R(c(a,b)+'id: "'+b+'" not found!');var k=e.store[a];"cacheResponse"in d||(d.cacheResponse=!0),g=g.then(function(b){return e.$q.promisify(h.beforeValidate)(a,b)}).then(function(b){return e.$q.promisify(h.validate)(a,b)}).then(function(b){return e.$q.promisify(h.afterValidate)(a,b)}).then(function(b){return e.$q.promisify(h.beforeUpdate)(a,b)}).then(function(c){if(d.changesOnly){k.observers[b].deliver();var f=[],g=e.changes(a,b);for(var i in g.added)f.push(i);for(i in g.changed)f.push(i);if(g=e.utils.pick(c,f),e.utils.isEmpty(g))return c;c=g}return e.adapters[d.adapter||h.defaultAdapter].update(h,b,h.serialize(a,c),d)}).then(function(b){return e.$q.promisify(h.afterUpdate)(a,h.deserialize(a,b))}).then(function(c){if(d.cacheResponse){var f=e.inject(h.name,c,d);return k.previousAttributes[b]=e.utils.deepMixIn({},f),k.saved[b]=e.utils.updateTimestamp(k.saved[b]),e.get(a,b)}return c}),f.resolve(j)}catch(l){f.reject(l)}return g}b.exports=d},{}],47:[function(a,b){function c(a,b){return"DS.update("+a+", "+b+", attrs[, options]): "}function d(a,b,d,e){var f=this,g=f.$q.defer(),h=g.promise;try{var i=f.errors.IA;if(e=e||{},!f.definitions[a])throw new f.errors.NER(c(a,b)+a);if(!f.utils.isString(b)&&!f.utils.isNumber(b))throw new i(c(a,b)+"id: Must be a string or a number!");if(!f.utils.isObject(d))throw new i(c(a,b)+"attrs: Must be an object!");if(!f.utils.isObject(e))throw new i(c(a,b)+"options: Must be an object!");var j=f.definitions[a],k=f.store[a];"cacheResponse"in e||(e.cacheResponse=!0),h=h.then(function(b){return f.$q.promisify(j.beforeValidate)(a,b)}).then(function(b){return f.$q.promisify(j.validate)(a,b)}).then(function(b){return f.$q.promisify(j.afterValidate)(a,b)}).then(function(b){return f.$q.promisify(j.beforeUpdate)(a,b)}).then(function(c){return f.adapters[e.adapter||j.defaultAdapter].update(j,b,j.serialize(a,c),e)}).then(function(b){return f.$q.promisify(j.afterUpdate)(a,j.deserialize(a,b))}).then(function(a){if(e.cacheResponse){var b=f.inject(j.name,a,e),c=b[j.idAttribute];return k.previousAttributes[c]=f.utils.deepMixIn({},b),k.saved[c]=f.utils.updateTimestamp(k.saved[c]),f.get(j.name,c)}return a}),g.resolve(d)}catch(l){g.reject(l)}return h}b.exports=d},{}],48:[function(a,b){function c(a){return"DS.updateAll("+a+", attrs, params[, options]): "}function d(a,b,d,e){var f=this,g=f.$q.defer(),h=g.promise;try{var i=f.errors.IA;if(e=e||{},!f.definitions[a])throw new f.errors.NER(c(a)+a);if(!f.utils.isObject(b))throw new i(c(a)+"attrs: Must be an object!");if(!f.utils.isObject(d))throw new i(c(a)+"params: Must be an object!");if(!f.utils.isObject(e))throw new i(c(a)+"options: Must be an object!");var j=f.definitions[a];"cacheResponse"in e||(e.cacheResponse=!0),h=h.then(function(b){return f.$q.promisify(j.beforeValidate)(a,b)}).then(function(b){return f.$q.promisify(j.validate)(a,b)}).then(function(b){return f.$q.promisify(j.afterValidate)(a,b)}).then(function(b){return f.$q.promisify(j.beforeUpdate)(a,b)}).then(function(b){return f.adapters[e.adapter||j.defaultAdapter].updateAll(j,j.serialize(a,b),d,e)}).then(function(b){return f.$q.promisify(j.afterUpdate)(a,j.deserialize(a,b))}).then(function(a){return e.cacheResponse?f.inject(j.name,a,e):a}),g.resolve(b)}catch(k){g.reject(k)}return h}b.exports=d},{}],49:[function(a,b){function c(a,b,c){c(null,b)}function d(){}function e(){var b=this.defaults=new d;this.$get=["$rootScope","$log","$q","DSHttpAdapter","DSLocalStorageAdapter","DSUtils","DSErrors",function(c,d,e,f,g,h,i){var j,k=a("./sync_methods"),l=a("./async_methods");try{j=angular.injector(["angular-data.DSCacheFactory"]).get("DSCacheFactory")}catch(m){d.warn(m),d.warn("DSCacheFactory is unavailable. Resorting to the lesser capabilities of $cacheFactory."),j=angular.injector(["ng"]).get("$cacheFactory")}var n={notify:function(a,b){var d=Array.prototype.slice.call(arguments,2);d.unshift(a.name),d.unshift("DS."+b),"broadcast"===a.events?c.$broadcast.apply(c,d):"emit"===a.events&&c.$emit.apply(c,d)},$rootScope:c,$log:d,$q:e,cacheFactory:j,defaults:b,store:{},definitions:{},adapters:{DSHttpAdapter:f,DSLocalStorageAdapter:g},errors:i,utils:h};return h.deepFreeze(k),h.deepFreeze(l),h.deepMixIn(n,k),h.deepMixIn(n,l),h.deepFreeze(n.errors),h.deepFreeze(n.utils),("function"!=typeof Object.observe||"function"!=typeof Array.observe)&&c.$watch(function(){return(new Date).getTime()/100|0},function(){n.digest()}),n}]}a("../utils")[0]();d.prototype.idAttribute="id",d.prototype.defaultAdapter="DSHttpAdapter",d.prototype.defaultFilter=function(a,b,c,d){var e=this,f=a,g=null,h={skip:"",offset:"",where:"",limit:"",orderBy:"",sort:""};g=this.utils.isObject(c.where)?c.where:{},d.allowSimpleWhere&&this.utils.forOwn(c,function(a,b){b in h||b in g||(g[b]={"==":a})}),this.utils.isEmpty(g)&&(g=null),g&&(f=this.utils.filter(f,function(a){var b=!0,c=!0;return e.utils.forOwn(g,function(d,f){e.utils.isString(d)?d={"===":d}:(e.utils.isNumber(d)||e.utils.isBoolean(d))&&(d={"==":d}),e.utils.isObject(d)&&e.utils.forOwn(d,function(d,g){"=="===g?c=b?a[f]==d:c&&a[f]==d:"==="===g?c=b?a[f]===d:c&&a[f]===d:"!="===g?c=b?a[f]!=d:c&&a[f]!=d:"!=="===g?c=b?a[f]!==d:c&&a[f]!==d:">"===g?c=b?a[f]>d:c&&a[f]>d:">="===g?c=b?a[f]>=d:c&&a[f]>=d:"<"===g?c=b?a[f]<d:c&&a[f]<d:"<="===g?c=b?a[f]<=d:c&&a[f]<=d:"in"===g?c=b?e.utils.contains(d,a[f]):c&&e.utils.contains(d,a[f]):"|=="===g?c=b?a[f]==d:c||a[f]==d:"|==="===g?c=b?a[f]===d:c||a[f]===d:"|!="===g?c=b?a[f]!=d:c||a[f]!=d:"|!=="===g?c=b?a[f]!==d:c||a[f]!==d:"|>"===g?c=b?a[f]>d:c||a[f]>d:"|>="===g?c=b?a[f]>=d:c||a[f]>=d:"|<"===g?c=b?a[f]<d:c||a[f]<d:"|<="===g?c=b?a[f]<=d:c||a[f]<=d:"|in"===g&&(c=b?e.utils.contains(d,a[f]):c||e.utils.contains(d,a[f])),b=!1})}),c}));var i=null;this.utils.isString(c.orderBy)?i=[[c.orderBy,"ASC"]]:this.utils.isArray(c.orderBy)&&(i=c.orderBy),!i&&this.utils.isString(c.sort)?i=[[c.sort,"ASC"]]:!i&&this.utils.isArray(c.sort)&&(i=c.sort),i&&angular.forEach(i,function(a){if(e.utils.isString(a))a=[a,"ASC"];else if(!e.utils.isArray(a))throw new e.errors.IllegalArgumentError("DS.filter(resourceName[, params][, options]): "+angular.toJson(a)+": Must be a string or an array!",{params:{"orderBy[i]":{actual:typeof a,expected:"string|array"}}});f=e.utils.sort(f,function(b,c){var d=b[a[0]],f=c[a[0]];return e.utils.isString(d)&&(d=e.utils.upperCase(d)),e.utils.isString(f)&&(f=e.utils.upperCase(f)),"DESC"===a[1]?d>f?-1:f>d?1:0:f>d?-1:d>f?1:0})});var j=angular.isNumber(c.limit)?c.limit:null,k=null;return angular.isNumber(c.skip)?k=c.skip:angular.isNumber(c.offset)&&(k=c.offset),j&&k?f=this.utils.slice(f,k,Math.min(f.length,k+j)):this.utils.isNumber(j)?f=this.utils.slice(f,0,Math.min(f.length,j)):this.utils.isNumber(k)&&(f=k<f.length?this.utils.slice(f,k):[]),f},d.prototype.baseUrl="",d.prototype.endpoint="",d.prototype.useClass=!1,d.prototype.beforeValidate=c,d.prototype.validate=c,d.prototype.afterValidate=c,d.prototype.beforeCreate=c,d.prototype.afterCreate=c,d.prototype.beforeUpdate=c,d.prototype.afterUpdate=c,d.prototype.beforeDestroy=c,d.prototype.afterDestroy=c,d.prototype.beforeInject=function(a,b){return b},d.prototype.afterInject=function(a,b){return b},d.prototype.serialize=function(a,b){return b},d.prototype.deserialize=function(a,b){return b.data},d.prototype.events="broadcast",b.exports=e},{"../utils":68,"./async_methods":43,"./sync_methods":61}],50:[function(a,b){function c(a){return"DS.bindAll(scope, expr, "+a+", params[, cb]): "}function d(a,b,d,e,f){var g=this,h=g.errors.IA;if(!g.utils.isObject(a))throw new h(c(d)+"scope: Must be an object!");
if(!g.utils.isString(b))throw new h(c(d)+"expr: Must be a string!");if(!g.definitions[d])throw new g.errors.NER(c(d)+d);if(!g.utils.isObject(e))throw new h(c(d)+"params: Must be an object!");try{return a.$watch(function(){return g.lastModified(d)},function(){var c=g.filter(d,e);g.utils.set(a,b,c),f&&f(null,c)})}catch(i){if(!f)throw i;f(i)}}b.exports=d},{}],51:[function(a,b){function c(a){return"DS.bindOne(scope, expr, "+a+", id[, cb]): "}function d(a,b,d,e,f){var g=this,h=g.errors.IA;if(!g.utils.isObject(a))throw new h(c(d)+"scope: Must be an object!");if(!g.utils.isString(b))throw new h(c(d)+"expr: Must be a string!");if(!g.definitions[d])throw new g.errors.NER(c(d)+d);if(!g.utils.isString(e)&&!g.utils.isNumber(e))throw new h(c(d)+"id: Must be a string or a number!");try{return a.$watch(function(){return g.lastModified(d,e)},function(){var c=g.get(d,e);g.utils.set(a,b,c),f&&f(null,c)})}catch(i){if(!f)throw i;f(i)}}b.exports=d},{}],52:[function(a,b){function c(a){return"DS.changes("+a+", id): "}function d(a,b){var d=this;if(!d.definitions[a])throw new d.errors.NER(c(a)+a);if(!d.utils.isString(b)&&!d.utils.isNumber(b))throw new d.errors.IA(c(a)+"id: Must be a string or a number!");var e=d.get(a,b);if(e){d.store[a].observers[b].deliver();var f=d.utils.diffObjectFromOldObject(e,d.store[a].previousAttributes[b]);return d.utils.forOwn(f,function(a,b){var c=[];d.utils.forOwn(a,function(a,b){angular.isFunction(a)||c.push(b)}),f[b]=d.utils.pick(f[b],c)}),f}}b.exports=d},{}],53:[function(a,b){function c(a){return"DS.createInstance("+a+"[, attrs][, options]): "}function d(a,b,d){var e=this,f=e.errors.IA,g=e.definitions[a];if(b=b||{},d=d||{},!g)throw new e.errors.NER(c(a)+a);if(b&&!e.utils.isObject(b))throw new f(c(a)+"attrs: Must be an object!");if(!e.utils.isObject(d))throw new f(c(a)+"options: Must be an object!");"useClass"in d||(d.useClass=!0);var h;if(d.useClass){var i=g[g.class];h=new i}else h={};return e.utils.deepMixIn(h,b)}b.exports=d},{}],54:[function(require,module,exports){function Resource(a,b){a.deepMixIn(this,b),this.endpoint="endpoint"in b?b.endpoint:this.name}function defineResource(definition){var DS=this,definitions=DS.definitions,IA=DS.errors.IA;if(DS.utils.isString(definition)&&(definition=definition.replace(/\s/gi,""),definition={name:definition}),!DS.utils.isObject(definition))throw new IA(errorPrefix+"definition: Must be an object!");if(!DS.utils.isString(definition.name))throw new IA(errorPrefix+"definition.name: Must be a string!");if(definition.idAttribute&&!DS.utils.isString(definition.idAttribute))throw new IA(errorPrefix+"definition.idAttribute: Must be a string!");if(definition.endpoint&&!DS.utils.isString(definition.endpoint))throw new IA(errorPrefix+"definition.endpoint: Must be a string!");if(DS.store[definition.name])throw new DS.errors.R(errorPrefix+definition.name+" is already registered!");try{Resource.prototype=DS.defaults,definitions[definition.name]=new Resource(DS.utils,definition);var def=definitions[definition.name];def.relations&&def.relations.belongsTo&&DS.utils.forOwn(def.relations.belongsTo,function(a,b){DS.utils.isArray(a)||(a=[a]),DS.utils.forEach(a,function(a){a.parent&&(def.parent=b,def.parentKey=a.localKey)})}),def.getEndpoint=function(a,b){var c,d,e=this.parent,f=this.parentKey;return b=b||{},b.params=b.params||{},e&&f&&definitions[e]&&b.params[f]!==!1&&((DS.utils.isNumber(a)||DS.utils.isString(a))&&(c=DS.get(this.name,a)),DS.utils.isObject(a)&&f in a?(delete b.params[f],d=DS.utils.makePath(definitions[e].getEndpoint(a,b),a[f],this.endpoint)):c&&f in c?(delete b.params[f],d=DS.utils.makePath(definitions[e].getEndpoint(a,b),c[f],this.endpoint)):b&&b.params[f]&&(d=DS.utils.makePath(definitions[e].getEndpoint(a,b),b.params[f],this.endpoint),delete b.params[f])),b.params[f]===!1&&delete b.params[f],d||this.endpoint},def.filter&&(def.defaultFilter=def.filter,delete def.filter);var cache=DS.cacheFactory("DS."+def.name,{maxAge:def.maxAge||null,recycleFreq:def.recycleFreq||1e3,cacheFlushInterval:def.cacheFlushInterval||null,deleteOnExpire:def.deleteOnExpire||"none",onExpire:function(a){var b=DS.eject(def.name,a);DS.utils.isFunction(def.onExpire)&&def.onExpire(a,b)},capacity:Number.MAX_VALUE,storageMode:"memory",storageImpl:null,disabled:!1,storagePrefix:"DS."+def.name});return def.class=DS.utils.pascalCase(definition.name),eval("function "+def.class+"() {}"),def[def.class]=eval(def.class),def.methods&&DS.utils.deepMixIn(def[def.class].prototype,def.methods),def.computed&&DS.utils.forOwn(def.computed,function(a,b){angular.isFunction(a)&&(def.computed[b]=[a],a=def.computed[b]),def.methods&&b in def.methods&&DS.$log.warn(errorPrefix+'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&&DS.$log.warn(errorPrefix+"Use the computed property array syntax for compatibility with minified code!")}c=a.slice(0,a.length-1),angular.forEach(c,function(a,b){c[b]=a.trim()}),a.deps=DS.utils.filter(c,function(a){return!!a})}),DS.store[def.name]={collection:[],completedQueries:{},pendingQueries:{},index:cache,modified:{},saved:{},previousAttributes:{},observers:{},collectionModified:0},angular.forEach(methodsToProxy,function(a){def[a]="bindOne"===a||"bindAll"===a?function(){var b=Array.prototype.slice.call(arguments);return b.splice(2,0,def.name),DS[a].apply(DS,b)}:function(){var b=Array.prototype.slice.call(arguments);return b.unshift(def.name),DS[a].apply(DS,b)}}),def}catch(err){throw DS.$log.error(err),delete definitions[definition.name],delete DS.store[definition.name],err}}var errorPrefix="DS.defineResource(definition): ",methodsToProxy=["bindAll","bindOne","changes","create","createInstance","destroy","destroyAll","eject","ejectAll","filter","find","findAll","get","hasChanges","inject","lastModified","lastSaved","loadRelations","previous","refresh","save","update","updateAll"];module.exports=defineResource},{}],55:[function(a,b){function c(){this.$rootScope.$$phase?d.Platform.performMicrotaskCheckpoint():this.$rootScope.$apply(function(){d.Platform.performMicrotaskCheckpoint()})}var d=a("../../../lib/observe-js/observe-js");b.exports=c},{"../../../lib/observe-js/observe-js":1}],56:[function(a,b){function c(a,b){return"DS.eject("+a+", "+b+"): "}function d(a,b,c){for(var d,e=!1,f=0;f<b.collection.length;f++)if(b.collection[f][a.idAttribute]==c){d=b.collection[f],e=!0;break}return e?(b.collection.splice(f,1),b.observers[c].close(),delete b.observers[c],b.index.remove(c),delete b.previousAttributes[c],delete b.completedQueries[c],delete b.modified[c],delete b.saved[c],b.collectionModified=this.utils.updateTimestamp(b.collectionModified),this.notify(a,"eject",d),d):void 0}function e(a,b){var e=this,f=e.definitions[a];if(!f)throw new e.errors.NER(c(a,b)+a);if(!e.utils.isString(b)&&!e.utils.isNumber(b))throw new e.errors.IA(c(a,b)+"id: Must be a string or a number!");var g,h=e.store[a];return e.$rootScope.$$phase?g=d.call(e,f,h,b):e.$rootScope.$apply(function(){g=d.call(e,f,h,b)}),g}b.exports=e},{}],57:[function(a,b){function c(a){return"DS.ejectAll("+a+"[, params]): "}function d(a,b,c){var d=this,e=d.utils.toJson(c),f=d.filter(a.name,c),g=d.utils.toLookup(f,a.idAttribute);return angular.forEach(g,function(b,c){d.eject(a.name,c)}),delete b.completedQueries[e],b.collectionModified=d.utils.updateTimestamp(b.collectionModified),d.notify(a,"eject",f),f}function e(a,b){var e=this,f=e.definitions[a];if(b=b||{},!f)throw new e.errors.NER(c(a)+a);if(!e.utils.isObject(b))throw new e.errors.IA(c(a)+"params: Must be an object!");var g,h=e.store[a];return e.utils.isEmpty(b)&&(h.completedQueries={}),e.$rootScope.$$phase?g=d.apply(e,[f,h,b]):e.$rootScope.$apply(function(){g=d.apply(e,[f,h,b])}),g}b.exports=e},{}],58:[function(a,b){function c(a){return"DS.filter("+a+"[, params][, options]): "}function d(a,b,d){var e=this,f=e.errors.IA,g=e.definitions[a];if(d=d||{},!g)throw new e.errors.NER(c(a)+a);if(b&&!e.utils.isObject(b))throw new f(c(a)+"params: Must be an object!");if(!e.utils.isObject(d))throw new f(c(a)+"options: Must be an object!");var h=e.store[a];b=b||{},d.allowSimpleWhere="allowSimpleWhere"in d?!!d.allowSimpleWhere:!0;var i=e.utils.toJson(b);return i in h.completedQueries||!d.loadFromServer||h.pendingQueries[i]||e.findAll(a,b,d),g.defaultFilter.call(e,h.collection,a,b,d)}b.exports=d},{}],59:[function(a,b){function c(a,b){return"DS.get("+a+", "+b+"): "}function d(a,b,d){var e=this,f=e.errors.IA;if(d=d||{},!e.definitions[a])throw new e.errors.NER(c(a,b)+a);if(!e.utils.isString(b)&&!e.utils.isNumber(b))throw new f(c(a,b)+"id: Must be a string or a number!");if(!e.utils.isObject(d))throw new f(c(a,b)+"options: Must be an object!");var g=e.store[a].index.get(b);return!g&&d.loadFromServer&&e.find(a,b,d).then(null,function(a){return e.$q.reject(a)}),g}b.exports=d},{}],60:[function(a,b){function c(a,b){return"DS.hasChanges("+a+", "+b+"): "}function d(a,b){return!(a.isEmpty(b.added)&&a.isEmpty(b.removed)&&a.isEmpty(b.changed))}function e(a,b){var e=this;if(!e.definitions[a])throw new e.errors.NER(c(a,b)+a);if(!e.utils.isString(b)&&!e.utils.isNumber(b))throw new e.errors.IA(c(a,b)+"id: Must be a string or a number!");return e.get(a,b)?d(e.utils,e.changes(a,b)):!1}b.exports=e},{}],61:[function(a,b){b.exports={bindOne:a("./bindOne"),bindAll:a("./bindAll"),createInstance:a("./createInstance"),defineResource:a("./defineResource"),eject:a("./eject"),ejectAll:a("./ejectAll"),filter:a("./filter"),get:a("./get"),inject:a("./inject"),lastModified:a("./lastModified"),lastSaved:a("./lastSaved"),digest:a("./digest"),changes:a("./changes"),previous:a("./previous"),hasChanges:a("./hasChanges")}},{"./bindAll":50,"./bindOne":51,"./changes":52,"./createInstance":53,"./defineResource":54,"./digest":55,"./eject":56,"./ejectAll":57,"./filter":58,"./get":59,"./hasChanges":60,"./inject":62,"./lastModified":63,"./lastSaved":64,"./previous":65}],62:[function(a,b){function c(a){return"DS.inject("+a+", attrs[, options]): "}function d(a,b,e){function f(c,d,e,f){var g=this,h=f&&f(a.idAttribute)?f(a.idAttribute):g[a.idAttribute];if(b.modified[h]=i.utils.updateTimestamp(b.modified[h]),b.collectionModified=i.utils.updateTimestamp(b.collectionModified),a.computed){var k=i.get(a.name,h);i.utils.forOwn(a.computed,function(a,b){var f=!1;if(angular.forEach(a.deps,function(a){(a in c||a in d||a in e||!(b in k))&&(f=!0)}),f=f||!a.deps.length){var g=[];angular.forEach(a.deps,function(a){g.push(k[a])}),k[b]=a[a.length-1].apply(k,g)}})}a.idAttribute in e&&j.error("Doh! You just changed the primary key of an object! I don't know how to handle this yet, so your data for the \""+a.name+'" resource is now in an undefined (probably broken) state.')}var h,i=this,j=i.$log;if(i.utils.isArray(e)){h=[];for(var k=0;k<e.length;k++)h.push(d.call(i,a,b,e[k]))}else{var l=a.computed,m=a.idAttribute;if(l&&l[m]){var n=[];angular.forEach(l[m].deps,function(a){n.push(e[a])}),e[m]=l[m][l[m].length-1].apply(e,n)}if(!(m in e)){var o=new i.errors.R(c(a.name)+"attrs: Must contain the property specified by `idAttribute`!");throw j.error(o),o}try{a.beforeInject(a.name,e);var p=e[m],q=i.get(a.name,p);q?(i.utils.deepMixIn(q,e),"function"==typeof b.index.touch?b.index.touch(p):b.index.put(p,b.index.get(p)),b.observers[p].deliver()):(q=a.methods||a.useClass?e instanceof a[a.class]?e:new a[a.class]:{},b.previousAttributes[p]={},i.utils.deepMixIn(q,e),i.utils.deepMixIn(b.previousAttributes[p],e),b.collection.push(q),b.observers[p]=new g.ObjectObserver(q),b.observers[p].open(f,q),b.index.put(p,q),f.call(q,{},{},{})),b.saved[p]=i.utils.updateTimestamp(b.saved[p]),a.afterInject(a.name,q),h=q}catch(r){j.error(r),j.error("inject failed!",a.name,e)}}return h}function e(a,b,d){var e=this;e.utils.forOwn(a.relations,function(f,g){e.utils.forOwn(f,function(f,h){function i(b,f){if(e.definitions[h]&&f[b.localField])try{f[b.localField]=e.inject(h,f[b.localField],d)}catch(i){e.$log.error(c(a.name)+"Failed to inject "+g+' relation: "'+h+'"!',i)}else if(d.findBelongsTo&&"belongsTo"===g)if(e.utils.isArray(f))e.utils.forEach(f,function(a){var c=a[b.localKey]?e.get(h,a[b.localKey]):null;c&&(a[b.localField]=c)});else{var j=f[b.localKey]?e.get(h,f[b.localKey]):null;j&&(f[b.localField]=j)}}e.utils.isArray(f)||(f=[f]),f.forEach(function(a){e.utils.isArray(b)?e.utils.forEach(b,function(b){i(a,b)}):i(a,b)})})})}function f(a,b,f){var g=this,h=g.errors.IA;if(f=f||{},!g.definitions[a])throw new g.errors.NER(c(a)+a);if(!g.utils.isObject(b)&&!g.utils.isArray(b))throw new h(c(a)+"attrs: Must be an object or an array!");if(!g.utils.isObject(f))throw new h(c(a)+"options: Must be an object!");var i,j=g.definitions[a],k=g.store[a];return"findBelongsTo"in f||(f.findBelongsTo=!0),g.$rootScope.$$phase?i=d.call(g,j,k,b):g.$rootScope.$apply(function(){i=d.call(g,j,k,b)}),j.relations&&e.call(g,j,i,f),g.notify(j,"inject",i),i}var g=a("../../../lib/observe-js/observe-js");b.exports=f},{"../../../lib/observe-js/observe-js":1}],63:[function(a,b){function c(a,b){return"DS.lastModified("+a+"[, "+b+"]): "}function d(a,b){var d=this,e=d.store[a];if(!d.definitions[a])throw new d.errors.NER(c(a,b)+a);if(b&&!d.utils.isString(b)&&!d.utils.isNumber(b))throw new d.errors.IA(c(a,b)+"id: Must be a string or a number!");return b?(b in e.modified||(e.modified[b]=0),e.modified[b]):e.collectionModified}b.exports=d},{}],64:[function(a,b){function c(a,b){return"DS.lastSaved("+a+"[, "+b+"]): "}function d(a,b){var d=this,e=d.store[a];if(!d.definitions[a])throw new d.errors.NER(c(a,b)+a);if(!d.utils.isString(b)&&!d.utils.isNumber(b))throw new d.errors.IA(c(a,b)+"id: Must be a string or a number!");return b in e.saved||(e.saved[b]=0),e.saved[b]}b.exports=d},{}],65:[function(a,b){function c(a,b){return"DS.previous("+a+"[, "+b+"]): "}function d(a,b){var d=this;if(!d.definitions[a])throw new d.errors.NER(c(a,b)+a);if(!d.utils.isString(b)&&!d.utils.isNumber(b))throw new d.errors.IA(c(a,b)+"id: Must be a string or a number!");return angular.copy(d.store[a].previousAttributes[b])}b.exports=d},{}],66:[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=Object.create(Error.prototype),c.prototype.constructor=c,d.prototype=Object.create(Error.prototype),d.prototype.constructor=d,e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,b.exports=[function(){return{IllegalArgumentError:c,IA:c,RuntimeError:d,R:d,NonexistentResourceError:e,NER:e}}]},{}],67:[function(a){!function(b,c){"use strict";c.module("angular-data.DS",["ng"]).factory("DSUtils",a("./utils")).factory("DSErrors",a("./errors")).provider("DSHttpAdapter",a("./adapters/http")).provider("DSLocalStorageAdapter",a("./adapters/localStorage")).provider("DS",a("./datastore")).config(["$provide",function(a){a.decorator("$q",["$delegate",function(a){return a.promisify=function(a,b){var c=this;return function(){var d=c.defer(),e=Array.prototype.slice.apply(arguments);e.push(function(a,b){a?d.reject(a):d.resolve(b)});try{a.apply(b||this,e)}catch(f){d.reject(f)}return d.promise}},a}])}])}(window,window.angular)},{"./adapters/http":36,"./adapters/localStorage":37,"./datastore":49,"./errors":66,"./utils":68}],68:[function(a,b){b.exports=[function(){return{isBoolean:a("mout/lang/isBoolean"),isString:angular.isString,isArray:angular.isArray,isObject:angular.isObject,isNumber:angular.isNumber,isFunction:angular.isFunction,isEmpty:a("mout/lang/isEmpty"),toJson:angular.toJson,makePath:a("mout/string/makePath"),upperCase:a("mout/string/upperCase"),pascalCase:a("mout/string/pascalCase"),deepMixIn:a("mout/object/deepMixIn"),forOwn:a("mout/object/forOwn"),forEach:angular.forEach,pick:a("mout/object/pick"),set:a("mout/object/set"),contains:a("mout/array/contains"),filter:a("mout/array/filter"),toLookup:a("mout/array/toLookup"),slice:a("mout/array/slice"),sort:a("mout/array/sort"),updateTimestamp:function(a){var b="function"==typeof Date.now?Date.now():(new Date).getTime();return a&&a>=b?a+1:b},deepFreeze:function b(a){if("function"==typeof Object.freeze){var c,d;Object.freeze(a);for(d in a)c=a[d],a.hasOwnProperty(d)&&"object"==typeof c&&!Object.isFrozen(c)&&b(c)}},diffObjectFromOldObject:function(a,b){var c={},d={},e={};for(var f in b){var g=a[f];(void 0===g||g!==b[f])&&(f in a?g!==b[f]&&(e[f]=g):d[f]=void 0)}for(var h in a)h in b||(c[h]=a[h]);return{added:c,removed:d,changed:e}}}}]},{"mout/array/contains":2,"mout/array/filter":3,"mout/array/slice":7,"mout/array/sort":8,"mout/array/toLookup":9,"mout/lang/isBoolean":14,"mout/lang/isEmpty":15,"mout/object/deepMixIn":22,"mout/object/forOwn":24,"mout/object/pick":27,"mout/object/set":28,"mout/string/makePath":31,"mout/string/pascalCase":32,"mout/string/upperCase":35}]},{},[67]);
!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);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.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 diffObjectFromOldObject(a,b){var c={},d={},e={};for(var f in b){var g=a[f];(void 0===g||g!==b[f])&&(f in a?g!==b[f]&&(e[f]=g):d[f]=void 0)}for(var f in a)f in b||(c[f]=a[f]);return Array.isArray(a)&&a.length!==b.length&&(e.length=a.length),{added:c,removed:d,changed:e}}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 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.Observer.runEOM_=runEOM,global.Observer.observerSentinel_=observerSentinel,global.Observer.hasObjectObserve=hasObserve,global.ObjectObserver=ObjectObserver}((exports.Number={isNaN:window.isNaN})?exports:exports)},{}],2:[function(a,b){function c(a,b){return-1!==d(a,b)}var d=a("./indexOf");b.exports=c},{"./indexOf":5}],3:[function(a,b){function c(a,b,c){b=d(b,c);var e=[];if(null==a)return e;for(var f,g=-1,h=a.length;++g<h;)f=a[g],b(f,g,a)&&e.push(f);return e}var d=a("../function/makeIterator_");b.exports=c},{"../function/makeIterator_":11}],4:[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},{}],5:[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},{}],6:[function(a,b){function c(a){return null!=a&&""!==a}function d(a,b){return b=b||"",e(a,c).join(b)}var e=a("./filter");b.exports=d},{"./filter":3}],7:[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},{}],8:[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},{}],9:[function(a,b){function c(a,b){var c={};if(null==a)return c;var e,f=-1,g=a.length;if(d(b))for(;++f<g;)e=a[f],c[b(e)]=e;else for(;++f<g;)e=a[f],c[e[b]]=e;return c}var d=a("../lang/isFunction");b.exports=c},{"../lang/isFunction":16}],10:[function(a,b){function c(a){return a}b.exports=c},{}],11:[function(a,b){function c(a,b){if(null==a)return d;switch(typeof a){case"function":return"undefined"!=typeof b?function(c,d,e){return a.call(b,c,d,e)}:a;case"object":return function(b){return f(b,a)};case"string":case"number":return e(a)}}var d=a("./identity"),e=a("./prop"),f=a("../object/deepMatches");b.exports=c},{"../object/deepMatches":21,"./identity":10,"./prop":12}],12:[function(a,b){function c(a){return function(b){return b[a]}}b.exports=c},{}],13:[function(a,b){var c=a("./isKind"),d=Array.isArray||function(a){return c(a,"Array")};b.exports=d},{"./isKind":17}],14:[function(a,b){function c(a){return d(a,"Boolean")}var d=a("./isKind");b.exports=c},{"./isKind":17}],15:[function(a,b){function c(a){if(null==a)return!1;if("string"==typeof a||e(a))return!a.length;if("object"==typeof a||"function"==typeof a){var b=!0;return d(a,function(){return b=!1,!1}),b}return!1}var d=a("../object/forOwn"),e=a("./isArray");b.exports=c},{"../object/forOwn":24,"./isArray":13}],16:[function(a,b){function c(a){return d(a,"Function")}var d=a("./isKind");b.exports=c},{"./isKind":17}],17:[function(a,b){function c(a,b){return d(a)===b}var d=a("./kindOf");b.exports=c},{"./kindOf":19}],18:[function(a,b){function c(a){return!!a&&"object"==typeof a&&a.constructor===Object}b.exports=c},{}],19:[function(a,b){function c(a){return null===a?"Null":a===d?"Undefined":e.exec(f.call(a))[1]}var d,e=/^\[object (.*)\]$/,f=Object.prototype.toString;b.exports=c},{}],20:[function(a,b){function c(a){return null==a?"":a.toString()}b.exports=c},{}],21:[function(a,b){function c(a,b){for(var c=-1,d=a.length;++c<d;)if(f(a[c],b))return!0;return!1}function d(a,b){for(var d=-1,e=b.length;++d<e;)if(!c(a,b[d]))return!1;return!0}function e(a,b){var c=!0;return g(b,function(b,d){return f(a[d],b)?void 0:c=!1}),c}function f(a,b){return a&&"object"==typeof a?h(a)&&h(b)?d(a,b):e(a,b):a===b}var g=a("./forOwn"),h=a("../lang/isArray");b.exports=f},{"../lang/isArray":13,"./forOwn":24}],22:[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":18,"./forOwn":24}],23:[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":25}],24:[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":23,"./hasOwn":25}],25:[function(a,b){function c(a,b){return Object.prototype.hasOwnProperty.call(a,b)}b.exports=c},{}],26:[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":4}],27:[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":7}],28:[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":26}],29:[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":20,"./lowerCase":30,"./removeNonWord":33,"./replaceAccents":34,"./upperCase":35}],30:[function(a,b){function c(a){return a=d(a),a.toLowerCase()}var d=a("../lang/toString");b.exports=c},{"../lang/toString":20}],31:[function(a,b){function c(){var a=d(e(arguments),"/");return a.replace(/([^:\/]|^)\/{2,}/g,"$1/")}var d=a("../array/join"),e=a("../array/slice");b.exports=c},{"../array/join":6,"../array/slice":7}],32:[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":20,"./camelCase":29,"./upperCase":35}],33:[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":20}],34:[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":20}],35:[function(a,b){function c(a){return a=d(a),a.toUpperCase()}var d=a("../lang/toString");b.exports=c},{"../lang/toString":20}],36:[function(a,b){function c(){var a=this.defaults={queryTransform:function(a,b){return b},$httpConfig:{}};this.$get=["$http","$log","DSUtils",function(b,c,d){return{defaults:a,HTTP:function(e){var f=(new Date).getTime();return e=d.deepMixIn(e,a.$httpConfig),b(e).then(function(a){return c.debug(a.config.method+" request:"+a.config.url+" Time taken: "+((new Date).getTime()-f)+"ms",arguments),a})},GET:function(a,b){return b=b||{},this.HTTP(d.deepMixIn(b,{url:a,method:"GET"}))},POST:function(a,b,c){return c=c||{},this.HTTP(d.deepMixIn(c,{url:a,data:b,method:"POST"}))},PUT:function(a,b,c){return c=c||{},this.HTTP(d.deepMixIn(c,{url:a,data:b||{},method:"PUT"}))},DEL:function(a,b){return b=b||{},this.HTTP(d.deepMixIn(b,{url:a,method:"DELETE"}))},find:function(a,b,c){return c=c||{},this.GET(d.makePath(c.baseUrl||a.baseUrl,a.getEndpoint(b,c),b),c)},findAll:function(b,c,e){return e=e||{},e.params=e.params||{},c&&(c=a.queryTransform(b.name,c),d.deepMixIn(e.params,c)),this.GET(d.makePath(e.baseUrl||b.baseUrl,b.getEndpoint(null,e)),e)},create:function(a,b,c){return c=c||{},this.POST(d.makePath(c.baseUrl||a.baseUrl,a.getEndpoint(b,c)),b,c)},update:function(a,b,c,e){return e=e||{},this.PUT(d.makePath(e.baseUrl||a.baseUrl,a.getEndpoint(b,e),b),c,e)},updateAll:function(b,c,e,f){return f=f||{},f.params=f.params||{},e&&(e=a.queryTransform(b.name,e),d.deepMixIn(f.params,e)),this.PUT(d.makePath(f.baseUrl||b.baseUrl,b.getEndpoint(null,f)),c,f)},destroy:function(a,b,c){return c=c||{},this.DEL(d.makePath(c.baseUrl||a.baseUrl,a.getEndpoint(b,c),b),c)},destroyAll:function(b,c,e){return e=e||{},e.params=e.params||{},c&&(c=a.queryTransform(b.name,c),d.deepMixIn(e.params,c)),this.DEL(d.makePath(e.baseUrl||b.baseUrl,b.getEndpoint(null,e)),e)}}}]}b.exports=c},{}],37:[function(a,b){function c(){this.$get=["$q","DSUtils","DSErrors",function(a,b,c){return{GET:function(b){var c=a.defer();try{var d=localStorage.getItem(b);c.resolve(d?angular.fromJson(d):void 0)}catch(e){c.reject(e)}return c.promise},PUT:function(a,c){var d=this;return d.GET(a).then(function(e){return e&&b.deepMixIn(e,c),localStorage.setItem(a,angular.toJson(e||c)),d.GET(a)})},DEL:function(b){var c=a.defer();try{localStorage.removeItem(b),c.resolve()}catch(d){c.reject(d)}return c.promise},find:function(a,c,d){return d=d||{},this.GET(b.makePath(d.baseUrl||a.baseUrl,a.endpoint,c))},findAll:function(){throw new Error("DSLocalStorageAdapter.findAll is not supported!")},create:function(a,d,e){if(!(a.idAttribute in d))throw new c.IA("DSLocalStorageAdapter.create: You must provide a primary key in the attrs object!");return e=e||{},this.PUT(b.makePath(e.baseUrl||a.baseUrl,a.getEndpoint(d,e),d[a.idAttribute]),d)},update:function(a,c,d,e){return e=e||{},this.PUT(b.makePath(e.baseUrl||a.baseUrl,a.getEndpoint(c,e),c),d)},updateAll:function(){throw new Error("DSLocalStorageAdapter.updateAll is not supported!")},destroy:function(a,c,d){return d=d||{},this.DEL(b.makePath(d.baseUrl||a.baseUrl,a.getEndpoint(c,d),c))},destroyAll:function(){throw new Error("Not supported!")}}}]}b.exports=c},{}],38:[function(a,b){function c(a){return"DS.create("+a+", attrs[, options]): "}function d(a,b,d){var e=this,f=e.$q.defer();try{var g=e.definitions[a];if(d=d||{},!g)throw new e.errors.NER(c(a)+a);if(!e.utils.isObject(b))throw new e.errors.IA(c(a)+"attrs: Must be an object!");return"cacheResponse"in d||(d.cacheResponse=!0),"upsert"in d||(d.upsert=!0),f.resolve(b),d.upsert&&b[g.idAttribute]?e.update(a,b[g.idAttribute],b,d):f.promise.then(function(b){var c=d.beforeValidate?e.$q.promisify(d.beforeValidate):g.beforeValidate;return c.call(b,a,b)}).then(function(b){var c=d.validate?e.$q.promisify(d.validate):g.validate;return c.call(b,a,b)}).then(function(b){var c=d.afterValidate?e.$q.promisify(d.afterValidate):g.afterValidate;return c.call(b,a,b)}).then(function(b){var c=d.beforeCreate?e.$q.promisify(d.beforeCreate):g.beforeCreate;return c.call(b,a,b)}).then(function(b){return e.adapters[d.adapter||g.defaultAdapter].create(g,g.serialize(a,b),d)}).then(function(b){var c=d.afterCreate?e.$q.promisify(d.afterCreate):g.afterCreate,f=g.deserialize(a,b);return c.call(f,a,f)}).then(function(b){if(d.cacheResponse){var c=e.store[a],f=e.inject(g.name,b,d),h=f[g.idAttribute];return c.completedQueries[h]=(new Date).getTime(),c.previousAttributes[h]=e.utils.deepMixIn({},f),c.saved[h]=e.utils.updateTimestamp(c.saved[h]),e.get(g.name,h)}return b})}catch(h){return f.reject(h),f.promise}}b.exports=d},{}],39:[function(a,b){function c(a,b){return"DS.destroy("+a+", "+b+"[, options]): "}function d(a,b,d){var e=this,f=e.$q.defer();try{var g=e.definitions[a];if(d=d||{},!g)throw new e.errors.NER(c(a,b)+a);if(!e.utils.isString(b)&&!e.utils.isNumber(b))throw new e.errors.IA(c(a,b)+"id: Must be a string or a number!");var h=e.get(a,b);if(!h)throw new e.errors.R(c(a,b)+'id: "'+b+'" not found!');return f.resolve(h),f.promise.then(function(b){var c=d.beforeDestroy?e.$q.promisify(d.beforeDestroy):g.beforeDestroy;return c.call(b,a,b)}).then(function(){return e.adapters[d.adapter||g.defaultAdapter].destroy(g,b,d)}).then(function(){var b=d.afterDestroy?e.$q.promisify(d.afterDestroy):g.afterDestroy;return b.call(h,a,h)}).then(function(){return e.eject(a,b),b})}catch(i){return f.reject(i),f.promise}}b.exports=d},{}],40:[function(a,b){function c(a){return"DS.destroyAll("+a+", params[, options]): "}function d(a,b,d){var e=this,f=e.$q.defer();try{var g=e.errors.IA,h=e.definitions[a];if(d=d||{},!h)throw new e.errors.NER(c(a)+a);if(!e.utils.isObject(b))throw new g(c(a)+"params: Must be an object!");if(!e.utils.isObject(d))throw new g(c(a)+"options: Must be an object!");return f.resolve(),f.promise.then(function(){return e.adapters[d.adapter||h.defaultAdapter].destroyAll(h,b,d)}).then(function(){return e.ejectAll(a,b)})}catch(i){return f.reject(i),f.promise}}b.exports=d},{}],41:[function(a,b){function c(a,b){return"DS.find("+a+", "+b+"[, options]): "}function d(a,b,d){var e=this,f=e.$q.defer(),g=f.promise;try{var h=e.errors.IA,i=e.definitions[a];if(d=d||{},!i)throw new e.errors.NER(c(a,b)+a);if(!e.utils.isString(b)&&!e.utils.isNumber(b))throw new h(c(a,b)+"id: Must be a string or a number!");if(!e.utils.isObject(d))throw new h(c(a,b)+"options: Must be an object!");"cacheResponse"in d||(d.cacheResponse=!0);var j=e.store[a];if((d.bypassCache||!d.cacheResponse)&&delete j.completedQueries[b],!(b in j.completedQueries))return b in j.pendingQueries||(g=j.pendingQueries[b]=e.adapters[d.adapter||i.defaultAdapter].find(i,b,d).then(function(c){var f=i.deserialize(a,c);return d.cacheResponse?(delete j.pendingQueries[b],j.completedQueries[b]=(new Date).getTime(),e.inject(a,f,d)):f},function(a){return delete j.pendingQueries[b],e.$q.reject(a)})),j.pendingQueries[b];f.resolve(e.get(a,b))}catch(k){f.reject(k)}return g}b.exports=d},{}],42:[function(a,b){function c(a){return"DS.findAll("+a+", params[, options]): "}function d(a,b,d,e){var f=this,g=f.store[b],h=f.definitions[b].idAttribute,i=(new Date).getTime();a=a||[],delete g.pendingQueries[d],g.completedQueries[d]=i,g.collectionModified=f.utils.updateTimestamp(g.collectionModified);var j=f.inject(b,a,e);return f.utils.isArray(j)?angular.forEach(j,function(a){a&&a[h]&&(g.completedQueries[a[h]]=i)}):(f.$log.warn(c(b)+"response is expected to be an array!"),g.completedQueries[j[h]]=i),j}function e(a,b,c){var e=this,f=e.definitions[a],g=e.store[a],h=e.utils.toJson(b);return(c.bypassCache||!c.cacheResponse)&&delete g.completedQueries[h],h in g.completedQueries?e.filter(a,b,c):(h in g.pendingQueries||(g.pendingQueries[h]=e.adapters[c.adapter||f.defaultAdapter].findAll(f,b,c).then(function(b){var g=f.deserialize(a,b);if(!c.cacheResponse)return g;try{return d.call(e,g,a,h,c)}catch(i){return e.$q.reject(i)}},function(a){return delete g.pendingQueries[h],e.$q.reject(a)})),g.pendingQueries[h])}function f(a,b,d){var f=this,g=f.$q.defer();try{var h=f.errors.IA;if(d=d||{},b=b||{},!f.definitions[a])throw new f.errors.NER(c(a)+a);if(!f.utils.isObject(b))throw new h(c(a)+"params: Must be an object!");if(!f.utils.isObject(d))throw new h(c(a)+"options: Must be an object!");return"cacheResponse"in d||(d.cacheResponse=!0),g.resolve(),g.promise.then(function(){return e.call(f,a,b,d)})}catch(i){return g.reject(i),g.promise}}b.exports=f},{}],43:[function(a,b){b.exports={create:a("./create"),destroy:a("./destroy"),destroyAll:a("./destroyAll"),find:a("./find"),findAll:a("./findAll"),loadRelations:a("./loadRelations"),refresh:a("./refresh"),save:a("./save"),update:a("./update"),updateAll:a("./updateAll")}},{"./create":38,"./destroy":39,"./destroyAll":40,"./find":41,"./findAll":42,"./loadRelations":44,"./refresh":45,"./save":46,"./update":47,"./updateAll":48}],44:[function(a,b){function c(a){return"DS.loadRelations("+a+", instance(Id), relations[, options]): "}function d(a,b,d,e){var f=this,g=f.$q.defer();try{var h=f.errors.IA,i=f.definitions[a];if(e=e||{},(angular.isString(b)||angular.isNumber(b))&&(b=f.get(a,b)),angular.isString(d)&&(d=[d]),!i)throw new f.errors.NER(c(a)+a);if(!f.utils.isObject(b))throw new h(c(a)+"instance(Id): Must be a string, number or object!");if(!f.utils.isArray(d))throw new h(c(a)+"relations: Must be a string or an array!");if(!f.utils.isObject(e))throw new h(c(a)+"options: Must be an object!");"findBelongsTo"in e||(e.findBelongsTo=!0),"findHasMany"in e||(e.findHasMany=!0);var j=[],k=[];return f.utils.forEach(i.relationList,function(a){var c=a.relation;if(f.utils.contains(d,c)){var g,h={};h[a.foreignKey]=b[i.idAttribute],"hasMany"===a.type?g=f.findAll(c,h,e):"hasOne"===a.type?a.localKey&&b[a.localKey]?g=f.find(c,b[a.localKey],e):a.foreignKey&&(g=f.findAll(c,h,e)):g=f.find(c,b[a.localKey],e),g&&(j.push(g),k.push(a.localField))}}),g.resolve(),g.promise.then(function(){return f.$q.all(j)}).then(function(a){return angular.forEach(k,function(c,d){b[c]=a[d]}),b})}catch(l){return g.reject(l),g.promise}}b.exports=d},{}],45:[function(a,b){function c(a,b){return"DS.refresh("+a+", "+b+"[, options]): "}function d(a,b,d){var e=this,f=e.errors.IA;if(d=d||{},e.definitions[a]){if(e.utils.isString(b)||e.utils.isNumber(b)){if(e.utils.isObject(d)){if(d.bypassCache=!0,e.get(a,b))return e.find(a,b,d);var g=e.$q.defer();return g.resolve(),g.promise}throw new f(c(a,b)+"options: Must be an object!")}throw new f(c(a,b)+"id: Must be a string or a number!")}throw new e.errors.NER(c(a,b)+a)}b.exports=d},{}],46:[function(a,b){function c(a,b){return"DS.save("+a+", "+b+"[, options]): "}function d(a,b,d){var e=this,f=e.$q.defer();try{var g=e.errors.IA,h=e.definitions[a];if(d=d||{},!h)throw new e.errors.NER(c(a,b)+a);if(!e.utils.isString(b)&&!e.utils.isNumber(b))throw new g(c(a,b)+"id: Must be a string or a number!");if(!e.utils.isObject(d))throw new g(c(a,b)+"options: Must be an object!");var i=e.get(a,b);if(!i)throw new e.errors.R(c(a,b)+'id: "'+b+'" not found!');return"cacheResponse"in d||(d.cacheResponse=!0),f.resolve(i),f.promise.then(function(b){var c=d.beforeValidate?e.$q.promisify(d.beforeValidate):h.beforeValidate;return c.call(b,a,b)}).then(function(b){var c=d.validate?e.$q.promisify(d.validate):h.validate;return c.call(b,a,b)}).then(function(b){var c=d.afterValidate?e.$q.promisify(d.afterValidate):h.afterValidate;return c.call(b,a,b)}).then(function(b){var c=d.beforeUpdate?e.$q.promisify(d.beforeUpdate):h.beforeUpdate;return c.call(b,a,b)}).then(function(c){if(d.changesOnly){var f=e.store[a];f.observers[b].deliver();var g=[],i=e.changes(a,b);for(var j in i.added)g.push(j);for(j in i.changed)g.push(j);if(i=e.utils.pick(c,g),e.utils.isEmpty(i))return c;c=i}return e.adapters[d.adapter||h.defaultAdapter].update(h,b,h.serialize(a,c),d)}).then(function(b){var c=d.afterUpdate?e.$q.promisify(d.afterUpdate):h.afterUpdate,f=h.deserialize(a,b);return c.call(f,a,f)}).then(function(c){if(d.cacheResponse){var f=e.store[a],g=e.inject(h.name,c,d);return f.previousAttributes[b]=e.utils.deepMixIn({},g),f.saved[b]=e.utils.updateTimestamp(f.saved[b]),f.observers[b].discardChanges(),e.get(a,b)}return c})}catch(j){return f.reject(j),f.promise}}b.exports=d},{}],47:[function(a,b){function c(a,b){return"DS.update("+a+", "+b+", attrs[, options]): "}function d(a,b,d,e){var f=this,g=f.$q.defer();try{var h=f.errors.IA,i=f.definitions[a];if(e=e||{},!i)throw new f.errors.NER(c(a,b)+a);if(!f.utils.isString(b)&&!f.utils.isNumber(b))throw new h(c(a,b)+"id: Must be a string or a number!");if(!f.utils.isObject(d))throw new h(c(a,b)+"attrs: Must be an object!");if(!f.utils.isObject(e))throw new h(c(a,b)+"options: Must be an object!");return"cacheResponse"in e||(e.cacheResponse=!0),g.resolve(d),g.promise.then(function(b){var c=e.beforeValidate?f.$q.promisify(e.beforeValidate):i.beforeValidate;return c.call(b,a,b)}).then(function(b){var c=e.validate?f.$q.promisify(e.validate):i.validate;return c.call(b,a,b)}).then(function(b){var c=e.afterValidate?f.$q.promisify(e.afterValidate):i.afterValidate;return c.call(b,a,b)}).then(function(b){var c=e.beforeUpdate?f.$q.promisify(e.beforeUpdate):i.beforeUpdate;return c.call(b,a,b)}).then(function(c){return f.adapters[e.adapter||i.defaultAdapter].update(i,b,i.serialize(a,c),e)}).then(function(b){var c=e.afterUpdate?f.$q.promisify(e.afterUpdate):i.afterUpdate,d=i.deserialize(a,b);return c.call(d,a,d)}).then(function(b){if(e.cacheResponse){var c=f.store[a],d=f.inject(i.name,b,e),g=d[i.idAttribute];return c.previousAttributes[g]=f.utils.deepMixIn({},d),c.saved[g]=f.utils.updateTimestamp(c.saved[g]),c.observers[g].discardChanges(),f.get(i.name,g)}return b})}catch(j){return g.reject(j),g.promise}}b.exports=d},{}],48:[function(a,b){function c(a){return"DS.updateAll("+a+", attrs, params[, options]): "}function d(a,b,d,e){var f=this,g=f.$q.defer();try{var h=f.errors.IA,i=f.definitions[a];if(e=e||{},!i)throw new f.errors.NER(c(a)+a);if(!f.utils.isObject(b))throw new h(c(a)+"attrs: Must be an object!");if(!f.utils.isObject(d))throw new h(c(a)+"params: Must be an object!");if(!f.utils.isObject(e))throw new h(c(a)+"options: Must be an object!");return"cacheResponse"in e||(e.cacheResponse=!0),g.resolve(b),g.promise.then(function(b){var c=e.beforeValidate?f.$q.promisify(e.beforeValidate):i.beforeValidate;return c.call(b,a,b)}).then(function(b){var c=e.validate?f.$q.promisify(e.validate):i.validate;return c.call(b,a,b)}).then(function(b){var c=e.afterValidate?f.$q.promisify(e.afterValidate):i.afterValidate;return c.call(b,a,b)}).then(function(b){var c=e.beforeUpdate?f.$q.promisify(e.beforeUpdate):i.beforeUpdate;return c.call(b,a,b)}).then(function(b){return f.adapters[e.adapter||i.defaultAdapter].updateAll(i,i.serialize(a,b),d,e)}).then(function(b){var c=e.afterUpdate?f.$q.promisify(e.afterUpdate):i.afterUpdate,d=i.deserialize(a,b);return c.call(d,a,d)}).then(function(a){return e.cacheResponse?f.inject(i.name,a,e):a})}catch(j){return g.reject(j),g.promise}}b.exports=d},{}],49:[function(a,b){function c(a,b,c){c(null,b)}function d(){}function e(){var b=this.defaults=new d;this.$get=["$rootScope","$log","$q","DSHttpAdapter","DSLocalStorageAdapter","DSUtils","DSErrors",function(c,d,e,f,g,h,i){var j,k=a("./sync_methods"),l=a("./async_methods");try{j=angular.injector(["angular-data.DSCacheFactory"]).get("DSCacheFactory")}catch(m){d.warn(m),d.warn("DSCacheFactory is unavailable. Resorting to the lesser capabilities of $cacheFactory."),j=angular.injector(["ng"]).get("$cacheFactory")}var n={notify:function(a,b){var d=Array.prototype.slice.call(arguments,2);d.unshift(a.name),d.unshift("DS."+b),"broadcast"===a.events?c.$broadcast.apply(c,d):"emit"===a.events&&c.$emit.apply(c,d)},$rootScope:c,$log:d,$q:e,cacheFactory:j,defaults:b,store:{},definitions:{},adapters:{DSHttpAdapter:f,DSLocalStorageAdapter:g},errors:i,utils:h};return h.deepFreeze(k),h.deepFreeze(l),h.deepMixIn(n,k),h.deepMixIn(n,l),h.deepFreeze(n.errors),h.deepFreeze(n.utils),("function"!=typeof Object.observe||"function"!=typeof Array.observe)&&c.$watch(function(){return(new Date).getTime()/100|0},function(){n.digest()}),n}]}a("../utils")[0]();d.prototype.idAttribute="id",d.prototype.defaultAdapter="DSHttpAdapter",d.prototype.defaultFilter=function(a,b,c,d){var e=this,f=a,g=null,h={skip:"",offset:"",where:"",limit:"",orderBy:"",sort:""};g=this.utils.isObject(c.where)?c.where:{},d.allowSimpleWhere&&this.utils.forOwn(c,function(a,b){b in h||b in g||(g[b]={"==":a})}),this.utils.isEmpty(g)&&(g=null),g&&(f=this.utils.filter(f,function(a){var b=!0,c=!0;return e.utils.forOwn(g,function(d,f){e.utils.isString(d)?d={"===":d}:(e.utils.isNumber(d)||e.utils.isBoolean(d))&&(d={"==":d}),e.utils.isObject(d)&&e.utils.forOwn(d,function(d,g){"=="===g?c=b?a[f]==d:c&&a[f]==d:"==="===g?c=b?a[f]===d:c&&a[f]===d:"!="===g?c=b?a[f]!=d:c&&a[f]!=d:"!=="===g?c=b?a[f]!==d:c&&a[f]!==d:">"===g?c=b?a[f]>d:c&&a[f]>d:">="===g?c=b?a[f]>=d:c&&a[f]>=d:"<"===g?c=b?a[f]<d:c&&a[f]<d:"<="===g?c=b?a[f]<=d:c&&a[f]<=d:"in"===g?c=b?e.utils.contains(d,a[f]):c&&e.utils.contains(d,a[f]):"|=="===g?c=b?a[f]==d:c||a[f]==d:"|==="===g?c=b?a[f]===d:c||a[f]===d:"|!="===g?c=b?a[f]!=d:c||a[f]!=d:"|!=="===g?c=b?a[f]!==d:c||a[f]!==d:"|>"===g?c=b?a[f]>d:c||a[f]>d:"|>="===g?c=b?a[f]>=d:c||a[f]>=d:"|<"===g?c=b?a[f]<d:c||a[f]<d:"|<="===g?c=b?a[f]<=d:c||a[f]<=d:"|in"===g&&(c=b?e.utils.contains(d,a[f]):c||e.utils.contains(d,a[f])),b=!1})}),c}));var i=null;this.utils.isString(c.orderBy)?i=[[c.orderBy,"ASC"]]:this.utils.isArray(c.orderBy)&&(i=c.orderBy),!i&&this.utils.isString(c.sort)?i=[[c.sort,"ASC"]]:!i&&this.utils.isArray(c.sort)&&(i=c.sort),i&&angular.forEach(i,function(a){if(e.utils.isString(a))a=[a,"ASC"];else if(!e.utils.isArray(a))throw new e.errors.IllegalArgumentError("DS.filter(resourceName[, params][, options]): "+angular.toJson(a)+": Must be a string or an array!",{params:{"orderBy[i]":{actual:typeof a,expected:"string|array"}}});f=e.utils.sort(f,function(b,c){var d=b[a[0]],f=c[a[0]];return e.utils.isString(d)&&(d=e.utils.upperCase(d)),e.utils.isString(f)&&(f=e.utils.upperCase(f)),"DESC"===a[1]?d>f?-1:f>d?1:0:f>d?-1:d>f?1:0
})});var j=angular.isNumber(c.limit)?c.limit:null,k=null;return angular.isNumber(c.skip)?k=c.skip:angular.isNumber(c.offset)&&(k=c.offset),j&&k?f=this.utils.slice(f,k,Math.min(f.length,k+j)):this.utils.isNumber(j)?f=this.utils.slice(f,0,Math.min(f.length,j)):this.utils.isNumber(k)&&(f=k<f.length?this.utils.slice(f,k):[]),f},d.prototype.baseUrl="",d.prototype.endpoint="",d.prototype.useClass=!1,d.prototype.beforeValidate=c,d.prototype.validate=c,d.prototype.afterValidate=c,d.prototype.beforeCreate=c,d.prototype.afterCreate=c,d.prototype.beforeUpdate=c,d.prototype.afterUpdate=c,d.prototype.beforeDestroy=c,d.prototype.afterDestroy=c,d.prototype.beforeInject=function(a,b){return b},d.prototype.afterInject=function(a,b){return b},d.prototype.serialize=function(a,b){return b},d.prototype.deserialize=function(a,b){return b.data},d.prototype.events="broadcast",b.exports=e},{"../utils":72,"./async_methods":43,"./sync_methods":62}],50:[function(a,b){function c(a){return"DS.bindAll(scope, expr, "+a+", params[, cb]): "}function d(a,b,d,e,f){var g=this,h=g.errors.IA;if(!g.utils.isObject(a))throw new h(c(d)+"scope: Must be an object!");if(!g.utils.isString(b))throw new h(c(d)+"expr: Must be a string!");if(!g.definitions[d])throw new g.errors.NER(c(d)+d);if(!g.utils.isObject(e))throw new h(c(d)+"params: Must be an object!");try{return a.$watch(function(){return g.lastModified(d)},function(){var c=g.filter(d,e);g.utils.set(a,b,c),f&&f(null,c)})}catch(i){if(!f)throw i;f(i)}}b.exports=d},{}],51:[function(a,b){function c(a){return"DS.bindOne(scope, expr, "+a+", id[, cb]): "}function d(a,b,d,e,f){var g=this,h=g.errors.IA;if(!g.utils.isObject(a))throw new h(c(d)+"scope: Must be an object!");if(!g.utils.isString(b))throw new h(c(d)+"expr: Must be a string!");if(!g.definitions[d])throw new g.errors.NER(c(d)+d);if(!g.utils.isString(e)&&!g.utils.isNumber(e))throw new h(c(d)+"id: Must be a string or a number!");try{return a.$watch(function(){return g.lastModified(d,e)},function(){var c=g.get(d,e);g.utils.set(a,b,c),f&&f(null,c)})}catch(i){if(!f)throw i;f(i)}}b.exports=d},{}],52:[function(a,b){function c(a){return"DS.changes("+a+", id): "}function d(a,b){var d=this;if(!d.definitions[a])throw new d.errors.NER(c(a)+a);if(!d.utils.isString(b)&&!d.utils.isNumber(b))throw new d.errors.IA(c(a)+"id: Must be a string or a number!");var e=d.get(a,b);if(e){d.store[a].observers[b].deliver();var f=d.utils.diffObjectFromOldObject(e,d.store[a].previousAttributes[b]);return d.utils.forOwn(f,function(a,b){var c=[];d.utils.forOwn(a,function(a,b){angular.isFunction(a)||c.push(b)}),f[b]=d.utils.pick(f[b],c)}),f}}b.exports=d},{}],53:[function(a,b){function c(a){return"DS.compute("+a+", instance): "}function d(a,b){var c=this,d=[];angular.forEach(a.deps,function(a){d.push(c[a])}),this[b]=a[a.length-1].apply(this,d)}function e(a,b){var e=this,f=e.errors.IA,g=e.definitions[a];if(!g)throw new e.errors.NER(c(a)+a);if(!e.utils.isObject(b)&&!e.utils.isString(b)&&!e.utils.isNumber(b))throw new f(c(a)+"instance: Must be an object, string or number!");return(e.utils.isString(b)||e.utils.isNumber(b))&&(b=e.get(a,b)),e.utils.forOwn(g.computed,function(a,c){d.call(b,a,c)}),b}b.exports={compute:e,_compute:d}},{}],54:[function(a,b){function c(a){return"DS.createInstance("+a+"[, attrs][, options]): "}function d(a,b,d){var e=this,f=e.errors.IA,g=e.definitions[a];if(b=b||{},d=d||{},!g)throw new e.errors.NER(c(a)+a);if(b&&!e.utils.isObject(b))throw new f(c(a)+"attrs: Must be an object!");if(!e.utils.isObject(d))throw new f(c(a)+"options: Must be an object!");"useClass"in d||(d.useClass=!0);var h;if(d.useClass){var i=g[g.class];h=new i}else h={};return e.utils.deepMixIn(h,b)}b.exports=d},{}],55:[function(require,module,exports){function Resource(a,b){a.deepMixIn(this,b),this.endpoint="endpoint"in b?b.endpoint:this.name}function defineResource(definition){var DS=this,definitions=DS.definitions,IA=DS.errors.IA;if(DS.utils.isString(definition)&&(definition=definition.replace(/\s/gi,""),definition={name:definition}),!DS.utils.isObject(definition))throw new IA(errorPrefix+"definition: Must be an object!");if(!DS.utils.isString(definition.name))throw new IA(errorPrefix+"definition.name: Must be a string!");if(definition.idAttribute&&!DS.utils.isString(definition.idAttribute))throw new IA(errorPrefix+"definition.idAttribute: Must be a string!");if(definition.endpoint&&!DS.utils.isString(definition.endpoint))throw new IA(errorPrefix+"definition.endpoint: Must be a string!");if(DS.store[definition.name])throw new DS.errors.R(errorPrefix+definition.name+" is already registered!");try{Resource.prototype=DS.defaults,definitions[definition.name]=new Resource(DS.utils,definition);var def=definitions[definition.name];def.relations&&(def.relationList=[],def.relationFields=[],DS.utils.forOwn(def.relations,function(a,b){DS.utils.forOwn(a,function(c,d){DS.utils.isArray(c)||(a[d]=[c]),DS.utils.forEach(a[d],function(a){a.type=b,a.relation=d,a.name=def.name,def.relationList.push(a),def.relationFields.push(a.localField)})})}),def.relations.belongsTo&&DS.utils.forOwn(def.relations.belongsTo,function(a,b){DS.utils.forEach(a,function(a){a.parent&&(def.parent=b,def.parentKey=a.localKey)})}),DS.utils.deepFreeze(def.relations),DS.utils.deepFreeze(def.relationList)),def.getEndpoint=function(a,b){var c,d,e=this.parent,f=this.parentKey,g=b.endpoint||this.endpoint;return delete b.endpoint,b=b||{},b.params=b.params||{},e&&f&&definitions[e]&&b.params[f]!==!1&&((DS.utils.isNumber(a)||DS.utils.isString(a))&&(c=DS.get(this.name,a)),DS.utils.isObject(a)&&f in a?(delete b.params[f],d=DS.utils.makePath(definitions[e].getEndpoint(a,b),a[f],g)):c&&f in c?(delete b.params[f],d=DS.utils.makePath(definitions[e].getEndpoint(a,b),c[f],g)):b&&b.params[f]&&(d=DS.utils.makePath(definitions[e].getEndpoint(a,b),b.params[f],g),delete b.params[f])),b.params[f]===!1&&delete b.params[f],d||g},def.filter&&(def.defaultFilter=def.filter,delete def.filter);var cache=DS.cacheFactory("DS."+def.name,{maxAge:def.maxAge||null,recycleFreq:def.recycleFreq||1e3,cacheFlushInterval:def.cacheFlushInterval||null,deleteOnExpire:def.deleteOnExpire||"none",onExpire:function(a){var b=DS.eject(def.name,a);DS.utils.isFunction(def.onExpire)&&def.onExpire(a,b)},capacity:Number.MAX_VALUE,storageMode:"memory",storageImpl:null,disabled:!1,storagePrefix:"DS."+def.name});return def.class=DS.utils.pascalCase(definition.name),eval("function "+def.class+"() {}"),def[def.class]=eval(def.class),def.methods&&DS.utils.deepMixIn(def[def.class].prototype,def.methods),def.computed&&(DS.utils.forOwn(def.computed,function(a,b){angular.isFunction(a)&&(def.computed[b]=[a],a=def.computed[b]),def.methods&&b in def.methods&&DS.$log.warn(errorPrefix+'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&&DS.$log.warn(errorPrefix+"Use the computed property array syntax for compatibility with minified code!")}c=a.slice(0,a.length-1),angular.forEach(c,function(a,b){c[b]=a.trim()}),a.deps=DS.utils.filter(c,function(a){return!!a})}),def[def.class].prototype.DSCompute=function(){return DS.compute(def.name,this)}),DS.store[def.name]={collection:[],completedQueries:{},pendingQueries:{},index:cache,modified:{},saved:{},previousAttributes:{},observers:{},collectionModified:0},angular.forEach(methodsToProxy,function(a){def[a]="bindOne"===a||"bindAll"===a?function(){var b=Array.prototype.slice.call(arguments);return b.splice(2,0,def.name),DS[a].apply(DS,b)}:function(){var b=Array.prototype.slice.call(arguments);return b.unshift(def.name),DS[a].apply(DS,b)}}),def.beforeValidate=DS.$q.promisify(def.beforeValidate),def.validate=DS.$q.promisify(def.validate),def.afterValidate=DS.$q.promisify(def.afterValidate),def.beforeCreate=DS.$q.promisify(def.beforeCreate),def.afterCreate=DS.$q.promisify(def.afterCreate),def.beforeUpdate=DS.$q.promisify(def.beforeUpdate),def.afterUpdate=DS.$q.promisify(def.afterUpdate),def.beforeDestroy=DS.$q.promisify(def.beforeDestroy),def.afterDestroy=DS.$q.promisify(def.afterDestroy),"function"==typeof Object.freeze&&Object.freeze(def),def}catch(err){throw DS.$log.error(err),delete definitions[definition.name],delete DS.store[definition.name],err}}var errorPrefix="DS.defineResource(definition): ",methodsToProxy=["bindAll","bindOne","changes","create","createInstance","destroy","destroyAll","eject","ejectAll","filter","find","findAll","get","hasChanges","inject","lastModified","lastSaved","link","linkAll","linkInverse","loadRelations","previous","refresh","save","update","updateAll"];module.exports=defineResource},{}],56:[function(a,b){function c(){this.$rootScope.$$phase?d.Platform.performMicrotaskCheckpoint():this.$rootScope.$apply(function(){d.Platform.performMicrotaskCheckpoint()})}var d=a("../../../lib/observe-js/observe-js");b.exports=c},{"../../../lib/observe-js/observe-js":1}],57:[function(a,b){function c(a,b){return"DS.eject("+a+", "+b+"): "}function d(a,b,c){for(var d,e=!1,f=0;f<b.collection.length;f++)if(b.collection[f][a.idAttribute]==c){d=b.collection[f],e=!0;break}return e?(b.collection.splice(f,1),b.observers[c].close(),delete b.observers[c],b.index.remove(c),delete b.previousAttributes[c],delete b.completedQueries[c],delete b.modified[c],delete b.saved[c],b.collectionModified=this.utils.updateTimestamp(b.collectionModified),this.notify(a,"eject",d),d):void 0}function e(a,b){var e=this,f=e.definitions[a];if(!f)throw new e.errors.NER(c(a,b)+a);if(!e.utils.isString(b)&&!e.utils.isNumber(b))throw new e.errors.IA(c(a,b)+"id: Must be a string or a number!");var g,h=e.store[a];return e.$rootScope.$$phase?g=d.call(e,f,h,b):e.$rootScope.$apply(function(){g=d.call(e,f,h,b)}),g}b.exports=e},{}],58:[function(a,b){function c(a){return"DS.ejectAll("+a+"[, params]): "}function d(a,b,c){var d=this,e=d.utils.toJson(c),f=d.filter(a.name,c),g=d.utils.toLookup(f,a.idAttribute);return angular.forEach(g,function(b,c){d.eject(a.name,c)}),delete b.completedQueries[e],b.collectionModified=d.utils.updateTimestamp(b.collectionModified),d.notify(a,"eject",f),f}function e(a,b){var e=this,f=e.definitions[a];if(b=b||{},!f)throw new e.errors.NER(c(a)+a);if(!e.utils.isObject(b))throw new e.errors.IA(c(a)+"params: Must be an object!");var g,h=e.store[a];return e.utils.isEmpty(b)&&(h.completedQueries={}),e.$rootScope.$$phase?g=d.call(e,f,h,b):e.$rootScope.$apply(function(){g=d.call(e,f,h,b)}),g}b.exports=e},{}],59:[function(a,b){function c(a){return"DS.filter("+a+"[, params][, options]): "}function d(a,b,d){var e=this,f=e.errors.IA,g=e.definitions[a];if(d=d||{},!g)throw new e.errors.NER(c(a)+a);if(b&&!e.utils.isObject(b))throw new f(c(a)+"params: Must be an object!");if(!e.utils.isObject(d))throw new f(c(a)+"options: Must be an object!");var h=e.store[a];b=b||{},d.allowSimpleWhere="allowSimpleWhere"in d?!!d.allowSimpleWhere:!0;var i=e.utils.toJson(b);return i in h.completedQueries||!d.loadFromServer||h.pendingQueries[i]||e.findAll(a,b,d),g.defaultFilter.call(e,h.collection,a,b,d)}b.exports=d},{}],60:[function(a,b){function c(a,b){return"DS.get("+a+", "+b+"): "}function d(a,b,d){var e=this,f=e.errors.IA;if(d=d||{},!e.definitions[a])throw new e.errors.NER(c(a,b)+a);if(!e.utils.isString(b)&&!e.utils.isNumber(b))throw new f(c(a,b)+"id: Must be a string or a number!");if(!e.utils.isObject(d))throw new f(c(a,b)+"options: Must be an object!");var g=e.store[a].index.get(b);return!g&&d.loadFromServer&&e.find(a,b,d).then(null,function(a){return e.$q.reject(a)}),g}b.exports=d},{}],61:[function(a,b){function c(a,b){return"DS.hasChanges("+a+", "+b+"): "}function d(a,b){return!(a.isEmpty(b.added)&&a.isEmpty(b.removed)&&a.isEmpty(b.changed))}function e(a,b){var e=this;if(!e.definitions[a])throw new e.errors.NER(c(a,b)+a);if(!e.utils.isString(b)&&!e.utils.isNumber(b))throw new e.errors.IA(c(a,b)+"id: Must be a string or a number!");return e.get(a,b)?d(e.utils,e.changes(a,b)):!1}b.exports=e},{}],62:[function(a,b){b.exports={bindOne:a("./bindOne"),bindAll:a("./bindAll"),compute:a("./compute").compute,createInstance:a("./createInstance"),defineResource:a("./defineResource"),eject:a("./eject"),ejectAll:a("./ejectAll"),filter:a("./filter"),get:a("./get"),inject:a("./inject"),lastModified:a("./lastModified"),lastSaved:a("./lastSaved"),link:a("./link"),linkAll:a("./linkAll"),linkInverse:a("./linkInverse"),digest:a("./digest"),changes:a("./changes"),previous:a("./previous"),hasChanges:a("./hasChanges")}},{"./bindAll":50,"./bindOne":51,"./changes":52,"./compute":53,"./createInstance":54,"./defineResource":55,"./digest":56,"./eject":57,"./ejectAll":58,"./filter":59,"./get":60,"./hasChanges":61,"./inject":63,"./lastModified":64,"./lastSaved":65,"./link":66,"./linkAll":67,"./linkInverse":68,"./previous":69}],63:[function(a,b){function c(a){return"DS.inject("+a+", attrs[, options]): "}function d(a,b,e){function f(c,d,e,f,g){var i,l=this,m=f&&f(a.idAttribute)?f(a.idAttribute):l[a.idAttribute];j.utils.forEach(a.relationFields,function(a){delete c[a],delete d[a],delete e[a]}),j.utils.isEmpty(c)&&j.utils.isEmpty(d)&&j.utils.isEmpty(e)&&!g||(b.modified[m]=j.utils.updateTimestamp(b.modified[m]),b.collectionModified=j.utils.updateTimestamp(b.collectionModified)),a.computed&&(i=j.get(a.name,m),j.utils.forOwn(a.computed,function(a,b){var f=!1;angular.forEach(a.deps,function(a){(a in c||a in d||a in e||!(b in i))&&(f=!0)}),f=f||!a.deps.length,f&&h.call(i,a,b)})),a.relations&&(i=j.get(a.name,m),j.utils.forEach(a.relationList,function(b){i[b.localField]&&(b.localKey in c||b.localKey in d||b.localKey in e)&&j.link(a.name,i[a.idAttribute],[b.relation])})),a.idAttribute in e&&k.error("Doh! You just changed the primary key of an object! I don't know how to handle this yet, so your data for the \""+a.name+'" resource is now in an undefined (probably broken) state.')}var i,j=this,k=j.$log;if(j.utils.isArray(e)){i=[];for(var l=0;l<e.length;l++)i.push(d.call(j,a,b,e[l]))}else{var m=a.computed,n=a.idAttribute;if(m&&m[n]){var o=[];angular.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 j.errors.R(c(a.name)+"attrs: Must contain the property specified by `idAttribute`!");throw k.error(p),p}try{a.beforeInject(a.name,e);var q=e[n],r=j.get(a.name,q);r?(j.utils.deepMixIn(r,e),"function"==typeof b.index.touch?b.index.touch(q):b.index.put(q,b.index.get(q)),b.observers[q].deliver()):(r=a.methods||a.useClass?e instanceof a[a.class]?e:new a[a.class]:{},b.previousAttributes[q]={},j.utils.deepMixIn(r,e),j.utils.deepMixIn(b.previousAttributes[q],e),b.collection.push(r),b.observers[q]=new g.ObjectObserver(r),b.observers[q].open(f,r),b.index.put(q,r),f.call(r,{},{},{},null,!0)),b.saved[q]=j.utils.updateTimestamp(b.saved[q]),a.afterInject(a.name,r),i=r}catch(s){k.error(s),k.error("inject failed!",a.name,e)}}return i}function e(a,b,d){function e(b,e,g){var h=f.definitions[e];if(h&&g[b.localField]&&!j.injectedSoFar[e+g[b.localField][h.idAttribute]])try{j.injectedSoFar[e+g[b.localField][h.idAttribute]]=1,g[b.localField]=f.inject(e,g[b.localField],d)}catch(i){f.$log.error(c(a.name)+"Failed to inject "+b.type+' relation: "'+e+'"!',i)}else d.findBelongsTo&&"belongsTo"===b.type?f.utils.isArray(g)?f.utils.forEach(g,function(b){f.link(a.name,b[a.idAttribute],[e])}):f.link(a.name,g[a.idAttribute],[e]):(d.findHasMany&&"hasMany"===b.type||d.findHasOne&&"hasOne"===b.type)&&(f.utils.isArray(g)?f.utils.forEach(g,function(b){f.link(a.name,b[a.idAttribute],[e])}):f.link(a.name,g[a.idAttribute],[e]))}var f=this;f.utils.forEach(a.relationList,function(a){f.utils.isArray(b)?f.utils.forEach(b,function(b){e(a,a.relation,b)}):e(a,a.relation,b)})}function f(a,b,f){var g=this,h=g.errors.IA,k=g.definitions[a];if(f=f||{},!k)throw new g.errors.NER(c(a)+a);if(!g.utils.isObject(b)&&!g.utils.isArray(b))throw new h(c(a)+"attrs: Must be an object or an array!");if(!g.utils.isObject(f))throw new h(c(a)+"options: Must be an object!");var l,m=g.store[a];i++;try{g.$rootScope.$$phase?l=d.call(g,k,m,b):g.$rootScope.$apply(function(){l=d.call(g,k,m,b)}),k.relations&&e.call(g,k,l,f),f.linkInverse&&(g.utils.isArray(l)&&l.length?g.linkInverse(k.name,l[0][k.idAttribute]):g.linkInverse(k.name,l[k.idAttribute])),g.notify(k,"inject",l),i--}catch(n){throw i--,n}return i||(j.injectedSoFar={}),l}var g=a("../../../lib/observe-js/observe-js"),h=a("./compute")._compute,i=0,j={injectedSoFar:{}};b.exports=f},{"../../../lib/observe-js/observe-js":1,"./compute":53}],64:[function(a,b){function c(a,b){return"DS.lastModified("+a+"[, "+b+"]): "}function d(a,b){var d=this,e=d.store[a];if(!d.definitions[a])throw new d.errors.NER(c(a,b)+a);if(b&&!d.utils.isString(b)&&!d.utils.isNumber(b))throw new d.errors.IA(c(a,b)+"id: Must be a string or a number!");return b?(b in e.modified||(e.modified[b]=0),e.modified[b]):e.collectionModified}b.exports=d},{}],65:[function(a,b){function c(a,b){return"DS.lastSaved("+a+"[, "+b+"]): "}function d(a,b){var d=this,e=d.store[a];if(!d.definitions[a])throw new d.errors.NER(c(a,b)+a);if(!d.utils.isString(b)&&!d.utils.isNumber(b))throw new d.errors.IA(c(a,b)+"id: Must be a string or a number!");return b in e.saved||(e.saved[b]=0),e.saved[b]}b.exports=d},{}],66:[function(a,b){function c(a){return"DS.link("+a+", id[, relations]): "}function d(a,b,c){var d=this;d.utils.forEach(a.relationList,function(e){var f=e.relation;if(!c.length||d.utils.contains(c,f)){var g={};if("belongsTo"===e.type){var h=b[e.localKey]?d.get(f,b[e.localKey]):null;h&&(b[e.localField]=h)}else if("hasMany"===e.type)g[e.foreignKey]=b[a.idAttribute],b[e.localField]=d.defaults.constructor.prototype.defaultFilter.call(d,d.store[f].collection,f,g,{allowSimpleWhere:!0});else if("hasOne"===e.type){g[e.foreignKey]=b[a.idAttribute];var i=d.defaults.constructor.prototype.defaultFilter.call(d,d.store[f].collection,f,g,{allowSimpleWhere:!0});i.length&&(b[e.localField]=i[0])}}})}function e(a,b,e){var f=this,g=f.errors.IA,h=f.definitions[a];if(e=e||[],!h)throw new f.errors.NER(c(a)+a);if(!f.utils.isString(b)&&!f.utils.isNumber(b))throw new g(c(a)+"id: Must be a string or a number!");if(!f.utils.isArray(e))throw new g(c(a)+"relations: Must be an array!");var i=f.get(a,b);return i&&(f.$rootScope.$$phase?d.call(f,h,i,e):f.$rootScope.$apply(function(){d.call(f,h,i,e)})),i}b.exports=e},{}],67:[function(a,b){function c(a){return"DS.linkAll("+a+"[, params][, relations]): "}function d(a,b,c){var d=this;d.utils.forEach(a.relationList,function(e){var f=e.relation;(!c.length||d.utils.contains(c,f))&&("belongsTo"===e.type?d.utils.forEach(b,function(a){var b=a[e.localKey]?d.get(f,a[e.localKey]):null;b&&(a[e.localField]=b)}):"hasMany"===e.type?d.utils.forEach(b,function(b){var c={};c[e.foreignKey]=b[a.idAttribute],b[e.localField]=d.defaults.constructor.prototype.defaultFilter.call(d,d.store[f].collection,f,c,{allowSimpleWhere:!0})}):"hasOne"===e.type&&d.utils.forEach(b,function(b){var c={};c[e.foreignKey]=b[a.idAttribute];var g=d.defaults.constructor.prototype.defaultFilter.call(d,d.store[f].collection,f,c,{allowSimpleWhere:!0});g.length&&(b[e.localField]=g[0])}))})}function e(a,b,e){var f=this,g=f.errors.IA,h=f.definitions[a];if(e=e||[],!h)throw new f.errors.NER(c(a)+a);if(b&&!f.utils.isObject(b))throw new g(c(a)+"params: Must be an object!");if(!f.utils.isArray(e))throw new g(c(a)+"relations: Must be an array!");var i=f.filter(a,b);return i&&(f.$rootScope.$$phase?d.call(f,h,i,e):f.$rootScope.$apply(function(){d.call(f,h,i,e)})),i}b.exports=e},{}],68:[function(a,b){function c(a){return"DS.linkInverse("+a+", id[, relations]): "}function d(a,b){var c=this;c.utils.forOwn(c.definitions,function(d){c.utils.forOwn(d.relations,function(e){c.utils.forOwn(e,function(e,f){(!b.length||c.utils.contains(b,d.name))&&a.name===f&&c.linkAll(d.name,{},[a.name])})})})}function e(a,b,e){var f=this,g=f.errors.IA,h=f.definitions[a];if(e=e||[],!h)throw new f.errors.NER(c(a)+a);if(!f.utils.isString(b)&&!f.utils.isNumber(b))throw new g(c(a)+"id: Must be a string or a number!");if(!f.utils.isArray(e))throw new g(c(a)+"relations: Must be an array!");var i=f.get(a,b);return i&&(f.$rootScope.$$phase?d.call(f,h,e):f.$rootScope.$apply(function(){d.call(f,h,e)})),i}b.exports=e},{}],69:[function(a,b){function c(a,b){return"DS.previous("+a+"[, "+b+"]): "}function d(a,b){var d=this;if(!d.definitions[a])throw new d.errors.NER(c(a,b)+a);if(!d.utils.isString(b)&&!d.utils.isNumber(b))throw new d.errors.IA(c(a,b)+"id: Must be a string or a number!");return angular.copy(d.store[a].previousAttributes[b])}b.exports=d},{}],70:[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=Object.create(Error.prototype),c.prototype.constructor=c,d.prototype=Object.create(Error.prototype),d.prototype.constructor=d,e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,b.exports=[function(){return{IllegalArgumentError:c,IA:c,RuntimeError:d,R:d,NonexistentResourceError:e,NER:e}}]},{}],71:[function(a){!function(b,c){"use strict";c.module("angular-data.DS",["ng"]).factory("DSUtils",a("./utils")).factory("DSErrors",a("./errors")).provider("DSHttpAdapter",a("./adapters/http")).provider("DSLocalStorageAdapter",a("./adapters/localStorage")).provider("DS",a("./datastore")).config(["$provide",function(a){a.decorator("$q",["$delegate",function(a){return a.promisify=function(a,b){if(a){if("function"!=typeof a)throw new Error("Can only promisify functions!");var c=this;return function(){var d=c.defer(),e=Array.prototype.slice.apply(arguments);e.push(function(a,b){a?d.reject(a):d.resolve(b)});try{a.apply(b||this,e)}catch(f){d.reject(f)}return d.promise}}},a}])}])}(window,window.angular)},{"./adapters/http":36,"./adapters/localStorage":37,"./datastore":49,"./errors":70,"./utils":72}],72:[function(a,b){b.exports=[function(){return{isBoolean:a("mout/lang/isBoolean"),isString:angular.isString,isArray:angular.isArray,isObject:angular.isObject,isNumber:angular.isNumber,isFunction:angular.isFunction,isEmpty:a("mout/lang/isEmpty"),toJson:angular.toJson,makePath:a("mout/string/makePath"),upperCase:a("mout/string/upperCase"),pascalCase:a("mout/string/pascalCase"),deepMixIn:a("mout/object/deepMixIn"),forOwn:a("mout/object/forOwn"),forEach:angular.forEach,pick:a("mout/object/pick"),set:a("mout/object/set"),contains:a("mout/array/contains"),filter:a("mout/array/filter"),toLookup:a("mout/array/toLookup"),slice:a("mout/array/slice"),sort:a("mout/array/sort"),updateTimestamp:function(a){var b="function"==typeof Date.now?Date.now():(new Date).getTime();return a&&a>=b?a+1:b},deepFreeze:function b(a){if("function"==typeof Object.freeze){var c,d;Object.freeze(a);for(d in a)c=a[d],a.hasOwnProperty(d)&&"object"==typeof c&&!Object.isFrozen(c)&&b(c)}},diffObjectFromOldObject:function(a,b){var c={},d={},e={};for(var f in b){var g=a[f];(void 0===g||g!==b[f])&&(f in a?g!==b[f]&&(e[f]=g):d[f]=void 0)}for(var h in a)h in b||(c[h]=a[h]);return{added:c,removed:d,changed:e}}}}]},{"mout/array/contains":2,"mout/array/filter":3,"mout/array/slice":7,"mout/array/sort":8,"mout/array/toLookup":9,"mout/lang/isBoolean":14,"mout/lang/isEmpty":15,"mout/object/deepMixIn":22,"mout/object/forOwn":24,"mout/object/pick":27,"mout/object/set":28,"mout/string/makePath":31,"mout/string/pascalCase":32,"mout/string/upperCase":35}]},{},[71]);
{
"name": "angular-data",
"description": "Data store for Angular.js.",
"version": "1.0.0-beta.1",
"version": "1.0.0-beta.2",
"homepage": "http://angular-data.pseudobry.com",

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

"karma-phantomjs-launcher": "^0.1.4",
"karma-mocha": "^0.1.8",
"karma-mocha": "^0.1.9",
"karma-sinon": "^1.0.3",
"karma-spec-reporter": "^0.0.13",
"time-grunt": "^0.4.0",
"time-grunt": "^1.0.0",
"jit-grunt": "^0.8.0",

@@ -45,0 +45,0 @@ "grunt-docular": "^0.1.4"

@@ -11,4 +11,4 @@ ## angular-data

__Latest Release:__ [1.0.0-beta.1](http://angular-data.pseudobry.com/)
__master:__ [1.0.0-beta.1](http://angular-data-next.pseudobry.com/)
__Latest Release:__ [1.0.0-beta.2](http://angular-data.pseudobry.com/)
__master:__ [1.0.0-beta.2](http://angular-data-next.pseudobry.com/)

@@ -15,0 +15,0 @@ Angular-data is in a 1.0.0 Beta. The API is rather stable and angular-data is well tested.

@@ -57,3 +57,2 @@ /**

* angular.extend(DSHttpAdapterProvider.defaults.$httpConfig, {
* interceptor: [...],
* headers: {

@@ -233,3 +232,4 @@ * Authorization: 'Basic YmVlcDpib29w'

*
* - `{string=}` - `baseUrl` - Base url to use.
* - `{string=}` - `baseUrl` - Override the default base url.
* - `{string=}` - `endpoint` - Override the default endpoint.
* - `{object=}` - `params` - Additional query string parameters to add to the url.

@@ -265,3 +265,4 @@ *

*
* - `{string=}` - `baseUrl` - Base url to use.
* - `{string=}` - `baseUrl` - Override the default base url.
* - `{string=}` - `endpoint` - Override the default endpoint.
* - `{object=}` - `params` - Additional query string parameters to add to the url.

@@ -302,3 +303,4 @@ *

*
* - `{string=}` - `baseUrl` - Base url to use.
* - `{string=}` - `baseUrl` - Override the default base url.
* - `{string=}` - `endpoint` - Override the default endpoint.
* - `{object=}` - `params` - Additional query string parameters to add to the url.

@@ -336,3 +338,4 @@ *

*
* - `{string=}` - `baseUrl` - Base url to use.
* - `{string=}` - `baseUrl` - Override the default base url.
* - `{string=}` - `endpoint` - Override the default endpoint.
* - `{object=}` - `params` - Additional query string parameters to add to the url.

@@ -370,3 +373,4 @@ *

*
* - `{string=}` - `baseUrl` - Base url to use.
* - `{string=}` - `baseUrl` - Override the default base url.
* - `{string=}` - `endpoint` - Override the default endpoint.
* - `{object=}` - `params` - Additional query string parameters to add to the url.

@@ -408,3 +412,4 @@ *

*
* - `{string=}` - `baseUrl` - Base url to use.
* - `{string=}` - `baseUrl` - Override the default base url.
* - `{string=}` - `endpoint` - Override the default endpoint.
* - `{object=}` - `params` - Additional query string parameters to add to the url.

@@ -440,3 +445,4 @@ *

*
* - `{string=}` - `baseUrl` - Base url to use.
* - `{string=}` - `baseUrl` - Override the default base url.
* - `{string=}` - `endpoint` - Override the default endpoint.
* - `{object=}` - `params` - Additional query string parameters to add to the url.

@@ -443,0 +449,0 @@ *

@@ -37,2 +37,7 @@ function errorPrefix(resourceName) {

* - `{boolean=}` - `upsert` - If `attrs` already contains a primary key, then attempt to call `DS.update` instead. Default: `true`.
* - `{function=}` - `beforeValidate` - Override the resource or global lifecycle hook.
* - `{function=}` - `validate` - Override the resource or global lifecycle hook.
* - `{function=}` - `afterValidate` - Override the resource or global lifecycle hook.
* - `{function=}` - `beforeCreate` - Override the resource or global lifecycle hook.
* - `{function=}` - `afterCreate` - Override the resource or global lifecycle hook.
*

@@ -53,6 +58,6 @@ * @returns {Promise} Promise produced by the `$q` service.

var deferred = DS.$q.defer();
var promise = deferred.promise;
var definition = DS.definitions[resourceName];
try {
var definition = DS.definitions[resourceName];
options = options || {};

@@ -65,4 +70,2 @@

}
var resource = DS.store[resourceName];
if (!('cacheResponse' in options)) {

@@ -76,17 +79,23 @@ options.cacheResponse = true;

deferred.resolve(attrs);
if (options.upsert && attrs[definition.idAttribute]) {
promise = DS.update(resourceName, attrs[definition.idAttribute], attrs, options);
return DS.update(resourceName, attrs[definition.idAttribute], attrs, options);
} else {
promise = promise
return deferred.promise
.then(function (attrs) {
return DS.$q.promisify(definition.beforeValidate)(resourceName, attrs);
var func = options.beforeValidate ? DS.$q.promisify(options.beforeValidate) : definition.beforeValidate;
return func.call(attrs, resourceName, attrs);
})
.then(function (attrs) {
return DS.$q.promisify(definition.validate)(resourceName, attrs);
var func = options.validate ? DS.$q.promisify(options.validate) : definition.validate;
return func.call(attrs, resourceName, attrs);
})
.then(function (attrs) {
return DS.$q.promisify(definition.afterValidate)(resourceName, attrs);
var func = options.afterValidate ? DS.$q.promisify(options.afterValidate) : definition.afterValidate;
return func.call(attrs, resourceName, attrs);
})
.then(function (attrs) {
return DS.$q.promisify(definition.beforeCreate)(resourceName, attrs);
var func = options.beforeCreate ? DS.$q.promisify(options.beforeCreate) : definition.beforeCreate;
return func.call(attrs, resourceName, attrs);
})

@@ -97,7 +106,10 @@ .then(function (attrs) {

.then(function (res) {
return DS.$q.promisify(definition.afterCreate)(resourceName, definition.deserialize(resourceName, res));
var func = options.afterCreate ? DS.$q.promisify(options.afterCreate) : definition.afterCreate;
var attrs = definition.deserialize(resourceName, res);
return func.call(attrs, resourceName, attrs);
})
.then(function (data) {
if (options.cacheResponse) {
var created = DS.inject(definition.name, data);
var resource = DS.store[resourceName];
var created = DS.inject(definition.name, data, options);
var id = created[definition.idAttribute];

@@ -113,11 +125,8 @@ resource.completedQueries[id] = new Date().getTime();

}
deferred.resolve(attrs);
} catch (err) {
deferred.reject(err);
return deferred.promise;
}
return promise;
}
module.exports = create;

@@ -31,3 +31,7 @@ function errorPrefix(resourceName, id) {

* @param {string|number} id The primary key of the item to remove.
* @param {object=} options Configuration options. Also passed along to the adapter's `destroy` method.
* @param {object=} options Configuration options. Also passed along to the adapter's `destroy` method. Properties:
*
* - `{function=}` - `beforeDestroy` - Override the resource or global lifecycle hook.
* - `{function=}` - `afterDestroy` - Override the resource or global lifecycle hook.
*
* @returns {Promise} Promise produced by the `$q` service.

@@ -48,6 +52,6 @@ *

var deferred = DS.$q.defer();
var promise = deferred.promise;
var definition = DS.definitions[resourceName];
try {
var definition = DS.definitions[resourceName];
options = options || {};

@@ -66,5 +70,8 @@

promise = promise
deferred.resolve(item);
return deferred.promise
.then(function (attrs) {
return DS.$q.promisify(definition.beforeDestroy)(resourceName, attrs);
var func = options.beforeDestroy ? DS.$q.promisify(options.beforeDestroy) : definition.beforeDestroy;
return func.call(attrs, resourceName, attrs);
})

@@ -75,3 +82,4 @@ .then(function () {

.then(function () {
return DS.$q.promisify(definition.afterDestroy)(resourceName, item);
var func = options.afterDestroy ? DS.$q.promisify(options.afterDestroy) : definition.afterDestroy;
return func.call(item, resourceName, item);
})

@@ -82,10 +90,8 @@ .then(function () {

});
deferred.resolve(item);
} catch (err) {
deferred.reject(err);
return deferred.promise;
}
return promise;
}
module.exports = destroy;

@@ -58,7 +58,6 @@ function errorPrefix(resourceName) {

var deferred = DS.$q.defer();
var promise = deferred.promise;
var definition = DS.definitions[resourceName];
try {
var IA = DS.errors.IA;
var definition = DS.definitions[resourceName];

@@ -75,3 +74,5 @@ options = options || {};

promise = promise
deferred.resolve();
return deferred.promise
.then(function () {

@@ -83,10 +84,8 @@ return DS.adapters[options.adapter || definition.defaultAdapter].destroyAll(definition, params, options);

});
deferred.resolve();
} catch (err) {
deferred.reject(err);
return deferred.promise;
}
return promise;
}
module.exports = destroyAll;

@@ -55,6 +55,7 @@ function errorPrefix(resourceName, id) {

var IA = DS.errors.IA;
var definition = DS.definitions[resourceName];
options = options || {};
if (!DS.definitions[resourceName]) {
if (!definition) {
throw new DS.errors.NER(errorPrefix(resourceName, id) + resourceName);

@@ -70,4 +71,2 @@ } else if (!DS.utils.isString(id) && !DS.utils.isNumber(id)) {

}
var definition = DS.definitions[resourceName];
var resource = DS.store[resourceName];

@@ -88,3 +87,3 @@

resource.completedQueries[id] = new Date().getTime();
return DS.inject(resourceName, data);
return DS.inject(resourceName, data, options);
} else {

@@ -91,0 +90,0 @@ return data;

@@ -5,3 +5,3 @@ function errorPrefix(resourceName) {

function processResults(data, resourceName, queryHash) {
function processResults(data, resourceName, queryHash, options) {
var DS = this;

@@ -22,3 +22,3 @@ var resource = DS.store[resourceName];

// Merge the new values into the cache
var injected = DS.inject(resourceName, data);
var injected = DS.inject(resourceName, data, options);

@@ -61,3 +61,3 @@ // Make sure each object is added to completedQueries

try {
return processResults.apply(DS, [data, resourceName, queryHash]);
return processResults.call(DS, data, resourceName, queryHash, options);
} catch (err) {

@@ -144,3 +144,2 @@ return DS.$q.reject(err);

var deferred = DS.$q.defer();
var promise = deferred.promise;

@@ -165,13 +164,13 @@ try {

promise = promise.then(function () {
return _findAll.apply(DS, [resourceName, params, options]);
deferred.resolve();
return deferred.promise.then(function () {
return _findAll.call(DS, resourceName, params, options);
});
deferred.resolve();
} catch (err) {
deferred.reject(err);
return deferred.promise;
}
return promise;
}
module.exports = findAll;

@@ -61,7 +61,6 @@ function errorPrefix(resourceName) {

var deferred = DS.$q.defer();
var promise = deferred.promise;
var definition = DS.definitions[resourceName];
try {
var IA = DS.errors.IA;
var definition = DS.definitions[resourceName];

@@ -88,39 +87,42 @@ options = options || {};

if (!('findBelongsTo' in options)) {
options.findBelongsTo = true;
}
if (!('findHasMany' in options)) {
options.findHasMany = true;
}
var tasks = [];
var fields = [];
DS.utils.forOwn(definition.relations, function (relatedModels, type) {
DS.utils.forOwn(relatedModels, function (defs, relationName) {
if (!DS.utils.isArray(defs)) {
defs = [defs];
DS.utils.forEach(definition.relationList, function (def) {
var relationName = def.relation;
if (DS.utils.contains(relations, relationName)) {
var task;
var params = {};
params[def.foreignKey] = instance[definition.idAttribute];
if (def.type === 'hasMany') {
task = DS.findAll(relationName, params, options);
} else if (def.type === 'hasOne') {
if (def.localKey && instance[def.localKey]) {
task = DS.find(relationName, instance[def.localKey], options);
} else if (def.foreignKey) {
task = DS.findAll(relationName, params, options);
}
} else {
task = DS.find(relationName, instance[def.localKey], options);
}
defs.forEach(function (def) {
if (DS.utils.contains(relations, relationName)) {
var task;
var params = {};
params[def.foreignKey] = instance[definition.idAttribute];
if (task) {
tasks.push(task);
fields.push(def.localField);
}
}
});
if (type === 'hasMany') {
task = DS.findAll(relationName, params, options);
} else if (type === 'hasOne') {
if (def.localKey && instance[def.localKey]) {
task = DS.find(relationName, instance[def.localKey], options);
} else if (def.foreignKey) {
task = DS.findAll(relationName, params, options);
}
} else {
task = DS.find(relationName, instance[def.localKey], options);
}
deferred.resolve();
if (task) {
tasks.push(task);
fields.push(def.localField);
}
}
});
});
});
promise = promise
return deferred.promise
.then(function () {

@@ -135,11 +137,8 @@ return DS.$q.all(tasks);

});
deferred.resolve();
} catch (err) {
deferred.reject(err);
return deferred.promise;
}
return promise;
}
module.exports = loadRelations;

@@ -36,2 +36,7 @@ function errorPrefix(resourceName, id) {

* - `{boolean=}` - `changesOnly` - Only send changed and added values to the adapter. Default: `false`.
* - `{function=}` - `beforeValidate` - Override the resource or global lifecycle hook.
* - `{function=}` - `validate` - Override the resource or global lifecycle hook.
* - `{function=}` - `afterValidate` - Override the resource or global lifecycle hook.
* - `{function=}` - `beforeUpdate` - Override the resource or global lifecycle hook.
* - `{function=}` - `afterUpdate` - Override the resource or global lifecycle hook.
*

@@ -53,7 +58,6 @@ * @returns {Promise} Promise produced by the `$q` service.

var deferred = DS.$q.defer();
var promise = deferred.promise;
var definition = DS.definitions[resourceName];
try {
var IA = DS.errors.IA;
var definition = DS.definitions[resourceName];

@@ -75,4 +79,2 @@ options = options || {};

var resource = DS.store[resourceName];
if (!('cacheResponse' in options)) {

@@ -82,17 +84,24 @@ options.cacheResponse = true;

promise = promise
deferred.resolve(item);
return deferred.promise
.then(function (attrs) {
return DS.$q.promisify(definition.beforeValidate)(resourceName, attrs);
var func = options.beforeValidate ? DS.$q.promisify(options.beforeValidate) : definition.beforeValidate;
return func.call(attrs, resourceName, attrs);
})
.then(function (attrs) {
return DS.$q.promisify(definition.validate)(resourceName, attrs);
var func = options.validate ? DS.$q.promisify(options.validate) : definition.validate;
return func.call(attrs, resourceName, attrs);
})
.then(function (attrs) {
return DS.$q.promisify(definition.afterValidate)(resourceName, attrs);
var func = options.afterValidate ? DS.$q.promisify(options.afterValidate) : definition.afterValidate;
return func.call(attrs, resourceName, attrs);
})
.then(function (attrs) {
return DS.$q.promisify(definition.beforeUpdate)(resourceName, attrs);
var func = options.beforeUpdate ? DS.$q.promisify(options.beforeUpdate) : definition.beforeUpdate;
return func.call(attrs, resourceName, attrs);
})
.then(function (attrs) {
if (options.changesOnly) {
var resource = DS.store[resourceName];
resource.observers[id].deliver();

@@ -119,9 +128,13 @@ var toKeep = [],

.then(function (res) {
return DS.$q.promisify(definition.afterUpdate)(resourceName, definition.deserialize(resourceName, res));
var func = options.afterUpdate ? DS.$q.promisify(options.afterUpdate) : definition.afterUpdate;
var attrs = definition.deserialize(resourceName, res);
return func.call(attrs, resourceName, attrs);
})
.then(function (data) {
if (options.cacheResponse) {
var resource = DS.store[resourceName];
var saved = DS.inject(definition.name, data, options);
resource.previousAttributes[id] = DS.utils.deepMixIn({}, saved);
resource.saved[id] = DS.utils.updateTimestamp(resource.saved[id]);
resource.observers[id].discardChanges();
return DS.get(resourceName, id);

@@ -132,11 +145,8 @@ } else {

});
deferred.resolve(item);
} catch (err) {
deferred.reject(err);
return deferred.promise;
}
return promise;
}
module.exports = save;

@@ -39,2 +39,7 @@ function errorPrefix(resourceName, id) {

* - `{boolean=}` - `cacheResponse` - Inject the data returned by the adapter into the data store. Default: `true`.
* - `{function=}` - `beforeValidate` - Override the resource or global lifecycle hook.
* - `{function=}` - `validate` - Override the resource or global lifecycle hook.
* - `{function=}` - `afterValidate` - Override the resource or global lifecycle hook.
* - `{function=}` - `beforeUpdate` - Override the resource or global lifecycle hook.
* - `{function=}` - `afterUpdate` - Override the resource or global lifecycle hook.
*

@@ -55,10 +60,10 @@ * @returns {Promise} Promise produced by the `$q` service.

var deferred = DS.$q.defer();
var promise = deferred.promise;
try {
var IA = DS.errors.IA;
var definition = DS.definitions[resourceName];
options = options || {};
if (!DS.definitions[resourceName]) {
if (!definition) {
throw new DS.errors.NER(errorPrefix(resourceName, id) + resourceName);

@@ -73,5 +78,2 @@ } else if (!DS.utils.isString(id) && !DS.utils.isNumber(id)) {

var definition = DS.definitions[resourceName];
var resource = DS.store[resourceName];
if (!('cacheResponse' in options)) {

@@ -81,14 +83,20 @@ options.cacheResponse = true;

promise = promise
deferred.resolve(attrs);
return deferred.promise
.then(function (attrs) {
return DS.$q.promisify(definition.beforeValidate)(resourceName, attrs);
var func = options.beforeValidate ? DS.$q.promisify(options.beforeValidate) : definition.beforeValidate;
return func.call(attrs, resourceName, attrs);
})
.then(function (attrs) {
return DS.$q.promisify(definition.validate)(resourceName, attrs);
var func = options.validate ? DS.$q.promisify(options.validate) : definition.validate;
return func.call(attrs, resourceName, attrs);
})
.then(function (attrs) {
return DS.$q.promisify(definition.afterValidate)(resourceName, attrs);
var func = options.afterValidate ? DS.$q.promisify(options.afterValidate) : definition.afterValidate;
return func.call(attrs, resourceName, attrs);
})
.then(function (attrs) {
return DS.$q.promisify(definition.beforeUpdate)(resourceName, attrs);
var func = options.beforeUpdate ? DS.$q.promisify(options.beforeUpdate) : definition.beforeUpdate;
return func.call(attrs, resourceName, attrs);
})

@@ -99,6 +107,9 @@ .then(function (attrs) {

.then(function (res) {
return DS.$q.promisify(definition.afterUpdate)(resourceName, definition.deserialize(resourceName, res));
var func = options.afterUpdate ? DS.$q.promisify(options.afterUpdate) : definition.afterUpdate;
var attrs = definition.deserialize(resourceName, res);
return func.call(attrs, resourceName, attrs);
})
.then(function (data) {
if (options.cacheResponse) {
var resource = DS.store[resourceName];
var updated = DS.inject(definition.name, data, options);

@@ -108,2 +119,3 @@ var id = updated[definition.idAttribute];

resource.saved[id] = DS.utils.updateTimestamp(resource.saved[id]);
resource.observers[id].discardChanges();
return DS.get(definition.name, id);

@@ -114,11 +126,8 @@ } else {

});
deferred.resolve(attrs);
} catch (err) {
deferred.reject(err);
return deferred.promise;
}
return promise;
}
module.exports = update;

@@ -71,10 +71,10 @@ function errorPrefix(resourceName) {

var deferred = DS.$q.defer();
var promise = deferred.promise;
try {
var IA = DS.errors.IA;
var definition = DS.definitions[resourceName];
options = options || {};
if (!DS.definitions[resourceName]) {
if (!definition) {
throw new DS.errors.NER(errorPrefix(resourceName) + resourceName);

@@ -89,4 +89,2 @@ } else if (!DS.utils.isObject(attrs)) {

var definition = DS.definitions[resourceName];
if (!('cacheResponse' in options)) {

@@ -96,14 +94,20 @@ options.cacheResponse = true;

promise = promise
deferred.resolve(attrs);
return deferred.promise
.then(function (attrs) {
return DS.$q.promisify(definition.beforeValidate)(resourceName, attrs);
var func = options.beforeValidate ? DS.$q.promisify(options.beforeValidate) : definition.beforeValidate;
return func.call(attrs, resourceName, attrs);
})
.then(function (attrs) {
return DS.$q.promisify(definition.validate)(resourceName, attrs);
var func = options.validate ? DS.$q.promisify(options.validate) : definition.validate;
return func.call(attrs, resourceName, attrs);
})
.then(function (attrs) {
return DS.$q.promisify(definition.afterValidate)(resourceName, attrs);
var func = options.afterValidate ? DS.$q.promisify(options.afterValidate) : definition.afterValidate;
return func.call(attrs, resourceName, attrs);
})
.then(function (attrs) {
return DS.$q.promisify(definition.beforeUpdate)(resourceName, attrs);
var func = options.beforeUpdate ? DS.$q.promisify(options.beforeUpdate) : definition.beforeUpdate;
return func.call(attrs, resourceName, attrs);
})

@@ -114,3 +118,5 @@ .then(function (attrs) {

.then(function (res) {
return DS.$q.promisify(definition.afterUpdate)(resourceName, definition.deserialize(resourceName, res));
var func = options.afterUpdate ? DS.$q.promisify(options.afterUpdate) : definition.afterUpdate;
var attrs = definition.deserialize(resourceName, res);
return func.call(attrs, resourceName, attrs);
})

@@ -124,11 +130,8 @@ .then(function (data) {

});
deferred.resolve(attrs);
} catch (err) {
deferred.reject(err);
return deferred.promise;
}
return promise;
}
module.exports = updateAll;

@@ -33,2 +33,5 @@ /*jshint evil:true*/

'lastSaved',
'link',
'linkAll',
'linkInverse',
'loadRelations',

@@ -134,14 +137,31 @@ 'previous',

// Setup nested parent configuration
if (def.relations && def.relations.belongsTo) {
DS.utils.forOwn(def.relations.belongsTo, function (relatedModel, modelName) {
if (!DS.utils.isArray(relatedModel)) {
relatedModel = [relatedModel];
}
DS.utils.forEach(relatedModel, function (relation) {
if (relation.parent) {
def.parent = modelName;
def.parentKey = relation.localKey;
if (def.relations) {
def.relationList = [];
def.relationFields = [];
DS.utils.forOwn(def.relations, function (relatedModels, type) {
DS.utils.forOwn(relatedModels, function (defs, relationName) {
if (!DS.utils.isArray(defs)) {
relatedModels[relationName] = [defs];
}
DS.utils.forEach(relatedModels[relationName], function (d) {
d.type = type;
d.relation = relationName;
d.name = def.name;
def.relationList.push(d);
def.relationFields.push(d.localField);
});
});
});
if (def.relations.belongsTo) {
DS.utils.forOwn(def.relations.belongsTo, function (relatedModel, modelName) {
DS.utils.forEach(relatedModel, function (relation) {
if (relation.parent) {
def.parent = modelName;
def.parentKey = relation.localKey;
}
});
});
}
DS.utils.deepFreeze(def.relations);
DS.utils.deepFreeze(def.relationList);
}

@@ -154,2 +174,4 @@

var endpoint;
var thisEndpoint = options.endpoint || this.endpoint;
delete options.endpoint;
options = options || {};

@@ -163,8 +185,8 @@ options.params = options.params || {};

delete options.params[parentKey];
endpoint = DS.utils.makePath(definitions[parent].getEndpoint(attrs, options), attrs[parentKey], this.endpoint);
endpoint = DS.utils.makePath(definitions[parent].getEndpoint(attrs, options), attrs[parentKey], thisEndpoint);
} else if (item && parentKey in item) {
delete options.params[parentKey];
endpoint = DS.utils.makePath(definitions[parent].getEndpoint(attrs, options), item[parentKey], this.endpoint);
endpoint = DS.utils.makePath(definitions[parent].getEndpoint(attrs, options), item[parentKey], thisEndpoint);
} else if (options && options.params[parentKey]) {
endpoint = DS.utils.makePath(definitions[parent].getEndpoint(attrs, options), options.params[parentKey], this.endpoint);
endpoint = DS.utils.makePath(definitions[parent].getEndpoint(attrs, options), options.params[parentKey], thisEndpoint);
delete options.params[parentKey];

@@ -176,3 +198,3 @@ }

}
return endpoint || this.endpoint;
return endpoint || thisEndpoint;
};

@@ -244,2 +266,6 @@

});
def[def.class].prototype.DSCompute = function () {
return DS.compute(def.name, this);
};
}

@@ -277,2 +303,16 @@

def.beforeValidate = DS.$q.promisify(def.beforeValidate);
def.validate = DS.$q.promisify(def.validate);
def.afterValidate = DS.$q.promisify(def.afterValidate);
def.beforeCreate = DS.$q.promisify(def.beforeCreate);
def.afterCreate = DS.$q.promisify(def.afterCreate);
def.beforeUpdate = DS.$q.promisify(def.beforeUpdate);
def.afterUpdate = DS.$q.promisify(def.afterUpdate);
def.beforeDestroy = DS.$q.promisify(def.beforeDestroy);
def.afterDestroy = DS.$q.promisify(def.afterDestroy);
if (typeof Object.freeze === 'function') {
Object.freeze(def);
}
return def;

@@ -279,0 +319,0 @@ } catch (err) {

@@ -103,6 +103,6 @@ function errorPrefix(resourceName) {

DS.$rootScope.$apply(function () {
ejected = _ejectAll.apply(DS, [definition, resource, params]);
ejected = _ejectAll.call(DS, definition, resource, params);
});
} else {
ejected = _ejectAll.apply(DS, [definition, resource, params]);
ejected = _ejectAll.call(DS, definition, resource, params);
}

@@ -109,0 +109,0 @@

@@ -25,2 +25,12 @@ module.exports = {

* @doc method
* @id DS.sync methods:compute
* @name compute
* @methodOf DS
* @description
* See [DS.compute](/documentation/api/api/DS.sync methods:compute).
*/
compute: require('./compute').compute,
/**
* @doc method
* @id DS.sync methods:createInstance

@@ -116,2 +126,32 @@ * @name createInstance

* @doc method
* @id DS.sync methods:link
* @name link
* @methodOf DS
* @description
* See [DS.link](/documentation/api/api/DS.sync methods:link).
*/
link: require('./link'),
/**
* @doc method
* @id DS.sync methods:linkAll
* @name linkAll
* @methodOf DS
* @description
* See [DS.linkAll](/documentation/api/api/DS.sync methods:linkAll).
*/
linkAll: require('./linkAll'),
/**
* @doc method
* @id DS.sync methods:linkInverse
* @name linkInverse
* @methodOf DS
* @description
* See [DS.linkInverse](/documentation/api/api/DS.sync methods:linkInverse).
*/
linkInverse: require('./linkInverse'),
/**
* @doc method
* @id DS.sync methods:digest

@@ -118,0 +158,0 @@ * @name digest

var observe = require('../../../lib/observe-js/observe-js');
var _compute = require('./compute')._compute;
var stack = 0;
var data = {
injectedSoFar: {}
};
function errorPrefix(resourceName) {

@@ -10,11 +16,20 @@ return 'DS.inject(' + resourceName + ', attrs[, options]): ';

function _react(added, removed, changed, oldValueFn) {
function _react(added, removed, changed, oldValueFn, firstTime) {
var target = this;
var item;
var innerId = (oldValueFn && oldValueFn(definition.idAttribute)) ? oldValueFn(definition.idAttribute) : target[definition.idAttribute];
resource.modified[innerId] = DS.utils.updateTimestamp(resource.modified[innerId]);
resource.collectionModified = DS.utils.updateTimestamp(resource.collectionModified);
DS.utils.forEach(definition.relationFields, function (field) {
delete added[field];
delete removed[field];
delete changed[field];
});
if (!DS.utils.isEmpty(added) || !DS.utils.isEmpty(removed) || !DS.utils.isEmpty(changed) || firstTime) {
resource.modified[innerId] = DS.utils.updateTimestamp(resource.modified[innerId]);
resource.collectionModified = DS.utils.updateTimestamp(resource.collectionModified);
}
if (definition.computed) {
var item = DS.get(definition.name, innerId);
item = DS.get(definition.name, innerId);
DS.utils.forOwn(definition.computed, function (fn, field) {

@@ -30,8 +45,3 @@ var compute = false;

if (compute) {
var args = [];
angular.forEach(fn.deps, function (dep) {
args.push(item[dep]);
});
// recompute property
item[field] = fn[fn.length - 1].apply(item, args);
_compute.call(item, fn, field);
}

@@ -41,2 +51,11 @@ });

if (definition.relations) {
item = DS.get(definition.name, innerId);
DS.utils.forEach(definition.relationList, function (def) {
if (item[def.localField] && (def.localKey in added || def.localKey in removed || def.localKey in changed)) {
DS.link(definition.name, item[definition.idAttribute], [def.relation]);
}
});
}
if (definition.idAttribute in changed) {

@@ -97,3 +116,3 @@ $log.error('Doh! You just changed the primary key of an object! ' +

_react.call(item, {}, {}, {});
_react.call(item, {}, {}, {}, null, true);
} else {

@@ -122,44 +141,39 @@ DS.utils.deepMixIn(item, attrs);

var DS = this;
DS.utils.forOwn(definition.relations, function (relatedModels, type) {
DS.utils.forOwn(relatedModels, function (defs, relationName) {
if (!DS.utils.isArray(defs)) {
defs = [defs];
}
function _process(def, injected) {
if (DS.definitions[relationName] && injected[def.localField]) {
try {
injected[def.localField] = DS.inject(relationName, injected[def.localField], options);
} catch (err) {
DS.$log.error(errorPrefix(definition.name) + 'Failed to inject ' + type + ' relation: "' + relationName + '"!', err);
}
} else if (options.findBelongsTo) {
if (type === 'belongsTo') {
if (DS.utils.isArray(injected)) {
DS.utils.forEach(injected, function (injectedItem) {
var parent = injectedItem[def.localKey] ? DS.get(relationName, injectedItem[def.localKey]) : null;
if (parent) {
injectedItem[def.localField] = parent;
}
});
} else {
var parent = injected[def.localKey] ? DS.get(relationName, injected[def.localKey]) : null;
if (parent) {
injected[def.localField] = parent;
}
}
}
}
function _process(def, relationName, injected) {
var relationDef = DS.definitions[relationName];
if (relationDef && injected[def.localField] && !data.injectedSoFar[relationName + injected[def.localField][relationDef.idAttribute]]) {
try {
data.injectedSoFar[relationName + injected[def.localField][relationDef.idAttribute]] = 1;
injected[def.localField] = DS.inject(relationName, injected[def.localField], options);
} catch (err) {
DS.$log.error(errorPrefix(definition.name) + 'Failed to inject ' + def.type + ' relation: "' + relationName + '"!', err);
}
} else if (options.findBelongsTo && def.type === 'belongsTo') {
if (DS.utils.isArray(injected)) {
DS.utils.forEach(injected, function (injectedItem) {
DS.link(definition.name, injectedItem[definition.idAttribute], [relationName]);
});
} else {
DS.link(definition.name, injected[definition.idAttribute], [relationName]);
}
} else if ((options.findHasMany && def.type === 'hasMany') || (options.findHasOne && def.type === 'hasOne')) {
if (DS.utils.isArray(injected)) {
DS.utils.forEach(injected, function (injectedItem) {
DS.link(definition.name, injectedItem[definition.idAttribute], [relationName]);
});
} else {
DS.link(definition.name, injected[definition.idAttribute], [relationName]);
}
}
}
defs.forEach(function (def) {
if (DS.utils.isArray(injected)) {
DS.utils.forEach(injected, function (injectedI) {
_process(def, injectedI);
});
} else {
_process(def, injected);
}
DS.utils.forEach(definition.relationList, function (def) {
if (DS.utils.isArray(injected)) {
DS.utils.forEach(injected, function (injectedI) {
_process(def, def.relation, injectedI);
});
});
} else {
_process(def, def.relation, injected);
}
});

@@ -215,3 +229,6 @@ }

*
* - `{boolean=}` - `findBelongsTo` - Find and attach any existing "belongsTo" relationships to the newly injected item. Default: `true`.
* - `{boolean=}` - `findBelongsTo` - Find and attach any existing "belongsTo" relationships to the newly injected item. Potentially expensive if enabled. Default: `false`.
* - `{boolean=}` - `findHasMany` - Find and attach any existing "hasMany" relationships to the newly injected item. Potentially expensive if enabled. Default: `false`.
* - `{boolean=}` - `findHasOne` - Find and attach any existing "hasOne" relationships to the newly injected item. Potentially expensive if enabled. Default: `false`.
* - `{boolean=}` - `linkInverse` - Look in the data store for relations of the injected item(s) and update their links to the injected. Potentially expensive if enabled. Default: `false`.
*

@@ -224,6 +241,7 @@ * @returns {object|array} A reference to the item that was injected into the data store or an array of references to

var IA = DS.errors.IA;
var definition = DS.definitions[resourceName];
options = options || {};
if (!DS.definitions[resourceName]) {
if (!definition) {
throw new DS.errors.NER(errorPrefix(resourceName) + resourceName);

@@ -235,23 +253,39 @@ } else if (!DS.utils.isObject(attrs) && !DS.utils.isArray(attrs)) {

}
var definition = DS.definitions[resourceName];
var resource = DS.store[resourceName];
var injected;
if (!('findBelongsTo' in options)) {
options.findBelongsTo = true;
}
stack++;
if (!DS.$rootScope.$$phase) {
DS.$rootScope.$apply(function () {
try {
if (!DS.$rootScope.$$phase) {
DS.$rootScope.$apply(function () {
injected = _inject.call(DS, definition, resource, attrs);
});
} else {
injected = _inject.call(DS, definition, resource, attrs);
});
} else {
injected = _inject.call(DS, definition, resource, attrs);
}
if (definition.relations) {
_injectRelations.call(DS, definition, injected, options);
}
if (options.linkInverse) {
if (DS.utils.isArray(injected) && injected.length) {
DS.linkInverse(definition.name, injected[0][definition.idAttribute]);
} else {
DS.linkInverse(definition.name, injected[definition.idAttribute]);
}
}
DS.notify(definition, 'inject', injected);
stack--;
} catch (err) {
stack--;
throw err;
}
if (definition.relations) {
_injectRelations.call(DS, definition, injected, options);
if (!stack) {
data.injectedSoFar = {};
}
DS.notify(definition, 'inject', injected);
return injected;

@@ -258,0 +292,0 @@ }

@@ -9,3 +9,3 @@ (function (window, angular, undefined) {

* @description
* __Version:__ 1.0.0-beta.1
* __Version:__ 1.0.0-beta.2
*

@@ -56,6 +56,11 @@ * ## Install

$delegate.promisify = function (fn, target) {
var _this = this;
if (!fn) {
return;
} else if (typeof fn !== 'function') {
throw new Error('Can only promisify functions!');
}
var $q = this;
return function () {
var deferred = _this.defer(),
args = Array.prototype.slice.apply(arguments);
var deferred = $q.defer();
var args = Array.prototype.slice.apply(arguments);

@@ -62,0 +67,0 @@ args.push(function (err, result) {

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

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