Skip to content

Commit

Permalink
chore(all): prepare release 1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
EisenbergEffect committed Oct 1, 2017
1 parent f4b0b5d commit 17cc4d7
Show file tree
Hide file tree
Showing 12 changed files with 90 additions and 66 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aurelia-http-client",
"version": "1.1.1",
"version": "1.2.0",
"description": "A simple, restful, message-based wrapper around XMLHttpRequest.",
"keywords": [
"aurelia",
Expand Down
23 changes: 11 additions & 12 deletions dist/amd/aurelia-http-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ define(['exports', 'aurelia-path', 'aurelia-pal'], function (exports, _aureliaPa

var Headers = exports.Headers = function () {
function Headers() {
var headers = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var headers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};



Expand Down Expand Up @@ -138,7 +138,7 @@ define(['exports', 'aurelia-path', 'aurelia-pal'], function (exports, _aureliaPa
var url = absoluteUrl.test(this.url) ? this.url : (0, _aureliaPath.join)(this.baseUrl, this.url);

if (this.params) {
var qs = (0, _aureliaPath.buildQueryString)(this.params);
var qs = (0, _aureliaPath.buildQueryString)(this.params, this.traditional);
url = qs ? url + (this.url.indexOf('?') < 0 ? '?' : '&') + qs : url;
}

Expand Down Expand Up @@ -616,8 +616,9 @@ define(['exports', 'aurelia-path', 'aurelia-pal'], function (exports, _aureliaPa
});
};

RequestBuilder.prototype.withParams = function withParams(params) {
RequestBuilder.prototype.withParams = function withParams(params, traditional) {
return this._addTransformer(function (client, processor, message) {
message.traditional = traditional;
message.params = params;
});
};
Expand Down Expand Up @@ -726,12 +727,10 @@ define(['exports', 'aurelia-path', 'aurelia-pal'], function (exports, _aureliaPa
client.isRequesting = client.pendingRequests.length > 0;

if (!client.isRequesting) {
(function () {
var evt = _aureliaPal.DOM.createCustomEvent('aurelia-http-client-requests-drained', { bubbles: true, cancelable: true });
setTimeout(function () {
return _aureliaPal.DOM.dispatchEvent(evt);
}, 1);
})();
var evt = _aureliaPal.DOM.createCustomEvent('aurelia-http-client-requests-drained', { bubbles: true, cancelable: true });
setTimeout(function () {
return _aureliaPal.DOM.dispatchEvent(evt);
}, 1);
}
}

Expand Down Expand Up @@ -808,16 +807,16 @@ define(['exports', 'aurelia-path', 'aurelia-pal'], function (exports, _aureliaPa
return this.createRequest(url).asDelete().send();
};

HttpClient.prototype.get = function get(url) {
return this.createRequest(url).asGet().send();
HttpClient.prototype.get = function get(url, params, traditional) {
return this.createRequest(url).asGet().withParams(params, traditional).send();
};

HttpClient.prototype.head = function head(url) {
return this.createRequest(url).asHead().send();
};

HttpClient.prototype.jsonp = function jsonp(url) {
var callbackParameterName = arguments.length <= 1 || arguments[1] === undefined ? 'jsoncallback' : arguments[1];
var callbackParameterName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'jsoncallback';

return this.createRequest(url).asJsonp(callbackParameterName).send();
};
Expand Down
16 changes: 12 additions & 4 deletions dist/aurelia-http-client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export declare interface XHRConstructor {

}

//new():XHR;
/**
* Represents an XHR.
*/
Expand Down Expand Up @@ -201,6 +200,11 @@ export declare class RequestMessage {
*/
headers: Headers;

/**
* Use tradional style for param serialization.
*/
traditional: boolean;

/**
* The base url that the request url is joined with.
*/
Expand Down Expand Up @@ -433,7 +437,6 @@ export declare class HttpRequestMessage extends RequestMessage {
constructor(method: string, url: string, content: any, headers?: Headers);
}

//text, arraybuffer, blob, document
/**
* Creates a RequestMessageProcessor for handling HTTP request messages.
* @return A processor instance for HTTP request messages.
Expand All @@ -448,6 +451,11 @@ export declare function createHttpRequestMessageProcessor(): RequestMessageProce
*/
export declare class RequestBuilder {

/**
* The HttpClient instance.
*/
client: HttpClient;

/**
* Creates an instance of RequestBuilder
* @param client An instance of HttpClient
Expand Down Expand Up @@ -529,7 +537,7 @@ export declare class RequestBuilder {
* @param params The key/value pairs to use to build the query string.
* @return The chainable RequestBuilder to use in further configuration of the request.
*/
withParams(params: Object): RequestBuilder;
withParams(params: Object, traditional?: boolean): RequestBuilder;

/**
* Sets the response type.
Expand Down Expand Up @@ -677,7 +685,7 @@ export declare class HttpClient {
* @param url The target URL.
* @return {Promise} A cancellable promise object.
*/
get(url: string): Promise<HttpResponseMessage>;
get(url: string, params?: Object, traditional?: boolean): Promise<HttpResponseMessage>;

/**
* Sends an HTTP HEAD request.
Expand Down
22 changes: 17 additions & 5 deletions dist/aurelia-http-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ export class RequestMessage {
*/
headers: Headers;

/**
* Use tradional style for param serialization.
*/
traditional: boolean;

/**
* The base url that the request url is joined with.
*/
Expand Down Expand Up @@ -148,7 +153,7 @@ export class RequestMessage {
let url = absoluteUrl.test(this.url) ? this.url : join(this.baseUrl, this.url);

if (this.params) {
let qs = buildQueryString(this.params);
let qs = buildQueryString(this.params, this.traditional);
url = qs ? url + (this.url.indexOf('?') < 0 ? '?' : '&') + qs : url;
}

Expand Down Expand Up @@ -801,6 +806,12 @@ interface RequestTransformer {
* A builder class allowing fluent composition of HTTP requests.
*/
export class RequestBuilder {

/**
* The HttpClient instance.
*/
client: HttpClient;

/**
* Creates an instance of RequestBuilder
* @param client An instance of HttpClient
Expand Down Expand Up @@ -931,8 +942,9 @@ export class RequestBuilder {
* @param params The key/value pairs to use to build the query string.
* @return The chainable RequestBuilder to use in further configuration of the request.
*/
withParams(params: Object): RequestBuilder {
withParams(params: Object, traditional ?: boolean): RequestBuilder {
return this._addTransformer(function(client, processor, message) {
message.traditional = traditional;
message.params = params;
});
}
Expand Down Expand Up @@ -1171,7 +1183,7 @@ export class HttpClient {
*/
send(requestMessage: RequestMessage, transformers: Array<RequestTransformer>): Promise<HttpResponseMessage> {
let createProcessor = this.requestProcessorFactories.get(requestMessage.constructor);
let processor;
let processor: RequestMessageProcessor;
let promise;
let i;
let ii;
Expand Down Expand Up @@ -1222,8 +1234,8 @@ export class HttpClient {
* @param url The target URL.
* @return {Promise} A cancellable promise object.
*/
get(url: string): Promise<HttpResponseMessage> {
return this.createRequest(url).asGet().send();
get(url: string, params?: Object, traditional?: boolean): Promise<HttpResponseMessage> {
return this.createRequest(url).asGet().withParams(params, traditional).send();
}

/**
Expand Down
23 changes: 11 additions & 12 deletions dist/commonjs/aurelia-http-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"

var Headers = exports.Headers = function () {
function Headers() {
var headers = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var headers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};



Expand Down Expand Up @@ -106,7 +106,7 @@ var RequestMessage = exports.RequestMessage = function () {
var url = absoluteUrl.test(this.url) ? this.url : (0, _aureliaPath.join)(this.baseUrl, this.url);

if (this.params) {
var qs = (0, _aureliaPath.buildQueryString)(this.params);
var qs = (0, _aureliaPath.buildQueryString)(this.params, this.traditional);
url = qs ? url + (this.url.indexOf('?') < 0 ? '?' : '&') + qs : url;
}

Expand Down Expand Up @@ -584,8 +584,9 @@ var RequestBuilder = exports.RequestBuilder = function () {
});
};

RequestBuilder.prototype.withParams = function withParams(params) {
RequestBuilder.prototype.withParams = function withParams(params, traditional) {
return this._addTransformer(function (client, processor, message) {
message.traditional = traditional;
message.params = params;
});
};
Expand Down Expand Up @@ -694,12 +695,10 @@ function trackRequestEnd(client, processor) {
client.isRequesting = client.pendingRequests.length > 0;

if (!client.isRequesting) {
(function () {
var evt = _aureliaPal.DOM.createCustomEvent('aurelia-http-client-requests-drained', { bubbles: true, cancelable: true });
setTimeout(function () {
return _aureliaPal.DOM.dispatchEvent(evt);
}, 1);
})();
var evt = _aureliaPal.DOM.createCustomEvent('aurelia-http-client-requests-drained', { bubbles: true, cancelable: true });
setTimeout(function () {
return _aureliaPal.DOM.dispatchEvent(evt);
}, 1);
}
}

Expand Down Expand Up @@ -776,16 +775,16 @@ var HttpClient = exports.HttpClient = function () {
return this.createRequest(url).asDelete().send();
};

HttpClient.prototype.get = function get(url) {
return this.createRequest(url).asGet().send();
HttpClient.prototype.get = function get(url, params, traditional) {
return this.createRequest(url).asGet().withParams(params, traditional).send();
};

HttpClient.prototype.head = function head(url) {
return this.createRequest(url).asHead().send();
};

HttpClient.prototype.jsonp = function jsonp(url) {
var callbackParameterName = arguments.length <= 1 || arguments[1] === undefined ? 'jsoncallback' : arguments[1];
var callbackParameterName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'jsoncallback';

return this.createRequest(url).asJsonp(callbackParameterName).send();
};
Expand Down
11 changes: 6 additions & 5 deletions dist/es2015/aurelia-http-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export let RequestMessage = class RequestMessage {
let url = absoluteUrl.test(this.url) ? this.url : join(this.baseUrl, this.url);

if (this.params) {
let qs = buildQueryString(this.params);
let qs = buildQueryString(this.params, this.traditional);
url = qs ? url + (this.url.indexOf('?') < 0 ? '?' : '&') + qs : url;
}

Expand Down Expand Up @@ -507,8 +507,9 @@ export let RequestBuilder = class RequestBuilder {
});
}

withParams(params) {
withParams(params, traditional) {
return this._addTransformer(function (client, processor, message) {
message.traditional = traditional;
message.params = params;
});
}
Expand Down Expand Up @@ -656,7 +657,7 @@ export let HttpClient = class HttpClient {
let ii;

if (!createProcessor) {
throw new Error(`No request message processor factory for ${ requestMessage.constructor }.`);
throw new Error(`No request message processor factory for ${requestMessage.constructor}.`);
}

processor = createProcessor();
Expand Down Expand Up @@ -689,8 +690,8 @@ export let HttpClient = class HttpClient {
return this.createRequest(url).asDelete().send();
}

get(url) {
return this.createRequest(url).asGet().send();
get(url, params, traditional) {
return this.createRequest(url).asGet().withParams(params, traditional).send();
}

head(url) {
Expand Down
23 changes: 11 additions & 12 deletions dist/native-modules/aurelia-http-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { PLATFORM, DOM } from 'aurelia-pal';

export var Headers = function () {
function Headers() {
var headers = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var headers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};



Expand Down Expand Up @@ -87,7 +87,7 @@ export var RequestMessage = function () {
var url = absoluteUrl.test(this.url) ? this.url : join(this.baseUrl, this.url);

if (this.params) {
var qs = buildQueryString(this.params);
var qs = buildQueryString(this.params, this.traditional);
url = qs ? url + (this.url.indexOf('?') < 0 ? '?' : '&') + qs : url;
}

Expand Down Expand Up @@ -565,8 +565,9 @@ export var RequestBuilder = function () {
});
};

RequestBuilder.prototype.withParams = function withParams(params) {
RequestBuilder.prototype.withParams = function withParams(params, traditional) {
return this._addTransformer(function (client, processor, message) {
message.traditional = traditional;
message.params = params;
});
};
Expand Down Expand Up @@ -675,12 +676,10 @@ function trackRequestEnd(client, processor) {
client.isRequesting = client.pendingRequests.length > 0;

if (!client.isRequesting) {
(function () {
var evt = DOM.createCustomEvent('aurelia-http-client-requests-drained', { bubbles: true, cancelable: true });
setTimeout(function () {
return DOM.dispatchEvent(evt);
}, 1);
})();
var evt = DOM.createCustomEvent('aurelia-http-client-requests-drained', { bubbles: true, cancelable: true });
setTimeout(function () {
return DOM.dispatchEvent(evt);
}, 1);
}
}

Expand Down Expand Up @@ -757,16 +756,16 @@ export var HttpClient = function () {
return this.createRequest(url).asDelete().send();
};

HttpClient.prototype.get = function get(url) {
return this.createRequest(url).asGet().send();
HttpClient.prototype.get = function get(url, params, traditional) {
return this.createRequest(url).asGet().withParams(params, traditional).send();
};

HttpClient.prototype.head = function head(url) {
return this.createRequest(url).asHead().send();
};

HttpClient.prototype.jsonp = function jsonp(url) {
var callbackParameterName = arguments.length <= 1 || arguments[1] === undefined ? 'jsoncallback' : arguments[1];
var callbackParameterName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'jsoncallback';

return this.createRequest(url).asJsonp(callbackParameterName).send();
};
Expand Down
Loading

0 comments on commit 17cc4d7

Please sign in to comment.