angular-data
Advanced tools
Comparing version 0.10.0-beta.1 to 0.10.0-beta.2
@@ -0,1 +1,12 @@ | ||
##### 0.10.0-beta.2 - 10 July 2014 | ||
###### Backwards compatible API changes | ||
- #89 - Added the `cacheResponse` option to `DS.create` and `DS.save` | ||
###### Backwards compatible bug fixes | ||
- #87 - Filter where boolean values | ||
###### Other | ||
- #88 - Fixed guide documentation for the simple default `where` filter | ||
##### 0.10.0-beta.1 - 28 June 2014 | ||
@@ -2,0 +13,0 @@ |
/** | ||
* @author Jason Dobry <jason.dobry@gmail.com> | ||
* @file angular-data.min.js | ||
* @version 0.10.0-beta.1 - Homepage <http://angular-data.pseudobry.com/> | ||
* @version 0.10.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(a,b,c){(function(){!function(a){"use strict";function b(){function a(a){"splice"===a[0].type&&"splice"===a[1].type&&(b=!0)}if("function"!=typeof Object.observe||"function"!=typeof Array.observe)return!1;var b=!1,c=[0];return Array.observe(c,a),c[1]=1,c.length=0,Object.deliverChangeRecords(a),b}function c(a){return a===Object(a)}function d(a){for(var b=0;s>b&&a.check();)a.report(),b++}function e(a){for(var b in a)return!1;return!0}function f(a){return e(a.added)&&e(a.removed)&&e(a.changed)}function g(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 h(a,b){var c=b||(Array.isArray(a)?[]:{});for(var d in a)c[d]=a[d];return Array.isArray(a)&&(c.length=a.length),c}function i(a,b,c,d){if(this.closed=!1,this.object=a,this.callback=b,this.target=c,this.token=d,this.reporting=!0,n){var e=this;this.boundInternalCallback=function(a){e.internalCallback(a)}}j(this),this.connect(),this.sync(!0)}function j(a){u&&(t.push(a),i._allObserversCount++)}function k(a,b,c,d){i.call(this,a,b,c,d)}function l(a){this.arr=[],this.callback=a,this.isObserved=!0}function m(a,b,c){for(var d={},e={},f=0;f<b.length;f++){var g=b[f];z[g.type]?(g.name in c||(c[g.name]=g.oldValue),"updated"!=g.type&&("new"!=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 n=b(),o=!1;try{var p=new Function("","return true;");o=p()}catch(q){}var r=(a.Number.isNaN||function(b){return"number"==typeof b&&a.isNaN(b)},"__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}),s=1e3;i.prototype={internalCallback:function(a){this.closed||this.reporting&&this.check(a)&&(this.report(),this.testingResults&&(this.testingResults.anyChanged=!0))},close:function(){this.closed||(this.object&&"function"==typeof this.object.unobserved&&this.object.unobserved(),this.disconnect(),this.object=void 0,this.closed=!0)},deliver:function(a){this.closed||(n?(this.testingResults=a,Object.deliverChangeRecords(this.boundInternalCallback),this.testingResults=void 0):d(this))},report:function(){this.reporting&&(this.sync(!1),this.reportArgs.push(this.token),this.invokeCallback(this.reportArgs),this.reportArgs=void 0)},invokeCallback:function(a){try{this.callback.apply(this.target,a)}catch(b){i._errorThrownDuringCallback=!0,console.error("Exception caught during observer callback: "+b)}},reset:function(){this.closed||(n&&(this.reporting=!1,Object.deliverChangeRecords(this.boundInternalCallback),this.reporting=!0),this.sync(!0))}};var t,u=!n||a.forceCollectObservers;i._allObserversCount=0,u&&(t=[]);var v=!1,w="function"==typeof Object.deliverAllChangeRecords;a.Platform=a.Platform||{},a.Platform.performMicrotaskCheckpoint=function(){if(!v){if(w)return void Object.deliverAllChangeRecords();if(u){v=!0;var a=0,b={};do{a++;var c=t;t=[],b.anyChanged=!1;for(var d=0;d<c.length;d++){var e=c[d];e.closed||(n?e.deliver(b):e.check()&&(b.anyChanged=!0,e.report()),t.push(e))}}while(s>a&&b.anyChanged);i._allObserversCount=t.length,v=!1}}},u&&(a.Platform.clearObservers=function(){t=[]}),k.prototype=r({__proto__:i.prototype,connect:function(){n&&Object.observe(this.object,this.boundInternalCallback)},sync:function(){n||(this.oldObject=h(this.object))},check:function(a){var b,c;if(n){if(!a)return!1;c={},b=m(this.object,a,c)}else c=this.oldObject,b=g(this.object,this.oldObject);return f(b)?!1:(this.reportArgs=[b.added||{},b.removed||{},b.changed||{}],this.reportArgs.push(function(a){return c[a]}),!0)},disconnect:function(){n?this.object&&Object.unobserve(this.object,this.boundInternalCallback):this.oldObject=void 0}});var x=Object.getPrototypeOf({}),y=Object.getPrototypeOf([]);l.prototype={reset:function(){this.isObserved=!this.isObserved},observe:function(a){if(c(a)&&a!==x&&a!==y){var b=this.arr.indexOf(a);b>=0&&this.arr[b+1]===this.isObserved||(0>b&&(b=this.arr.length,this.arr[b]=a,Object.observe(a,this.callback)),this.arr[b+1]=this.isObserved,this.observe(Object.getPrototypeOf(a)))}},cleanup:function(){for(var a=0,b=0,c=this.isObserved;b<this.arr.length;){var d=this.arr[b];this.arr[b+1]==c?(b>a&&(this.arr[a]=d,this.arr[a+1]=c),a+=2):Object.unobserve(d,this.callback),b+=2}this.arr.length=a}};var z={"new":!0,updated:!0,deleted:!0};a.Observer=i,a.Observer.hasObjectObserve=n,a.ObjectObserver=k}((c.Number={isNaN:window.isNaN})?c:c)}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],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":15}],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":20,"./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":16}],14:[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":23,"./isArray":13}],15:[function(a,b){function c(a){return d(a,"Function")}var d=a("./isKind");b.exports=c},{"./isKind":16}],16:[function(a,b){function c(a,b){return d(a)===b}var d=a("./kindOf");b.exports=c},{"./kindOf":18}],17:[function(a,b){function c(a){return!!a&&"object"==typeof a&&a.constructor===Object}b.exports=c},{}],18:[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},{}],19:[function(a,b){function c(a){return null==a?"":a.toString()}b.exports=c},{}],20:[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":23}],21:[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":17,"./forOwn":23}],22:[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":24}],23:[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":22,"./hasOwn":24}],24:[function(a,b){function c(a,b){return Object.prototype.hasOwnProperty.call(a,b)}b.exports=c},{}],25:[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}],26:[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}],27:[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":25}],28:[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}],29:[function(a,b){function c(a){return a=d(a),a.toUpperCase()}var d=a("../lang/toString");b.exports=c},{"../lang/toString":19}],30:[function(a,b){function c(){var a=this.defaults={queryTransform:function(a,b){return b}};this.$get=["$http","$log","DSUtils",function(b,c,d){function e(a){var d=(new Date).getTime();return b(a).then(function(a){return c.debug(a.config.method+" request:"+a.config.url+" Time taken: "+((new Date).getTime()-d)+"ms",arguments),a})}function f(a,b){return b=b||{},e(d.deepMixIn(b,{url:a,method:"GET"}))}function g(a,b,c){return c=c||{},e(d.deepMixIn(c,{url:a,data:b,method:"POST"}))}function h(a,b,c){return c=c||{},e(d.deepMixIn(c,{url:a,data:b,method:"PUT"}))}function i(a,b){return b=b||{},this.HTTP(d.deepMixIn(b,{url:a,method:"DELETE"}))}function j(a,b,c){return c=c||{},this.POST(d.makePath(c.baseUrl||a.baseUrl,a.endpoint),b,c)}function k(a,b,c){return c=c||{},this.DEL(d.makePath(c.baseUrl||a.baseUrl,a.endpoint,b),c)}function l(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.endpoint),e)}function m(a,b,c){return c=c||{},this.GET(d.makePath(c.baseUrl||a.baseUrl,a.endpoint,b),c)}function n(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.endpoint),e)}function o(a,b,c,e){return e=e||{},this.PUT(d.makePath(e.baseUrl||a.baseUrl,a.endpoint,b),c,e)}function p(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.endpoint),c,f)}return{defaults:a,HTTP:e,GET:f,POST:g,PUT:h,DEL:i,find:m,findAll:n,create:j,update:o,updateAll:p,destroy:k,destroyAll:l}}]}b.exports=c},{}],31:[function(a,b){function c(){this.$get=["$q","DSUtils",function(a,b){function c(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}function d(c,d){var e=a.defer();try{var f=localStorage.getItem(c);f?(f=angular.fromJson(f),b.deepMixIn(f,d),e.resolve(localStorage.setItem(c,angular.toJson(f)))):e.resolve(localStorage.setItem(c,angular.toJson(d)))}catch(g){e.reject(g)}return e.promise}function e(b){var c=a.defer();try{c.resolve(localStorage.removeItem(b))}catch(d){c.reject(d)}return c.promise}function f(a,c,d){return d=d||{},e(b.makePath(d.baseUrl||a.baseUrl,a.endpoint,c),d)}function g(a,d,e){return e=e||{},c(b.makePath(e.baseUrl||a.baseUrl,a.endpoint,d),e)}function h(a,e,f,g){return g=g||{},d(b.makePath(g.baseUrl||a.baseUrl,a.endpoint,e),f,g).then(function(){return c(b.makePath(g.baseUrl||a.baseUrl,a.endpoint,e))})}return{find:g,findAll:function(){throw new Error("Not supported!")},create:function(){throw new Error("Not supported!")},update:h,updateAll:function(){throw new Error("Not supported!")},destroy:f,destroyAll:function(){throw new Error("Not supported!")}}}]}b.exports=c},{}],32:[function(a,b){function c(a,b,c){var e=this.$q.defer(),f=e.promise;try{if(c=c||{},!this.definitions[a])throw new this.errors.NER(d+a);if(!this.utils.isObject(b))throw new this.errors.IA(d+"attrs: Must be an object!");var g=this.definitions[a],h=this.store[a],i=this;f=f.then(function(b){return i.$q.promisify(g.beforeValidate)(a,b)}).then(function(b){return i.$q.promisify(g.validate)(a,b)}).then(function(b){return i.$q.promisify(g.afterValidate)(a,b)}).then(function(b){return i.$q.promisify(g.beforeCreate)(a,b)}).then(function(b){return i.adapters[c.adapter||g.defaultAdapter].create(g,g.serialize(a,b),c)}).then(function(b){return i.$q.promisify(g.afterCreate)(a,g.deserialize(a,b))}).then(function(a){var b=i.inject(g.name,a),c=b[g.idAttribute];return h.previousAttributes[c]=i.utils.deepMixIn({},b),h.saved[c]=i.utils.updateTimestamp(h.saved[c]),i.get(g.name,c)}),e.resolve(b)}catch(j){e.reject(j)}return f}var d="DS.create(resourceName, attrs[, options]): ";b.exports=c},{}],33:[function(a,b){function c(a,b,c){var e=this.$q.defer(),f=e.promise;try{if(c=c||{},!this.definitions[a])throw new this.errors.NER(d+a);if(!this.utils.isString(b)&&!this.utils.isNumber(b))throw new this.errors.IA(d+"id: Must be a string or a number!");var g=this.get(a,b);if(!g)throw new this.errors.R(d+'id: "'+b+'" not found!');var h=this.definitions[a],i=this;f=f.then(function(b){return i.$q.promisify(h.beforeDestroy)(a,b)}).then(function(){return i.adapters[c.adapter||h.defaultAdapter].destroy(h,b,c)}).then(function(){return i.$q.promisify(h.afterDestroy)(a,g)}).then(function(){return i.eject(a,b),b}),e.resolve(g)}catch(j){e.reject(j)}return f}var d="DS.destroy(resourceName, id): ";b.exports=c},{}],34:[function(a,b){function c(a,b,c){var e=this.$q.defer(),f=e.promise;try{var g=this,h=this.errors.IA;if(c=c||{},!this.definitions[a])throw new this.errors.NER(d+a);if(!this.utils.isObject(b))throw new h(d+"params: Must be an object!");if(!this.utils.isObject(c))throw new h(d+"options: Must be an object!");var i=this.definitions[a];f=f.then(function(){return g.adapters[c.adapter||i.defaultAdapter].destroyAll(i,b,c)}).then(function(){return g.ejectAll(a,b)}),e.resolve()}catch(j){e.reject(j)}return f}var d="DS.destroyAll(resourceName, params[, options]): ";b.exports=c},{}],35:[function(a,b){function c(a,b,c){var e=this.$q.defer(),f=e.promise;try{var g=this.errors.IA;if(c=c||{},!this.definitions[a])throw new this.errors.NER(d+a);if(!this.utils.isString(b)&&!this.utils.isNumber(b))throw new g(d+"id: Must be a string or a number!");if(!this.utils.isObject(c))throw new g(d+"options: Must be an object!");c.cacheResponse="cacheResponse"in c?!!c.cacheResponse:!0;var h=this.definitions[a],i=this.store[a],j=this;if(c.bypassCache&&delete i.completedQueries[b],!(b in i.completedQueries))return b in i.pendingQueries||(f=i.pendingQueries[b]=j.adapters[c.adapter||h.defaultAdapter].find(h,b,c).then(function(d){var e=h.deserialize(a,d);return c.cacheResponse?(delete i.pendingQueries[b],i.completedQueries[b]=(new Date).getTime(),j.inject(a,e)):e},function(a){return delete i.pendingQueries[b],j.$q.reject(a)})),i.pendingQueries[b];e.resolve(j.get(a,b))}catch(k){e.reject(k)}return f}var d="DS.find(resourceName, id[, options]): ";b.exports=c},{}],36:[function(a,b){function c(a,b,c,d){var e=this.store[c];return b=b||[],delete e.pendingQueries[d],e.completedQueries[d]=(new Date).getTime(),e.collectionModified=a.updateTimestamp(e.collectionModified),this.inject(c,b)}function d(a,b,d,e){var f=this.definitions[b],g=this.store[b],h=this,i=a.toJson(d);return e.bypassCache&&delete g.completedQueries[i],i in g.completedQueries?this.filter(b,d,e):(i in g.pendingQueries||(g.pendingQueries[i]=h.adapters[e.adapter||f.defaultAdapter].findAll(f,d,e).then(function(d){var g=f.deserialize(b,d);if(!e.cacheResponse)return g;try{return c.apply(h,[a,g,b,i])}catch(j){return h.$q.reject(j)}},function(a){return delete g.pendingQueries[i],h.$q.reject(a)})),g.pendingQueries[i])}function e(a,b,c){var e=this.$q.defer(),g=e.promise;try{var h=this.errors.IA,i=this;if(c=c||{},b=b||{},!this.definitions[a])throw new this.errors.NER(f+a);if(!this.utils.isObject(b))throw new h(f+"params: Must be an object!");if(!this.utils.isObject(c))throw new h(f+"options: Must be an object!");c.cacheResponse="cacheResponse"in c?!!c.cacheResponse:!0,g=g.then(function(){return d.apply(i,[i.utils,a,b,c])}),e.resolve()}catch(j){e.reject(j)}return g}var f="DS.findAll(resourceName, params[, options]): ";b.exports=e},{}],37:[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":32,"./destroy":33,"./destroyAll":34,"./find":35,"./findAll":36,"./loadRelations":38,"./refresh":39,"./save":40,"./update":41,"./updateAll":42}],38:[function(a,b){function c(a,b,c,e){var f=this.$q.defer(),g=f.promise;try{var h=this.errors.IA;if(e=e||{},(angular.isString(b)||angular.isNumber(b))&&(b=this.get(a,b)),angular.isString(c)&&(c=[c]),!this.definitions[a])throw new this.errors.NER(d+a);if(!this.utils.isObject(b))throw new h(d+"instance(Id): Must be a string, number or object!");if(!this.utils.isArray(c))throw new h(d+"relations: Must be a string or an array!");if(!this.utils.isObject(e))throw new h(d+"options: Must be an object!");var i=this.definitions[a],j=this,k=[],l=[];j.utils.forOwn(i.relations,function(a,d){j.utils.forOwn(a,function(a,f){if(j.utils.contains(c,f)){var g,h={};h[a.foreignKey]=b[i.idAttribute],"hasMany"===d?g=j.findAll(f,h,e):"hasOne"===d?a.localKey&&b[a.localKey]?g=j.find(f,b[a.localKey],e):a.foreignKey&&(g=j.findAll(f,h,e)):g=j.find(f,b[a.localKey],e),g&&(k.push(g),l.push(a.localField))}})}),g=g.then(function(){return j.$q.all(k)}).then(function(a){return angular.forEach(l,function(c,d){b[c]=a[d]}),b}),f.resolve()}catch(m){f.reject(m)}return g}var d="DS.loadRelations(resourceName, instance(Id), relations[, options]): ";b.exports=c},{}],39:[function(a,b){function c(a,b,c){var e=this.errors.IA;if(c=c||{},this.definitions[a]){if(this.utils.isString(b)||this.utils.isNumber(b)){if(this.utils.isObject(c))return c.bypassCache=!0,this.get(a,b)?this.find(a,b,c):!1;throw new e(d+"options: Must be an object!")}throw new e(d+"id: Must be a string or a number!")}throw new this.errors.NER(d+a)}var d="DS.refresh(resourceName, id[, options]): ";b.exports=c},{}],40:[function(a,b){function c(a,b,c){var e=this.$q.defer(),f=e.promise;try{var g=this.errors.IA;if(c=c||{},!this.definitions[a])throw new this.errors.NER(d+a);if(!this.utils.isString(b)&&!this.utils.isNumber(b))throw new g(d+"id: Must be a string or a number!");if(!this.utils.isObject(c))throw new g(d+"options: Must be an object!");var h=this.get(a,b);if(!h)throw new this.errors.R(d+'id: "'+b+'" not found!');var i=this.definitions[a],j=this.store[a],k=this;f=f.then(function(b){return k.$q.promisify(i.beforeValidate)(a,b)}).then(function(b){return k.$q.promisify(i.validate)(a,b)}).then(function(b){return k.$q.promisify(i.afterValidate)(a,b)}).then(function(b){return k.$q.promisify(i.beforeUpdate)(a,b)}).then(function(d){if(c.changesOnly){j.observers[b].deliver();var e=[],f=k.changes(a,b);for(var g in f.added)e.push(g);for(g in f.changed)e.push(g);if(f=k.utils.pick(d,e),k.utils.isEmpty(f))return d;d=f}return k.adapters[c.adapter||i.defaultAdapter].update(i,b,i.serialize(a,d),c)}).then(function(b){return k.$q.promisify(i.afterUpdate)(a,i.deserialize(a,b))}).then(function(d){return k.inject(i.name,d,c),j.previousAttributes[b]=k.utils.deepMixIn({},d),j.saved[b]=k.utils.updateTimestamp(j.saved[b]),k.get(a,b)}),e.resolve(h)}catch(l){e.reject(l)}return f}var d="DS.save(resourceName, id[, options]): ";b.exports=c},{}],41:[function(a,b){function c(a,b,c,e){var f=this.$q.defer(),g=f.promise;try{var h=this.errors.IA;if(e=e||{},!this.definitions[a])throw new this.errors.NER(d+a);if(!this.utils.isString(b)&&!this.utils.isNumber(b))throw new h(d+"id: Must be a string or a number!");if(!this.utils.isObject(c))throw new h(d+"attrs: Must be an object!");if(!this.utils.isObject(e))throw new h(d+"options: Must be an object!");var i=this.definitions[a],j=this.store[a],k=this;e.cacheResponse="cacheResponse"in e?!!e.cacheResponse:!0,g=g.then(function(b){return k.$q.promisify(i.beforeValidate)(a,b)}).then(function(b){return k.$q.promisify(i.validate)(a,b)}).then(function(b){return k.$q.promisify(i.afterValidate)(a,b)}).then(function(b){return k.$q.promisify(i.beforeUpdate)(a,b)}).then(function(c){return k.adapters[e.adapter||i.defaultAdapter].update(i,b,i.serialize(a,c),e)}).then(function(b){return k.$q.promisify(i.afterUpdate)(a,i.deserialize(a,b))}).then(function(a){if(e.cacheResponse){var b=k.inject(i.name,a,e),c=b[i.idAttribute];return j.previousAttributes[c]=k.utils.deepMixIn({},b),j.saved[c]=k.utils.updateTimestamp(j.saved[c]),k.get(i.name,c)}return a}),f.resolve(c)}catch(l){f.reject(l)}return g}var d="DS.update(resourceName, id, attrs[, options]): ";b.exports=c},{}],42:[function(a,b){function c(a,b,c,e){var f=this.$q.defer(),g=f.promise;try{var h=this.errors.IA;if(e=e||{},!this.definitions[a])throw new this.errors.NER(d+a);if(!this.utils.isObject(b))throw new h(d+"attrs: Must be an object!");if(!this.utils.isObject(c))throw new h(d+"params: Must be an object!");if(!this.utils.isObject(e))throw new h(d+"options: Must be an object!");var i=this.definitions[a],j=this;e.cacheResponse="cacheResponse"in e?!!e.cacheResponse:!0,g=g.then(function(b){return j.$q.promisify(i.beforeValidate)(a,b)}).then(function(b){return j.$q.promisify(i.validate)(a,b)}).then(function(b){return j.$q.promisify(i.afterValidate)(a,b)}).then(function(b){return j.$q.promisify(i.beforeUpdate)(a,b)}).then(function(b){return j.adapters[e.adapter||i.defaultAdapter].updateAll(i,i.serialize(a,b),c,e)}).then(function(b){return j.$q.promisify(i.afterUpdate)(a,i.deserialize(a,b))}).then(function(a){return e.cacheResponse?j.inject(i.name,a,e):a}),f.resolve(b)}catch(k){f.reject(k)}return g}var d="DS.updateAll(resourceName, attrs, params[, options]): ";b.exports=c},{}],43:[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={$rootScope:c,$log:d,$q:e,cacheFactory:j,defaults:b,store:{},definitions:{},adapters:{DSHttpAdapter:f,DSLocalStorageAdapter:g},errors:i,utils:h};h.deepFreeze(k),h.deepFreeze(l),h.deepMixIn(n,k),h.deepMixIn(n,l),h.deepFreeze(n.errors),h.deepFreeze(n.utils);var o=c.$new();return o.$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.filter=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)&&(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.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},b.exports=e},{"../utils":61,"./async_methods":37,"./sync_methods":54}],44:[function(a,b){function c(a,b,c,e,f){var g=this.errors.IA;if(!this.utils.isObject(a))throw new g(d+"scope: Must be an object!");if(!this.utils.isString(b))throw new g(d+"expr: Must be a string!");if(!this.definitions[c])throw new this.errors.NER(d+c);if(!this.utils.isObject(e))throw new g(d+"params: Must be an object!");var h=this;try{return a.$watch(function(){return h.lastModified(c)},function(){var d=h.filter(c,e);h.utils.set(a,b,d),f&&f(null,d)})}catch(i){if(!f)throw i;f(i)}}var d="DS.bindAll(scope, expr, resourceName, params[, cb]): ";b.exports=c},{}],45:[function(a,b){function c(a,b,c,e,f){var g=this.errors.IA;if(!this.utils.isObject(a))throw new g(d+"scope: Must be an object!");if(!this.utils.isString(b))throw new g(d+"expr: Must be a string!");if(!this.definitions[c])throw new this.errors.NER(d+c);if(!this.utils.isString(e)&&!this.utils.isNumber(e))throw new g(d+"id: Must be a string or a number!");var h=this;try{return a.$watch(function(){return h.lastModified(c,e)},function(){var d=h.get(c,e);h.utils.set(a,b,d),f&&f(null,d)})}catch(i){if(!f)throw i;f(i)}}var d="DS.bindOne(scope, expr, resourceName, id[, cb]): ";b.exports=c},{}],46:[function(a,b){function c(a,b){if(!this.definitions[a])throw new this.errors.NER(d+a);if(!this.utils.isString(b)&&!this.utils.isNumber(b))throw new this.errors.IA(d+"id: Must be a string or a number!");var c=this.get(a,b);return c?(this.store[a].observers[b].deliver(),this.utils.diffObjectFromOldObject(c,this.store[a].previousAttributes[b])):void 0}var d="DS.changes(resourceName, id): ";b.exports=c},{}],47:[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 IA=this.errors.IA;if(this.utils.isString(definition)&&(definition={name:definition}),!this.utils.isObject(definition))throw new IA(errorPrefix+"definition: Must be an object!");if(!this.utils.isString(definition.name))throw new IA(errorPrefix+"definition.name: Must be a string!");if(definition.idAttribute&&!this.utils.isString(definition.idAttribute))throw new IA(errorPrefix+"definition.idAttribute: Must be a string!");if(definition.endpoint&&!this.utils.isString(definition.endpoint))throw new IA(errorPrefix+"definition.endpoint: Must be a string!");if(this.store[definition.name])throw new this.errors.R(errorPrefix+definition.name+" is already registered!");try{Resource.prototype=this.defaults,this.definitions[definition.name]=new Resource(this.utils,definition);var _this=this,def=this.definitions[definition.name],cache=this.cacheFactory("DS."+def.name,{maxAge:def.maxAge||null,recycleFreq:def.recycleFreq||1e3,cacheFlushInterval:def.cacheFlushInterval||null,deleteOnExpire:def.deleteOnExpire||"none",onExpire:function(a){_this.eject(def.name,a)},capacity:Number.MAX_VALUE,storageMode:"memory",storageImpl:null,disabled:!1,storagePrefix:"DS."+def.name});def.methods&&(def.class=definition.name[0].toUpperCase()+definition.name.substring(1),eval("function "+def.class+"() {}"),def[def.class]=eval(def.class),this.utils.deepMixIn(def[def.class].prototype,def.methods)),def.computed&&this.utils.forOwn(def.computed,function(a,b){def.methods&&b in def.methods&&_this.$log.warn(errorPrefix+'Computed property "'+b+'" conflicts with previously defined prototype method!');var c=a.toString().match(/function.*?\(([\s\S]*?)\)/),d=c[1].split(",");a.deps=_this.utils.filter(d,function(a){return!!a}),angular.forEach(a.deps,function(b,c){a.deps[c]=b.trim()})}),this.store[def.name]={collection:[],completedQueries:{},pendingQueries:{},index:cache,modified:{},saved:{},previousAttributes:{},observers:{},collectionModified:0}}catch(err){throw delete this.definitions[definition.name],delete this.store[definition.name],err}}var errorPrefix="DS.defineResource(definition): ";module.exports=defineResource},{}],48:[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}],49:[function(a,b){function c(a,b,c){for(var d=!1,e=0;e<b.collection.length;e++)if(b.collection[e][a.idAttribute]==c){d=!0;break}d&&(b.collection.splice(e,1),b.observers[c].close(),delete b.observers[c],b.index.remove(c),delete b.previousAttributes[c],delete b.modified[c],delete b.saved[c])}function d(a,b){if(!this.definitions[a])throw new this.errors.NER(e+a);if(!this.utils.isString(b)&&!this.utils.isNumber(b))throw new this.errors.IA(e+"id: Must be a string or a number!"); | ||
var d=this.store[a],f=this;this.$rootScope.$$phase?(c(f.definitions[a],d,b),d.collectionModified=f.utils.updateTimestamp(d.collectionModified)):this.$rootScope.$apply(function(){c(f.definitions[a],d,b),d.collectionModified=f.utils.updateTimestamp(d.collectionModified)}),delete this.store[a].completedQueries[b]}var e="DS.eject(resourceName, id): ";b.exports=d},{}],50:[function(a,b){function c(a,b,c){var d=this.utils.toJson(c),e=this.filter(a.name,c),f=this.utils.toLookup(e,a.idAttribute),g=this;angular.forEach(f,function(b,c){g.eject(a.name,c)}),delete b.completedQueries[d]}function d(a,b){if(b=b||{},!this.definitions[a])throw new this.errors.NER(e+a);if(!this.utils.isObject(b))throw new this.errors.IA(e+"params: Must be an object!");var d=this,f=this.store[a],g=this.utils.toJson(b);delete f.completedQueries[g],this.utils.isEmpty(b)&&(f.completedQueries={}),this.$rootScope.$$phase?(c.apply(d,[d.definitions[a],f,b]),f.collectionModified=this.utils.updateTimestamp(f.collectionModified)):this.$rootScope.$apply(function(){c.apply(d,[d.definitions[a],f,b]),f.collectionModified=d.utils.updateTimestamp(f.collectionModified)})}var e="DS.ejectAll(resourceName[, params]): ";b.exports=d},{}],51:[function(a,b){function c(a,b,c){var e=this.errors.IA;if(c=c||{},!this.definitions[a])throw new this.errors.NER(d+a);if(b&&!this.utils.isObject(b))throw new e(d+"params: Must be an object!");if(!this.utils.isObject(c))throw new e(d+"options: Must be an object!");var f=this.definitions[a],g=this.store[a];b=b||{},c.allowSimpleWhere="allowSimpleWhere"in c?!!c.allowSimpleWhere:!0;var h=this.utils.toJson(b);return h in g.completedQueries||!c.loadFromServer||g.pendingQueries[h]||this.findAll(a,b,c),f.filter.call(this,g.collection,a,b,c)}var d="DS.filter(resourceName[, params][, options]): ";b.exports=c},{}],52:[function(a,b){function c(a,b,c){var e=this.errors.IA;if(c=c||{},!this.definitions[a])throw new this.errors.NER(d+a);if(!this.utils.isString(b)&&!this.utils.isNumber(b))throw new e(d+"id: Must be a string or a number!");if(!this.utils.isObject(c))throw new e(d+"options: Must be an object!");var f=this,g=this.store[a].index.get(b);return!g&&c.loadFromServer&&this.find(a,b).then(null,function(a){return f.$q.reject(a)}),g}var d="DS.get(resourceName, id[, options]): ";b.exports=c},{}],53:[function(a,b){function c(a,b){return!(a.isEmpty(b.added)&&a.isEmpty(b.removed)&&a.isEmpty(b.changed))}function d(a,b){if(!this.definitions[a])throw new this.errors.NER(e+a);if(!this.utils.isString(b)&&!this.utils.isNumber(b))throw new this.errors.IA(e+"id: Must be a string or a number!");return this.get(a,b)?c(this.utils,this.changes(a,b)):!1}var e="DS.hasChanges(resourceName, id): ";b.exports=d},{}],54:[function(a,b){b.exports={defineResource:a("./defineResource"),bindOne:a("./bindOne"),bindAll:a("./bindAll"),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":44,"./bindOne":45,"./changes":46,"./defineResource":47,"./digest":48,"./eject":49,"./ejectAll":50,"./filter":51,"./get":52,"./hasChanges":53,"./inject":55,"./lastModified":56,"./lastSaved":57,"./previous":58}],55:[function(a,b){function c(a,b,d){function e(c,d,e,f){var g=f(a.idAttribute);if(b.modified[g]=i.utils.updateTimestamp(b.modified[g]),b.collectionModified=i.utils.updateTimestamp(b.collectionModified),a.computed){var h=i.get(a.name,g);i.utils.forOwn(a.computed,function(a,b){var c=!1;if(angular.forEach(a.deps,function(a){(a in e||a in d||a in e||!(b in h))&&(c=!0)}),c){var f=[];angular.forEach(a.deps,function(a){f.push(h[a])}),h[b]=a.apply(h,f)}})}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(d)){h=[];for(var k=0;k<d.length;k++)h.push(c.call(i,a,b,d[k]))}else{if(a.computed&&a.computed[a.idAttribute]){var l=[];angular.forEach(a.computed[a.idAttribute].deps,function(a){l.push(d[a])}),d[a.idAttribute]=a.computed[a.idAttribute].apply(d,l)}if(!(a.idAttribute in d))throw new i.errors.R(g+"attrs: Must contain the property specified by `idAttribute`!");try{a.beforeInject(a.name,d);var m=d[a.idAttribute],n=this.get(a.name,m);n?(i.utils.deepMixIn(n,d),"function"==typeof b.index.touch?b.index.touch(m):b.index.put(m,b.index.get(m)),b.observers[m].deliver()):(n=a.class?d instanceof a[a.class]?d:new a[a.class]:{},b.previousAttributes[m]={},i.utils.deepMixIn(n,d),i.utils.deepMixIn(b.previousAttributes[m],d),b.collection.push(n),b.observers[m]=new f.ObjectObserver(n,e),b.index.put(m,n),e({},{},{},function(){return m})),b.saved[m]=i.utils.updateTimestamp(b.saved[m]),a.afterInject(a.name,n),h=n}catch(o){j.error(o),j.error("inject failed!",a.name,d)}}return h}function d(a,b){var c=this;c.utils.forOwn(a.relations,function(a,d){c.utils.forOwn(a,function(a,e){if(c.definitions[e]&&b[a.localField])try{b[a.localField]=c.inject(e,b[a.localField])}catch(f){c.$log.error(g+"Failed to inject "+d+' relation: "'+e+'"!',f)}})})}function e(a,b,e){var f=this.errors.IA;if(e=e||{},!this.definitions[a])throw new this.errors.NER(g+a);if(!this.utils.isObject(b)&&!this.utils.isArray(b))throw new f(g+"attrs: Must be an object or an array!");if(!this.utils.isObject(e))throw new f(g+"options: Must be an object!");var h,i=this.definitions[a],j=this.store[a],k=this;return this.$rootScope.$$phase?h=c.call(k,i,j,b):this.$rootScope.$apply(function(){h=c.call(k,i,j,b)}),i.relations&&d.call(k,i,h),h}var f=a("../../../lib/observe-js/observe-js"),g="DS.inject(resourceName, attrs[, options]): ";b.exports=e},{"../../../lib/observe-js/observe-js":1}],56:[function(a,b){function c(a,b){if(!this.definitions[a])throw new this.errors.NER(d+a);if(b&&!this.utils.isString(b)&&!this.utils.isNumber(b))throw new this.errors.IA(d+"id: Must be a string or a number!");return b?(b in this.store[a].modified||(this.store[a].modified[b]=0),this.store[a].modified[b]):this.store[a].collectionModified}var d="DS.lastModified(resourceName[, id]): ";b.exports=c},{}],57:[function(a,b){function c(a,b){if(!this.definitions[a])throw new this.errors.NER(d+a);if(!this.utils.isString(b)&&!this.utils.isNumber(b))throw new this.errors.IA(d+"id: Must be a string or a number!");return b in this.store[a].saved||(this.store[a].saved[b]=0),this.store[a].saved[b]}var d="DS.lastSaved(resourceName[, id]): ";b.exports=c},{}],58:[function(a,b){function c(a,b){if(!this.definitions[a])throw new this.errors.NER(d+a);if(!this.utils.isString(b)&&!this.utils.isNumber(b))throw new this.errors.IA(d+"id: Must be a string or a number!");return angular.copy(this.store[a].previousAttributes[b])}var d="DS.previous(resourceName, id): ";b.exports=c},{}],59:[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}}]},{}],60:[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":30,"./adapters/localStorage":31,"./datastore":43,"./errors":59,"./utils":61}],61:[function(a,b){b.exports=[function(){return{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"),deepMixIn:a("mout/object/deepMixIn"),forOwn:a("mout/object/forOwn"),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/isEmpty":14,"mout/object/deepMixIn":21,"mout/object/forOwn":23,"mout/object/pick":26,"mout/object/set":27,"mout/string/makePath":28,"mout/string/upperCase":29}]},{},[60]); | ||
!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(a,b,c){(function(){!function(a){"use strict";function b(){function a(a){"splice"===a[0].type&&"splice"===a[1].type&&(b=!0)}if("function"!=typeof Object.observe||"function"!=typeof Array.observe)return!1;var b=!1,c=[0];return Array.observe(c,a),c[1]=1,c.length=0,Object.deliverChangeRecords(a),b}function c(a){return a===Object(a)}function d(a){for(var b=0;s>b&&a.check();)a.report(),b++}function e(a){for(var b in a)return!1;return!0}function f(a){return e(a.added)&&e(a.removed)&&e(a.changed)}function g(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 h(a,b){var c=b||(Array.isArray(a)?[]:{});for(var d in a)c[d]=a[d];return Array.isArray(a)&&(c.length=a.length),c}function i(a,b,c,d){if(this.closed=!1,this.object=a,this.callback=b,this.target=c,this.token=d,this.reporting=!0,n){var e=this;this.boundInternalCallback=function(a){e.internalCallback(a)}}j(this),this.connect(),this.sync(!0)}function j(a){u&&(t.push(a),i._allObserversCount++)}function k(a,b,c,d){i.call(this,a,b,c,d)}function l(a){this.arr=[],this.callback=a,this.isObserved=!0}function m(a,b,c){for(var d={},e={},f=0;f<b.length;f++){var g=b[f];z[g.type]?(g.name in c||(c[g.name]=g.oldValue),"updated"!=g.type&&("new"!=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 n=b(),o=!1;try{var p=new Function("","return true;");o=p()}catch(q){}var r=(a.Number.isNaN||function(b){return"number"==typeof b&&a.isNaN(b)},"__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}),s=1e3;i.prototype={internalCallback:function(a){this.closed||this.reporting&&this.check(a)&&(this.report(),this.testingResults&&(this.testingResults.anyChanged=!0))},close:function(){this.closed||(this.object&&"function"==typeof this.object.unobserved&&this.object.unobserved(),this.disconnect(),this.object=void 0,this.closed=!0)},deliver:function(a){this.closed||(n?(this.testingResults=a,Object.deliverChangeRecords(this.boundInternalCallback),this.testingResults=void 0):d(this))},report:function(){this.reporting&&(this.sync(!1),this.reportArgs.push(this.token),this.invokeCallback(this.reportArgs),this.reportArgs=void 0)},invokeCallback:function(a){try{this.callback.apply(this.target,a)}catch(b){i._errorThrownDuringCallback=!0,console.error("Exception caught during observer callback: "+b)}},reset:function(){this.closed||(n&&(this.reporting=!1,Object.deliverChangeRecords(this.boundInternalCallback),this.reporting=!0),this.sync(!0))}};var t,u=!n||a.forceCollectObservers;i._allObserversCount=0,u&&(t=[]);var v=!1,w="function"==typeof Object.deliverAllChangeRecords;a.Platform=a.Platform||{},a.Platform.performMicrotaskCheckpoint=function(){if(!v){if(w)return void Object.deliverAllChangeRecords();if(u){v=!0;var a=0,b={};do{a++;var c=t;t=[],b.anyChanged=!1;for(var d=0;d<c.length;d++){var e=c[d];e.closed||(n?e.deliver(b):e.check()&&(b.anyChanged=!0,e.report()),t.push(e))}}while(s>a&&b.anyChanged);i._allObserversCount=t.length,v=!1}}},u&&(a.Platform.clearObservers=function(){t=[]}),k.prototype=r({__proto__:i.prototype,connect:function(){n&&Object.observe(this.object,this.boundInternalCallback)},sync:function(){n||(this.oldObject=h(this.object))},check:function(a){var b,c;if(n){if(!a)return!1;c={},b=m(this.object,a,c)}else c=this.oldObject,b=g(this.object,this.oldObject);return f(b)?!1:(this.reportArgs=[b.added||{},b.removed||{},b.changed||{}],this.reportArgs.push(function(a){return c[a]}),!0)},disconnect:function(){n?this.object&&Object.unobserve(this.object,this.boundInternalCallback):this.oldObject=void 0}});var x=Object.getPrototypeOf({}),y=Object.getPrototypeOf([]);l.prototype={reset:function(){this.isObserved=!this.isObserved},observe:function(a){if(c(a)&&a!==x&&a!==y){var b=this.arr.indexOf(a);b>=0&&this.arr[b+1]===this.isObserved||(0>b&&(b=this.arr.length,this.arr[b]=a,Object.observe(a,this.callback)),this.arr[b+1]=this.isObserved,this.observe(Object.getPrototypeOf(a)))}},cleanup:function(){for(var a=0,b=0,c=this.isObserved;b<this.arr.length;){var d=this.arr[b];this.arr[b+1]==c?(b>a&&(this.arr[a]=d,this.arr[a+1]=c),a+=2):Object.unobserve(d,this.callback),b+=2}this.arr.length=a}};var z={"new":!0,updated:!0,deleted:!0};a.Observer=i,a.Observer.hasObjectObserve=n,a.ObjectObserver=k}((c.Number={isNaN:window.isNaN})?c:c)}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],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(){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}],30:[function(a,b){function c(a){return a=d(a),a.toUpperCase()}var d=a("../lang/toString");b.exports=c},{"../lang/toString":20}],31:[function(a,b){function c(){var a=this.defaults={queryTransform:function(a,b){return b}};this.$get=["$http","$log","DSUtils",function(b,c,d){function e(a){var d=(new Date).getTime();return b(a).then(function(a){return c.debug(a.config.method+" request:"+a.config.url+" Time taken: "+((new Date).getTime()-d)+"ms",arguments),a})}function f(a,b){return b=b||{},e(d.deepMixIn(b,{url:a,method:"GET"}))}function g(a,b,c){return c=c||{},e(d.deepMixIn(c,{url:a,data:b,method:"POST"}))}function h(a,b,c){return c=c||{},e(d.deepMixIn(c,{url:a,data:b,method:"PUT"}))}function i(a,b){return b=b||{},this.HTTP(d.deepMixIn(b,{url:a,method:"DELETE"}))}function j(a,b,c){return c=c||{},this.POST(d.makePath(c.baseUrl||a.baseUrl,a.endpoint),b,c)}function k(a,b,c){return c=c||{},this.DEL(d.makePath(c.baseUrl||a.baseUrl,a.endpoint,b),c)}function l(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.endpoint),e)}function m(a,b,c){return c=c||{},this.GET(d.makePath(c.baseUrl||a.baseUrl,a.endpoint,b),c)}function n(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.endpoint),e)}function o(a,b,c,e){return e=e||{},this.PUT(d.makePath(e.baseUrl||a.baseUrl,a.endpoint,b),c,e)}function p(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.endpoint),c,f)}return{defaults:a,HTTP:e,GET:f,POST:g,PUT:h,DEL:i,find:m,findAll:n,create:j,update:o,updateAll:p,destroy:k,destroyAll:l}}]}b.exports=c},{}],32:[function(a,b){function c(){this.$get=["$q","DSUtils",function(a,b){function c(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}function d(c,d){var e=a.defer();try{var f=localStorage.getItem(c);f?(f=angular.fromJson(f),b.deepMixIn(f,d),e.resolve(localStorage.setItem(c,angular.toJson(f)))):e.resolve(localStorage.setItem(c,angular.toJson(d)))}catch(g){e.reject(g)}return e.promise}function e(b){var c=a.defer();try{c.resolve(localStorage.removeItem(b))}catch(d){c.reject(d)}return c.promise}function f(a,c,d){return d=d||{},e(b.makePath(d.baseUrl||a.baseUrl,a.endpoint,c),d)}function g(a,d,e){return e=e||{},c(b.makePath(e.baseUrl||a.baseUrl,a.endpoint,d),e)}function h(a,e,f,g){return g=g||{},d(b.makePath(g.baseUrl||a.baseUrl,a.endpoint,e),f,g).then(function(){return c(b.makePath(g.baseUrl||a.baseUrl,a.endpoint,e))})}return{find:g,findAll:function(){throw new Error("Not supported!")},create:function(){throw new Error("Not supported!")},update:h,updateAll:function(){throw new Error("Not supported!")},destroy:f,destroyAll:function(){throw new Error("Not supported!")}}}]}b.exports=c},{}],33:[function(a,b){function c(a,b,c){var e=this.$q.defer(),f=e.promise;try{if(c=c||{},!this.definitions[a])throw new this.errors.NER(d+a);if(!this.utils.isObject(b))throw new this.errors.IA(d+"attrs: Must be an object!");var g=this.definitions[a],h=this.store[a],i=this;"cacheResponse"in c||(c.cacheResponse=!0),f=f.then(function(b){return i.$q.promisify(g.beforeValidate)(a,b)}).then(function(b){return i.$q.promisify(g.validate)(a,b)}).then(function(b){return i.$q.promisify(g.afterValidate)(a,b)}).then(function(b){return i.$q.promisify(g.beforeCreate)(a,b)}).then(function(b){return i.adapters[c.adapter||g.defaultAdapter].create(g,g.serialize(a,b),c)}).then(function(b){return i.$q.promisify(g.afterCreate)(a,g.deserialize(a,b))}).then(function(a){if(c.cacheResponse){var b=i.inject(g.name,a),d=b[g.idAttribute];return h.previousAttributes[d]=i.utils.deepMixIn({},b),h.saved[d]=i.utils.updateTimestamp(h.saved[d]),i.get(g.name,d)}return a}),e.resolve(b)}catch(j){e.reject(j)}return f}var d="DS.create(resourceName, attrs[, options]): ";b.exports=c},{}],34:[function(a,b){function c(a,b,c){var e=this.$q.defer(),f=e.promise;try{if(c=c||{},!this.definitions[a])throw new this.errors.NER(d+a);if(!this.utils.isString(b)&&!this.utils.isNumber(b))throw new this.errors.IA(d+"id: Must be a string or a number!");var g=this.get(a,b);if(!g)throw new this.errors.R(d+'id: "'+b+'" not found!');var h=this.definitions[a],i=this;f=f.then(function(b){return i.$q.promisify(h.beforeDestroy)(a,b)}).then(function(){return i.adapters[c.adapter||h.defaultAdapter].destroy(h,b,c)}).then(function(){return i.$q.promisify(h.afterDestroy)(a,g)}).then(function(){return i.eject(a,b),b}),e.resolve(g)}catch(j){e.reject(j)}return f}var d="DS.destroy(resourceName, id): ";b.exports=c},{}],35:[function(a,b){function c(a,b,c){var e=this.$q.defer(),f=e.promise;try{var g=this,h=this.errors.IA;if(c=c||{},!this.definitions[a])throw new this.errors.NER(d+a);if(!this.utils.isObject(b))throw new h(d+"params: Must be an object!");if(!this.utils.isObject(c))throw new h(d+"options: Must be an object!");var i=this.definitions[a];f=f.then(function(){return g.adapters[c.adapter||i.defaultAdapter].destroyAll(i,b,c)}).then(function(){return g.ejectAll(a,b)}),e.resolve()}catch(j){e.reject(j)}return f}var d="DS.destroyAll(resourceName, params[, options]): ";b.exports=c},{}],36:[function(a,b){function c(a,b,c){var e=this.$q.defer(),f=e.promise;try{var g=this.errors.IA;if(c=c||{},!this.definitions[a])throw new this.errors.NER(d+a);if(!this.utils.isString(b)&&!this.utils.isNumber(b))throw new g(d+"id: Must be a string or a number!");if(!this.utils.isObject(c))throw new g(d+"options: Must be an object!");"cacheResponse"in c||(c.cacheResponse=!0);var h=this.definitions[a],i=this.store[a],j=this;if(c.bypassCache&&delete i.completedQueries[b],!(b in i.completedQueries))return b in i.pendingQueries||(f=i.pendingQueries[b]=j.adapters[c.adapter||h.defaultAdapter].find(h,b,c).then(function(d){var e=h.deserialize(a,d);return c.cacheResponse?(delete i.pendingQueries[b],i.completedQueries[b]=(new Date).getTime(),j.inject(a,e)):e},function(a){return delete i.pendingQueries[b],j.$q.reject(a)})),i.pendingQueries[b];e.resolve(j.get(a,b))}catch(k){e.reject(k)}return f}var d="DS.find(resourceName, id[, options]): ";b.exports=c},{}],37:[function(a,b){function c(a,b,c,d){var e=this.store[c];return b=b||[],delete e.pendingQueries[d],e.completedQueries[d]=(new Date).getTime(),e.collectionModified=a.updateTimestamp(e.collectionModified),this.inject(c,b)}function d(a,b,d,e){var f=this.definitions[b],g=this.store[b],h=this,i=a.toJson(d);return e.bypassCache&&delete g.completedQueries[i],i in g.completedQueries?this.filter(b,d,e):(i in g.pendingQueries||(g.pendingQueries[i]=h.adapters[e.adapter||f.defaultAdapter].findAll(f,d,e).then(function(d){var g=f.deserialize(b,d);if(!e.cacheResponse)return g;try{return c.apply(h,[a,g,b,i])}catch(j){return h.$q.reject(j)}},function(a){return delete g.pendingQueries[i],h.$q.reject(a)})),g.pendingQueries[i])}function e(a,b,c){var e=this.$q.defer(),g=e.promise;try{var h=this.errors.IA,i=this;if(c=c||{},b=b||{},!this.definitions[a])throw new this.errors.NER(f+a);if(!this.utils.isObject(b))throw new h(f+"params: Must be an object!");if(!this.utils.isObject(c))throw new h(f+"options: Must be an object!");"cacheResponse"in c||(c.cacheResponse=!0),g=g.then(function(){return d.apply(i,[i.utils,a,b,c])}),e.resolve()}catch(j){e.reject(j)}return g}var f="DS.findAll(resourceName, params[, options]): ";b.exports=e},{}],38:[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":33,"./destroy":34,"./destroyAll":35,"./find":36,"./findAll":37,"./loadRelations":39,"./refresh":40,"./save":41,"./update":42,"./updateAll":43}],39:[function(a,b){function c(a,b,c,e){var f=this.$q.defer(),g=f.promise;try{var h=this.errors.IA;if(e=e||{},(angular.isString(b)||angular.isNumber(b))&&(b=this.get(a,b)),angular.isString(c)&&(c=[c]),!this.definitions[a])throw new this.errors.NER(d+a);if(!this.utils.isObject(b))throw new h(d+"instance(Id): Must be a string, number or object!");if(!this.utils.isArray(c))throw new h(d+"relations: Must be a string or an array!");if(!this.utils.isObject(e))throw new h(d+"options: Must be an object!");var i=this.definitions[a],j=this,k=[],l=[];j.utils.forOwn(i.relations,function(a,d){j.utils.forOwn(a,function(a,f){if(j.utils.contains(c,f)){var g,h={};h[a.foreignKey]=b[i.idAttribute],"hasMany"===d?g=j.findAll(f,h,e):"hasOne"===d?a.localKey&&b[a.localKey]?g=j.find(f,b[a.localKey],e):a.foreignKey&&(g=j.findAll(f,h,e)):g=j.find(f,b[a.localKey],e),g&&(k.push(g),l.push(a.localField))}})}),g=g.then(function(){return j.$q.all(k)}).then(function(a){return angular.forEach(l,function(c,d){b[c]=a[d]}),b}),f.resolve()}catch(m){f.reject(m)}return g}var d="DS.loadRelations(resourceName, instance(Id), relations[, options]): ";b.exports=c},{}],40:[function(a,b){function c(a,b,c){var e=this.errors.IA;if(c=c||{},this.definitions[a]){if(this.utils.isString(b)||this.utils.isNumber(b)){if(this.utils.isObject(c))return c.bypassCache=!0,this.get(a,b)?this.find(a,b,c):!1;throw new e(d+"options: Must be an object!")}throw new e(d+"id: Must be a string or a number!")}throw new this.errors.NER(d+a)}var d="DS.refresh(resourceName, id[, options]): ";b.exports=c},{}],41:[function(a,b){function c(a,b,c){var e=this.$q.defer(),f=e.promise;try{var g=this.errors.IA;if(c=c||{},!this.definitions[a])throw new this.errors.NER(d+a);if(!this.utils.isString(b)&&!this.utils.isNumber(b))throw new g(d+"id: Must be a string or a number!");if(!this.utils.isObject(c))throw new g(d+"options: Must be an object!");var h=this.get(a,b);if(!h)throw new this.errors.R(d+'id: "'+b+'" not found!');var i=this.definitions[a],j=this.store[a],k=this;"cacheResponse"in c||(c.cacheResponse=!0),f=f.then(function(b){return k.$q.promisify(i.beforeValidate)(a,b)}).then(function(b){return k.$q.promisify(i.validate)(a,b)}).then(function(b){return k.$q.promisify(i.afterValidate)(a,b)}).then(function(b){return k.$q.promisify(i.beforeUpdate)(a,b)}).then(function(d){if(c.changesOnly){j.observers[b].deliver();var e=[],f=k.changes(a,b);for(var g in f.added)e.push(g);for(g in f.changed)e.push(g);if(f=k.utils.pick(d,e),k.utils.isEmpty(f))return d;d=f}return k.adapters[c.adapter||i.defaultAdapter].update(i,b,i.serialize(a,d),c)}).then(function(b){return k.$q.promisify(i.afterUpdate)(a,i.deserialize(a,b))}).then(function(d){if(c.cacheResponse){var e=k.inject(i.name,d,c);return j.previousAttributes[b]=k.utils.deepMixIn({},e),j.saved[b]=k.utils.updateTimestamp(j.saved[b]),k.get(a,b)}return d}),e.resolve(h)}catch(l){e.reject(l)}return f}var d="DS.save(resourceName, id[, options]): ";b.exports=c},{}],42:[function(a,b){function c(a,b,c,e){var f=this.$q.defer(),g=f.promise;try{var h=this.errors.IA;if(e=e||{},!this.definitions[a])throw new this.errors.NER(d+a);if(!this.utils.isString(b)&&!this.utils.isNumber(b))throw new h(d+"id: Must be a string or a number!");if(!this.utils.isObject(c))throw new h(d+"attrs: Must be an object!");if(!this.utils.isObject(e))throw new h(d+"options: Must be an object!");var i=this.definitions[a],j=this.store[a],k=this;"cacheResponse"in e||(e.cacheResponse=!0),g=g.then(function(b){return k.$q.promisify(i.beforeValidate)(a,b)}).then(function(b){return k.$q.promisify(i.validate)(a,b)}).then(function(b){return k.$q.promisify(i.afterValidate)(a,b)}).then(function(b){return k.$q.promisify(i.beforeUpdate)(a,b)}).then(function(c){return k.adapters[e.adapter||i.defaultAdapter].update(i,b,i.serialize(a,c),e)}).then(function(b){return k.$q.promisify(i.afterUpdate)(a,i.deserialize(a,b))}).then(function(a){if(e.cacheResponse){var b=k.inject(i.name,a,e),c=b[i.idAttribute];return j.previousAttributes[c]=k.utils.deepMixIn({},b),j.saved[c]=k.utils.updateTimestamp(j.saved[c]),k.get(i.name,c)}return a}),f.resolve(c)}catch(l){f.reject(l)}return g}var d="DS.update(resourceName, id, attrs[, options]): ";b.exports=c},{}],43:[function(a,b){function c(a,b,c,e){var f=this.$q.defer(),g=f.promise;try{var h=this.errors.IA;if(e=e||{},!this.definitions[a])throw new this.errors.NER(d+a);if(!this.utils.isObject(b))throw new h(d+"attrs: Must be an object!");if(!this.utils.isObject(c))throw new h(d+"params: Must be an object!");if(!this.utils.isObject(e))throw new h(d+"options: Must be an object!");var i=this.definitions[a],j=this;"cacheResponse"in e||(e.cacheResponse=!0),g=g.then(function(b){return j.$q.promisify(i.beforeValidate)(a,b)}).then(function(b){return j.$q.promisify(i.validate)(a,b)}).then(function(b){return j.$q.promisify(i.afterValidate)(a,b)}).then(function(b){return j.$q.promisify(i.beforeUpdate)(a,b)}).then(function(b){return j.adapters[e.adapter||i.defaultAdapter].updateAll(i,i.serialize(a,b),c,e)}).then(function(b){return j.$q.promisify(i.afterUpdate)(a,i.deserialize(a,b))}).then(function(a){return e.cacheResponse?j.inject(i.name,a,e):a}),f.resolve(b)}catch(k){f.reject(k)}return g}var d="DS.updateAll(resourceName, attrs, params[, options]): ";b.exports=c},{}],44:[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={$rootScope:c,$log:d,$q:e,cacheFactory:j,defaults:b,store:{},definitions:{},adapters:{DSHttpAdapter:f,DSLocalStorageAdapter:g},errors:i,utils:h};h.deepFreeze(k),h.deepFreeze(l),h.deepMixIn(n,k),h.deepMixIn(n,l),h.deepFreeze(n.errors),h.deepFreeze(n.utils);var o=c.$new();return o.$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.filter=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.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},b.exports=e},{"../utils":62,"./async_methods":38,"./sync_methods":55}],45:[function(a,b){function c(a,b,c,e,f){var g=this.errors.IA;if(!this.utils.isObject(a))throw new g(d+"scope: Must be an object!");if(!this.utils.isString(b))throw new g(d+"expr: Must be a string!");if(!this.definitions[c])throw new this.errors.NER(d+c);if(!this.utils.isObject(e))throw new g(d+"params: Must be an object!");var h=this;try{return a.$watch(function(){return h.lastModified(c)},function(){var d=h.filter(c,e);h.utils.set(a,b,d),f&&f(null,d)})}catch(i){if(!f)throw i;f(i)}}var d="DS.bindAll(scope, expr, resourceName, params[, cb]): ";b.exports=c},{}],46:[function(a,b){function c(a,b,c,e,f){var g=this.errors.IA;if(!this.utils.isObject(a))throw new g(d+"scope: Must be an object!");if(!this.utils.isString(b))throw new g(d+"expr: Must be a string!");if(!this.definitions[c])throw new this.errors.NER(d+c);if(!this.utils.isString(e)&&!this.utils.isNumber(e))throw new g(d+"id: Must be a string or a number!");var h=this;try{return a.$watch(function(){return h.lastModified(c,e)},function(){var d=h.get(c,e);h.utils.set(a,b,d),f&&f(null,d)})}catch(i){if(!f)throw i;f(i)}}var d="DS.bindOne(scope, expr, resourceName, id[, cb]): ";b.exports=c},{}],47:[function(a,b){function c(a,b){if(!this.definitions[a])throw new this.errors.NER(d+a);if(!this.utils.isString(b)&&!this.utils.isNumber(b))throw new this.errors.IA(d+"id: Must be a string or a number!");var c=this.get(a,b);return c?(this.store[a].observers[b].deliver(),this.utils.diffObjectFromOldObject(c,this.store[a].previousAttributes[b])):void 0}var d="DS.changes(resourceName, id): ";b.exports=c},{}],48:[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 IA=this.errors.IA;if(this.utils.isString(definition)&&(definition={name:definition}),!this.utils.isObject(definition))throw new IA(errorPrefix+"definition: Must be an object!");if(!this.utils.isString(definition.name))throw new IA(errorPrefix+"definition.name: Must be a string!");if(definition.idAttribute&&!this.utils.isString(definition.idAttribute))throw new IA(errorPrefix+"definition.idAttribute: Must be a string!");if(definition.endpoint&&!this.utils.isString(definition.endpoint))throw new IA(errorPrefix+"definition.endpoint: Must be a string!");if(this.store[definition.name])throw new this.errors.R(errorPrefix+definition.name+" is already registered!");try{Resource.prototype=this.defaults,this.definitions[definition.name]=new Resource(this.utils,definition);var _this=this,def=this.definitions[definition.name],cache=this.cacheFactory("DS."+def.name,{maxAge:def.maxAge||null,recycleFreq:def.recycleFreq||1e3,cacheFlushInterval:def.cacheFlushInterval||null,deleteOnExpire:def.deleteOnExpire||"none",onExpire:function(a){_this.eject(def.name,a)},capacity:Number.MAX_VALUE,storageMode:"memory",storageImpl:null,disabled:!1,storagePrefix:"DS."+def.name});def.methods&&(def.class=definition.name[0].toUpperCase()+definition.name.substring(1),eval("function "+def.class+"() {}"),def[def.class]=eval(def.class),this.utils.deepMixIn(def[def.class].prototype,def.methods)),def.computed&&this.utils.forOwn(def.computed,function(a,b){def.methods&&b in def.methods&&_this.$log.warn(errorPrefix+'Computed property "'+b+'" conflicts with previously defined prototype method!');var c=a.toString().match(/function.*?\(([\s\S]*?)\)/),d=c[1].split(",");a.deps=_this.utils.filter(d,function(a){return!!a}),angular.forEach(a.deps,function(b,c){a.deps[c]=b.trim()})}),this.store[def.name]={collection:[],completedQueries:{},pendingQueries:{},index:cache,modified:{},saved:{},previousAttributes:{},observers:{},collectionModified:0}}catch(err){throw delete this.definitions[definition.name],delete this.store[definition.name],err}}var errorPrefix="DS.defineResource(definition): ";module.exports=defineResource},{}],49:[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}],50:[function(a,b){function c(a,b,c){for(var d=!1,e=0;e<b.collection.length;e++)if(b.collection[e][a.idAttribute]==c){d=!0;break}d&&(b.collection.splice(e,1),b.observers[c].close(),delete b.observers[c],b.index.remove(c),delete b.previousAttributes[c],delete b.modified[c],delete b.saved[c]) | ||
}function d(a,b){if(!this.definitions[a])throw new this.errors.NER(e+a);if(!this.utils.isString(b)&&!this.utils.isNumber(b))throw new this.errors.IA(e+"id: Must be a string or a number!");var d=this.store[a],f=this;this.$rootScope.$$phase?(c(f.definitions[a],d,b),d.collectionModified=f.utils.updateTimestamp(d.collectionModified)):this.$rootScope.$apply(function(){c(f.definitions[a],d,b),d.collectionModified=f.utils.updateTimestamp(d.collectionModified)}),delete this.store[a].completedQueries[b]}var e="DS.eject(resourceName, id): ";b.exports=d},{}],51:[function(a,b){function c(a,b,c){var d=this.utils.toJson(c),e=this.filter(a.name,c),f=this.utils.toLookup(e,a.idAttribute),g=this;angular.forEach(f,function(b,c){g.eject(a.name,c)}),delete b.completedQueries[d]}function d(a,b){if(b=b||{},!this.definitions[a])throw new this.errors.NER(e+a);if(!this.utils.isObject(b))throw new this.errors.IA(e+"params: Must be an object!");var d=this,f=this.store[a],g=this.utils.toJson(b);delete f.completedQueries[g],this.utils.isEmpty(b)&&(f.completedQueries={}),this.$rootScope.$$phase?(c.apply(d,[d.definitions[a],f,b]),f.collectionModified=this.utils.updateTimestamp(f.collectionModified)):this.$rootScope.$apply(function(){c.apply(d,[d.definitions[a],f,b]),f.collectionModified=d.utils.updateTimestamp(f.collectionModified)})}var e="DS.ejectAll(resourceName[, params]): ";b.exports=d},{}],52:[function(a,b){function c(a,b,c){var e=this.errors.IA;if(c=c||{},!this.definitions[a])throw new this.errors.NER(d+a);if(b&&!this.utils.isObject(b))throw new e(d+"params: Must be an object!");if(!this.utils.isObject(c))throw new e(d+"options: Must be an object!");var f=this.definitions[a],g=this.store[a];b=b||{},c.allowSimpleWhere="allowSimpleWhere"in c?!!c.allowSimpleWhere:!0;var h=this.utils.toJson(b);return h in g.completedQueries||!c.loadFromServer||g.pendingQueries[h]||this.findAll(a,b,c),f.filter.call(this,g.collection,a,b,c)}var d="DS.filter(resourceName[, params][, options]): ";b.exports=c},{}],53:[function(a,b){function c(a,b,c){var e=this.errors.IA;if(c=c||{},!this.definitions[a])throw new this.errors.NER(d+a);if(!this.utils.isString(b)&&!this.utils.isNumber(b))throw new e(d+"id: Must be a string or a number!");if(!this.utils.isObject(c))throw new e(d+"options: Must be an object!");var f=this,g=this.store[a].index.get(b);return!g&&c.loadFromServer&&this.find(a,b).then(null,function(a){return f.$q.reject(a)}),g}var d="DS.get(resourceName, id[, options]): ";b.exports=c},{}],54:[function(a,b){function c(a,b){return!(a.isEmpty(b.added)&&a.isEmpty(b.removed)&&a.isEmpty(b.changed))}function d(a,b){if(!this.definitions[a])throw new this.errors.NER(e+a);if(!this.utils.isString(b)&&!this.utils.isNumber(b))throw new this.errors.IA(e+"id: Must be a string or a number!");return this.get(a,b)?c(this.utils,this.changes(a,b)):!1}var e="DS.hasChanges(resourceName, id): ";b.exports=d},{}],55:[function(a,b){b.exports={defineResource:a("./defineResource"),bindOne:a("./bindOne"),bindAll:a("./bindAll"),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":45,"./bindOne":46,"./changes":47,"./defineResource":48,"./digest":49,"./eject":50,"./ejectAll":51,"./filter":52,"./get":53,"./hasChanges":54,"./inject":56,"./lastModified":57,"./lastSaved":58,"./previous":59}],56:[function(a,b){function c(a,b,d){function e(c,d,e,f){var g=f(a.idAttribute);if(b.modified[g]=i.utils.updateTimestamp(b.modified[g]),b.collectionModified=i.utils.updateTimestamp(b.collectionModified),a.computed){var h=i.get(a.name,g);i.utils.forOwn(a.computed,function(a,b){var c=!1;if(angular.forEach(a.deps,function(a){(a in e||a in d||a in e||!(b in h))&&(c=!0)}),c){var f=[];angular.forEach(a.deps,function(a){f.push(h[a])}),h[b]=a.apply(h,f)}})}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(d)){h=[];for(var k=0;k<d.length;k++)h.push(c.call(i,a,b,d[k]))}else{if(a.computed&&a.computed[a.idAttribute]){var l=[];angular.forEach(a.computed[a.idAttribute].deps,function(a){l.push(d[a])}),d[a.idAttribute]=a.computed[a.idAttribute].apply(d,l)}if(!(a.idAttribute in d))throw new i.errors.R(g+"attrs: Must contain the property specified by `idAttribute`!");try{a.beforeInject(a.name,d);var m=d[a.idAttribute],n=this.get(a.name,m);n?(i.utils.deepMixIn(n,d),"function"==typeof b.index.touch?b.index.touch(m):b.index.put(m,b.index.get(m)),b.observers[m].deliver()):(n=a.class?d instanceof a[a.class]?d:new a[a.class]:{},b.previousAttributes[m]={},i.utils.deepMixIn(n,d),i.utils.deepMixIn(b.previousAttributes[m],d),b.collection.push(n),b.observers[m]=new f.ObjectObserver(n,e),b.index.put(m,n),e({},{},{},function(){return m})),b.saved[m]=i.utils.updateTimestamp(b.saved[m]),a.afterInject(a.name,n),h=n}catch(o){j.error(o),j.error("inject failed!",a.name,d)}}return h}function d(a,b){var c=this;c.utils.forOwn(a.relations,function(a,d){c.utils.forOwn(a,function(a,e){if(c.definitions[e]&&b[a.localField])try{b[a.localField]=c.inject(e,b[a.localField])}catch(f){c.$log.error(g+"Failed to inject "+d+' relation: "'+e+'"!',f)}})})}function e(a,b,e){var f=this.errors.IA;if(e=e||{},!this.definitions[a])throw new this.errors.NER(g+a);if(!this.utils.isObject(b)&&!this.utils.isArray(b))throw new f(g+"attrs: Must be an object or an array!");if(!this.utils.isObject(e))throw new f(g+"options: Must be an object!");var h,i=this.definitions[a],j=this.store[a],k=this;return this.$rootScope.$$phase?h=c.call(k,i,j,b):this.$rootScope.$apply(function(){h=c.call(k,i,j,b)}),i.relations&&d.call(k,i,h),h}var f=a("../../../lib/observe-js/observe-js"),g="DS.inject(resourceName, attrs[, options]): ";b.exports=e},{"../../../lib/observe-js/observe-js":1}],57:[function(a,b){function c(a,b){if(!this.definitions[a])throw new this.errors.NER(d+a);if(b&&!this.utils.isString(b)&&!this.utils.isNumber(b))throw new this.errors.IA(d+"id: Must be a string or a number!");return b?(b in this.store[a].modified||(this.store[a].modified[b]=0),this.store[a].modified[b]):this.store[a].collectionModified}var d="DS.lastModified(resourceName[, id]): ";b.exports=c},{}],58:[function(a,b){function c(a,b){if(!this.definitions[a])throw new this.errors.NER(d+a);if(!this.utils.isString(b)&&!this.utils.isNumber(b))throw new this.errors.IA(d+"id: Must be a string or a number!");return b in this.store[a].saved||(this.store[a].saved[b]=0),this.store[a].saved[b]}var d="DS.lastSaved(resourceName[, id]): ";b.exports=c},{}],59:[function(a,b){function c(a,b){if(!this.definitions[a])throw new this.errors.NER(d+a);if(!this.utils.isString(b)&&!this.utils.isNumber(b))throw new this.errors.IA(d+"id: Must be a string or a number!");return angular.copy(this.store[a].previousAttributes[b])}var d="DS.previous(resourceName, id): ";b.exports=c},{}],60:[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}}]},{}],61:[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":31,"./adapters/localStorage":32,"./datastore":44,"./errors":60,"./utils":62}],62:[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"),deepMixIn:a("mout/object/deepMixIn"),forOwn:a("mout/object/forOwn"),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":29,"mout/string/upperCase":30}]},{},[61]); |
@@ -14,4 +14,4 @@ /* | ||
var dev = process.cwd().indexOf('/home/jdobry/angular-data') === -1, | ||
pkg = grunt.file.readJSON('package.json'); | ||
var dev = process.cwd().indexOf('/home/jdobry/angular-data') === -1; | ||
var pkg = grunt.file.readJSON('package.json'); | ||
@@ -18,0 +18,0 @@ // Project configuration. |
{ | ||
"name": "angular-data", | ||
"description": "Data store for Angular.js.", | ||
"version": "0.10.0-beta.1", | ||
"version": "0.10.0-beta.2", | ||
"homepage": "http://angular-data.pseudobry.com", | ||
@@ -6,0 +6,0 @@ "repository": { |
@@ -6,14 +6,12 @@ ## angular-data | ||
__Latest Release:__ [0.9.1](http://angular-data.pseudobry.com/) | ||
__master:__ [0.9.1](http://angular-data-next.pseudobry.com/) | ||
__master:__ [0.10.0-beta.2](http://angular-data-next.pseudobry.com/) | ||
Angular-data is in a pre-1.0.0 development stage; the API is fluctuating, not a lot of tests yet, etc. | ||
Angular-data is approaching 1.0.0 Beta. The API is stabilizing and angular-data is well tested. | ||
Not for production use (yet). If you still want to develop with Angular-data, be prepared to keep a close eye on the changelog, as the API is still liable to change before 1.0.0. | ||
Angular-data is being used in production, though it's not 1.0.0. If you want to use Angular-data, keep an eye on the changelog. 1.0.0 will introduce strict semver (minor number is bumped for breaking changes right now). | ||
Roadmap: | ||
- Relations/Associations | ||
- Various Adapters | ||
- Schema Definition/Validation | ||
- Even more adapters | ||
- Nested Resources | ||
- See [issues](https://github.com/jmdobry/angular-data/issues?milestone=7&page=1&state=open) for what's in development | ||
- See [issues](https://github.com/jmdobry/angular-data/issues?page=1&state=open) for what's in development | ||
- See [Design Doc](https://docs.google.com/document/d/1o069KLuBH4jpwm1FCLZFwKMgM73Xi8_1JyjhSxVpidM/edit?usp=sharing) for other juicy reading material | ||
@@ -24,2 +22,5 @@ | ||
## Version Migration | ||
[TRANSITION.md](https://github.com/jmdobry/angular-data/blob/master/TRANSITION.md) | ||
## Resources | ||
@@ -26,0 +27,0 @@ |
@@ -32,3 +32,6 @@ var errorPrefix = 'DS.create(resourceName, attrs[, options]): '; | ||
* the primary key specified by `id`. | ||
* @param {object=} options Configuration options. | ||
* @param {object=} options Configuration options. Properties: | ||
* | ||
* - `{boolean=}` - `cacheResponse` - Inject the data returned by the server into the data store. Default: `true`. | ||
* | ||
* @returns {Promise} Promise produced by the `$q` service. | ||
@@ -61,2 +64,6 @@ * | ||
if (!('cacheResponse' in options)) { | ||
options.cacheResponse = true; | ||
} | ||
promise = promise | ||
@@ -82,7 +89,11 @@ .then(function (attrs) { | ||
.then(function (data) { | ||
var created = _this.inject(definition.name, data); | ||
var id = created[definition.idAttribute]; | ||
resource.previousAttributes[id] = _this.utils.deepMixIn({}, created); | ||
resource.saved[id] = _this.utils.updateTimestamp(resource.saved[id]); | ||
return _this.get(definition.name, id); | ||
if (options.cacheResponse) { | ||
var created = _this.inject(definition.name, data); | ||
var id = created[definition.idAttribute]; | ||
resource.previousAttributes[id] = _this.utils.deepMixIn({}, created); | ||
resource.saved[id] = _this.utils.updateTimestamp(resource.saved[id]); | ||
return _this.get(definition.name, id); | ||
} else { | ||
return data; | ||
} | ||
}); | ||
@@ -89,0 +100,0 @@ |
@@ -32,2 +32,3 @@ var errorPrefix = 'DS.find(resourceName, id[, options]): '; | ||
* @param {object=} options Optional configuration. Properties: | ||
* | ||
* - `{boolean=}` - `bypassCache` - Bypass the cache. Default: `false`. | ||
@@ -66,4 +67,2 @@ * - `{boolean=}` - `cacheResponse` - Inject the data returned by the server into the data store. Default: `true`. | ||
options.cacheResponse = true; | ||
} else { | ||
options.cacheResponse = !!options.cacheResponse; | ||
} | ||
@@ -70,0 +69,0 @@ |
@@ -106,2 +106,3 @@ var errorPrefix = 'DS.findAll(resourceName, params[, options]): '; | ||
* @param {object=} options Optional configuration. Properties: | ||
* | ||
* - `{boolean=}` - `bypassCache` - Bypass the cache. Default: `false`. | ||
@@ -142,4 +143,2 @@ * - `{boolean=}` - `cacheResponse` - Inject the data returned by the server into the data store. Default: `true`. | ||
options.cacheResponse = true; | ||
} else { | ||
options.cacheResponse = !!options.cacheResponse; | ||
} | ||
@@ -146,0 +145,0 @@ |
@@ -38,3 +38,3 @@ var errorPrefix = 'DS.refresh(resourceName, id[, options]): '; | ||
* @param {string|number} id The primary key of the item to refresh from the server. | ||
* @param {object=} options Optional configuration. Properties: | ||
* @param {object=} options Optional configuration passed through to `DS.find` if it is called. | ||
* @returns {false|Promise} `false` if the item doesn't already exist in the data store. A `Promise` if the item does | ||
@@ -41,0 +41,0 @@ * exist in the data store and is being refreshed. |
@@ -30,3 +30,5 @@ var errorPrefix = 'DS.save(resourceName, id[, options]): '; | ||
* @param {string|number} id The primary key of the item to retrieve. | ||
* @param {object=} options Optional configuration. Properties: | ||
* @param {object=} options Optional configuration. Properties:: | ||
* | ||
* - `{boolean=}` - `cacheResponse` - Inject the data returned by the server into the data store. Default: `true`. | ||
* - `{boolean=}` - `changesOnly` - Only send changed and added values back to the server. | ||
@@ -72,2 +74,6 @@ * | ||
if (!('cacheResponse' in options)) { | ||
options.cacheResponse = true; | ||
} | ||
promise = promise | ||
@@ -112,6 +118,10 @@ .then(function (attrs) { | ||
.then(function (data) { | ||
_this.inject(definition.name, data, options); | ||
resource.previousAttributes[id] = _this.utils.deepMixIn({}, data); | ||
resource.saved[id] = _this.utils.updateTimestamp(resource.saved[id]); | ||
return _this.get(resourceName, id); | ||
if (options.cacheResponse) { | ||
var saved = _this.inject(definition.name, data, options); | ||
resource.previousAttributes[id] = _this.utils.deepMixIn({}, saved); | ||
resource.saved[id] = _this.utils.updateTimestamp(resource.saved[id]); | ||
return _this.get(resourceName, id); | ||
} else { | ||
return data; | ||
} | ||
}); | ||
@@ -118,0 +128,0 @@ |
@@ -34,2 +34,3 @@ var errorPrefix = 'DS.update(resourceName, id, attrs[, options]): '; | ||
* @param {object=} options Optional configuration. Properties: | ||
* | ||
* - `{boolean=}` - `cacheResponse` - Inject the data returned by the server into the data store. Default: `true`. | ||
@@ -73,4 +74,2 @@ * | ||
options.cacheResponse = true; | ||
} else { | ||
options.cacheResponse = !!options.cacheResponse; | ||
} | ||
@@ -77,0 +76,0 @@ |
@@ -48,2 +48,3 @@ var errorPrefix = 'DS.updateAll(resourceName, attrs, params[, options]): '; | ||
* @param {object=} options Optional configuration. Properties: | ||
* | ||
* - `{boolean=}` - `cacheResponse` - Inject the data returned by the server into the data store. Default: `true`. | ||
@@ -86,4 +87,2 @@ * | ||
options.cacheResponse = true; | ||
} else { | ||
options.cacheResponse = !!options.cacheResponse; | ||
} | ||
@@ -90,0 +89,0 @@ |
@@ -47,7 +47,5 @@ var utils = require('../utils')[0](); | ||
filtered = this.utils.filter(filtered, function (attrs) { | ||
// console.log(attrs); | ||
var first = true; | ||
var keep = true; | ||
_this.utils.forOwn(where, function (clause, field) { | ||
// console.log(clause, field); | ||
if (_this.utils.isString(clause)) { | ||
@@ -57,3 +55,3 @@ clause = { | ||
}; | ||
} else if (_this.utils.isNumber(clause)) { | ||
} else if (_this.utils.isNumber(clause) || _this.utils.isBoolean(clause)) { | ||
clause = { | ||
@@ -65,3 +63,2 @@ '==': clause | ||
_this.utils.forOwn(clause, function (val, op) { | ||
// console.log(op, val); | ||
if (op === '==') { | ||
@@ -105,3 +102,2 @@ keep = first ? (attrs[field] == val) : keep && (attrs[field] == val); | ||
first = false; | ||
// console.log(keep, first); | ||
}); | ||
@@ -108,0 +104,0 @@ } |
module.exports = [function () { | ||
return { | ||
isBoolean: require('mout/lang/isBoolean'), | ||
isString: angular.isString, | ||
@@ -4,0 +5,0 @@ isArray: angular.isArray, |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
386743
9447
66