angular-data
Advanced tools
Comparing version 0.0.1-SNAPSHOT to 0.4.0
@@ -27,3 +27,7 @@ { | ||
".travis.yml" | ||
] | ||
], | ||
"devDependencies": { | ||
"angular": "~1.2.8", | ||
"angular-mocks": "~1.2.8" | ||
} | ||
} |
/** | ||
* @author Jason Dobry <jason.dobry@gmail.com> | ||
* @file angular-data.min.js | ||
* @version 0.0.1-SNAPSHOT - Homepage <http://jmdobry.github.io/angular-data/> | ||
* @copyright (c) 2014 Jason Dobry <http://jmdobry.github.io/angular-data> | ||
* @version 0.4.0 - Homepage <http://jmdobry.github.io/angular-data/> | ||
* @copyright (c) 2014 Jason Dobry <https://github.com/jmdobry/angular-data> | ||
* @license MIT <https://github.com/jmdobry/angular-data/blob/master/LICENSE> | ||
@@ -10,3 +10,3 @@ * | ||
*/ | ||
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=(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"}],28:[function(a,b){function c(a,b){var c=$q.defer();f[a]?d.isObject(b)||c.reject(new e.IllegalArgumentError("DS.create(resourceName, attrs): attrs: Must be an object!",{attrs:{actual:typeof b,expected:"object"}})):c.reject(new e.RuntimeError("DS.create(resourceName, attrs): "+a+" is not a registered resource!"));try{var g=f[a],h=this;g.validate?g.validate(b,null,function(a){a?c.reject(a):h.POST(g.url,b,null).then(function(a){try{c.resolve(h.inject(g.name,a))}catch(b){c.reject(b)}},c.reject)}):h.POST(g.url,b,null).then(function(a){try{c.resolve(h.inject(g.name,a))}catch(b){c.reject(b)}},c.reject)}catch(i){c.reject(new e.UnhandledError(i))}return c.promise}{var d=a("utils"),e=a("errors"),f=a("store");a("services")}b.exports=c},{errors:"hIh4e1",services:"cX8q+p",store:"hT1bCX",utils:"uE/lJt"}],29:[function(a,b){function c(a,b){var c=$q.defer();f[a]?d.isString(b)||d.isNumber(b)||c.reject(new e.IllegalArgumentError("DS.destroy(resourceName, id): id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}})):c.reject(new e.RuntimeError("DS.destroy(resourceName, id): "+a+" is not a registered resource!"));try{var g=f[a],h=this;h.DEL(d.makePath(g.url,b),null).then(function(){try{h.eject(a,b),c.resolve(b)}catch(d){c.reject(d)}},c.reject)}catch(i){c.reject(new e.UnhandledError(i))}return c.promise}var d=a("utils"),e=a("errors"),f=a("store");b.exports=c},{errors:"hIh4e1",store:"hT1bCX",utils:"uE/lJt"}],30:[function(a,b){function c(a,b,c){var h=$q.defer();f[a]?d.isString(b)||d.isNumber(b)||h.reject(new e.IllegalArgumentError("DS.find(resourceName, id[, forceRefresh]): id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}})):h.reject(new e.RuntimeError("DS.find(resourceName, id[, forceRefresh]): "+a+" is not a registered resource!"));var i=this;try{var j=f[a];b in j.index&&!c?h.resolve(i.get(a,b)):g(d.makePath(j.url,b),null).then(function(c){try{i.inject(a,c),h.resolve(i.get(a,b))}catch(d){h.reject(d)}},h.reject)}catch(k){h.reject(new e.UnhandledError(k))}return h.promise}var d=a("utils"),e=a("errors"),f=a("store"),g=(a("services"),a("../../HTTP").GET);b.exports=c},{"../../HTTP":27,errors:"hIh4e1",services:"cX8q+p",store:"hT1bCX",utils:"uE/lJt"}],31:[function(a,b){function c(a,b,c){var d=h[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 i=h[b],k=f.toJson(d);e&&delete i.completedQueries[k],k in i.completedQueries?a.resolve(this.filter(b,d)):i.pendingQueries[k]||(i.pendingQueries[k]=j(i.url,{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=i.$q.defer();if(b=b||{},h[a])if(f.isObject(b))try{d.apply(this,[e,a,b,c])}catch(j){e.reject(new g.UnhandledError(j))}else e.reject(new g.IllegalArgumentError("DS.findAll(resourceName[, params]): params: Must be an object!",{params:{actual:typeof b,expected:"object"}}));else e.reject(new g.RuntimeError("DS.findAll(resourceName[, params]): "+a+" is not a registered resource!"));return e.promise}var f=a("utils"),g=a("errors"),h=a("store"),i=a("services"),j=a("../../HTTP").GET;b.exports=e},{"../../HTTP":27,errors:"hIh4e1",services:"cX8q+p",store:"hT1bCX",utils:"uE/lJt"}],32:[function(a,b){b.exports={create:a("./create"),destroy:a("./destroy"),find:a("./find"),findAll:a("./findAll"),refresh:a("./refresh"),save:a("./save")}},{"./create":28,"./destroy":29,"./find":30,"./findAll":31,"./refresh":33,"./save":34}],33:[function(a,b){function c(a,b){if(!f[a])throw new e.RuntimeError("DS.refresh(resourceName, id): "+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"}});return b in f[a].index?this.find(a,b,!0):!1}{var d=a("utils"),e=a("errors"),f=a("store");a("../../HTTP").PUT}b.exports=c},{"../../HTTP":27,errors:"hIh4e1",store:"hT1bCX",utils:"uE/lJt"}],34:[function(a,b){function c(a,b,c,d){var f=this;h(e.makePath(b.url,c),d,null).then(function(c){var d=f.inject(b.name,c);b.saved[d[b.idAttribute]]=e.saveTimestamp(b.saved[d[b.idAttribute]]),a.resolve(d)},a.reject)}function d(a,b){var d=$q.defer();g[a]?e.isString(b)||e.isNumber(b)||d.reject(new f.IllegalArgumentError("DS.save(resourceName, id, attrs): id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}})):d.reject(new f.RuntimeError("DS.save(resourceName, id, attrs): "+a+" is not a registered resource!"));var h=this;try{var i=g[a];i.validate?i.validate(i.index[i.idAttribute||"id"],function(a){a?d.reject(a):c.call(h,d,i,b)}):c.call(h,d,i,b)}catch(j){d.reject(new f.UnhandledError(j))}return d.promise}var e=a("utils"),f=a("errors"),g=a("store"),h=(a("services"),a("../../HTTP").PUT);b.exports=d},{"../../HTTP":27,errors:"hIh4e1",services:"cX8q+p",store:"hT1bCX",utils:"uE/lJt"}],35:[function(a,b){b.exports=a(27)},{errors:"hIh4e1",services:"cX8q+p",utils:"uE/lJt"}],36:[function(a,b){function c(){this.$get=["$rootScope","$log","$http","$q",function(b,c,f,g){e.$rootScope=b,e.$log=c,e.$http=f,e.$q=g;var h={};d.deepMixIn(h,a("./http")),d.deepMixIn(h,a("./sync_methods")),d.deepMixIn(h,a("./async_methods")),d.deepFreeze(h);var i=b.$new();return i.$watch(function(){return(new Date).getTime()/100|0},function(){h.digest()}),h}]}var d=a("utils"),e=a("services");b.exports=c},{"./async_methods":32,"./http":35,"./sync_methods":48,services:"cX8q+p",utils:"uE/lJt"}],services:[function(a,b){b.exports=a("cX8q+p")},{}],"cX8q+p":[function(a,b){b.exports={}},{}],hT1bCX:[function(a,b){b.exports={}},{}],store:[function(a,b){b.exports=a("hT1bCX")},{}],41:[function(a,b){function c(a,b){if(!f[a])throw new e.IllegalArgumentError("DS.changes(resourceName, id): "+a+" is not a registered resource!");if(!d.isString(b)&&!d.isNumber(b))throw new e.IllegalArgumentError("DS.changes(resourceName, id): id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}});try{return angular.copy(f[a].changes[b])}catch(c){throw new e.UnhandledError(c)}}var d=a("utils"),e=a("errors"),f=a("store");b.exports=c},{errors:"hIh4e1",store:"hT1bCX",utils:"uE/lJt"}],42:[function(a,b){function c(a){if(d.isString(a)&&(a={name:a}),!d.isObject(a))throw new e.IllegalArgumentError("DS.defineResource(definition): definition: Must be an object!",{definition:{actual:typeof a,expected:"object"}});if(!d.isString(a.name))throw new e.IllegalArgumentError("DS.defineResource(definition): 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("DS.defineResource(definition): definition.idAttribute: Must be a string!",{definition:{idAttribute:{actual:typeof a.idAttribute,expected:"string"}}});if(f[a.name])throw new e.RuntimeError("DS.defineResource(definition): "+a.name+" is already registered!");try{f[a.name]=a;var b=f[a.name];b.url=d.makePath(b.baseUrl,b.endpoint||b.name),b.collection=[],b.completedQueries={},b.pendingQueries={},b.index={},b.modified={},b.changes={},b.previous_attributes={},b.saved={},b.observers={},b.collectionModified=0}catch(c){throw new e.UnhandledError(c)}}var d=a("utils"),e=a("errors"),f=a("store");b.exports=c},{errors:"hIh4e1",store:"hT1bCX",utils:"uE/lJt"}],43:[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("store"),a("services")),f=a("observejs");b.exports=c},{errors:"hIh4e1",observejs:"q+M0EE",services:"cX8q+p",store:"hT1bCX",utils:"uE/lJt"}],44:[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[a])throw new f.RuntimeError("DS.eject(resourceName, id): "+a+" is not a registered resource!");if(b&&!e.isString(b)&&!e.isNumber(b))throw new f.IllegalArgumentError("DS.eject(resourceName, id): id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}});try{h.$rootScope.$$phase?c(g[a],b):h.$rootScope.$apply(function(){c(g[a],b)})}catch(d){throw new f.UnhandledError(d)}}var e=a("utils"),f=a("errors"),g=a("store"),h=a("services");b.exports=d},{errors:"hIh4e1",services:"cX8q+p",store:"hT1bCX",utils:"uE/lJt"}],45:[function(a,b){function c(a,b,c){if(c=c||{},!f[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"}});var h=f[a];b=b||{},b.query=b.query||{};var i=d.toJson(b);if(i in h.completedQueries||!c.loadFromServer){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}),-1!==e.indexOf(".")&&(e=e.split(".")[1]),b["=="]?c="null"==b["=="]?c&&null===a[e]:c&&a[e]==b["=="]:b["!="]?c=c&&a[e]!=b["!="]:b[">"]?c=c&&a[e]>b[">"]:b[">="]?c=c&&a[e]>=b[">="]:b["<"]?c=c&&a[e]<b["<"]:b["<="]?c=c&&a[e]<=b["<="]:b["in"]&&(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 an array!",{params:{query:{orderBy:{actual:typeof b.query.orderBy,expected:"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 an array!",{params:{query:{"orderBy[i]":{actual:typeof b.query.orderBy[k],expected:"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.offset)?j=d.slice(j,b.query.offset,b.query.offset+b.query.limit):d.isNumber(b.query.limit)?j=d.slice(j,0,b.query.limit):d.isNumber(b.query.offset)&&(j=d.slice(j,b.query.offset)),j}return h.pendingQueries[i]||this.findAll(a,b),[]}var d=a("utils"),e=a("errors"),f=a("store"),g="DS.filter(resourceName, params[, options])";b.exports=c},{errors:"hIh4e1",store:"hT1bCX",utils:"uE/lJt"}],46:[function(a,b){function c(a,b){if(!f[a])throw new e.IllegalArgumentError("DS.get(resourceName, id): "+a+" is not a registered resource!");if(!d.isString(b)&&!d.isNumber(b))throw new e.IllegalArgumentError("DS.get(resourceName, id): id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}});try{return b in f[a].index||this.find(a,b),f[a].index[b]}catch(c){throw new e.UnhandledError(c)}}var d=a("utils"),e=a("errors"),f=a("store");b.exports=c},{errors:"hIh4e1",store:"hT1bCX",utils:"uE/lJt"}],47:[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[a])throw new f.IllegalArgumentError("DS.hasChanges(resourceName, id): "+a+" is not a registered resource!");if(!e.isString(b)&&!e.isNumber(b))throw new f.IllegalArgumentError("DS.hasChanges(resourceName, id): id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}});try{return c(g[a].changes[b])}catch(d){throw new f.UnhandledError(d)}}var e=a("utils"),f=a("errors"),g=a("store");b.exports=d},{errors:"hIh4e1",store:"hT1bCX",utils:"uE/lJt"}],48:[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":41,"./defineResource":42,"./digest":43,"./eject":44,"./filter":45,"./get":46,"./hasChanges":47,"./inject":49,"./lastModified":50,"./lastSaved":51,"./previous":52}],49:[function(a,b){function c(a,b){var d=this;if(e.isArray(b))for(var g=0;g<b.length;g++)c.call(d,a,b[g]);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 i.ObjectObserver(a.index[j],function(b,c,d,g){try{var i=g(a.idAttribute||"id");a.index[i][a.idAttribute||"id"]!=i&&(a.index[i][a.idAttribute||"id"]=i,h.$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),h.$log.debug("old value:",JSON.stringify(a.previous_attributes[i],null,2)),h.$log.debug("changes:",a.changes[i]),h.$log.debug("new value:",JSON.stringify(a.index[i],null,2))}catch(j){throw h.$log.error(j.stack),new f.UnhandledError(j)}}),a.observers[j].deliver())}}function d(a,b){if(!g[a])throw new f.RuntimeError("DS.inject(resourceName, attrs): "+a+" is not a registered resource!");if(!e.isObject(b)&&!e.isArray(b))throw new f.IllegalArgumentError("DS.inject(resourceName, attrs): attrs: Must be an object or an array!",{attrs:{actual:typeof b,expected:"object|array"}});var d=g[a],i=this,j=d.idAttribute||"id";if(b[j]){try{h.$rootScope.$$phase?c.apply(i,[g[a],b]):h.$rootScope.$apply(function(){c.apply(i,[g[a],b])})}catch(k){throw new f.UnhandledError(k) | ||
}return d.index[b[j]]}throw new f.RuntimeError("DS.inject(resourceName, attrs): attrs: Must contain the property specified by `idAttribute` in the resource definition!")}var e=a("utils"),f=a("errors"),g=a("store"),h=a("services"),i=a("observejs");b.exports=d},{errors:"hIh4e1",observejs:"q+M0EE",services:"cX8q+p",store:"hT1bCX",utils:"uE/lJt"}],50:[function(a,b){function c(a,b){if(!f[a])throw new e.RuntimeError("DS.lastModified(resourceName[, id]): "+a+" is not a registered resource!");if(b&&!d.isString(b)&&!d.isNumber(b))throw new e.IllegalArgumentError("DS.lastModified(resourceName[, id]): id: Must be a string or number!",{id:{actual:typeof b,expected:"string|number"}});try{return b?(b in f[a].modified||(f[a].modified[b]=0),f[a].modified[b]):f[a].collectionModified}catch(c){throw new e.UnhandledError(c)}}var d=a("utils"),e=a("errors"),f=a("store");b.exports=c},{errors:"hIh4e1",store:"hT1bCX",utils:"uE/lJt"}],51:[function(a,b){function c(a,b){if(!f[a])throw new e.RuntimeError("DS.lastSaved(resourceName[, id]): "+a+" is not a registered resource!");if(b&&!d.isString(b)&&!d.isNumber(b))throw new e.IllegalArgumentError("DS.lastSaved(resourceName[, id]): id: Must be a string or number!",{id:{actual:typeof b,expected:"string|number"}});try{return b?(b in f[a].saved||(f[a].saved[b]=0),f[a].saved[b]):f[a].collectionModified}catch(c){throw new e.UnhandledError(c)}}var d=a("utils"),e=a("errors"),f=a("store");b.exports=c},{errors:"hIh4e1",store:"hT1bCX",utils:"uE/lJt"}],52:[function(a,b){function c(a,b){if(!f[a])throw new e.IllegalArgumentError("DS.previous(resourceName, id): "+a+" is not a registered resource!");if(!d.isString(b)&&!d.isNumber(b))throw new e.IllegalArgumentError("DS.previous(resourceName, id): id: Must be a string or a number!",{id:{actual:typeof b,expected:"string|number"}});try{return angular.copy(f[a].previous_attributes[b])}catch(c){throw new e.UnhandledError(c)}}var d=a("utils"),e=a("errors"),f=a("store");b.exports=c},{errors:"hIh4e1",store:"hT1bCX",utils:"uE/lJt"}],errors:[function(a,b){b.exports=a("hIh4e1")},{}],hIh4e1:[function(a,b){function c(a){Error.call(this),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),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),Error.captureStackTrace(this,this.constructor),this.type=this.constructor.name,this.errors=b||{},this.message=a||"Validation 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={UnhandledError:c,IllegalArgumentError:d,ValidationError:e,RuntimeError:function(a,b){Error.call(this),Error.captureStackTrace(this,this.constructor),this.type=this.constructor.name,this.errors=b||{},this.message=a||"RuntimeError Error!"}}},{}],55:[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":36}],utils:[function(a,b){b.exports=a("uE/lJt")},{}],"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}]},{},[55]); | ||
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(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(!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":47,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:{}}},{}],hT1bCX:[function(a,b){b.exports={}},{}],store:[function(a,b){b.exports=a("hT1bCX")},{}],40:[function(a,b){function c(a,b){if(!f.store[a])throw new e.IllegalArgumentError(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"}],41:[function(a,b){function c(a){if(d.isString(a)&&(a={name:a}),!d.isObject(a))throw new e.IllegalArgumentError("DS.defineResource(definition): definition: Must be an object!",{definition:{actual:typeof a,expected:"object"}});if(!d.isString(a.name))throw new e.IllegalArgumentError("DS.defineResource(definition): 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("DS.defineResource(definition): definition.idAttribute: Must be a string!",{definition:{idAttribute:{actual:typeof a.idAttribute,expected:"string"}}});if(f.store[a.name])throw new e.RuntimeError("DS.defineResource(definition): "+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 new e.UnhandledError(c)}}var d=a("utils"),e=a("errors"),f=a("services");b.exports=c},{errors:"hIh4e1",services:"cX8q+p",utils:"uE/lJt"}],42:[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"}],43:[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("DS.eject(resourceName, id): "+a+" is not a registered resource!");if(b&&!e.isString(b)&&!e.isNumber(b))throw new f.IllegalArgumentError("DS.eject(resourceName, id): 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");b.exports=d},{errors:"hIh4e1",services:"cX8q+p",utils:"uE/lJt"}],44:[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"}],45:[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 b in f.store[a].index||this.find(a,b),f.store[a].index[b]}catch(c){throw new e.UnhandledError(c)}}var d=a("utils"),e=a("errors"),f=a("services"),g="DS.get(resourceName, id): ";b.exports=c},{errors:"hIh4e1",services:"cX8q+p",utils:"uE/lJt"}],46:[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.IllegalArgumentError("DS.hasChanges(resourceName, id): "+a+" is not a registered resource!");if(!e.isString(b)&&!e.isNumber(b))throw new f.IllegalArgumentError("DS.hasChanges(resourceName, id): 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");b.exports=d},{errors:"hIh4e1",services:"cX8q+p",utils:"uE/lJt"}],47:[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":40,"./defineResource":41,"./digest":42,"./eject":43,"./filter":44,"./get":45,"./hasChanges":46,"./inject":48,"./lastModified":49,"./lastSaved":50,"./previous":51}],48:[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){if(!g.store[a])throw new f.RuntimeError("DS.inject(resourceName, attrs): "+a+" is not a registered resource!");if(!e.isObject(b)&&!e.isArray(b))throw new f.IllegalArgumentError("DS.inject(resourceName, attrs): attrs: Must be an object or an array!",{attrs:{actual:typeof b,expected:"object|array"}});var d=g.store[a],h=this,i=d.idAttribute||"id";if(b[i]){try{g.$rootScope.$$phase?c.apply(h,[g.store[a],b]):g.$rootScope.$apply(function(){c.apply(h,[g.store[a],b])})}catch(j){throw new f.UnhandledError(j)}return d.index[b[i]]}throw new f.RuntimeError("DS.inject(resourceName, attrs): 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");b.exports=d},{errors:"hIh4e1",observejs:"q+M0EE",services:"cX8q+p",utils:"uE/lJt"}],49:[function(a,b){function c(a,b){if(!f.store[a])throw new e.RuntimeError("DS.lastModified(resourceName[, id]): "+a+" is not a registered resource!");if(b&&!d.isString(b)&&!d.isNumber(b))throw new e.IllegalArgumentError("DS.lastModified(resourceName[, id]): 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");b.exports=c},{errors:"hIh4e1",services:"cX8q+p",utils:"uE/lJt"}],50:[function(a,b){function c(a,b){if(!f.store[a])throw new e.RuntimeError("DS.lastSaved(resourceName[, id]): "+a+" is not a registered resource!");if(b&&!d.isString(b)&&!d.isNumber(b))throw new e.IllegalArgumentError("DS.lastSaved(resourceName[, id]): 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");b.exports=c},{errors:"hIh4e1",services:"cX8q+p",utils:"uE/lJt"}],51:[function(a,b){function c(a,b){if(!f.store[a])throw new e.IllegalArgumentError(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}},{}],54:[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}],utils:[function(a,b){b.exports=a("uE/lJt")},{}],"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}]},{},[54]); |
@@ -41,2 +41,6 @@ /* | ||
}, | ||
watch: { | ||
files: ['src/**/*.js'], | ||
tasks: ['build'] | ||
}, | ||
uglify: { | ||
@@ -49,3 +53,3 @@ main: { | ||
'* @version <%= pkg.version %> - Homepage <http://jmdobry.github.io/angular-data/>\n' + | ||
'* @copyright (c) 2014 Jason Dobry <http://jmdobry.github.io/angular-data>\n' + | ||
'* @copyright (c) 2014 Jason Dobry <https://github.com/jmdobry/angular-data>\n' + | ||
'* @license MIT <https://github.com/jmdobry/angular-data/blob/master/LICENSE>\n' + | ||
@@ -89,18 +93,21 @@ '*\n' + | ||
} | ||
// }, | ||
// karma: { | ||
// options: { | ||
// configFile: './karma.conf.js' | ||
// }, | ||
// dev: { | ||
// browsers: ['Chrome'], | ||
// autoWatch: true, | ||
// singleRun: false | ||
// }, | ||
// }, | ||
// coveralls: { | ||
// options: { | ||
// coverage_dir: 'coverage' | ||
// } | ||
}, | ||
karma: { | ||
options: { | ||
configFile: './karma.conf.js' | ||
}, | ||
dev: { | ||
browsers: ['Chrome'], | ||
autoWatch: true, | ||
singleRun: false | ||
}, | ||
ci: { | ||
browsers: ['Firefox', 'PhantomJS'] | ||
} | ||
}, | ||
coveralls: { | ||
options: { | ||
coverage_dir: 'coverage' | ||
} | ||
}, | ||
@@ -237,2 +244,3 @@ concat: { | ||
grunt.registerTask('test', ['clean:coverage', 'karma:dev']); | ||
grunt.registerTask('doc', ['clean:doc', 'docular', 'concat', 'copy', 'clean:afterDoc', 'uglify:scripts']); | ||
@@ -242,5 +250,4 @@ grunt.registerTask('build', ['clean:dist', 'jshint', 'browserify', 'uglify:main']); | ||
// Used by the CLI build servers | ||
grunt.registerTask('test-cli', ['karma:1.0.4', 'karma:1.0.5', 'karma:1.0.6', 'karma:1.0.7', 'karma:1.0.8', 'karma:1.1.4', 'karma:1.1.5']); | ||
grunt.registerTask('cli', ['clean', 'jshint', 'copy', 'uglify', 'test-cli', 'coveralls']); | ||
// Used by TravisCI | ||
grunt.registerTask('ci', ['build', 'karma:ci', 'coveralls', 'doc']); | ||
}; |
// an example karma.conf.js | ||
module.exports = function (config) { | ||
config.set({ | ||
// base path, that will be used to resolve files and exclude | ||
basePath: './', | ||
frameworks: ['sinon', 'chai', 'mocha'], | ||
plugins: [ | ||
// these plugins will be require() by Karma | ||
'karma-sinon', | ||
'karma-mocha', | ||
'karma-chai', | ||
'karma-chrome-launcher', | ||
'karma-phantomjs-launcher', | ||
'karma-firefox-launcher', | ||
'karma-coverage' | ||
], | ||
autoWatch: false, | ||
browsers: ['Chrome'], | ||
config.set({ | ||
// base path, that will be used to resolve files and exclude | ||
basePath: './', | ||
frameworks: ['sinon', 'chai', 'mocha'], | ||
plugins: [ | ||
// these plugins will be require() by Karma | ||
'karma-sinon', | ||
'karma-mocha', | ||
'karma-chai', | ||
'karma-chrome-launcher', | ||
'karma-phantomjs-launcher', | ||
'karma-firefox-launcher', | ||
'karma-coverage' | ||
], | ||
autoWatch: false, | ||
browsers: ['Chrome'], | ||
// list of files / patterns to load in the browser | ||
files: [ | ||
'bower_components/angular/angular.js', | ||
'bower_components/angular-mocks/angular-mocks.js', | ||
'karma.start.js', | ||
'dist/angular-data.js', | ||
'test/**/*.js' | ||
], | ||
// list of files / patterns to load in the browser | ||
files: [ | ||
'bower_components/angular/angular.js', | ||
'bower_components/angular-mocks/angular-mocks.js', | ||
'dist/angular-data.js', | ||
'test/**/*.js', | ||
'karma.start.js' | ||
], | ||
reporters: ['progress', 'coverage'], | ||
reporters: ['progress', 'coverage'], | ||
preprocessors: { | ||
'dist/angular-data.js': ['coverage'] | ||
}, | ||
preprocessors: { | ||
'dist/angular-data.js': ['coverage'] | ||
}, | ||
// optionally, configure the reporter | ||
coverageReporter: { | ||
type : 'html', | ||
dir : 'coverage/' | ||
}, | ||
// optionally, configure the reporter | ||
coverageReporter: { | ||
type: 'lcov', | ||
dir: 'coverage/' | ||
}, | ||
// web server port | ||
port: 8080, | ||
// web server port | ||
port: 8080, | ||
// cli runner port | ||
runnerPort: 9100, | ||
// cli runner port | ||
runnerPort: 9100, | ||
// enable / disable colors in the output (reporters and logs) | ||
colors: true, | ||
// enable / disable colors in the output (reporters and logs) | ||
colors: true, | ||
// level of logging | ||
logLevel: config.LOG_INFO, | ||
// level of logging | ||
logLevel: config.LOG_INFO, | ||
// If browser does not capture in given timeout [ms], kill it | ||
captureTimeout: 30000, | ||
// If browser does not capture in given timeout [ms], kill it | ||
captureTimeout: 30000, | ||
// Continuous Integration mode | ||
// if true, it capture browsers, run tests and exit | ||
singleRun: false | ||
}); | ||
// Continuous Integration mode | ||
// if true, it capture browsers, run tests and exit | ||
singleRun: true | ||
}); | ||
}; |
// Setup global test variables | ||
var $rootScope, $q, $log; | ||
var $rootScope, $q, $log, DS, app, $httpBackend, p1, p2, p3, p4; | ||
// Helper globals | ||
var fail = function (msg) { | ||
assert.equal('should not reach this!: ' + msg, 'failure'); | ||
}, | ||
TYPES_EXCEPT_STRING = [123, 123.123, null, undefined, {}, [], true, false, function () {}], | ||
TYPES_EXCEPT_STRING_OR_ARRAY = [123, 123.123, null, undefined, {}, true, false, function () {}], | ||
TYPES_EXCEPT_ARRAY = ['string', 123, 123.123, null, undefined, {}, true, false, function () {}], | ||
TYPES_EXCEPT_STRING_OR_NUMBER = [null, undefined, {}, [], true, false, function () {}], | ||
TYPES_EXCEPT_STRING_OR_ARRAY_OR_NUMBER = [null, undefined, {}, true, false, function () {}], | ||
TYPES_EXCEPT_NUMBER = ['string', null, undefined, {}, [], true, false, function () {}], | ||
TYPES_EXCEPT_OBJECT = ['string', 123, 123.123, null, undefined, true, false, function () {}], | ||
TYPES_EXCEPT_BOOLEAN = ['string', 123, 123.123, null, undefined, {}, [], function () {}], | ||
TYPES_EXCEPT_FUNCTION = ['string', 123, 123.123, null, undefined, {}, [], true, false]; | ||
assert.equal('should not reach this!: ' + msg, 'failure'); | ||
}, | ||
TYPES_EXCEPT_STRING = [123, 123.123, null, undefined, {}, [], true, false, function () { | ||
}], | ||
TYPES_EXCEPT_STRING_OR_ARRAY = [123, 123.123, null, undefined, {}, true, false, function () { | ||
}], | ||
TYPES_EXCEPT_ARRAY = ['string', 123, 123.123, null, undefined, {}, true, false, function () { | ||
}], | ||
TYPES_EXCEPT_STRING_OR_NUMBER = [null, undefined, {}, [], true, false, function () { | ||
}], | ||
TYPES_EXCEPT_STRING_OR_ARRAY_OR_NUMBER = [null, undefined, {}, true, false, function () { | ||
}], | ||
TYPES_EXCEPT_NUMBER = ['string', null, undefined, {}, [], true, false, function () { | ||
}], | ||
TYPES_EXCEPT_OBJECT = ['string', 123, 123.123, null, undefined, true, false, function () { | ||
}], | ||
TYPES_EXCEPT_BOOLEAN = ['string', 123, 123.123, null, undefined, {}, [], function () { | ||
}], | ||
TYPES_EXCEPT_FUNCTION = ['string', 123, 123.123, null, undefined, {}, [], true, false]; | ||
angular.module('jmdobry.angular-data', ['ng', 'jmdobry.binary-heap', 'ngMock']); | ||
angular.module('app', ['ng', 'jmdobry.angular-data']); | ||
beforeEach(module('jmdobry.angular-data')); | ||
// Setup before each test | ||
beforeEach(inject(function (_$rootScope_, _$q_) { | ||
// Setup global mocks | ||
$q = _$q_; | ||
$rootScope = _$rootScope_; | ||
$log = { | ||
warn: function () {}, | ||
log: function () {}, | ||
info: function () {}, | ||
error: function () {}, | ||
debug: function () {} | ||
}; | ||
beforeEach(function (done) { | ||
module('app'); | ||
inject(function (_$rootScope_, _$q_, _$httpBackend_, _DS_) { | ||
// Setup global mocks | ||
$q = _$q_; | ||
$rootScope = _$rootScope_; | ||
DS = _DS_; | ||
$httpBackend = _$httpBackend_; | ||
app = { | ||
baseUrl: 'http://test.angular-cache.com' | ||
}; | ||
DS.defineResource({ | ||
name: 'post', | ||
endpoint: '/posts', | ||
baseUrl: app.baseUrl | ||
}); | ||
$log = { | ||
warn: function () { | ||
}, | ||
log: function () { | ||
}, | ||
info: function () { | ||
}, | ||
error: function () { | ||
}, | ||
debug: function () { | ||
} | ||
}; | ||
// Setup global spies | ||
sinon.spy($log, 'warn'); | ||
sinon.spy($log, 'log'); | ||
sinon.spy($log, 'info'); | ||
sinon.spy($log, 'error'); | ||
sinon.spy($log, 'debug'); | ||
})); | ||
// Setup global spies | ||
sinon.spy($log, 'warn'); | ||
sinon.spy($log, 'log'); | ||
sinon.spy($log, 'info'); | ||
sinon.spy($log, 'error'); | ||
sinon.spy($log, 'debug'); | ||
}); | ||
p1 = { author: 'John', age: 30, id: 5 }; | ||
p2 = { author: 'Sally', age: 31, id: 6 }; | ||
p3 = { author: 'Mike', age: 32, id: 7 }; | ||
p4 = { author: 'Adam', age: 33, id: 8 }; | ||
done(); | ||
}); | ||
// Clean up after each test | ||
afterEach(function () { | ||
// Tear down global spies | ||
$log.warn.restore(); | ||
$log.log.restore(); | ||
$log.info.restore(); | ||
$log.error.restore(); | ||
$log.debug.restore(); | ||
// Tear down global spies | ||
$log.warn.restore(); | ||
$log.log.restore(); | ||
$log.info.restore(); | ||
$log.error.restore(); | ||
$log.debug.restore(); | ||
$httpBackend.verifyNoOutstandingExpectation(); | ||
$httpBackend.verifyNoOutstandingRequest(); | ||
}); |
{ | ||
"name": "angular-data", | ||
"description": "Data store for Angular.js.", | ||
"version": "0.0.1-SNAPSHOT", | ||
"homepage": "http://jmdobry.github.io/angular-data", | ||
"version": "0.4.0", | ||
"homepage": "http://github.com/jmdobry/angular-data", | ||
"repository": { | ||
@@ -24,29 +24,38 @@ "type": "git", | ||
"grunt-cli": "0.1.11", | ||
"browserify": "3.18.0", | ||
"grunt-browserify": "1.3.0", | ||
"grunt-contrib-clean": "0.5.0", | ||
"load-grunt-tasks": "0.2.1", | ||
"time-grunt": "0.2.7", | ||
"mout": "0.8.0", | ||
"grunt-docular": "0.1.2", | ||
"grunt-contrib-uglify": "0.2.7", | ||
"grunt-contrib-jshint": "0.8.0", | ||
"karma": "0.11.12", | ||
"karma-phantomjs-launcher": "0.1.1", | ||
"karma-mocha": "0.1.1", | ||
"karma-chrome-launcher": "0.1.2", | ||
"karma-firefox-launcher": "0.1.3", | ||
"karma-sinon": "1.0.0", | ||
"karma-coverage": "0.1.4", | ||
"grunt-contrib-copy": "0.5.0", | ||
"grunt-contrib-concat": "0.3.0", | ||
"karma-script-launcher": "~0.1.0", | ||
"karma-chrome-launcher": "~0.1.2", | ||
"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": "~0.10.9", | ||
"grunt-karma": "~0.6.2", | ||
"karma-chai": "0.0.2", | ||
"grunt-contrib-copy": "0.5.0", | ||
"grunt-contrib-concat": "0.3.0" | ||
"mocha": "~1.17.0", | ||
"karma-coverage": "~0.1.4", | ||
"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" | ||
}, | ||
"scripts": { | ||
"test": "node node_modules/grunt-cli/bin/grunt build", | ||
"test_travis": "node node_modules/grunt-cli/bin/grunt travis" | ||
"test": "node node_modules/grunt-cli/bin/grunt test" | ||
}, | ||
"dependencies": { | ||
"observe-js": "0.1.0" | ||
"observe-js": "0.1.0", | ||
"mout": "0.8.0" | ||
} | ||
} |
@@ -5,6 +5,26 @@ ## angular-data | ||
__Current version:__ 0.0.1-SNAPSHOT | ||
__Current version:__ 0.4.0 | ||
This is a pre-alpha. Not much to see yet, but stay tuned! | ||
Angular-data is in a pre-1.0.0 development stage; the API is fluctuating, not a lot of tests yet, etc. | ||
Not for production use (yet). | ||
## Resources | ||
#### Community | ||
[Issues](https://github.com/jmdobry/angular-data/issues) - Found a bug? Feature request? Submit an issue! | ||
[GitHub](https://github.com/jmdobry/angular-data) - View the source code for angular-data. | ||
## Project Status | ||
| Branch | Master | | ||
| ------ | ------ | | ||
| Bower | [![Bower version](https://badge.fury.io/bo/angular-data.png)](http://badge.fury.io/bo/angular-data) | | ||
| NPM | [![NPM version](https://badge.fury.io/js/angular-data.png)](http://badge.fury.io/js/angular-data) | | ||
| Build Status | [![Build Status](https://travis-ci.org/jmdobry/angular-data.png?branch=master)](https://travis-ci.org/jmdobry/angular-data) | | ||
| Code Climate | [![Code Climate](https://codeclimate.com/github/jmdobry/angular-data.png)](https://codeclimate.com/github/jmdobry/angular-data) | | ||
| Dependency Status | [![Dependency Status](https://gemnasium.com/jmdobry/angular-data.png)](https://gemnasium.com/jmdobry/angular-data) | | ||
| Coverage | [![Coverage Status](https://coveralls.io/repos/jmdobry/angular-data/badge.png?branch=master)](https://coveralls.io/r/jmdobry/angular-data?branch=master) | | ||
Copyright (C) 2014 Jason Dobry | ||
@@ -11,0 +31,0 @@ |
var utils = require('utils'), | ||
errors = require('errors'), | ||
store = require('store'), | ||
services = require('services'); | ||
services = require('services'), | ||
errorPrefix = 'DS.create(resourceName, attrs): '; | ||
@@ -11,10 +11,21 @@ /** | ||
* @description | ||
* `create(resourceName, attrs)` | ||
* Create a new resource and save it to the server. | ||
* | ||
* Create a new resource. | ||
* ## Signature: | ||
* ```js | ||
* DS.create(resourceName, attrs) | ||
* ``` | ||
* | ||
* Example: | ||
* ## Example: | ||
* | ||
* ```js | ||
* TODO: create(resourceName, attrs) | ||
* DS.create('document', { author: 'John Anderson' }) | ||
* .then(function (document) { | ||
* document; // { id: 'aab7ff66-e21e-46e2-8be8-264d82aee535', author: 'John Anderson' } | ||
* | ||
* // The new document is already in the data store | ||
* DS.get('document', document.id); // { id: 'aab7ff66-e21e-46e2-8be8-264d82aee535', author: 'John Anderson' } | ||
* }, function (err) { | ||
* // handle error | ||
* }); | ||
* ``` | ||
@@ -27,23 +38,24 @@ * | ||
* | ||
* ## ResolvesWith: | ||
* ## Resolves with: | ||
* | ||
* - `{object}` - `item` - A reference to the newly created item. | ||
* | ||
* ## RejectsWith: | ||
* ## Rejects with: | ||
* | ||
* - `{IllegalArgumentError}` - `err` - Argument `attrs` must be an object. | ||
* - `{RuntimeError}` - `err` - Argument `resourceName` must refer to an already registered resource. | ||
* - `{UnhandledError}` - `err` - Thrown for any uncaught exception. | ||
* - `{IllegalArgumentError}` | ||
* - `{RuntimeError}` | ||
* - `{UnhandledError}` | ||
*/ | ||
function create(resourceName, attrs) { | ||
var deferred = $q.defer(); | ||
if (!store[resourceName]) { | ||
deferred.reject(new errors.RuntimeError('DS.create(resourceName, attrs): ' + resourceName + ' is not a registered resource!')); | ||
if (!services.store[resourceName]) { | ||
deferred.reject(new errors.RuntimeError(errorPrefix + resourceName + ' is not a registered resource!')); | ||
} else if (!utils.isObject(attrs)) { | ||
deferred.reject(new errors.IllegalArgumentError('DS.create(resourceName, attrs): attrs: Must be an object!', { attrs: { actual: typeof attrs, expected: 'object' } })); | ||
deferred.reject(new errors.IllegalArgumentError(errorPrefix + 'attrs: Must be an object!', { attrs: { actual: typeof attrs, expected: 'object' } })); | ||
} | ||
try { | ||
var resource = store[resourceName], | ||
_this = this; | ||
var resource = services.store[resourceName], | ||
_this = this, | ||
url = utils.makePath(resource.baseUrl || services.config.baseUrl, resource.endpoint || resource.name); | ||
@@ -55,3 +67,4 @@ if (resource.validate) { | ||
} else { | ||
_this.POST(resource.url, attrs, null).then(function (data) { | ||
_this.POST(url, attrs, null).then(function (data) { | ||
try { | ||
@@ -66,3 +79,3 @@ deferred.resolve(_this.inject(resource.name, data)); | ||
} else { | ||
_this.POST(resource.url, attrs, null).then(function (data) { | ||
_this.POST(url, attrs, null).then(function (data) { | ||
try { | ||
@@ -69,0 +82,0 @@ deferred.resolve(_this.inject(resource.name, data)); |
var utils = require('utils'), | ||
errors = require('errors'), | ||
store = require('store'); | ||
services = require('services'), | ||
errorPrefix = 'DS.destroy(resourceName, id): '; | ||
@@ -10,11 +11,22 @@ /** | ||
* @description | ||
* `destroy(resourceName, id)` | ||
* | ||
* Delete the item of the type specified by `resourceName` with the primary key specified by `id` from the data store | ||
* and the server. | ||
* | ||
* Example: | ||
* ## Signature: | ||
* ```js | ||
* DS.destroy(resourceName, id); | ||
* ``` | ||
* | ||
* ## Example: | ||
* | ||
* ```js | ||
* TODO: destroy(type, id) example | ||
* DS.destroy('document', 'aab7ff66-e21e-46e2-8be8-264d82aee535') | ||
* .then(function (id) { | ||
* id; // 'aab7ff66-e21e-46e2-8be8-264d82aee535' | ||
* | ||
* // The document is gone | ||
* DS.get('document', 'aab7ff66-e21e-46e2-8be8-264d82aee535'); // undefined | ||
* }, function (err) { | ||
* // Handle error | ||
* }); | ||
* ``` | ||
@@ -26,25 +38,26 @@ * | ||
* | ||
* ## ResolvesWith: | ||
* ## Resolves with: | ||
* | ||
* - `{string|number}` - `id` - The primary key of the destroyed item. | ||
* | ||
* ## RejectsWith: | ||
* ## Rejects with: | ||
* | ||
* - `{IllegalArgumentError}` - `err` - Argument `id` must be a string or a number. | ||
* - `{RuntimeError}` - `err` - Argument `resourceName` must refer to an already registered resource. | ||
* - `{UnhandledError}` - `err` - Thrown for any uncaught exception. | ||
* - `{IllegalArgumentError}` | ||
* - `{RuntimeError}` | ||
* - `{UnhandledError}` | ||
*/ | ||
function destroy(resourceName, id) { | ||
var deferred = $q.defer(); | ||
if (!store[resourceName]) { | ||
deferred.reject(new errors.RuntimeError('DS.destroy(resourceName, id): ' + resourceName + ' is not a registered resource!')); | ||
if (!services.store[resourceName]) { | ||
deferred.reject(new errors.RuntimeError(errorPrefix + resourceName + ' is not a registered resource!')); | ||
} else if (!utils.isString(id) && !utils.isNumber(id)) { | ||
deferred.reject(new errors.IllegalArgumentError('DS.destroy(resourceName, id): id: Must be a string or a number!', { id: { actual: typeof id, expected: 'string|number' } })); | ||
deferred.reject(new errors.IllegalArgumentError(errorPrefix + 'id: Must be a string or a number!', { id: { actual: typeof id, expected: 'string|number' } })); | ||
} | ||
try { | ||
var resource = store[resourceName], | ||
_this = this; | ||
var resource = services.store[resourceName], | ||
_this = this, | ||
url = utils.makePath(resource.baseUrl || services.config.baseUrl, resource.endpoint || resource.name, id); | ||
_this.DEL(utils.makePath(resource.url, id), null).then(function () { | ||
_this.DEL(url, null).then(function () { | ||
try { | ||
@@ -51,0 +64,0 @@ _this.eject(resourceName, id); |
var utils = require('utils'), | ||
errors = require('errors'), | ||
store = require('store'), | ||
services = require('services'), | ||
GET = require('../../HTTP').GET; | ||
GET = require('../../http').GET, | ||
errorPrefix = 'DS.find(resourceName, id[, options]): '; | ||
@@ -12,11 +12,21 @@ /** | ||
* @description | ||
* `find(resourceName, id[, forceRefresh])` | ||
* | ||
* Asynchronously return the resource with the given id from the server. The result will be added to the data | ||
* store when it returns from the server. | ||
* | ||
* Example: | ||
* ## Signature: | ||
* ```js | ||
* DS.find(resourceName, id[, options]) | ||
* ``` | ||
* | ||
* ## Example: | ||
* | ||
* ```js | ||
* TODO: find(resourceName, id[, forceRefresh]) example | ||
* DS.get('document', 5); // undefined | ||
* DS.find('document', 5).then(function (document) { | ||
* document; // { id: 5, author: 'John Anderson' } | ||
* | ||
* DS.get('document', 5); // { id: 5, author: 'John Anderson' } | ||
* }, function (err) { | ||
* // Handled errors | ||
* }); | ||
* ``` | ||
@@ -26,42 +36,61 @@ * | ||
* @param {string|number} id The primary key of the item to retrieve. | ||
* @param {boolean=} forceRefresh Bypass the cache. | ||
* @param {object=} options Optional configuration. Properties: | ||
* - `{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"`. | ||
* @returns {Promise} Promise produced by the `$q` service. | ||
* | ||
* ## ResolvesWith: | ||
* ## Resolves with: | ||
* | ||
* - `{array}` - `item` - The item with the primary key specified by `id`. | ||
* - `{object}` - `item` - The item with the primary key specified by `id`. | ||
* | ||
* ## RejectsWith: | ||
* ## Rejects with: | ||
* | ||
* - `{IllegalArgumentError}` - `err` - Argument `id` must be a string or a number. | ||
* - `{RuntimeError}` - `err` - Argument `resourceName` must refer to an already registered resource. | ||
* - `{UnhandledError}` - `err` - Thrown for any uncaught exception. | ||
* - `{IllegalArgumentError}` | ||
* - `{RuntimeError}` | ||
* - `{UnhandledError}` | ||
*/ | ||
function find(resourceName, id, forceRefresh) { | ||
function find(resourceName, id, options) { | ||
var deferred = $q.defer(); | ||
if (!store[resourceName]) { | ||
deferred.reject(new errors.RuntimeError('DS.find(resourceName, id[, forceRefresh]): ' + resourceName + ' is not a registered resource!')); | ||
if (!services.store[resourceName]) { | ||
deferred.reject(new errors.RuntimeError(errorPrefix + resourceName + ' is not a registered resource!')); | ||
} else if (!utils.isString(id) && !utils.isNumber(id)) { | ||
deferred.reject(new errors.IllegalArgumentError('DS.find(resourceName, id[, forceRefresh]): id: Must be a string or a number!', { id: { actual: typeof id, expected: 'string|number' } })); | ||
} | ||
deferred.reject(new errors.IllegalArgumentError(errorPrefix + 'id: Must be a string or a number!', { id: { actual: typeof id, expected: 'string|number' } })); | ||
} else if (!utils.isObject(options)) { | ||
deferred.reject(new errors.IllegalArgumentError(errorPrefix + 'options: Must be an object!', { options: { actual: typeof options, expected: 'object' } })); | ||
} else { | ||
var _this = this; | ||
var _this = this; | ||
try { | ||
var resource = services.store[resourceName]; | ||
try { | ||
var resource = store[resourceName]; | ||
if (id in resource.index && !options.bypassCache) { | ||
deferred.resolve(_this.get(resourceName, id)); | ||
} else { | ||
var url = utils.makePath(resource.baseUrl || services.config.baseUrl, resource.endpoint || resource.name, id), | ||
config = null; | ||
if (id in resource.index && !forceRefresh) { | ||
deferred.resolve(_this.get(resourceName, id)); | ||
} else { | ||
GET(utils.makePath(resource.url, id), null).then(function (data) { | ||
try { | ||
_this.inject(resourceName, data); | ||
deferred.resolve(_this.get(resourceName, id)); | ||
} catch (err) { | ||
deferred.reject(err); | ||
if (options.bypassCache) { | ||
config = { | ||
headers: { | ||
'Last-Modified': new Date(resource.modified[id]) | ||
} | ||
}; | ||
} | ||
}, deferred.reject); | ||
GET(url, config).then(function (data) { | ||
try { | ||
_this.inject(resourceName, data); | ||
deferred.resolve(_this.get(resourceName, id)); | ||
} catch (err) { | ||
deferred.reject(err); | ||
} | ||
}, deferred.reject); | ||
} | ||
} catch (err) { | ||
if (!(err instanceof errors.UnhandledError)) { | ||
deferred.reject(new errors.UnhandledError(err)); | ||
} else { | ||
deferred.reject(err); | ||
} | ||
} | ||
} catch (err) { | ||
deferred.reject(new errors.UnhandledError(err)); | ||
} | ||
@@ -68,0 +97,0 @@ |
var utils = require('utils'), | ||
errors = require('errors'), | ||
store = require('store'), | ||
services = require('services'), | ||
GET = require('../../HTTP').GET; | ||
GET = require('../../http').GET, | ||
errorPrefix = 'DS.findAll(resourceName, params[, options]): '; | ||
function processResults(data, resourceName, queryHash) { | ||
var resource = store[resourceName]; | ||
var resource = services.store[resourceName]; | ||
@@ -36,8 +36,8 @@ data = data || []; | ||
function _findAll(deferred, resourceName, params, forceRefresh) { | ||
var resource = store[resourceName]; | ||
function _findAll(deferred, resourceName, params, options) { | ||
var resource = services.store[resourceName]; | ||
var queryHash = utils.toJson(params); | ||
if (forceRefresh) { | ||
if (options.bypassCache) { | ||
delete resource.completedQueries[queryHash]; | ||
@@ -52,3 +52,4 @@ } | ||
// This particular query has never even been started | ||
resource.pendingQueries[queryHash] = GET(resource.url, { params: params }).then(function (data) { | ||
var url = utils.makePath(resource.baseUrl || services.config.baseUrl, resource.endpoint || resource.name); | ||
resource.pendingQueries[queryHash] = GET(url, { params: params }).then(function (data) { | ||
try { | ||
@@ -62,3 +63,3 @@ deferred.resolve(processResults(data, resourceName, queryHash)); | ||
} else { | ||
deferred.resolve(this.filter(resourceName, params)); | ||
deferred.resolve(this.filter(resourceName, params, options)); | ||
} | ||
@@ -72,15 +73,40 @@ } | ||
* @description | ||
* `findAll(resourceName[, params][, forceRefresh])` | ||
* | ||
* Asynchronously return the resource from the server filtered by the query. The results will be added to the data | ||
* store when it returns from the server. | ||
* | ||
* Example: | ||
* ## Signature: | ||
* ```js | ||
* DS.findAll(resourceName, params[, options]) | ||
* ``` | ||
* | ||
* ## Example: | ||
* | ||
* ```js | ||
* TODO: findAll(resourceName[, params][, forceRefresh]) example | ||
* var query = { | ||
* where: { | ||
* author: { | ||
* '==': 'John Anderson' | ||
* } | ||
* } | ||
* }; | ||
* | ||
* DS.findAll('document', { | ||
* query: query | ||
* }).then(function (documents) { | ||
* documents; // [{ id: 'aab7ff66-e21e-46e2-8be8-264d82aee535', author: 'John Anderson', title: 'How to cook' }, | ||
* // { id: 'ee7f3f4d-98d5-4934-9e5a-6a559b08479f', author: 'John Anderson', title: 'How NOT to cook' }] | ||
* | ||
* // The documents are now in the data store | ||
* DS.filter('document', { | ||
* query: query | ||
* }); // [{ id: 'aab7ff66-e21e-46e2-8be8-264d82aee535', author: 'John Anderson', title: 'How to cook' }, | ||
* // { id: 'ee7f3f4d-98d5-4934-9e5a-6a559b08479f', author: 'John Anderson', title: 'How NOT to cook' }] | ||
* | ||
* }, function (err) { | ||
* // handle error | ||
* }); | ||
* ``` | ||
* | ||
* @param {string} resourceName The resource type, e.g. 'user', 'comment', etc. | ||
* @param {object=} params Parameter object that is serialized into the query string. Properties: | ||
* @param {object} params Parameter object that is serialized into the query string. Properties: | ||
* | ||
@@ -91,29 +117,35 @@ * - `{object=}` - `query` - The query object by which to filter items of the type specified by `resourceName`. Properties: | ||
* - `{skip=}` - `skip` - Skip clause. | ||
* - `{orderBy=}` - `orderBy` - OrderBy clause. | ||
* | ||
* @param {boolean=} forceRefresh Bypass the cache. | ||
* @param {object=} options Optional configuration. Properties: | ||
* - `{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"`. | ||
* | ||
* @returns {Promise} Promise produced by the `$q` service. | ||
* | ||
* ## ResolvesWith: | ||
* ## Resolves with: | ||
* | ||
* - `{array}` - `items` - The collection of items returned by the server. | ||
* | ||
* ## RejectsWith: | ||
* ## Rejects with: | ||
* | ||
* - `{IllegalArgumentError}` - `err` - Argument `params` must be an object. | ||
* - `{RuntimeError}` - `err` - Argument `resourceName` must refer to an already registered resource. | ||
* - `{UnhandledError}` - `err` - Thrown for any uncaught exception. | ||
* - `{IllegalArgumentError}` | ||
* - `{RuntimeError}` | ||
* - `{UnhandledError}` | ||
*/ | ||
function findAll(resourceName, params, forceRefresh) { | ||
function findAll(resourceName, params, options) { | ||
var deferred = services.$q.defer(); | ||
params = params || {}; | ||
options = options || {}; | ||
if (!store[resourceName]) { | ||
deferred.reject(new errors.RuntimeError('DS.findAll(resourceName[, params]): ' + resourceName + ' is not a registered resource!')); | ||
if (!services.store[resourceName]) { | ||
deferred.reject(new errors.RuntimeError(errorPrefix + resourceName + ' is not a registered resource!')); | ||
} else if (!utils.isObject(params)) { | ||
deferred.reject(new errors.IllegalArgumentError('DS.findAll(resourceName[, params]): params: Must be an object!', { params: { actual: typeof params, expected: 'object' } })); | ||
deferred.reject(new errors.IllegalArgumentError(errorPrefix + 'params: Must be an object!', { params: { actual: typeof params, expected: 'object' } })); | ||
} else if (!utils.isObject(options)) { | ||
deferred.reject(new errors.IllegalArgumentError(errorPrefix + 'options: Must be an object!', { options: { actual: typeof options, expected: 'object' } })); | ||
} else { | ||
try { | ||
_findAll.apply(this, [deferred, resourceName, params, forceRefresh]); | ||
_findAll.apply(this, [deferred, resourceName, params, options]); | ||
} catch (err) { | ||
@@ -120,0 +152,0 @@ deferred.reject(new errors.UnhandledError(err)); |
@@ -8,26 +8,3 @@ module.exports = { | ||
* @description | ||
* `create(resourceName, attrs)` | ||
* | ||
* Create a new resource. | ||
* | ||
* Example: | ||
* | ||
* ```js | ||
* TODO: create(resourceName, attrs) | ||
* ``` | ||
* | ||
* @param {string} resourceName The resource type, e.g. 'user', 'comment', etc. | ||
* @param {object} attrs The attributes with which to update the item of the type specified by `resourceName` that has | ||
* the primary key specified by `id`. | ||
* @returns {Promise} Promise produced by the `$q` service. | ||
* | ||
* ## ResolvesWith: | ||
* | ||
* - `{object}` - `item` - A reference to the newly created item. | ||
* | ||
* ## RejectsWith: | ||
* | ||
* - `{IllegalArgumentError}` - `err` - Argument `attrs` must be an object. | ||
* - `{RuntimeError}` - `err` - Argument `resourceName` must refer to an already registered resource. | ||
* - `{UnhandledError}` - `err` - Thrown for any uncaught exception. | ||
* See [DS.create](/documentation/api/api/DS.async_methods:create). | ||
*/ | ||
@@ -42,26 +19,3 @@ create: require('./create'), | ||
* @description | ||
* `destroy(resourceName, id)` | ||
* | ||
* Delete the item of the type specified by `resourceName` with the primary key specified by `id` from the data store | ||
* and the server. | ||
* | ||
* Example: | ||
* | ||
* ```js | ||
* TODO: destroy(type, id) example | ||
* ``` | ||
* | ||
* @param {string} resourceName The resource type, e.g. 'user', 'comment', etc. | ||
* @param {string|number} id The primary key of the item to remove. | ||
* @returns {Promise} Promise produced by the `$q` service. | ||
* | ||
* ## ResolvesWith: | ||
* | ||
* - `{string|number}` - `id` - The primary key of the destroyed item. | ||
* | ||
* ## RejectsWith: | ||
* | ||
* - `{IllegalArgumentError}` - `err` - Argument `id` must be a string or a number. | ||
* - `{RuntimeError}` - `err` - Argument `resourceName` must refer to an already registered resource. | ||
* - `{UnhandledError}` - `err` - Thrown for any uncaught exception. | ||
* See [DS.destroy](/documentation/api/api/DS.async_methods:destroy). | ||
*/ | ||
@@ -76,27 +30,3 @@ destroy: require('./destroy'), | ||
* @description | ||
* `find(resourceName, id[, forceRefresh])` | ||
* | ||
* Asynchronously return the resource with the given id from the server. The result will be added to the data | ||
* store when it returns from the server. | ||
* | ||
* Example: | ||
* | ||
* ```js | ||
* TODO: find(resourceName, id[, forceRefresh]) example | ||
* ``` | ||
* | ||
* @param {string} resourceName The resource type, e.g. 'user', 'comment', etc. | ||
* @param {string|number} id The primary key of the item to retrieve. | ||
* @param {boolean=} forceRefresh Bypass the cache. | ||
* @returns {Promise} Promise produced by the `$q` service. | ||
* | ||
* ## ResolvesWith: | ||
* | ||
* - `{array}` - `item` - The item with the primary key specified by `id`. | ||
* | ||
* ## RejectsWith: | ||
* | ||
* - `{IllegalArgumentError}` - `err` - Argument `id` must be a string or a number. | ||
* - `{RuntimeError}` - `err` - Argument `resourceName` must refer to an already registered resource. | ||
* - `{UnhandledError}` - `err` - Thrown for any uncaught exception. | ||
* See [DS.find](/documentation/api/api/DS.async_methods:find). | ||
*/ | ||
@@ -111,34 +41,3 @@ find: require('./find'), | ||
* @description | ||
* `findAll(resourceName[, params][, forceRefresh])` | ||
* | ||
* Asynchronously return the resource from the server filtered by the query. The results will be added to the data | ||
* store when it returns from the server. | ||
* | ||
* Example: | ||
* | ||
* ```js | ||
* TODO: findAll(resourceName[, params][, forceRefresh]) example | ||
* ``` | ||
* | ||
* @param {string} resourceName The resource type, e.g. 'user', 'comment', etc. | ||
* @param {object=} params Parameter object that is serialized into the query string. Properties: | ||
* | ||
* - `{object=}` - `query` - The query object by which to filter items of the type specified by `resourceName`. Properties: | ||
* - `{object=}` - `where` - Where clause. | ||
* - `{number=}` - `limit` - Limit clause. | ||
* - `{skip=}` - `skip` - Skip clause. | ||
* | ||
* @param {boolean=} forceRefresh Bypass the cache. | ||
* | ||
* @returns {Promise} Promise produced by the `$q` service. | ||
* | ||
* ## ResolvesWith: | ||
* | ||
* - `{array}` - `items` - The collection of items returned by the server. | ||
* | ||
* ## RejectsWith: | ||
* | ||
* - `{IllegalArgumentError}` - `err` - Argument `params` must be an object. | ||
* - `{RuntimeError}` - `err` - Argument `resourceName` must refer to an already registered resource. | ||
* - `{UnhandledError}` - `err` - Thrown for any uncaught exception. | ||
* See [DS.findAll](/documentation/api/api/DS.async_methods:findAll). | ||
*/ | ||
@@ -153,31 +52,3 @@ findAll: require('./findAll'), | ||
* @description | ||
* `refresh(resourceName, id)` | ||
* | ||
* Like find(), except the resource is only refreshed from the server if it already exists in the data store. | ||
* | ||
* Example: | ||
* | ||
* ```js | ||
* TODO: refresh(resourceName, id) example | ||
* ``` | ||
* | ||
* ## Throws | ||
* | ||
* - `{IllegalArgumentError}` - Argument `id` must be a string or a number. | ||
* - `{RuntimeError}` - Argument `resourceName` must refer to an already registered resource. | ||
* | ||
* @param {string} resourceName The resource type, e.g. 'user', 'comment', etc. | ||
* @param {string|number} id The primary key of the item to refresh from the server. | ||
* @returns {false|Promise} `false` if the item doesn't already exist in the data store. A `Promise` if the item does | ||
* exist in the data store and is being refreshed. | ||
* | ||
* ## ResolvesWith: | ||
* | ||
* - `{object}` - `item` - A reference to the refreshed item. | ||
* | ||
* ## RejectsWith: | ||
* | ||
* - `{IllegalArgumentError}` - `err` - Argument `id` must be a string or a number. | ||
* - `{RuntimeError}` - `err` - Argument `resourceName` must refer to an already registered resource. | ||
* - `{UnhandledError}` - `err` - Thrown for any uncaught exception. | ||
* See [DS.refresh](/documentation/api/api/DS.async_methods:refresh). | ||
*/ | ||
@@ -192,27 +63,5 @@ refresh: require('./refresh'), | ||
* @description | ||
* `save(resourceName, id)` | ||
* | ||
* save the item of the type specified by `resourceName` that has the primary key specified by `id`. | ||
* | ||
* Example: | ||
* | ||
* ```js | ||
* TODO: save(resourceName, id) example | ||
* ``` | ||
* | ||
* @param {string} resourceName The resource type, e.g. 'user', 'comment', etc. | ||
* @param {string|number} id The primary key of the item to retrieve. | ||
* @returns {Promise} Promise produced by the `$q` service. | ||
* | ||
* ## ResolvesWith: | ||
* | ||
* - `{object}` - `item` - A reference to the newly saved item. | ||
* | ||
* ## RejectsWith: | ||
* | ||
* - `{IllegalArgumentError}` - `err` - Argument `id` must be a string or a number. | ||
* - `{RuntimeError}` - `err` - Argument `resourceName` must refer to an already registered resource. | ||
* - `{UnhandledError}` - `err` - Thrown for any uncaught exception. | ||
* See [DS.save](/documentation/api/api/DS.async_methods:save). | ||
*/ | ||
save: require('./save') | ||
}; |
var utils = require('utils'), | ||
errors = require('errors'), | ||
store = require('store'), | ||
PUT = require('../../HTTP').PUT; | ||
services = require('services'), | ||
PUT = require('../../http').PUT, | ||
errorPrefix = 'DS.refresh(resourceName, id): '; | ||
@@ -11,10 +12,23 @@ /** | ||
* @description | ||
* `refresh(resourceName, id)` | ||
* | ||
* Like find(), except the resource is only refreshed from the server if it already exists in the data store. | ||
* | ||
* Example: | ||
* ## Signature: | ||
* ```js | ||
* DS.refresh(resourceName, id) | ||
* ``` | ||
* ## Example: | ||
* | ||
* ```js | ||
* TODO: refresh(resourceName, id) example | ||
* // Exists in the data store, but we want a fresh copy | ||
* DS.get('document', 'ee7f3f4d-98d5-4934-9e5a-6a559b08479f'); | ||
* | ||
* DS.refresh('document', 'ee7f3f4d-98d5-4934-9e5a-6a559b08479f') | ||
* .then(function (document) { | ||
* document; // The fresh copy | ||
* }); | ||
* | ||
* // Does not exist in the data store | ||
* DS.get('document', 'aab7ff66-e21e-46e2-8be8-264d82aee535'); | ||
* | ||
* DS.refresh('document', 'aab7ff66-e21e-46e2-8be8-264d82aee535'); // false | ||
* ``` | ||
@@ -24,28 +38,33 @@ * | ||
* | ||
* - `{IllegalArgumentError}` - Argument `id` must be a string or a number. | ||
* - `{RuntimeError}` - Argument `resourceName` must refer to an already registered resource. | ||
* - `{IllegalArgumentError}` | ||
* - `{RuntimeError}` | ||
* | ||
* @param {string} resourceName The resource type, e.g. 'user', 'comment', etc. | ||
* @param {string|number} id The primary key of the item to refresh from the server. | ||
* @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 | ||
* exist in the data store and is being refreshed. | ||
* | ||
* ## ResolvesWith: | ||
* ## Resolves with: | ||
* | ||
* - `{object}` - `item` - A reference to the refreshed item. | ||
* | ||
* ## RejectsWith: | ||
* ## Rejects with: | ||
* | ||
* - `{IllegalArgumentError}` - `err` - Argument `id` must be a string or a number. | ||
* - `{RuntimeError}` - `err` - Argument `resourceName` must refer to an already registered resource. | ||
* - `{UnhandledError}` - `err` - Thrown for any uncaught exception. | ||
* - `{IllegalArgumentError}` | ||
* - `{RuntimeError}` | ||
* - `{UnhandledError}` | ||
*/ | ||
function refresh(resourceName, id) { | ||
if (!store[resourceName]) { | ||
throw new errors.RuntimeError('DS.refresh(resourceName, id): ' + resourceName + ' is not a registered resource!'); | ||
function refresh(resourceName, id, options) { | ||
if (!services.store[resourceName]) { | ||
throw new errors.RuntimeError(errorPrefix + resourceName + ' is not a registered resource!'); | ||
} else if (!utils.isString(id) && !utils.isNumber(id)) { | ||
throw new errors.IllegalArgumentError('DS.refresh(resourceName, id): id: Must be a string or a number!', { id: { actual: typeof id, expected: 'string|number' } }); | ||
} else if (!utils.isObject(options)) { | ||
throw new errors.IllegalArgumentError(errorPrefix + 'options: Must be an object!', { options: { actual: typeof options, expected: 'object' } }); | ||
} | ||
if (id in store[resourceName].index) { | ||
if (id in services.store[resourceName].index) { | ||
return this.find(resourceName, id, true); | ||
@@ -52,0 +71,0 @@ } else { |
var utils = require('utils'), | ||
errors = require('errors'), | ||
store = require('store'), | ||
services = require('services'), | ||
PUT = require('../../HTTP').PUT; | ||
PUT = require('../../http').PUT, | ||
errorPrefix = 'DS.save(resourceName, id[, options]): '; | ||
function _save(deferred, resource, id, attrs) { | ||
function _save(deferred, resource, id, options) { | ||
var _this = this; | ||
PUT(utils.makePath(resource.url, id), attrs, null).then(function (data) { | ||
var saved = _this.inject(resource.name, data); | ||
resource.saved[saved[resource.idAttribute]] = utils.saveTimestamp(resource.saved[saved[resource.idAttribute]]); | ||
var url = utils.makePath(resource.baseUrl || services.config.baseUrl, resource.endpoint || resource.name, id); | ||
PUT(url, resource.index[id], null).then(function (data) { | ||
var saved = _this.inject(resource.name, data, options); | ||
resource.saved[id] = utils.updateTimestamp(resource.saved[id]); | ||
deferred.resolve(saved); | ||
@@ -21,10 +22,20 @@ }, deferred.reject); | ||
* @description | ||
* `save(resourceName, id)` | ||
* Save the item of the type specified by `resourceName` that has the primary key specified by `id`. | ||
* | ||
* save the item of the type specified by `resourceName` that has the primary key specified by `id`. | ||
* ## Signature: | ||
* ```js | ||
* DS.save(resourceName, id[, options]) | ||
* ``` | ||
* | ||
* Example: | ||
* ## Example: | ||
* | ||
* ```js | ||
* TODO: save(resourceName, id) example | ||
* var document = DS.get('document', 'ee7f3f4d-98d5-4934-9e5a-6a559b08479f'); | ||
* | ||
* document.title = 'How to cook in style'; | ||
* | ||
* DS.save('document', 'ee7f3f4d-98d5-4934-9e5a-6a559b08479f') | ||
* .then(function (document) { | ||
* document; // A reference to the document that's been saved to the server | ||
* }); | ||
* ``` | ||
@@ -34,40 +45,53 @@ * | ||
* @param {string|number} id The primary key of the item to retrieve. | ||
* @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. | ||
* | ||
* ## ResolvesWith: | ||
* ## Resolves with: | ||
* | ||
* - `{object}` - `item` - A reference to the newly saved item. | ||
* | ||
* ## RejectsWith: | ||
* ## Rejects with: | ||
* | ||
* - `{IllegalArgumentError}` - `err` - Argument `id` must be a string or a number. | ||
* - `{RuntimeError}` - `err` - Argument `resourceName` must refer to an already registered resource. | ||
* - `{UnhandledError}` - `err` - Thrown for any uncaught exception. | ||
* - `{IllegalArgumentError}` | ||
* - `{RuntimeError}` | ||
* - `{UnhandledError}` | ||
*/ | ||
function save(resourceName, id) { | ||
function save(resourceName, id, options) { | ||
var deferred = $q.defer(); | ||
if (!store[resourceName]) { | ||
deferred.reject(new errors.RuntimeError('DS.save(resourceName, id, attrs): ' + resourceName + ' is not a registered resource!')); | ||
options = options || {}; | ||
if (!services.store[resourceName]) { | ||
deferred.reject(new errors.RuntimeError(errorPrefix + resourceName + ' is not a registered resource!')); | ||
} else if (!utils.isString(id) && !utils.isNumber(id)) { | ||
deferred.reject(new errors.IllegalArgumentError('DS.save(resourceName, id, attrs): id: Must be a string or a number!', { id: { actual: typeof id, expected: 'string|number' } })); | ||
} | ||
deferred.reject(new errors.IllegalArgumentError(errorPrefix + 'id: Must be a string or a number!', { id: { actual: typeof id, expected: 'string|number' } })); | ||
} else if (!utils.isObject(options)) { | ||
deferred.reject(new errors.IllegalArgumentError(errorPrefix + 'id: Must be an object!', { options: { actual: typeof options, expected: 'object' } })); | ||
} else { | ||
var _this = this; | ||
var _this = this; | ||
try { | ||
var resource = services.store[resourceName]; | ||
try { | ||
var resource = store[resourceName]; | ||
if (resource.validate) { | ||
resource.validate(resource.index[resource.idAttribute || 'id'], function (err) { | ||
if (err) { | ||
deferred.reject(err); | ||
} else { | ||
_save.call(_this, deferred, resource, id); | ||
} | ||
}); | ||
} else { | ||
_save.call(_this, deferred, resource, id); | ||
if (resource.schema) { | ||
resource.schema.validate(resource.index[id], function (err) { | ||
if (err) { | ||
deferred.reject(err); | ||
} else { | ||
_save.call(_this, deferred, resource, id, options); | ||
} | ||
}); | ||
} else { | ||
_save.call(_this, deferred, resource, id, options); | ||
} | ||
} catch (err) { | ||
if (!(err instanceof errors.UnhandledError)) { | ||
deferred.reject(new errors.UnhandledError(err)); | ||
} else { | ||
deferred.reject(err); | ||
} | ||
} | ||
} catch (err) { | ||
deferred.reject(new errors.UnhandledError(err)); | ||
} | ||
@@ -74,0 +98,0 @@ |
var utils = require('utils'), | ||
services = require('services'); | ||
errors = require('errors'), | ||
IllegalArgumentError = errors.IllegalArgumentError, | ||
services = require('services'), | ||
errorPrefix = 'DSProvider.config(options): '; | ||
/** | ||
* @doc method | ||
* @id DSProvider.methods:config | ||
* @name config | ||
* @description | ||
* Configure the DS service. | ||
* | ||
* ## Throws: | ||
* | ||
* - `{IllegalArgumentError}` | ||
* | ||
* @param {object} options Configuration for the data store. | ||
*/ | ||
function config(options) { | ||
options = options || {}; | ||
if (!utils.isObject(options)) { | ||
throw new IllegalArgumentError(errorPrefix + 'options: Must be an object!', { actual: typeof options, expected: 'object' }); | ||
} else if (!utils.isString(options.baseUrl)) { | ||
throw new IllegalArgumentError(errorPrefix + 'options: Must be an object!', { baseUrl: { actual: typeof options, expected: 'object' } }); | ||
} | ||
utils.deepMixIn(services.config, options); | ||
} | ||
/** | ||
* @doc interface | ||
@@ -10,2 +38,13 @@ * @id DSProvider | ||
function DSProvider() { | ||
/** | ||
* @doc method | ||
* @id DSProvider.methods:config | ||
* @name config | ||
* @methodOf DSProvider | ||
* @description | ||
* See [DSProvider.config](/documentation/api/api/DSProvider.methods:config). | ||
*/ | ||
this.config = config; | ||
this.$get = ['$rootScope', '$log', '$http', '$q', function ($rootScope, $log, $http, $q) { | ||
@@ -17,2 +56,3 @@ | ||
services.$q = $q; | ||
services.store = {}; | ||
@@ -32,2 +72,4 @@ /** | ||
DS.errors = errors; | ||
utils.deepFreeze(DS); | ||
@@ -34,0 +76,0 @@ |
@@ -1,1 +0,6 @@ | ||
module.exports = {}; | ||
module.exports = { | ||
config: { | ||
idAttribute: 'id' | ||
}, | ||
store: {} | ||
}; |
var utils = require('utils'), | ||
errors = require('errors'), | ||
store = require('store'); | ||
services = require('services'), | ||
errorPrefix = 'DS.changes(resourceName, id): '; | ||
@@ -10,4 +11,2 @@ /** | ||
* @description | ||
* `changes(resourceName, id)` | ||
* | ||
* Synchronously return the changes object of the item of the type specified by `resourceName` that has the primary key | ||
@@ -17,4 +16,9 @@ * specified by `id`. This object represents the diff between the item in its current state and the state of the item | ||
* | ||
* Example: | ||
* ## Signature: | ||
* ```js | ||
* DS.changes(resourceName, id) | ||
* ``` | ||
* | ||
* ## Example: | ||
* | ||
* ```js | ||
@@ -26,5 +30,5 @@ * TODO: changes(resourceName, id) example | ||
* | ||
* - `{IllegalArgumentError}` - Argument `id` must be a string or a number. | ||
* - `{RuntimeError}` - Argument `resourceName` must refer to an already registered resource. | ||
* - `{UnhandledError}` - Thrown for any uncaught exception. | ||
* - `{IllegalArgumentError}` | ||
* - `{RuntimeError}` | ||
* - `{UnhandledError}` | ||
* | ||
@@ -36,11 +40,10 @@ * @param {string} resourceName The resource type, e.g. 'user', 'comment', etc. | ||
function changes(resourceName, id) { | ||
if (!store[resourceName]) { | ||
throw new errors.IllegalArgumentError('DS.changes(resourceName, id): ' + resourceName + ' is not a registered resource!'); | ||
if (!services.store[resourceName]) { | ||
throw new errors.IllegalArgumentError(errorPrefix + resourceName + ' is not a registered resource!'); | ||
} else if (!utils.isString(id) && !utils.isNumber(id)) { | ||
throw new errors.IllegalArgumentError('DS.changes(resourceName, id): id: Must be a string or a number!', { id: { actual: typeof id, expected: 'string|number' } }); | ||
throw new errors.IllegalArgumentError(errorPrefix + 'id: Must be a string or a number!', { id: { actual: typeof id, expected: 'string|number' } }); | ||
} | ||
try { | ||
// return resource from cache | ||
return angular.copy(store[resourceName].changes[id]); | ||
return utils.deepMixIn({}, services.store[resourceName].changes[id]); | ||
} catch (err) { | ||
@@ -47,0 +50,0 @@ throw new errors.UnhandledError(err); |
var utils = require('utils'), | ||
errors = require('errors'), | ||
store = require('store'); | ||
services = require('services'); | ||
@@ -46,3 +46,3 @@ /** | ||
throw new errors.IllegalArgumentError('DS.defineResource(definition): definition.idAttribute: Must be a string!', { definition: { idAttribute: { actual: typeof definition.idAttribute, expected: 'string' } } }); | ||
} else if (store[definition.name]) { | ||
} else if (services.store[definition.name]) { | ||
throw new errors.RuntimeError('DS.defineResource(definition): ' + definition.name + ' is already registered!'); | ||
@@ -52,6 +52,5 @@ } | ||
try { | ||
store[definition.name] = definition; | ||
services.store[definition.name] = definition; | ||
var resource = store[definition.name]; | ||
resource.url = utils.makePath(resource.baseUrl, (resource.endpoint || resource.name)); | ||
var resource = services.store[definition.name]; | ||
resource.collection = []; | ||
@@ -67,2 +66,3 @@ resource.completedQueries = {}; | ||
resource.collectionModified = 0; | ||
resource.idAttribute = resource.idAttribute || services.config.idAttribute || 'id'; | ||
} catch (err) { | ||
@@ -69,0 +69,0 @@ throw new errors.UnhandledError(err); |
var utils = require('utils'), | ||
errors = require('errors'), | ||
store = require('store'), | ||
services = require('services'), | ||
@@ -5,0 +4,0 @@ observe = require('observejs'); |
var utils = require('utils'), | ||
errors = require('errors'), | ||
store = require('store'), | ||
services = require('services'); | ||
@@ -70,3 +69,3 @@ | ||
function eject(resourceName, id) { | ||
if (!store[resourceName]) { | ||
if (!services.store[resourceName]) { | ||
throw new errors.RuntimeError('DS.eject(resourceName, id): ' + resourceName + ' is not a registered resource!'); | ||
@@ -80,6 +79,6 @@ } else if (id && !utils.isString(id) && !utils.isNumber(id)) { | ||
services.$rootScope.$apply(function () { | ||
_eject(store[resourceName], id); | ||
_eject(services.store[resourceName], id); | ||
}); | ||
} else { | ||
_eject(store[resourceName], id); | ||
_eject(services.store[resourceName], id); | ||
} | ||
@@ -86,0 +85,0 @@ } catch (err) { |
/* jshint loopfunc: true */ | ||
var utils = require('utils'), | ||
errors = require('errors'), | ||
store = require('store'), | ||
errorPrefix = 'DS.filter(resourceName, params[, options])'; | ||
services = require('services'), | ||
errorPrefix = 'DS.filter(resourceName, params[, options]): '; | ||
@@ -32,3 +32,3 @@ /** | ||
* @param {string} resourceName The resource type, e.g. 'user', 'comment', etc. | ||
* @param {object=} params Parameter object that is serialized into the query string. Properties: | ||
* @param {object} params Parameter object that is serialized into the query string. Properties: | ||
* | ||
@@ -39,5 +39,9 @@ * - `{object=}` - `query` - The query object by which to filter items of the type specified by `resourceName`. Properties: | ||
* - `{skip=}` - `skip` - Skip clause. | ||
* @param {object=} options Whether to load the query from the server if it hasn't been loaded yet. Properties: | ||
* - `{boolean=}` - `bypassCache` - Bypass the cache. | ||
* - `{orderBy=}` - `orderBy` - OrderBy clause. | ||
* | ||
* @param {object=} options Optional configuration. Properties: | ||
* - `{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`. | ||
@@ -48,3 +52,3 @@ */ | ||
if (!store[resourceName]) { | ||
if (!services.store[resourceName]) { | ||
throw new errors.RuntimeError(errorPrefix + resourceName + ' is not a registered resource!'); | ||
@@ -57,26 +61,24 @@ } else if (!utils.isObject(params)) { | ||
var resource = store[resourceName]; | ||
try { | ||
var resource = services.store[resourceName]; | ||
// Protect against null | ||
params = params || {}; | ||
params.query = params.query || {}; | ||
// Protect against null | ||
params.query = params.query || {}; | ||
var queryHash = utils.toJson(params); | ||
var queryHash = utils.toJson(params); | ||
if (!(queryHash in resource.completedQueries) && options.loadFromServer) { | ||
// This particular query has never been completed | ||
if (!(queryHash in resource.completedQueries) && options.loadFromServer) { | ||
// This particular query has never been completed | ||
if (!resource.pendingQueries[queryHash]) { | ||
// This particular query has never even been started | ||
this.findAll(resourceName, params); | ||
if (!resource.pendingQueries[queryHash]) { | ||
// This particular query has never even been started | ||
this.findAll(resourceName, params, options); | ||
} | ||
} | ||
// Return empty results until the query completes | ||
return []; | ||
} else { | ||
// The query has been completed, so hit the cache with the query | ||
// Apply 'where' clauses | ||
var filtered = utils.filter(resource.collection, function (value) { | ||
var keep = true; | ||
// Apply 'where' clauses | ||
if (params.query.where) { | ||
@@ -89,25 +91,20 @@ if (!utils.isObject(params.query.where)) { | ||
value2 = { | ||
'==': value2 | ||
'===': value2 | ||
}; | ||
} | ||
if (key2.indexOf('.') !== -1) { | ||
key2 = key2.split('.')[1]; | ||
} | ||
if (value2['==']) { | ||
if (value2['=='] == 'null') { | ||
keep = keep && (value[key2] === null); | ||
} else { | ||
keep = keep && (value[key2] == value2['==']); | ||
} | ||
} else if (value2['!=']) { | ||
if ('==' in value2) { | ||
keep = keep && (value[key2] == value2['==']); | ||
} else if ('===' in value2) { | ||
keep = keep && (value[key2] === value2['===']); | ||
} else if ('!=' in value2) { | ||
keep = keep && (value[key2] != value2['!=']); | ||
} else if (value2['>']) { | ||
} else if ('>' in value2) { | ||
keep = keep && (value[key2] > value2['>']); | ||
} else if (value2['>=']) { | ||
} else if ('>=' in value2) { | ||
keep = keep && (value[key2] >= value2['>=']); | ||
} else if (value2['<']) { | ||
} else if ('<' in value2) { | ||
keep = keep && (value[key2] < value2['<']); | ||
} else if (value2['<=']) { | ||
} else if ('<=' in value2) { | ||
keep = keep && (value[key2] <= value2['<=']); | ||
} else if (value2['in']) { | ||
} else if ('in' in value2) { | ||
keep = keep && utils.contains(value2['in'], value[key2]); | ||
@@ -132,3 +129,3 @@ } | ||
} else if (!utils.isArray(params.query.orderBy[i])) { | ||
throw new errors.IllegalArgumentError(errorPrefix + 'params.query.orderBy[' + i + ']: Must be an array!', { params: { query: { 'orderBy[i]': { actual: typeof params.query.orderBy[i], expected: 'array' } } } }); | ||
throw new errors.IllegalArgumentError(errorPrefix + 'params.query.orderBy[' + i + ']: Must be a string or an array!', { params: { query: { 'orderBy[i]': { actual: typeof params.query.orderBy[i], expected: 'string|array' } } } }); | ||
} | ||
@@ -163,16 +160,22 @@ filtered = utils.sort(filtered, function (a, b) { | ||
} else { | ||
throw new errors.IllegalArgumentError(errorPrefix + 'params.query.orderBy: Must be an array!', { params: { query: { orderBy: { actual: typeof params.query.orderBy, expected: 'array' } } } }); | ||
throw new errors.IllegalArgumentError(errorPrefix + 'params.query.orderBy: Must be a string or an array!', { params: { query: { orderBy: { actual: typeof params.query.orderBy, expected: 'string|array' } } } }); | ||
} | ||
} | ||
// Apply 'limit' and 'offset' | ||
if (utils.isNumber(params.query.limit) && utils.isNumber(params.query.offset)) { | ||
filtered = utils.slice(filtered, params.query.offset, params.query.offset + params.query.limit); | ||
// Apply 'limit' and 'skip' | ||
if (utils.isNumber(params.query.limit) && utils.isNumber(params.query.skip)) { | ||
filtered = utils.slice(filtered, params.query.skip, params.query.skip + params.query.limit); | ||
} else if (utils.isNumber(params.query.limit)) { | ||
filtered = utils.slice(filtered, 0, params.query.limit); | ||
} else if (utils.isNumber(params.query.offset)) { | ||
filtered = utils.slice(filtered, params.query.offset); | ||
} else if (utils.isNumber(params.query.skip)) { | ||
filtered = utils.slice(filtered, params.query.skip); | ||
} | ||
return filtered; | ||
} catch (err) { | ||
if (err instanceof errors.IllegalArgumentError) { | ||
throw err; | ||
} else { | ||
throw new errors.UnhandledError(err); | ||
} | ||
} | ||
@@ -179,0 +182,0 @@ } |
var utils = require('utils'), | ||
errors = require('errors'), | ||
store = require('store'); | ||
services = require('services'), | ||
errorPrefix = 'DS.get(resourceName, id): '; | ||
@@ -10,9 +11,12 @@ /** | ||
* @description | ||
* `get(resourceName, id)` | ||
* | ||
* Synchronously return the resource with the given id. The data store will forward the request to the server if the | ||
* item is not in the cache. | ||
* | ||
* Example: | ||
* ## Signature: | ||
* ```js | ||
* DS.get(resourceName, id) | ||
* ``` | ||
* | ||
* ## Example: | ||
* | ||
* ```js | ||
@@ -24,5 +28,5 @@ * TODO: get(resourceName, id) example | ||
* | ||
* - `{IllegalArgumentError}` - Argument `id` must be a string or a number. | ||
* - `{RuntimeError}` - Argument `resourceName` must refer to an already registered resource. | ||
* - `{UnhandledError}` - Thrown for any uncaught exception. | ||
* - `{IllegalArgumentError}` | ||
* - `{RuntimeError}` | ||
* - `{UnhandledError}` | ||
* | ||
@@ -34,6 +38,6 @@ * @param {string} resourceName The resource type, e.g. 'user', 'comment', etc. | ||
function get(resourceName, id) { | ||
if (!store[resourceName]) { | ||
throw new errors.IllegalArgumentError('DS.get(resourceName, id): ' + resourceName + ' is not a registered resource!'); | ||
if (!services.store[resourceName]) { | ||
throw new errors.RuntimeError(errorPrefix + resourceName + ' is not a registered resource!'); | ||
} else if (!utils.isString(id) && !utils.isNumber(id)) { | ||
throw new errors.IllegalArgumentError('DS.get(resourceName, id): id: Must be a string or a number!', { id: { actual: typeof id, expected: 'string|number' } }); | ||
throw new errors.IllegalArgumentError(errorPrefix + 'id: Must be a string or a number!', { id: { actual: typeof id, expected: 'string|number' } }); | ||
} | ||
@@ -43,3 +47,3 @@ | ||
// cache miss, request resource from server | ||
if (!(id in store[resourceName].index)) { | ||
if (!(id in services.store[resourceName].index)) { | ||
this.find(resourceName, id); | ||
@@ -49,3 +53,3 @@ } | ||
// return resource from cache | ||
return store[resourceName].index[id]; | ||
return services.store[resourceName].index[id]; | ||
} catch (err) { | ||
@@ -52,0 +56,0 @@ throw new errors.UnhandledError(err); |
var utils = require('utils'), | ||
errors = require('errors'), | ||
store = require('store'); | ||
services = require('services'); | ||
@@ -38,3 +38,3 @@ function diffIsEmpty(diff) { | ||
function hasChanges(resourceName, id) { | ||
if (!store[resourceName]) { | ||
if (!services.store[resourceName]) { | ||
throw new errors.IllegalArgumentError('DS.hasChanges(resourceName, id): ' + resourceName + ' is not a registered resource!'); | ||
@@ -47,3 +47,3 @@ } else if (!utils.isString(id) && !utils.isNumber(id)) { | ||
// return resource from cache | ||
return diffIsEmpty(store[resourceName].changes[id]); | ||
return diffIsEmpty(services.store[resourceName].changes[id]); | ||
} catch (err) { | ||
@@ -50,0 +50,0 @@ throw new errors.UnhandledError(err); |
var utils = require('utils'), | ||
errors = require('errors'), | ||
store = require('store'), | ||
services = require('services'), | ||
@@ -98,3 +97,3 @@ observe = require('observejs'); | ||
function inject(resourceName, attrs) { | ||
if (!store[resourceName]) { | ||
if (!services.store[resourceName]) { | ||
throw new errors.RuntimeError('DS.inject(resourceName, attrs): ' + resourceName + ' is not a registered resource!'); | ||
@@ -105,3 +104,3 @@ } else if (!utils.isObject(attrs) && !utils.isArray(attrs)) { | ||
var resource = store[resourceName], | ||
var resource = services.store[resourceName], | ||
_this = this; | ||
@@ -116,6 +115,6 @@ | ||
services.$rootScope.$apply(function () { | ||
_inject.apply(_this, [store[resourceName], attrs]); | ||
_inject.apply(_this, [services.store[resourceName], attrs]); | ||
}); | ||
} else { | ||
_inject.apply(_this, [store[resourceName], attrs]); | ||
_inject.apply(_this, [services.store[resourceName], attrs]); | ||
} | ||
@@ -122,0 +121,0 @@ } catch (err) { |
var utils = require('utils'), | ||
errors = require('errors'), | ||
store = require('store'); | ||
services = require('services'); | ||
@@ -33,3 +33,3 @@ /** | ||
function lastModified(resourceName, id) { | ||
if (!store[resourceName]) { | ||
if (!services.store[resourceName]) { | ||
throw new errors.RuntimeError('DS.lastModified(resourceName[, id]): ' + resourceName + ' is not a registered resource!'); | ||
@@ -41,8 +41,8 @@ } else if (id && !utils.isString(id) && !utils.isNumber(id)) { | ||
if (id) { | ||
if (!(id in store[resourceName].modified)) { | ||
store[resourceName].modified[id] = 0; | ||
if (!(id in services.store[resourceName].modified)) { | ||
services.store[resourceName].modified[id] = 0; | ||
} | ||
return store[resourceName].modified[id]; | ||
return services.store[resourceName].modified[id]; | ||
} | ||
return store[resourceName].collectionModified; | ||
return services.store[resourceName].collectionModified; | ||
} catch (err) { | ||
@@ -49,0 +49,0 @@ throw new errors.UnhandledError(err); |
var utils = require('utils'), | ||
errors = require('errors'), | ||
store = require('store'); | ||
services = require('services'); | ||
@@ -33,3 +33,3 @@ /** | ||
function lastSaved(resourceName, id) { | ||
if (!store[resourceName]) { | ||
if (!services.store[resourceName]) { | ||
throw new errors.RuntimeError('DS.lastSaved(resourceName[, id]): ' + resourceName + ' is not a registered resource!'); | ||
@@ -41,8 +41,8 @@ } else if (id && !utils.isString(id) && !utils.isNumber(id)) { | ||
if (id) { | ||
if (!(id in store[resourceName].saved)) { | ||
store[resourceName].saved[id] = 0; | ||
if (!(id in services.store[resourceName].saved)) { | ||
services.store[resourceName].saved[id] = 0; | ||
} | ||
return store[resourceName].saved[id]; | ||
return services.store[resourceName].saved[id]; | ||
} | ||
return store[resourceName].collectionModified; | ||
return services.store[resourceName].collectionModified; | ||
} catch (err) { | ||
@@ -49,0 +49,0 @@ throw new errors.UnhandledError(err); |
var utils = require('utils'), | ||
errors = require('errors'), | ||
store = require('store'); | ||
services = require('services'), | ||
errorPrefix = 'DS.previous(resourceName, id): '; | ||
@@ -10,9 +11,12 @@ /** | ||
* @description | ||
* `previous(resourceName, id)` | ||
* | ||
* Synchronously return the previous attributes of the item of the type specified by `resourceName` that has the primary key | ||
* specified by `id`. This object represents the state of the item the last time it was saved via an async adapter. | ||
* | ||
* Example: | ||
* ## Signature: | ||
* ```js | ||
* DS.previous(resourceName, id) | ||
* ``` | ||
* | ||
* ## Example: | ||
* | ||
* ```js | ||
@@ -24,5 +28,5 @@ * TODO: previous(resourceName, id) example | ||
* | ||
* - `{IllegalArgumentError}` - Argument `id` must be a string or a number. | ||
* - `{RuntimeError}` - Argument `resourceName` must refer to an already registered resource. | ||
* - `{UnhandledError}` - Thrown for any uncaught exception. | ||
* - `{IllegalArgumentError}` | ||
* - `{RuntimeError}` | ||
* - `{UnhandledError}` | ||
* | ||
@@ -34,6 +38,6 @@ * @param {string} resourceName The resource type, e.g. 'user', 'comment', etc. | ||
function previous(resourceName, id) { | ||
if (!store[resourceName]) { | ||
throw new errors.IllegalArgumentError('DS.previous(resourceName, id): ' + resourceName + ' is not a registered resource!'); | ||
if (!services.store[resourceName]) { | ||
throw new errors.IllegalArgumentError(errorPrefix + resourceName + ' is not a registered resource!'); | ||
} else if (!utils.isString(id) && !utils.isNumber(id)) { | ||
throw new errors.IllegalArgumentError('DS.previous(resourceName, id): id: Must be a string or a number!', { id: { actual: typeof id, expected: 'string|number' } }); | ||
throw new errors.IllegalArgumentError(errorPrefix + 'id: Must be a string or a number!', { id: { actual: typeof id, expected: 'string|number' } }); | ||
} | ||
@@ -43,3 +47,3 @@ | ||
// return resource from cache | ||
return angular.copy(store[resourceName].previous_attributes[id]); | ||
return angular.copy(services.store[resourceName].previous_attributes[id]); | ||
} catch (err) { | ||
@@ -46,0 +50,0 @@ throw new errors.UnhandledError(err); |
@@ -11,3 +11,5 @@ /** | ||
Error.call(this); | ||
Error.captureStackTrace(this, this.constructor); | ||
if (typeof Error.captureStackTrace === 'function') { | ||
Error.captureStackTrace(this, this.constructor); | ||
} | ||
@@ -68,3 +70,5 @@ error = error || {}; | ||
Error.call(this); | ||
Error.captureStackTrace(this, this.constructor); | ||
if (typeof Error.captureStackTrace === 'function') { | ||
Error.captureStackTrace(this, this.constructor); | ||
} | ||
@@ -113,3 +117,5 @@ /** | ||
Error.call(this); | ||
Error.captureStackTrace(this, this.constructor); | ||
if (typeof Error.captureStackTrace === 'function') { | ||
Error.captureStackTrace(this, this.constructor); | ||
} | ||
@@ -148,2 +154,48 @@ /** | ||
/** | ||
* @doc function | ||
* @id errors.types:RuntimeError | ||
* @name RuntimeError | ||
* @description Error that is thrown/returned for invalid state during runtime. | ||
* @param {string=} message Error message. Default: `"Runtime Error!"`. | ||
* @param {object=} errors Object containing information about the error. | ||
* @returns {RuntimeError} A new instance of `RuntimeError`. | ||
*/ | ||
function RuntimeError(message, errors) { | ||
Error.call(this); | ||
if (typeof Error.captureStackTrace === 'function') { | ||
Error.captureStackTrace(this, this.constructor); | ||
} | ||
/** | ||
* @doc property | ||
* @id errors.types:RuntimeError.type | ||
* @name type | ||
* @propertyOf errors.types:RuntimeError | ||
* @description Name of error type. Default: `"RuntimeError"`. | ||
*/ | ||
this.type = this.constructor.name; | ||
/** | ||
* @doc property | ||
* @id errors.types:RuntimeError.errors | ||
* @name errors | ||
* @propertyOf errors.types:RuntimeError | ||
* @description Object containing information about the error. | ||
*/ | ||
this.errors = errors || {}; | ||
/** | ||
* @doc property | ||
* @id errors.types:RuntimeError.message | ||
* @name message | ||
* @propertyOf errors.types:RuntimeError | ||
* @description Error message. Default: `"Runtime Error!"`. | ||
*/ | ||
this.message = message || 'RuntimeError Error!'; | ||
} | ||
RuntimeError.prototype = Object.create(Error.prototype); | ||
RuntimeError.prototype.constructor = RuntimeError; | ||
/** | ||
* @doc interface | ||
@@ -159,43 +211,3 @@ * @id errors | ||
ValidationError: ValidationError, | ||
/** | ||
* @doc function | ||
* @id errors.types:RuntimeError | ||
* @name RuntimeError | ||
* @description Error that is thrown/returned for invalid state during runtime. | ||
* @param {string=} message Error message. Default: `"Runtime Error!"`. | ||
* @param {object=} errors Object containing information about the error. | ||
* @returns {RuntimeError} A new instance of `RuntimeError`. | ||
*/ | ||
RuntimeError: function RuntimeError(message, errors) { | ||
Error.call(this); | ||
Error.captureStackTrace(this, this.constructor); | ||
/** | ||
* @doc property | ||
* @id errors.types:RuntimeError.type | ||
* @name type | ||
* @propertyOf errors.types:RuntimeError | ||
* @description Name of error type. Default: `"RuntimeError"`. | ||
*/ | ||
this.type = this.constructor.name; | ||
/** | ||
* @doc property | ||
* @id errors.types:RuntimeError.errors | ||
* @name errors | ||
* @propertyOf errors.types:RuntimeError | ||
* @description Object containing information about the error. | ||
*/ | ||
this.errors = errors || {}; | ||
/** | ||
* @doc property | ||
* @id errors.types:RuntimeError.message | ||
* @name message | ||
* @propertyOf errors.types:RuntimeError | ||
* @description Error message. Default: `"Runtime Error!"`. | ||
*/ | ||
this.message = message || 'RuntimeError Error!'; | ||
} | ||
RuntimeError: RuntimeError | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
320168
58
7275
2
47
2
30
+ Addedmout@0.8.0
+ Addedmout@0.8.0(transitive)