Skip to content

Commit bb5d2ce

Browse files
committed
2017-07-20 3.24.1
* feat(headers): add functions to remove and get extra headers (algolia#572) * client.setExtraHeader('X-cool-header','hello there'); * client.getExtraHeader('X-cool-header'); //hello there * client.unsetExtraHeader('X-cool-header'); * client.getExtraHeader('X-cool-header'); //undefined * feat(deprecation): use console.warn to be more visible * refact(rules): Adapt to latest JSON schema for Query Rules
1 parent c013fa5 commit bb5d2ce

13 files changed

+157
-79
lines changed

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
CHANGELOG
2+
2017-07-20 3.24.1
3+
* feat(headers): add functions to remove and get extra headers (#572)
4+
* client.setExtraHeader('X-cool-header','hello there');
5+
* client.getExtraHeader('X-cool-header'); //hello there
6+
* client.unsetExtraHeader('X-cool-header');
7+
* client.getExtraHeader('X-cool-header'); //undefined
8+
* feat(deprecation): use console.warn to be more visible
9+
* refact(rules): Adapt to latest JSON schema for Query Rules
210

311
2017-06-21 3.24.0
412
* feat(rules): Add query rules beta version, you cannot use this for now

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "algoliasearch",
3-
"version": "3.24.0",
3+
"version": "3.24.1",
44
"homepage": "https://github.com/algolia/algoliasearch-client-js",
55
"authors": [
66
"Algolia Team <[email protected]>"

dist/algoliasearch.angular.js

+27-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! algoliasearch 3.24.0 | © 2014, 2015 Algolia SAS | github.com/algolia/algoliasearch-client-js */
1+
/*! algoliasearch 3.24.1 | © 2014, 2015 Algolia SAS | github.com/algolia/algoliasearch-client-js */
22
(function(f){var g;if(typeof window!=='undefined'){g=window}else if(typeof self!=='undefined'){g=self}g.ALGOLIA_MIGRATION_LAYER=f()})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
33

44
module.exports = function load (src, opts, cb) {
@@ -3324,7 +3324,7 @@ function AlgoliaSearchCore(applicationID, apiKey, opts) {
33243324
this.hosts.read = map(this.hosts.read, prepareHost(protocol));
33253325
this.hosts.write = map(this.hosts.write, prepareHost(protocol));
33263326

3327-
this.extraHeaders = [];
3327+
this.extraHeaders = {};
33283328

33293329
// In some situations you might want to warm the cache
33303330
this.cache = opts._cache || {};
@@ -3355,9 +3355,25 @@ AlgoliaSearchCore.prototype.initIndex = function(indexName) {
33553355
* @param value the header field value
33563356
*/
33573357
AlgoliaSearchCore.prototype.setExtraHeader = function(name, value) {
3358-
this.extraHeaders.push({
3359-
name: name.toLowerCase(), value: value
3360-
});
3358+
this.extraHeaders[name.toLowerCase()] = value;
3359+
};
3360+
3361+
/**
3362+
* Get the value of an extra HTTP header
3363+
*
3364+
* @param name the header field name
3365+
*/
3366+
AlgoliaSearchCore.prototype.getExtraHeader = function(name) {
3367+
return this.extraHeaders[name.toLowerCase()];
3368+
};
3369+
3370+
/**
3371+
* Remove an extra field from the HTTP request
3372+
*
3373+
* @param name the header field name
3374+
*/
3375+
AlgoliaSearchCore.prototype.unsetExtraHeader = function(name) {
3376+
delete this.extraHeaders[name.toLowerCase()];
33613377
};
33623378

33633379
/**
@@ -3699,11 +3715,9 @@ AlgoliaSearchCore.prototype._computeRequestHeaders = function(additionalUA, with
36993715
requestHeaders['x-algolia-tagfilters'] = this.securityTags;
37003716
}
37013717

3702-
if (this.extraHeaders) {
3703-
forEach(this.extraHeaders, function addToRequestHeaders(header) {
3704-
requestHeaders[header.name] = header.value;
3705-
});
3706-
}
3718+
forEach(this.extraHeaders, function addToRequestHeaders(value, key) {
3719+
requestHeaders[key] = value;
3720+
});
37073721

37083722
return requestHeaders;
37093723
};
@@ -6256,7 +6270,7 @@ module.exports = function deprecate(fn, message) {
62566270
function deprecated() {
62576271
if (!warned) {
62586272
/* eslint no-console:0 */
6259-
console.log(message);
6273+
console.warn(message);
62606274
warned = true;
62616275
}
62626276

@@ -6273,7 +6287,7 @@ module.exports = function deprecatedMessage(previousUsage, newUsage) {
62736287
.replace('()', '');
62746288

62756289
return 'algoliasearch: `' + previousUsage + '` was replaced by `' + newUsage +
6276-
'`. Please see https://github.com/algolia/algoliasearch-client-js/wiki/Deprecated#' + githubAnchorLink;
6290+
'`. Please see https://github.com/algolia/algoliasearch-client-javascript/wiki/Deprecated#' + githubAnchorLink;
62776291
};
62786292

62796293
},{}],29:[function(require,module,exports){
@@ -6545,6 +6559,6 @@ function cleanup() {
65456559
},{"1":1}],36:[function(require,module,exports){
65466560
'use strict';
65476561

6548-
module.exports = '3.24.0';
6562+
module.exports = '3.24.1';
65496563

65506564
},{}]},{},[19]);

dist/algoliasearch.angular.min.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/algoliasearch.jquery.js

+27-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! algoliasearch 3.24.0 | © 2014, 2015 Algolia SAS | github.com/algolia/algoliasearch-client-js */
1+
/*! algoliasearch 3.24.1 | © 2014, 2015 Algolia SAS | github.com/algolia/algoliasearch-client-js */
22
(function(f){var g;if(typeof window!=='undefined'){g=window}else if(typeof self!=='undefined'){g=self}g.ALGOLIA_MIGRATION_LAYER=f()})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
33

44
module.exports = function load (src, opts, cb) {
@@ -3324,7 +3324,7 @@ function AlgoliaSearchCore(applicationID, apiKey, opts) {
33243324
this.hosts.read = map(this.hosts.read, prepareHost(protocol));
33253325
this.hosts.write = map(this.hosts.write, prepareHost(protocol));
33263326

3327-
this.extraHeaders = [];
3327+
this.extraHeaders = {};
33283328

33293329
// In some situations you might want to warm the cache
33303330
this.cache = opts._cache || {};
@@ -3355,9 +3355,25 @@ AlgoliaSearchCore.prototype.initIndex = function(indexName) {
33553355
* @param value the header field value
33563356
*/
33573357
AlgoliaSearchCore.prototype.setExtraHeader = function(name, value) {
3358-
this.extraHeaders.push({
3359-
name: name.toLowerCase(), value: value
3360-
});
3358+
this.extraHeaders[name.toLowerCase()] = value;
3359+
};
3360+
3361+
/**
3362+
* Get the value of an extra HTTP header
3363+
*
3364+
* @param name the header field name
3365+
*/
3366+
AlgoliaSearchCore.prototype.getExtraHeader = function(name) {
3367+
return this.extraHeaders[name.toLowerCase()];
3368+
};
3369+
3370+
/**
3371+
* Remove an extra field from the HTTP request
3372+
*
3373+
* @param name the header field name
3374+
*/
3375+
AlgoliaSearchCore.prototype.unsetExtraHeader = function(name) {
3376+
delete this.extraHeaders[name.toLowerCase()];
33613377
};
33623378

33633379
/**
@@ -3699,11 +3715,9 @@ AlgoliaSearchCore.prototype._computeRequestHeaders = function(additionalUA, with
36993715
requestHeaders['x-algolia-tagfilters'] = this.securityTags;
37003716
}
37013717

3702-
if (this.extraHeaders) {
3703-
forEach(this.extraHeaders, function addToRequestHeaders(header) {
3704-
requestHeaders[header.name] = header.value;
3705-
});
3706-
}
3718+
forEach(this.extraHeaders, function addToRequestHeaders(value, key) {
3719+
requestHeaders[key] = value;
3720+
});
37073721

37083722
return requestHeaders;
37093723
};
@@ -6202,7 +6216,7 @@ module.exports = function deprecate(fn, message) {
62026216
function deprecated() {
62036217
if (!warned) {
62046218
/* eslint no-console:0 */
6205-
console.log(message);
6219+
console.warn(message);
62066220
warned = true;
62076221
}
62086222

@@ -6219,7 +6233,7 @@ module.exports = function deprecatedMessage(previousUsage, newUsage) {
62196233
.replace('()', '');
62206234

62216235
return 'algoliasearch: `' + previousUsage + '` was replaced by `' + newUsage +
6222-
'`. Please see https://github.com/algolia/algoliasearch-client-js/wiki/Deprecated#' + githubAnchorLink;
6236+
'`. Please see https://github.com/algolia/algoliasearch-client-javascript/wiki/Deprecated#' + githubAnchorLink;
62236237
};
62246238

62256239
},{}],29:[function(require,module,exports){
@@ -6491,6 +6505,6 @@ function cleanup() {
64916505
},{"1":1}],36:[function(require,module,exports){
64926506
'use strict';
64936507

6494-
module.exports = '3.24.0';
6508+
module.exports = '3.24.1';
64956509

64966510
},{}]},{},[19]);

dist/algoliasearch.jquery.min.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/algoliasearch.js

+27-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! algoliasearch 3.24.0 | © 2014, 2015 Algolia SAS | github.com/algolia/algoliasearch-client-js */
1+
/*! algoliasearch 3.24.1 | © 2014, 2015 Algolia SAS | github.com/algolia/algoliasearch-client-js */
22
(function(f){var g;if(typeof window!=='undefined'){g=window}else if(typeof self!=='undefined'){g=self}g.ALGOLIA_MIGRATION_LAYER=f()})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
33

44
module.exports = function load (src, opts, cb) {
@@ -3324,7 +3324,7 @@ function AlgoliaSearchCore(applicationID, apiKey, opts) {
33243324
this.hosts.read = map(this.hosts.read, prepareHost(protocol));
33253325
this.hosts.write = map(this.hosts.write, prepareHost(protocol));
33263326

3327-
this.extraHeaders = [];
3327+
this.extraHeaders = {};
33283328

33293329
// In some situations you might want to warm the cache
33303330
this.cache = opts._cache || {};
@@ -3355,9 +3355,25 @@ AlgoliaSearchCore.prototype.initIndex = function(indexName) {
33553355
* @param value the header field value
33563356
*/
33573357
AlgoliaSearchCore.prototype.setExtraHeader = function(name, value) {
3358-
this.extraHeaders.push({
3359-
name: name.toLowerCase(), value: value
3360-
});
3358+
this.extraHeaders[name.toLowerCase()] = value;
3359+
};
3360+
3361+
/**
3362+
* Get the value of an extra HTTP header
3363+
*
3364+
* @param name the header field name
3365+
*/
3366+
AlgoliaSearchCore.prototype.getExtraHeader = function(name) {
3367+
return this.extraHeaders[name.toLowerCase()];
3368+
};
3369+
3370+
/**
3371+
* Remove an extra field from the HTTP request
3372+
*
3373+
* @param name the header field name
3374+
*/
3375+
AlgoliaSearchCore.prototype.unsetExtraHeader = function(name) {
3376+
delete this.extraHeaders[name.toLowerCase()];
33613377
};
33623378

33633379
/**
@@ -3699,11 +3715,9 @@ AlgoliaSearchCore.prototype._computeRequestHeaders = function(additionalUA, with
36993715
requestHeaders['x-algolia-tagfilters'] = this.securityTags;
37003716
}
37013717

3702-
if (this.extraHeaders) {
3703-
forEach(this.extraHeaders, function addToRequestHeaders(header) {
3704-
requestHeaders[header.name] = header.value;
3705-
});
3706-
}
3718+
forEach(this.extraHeaders, function addToRequestHeaders(value, key) {
3719+
requestHeaders[key] = value;
3720+
});
37073721

37083722
return requestHeaders;
37093723
};
@@ -6048,7 +6062,7 @@ module.exports = function deprecate(fn, message) {
60486062
function deprecated() {
60496063
if (!warned) {
60506064
/* eslint no-console:0 */
6051-
console.log(message);
6065+
console.warn(message);
60526066
warned = true;
60536067
}
60546068

@@ -6065,7 +6079,7 @@ module.exports = function deprecatedMessage(previousUsage, newUsage) {
60656079
.replace('()', '');
60666080

60676081
return 'algoliasearch: `' + previousUsage + '` was replaced by `' + newUsage +
6068-
'`. Please see https://github.com/algolia/algoliasearch-client-js/wiki/Deprecated#' + githubAnchorLink;
6082+
'`. Please see https://github.com/algolia/algoliasearch-client-javascript/wiki/Deprecated#' + githubAnchorLink;
60696083
};
60706084

60716085
},{}],28:[function(require,module,exports){
@@ -6337,7 +6351,7 @@ function cleanup() {
63376351
},{"1":1}],35:[function(require,module,exports){
63386352
'use strict';
63396353

6340-
module.exports = '3.24.0';
6354+
module.exports = '3.24.1';
63416355

63426356
},{}]},{},[19])(19)
63436357
});

dist/algoliasearch.min.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/algoliasearch.parse.js

+26-12
Original file line numberDiff line numberDiff line change
@@ -2527,7 +2527,7 @@ module.exports =
25272527
function deprecated() {
25282528
if (!warned) {
25292529
/* eslint no-console:0 */
2530-
console.log(message);
2530+
console.warn(message);
25312531
warned = true;
25322532
}
25332533

@@ -2548,7 +2548,7 @@ module.exports =
25482548
.replace('()', '');
25492549

25502550
return 'algoliasearch: `' + previousUsage + '` was replaced by `' + newUsage +
2551-
'`. Please see https://github.com/algolia/algoliasearch-client-js/wiki/Deprecated#' + githubAnchorLink;
2551+
'`. Please see https://github.com/algolia/algoliasearch-client-javascript/wiki/Deprecated#' + githubAnchorLink;
25522552
};
25532553

25542554

@@ -2982,7 +2982,7 @@ module.exports =
29822982
this.hosts.read = map(this.hosts.read, prepareHost(protocol));
29832983
this.hosts.write = map(this.hosts.write, prepareHost(protocol));
29842984

2985-
this.extraHeaders = [];
2985+
this.extraHeaders = {};
29862986

29872987
// In some situations you might want to warm the cache
29882988
this.cache = opts._cache || {};
@@ -3013,9 +3013,25 @@ module.exports =
30133013
* @param value the header field value
30143014
*/
30153015
AlgoliaSearchCore.prototype.setExtraHeader = function(name, value) {
3016-
this.extraHeaders.push({
3017-
name: name.toLowerCase(), value: value
3018-
});
3016+
this.extraHeaders[name.toLowerCase()] = value;
3017+
};
3018+
3019+
/**
3020+
* Get the value of an extra HTTP header
3021+
*
3022+
* @param name the header field name
3023+
*/
3024+
AlgoliaSearchCore.prototype.getExtraHeader = function(name) {
3025+
return this.extraHeaders[name.toLowerCase()];
3026+
};
3027+
3028+
/**
3029+
* Remove an extra field from the HTTP request
3030+
*
3031+
* @param name the header field name
3032+
*/
3033+
AlgoliaSearchCore.prototype.unsetExtraHeader = function(name) {
3034+
delete this.extraHeaders[name.toLowerCase()];
30193035
};
30203036

30213037
/**
@@ -3357,11 +3373,9 @@ module.exports =
33573373
requestHeaders['x-algolia-tagfilters'] = this.securityTags;
33583374
}
33593375

3360-
if (this.extraHeaders) {
3361-
forEach(this.extraHeaders, function addToRequestHeaders(header) {
3362-
requestHeaders[header.name] = header.value;
3363-
});
3364-
}
3376+
forEach(this.extraHeaders, function addToRequestHeaders(value, key) {
3377+
requestHeaders[key] = value;
3378+
});
33653379

33663380
return requestHeaders;
33673381
};
@@ -3761,7 +3775,7 @@ module.exports =
37613775

37623776

37633777

3764-
module.exports = '3.24.0';
3778+
module.exports = '3.24.1';
37653779

37663780

37673781
/***/ }

0 commit comments

Comments
 (0)