From cc066d9c7a038da3ec0da29e922f175dc920ea39 Mon Sep 17 00:00:00 2001 From: guylabs Date: Mon, 20 Apr 2015 07:12:02 +0200 Subject: [PATCH] Update to version 0.4.1 --- bower.json | 2 +- dist/angular-spring-data-rest.js | 8 +- dist/angular-spring-data-rest.min.js | 162 +----------------- package.json | 2 +- ...ar-spring-data-rest-provider.fetch.spec.js | 1 - 5 files changed, 8 insertions(+), 167 deletions(-) diff --git a/bower.json b/bower.json index 1ee5076..dc5d96f 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-spring-data-rest", - "version": "0.4.0", + "version": "0.4.1", "description": "An AngularJS module to ease the work with a Spring Data REST backend.", "main": "./dist/angular-spring-data-rest.js", "license": "MIT", diff --git a/dist/angular-spring-data-rest.js b/dist/angular-spring-data-rest.js index c39dc45..4bc30f5 100644 --- a/dist/angular-spring-data-rest.js +++ b/dist/angular-spring-data-rest.js @@ -1,10 +1,10 @@ -(function () { +(function() { 'use strict'; /** * @module spring-data-rest - * @version 0.4.0 + * @version 0.4.1 * * An AngularJS module to ease the work with a Spring Data REST backend. */ @@ -12,7 +12,7 @@ angular.module("spring-data-rest", ["ngResource"]); /** * @module spring-data-rest - * @version 0.4.0 + * @version 0.4.1 * * Provider for the SpringDataRestAdapter which is the core of this module. */ @@ -335,7 +335,7 @@ angular.module("spring-data-rest").provider("SpringDataRestAdapter", function () }); /** * @module spring-data-rest - * @version 0.4.0 + * @version 0.4.1 * * Provider for the interceptor which wraps the SpringDataRestAdapter around the response object. */ diff --git a/dist/angular-spring-data-rest.min.js b/dist/angular-spring-data-rest.min.js index 0a3740c..30aaa42 100644 --- a/dist/angular-spring-data-rest.min.js +++ b/dist/angular-spring-data-rest.min.js @@ -1,164 +1,6 @@ /*! - * angular-spring-data-rest 0.4.0 + * angular-spring-data-rest 0.4.1 * Copyright 2015 Guy Brand (@guy_labs) * https://github.com/guylabs/angular-spring-data-rest */ -!function () { - "use strict"; - function a(b) { - return angular.forEach(arguments, function (c) { - c !== b && angular.forEach(c, function (c, d) { - b[d] && b[d].constructor && b[d].constructor === Object ? a(b[d], c) : b[d] = c - }) - }), angular.copy(b) - } - - function b(a, b, c, d) { - var e = a[b]; - if (e) { - var f = {}; - if (f[c] = {}, d === !0)angular.forEach(Object.keys(e), function (a) { - f[c][a] = e[a] - }); else { - var g = Object.keys(e)[0]; - f[c] = e[g] - } - a = angular.extend(a, f), delete a[b] - } - return a - } - - function c(a, b) { - return b && (a = e(a)), a - } - - function d(a, b, c) { - if (void 0 == a || !a)throw new Error("The provided resource name '" + b + "' has no valid URL in the '" + c + "' property."); - return a - } - - function e(a) { - return a.replace(/{.*}/g, "") - } - - function f(a) { - var b = {}, c = /{\?(.*)}/g, d = c.exec(a)[1].split(","); - return angular.forEach(d, function (a) { - b[a] = "" - }), b - } - - angular.module("spring-data-rest", ["ngResource"]), angular.module("spring-data-rest").provider("SpringDataRestAdapter", function () { - var e = { - linksKey: "_links", - linksHrefKey: "href", - linksSelfLinkName: "self", - embeddedKey: "_embedded", - embeddedNewKey: "_embeddedItems", - embeddedNamedResources: !1, - resourcesKey: "_resources", - resourcesFunction: void 0, - fetchFunction: void 0, - fetchAllKey: "_allLinks" - }; - return { - config: function (b) { - if ("undefined" != typeof b) { - if (!angular.isObject(b))throw new Error("The given configuration '" + b + "' is not an object."); - if (void 0 != b.resourcesFunction && "function" != typeof b.resourcesFunction)throw new Error("The given resource function '" + b.resourcesFunction + "' is not of type function."); - if (void 0 != b.fetchFunction && "function" != typeof b.fetchFunction)throw new Error("The given fetch function '" + b.fetchFunction + "' is not of type function."); - e = a(e, b) - } - return e - }, $get: ["$injector", function (a) { - function g(b, c, d, f) { - return void 0 == e.resourcesFunction ? a.get("$resource")(b, c, d, f) : e.resourcesFunction(b, c, d, f) - } - - function h(b, c, d, f, g) { - if (void 0 == e.fetchFunction) { - var h = []; - return h.push(a.get("$http").get(b).then(function (a) { - return g ? i(a.data, f, !0).then(function (a) { - d[c] = a - }) : i(a.data).then(function (a) { - d[c] = a - }) - }, function (b) { - return 404 != b.status ? a.get("$q").reject(b) : void 0 - })), a.get("$q").all(h) - } - return e.fetchFunction(b, c, d, f, g) - } - - var i = function j(i, k, l) { - function m(a, b) { - var f = d(a[e.linksKey][b][e.linksHrefKey], b, e.linksHrefKey); - return c(f, a[e.linksKey][b].templated) - } - - return a.get("$q").when(i).then(function (c) { - var d = function (a, b, d, h) { - var i = this[e.linksKey], j = b; - if (angular.isObject(a)) { - if (!a.name)throw new Error("The provided resource object must contain a name property."); - var k = a.parameters; - return b && angular.isObject(b) ? j = k && angular.isObject(k) ? angular.extend(angular.copy(b), angular.copy(k)) : angular.copy(b) : k && angular.isObject(k) && (j = angular.copy(k)), angular.forEach(j, function (a, b) { - "" === a && delete j[b] - }), g(m(c, a.name), j, d, h) - } - if (a in i)return g(m(c, a), j, d, h); - var l = []; - return angular.forEach(i, function (a, b) { - if (a.templated) { - var c = f(a[e.linksHrefKey]); - l.push({name: b, parameters: c}) - } else l.push({name: b}) - }), l - }; - if (c && c.data && (c = c.data), !angular.isObject(c) || c instanceof Array)return a.get("$q").reject("Given data '" + c + "' is not of type object."); - if (k && !(k instanceof Array || "string" == typeof k))return a.get("$q").reject("Given fetch links '" + k + "' is not of type array or string."); - var i = void 0, n = []; - if (e.linksKey in c) { - var o = {}; - o[e.resourcesKey] = d, i = angular.extend(angular.copy(c), o), void 0 != k && angular.forEach(c[e.linksKey], function (a, b) { - b != e.linksSelfLinkName && (k == e.fetchAllKey || "string" == typeof k && b == k || k instanceof Array && k.indexOf(b) >= 0) && n.push(h(m(c, b), b, i, k, l)) - }) - } - return e.embeddedKey in c && (i || (i = angular.copy(c)), i = b(i, e.embeddedKey, e.embeddedNewKey, e.embeddedNamedResources), angular.forEach(i[e.embeddedNewKey], function (a, b) { - if (a instanceof Array && a.length > 0) { - var c, d = []; - angular.forEach(a, function (a, b) { - c = j({data: a}, k, l).then(function (a) { - d[b] = a - }), n.push(c) - }), c && c.then(function () { - i[e.embeddedNewKey][b] = d - }) - } else n.push(j({data: a}, k, l).then(function (a) { - i[e.embeddedNewKey][b] = a - })) - })), a.get("$q").all(n).then(function () { - return i ? i : c - }) - }) - }; - return {process: i} - }] - } - }), angular.module("spring-data-rest").provider("SpringDataRestInterceptor", ["$httpProvider", "SpringDataRestAdapterProvider", function (a) { - return { - apply: function () { - a.interceptors.push("SpringDataRestInterceptor") - }, $get: ["SpringDataRestAdapter", "$q", function (a) { - return { - response: function (b) { - return a.process(b.data).then(function (a) { - return b.data = a, b - }) - } - } - }] - } - }]) -}(); \ No newline at end of file +!function(){"use strict";function a(b){return angular.forEach(arguments,function(c){c!==b&&angular.forEach(c,function(c,d){b[d]&&b[d].constructor&&b[d].constructor===Object?a(b[d],c):b[d]=c})}),angular.copy(b)}function b(a,b,c,d){var e=a[b];if(e){var f={};if(f[c]={},d===!0)angular.forEach(Object.keys(e),function(a){f[c][a]=e[a]});else{var g=Object.keys(e)[0];f[c]=e[g]}a=angular.extend(a,f),delete a[b]}return a}function c(a,b){return b&&(a=e(a)),a}function d(a,b,c){if(void 0==a||!a)throw new Error("The provided resource name '"+b+"' has no valid URL in the '"+c+"' property.");return a}function e(a){return a.replace(/{.*}/g,"")}function f(a){var b={},c=/{\?(.*)}/g,d=c.exec(a)[1].split(",");return angular.forEach(d,function(a){b[a]=""}),b}angular.module("spring-data-rest",["ngResource"]),angular.module("spring-data-rest").provider("SpringDataRestAdapter",function(){var e={linksKey:"_links",linksHrefKey:"href",linksSelfLinkName:"self",embeddedKey:"_embedded",embeddedNewKey:"_embeddedItems",embeddedNamedResources:!1,resourcesKey:"_resources",resourcesFunction:void 0,fetchFunction:void 0,fetchAllKey:"_allLinks"};return{config:function(b){if("undefined"!=typeof b){if(!angular.isObject(b))throw new Error("The given configuration '"+b+"' is not an object.");if(void 0!=b.resourcesFunction&&"function"!=typeof b.resourcesFunction)throw new Error("The given resource function '"+b.resourcesFunction+"' is not of type function.");if(void 0!=b.fetchFunction&&"function"!=typeof b.fetchFunction)throw new Error("The given fetch function '"+b.fetchFunction+"' is not of type function.");e=a(e,b)}return e},$get:["$injector",function(a){function g(b,c,d,f){return void 0==e.resourcesFunction?a.get("$resource")(b,c,d,f):e.resourcesFunction(b,c,d,f)}function h(b,c,d,f,g){if(void 0==e.fetchFunction){var h=[];return h.push(a.get("$http").get(b).then(function(a){return g?i(a.data,f,!0).then(function(a){d[c]=a}):i(a.data).then(function(a){d[c]=a})},function(b){return 404!=b.status?a.get("$q").reject(b):void 0})),a.get("$q").all(h)}return e.fetchFunction(b,c,d,f,g)}var i=function j(i,k,l){function m(a,b){var f=d(a[e.linksKey][b][e.linksHrefKey],b,e.linksHrefKey);return c(f,a[e.linksKey][b].templated)}return a.get("$q").when(i).then(function(c){var d=function(a,b,d,h){var i=this[e.linksKey],j=b;if(angular.isObject(a)){if(!a.name)throw new Error("The provided resource object must contain a name property.");var k=a.parameters;return b&&angular.isObject(b)?j=k&&angular.isObject(k)?angular.extend(angular.copy(b),angular.copy(k)):angular.copy(b):k&&angular.isObject(k)&&(j=angular.copy(k)),angular.forEach(j,function(a,b){""===a&&delete j[b]}),g(m(c,a.name),j,d,h)}if(a in i)return g(m(c,a),j,d,h);var l=[];return angular.forEach(i,function(a,b){if(a.templated){var c=f(a[e.linksHrefKey]);l.push({name:b,parameters:c})}else l.push({name:b})}),l};if(c&&c.data&&(c=c.data),!angular.isObject(c)||c instanceof Array)return a.get("$q").reject("Given data '"+c+"' is not of type object.");if(k&&!(k instanceof Array||"string"==typeof k))return a.get("$q").reject("Given fetch links '"+k+"' is not of type array or string.");var i=void 0,n=[];if(e.linksKey in c){var o={};o[e.resourcesKey]=d,i=angular.extend(angular.copy(c),o),void 0!=k&&angular.forEach(c[e.linksKey],function(a,b){b!=e.linksSelfLinkName&&(k==e.fetchAllKey||"string"==typeof k&&b==k||k instanceof Array&&k.indexOf(b)>=0)&&n.push(h(m(c,b),b,i,k,l))})}return e.embeddedKey in c&&(i||(i=angular.copy(c)),i=b(i,e.embeddedKey,e.embeddedNewKey,e.embeddedNamedResources),angular.forEach(i[e.embeddedNewKey],function(a,b){if(a instanceof Array&&a.length>0){var c,d=[];angular.forEach(a,function(a,b){c=j({data:a},k,l).then(function(a){d[b]=a}),n.push(c)}),c&&c.then(function(){i[e.embeddedNewKey][b]=d})}else n.push(j({data:a},k,l).then(function(a){i[e.embeddedNewKey][b]=a}))})),a.get("$q").all(n).then(function(){return i?i:c})})};return{process:i}}]}}),angular.module("spring-data-rest").provider("SpringDataRestInterceptor",["$httpProvider","SpringDataRestAdapterProvider",function(a){return{apply:function(){a.interceptors.push("SpringDataRestInterceptor")},$get:["SpringDataRestAdapter","$q",function(a){return{response:function(b){return a.process(b.data).then(function(a){return b.data=a,b})}}}]}}])}(); \ No newline at end of file diff --git a/package.json b/package.json index 881bfb0..91b390b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-spring-data-rest", - "version": "0.4.0", + "version": "0.4.1", "description": "An AngularJS module to ease the work with a Spring Data REST backend.", "keywords": [ "AngularJS", diff --git a/test/angular-spring-data-rest-provider.fetch.spec.js b/test/angular-spring-data-rest-provider.fetch.spec.js index a53520e..9cbbcd9 100644 --- a/test/angular-spring-data-rest-provider.fetch.spec.js +++ b/test/angular-spring-data-rest-provider.fetch.spec.js @@ -243,7 +243,6 @@ describe("the fetch function", function () { this.httpBackend.verifyNoOutstandingExpectation(); }); - it("must process the fetched responses as all the other responses", function () { var embeddedNewKey = this.config.embeddedNewKey;