From ef8e42bea7086657697e38aa643d1d882faf496d Mon Sep 17 00:00:00 2001 From: Jason Dobry Date: Sat, 30 Aug 2014 11:32:32 -0600 Subject: [PATCH] Stable Version 1.0.0-beta.3. --- CHANGELOG.md | 5 +++++ README.md | 4 ++-- bower.json | 6 +++--- dist/angular-data.js | 8 ++------ dist/angular-data.min.js | 4 ++-- guide/nav.html | 6 +++--- package.json | 2 +- src/datastore/sync_methods/defineResource.js | 4 ---- src/index.js | 2 +- 9 files changed, 19 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ca5bb0..89d8c04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +##### 1.0.0-beta.3 - 30 August 2014 + +###### Backwards compatible bug fixes +- Unfroze resource definitions + ##### 1.0.0-beta.2 - 27 August 2014 ###### Breaking API changes diff --git a/README.md b/README.md index 652769f..f899d3c 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,8 @@ Unlike Backbone and Ember Models, angular-data does not require the use of gette Supporting relations, computed properties, model lifecycle control and a slew of other features, angular-data is the tool for giving your data the respect it deserves. -__Latest Release:__ [1.0.0-beta.2](http://angular-data.pseudobry.com/) -__master:__ [1.0.0-beta.2](http://angular-data-next.pseudobry.com/) +__Latest Release:__ [1.0.0-beta.3](http://angular-data.pseudobry.com/) +__master:__ [1.0.0-beta.3](http://angular-data-next.pseudobry.com/) Angular-data is in a 1.0.0 Beta. The API is rather stable and angular-data is well tested. diff --git a/bower.json b/bower.json index 011da9b..c813a7e 100644 --- a/bower.json +++ b/bower.json @@ -2,7 +2,7 @@ "author": "Jason Dobry", "name": "angular-data", "description": "Data store for Angular.js.", - "version": "1.0.0-beta.2", + "version": "1.0.0-beta.3", "homepage": "http://angular-data.pseudobry.com/", "repository": { "type": "git", @@ -28,9 +28,9 @@ "devDependencies": { "angular": "~1.2.22", "angular-mocks": "~1.2.22", - "angular-cache": "~3.1.0", + "angular-cache": "~3.1.1", "observe-js": "0.3.4", - "angular-data-mocks": "~0.5.5", + "angular-data-mocks": "~0.6.0", "bootstrap": "~3.2.0" } } diff --git a/dist/angular-data.js b/dist/angular-data.js index 8ba219c..8f97e81 100644 --- a/dist/angular-data.js +++ b/dist/angular-data.js @@ -1,7 +1,7 @@ /** * @author Jason Dobry * @file angular-data.js -* @version 1.0.0-beta.2 - Homepage +* @version 1.0.0-beta.3 - Homepage * @copyright (c) 2014 Jason Dobry * @license MIT * @@ -4969,10 +4969,6 @@ function defineResource(definition) { def.beforeDestroy = DS.$q.promisify(def.beforeDestroy); def.afterDestroy = DS.$q.promisify(def.afterDestroy); - if (typeof Object.freeze === 'function') { - Object.freeze(def); - } - return def; } catch (err) { DS.$log.error(err); @@ -6549,7 +6545,7 @@ module.exports = [function () { * @id angular-data * @name angular-data * @description - * __Version:__ 1.0.0-beta.2 + * __Version:__ 1.0.0-beta.3 * * ## Install * diff --git a/dist/angular-data.min.js b/dist/angular-data.min.js index 313d564..94b8600 100644 --- a/dist/angular-data.min.js +++ b/dist/angular-data.min.js @@ -1,11 +1,11 @@ /** * @author Jason Dobry * @file angular-data.min.js -* @version 1.0.0-beta.2 - Homepage +* @version 1.0.0-beta.3 - Homepage * @copyright (c) 2014 Jason Dobry * @license MIT * * @overview Data store for Angular.js. */ !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;gb&&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;acycles&&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;++gc?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-1&&(a=a.replace(/[\xC0-\xC5]/g,"A").replace(/[\xC6]/g,"AE").replace(/[\xC7]/g,"C").replace(/[\xC8-\xCB]/g,"E").replace(/[\xCC-\xCF]/g,"I").replace(/[\xD0]/g,"D").replace(/[\xD1]/g,"N").replace(/[\xD2-\xD6\xD8]/g,"O").replace(/[\xD9-\xDC]/g,"U").replace(/[\xDD]/g,"Y").replace(/[\xDE]/g,"P").replace(/[\xE0-\xE5]/g,"a").replace(/[\xE6]/g,"ae").replace(/[\xE7]/g,"c").replace(/[\xE8-\xEB]/g,"e").replace(/[\xEC-\xEF]/g,"i").replace(/[\xF1]/g,"n").replace(/[\xF2-\xF6\xF8]/g,"o").replace(/[\xF9-\xFC]/g,"u").replace(/[\xFE]/g,"p").replace(/[\xFD\xFF]/g,"y")),a}var d=a("../lang/toString");b.exports=c},{"../lang/toString":20}],35:[function(a,b){function c(a){return a=d(a),a.toUpperCase()}var d=a("../lang/toString");b.exports=c},{"../lang/toString":20}],36:[function(a,b){function c(){var a=this.defaults={queryTransform:function(a,b){return b},$httpConfig:{}};this.$get=["$http","$log","DSUtils",function(b,c,d){return{defaults:a,HTTP:function(e){var f=(new Date).getTime();return e=d.deepMixIn(e,a.$httpConfig),b(e).then(function(a){return c.debug(a.config.method+" request:"+a.config.url+" Time taken: "+((new Date).getTime()-f)+"ms",arguments),a})},GET:function(a,b){return b=b||{},this.HTTP(d.deepMixIn(b,{url:a,method:"GET"}))},POST:function(a,b,c){return c=c||{},this.HTTP(d.deepMixIn(c,{url:a,data:b,method:"POST"}))},PUT:function(a,b,c){return c=c||{},this.HTTP(d.deepMixIn(c,{url:a,data:b||{},method:"PUT"}))},DEL:function(a,b){return b=b||{},this.HTTP(d.deepMixIn(b,{url:a,method:"DELETE"}))},find:function(a,b,c){return c=c||{},this.GET(d.makePath(c.baseUrl||a.baseUrl,a.getEndpoint(b,c),b),c)},findAll:function(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.getEndpoint(null,e)),e)},create:function(a,b,c){return c=c||{},this.POST(d.makePath(c.baseUrl||a.baseUrl,a.getEndpoint(b,c)),b,c)},update:function(a,b,c,e){return e=e||{},this.PUT(d.makePath(e.baseUrl||a.baseUrl,a.getEndpoint(b,e),b),c,e)},updateAll:function(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.getEndpoint(null,f)),c,f)},destroy:function(a,b,c){return c=c||{},this.DEL(d.makePath(c.baseUrl||a.baseUrl,a.getEndpoint(b,c),b),c)},destroyAll:function(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.getEndpoint(null,e)),e)}}}]}b.exports=c},{}],37:[function(a,b){function c(){this.$get=["$q","DSUtils","DSErrors",function(a,b,c){return{GET:function(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},PUT:function(a,c){var d=this;return d.GET(a).then(function(e){return e&&b.deepMixIn(e,c),localStorage.setItem(a,angular.toJson(e||c)),d.GET(a)})},DEL:function(b){var c=a.defer();try{localStorage.removeItem(b),c.resolve()}catch(d){c.reject(d)}return c.promise},find:function(a,c,d){return d=d||{},this.GET(b.makePath(d.baseUrl||a.baseUrl,a.endpoint,c))},findAll:function(){throw new Error("DSLocalStorageAdapter.findAll is not supported!")},create:function(a,d,e){if(!(a.idAttribute in d))throw new c.IA("DSLocalStorageAdapter.create: You must provide a primary key in the attrs object!");return e=e||{},this.PUT(b.makePath(e.baseUrl||a.baseUrl,a.getEndpoint(d,e),d[a.idAttribute]),d)},update:function(a,c,d,e){return e=e||{},this.PUT(b.makePath(e.baseUrl||a.baseUrl,a.getEndpoint(c,e),c),d)},updateAll:function(){throw new Error("DSLocalStorageAdapter.updateAll is not supported!")},destroy:function(a,c,d){return d=d||{},this.DEL(b.makePath(d.baseUrl||a.baseUrl,a.getEndpoint(c,d),c))},destroyAll:function(){throw new Error("Not supported!")}}}]}b.exports=c},{}],38:[function(a,b){function c(a){return"DS.create("+a+", attrs[, options]): "}function d(a,b,d){var e=this,f=e.$q.defer();try{var g=e.definitions[a];if(d=d||{},!g)throw new e.errors.NER(c(a)+a);if(!e.utils.isObject(b))throw new e.errors.IA(c(a)+"attrs: Must be an object!");return"cacheResponse"in d||(d.cacheResponse=!0),"upsert"in d||(d.upsert=!0),f.resolve(b),d.upsert&&b[g.idAttribute]?e.update(a,b[g.idAttribute],b,d):f.promise.then(function(b){var c=d.beforeValidate?e.$q.promisify(d.beforeValidate):g.beforeValidate;return c.call(b,a,b)}).then(function(b){var c=d.validate?e.$q.promisify(d.validate):g.validate;return c.call(b,a,b)}).then(function(b){var c=d.afterValidate?e.$q.promisify(d.afterValidate):g.afterValidate;return c.call(b,a,b)}).then(function(b){var c=d.beforeCreate?e.$q.promisify(d.beforeCreate):g.beforeCreate;return c.call(b,a,b)}).then(function(b){return e.adapters[d.adapter||g.defaultAdapter].create(g,g.serialize(a,b),d)}).then(function(b){var c=d.afterCreate?e.$q.promisify(d.afterCreate):g.afterCreate,f=g.deserialize(a,b);return c.call(f,a,f)}).then(function(b){if(d.cacheResponse){var c=e.store[a],f=e.inject(g.name,b,d),h=f[g.idAttribute];return c.completedQueries[h]=(new Date).getTime(),c.previousAttributes[h]=e.utils.deepMixIn({},f),c.saved[h]=e.utils.updateTimestamp(c.saved[h]),e.get(g.name,h)}return b})}catch(h){return f.reject(h),f.promise}}b.exports=d},{}],39:[function(a,b){function c(a,b){return"DS.destroy("+a+", "+b+"[, options]): "}function d(a,b,d){var e=this,f=e.$q.defer();try{var g=e.definitions[a];if(d=d||{},!g)throw new e.errors.NER(c(a,b)+a);if(!e.utils.isString(b)&&!e.utils.isNumber(b))throw new e.errors.IA(c(a,b)+"id: Must be a string or a number!");var h=e.get(a,b);if(!h)throw new e.errors.R(c(a,b)+'id: "'+b+'" not found!');return f.resolve(h),f.promise.then(function(b){var c=d.beforeDestroy?e.$q.promisify(d.beforeDestroy):g.beforeDestroy;return c.call(b,a,b)}).then(function(){return e.adapters[d.adapter||g.defaultAdapter].destroy(g,b,d)}).then(function(){var b=d.afterDestroy?e.$q.promisify(d.afterDestroy):g.afterDestroy;return b.call(h,a,h)}).then(function(){return e.eject(a,b),b})}catch(i){return f.reject(i),f.promise}}b.exports=d},{}],40:[function(a,b){function c(a){return"DS.destroyAll("+a+", params[, options]): "}function d(a,b,d){var e=this,f=e.$q.defer();try{var g=e.errors.IA,h=e.definitions[a];if(d=d||{},!h)throw new e.errors.NER(c(a)+a);if(!e.utils.isObject(b))throw new g(c(a)+"params: Must be an object!");if(!e.utils.isObject(d))throw new g(c(a)+"options: Must be an object!");return f.resolve(),f.promise.then(function(){return e.adapters[d.adapter||h.defaultAdapter].destroyAll(h,b,d)}).then(function(){return e.ejectAll(a,b)})}catch(i){return f.reject(i),f.promise}}b.exports=d},{}],41:[function(a,b){function c(a,b){return"DS.find("+a+", "+b+"[, options]): "}function d(a,b,d){var e=this,f=e.$q.defer(),g=f.promise;try{var h=e.errors.IA,i=e.definitions[a];if(d=d||{},!i)throw new e.errors.NER(c(a,b)+a);if(!e.utils.isString(b)&&!e.utils.isNumber(b))throw new h(c(a,b)+"id: Must be a string or a number!");if(!e.utils.isObject(d))throw new h(c(a,b)+"options: Must be an object!");"cacheResponse"in d||(d.cacheResponse=!0);var j=e.store[a];if((d.bypassCache||!d.cacheResponse)&&delete j.completedQueries[b],!(b in j.completedQueries))return b in j.pendingQueries||(g=j.pendingQueries[b]=e.adapters[d.adapter||i.defaultAdapter].find(i,b,d).then(function(c){var f=i.deserialize(a,c);return d.cacheResponse?(delete j.pendingQueries[b],j.completedQueries[b]=(new Date).getTime(),e.inject(a,f,d)):f},function(a){return delete j.pendingQueries[b],e.$q.reject(a)})),j.pendingQueries[b];f.resolve(e.get(a,b))}catch(k){f.reject(k)}return g}b.exports=d},{}],42:[function(a,b){function c(a){return"DS.findAll("+a+", params[, options]): "}function d(a,b,d,e){var f=this,g=f.store[b],h=f.definitions[b].idAttribute,i=(new Date).getTime();a=a||[],delete g.pendingQueries[d],g.completedQueries[d]=i,g.collectionModified=f.utils.updateTimestamp(g.collectionModified);var j=f.inject(b,a,e);return f.utils.isArray(j)?angular.forEach(j,function(a){a&&a[h]&&(g.completedQueries[a[h]]=i)}):(f.$log.warn(c(b)+"response is expected to be an array!"),g.completedQueries[j[h]]=i),j}function e(a,b,c){var e=this,f=e.definitions[a],g=e.store[a],h=e.utils.toJson(b);return(c.bypassCache||!c.cacheResponse)&&delete g.completedQueries[h],h in g.completedQueries?e.filter(a,b,c):(h in g.pendingQueries||(g.pendingQueries[h]=e.adapters[c.adapter||f.defaultAdapter].findAll(f,b,c).then(function(b){var g=f.deserialize(a,b);if(!c.cacheResponse)return g;try{return d.call(e,g,a,h,c)}catch(i){return e.$q.reject(i)}},function(a){return delete g.pendingQueries[h],e.$q.reject(a)})),g.pendingQueries[h])}function f(a,b,d){var f=this,g=f.$q.defer();try{var h=f.errors.IA;if(d=d||{},b=b||{},!f.definitions[a])throw new f.errors.NER(c(a)+a);if(!f.utils.isObject(b))throw new h(c(a)+"params: Must be an object!");if(!f.utils.isObject(d))throw new h(c(a)+"options: Must be an object!");return"cacheResponse"in d||(d.cacheResponse=!0),g.resolve(),g.promise.then(function(){return e.call(f,a,b,d)})}catch(i){return g.reject(i),g.promise}}b.exports=f},{}],43:[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":38,"./destroy":39,"./destroyAll":40,"./find":41,"./findAll":42,"./loadRelations":44,"./refresh":45,"./save":46,"./update":47,"./updateAll":48}],44:[function(a,b){function c(a){return"DS.loadRelations("+a+", instance(Id), relations[, options]): "}function d(a,b,d,e){var f=this,g=f.$q.defer();try{var h=f.errors.IA,i=f.definitions[a];if(e=e||{},(angular.isString(b)||angular.isNumber(b))&&(b=f.get(a,b)),angular.isString(d)&&(d=[d]),!i)throw new f.errors.NER(c(a)+a);if(!f.utils.isObject(b))throw new h(c(a)+"instance(Id): Must be a string, number or object!");if(!f.utils.isArray(d))throw new h(c(a)+"relations: Must be a string or an array!");if(!f.utils.isObject(e))throw new h(c(a)+"options: Must be an object!");"findBelongsTo"in e||(e.findBelongsTo=!0),"findHasMany"in e||(e.findHasMany=!0);var j=[],k=[];return f.utils.forEach(i.relationList,function(a){var c=a.relation;if(f.utils.contains(d,c)){var g,h={};h[a.foreignKey]=b[i.idAttribute],"hasMany"===a.type?g=f.findAll(c,h,e):"hasOne"===a.type?a.localKey&&b[a.localKey]?g=f.find(c,b[a.localKey],e):a.foreignKey&&(g=f.findAll(c,h,e)):g=f.find(c,b[a.localKey],e),g&&(j.push(g),k.push(a.localField))}}),g.resolve(),g.promise.then(function(){return f.$q.all(j)}).then(function(a){return angular.forEach(k,function(c,d){b[c]=a[d]}),b})}catch(l){return g.reject(l),g.promise}}b.exports=d},{}],45:[function(a,b){function c(a,b){return"DS.refresh("+a+", "+b+"[, options]): "}function d(a,b,d){var e=this,f=e.errors.IA;if(d=d||{},e.definitions[a]){if(e.utils.isString(b)||e.utils.isNumber(b)){if(e.utils.isObject(d)){if(d.bypassCache=!0,e.get(a,b))return e.find(a,b,d);var g=e.$q.defer();return g.resolve(),g.promise}throw new f(c(a,b)+"options: Must be an object!")}throw new f(c(a,b)+"id: Must be a string or a number!")}throw new e.errors.NER(c(a,b)+a)}b.exports=d},{}],46:[function(a,b){function c(a,b){return"DS.save("+a+", "+b+"[, options]): "}function d(a,b,d){var e=this,f=e.$q.defer();try{var g=e.errors.IA,h=e.definitions[a];if(d=d||{},!h)throw new e.errors.NER(c(a,b)+a);if(!e.utils.isString(b)&&!e.utils.isNumber(b))throw new g(c(a,b)+"id: Must be a string or a number!");if(!e.utils.isObject(d))throw new g(c(a,b)+"options: Must be an object!");var i=e.get(a,b);if(!i)throw new e.errors.R(c(a,b)+'id: "'+b+'" not found!');return"cacheResponse"in d||(d.cacheResponse=!0),f.resolve(i),f.promise.then(function(b){var c=d.beforeValidate?e.$q.promisify(d.beforeValidate):h.beforeValidate;return c.call(b,a,b)}).then(function(b){var c=d.validate?e.$q.promisify(d.validate):h.validate;return c.call(b,a,b)}).then(function(b){var c=d.afterValidate?e.$q.promisify(d.afterValidate):h.afterValidate;return c.call(b,a,b)}).then(function(b){var c=d.beforeUpdate?e.$q.promisify(d.beforeUpdate):h.beforeUpdate;return c.call(b,a,b)}).then(function(c){if(d.changesOnly){var f=e.store[a];f.observers[b].deliver();var g=[],i=e.changes(a,b);for(var j in i.added)g.push(j);for(j in i.changed)g.push(j);if(i=e.utils.pick(c,g),e.utils.isEmpty(i))return c;c=i}return e.adapters[d.adapter||h.defaultAdapter].update(h,b,h.serialize(a,c),d)}).then(function(b){var c=d.afterUpdate?e.$q.promisify(d.afterUpdate):h.afterUpdate,f=h.deserialize(a,b);return c.call(f,a,f)}).then(function(c){if(d.cacheResponse){var f=e.store[a],g=e.inject(h.name,c,d);return f.previousAttributes[b]=e.utils.deepMixIn({},g),f.saved[b]=e.utils.updateTimestamp(f.saved[b]),f.observers[b].discardChanges(),e.get(a,b)}return c})}catch(j){return f.reject(j),f.promise}}b.exports=d},{}],47:[function(a,b){function c(a,b){return"DS.update("+a+", "+b+", attrs[, options]): "}function d(a,b,d,e){var f=this,g=f.$q.defer();try{var h=f.errors.IA,i=f.definitions[a];if(e=e||{},!i)throw new f.errors.NER(c(a,b)+a);if(!f.utils.isString(b)&&!f.utils.isNumber(b))throw new h(c(a,b)+"id: Must be a string or a number!");if(!f.utils.isObject(d))throw new h(c(a,b)+"attrs: Must be an object!");if(!f.utils.isObject(e))throw new h(c(a,b)+"options: Must be an object!");return"cacheResponse"in e||(e.cacheResponse=!0),g.resolve(d),g.promise.then(function(b){var c=e.beforeValidate?f.$q.promisify(e.beforeValidate):i.beforeValidate;return c.call(b,a,b)}).then(function(b){var c=e.validate?f.$q.promisify(e.validate):i.validate;return c.call(b,a,b)}).then(function(b){var c=e.afterValidate?f.$q.promisify(e.afterValidate):i.afterValidate;return c.call(b,a,b)}).then(function(b){var c=e.beforeUpdate?f.$q.promisify(e.beforeUpdate):i.beforeUpdate;return c.call(b,a,b)}).then(function(c){return f.adapters[e.adapter||i.defaultAdapter].update(i,b,i.serialize(a,c),e)}).then(function(b){var c=e.afterUpdate?f.$q.promisify(e.afterUpdate):i.afterUpdate,d=i.deserialize(a,b);return c.call(d,a,d)}).then(function(b){if(e.cacheResponse){var c=f.store[a],d=f.inject(i.name,b,e),g=d[i.idAttribute];return c.previousAttributes[g]=f.utils.deepMixIn({},d),c.saved[g]=f.utils.updateTimestamp(c.saved[g]),c.observers[g].discardChanges(),f.get(i.name,g)}return b})}catch(j){return g.reject(j),g.promise}}b.exports=d},{}],48:[function(a,b){function c(a){return"DS.updateAll("+a+", attrs, params[, options]): "}function d(a,b,d,e){var f=this,g=f.$q.defer();try{var h=f.errors.IA,i=f.definitions[a];if(e=e||{},!i)throw new f.errors.NER(c(a)+a);if(!f.utils.isObject(b))throw new h(c(a)+"attrs: Must be an object!");if(!f.utils.isObject(d))throw new h(c(a)+"params: Must be an object!");if(!f.utils.isObject(e))throw new h(c(a)+"options: Must be an object!");return"cacheResponse"in e||(e.cacheResponse=!0),g.resolve(b),g.promise.then(function(b){var c=e.beforeValidate?f.$q.promisify(e.beforeValidate):i.beforeValidate;return c.call(b,a,b)}).then(function(b){var c=e.validate?f.$q.promisify(e.validate):i.validate;return c.call(b,a,b)}).then(function(b){var c=e.afterValidate?f.$q.promisify(e.afterValidate):i.afterValidate;return c.call(b,a,b)}).then(function(b){var c=e.beforeUpdate?f.$q.promisify(e.beforeUpdate):i.beforeUpdate;return c.call(b,a,b)}).then(function(b){return f.adapters[e.adapter||i.defaultAdapter].updateAll(i,i.serialize(a,b),d,e)}).then(function(b){var c=e.afterUpdate?f.$q.promisify(e.afterUpdate):i.afterUpdate,d=i.deserialize(a,b);return c.call(d,a,d)}).then(function(a){return e.cacheResponse?f.inject(i.name,a,e):a})}catch(j){return g.reject(j),g.promise}}b.exports=d},{}],49:[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={notify:function(a,b){var d=Array.prototype.slice.call(arguments,2);d.unshift(a.name),d.unshift("DS."+b),"broadcast"===a.events?c.$broadcast.apply(c,d):"emit"===a.events&&c.$emit.apply(c,d)},$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),("function"!=typeof Object.observe||"function"!=typeof Array.observe)&&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]"===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]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=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":31,"mout/string/pascalCase":32,"mout/string/upperCase":35}]},{},[71]); \ No newline at end of file +})});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=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":31,"mout/string/pascalCase":32,"mout/string/upperCase":35}]},{},[71]); \ No newline at end of file diff --git a/guide/nav.html b/guide/nav.html index 84a6b5d..63762d3 100644 --- a/guide/nav.html +++ b/guide/nav.html @@ -82,7 +82,7 @@ API