diff --git a/sanitizer/_deprecate_quattroshapes.js b/sanitizer/_deprecate_quattroshapes.js deleted file mode 100644 index 1db2fef1..00000000 --- a/sanitizer/_deprecate_quattroshapes.js +++ /dev/null @@ -1,43 +0,0 @@ -var _ = require('lodash'); - -/** - In the process of phasing out the 'quattroshapes' source in favour of 'whosonfirst' - we will emit a warning to users so they can begin upgrading their clients. - - In the interim we will automatically rewrite all requests for quattroshapes to whosonfirst. - - @todo: this is only temporary - @see: https://github.com/pelias/api/issues/442 -**/ - -function _sanitize( raw, clean, opts ) { - // error & warning messages - var messages = { errors: [], warnings: [] }; - - // only applicably when 'sources' param is privided - if( raw.hasOwnProperty('sources') ){ - - var sources = raw.sources.split(','); - if (_.includes(sources, 'quattroshapes') || _.includes(sources, 'qs')) { - - // emit a warning message so users can transition. - messages.warnings.push('You are using Quattroshapes as a data source in this query. ' + - 'Quattroshapes has been disabled as a data source for Mapzen Search, and has been' + - 'replaced by Who\'s on First, an actively maintained data project based on Quattroshapes' + - 'Your existing queries WILL CONTINUE TO WORK for the foreseeable future, but results will ' + - 'be coming from Who\'s on First and `sources=quattroshapes` will be interpreted as ' + - '`sources=whosonfirst`. If you have any questions, please email pelias.team@gmail.com.'); - - // user requested 'quattroshapes', we will give them 'whosonfirst' instead. - sources = _.without(sources, 'quattroshapes', 'qs'); - sources.push('whosonfirst'); - raw.sources = sources.join(','); - } - } - - return messages; -} - -module.exports = () => ({ - sanitize: _sanitize -}); diff --git a/sanitizer/nearby.js b/sanitizer/nearby.js index 1cd3b276..087492de 100644 --- a/sanitizer/nearby.js +++ b/sanitizer/nearby.js @@ -5,7 +5,6 @@ var type_mapping = require('../helper/type_mapping'); var sanitizers = { singleScalarParameters: require('../sanitizer/_single_scalar_parameters')(), debug: require('../sanitizer/_debug')(), - quattroshapes_deprecation: require('../sanitizer/_deprecate_quattroshapes')(), layers: require('../sanitizer/_targets')('layers', type_mapping.layer_mapping), sources: require('../sanitizer/_targets')('sources', type_mapping.source_mapping), // depends on the layers and sources sanitizers, must be run after them diff --git a/sanitizer/reverse.js b/sanitizer/reverse.js index ce14e862..c3bb89dc 100644 --- a/sanitizer/reverse.js +++ b/sanitizer/reverse.js @@ -3,7 +3,6 @@ var sanitizeAll = require('../sanitizer/sanitizeAll'), sanitizers = { singleScalarParameters: require('../sanitizer/_single_scalar_parameters')(), debug: require('../sanitizer/_debug')(), - quattroshapes_deprecation: require('../sanitizer/_deprecate_quattroshapes')(), layers: require('../sanitizer/_targets')('layers', type_mapping.layer_mapping), sources: require('../sanitizer/_targets')('sources', type_mapping.source_mapping), // depends on the layers and sources sanitizers, must be run after them diff --git a/sanitizer/search.js b/sanitizer/search.js index 008ae693..4b74bd2d 100644 --- a/sanitizer/search.js +++ b/sanitizer/search.js @@ -5,7 +5,6 @@ module.exports.middleware = (_api_pelias_config) => { var sanitizers = { singleScalarParameters: require('../sanitizer/_single_scalar_parameters')(), debug: require('../sanitizer/_debug')(), - quattroshapes_deprecation: require('../sanitizer/_deprecate_quattroshapes')(), text: require('../sanitizer/_text')(), size: require('../sanitizer/_size')(/* use defaults*/), layers: require('../sanitizer/_targets')('layers', type_mapping.layer_mapping), diff --git a/sanitizer/structured_geocoding.js b/sanitizer/structured_geocoding.js index 670a26aa..047bb8ff 100644 --- a/sanitizer/structured_geocoding.js +++ b/sanitizer/structured_geocoding.js @@ -6,7 +6,6 @@ module.exports.middleware = (_api_pelias_config) => { var sanitizers = { singleScalarParameters: require('../sanitizer/_single_scalar_parameters')(), debug: require('../sanitizer/_debug')(), - quattroshapes_deprecation: require('../sanitizer/_deprecate_quattroshapes')(), synthesize_analysis: require('../sanitizer/_synthesize_analysis')(), iso2_to_iso3: require('../sanitizer/_iso2_to_iso3')(), city_name_standardizer: require('../sanitizer/_city_name_standardizer')(), diff --git a/test/ciao/reverse/sources_deprecation_warning.coffee b/test/ciao/reverse/sources_deprecation_warning.coffee deleted file mode 100644 index 51445800..00000000 --- a/test/ciao/reverse/sources_deprecation_warning.coffee +++ /dev/null @@ -1,34 +0,0 @@ - -#> quattroshapes is being phased out and so should emit a warning message -path: '/v1/reverse?point.lat=1&point.lon=2&sources=qs' - -#? 200 ok -response.statusCode.should.be.equal 200 -response.should.have.header 'charset', 'utf8' -response.should.have.header 'content-type', 'application/json; charset=utf-8' - -#? valid geocoding block -should.exist json.geocoding -should.exist json.geocoding.version -should.exist json.geocoding.attribution -should.exist json.geocoding.query -should.exist json.geocoding.engine -should.exist json.geocoding.engine.name -should.exist json.geocoding.engine.author -should.exist json.geocoding.engine.version -should.exist json.geocoding.timestamp - -#? valid geojson -json.type.should.be.equal 'FeatureCollection' -json.features.should.be.instanceof Array - -#? expected errors -should.not.exist json.geocoding.errors - -#? expected warnings -should.exist json.geocoding.warnings -json.geocoding.warnings.should.eql ['You are using Quattroshapes as a data source in this query. Quattroshapes has been disabled as a data source for Mapzen Search, and has beenreplaced by Who\'s on First, an actively maintained data project based on QuattroshapesYour existing queries WILL CONTINUE TO WORK for the foreseeable future, but results will be coming from Who\'s on First and `sources=quattroshapes` will be interpreted as `sources=whosonfirst`. If you have any questions, please email pelias.team@gmail.com.' ] - -#? inputs -json.geocoding.query['size'].should.eql 10 -json.geocoding.query.sources.should.eql ['whosonfirst'] # should use 'whosonfirst' instead of 'quattroshapes' diff --git a/test/ciao/search/sources_deprecation_warning.coffee b/test/ciao/search/sources_deprecation_warning.coffee deleted file mode 100644 index fe82d298..00000000 --- a/test/ciao/search/sources_deprecation_warning.coffee +++ /dev/null @@ -1,35 +0,0 @@ - -#> quattroshapes is being phased out and so should emit a warning message -path: '/v1/search?sources=qs&text=a' - -#? 200 ok -response.statusCode.should.be.equal 200 -response.should.have.header 'charset', 'utf8' -response.should.have.header 'content-type', 'application/json; charset=utf-8' - -#? valid geocoding block -should.exist json.geocoding -should.exist json.geocoding.version -should.exist json.geocoding.attribution -should.exist json.geocoding.query -should.exist json.geocoding.engine -should.exist json.geocoding.engine.name -should.exist json.geocoding.engine.author -should.exist json.geocoding.engine.version -should.exist json.geocoding.timestamp - -#? valid geojson -json.type.should.be.equal 'FeatureCollection' -json.features.should.be.instanceof Array - -#? expected errors -should.not.exist json.geocoding.errors - -#? expected warnings -should.exist json.geocoding.warnings -json.geocoding.warnings.should.eql ['You are using Quattroshapes as a data source in this query. Quattroshapes has been disabled as a data source for Mapzen Search, and has beenreplaced by Who\'s on First, an actively maintained data project based on QuattroshapesYour existing queries WILL CONTINUE TO WORK for the foreseeable future, but results will be coming from Who\'s on First and `sources=quattroshapes` will be interpreted as `sources=whosonfirst`. If you have any questions, please email pelias.team@gmail.com.' ] - -#? inputs -json.geocoding.query['size'].should.eql 10 -json.geocoding.query['text'].should.eql 'a' -json.geocoding.query.sources.should.eql ['whosonfirst'] # should use 'whosonfirst' instead of 'quattroshapes' diff --git a/test/unit/run.js b/test/unit/run.js index ae93bd4f..f196dc53 100644 --- a/test/unit/run.js +++ b/test/unit/run.js @@ -92,7 +92,6 @@ var tests = [ require('./sanitizer/_text'), require('./sanitizer/_text_addressit'), require('./sanitizer/_tokenizer'), - require('./sanitizer/_deprecate_quattroshapes'), require('./sanitizer/_categories'), require('./sanitizer/nearby'), require('./sanitizer/autocomplete'), diff --git a/test/unit/sanitizer/_deprecate_quattroshapes.js b/test/unit/sanitizer/_deprecate_quattroshapes.js deleted file mode 100644 index 6cbe1f09..00000000 --- a/test/unit/sanitizer/_deprecate_quattroshapes.js +++ /dev/null @@ -1,65 +0,0 @@ -var sanitizer = require('../../../sanitizer/_deprecate_quattroshapes')(); - -module.exports.tests = {}; - -module.exports.tests.warning_message_1 = function(test, common) { - test('[qs] should emit a deprecation warning', function(t) { - var raw = { sources: 'qs' }; - var clean = {}; - - var messages = sanitizer.sanitize(raw, clean); - t.deepEquals(messages, { - errors: [], - warnings: ['You are using Quattroshapes as a data source in this query. ' + - 'Quattroshapes has been disabled as a data source for Mapzen Search, and has been' + - 'replaced by Who\'s on First, an actively maintained data project based on Quattroshapes' + - 'Your existing queries WILL CONTINUE TO WORK for the foreseeable future, but results will ' + - 'be coming from Who\'s on First and `sources=quattroshapes` will be interpreted as ' + - '`sources=whosonfirst`. If you have any questions, please email pelias.team@gmail.com.'] - }, 'warning emitted'); - - t.end(); - }); -}; - -module.exports.tests.warning_message_2 = function(test, common) { - test('[quattroshapes] should emit a deprecation warning', function(t) { - var raw = { sources: 'quattroshapes' }; - var clean = {}; - - var messages = sanitizer.sanitize(raw, clean); - t.deepEquals(messages, { - errors: [], - warnings: ['You are using Quattroshapes as a data source in this query. ' + - 'Quattroshapes has been disabled as a data source for Mapzen Search, and has been' + - 'replaced by Who\'s on First, an actively maintained data project based on Quattroshapes' + - 'Your existing queries WILL CONTINUE TO WORK for the foreseeable future, but results will ' + - 'be coming from Who\'s on First and `sources=quattroshapes` will be interpreted as ' + - '`sources=whosonfirst`. If you have any questions, please email pelias.team@gmail.com.'] - }, 'warning emitted'); - - t.end(); - }); -}; - -module.exports.tests.rewrite = function(test, common) { - test('should rewrite qs and quattroshapes to whosonfirst', function(t) { - var raw = { sources: 'qs,quattroshapes,qs,quattroshapes,osm' }; - var clean = {}; - - sanitizer.sanitize(raw, clean); - t.equals(raw.sources,'osm,whosonfirst','use wof instead of qs'); - - t.end(); - }); -}; - -module.exports.all = function (tape, common) { - function test(name, testFunction) { - return tape('SANITIZE _deprecate_quattroshapes ' + name, testFunction); - } - - for( var testCase in module.exports.tests ){ - module.exports.tests[testCase](test, common); - } -}; diff --git a/test/unit/sanitizer/nearby.js b/test/unit/sanitizer/nearby.js index cff81b71..b4462943 100644 --- a/test/unit/sanitizer/nearby.js +++ b/test/unit/sanitizer/nearby.js @@ -26,14 +26,6 @@ module.exports.tests.sanitize = function(test, common) { } }; }, - '../sanitizer/_deprecate_quattroshapes': function () { - return { - sanitize: () => { - called_sanitizers.push('_deprecate_quattroshapes'); - return { errors: [], warnings: [] }; - } - }; - }, '../sanitizer/_targets': function (type) { if (['layers', 'sources'].indexOf(type) !== -1) { return { @@ -123,7 +115,6 @@ module.exports.tests.sanitize = function(test, common) { const expected_sanitizers = [ '_single_scalar_parameters', '_debug', - '_deprecate_quattroshapes', '_targets/layers', '_targets/sources', '_sources_and_layers', diff --git a/test/unit/sanitizer/reverse.js b/test/unit/sanitizer/reverse.js index c979ec67..22ac08aa 100644 --- a/test/unit/sanitizer/reverse.js +++ b/test/unit/sanitizer/reverse.js @@ -26,14 +26,6 @@ module.exports.tests.sanitize = function(test, common) { } }; }, - '../sanitizer/_deprecate_quattroshapes': function () { - return { - sanitize: () => { - called_sanitizers.push('_deprecate_quattroshapes'); - return { errors: [], warnings: [] }; - } - }; - }, '../sanitizer/_targets': function (type) { if (['layers', 'sources'].indexOf(type) !== -1) { return { @@ -115,7 +107,6 @@ module.exports.tests.sanitize = function(test, common) { const expected_sanitizers = [ '_single_scalar_parameters', '_debug', - '_deprecate_quattroshapes', '_targets/layers', '_targets/sources', '_sources_and_layers', diff --git a/test/unit/sanitizer/search.js b/test/unit/sanitizer/search.js index 9ac585ad..e72a6ccd 100644 --- a/test/unit/sanitizer/search.js +++ b/test/unit/sanitizer/search.js @@ -14,14 +14,6 @@ module.exports.tests.sanitize = (test, common) => { // the object contains a key called {function} sanitize, // which pushes the name of the sanitizer to {array} called_sanitizers const search = proxyquire('../../../sanitizer/search', { - '../sanitizer/_deprecate_quattroshapes': function () { - return { - sanitize: () => { - called_sanitizers.push('_deprecate_quattroshapes'); - return { errors: [], warnings: [] }; - } - }; - }, '../sanitizer/_single_scalar_parameters': function () { return { sanitize: () => { @@ -148,7 +140,6 @@ module.exports.tests.sanitize = (test, common) => { const expected_sanitizers = [ '_single_scalar_parameters', '_debug', - '_deprecate_quattroshapes', '_text', '_size', '_targets/layers', diff --git a/test/unit/sanitizer/structured_geocoding.js b/test/unit/sanitizer/structured_geocoding.js index 963aa21d..bff07b22 100644 --- a/test/unit/sanitizer/structured_geocoding.js +++ b/test/unit/sanitizer/structured_geocoding.js @@ -10,14 +10,6 @@ module.exports.tests.sanitize = function(test, common) { // rather than re-verify the functionality of all the sanitizers, this test just verifies that they // were all called correctly var search = proxyquire('../../../sanitizer/structured_geocoding', { - '../sanitizer/_deprecate_quattroshapes': function () { - return { - sanitize: () => { - called_sanitizers.push('_deprecate_quattroshapes'); - return { errors: [], warnings: [] }; - } - }; - }, '../sanitizer/_single_scalar_parameters': function () { return { sanitize: () => { @@ -151,7 +143,6 @@ module.exports.tests.sanitize = function(test, common) { var expected_sanitizers = [ '_single_scalar_parameters', '_debug', - '_deprecate_quattroshapes', '_synthesize_analysis', '_iso2_to_iso3', '_city_name_standardizer',