11/*!
2- * angular-spring-data-rest 0.3.0
2+ * angular-spring-data-rest 0.3.1
33 * Copyright 2014 Guy Brûlé (@guy_labs)
44 * https://github.com/guylabs/angular-spring-data-rest
55 */
3838 function f ( a ) {
3939 var b = { } , c = / { \? ( .* ) } / g, d = c . exec ( a ) [ 1 ] . split ( "," ) ;
4040 return angular . forEach ( d , function ( a ) {
41- b [ a ] = void 0
41+ b [ a ] = ""
4242 } ) , b
4343 }
4444
4545 angular . module ( "spring-data-rest" , [ "ngResource" ] ) , angular . module ( "spring-data-rest" ) . provider ( "SpringDataRestAdapter" , function ( ) {
46- var e = { linksKey : "_links" , linksHrefKey : "href" , linksSelfLinkName : "self" , embeddedKey : "_embedded" , embeddedNewKey : "_embeddedItems" , resourcesKey : "_resources" , resourcesFunction : void 0 , fetchFunction : void 0 , fetchAllKey : "_allLinks" } ;
47- return { config : function ( b ) {
48- if ( "undefined" != typeof b ) {
49- if ( ! angular . isObject ( b ) ) throw new Error ( "The given configuration '" + b + "' is not an object." ) ;
50- if ( void 0 != b . resourcesFunction && "function" != typeof b . resourcesFunction ) throw new Error ( "The given resource function '" + b . resourcesFunction + "' is not of type function." ) ;
51- if ( void 0 != b . fetchFunction && "function" != typeof b . fetchFunction ) throw new Error ( "The given fetch function '" + b . fetchFunction + "' is not of type function." ) ;
52- e = a ( e , b )
53- }
54- return e
55- } , $get : [ "$injector" , function ( a ) {
56- function g ( b , c , d , f ) {
57- return void 0 == e . resourcesFunction ? a . get ( "$resource" ) ( b , c , d , f ) : e . resourcesFunction ( b , c , d , f )
58- }
59-
60- function h ( b , c , d , f , g ) {
61- void 0 == e . fetchFunction ? a . get ( "$http" ) . get ( b ) . success ( function ( a ) {
62- d [ c ] = g ? i ( a , f , ! 0 ) : a
63- } ) . error ( function ( a , c ) {
64- throw new Error ( "There was an error (" + c + ") retrieving the data from '" + b + "'" )
65- } ) : e . fetchFunction ( b , c , d , f , g )
66- }
46+ var e = {
47+ linksKey : "_links" ,
48+ linksHrefKey : "href" ,
49+ linksSelfLinkName : "self" ,
50+ embeddedKey : "_embedded" ,
51+ embeddedNewKey : "_embeddedItems" ,
52+ resourcesKey : "_resources" ,
53+ resourcesFunction : void 0 ,
54+ fetchFunction : void 0 ,
55+ fetchAllKey : "_allLinks"
56+ } ;
57+ return {
58+ config : function ( b ) {
59+ if ( "undefined" != typeof b ) {
60+ if ( ! angular . isObject ( b ) ) throw new Error ( "The given configuration '" + b + "' is not an object." ) ;
61+ if ( void 0 != b . resourcesFunction && "function" != typeof b . resourcesFunction ) throw new Error ( "The given resource function '" + b . resourcesFunction + "' is not of type function." ) ;
62+ if ( void 0 != b . fetchFunction && "function" != typeof b . fetchFunction ) throw new Error ( "The given fetch function '" + b . fetchFunction + "' is not of type function." ) ;
63+ e = a ( e , b )
64+ }
65+ return e
66+ } , $get : [ "$injector" , function ( a ) {
67+ function g ( b , c , d , f ) {
68+ return void 0 == e . resourcesFunction ? a . get ( "$resource" ) ( b , c , d , f ) : e . resourcesFunction ( b , c , d , f )
69+ }
6770
68- var i = function k ( a , i , j ) {
69- function l ( a , b ) {
70- var f = d ( a [ e . linksKey ] [ b ] [ e . linksHrefKey ] , b , e . linksHrefKey ) ;
71- return c ( f , a [ e . linksKey ] [ b ] . templated )
71+ function h ( b , c , d , f , g ) {
72+ void 0 == e . fetchFunction ? a . get ( "$http" ) . get ( b ) . success ( function ( a ) {
73+ d [ c ] = g ? i ( a , f , ! 0 ) : a
74+ } ) . error ( function ( a , c ) {
75+ throw new Error ( "There was an error (" + c + ") retrieving the data from '" + b + "'" )
76+ } ) : e . fetchFunction ( b , c , d , f , g )
7277 }
7378
74- var m = function ( b , c , d , h ) {
75- var i = this [ e . linksKey ] , j = c ;
76- if ( angular . isObject ( b ) ) {
77- if ( ! b . name ) throw new Error ( "The provided resource object must contain a name property." ) ;
78- var k = b . parameters ;
79- return c && angular . isObject ( c ) ? j = k && angular . isObject ( k ) ? angular . extend ( angular . copy ( c ) , angular . copy ( k ) ) : angular . copy ( c ) : k && angular . isObject ( k ) && ( j = angular . copy ( k ) ) , g ( l ( a , b . name ) , j , d , h )
79+ var i = function k ( a , i , j ) {
80+ function l ( a , b ) {
81+ var f = d ( a [ e . linksKey ] [ b ] [ e . linksHrefKey ] , b , e . linksHrefKey ) ;
82+ return c ( f , a [ e . linksKey ] [ b ] . templated )
83+ }
84+
85+ var m = function ( b , c , d , h ) {
86+ var i = this [ e . linksKey ] , j = c ;
87+ if ( angular . isObject ( b ) ) {
88+ if ( ! b . name ) throw new Error ( "The provided resource object must contain a name property." ) ;
89+ var k = b . parameters ;
90+ return c && angular . isObject ( c ) ? j = k && angular . isObject ( k ) ? angular . extend ( angular . copy ( c ) , angular . copy ( k ) ) : angular . copy ( c ) : k && angular . isObject ( k ) && ( j = angular . copy ( k ) ) , angular . forEach ( j , function ( a , b ) {
91+ "" === a && delete j [ b ]
92+ } ) , g ( l ( a , b . name ) , j , d , h )
93+ }
94+ if ( b in i ) return g ( l ( a , b ) , j , d , h ) ;
95+ var m = [ ] ;
96+ return angular . forEach ( i , function ( a , b ) {
97+ if ( a . templated ) {
98+ var c = f ( a [ e . linksHrefKey ] ) ;
99+ m . push ( { name : b , parameters : c } )
100+ } else m . push ( { name : b } )
101+ } ) , m
102+ } ;
103+ if ( ! angular . isObject ( a ) || a instanceof Array ) throw new Error ( "Given data '" + a + "' is not of type object." ) ;
104+ if ( void 0 != i && ! ( i instanceof Array || "string" == typeof i ) ) throw new Error ( "Given fetch links '" + i + "' is not of type array or string." ) ;
105+ var n = void 0 ;
106+ if ( e . linksKey in a ) {
107+ var o = { } ;
108+ o [ e . resourcesKey ] = m , n = angular . extend ( angular . copy ( a ) , o ) , void 0 != i && ( n || ( n = angular . copy ( a ) ) , angular . forEach ( a [ e . linksKey ] , function ( b , c ) {
109+ c != e . linksSelfLinkName && ( i == e . fetchAllKey || "string" == typeof i && c == i || i instanceof Array && i . indexOf ( c ) >= 0 ) && h ( l ( a , c ) , c , n , i , j )
110+ } ) )
80111 }
81- if ( b in i ) return g ( l ( a , b ) , j , d , h ) ;
82- var m = [ ] ;
83- return angular . forEach ( i , function ( a , b ) {
84- if ( a . templated ) {
85- var c = f ( a [ e . linksHrefKey ] ) ;
86- m . push ( { name : b , parameters : c } )
87- } else m . push ( { name : b } )
88- } ) , m
112+ return e . embeddedKey in a && ( n || ( n = angular . copy ( a ) ) , n = b ( n , e . embeddedKey , e . embeddedNewKey ) , angular . forEach ( n [ e . embeddedNewKey ] , function ( a , b ) {
113+ n [ e . embeddedNewKey ] [ b ] = k ( a , i , j )
114+ } ) ) , n ? n : a
115+ } , j = function ( b , c , d ) {
116+ var e = a . get ( "$q" ) . when ( b ) , f = a . get ( "$q" ) . defer ( ) ;
117+ return e . then ( function ( a ) {
118+ var b = i ( a . data , c , d ) ;
119+ f . resolve ( b )
120+ } , function ( b ) {
121+ return f . reject ( b ) , a . get ( "$q" ) . reject ( b )
122+ } ) , f . promise
89123 } ;
90- if ( ! angular . isObject ( a ) || a instanceof Array ) throw new Error ( "Given data '" + a + "' is not of type object." ) ;
91- if ( void 0 != i && ! ( i instanceof Array || "string" == typeof i ) ) throw new Error ( "Given fetch links '" + i + "' is not of type array or string." ) ;
92- var n = void 0 ;
93- if ( e . linksKey in a ) {
94- var o = { } ;
95- o [ e . resourcesKey ] = m , n = angular . extend ( angular . copy ( a ) , o ) , void 0 != i && ( n || ( n = angular . copy ( a ) ) , angular . forEach ( a [ e . linksKey ] , function ( b , c ) {
96- c != e . linksSelfLinkName && ( i == e . fetchAllKey || "string" == typeof i && c == i || i instanceof Array && i . indexOf ( c ) >= 0 ) && h ( l ( a , c ) , c , n , i , j )
97- } ) )
98- }
99- return e . embeddedKey in a && ( n || ( n = angular . copy ( a ) ) , n = b ( n , e . embeddedKey , e . embeddedNewKey ) , angular . forEach ( n [ e . embeddedNewKey ] , function ( a , b ) {
100- n [ e . embeddedNewKey ] [ b ] = k ( a , i , j )
101- } ) ) , n ? n : a
102- } , j = function ( b , c , d ) {
103- var e = a . get ( "$q" ) . when ( b ) , f = a . get ( "$q" ) . defer ( ) ;
104- return e . then ( function ( a ) {
105- var b = i ( a . data , c , d ) ;
106- f . resolve ( b )
107- } , function ( b ) {
108- return f . reject ( b ) , a . get ( "$q" ) . reject ( b )
109- } ) , f . promise
110- } ;
111- return { process : i , processWithPromise : j }
112- } ] }
124+ return { process : i , processWithPromise : j }
125+ } ]
126+ }
113127 } ) , angular . module ( "spring-data-rest" ) . provider ( "SpringDataRestInterceptor" , [ "$httpProvider" , "SpringDataRestAdapterProvider" , function ( a ) {
114- return { apply : function ( ) {
115- a . interceptors . push ( "SpringDataRestInterceptor" )
116- } , $get : [ "SpringDataRestAdapter" , "$q" , function ( a , b ) {
117- return { response : function ( c ) {
118- return c && angular . isObject ( c . data ) && ( c . data = a . process ( c . data ) ) , c || b . when ( c )
119- } }
120- } ] }
128+ return {
129+ apply : function ( ) {
130+ a . interceptors . push ( "SpringDataRestInterceptor" )
131+ } , $get : [ "SpringDataRestAdapter" , "$q" , function ( a , b ) {
132+ return {
133+ response : function ( c ) {
134+ return c && angular . isObject ( c . data ) && ( c . data = a . process ( c . data ) ) , c || b . when ( c )
135+ }
136+ }
137+ } ]
138+ }
121139 } ] )
122140} ( ) ;
0 commit comments