angular-data
Advanced tools
Comparing version 0.10.1 to 0.10.2
@@ -0,4 +1,9 @@ | ||
##### 0.10.2 - 21 July 2014 | ||
###### Backwards compatible bug fixes | ||
- #99 - Computed properties + uglify | ||
##### 0.10.1 - 20 July 2014 | ||
##### Backwards compatible API changes | ||
###### Backwards compatible API changes | ||
- #93 - Added `DS.createInstance(resourceName[, attrs][, options])` | ||
@@ -5,0 +10,0 @@ - #96 - Resource definitions should be able to proxy DS methods |
@@ -11,2 +11,2 @@ /** | ||
!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(require,module,exports){!function(global){"use strict";function detectObjectObserve(){function a(a){b=a}if("function"!=typeof Object.observe||"function"!=typeof Array.observe)return!1;var b=[],c={},d=[];return Object.observe(c,a),Array.observe(d,a),c.id=1,c.id=2,delete c.id,d.push(1,2),d.length=0,Object.deliverChangeRecords(a),5!==b.length?!1:"add"!=b[0].type||"update"!=b[1].type||"delete"!=b[2].type||"splice"!=b[3].type||"splice"!=b[4].type?!1:(Object.unobserve(c,a),Array.unobserve(d,a),!0)}function detectEval(){if("undefined"!=typeof chrome&&chrome.app&&chrome.app.runtime)return!1;try{var a=new Function("","return true;");return a()}catch(b){return!1}}function dirtyCheck(a){for(var b=0;MAX_DIRTY_CHECK_CYCLES>b&&a.check_();)b++;return global.testingExposeCycleCount&&(global.dirtyCheckCycleCount=b),b>0}function objectIsEmpty(a){for(var b in a)return!1;return!0}function diffIsEmpty(a){return objectIsEmpty(a.added)&&objectIsEmpty(a.removed)&&objectIsEmpty(a.changed)}function diffObjectFromOldObject(a,b){var c={},d={},e={};for(var f in b){var g=a[f];(void 0===g||g!==b[f])&&(f in a?g!==b[f]&&(e[f]=g):d[f]=void 0)}for(var f in a)f in b||(c[f]=a[f]);return Array.isArray(a)&&a.length!==b.length&&(e.length=a.length),{added:c,removed:d,changed:e}}function runEOMTasks(){if(!eomTasks.length)return!1;for(var a=0;a<eomTasks.length;a++)eomTasks[a]();return eomTasks.length=0,!0}function newObservedObject(){function a(a){b&&b.state_===OPENED&&!d&&b.check_(a)}var b,c,d=!1,e=!0;return{open:function(c){if(b)throw Error("ObservedObject in use");e||Object.deliverChangeRecords(a),b=c,e=!1},observe:function(b,d){c=b,d?Array.observe(c,a):Object.observe(c,a)},deliver:function(b){d=b,Object.deliverChangeRecords(a),d=!1},close:function(){b=void 0,Object.unobserve(c,a),observedObjectCache.push(this)}}}function getObservedObject(a,b,c){var d=observedObjectCache.pop()||newObservedObject();return d.open(a),d.observe(b,c),d}function Observer(){this.state_=UNOPENED,this.callback_=void 0,this.target_=void 0,this.directObserver_=void 0,this.value_=void 0,this.id_=nextObserverId++}function addToAll(a){Observer._allObserversCount++,collectObservers&&allObservers.push(a)}function removeFromAll(){Observer._allObserversCount--}function ObjectObserver(a){Observer.call(this),this.value_=a,this.oldObject_=void 0}function diffObjectFromChangeRecords(a,b,c){for(var d={},e={},f=0;f<b.length;f++){var g=b[f];expectedRecordTypes[g.type]?(g.name in c||(c[g.name]=g.oldValue),"update"!=g.type&&("add"!=g.type?g.name in d?(delete d[g.name],delete c[g.name]):e[g.name]=!0:g.name in e?delete e[g.name]:d[g.name]=!0)):(console.error("Unknown changeRecord type: "+g.type),console.error(g))}for(var h in d)d[h]=a[h];for(var h in e)e[h]=void 0;var i={};for(var h in c)if(!(h in d||h in e)){var j=a[h];c[h]!==j&&(i[h]=j)}return{added:d,removed:e,changed:i}}var hasObserve=detectObjectObserve(),hasEval=detectEval(),createObject="__proto__"in{}?function(a){return a}:function(a){var b=a.__proto__;if(!b)return a;var c=Object.create(b);return Object.getOwnPropertyNames(a).forEach(function(b){Object.defineProperty(c,b,Object.getOwnPropertyDescriptor(a,b))}),c},MAX_DIRTY_CHECK_CYCLES=1e3,eomTasks=[],runEOM=hasObserve?function(){var a={pingPong:!0},b=!1;return Object.observe(a,function(){runEOMTasks(),b=!1}),function(c){eomTasks.push(c),b||(b=!0,a.pingPong=!a.pingPong)}}():function(){return function(a){eomTasks.push(a)}}(),observedObjectCache=[],UNOPENED=0,OPENED=1,CLOSED=2,nextObserverId=1;Observer.prototype={open:function(a,b){if(this.state_!=UNOPENED)throw Error("Observer has already been opened.");return addToAll(this),this.callback_=a,this.target_=b,this.connect_(),this.state_=OPENED,this.value_},close:function(){this.state_==OPENED&&(removeFromAll(this),this.disconnect_(),this.value_=void 0,this.callback_=void 0,this.target_=void 0,this.state_=CLOSED)},deliver:function(){this.state_==OPENED&&dirtyCheck(this)},report_:function(a){try{this.callback_.apply(this.target_,a)}catch(b){Observer._errorThrownDuringCallback=!0,console.error("Exception caught during observer callback: "+(b.stack||b))}},discardChanges:function(){return this.check_(void 0,!0),this.value_}};var collectObservers=!hasObserve,allObservers;Observer._allObserversCount=0,collectObservers&&(allObservers=[]);var runningMicrotaskCheckpoint=!1,hasDebugForceFullDelivery=hasObserve&&hasEval&&function(){try{return eval("%RunMicrotasks()"),!0}catch(ex){return!1}}();global.Platform=global.Platform||{},global.Platform.performMicrotaskCheckpoint=function(){if(!runningMicrotaskCheckpoint){if(hasDebugForceFullDelivery)return void eval("%RunMicrotasks()");if(collectObservers){runningMicrotaskCheckpoint=!0;var cycles=0,anyChanged,toCheck;do{cycles++,toCheck=allObservers,allObservers=[],anyChanged=!1;for(var i=0;i<toCheck.length;i++){var observer=toCheck[i];observer.state_==OPENED&&(observer.check_()&&(anyChanged=!0),allObservers.push(observer))}runEOMTasks()&&(anyChanged=!0)}while(MAX_DIRTY_CHECK_CYCLES>cycles&&anyChanged);global.testingExposeCycleCount&&(global.dirtyCheckCycleCount=cycles),runningMicrotaskCheckpoint=!1}}},collectObservers&&(global.Platform.clearObservers=function(){allObservers=[]}),ObjectObserver.prototype=createObject({__proto__:Observer.prototype,arrayObserve:!1,connect_:function(){hasObserve?this.directObserver_=getObservedObject(this,this.value_,this.arrayObserve):this.oldObject_=this.copyObject(this.value_)},copyObject:function(a){var b=Array.isArray(a)?[]:{};for(var c in a)b[c]=a[c];return Array.isArray(a)&&(b.length=a.length),b},check_:function(a){var b,c;if(hasObserve){if(!a)return!1;c={},b=diffObjectFromChangeRecords(this.value_,a,c)}else c=this.oldObject_,b=diffObjectFromOldObject(this.value_,this.oldObject_);return diffIsEmpty(b)?!1:(hasObserve||(this.oldObject_=this.copyObject(this.value_)),this.report_([b.added||{},b.removed||{},b.changed||{},function(a){return c[a]}]),!0)},disconnect_:function(){hasObserve?(this.directObserver_.close(),this.directObserver_=void 0):this.oldObject_=void 0},deliver:function(){this.state_==OPENED&&(hasObserve?this.directObserver_.deliver(!1):dirtyCheck(this))},discardChanges:function(){return this.directObserver_?this.directObserver_.deliver(!0):this.oldObject_=this.copyObject(this.value_),this.value_}});var observerSentinel={},expectedRecordTypes={add:!0,update:!0,"delete":!0};global.Observer=Observer,global.Observer.runEOM_=runEOM,global.Observer.observerSentinel_=observerSentinel,global.Observer.hasObjectObserve=hasObserve,global.ObjectObserver=ObjectObserver}((exports.Number={isNaN:window.isNaN})?exports:exports)},{}],2:[function(a,b){function c(a,b){return-1!==d(a,b)}var d=a("./indexOf");b.exports=c},{"./indexOf":5}],3:[function(a,b){function c(a,b,c){b=d(b,c);var e=[];if(null==a)return e;for(var f,g=-1,h=a.length;++g<h;)f=a[g],b(f,g,a)&&e.push(f);return e}var d=a("../function/makeIterator_");b.exports=c},{"../function/makeIterator_":11}],4:[function(a,b){function c(a,b,c){if(null!=a)for(var d=-1,e=a.length;++d<e&&b.call(c,a[d],d,a)!==!1;);}b.exports=c},{}],5:[function(a,b){function c(a,b,c){if(c=c||0,null==a)return-1;for(var d=a.length,e=0>c?d+c:c;d>e;){if(a[e]===b)return e;e++}return-1}b.exports=c},{}],6:[function(a,b){function c(a){return null!=a&&""!==a}function d(a,b){return b=b||"",e(a,c).join(b)}var e=a("./filter");b.exports=d},{"./filter":3}],7:[function(a,b){function c(a,b,c){var d=a.length;b=null==b?0:0>b?Math.max(d+b,0):Math.min(b,d),c=null==c?d:0>c?Math.max(d+c,0):Math.min(c,d);for(var e=[];c>b;)e.push(a[b++]);return e}b.exports=c},{}],8:[function(a,b){function c(a,b){if(null==a)return[];if(a.length<2)return a;null==b&&(b=d);var f,g,h;return f=~~(a.length/2),g=c(a.slice(0,f),b),h=c(a.slice(f,a.length),b),e(g,h,b)}function d(a,b){return b>a?-1:a>b?1:0}function e(a,b,c){for(var d=[];a.length&&b.length;)d.push(c(a[0],b[0])<=0?a.shift():b.shift());return a.length&&d.push.apply(d,a),b.length&&d.push.apply(d,b),d}b.exports=c},{}],9:[function(a,b){function c(a,b){var c={};if(null==a)return c;var e,f=-1,g=a.length;if(d(b))for(;++f<g;)e=a[f],c[b(e)]=e;else for(;++f<g;)e=a[f],c[e[b]]=e;return c}var d=a("../lang/isFunction");b.exports=c},{"../lang/isFunction":16}],10:[function(a,b){function c(a){return a}b.exports=c},{}],11:[function(a,b){function c(a,b){if(null==a)return d;switch(typeof a){case"function":return"undefined"!=typeof b?function(c,d,e){return a.call(b,c,d,e)}:a;case"object":return function(b){return f(b,a)};case"string":case"number":return e(a)}}var d=a("./identity"),e=a("./prop"),f=a("../object/deepMatches");b.exports=c},{"../object/deepMatches":21,"./identity":10,"./prop":12}],12:[function(a,b){function c(a){return function(b){return b[a]}}b.exports=c},{}],13:[function(a,b){var c=a("./isKind"),d=Array.isArray||function(a){return c(a,"Array")};b.exports=d},{"./isKind":17}],14:[function(a,b){function c(a){return d(a,"Boolean")}var d=a("./isKind");b.exports=c},{"./isKind":17}],15:[function(a,b){function c(a){if(null==a)return!1;if("string"==typeof a||e(a))return!a.length;if("object"==typeof a||"function"==typeof a){var b=!0;return d(a,function(){return b=!1,!1}),b}return!1}var d=a("../object/forOwn"),e=a("./isArray");b.exports=c},{"../object/forOwn":24,"./isArray":13}],16:[function(a,b){function c(a){return d(a,"Function")}var d=a("./isKind");b.exports=c},{"./isKind":17}],17:[function(a,b){function c(a,b){return d(a)===b}var d=a("./kindOf");b.exports=c},{"./kindOf":19}],18:[function(a,b){function c(a){return!!a&&"object"==typeof a&&a.constructor===Object}b.exports=c},{}],19:[function(a,b){function c(a){return null===a?"Null":a===d?"Undefined":e.exec(f.call(a))[1]}var d,e=/^\[object (.*)\]$/,f=Object.prototype.toString;b.exports=c},{}],20:[function(a,b){function c(a){return null==a?"":a.toString()}b.exports=c},{}],21:[function(a,b){function c(a,b){for(var c=-1,d=a.length;++c<d;)if(f(a[c],b))return!0;return!1}function d(a,b){for(var d=-1,e=b.length;++d<e;)if(!c(a,b[d]))return!1;return!0}function e(a,b){var c=!0;return g(b,function(b,d){return f(a[d],b)?void 0:c=!1}),c}function f(a,b){return a&&"object"==typeof a?h(a)&&h(b)?d(a,b):e(a,b):a===b}var g=a("./forOwn"),h=a("../lang/isArray");b.exports=f},{"../lang/isArray":13,"./forOwn":24}],22:[function(a,b){function c(a){for(var b,c=0,f=arguments.length;++c<f;)b=arguments[c],b&&e(b,d,a);return a}function d(a,b){var d=this[b];f(a)&&f(d)?c(d,a):this[b]=a}var e=a("./forOwn"),f=a("../lang/isPlainObject");b.exports=c},{"../lang/isPlainObject":18,"./forOwn":24}],23:[function(a,b){function c(){g=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],f=!0;for(var a in{toString:null})f=!1}function d(a,b,d){var i,j=0;null==f&&c();for(i in a)if(e(b,a,i,d)===!1)break;if(f)for(var k=a.constructor,l=!!k&&a===k.prototype;(i=g[j++])&&("constructor"===i&&(l||!h(a,i))||a[i]===Object.prototype[i]||e(b,a,i,d)!==!1););}function e(a,b,c,d){return a.call(d,b[c],c,b)}var f,g,h=a("./hasOwn");b.exports=d},{"./hasOwn":25}],24:[function(a,b){function c(a,b,c){e(a,function(e,f){return d(a,f)?b.call(c,a[f],f,a):void 0})}var d=a("./hasOwn"),e=a("./forIn");b.exports=c},{"./forIn":23,"./hasOwn":25}],25:[function(a,b){function c(a,b){return Object.prototype.hasOwnProperty.call(a,b)}b.exports=c},{}],26:[function(a,b){function c(a,b){return b?(d(b.split("."),function(b){a[b]||(a[b]={}),a=a[b]}),a):a}var d=a("../array/forEach");b.exports=c},{"../array/forEach":4}],27:[function(a,b){function c(a){for(var b,c="string"!=typeof arguments[1]?arguments[1]:d(arguments,1),e={},f=0;b=c[f++];)e[b]=a[b];return e}var d=a("../array/slice");b.exports=c},{"../array/slice":7}],28:[function(a,b){function c(a,b,c){var e=/^(.+)\.(.+)$/.exec(b);e?d(a,e[1])[e[2]]=c:a[b]=c}var d=a("./namespace");b.exports=c},{"./namespace":26}],29:[function(a,b){function c(){var a=d(e(arguments),"/");return a.replace(/([^:\/]|^)\/{2,}/g,"$1/")}var d=a("../array/join"),e=a("../array/slice");b.exports=c},{"../array/join":6,"../array/slice":7}],30:[function(a,b){function c(a){return a=d(a),a.toUpperCase()}var d=a("../lang/toString");b.exports=c},{"../lang/toString":20}],31:[function(a,b){function c(){var a=this.defaults={queryTransform:function(a,b){return b}};this.$get=["$http","$log","DSUtils",function(b,c,d){function e(a){var d=(new Date).getTime();return b(a).then(function(a){return c.debug(a.config.method+" request:"+a.config.url+" Time taken: "+((new Date).getTime()-d)+"ms",arguments),a})}function f(a,b){return b=b||{},e(d.deepMixIn(b,{url:a,method:"GET"}))}function g(a,b,c){return c=c||{},e(d.deepMixIn(c,{url:a,data:b,method:"POST"}))}function h(a,b,c){return c=c||{},e(d.deepMixIn(c,{url:a,data:b,method:"PUT"}))}function i(a,b){return b=b||{},this.HTTP(d.deepMixIn(b,{url:a,method:"DELETE"}))}function j(a,b,c){return c=c||{},this.POST(d.makePath(c.baseUrl||a.baseUrl,a.endpoint),b,c)}function k(a,b,c){return c=c||{},this.DEL(d.makePath(c.baseUrl||a.baseUrl,a.endpoint,b),c)}function l(b,c,e){return e=e||{},e.params=e.params||{},c&&(c=a.queryTransform(b.name,c),d.deepMixIn(e.params,c)),this.DEL(d.makePath(e.baseUrl||b.baseUrl,b.endpoint),e)}function m(a,b,c){return c=c||{},this.GET(d.makePath(c.baseUrl||a.baseUrl,a.endpoint,b),c)}function n(b,c,e){return e=e||{},e.params=e.params||{},c&&(c=a.queryTransform(b.name,c),d.deepMixIn(e.params,c)),this.GET(d.makePath(e.baseUrl||b.baseUrl,b.endpoint),e)}function o(a,b,c,e){return e=e||{},this.PUT(d.makePath(e.baseUrl||a.baseUrl,a.endpoint,b),c,e)}function p(b,c,e,f){return f=f||{},f.params=f.params||{},e&&(e=a.queryTransform(b.name,e),d.deepMixIn(f.params,e)),this.PUT(d.makePath(f.baseUrl||b.baseUrl,b.endpoint),c,f)}return{defaults:a,HTTP:e,GET:f,POST:g,PUT:h,DEL:i,find:m,findAll:n,create:j,update:o,updateAll:p,destroy:k,destroyAll:l}}]}b.exports=c},{}],32:[function(a,b){function c(){this.$get=["$q","DSUtils",function(a,b){function c(b){var c=a.defer();try{var d=localStorage.getItem(b);c.resolve(d?angular.fromJson(d):void 0)}catch(e){c.reject(e)}return c.promise}function d(c,d){var e=a.defer();try{var f=localStorage.getItem(c);f?(f=angular.fromJson(f),b.deepMixIn(f,d),e.resolve(localStorage.setItem(c,angular.toJson(f)))):e.resolve(localStorage.setItem(c,angular.toJson(d)))}catch(g){e.reject(g)}return e.promise}function e(b){var c=a.defer();try{c.resolve(localStorage.removeItem(b))}catch(d){c.reject(d)}return c.promise}function f(a,c,d){return d=d||{},e(b.makePath(d.baseUrl||a.baseUrl,a.endpoint,c),d)}function g(a,d,e){return e=e||{},c(b.makePath(e.baseUrl||a.baseUrl,a.endpoint,d),e)}function h(a,e,f,g){return g=g||{},d(b.makePath(g.baseUrl||a.baseUrl,a.endpoint,e),f,g).then(function(){return c(b.makePath(g.baseUrl||a.baseUrl,a.endpoint,e))})}return{find:g,findAll:function(){throw new Error("Not supported!")},create:function(){throw new Error("Not supported!")},update:h,updateAll:function(){throw new Error("Not supported!")},destroy:f,destroyAll:function(){throw new Error("Not supported!")}}}]}b.exports=c},{}],33:[function(a,b){function c(a,b,c){var e=this.$q.defer(),f=e.promise;try{if(c=c||{},!this.definitions[a])throw new this.errors.NER(d+a);if(!this.utils.isObject(b))throw new this.errors.IA(d+"attrs: Must be an object!");var g=this.definitions[a],h=this.store[a],i=this;"cacheResponse"in c||(c.cacheResponse=!0),f=f.then(function(b){return i.$q.promisify(g.beforeValidate)(a,b)}).then(function(b){return i.$q.promisify(g.validate)(a,b)}).then(function(b){return i.$q.promisify(g.afterValidate)(a,b)}).then(function(b){return i.$q.promisify(g.beforeCreate)(a,b)}).then(function(b){return i.adapters[c.adapter||g.defaultAdapter].create(g,g.serialize(a,b),c)}).then(function(b){return i.$q.promisify(g.afterCreate)(a,g.deserialize(a,b))}).then(function(a){if(c.cacheResponse){var b=i.inject(g.name,a),d=b[g.idAttribute];return h.completedQueries[d]=(new Date).getTime(),h.previousAttributes[d]=i.utils.deepMixIn({},b),h.saved[d]=i.utils.updateTimestamp(h.saved[d]),i.get(g.name,d)}return a}),e.resolve(b)}catch(j){e.reject(j)}return f}var d="DS.create(resourceName, attrs[, options]): ";b.exports=c},{}],34:[function(a,b){function c(a,b,c){var e=this.$q.defer(),f=e.promise;try{if(c=c||{},!this.definitions[a])throw new this.errors.NER(d+a);if(!this.utils.isString(b)&&!this.utils.isNumber(b))throw new this.errors.IA(d+"id: Must be a string or a number!");var g=this.get(a,b);if(!g)throw new this.errors.R(d+'id: "'+b+'" not found!');var h=this.definitions[a],i=this;f=f.then(function(b){return i.$q.promisify(h.beforeDestroy)(a,b)}).then(function(){return i.adapters[c.adapter||h.defaultAdapter].destroy(h,b,c)}).then(function(){return i.$q.promisify(h.afterDestroy)(a,g)}).then(function(){return i.eject(a,b),b}),e.resolve(g)}catch(j){e.reject(j)}return f}var d="DS.destroy(resourceName, id): ";b.exports=c},{}],35:[function(a,b){function c(a,b,c){var e=this.$q.defer(),f=e.promise;try{var g=this,h=this.errors.IA;if(c=c||{},!this.definitions[a])throw new this.errors.NER(d+a);if(!this.utils.isObject(b))throw new h(d+"params: Must be an object!");if(!this.utils.isObject(c))throw new h(d+"options: Must be an object!");var i=this.definitions[a];f=f.then(function(){return g.adapters[c.adapter||i.defaultAdapter].destroyAll(i,b,c)}).then(function(){return g.ejectAll(a,b)}),e.resolve()}catch(j){e.reject(j)}return f}var d="DS.destroyAll(resourceName, params[, options]): ";b.exports=c},{}],36:[function(a,b){function c(a,b,c){var e=this.$q.defer(),f=e.promise;try{var g=this.errors.IA;if(c=c||{},!this.definitions[a])throw new this.errors.NER(d+a);if(!this.utils.isString(b)&&!this.utils.isNumber(b))throw new g(d+"id: Must be a string or a number!");if(!this.utils.isObject(c))throw new g(d+"options: Must be an object!");"cacheResponse"in c||(c.cacheResponse=!0);var h=this.definitions[a],i=this.store[a],j=this;if(c.bypassCache&&delete i.completedQueries[b],!(b in i.completedQueries))return b in i.pendingQueries||(f=i.pendingQueries[b]=j.adapters[c.adapter||h.defaultAdapter].find(h,b,c).then(function(d){var e=h.deserialize(a,d);return c.cacheResponse?(delete i.pendingQueries[b],i.completedQueries[b]=(new Date).getTime(),j.inject(a,e)):e},function(a){return delete i.pendingQueries[b],j.$q.reject(a)})),i.pendingQueries[b];e.resolve(j.get(a,b))}catch(k){e.reject(k)}return f}var d="DS.find(resourceName, id[, options]): ";b.exports=c},{}],37:[function(a,b){function c(a,b,c,d){var e=this.store[c];return b=b||[],delete e.pendingQueries[d],e.completedQueries[d]=(new Date).getTime(),e.collectionModified=a.updateTimestamp(e.collectionModified),this.inject(c,b)}function d(a,b,d,e){var f=this.definitions[b],g=this.store[b],h=this,i=a.toJson(d);return e.bypassCache&&delete g.completedQueries[i],i in g.completedQueries?this.filter(b,d,e):(i in g.pendingQueries||(g.pendingQueries[i]=h.adapters[e.adapter||f.defaultAdapter].findAll(f,d,e).then(function(d){var g=f.deserialize(b,d);if(!e.cacheResponse)return g;try{return c.apply(h,[a,g,b,i])}catch(j){return h.$q.reject(j)}},function(a){return delete g.pendingQueries[i],h.$q.reject(a)})),g.pendingQueries[i])}function e(a,b,c){var e=this.$q.defer(),g=e.promise;try{var h=this.errors.IA,i=this;if(c=c||{},b=b||{},!this.definitions[a])throw new this.errors.NER(f+a);if(!this.utils.isObject(b))throw new h(f+"params: Must be an object!");if(!this.utils.isObject(c))throw new h(f+"options: Must be an object!");"cacheResponse"in c||(c.cacheResponse=!0),g=g.then(function(){return d.apply(i,[i.utils,a,b,c])}),e.resolve()}catch(j){e.reject(j)}return g}var f="DS.findAll(resourceName, params[, options]): ";b.exports=e},{}],38:[function(a,b){b.exports={create:a("./create"),destroy:a("./destroy"),destroyAll:a("./destroyAll"),find:a("./find"),findAll:a("./findAll"),loadRelations:a("./loadRelations"),refresh:a("./refresh"),save:a("./save"),update:a("./update"),updateAll:a("./updateAll")}},{"./create":33,"./destroy":34,"./destroyAll":35,"./find":36,"./findAll":37,"./loadRelations":39,"./refresh":40,"./save":41,"./update":42,"./updateAll":43}],39:[function(a,b){function c(a,b,c,e){var f=this.$q.defer(),g=f.promise;try{var h=this.errors.IA;if(e=e||{},(angular.isString(b)||angular.isNumber(b))&&(b=this.get(a,b)),angular.isString(c)&&(c=[c]),!this.definitions[a])throw new this.errors.NER(d+a);if(!this.utils.isObject(b))throw new h(d+"instance(Id): Must be a string, number or object!");if(!this.utils.isArray(c))throw new h(d+"relations: Must be a string or an array!");if(!this.utils.isObject(e))throw new h(d+"options: Must be an object!");var i=this.definitions[a],j=this,k=[],l=[];j.utils.forOwn(i.relations,function(a,d){j.utils.forOwn(a,function(a,f){if(j.utils.contains(c,f)){var g,h={};h[a.foreignKey]=b[i.idAttribute],"hasMany"===d?g=j.findAll(f,h,e):"hasOne"===d?a.localKey&&b[a.localKey]?g=j.find(f,b[a.localKey],e):a.foreignKey&&(g=j.findAll(f,h,e)):g=j.find(f,b[a.localKey],e),g&&(k.push(g),l.push(a.localField))}})}),g=g.then(function(){return j.$q.all(k)}).then(function(a){return angular.forEach(l,function(c,d){b[c]=a[d]}),b}),f.resolve()}catch(m){f.reject(m)}return g}var d="DS.loadRelations(resourceName, instance(Id), relations[, options]): ";b.exports=c},{}],40:[function(a,b){function c(a,b,c){var e=this.errors.IA;if(c=c||{},this.definitions[a]){if(this.utils.isString(b)||this.utils.isNumber(b)){if(this.utils.isObject(c))return c.bypassCache=!0,this.get(a,b)?this.find(a,b,c):!1;throw new e(d+"options: Must be an object!")}throw new e(d+"id: Must be a string or a number!")}throw new this.errors.NER(d+a)}var d="DS.refresh(resourceName, id[, options]): ";b.exports=c},{}],41:[function(a,b){function c(a,b,c){var e=this.$q.defer(),f=e.promise;try{var g=this.errors.IA;if(c=c||{},!this.definitions[a])throw new this.errors.NER(d+a);if(!this.utils.isString(b)&&!this.utils.isNumber(b))throw new g(d+"id: Must be a string or a number!");if(!this.utils.isObject(c))throw new g(d+"options: Must be an object!");var h=this.get(a,b);if(!h)throw new this.errors.R(d+'id: "'+b+'" not found!');var i=this.definitions[a],j=this.store[a],k=this;"cacheResponse"in c||(c.cacheResponse=!0),f=f.then(function(b){return k.$q.promisify(i.beforeValidate)(a,b)}).then(function(b){return k.$q.promisify(i.validate)(a,b)}).then(function(b){return k.$q.promisify(i.afterValidate)(a,b)}).then(function(b){return k.$q.promisify(i.beforeUpdate)(a,b)}).then(function(d){if(c.changesOnly){j.observers[b].deliver();var e=[],f=k.changes(a,b);for(var g in f.added)e.push(g);for(g in f.changed)e.push(g);if(f=k.utils.pick(d,e),k.utils.isEmpty(f))return d;d=f}return k.adapters[c.adapter||i.defaultAdapter].update(i,b,i.serialize(a,d),c)}).then(function(b){return k.$q.promisify(i.afterUpdate)(a,i.deserialize(a,b))}).then(function(d){if(c.cacheResponse){var e=k.inject(i.name,d,c);return j.previousAttributes[b]=k.utils.deepMixIn({},e),j.saved[b]=k.utils.updateTimestamp(j.saved[b]),k.get(a,b)}return d}),e.resolve(h)}catch(l){e.reject(l)}return f}var d="DS.save(resourceName, id[, options]): ";b.exports=c},{}],42:[function(a,b){function c(a,b,c,e){var f=this.$q.defer(),g=f.promise;try{var h=this.errors.IA;if(e=e||{},!this.definitions[a])throw new this.errors.NER(d+a);if(!this.utils.isString(b)&&!this.utils.isNumber(b))throw new h(d+"id: Must be a string or a number!");if(!this.utils.isObject(c))throw new h(d+"attrs: Must be an object!");if(!this.utils.isObject(e))throw new h(d+"options: Must be an object!");var i=this.definitions[a],j=this.store[a],k=this;"cacheResponse"in e||(e.cacheResponse=!0),g=g.then(function(b){return k.$q.promisify(i.beforeValidate)(a,b)}).then(function(b){return k.$q.promisify(i.validate)(a,b)}).then(function(b){return k.$q.promisify(i.afterValidate)(a,b)}).then(function(b){return k.$q.promisify(i.beforeUpdate)(a,b)}).then(function(c){return k.adapters[e.adapter||i.defaultAdapter].update(i,b,i.serialize(a,c),e)}).then(function(b){return k.$q.promisify(i.afterUpdate)(a,i.deserialize(a,b))}).then(function(a){if(e.cacheResponse){var b=k.inject(i.name,a,e),c=b[i.idAttribute];return j.previousAttributes[c]=k.utils.deepMixIn({},b),j.saved[c]=k.utils.updateTimestamp(j.saved[c]),k.get(i.name,c)}return a}),f.resolve(c)}catch(l){f.reject(l)}return g}var d="DS.update(resourceName, id, attrs[, options]): ";b.exports=c},{}],43:[function(a,b){function c(a,b,c,e){var f=this.$q.defer(),g=f.promise;try{var h=this.errors.IA;if(e=e||{},!this.definitions[a])throw new this.errors.NER(d+a);if(!this.utils.isObject(b))throw new h(d+"attrs: Must be an object!");if(!this.utils.isObject(c))throw new h(d+"params: Must be an object!");if(!this.utils.isObject(e))throw new h(d+"options: Must be an object!");var i=this.definitions[a],j=this;"cacheResponse"in e||(e.cacheResponse=!0),g=g.then(function(b){return j.$q.promisify(i.beforeValidate)(a,b)}).then(function(b){return j.$q.promisify(i.validate)(a,b)}).then(function(b){return j.$q.promisify(i.afterValidate)(a,b)}).then(function(b){return j.$q.promisify(i.beforeUpdate)(a,b)}).then(function(b){return j.adapters[e.adapter||i.defaultAdapter].updateAll(i,i.serialize(a,b),c,e)}).then(function(b){return j.$q.promisify(i.afterUpdate)(a,i.deserialize(a,b))}).then(function(a){return e.cacheResponse?j.inject(i.name,a,e):a}),f.resolve(b)}catch(k){f.reject(k)}return g}var d="DS.updateAll(resourceName, attrs, params[, options]): ";b.exports=c},{}],44:[function(a,b){function c(a,b,c){c(null,b)}function d(){}function e(){var b=this.defaults=new d;this.$get=["$rootScope","$log","$q","DSHttpAdapter","DSLocalStorageAdapter","DSUtils","DSErrors",function(c,d,e,f,g,h,i){var j,k=a("./sync_methods"),l=a("./async_methods");try{j=angular.injector(["angular-data.DSCacheFactory"]).get("DSCacheFactory")}catch(m){d.warn(m),d.warn("DSCacheFactory is unavailable. Resorting to the lesser capabilities of $cacheFactory."),j=angular.injector(["ng"]).get("$cacheFactory")}var n={$rootScope:c,$log:d,$q:e,cacheFactory:j,defaults:b,store:{},definitions:{},adapters:{DSHttpAdapter:f,DSLocalStorageAdapter:g},errors:i,utils:h};return h.deepFreeze(k),h.deepFreeze(l),h.deepMixIn(n,k),h.deepMixIn(n,l),h.deepFreeze(n.errors),h.deepFreeze(n.utils),c.$watch(function(){return(new Date).getTime()/100|0},function(){n.digest()}),n}]}a("../utils")[0]();d.prototype.idAttribute="id",d.prototype.defaultAdapter="DSHttpAdapter",d.prototype.defaultFilter=function(a,b,c,d){var e=this,f=a,g=null,h={skip:"",offset:"",where:"",limit:"",orderBy:"",sort:""};g=this.utils.isObject(c.where)?c.where:{},d.allowSimpleWhere&&this.utils.forOwn(c,function(a,b){b in h||b in g||(g[b]={"==":a})}),this.utils.isEmpty(g)&&(g=null),g&&(f=this.utils.filter(f,function(a){var b=!0,c=!0;return e.utils.forOwn(g,function(d,f){e.utils.isString(d)?d={"===":d}:(e.utils.isNumber(d)||e.utils.isBoolean(d))&&(d={"==":d}),e.utils.isObject(d)&&e.utils.forOwn(d,function(d,g){"=="===g?c=b?a[f]==d:c&&a[f]==d:"==="===g?c=b?a[f]===d:c&&a[f]===d:"!="===g?c=b?a[f]!=d:c&&a[f]!=d:"!=="===g?c=b?a[f]!==d:c&&a[f]!==d:">"===g?c=b?a[f]>d:c&&a[f]>d:">="===g?c=b?a[f]>=d:c&&a[f]>=d:"<"===g?c=b?a[f]<d:c&&a[f]<d:"<="===g?c=b?a[f]<=d:c&&a[f]<=d:"in"===g?c=b?e.utils.contains(d,a[f]):c&&e.utils.contains(d,a[f]):"|=="===g?c=b?a[f]==d:c||a[f]==d:"|==="===g?c=b?a[f]===d:c||a[f]===d:"|!="===g?c=b?a[f]!=d:c||a[f]!=d:"|!=="===g?c=b?a[f]!==d:c||a[f]!==d:"|>"===g?c=b?a[f]>d:c||a[f]>d:"|>="===g?c=b?a[f]>=d:c||a[f]>=d:"|<"===g?c=b?a[f]<d:c||a[f]<d:"|<="===g?c=b?a[f]<=d:c||a[f]<=d:"|in"===g&&(c=b?e.utils.contains(d,a[f]):c||e.utils.contains(d,a[f])),b=!1})}),c}));var i=null;this.utils.isString(c.orderBy)?i=[[c.orderBy,"ASC"]]:this.utils.isArray(c.orderBy)&&(i=c.orderBy),!i&&this.utils.isString(c.sort)?i=[[c.sort,"ASC"]]:!i&&this.utils.isArray(c.sort)&&(i=c.sort),i&&angular.forEach(i,function(a){if(e.utils.isString(a))a=[a,"ASC"];else if(!e.utils.isArray(a))throw new e.errors.IllegalArgumentError("DS.filter(resourceName[, params][, options]): "+angular.toJson(a)+": Must be a string or an array!",{params:{"orderBy[i]":{actual:typeof a,expected:"string|array"}}});f=e.utils.sort(f,function(b,c){var d=b[a[0]],f=c[a[0]];return e.utils.isString(d)&&(d=e.utils.upperCase(d)),e.utils.isString(f)&&(f=e.utils.upperCase(f)),"DESC"===a[1]?d>f?-1:f>d?1:0:f>d?-1:d>f?1:0})});var j=angular.isNumber(c.limit)?c.limit:null,k=null;return angular.isNumber(c.skip)?k=c.skip:angular.isNumber(c.offset)&&(k=c.offset),j&&k?f=this.utils.slice(f,k,Math.min(f.length,k+j)):this.utils.isNumber(j)?f=this.utils.slice(f,0,Math.min(f.length,j)):this.utils.isNumber(k)&&(f=k<f.length?this.utils.slice(f,k):[]),f},d.prototype.baseUrl="",d.prototype.endpoint="",d.prototype.useClass=!1,d.prototype.beforeValidate=c,d.prototype.validate=c,d.prototype.afterValidate=c,d.prototype.beforeCreate=c,d.prototype.afterCreate=c,d.prototype.beforeUpdate=c,d.prototype.afterUpdate=c,d.prototype.beforeDestroy=c,d.prototype.afterDestroy=c,d.prototype.beforeInject=function(a,b){return b},d.prototype.afterInject=function(a,b){return b},d.prototype.serialize=function(a,b){return b},d.prototype.deserialize=function(a,b){return b.data},b.exports=e},{"../utils":63,"./async_methods":38,"./sync_methods":56}],45:[function(a,b){function c(a,b,c,e,f){var g=this.errors.IA;if(!this.utils.isObject(a))throw new g(d+"scope: Must be an object!");if(!this.utils.isString(b))throw new g(d+"expr: Must be a string!");if(!this.definitions[c])throw new this.errors.NER(d+c);if(!this.utils.isObject(e))throw new g(d+"params: Must be an object!");var h=this;try{return a.$watch(function(){return h.lastModified(c)},function(){var d=h.filter(c,e);h.utils.set(a,b,d),f&&f(null,d)})}catch(i){if(!f)throw i;f(i)}}var d="DS.bindAll(scope, expr, resourceName, params[, cb]): ";b.exports=c},{}],46:[function(a,b){function c(a,b,c,e,f){var g=this.errors.IA;if(!this.utils.isObject(a))throw new g(d+"scope: Must be an object!");if(!this.utils.isString(b))throw new g(d+"expr: Must be a string!");if(!this.definitions[c])throw new this.errors.NER(d+c);if(!this.utils.isString(e)&&!this.utils.isNumber(e))throw new g(d+"id: Must be a string or a number!");var h=this;try{return a.$watch(function(){return h.lastModified(c,e)},function(){var d=h.get(c,e);h.utils.set(a,b,d),f&&f(null,d)})}catch(i){if(!f)throw i;f(i)}}var d="DS.bindOne(scope, expr, resourceName, id[, cb]): ";b.exports=c},{}],47:[function(a,b){function c(a,b){if(!this.definitions[a])throw new this.errors.NER(d+a);if(!this.utils.isString(b)&&!this.utils.isNumber(b))throw new this.errors.IA(d+"id: Must be a string or a number!");var c=this.get(a,b);return c?(this.store[a].observers[b].deliver(),this.utils.diffObjectFromOldObject(c,this.store[a].previousAttributes[b])):void 0}var d="DS.changes(resourceName, id): ";b.exports=c},{}],48:[function(a,b){function c(a,b,c){var e=this.errors.IA;if(b=b||{},c=c||{},!this.definitions[a])throw new this.errors.NER(d+a);if(b&&!this.utils.isObject(b))throw new e(d+"attrs: Must be an object!");if(!this.utils.isObject(c))throw new e(d+"options: Must be an object!");"useClass"in c||(c.useClass=!0);var f;if(c.useClass){var g=this.definitions[a][this.definitions[a].class];f=new g}else f={};return this.utils.deepMixIn(f,b)}var d="DS.createInstance(resourceName[, attrs][, options]): ";b.exports=c},{}],49:[function(require,module,exports){function Resource(a,b){a.deepMixIn(this,b),this.endpoint="endpoint"in b?b.endpoint:this.name}function defineResource(definition){var IA=this.errors.IA,DS=this;if(this.utils.isString(definition)&&(definition=definition.replace(/\s/gi,""),definition={name:definition}),!this.utils.isObject(definition))throw new IA(errorPrefix+"definition: Must be an object!");if(!this.utils.isString(definition.name))throw new IA(errorPrefix+"definition.name: Must be a string!");if(definition.idAttribute&&!this.utils.isString(definition.idAttribute))throw new IA(errorPrefix+"definition.idAttribute: Must be a string!"); | ||
if(definition.endpoint&&!this.utils.isString(definition.endpoint))throw new IA(errorPrefix+"definition.endpoint: Must be a string!");if(this.store[definition.name])throw new this.errors.R(errorPrefix+definition.name+" is already registered!");try{Resource.prototype=DS.defaults,DS.definitions[definition.name]=new Resource(DS.utils,definition);var def=DS.definitions[definition.name];def.filter&&(def.defaultFilter=def.filter,delete def.filter);var cache=DS.cacheFactory("DS."+def.name,{maxAge:def.maxAge||null,recycleFreq:def.recycleFreq||1e3,cacheFlushInterval:def.cacheFlushInterval||null,deleteOnExpire:def.deleteOnExpire||"none",onExpire:function(a){DS.eject(def.name,a)},capacity:Number.MAX_VALUE,storageMode:"memory",storageImpl:null,disabled:!1,storagePrefix:"DS."+def.name});return def.class=definition.name[0].toUpperCase()+definition.name.substring(1),eval("function "+def.class+"() {}"),def[def.class]=eval(def.class),def.methods&&DS.utils.deepMixIn(def[def.class].prototype,def.methods),def.computed&&DS.utils.forOwn(def.computed,function(a,b){def.methods&&b in def.methods&&DS.$log.warn(errorPrefix+'Computed property "'+b+'" conflicts with previously defined prototype method!');var c=a.toString().match(/function.*?\(([\s\S]*?)\)/),d=c[1].split(",");a.deps=DS.utils.filter(d,function(a){return!!a}),angular.forEach(a.deps,function(b,c){a.deps[c]=b.trim()})}),DS.store[def.name]={collection:[],completedQueries:{},pendingQueries:{},index:cache,modified:{},saved:{},previousAttributes:{},observers:{},collectionModified:0},angular.forEach(methodsToProxy,function(a){def[a]="bindOne"===a||"bindAll"===a?function(){var b=Array.prototype.slice.call(arguments);return b.splice(2,0,def.name),DS[a].apply(DS,b)}:function(){var b=Array.prototype.slice.call(arguments);return b.unshift(def.name),DS[a].apply(DS,b)}}),def}catch(err){throw DS.$log.error(err),delete this.definitions[definition.name],delete this.store[definition.name],err}}var errorPrefix="DS.defineResource(definition): ",methodsToProxy=["bindAll","bindOne","create","createInstance","destroy","destroyAll","filter","find","findAll","get","hasChanges","inject","lastModified","lastSaved","loadRelations","previous","refresh","save","update","updateAll"];module.exports=defineResource},{}],50:[function(a,b){function c(){this.$rootScope.$$phase?d.Platform.performMicrotaskCheckpoint():this.$rootScope.$apply(function(){d.Platform.performMicrotaskCheckpoint()})}var d=a("../../../lib/observe-js/observe-js");b.exports=c},{"../../../lib/observe-js/observe-js":1}],51:[function(a,b){function c(a,b,c){for(var d=!1,e=0;e<b.collection.length;e++)if(b.collection[e][a.idAttribute]==c){d=!0;break}d&&(b.collection.splice(e,1),b.observers[c].close(),delete b.observers[c],b.index.remove(c),delete b.previousAttributes[c],delete b.modified[c],delete b.saved[c])}function d(a,b){if(!this.definitions[a])throw new this.errors.NER(e+a);if(!this.utils.isString(b)&&!this.utils.isNumber(b))throw new this.errors.IA(e+"id: Must be a string or a number!");var d=this.store[a],f=this;this.$rootScope.$$phase?(c(f.definitions[a],d,b),d.collectionModified=f.utils.updateTimestamp(d.collectionModified)):this.$rootScope.$apply(function(){c(f.definitions[a],d,b),d.collectionModified=f.utils.updateTimestamp(d.collectionModified)}),delete this.store[a].completedQueries[b]}var e="DS.eject(resourceName, id): ";b.exports=d},{}],52:[function(a,b){function c(a,b,c){var d=this.utils.toJson(c),e=this.filter(a.name,c),f=this.utils.toLookup(e,a.idAttribute),g=this;angular.forEach(f,function(b,c){g.eject(a.name,c)}),delete b.completedQueries[d]}function d(a,b){if(b=b||{},!this.definitions[a])throw new this.errors.NER(e+a);if(!this.utils.isObject(b))throw new this.errors.IA(e+"params: Must be an object!");var d=this,f=this.store[a],g=this.utils.toJson(b);delete f.completedQueries[g],this.utils.isEmpty(b)&&(f.completedQueries={}),this.$rootScope.$$phase?(c.apply(d,[d.definitions[a],f,b]),f.collectionModified=this.utils.updateTimestamp(f.collectionModified)):this.$rootScope.$apply(function(){c.apply(d,[d.definitions[a],f,b]),f.collectionModified=d.utils.updateTimestamp(f.collectionModified)})}var e="DS.ejectAll(resourceName[, params]): ";b.exports=d},{}],53:[function(a,b){function c(a,b,c){var e=this.errors.IA;if(c=c||{},!this.definitions[a])throw new this.errors.NER(d+a);if(b&&!this.utils.isObject(b))throw new e(d+"params: Must be an object!");if(!this.utils.isObject(c))throw new e(d+"options: Must be an object!");var f=this.definitions[a],g=this.store[a];b=b||{},c.allowSimpleWhere="allowSimpleWhere"in c?!!c.allowSimpleWhere:!0;var h=this.utils.toJson(b);return h in g.completedQueries||!c.loadFromServer||g.pendingQueries[h]||this.findAll(a,b,c),f.defaultFilter.call(this,g.collection,a,b,c)}var d="DS.filter(resourceName[, params][, options]): ";b.exports=c},{}],54:[function(a,b){function c(a,b,c){var e=this.errors.IA;if(c=c||{},!this.definitions[a])throw new this.errors.NER(d+a);if(!this.utils.isString(b)&&!this.utils.isNumber(b))throw new e(d+"id: Must be a string or a number!");if(!this.utils.isObject(c))throw new e(d+"options: Must be an object!");var f=this,g=this.store[a].index.get(b);return!g&&c.loadFromServer&&this.find(a,b).then(null,function(a){return f.$q.reject(a)}),g}var d="DS.get(resourceName, id[, options]): ";b.exports=c},{}],55:[function(a,b){function c(a,b){return!(a.isEmpty(b.added)&&a.isEmpty(b.removed)&&a.isEmpty(b.changed))}function d(a,b){if(!this.definitions[a])throw new this.errors.NER(e+a);if(!this.utils.isString(b)&&!this.utils.isNumber(b))throw new this.errors.IA(e+"id: Must be a string or a number!");return this.get(a,b)?c(this.utils,this.changes(a,b)):!1}var e="DS.hasChanges(resourceName, id): ";b.exports=d},{}],56:[function(a,b){b.exports={bindOne:a("./bindOne"),bindAll:a("./bindAll"),createInstance:a("./createInstance"),defineResource:a("./defineResource"),eject:a("./eject"),ejectAll:a("./ejectAll"),filter:a("./filter"),get:a("./get"),inject:a("./inject"),lastModified:a("./lastModified"),lastSaved:a("./lastSaved"),digest:a("./digest"),changes:a("./changes"),previous:a("./previous"),hasChanges:a("./hasChanges")}},{"./bindAll":45,"./bindOne":46,"./changes":47,"./createInstance":48,"./defineResource":49,"./digest":50,"./eject":51,"./ejectAll":52,"./filter":53,"./get":54,"./hasChanges":55,"./inject":57,"./lastModified":58,"./lastSaved":59,"./previous":60}],57:[function(a,b){function c(a,b,d){function e(c,d,e,f){var g=this,h=f&&f(a.idAttribute)?f(a.idAttribute):g[a.idAttribute];if(b.modified[h]=i.utils.updateTimestamp(b.modified[h]),b.collectionModified=i.utils.updateTimestamp(b.collectionModified),a.computed){var k=i.get(a.name,h);i.utils.forOwn(a.computed,function(a,b){var f=!1;if(angular.forEach(a.deps,function(a){(a in c||a in d||a in e||!(b in k))&&(f=!0)}),f){var g=[];angular.forEach(a.deps,function(a){g.push(k[a])}),k[b]=a.apply(k,g)}})}a.idAttribute in e&&j.error("Doh! You just changed the primary key of an object! I don't know how to handle this yet, so your data for the \""+a.name+'" resource is now in an undefined (probably broken) state.')}var h,i=this,j=i.$log;if(i.utils.isArray(d)){h=[];for(var k=0;k<d.length;k++)h.push(c.call(i,a,b,d[k]))}else{if(a.computed&&a.computed[a.idAttribute]){var l=[];angular.forEach(a.computed[a.idAttribute].deps,function(a){l.push(d[a])}),d[a.idAttribute]=a.computed[a.idAttribute].apply(d,l)}if(!(a.idAttribute in d)){var m=new i.errors.R(g+"attrs: Must contain the property specified by `idAttribute`!");throw j.error(m),m}try{a.beforeInject(a.name,d);var n=d[a.idAttribute],o=this.get(a.name,n);o?(i.utils.deepMixIn(o,d),"function"==typeof b.index.touch?b.index.touch(n):b.index.put(n,b.index.get(n)),b.observers[n].deliver()):(o=a.methods||a.useClass?d instanceof a[a.class]?d:new a[a.class]:{},b.previousAttributes[n]={},i.utils.deepMixIn(o,d),i.utils.deepMixIn(b.previousAttributes[n],d),b.collection.push(o),b.observers[n]=new f.ObjectObserver(o),b.observers[n].open(e,o),b.index.put(n,o),e.call(o,{},{},{})),b.saved[n]=i.utils.updateTimestamp(b.saved[n]),a.afterInject(a.name,o),h=o}catch(p){j.error(p),j.error("inject failed!",a.name,d)}}return h}function d(a,b){var c=this;c.utils.forOwn(a.relations,function(a,d){c.utils.forOwn(a,function(a,e){if(c.definitions[e]&&b[a.localField])try{b[a.localField]=c.inject(e,b[a.localField])}catch(f){c.$log.error(g+"Failed to inject "+d+' relation: "'+e+'"!',f)}})})}function e(a,b,e){var f=this.errors.IA;if(e=e||{},!this.definitions[a])throw new this.errors.NER(g+a);if(!this.utils.isObject(b)&&!this.utils.isArray(b))throw new f(g+"attrs: Must be an object or an array!");if(!this.utils.isObject(e))throw new f(g+"options: Must be an object!");var h,i=this.definitions[a],j=this.store[a],k=this;return this.$rootScope.$$phase?h=c.call(k,i,j,b):this.$rootScope.$apply(function(){h=c.call(k,i,j,b)}),i.relations&&d.call(k,i,h),h}var f=a("../../../lib/observe-js/observe-js"),g="DS.inject(resourceName, attrs[, options]): ";b.exports=e},{"../../../lib/observe-js/observe-js":1}],58:[function(a,b){function c(a,b){if(!this.definitions[a])throw new this.errors.NER(d+a);if(b&&!this.utils.isString(b)&&!this.utils.isNumber(b))throw new this.errors.IA(d+"id: Must be a string or a number!");return b?(b in this.store[a].modified||(this.store[a].modified[b]=0),this.store[a].modified[b]):this.store[a].collectionModified}var d="DS.lastModified(resourceName[, id]): ";b.exports=c},{}],59:[function(a,b){function c(a,b){if(!this.definitions[a])throw new this.errors.NER(d+a);if(!this.utils.isString(b)&&!this.utils.isNumber(b))throw new this.errors.IA(d+"id: Must be a string or a number!");return b in this.store[a].saved||(this.store[a].saved[b]=0),this.store[a].saved[b]}var d="DS.lastSaved(resourceName[, id]): ";b.exports=c},{}],60:[function(a,b){function c(a,b){if(!this.definitions[a])throw new this.errors.NER(d+a);if(!this.utils.isString(b)&&!this.utils.isNumber(b))throw new this.errors.IA(d+"id: Must be a string or a number!");return angular.copy(this.store[a].previousAttributes[b])}var d="DS.previous(resourceName, id): ";b.exports=c},{}],61:[function(a,b){function c(a){Error.call(this),"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.type=this.constructor.name,this.message=a||"Illegal Argument!"}function d(a){Error.call(this),"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.type=this.constructor.name,this.message=a||"RuntimeError Error!"}function e(a){Error.call(this),"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.type=this.constructor.name,this.message=(a||"")+" is not a registered resource!"}c.prototype=Object.create(Error.prototype),c.prototype.constructor=c,d.prototype=Object.create(Error.prototype),d.prototype.constructor=d,e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,b.exports=[function(){return{IllegalArgumentError:c,IA:c,RuntimeError:d,R:d,NonexistentResourceError:e,NER:e}}]},{}],62:[function(a){!function(b,c){"use strict";c.module("angular-data.DS",["ng"]).factory("DSUtils",a("./utils")).factory("DSErrors",a("./errors")).provider("DSHttpAdapter",a("./adapters/http")).provider("DSLocalStorageAdapter",a("./adapters/localStorage")).provider("DS",a("./datastore")).config(["$provide",function(a){a.decorator("$q",["$delegate",function(a){return a.promisify=function(a,b){var c=this;return function(){var d=c.defer(),e=Array.prototype.slice.apply(arguments);e.push(function(a,b){a?d.reject(a):d.resolve(b)});try{a.apply(b||this,e)}catch(f){d.reject(f)}return d.promise}},a}])}])}(window,window.angular)},{"./adapters/http":31,"./adapters/localStorage":32,"./datastore":44,"./errors":61,"./utils":63}],63:[function(a,b){b.exports=[function(){return{isBoolean:a("mout/lang/isBoolean"),isString:angular.isString,isArray:angular.isArray,isObject:angular.isObject,isNumber:angular.isNumber,isFunction:angular.isFunction,isEmpty:a("mout/lang/isEmpty"),toJson:angular.toJson,makePath:a("mout/string/makePath"),upperCase:a("mout/string/upperCase"),deepMixIn:a("mout/object/deepMixIn"),forOwn:a("mout/object/forOwn"),pick:a("mout/object/pick"),set:a("mout/object/set"),contains:a("mout/array/contains"),filter:a("mout/array/filter"),toLookup:a("mout/array/toLookup"),slice:a("mout/array/slice"),sort:a("mout/array/sort"),updateTimestamp:function(a){var b="function"==typeof Date.now?Date.now():(new Date).getTime();return a&&a>=b?a+1:b},deepFreeze:function b(a){if("function"==typeof Object.freeze){var c,d;Object.freeze(a);for(d in a)c=a[d],a.hasOwnProperty(d)&&"object"==typeof c&&!Object.isFrozen(c)&&b(c)}},diffObjectFromOldObject:function(a,b){var c={},d={},e={};for(var f in b){var g=a[f];(void 0===g||g!==b[f])&&(f in a?g!==b[f]&&(e[f]=g):d[f]=void 0)}for(var h in a)h in b||(c[h]=a[h]);return{added:c,removed:d,changed:e}}}}]},{"mout/array/contains":2,"mout/array/filter":3,"mout/array/slice":7,"mout/array/sort":8,"mout/array/toLookup":9,"mout/lang/isBoolean":14,"mout/lang/isEmpty":15,"mout/object/deepMixIn":22,"mout/object/forOwn":24,"mout/object/pick":27,"mout/object/set":28,"mout/string/makePath":29,"mout/string/upperCase":30}]},{},[62]); | ||
if(definition.endpoint&&!this.utils.isString(definition.endpoint))throw new IA(errorPrefix+"definition.endpoint: Must be a string!");if(this.store[definition.name])throw new this.errors.R(errorPrefix+definition.name+" is already registered!");try{Resource.prototype=DS.defaults,DS.definitions[definition.name]=new Resource(DS.utils,definition);var def=DS.definitions[definition.name];def.filter&&(def.defaultFilter=def.filter,delete def.filter);var cache=DS.cacheFactory("DS."+def.name,{maxAge:def.maxAge||null,recycleFreq:def.recycleFreq||1e3,cacheFlushInterval:def.cacheFlushInterval||null,deleteOnExpire:def.deleteOnExpire||"none",onExpire:function(a){DS.eject(def.name,a)},capacity:Number.MAX_VALUE,storageMode:"memory",storageImpl:null,disabled:!1,storagePrefix:"DS."+def.name});return def.class=definition.name[0].toUpperCase()+definition.name.substring(1),eval("function "+def.class+"() {}"),def[def.class]=eval(def.class),def.methods&&DS.utils.deepMixIn(def[def.class].prototype,def.methods),def.computed&&DS.utils.forOwn(def.computed,function(a,b){def.methods&&b in def.methods&&DS.$log.warn(errorPrefix+'Computed property "'+b+'" conflicts with previously defined prototype method!');var c;if(angular.isFunction(a)){var d=a.toString().match(/function.*?\(([\s\S]*?)\)/);c=d[1].split(","),DS.$log.warn(errorPrefix+"Use the computed property array for compatibility with minified code!")}else c=a.slice(0,a.length-1);a.deps=DS.utils.filter(c,function(a){return!!a}),angular.forEach(a.deps,function(b,c){a.deps[c]=b.trim()})}),DS.store[def.name]={collection:[],completedQueries:{},pendingQueries:{},index:cache,modified:{},saved:{},previousAttributes:{},observers:{},collectionModified:0},angular.forEach(methodsToProxy,function(a){def[a]="bindOne"===a||"bindAll"===a?function(){var b=Array.prototype.slice.call(arguments);return b.splice(2,0,def.name),DS[a].apply(DS,b)}:function(){var b=Array.prototype.slice.call(arguments);return b.unshift(def.name),DS[a].apply(DS,b)}}),def}catch(err){throw DS.$log.error(err),delete this.definitions[definition.name],delete this.store[definition.name],err}}var errorPrefix="DS.defineResource(definition): ",methodsToProxy=["bindAll","bindOne","create","createInstance","destroy","destroyAll","filter","find","findAll","get","hasChanges","inject","lastModified","lastSaved","loadRelations","previous","refresh","save","update","updateAll"];module.exports=defineResource},{}],50:[function(a,b){function c(){this.$rootScope.$$phase?d.Platform.performMicrotaskCheckpoint():this.$rootScope.$apply(function(){d.Platform.performMicrotaskCheckpoint()})}var d=a("../../../lib/observe-js/observe-js");b.exports=c},{"../../../lib/observe-js/observe-js":1}],51:[function(a,b){function c(a,b,c){for(var d=!1,e=0;e<b.collection.length;e++)if(b.collection[e][a.idAttribute]==c){d=!0;break}d&&(b.collection.splice(e,1),b.observers[c].close(),delete b.observers[c],b.index.remove(c),delete b.previousAttributes[c],delete b.modified[c],delete b.saved[c])}function d(a,b){if(!this.definitions[a])throw new this.errors.NER(e+a);if(!this.utils.isString(b)&&!this.utils.isNumber(b))throw new this.errors.IA(e+"id: Must be a string or a number!");var d=this.store[a],f=this;this.$rootScope.$$phase?(c(f.definitions[a],d,b),d.collectionModified=f.utils.updateTimestamp(d.collectionModified)):this.$rootScope.$apply(function(){c(f.definitions[a],d,b),d.collectionModified=f.utils.updateTimestamp(d.collectionModified)}),delete this.store[a].completedQueries[b]}var e="DS.eject(resourceName, id): ";b.exports=d},{}],52:[function(a,b){function c(a,b,c){var d=this.utils.toJson(c),e=this.filter(a.name,c),f=this.utils.toLookup(e,a.idAttribute),g=this;angular.forEach(f,function(b,c){g.eject(a.name,c)}),delete b.completedQueries[d]}function d(a,b){if(b=b||{},!this.definitions[a])throw new this.errors.NER(e+a);if(!this.utils.isObject(b))throw new this.errors.IA(e+"params: Must be an object!");var d=this,f=this.store[a],g=this.utils.toJson(b);delete f.completedQueries[g],this.utils.isEmpty(b)&&(f.completedQueries={}),this.$rootScope.$$phase?(c.apply(d,[d.definitions[a],f,b]),f.collectionModified=this.utils.updateTimestamp(f.collectionModified)):this.$rootScope.$apply(function(){c.apply(d,[d.definitions[a],f,b]),f.collectionModified=d.utils.updateTimestamp(f.collectionModified)})}var e="DS.ejectAll(resourceName[, params]): ";b.exports=d},{}],53:[function(a,b){function c(a,b,c){var e=this.errors.IA;if(c=c||{},!this.definitions[a])throw new this.errors.NER(d+a);if(b&&!this.utils.isObject(b))throw new e(d+"params: Must be an object!");if(!this.utils.isObject(c))throw new e(d+"options: Must be an object!");var f=this.definitions[a],g=this.store[a];b=b||{},c.allowSimpleWhere="allowSimpleWhere"in c?!!c.allowSimpleWhere:!0;var h=this.utils.toJson(b);return h in g.completedQueries||!c.loadFromServer||g.pendingQueries[h]||this.findAll(a,b,c),f.defaultFilter.call(this,g.collection,a,b,c)}var d="DS.filter(resourceName[, params][, options]): ";b.exports=c},{}],54:[function(a,b){function c(a,b,c){var e=this.errors.IA;if(c=c||{},!this.definitions[a])throw new this.errors.NER(d+a);if(!this.utils.isString(b)&&!this.utils.isNumber(b))throw new e(d+"id: Must be a string or a number!");if(!this.utils.isObject(c))throw new e(d+"options: Must be an object!");var f=this,g=this.store[a].index.get(b);return!g&&c.loadFromServer&&this.find(a,b).then(null,function(a){return f.$q.reject(a)}),g}var d="DS.get(resourceName, id[, options]): ";b.exports=c},{}],55:[function(a,b){function c(a,b){return!(a.isEmpty(b.added)&&a.isEmpty(b.removed)&&a.isEmpty(b.changed))}function d(a,b){if(!this.definitions[a])throw new this.errors.NER(e+a);if(!this.utils.isString(b)&&!this.utils.isNumber(b))throw new this.errors.IA(e+"id: Must be a string or a number!");return this.get(a,b)?c(this.utils,this.changes(a,b)):!1}var e="DS.hasChanges(resourceName, id): ";b.exports=d},{}],56:[function(a,b){b.exports={bindOne:a("./bindOne"),bindAll:a("./bindAll"),createInstance:a("./createInstance"),defineResource:a("./defineResource"),eject:a("./eject"),ejectAll:a("./ejectAll"),filter:a("./filter"),get:a("./get"),inject:a("./inject"),lastModified:a("./lastModified"),lastSaved:a("./lastSaved"),digest:a("./digest"),changes:a("./changes"),previous:a("./previous"),hasChanges:a("./hasChanges")}},{"./bindAll":45,"./bindOne":46,"./changes":47,"./createInstance":48,"./defineResource":49,"./digest":50,"./eject":51,"./ejectAll":52,"./filter":53,"./get":54,"./hasChanges":55,"./inject":57,"./lastModified":58,"./lastSaved":59,"./previous":60}],57:[function(a,b){function c(a,b,d){function e(c,d,e,f){var g=this,h=f&&f(a.idAttribute)?f(a.idAttribute):g[a.idAttribute];if(b.modified[h]=i.utils.updateTimestamp(b.modified[h]),b.collectionModified=i.utils.updateTimestamp(b.collectionModified),a.computed){var k=i.get(a.name,h);i.utils.forOwn(a.computed,function(a,b){var f=!1;if(angular.forEach(a.deps,function(a){(a in c||a in d||a in e||!(b in k))&&(f=!0)}),f){var g=[];angular.forEach(a.deps,function(a){g.push(k[a])}),k[b]=angular.isFunction(a)?a.apply(k,g):a[a.length-1].apply(k,g)}})}a.idAttribute in e&&j.error("Doh! You just changed the primary key of an object! I don't know how to handle this yet, so your data for the \""+a.name+'" resource is now in an undefined (probably broken) state.')}var h,i=this,j=i.$log;if(i.utils.isArray(d)){h=[];for(var k=0;k<d.length;k++)h.push(c.call(i,a,b,d[k]))}else{if(a.computed&&a.computed[a.idAttribute]){var l=[];angular.forEach(a.computed[a.idAttribute].deps,function(a){l.push(d[a])}),d[a.idAttribute]=a.computed[a.idAttribute].apply(d,l)}if(!(a.idAttribute in d)){var m=new i.errors.R(g+"attrs: Must contain the property specified by `idAttribute`!");throw j.error(m),m}try{a.beforeInject(a.name,d);var n=d[a.idAttribute],o=this.get(a.name,n);o?(i.utils.deepMixIn(o,d),"function"==typeof b.index.touch?b.index.touch(n):b.index.put(n,b.index.get(n)),b.observers[n].deliver()):(o=a.methods||a.useClass?d instanceof a[a.class]?d:new a[a.class]:{},b.previousAttributes[n]={},i.utils.deepMixIn(o,d),i.utils.deepMixIn(b.previousAttributes[n],d),b.collection.push(o),b.observers[n]=new f.ObjectObserver(o),b.observers[n].open(e,o),b.index.put(n,o),e.call(o,{},{},{})),b.saved[n]=i.utils.updateTimestamp(b.saved[n]),a.afterInject(a.name,o),h=o}catch(p){j.error(p),j.error("inject failed!",a.name,d)}}return h}function d(a,b){var c=this;c.utils.forOwn(a.relations,function(a,d){c.utils.forOwn(a,function(a,e){if(c.definitions[e]&&b[a.localField])try{b[a.localField]=c.inject(e,b[a.localField])}catch(f){c.$log.error(g+"Failed to inject "+d+' relation: "'+e+'"!',f)}})})}function e(a,b,e){var f=this.errors.IA;if(e=e||{},!this.definitions[a])throw new this.errors.NER(g+a);if(!this.utils.isObject(b)&&!this.utils.isArray(b))throw new f(g+"attrs: Must be an object or an array!");if(!this.utils.isObject(e))throw new f(g+"options: Must be an object!");var h,i=this.definitions[a],j=this.store[a],k=this;return this.$rootScope.$$phase?h=c.call(k,i,j,b):this.$rootScope.$apply(function(){h=c.call(k,i,j,b)}),i.relations&&d.call(k,i,h),h}var f=a("../../../lib/observe-js/observe-js"),g="DS.inject(resourceName, attrs[, options]): ";b.exports=e},{"../../../lib/observe-js/observe-js":1}],58:[function(a,b){function c(a,b){if(!this.definitions[a])throw new this.errors.NER(d+a);if(b&&!this.utils.isString(b)&&!this.utils.isNumber(b))throw new this.errors.IA(d+"id: Must be a string or a number!");return b?(b in this.store[a].modified||(this.store[a].modified[b]=0),this.store[a].modified[b]):this.store[a].collectionModified}var d="DS.lastModified(resourceName[, id]): ";b.exports=c},{}],59:[function(a,b){function c(a,b){if(!this.definitions[a])throw new this.errors.NER(d+a);if(!this.utils.isString(b)&&!this.utils.isNumber(b))throw new this.errors.IA(d+"id: Must be a string or a number!");return b in this.store[a].saved||(this.store[a].saved[b]=0),this.store[a].saved[b]}var d="DS.lastSaved(resourceName[, id]): ";b.exports=c},{}],60:[function(a,b){function c(a,b){if(!this.definitions[a])throw new this.errors.NER(d+a);if(!this.utils.isString(b)&&!this.utils.isNumber(b))throw new this.errors.IA(d+"id: Must be a string or a number!");return angular.copy(this.store[a].previousAttributes[b])}var d="DS.previous(resourceName, id): ";b.exports=c},{}],61:[function(a,b){function c(a){Error.call(this),"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.type=this.constructor.name,this.message=a||"Illegal Argument!"}function d(a){Error.call(this),"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.type=this.constructor.name,this.message=a||"RuntimeError Error!"}function e(a){Error.call(this),"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.type=this.constructor.name,this.message=(a||"")+" is not a registered resource!"}c.prototype=Object.create(Error.prototype),c.prototype.constructor=c,d.prototype=Object.create(Error.prototype),d.prototype.constructor=d,e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,b.exports=[function(){return{IllegalArgumentError:c,IA:c,RuntimeError:d,R:d,NonexistentResourceError:e,NER:e}}]},{}],62:[function(a){!function(b,c){"use strict";c.module("angular-data.DS",["ng"]).factory("DSUtils",a("./utils")).factory("DSErrors",a("./errors")).provider("DSHttpAdapter",a("./adapters/http")).provider("DSLocalStorageAdapter",a("./adapters/localStorage")).provider("DS",a("./datastore")).config(["$provide",function(a){a.decorator("$q",["$delegate",function(a){return a.promisify=function(a,b){var c=this;return function(){var d=c.defer(),e=Array.prototype.slice.apply(arguments);e.push(function(a,b){a?d.reject(a):d.resolve(b)});try{a.apply(b||this,e)}catch(f){d.reject(f)}return d.promise}},a}])}])}(window,window.angular)},{"./adapters/http":31,"./adapters/localStorage":32,"./datastore":44,"./errors":61,"./utils":63}],63:[function(a,b){b.exports=[function(){return{isBoolean:a("mout/lang/isBoolean"),isString:angular.isString,isArray:angular.isArray,isObject:angular.isObject,isNumber:angular.isNumber,isFunction:angular.isFunction,isEmpty:a("mout/lang/isEmpty"),toJson:angular.toJson,makePath:a("mout/string/makePath"),upperCase:a("mout/string/upperCase"),deepMixIn:a("mout/object/deepMixIn"),forOwn:a("mout/object/forOwn"),pick:a("mout/object/pick"),set:a("mout/object/set"),contains:a("mout/array/contains"),filter:a("mout/array/filter"),toLookup:a("mout/array/toLookup"),slice:a("mout/array/slice"),sort:a("mout/array/sort"),updateTimestamp:function(a){var b="function"==typeof Date.now?Date.now():(new Date).getTime();return a&&a>=b?a+1:b},deepFreeze:function b(a){if("function"==typeof Object.freeze){var c,d;Object.freeze(a);for(d in a)c=a[d],a.hasOwnProperty(d)&&"object"==typeof c&&!Object.isFrozen(c)&&b(c)}},diffObjectFromOldObject:function(a,b){var c={},d={},e={};for(var f in b){var g=a[f];(void 0===g||g!==b[f])&&(f in a?g!==b[f]&&(e[f]=g):d[f]=void 0)}for(var h in a)h in b||(c[h]=a[h]);return{added:c,removed:d,changed:e}}}}]},{"mout/array/contains":2,"mout/array/filter":3,"mout/array/slice":7,"mout/array/sort":8,"mout/array/toLookup":9,"mout/lang/isBoolean":14,"mout/lang/isEmpty":15,"mout/object/deepMixIn":22,"mout/object/forOwn":24,"mout/object/pick":27,"mout/object/set":28,"mout/string/makePath":29,"mout/string/upperCase":30}]},{},[62]); |
{ | ||
"name": "angular-data", | ||
"description": "Data store for Angular.js.", | ||
"version": "0.10.1", | ||
"version": "0.10.2", | ||
"homepage": "http://angular-data.pseudobry.com", | ||
@@ -6,0 +6,0 @@ "repository": { |
@@ -167,4 +167,10 @@ /*jshint evil:true*/ | ||
} | ||
var match = fn.toString().match(/function.*?\(([\s\S]*?)\)/); | ||
var deps = match[1].split(','); | ||
var deps; | ||
if (angular.isFunction(fn)) { | ||
var match = fn.toString().match(/function.*?\(([\s\S]*?)\)/); | ||
deps = match[1].split(','); | ||
DS.$log.warn(errorPrefix + 'Use the computed property array for compatibility with minified code!'); | ||
} else { | ||
deps = fn.slice(0, fn.length - 1); | ||
} | ||
fn.deps = DS.utils.filter(deps, function (dep) { | ||
@@ -171,0 +177,0 @@ return !!dep; |
@@ -31,3 +31,7 @@ var observe = require('../../../lib/observe-js/observe-js'); | ||
// recompute property | ||
item[field] = fn.apply(item, args); | ||
if (angular.isFunction(fn)) { | ||
item[field] = fn.apply(item, args); | ||
} else { | ||
item[field] = fn[fn.length - 1].apply(item, args); | ||
} | ||
} | ||
@@ -34,0 +38,0 @@ }); |
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
406298
9878