angular-data
Advanced tools
Comparing version 0.6.0 to 0.7.0
@@ -0,1 +1,11 @@ | ||
##### 0.7.0 - 24 February 2014 | ||
###### Breaking API changes | ||
- `DS.eject(resourceName, id)` can now only eject individual items | ||
###### Backwards API changes | ||
- #34 - Added `DS.ejectAll(resourceName, params)` | ||
- #33 - Added `DS.destroyAll(resourceName, params[, options])` | ||
- #35 - Add options for asynchronous getter methods to return data without putting it into the data store | ||
##### 0.6.0 - 17 January 2014 | ||
@@ -2,0 +12,0 @@ |
/** | ||
* @author Jason Dobry <jason.dobry@gmail.com> | ||
* @file angular-data.min.js | ||
* @version 0.6.0 - Homepage <http://jmdobry.github.io/angular-data/> | ||
* @version 0.7.0 - Homepage <http://jmdobry.github.io/angular-data/> | ||
* @copyright (c) 2014 Jason Dobry <https://github.com/jmdobry/angular-data> | ||
@@ -10,3 +10,3 @@ * @license MIT <https://github.com/jmdobry/angular-data/blob/master/LICENSE> | ||
*/ | ||
require=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}({"u+GZEJ":[function(a,b,c){!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 Object.deliverAllChangeRecords(),void 0;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)},{}],observejs:[function(a,b){b.exports=a("u+GZEJ")},{}],3:[function(a,b){function c(a,b){return-1!==d(a,b)}var d=a("./indexOf");b.exports=c},{"./indexOf":5}],4:[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}],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":4}],7:[function(a,b){function c(a,b,c){return d.call(a,b,c)}var d=Array.prototype.slice;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;)c(a[0],b[0])<=0?d.push(a.shift()):d.push(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 h,i=0;null==f&&c();for(h in a)if(e(b,a,h,d)===!1)break;if(f)for(;(h=g[i++])&&(a[h]===Object.prototype[h]||e(b,a,h,d)!==!1););}function e(a,b,c,d){return a.call(d,b[c],c,b)}var f,g;b.exports=d},{}],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(){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}],26:[function(a,b){function c(a){return a=d(a),a.toUpperCase()}var d=a("../lang/toString");b.exports=c},{"../lang/toString":19}],27:[function(a,b){function c(){this.$get=["$http","$log","DSUtils",function(a,b,c){function d(c){var d=(new Date).getTime();return a(c).then(function(a){return b.debug(a.config.method+" request:"+a.config.url+" Time taken: "+((new Date).getTime()-d)+"ms",arguments),n.deserialize(a)})}function e(a,b){return b=b||{},d(c.deepMixIn(b,{url:a,method:"GET"}))}function f(a,b,e){return e=e||{},d(c.deepMixIn(e,{url:a,data:b,method:"POST"}))}function g(a,b,e){return e=e||{},d(c.deepMixIn(e,{url:a,data:b,method:"PUT"}))}function h(a,b){return b=b||{},this.HTTP(c.deepMixIn(b,{url:a,method:"DELETE"}))}function i(a,b,d){return this.GET(c.makePath(a.baseUrl,a.endpoint,b),d)}function j(a,b,d){return d=d||{},d.params=d.params||{},d.params.query&&(d.params.query=n.queryTransform(d.params.query)),c.deepMixIn(d,b),this.GET(c.makePath(a.baseUrl,a.endpoint),d)}function k(a,b,d){return this.POST(c.makePath(a.baseUrl,a.endpoint),n.serialize(b),d)}function l(a,b,d){return this.PUT(c.makePath(a.baseUrl,a.endpoint,b[a.idAttribute]),n.serialize(b),d)}function m(a,b,d){return this.DEL(c.makePath(a.baseUrl,a.endpoint,b),d)}var n=this.defaults={serialize:function(a){return a},deserialize:function(a){return a.data},queryTransform:function(a){return a}};return{defaults:n,HTTP:d,GET:e,POST:f,PUT:g,DEL:h,find:i,findAll:j,create:k,createMany:function(){throw new Error("Not yet implemented!")},update:l,updateMany:function(){throw new Error("Not yet implemented!")},destroy:m,destroyMany:function(){throw new Error("Not yet implemented!")}}}]}b.exports=c},{}],28:[function(a,b){function c(a,b,c){for(var d=a[c],e=b(d);c>0;){var f=Math.floor((c+1)/2)-1,g=a[f];if(e>=b(g))break;a[f]=d,a[c]=g,c=f}}function d(a,b,c){for(var d=a.length,e=a[c],f=b(e);;){var g=2*(c+1),h=g-1,i=null;if(d>h){var j=a[h],k=b(j);f>k&&(i=h)}if(d>g){var l=a[g],m=b(l);m<(null===i?f:b(a[h]))&&(i=g)}if(null===i)break;a[c]=a[i],a[i]=e,c=i}}function e(a){if(a&&"function"!=typeof a)throw new Error("BinaryHeap(weightFunc): weightFunc: must be a function!");a=defaults.userProvidedDefaultWeightFunc||defaults.defaultWeightFunc,this.weightFunc=a,this.heap=[]}function f(){function a(a){if(!angular.isFunction(a))throw new Error("BinaryHeapProvider.setDefaultWeightFunction(weightFunc): weightFunc: Must be a function!");b.userProvidedDefaultWeightFunc=a}var b={defaultWeightFunc:function(a){return a},userProvidedDefaultWeightFunc:null};this.setDefaultWeightFunction=a,this.$get=function(){return e}}e.prototype.push=function(a){this.heap.push(a),c(this.heap,this.weightFunc,this.heap.length-1)},e.prototype.peek=function(){return this.heap[0]},e.prototype.pop=function(){var a=this.heap[0],b=this.heap.pop();return this.heap.length>0&&(this.heap[0]=b,d(this.heap,this.weightFunc,0)),a},e.prototype.remove=function(a){for(var b=this.heap.length,e=0;b>e;e++)if(angular.equals(this.heap[e],a)){var f=this.heap[e],g=this.heap.pop();return e!==b-1&&(this.heap[e]=g,c(this.heap,this.weightFunc,e),d(this.heap,this.weightFunc,e)),f}return null},e.prototype.removeAll=function(){this.heap=[]},e.prototype.size=function(){return this.heap.length},b.exports=f},{}],29:[function(a,b){function c(a,b,c){var e=this.$q.defer(),f=e.promise;if(c=c||{},this.definitions[a])if(this.utils.isObject(b))try{var g=this.definitions[a],h=this;f=f.then(function(b){return h.$q.promisify(g.beforeValidate)(a,b)}).then(function(b){return h.$q.promisify(g.validate)(a,b)}).then(function(b){return h.$q.promisify(g.afterValidate)(a,b)}).then(function(b){return h.$q.promisify(g.beforeCreate)(a,b)}).then(function(a){return h.adapters[c.adapter||g.defaultAdapter].create(g,a,c)}).then(function(b){return h.$q.promisify(g.afterCreate)(a,b)}).then(function(a){return h.inject(g.name,a)}),e.resolve(b)}catch(i){e.reject(new this.errors.UnhandledError(i))}else e.reject(new this.errors.IllegalArgumentError(d+"attrs: Must be an object!",{attrs:{actual:typeof b,expected:"object"}}));else e.reject(new this.errors.RuntimeError(d+a+" is not a registered resource!"));return f}var d="DS.create(resourceName, attrs): ";b.exports=c},{}],30:[function(a,b){function c(a,b,c){var e=this.$q.defer(),f=e.promise;if(c=c||{},this.definitions[a])if(this.utils.isString(b)||this.utils.isNumber(b)){var g=this.definitions[a],h=this.store[a],i=this;b in h.index?(f=f.then(function(b){return i.$q.promisify(g.beforeDestroy)(a,b)}).then(function(){return i.adapters[c.adapter||g.defaultAdapter].destroy(g,b,c)}).then(function(){return i.$q.promisify(g.afterDestroy)(a,h.index[b])}).then(function(){return i.eject(a,b),b}),e.resolve(h.index[b])):e.resolve()}else e.reject(new this.errors.IllegalArgumentError(d+"id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}}));else e.reject(new this.errors.RuntimeError(d+a+" is not a registered resource!"));return f}var d="DS.destroy(resourceName, id): ";b.exports=c},{}],31:[function(a,b){function c(a,b,c){var e=this.$q.defer(),f=e.promise;if(c=c||{},this.definitions[a])if(this.utils.isString(b)||this.utils.isNumber(b))if(this.utils.isObject(c))try{var g=this.definitions[a],h=this.store[a],i=this;if(c.bypassCache&&delete h.completedQueries[b],!(b in h.completedQueries))return b in h.pendingQueries||(f=h.pendingQueries[b]=i.adapters[c.adapter||g.defaultAdapter].find(g,b,c).then(function(c){return delete h.pendingQueries[b],h.completedQueries[b]=(new Date).getTime(),i.inject(a,c)})),h.pendingQueries[b];e.resolve(i.get(a,b))}catch(j){e.reject(j)}else e.reject(new this.errors.IllegalArgumentError(d+"options: Must be an object!",{options:{actual:typeof c,expected:"object"}}));else e.reject(new this.errors.IllegalArgumentError(d+"id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}}));else e.reject(new this.errors.RuntimeError(d+a+" is not a registered resource!"));return f}var d="DS.find(resourceName, id[, options]): ";b.exports=c},{}],32:[function(a,b){function c(a,b,c,d){var e=this.store[c];b=b||[],delete e.pendingQueries[d],e.completedQueries[d]=(new Date).getTime();for(var f=0;f<b.length;f++)this.inject(c,b[f]);return e.index=a.toLookup(e.collection,this.definitions[c].idAttribute),e.collectionModified=a.updateTimestamp(e.collectionModified),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,{params:d},e).then(function(d){try{return c.apply(h,[a,d,b,i])}catch(e){throw new h.errors.UnhandledError(e)}})),g.pendingQueries[i])}function e(a,b,c){var e=this.$q.defer(),g=e.promise,h=this;if(c=c||{},this.definitions[a])if(this.utils.isObject(b))if(this.utils.isObject(c))try{g=g.then(function(){return d.apply(h,[h.utils,a,b,c])}),e.resolve()}catch(i){e.reject(new this.errors.UnhandledError(i))}else e.reject(new this.errors.IllegalArgumentError(f+"options: Must be an object!",{options:{actual:typeof c,expected:"object"}}));else e.reject(new this.errors.IllegalArgumentError(f+"params: Must be an object!",{params:{actual:typeof b,expected:"object"}}));else e.reject(new this.errors.RuntimeError(f+a+" is not a registered resource!"));return g}var f="DS.findAll(resourceName, params[, options]): ";b.exports=e},{}],33:[function(a,b){b.exports={create:a("./create"),destroy:a("./destroy"),find:a("./find"),findAll:a("./findAll"),refresh:a("./refresh"),save:a("./save")}},{"./create":29,"./destroy":30,"./find":31,"./findAll":32,"./refresh":34,"./save":35}],34:[function(a,b){function c(a,b,c){if(c=c||{},this.definitions[a]){if(this.utils.isString(b)||this.utils.isNumber(b)){if(this.utils.isObject(c))return c.bypassCache=!0,b in this.store[a].index?this.find(a,b,c):!1;throw new this.errors.IllegalArgumentError(d+"options: Must be an object!",{options:{actual:typeof c,expected:"object"}})}throw new this.errors.IllegalArgumentError(d+"id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}})}throw new this.errors.RuntimeError(d+a+" is not a registered resource!")}var d="DS.refresh(resourceName, id[, options]): ";b.exports=c},{}],35:[function(a,b){function c(a,b,c){var e=this.$q.defer(),f=e.promise;if(c=c||{},this.definitions[a])if(this.utils.isString(b)||this.utils.isNumber(b))if(this.utils.isObject(c))if(b in this.store[a].index){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.beforeUpdate)(a,b)}).then(function(a){return i.adapters[c.adapter||g.defaultAdapter].update(g,a,c)}).then(function(b){return i.$q.promisify(g.afterUpdate)(a,b)}).then(function(a){var d=i.inject(g.name,a,c);return h.previousAttributes[b]=i.utils.deepMixIn({},a),h.saved[b]=i.utils.updateTimestamp(h.saved[b]),d}),e.resolve(h.index[b])}else e.reject(new this.errors.RuntimeError(d+'id: "'+b+'" not found!'));else e.reject(new this.errors.IllegalArgumentError(d+"options: Must be an object!",{options:{actual:typeof c,expected:"object"}}));else e.reject(new this.errors.IllegalArgumentError(d+"id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}}));else e.reject(new this.errors.RuntimeError(d+a+" is not a registered resource!"));return f}var d="DS.save(resourceName, id[, options]): ";b.exports=c},{}],36:[function(a,b){function c(a,b,c){c(null,b)}function d(){}function e(){var b=this.defaults=new d,c=this.adapters={};this.$get=["$rootScope","$log","$q","DSHttpAdapter","DSUtils","DSErrors",function(d,e,f,g,h,i){var j=a("./sync_methods"),k=a("./async_methods");c.DSHttpAdapter=g;var l={$rootScope:d,$log:e,$q:f,defaults:b,store:{},definitions:{},adapters:c,errors:i,utils:h};h.deepFreeze(j),h.deepFreeze(k),h.deepMixIn(l,j),h.deepMixIn(l,k),h.deepFreeze(l.errors),h.deepFreeze(l.utils);var m=d.$new();return m.$watch(function(){return(new Date).getTime()/100|0},function(){l.digest()}),l}]}var f=a("../utils")[0]();d.prototype.idAttribute="id",d.prototype.defaultAdapter="DSHttpAdapter",d.prototype.filter=function(a,b,c){var d=!0;return f.forOwn(b,function(a,b){f.isString(a)&&(a={"===":a}),"=="in a?d=d&&c[b]==a["=="]:"==="in a?d=d&&c[b]===a["==="]:"!="in a?d=d&&c[b]!=a["!="]:">"in a?d=d&&c[b]>a[">"]:">="in a?d=d&&c[b]>=a[">="]:"<"in a?d=d&&c[b]<a["<"]:"<="in a?d=d&&c[b]<=a["<="]:"in"in a&&(d=d&&f.contains(a["in"],c[b]))}),d},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,b.exports=e},{"../utils":"uE/lJt","./async_methods":33,"./sync_methods":44}],37:[function(a,b){function c(a,b){if(!this.definitions[a])throw new this.errors.RuntimeError(d+a+" is not a registered resource!");if(!this.utils.isString(b)&&!this.utils.isNumber(b))throw new this.errors.IllegalArgumentError(d+"id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}});try{return angular.copy(this.store[a].changes[b])}catch(c){throw new this.errors.UnhandledError(c)}}var d="DS.changes(resourceName, id): ";b.exports=c},{}],38:[function(a,b){function c(a,b){a.deepMixIn(this,b),this.endpoint="endpoint"in b?b.endpoint:this.name}function d(a){if(this.utils.isString(a)&&(a={name:a}),!this.utils.isObject(a))throw new this.errors.IllegalArgumentError(e+"definition: Must be an object!",{definition:{actual:typeof a,expected:"object"}});if(!this.utils.isString(a.name))throw new this.errors.IllegalArgumentError(e+"definition.name: Must be a string!",{definition:{name:{actual:typeof a.name,expected:"string"}}});if(a.idAttribute&&!this.utils.isString(a.idAttribute))throw new this.errors.IllegalArgumentError(e+"definition.idAttribute: Must be a string!",{definition:{idAttribute:{actual:typeof a.idAttribute,expected:"string"}}});if(a.endpoint&&!this.utils.isString(a.endpoint))throw new this.errors.IllegalArgumentError(e+"definition.endpoint: Must be a string!",{definition:{endpoint:{actual:typeof a.endpoint,expected:"string"}}});if(this.store[a.name])throw new this.errors.RuntimeError(e+a.name+" is already registered!");try{c.prototype=this.defaults,this.definitions[a.name]=new c(this.utils,a),this.store[a.name]={collection:[],completedQueries:{},pendingQueries:{},index:{},changes:{},modified:{},saved:{},previousAttributes:{},observers:{},collectionModified:0}}catch(b){throw delete this.definitions[a.name],delete this.store[a.name],new this.errors.UnhandledError(b)}}var e="DS.defineResource(definition): ";b.exports=d},{}],39:[function(a,b){function c(){try{this.$rootScope.$$phase?d.Platform.performMicrotaskCheckpoint():this.$rootScope.$apply(function(){d.Platform.performMicrotaskCheckpoint()})}catch(a){throw new this.errors.UnhandledError(a)}}var d=a("observejs");b.exports=c},{observejs:"u+GZEJ"}],40:[function(a,b){function c(a,b,c){if(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],delete b.index[c],delete b.changes[c],delete b.previousAttributes[c],delete b.modified[c],delete b.saved[c])}else b.collection=[],b.index={},b.modified={},b.saved={},b.changes={},b.previousAttributes={}}function d(a,b){if(!this.definitions[a])throw new this.errors.RuntimeError(e+a+" is not a registered resource!");if(b&&!this.utils.isString(b)&&!this.utils.isNumber(b))throw new this.errors.IllegalArgumentError(e+"id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}});var d=this.store[a],f=this;try{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)})}catch(g){throw new this.errors.UnhandledError(g)}}var e="DS.eject(resourceName, id): ";b.exports=d},{}],41:[function(a,b){function c(a,b,c){if(c=c||{},!this.definitions[a])throw new this.errors.RuntimeError(d+a+" is not a registered resource!");if(!this.utils.isObject(b))throw new this.errors.IllegalArgumentError(d+"params: Must be an object!",{params:{actual:typeof b,expected:"object"}});if(!this.utils.isObject(c))throw new this.errors.IllegalArgumentError(d+"options: Must be an object!",{options:{actual:typeof c,expected:"object"}});try{var e=this.definitions[a],f=this.store[a],g=this;b.query=b.query||{};var h=this.utils.toJson(b);h in f.completedQueries||!c.loadFromServer||f.pendingQueries[h]||this.findAll(a,b,c);var i=this.utils.filter(f.collection,function(c){var f=!0,h=b.query.where;if(h){if(!g.utils.isObject(h))throw new g.errors.IllegalArgumentError(d+"params.query.where: Must be an object!",{params:{query:{where:{actual:typeof b.query.where,expected:"object"}}}});f=e.filter(a,h,c)}return f});if(b.query.orderBy){if(this.utils.isString(b.query.orderBy)&&(b.query.orderBy=[[b.query.orderBy,"ASC"]]),!this.utils.isArray(b.query.orderBy))throw new this.errors.IllegalArgumentError(d+"params.query.orderBy: Must be a string or an array!",{params:{query:{orderBy:{actual:typeof b.query.orderBy,expected:"string|array"}}}});for(var j=0;j<b.query.orderBy.length;j++){if(this.utils.isString(b.query.orderBy[j]))b.query.orderBy[j]=[b.query.orderBy[j],"ASC"];else if(!this.utils.isArray(b.query.orderBy[j]))throw new this.errors.IllegalArgumentError(d+"params.query.orderBy["+j+"]: Must be a string or an array!",{params:{query:{"orderBy[i]":{actual:typeof b.query.orderBy[j],expected:"string|array"}}}});i=this.utils.sort(i,function(a,c){var d=a[b.query.orderBy[j][0]],e=c[b.query.orderBy[j][0]];return g.utils.isString(d)&&(d=g.utils.upperCase(d)),g.utils.isString(e)&&(e=g.utils.upperCase(e)),"DESC"===b.query.orderBy[j][1]?d>e?-1:e>d?1:0:e>d?-1:d>e?1:0})}}return this.utils.isNumber(b.query.limit)&&this.utils.isNumber(b.query.skip)?i=this.utils.slice(i,b.query.skip,b.query.skip+b.query.limit):this.utils.isNumber(b.query.limit)?i=this.utils.slice(i,0,b.query.limit):this.utils.isNumber(b.query.skip)&&(i=this.utils.slice(i,b.query.skip)),i}catch(k){throw k instanceof this.errors.IllegalArgumentError?k:new this.errors.UnhandledError(k)}}var d="DS.filter(resourceName, params[, options]): ";b.exports=c},{}],42:[function(a,b){function c(a,b,c){if(c=c||{},!this.definitions[a])throw new this.errors.RuntimeError(d+a+" is not a registered resource!");if(!this.utils.isString(b)&&!this.utils.isNumber(b))throw new this.errors.IllegalArgumentError(d+"id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}});if(!this.utils.isObject(c))throw new this.errors.IllegalArgumentError(d+"options: Must be an object!",{options:{actual:typeof c,expected:"object"}});try{return b in this.store[a].index||!c.loadFromServer||this.find(a,b).then(null,function(a){throw a}),this.store[a].index[b]}catch(e){throw new this.errors.UnhandledError(e)}}var d="DS.get(resourceName, id[, options]): ";b.exports=c},{}],43:[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.RuntimeError(e+a+" is not a registered resource!");if(!this.utils.isString(b)&&!this.utils.isNumber(b))throw new this.errors.IllegalArgumentError(e+"id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}});try{return b in this.store[a].changes?c(this.utils,this.store[a].changes[b]):!1}catch(d){throw new this.errors.UnhandledError(d)}}var e="DS.hasChanges(resourceName, id): ";b.exports=d},{}],44:[function(a,b){b.exports={defineResource:a("./defineResource"),eject:a("./eject"),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")}},{"./changes":37,"./defineResource":38,"./digest":39,"./eject":40,"./filter":41,"./get":42,"./hasChanges":43,"./inject":45,"./lastModified":46,"./lastSaved":47,"./previous":48}],45:[function(a,b){function c(a,b,d){function g(c,d,e,f){try{var g=f(a.idAttribute);b.changes[g]=h.utils.diffObjectFromOldObject(b.index[g],b.previousAttributes[g]),b.modified[g]=h.utils.updateTimestamp(b.modified[g]),b.collectionModified=h.utils.updateTimestamp(b.collectionModified),a.idAttribute in e&&$log.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.')}catch(i){throw new h.errors.UnhandledError(i)}}var h=this;if(h.utils.isArray(d))for(var i=0;i<d.length;i++)c.call(h,a,b,d[i]);else{if(!(a.idAttribute in d))throw new h.errors.RuntimeError(f+"attrs: Must contain the property specified by `idAttribute`!");var j=d[a.idAttribute];j in b.index?(h.utils.deepMixIn(b.index[j],d),b.observers[j].deliver()):(b.index[j]={},b.previousAttributes[j]={},h.utils.deepMixIn(b.index[j],d),h.utils.deepMixIn(b.previousAttributes[j],d),b.collection.push(b.index[j]),b.observers[j]=new e.ObjectObserver(b.index[j],g),g({},{},{},function(){return j}))}}function d(a,b,d){if(d=d||{},!this.definitions[a])throw new this.errors.RuntimeError(f+a+" is not a registered resource!");if(!this.utils.isObject(b)&&!this.utils.isArray(b))throw new this.errors.IllegalArgumentError(f+"attrs: Must be an object or an array!",{attrs:{actual:typeof b,expected:"object|array"}});if(!this.utils.isObject(d))throw new this.errors.IllegalArgumentError(f+"options: Must be an object!",{options:{actual:typeof d,expected:"object"}});var e=this.definitions[a],g=this.store[a],h=this;try{return this.$rootScope.$$phase?c.apply(h,[e,g,b]):this.$rootScope.$apply(function(){c.apply(h,[e,g,b])}),b}catch(i){throw i instanceof this.errors.RuntimeError?i:new this.errors.UnhandledError(i)}}var e=a("observejs"),f="DS.inject(resourceName, attrs[, options]): ";b.exports=d},{observejs:"u+GZEJ"}],46:[function(a,b){function c(a,b){if(!this.definitions[a])throw new this.errors.RuntimeError(d+a+" is not a registered resource!");if(b&&!this.utils.isString(b)&&!this.utils.isNumber(b))throw new this.errors.IllegalArgumentError(d+"id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}});try{return b?(b in this.store[a].modified||(this.store[a].modified[b]=0),this.store[a].modified[b]):this.store[a].collectionModified}catch(c){throw new this.errors.UnhandledError(c)}}var d="DS.lastModified(resourceName[, id]): ";b.exports=c},{}],47:[function(a,b){function c(a,b){if(!this.definitions[a])throw new this.errors.RuntimeError(d+a+" is not a registered resource!");if(b&&!this.utils.isString(b)&&!this.utils.isNumber(b))throw new this.errors.IllegalArgumentError(d+"id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}});try{return b?(b in this.store[a].saved||(this.store[a].saved[b]=0),this.store[a].saved[b]):this.store[a].collectionModified}catch(c){throw new this.errors.UnhandledError(c)}}var d="DS.lastSaved(resourceName[, id]): ";b.exports=c},{}],48:[function(a,b){function c(a,b){if(!this.definitions[a])throw new this.errors.RuntimeError(d+a+" is not a registered resource!");if(!this.utils.isString(b)&&!this.utils.isNumber(b))throw new this.errors.IllegalArgumentError(d+"id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}});try{return angular.copy(this.store[a].previousAttributes[b])}catch(c){throw new this.errors.UnhandledError(c)}}var d="DS.previous(resourceName, id): ";b.exports=c},{}],errors:[function(a,b){b.exports=a("hIh4e1")},{}],hIh4e1:[function(a,b){function c(a){Error.call(this),"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),a=a||{},this.type=this.constructor.name,this.originalError=a,this.message="UnhandledError: This is an uncaught exception. Please consider submitting an issue at https://github.com/jmdobry/angular-data/issues.\n\nOriginal Uncaught Exception:\n"+(a.stack?a.stack.toString():a.stack),this.stack=this.message | ||
}function d(a,b){Error.call(this),"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.type=this.constructor.name,this.errors=b||{},this.message=a||"Illegal Argument!"}function e(a,b){Error.call(this),"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.type=this.constructor.name,this.errors=b||{},this.message=a||"RuntimeError Error!"}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{UnhandledError:c,IllegalArgumentError:d,RuntimeError:e}}]},{}],51:[function(a){!function(b,c){"use strict";c.module("angular-data.BinaryHeap",[]).provider("BinaryHeap",a("./binaryHeap")),c.module("angular-data.DS",["ng","angular-data.BinaryHeap"]).service("DSUtils",a("./utils")).service("DSErrors",a("./errors")).provider("DSHttpAdapter",a("./adapters/http")).provider("DS",a("./datastore")).config(["$provide",function(a){a.decorator("$q",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":27,"./binaryHeap":28,"./datastore":36,"./errors":"hIh4e1","./utils":"uE/lJt"}],"uE/lJt":[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"),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":3,"mout/array/filter":4,"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/string/makePath":25,"mout/string/upperCase":26}],utils:[function(a,b){b.exports=a("uE/lJt")},{}]},{},[51]); | ||
require=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}({salHtg:[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:{})},{}],observejs:[function(a,b){b.exports=a("salHtg")},{}],3:[function(a,b){function c(a,b){return-1!==d(a,b)}var d=a("./indexOf");b.exports=c},{"./indexOf":5}],4:[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}],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":4}],7:[function(a,b){function c(a,b,c){null==b?b=0:0>b&&(b=Math.max(a.length+b,0)),null==c?c=a.length:0>c&&(c=Math.max(a.length+c,0));for(var d=[];c>b;)d.push(a[b++]);return d}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(){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}],26:[function(a,b){function c(a){return a=d(a),a.toUpperCase()}var d=a("../lang/toString");b.exports=c},{"../lang/toString":19}],27:[function(a,b){function c(){this.$get=["$http","$log","DSUtils",function(a,b,c){function d(c){var d=(new Date).getTime();return a(c).then(function(a){return b.debug(a.config.method+" request:"+a.config.url+" Time taken: "+((new Date).getTime()-d)+"ms",arguments),o.deserialize(a)})}function e(a,b){return b=b||{},d(c.deepMixIn(b,{url:a,method:"GET"}))}function f(a,b,e){return e=e||{},d(c.deepMixIn(e,{url:a,data:b,method:"POST"}))}function g(a,b,e){return e=e||{},d(c.deepMixIn(e,{url:a,data:b,method:"PUT"}))}function h(a,b){return b=b||{},this.HTTP(c.deepMixIn(b,{url:a,method:"DELETE"}))}function i(a,b,d){return d=d||{},this.GET(c.makePath(a.baseUrl,a.endpoint,b),d)}function j(a,b,d){return d=d||{},d.params=d.params||{},d.params.query&&(d.params.query=o.queryTransform(d.params.query)),c.deepMixIn(d,b),this.GET(c.makePath(a.baseUrl,a.endpoint),d)}function k(a,b,d){return d=d||{},this.POST(c.makePath(a.baseUrl,a.endpoint),o.serialize(b),d)}function l(a,b,d,e){return this.PUT(c.makePath(a.baseUrl,a.endpoint,b),o.serialize(d),e)}function m(a,b,d){return d=d||{},this.DEL(c.makePath(a.baseUrl,a.endpoint,b),d)}function n(a,b,d){return d=d||{},d.params=d.params||{},d.params.query&&(d.params.query=o.queryTransform(d.params.query)),c.deepMixIn(d,b),this.DEL(c.makePath(a.baseUrl,a.endpoint),d)}var o=this.defaults={serialize:function(a){return a},deserialize:function(a){return a.data},queryTransform:function(a){return a}};return{defaults:o,HTTP:d,GET:e,POST:f,PUT:g,DEL:h,find:i,findAll:j,create:k,createMany:function(){throw new Error("Not yet implemented!")},update:l,updateMany:function(){throw new Error("Not yet implemented!")},destroy:m,destroyAll:n}}]}b.exports=c},{}],28:[function(a,b){function c(a,b,c){var e=this.$q.defer(),f=e.promise;if(c=c||{},this.definitions[a])if(this.utils.isObject(b))try{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(a){return i.adapters[c.adapter||g.defaultAdapter].create(g,a,c)}).then(function(b){return i.$q.promisify(g.afterCreate)(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(new this.errors.UnhandledError(j))}else e.reject(new this.errors.IllegalArgumentError(d+"attrs: Must be an object!",{attrs:{actual:typeof b,expected:"object"}}));else e.reject(new this.errors.RuntimeError(d+a+" is not a registered resource!"));return f}var d="DS.create(resourceName, attrs): ";b.exports=c},{}],29:[function(a,b){function c(a,b,c){var e=this.$q.defer(),f=e.promise;if(c=c||{},this.definitions[a])if(this.utils.isString(b)||this.utils.isNumber(b))if(b in this.store[a].index){var g=this.definitions[a],h=this.store[a],i=this;b in h.index?(f=f.then(function(b){return i.$q.promisify(g.beforeDestroy)(a,b)}).then(function(){return i.adapters[c.adapter||g.defaultAdapter].destroy(g,b,c)}).then(function(){return i.$q.promisify(g.afterDestroy)(a,h.index[b])}).then(function(){return i.eject(a,b),b}),e.resolve(h.index[b])):e.resolve()}else e.reject(new this.errors.RuntimeError(d+'id: "'+b+'" not found!'));else e.reject(new this.errors.IllegalArgumentError(d+"id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}}));else e.reject(new this.errors.RuntimeError(d+a+" is not a registered resource!"));return f}var d="DS.destroy(resourceName, id): ";b.exports=c},{}],30:[function(a,b){function c(a,b,c){var e=this.$q.defer(),f=e.promise,g=this;if(c=c||{},this.definitions[a])if(this.utils.isObject(b))if(this.utils.isObject(c))try{var h=this.definitions[a];f=f.then(function(){return g.adapters[c.adapter||h.defaultAdapter].destroyAll(h,{params:b},c)}).then(function(){return g.ejectAll(a,b)}),e.resolve()}catch(i){e.reject(new this.errors.UnhandledError(i))}else e.reject(new this.errors.IllegalArgumentError(d+"options: Must be an object!",{options:{actual:typeof c,expected:"object"}}));else e.reject(new this.errors.IllegalArgumentError(d+"params: Must be an object!",{params:{actual:typeof b,expected:"object"}}));else e.reject(new this.errors.RuntimeError(d+a+" is not a registered resource!"));return f}var d="DS.destroyAll(resourceName, params[, options]): ";b.exports=c},{}],31:[function(a,b){function c(a,b,c){var e=this.$q.defer(),f=e.promise;if(c=c||{},this.definitions[a])if(this.utils.isString(b)||this.utils.isNumber(b))if(this.utils.isObject(c)){c.cacheResponse="cacheResponse"in c?!!c.cacheResponse:!0;try{var g=this.definitions[a],h=this.store[a],i=this;if(c.bypassCache&&delete h.completedQueries[b],!(b in h.completedQueries))return b in h.pendingQueries||(f=h.pendingQueries[b]=i.adapters[c.adapter||g.defaultAdapter].find(g,b,c).then(function(d){return c.cacheResponse?(delete h.pendingQueries[b],h.completedQueries[b]=(new Date).getTime(),i.inject(a,d)):d})),h.pendingQueries[b];e.resolve(i.get(a,b))}catch(j){e.reject(j)}}else e.reject(new this.errors.IllegalArgumentError(d+"options: Must be an object!",{options:{actual:typeof c,expected:"object"}}));else e.reject(new this.errors.IllegalArgumentError(d+"id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}}));else e.reject(new this.errors.RuntimeError(d+a+" is not a registered resource!"));return f}var d="DS.find(resourceName, id[, options]): ";b.exports=c},{}],32:[function(a,b){function c(a,b,c,d){var e=this.store[c];b=b||[],delete e.pendingQueries[d],e.completedQueries[d]=(new Date).getTime();for(var f=0;f<b.length;f++)this.inject(c,b[f]);return e.index=a.toLookup(e.collection,this.definitions[c].idAttribute),e.collectionModified=a.updateTimestamp(e.collectionModified),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,{params:d},e).then(function(d){if(!e.cacheResponse)return d;try{return c.apply(h,[a,d,b,i])}catch(f){throw new h.errors.UnhandledError(f)}})),g.pendingQueries[i])}function e(a,b,c){var e=this.$q.defer(),g=e.promise,h=this;if(c=c||{},this.definitions[a])if(this.utils.isObject(b))if(this.utils.isObject(c)){c.cacheResponse="cacheResponse"in c?!!c.cacheResponse:!0;try{g=g.then(function(){return d.apply(h,[h.utils,a,b,c])}),e.resolve()}catch(i){e.reject(new this.errors.UnhandledError(i))}}else e.reject(new this.errors.IllegalArgumentError(f+"options: Must be an object!",{options:{actual:typeof c,expected:"object"}}));else e.reject(new this.errors.IllegalArgumentError(f+"params: Must be an object!",{params:{actual:typeof b,expected:"object"}}));else e.reject(new this.errors.RuntimeError(f+a+" is not a registered resource!"));return g}var f="DS.findAll(resourceName, params[, options]): ";b.exports=e},{}],33:[function(a,b){b.exports={create:a("./create"),destroy:a("./destroy"),destroyAll:a("./destroyAll"),find:a("./find"),findAll:a("./findAll"),refresh:a("./refresh"),save:a("./save")}},{"./create":28,"./destroy":29,"./destroyAll":30,"./find":31,"./findAll":32,"./refresh":34,"./save":35}],34:[function(a,b){function c(a,b,c){if(c=c||{},this.definitions[a]){if(this.utils.isString(b)||this.utils.isNumber(b)){if(this.utils.isObject(c))return c.bypassCache=!0,b in this.store[a].index?this.find(a,b,c):!1;throw new this.errors.IllegalArgumentError(d+"options: Must be an object!",{options:{actual:typeof c,expected:"object"}})}throw new this.errors.IllegalArgumentError(d+"id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}})}throw new this.errors.RuntimeError(d+a+" is not a registered resource!")}var d="DS.refresh(resourceName, id[, options]): ";b.exports=c},{}],35:[function(a,b){function c(a,b,c){var e=this.$q.defer(),f=e.promise;if(c=c||{},this.definitions[a])if(this.utils.isString(b)||this.utils.isNumber(b))if(this.utils.isObject(c))if(b in this.store[a].index){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.beforeUpdate)(a,b)}).then(function(a){return i.adapters[c.adapter||g.defaultAdapter].update(g,b,a,c)}).then(function(b){return i.$q.promisify(g.afterUpdate)(a,b)}).then(function(d){return i.inject(g.name,d,c),h.previousAttributes[b]=i.utils.deepMixIn({},d),h.saved[b]=i.utils.updateTimestamp(h.saved[b]),i.get(a,b)}),e.resolve(h.index[b])}else e.reject(new this.errors.RuntimeError(d+'id: "'+b+'" not found!'));else e.reject(new this.errors.IllegalArgumentError(d+"options: Must be an object!",{options:{actual:typeof c,expected:"object"}}));else e.reject(new this.errors.IllegalArgumentError(d+"id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}}));else e.reject(new this.errors.RuntimeError(d+a+" is not a registered resource!"));return f}var d="DS.save(resourceName, id[, options]): ";b.exports=c},{}],36:[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","DSUtils","DSErrors",function(c,d,e,f,g,h){var i=a("./sync_methods"),j=a("./async_methods"),k={$rootScope:c,$log:d,$q:e,defaults:b,store:{},definitions:{},adapters:{DSHttpAdapter:f},errors:h,utils:g};g.deepFreeze(i),g.deepFreeze(j),g.deepMixIn(k,i),g.deepMixIn(k,j),g.deepFreeze(k.errors),g.deepFreeze(k.utils);var l=c.$new();return l.$watch(function(){return(new Date).getTime()/100|0},function(){k.digest()}),k}]}var f=a("../utils")[0]();d.prototype.idAttribute="id",d.prototype.defaultAdapter="DSHttpAdapter",d.prototype.filter=function(a,b,c){var d=!0;return f.forOwn(b,function(a,b){f.isString(a)?a={"===":a}:f.isNumber(a)&&(a={"==":a}),"=="in a?d=d&&c[b]==a["=="]:"==="in a?d=d&&c[b]===a["==="]:"!="in a?d=d&&c[b]!=a["!="]:">"in a?d=d&&c[b]>a[">"]:">="in a?d=d&&c[b]>=a[">="]:"<"in a?d=d&&c[b]<a["<"]:"<="in a?d=d&&c[b]<=a["<="]:"in"in a&&(d=d&&f.contains(a["in"],c[b]))}),d},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,b.exports=e},{"../utils":"uE/lJt","./async_methods":33,"./sync_methods":45}],37:[function(a,b){function c(a,b){if(!this.definitions[a])throw new this.errors.RuntimeError(d+a+" is not a registered resource!");if(!this.utils.isString(b)&&!this.utils.isNumber(b))throw new this.errors.IllegalArgumentError(d+"id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}});try{return angular.copy(this.store[a].changes[b])}catch(c){throw new this.errors.UnhandledError(c)}}var d="DS.changes(resourceName, id): ";b.exports=c},{}],38:[function(a,b){function c(a,b){a.deepMixIn(this,b),this.endpoint="endpoint"in b?b.endpoint:this.name}function d(a){if(this.utils.isString(a)&&(a={name:a}),!this.utils.isObject(a))throw new this.errors.IllegalArgumentError(e+"definition: Must be an object!",{definition:{actual:typeof a,expected:"object"}});if(!this.utils.isString(a.name))throw new this.errors.IllegalArgumentError(e+"definition.name: Must be a string!",{definition:{name:{actual:typeof a.name,expected:"string"}}});if(a.idAttribute&&!this.utils.isString(a.idAttribute))throw new this.errors.IllegalArgumentError(e+"definition.idAttribute: Must be a string!",{definition:{idAttribute:{actual:typeof a.idAttribute,expected:"string"}}});if(a.endpoint&&!this.utils.isString(a.endpoint))throw new this.errors.IllegalArgumentError(e+"definition.endpoint: Must be a string!",{definition:{endpoint:{actual:typeof a.endpoint,expected:"string"}}});if(this.store[a.name])throw new this.errors.RuntimeError(e+a.name+" is already registered!");try{c.prototype=this.defaults,this.definitions[a.name]=new c(this.utils,a),this.store[a.name]={collection:[],completedQueries:{},pendingQueries:{},index:{},changes:{},modified:{},saved:{},previousAttributes:{},observers:{},collectionModified:0}}catch(b){throw delete this.definitions[a.name],delete this.store[a.name],new this.errors.UnhandledError(b)}}var e="DS.defineResource(definition): ";b.exports=d},{}],39:[function(a,b){function c(){try{this.$rootScope.$$phase?d.Platform.performMicrotaskCheckpoint():this.$rootScope.$apply(function(){d.Platform.performMicrotaskCheckpoint()})}catch(a){throw new this.errors.UnhandledError(a)}}var d=a("observejs");b.exports=c},{observejs:"salHtg"}],40:[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],delete b.index[c],delete b.changes[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.RuntimeError(e+a+" is not a registered resource!");if(!this.utils.isString(b)&&!this.utils.isNumber(b))throw new this.errors.IllegalArgumentError(e+"id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}});var d=this.store[a],f=this;try{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]}catch(g){throw new this.errors.UnhandledError(g)}}var e="DS.eject(resourceName, id): ";b.exports=d},{}],41:[function(a,b){function c(a,b,c){for(var d=this.utils.toJson(c),e=this.filter(a.name,c),f=0;f<e.length;f++)this.eject(a.name,e[f][a.idAttribute]);delete b.completedQueries[d]}function d(a,b){if(b=b||{},!this.definitions[a])throw new this.errors.RuntimeError(e+a+" is not a registered resource!");if(!this.utils.isObject(b))throw new this.errors.IllegalArgumentError(e+"params: Must be an object!",{params:{actual:typeof b,expected:"object"}});var d=this.store[a],f=this;try{this.$rootScope.$$phase?(c.apply(f,[f.definitions[a],d,b]),d.collectionModified=this.utils.updateTimestamp(d.collectionModified)):this.$rootScope.$apply(function(){c.apply(f,[f.definitions[a],d,b]),d.collectionModified=f.utils.updateTimestamp(d.collectionModified)})}catch(g){throw new this.errors.UnhandledError(g)}}var e="DS.ejectAll(resourceName[, params]): ";b.exports=d},{}],42:[function(a,b){function c(a,b,c){if(c=c||{},!this.definitions[a])throw new this.errors.RuntimeError(d+a+" is not a registered resource!");if(!this.utils.isObject(b))throw new this.errors.IllegalArgumentError(d+"params: Must be an object!",{params:{actual:typeof b,expected:"object"}});if(!this.utils.isObject(c))throw new this.errors.IllegalArgumentError(d+"options: Must be an object!",{options:{actual:typeof c,expected:"object"}});try{var e=this.definitions[a],f=this.store[a],g=this;b.query=b.query||{};var h=this.utils.toJson(b);h in f.completedQueries||!c.loadFromServer||f.pendingQueries[h]||this.findAll(a,b,c);var i=this.utils.filter(f.collection,function(c){var f=!0,h=b.query.where;if(h){if(!g.utils.isObject(h))throw new g.errors.IllegalArgumentError(d+"params.query.where: Must be an object!",{params:{query:{where:{actual:typeof b.query.where,expected:"object"}}}});f=e.filter(a,h,c)}return f});if(b.query.orderBy){if(this.utils.isString(b.query.orderBy)&&(b.query.orderBy=[[b.query.orderBy,"ASC"]]),!this.utils.isArray(b.query.orderBy))throw new this.errors.IllegalArgumentError(d+"params.query.orderBy: Must be a string or an array!",{params:{query:{orderBy:{actual:typeof b.query.orderBy,expected:"string|array"}}}});for(var j=0;j<b.query.orderBy.length;j++){if(this.utils.isString(b.query.orderBy[j]))b.query.orderBy[j]=[b.query.orderBy[j],"ASC"];else if(!this.utils.isArray(b.query.orderBy[j]))throw new this.errors.IllegalArgumentError(d+"params.query.orderBy["+j+"]: Must be a string or an array!",{params:{query:{"orderBy[i]":{actual:typeof b.query.orderBy[j],expected:"string|array"}}}});i=this.utils.sort(i,function(a,c){var d=a[b.query.orderBy[j][0]],e=c[b.query.orderBy[j][0]];return g.utils.isString(d)&&(d=g.utils.upperCase(d)),g.utils.isString(e)&&(e=g.utils.upperCase(e)),"DESC"===b.query.orderBy[j][1]?d>e?-1:e>d?1:0:e>d?-1:d>e?1:0})}}return this.utils.isNumber(b.query.limit)&&this.utils.isNumber(b.query.skip)?i=this.utils.slice(i,b.query.skip,b.query.skip+b.query.limit):this.utils.isNumber(b.query.limit)?i=this.utils.slice(i,0,b.query.limit):this.utils.isNumber(b.query.skip)&&(i=this.utils.slice(i,b.query.skip)),i}catch(k){throw k instanceof this.errors.IllegalArgumentError?k:new this.errors.UnhandledError(k)}}var d="DS.filter(resourceName, params[, options]): ";b.exports=c},{}],43:[function(a,b){function c(a,b,c){if(c=c||{},!this.definitions[a])throw new this.errors.RuntimeError(d+a+" is not a registered resource!");if(!this.utils.isString(b)&&!this.utils.isNumber(b))throw new this.errors.IllegalArgumentError(d+"id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}});if(!this.utils.isObject(c))throw new this.errors.IllegalArgumentError(d+"options: Must be an object!",{options:{actual:typeof c,expected:"object"}});try{return b in this.store[a].index||!c.loadFromServer||this.find(a,b).then(null,function(a){throw a}),this.store[a].index[b]}catch(e){throw new this.errors.UnhandledError(e)}}var d="DS.get(resourceName, id[, options]): ";b.exports=c},{}],44:[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.RuntimeError(e+a+" is not a registered resource!");if(!this.utils.isString(b)&&!this.utils.isNumber(b))throw new this.errors.IllegalArgumentError(e+"id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}});try{return b in this.store[a].changes?c(this.utils,this.store[a].changes[b]):!1}catch(d){throw new this.errors.UnhandledError(d)}}var e="DS.hasChanges(resourceName, id): ";b.exports=d},{}],45:[function(a,b){b.exports={defineResource:a("./defineResource"),eject:a("./eject"),ejectAll:a("./ejectAll"),filter:a("./filter"),get:a("./get"),inject:a("./inject"),lastModified:a("./lastModified"),lastSaved:a("./lastSaved"),digest:a("./digest"),changes:a("./changes"),previous:a("./previous"),hasChanges:a("./hasChanges")}},{"./changes":37,"./defineResource":38,"./digest":39,"./eject":40,"./ejectAll":41,"./filter":42,"./get":43,"./hasChanges":44,"./inject":46,"./lastModified":47,"./lastSaved":48,"./previous":49}],46:[function(a,b){function c(a,b,d){function g(c,d,e,f){try{var g=f(a.idAttribute);b.changes[g]=h.utils.diffObjectFromOldObject(b.index[g],b.previousAttributes[g]),b.modified[g]=h.utils.updateTimestamp(b.modified[g]),b.collectionModified=h.utils.updateTimestamp(b.collectionModified),a.idAttribute in e&&$log.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.')}catch(i){throw new h.errors.UnhandledError(i)}}var h=this;if(h.utils.isArray(d))for(var i=0;i<d.length;i++)c.call(h,a,b,d[i]);else{if(!(a.idAttribute in d))throw new h.errors.RuntimeError(f+"attrs: Must contain the property specified by `idAttribute`!");var j=d[a.idAttribute];j in b.index?(h.utils.deepMixIn(b.index[j],d),b.observers[j].deliver()):(b.index[j]={},b.previousAttributes[j]={},h.utils.deepMixIn(b.index[j],d),h.utils.deepMixIn(b.previousAttributes[j],d),b.collection.push(b.index[j]),b.observers[j]=new e.ObjectObserver(b.index[j],g),g({},{},{},function(){return j}))}}function d(a,b,d){if(d=d||{},!this.definitions[a])throw new this.errors.RuntimeError(f+a+" is not a registered resource!");if(!this.utils.isObject(b)&&!this.utils.isArray(b))throw new this.errors.IllegalArgumentError(f+"attrs: Must be an object or an array!",{attrs:{actual:typeof b,expected:"object|array"}});if(!this.utils.isObject(d))throw new this.errors.IllegalArgumentError(f+"options: Must be an object!",{options:{actual:typeof d,expected:"object"}});var e=this.definitions[a],g=this.store[a],h=this;try{return this.$rootScope.$$phase?c.apply(h,[e,g,b]):this.$rootScope.$apply(function(){c.apply(h,[e,g,b])}),b}catch(i){throw i instanceof this.errors.RuntimeError?i:new this.errors.UnhandledError(i)}}var e=a("observejs"),f="DS.inject(resourceName, attrs[, options]): ";b.exports=d},{observejs:"salHtg"}],47:[function(a,b){function c(a,b){if(!this.definitions[a])throw new this.errors.RuntimeError(d+a+" is not a registered resource!");if(b&&!this.utils.isString(b)&&!this.utils.isNumber(b))throw new this.errors.IllegalArgumentError(d+"id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}});try{return b?(b in this.store[a].modified||(this.store[a].modified[b]=0),this.store[a].modified[b]):this.store[a].collectionModified}catch(c){throw new this.errors.UnhandledError(c)}}var d="DS.lastModified(resourceName[, id]): ";b.exports=c},{}],48:[function(a,b){function c(a,b){if(!this.definitions[a])throw new this.errors.RuntimeError(d+a+" is not a registered resource!");if(b&&!this.utils.isString(b)&&!this.utils.isNumber(b))throw new this.errors.IllegalArgumentError(d+"id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}});try{return b?(b in this.store[a].saved||(this.store[a].saved[b]=0),this.store[a].saved[b]):this.store[a].collectionModified}catch(c){throw new this.errors.UnhandledError(c) | ||
}}var d="DS.lastSaved(resourceName[, id]): ";b.exports=c},{}],49:[function(a,b){function c(a,b){if(!this.definitions[a])throw new this.errors.RuntimeError(d+a+" is not a registered resource!");if(!this.utils.isString(b)&&!this.utils.isNumber(b))throw new this.errors.IllegalArgumentError(d+"id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}});try{return angular.copy(this.store[a].previousAttributes[b])}catch(c){throw new this.errors.UnhandledError(c)}}var d="DS.previous(resourceName, id): ";b.exports=c},{}],errors:[function(a,b){b.exports=a("hIh4e1")},{}],hIh4e1:[function(a,b){function c(a){Error.call(this),"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),a=a||{},this.type=this.constructor.name,this.originalError=a,this.message="UnhandledError: This is an uncaught exception. Please consider submitting an issue at https://github.com/jmdobry/angular-data/issues.\n\nOriginal Uncaught Exception:\n"+(a.stack?a.stack.toString():a.stack),this.stack=this.message}function d(a,b){Error.call(this),"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.type=this.constructor.name,this.errors=b||{},this.message=a||"Illegal Argument!"}function e(a,b){Error.call(this),"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.type=this.constructor.name,this.errors=b||{},this.message=a||"RuntimeError Error!"}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{UnhandledError:c,IllegalArgumentError:d,RuntimeError:e}}]},{}],52:[function(a){!function(b,c){"use strict";c.module("angular-data.DS",["ng"]).service("DSUtils",a("./utils")).service("DSErrors",a("./errors")).provider("DSHttpAdapter",a("./adapters/http")).provider("DS",a("./datastore")).config(["$provide",function(a){a.decorator("$q",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":27,"./datastore":36,"./errors":"hIh4e1","./utils":"uE/lJt"}],"uE/lJt":[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"),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":3,"mout/array/filter":4,"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/string/makePath":25,"mout/string/upperCase":26}],utils:[function(a,b){b.exports=a("uE/lJt")},{}]},{},[52]); |
102
Gruntfile.js
@@ -14,5 +14,8 @@ /* | ||
var dev = process.cwd().indexOf('/home/codetrain/angular-data') === -1, | ||
pkg = grunt.file.readJSON('package.json'); | ||
// Project configuration. | ||
grunt.initConfig({ | ||
pkg: grunt.file.readJSON('package.json'), | ||
pkg: pkg, | ||
clean: { | ||
@@ -74,9 +77,9 @@ coverage: ['coverage/'], | ||
}, | ||
// TODO: There's got to be a better way to consume observe-js without it polluting the global space | ||
options: { | ||
alias: [ | ||
'lib/observe-js.js:observejs', | ||
'lib/observe-js/observe-js.js:observejs', | ||
'src/errors/index.js:errors', | ||
'src/utils/index.js:utils' | ||
], | ||
// TODO: There's got to be a better way to consume observe-js without it polluting the global space | ||
postBundleCB: function (err, src, next) { | ||
@@ -175,2 +178,9 @@ if (err) { | ||
}, | ||
chart: { | ||
expand: true, | ||
cwd: 'guide/', | ||
src: 'chart.png', | ||
dest: 'doc/resources/img/', | ||
flatten: true | ||
}, | ||
cream_dust: { | ||
@@ -192,5 +202,11 @@ expand: true, | ||
{ | ||
id: 'overview', | ||
title: 'Overview', | ||
docs: ['guide/overview/'], | ||
id: 'angular-data', | ||
title: 'angular-data', | ||
docs: [ | ||
'guide/angular-data/index.doc', | ||
'guide/angular-data/overview.doc', | ||
'guide/angular-data/resources.doc', | ||
'guide/angular-data/synchronous.doc', | ||
'guide/angular-data/asynchronous.doc' | ||
], | ||
rank: { | ||
@@ -205,5 +221,17 @@ index: 1, | ||
{ | ||
id: 'resource', | ||
id: 'angular-cache', | ||
title: 'angular-cache', | ||
docs: ['guide/angular-cache/'], | ||
rank: { | ||
index: 1, | ||
basics: 2, | ||
configure: 3, | ||
http: 4, | ||
storage: 5 | ||
} | ||
}, | ||
{ | ||
id: 'angular-data-resource', | ||
title: 'Defining Resources', | ||
docs: ['guide/resource/'], | ||
docs: ['guide/angular-data/resource/'], | ||
rank: { | ||
@@ -213,4 +241,23 @@ index: 1, | ||
basic: 3, | ||
advanced: 4 | ||
advanced: 4, | ||
lifecycle: 5 | ||
} | ||
}, | ||
{ | ||
id: 'angular-data-queries', | ||
title: 'Queries', | ||
docs: ['guide/angular-data/queries/'], | ||
rank: { | ||
index: 1, | ||
overview: 2 | ||
} | ||
}, | ||
{ | ||
id: 'angular-data-adapters', | ||
title: 'Adapters', | ||
docs: ['guide/angular-data/adapters/'], | ||
rank: { | ||
index: 1, | ||
overview: 2 | ||
} | ||
} | ||
@@ -226,3 +273,3 @@ ] | ||
{ | ||
id: 'api', | ||
id: 'angular-data', | ||
title: 'angular-data', | ||
@@ -233,2 +280,10 @@ scripts: [ | ||
docs: ['guide/api'] | ||
}, | ||
{ | ||
id: 'angular-cache', | ||
title: 'angular-cache', | ||
scripts: [ | ||
'bower_components/angular-cache/dist/angular-cache.js' | ||
], | ||
docs: ['guide/api'] | ||
} | ||
@@ -243,9 +298,32 @@ ] | ||
docular_partial_navigation: 'guide/nav.html', | ||
docular_partial_footer: 'guide/footer.html' | ||
docular_partial_footer: 'guide/footer.html'//, | ||
// analytics: { | ||
// account: 'UA-46792694-5', | ||
// domainName: 'angular-cache.codetrain.io' | ||
// }, | ||
// discussions: { | ||
// shortName: 'angular-data', | ||
// url: 'http://angular-cache.codetrain.io', | ||
// dev: dev | ||
// } | ||
} | ||
}); | ||
grunt.registerTask('version', function (filePath) { | ||
var file = grunt.file.read(filePath); | ||
file = file.replace(/<%= pkg\.version %>/gi, pkg.version); | ||
grunt.file.write(filePath, file); | ||
}); | ||
grunt.registerTask('test', ['clean:coverage', 'karma:dev']); | ||
grunt.registerTask('doc', ['clean:doc', 'docular', 'concat', 'copy', 'clean:afterDoc', 'uglify:scripts']); | ||
grunt.registerTask('build', ['clean:dist', 'jshint', 'browserify', 'uglify:main']); | ||
grunt.registerTask('build', [ | ||
'clean', | ||
'jshint', | ||
'browserify', | ||
'version:dist/angular-data.js', | ||
'uglify:main' | ||
]); | ||
grunt.registerTask('default', ['build']); | ||
@@ -252,0 +330,0 @@ |
{ | ||
"name": "angular-data", | ||
"description": "Data store for Angular.js.", | ||
"version": "0.6.0", | ||
"version": "0.7.0", | ||
"homepage": "http://github.com/jmdobry/angular-data", | ||
@@ -23,8 +23,8 @@ "repository": { | ||
"grunt": "0.4.2", | ||
"grunt-cli": "0.1.11", | ||
"grunt-browserify": "1.3.0", | ||
"grunt-cli": "0.1.13", | ||
"grunt-browserify": "1.3.1", | ||
"grunt-contrib-clean": "0.5.0", | ||
"load-grunt-tasks": "0.2.1", | ||
"load-grunt-tasks": "0.3.0", | ||
"grunt-docular": "0.1.2", | ||
"grunt-contrib-uglify": "0.2.7", | ||
"grunt-contrib-uglify": "0.3.2", | ||
"grunt-contrib-jshint": "0.8.0", | ||
@@ -36,19 +36,14 @@ "grunt-contrib-copy": "0.5.0", | ||
"karma-firefox-launcher": "~0.1.3", | ||
"karma-html2js-preprocessor": "~0.1.0", | ||
"karma-jasmine": "~0.1.5", | ||
"karma-coffee-preprocessor": "~0.1.2", | ||
"requirejs": "~2.1.10", | ||
"karma-requirejs": "~0.2.1", | ||
"karma-phantomjs-launcher": "~0.1.1", | ||
"karma-phantomjs-launcher": "~0.1.2", | ||
"karma": "~0.10.9", | ||
"grunt-karma": "~0.6.2", | ||
"karma-chai": "0.0.2", | ||
"mocha": "~1.17.0", | ||
"karma-coverage": "~0.1.4", | ||
"karma-chai": "0.1.0", | ||
"mocha": "~1.17.1", | ||
"karma-coverage": "~0.1.2", | ||
"grunt-contrib-watch": "~0.5.3", | ||
"grunt-karma-coveralls": "~2.3.0", | ||
"karma-mocha": "~0.1.1", | ||
"karma-sinon": "~1.0.0", | ||
"time-grunt": "~0.2.8", | ||
"browserify": "~3.20.0" | ||
"karma-sinon": "~1.0.2", | ||
"time-grunt": "~0.2.9", | ||
"browserify": "~3.30.2" | ||
}, | ||
@@ -60,4 +55,4 @@ "scripts": { | ||
"observe-js": "0.1.0", | ||
"mout": "0.8.0" | ||
"mout": "0.9.0" | ||
} | ||
} |
@@ -0,1 +1,6 @@ | ||
/** | ||
* @doc function | ||
* @id DSHttpAdapterProvider | ||
* @name DSHttpAdapterProvider | ||
*/ | ||
function DSHttpAdapterProvider() { | ||
@@ -5,9 +10,56 @@ | ||
/** | ||
* @doc property | ||
* @id DSHttpAdapterProvider.properties:defaults | ||
* @name defaults | ||
* @description | ||
* Default configuration for this adapter. | ||
* | ||
* Properties: | ||
* | ||
* - `{function}` - `serialize` - See [the guide](/documentation/guide/adapters/index). Default: No-op. | ||
* - `{function}` - `deserialize` - See [the guide](/documentation/guide/adapters/index). Default: No-op. | ||
* - `{function}` - `queryTransform` - See [the guide](/documentation/guide/adapters/index). Default: No-op. | ||
*/ | ||
var defaults = this.defaults = { | ||
/** | ||
* @doc property | ||
* @id DSHttpAdapterProvider.properties:defaults.serialize | ||
* @name defaults.serialize | ||
* @description | ||
* Your server might expect a custom request object rather than the plain POJO payload. Use `serialize` to | ||
* create your custom request object. | ||
* | ||
* @param {object} data Data to be sent to the server. | ||
* @returns {*} Returns `data` as-is. | ||
*/ | ||
serialize: function (data) { | ||
return data; | ||
}, | ||
/** | ||
* @doc property | ||
* @id DSHttpAdapterProvider.properties:defaults.deserialize | ||
* @name defaults.deserialize | ||
* @description | ||
* Your server might return a custom response object instead of the plain POJO payload. Use `deserialize` to | ||
* pull the payload out of your response object so angular-data can use it. | ||
* | ||
* @param {object} data Response object from `$http()`. | ||
* @returns {*} Returns `data.data`. | ||
*/ | ||
deserialize: function (data) { | ||
return data.data; | ||
}, | ||
/** | ||
* @doc property | ||
* @id DSHttpAdapterProvider.properties:defaults.queryTransform | ||
* @name defaults.queryTransform | ||
* @description | ||
* Transform the angular-data query to something your server understands. You might just do this on the server instead. | ||
* | ||
* @param {object} query Response object from `$http()`. | ||
* @returns {*} Returns `query` as-is. | ||
*/ | ||
queryTransform: function (query) { | ||
@@ -18,3 +70,18 @@ return query; | ||
/** | ||
* @doc interface | ||
* @id DSHttpAdapter | ||
* @name DSHttpAdapter | ||
* @description | ||
* Default adapter used by angular-data. This adapter uses AJAX and JSON to send/retrieve data to/from a server. | ||
* Developers may provide custom adapters that implement the adapter interface. | ||
*/ | ||
return { | ||
/** | ||
* @doc property | ||
* @id DSHttpAdapter.properties:defaults | ||
* @name defaults | ||
* @description | ||
* Reference to [DSHttpAdapterProvider.defaults](/documentation/api/api/DSHttpAdapterProvider.properties:defaults). | ||
*/ | ||
defaults: defaults, | ||
@@ -143,6 +210,55 @@ | ||
/** | ||
* @doc method | ||
* @id DSHttpAdapter.methods:find | ||
* @name find | ||
* @description | ||
* Retrieve a single entity from the server. | ||
* | ||
* Sends a `GET` request to `:baseUrl/:endpoint/:id`. | ||
* | ||
* @param {object} resourceConfig Properties: | ||
* - `{string}` - `baseUrl` - Base url. | ||
* - `{string=}` - `endpoint` - Endpoint path for the resource. | ||
* @param {string|number} id The primary key of the entity to retrieve. | ||
* @param {object=} options Optional configuration. Refer to the documentation for `$http.get`. | ||
* @returns {Promise} Promise. | ||
*/ | ||
find: find, | ||
/** | ||
* @doc method | ||
* @id DSHttpAdapter.methods:findAll | ||
* @name findAll | ||
* @description | ||
* Retrieve a collection of entities from the server. | ||
* | ||
* Sends a `GET` request to `:baseUrl/:endpoint`. | ||
* | ||
* | ||
* @param {object} resourceConfig Properties: | ||
* - `{string}` - `baseUrl` - Base url. | ||
* - `{string=}` - `endpoint` - Endpoint path for the resource. | ||
* @param {object=} params Search query parameters. See the [query guide](/documentation/guide/queries/index). | ||
* @param {object=} options Optional configuration. Refer to the documentation for `$http.get`. | ||
* @returns {Promise} Promise. | ||
*/ | ||
findAll: findAll, | ||
/** | ||
* @doc method | ||
* @id DSHttpAdapter.methods:findAll | ||
* @name find | ||
* @description | ||
* Create a new entity on the server. | ||
* | ||
* Sends a `POST` request to `:baseUrl/:endpoint`. | ||
* | ||
* @param {object} resourceConfig Properties: | ||
* - `{string}` - `baseUrl` - Base url. | ||
* - `{string=}` - `endpoint` - Endpoint path for the resource. | ||
* @param {object=} params Search query parameters. See the [query guide](/documentation/guide/queries/index). | ||
* @param {object=} options Optional configuration. Refer to the documentation for `$http.post`. | ||
* @returns {Promise} Promise. | ||
*/ | ||
create: create, | ||
@@ -154,2 +270,19 @@ | ||
/** | ||
* @doc method | ||
* @id DSHttpAdapter.methods:update | ||
* @name update | ||
* @description | ||
* Update an entity on the server. | ||
* | ||
* Sends a `PUT` request to `:baseUrl/:endpoint/:id`. | ||
* | ||
* @param {object} resourceConfig Properties: | ||
* - `{string}` - `baseUrl` - Base url. | ||
* - `{string=}` - `endpoint` - Endpoint path for the resource. | ||
* @param {string|number} id The primary key of the entity to update. | ||
* @param {object} attrs The attributes with which to update the entity. See the [query guide](/documentation/guide/queries/index). | ||
* @param {object=} options Optional configuration. Refer to the documentation for `$http.put`. | ||
* @returns {Promise} Promise. | ||
*/ | ||
update: update, | ||
@@ -161,7 +294,38 @@ | ||
/** | ||
* @doc method | ||
* @id DSHttpAdapter.methods:destroy | ||
* @name destroy | ||
* @description | ||
* destroy an entity on the server. | ||
* | ||
* Sends a `PUT` request to `:baseUrl/:endpoint/:id`. | ||
* | ||
* @param {object} resourceConfig Properties: | ||
* - `{string}` - `baseUrl` - Base url. | ||
* - `{string=}` - `endpoint` - Endpoint path for the resource. | ||
* @param {string|number} id The primary key of the entity to destroy. | ||
* @param {object=} options Optional configuration. Refer to the documentation for `$http.delete`. | ||
* @returns {Promise} Promise. | ||
*/ | ||
destroy: destroy, | ||
destroyMany: function () { | ||
throw new Error('Not yet implemented!'); | ||
} | ||
/** | ||
* @doc method | ||
* @id DSHttpAdapter.methods:destroyAll | ||
* @name destroyAll | ||
* @description | ||
* Retrieve a collection of entities from the server. | ||
* | ||
* Sends a `DELETE` request to `:baseUrl/:endpoint`. | ||
* | ||
* | ||
* @param {object} resourceConfig Properties: | ||
* - `{string}` - `baseUrl` - Base url. | ||
* - `{string=}` - `endpoint` - Endpoint path for the resource. | ||
* @param {object=} params Search query parameters. See the [query guide](/documentation/guide/queries/index). | ||
* @param {object=} options Optional configuration. Refer to the documentation for `$http.delete`. | ||
* @returns {Promise} Promise. | ||
*/ | ||
destroyAll: destroyAll | ||
}; | ||
@@ -212,14 +376,4 @@ | ||
/** | ||
* @doc method | ||
* @id DSHttpAdapter.methods:find | ||
* @name find | ||
* @param {object} resourceConfig Properties: | ||
* - `{string}` - `baseUrl` - Base url. | ||
* - `{string=}` - `endpoint` - Endpoint path for the resource. | ||
* @param {string|number} id | ||
* @param {object=} options | ||
* @returns {Promise} Promise. | ||
*/ | ||
function find(resourceConfig, id, options) { | ||
options = options || {}; | ||
return this.GET( | ||
@@ -245,2 +399,3 @@ DSUtils.makePath(resourceConfig.baseUrl, resourceConfig.endpoint, id), | ||
function create(resourceConfig, attrs, options) { | ||
options = options || {}; | ||
return this.POST( | ||
@@ -253,5 +408,5 @@ DSUtils.makePath(resourceConfig.baseUrl, resourceConfig.endpoint), | ||
function update(resourceConfig, attrs, options) { | ||
function update(resourceConfig, id, attrs, options) { | ||
return this.PUT( | ||
DSUtils.makePath(resourceConfig.baseUrl, resourceConfig.endpoint, attrs[resourceConfig.idAttribute]), | ||
DSUtils.makePath(resourceConfig.baseUrl, resourceConfig.endpoint, id), | ||
defaults.serialize(attrs), | ||
@@ -263,2 +418,3 @@ options | ||
function destroy(resourceConfig, id, options) { | ||
options = options || {}; | ||
return this.DEL( | ||
@@ -269,2 +425,15 @@ DSUtils.makePath(resourceConfig.baseUrl, resourceConfig.endpoint, id), | ||
} | ||
function destroyAll(resourceConfig, params, options) { | ||
options = options || {}; | ||
options.params = options.params || {}; | ||
if (options.params.query) { | ||
options.params.query = defaults.queryTransform(options.params.query); | ||
} | ||
DSUtils.deepMixIn(options, params); | ||
return this.DEL( | ||
DSUtils.makePath(resourceConfig.baseUrl, resourceConfig.endpoint), | ||
options | ||
); | ||
} | ||
}]; | ||
@@ -271,0 +440,0 @@ } |
@@ -58,2 +58,3 @@ var errorPrefix = 'DS.create(resourceName, attrs): '; | ||
var definition = this.definitions[resourceName], | ||
resource = this.store[resourceName], | ||
_this = this; | ||
@@ -81,3 +82,7 @@ | ||
.then(function (data) { | ||
return _this.inject(definition.name, data); | ||
var created = _this.inject(definition.name, data), | ||
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); | ||
}); | ||
@@ -84,0 +89,0 @@ |
@@ -55,2 +55,4 @@ var errorPrefix = 'DS.destroy(resourceName, id): '; | ||
deferred.reject(new this.errors.IllegalArgumentError(errorPrefix + 'id: Must be a string or a number!', { id: { actual: typeof id, expected: 'string|number' } })); | ||
} else if (!(id in this.store[resourceName].index)) { | ||
deferred.reject(new this.errors.RuntimeError(errorPrefix + 'id: "' + id + '" not found!')); | ||
} else { | ||
@@ -57,0 +59,0 @@ var definition = this.definitions[resourceName], |
@@ -33,4 +33,4 @@ var errorPrefix = 'DS.find(resourceName, id[, options]): '; | ||
* - `{boolean=}` - `bypassCache` - Bypass the cache. Default: `false`. | ||
* - `{string=}` - `mergeStrategy` - If `findAll` is called, specify the merge strategy that should be used when the new | ||
* items are injected into the data store. Default: `"mergeWithExisting"`. | ||
* - `{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 +61,7 @@ * | ||
} else { | ||
if (!('cacheResponse' in options)) { | ||
options.cacheResponse = true; | ||
} else { | ||
options.cacheResponse = !!options.cacheResponse; | ||
} | ||
try { | ||
@@ -75,6 +80,10 @@ var definition = this.definitions[resourceName], | ||
.then(function (data) { | ||
// Query is no longer pending | ||
delete resource.pendingQueries[id]; | ||
resource.completedQueries[id] = new Date().getTime(); | ||
return _this.inject(resourceName, data); | ||
if (options.cacheResponse) { | ||
// Query is no longer pending | ||
delete resource.pendingQueries[id]; | ||
resource.completedQueries[id] = new Date().getTime(); | ||
return _this.inject(resourceName, data); | ||
} else { | ||
return data; | ||
} | ||
}); | ||
@@ -81,0 +90,0 @@ } |
@@ -43,6 +43,10 @@ var errorPrefix = 'DS.findAll(resourceName, params[, options]): '; | ||
.then(function (data) { | ||
try { | ||
return processResults.apply(_this, [utils, data, resourceName, queryHash]); | ||
} catch (err) { | ||
throw new _this.errors.UnhandledError(err); | ||
if (options.cacheResponse) { | ||
try { | ||
return processResults.apply(_this, [utils, data, resourceName, queryHash]); | ||
} catch (err) { | ||
throw new _this.errors.UnhandledError(err); | ||
} | ||
} else { | ||
return data; | ||
} | ||
@@ -110,4 +114,3 @@ }); | ||
* - `{boolean=}` - `bypassCache` - Bypass the cache. Default: `false`. | ||
* - `{string=}` - `mergeStrategy` - If `findAll` is called, specify the merge strategy that should be used when the new | ||
* items are injected into the data store. Default `"mergeWithExisting"`. | ||
* - `{boolean=}` - `cacheResponse` - Inject the data returned by the server into the data store. Default: `true`. | ||
* | ||
@@ -140,2 +143,7 @@ * @returns {Promise} Promise produced by the `$q` service. | ||
} else { | ||
if (!('cacheResponse' in options)) { | ||
options.cacheResponse = true; | ||
} else { | ||
options.cacheResponse = !!options.cacheResponse; | ||
} | ||
try { | ||
@@ -142,0 +150,0 @@ promise = promise.then(function () { |
@@ -24,2 +24,12 @@ module.exports = { | ||
* @doc method | ||
* @id DS.async_methods:destroyAll | ||
* @name destroyAll | ||
* @methodOf DS | ||
* @description | ||
* See [DS.destroyAll](/documentation/api/api/DS.async_methods:destroyAll). | ||
*/ | ||
destroyAll: require('./destroyAll'), | ||
/** | ||
* @doc method | ||
* @id DS.async_methods:find | ||
@@ -26,0 +36,0 @@ * @name find |
@@ -39,4 +39,2 @@ var errorPrefix = 'DS.refresh(resourceName, id[, options]): '; | ||
* @param {object=} options Optional configuration. Properties: | ||
* - `{string=}` - `mergeStrategy` - Specify what merge strategy is to be used when the fresh item returns from the | ||
* server and needs to be inserted into the data store. Default `"mergeWithExisting"`. | ||
* @returns {false|Promise} `false` if the item doesn't already exist in the data store. A `Promise` if the item does | ||
@@ -43,0 +41,0 @@ * exist in the data store and is being refreshed. |
@@ -31,5 +31,2 @@ var errorPrefix = 'DS.save(resourceName, id[, options]): '; | ||
* @param {object=} options Optional configuration. Properties: | ||
* - `{string=}` - `mergeStrategy` - When the updated item returns from the server, specify the merge strategy that | ||
* should be used when the updated item is injected into the data store. Default: `"mergeWithExisting"`. | ||
* | ||
* @returns {Promise} Promise produced by the `$q` service. | ||
@@ -80,3 +77,3 @@ * | ||
.then(function (attrs) { | ||
return _this.adapters[options.adapter || definition.defaultAdapter].update(definition, attrs, options); | ||
return _this.adapters[options.adapter || definition.defaultAdapter].update(definition, id, attrs, options); | ||
}) | ||
@@ -87,6 +84,6 @@ .then(function (data) { | ||
.then(function (data) { | ||
var saved = _this.inject(definition.name, data, options); | ||
_this.inject(definition.name, data, options); | ||
resource.previousAttributes[id] = _this.utils.deepMixIn({}, data); | ||
resource.saved[id] = _this.utils.updateTimestamp(resource.saved[id]); | ||
return saved; | ||
return _this.get(resourceName, id); | ||
}); | ||
@@ -93,0 +90,0 @@ |
@@ -1,3 +0,2 @@ | ||
var errorPrefix = 'DSProvider.registerAdapter(name, adapter): ', | ||
utils = require('../utils')[0](); | ||
var utils = require('../utils')[0](); | ||
@@ -20,2 +19,6 @@ function lifecycleNoop(resourceName, attrs, cb) { | ||
}; | ||
} else if (utils.isNumber(clause)) { | ||
clause = { | ||
'==': clause | ||
}; | ||
} | ||
@@ -55,3 +58,3 @@ if ('==' in clause) { | ||
/** | ||
* @doc interface | ||
* @doc function | ||
* @id DSProvider | ||
@@ -62,6 +65,27 @@ * @name DSProvider | ||
/** | ||
* @doc property | ||
* @id DSProvider.properties:defaults | ||
* @name defaults | ||
* @description | ||
* See the [configuration guide](/documentation/guide/configure/global). | ||
* | ||
* Properties: | ||
* | ||
* - `{string}` - `baseUrl` | ||
* - `{string}` - `idAttribute` - Default: `"id"` | ||
* - `{string}` - `defaultAdapter` - Default: `"DSHttpAdapter"` | ||
* - `{function}` - `filter` - Default: See [angular-data query language](/documentation/guide/queries/custom). | ||
* - `{function}` - `beforeValidate` - See [](). Default: No-op | ||
* - `{function}` - `validate` - See [](). Default: No-op | ||
* - `{function}` - `afterValidate` - See [](). Default: No-op | ||
* - `{function}` - `beforeCreate` - See [](). Default: No-op | ||
* - `{function}` - `afterCreate` - See [](). Default: No-op | ||
* - `{function}` - `beforeUpdate` - See [](). Default: No-op | ||
* - `{function}` - `afterUpdate` - See [](). Default: No-op | ||
* - `{function}` - `beforeDestroy` - See [](). Default: No-op | ||
* - `{function}` - `afterDestroy` - See [](). Default: No-op | ||
*/ | ||
var defaults = this.defaults = new BaseConfig(); | ||
var defaults = this.defaults = new BaseConfig(), | ||
adapters = this.adapters = {}; | ||
this.$get = [ | ||
@@ -74,4 +98,2 @@ '$rootScope', '$log', '$q', 'DSHttpAdapter', 'DSUtils', 'DSErrors', | ||
adapters.DSHttpAdapter = DSHttpAdapter; | ||
/** | ||
@@ -82,3 +104,5 @@ * @doc interface | ||
* @description | ||
* Data store | ||
* Public data store interface. Consists of several properties and a number of methods. Injectable as `DS`. | ||
* | ||
* See the [guide](/documentation/guide/overview/index). | ||
*/ | ||
@@ -89,11 +113,61 @@ var DS = { | ||
$q: $q, | ||
/** | ||
* @doc property | ||
* @id DS.properties:defaults | ||
* @name defaults | ||
* @description | ||
* Reference to [DSProvider.defaults](/documentation/api/api/DSProvider.properties:defaults). | ||
*/ | ||
defaults: defaults, | ||
/*! | ||
* @doc property | ||
* @id DS.properties:store | ||
* @name store | ||
* @description | ||
* Meta data for each registered resource. | ||
*/ | ||
store: {}, | ||
/*! | ||
* @doc property | ||
* @id DS.properties:definitions | ||
* @name definitions | ||
* @description | ||
* Registered resource definitions available to the data store. | ||
*/ | ||
definitions: {}, | ||
adapters: adapters, | ||
/** | ||
* @doc property | ||
* @id DS.properties:adapters | ||
* @name adapters | ||
* @description | ||
* Registered adapters available to the data store. Object consists of key-values pairs where the key is | ||
* the name of the adapter and the value is the adapter itself. | ||
*/ | ||
adapters: { | ||
DSHttpAdapter: DSHttpAdapter | ||
}, | ||
/** | ||
* @doc property | ||
* @id DS.properties:errors | ||
* @name errors | ||
* @description | ||
* References to the various [error types](/documentation/api/api/errors) used by angular-data. | ||
*/ | ||
errors: DSErrors, | ||
/*! | ||
* @doc property | ||
* @id DS.properties:utils | ||
* @name utils | ||
* @description | ||
* Utility functions used internally by angular-data. | ||
*/ | ||
utils: DSUtils | ||
}; | ||
DSUtils.deepFreeze(syncMethods); | ||
@@ -112,2 +186,3 @@ DSUtils.deepFreeze(asyncMethods); | ||
// Throttle angular-data's digest loop to tenths of a second | ||
// TODO: Is this okay? | ||
return new Date().getTime() / 100 | 0; | ||
@@ -114,0 +189,0 @@ }, function () { |
var errorPrefix = 'DS.eject(resourceName, id): '; | ||
function _eject(definition, resource, id) { | ||
if (id) { | ||
var found = false; | ||
for (var i = 0; i < resource.collection.length; i++) { | ||
if (resource.collection[i][definition.idAttribute] == id) { | ||
found = true; | ||
break; | ||
} | ||
var found = false; | ||
for (var i = 0; i < resource.collection.length; i++) { | ||
if (resource.collection[i][definition.idAttribute] == id) { | ||
found = true; | ||
break; | ||
} | ||
if (found) { | ||
resource.collection.splice(i, 1); | ||
resource.observers[id].close(); | ||
delete resource.observers[id]; | ||
delete resource.index[id]; | ||
delete resource.changes[id]; | ||
delete resource.previousAttributes[id]; | ||
delete resource.modified[id]; | ||
delete resource.saved[id]; | ||
} | ||
} else { | ||
resource.collection = []; | ||
resource.index = {}; | ||
resource.modified = {}; | ||
resource.saved = {}; | ||
resource.changes = {}; | ||
resource.previousAttributes = {}; | ||
} | ||
if (found) { | ||
resource.collection.splice(i, 1); | ||
resource.observers[id].close(); | ||
delete resource.observers[id]; | ||
delete resource.index[id]; | ||
delete resource.changes[id]; | ||
delete resource.previousAttributes[id]; | ||
delete resource.modified[id]; | ||
delete resource.saved[id]; | ||
} | ||
} | ||
@@ -37,5 +28,4 @@ | ||
* @description | ||
* Eject the item of the specified type that has the given primary key from the data store. If no primary key is | ||
* provided, eject all items of the specified type from the data store. Ejection only removes items from the data store | ||
* and does not attempt to delete items on the server. | ||
* Eject the item of the specified type that has the given primary key from the data store. Ejection only removes items | ||
* from the data store and does not attempt to delete items on the server. | ||
* | ||
@@ -47,3 +37,3 @@ * ## Signature: | ||
* | ||
* ## Examples: | ||
* ## Example: | ||
* | ||
@@ -58,12 +48,2 @@ * ```js | ||
* | ||
* Eject all items of the specified type from the data store. | ||
* | ||
* ```js | ||
* DS.filter('document'); // [ { title: 'How to Cook', id: 45 }, { title: 'How to Eat', id: 46 } ] | ||
* | ||
* DS.eject('document'); | ||
* | ||
* DS.filter('document'); // [ ] | ||
* ``` | ||
* | ||
* ## Throws | ||
@@ -76,3 +56,3 @@ * | ||
* @param {string} resourceName The resource type, e.g. 'user', 'comment', etc. | ||
* @param {string|number=} id The primary key of the item to eject. | ||
* @param {string|number} id The primary key of the item to eject. | ||
*/ | ||
@@ -82,3 +62,3 @@ function eject(resourceName, id) { | ||
throw new this.errors.RuntimeError(errorPrefix + resourceName + ' is not a registered resource!'); | ||
} else if (id && !this.utils.isString(id) && !this.utils.isNumber(id)) { | ||
} else if (!this.utils.isString(id) && !this.utils.isNumber(id)) { | ||
throw new this.errors.IllegalArgumentError(errorPrefix + 'id: Must be a string or a number!', { id: { actual: typeof id, expected: 'string|number' } }); | ||
@@ -100,2 +80,3 @@ } | ||
} | ||
delete this.store[resourceName].completedQueries[id]; | ||
} catch (err) { | ||
@@ -102,0 +83,0 @@ throw new this.errors.UnhandledError(err); |
@@ -39,5 +39,2 @@ /* jshint loopfunc: true */ | ||
* - `{boolean=}` - `loadFromServer` - Send the query to server if it has not been sent yet. Default: `false`. | ||
* - `{string=}` - `mergeStrategy` - If `findAll` is called, specify the merge strategy that should be used when the new | ||
* items are injected into the data store. Default: `"mergeWithExisting"`. | ||
* | ||
* @returns {array} The filtered collection of items of the type specified by `resourceName`. | ||
@@ -44,0 +41,0 @@ */ |
@@ -24,2 +24,12 @@ module.exports = { | ||
* @doc method | ||
* @id DS.sync_methods:ejectAll | ||
* @name ejectAll | ||
* @methodOf DS | ||
* @description | ||
* See [DS.ejectAll](/documentation/api/api/DS.sync_methods:ejectAll). | ||
*/ | ||
ejectAll: require('./ejectAll'), | ||
/** | ||
* @doc method | ||
* @id DS.sync_methods:filter | ||
@@ -47,2 +57,3 @@ * @name filter | ||
* @name inject | ||
* @methodOf DS | ||
* @description | ||
@@ -49,0 +60,0 @@ * See [DS.inject](/documentation/api/api/DS.sync_methods:inject). |
@@ -99,3 +99,2 @@ var observe = require('observejs'), | ||
* @param {object=} options Optional configuration. Properties: | ||
* - `{string=}` - `mergeStrategy` - Specify the merge strategy to use if the item is already in the cache. Default: `"mergeWithExisting"`. | ||
* @returns {object|array} A reference to the item that was injected into the data store or an array of references to | ||
@@ -102,0 +101,0 @@ * the items that were injected into the data store. |
@@ -155,5 +155,9 @@ /** | ||
* @description | ||
* `UnhandledError`, `IllegalArgumentError` and `RuntimeError`. | ||
* Various error types that may be thrown by angular-data. | ||
* | ||
* References to the constructor functions of these errors can be found at `DS.errors`. | ||
* - [UnhandledError](/documentation/api/api/errors.types:UnhandledError) | ||
* - [IllegalArgumentError](/documentation/api/api/errors.types:IllegalArgumentError) | ||
* - [RuntimeError](/documentation/api/api/errors.types:RuntimeError) | ||
* | ||
* References to the constructor functions of these errors can be found in `DS.errors`. | ||
*/ | ||
@@ -160,0 +164,0 @@ module.exports = [function () { |
(function (window, angular, undefined) { | ||
'use strict'; | ||
angular.module('angular-data.BinaryHeap', []) | ||
.provider('BinaryHeap', require('./binaryHeap')); | ||
angular.module('angular-data.DS', ['ng', 'angular-data.BinaryHeap']) | ||
/** | ||
* @doc overview | ||
* @id angular-data | ||
* @name angular-data | ||
* @description | ||
* __Version:__ <%= pkg.version %> | ||
* | ||
* ## Install | ||
* | ||
* #### Bower | ||
* ```text | ||
* bower install angular-data | ||
* ``` | ||
* | ||
* Load `dist/angular-data.js` or `dist/angular-data.min.js` onto your web page after Angular.js. | ||
* | ||
* #### Npm | ||
* ```text | ||
* npm install angular-data | ||
* ``` | ||
* | ||
* Load `dist/angular-data.js` or `dist/angular-data.min.js` onto your web page after Angular.js. | ||
* | ||
* #### Manual download | ||
* Download angular-data.<%= pkg.version %>.js from the [Releases](https://github.com/jmdobry/angular-data/releases) | ||
* section of the angular-data GitHub project. | ||
* | ||
* ## Load into Angular | ||
* Your Angular app must depend on the module `"angular-data.DS"` in order to use angular-data. Loading | ||
* angular-data into your app allows you to inject the following: | ||
* | ||
* - `DS` | ||
* - `DSHttpAdapter` | ||
* - `DSUtils` | ||
* - `DSErrors` | ||
* | ||
* [DS](/documentation/api/api/DS) is the Data Store itself, which you will inject often. | ||
* [DSHttpAdapter](/documentation/api/api/DSHttpAdapter) is useful as a wrapper for `$http` and is configurable. | ||
* [DSUtils](/documentation/api/api/DSUtils) has some useful utility methods. | ||
* [DSErrors](/documentation/api/api/DSErrors) provides references to the various errors thrown by the data store. | ||
*/ | ||
angular.module('angular-data.DS', ['ng']) | ||
.service('DSUtils', require('./utils')) | ||
@@ -8,0 +47,0 @@ .service('DSErrors', require('./errors')) |
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
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
25
2
284209
38
2
80
6902
+ Addedmout@0.9.0(transitive)
- Removedmout@0.8.0(transitive)
Updatedmout@0.9.0