angular-data
Advanced tools
Comparing version 0.4.1 to 0.4.2
@@ -5,3 +5,3 @@ { | ||
"description": "Data store for Angular.js.", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"homepage": "http://jmdobry.github.io/angular-data/", | ||
@@ -8,0 +8,0 @@ "repository": { |
/** | ||
* @author Jason Dobry <jason.dobry@gmail.com> | ||
* @file angular-data.min.js | ||
* @version 0.4.1 - Homepage <http://jmdobry.github.io/angular-data/> | ||
* @version 0.4.2 - 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}({1:[function(a,b){function c(a,b){return-1!==d(a,b)}var d=a("./indexOf");b.exports=c},{"./indexOf":3}],2:[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_":9}],3:[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},{}],4:[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":2}],5:[function(a,b){function c(a,b,c){return d.call(a,b,c)}var d=Array.prototype.slice;b.exports=c},{}],6:[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},{}],7:[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":13}],8:[function(a,b){function c(a){return a}b.exports=c},{}],9:[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":18,"./identity":8,"./prop":10}],10:[function(a,b){function c(a){return function(b){return b[a]}}b.exports=c},{}],11:[function(a,b){var c=a("./isKind"),d=Array.isArray||function(a){return c(a,"Array")};b.exports=d},{"./isKind":14}],12:[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":21,"./isArray":11}],13:[function(a,b){function c(a){return d(a,"Function")}var d=a("./isKind");b.exports=c},{"./isKind":14}],14:[function(a,b){function c(a,b){return d(a)===b}var d=a("./kindOf");b.exports=c},{"./kindOf":16}],15:[function(a,b){function c(a){return!!a&&"object"==typeof a&&a.constructor===Object}b.exports=c},{}],16:[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},{}],17:[function(a,b){function c(a){return null==a?"":a.toString()}b.exports=c},{}],18:[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":11,"./forOwn":21}],19:[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":15,"./forOwn":21}],20:[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},{}],21:[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":20,"./hasOwn":22}],22:[function(a,b){function c(a,b){return Object.prototype.hasOwnProperty.call(a,b)}b.exports=c},{}],23:[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":4,"../array/slice":5}],24:[function(a,b){function c(a){return a=d(a),a.toUpperCase()}var d=a("../lang/toString");b.exports=c},{"../lang/toString":17}],observejs:[function(a,b){b.exports=a("q+M0EE")},{}],"q+M0EE":[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===a>>>0}function d(a){return+a}function e(a){return a===Object(a)}function f(a,b){return a===b?0!==a||1/a===1/b:K(a)&&K(b)?!0:a!==a&&b!==b}function g(a){return"string"!=typeof a?!1:(a=a.replace(/\s/g,""),""==a?!0:"."==a[0]?!1:S.test(a))}function h(a){var b=T[a];if(b)return b;if(g(a)){var b=new i(a);return T[a]=b,b}}function i(a){return""==a.trim()?this:c(a)?(this.push(String(a)),this):(a.split(/\./).filter(function(a){return a}).forEach(function(a){this.push(a)},this),H&&this.length&&(this.getValueFrom=this.compiledGetValueFromFn()),void 0)}function j(a){for(var b=0;U>b&&a.check();)a.report(),b++}function k(a){for(var b in a)return!1;return!0}function l(a){return k(a.added)&&k(a.removed)&&k(a.changed)}function m(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 n(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 o(a,b,c,d){if(this.closed=!1,this.object=a,this.callback=b,this.target=c,this.token=d,this.reporting=!0,G){var e=this;this.boundInternalCallback=function(a){e.internalCallback(a)}}p(this),this.connect(),this.sync(!0)}function p(a){W&&(V.push(a),o._allObserversCount++)}function q(a,b,c,d){o.call(this,a,b,c,d)}function r(a,b,c,d){if(!Array.isArray(a))throw Error("Provided object is not an Array");o.call(this,a,b,c,d)}function s(a){this.arr=[],this.callback=a,this.isObserved=!0}function t(a,b,c,d,f){this.value=void 0;var g=h(b);return g?g.length?e(a)?(this.path=g,o.call(this,a,c,d,f),void 0):(this.closed=!0,this.value=void 0,void 0):(this.closed=!0,this.value=a,void 0):(this.closed=!0,this.value=void 0,void 0)}function u(a,b){if("function"==typeof Object.observe){var c=Object.getNotifier(a);return function(d,e){var f={object:a,type:d,name:b};2===arguments.length&&(f.oldValue=e),c.notify(f)}}}function v(a,b,c){for(var d={},e={},f=0;f<b.length;f++){var g=b[f];_[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}}function w(a,b,c,d,e,f){for(var g=f-e+1,h=c-b+1,i=new Array(g),j=0;g>j;j++)i[j]=new Array(h),i[j][0]=j;for(var k=0;h>k;k++)i[0][k]=k;for(var j=1;g>j;j++)for(var k=1;h>k;k++)if(d[e+j-1]===a[b+k-1])i[j][k]=i[j-1][k-1];else{var l=i[j-1][k]+1,m=i[j][k-1]+1;i[j][k]=m>l?l:m}return i}function x(a){for(var b=a.length-1,c=a[0].length-1,d=a[b][c],e=[];b>0||c>0;)if(0!=b)if(0!=c){var f,g=a[b-1][c-1],h=a[b-1][c],i=a[b][c-1];f=i>h?g>h?h:g:g>i?i:g,f==g?(g==d?e.push(ab):(e.push(bb),d=g),b--,c--):f==h?(e.push(db),b--,d=h):(e.push(cb),c--,d=i)}else e.push(db),b--;else e.push(cb),c--;return e.reverse(),e}function y(a,b,c){for(var d=0;c>d;d++)if(a[d]!==b[d])return d;return c}function z(a,b,c){for(var d=a.length,e=b.length,f=0;c>f&&a[--d]===b[--e];)f++;return f}function A(a,b,c){return{index:a,removed:b,addedCount:c}}function B(a,b,c,d,e,f){var g=0,h=0,i=Math.min(c-b,f-e);if(0==b&&0==e&&(g=y(a,d,i)),c==a.length&&f==d.length&&(h=z(a,d,i-g)),b+=g,e+=g,c-=h,f-=h,c-b==0&&f-e==0)return[];if(b==c){for(var j=A(b,[],0);f>e;)j.removed.push(d[e++]);return[j]}if(e==f)return[A(b,[],c-b)];for(var k=x(w(a,b,c,d,e,f)),j=void 0,l=[],m=b,n=e,o=0;o<k.length;o++)switch(k[o]){case ab:j&&(l.push(j),j=void 0),m++,n++;break;case bb:j||(j=A(m,[],0)),j.addedCount++,m++,j.removed.push(d[n]),n++;break;case cb:j||(j=A(m,[],0)),j.addedCount++,m++;break;case db:j||(j=A(m,[],0)),j.removed.push(d[n]),n++}return j&&l.push(j),l}function C(a,b,c,d){return c>b||a>d?-1:b==c||d==a?0:c>a?d>b?b-c:d-c:b>d?d-a:b-a}function D(a,b,c,d){for(var e=A(b,c,d),f=!1,g=0,h=0;h<a.length;h++){var i=a[h];if(i.index+=g,!f){var j=C(e.index,e.index+e.removed.length,i.index,i.index+i.addedCount);if(j>=0){a.splice(h,1),h--,g-=i.addedCount-i.removed.length,e.addedCount+=i.addedCount-j;var k=e.removed.length+i.removed.length-j;if(e.addedCount||k){var c=i.removed;if(e.index<i.index){var l=e.removed.slice(0,i.index-e.index);Array.prototype.push.apply(l,c),c=l}if(e.index+e.removed.length>i.index+i.addedCount){var m=e.removed.slice(i.index+i.addedCount-e.index);Array.prototype.push.apply(c,m)}e.removed=c,i.index<e.index&&(e.index=i.index)}else f=!0}else if(e.index<i.index){f=!0,a.splice(h,0,e),h++;var n=e.addedCount-e.removed.length;i.index+=n,g+=n}}}f||a.push(e)}function E(a,b){for(var e=[],f=0;f<b.length;f++){var g=b[f];switch(g.type){case"splice":D(e,g.index,g.removed.slice(),g.addedCount);break;case"new":case"updated":case"deleted":if(!c(g.name))continue;var h=d(g.name);if(0>h)continue;D(e,h,[g.oldValue],1);break;default:console.error("Unexpected record type: "+JSON.stringify(g))}}return e}function F(a,b){var c=[];return E(a,b).forEach(function(b){return 1==b.addedCount&&1==b.removed.length?(b.removed[0]!==a[b.index]&&c.push(b),void 0):(c=c.concat(B(a,b.index,b.index+b.addedCount,b.removed,0,b.removed.length)),void 0)}),c}var G=b(),H=!1;try{var I=new Function("","return true;");H=I()}catch(J){}var K=a.Number.isNaN||function(b){return"number"==typeof b&&a.isNaN(b)},L="__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},M="[$_a-zA-Z]",N="[$_a-zA-Z0-9]",O=M+"+"+N+"*",P="(?:[0-9]|[1-9]+[0-9]+)",Q="(?:"+O+"|"+P+")",R="(?:"+Q+")(?:\\."+Q+")*",S=new RegExp("^"+R+"$"),T={};i.prototype=L({__proto__:[],toString:function(){return this.join(".")},getValueFrom:function(a){for(var b=0;b<this.length;b++){if(void 0===a||null===a)return;a=a[this[b]]}return a},getValueFromObserved:function(a,b){b.reset();for(var c=0;c<this.length;c++){if(void 0===a||null===a)return b.cleanup(),void 0;b.observe(a),a=a[this[c]]}return a},compiledGetValueFromFn:function(){var a=this.map(function(a){return c(a)?'["'+a+'"]':"."+a}),b="",d="obj";b+="if (obj !== null && obj !== undefined";for(var e=0;e<this.length-1;e++){{this[e]}d+=a[e],b+=" &&\n "+d+" !== null && "+d+" !== undefined"}return b+=")\n",d+=a[e],b+=" return "+d+";\nelse\n return undefined;",new Function("obj",b)},setValueFrom:function(a,b){if(!this.length)return!1;for(var c=0;c<this.length-1;c++){if(void 0===a||null===a)return!1;a=a[this[c]]}return void 0===a||null===a?!1:(a[this[this.length-1]]=b,!0)}});var U=1e3;o.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||(G?(this.testingResults=a,Object.deliverChangeRecords(this.boundInternalCallback),this.testingResults=void 0):j(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){o._errorThrownDuringCallback=!0,console.error("Exception caught during observer callback: "+b)}},reset:function(){this.closed||(G&&(this.reporting=!1,Object.deliverChangeRecords(this.boundInternalCallback),this.reporting=!0),this.sync(!0))}};var V,W=!G||a.forceCollectObservers;o._allObserversCount=0,W&&(V=[]);var X=!1,Y="function"==typeof Object.deliverAllChangeRecords;a.Platform=a.Platform||{},a.Platform.performMicrotaskCheckpoint=function(){if(!X){if(Y)return Object.deliverAllChangeRecords(),void 0;if(W){X=!0;var a=0,b={};do{a++;var c=V;V=[],b.anyChanged=!1;for(var d=0;d<c.length;d++){var e=c[d];e.closed||(G?e.deliver(b):e.check()&&(b.anyChanged=!0,e.report()),V.push(e))}}while(U>a&&b.anyChanged);o._allObserversCount=V.length,X=!1}}},W&&(a.Platform.clearObservers=function(){V=[]}),q.prototype=L({__proto__:o.prototype,connect:function(){G&&Object.observe(this.object,this.boundInternalCallback)},sync:function(){G||(this.oldObject=n(this.object))},check:function(a){var b,c;if(G){if(!a)return!1;c={},b=v(this.object,a,c)}else c=this.oldObject,b=m(this.object,this.oldObject);return l(b)?!1:(this.reportArgs=[b.added||{},b.removed||{},b.changed||{}],this.reportArgs.push(function(a){return c[a]}),!0)},disconnect:function(){G?this.object&&Object.unobserve(this.object,this.boundInternalCallback):this.oldObject=void 0}}),r.prototype=L({__proto__:q.prototype,connect:function(){G&&Array.observe(this.object,this.boundInternalCallback)},sync:function(){G||(this.oldObject=this.object.slice())},check:function(a){var b;if(G){if(!a)return!1;b=F(this.object,a)}else b=B(this.object,0,this.object.length,this.oldObject,0,this.oldObject.length);return b&&b.length?(this.reportArgs=[b],!0):!1}}),r.applySplices=function(a,b,c){c.forEach(function(c){for(var d=[c.index,c.removed.length],e=c.index;e<c.index+c.addedCount;)d.push(b[e]),e++;Array.prototype.splice.apply(a,d)})};var Z=Object.getPrototypeOf({}),$=Object.getPrototypeOf([]);s.prototype={reset:function(){this.isObserved=!this.isObserved},observe:function(a){if(e(a)&&a!==Z&&a!==$){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}},t.prototype=L({__proto__:o.prototype,connect:function(){G&&(this.observedSet=new s(this.boundInternalCallback))},disconnect:function(){this.value=void 0,G&&(this.observedSet.reset(),this.observedSet.cleanup(),this.observedSet=void 0)},check:function(){return this.value=G?this.path.getValueFromObserved(this.object,this.observedSet):this.path.getValueFrom(this.object),f(this.value,this.oldValue)?!1:(this.reportArgs=[this.value,this.oldValue],!0)},sync:function(a){a&&(this.value=G?this.path.getValueFromObserved(this.object,this.observedSet):this.path.getValueFrom(this.object)),this.oldValue=this.value}}),t.getValueAtPath=function(a,b){var c=h(b);if(c)return c.getValueFrom(a)},t.setValueAtPath=function(a,b,c){var d=h(b);d&&d.setValueFrom(a,c)};var _={"new":!0,updated:!0,deleted:!0};t.defineProperty=function(a,b,c){var d=c.object,e=h(c.path),f=u(a,b),g=new t(d,c.path,function(a,b){f&&f("updated",b)});return Object.defineProperty(a,b,{get:function(){return e.getValueFrom(d)},set:function(a){e.setValueFrom(d,a)},configurable:!0}),{close:function(){var c=e.getValueFrom(d);f&&g.deliver(),g.close(),Object.defineProperty(a,b,{value:c,writable:!0,configurable:!0})}}};var ab=0,bb=1,cb=2,db=3;a.Observer=o,a.Observer.hasObjectObserve=G,a.ArrayObserver=r,a.ArrayObserver.calculateSplices=function(a,b){return B(a,0,a.length,b,0,b.length)},a.ObjectObserver=q,a.PathObserver=t,a.Path=i}((c.Number={isNaN:window.isNaN})?c:c)},{}],27:[function(a,b){function c(a,b){var c=$q.defer();f.store[a]?d.isObject(b)||c.reject(new e.IllegalArgumentError(g+"attrs: Must be an object!",{attrs:{actual:typeof b,expected:"object"}})):c.reject(new e.RuntimeError(g+a+" is not a registered resource!"));try{var h=f.store[a],i=this,j=d.makePath(h.baseUrl||f.config.baseUrl,h.endpoint||h.name);h.validate?h.validate(b,null,function(a){a?c.reject(a):i.POST(j,b,null).then(function(a){try{c.resolve(i.inject(h.name,a))}catch(b){c.reject(b)}},c.reject)}):i.POST(j,b,null).then(function(a){try{c.resolve(i.inject(h.name,a))}catch(b){c.reject(b)}},c.reject)}catch(k){c.reject(new e.UnhandledError(k))}return c.promise}var d=a("utils"),e=a("errors"),f=a("services"),g="DS.create(resourceName, attrs): ";b.exports=c},{errors:"hIh4e1",services:"cX8q+p",utils:"uE/lJt"}],28:[function(a,b){function c(a,b){var c=$q.defer();f.store[a]?d.isString(b)||d.isNumber(b)||c.reject(new e.IllegalArgumentError(g+"id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}})):c.reject(new e.RuntimeError(g+a+" is not a registered resource!"));try{var h=f.store[a],i=this,j=d.makePath(h.baseUrl||f.config.baseUrl,h.endpoint||h.name,b);i.DEL(j,null).then(function(){try{i.eject(a,b),c.resolve(b)}catch(d){c.reject(d)}},c.reject)}catch(k){c.reject(new e.UnhandledError(k))}return c.promise}var d=a("utils"),e=a("errors"),f=a("services"),g="DS.destroy(resourceName, id): ";b.exports=c},{errors:"hIh4e1",services:"cX8q+p",utils:"uE/lJt"}],29:[function(a,b){function c(a,b,c){var i=$q.defer();if(c=c||{},f.store[a])if(d.isString(b)||d.isNumber(b))if(d.isObject(c)){var j=this;try{var k=f.store[a];if(b in k.index&&!c.bypassCache)i.resolve(j.get(a,b));else{var l=d.makePath(k.baseUrl||f.config.baseUrl,k.endpoint||k.name,b),m=null;c.bypassCache&&(m={headers:{"Last-Modified":new Date(k.modified[b])}}),g(l,m).then(function(c){try{j.inject(a,c),i.resolve(j.get(a,b))}catch(d){i.reject(d)}},i.reject)}}catch(n){n instanceof e.UnhandledError?i.reject(n):i.reject(new e.UnhandledError(n))}}else i.reject(new e.IllegalArgumentError(h+"options: Must be an object!",{options:{actual:typeof c,expected:"object"}}));else i.reject(new e.IllegalArgumentError(h+"id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}}));else i.reject(new e.RuntimeError(h+a+" is not a registered resource!"));return i.promise}var d=a("utils"),e=a("errors"),f=a("services"),g=a("../../http").GET,h="DS.find(resourceName, id[, options]): ";b.exports=c},{"../../http":34,errors:"hIh4e1",services:"cX8q+p",utils:"uE/lJt"}],30:[function(a,b){function c(a,b,c){var d=h.store[b];a=a||[],delete d.pendingQueries[c],d.completedQueries[c]=(new Date).getTime();for(var e=[],g=0;g<a.length;g++)e.push(a[g]);d.collection=f.mergeArrays(d.collection,a,d.idAttribute||"id"),d.index=f.toLookup(d.collection,d.idAttribute||"id");for(var i=0;i<e.length;i++)d.modified[e[i][d.idAttribute||"id"]]=f.updateTimestamp(d.modified[e[i][d.idAttribute||"id"]]);return d.collectionModified=f.updateTimestamp(d.collectionModified),e}function d(a,b,d,e){var j=h.store[b],k=f.toJson(d);if(e.bypassCache&&delete j.completedQueries[k],k in j.completedQueries)a.resolve(this.filter(b,d,e));else if(!j.pendingQueries[k]){var l=f.makePath(j.baseUrl||h.config.baseUrl,j.endpoint||j.name);j.pendingQueries[k]=i(l,{params:d}).then(function(d){try{a.resolve(c(d,b,k))}catch(e){a.reject(new g.UnhandledError(e))}},a.reject)}}function e(a,b,c){var e=h.$q.defer();if(c=c||{},h.store[a])if(f.isObject(b))if(f.isObject(c))try{d.apply(this,[e,a,b,c])}catch(i){e.reject(new g.UnhandledError(i))}else e.reject(new g.IllegalArgumentError(j+"options: Must be an object!",{options:{actual:typeof c,expected:"object"}}));else e.reject(new g.IllegalArgumentError(j+"params: Must be an object!",{params:{actual:typeof b,expected:"object"}}));else e.reject(new g.RuntimeError(j+a+" is not a registered resource!"));return e.promise}var f=a("utils"),g=a("errors"),h=a("services"),i=a("../../http").GET,j="DS.findAll(resourceName, params[, options]): ";b.exports=e},{"../../http":34,errors:"hIh4e1",services:"cX8q+p",utils:"uE/lJt"}],31:[function(a,b){b.exports={create:a("./create"),destroy:a("./destroy"),find:a("./find"),findAll:a("./findAll"),refresh:a("./refresh"),save:a("./save")}},{"./create":27,"./destroy":28,"./find":29,"./findAll":30,"./refresh":32,"./save":33}],32:[function(a,b){function c(a,b,c){if(c=c||{},!f.store[a])throw new e.RuntimeError(g+a+" is not a registered resource!");if(!d.isString(b)&&!d.isNumber(b))throw new e.IllegalArgumentError("DS.refresh(resourceName, id): id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}});if(!d.isObject(c))throw new e.IllegalArgumentError(g+"options: Must be an object!",{options:{actual:typeof c,expected:"object"}});return b in f.store[a].index?this.find(a,b,!0):!1}var d=a("utils"),e=a("errors"),f=a("services"),g=(a("../../http").PUT,"DS.refresh(resourceName, id): ");b.exports=c},{"../../http":34,errors:"hIh4e1",services:"cX8q+p",utils:"uE/lJt"}],33:[function(a,b){function c(a,b,c,d){var f=this,i=e.makePath(b.baseUrl||g.config.baseUrl,b.endpoint||b.name,c);h(i,b.index[c],null).then(function(g){var h=f.inject(b.name,g,d);b.saved[c]=e.updateTimestamp(b.saved[c]),a.resolve(h)},a.reject)}function d(a,b,d){var h=$q.defer();if(d=d||{},g.store[a])if(e.isString(b)||e.isNumber(b))if(e.isObject(d)){var j=this;try{var k=g.store[a];k.schema?k.schema.validate(k.index[b],function(a){a?h.reject(a):c.call(j,h,k,b,d)}):c.call(j,h,k,b,d)}catch(l){l instanceof f.UnhandledError?h.reject(l):h.reject(new f.UnhandledError(l))}}else h.reject(new f.IllegalArgumentError(i+"id: Must be an object!",{options:{actual:typeof d,expected:"object"}}));else h.reject(new f.IllegalArgumentError(i+"id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}}));else h.reject(new f.RuntimeError(i+a+" is not a registered resource!"));return h.promise}var e=a("utils"),f=a("errors"),g=a("services"),h=a("../../http").PUT,i="DS.save(resourceName, id[, options]): ";b.exports=d},{"../../http":34,errors:"hIh4e1",services:"cX8q+p",utils:"uE/lJt"}],34:[function(a,b){function c(a,b){var c=(new Date).getTime();k.$http(b).success(function(b,d,e,f){k.$log.debug(f.method+" request:"+f.url+" Time taken: "+((new Date).getTime()-c)+"ms",arguments),a.resolve(b)}).error(function(b){k.$log.error(arguments),a.reject(b)})}function d(a){var b=k.$q.defer();try{k.$rootScope.$$phase?c(b,a):k.$rootScope.$apply(function(){c(b,a)})}catch(d){b.reject(new j.UnhandledError(d))}return b.promise}function e(a,b){return b=b||{},d(i.deepMixIn(b,{url:a,method:"GET"}))}function f(a,b,c){return c=c||{},d(i.deepMixIn(c,{url:a,data:b,method:"PUT"}))}function g(a,b,c){return c=c||{},d(i.deepMixIn(c,{url:a,data:b,method:"POST"}))}function h(a,b){return b=b||{},d(i.deepMixIn(b,{url:a,method:"DELETE"}))}var i=a("utils"),j=a("errors"),k=a("services");b.exports={HTTP:d,GET:e,POST:g,PUT:f,DEL:h}},{errors:"hIh4e1",services:"cX8q+p",utils:"uE/lJt"}],35:[function(a,b){function c(a){if(a=a||{},!e.isObject(a))throw new g(i+"options: Must be an object!",{actual:typeof a,expected:"object"});if(!e.isString(a.baseUrl))throw new g(i+"options: Must be an object!",{baseUrl:{actual:typeof a,expected:"object"}});e.deepMixIn(h.config,a)}function d(){this.config=c,this.$get=["$rootScope","$log","$http","$q",function(b,c,d,g){h.$rootScope=b,h.$log=c,h.$http=d,h.$q=g,h.store={};var i={};e.deepMixIn(i,a("./http")),e.deepMixIn(i,a("./sync_methods")),e.deepMixIn(i,a("./async_methods")),i.errors=f,e.deepFreeze(i);var j=b.$new();return j.$watch(function(){return(new Date).getTime()/100|0},function(){i.digest()}),i}]}var e=a("utils"),f=a("errors"),g=f.IllegalArgumentError,h=a("services"),i="DSProvider.config(options): ";b.exports=d},{"./async_methods":31,"./http":34,"./sync_methods":45,errors:"hIh4e1",services:"cX8q+p",utils:"uE/lJt"}],"cX8q+p":[function(a,b){b.exports={config:{idAttribute:"id"},store:{}}},{}],services:[function(a,b){b.exports=a("cX8q+p")},{}],38:[function(a,b){function c(a,b){if(!f.store[a])throw new e.RuntimeError(g+a+" is not a registered resource!");if(!d.isString(b)&&!d.isNumber(b))throw new e.IllegalArgumentError(g+"id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}});try{return d.deepMixIn({},f.store[a].changes[b])}catch(c){throw new e.UnhandledError(c)}}var d=a("utils"),e=a("errors"),f=a("services"),g="DS.changes(resourceName, id): ";b.exports=c},{errors:"hIh4e1",services:"cX8q+p",utils:"uE/lJt"}],39:[function(a,b){function c(a){if(d.isString(a)&&(a={name:a}),!d.isObject(a))throw new e.IllegalArgumentError(g+"definition: Must be an object!",{definition:{actual:typeof a,expected:"object"}});if(!d.isString(a.name))throw new e.IllegalArgumentError(g+"definition.name: Must be a string!",{definition:{name:{actual:typeof a.name,expected:"string"}}});if(a.idAttribute&&!d.isString(a.idAttribute))throw new e.IllegalArgumentError(g+"definition.idAttribute: Must be a string!",{definition:{idAttribute:{actual:typeof a.idAttribute,expected:"string"}}});if(f.store[a.name])throw new e.RuntimeError(g+a.name+" is already registered!");try{f.store[a.name]=a;var b=f.store[a.name];b.collection=[],b.completedQueries={},b.pendingQueries={},b.index={},b.modified={},b.changes={},b.previous_attributes={},b.saved={},b.observers={},b.collectionModified=0,b.idAttribute=b.idAttribute||f.config.idAttribute||"id"}catch(c){throw delete f.store[a.name],new e.UnhandledError(c)}}var d=a("utils"),e=a("errors"),f=a("services"),g="DS.defineResource(definition): ";b.exports=c},{errors:"hIh4e1",services:"cX8q+p",utils:"uE/lJt"}],40:[function(a,b){function c(){try{e.$rootScope.$$phase?f.Platform.performMicrotaskCheckpoint():e.$rootScope.$apply(function(){f.Platform.performMicrotaskCheckpoint()})}catch(a){throw new d.UnhandledError(a)}}var d=(a("utils"),a("errors")),e=a("services"),f=a("observejs");b.exports=c},{errors:"hIh4e1",observejs:"q+M0EE",services:"cX8q+p",utils:"uE/lJt"}],41:[function(a,b){function c(a,b){if(b){for(var c=0;c<a.collection.length&&a.collection[c][a.idAttribute||"id"]!=b;c++);a.collection.splice(c,1),a.observers[b].close(),delete a.observers[b],delete a.index[b],delete a.changes[b],delete a.previous_attributes[b],delete a.modified[b],delete a.saved[b]}else a.collection=[],a.index={},a.modified={};a.collectionModified=e.updateTimestamp(a.collectionModified)}function d(a,b){if(!g.store[a])throw new f.RuntimeError(h+a+" is not a registered resource!");if(b&&!e.isString(b)&&!e.isNumber(b))throw new f.IllegalArgumentError(h+"id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}});try{g.$rootScope.$$phase?c(g.store[a],b):g.$rootScope.$apply(function(){c(g.store[a],b)})}catch(d){throw new f.UnhandledError(d)}}var e=a("utils"),f=a("errors"),g=a("services"),h="DS.eject(resourceName, id): ";b.exports=d},{errors:"hIh4e1",services:"cX8q+p",utils:"uE/lJt"}],42:[function(a,b){function c(a,b,c){if(c=c||{},!f.store[a])throw new e.RuntimeError(g+a+" is not a registered resource!");if(!d.isObject(b))throw new e.IllegalArgumentError(g+"params: Must be an object!",{params:{actual:typeof b,expected:"object"}});if(!d.isObject(c))throw new e.IllegalArgumentError(g+"options: Must be an object!",{options:{actual:typeof c,expected:"object"}});try{var h=f.store[a];b.query=b.query||{};var i=d.toJson(b);i in h.completedQueries||!c.loadFromServer||h.pendingQueries[i]||this.findAll(a,b,c);var j=d.filter(h.collection,function(a){var c=!0;if(b.query.where){if(!d.isObject(b.query.where))throw new e.IllegalArgumentError(g+"params.query.where: Must be an object!",{params:{query:{where:{actual:typeof b.query.where,expected:"object"}}}});d.forOwn(b.query.where,function(b,e){d.isString(b)&&(b={"===":b}),"=="in b?c=c&&a[e]==b["=="]:"==="in b?c=c&&a[e]===b["==="]:"!="in b?c=c&&a[e]!=b["!="]:">"in b?c=c&&a[e]>b[">"]:">="in b?c=c&&a[e]>=b[">="]:"<"in b?c=c&&a[e]<b["<"]:"<="in b?c=c&&a[e]<=b["<="]:"in"in b&&(c=c&&d.contains(b["in"],a[e]))})}return c});if(b.query.orderBy){if(d.isString(b.query.orderBy)&&(b.query.orderBy=[[b.query.orderBy,"ASC"]]),!d.isArray(b.query.orderBy))throw new e.IllegalArgumentError(g+"params.query.orderBy: Must be a string or an array!",{params:{query:{orderBy:{actual:typeof b.query.orderBy,expected:"string|array"}}}});for(var k=0;k<b.query.orderBy.length;k++){if(d.isString(b.query.orderBy[k]))b.query.orderBy[k]=[b.query.orderBy[k],"ASC"];else if(!d.isArray(b.query.orderBy[k]))throw new e.IllegalArgumentError(g+"params.query.orderBy["+k+"]: Must be a string or an array!",{params:{query:{"orderBy[i]":{actual:typeof b.query.orderBy[k],expected:"string|array"}}}});j=d.sort(j,function(a,c){var e=a[b.query.orderBy[k][0]],f=c[b.query.orderBy[k][0]];return d.isString(e)&&(e=d.upperCase(e)),d.isString(f)&&(f=d.upperCase(f)),"DESC"===b.query.orderBy[k][1]?e>f?-1:f>e?1:0:f>e?-1:e>f?1:0})}}return d.isNumber(b.query.limit)&&d.isNumber(b.query.skip)?j=d.slice(j,b.query.skip,b.query.skip+b.query.limit):d.isNumber(b.query.limit)?j=d.slice(j,0,b.query.limit):d.isNumber(b.query.skip)&&(j=d.slice(j,b.query.skip)),j}catch(l){throw l instanceof e.IllegalArgumentError?l:new e.UnhandledError(l)}}var d=a("utils"),e=a("errors"),f=a("services"),g="DS.filter(resourceName, params[, options]): ";b.exports=c},{errors:"hIh4e1",services:"cX8q+p",utils:"uE/lJt"}],43:[function(a,b){function c(a,b,c){if(c=c||{},!f.store[a])throw new e.RuntimeError(g+a+" is not a registered resource!");if(!d.isString(b)&&!d.isNumber(b))throw new e.IllegalArgumentError(g+"id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}});if(!d.isObject(c))throw new e.IllegalArgumentError(g+"options: Must be an object!",{options:{actual:typeof c,expected:"object"}});try{return b in f.store[a].index||!c.loadFromServer||this.find(a,b),f.store[a].index[b]}catch(h){throw new e.UnhandledError(h)}}var d=a("utils"),e=a("errors"),f=a("services"),g="DS.get(resourceName, id[, options]): ";b.exports=c},{errors:"hIh4e1",services:"cX8q+p",utils:"uE/lJt"}],44:[function(a,b){function c(a){return e.isEmpty(a.added)&&e.isEmpty(a.removed)&&e.isEmpty(a.changed)}function d(a,b){if(!g.store[a])throw new f.RuntimeError(h+a+" is not a registered resource!");if(!e.isString(b)&&!e.isNumber(b))throw new f.IllegalArgumentError(h+"id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}});try{return c(g.store[a].changes[b])}catch(d){throw new f.UnhandledError(d)}}var e=a("utils"),f=a("errors"),g=a("services"),h="DS.hasChanges(resourceName, id): ";b.exports=d},{errors:"hIh4e1",services:"cX8q+p",utils:"uE/lJt"}],45:[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":38,"./defineResource":39,"./digest":40,"./eject":41,"./filter":42,"./get":43,"./hasChanges":44,"./inject":46,"./lastModified":47,"./lastSaved":48,"./previous":49}],46:[function(a,b){function c(a,b){var d=this;if(e.isArray(b))for(var i=0;i<b.length;i++)c.call(d,a,b[i]);else{var j=b[a.idAttribute||"id"];j in a.index?(e.deepMixIn(a.index[j],b),a.observers[j].deliver()):(a.index[j]={},a.previous_attributes[j]={},e.deepMixIn(a.index[j],b),e.deepMixIn(a.previous_attributes[j],b),a.collection.push(a.index[j]),a.observers[j]=new h.ObjectObserver(a.index[j],function(b,c,d,h){try{var i=h(a.idAttribute||"id"); | ||
a.index[i][a.idAttribute||"id"]!=i&&(a.index[i][a.idAttribute||"id"]=i,g.$log.error("You cannot change the primary key of an object! Reverting change to primary key.")),a.changes[i]=e.diffObjectFromOldObject(a.index[i],a.previous_attributes[i]),a.modified[i]=e.updateTimestamp(a.modified[i]),a.collectionModified=e.updateTimestamp(a.collectionModified),g.$log.debug("old value:",JSON.stringify(a.previous_attributes[i],null,2)),g.$log.debug("changes:",a.changes[i]),g.$log.debug("new value:",JSON.stringify(a.index[i],null,2))}catch(j){throw g.$log.error(j.stack),new f.UnhandledError(j)}}),a.observers[j].deliver())}}function d(a,b,d){if(d=d||{},!g.store[a])throw new f.RuntimeError(i+a+" is not a registered resource!");if(!e.isObject(b)&&!e.isArray(b))throw new f.IllegalArgumentError(i+"attrs: Must be an object or an array!",{attrs:{actual:typeof b,expected:"object|array"}});if(!e.isObject(d))throw new f.IllegalArgumentError(i+"options: Must be an object!",{options:{actual:typeof d,expected:"object"}});var h=g.store[a],j=this,k=h.idAttribute||"id";if(b[k]){try{g.$rootScope.$$phase?c.apply(j,[g.store[a],b]):g.$rootScope.$apply(function(){c.apply(j,[g.store[a],b])})}catch(l){throw new f.UnhandledError(l)}return h.index[b[k]]}throw new f.RuntimeError(i+"attrs: Must contain the property specified by `idAttribute` in the resource definition!")}var e=a("utils"),f=a("errors"),g=a("services"),h=a("observejs"),i="DS.inject(resourceName, attrs[, options]): ";b.exports=d},{errors:"hIh4e1",observejs:"q+M0EE",services:"cX8q+p",utils:"uE/lJt"}],47:[function(a,b){function c(a,b){if(!f.store[a])throw new e.RuntimeError(g+a+" is not a registered resource!");if(b&&!d.isString(b)&&!d.isNumber(b))throw new e.IllegalArgumentError(g+"id: Must be a string or number!",{id:{actual:typeof b,expected:"string|number"}});try{return b?(b in f.store[a].modified||(f.store[a].modified[b]=0),f.store[a].modified[b]):f.store[a].collectionModified}catch(c){throw new e.UnhandledError(c)}}var d=a("utils"),e=a("errors"),f=a("services"),g="DS.lastModified(resourceName[, id]): ";b.exports=c},{errors:"hIh4e1",services:"cX8q+p",utils:"uE/lJt"}],48:[function(a,b){function c(a,b){if(!f.store[a])throw new e.RuntimeError(g+a+" is not a registered resource!");if(b&&!d.isString(b)&&!d.isNumber(b))throw new e.IllegalArgumentError(g+"id: Must be a string or number!",{id:{actual:typeof b,expected:"string|number"}});try{return b?(b in f.store[a].saved||(f.store[a].saved[b]=0),f.store[a].saved[b]):f.store[a].collectionModified}catch(c){throw new e.UnhandledError(c)}}var d=a("utils"),e=a("errors"),f=a("services"),g="DS.lastSaved(resourceName[, id]): ";b.exports=c},{errors:"hIh4e1",services:"cX8q+p",utils:"uE/lJt"}],49:[function(a,b){function c(a,b){if(!f.store[a])throw new e.RuntimeError(g+a+" is not a registered resource!");if(!d.isString(b)&&!d.isNumber(b))throw new e.IllegalArgumentError(g+"id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}});try{return angular.copy(f.store[a].previous_attributes[b])}catch(c){throw new e.UnhandledError(c)}}var d=a("utils"),e=a("errors"),f=a("services"),g="DS.previous(resourceName, id): ";b.exports=c},{errors:"hIh4e1",services:"cX8q+p",utils:"uE/lJt"}],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||"Validation Error!"}function f(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,f.prototype=Object.create(Error.prototype),f.prototype.constructor=f,b.exports={UnhandledError:c,IllegalArgumentError:d,ValidationError:e,RuntimeError:f}},{}],52:[function(a){!function(b,c){"use strict";c.module("jmdobry.angular-data",["ng"]),c.module("jmdobry.angular-data").provider("DS",a("./datastore"))}(window,window.angular)},{"./datastore":35}],"uE/lJt":[function(a,b){b.exports={isString:angular.isString,isArray:angular.isArray,isObject:angular.isObject,isNumber:angular.isNumber,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},mergeArrays:function(a,b,c){c=c||"id";for(var d=0;d<a.length;d++)for(var e=0;e<b.length;e++)if(a[d][c]==b[e][c]){angular.extend(a[d],b[e]),b.splice(e,1);break}return a.concat(b)},deepFreeze:function c(a){if("function"==typeof Object.freeze){var b,d;Object.freeze(a);for(d in a)b=a[d],a.hasOwnProperty(d)&&"object"==typeof b&&!Object.isFrozen(b)&&c(b)}},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":1,"mout/array/filter":2,"mout/array/slice":5,"mout/array/sort":6,"mout/array/toLookup":7,"mout/lang/isEmpty":12,"mout/object/deepMixIn":19,"mout/object/forOwn":21,"mout/string/makePath":23,"mout/string/upperCase":24}],utils:[function(a,b){b.exports=a("uE/lJt")},{}]},{},[52]); | ||
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}({1:[function(a,b){function c(a,b){return-1!==d(a,b)}var d=a("./indexOf");b.exports=c},{"./indexOf":3}],2:[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_":9}],3:[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},{}],4:[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":2}],5:[function(a,b){function c(a,b,c){return d.call(a,b,c)}var d=Array.prototype.slice;b.exports=c},{}],6:[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},{}],7:[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":13}],8:[function(a,b){function c(a){return a}b.exports=c},{}],9:[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":18,"./identity":8,"./prop":10}],10:[function(a,b){function c(a){return function(b){return b[a]}}b.exports=c},{}],11:[function(a,b){var c=a("./isKind"),d=Array.isArray||function(a){return c(a,"Array")};b.exports=d},{"./isKind":14}],12:[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":21,"./isArray":11}],13:[function(a,b){function c(a){return d(a,"Function")}var d=a("./isKind");b.exports=c},{"./isKind":14}],14:[function(a,b){function c(a,b){return d(a)===b}var d=a("./kindOf");b.exports=c},{"./kindOf":16}],15:[function(a,b){function c(a){return!!a&&"object"==typeof a&&a.constructor===Object}b.exports=c},{}],16:[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},{}],17:[function(a,b){function c(a){return null==a?"":a.toString()}b.exports=c},{}],18:[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":11,"./forOwn":21}],19:[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":15,"./forOwn":21}],20:[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},{}],21:[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":20,"./hasOwn":22}],22:[function(a,b){function c(a,b){return Object.prototype.hasOwnProperty.call(a,b)}b.exports=c},{}],23:[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":4,"../array/slice":5}],24:[function(a,b){function c(a){return a=d(a),a.toUpperCase()}var d=a("../lang/toString");b.exports=c},{"../lang/toString":17}],observejs:[function(a,b){b.exports=a("q+M0EE")},{}],"q+M0EE":[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===a>>>0}function d(a){return+a}function e(a){return a===Object(a)}function f(a,b){return a===b?0!==a||1/a===1/b:K(a)&&K(b)?!0:a!==a&&b!==b}function g(a){return"string"!=typeof a?!1:(a=a.replace(/\s/g,""),""==a?!0:"."==a[0]?!1:S.test(a))}function h(a){var b=T[a];if(b)return b;if(g(a)){var b=new i(a);return T[a]=b,b}}function i(a){return""==a.trim()?this:c(a)?(this.push(String(a)),this):(a.split(/\./).filter(function(a){return a}).forEach(function(a){this.push(a)},this),H&&this.length&&(this.getValueFrom=this.compiledGetValueFromFn()),void 0)}function j(a){for(var b=0;U>b&&a.check();)a.report(),b++}function k(a){for(var b in a)return!1;return!0}function l(a){return k(a.added)&&k(a.removed)&&k(a.changed)}function m(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 n(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 o(a,b,c,d){if(this.closed=!1,this.object=a,this.callback=b,this.target=c,this.token=d,this.reporting=!0,G){var e=this;this.boundInternalCallback=function(a){e.internalCallback(a)}}p(this),this.connect(),this.sync(!0)}function p(a){W&&(V.push(a),o._allObserversCount++)}function q(a,b,c,d){o.call(this,a,b,c,d)}function r(a,b,c,d){if(!Array.isArray(a))throw Error("Provided object is not an Array");o.call(this,a,b,c,d)}function s(a){this.arr=[],this.callback=a,this.isObserved=!0}function t(a,b,c,d,f){this.value=void 0;var g=h(b);return g?g.length?e(a)?(this.path=g,o.call(this,a,c,d,f),void 0):(this.closed=!0,this.value=void 0,void 0):(this.closed=!0,this.value=a,void 0):(this.closed=!0,this.value=void 0,void 0)}function u(a,b){if("function"==typeof Object.observe){var c=Object.getNotifier(a);return function(d,e){var f={object:a,type:d,name:b};2===arguments.length&&(f.oldValue=e),c.notify(f)}}}function v(a,b,c){for(var d={},e={},f=0;f<b.length;f++){var g=b[f];_[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}}function w(a,b,c,d,e,f){for(var g=f-e+1,h=c-b+1,i=new Array(g),j=0;g>j;j++)i[j]=new Array(h),i[j][0]=j;for(var k=0;h>k;k++)i[0][k]=k;for(var j=1;g>j;j++)for(var k=1;h>k;k++)if(d[e+j-1]===a[b+k-1])i[j][k]=i[j-1][k-1];else{var l=i[j-1][k]+1,m=i[j][k-1]+1;i[j][k]=m>l?l:m}return i}function x(a){for(var b=a.length-1,c=a[0].length-1,d=a[b][c],e=[];b>0||c>0;)if(0!=b)if(0!=c){var f,g=a[b-1][c-1],h=a[b-1][c],i=a[b][c-1];f=i>h?g>h?h:g:g>i?i:g,f==g?(g==d?e.push(ab):(e.push(bb),d=g),b--,c--):f==h?(e.push(db),b--,d=h):(e.push(cb),c--,d=i)}else e.push(db),b--;else e.push(cb),c--;return e.reverse(),e}function y(a,b,c){for(var d=0;c>d;d++)if(a[d]!==b[d])return d;return c}function z(a,b,c){for(var d=a.length,e=b.length,f=0;c>f&&a[--d]===b[--e];)f++;return f}function A(a,b,c){return{index:a,removed:b,addedCount:c}}function B(a,b,c,d,e,f){var g=0,h=0,i=Math.min(c-b,f-e);if(0==b&&0==e&&(g=y(a,d,i)),c==a.length&&f==d.length&&(h=z(a,d,i-g)),b+=g,e+=g,c-=h,f-=h,c-b==0&&f-e==0)return[];if(b==c){for(var j=A(b,[],0);f>e;)j.removed.push(d[e++]);return[j]}if(e==f)return[A(b,[],c-b)];for(var k=x(w(a,b,c,d,e,f)),j=void 0,l=[],m=b,n=e,o=0;o<k.length;o++)switch(k[o]){case ab:j&&(l.push(j),j=void 0),m++,n++;break;case bb:j||(j=A(m,[],0)),j.addedCount++,m++,j.removed.push(d[n]),n++;break;case cb:j||(j=A(m,[],0)),j.addedCount++,m++;break;case db:j||(j=A(m,[],0)),j.removed.push(d[n]),n++}return j&&l.push(j),l}function C(a,b,c,d){return c>b||a>d?-1:b==c||d==a?0:c>a?d>b?b-c:d-c:b>d?d-a:b-a}function D(a,b,c,d){for(var e=A(b,c,d),f=!1,g=0,h=0;h<a.length;h++){var i=a[h];if(i.index+=g,!f){var j=C(e.index,e.index+e.removed.length,i.index,i.index+i.addedCount);if(j>=0){a.splice(h,1),h--,g-=i.addedCount-i.removed.length,e.addedCount+=i.addedCount-j;var k=e.removed.length+i.removed.length-j;if(e.addedCount||k){var c=i.removed;if(e.index<i.index){var l=e.removed.slice(0,i.index-e.index);Array.prototype.push.apply(l,c),c=l}if(e.index+e.removed.length>i.index+i.addedCount){var m=e.removed.slice(i.index+i.addedCount-e.index);Array.prototype.push.apply(c,m)}e.removed=c,i.index<e.index&&(e.index=i.index)}else f=!0}else if(e.index<i.index){f=!0,a.splice(h,0,e),h++;var n=e.addedCount-e.removed.length;i.index+=n,g+=n}}}f||a.push(e)}function E(a,b){for(var e=[],f=0;f<b.length;f++){var g=b[f];switch(g.type){case"splice":D(e,g.index,g.removed.slice(),g.addedCount);break;case"new":case"updated":case"deleted":if(!c(g.name))continue;var h=d(g.name);if(0>h)continue;D(e,h,[g.oldValue],1);break;default:console.error("Unexpected record type: "+JSON.stringify(g))}}return e}function F(a,b){var c=[];return E(a,b).forEach(function(b){return 1==b.addedCount&&1==b.removed.length?(b.removed[0]!==a[b.index]&&c.push(b),void 0):(c=c.concat(B(a,b.index,b.index+b.addedCount,b.removed,0,b.removed.length)),void 0)}),c}var G=b(),H=!1;try{var I=new Function("","return true;");H=I()}catch(J){}var K=a.Number.isNaN||function(b){return"number"==typeof b&&a.isNaN(b)},L="__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},M="[$_a-zA-Z]",N="[$_a-zA-Z0-9]",O=M+"+"+N+"*",P="(?:[0-9]|[1-9]+[0-9]+)",Q="(?:"+O+"|"+P+")",R="(?:"+Q+")(?:\\."+Q+")*",S=new RegExp("^"+R+"$"),T={};i.prototype=L({__proto__:[],toString:function(){return this.join(".")},getValueFrom:function(a){for(var b=0;b<this.length;b++){if(void 0===a||null===a)return;a=a[this[b]]}return a},getValueFromObserved:function(a,b){b.reset();for(var c=0;c<this.length;c++){if(void 0===a||null===a)return b.cleanup(),void 0;b.observe(a),a=a[this[c]]}return a},compiledGetValueFromFn:function(){var a=this.map(function(a){return c(a)?'["'+a+'"]':"."+a}),b="",d="obj";b+="if (obj !== null && obj !== undefined";for(var e=0;e<this.length-1;e++){{this[e]}d+=a[e],b+=" &&\n "+d+" !== null && "+d+" !== undefined"}return b+=")\n",d+=a[e],b+=" return "+d+";\nelse\n return undefined;",new Function("obj",b)},setValueFrom:function(a,b){if(!this.length)return!1;for(var c=0;c<this.length-1;c++){if(void 0===a||null===a)return!1;a=a[this[c]]}return void 0===a||null===a?!1:(a[this[this.length-1]]=b,!0)}});var U=1e3;o.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||(G?(this.testingResults=a,Object.deliverChangeRecords(this.boundInternalCallback),this.testingResults=void 0):j(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){o._errorThrownDuringCallback=!0,console.error("Exception caught during observer callback: "+b)}},reset:function(){this.closed||(G&&(this.reporting=!1,Object.deliverChangeRecords(this.boundInternalCallback),this.reporting=!0),this.sync(!0))}};var V,W=!G||a.forceCollectObservers;o._allObserversCount=0,W&&(V=[]);var X=!1,Y="function"==typeof Object.deliverAllChangeRecords;a.Platform=a.Platform||{},a.Platform.performMicrotaskCheckpoint=function(){if(!X){if(Y)return Object.deliverAllChangeRecords(),void 0;if(W){X=!0;var a=0,b={};do{a++;var c=V;V=[],b.anyChanged=!1;for(var d=0;d<c.length;d++){var e=c[d];e.closed||(G?e.deliver(b):e.check()&&(b.anyChanged=!0,e.report()),V.push(e))}}while(U>a&&b.anyChanged);o._allObserversCount=V.length,X=!1}}},W&&(a.Platform.clearObservers=function(){V=[]}),q.prototype=L({__proto__:o.prototype,connect:function(){G&&Object.observe(this.object,this.boundInternalCallback)},sync:function(){G||(this.oldObject=n(this.object))},check:function(a){var b,c;if(G){if(!a)return!1;c={},b=v(this.object,a,c)}else c=this.oldObject,b=m(this.object,this.oldObject);return l(b)?!1:(this.reportArgs=[b.added||{},b.removed||{},b.changed||{}],this.reportArgs.push(function(a){return c[a]}),!0)},disconnect:function(){G?this.object&&Object.unobserve(this.object,this.boundInternalCallback):this.oldObject=void 0}}),r.prototype=L({__proto__:q.prototype,connect:function(){G&&Array.observe(this.object,this.boundInternalCallback)},sync:function(){G||(this.oldObject=this.object.slice())},check:function(a){var b;if(G){if(!a)return!1;b=F(this.object,a)}else b=B(this.object,0,this.object.length,this.oldObject,0,this.oldObject.length);return b&&b.length?(this.reportArgs=[b],!0):!1}}),r.applySplices=function(a,b,c){c.forEach(function(c){for(var d=[c.index,c.removed.length],e=c.index;e<c.index+c.addedCount;)d.push(b[e]),e++;Array.prototype.splice.apply(a,d)})};var Z=Object.getPrototypeOf({}),$=Object.getPrototypeOf([]);s.prototype={reset:function(){this.isObserved=!this.isObserved},observe:function(a){if(e(a)&&a!==Z&&a!==$){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}},t.prototype=L({__proto__:o.prototype,connect:function(){G&&(this.observedSet=new s(this.boundInternalCallback))},disconnect:function(){this.value=void 0,G&&(this.observedSet.reset(),this.observedSet.cleanup(),this.observedSet=void 0)},check:function(){return this.value=G?this.path.getValueFromObserved(this.object,this.observedSet):this.path.getValueFrom(this.object),f(this.value,this.oldValue)?!1:(this.reportArgs=[this.value,this.oldValue],!0)},sync:function(a){a&&(this.value=G?this.path.getValueFromObserved(this.object,this.observedSet):this.path.getValueFrom(this.object)),this.oldValue=this.value}}),t.getValueAtPath=function(a,b){var c=h(b);if(c)return c.getValueFrom(a)},t.setValueAtPath=function(a,b,c){var d=h(b);d&&d.setValueFrom(a,c)};var _={"new":!0,updated:!0,deleted:!0};t.defineProperty=function(a,b,c){var d=c.object,e=h(c.path),f=u(a,b),g=new t(d,c.path,function(a,b){f&&f("updated",b)});return Object.defineProperty(a,b,{get:function(){return e.getValueFrom(d)},set:function(a){e.setValueFrom(d,a)},configurable:!0}),{close:function(){var c=e.getValueFrom(d);f&&g.deliver(),g.close(),Object.defineProperty(a,b,{value:c,writable:!0,configurable:!0})}}};var ab=0,bb=1,cb=2,db=3;a.Observer=o,a.Observer.hasObjectObserve=G,a.ArrayObserver=r,a.ArrayObserver.calculateSplices=function(a,b){return B(a,0,a.length,b,0,b.length)},a.ObjectObserver=q,a.PathObserver=t,a.Path=i}((c.Number={isNaN:window.isNaN})?c:c)},{}],27:[function(a,b){function c(a,b){var c=$q.defer();f.store[a]?d.isObject(b)||c.reject(new e.IllegalArgumentError(g+"attrs: Must be an object!",{attrs:{actual:typeof b,expected:"object"}})):c.reject(new e.RuntimeError(g+a+" is not a registered resource!"));try{var h=f.store[a],i=this,j=d.makePath(h.baseUrl||f.config.baseUrl,h.endpoint||h.name);h.validate?h.validate(b,null,function(a){a?c.reject(a):i.POST(j,b,null).then(function(a){try{c.resolve(i.inject(h.name,a))}catch(b){c.reject(b)}},c.reject)}):i.POST(j,b,null).then(function(a){try{c.resolve(i.inject(h.name,a))}catch(b){c.reject(b)}},c.reject)}catch(k){c.reject(new e.UnhandledError(k))}return c.promise}var d=a("utils"),e=a("errors"),f=a("services"),g="DS.create(resourceName, attrs): ";b.exports=c},{errors:"hIh4e1",services:"cX8q+p",utils:"uE/lJt"}],28:[function(a,b){function c(a,b){var c=$q.defer();f.store[a]?d.isString(b)||d.isNumber(b)||c.reject(new e.IllegalArgumentError(g+"id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}})):c.reject(new e.RuntimeError(g+a+" is not a registered resource!"));try{var h=f.store[a],i=this,j=d.makePath(h.baseUrl||f.config.baseUrl,h.endpoint||h.name,b);i.DEL(j,null).then(function(){try{i.eject(a,b),c.resolve(b)}catch(d){c.reject(d)}},c.reject)}catch(k){c.reject(new e.UnhandledError(k))}return c.promise}var d=a("utils"),e=a("errors"),f=a("services"),g="DS.destroy(resourceName, id): ";b.exports=c},{errors:"hIh4e1",services:"cX8q+p",utils:"uE/lJt"}],29:[function(a,b){function c(a,b,c){var i=$q.defer();if(c=c||{},f.store[a])if(d.isString(b)||d.isNumber(b))if(d.isObject(c)){var j=this;try{var k=f.store[a];if(b in k.index&&!c.bypassCache)i.resolve(j.get(a,b));else{var l=d.makePath(k.baseUrl||f.config.baseUrl,k.endpoint||k.name,b),m=null;c.bypassCache&&(m={headers:{"Last-Modified":new Date(k.modified[b])}}),g(l,m).then(function(c){try{j.inject(a,c),i.resolve(j.get(a,b))}catch(d){i.reject(d)}},i.reject)}}catch(n){n instanceof e.UnhandledError?i.reject(n):i.reject(new e.UnhandledError(n))}}else i.reject(new e.IllegalArgumentError(h+"options: Must be an object!",{options:{actual:typeof c,expected:"object"}}));else i.reject(new e.IllegalArgumentError(h+"id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}}));else i.reject(new e.RuntimeError(h+a+" is not a registered resource!"));return i.promise}var d=a("utils"),e=a("errors"),f=a("services"),g=a("../../http").GET,h="DS.find(resourceName, id[, options]): ";b.exports=c},{"../../http":34,errors:"hIh4e1",services:"cX8q+p",utils:"uE/lJt"}],30:[function(a,b){function c(a,b,c){var d=h.store[b];a=a||[],delete d.pendingQueries[c],d.completedQueries[c]=(new Date).getTime();for(var e=0;e<a.length;e++)this.inject(b,a[e]);return d.index=f.toLookup(d.collection,d.idAttribute||h.config.idAttribute||"id"),d.collectionModified=f.updateTimestamp(d.collectionModified),a}function d(a,b,d,e){var j=h.store[b],k=this,l=f.toJson(d);if(e.bypassCache&&delete j.completedQueries[l],l in j.completedQueries)a.resolve(this.filter(b,d,e));else if(!j.pendingQueries[l]){var m=f.makePath(j.baseUrl||h.config.baseUrl,j.endpoint||j.name);j.pendingQueries[l]=i(m,{params:d}).then(function(d){try{a.resolve(c.apply(k,[d,b,l]))}catch(e){a.reject(new g.UnhandledError(e))}},a.reject)}}function e(a,b,c){var e=h.$q.defer();if(c=c||{},h.store[a])if(f.isObject(b))if(f.isObject(c))try{d.apply(this,[e,a,b,c])}catch(i){e.reject(new g.UnhandledError(i))}else e.reject(new g.IllegalArgumentError(j+"options: Must be an object!",{options:{actual:typeof c,expected:"object"}}));else e.reject(new g.IllegalArgumentError(j+"params: Must be an object!",{params:{actual:typeof b,expected:"object"}}));else e.reject(new g.RuntimeError(j+a+" is not a registered resource!"));return e.promise}var f=a("utils"),g=a("errors"),h=a("services"),i=a("../../http").GET,j="DS.findAll(resourceName, params[, options]): ";b.exports=e},{"../../http":34,errors:"hIh4e1",services:"cX8q+p",utils:"uE/lJt"}],31:[function(a,b){b.exports={create:a("./create"),destroy:a("./destroy"),find:a("./find"),findAll:a("./findAll"),refresh:a("./refresh"),save:a("./save")}},{"./create":27,"./destroy":28,"./find":29,"./findAll":30,"./refresh":32,"./save":33}],32:[function(a,b){function c(a,b,c){if(c=c||{},!f.store[a])throw new e.RuntimeError(g+a+" is not a registered resource!");if(!d.isString(b)&&!d.isNumber(b))throw new e.IllegalArgumentError("DS.refresh(resourceName, id): id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}});if(!d.isObject(c))throw new e.IllegalArgumentError(g+"options: Must be an object!",{options:{actual:typeof c,expected:"object"}});return b in f.store[a].index?this.find(a,b,!0):!1}var d=a("utils"),e=a("errors"),f=a("services"),g=(a("../../http").PUT,"DS.refresh(resourceName, id): ");b.exports=c},{"../../http":34,errors:"hIh4e1",services:"cX8q+p",utils:"uE/lJt"}],33:[function(a,b){function c(a,b,c,d){var f=this,i=e.makePath(b.baseUrl||g.config.baseUrl,b.endpoint||b.name,c);h(i,b.index[c],null).then(function(g){var h=f.inject(b.name,g,d);b.saved[c]=e.updateTimestamp(b.saved[c]),a.resolve(h)},a.reject)}function d(a,b,d){var h=$q.defer();if(d=d||{},g.store[a])if(e.isString(b)||e.isNumber(b))if(e.isObject(d)){var j=this;try{var k=g.store[a];k.schema?k.schema.validate(k.index[b],function(a){a?h.reject(a):c.call(j,h,k,b,d)}):c.call(j,h,k,b,d)}catch(l){l instanceof f.UnhandledError?h.reject(l):h.reject(new f.UnhandledError(l))}}else h.reject(new f.IllegalArgumentError(i+"id: Must be an object!",{options:{actual:typeof d,expected:"object"}}));else h.reject(new f.IllegalArgumentError(i+"id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}}));else h.reject(new f.RuntimeError(i+a+" is not a registered resource!"));return h.promise}var e=a("utils"),f=a("errors"),g=a("services"),h=a("../../http").PUT,i="DS.save(resourceName, id[, options]): ";b.exports=d},{"../../http":34,errors:"hIh4e1",services:"cX8q+p",utils:"uE/lJt"}],34:[function(a,b){function c(a,b){var c=(new Date).getTime();k.$http(b).success(function(b,d,e,f){k.$log.debug(f.method+" request:"+f.url+" Time taken: "+((new Date).getTime()-c)+"ms",arguments),a.resolve(b)}).error(function(b){k.$log.error(arguments),a.reject(b)})}function d(a){var b=k.$q.defer();try{k.$rootScope.$$phase?c(b,a):k.$rootScope.$apply(function(){c(b,a)})}catch(d){b.reject(new j.UnhandledError(d))}return b.promise}function e(a,b){return b=b||{},d(i.deepMixIn(b,{url:a,method:"GET"}))}function f(a,b,c){return c=c||{},d(i.deepMixIn(c,{url:a,data:b,method:"PUT"}))}function g(a,b,c){return c=c||{},d(i.deepMixIn(c,{url:a,data:b,method:"POST"}))}function h(a,b){return b=b||{},d(i.deepMixIn(b,{url:a,method:"DELETE"}))}var i=a("utils"),j=a("errors"),k=a("services");b.exports={HTTP:d,GET:e,POST:g,PUT:f,DEL:h}},{errors:"hIh4e1",services:"cX8q+p",utils:"uE/lJt"}],35:[function(a,b){function c(a){if(a=a||{},!e.isObject(a))throw new g(i+"options: Must be an object!",{actual:typeof a,expected:"object"});if(!e.isString(a.baseUrl))throw new g(i+"options: Must be an object!",{baseUrl:{actual:typeof a,expected:"object"}});e.deepMixIn(h.config,a)}function d(){this.config=c,this.$get=["$rootScope","$log","$http","$q",function(b,c,d,g){h.$rootScope=b,h.$log=c,h.$http=d,h.$q=g,h.store={};var i={};e.deepMixIn(i,a("./http")),e.deepMixIn(i,a("./sync_methods")),e.deepMixIn(i,a("./async_methods")),i.errors=f,e.deepFreeze(i);var j=b.$new();return j.$watch(function(){return(new Date).getTime()/100|0},function(){i.digest()}),i}]}var e=a("utils"),f=a("errors"),g=f.IllegalArgumentError,h=a("services"),i="DSProvider.config(options): ";b.exports=d},{"./async_methods":31,"./http":34,"./sync_methods":45,errors:"hIh4e1",services:"cX8q+p",utils:"uE/lJt"}],services:[function(a,b){b.exports=a("cX8q+p")},{}],"cX8q+p":[function(a,b){b.exports={config:{idAttribute:"id"},store:{}}},{}],38:[function(a,b){function c(a,b){if(!f.store[a])throw new e.RuntimeError(g+a+" is not a registered resource!");if(!d.isString(b)&&!d.isNumber(b))throw new e.IllegalArgumentError(g+"id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}});try{return d.deepMixIn({},f.store[a].changes[b])}catch(c){throw new e.UnhandledError(c)}}var d=a("utils"),e=a("errors"),f=a("services"),g="DS.changes(resourceName, id): ";b.exports=c},{errors:"hIh4e1",services:"cX8q+p",utils:"uE/lJt"}],39:[function(a,b){function c(a){if(d.isString(a)&&(a={name:a}),!d.isObject(a))throw new e.IllegalArgumentError(g+"definition: Must be an object!",{definition:{actual:typeof a,expected:"object"}});if(!d.isString(a.name))throw new e.IllegalArgumentError(g+"definition.name: Must be a string!",{definition:{name:{actual:typeof a.name,expected:"string"}}});if(a.idAttribute&&!d.isString(a.idAttribute))throw new e.IllegalArgumentError(g+"definition.idAttribute: Must be a string!",{definition:{idAttribute:{actual:typeof a.idAttribute,expected:"string"}}});if(f.store[a.name])throw new e.RuntimeError(g+a.name+" is already registered!");try{f.store[a.name]=a;var b=f.store[a.name];b.collection=[],b.completedQueries={},b.pendingQueries={},b.index={},b.modified={},b.changes={},b.previous_attributes={},b.saved={},b.observers={},b.collectionModified=0,b.idAttribute=b.idAttribute||f.config.idAttribute||"id"}catch(c){throw delete f.store[a.name],new e.UnhandledError(c)}}var d=a("utils"),e=a("errors"),f=a("services"),g="DS.defineResource(definition): ";b.exports=c},{errors:"hIh4e1",services:"cX8q+p",utils:"uE/lJt"}],40:[function(a,b){function c(){try{e.$rootScope.$$phase?f.Platform.performMicrotaskCheckpoint():e.$rootScope.$apply(function(){f.Platform.performMicrotaskCheckpoint()})}catch(a){throw new d.UnhandledError(a)}}var d=(a("utils"),a("errors")),e=a("services"),f=a("observejs");b.exports=c},{errors:"hIh4e1",observejs:"q+M0EE",services:"cX8q+p",utils:"uE/lJt"}],41:[function(a,b){function c(a,b){if(b){for(var c=0;c<a.collection.length&&a.collection[c][a.idAttribute||"id"]!=b;c++);a.collection.splice(c,1),a.observers[b].close(),delete a.observers[b],delete a.index[b],delete a.changes[b],delete a.previous_attributes[b],delete a.modified[b],delete a.saved[b]}else a.collection=[],a.index={},a.modified={};a.collectionModified=e.updateTimestamp(a.collectionModified)}function d(a,b){if(!g.store[a])throw new f.RuntimeError(h+a+" is not a registered resource!");if(b&&!e.isString(b)&&!e.isNumber(b))throw new f.IllegalArgumentError(h+"id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}});try{g.$rootScope.$$phase?c(g.store[a],b):g.$rootScope.$apply(function(){c(g.store[a],b)})}catch(d){throw new f.UnhandledError(d)}}var e=a("utils"),f=a("errors"),g=a("services"),h="DS.eject(resourceName, id): ";b.exports=d},{errors:"hIh4e1",services:"cX8q+p",utils:"uE/lJt"}],42:[function(a,b){function c(a,b,c){if(c=c||{},!f.store[a])throw new e.RuntimeError(g+a+" is not a registered resource!");if(!d.isObject(b))throw new e.IllegalArgumentError(g+"params: Must be an object!",{params:{actual:typeof b,expected:"object"}});if(!d.isObject(c))throw new e.IllegalArgumentError(g+"options: Must be an object!",{options:{actual:typeof c,expected:"object"}});try{var h=f.store[a];b.query=b.query||{};var i=d.toJson(b);i in h.completedQueries||!c.loadFromServer||h.pendingQueries[i]||this.findAll(a,b,c);var j=d.filter(h.collection,function(a){var c=!0;if(b.query.where){if(!d.isObject(b.query.where))throw new e.IllegalArgumentError(g+"params.query.where: Must be an object!",{params:{query:{where:{actual:typeof b.query.where,expected:"object"}}}});d.forOwn(b.query.where,function(b,e){d.isString(b)&&(b={"===":b}),"=="in b?c=c&&a[e]==b["=="]:"==="in b?c=c&&a[e]===b["==="]:"!="in b?c=c&&a[e]!=b["!="]:">"in b?c=c&&a[e]>b[">"]:">="in b?c=c&&a[e]>=b[">="]:"<"in b?c=c&&a[e]<b["<"]:"<="in b?c=c&&a[e]<=b["<="]:"in"in b&&(c=c&&d.contains(b["in"],a[e]))})}return c});if(b.query.orderBy){if(d.isString(b.query.orderBy)&&(b.query.orderBy=[[b.query.orderBy,"ASC"]]),!d.isArray(b.query.orderBy))throw new e.IllegalArgumentError(g+"params.query.orderBy: Must be a string or an array!",{params:{query:{orderBy:{actual:typeof b.query.orderBy,expected:"string|array"}}}});for(var k=0;k<b.query.orderBy.length;k++){if(d.isString(b.query.orderBy[k]))b.query.orderBy[k]=[b.query.orderBy[k],"ASC"];else if(!d.isArray(b.query.orderBy[k]))throw new e.IllegalArgumentError(g+"params.query.orderBy["+k+"]: Must be a string or an array!",{params:{query:{"orderBy[i]":{actual:typeof b.query.orderBy[k],expected:"string|array"}}}});j=d.sort(j,function(a,c){var e=a[b.query.orderBy[k][0]],f=c[b.query.orderBy[k][0]];return d.isString(e)&&(e=d.upperCase(e)),d.isString(f)&&(f=d.upperCase(f)),"DESC"===b.query.orderBy[k][1]?e>f?-1:f>e?1:0:f>e?-1:e>f?1:0})}}return d.isNumber(b.query.limit)&&d.isNumber(b.query.skip)?j=d.slice(j,b.query.skip,b.query.skip+b.query.limit):d.isNumber(b.query.limit)?j=d.slice(j,0,b.query.limit):d.isNumber(b.query.skip)&&(j=d.slice(j,b.query.skip)),j}catch(l){throw l instanceof e.IllegalArgumentError?l:new e.UnhandledError(l)}}var d=a("utils"),e=a("errors"),f=a("services"),g="DS.filter(resourceName, params[, options]): ";b.exports=c},{errors:"hIh4e1",services:"cX8q+p",utils:"uE/lJt"}],43:[function(a,b){function c(a,b,c){if(c=c||{},!f.store[a])throw new e.RuntimeError(g+a+" is not a registered resource!");if(!d.isString(b)&&!d.isNumber(b))throw new e.IllegalArgumentError(g+"id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}});if(!d.isObject(c))throw new e.IllegalArgumentError(g+"options: Must be an object!",{options:{actual:typeof c,expected:"object"}});try{return b in f.store[a].index||!c.loadFromServer||this.find(a,b),f.store[a].index[b]}catch(h){throw new e.UnhandledError(h)}}var d=a("utils"),e=a("errors"),f=a("services"),g="DS.get(resourceName, id[, options]): ";b.exports=c},{errors:"hIh4e1",services:"cX8q+p",utils:"uE/lJt"}],44:[function(a,b){function c(a){return e.isEmpty(a.added)&&e.isEmpty(a.removed)&&e.isEmpty(a.changed)}function d(a,b){if(!g.store[a])throw new f.RuntimeError(h+a+" is not a registered resource!");if(!e.isString(b)&&!e.isNumber(b))throw new f.IllegalArgumentError(h+"id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}});try{return c(g.store[a].changes[b])}catch(d){throw new f.UnhandledError(d)}}var e=a("utils"),f=a("errors"),g=a("services"),h="DS.hasChanges(resourceName, id): ";b.exports=d},{errors:"hIh4e1",services:"cX8q+p",utils:"uE/lJt"}],45:[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":38,"./defineResource":39,"./digest":40,"./eject":41,"./filter":42,"./get":43,"./hasChanges":44,"./inject":46,"./lastModified":47,"./lastSaved":48,"./previous":49}],46:[function(a,b){function c(a,b){var d=this;if(e.isArray(b))for(var i=0;i<b.length;i++)c.call(d,a,b[i]);else{var j=b[a.idAttribute||"id"];j in a.index?(e.deepMixIn(a.index[j],b),a.observers[j].deliver()):(a.index[j]={},a.previous_attributes[j]={},e.deepMixIn(a.index[j],b),e.deepMixIn(a.previous_attributes[j],b),a.collection.push(a.index[j]),a.observers[j]=new h.ObjectObserver(a.index[j],function(b,c,d,h){try{var i=h(a.idAttribute||"id"); | ||
a.index[i][a.idAttribute||"id"]!=i&&(a.index[i][a.idAttribute||"id"]=i,g.$log.error("You cannot change the primary key of an object! Reverting change to primary key.")),a.changes[i]=e.diffObjectFromOldObject(a.index[i],a.previous_attributes[i]),a.modified[i]=e.updateTimestamp(a.modified[i]),a.collectionModified=e.updateTimestamp(a.collectionModified)}catch(j){throw new f.UnhandledError(j)}}),a.observers[j].deliver())}}function d(a,b,d){if(d=d||{},!g.store[a])throw new f.RuntimeError(i+a+" is not a registered resource!");if(!e.isObject(b)&&!e.isArray(b))throw new f.IllegalArgumentError(i+"attrs: Must be an object or an array!",{attrs:{actual:typeof b,expected:"object|array"}});if(!e.isObject(d))throw new f.IllegalArgumentError(i+"options: Must be an object!",{options:{actual:typeof d,expected:"object"}});var h=g.store[a],j=this,k=h.idAttribute||"id";if(b[k]){try{g.$rootScope.$$phase?c.apply(j,[g.store[a],b]):g.$rootScope.$apply(function(){c.apply(j,[g.store[a],b])})}catch(l){throw new f.UnhandledError(l)}return h.index[b[k]]}throw new f.RuntimeError(i+"attrs: Must contain the property specified by `idAttribute` in the resource definition!")}var e=a("utils"),f=a("errors"),g=a("services"),h=a("observejs"),i="DS.inject(resourceName, attrs[, options]): ";b.exports=d},{errors:"hIh4e1",observejs:"q+M0EE",services:"cX8q+p",utils:"uE/lJt"}],47:[function(a,b){function c(a,b){if(!f.store[a])throw new e.RuntimeError(g+a+" is not a registered resource!");if(b&&!d.isString(b)&&!d.isNumber(b))throw new e.IllegalArgumentError(g+"id: Must be a string or number!",{id:{actual:typeof b,expected:"string|number"}});try{return b?(b in f.store[a].modified||(f.store[a].modified[b]=0),f.store[a].modified[b]):f.store[a].collectionModified}catch(c){throw new e.UnhandledError(c)}}var d=a("utils"),e=a("errors"),f=a("services"),g="DS.lastModified(resourceName[, id]): ";b.exports=c},{errors:"hIh4e1",services:"cX8q+p",utils:"uE/lJt"}],48:[function(a,b){function c(a,b){if(!f.store[a])throw new e.RuntimeError(g+a+" is not a registered resource!");if(b&&!d.isString(b)&&!d.isNumber(b))throw new e.IllegalArgumentError(g+"id: Must be a string or number!",{id:{actual:typeof b,expected:"string|number"}});try{return b?(b in f.store[a].saved||(f.store[a].saved[b]=0),f.store[a].saved[b]):f.store[a].collectionModified}catch(c){throw new e.UnhandledError(c)}}var d=a("utils"),e=a("errors"),f=a("services"),g="DS.lastSaved(resourceName[, id]): ";b.exports=c},{errors:"hIh4e1",services:"cX8q+p",utils:"uE/lJt"}],49:[function(a,b){function c(a,b){if(!f.store[a])throw new e.RuntimeError(g+a+" is not a registered resource!");if(!d.isString(b)&&!d.isNumber(b))throw new e.IllegalArgumentError(g+"id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}});try{return angular.copy(f.store[a].previous_attributes[b])}catch(c){throw new e.UnhandledError(c)}}var d=a("utils"),e=a("errors"),f=a("services"),g="DS.previous(resourceName, id): ";b.exports=c},{errors:"hIh4e1",services:"cX8q+p",utils:"uE/lJt"}],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||"Validation Error!"}function f(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,f.prototype=Object.create(Error.prototype),f.prototype.constructor=f,b.exports={UnhandledError:c,IllegalArgumentError:d,ValidationError:e,RuntimeError:f}},{}],52:[function(a){!function(b,c){"use strict";c.module("jmdobry.angular-data",["ng"]),c.module("jmdobry.angular-data").provider("DS",a("./datastore"))}(window,window.angular)},{"./datastore":35}],"uE/lJt":[function(a,b){b.exports={isString:angular.isString,isArray:angular.isArray,isObject:angular.isObject,isNumber:angular.isNumber,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 c(a){if("function"==typeof Object.freeze){var b,d;Object.freeze(a);for(d in a)b=a[d],a.hasOwnProperty(d)&&"object"==typeof b&&!Object.isFrozen(b)&&c(b)}},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":1,"mout/array/filter":2,"mout/array/slice":5,"mout/array/sort":6,"mout/array/toLookup":7,"mout/lang/isEmpty":12,"mout/object/deepMixIn":19,"mout/object/forOwn":21,"mout/string/makePath":23,"mout/string/upperCase":24}],utils:[function(a,b){b.exports=a("uE/lJt")},{}]},{},[52]); |
@@ -42,3 +42,3 @@ // an example karma.conf.js | ||
// web server port | ||
port: 8080, | ||
port: 9876, | ||
@@ -45,0 +45,0 @@ // cli runner port |
{ | ||
"name": "angular-data", | ||
"description": "Data store for Angular.js.", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"homepage": "http://github.com/jmdobry/angular-data", | ||
@@ -6,0 +6,0 @@ "repository": { |
@@ -5,3 +5,3 @@ ## angular-data | ||
__Current version:__ 0.4.0 | ||
__Current version:__ 0.4.2 | ||
@@ -12,2 +12,11 @@ Angular-data is in a pre-1.0.0 development stage; the API is fluctuating, not a lot of tests yet, etc. | ||
Pending: | ||
- Roadmap | ||
- Website / documentation | ||
- 100% tested (whatever _that_ means) | ||
- See [issues](https://github.com/jmdobry/angular-data/issues?milestone=8&page=1&state=open) for what's in development | ||
## Changelog | ||
[CHANGELOG.md](https://github.com/jmdobry/angular-data/blob/master/CHANGELOG.md) | ||
## Resources | ||
@@ -14,0 +23,0 @@ |
@@ -16,24 +16,18 @@ var utils = require('utils'), | ||
var temp = []; | ||
// Merge the new values into the cache | ||
for (var i = 0; i < data.length; i++) { | ||
temp.push(data[i]); | ||
this.inject(resourceName, data[i]); | ||
} | ||
// Merge the new values into the cache | ||
resource.collection = utils.mergeArrays(resource.collection, data, resource.idAttribute || 'id'); | ||
// Update the data store's index for this resource | ||
resource.index = utils.toLookup(resource.collection, resource.idAttribute || 'id'); | ||
resource.index = utils.toLookup(resource.collection, resource.idAttribute || services.config.idAttribute || 'id'); | ||
// Update modified timestamp for values that were return by the server | ||
for (var j = 0; j < temp.length; j++) { | ||
resource.modified[temp[j][resource.idAttribute || 'id']] = utils.updateTimestamp(resource.modified[temp[j][resource.idAttribute || 'id']]); | ||
} | ||
// Update modified timestamp of collection | ||
resource.collectionModified = utils.updateTimestamp(resource.collectionModified); | ||
return temp; | ||
return data; | ||
} | ||
function _findAll(deferred, resourceName, params, options) { | ||
var resource = services.store[resourceName]; | ||
var resource = services.store[resourceName], | ||
_this = this; | ||
@@ -55,3 +49,3 @@ var queryHash = utils.toJson(params); | ||
try { | ||
deferred.resolve(processResults(data, resourceName, queryHash)); | ||
deferred.resolve(processResults.apply(_this, [data, resourceName, queryHash])); | ||
} catch (err) { | ||
@@ -58,0 +52,0 @@ deferred.reject(new errors.UnhandledError(err)); |
@@ -38,8 +38,3 @@ var utils = require('utils'), | ||
resource.collectionModified = utils.updateTimestamp(resource.collectionModified); | ||
services.$log.debug('old value:', JSON.stringify(resource.previous_attributes[innerId], null, 2)); | ||
services.$log.debug('changes:', resource.changes[innerId]); | ||
services.$log.debug('new value:', JSON.stringify(resource.index[innerId], null, 2)); | ||
} catch (err) { | ||
services.$log.error(err.stack); | ||
throw new errors.UnhandledError(err); | ||
@@ -46,0 +41,0 @@ } |
@@ -25,15 +25,2 @@ module.exports = { | ||
}, | ||
mergeArrays: function (a, b, mergeKey) { | ||
mergeKey = mergeKey || 'id'; | ||
for (var i = 0; i < a.length; i++) { | ||
for (var j = 0; j < b.length; j++) { | ||
if (a[i][mergeKey] == b[j][mergeKey]) { | ||
angular.extend(a[i], b[j]); | ||
b.splice(j, 1); | ||
break; | ||
} | ||
} | ||
} | ||
return a.concat(b); | ||
}, | ||
deepFreeze: function deepFreeze(o) { | ||
@@ -40,0 +27,0 @@ if (typeof Object.freeze === 'function') { |
@@ -72,3 +72,3 @@ describe('DS.filter(resourceName, params[, options])', function () { | ||
it('should return an empty array if the query has never been made before', function (done) { | ||
$httpBackend.expectGET(new RegExp('\\' + app.baseUrl + '/posts' + '\\?query=.*')).respond(200, p1); | ||
$httpBackend.expectGET(new RegExp('\\' + app.baseUrl + '/posts' + '\\?query=.*')).respond(200, [p1]); | ||
@@ -75,0 +75,0 @@ assert.deepEqual(DS.filter('post', { |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
58
56
300185
6832