angular-odata-resources
Version:
Allows making fluent OData queries from angular resources
2 lines • 22.6 kB
JavaScript
/*! ODataResources 2016-10-04 */
angular.module("ODataResources",["ng"]),angular.module("ODataResources").factory("$odataOperators",[function(){var a=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,b=function(b){return b.replace(a,"")},c={eq:["=","==","==="],ne:["!=","!==","<>"],gt:[">"],ge:[">=",">=="],lt:["<"],le:["<=","<=="],and:["&&"],or:["||"],not:["!"],add:["+"],sub:["-"],mul:["*"],div:["/"],mod:["%"]},d=function(a){var d,e=b(a).toLowerCase();for(d in c){if(e===d)return d;for(var f=c[d],g=0;g<f.length;g++)if(e===f[g])return d}throw"Operator "+a+" not found"};return{operators:c,convert:d}}]),angular.module("ODataResources").factory("$odataValue",[function(){var a={"%":"%25","+":"%2B","/":"%2F","?":"%3F","#":"%23","&":"%26"},b=function(b){for(var c in a)b=b.replace(c,a[c]);return b=b.replace(/'/g,"''")},c=function(a,b){this.value=a,this.type=b},d=function(a,b){return b?a.getFullYear()+"-"+("0"+(a.getMonth()+1)).slice(-2)+"-"+("0"+a.getDate()).slice(-2)+"T"+("0"+a.getHours()).slice(-2)+":"+("0"+a.getMinutes()).slice(-2)+":"+("0"+a.getSeconds()).slice(-2)+"Z":"datetime'"+a.getFullYear()+"-"+("0"+(a.getMonth()+1)).slice(-2)+"-"+("0"+a.getDate()).slice(-2)+"T"+("0"+a.getHours()).slice(-2)+":"+("0"+a.getMinutes()).slice(-2)+":"+("0"+a.getSeconds()).slice(-2)+"'"},e=function(a,b){return b?a:"guid'"+a+"'"},f=function(a,b){return b?a.getFullYear()+"-"+("0"+(a.getMonth()+1)).slice(-2)+"-"+("0"+a.getDate()).slice(-2)+"T"+("0"+a.getHours()).slice(-2)+":"+("0"+a.getMinutes()).slice(-2)+":"+("0"+a.getSeconds()).slice(-2)+"Z":"datetimeoffset'"+a.getFullYear()+"-"+("0"+(a.getMonth()+1)).slice(-2)+"-"+("0"+a.getDate()).slice(-2)+"T"+("0"+a.getHours()).slice(-2)+":"+("0"+a.getMinutes()).slice(-2)+":"+("0"+a.getSeconds()).slice(-2)+"'"};return c.prototype.executeWithUndefinedType=function(a){if(angular.isString(this.value))return"'"+b(this.value)+"'";if(this.value===!1)return"false";if(this.value===!0)return"true";if(angular.isDate(this.value))return d(this.value,a);if(isNaN(this.value))throw"Unrecognized type of "+this.value;return this.value},c.prototype.executeWithType=function(a){if(this.value===!0||this.value===!1){if("boolean"===this.type.toLowerCase())return!!this.value+"";if("string"===this.type.toLowerCase())return"'"+!!this.value+"'";throw"Cannot convert bool ("+this.value+") into "+this.type}if(angular.isDate(this.value)){if("decimal"===this.type.toLowerCase())return this.value.getTime()+"M";if("int32"===this.type.toLowerCase())return this.value.getTime()+"";if("single"===this.type.toLowerCase())return this.value.getTime()+"f";if("double"===this.type.toLowerCase())return this.value.getTime()+"d";if("datetime"===this.type.toLowerCase())return d(this.value,a);if("datetimeoffset"===this.type.toLowerCase())return f(new Date(this.value),a);if("string"===this.type.toLowerCase())return"'"+this.value.toISOString()+"'";throw"Cannot convert date ("+this.value+") into "+this.type}if(angular.isString(this.value)){if("guid"===this.type.toLowerCase())return e(this.value,a);if("datetime"===this.type.toLowerCase())return d(new Date(this.value),a);if("datetimeoffset"===this.type.toLowerCase())return f(new Date(this.value),a);if("single"===this.type.toLowerCase())return parseFloat(this.value)+"f";if("double"===this.type.toLowerCase())return parseFloat(this.value)+"d";if("decimal"===this.type.toLowerCase())return parseFloat(this.value)+"M";if("boolean"===this.type.toLowerCase())return this.value;if("int32"===this.type.toLowerCase())return parseInt(this.value)+"";throw"Cannot convert "+this.value+" into "+this.type}if(isNaN(this.value))throw"Source type of "+this.value+" to be conververted into "+this.type+"is not supported";if("boolean"===this.type.toLowerCase())return!!this.value+"";if("decimal"===this.type.toLowerCase())return this.value+"M";if("double"===this.type.toLowerCase())return this.value+"d";if("single"===this.type.toLowerCase())return this.value+"f";if("byte"===this.type.toLowerCase())return(this.value%255).toString(16);if("datetime"===this.type.toLowerCase())return d(new Date(this.value),a);if("string"===this.type.toLowerCase())return"'"+this.value+"'";throw"Cannot convert number ("+this.value+") into "+this.type},c.prototype.execute=function(a){return null===this.value?"null":void 0===this.type?this.executeWithUndefinedType(a):this.executeWithType(a)},c}]),angular.module("ODataResources").factory("$odataProperty",[function(){var a=function(a){this.value=a};return a.prototype.execute=function(){return this.value},a}]),angular.module("ODataResources").factory("$odataBinaryOperation",["$odataOperators","$odataProperty","$odataValue",function(a,b,c){var d=function(d,e,f){if(void 0===d)throw"The property of a filter cannot be undefined";if(void 0===e)throw"The value of a filter cannot be undefined";void 0===f?(angular.isFunction(d.execute)?this.operandA=d:this.operandA=new b(d),null!==e&&angular.isFunction(e.execute)?this.operandB=e:this.operandB=new c(e),this.filterOperator="eq"):(angular.isFunction(d.execute)?this.operandA=d:this.operandA=new b(d),null!==f&&angular.isFunction(f.execute)?this.operandB=f:this.operandB=new c(f),this.filterOperator=a.convert(e))};return d.prototype.execute=function(a,b){var c=this.operandA.execute(a)+" "+this.filterOperator+" "+this.operandB.execute(a);return b||(c="("+c+")"),c},d.prototype.or=function(a,b,c){var e;if(void 0!==b)e=new d(a,b,c);else{if(!angular.isFunction(a.execute))throw"The object "+a+" passed as a parameter of the or method is not valid";e=a}return new d(this,"or",e)},d.prototype.and=function(a,b,c){var e;if(void 0!==b)e=new d(a,b,c);else{if(!angular.isFunction(a.execute))throw"The object "+a+" passed as a parameter of the and method is not valid";e=a}return new d(this,"and",e)},d}]),angular.module("ODataResources").factory("$odataExpandPredicate",["$odataPredicate","$odataBinaryOperation","$odataOrderByStatement",function(a,b,c){var d=function(a,b){if(void 0===a)throw"ExpandPredicate should be passed a table name but got undefined.";if(void 0===b)throw"ExpandPredicate should be passed a context but got undefined.";this.name=a,this.expandables=[],this.options={select:[],filter:[],orderby:[],expand:this.expandables},this.context=b};return d.prototype.filter=function(a,c,d){if(void 0===a)throw"The first parameter is undefined. Did you forget to invoke the method as a constructor by adding the 'new' keyword?";var e;return e=angular.isFunction(a.execute)&&void 0===c?a:new b(a,c,d),this.options.filter.push(e),this},d.prototype.select=function(a){function b(b,c){return c===a[b]}if(void 0===a)throw"ExpandPredicate.select should be passed a property name but got undefined.";angular.isArray(a)||(a=a.split(","));for(var c=0;c<a.length;c++)this.options.select.some(b.bind(this,c))||this.options.select.push(a[c]);return this},d.prototype.orderBy=function(a,b){return this.options.orderby.push(new c(a,b).execute()),this},d.prototype.expand=function(a){if(void 0===a)throw"ExpandPredicate.expand should be passed a table name but got undefined.";return new d(a,this).finish()},d.prototype.expandPredicate=function(a){if(void 0===a)throw"ExpandPredicate.expandPredicate should be passed a table name but got undefined.";return new d(a,this)},d.prototype.build=function(){var b=this.name,c=[];for(var d in this.options)this.options[d].length&&("filter"===d?c.push("$filter="+a.and(this.options.filter).execute(this.isv4,!0)):c.push("$"+d+"="+this.options[d].join(",")));return c.length&&(b+="("+c.join(";")+")"),b},d.prototype.finish=function(){var a=this.build();return this.context.expandables.push(a),this.context},d}]),angular.module("ODataResources").factory("$odataMethodCall",["$odataProperty","$odataValue",function(a,b){var c=function(c){if(void 0===c||""===c)throw"Method name should be defined";if(this.params=[],arguments.length<2)throw"Method should be invoked with arguments";for(var d=1;d<arguments.length;d++){var e=arguments[d];angular.isFunction(e.execute)?this.params.push(e):1==d?this.params.push(new a(e)):this.params.push(new b(e))}this.methodName=c};return c.prototype.execute=function(){var a=["any","all"],b="";if(a.indexOf(this.methodName)>-1)for(var c=0;c<this.params.length;c++)0===c?(b+=this.params[c].execute(),b+="/",b+=this.methodName):1===c?(b+="(",b+=this.params[c].value,b+=":"):(b+=this.params[c].execute(),b+=")");else{b+=this.methodName+"(";for(var d=0;d<this.params.length;d++)d>0&&(b+=","),b+=this.params[d].execute();b+=")"}return b},c}]),angular.module("ODataResources").factory("$odataOrderByStatement",[function(a,b,c){var d=function(a,b){if(void 0===a)throw"Orderby should be passed a property name but got undefined";this.propertyName=a,this.direction=b||"asc"};return d.prototype.execute=function(){return this.propertyName+" "+this.direction},d}]),angular.module("ODataResources").factory("$odataPredicate",["$odataBinaryOperation",function(a){var b=function(b,c,d){return angular.isFunction(b.execute)&&void 0===c?b:new a(b,c,d)};return b.and=function(b){if(b.length>0){for(var c=b[0],d=1;d<b.length;d++)c=new a(c,"and",b[d]);return c}throw"No statements specified"},b.or=function(b){if(b.length>0){for(var c=b[0],d=1;d<b.length;d++)c=new a(c,"or",b[d]);return c}throw"No statements specified for OR predicate"},b.create=function(b,c,d){return angular.isFunction(b.execute)&&void 0===c?b:new a(b,c,d)},b}]),angular.module("ODataResources").factory("$odataProvider",["$odataOperators","$odataBinaryOperation","$odataPredicate","$odataOrderByStatement","$odataExpandPredicate",function(a,b,c,d,e){function f(a,b){var c={};if(b||"count"!==a&&"single"!==a||(b=!0),Object.defineProperty(c,"$$type",{enumerble:!1,writable:!0,configurable:!0,value:a}),b){for(var d in this)!this.hasOwnProperty(d)||"$"===d.charAt(0)&&"$"===d.charAt(1)||(c[d]=this[d]);return c}return this.selectables.length&&(c.selectables=this.selectables),this.expandables.length&&(c.expandables=this.expandables),this.formatBy&&(c.formatBy=this.formatBy),c}var g=function(a,b,c){this.$$callback=a,this.filters=[],this.sortOrders=[],this.takeAmount=void 0,this.skipAmount=void 0,this.expandables=[],this.isv4=b,this.hasInlineCount=!1,this.selectables=[],this.transformUrls=[],this.formatBy=void 0,c&&(this.$$reusables=c)};g.prototype.filter=function(a,c,d){if(void 0===a)throw"The first parameted is undefined. Did you forget to invoke the method as a constructor by adding the 'new' keyword?";var e;return e=angular.isFunction(a.execute)&&void 0===c?a:new b(a,c,d),this.filters.push(e),this},g.prototype.transformUrl=function(a){return this.transformUrls.push(a),this},g.prototype.orderBy=function(a,b){return this.sortOrders.push(new d(a,b)),this},g.prototype.take=function(a){return this.takeAmount=a,this},g.prototype.skip=function(a){return this.skipAmount=a,this},g.prototype.format=function(a){return this.formatBy=a,this},g.prototype.execute=function(){var a,b="";if(this.filters.length>0&&(b="$filter="+c.and(this.filters).execute(this.isv4,!0)),this.sortOrders.length>0)for(""!==b&&(b+="&"),b+="$orderby=",a=0;a<this.sortOrders.length;a++)a>0&&(b+=","),b+=this.sortOrders[a].execute();for(this.takeAmount&&(""!==b&&(b+="&"),b+="$top="+this.takeAmount),this.skipAmount&&(""!==b&&(b+="&"),b+="$skip="+this.skipAmount),this.expandables.length>0&&(""!==b&&(b+="&"),b+="$expand="+this.expandables.join(",")),this.selectables.length>0&&(""!==b&&(b+="&"),b+="$select="+this.selectables.join(",")),this.hasInlineCount>0&&(""!==b&&(b+="&"),b+=this.isv4?"$count=true":"$inlinecount=allpages"),this.formatBy&&(""!==b&&(b+="&"),b+="$format="+this.formatBy),a=0;a<this.transformUrls.length;a++){var d=this.transformUrls[a];b=d(b)}return b},g.prototype.query=function(a,b){if(!angular.isFunction(this.$$callback))throw"Cannot execute query, no callback was specified";return a=a||angular.noop,b=b||angular.noop,this.$$callback(this.execute(),a,b,!1,!1,f.bind(this,"query"))},g.prototype.single=function(a,b){if(!angular.isFunction(this.$$callback))throw"Cannot execute single, no callback was specified";return a=a||angular.noop,b=b||angular.noop,this.$$callback(this.execute(),a,b,!0,!0,f.bind(this,"single"))},g.prototype.get=function(a,b,c){if(!angular.isFunction(this.$$callback))throw"Cannot execute get, no callback was specified";b=b||angular.noop,c=c||angular.noop;var d=this.execute();return d.length>0&&(d="?"+d),this.$$callback("("+a+")"+d,b,c,!0,!1,f.bind(this,"get"))},g.prototype.count=function(a,b){if(!angular.isFunction(this.$$callback))throw"Cannot execute count, no callback was specified";a=a||angular.noop,b=b||angular.noop;var c=this.execute();return c.length>0&&(c="/?"+c),this.$$callback("/$count"+c,a,b,!0,!1,f.bind(this,"count"))},g.prototype.withInlineCount=function(){return this.hasInlineCount=!0,this};var h=function(a){var b=a.shift(),c=b;return a.length>0&&(c=c+"($expand="+h(a)+")"),c};return g.prototype.expand=function(a){if(!angular.isString(a)&&!angular.isArray(a))throw"Invalid parameter passed to expand method ("+a+")";if(""!==a){var b=a;if(this.isv4)angular.isArray(a)||(a=Array.prototype.slice.call(arguments)),b=h(a);else{b=angular.isArray(a)?a.join("/"):Array.prototype.slice.call(arguments).join("/");for(var c=0;c<this.expandables.length;c++)if(this.expandables[c]===b)return this}return this.expandables.push(b),this}},g.prototype.expandPredicate=function(a){return new e(a,this)},g.prototype.select=function(a){if(!angular.isString(a)&&!angular.isArray(a))throw"Invalid parameter passed to select method ("+a+")";if(""!==a){angular.isArray(a)||(a=Array.prototype.slice.call(arguments));for(var b=a.length-1;b>=0;b--)this.selectables.push(a[b]);return this}},g.prototype.re=function(a){if(this.$$reusables)for(var b in this.$$reusables)if(angular.isArray(this.$$reusables[b]))for(var c=0;c<this.$$reusables[b].length;c++)-1===this[b].indexOf(this.$$reusables[b][c])&&this[b].push(this.$$reusables[b][c]);else this[b]=this.$$reusables[b];return this},g}]),function(a,b,c){"use strict";function d(a){return null!==a&&""!==a&&"hasOwnProperty"!==a&&h.test("."+a)}function e(a,b){if(!d(b))throw g("badmember",'Dotted member path "@{0}" is invalid.',b);for(var e=b.split("."),f=0,h=e.length;h>f&&a!==c;f++){var i=e[f];a=null!==a?a[i]:c}return a}function f(a,c){c=c||{},b.forEach(c,function(a,b){delete c[b]});for(var d in a)!a.hasOwnProperty(d)||"$"===d.charAt(0)&&"$"===d.charAt(1)||(c[d]=a[d]);return c}var g=b.$$minErr("$resource"),h=/^(\.[a-zA-Z_$@][0-9a-zA-Z_$@]*)+$/;b.module("ODataResources").provider("$odataresource",function(){var a=this;this.defaults={stripTrailingSlashes:!0,actions:{get:{method:"GET"},save:{method:"POST"},query:{method:"GET",isArray:!0},remove:{method:"DELETE"},"delete":{method:"DELETE"},update:{method:"PUT"},odata:{method:"GET",isArray:!0}}},this.$get=["$http","$q","$odata",function(d,h,i){function j(a){return k(a,!0).replace(/%26/gi,"&").replace(/%3D/gi,"=").replace(/%2B/gi,"+")}function k(a,b){return encodeURIComponent(a).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,b?"%20":"+")}function l(b,c){this.template=b,this.defaults=p({},a.defaults,c),this.urlParams={}}function m(j,k,t,u){function v(a,b){var c={};return b=p({},k,b),o(b,function(b,d){r(b)&&(b=b()),c[d]=b&&b.charAt&&"@"==b.charAt(0)?e(a,b.substr(1)):b}),c}function w(a){return a.resource}function x(a){f(a||{},this)}u=u||{},b.isString(k)&&(u.odatakey=k,k={});var y=new l(j,u);t=p({},a.defaults.actions,t),x.prototype.toJSON=function(){var a=p({},this);return delete a.$promise,delete a.$resolved,a},x.store=function(a){var c=s.filter(function(b){return b.resource===a});return c.length?(Array.prototype.splice.call(arguments,0,1,c[0]),b.extend.apply(b,arguments)):(Array.prototype.splice.call(arguments,0,1,{resource:a}),c=b.extend.apply(b,arguments),s.push(c),c)},x.isResource=function(a){return s.filter(function(b){return b.resource===a}).length},x.store.get=function(a){var b=s.filter(function(b){return b.resource===a});return b.length?b[0]:null},x.store.getHeaders=function(a){var b=x.store.get(a);return b?b.headers:null},x.store.copyHeaders=function(a,b){return x.store(a,{headers:x.store.getHeaders(b)})},x.store.getConfig=function(a){var b=x.store.get(a);return b?b.config:null},x.store.updateConfig=function(a){if(arguments.length<2)return!1;var c=["url","paramDefaults","action","options"],d=arguments.length>2&&b.isString(arguments[1])?Array.prototype.slice.call(arguments,1,5).reduce(function(a,b,d){return a[c[d]]=b,a},{}):arguments[1];return x.isResource(d)&&(d=x.store.getConfig(d)),b.extend(t,d.actions||{}),b.extend(k,d.paramDefaults||{}),b.extend(u,d.options||{}),b.isDefined(d.url)&&b.isString(d.url)&&(j=d.url),y=new l(j,u),x.store(a,{config:{url:j,paramDefaults:k,actions:t,options:u},pendingCorrection:!1}),!0},x.store.pendingCorrection=function(a){var b=x.store.get(a);return b?b.pendingCorrection||!1:!1},x.store.getRefreshingResource=function(a){var b=s.filter(function(b){return b.refreshedAs===a});return b?b[0]:null},o(t,function(a,e){var i=/^(POST|PUT|PATCH)$/i.test(a.method);x[e]=function(l,m,s,z,B,C,D,E,F){function G(c){var d=c.data,h=R.$promise;if(d&&b.isNumber(d["@odata.count"])&&(d.count=d["@odata.count"]),d&&(b.isString(d["@odata.context"])||b.isString(d["odata.metadata"]))&&d.value&&b.isArray(d.value)){var i=d;d=d.value;for(var j in i)"value"!==j&&(R[j]=i[j])}if(d){if(b.isArray(d)!==(!D&&!!a.isArray)&&!E)throw g("badcfg","Error in resource configuration for action `{0}`. Expected response to contain an {1} but got an {2} (Request: {3} {4})",e,!D&&a.isArray?"array":"object",b.isArray(d)?"array":"object",S.method,S.url);if(b.isArray(d)&&E){if(!(d.length>0))throw"The response returned no result";d=d[0]}!D&&a.isArray&&isNaN(parseInt(d))?(R.length=0,o(d,function(a){if("object"==typeof a){var b=new x(a);A(b,F,!1),R.push(b)}else R.push(a)})):(f(d,R),R.$promise=h)}return b.isNumber(d)&&D?R.result=d:!isNaN(parseInt(d))&&D&&(R.result=parseInt(d)),R.$resolved=!0,c.resource=R,x.store(R,{headers:c.headers()}),T(c)||c}function H(a){R.$resolved=!0;var b=x.store.getRefreshingResource(R);return b&&b.preventErrorLooping?(x.store(b.resource,{preventErrorLooping:!1}),h.reject(a)):(x.store(R,{headers:a.headers(),preventErrorLooping:!0}),K((U||n)(a)||a))}function I(a){return(N||n)(a,x.store.getHeaders(R)),a}function J(a){var b=x.store.getRefreshingResource(R);return b&&b.preventErrorLooping?(x.store(b.resource,{preventErrorLooping:!1}),h.reject(a)):(x.store(R,{preventErrorLooping:!0}),K((O||n)(a)||a).then(function(a){return(N||n)(a,x.store.getHeaders(R)),a}))}function K(a){if(b.isDefined(a)&&b.isObject(a)&&b.isObject(a.$correction)){x.store.updateConfig(R,a.$correction);var c=R.$refresh();return x.store(R,{refreshedAs:c}),c.$promise.then(L)}return b.isDefined(a)&&b.isDefined(a.$value)&&a.$correction&&(x.store(R,{pendingCorrection:a.$correction}),a=a.$value),x.isResource(a)?a.$promise.then(L):b.isDefined(a)&&b.isFunction(a.then)?a.then(L):h.reject(a)}function L(a){return x.isResource(a)?(x.store.copyHeaders(R,a),x.store.pendingCorrection(R)&&x.store.updateConfig(R,a),x.store(R,{preventErrorLooping:!1}),f(a,R),R):b.isDefined(a)&&b.isObject(a)&&b.isFunction(a.headers)?h.when(a).then(G):h.when({data:a,headers:function(){return null}}).then(G)}var M,N,O,P={};switch(arguments.length){case 9:case 8:case 7:case 6:case 4:O=z,N=s;case 3:case 2:if(!r(m)){P=l,M=m,N=s;break}if(r(l)){N=l,O=m;break}N=m,O=s;case 1:r(l)?N=l:i?M=l:P=l;break;case 0:break;default:throw g("badargs","Expected up to 4 arguments [params, data, success, error], got {0} arguments",arguments.length)}var Q=this instanceof x,R=Q?M:!D&&a.isArray?[]:new x(M),S={},T=a.interceptor&&a.interceptor.response||w,U=a.interceptor&&a.interceptor.responseError||c;A(R,F),o(a,function(a,b){"params"!=b&&"isArray"!=b&&"interceptor"!=b&&(S[b]=q(a))}),i&&(S.data=M),y.setUrlParams(S,p({},v(M,a.params||{}),P),a.url,M,B),!B||""===C||D&&!E?""!==C&&D&&(S.url+=C):S.url+="?"+C,u.ignoreLoadingBar&&(S.ignoreLoadingBar=!0);var V=d(S).then(G,H).then(I,J);return Q?V:(R.$promise=V,R.$resolved=!1,x.store(R,{config:{url:j,paramDefaults:k,actions:t,options:u}}),R)},x.prototype["$"+e]=function(a,b,c){r(a)&&(c=b,b=a,a={});var d=x[e].call(this,a,this,b,c);return d.$promise||d}});var z=x.odata;x.odata=function(a){var b=function(a,b,c,d,e,f){return z({},{},b,c,!0,a,d,e,f)},c=new i.Provider(b,u.isodatav4,this.$refresh?this.$refresh.$$persistence:null);return u.persistence?c.re():c};var A=function(a,c,d){if(d="boolean"==typeof d?d:!0,b.isDefined(a)&&b.isDefined(c)){var e=B.bind(a);e.$$persistence=b.isFunction(c)?c(d):c,Object.defineProperty(a,"$refresh",{enumerable:!1,configurable:!0,writable:!0,value:e})}},B=function(a,b){var d=function(a,b,c,d,e,f){return z({},{},b,c,!0,a,d,e,f)},e=new i.Provider(d,u.isodatav4,this.$refresh.$$persistence);if(e=e.re(),"count"==this.$refresh.$$persistence.$$type)return e.count();if("single"==this.$refresh.$$persistence.$$type)return e.single();var f=e.execute(),g=this instanceof Array;return x[g?"query":"get"].call(c,{},g?{}:this,a,b,g,(g?"":"?")+f,!g,!1,this.$refresh.$$persistence)};return x.bind=function(a){return m(j,p({},k,a),t)},x}var n=b.noop,o=b.forEach,p=b.extend,q=b.copy,r=b.isFunction,s=[];return l.prototype={setUrlParams:function(a,c,d,e,f){var h,i,k=this,l=d||k.template;if(l===k.template&&("PUT"===a.method||"DELETE"===a.method||"GET"==a.method&&!f||"PATCH"==a.method)&&b.isString(k.defaults.odatakey)){k.defaults.stripTrailingSlashes&&(l=l.replace(/\/+$/,"")||"/");var m=k.defaults.odatakey.split(","),n=m.map(function(a){return m.length>1?a+"=:"+a:":"+a});l=l+"("+n.join(",")+")",e&&o(m,function(a){c[a]=e[a]})}var p=k.urlParams={};o(l.split(/\W/),function(a){if("hasOwnProperty"===a)throw g("badname","hasOwnProperty is not a valid parameter name.");!new RegExp("^\\d+$").test(a)&&a&&new RegExp("(^|[^\\\\]):"+a+"(\\W|$)").test(l)&&(p[a]=!0)}),l=l.replace(/\\:/g,":"),c=c||{},o(k.urlParams,function(a,d){h=c.hasOwnProperty(d)?c[d]:k.defaults[d],b.isDefined(h)&&null!==h?(i=j(h),l=l.replace(new RegExp(":"+d+"(\\W|$)","g"),function(a,b){return i+b})):l=l.replace(new RegExp("(/?):"+d+"(\\W|$)","g"),function(a,b,c){return"/"==c.charAt(0)?c:b+c})}),k.defaults.stripTrailingSlashes&&(l=l.replace(/\/+$/,"")||"/"),l=l.replace(/\/\.(?=\w+($|\?))/,"."),a.url=l.replace(/\/\\\./,"/."),o(c,function(b,c){k.urlParams[c]||(a.params=a.params||{},a.params[c]=b)})}},m}]})}(window,window.angular),angular.module("ODataResources").factory("$odata",["$odataBinaryOperation","$odataProvider","$odataValue","$odataProperty","$odataMethodCall","$odataPredicate","$odataOrderByStatement","$odataExpandPredicate",function(a,b,c,d,e,f,g,h){return{Provider:b,BinaryOperation:a,Value:c,Property:d,Func:e,Predicate:f,OrderBy:g,ExpandPredicate:h}}]);