From 1f38696b5228d1a5fd9600f9fad8d000c4e51d58 Mon Sep 17 00:00:00 2001 From: jleveugle Date: Wed, 18 Apr 2018 11:15:25 +0200 Subject: [PATCH] Release v1.2.2 --- bower.json | 2 +- dist/ovh-angular-apiv7.min.js | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bower.json b/bower.json index 2eb101f..299edd9 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "ovh-angular-apiv7", - "version": "1.2.1", + "version": "1.2.2", "description": "The ovh-angular-apiv7 module is an angular component designed to configure Apiv7Endpoints with the same interface as a $resource yet allow for extended configuration by providing Apiv7Requests objects that can be modified with chained methods to define the parameters sent to APIv7.", "keywords": [ "angular", diff --git a/dist/ovh-angular-apiv7.min.js b/dist/ovh-angular-apiv7.min.js index 6517295..cc68b66 100644 --- a/dist/ovh-angular-apiv7.min.js +++ b/dist/ovh-angular-apiv7.min.js @@ -1,2 +1,2 @@ -/*! ovh-angular-apiv7 - 2018-04-17 */ +/*! ovh-angular-apiv7 - 2018-04-18 */ angular.module("ovh-angular-apiv7",["ngResource"]),angular.module("ovh-angular-apiv7").service("apiv7AggregationResponseTransformer",function(){"use strict";return{create:function(a,b){var c=a.url,d=a.transformResponse,e=b;return angular.isArray(e)||(e=[b]),function(a,b,f){if(200!==f)return a;var g=c.replace(new RegExp(":("+e.join("|")+")","g"),"([^/]+)").replace(/:[^\/]+/,"[^/]+"),h=new RegExp(g),i=angular.fromJson(a);return i.map(function(a){var c={};if(a.key)c.key=a.key;else{var e=a.path.match(h);e&&e.length>=1&&(c.key=e[1])}return c.path=a.path,a.error&&(c.error=a.error),d?c.value=d(angular.toJson(a.value),b,f):c.value=a.value,c})}}}}),angular.module("ovh-angular-apiv7").constant("APIV7_ENDPOINT_DEFAULT_ACTIONS",{query:{method:"GET",isArray:!0},get:{method:"GET"},save:{method:"POST"},"delete":{method:"DELETE"},remove:{method:"DELETE"}}),angular.module("ovh-angular-apiv7").factory("Apiv7Endpoint",["Apiv7Request","APIV7_ENDPOINT_DEFAULT_ACTIONS",function(a,b){"use strict";function c(a,c,d,e){var f=_.merge({},b,d);this.createRequestBuilders(a,c,f,e)}return c.prototype.createRequestBuilders=function(b,c,d,e){var f=this;_.forOwn(d,function(d,g){var h=d.disabledOperations,i=_.omit(d,"disabledOperations");f[g]=function(d){return new a(b,c,i,e,d,h)}})},c}]),angular.module("ovh-angular-apiv7").constant("APIV7_FILTER_COMPARATOR",{EQUAL:"=",NOT_EQUAL:"<>",GREATER_OR_EQUAL:">=",GREATER_THAN:">",LESS_OR_EQUAL:"<=",LESS_THAN:"<",IN:"in",LIKE:"like"}).constant("APIV7_SORT_ORDER",{ASC:"ASC",DESC:"DESC"}),angular.module("ovh-angular-apiv7").service("apiv7",["Apiv7Endpoint",function(a){"use strict";return function(b,c,d,e){return new a(b,c,d,e)}}]),angular.module("ovh-angular-apiv7").service("apiv7RequestUpgrader",["apiv7AggregationResponseTransformer",function(a){"use strict";function b(a,b){a.limit>0&&(b.$limit=a.limit)}function c(a,b){a.offset>0&&(b.$offset=a.offset)}function d(a,b){angular.isDefined(a.expansion)&&(b.$expand=1)}function e(a,b){angular.isArray(a.filters)&&a.filters.forEach(function(a){var c=[a.field,a.comparator].join(":");b.params[c]=angular.isArray(a.reference)?a.reference.join(","):a.reference})}function f(a,b){a.sort&&(b.$sort=a.sort.field,b.$order=a.sort.order)}function g(a,b,c){a.batch&&(b.$batch=a.batch.separator,delete c.params[a.batch.parameter],c.options.isArray=!0,c.options.url=c.options.url.replace(":"+a.batch.parameter,a.batch.values.join(a.batch.separator)))}function h(b,c,d){if(b.aggregation){var e=b.aggregation;angular.isArray(e)||(e=[e]),c.$aggreg=1,d.options.isArray=!0,d.options.transformResponse=a.create(d.options,e),e.forEach(function(a){d.params[a]=void 0,d.options.url&&(d.options.url=d.options.url.replace(":"+a,"*"))})}}return{buildAction:function(a,i,j){var k={params:angular.copy(a),options:angular.copy(i)},l={};return _.merge(k.options,{headers:{"X-Ovh-ApiVersion":"beta"},serviceType:"apiv7"}),d(j,l),b(j,l),c(j,l),h(j,l,k),g(j,l,k),f(j,l),e(j,k),angular.extend(k.params,l),k}}}]),angular.module("ovh-angular-apiv7").factory("Apiv7Request",["$resource","apiv7RequestUpgrader",function(a,b){"use strict";function c(a,b,c,d,e,f){return this.defaultUrl=a,this.defaultParams=b,this.actionOptions=c,this.options=d,this.v7Options=e||{},this.v7DisabledOperations=f||[],angular.isUndefined(c.url)&&(this.actionOptions.url=this.defaultUrl),this}function d(a,b){_.forEach(a,function(a,c){e(c,b)})}function e(a,b){if(b.indexOf(a)!==-1)throw new Error("This action does not support the APIv7 '"+a+"' operation")}return c.prototype.expand=function(a){var b=this.clone();return b.v7Options.expansion=!angular.isDefined(a)||a,b},c.prototype.sort=function(a,b){var c=this.clone(),d=b||"ASC";return a&&""!==a?(c.v7Options.sort={field:a,order:d.toUpperCase()},c):(c.v7Options.sort=void 0,c)},c.prototype.setFilter=function(a,b,c){var d=this.clone();return a?(d.v7Options.filters=[{field:a,comparator:b,reference:angular.isArray(c)?c.join(","):c}],d):(delete d.v7Options.filters,d)},c.prototype.filter=c.prototype.setFilter,c.prototype.addFilter=function(a,b,c){var d=this.clone();return d.v7Options.filters=d.v7Options.filters||[],d.v7Options.filters.push({field:a,comparator:b,reference:c}),d},c.prototype.batch=function(a,b,c){var d=this.clone();return d.v7Options.batch={parameter:a,values:b,separator:c||","},d},c.prototype.aggregate=function(a){var b=this.clone();return angular.isArray(b.v7Options.aggregation)||(b.v7Options.aggregation=[]),angular.isString(a)&&b.v7Options.aggregation.push(a),b},c.prototype.limit=function(a){var b=this.clone();return b.v7Options.limit=a,b},c.prototype.offset=function(a){var b=this.clone();return b.v7Options.offset=a,b},c.prototype.execute=function(c){d(this.v7Options,this.v7DisabledOperations);var e=angular.extend({},c),f=b.buildAction(e,this.actionOptions,this.v7Options),g=a(this.defaultUrl,this.defaultParams,{doRequest:f.options},this.options);return g.doRequest(f.params)},c.prototype.clone=function(){return angular.copy(this)},c}]); \ No newline at end of file diff --git a/package.json b/package.json index 711e12a..8d44ba2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ovh-angular-apiv7", - "version": "1.2.1", + "version": "1.2.2", "description": "The ovh-angular-apiv7 module is an angular component designed to configure Apiv7Endpoints with the same interface as a $resource yet allow for extended configuration by providing Apiv7Requests objects that can be modified with chained methods to define the parameters sent to APIv7.", "keywords": [ "angular",